Mercurial > pytave
comparison oct-py-types.cc @ 400:6c316b5f30f7
Convert empty 1-D or 2-D arrays to Python array.array (fixes issue #69)
* oct-py-types.cc (pytave::make_py_array): Also convert arrays with zero columns
or zero rows.
* octave_to_python.cc (pytave::octvalue_to_pyobj): Convert numeric arrays with
zero columns or zero rows with make_py_array.
* @pyobject/pyobject.m: Add %!tests.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Fri, 28 Apr 2017 10:34:18 -0700 |
parents | d362cdd1ddeb |
children | c4b78e449c62 |
comparison
equal
deleted
inserted
replaced
399:692cecebc71f | 400:6c316b5f30f7 |
---|---|
279 | 279 |
280 PyObject * | 280 PyObject * |
281 make_py_array (const octave_value& value) | 281 make_py_array (const octave_value& value) |
282 { | 282 { |
283 if (value.is_numeric_type () && ! value.is_complex_type () | 283 if (value.is_numeric_type () && ! value.is_complex_type () |
284 && value.ndims () == 2 && (value.columns () == 1 || value.rows () == 1)) | 284 && value.ndims () == 2 && (value.columns () <= 1 || value.rows () <= 1)) |
285 { | 285 { |
286 if (value.is_double_type ()) | 286 if (value.is_double_type ()) |
287 return make_py_array (value.array_value ()); | 287 return make_py_array (value.array_value ()); |
288 else if (value.is_single_type ()) | 288 else if (value.is_single_type ()) |
289 return make_py_array (value.float_array_value ()); | 289 return make_py_array (value.float_array_value ()); |