Skip to content
This repository

RF: fix for squeezing 0d scalars from ticket 1230 #252

Merged
merged 1 commit into from almost 2 years ago

2 participants

Matthew Brett Ralf Gommers
Matthew Brett

With test.

Ralf Gommers rgommers merged commit 3199911 into from June 10, 2012
Ralf Gommers rgommers closed this June 10, 2012
Clemens ClemensFMN referenced this pull request from a commit August 06, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 10, 2012
Matthew Brett RF: fix for squeezing 0d scalars from ticket 1230
With test.
b65beb1
This page is out of date. Refresh to see the latest.
221  scipy/io/matlab/mio_utils.c
... ...
@@ -1,4 +1,4 @@
1  
-/* Generated by Cython 0.15 on Tue Nov  1 18:18:44 2011 */
  1
+/* Generated by Cython 0.15.1 on Sun Jun 10 11:32:23 2012 */
2 2
 
3 3
 #define PY_SSIZE_T_CLEAN
4 4
 #include "Python.h"
@@ -266,7 +266,7 @@
266 266
 #   else
267 267
 #     define CYTHON_UNUSED
268 268
 #   endif
269  
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  269
+# elif defined(__ICC) || defined(__INTEL_COMPILER)
270 270
 #   define CYTHON_UNUSED __attribute__ ((__unused__))
271 271
 # else
272 272
 #   define CYTHON_UNUSED
@@ -728,6 +728,18 @@ static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/
728 728
 
729 729
 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
730 730
 
  731
+#include <string.h>
  732
+
  733
+static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  734
+
  735
+static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  736
+
  737
+#if PY_MAJOR_VERSION >= 3
  738
+#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  739
+#else
  740
+#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  741
+#endif
  742
+
731 743
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_Py_intptr_t(Py_intptr_t);
732 744
 
733 745
 #if CYTHON_CCOMPLEX
@@ -926,6 +938,7 @@ static char __pyx_k__I[] = "I";
926 938
 static char __pyx_k__L[] = "L";
927 939
 static char __pyx_k__O[] = "O";
928 940
 static char __pyx_k__Q[] = "Q";
  941
+static char __pyx_k__V[] = "V";
929 942
 static char __pyx_k__b[] = "b";
930 943
 static char __pyx_k__d[] = "d";
931 944
 static char __pyx_k__f[] = "f";
@@ -940,6 +953,7 @@ static char __pyx_k__Zg[] = "Zg";
940 953
 static char __pyx_k__np[] = "np";
941 954
 static char __pyx_k__str[] = "str";
942 955
 static char __pyx_k__item[] = "item";
  956
+static char __pyx_k__kind[] = "kind";
943 957
 static char __pyx_k__size[] = "size";
944 958
 static char __pyx_k__view[] = "view";
945 959
 static char __pyx_k__array[] = "array";
@@ -951,7 +965,6 @@ static char __pyx_k__reshape[] = "reshape";
951 965
 static char __pyx_k__squeeze[] = "squeeze";
952 966
 static char __pyx_k____main__[] = "__main__";
953 967
 static char __pyx_k____test__[] = "__test__";
954  
-static char __pyx_k__isbuiltin[] = "isbuiltin";
955 968
 static char __pyx_k__ValueError[] = "ValueError";
956 969
 static char __pyx_k__RuntimeError[] = "RuntimeError";
957 970
 static char __pyx_k__ascontiguousarray[] = "ascontiguousarray";
@@ -962,14 +975,15 @@ static PyObject *__pyx_kp_u_5;
962 975
 static PyObject *__pyx_kp_u_7;
963 976
 static PyObject *__pyx_kp_u_9;
964 977
 static PyObject *__pyx_n_s__RuntimeError;
  978
+static PyObject *__pyx_n_s__V;
965 979
 static PyObject *__pyx_n_s__ValueError;
966 980
 static PyObject *__pyx_n_s____main__;
967 981
 static PyObject *__pyx_n_s____test__;
968 982
 static PyObject *__pyx_n_s__array;
969 983
 static PyObject *__pyx_n_s__ascontiguousarray;
970 984
 static PyObject *__pyx_n_s__dtype;
971  
-static PyObject *__pyx_n_s__isbuiltin;
972 985
 static PyObject *__pyx_n_s__item;
  986
+static PyObject *__pyx_n_s__kind;
973 987
 static PyObject *__pyx_n_s__np;
974 988
 static PyObject *__pyx_n_s__numpy;
975 989
 static PyObject *__pyx_n_s__range;
@@ -1158,7 +1172,7 @@ static PyObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_squeeze_element(PyArrayOb
1158 1172
  *     if not arr.size:
1159 1173
  *         return np.array([])             # <<<<<<<<<<<<<<
1160 1174
  *     arr2 = np.squeeze(arr)
1161  
- *     if (not arr2.shape) and arr2.dtype.isbuiltin: # 0d coverted to scalar
  1175
+ *     # We want to squeeze 0d arrays, unless they are record arrays
1162 1176
  */
1163 1177
     __Pyx_XDECREF(__pyx_r);
1164 1178
     __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -1188,8 +1202,8 @@ static PyObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_squeeze_element(PyArrayOb
1188 1202
  *     if not arr.size:
1189 1203
  *         return np.array([])
1190 1204
  *     arr2 = np.squeeze(arr)             # <<<<<<<<<<<<<<
1191  
- *     if (not arr2.shape) and arr2.dtype.isbuiltin: # 0d coverted to scalar
1192  
- *         return arr2.item()
  1205
+ *     # We want to squeeze 0d arrays, unless they are record arrays
  1206
+ *     if (not arr2.shape) and arr2.dtype.kind != 'V':
1193 1207
  */
1194 1208
   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1195 1209
   __Pyx_GOTREF(__pyx_t_1);
@@ -1208,25 +1222,25 @@ static PyObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_squeeze_element(PyArrayOb
1208 1222
   __pyx_v_arr2 = __pyx_t_4;
1209 1223
   __pyx_t_4 = 0;
1210 1224
 
1211  
-  /* "scipy/io/matlab/mio_utils.pyx":25
1212  
- *         return np.array([])
  1225
+  /* "scipy/io/matlab/mio_utils.pyx":26
1213 1226
  *     arr2 = np.squeeze(arr)
1214  
- *     if (not arr2.shape) and arr2.dtype.isbuiltin: # 0d coverted to scalar             # <<<<<<<<<<<<<<
  1227
+ *     # We want to squeeze 0d arrays, unless they are record arrays
  1228
+ *     if (not arr2.shape) and arr2.dtype.kind != 'V':             # <<<<<<<<<<<<<<
1215 1229
  *         return arr2.item()
1216 1230
  *     return arr2
1217 1231
  */
1218  
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_arr2, __pyx_n_s__shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1232
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_arr2, __pyx_n_s__shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1219 1233
   __Pyx_GOTREF(__pyx_t_4);
1220  
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1234
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1221 1235
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1222 1236
   __pyx_t_2 = (!__pyx_t_3);
1223 1237
   if (__pyx_t_2) {
1224  
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_arr2, __pyx_n_s__dtype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1238
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_arr2, __pyx_n_s__dtype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1225 1239
     __Pyx_GOTREF(__pyx_t_4);
1226  
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__isbuiltin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1240
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__kind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1227 1241
     __Pyx_GOTREF(__pyx_t_1);
1228 1242
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1229  
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1243
+    __pyx_t_3 = __Pyx_PyString_Equals(__pyx_t_1, ((PyObject *)__pyx_n_s__V), Py_NE); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1230 1244
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1231 1245
     __pyx_t_6 = __pyx_t_3;
1232 1246
   } else {
@@ -1234,17 +1248,17 @@ static PyObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_squeeze_element(PyArrayOb
1234 1248
   }
1235 1249
   if (__pyx_t_6) {
1236 1250
 
1237  
-    /* "scipy/io/matlab/mio_utils.pyx":26
1238  
- *     arr2 = np.squeeze(arr)
1239  
- *     if (not arr2.shape) and arr2.dtype.isbuiltin: # 0d coverted to scalar
  1251
+    /* "scipy/io/matlab/mio_utils.pyx":27
  1252
+ *     # We want to squeeze 0d arrays, unless they are record arrays
  1253
+ *     if (not arr2.shape) and arr2.dtype.kind != 'V':
1240 1254
  *         return arr2.item()             # <<<<<<<<<<<<<<
1241 1255
  *     return arr2
1242 1256
  * 
1243 1257
  */
1244 1258
     __Pyx_XDECREF(__pyx_r);
1245  
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_arr2, __pyx_n_s__item); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1259
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_arr2, __pyx_n_s__item); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1246 1260
     __Pyx_GOTREF(__pyx_t_1);
1247  
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1261
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1248 1262
     __Pyx_GOTREF(__pyx_t_4);
1249 1263
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1250 1264
     __pyx_r = __pyx_t_4;
@@ -1254,8 +1268,8 @@ static PyObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_squeeze_element(PyArrayOb
1254 1268
   }
1255 1269
   __pyx_L4:;
1256 1270
 
1257  
-  /* "scipy/io/matlab/mio_utils.pyx":27
1258  
- *     if (not arr2.shape) and arr2.dtype.isbuiltin: # 0d coverted to scalar
  1271
+  /* "scipy/io/matlab/mio_utils.pyx":28
  1272
+ *     if (not arr2.shape) and arr2.dtype.kind != 'V':
1259 1273
  *         return arr2.item()
1260 1274
  *     return arr2             # <<<<<<<<<<<<<<
1261 1275
  * 
@@ -1320,7 +1334,7 @@ static PyObject *__pyx_pf_5scipy_2io_6matlab_9mio_utils_1squeeze_element(PyObjec
1320 1334
   return __pyx_r;
1321 1335
 }
1322 1336
 
1323  
-/* "scipy/io/matlab/mio_utils.pyx":30
  1337
+/* "scipy/io/matlab/mio_utils.pyx":31
1324 1338
  * 
1325 1339
  * 
1326 1340
  * cpdef cnp.ndarray chars_to_strings(in_arr):             # <<<<<<<<<<<<<<
@@ -1347,18 +1361,18 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1347 1361
   int __pyx_clineno = 0;
1348 1362
   __Pyx_RefNannySetupContext("chars_to_strings");
1349 1363
 
1350  
-  /* "scipy/io/matlab/mio_utils.pyx":44
  1364
+  /* "scipy/io/matlab/mio_utils.pyx":45
1351 1365
  *        ``arr``
1352 1366
  *     '''
1353 1367
  *     cdef cnp.ndarray arr = in_arr             # <<<<<<<<<<<<<<
1354 1368
  *     cdef int ndim = arr.ndim
1355 1369
  *     cdef cnp.npy_intp *dims = arr.shape
1356 1370
  */
1357  
-  if (!(likely(((__pyx_v_in_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_in_arr, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1371
+  if (!(likely(((__pyx_v_in_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_in_arr, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1358 1372
   __Pyx_INCREF(__pyx_v_in_arr);
1359 1373
   __pyx_v_arr = ((PyArrayObject *)__pyx_v_in_arr);
1360 1374
 
1361  
-  /* "scipy/io/matlab/mio_utils.pyx":45
  1375
+  /* "scipy/io/matlab/mio_utils.pyx":46
1362 1376
  *     '''
1363 1377
  *     cdef cnp.ndarray arr = in_arr
1364 1378
  *     cdef int ndim = arr.ndim             # <<<<<<<<<<<<<<
@@ -1367,7 +1381,7 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1367 1381
  */
1368 1382
   __pyx_v_ndim = __pyx_v_arr->nd;
1369 1383
 
1370  
-  /* "scipy/io/matlab/mio_utils.pyx":46
  1384
+  /* "scipy/io/matlab/mio_utils.pyx":47
1371 1385
  *     cdef cnp.ndarray arr = in_arr
1372 1386
  *     cdef int ndim = arr.ndim
1373 1387
  *     cdef cnp.npy_intp *dims = arr.shape             # <<<<<<<<<<<<<<
@@ -1376,7 +1390,7 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1376 1390
  */
1377 1391
   __pyx_v_dims = __pyx_v_arr->dimensions;
1378 1392
 
1379  
-  /* "scipy/io/matlab/mio_utils.pyx":47
  1393
+  /* "scipy/io/matlab/mio_utils.pyx":48
1380 1394
  *     cdef int ndim = arr.ndim
1381 1395
  *     cdef cnp.npy_intp *dims = arr.shape
1382 1396
  *     cdef cnp.npy_intp last_dim = dims[ndim-1]             # <<<<<<<<<<<<<<
@@ -1385,7 +1399,7 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1385 1399
  */
1386 1400
   __pyx_v_last_dim = (__pyx_v_dims[(__pyx_v_ndim - 1)]);
1387 1401
 
1388  
-  /* "scipy/io/matlab/mio_utils.pyx":49
  1402
+  /* "scipy/io/matlab/mio_utils.pyx":50
1389 1403
  *     cdef cnp.npy_intp last_dim = dims[ndim-1]
1390 1404
  *     cdef object new_dt_str, out_shape
1391 1405
  *     if last_dim == 0: # deal with empty array case             # <<<<<<<<<<<<<<
@@ -1395,22 +1409,22 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1395 1409
   __pyx_t_1 = (__pyx_v_last_dim == 0);
1396 1410
   if (__pyx_t_1) {
1397 1411
 
1398  
-    /* "scipy/io/matlab/mio_utils.pyx":51
  1412
+    /* "scipy/io/matlab/mio_utils.pyx":52
1399 1413
  *     if last_dim == 0: # deal with empty array case
1400 1414
  *         # Started with U1 - which is OK for us
1401 1415
  *         new_dt_str = arr.dtype.str             # <<<<<<<<<<<<<<
1402 1416
  *         # So far we only know this is an empty array and that the last length is
1403 1417
  *         # 0.  The other dimensions could be non-zero.  We set the next to last
1404 1418
  */
1405  
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__dtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1419
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__dtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1406 1420
     __Pyx_GOTREF(__pyx_t_2);
1407  
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__str); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1421
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__str); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1408 1422
     __Pyx_GOTREF(__pyx_t_3);
1409 1423
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1410 1424
     __pyx_v_new_dt_str = __pyx_t_3;
1411 1425
     __pyx_t_3 = 0;
1412 1426
 
1413  
-    /* "scipy/io/matlab/mio_utils.pyx":55
  1427
+    /* "scipy/io/matlab/mio_utils.pyx":56
1414 1428
  *         # 0.  The other dimensions could be non-zero.  We set the next to last
1415 1429
  *         # dimension to zero to signal emptiness
1416 1430
  *         if ndim == 2:             # <<<<<<<<<<<<<<
@@ -1420,7 +1434,7 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1420 1434
     __pyx_t_1 = (__pyx_v_ndim == 2);
1421 1435
     if (__pyx_t_1) {
1422 1436
 
1423  
-      /* "scipy/io/matlab/mio_utils.pyx":56
  1437
+      /* "scipy/io/matlab/mio_utils.pyx":57
1424 1438
  *         # dimension to zero to signal emptiness
1425 1439
  *         if ndim == 2:
1426 1440
  *             out_shape = (0,)             # <<<<<<<<<<<<<<
@@ -1433,19 +1447,19 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1433 1447
     }
1434 1448
     /*else*/ {
1435 1449
 
1436  
-      /* "scipy/io/matlab/mio_utils.pyx":58
  1450
+      /* "scipy/io/matlab/mio_utils.pyx":59
1437 1451
  *             out_shape = (0,)
1438 1452
  *         else:
1439 1453
  *             out_shape = in_arr.shape[:-2] + (0,)             # <<<<<<<<<<<<<<
1440 1454
  *     else: # make new dtype string with N appended
1441 1455
  *         new_dt_str = arr.dtype.str[:-1] + str(last_dim)
1442 1456
  */
1443  
-      __pyx_t_3 = PyObject_GetAttr(__pyx_v_in_arr, __pyx_n_s__shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1457
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_in_arr, __pyx_n_s__shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1444 1458
       __Pyx_GOTREF(__pyx_t_3);
1445  
-      __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_t_3, 0, -2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1459
+      __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_t_3, 0, -2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1446 1460
       __Pyx_GOTREF(__pyx_t_2);
1447 1461
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1448  
-      __pyx_t_3 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_k_tuple_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1462
+      __pyx_t_3 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_k_tuple_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1449 1463
       __Pyx_GOTREF(__pyx_t_3);
1450 1464
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1451 1465
       __pyx_v_out_shape = __pyx_t_3;
@@ -1456,48 +1470,48 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1456 1470
   }
1457 1471
   /*else*/ {
1458 1472
 
1459  
-    /* "scipy/io/matlab/mio_utils.pyx":60
  1473
+    /* "scipy/io/matlab/mio_utils.pyx":61
1460 1474
  *             out_shape = in_arr.shape[:-2] + (0,)
1461 1475
  *     else: # make new dtype string with N appended
1462 1476
  *         new_dt_str = arr.dtype.str[:-1] + str(last_dim)             # <<<<<<<<<<<<<<
1463 1477
  *         out_shape = in_arr.shape[:-1]
1464 1478
  *     # Copy to deal with F ordered arrays
1465 1479
  */
1466  
-    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__dtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1480
+    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__dtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1467 1481
     __Pyx_GOTREF(__pyx_t_3);
1468  
-    __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__str); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1482
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__str); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1469 1483
     __Pyx_GOTREF(__pyx_t_2);
1470 1484
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1471  
-    __pyx_t_3 = __Pyx_PySequence_GetSlice(__pyx_t_2, 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1485
+    __pyx_t_3 = __Pyx_PySequence_GetSlice(__pyx_t_2, 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1472 1486
     __Pyx_GOTREF(__pyx_t_3);
1473 1487
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1474  
-    __pyx_t_2 = __Pyx_PyInt_to_py_Py_intptr_t(__pyx_v_last_dim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1488
+    __pyx_t_2 = __Pyx_PyInt_to_py_Py_intptr_t(__pyx_v_last_dim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1475 1489
     __Pyx_GOTREF(__pyx_t_2);
1476  
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1490
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1477 1491
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
1478 1492
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
1479 1493
     __Pyx_GIVEREF(__pyx_t_2);
1480 1494
     __pyx_t_2 = 0;
1481  
-    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1495
+    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1482 1496
     __Pyx_GOTREF(__pyx_t_2);
1483 1497
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
1484  
-    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1498
+    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1485 1499
     __Pyx_GOTREF(__pyx_t_4);
1486 1500
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1487 1501
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1488 1502
     __pyx_v_new_dt_str = __pyx_t_4;
1489 1503
     __pyx_t_4 = 0;
1490 1504
 
1491  
-    /* "scipy/io/matlab/mio_utils.pyx":61
  1505
+    /* "scipy/io/matlab/mio_utils.pyx":62
1492 1506
  *     else: # make new dtype string with N appended
1493 1507
  *         new_dt_str = arr.dtype.str[:-1] + str(last_dim)
1494 1508
  *         out_shape = in_arr.shape[:-1]             # <<<<<<<<<<<<<<
1495 1509
  *     # Copy to deal with F ordered arrays
1496 1510
  *     arr = np.ascontiguousarray(arr)
1497 1511
  */
1498  
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_in_arr, __pyx_n_s__shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1512
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_in_arr, __pyx_n_s__shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1499 1513
     __Pyx_GOTREF(__pyx_t_4);
1500  
-    __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_t_4, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1514
+    __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_t_4, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1501 1515
     __Pyx_GOTREF(__pyx_t_2);
1502 1516
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1503 1517
     __pyx_v_out_shape = __pyx_t_2;
@@ -1505,72 +1519,72 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1505 1519
   }
1506 1520
   __pyx_L3:;
1507 1521
 
1508  
-  /* "scipy/io/matlab/mio_utils.pyx":63
  1522
+  /* "scipy/io/matlab/mio_utils.pyx":64
1509 1523
  *         out_shape = in_arr.shape[:-1]
1510 1524
  *     # Copy to deal with F ordered arrays
1511 1525
  *     arr = np.ascontiguousarray(arr)             # <<<<<<<<<<<<<<
1512 1526
  *     arr = arr.view(new_dt_str)
1513 1527
  *     return arr.reshape(out_shape)
1514 1528
  */
1515  
-  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1529
+  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1516 1530
   __Pyx_GOTREF(__pyx_t_2);
1517  
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ascontiguousarray); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1531
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ascontiguousarray); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1518 1532
   __Pyx_GOTREF(__pyx_t_4);
1519 1533
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1520  
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1534
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1521 1535
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1522 1536
   __Pyx_INCREF(((PyObject *)__pyx_v_arr));
1523 1537
   PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_arr));
1524 1538
   __Pyx_GIVEREF(((PyObject *)__pyx_v_arr));
1525  
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1539
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1526 1540
   __Pyx_GOTREF(__pyx_t_3);
1527 1541
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1528 1542
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1529  
-  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1543
+  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1530 1544
   __Pyx_DECREF(((PyObject *)__pyx_v_arr));
1531 1545
   __pyx_v_arr = ((PyArrayObject *)__pyx_t_3);
1532 1546
   __pyx_t_3 = 0;
1533 1547
 
1534  
-  /* "scipy/io/matlab/mio_utils.pyx":64
  1548
+  /* "scipy/io/matlab/mio_utils.pyx":65
1535 1549
  *     # Copy to deal with F ordered arrays
1536 1550
  *     arr = np.ascontiguousarray(arr)
1537 1551
  *     arr = arr.view(new_dt_str)             # <<<<<<<<<<<<<<
1538 1552
  *     return arr.reshape(out_shape)
1539 1553
  */
1540  
-  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__view); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1554
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__view); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1541 1555
   __Pyx_GOTREF(__pyx_t_3);
1542  
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1556
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1543 1557
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1544 1558
   __Pyx_INCREF(__pyx_v_new_dt_str);
1545 1559
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_new_dt_str);
1546 1560
   __Pyx_GIVEREF(__pyx_v_new_dt_str);
1547  
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1561
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1548 1562
   __Pyx_GOTREF(__pyx_t_4);
1549 1563
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1550 1564
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1551  
-  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1565
+  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1552 1566
   __Pyx_DECREF(((PyObject *)__pyx_v_arr));
1553 1567
   __pyx_v_arr = ((PyArrayObject *)__pyx_t_4);
1554 1568
   __pyx_t_4 = 0;
1555 1569
 
1556  
-  /* "scipy/io/matlab/mio_utils.pyx":65
  1570
+  /* "scipy/io/matlab/mio_utils.pyx":66
1557 1571
  *     arr = np.ascontiguousarray(arr)
1558 1572
  *     arr = arr.view(new_dt_str)
1559 1573
  *     return arr.reshape(out_shape)             # <<<<<<<<<<<<<<
1560 1574
  */
1561 1575
   __Pyx_XDECREF(((PyObject *)__pyx_r));
1562  
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__reshape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1576
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_s__reshape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1563 1577
   __Pyx_GOTREF(__pyx_t_4);
1564  
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1578
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1565 1579
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1566 1580
   __Pyx_INCREF(__pyx_v_out_shape);
1567 1581
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_out_shape);
1568 1582
   __Pyx_GIVEREF(__pyx_v_out_shape);
1569  
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1583
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1570 1584
   __Pyx_GOTREF(__pyx_t_3);
1571 1585
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1572 1586
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1573  
-  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1587
+  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1574 1588
   __pyx_r = ((PyArrayObject *)__pyx_t_3);
1575 1589
   __pyx_t_3 = 0;
1576 1590
   goto __pyx_L0;
@@ -1592,7 +1606,7 @@ static PyArrayObject *__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(PyO
1592 1606
   return __pyx_r;
1593 1607
 }
1594 1608
 
1595  
-/* "scipy/io/matlab/mio_utils.pyx":30
  1609
+/* "scipy/io/matlab/mio_utils.pyx":31
1596 1610
  * 
1597 1611
  * 
1598 1612
  * cpdef cnp.ndarray chars_to_strings(in_arr):             # <<<<<<<<<<<<<<
@@ -1612,7 +1626,7 @@ static PyObject *__pyx_pf_5scipy_2io_6matlab_9mio_utils_2chars_to_strings(PyObje
1612 1626
   __Pyx_RefNannySetupContext("chars_to_strings");
1613 1627
   __pyx_self = __pyx_self;
1614 1628
   __Pyx_XDECREF(__pyx_r);
1615  
-  __pyx_t_1 = ((PyObject *)__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(__pyx_v_in_arr, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1629
+  __pyx_t_1 = ((PyObject *)__pyx_f_5scipy_2io_6matlab_9mio_utils_chars_to_strings(__pyx_v_in_arr, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1616 1630
   __Pyx_GOTREF(__pyx_t_1);
1617 1631
   __pyx_r = __pyx_t_1;
1618 1632
   __pyx_t_1 = 0;
@@ -3595,14 +3609,15 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
3595 3609
   {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0},
3596 3610
   {&__pyx_kp_u_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 1, 0, 0},
3597 3611
   {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  3612
+  {&__pyx_n_s__V, __pyx_k__V, sizeof(__pyx_k__V), 0, 0, 1, 1},
3598 3613
   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
3599 3614
   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
3600 3615
   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
3601 3616
   {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 0, 0, 1, 1},
3602 3617
   {&__pyx_n_s__ascontiguousarray, __pyx_k__ascontiguousarray, sizeof(__pyx_k__ascontiguousarray), 0, 0, 1, 1},
3603 3618
   {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1},
3604  
-  {&__pyx_n_s__isbuiltin, __pyx_k__isbuiltin, sizeof(__pyx_k__isbuiltin), 0, 0, 1, 1},
3605 3619
   {&__pyx_n_s__item, __pyx_k__item, sizeof(__pyx_k__item), 0, 0, 1, 1},
  3620
+  {&__pyx_n_s__kind, __pyx_k__kind, sizeof(__pyx_k__kind), 0, 0, 1, 1},
3606 3621
   {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1},
3607 3622
   {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1},
3608 3623
   {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
@@ -3627,28 +3642,28 @@ static int __Pyx_InitCachedConstants(void) {
3627 3642
   __Pyx_RefNannyDeclarations
3628 3643
   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
3629 3644
 
3630  
-  /* "scipy/io/matlab/mio_utils.pyx":56
  3645
+  /* "scipy/io/matlab/mio_utils.pyx":57
3631 3646
  *         # dimension to zero to signal emptiness
3632 3647
  *         if ndim == 2:
3633 3648
  *             out_shape = (0,)             # <<<<<<<<<<<<<<
3634 3649
  *         else:
3635 3650
  *             out_shape = in_arr.shape[:-2] + (0,)
3636 3651
  */
3637  
-  __pyx_k_tuple_1 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3652
+  __pyx_k_tuple_1 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3638 3653
   __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_1));
3639 3654
   __Pyx_INCREF(__pyx_int_0);
3640 3655
   PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, __pyx_int_0);
3641 3656
   __Pyx_GIVEREF(__pyx_int_0);
3642 3657
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));
3643 3658
 
3644  
-  /* "scipy/io/matlab/mio_utils.pyx":58
  3659
+  /* "scipy/io/matlab/mio_utils.pyx":59
3645 3660
  *             out_shape = (0,)
3646 3661
  *         else:
3647 3662
  *             out_shape = in_arr.shape[:-2] + (0,)             # <<<<<<<<<<<<<<
3648 3663
  *     else: # make new dtype string with N appended
3649 3664
  *         new_dt_str = arr.dtype.str[:-1] + str(last_dim)
3650 3665
  */
3651  
-  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3666
+  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3652 3667
   __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2));
3653 3668
   __Pyx_INCREF(__pyx_int_0);
3654 3669
   PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, __pyx_int_0);
@@ -4170,6 +4185,68 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
4170 4185
     return module;
4171 4186
 }
4172 4187
 
  4188
+static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  4189
+    if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
  4190
+        return (equals == Py_EQ);
  4191
+    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  4192
+        if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
  4193
+            return (equals == Py_NE);
  4194
+        } else if (PyBytes_GET_SIZE(s1) == 1) {
  4195
+            if (equals == Py_EQ)
  4196
+                return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
  4197
+            else
  4198
+                return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
  4199
+        } else {
  4200
+            int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
  4201
+            return (equals == Py_EQ) ? (result == 0) : (result != 0);
  4202
+        }
  4203
+    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  4204
+        return (equals == Py_NE);
  4205
+    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  4206
+        return (equals == Py_NE);
  4207
+    } else {
  4208
+        int result;
  4209
+        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  4210
+        if (!py_result)
  4211
+            return -1;
  4212
+        result = __Pyx_PyObject_IsTrue(py_result);
  4213
+        Py_DECREF(py_result);
  4214
+        return result;
  4215
+    }
  4216
+}
  4217
+
  4218
+static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  4219
+    if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
  4220
+        return (equals == Py_EQ);
  4221
+    } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
  4222
+        if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) {
  4223
+            return (equals == Py_NE);
  4224
+        } else if (PyUnicode_GET_SIZE(s1) == 1) {
  4225
+            if (equals == Py_EQ)
  4226
+                return (PyUnicode_AS_UNICODE(s1)[0] == PyUnicode_AS_UNICODE(s2)[0]);
  4227
+            else
  4228
+                return (PyUnicode_AS_UNICODE(s1)[0] != PyUnicode_AS_UNICODE(s2)[0]);
  4229
+        } else {
  4230
+            int result = PyUnicode_Compare(s1, s2);
  4231
+            if ((result == -1) && unlikely(PyErr_Occurred()))
  4232
+                return -1;
  4233
+            return (equals == Py_EQ) ? (result == 0) : (result != 0);
  4234
+        }
  4235
+    } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) {
  4236
+        return (equals == Py_NE);
  4237
+    } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) {
  4238
+        return (equals == Py_NE);
  4239
+    } else {
  4240
+        int result;
  4241
+        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  4242
+        if (!py_result)
  4243
+            return -1;
  4244
+        result = __Pyx_PyObject_IsTrue(py_result);
  4245
+        Py_DECREF(py_result);
  4246
+        return result;
  4247
+    }
  4248
+}
  4249
+
4173 4250
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_Py_intptr_t(Py_intptr_t val) {
4174 4251
     const Py_intptr_t neg_one = (Py_intptr_t)-1, const_zero = (Py_intptr_t)0;
4175 4252
     const int is_unsigned = const_zero < neg_one;
3  scipy/io/matlab/mio_utils.pyx
@@ -22,7 +22,8 @@ cpdef object squeeze_element(cnp.ndarray arr):
22 22
     if not arr.size:
23 23
         return np.array([])
24 24
     arr2 = np.squeeze(arr)
25  
-    if (not arr2.shape) and arr2.dtype.isbuiltin: # 0d coverted to scalar
  25
+    # We want to squeeze 0d arrays, unless they are record arrays
  26
+    if (not arr2.shape) and arr2.dtype.kind != 'V':
26 27
         return arr2.item()
27 28
     return arr2
28 29
 
10  scipy/io/matlab/tests/test_mio.py
@@ -829,6 +829,16 @@ def test_mat_struct_squeeze():
829 829
                     )
830 830
 
831 831
 
  832
+def test_scalar_squeeze():
  833
+    stream = BytesIO()
  834
+    in_d = {'scalar': [[0.1]], 'string': 'my name', 'st':{'one':1, 'two':2}}
  835
+    savemat_future(stream, in_d)
  836
+    out_d = loadmat(stream, squeeze_me=True)
  837
+    assert_true(isinstance(out_d['scalar'], float))
  838
+    assert_true(isinstance(out_d['string'], basestring))
  839
+    assert_true(isinstance(out_d['st'], np.ndarray))
  840
+
  841
+
832 842
 def test_str_round():
833 843
     # from report by Angus McMorland on mailing list 3 May 2010
834 844
     stream = BytesIO()
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.