Skip to content

Commit 426a36a

Browse files
committed
update pyobject method for more recent pytave, add doctest
1 parent 1d18f52 commit 426a36a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

inst/@sym/pyobject.m

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%% Copyright (C) 2016 Colin B. Macdonald
1+
%% Copyright (C) 2016-2017 Colin B. Macdonald
22
%%
33
%% This file is part of OctSymPy.
44
%%
@@ -24,31 +24,41 @@
2424
%% Example:
2525
%% @example
2626
%% @group
27+
%% @c doctest: +SKIP_IF(~strcmp(sympref('ipc'), 'native'))
2728
%% syms x
2829
%% f = 2*sin(x/2);
2930
%% pyobject(f)
30-
%% @result{} ans = [pyobject ...]
31+
%% @result{} ans = [Python object of type sympy.core.mul.Mul]
3132
%%
3233
%% 2*sin(x/2)
3334
%%
3435
%% @end group
3536
%% @end example
36-
%% @seealso{@@sym/char, py, @@pyobject/pyobject}
37+
%% @seealso{@@sym/sympy, py, @@pyobject/pyobject}
3738
%% @end defmethod
3839

3940

4041
function y = pyobject (x)
4142

42-
y = py.sympy.S (char (x));
43+
y = py.sympy.S (sympy (x));
4344

4445
% Above is nice because it needs no imports. But downside is some
4546
% things like NonElementaryIntegral and MatrixElement will fail. See
4647
% e.g., commit 51a80384d5caea0db211e452d39f0b4f6b3778cc
4748

4849
% Alternatively, with many imports (see python_header.py), this works:
49-
%y = pyeval (char (x));
50+
%y = pyeval (sympy (x));
5051

5152
end
5253

5354

54-
%!assert (isa (pyobject (sym ('x')), 'pyobject'))
55+
%!test
56+
%! try
57+
%! q = py.int(7);
58+
%! have_pytave = true;
59+
%! catch
60+
%! have_pytave = false;
61+
%! end
62+
%! if (have_pytave)
63+
%! assert (isa (pyobject (sym ('x')), 'pyobject'))
64+
%! end

0 commit comments

Comments
 (0)