Skip to content

Commit fbe9eaf

Browse files
committed
remove refrences to matlab types to make scalars more language agnostic
1 parent ae7b93c commit fbe9eaf

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

datajoint/blob.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414
from .settings import config
1515

1616

17-
mxClassID = dict(
17+
scalar_id = dict(
1818
(
1919
# 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]")),
3838
)
3939
)
4040

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)
4444

4545
compression = {b"ZL123\0": zlib.decompress}
4646

@@ -217,12 +217,12 @@ def read_array(self):
217217
dtype_id, is_complex = self.read_value("uint32", 2)
218218
dtype = dtype_list[dtype_id]
219219

220-
if type_names[dtype_id] == "mxVOID_CLASS":
220+
if type_names[dtype_id] == "VOID":
221221
data = np.array(
222222
list(self.read_blob(self.read_value()) for _ in range(n_elem)),
223223
dtype=np.dtype("O"),
224224
)
225-
elif type_names[dtype_id] == "mxCHAR_CLASS":
225+
elif type_names[dtype_id] == "CHAR":
226226
# compensate for MATLAB packing of char arrays
227227
data = self.read_value(dtype, count=2 * n_elem)
228228
data = data[::2].astype("U1")
@@ -264,13 +264,13 @@ def pack_array(self, array):
264264
raise DataJointError("Type %s is ambiguous or unknown" % array.dtype)
265265

266266
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')
268268
blob += b"".join(
269269
len_u64(it) + it
270270
for it in (self.pack_blob(e) for e in array.flatten(order="F"))
271271
)
272272
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')
274274
blob += (
275275
array.view(np.uint8).astype(np.uint16).tobytes()
276276
) # convert to 16-bit chars for MATLAB

0 commit comments

Comments
 (0)