|
14 | 14 | from .settings import config
|
15 | 15 |
|
16 | 16 |
|
17 |
| -mxClassID = dict( |
| 17 | +scalar_id = dict( |
18 | 18 | (
|
19 | 19 | # see http://www.mathworks.com/help/techdoc/apiref/mxclassid.html
|
20 |
| - ("mxUNKNOWN_CLASS", None), |
21 |
| - ("mxCELL_CLASS", None), |
22 |
| - ("mxSTRUCT_CLASS", None), |
23 |
| - ("mxLOGICAL_CLASS", np.dtype("bool")), |
24 |
| - ("mxCHAR_CLASS", np.dtype("c")), |
25 |
| - ("mxVOID_CLASS", np.dtype("O")), |
26 |
| - ("mxDOUBLE_CLASS", np.dtype("float64")), |
27 |
| - ("mxSINGLE_CLASS", np.dtype("float32")), |
28 |
| - ("mxINT8_CLASS", np.dtype("int8")), |
29 |
| - ("mxUINT8_CLASS", np.dtype("uint8")), |
30 |
| - ("mxINT16_CLASS", np.dtype("int16")), |
31 |
| - ("mxUINT16_CLASS", np.dtype("uint16")), |
32 |
| - ("mxINT32_CLASS", np.dtype("int32")), |
33 |
| - ("mxUINT32_CLASS", np.dtype("uint32")), |
34 |
| - ("mxINT64_CLASS", np.dtype("int64")), |
35 |
| - ("mxUINT64_CLASS", np.dtype("uint64")), |
36 |
| - ("mxFUNCTION_CLASS", None), |
37 |
| - ("NON_mx_DATETIME64", np.dtype("<M8[us]")), |
| 20 | + ("UNKNOWN", None), |
| 21 | + ("CELL", None), |
| 22 | + ("STRUCT", None), |
| 23 | + ("LOGICAL", np.dtype("bool")), |
| 24 | + ("CHAR", np.dtype("c")), |
| 25 | + ("VOID", np.dtype("O")), |
| 26 | + ("DOUBLE", np.dtype("float64")), |
| 27 | + ("SINGLE", np.dtype("float32")), |
| 28 | + ("INT8", np.dtype("int8")), |
| 29 | + ("UINT8", np.dtype("uint8")), |
| 30 | + ("INT16", np.dtype("int16")), |
| 31 | + ("UINT16", np.dtype("uint16")), |
| 32 | + ("INT32", np.dtype("int32")), |
| 33 | + ("UINT32", np.dtype("uint32")), |
| 34 | + ("INT64", np.dtype("int64")), |
| 35 | + ("UINT64", np.dtype("uint64")), |
| 36 | + ("FUNCTION", None), |
| 37 | + ("DATETIME64", np.dtype("<M8[us]")), |
38 | 38 | )
|
39 | 39 | )
|
40 | 40 |
|
41 |
| -rev_class_id = {dtype: i for i, dtype in enumerate(mxClassID.values())} |
42 |
| -dtype_list = list(mxClassID.values()) |
43 |
| -type_names = list(mxClassID) |
| 41 | +rev_class_id = {dtype: i for i, dtype in enumerate(scalar_id.values())} |
| 42 | +dtype_list = list(scalar_id.values()) |
| 43 | +type_names = list(scalar_id) |
44 | 44 |
|
45 | 45 | compression = {b"ZL123\0": zlib.decompress}
|
46 | 46 |
|
@@ -217,12 +217,12 @@ def read_array(self):
|
217 | 217 | dtype_id, is_complex = self.read_value("uint32", 2)
|
218 | 218 | dtype = dtype_list[dtype_id]
|
219 | 219 |
|
220 |
| - if type_names[dtype_id] == "mxVOID_CLASS": |
| 220 | + if type_names[dtype_id] == "VOID": |
221 | 221 | data = np.array(
|
222 | 222 | list(self.read_blob(self.read_value()) for _ in range(n_elem)),
|
223 | 223 | dtype=np.dtype("O"),
|
224 | 224 | )
|
225 |
| - elif type_names[dtype_id] == "mxCHAR_CLASS": |
| 225 | + elif type_names[dtype_id] == "CHAR": |
226 | 226 | # compensate for MATLAB packing of char arrays
|
227 | 227 | data = self.read_value(dtype, count=2 * n_elem)
|
228 | 228 | data = data[::2].astype("U1")
|
@@ -264,13 +264,13 @@ def pack_array(self, array):
|
264 | 264 | raise DataJointError("Type %s is ambiguous or unknown" % array.dtype)
|
265 | 265 |
|
266 | 266 | blob += np.array([type_id, is_complex], dtype=np.uint32).tobytes()
|
267 |
| - if type_names[type_id] == "mxVOID_CLASS": # array of dtype('O') |
| 267 | + if type_names[type_id] == "VOID": # array of dtype('O') |
268 | 268 | blob += b"".join(
|
269 | 269 | len_u64(it) + it
|
270 | 270 | for it in (self.pack_blob(e) for e in array.flatten(order="F"))
|
271 | 271 | )
|
272 | 272 | self.set_dj0() # not supported by original mym
|
273 |
| - elif type_names[type_id] == "mxCHAR_CLASS": # array of dtype('c') |
| 273 | + elif type_names[type_id] == "CHAR": # array of dtype('c') |
274 | 274 | blob += (
|
275 | 275 | array.view(np.uint8).astype(np.uint16).tobytes()
|
276 | 276 | ) # convert to 16-bit chars for MATLAB
|
|
0 commit comments