Skip to content

Commit b5966a8

Browse files
committed
[Bug fix] Use fromiter instead of array to convert empty matlab cell data
1 parent 8e7cf1f commit b5966a8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

spm/__wrapper__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,11 +1688,11 @@ class Cell(_ListMixin, WrappedArray):
16881688
_DelayedType = DelayedCell
16891689

16901690
@classmethod
1691-
def _DEFAULT(cls, n: list = ()) -> np.ndarray:
1692-
if len(n) == 0:
1691+
def _DEFAULT(cls, shape: list = ()) -> np.ndarray:
1692+
if len(shape) == 0:
16931693
return Array.from_any([])
16941694

1695-
data = np.empty(n, dtype=object)
1695+
data = np.empty(shape, dtype=object)
16961696
opt = dict(
16971697
flags=['refs_ok', 'zerosize_ok'],
16981698
op_flags=['writeonly', 'no_broadcast']
@@ -1737,9 +1737,9 @@ def _from_runtime(cls, objdict: dict) -> "Cell":
17371737
if objdict['type__'] != 'cell':
17381738
raise TypeError('objdict is not a cell')
17391739
size = np.array(objdict['size__'], dtype=np.uint32).ravel()
1740-
data = np.array(objdict['data__'], dtype=object)
1740+
data = np.fromiter(objdict['data__'], dtype=object)
17411741
data = data.reshape(size[::-1]).transpose()
1742-
try:
1742+
try:
17431743
obj = data.view(cls)
17441744
except Exception:
17451745
raise RuntimeError(

0 commit comments

Comments
 (0)