Skip to content

Commit 8c3f7f1

Browse files
committed
[Fix] Make imports pointing directly to files
1 parent 7a1893b commit 8c3f7f1

10 files changed

Lines changed: 25 additions & 39 deletions

File tree

spm/__wrapper__/Array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def from_cell(cls, other, **kwargs) -> "Array":
178178
array : Array
179179
Converted array.
180180
"""
181-
from .. import Cell # FIXME: avoid circular import
182-
181+
from .cell import Cell # FIXME: avoid circular import
182+
183183
if not isinstance(other, Cell):
184184
raise TypeError(f"Expected a {Cell} but got a {type(other)}")
185185
order = kwargs.get("order", None)

spm/__wrapper__/Runtime.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
from .utils import _import_matlab
33

44

5-
# ----------------------------------------------------------------------
6-
# Runtime
7-
# ----------------------------------------------------------------------
85
class Runtime:
96
"""Namespace that holds the matlab runtime. All methods are static."""
107

spm/__wrapper__/Struct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def from_any(cls, other, **kwargs) -> "Struct":
271271
@classmethod
272272
def from_cell(cls, other, **kwargs) -> "Struct":
273273
"""See `from_any`."""
274-
from . import Cell
274+
from .cell import Cell
275275
if not isinstance(other, Cell):
276276
raise TypeError(f"Expected a {Cell} but got a {type(other)}.")
277277
return cls.from_any(other, **kwargs)
@@ -352,7 +352,7 @@ def as_dict(self, keys=None) -> dict:
352352
for key in keys:
353353
asdict[key].append(item[key])
354354

355-
from . import Cell
355+
from .cell import Cell
356356
for key in keys:
357357
asdict[key] = Cell.from_any(asdict[key])
358358

spm/__wrapper__/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
from .array import Array
66
from .sparse_array import SparseArray
77
from .runtime import Runtime
8-
from . import utils
9-
from . import core
10-
from . import helpers
11-
128

139
# ----------------------------------------------------------------------
1410
# Questions

spm/__wrapper__/core/base_types.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ def from_any(cls, other, **kwargs):
2020
from .delayed_types import AnyDelayedArray
2121

2222
# FIXME: Circular import
23-
from .. import (
24-
Cell,
25-
Array,
26-
MatlabFunction,
27-
MatlabClass,
28-
Struct,
29-
SparseArray,
30-
)
23+
from ..cell import Cell
24+
from ..array import Array
25+
from ..matlab_function import MatlabFunction
26+
from ..matlab_class import MatlabClass
27+
from ..struct import Struct
28+
from ..sparse_array import SparseArray
3129

3230
# Conversion rules:
3331
# - we do not convert to matlab's own array types

spm/__wrapper__/core/delayed_types.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def as_num(self) -> "DelayedArray":
193193
return self._future
194194

195195
def as_obj(self, obj):
196-
from .. import MatlabClass
196+
from ..matlab_class import MatlabClass
197197
if (
198198
self._future is not None and
199199
not isinstance(self._future, MatlabClass)
@@ -216,12 +216,10 @@ def __getattr__(self, key):
216216
return self.as_struct[key]
217217

218218
def __setitem__(self, index, value):
219-
from .. import (
220-
MatlabClass,
221-
Cell,
222-
Array,
223-
Struct
224-
)
219+
from ..matlab_class import MatlabClass
220+
from ..cell import Cell
221+
from ..struct import Struct
222+
from ..array import Array
225223

226224
if isinstance(index, str):
227225
arr = self.as_struct
@@ -317,7 +315,7 @@ def __init__(self, shape, parent, *index):
317315
*index : int | str
318316
Index of the future object in its parent.
319317
"""
320-
from .. import Struct
318+
from ..struct import Struct
321319
future = Struct.from_shape(shape)
322320
future._delayed_wrapper = self
323321
super().__init__(future, parent, *index)
@@ -341,7 +339,7 @@ def __init__(self, shape, parent, *index):
341339
*index : int | str
342340
Index of the future object in its parent.
343341
"""
344-
from .. import Cell
342+
from ..cell import Cell
345343
future = Cell.from_shape(shape)
346344
future._delayed_wrapper = self
347345
super().__init__(future, parent, *index)
@@ -375,7 +373,7 @@ def __init__(self, shape, parent, *index):
375373
*index : int | str
376374
Index of the future object in its parent.
377375
"""
378-
from .. import Array
376+
from ..array import Array
379377
future = Array.from_shape(shape)
380378
future._delayed_wrapper = self
381379
super().__init__(future, parent, *index)

spm/__wrapper__/core/mixin_types.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
ItemsView
1313
)
1414

15-
from typing import TYPE_CHECKING
16-
if TYPE_CHECKING:
17-
from .. import Struct, Cell
18-
1915
class _ListishMixin:
2016
"""These methods are implemented in Cell and Array, but not Struct."""
2117

@@ -572,11 +568,11 @@ class deal: # FIXME: Removed dependency to Cell
572568
def __new__(cls, arg, **kwargs):
573569
return cls.from_any(arg, **kwargs)
574570

575-
def broadcast_to_struct(self, struct: "Struct") -> "Struct":
571+
def broadcast_to_struct(self, struct):
576572
shape = struct.shape + self.shape[len(struct.shape):]
577573
return np.broadcast_to(self, shape)
578574

579-
def to_cell(self) -> "Cell":
580-
from .. import Cell # FIXME: circular imports
575+
def to_cell(self):
576+
from ..cell import Cell # FIXME: circular imports
581577
return np.ndarray.view(self, Cell)
582578

spm/__wrapper__/core/wrapped_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def _resize_for_index(self, index, set_default=True):
293293
arr[scalar_index] = scalar
294294

295295
def _return_delayed(self, index):
296-
from .. import Cell, Struct # FIXME: avoid circular import
296+
from ..cell import Cell
297+
from ..struct import Struct # FIXME: avoid circular import
297298

298299
if not isinstance(index, tuple):
299300
index = (index,)

spm/__wrapper__/matlab_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .core import MatlabType
2-
from .runtime import Runtime
32
from .utils import _import_matlab
43

54
class MatlabFunction(MatlabType):
@@ -37,4 +36,5 @@ def from_any(cls, other):
3736
return cls._from_runtime(other)
3837

3938
def __call__(self, *args, **kwargs):
39+
from .runtime import Runtime
4040
return Runtime.call(self._matlab_object, *args, **kwargs)

spm/__wrapper__/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ def _matlab_array_types():
7272

7373
def _empty_array():
7474
"""Matlab's default cell/struct elements are 0x0 arrays."""
75-
from . import Array
75+
from .array import Array
7676
return Array.from_shape([0, 0])

0 commit comments

Comments
 (0)