comparison @pyobject/dummy.m @ 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 01ff03fef237
children 087e7bc3697f
comparison
equal deleted inserted replaced
326:37df9bd607ed 327:15c20ab4b80a
23 ## 23 ##
24 ## 24 ##
25 ## Some simple Python objects are converted to equivalent Octave values: 25 ## Some simple Python objects are converted to equivalent Octave values:
26 ## @example 26 ## @example
27 ## @group 27 ## @group
28 ## pyeval ("6") 28 ## pyeval ("6.0")
29 ## @result{} ans = 6 29 ## @result{} ans = 6
30 ## @end group 30 ## @end group
31 ## @end example 31 ## @end example
32 ## 32 ##
33 ## To ensure the return value is a @@pyobject, it can be cast: 33 ## To ensure the return value is a @@pyobject, it can be cast:
52 ## [2,1] = imag 52 ## [2,1] = imag
53 ## [3,1] = numerator 53 ## [3,1] = numerator
54 ## [4,1] = real 54 ## [4,1] = real
55 ## @} 55 ## @}
56 ## 56 ##
57 ## g.numerator 57 ## double (g.numerator)
58 ## @result{} ans = 6 58 ## @result{} ans = 6
59 ## g.denominator 59 ## double (g.denominator)
60 ## @result{} ans = 1 60 ## @result{} ans = 1
61 ## @end group 61 ## @end group
62 ## @end example 62 ## @end example
63 ## 63 ##
64 ## 64 ##
81 ## @end example 81 ## @end example
82 ## 82 ##
83 ## We can accesss ``callables'' (methods) of objects: 83 ## We can accesss ``callables'' (methods) of objects:
84 ## @example 84 ## @example
85 ## @group 85 ## @group
86 ## x.pop ("two") 86 ## double (x.pop ("two"))
87 ## @result{} ans = 2 87 ## @result{} ans = 2
88 ## @end group 88 ## @end group
89 ## @end example 89 ## @end example
90 ## And note this has changed the Python dict @code{x}: 90 ## And note this has changed the Python dict @code{x}:
91 ## @example 91 ## @example
118 ## 118 ##
119 ## 119 ##
120 ## A Python list is returned as a @@pyobject: 120 ## A Python list is returned as a @@pyobject:
121 ## @example 121 ## @example
122 ## @group 122 ## @group
123 ## L = pyeval ("[42, 'hello', sys]") 123 ## L = pyeval ("[42.0, 'hello', sys]")
124 ## @result{} L = [pyobject ...] 124 ## @result{} L = [pyobject ...]
125 ## [42, 'hello', <module 'sys' (built-in)>] 125 ## [42.0, 'hello', <module 'sys' (built-in)>]
126 ## @end group 126 ## @end group
127 ## @end example 127 ## @end example
128 ## 128 ##
129 ## Elements of the list can be accessed directly 129 ## Elements of the list can be accessed directly
130 ## @example 130 ## @example