-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
The mpython code currently imports spm
What I would suggest is transform all of the Runtime's@staticmethod to @classmethod and let downstream package define their own runtime that inherits from the mpython one.
Something like
In mpython:
import abc
class Runtime(abc.ABC):
_instance = None
verbose = True
@classmethod
def instance(cls):
if cls._instance is None:
if cls.verbose:
print("Initializing Matlab Runtime...")
cls._initialize()
return cls._instance
@classmethod
def call(cls, fn, *args, **kwargs):
(args, kwargs) = cls._process_argin(*args, **kwargs)
res = cls.instance().mpython_endpoint(fn, *args, **kwargs)
return cls._process_argout(res)
@classmethod
def _process_argin(cls, *args, **kwargs):
to_runtime = MatlabType._to_runtime
args = tuple(map(to_runtime, args))
kwargs = dict(zip(kwargs.keys(), map(to_runtime, kwargs.values())))
return args, kwargs
@classmethod
def _process_argout(cls, res):
return MatlabType._from_runtime(res)
@classmethod
@abc.abstractmethod
def _initialize(cls):
...And in spm:
import mpython
class Runtime(mpython.Runtime):
@classmethod
def _initialize(cls):
from spm._spm import initialize
cls._instance = initialize()Metadata
Metadata
Assignees
Labels
No labels