@@ -128,7 +128,6 @@ def to_struct(self, name: str) -> "Struct":
128128 return s
129129
130130
131-
132131# ----------------------------------------------------------------------
133132# Types
134133# ----------------------------------------------------------------------
@@ -164,7 +163,7 @@ def from_any(cls, other):
164163 # and the array shape in size__.
165164 return Struct ._from_runtime (other )
166165
167- if type__ == "cell" :
166+ elif type__ == "cell" :
168167 # Matlab returns a list of dictionaries in data__
169168 # and the array shape in size__.
170169 return Cell ._from_runtime (other )
@@ -777,7 +776,7 @@ def sort(self, *, key=None, reverse=False, kind="stable", axis=0):
777776 asarray = np .stack (aslist , axis = axis )
778777 self [...] = asarray
779778 else :
780- np .ndarray .sort (self , kind = "stable" , axis = axis )
779+ np .ndarray .sort (self , kind = kind , axis = axis )
781780 if reverse :
782781 self .reverse ()
783782
@@ -1050,27 +1049,27 @@ def __init__(self, parent):
10501049 self ._parent = parent
10511050
10521051 def __len__ (self ):
1053- return len (self ._parent ._asdict ().values ())
1052+ return len (self ._parent .as_dict ().values ())
10541053
10551054 def __iter__ (self ):
1056- return iter (self ._parent ._asdict ().values ())
1055+ return iter (self ._parent .as_dict ().values ())
10571056
10581057 def __contains__ (self , value ):
1059- return value in self ._parent ._asdict ().values ()
1058+ return value in self ._parent .as_dict ().values ()
10601059
10611060 class ItemsView (ItemsView ):
10621061
10631062 def __init__ (self , parent ):
10641063 self ._parent = parent
10651064
10661065 def __len__ (self ):
1067- return len (self ._parent ._asdict ().items ())
1066+ return len (self ._parent .as_dict ().items ())
10681067
10691068 def __iter__ (self ):
1070- return iter (self ._parent ._asdict ().items ())
1069+ return iter (self ._parent .as_dict ().items ())
10711070
10721071 def __contains__ (self , item ):
1073- return item in self ._parent ._asdict ().items ()
1072+ return item in self ._parent .as_dict ().items ()
10741073
10751074 # --- magic --------------------------------------------------------
10761075
@@ -1316,13 +1315,11 @@ def _from_runtime(cls, objdict: dict) -> "Struct":
13161315 return MatlabType .from_any (obj )
13171316
13181317 def _as_runtime (self ) -> dict :
1319- array = np .ndarray .view (self , np .ndarray )
1320- array = np .reshape (array , [- 1 ], order = "F" )
1321- return dict (
1322- type__ = 'structarray' ,
1323- size__ = np .array ([[* np .shape (self )]]),
1324- data__ = MatlabType ._to_runtime (array )
1325- )
1318+ size = np .array ([[* np .shape (self )]])
1319+ data = np .ndarray .view (self , np .ndarray )
1320+ data = np .reshape (data , [- 1 ], order = "F" )
1321+ data = MatlabType ._to_runtime (data )
1322+ return dict (type__ = 'structarray' , size__ = size , data__ = data )
13261323
13271324 @property
13281325 def as_struct (self ) -> "Struct" :
0 commit comments