|
38 | 38 | )
|
39 | 39 | )
|
40 | 40 |
|
41 |
| -rev_class_id = {dtype: i for i, dtype in enumerate(scalar_id.values())} |
| 41 | +# Matlab numeric codes |
| 42 | +matlab_scalar_mapping = { |
| 43 | + np.dtype("bool"): 3, # LOGICAL |
| 44 | + np.dtype("c"): 4, # CHAR |
| 45 | + np.dtype("O"): 5, # VOID |
| 46 | + np.dtype("float64"): 6, # DOUBLE |
| 47 | + np.dtype("float32"): 7, # SINGLE |
| 48 | + np.dtype("int8"): 8, # INT8 |
| 49 | + np.dtype("uint8"): 9, # UINT8 |
| 50 | + np.dtype("int16"): 10, # INT16 |
| 51 | + np.dtype("uint16"): 11, # UINT16 |
| 52 | + np.dtype("int32"): 12, # INT32 |
| 53 | + np.dtype("uint32"): 13, # UINT32 |
| 54 | + np.dtype("int64"): 14, # INT64 |
| 55 | + np.dtype("uint64"): 15, # UINT64 |
| 56 | +} |
| 57 | + |
42 | 58 | dtype_list = list(scalar_id.values())
|
43 | 59 | type_names = list(scalar_id)
|
44 | 60 |
|
@@ -256,9 +272,13 @@ def pack_array(self, array):
|
256 | 272 | if is_complex:
|
257 | 273 | array, imaginary = np.real(array), np.imag(array)
|
258 | 274 | type_id = (
|
259 |
| - rev_class_id[array.dtype] |
260 |
| - if array.dtype.char != "U" |
261 |
| - else rev_class_id[np.dtype("O")] |
| 275 | + matlab_scalar_mapping[np.dtype("O")] |
| 276 | + if array.dtype not in matlab_scalar_mapping |
| 277 | + else ( |
| 278 | + matlab_scalar_mapping[array.dtype] |
| 279 | + if array.dtype.char != "U" |
| 280 | + else matlab_scalar_mapping[np.dtype("O")] |
| 281 | + ) |
262 | 282 | )
|
263 | 283 | if dtype_list[type_id] is None:
|
264 | 284 | raise DataJointError("Type %s is ambiguous or unknown" % array.dtype)
|
|
0 commit comments