Mercurial > pytave
comparison @pyobject/cell.m @ 365:087e7bc3697f
Do not automatically convert Python strings to Octave strings (fixes issue #65)
* python_to_octave.cc (pytave::pyobj_to_octvalue): Drop conversion of bytes and
unicode objects.
* __py_struct_from_dict__.cc (F__py_string_value__): New function.
* @pyobject/char.m: Define outside class definition, use __py_string_value__.
* @pyobject/pyobject.m: Delete previous pyobject.char definition.
* @pyobject/methods.m: Apply char conversion to __name__ attribute.
* @py/py.m, @pyobject/cell.m, @pyobject/dummy.m, @pyobject/subsasgn.m,
@pyobject/subsref.m, pyargs.m, pycall.cc, pyeval.cc: Adapt examples and tests
to changes.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Thu, 25 Aug 2016 14:06:56 -0700 |
parents | 15c20ab4b80a |
children | 750a86973625 |
comparison
equal
deleted
inserted
replaced
364:1470ed26917a | 365:087e7bc3697f |
---|---|
40 ## C = cell (L) | 40 ## C = cell (L) |
41 ## @result{} C = | 41 ## @result{} C = |
42 ## @{ | 42 ## @{ |
43 ## [1,1] = 10 | 43 ## [1,1] = 10 |
44 ## [1,2] = 20 | 44 ## [1,2] = 20 |
45 ## [1,3] = hello | 45 ## = [pyobject ...] |
46 ## | |
47 ## hello | |
46 ## @} | 48 ## @} |
47 ## @end group | 49 ## @end group |
48 ## @end example | 50 ## @end example |
49 ## | 51 ## |
50 ## The conversion is not recursive, in the following sense: | 52 ## The conversion is not recursive, in the following sense: |
82 | 84 |
83 %!assert (cell (pyeval ("[]")), cell (1, 0)) | 85 %!assert (cell (pyeval ("[]")), cell (1, 0)) |
84 %!assert (cell (pyeval ("[1.]")), {1}) | 86 %!assert (cell (pyeval ("[1.]")), {1}) |
85 %!assert (cell (pyeval ("[1., 2., 3.]")), {1, 2, 3}) | 87 %!assert (cell (pyeval ("[1., 2., 3.]")), {1, 2, 3}) |
86 %!assert (cell (pyeval ("(1., 2., 3.)")), {1, 2, 3}) | 88 %!assert (cell (pyeval ("(1., 2., 3.)")), {1, 2, 3}) |
87 %!assert (cell (pyobject ("asdf")), {"a", "s", "d", "f"}) | 89 %!assert (cellfun (@char, cell (pyobject ("asdf")), "uniformoutput", false), {"a", "s", "d", "f"}) |
88 | 90 |
89 %!test | 91 %!test |
90 %! c = cell (pyeval ("range(10)")); | 92 %! c = cell (pyeval ("range(10)")); |
91 %! c = cellfun (@(x) eval ("double (x)"), c, "uniformoutput", false); | 93 %! c = cellfun (@(x) eval ("double (x)"), c, "uniformoutput", false); |
92 %! assert (c, num2cell (0:9)) | 94 %! assert (c, num2cell (0:9)) |