Mercurial > pytave
comparison python_to_octave.cc @ 327:15c20ab4b80a
Do not automatically convert Python integer types to Octave (see issue #56)
* python_to_octave.cc (pytave::pyobj_to_octvalue): Drop automatic conversion of
Python int and long types to Octave.
* @pyobject/pyobject.m (pyobject.length, pyobject.size): Cast values to double.
Adapt %!tests to changes.
* @pyobject/cell.m, @pyobject/dummy.m, @pyobject/subsasgn.m,
@pyobject/subsref.m, pycall.cc, pyeval.cc: Adapt usage examples and %!tests
to changes.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sat, 13 Aug 2016 21:24:29 -0700 |
parents | 37df9bd607ed |
children | 5782d7932529 |
comparison
equal
deleted
inserted
replaced
326:37df9bd607ed | 327:15c20ab4b80a |
---|---|
336 } | 336 } |
337 | 337 |
338 void pyobj_to_octvalue (octave_value& oct_value, | 338 void pyobj_to_octvalue (octave_value& oct_value, |
339 const boost::python::object& py_object) | 339 const boost::python::object& py_object) |
340 { | 340 { |
341 extract<long> longx (py_object); | |
342 extract<bool> boolx (py_object); | 341 extract<bool> boolx (py_object); |
343 extract<double> doublex (py_object); | 342 extract<double> doublex (py_object); |
344 extract<Complex> complexx (py_object); | 343 extract<Complex> complexx (py_object); |
345 extract<numeric::array> arrayx (py_object); | 344 extract<numeric::array> arrayx (py_object); |
346 | 345 |
347 if (boolx.check () && PyBool_Check ((PyArrayObject*)py_object.ptr ())) | 346 if (PyBool_Check (py_object.ptr ())) |
348 oct_value = boolx (); | 347 oct_value = boolx (); |
349 else if (longx.check ()) | 348 else if (PyFloat_Check (py_object.ptr ())) |
350 oct_value = longx (); | |
351 else if (doublex.check ()) | |
352 oct_value = doublex (); | 349 oct_value = doublex (); |
353 else if (complexx.check ()) | 350 else if (PyComplex_Check (py_object.ptr ())) |
354 oct_value = complexx (); | 351 oct_value = complexx (); |
355 else if (arrayx.check ()) | 352 else if (arrayx.check ()) |
356 pyarr_to_octvalue (oct_value, (PyArrayObject*)py_object.ptr ()); | 353 pyarr_to_octvalue (oct_value, (PyArrayObject*)py_object.ptr ()); |
357 else if (PyBytes_Check (py_object.ptr ()) || PyUnicode_Check (py_object.ptr ())) | 354 else if (PyBytes_Check (py_object.ptr ()) || PyUnicode_Check (py_object.ptr ())) |
358 oct_value = extract_py_str (py_object.ptr ()); | 355 oct_value = extract_py_str (py_object.ptr ()); |