From c0e3095408ef74e8dd43a0bed3bc524ec6f4dea0 Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Sun, 3 Jul 2022 11:36:10 -0700 Subject: [PATCH 1/2] Remove unnecessary version exclusions --- inst/@sym/ccode.m | 5 +---- inst/@sym/cond.m | 3 +-- inst/@sym/dot.m | 2 -- inst/@sym/ellipticCE.m | 1 - inst/@sym/ellipticCK.m | 1 - inst/@sym/ellipticCPi.m | 1 - inst/@sym/ellipticK.m | 1 - inst/@sym/fortran.m | 5 +---- inst/@sym/mldivide.m | 1 - inst/@sym/rewrite.m | 3 +-- inst/@sym/symprod.m | 1 - inst/@symfun/diff.m | 3 +-- inst/@symfun/symfun.m | 1 - 13 files changed, 5 insertions(+), 23 deletions(-) diff --git a/inst/@sym/ccode.m b/inst/@sym/ccode.m index 065aae2c5..00b7ae692 100644 --- a/inst/@sym/ccode.m +++ b/inst/@sym/ccode.m @@ -1,4 +1,4 @@ -%% Copyright (C) 2014-2016, 2018-2019 Colin B. Macdonald +%% Copyright (C) 2014-2016, 2018-2019, 2022 Colin B. Macdonald %% %% This file is part of OctSymPy. %% @@ -29,13 +29,11 @@ %% @group %% syms x %% g = taylor(log(1 + x), x, 0, 'order', 5); -%% @c doctest: +XFAIL_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% g = horner(g) %% @result{} g = (sym) %% ⎛ ⎛ ⎛1 x⎞ 1⎞ ⎞ %% x⋅⎜x⋅⎜x⋅⎜─ - ─⎟ - ─⎟ + 1⎟ %% ⎝ ⎝ ⎝3 4⎠ 2⎠ ⎠ -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% ccode(g) %% @result{} x*(x*(x*(1.0/3.0 - 1.0/4.0*x) - 1.0/2.0) + 1) %% @end group @@ -62,7 +60,6 @@ %% @end group %% %% @group -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% disp(C.code) %% @print{} #include "file.h" %% @print{} #include diff --git a/inst/@sym/cond.m b/inst/@sym/cond.m index 885d86578..2a9c5ac7d 100644 --- a/inst/@sym/cond.m +++ b/inst/@sym/cond.m @@ -1,4 +1,4 @@ -%% Copyright (C) 2014, 2016, 2019 Colin B. Macdonald +%% Copyright (C) 2014, 2016, 2019, 2022 Colin B. Macdonald %% %% This file is part of OctSymPy. %% @@ -25,7 +25,6 @@ %% @example %% @group %% A = sym([1 2; 3 0]); -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% cond(A)^2 %% @result{} (sym) %% diff --git a/inst/@sym/dot.m b/inst/@sym/dot.m index d7601c6fc..430b5bc75 100644 --- a/inst/@sym/dot.m +++ b/inst/@sym/dot.m @@ -62,8 +62,6 @@ % conjugate a to match the behavior of @double/dot cmd = { 'a, b = _ins' - 'if Version(spver) <= Version("1.3"):' - ' return a.conjugate().dot(b)' 'return a.dot(b, hermitian=True, conjugate_convention="left")' }; diff --git a/inst/@sym/ellipticCE.m b/inst/@sym/ellipticCE.m index f9cd027a0..269002630 100644 --- a/inst/@sym/ellipticCE.m +++ b/inst/@sym/ellipticCE.m @@ -27,7 +27,6 @@ %% @example %% @group %% syms m -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% ellipticCE (m) %% @result{} ans = (sym) E(1 - m) %% @end group diff --git a/inst/@sym/ellipticCK.m b/inst/@sym/ellipticCK.m index ea889f148..3b1eef688 100644 --- a/inst/@sym/ellipticCK.m +++ b/inst/@sym/ellipticCK.m @@ -27,7 +27,6 @@ %% @example %% @group %% syms m -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% ellipticCK (m) %% @result{} ans = (sym) K(1 - m) %% @end group diff --git a/inst/@sym/ellipticCPi.m b/inst/@sym/ellipticCPi.m index f709db63a..198d6aaa3 100644 --- a/inst/@sym/ellipticCPi.m +++ b/inst/@sym/ellipticCPi.m @@ -27,7 +27,6 @@ %% @example %% @group %% syms nu m -%% @c doctest: +XFAIL_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% ellipticCPi (nu, m) %% @result{} ans = (sym) Π(ν│1 - m) %% @end group diff --git a/inst/@sym/ellipticK.m b/inst/@sym/ellipticK.m index 1df3a2402..9cca4d69d 100644 --- a/inst/@sym/ellipticK.m +++ b/inst/@sym/ellipticK.m @@ -51,7 +51,6 @@ %% Examples: %% @example %% @group -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% diff (ellipticK (m), m) %% @result{} (sym) %% -(1 - m)⋅K(m) + E(m) diff --git a/inst/@sym/fortran.m b/inst/@sym/fortran.m index 8291269f1..61b0032c0 100644 --- a/inst/@sym/fortran.m +++ b/inst/@sym/fortran.m @@ -1,4 +1,4 @@ -%% Copyright (C) 2014-2016, 2019 Colin B. Macdonald +%% Copyright (C) 2014-2016, 2019, 2022 Colin B. Macdonald %% Copyright (C) 2017 Mike Miller %% Copyright (C) 2017 Alex Vong %% @@ -31,13 +31,11 @@ %% @group %% syms x %% g = taylor(log(1 + x), x, 0, 'order', 5); -%% @c doctest: +XFAIL_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% g = horner(g) %% @result{} g = (sym) %% ⎛ ⎛ ⎛1 x⎞ 1⎞ ⎞ %% x⋅⎜x⋅⎜x⋅⎜─ - ─⎟ - ─⎟ + 1⎟ %% ⎝ ⎝ ⎝3 4⎠ 2⎠ ⎠ -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% fortran(g) %% @result{} x*(x*(x*(1.0d0/3.0d0 - 1.0d0/4.0d0*x) - 1.0d0/2.0d0) + 1) %% @end group @@ -54,7 +52,6 @@ %% @end group %% %% @group -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% disp(f90.code) %% @print{} REAL*8 function myfun(x) %% @print{} implicit none diff --git a/inst/@sym/mldivide.m b/inst/@sym/mldivide.m index 0a4c47c02..0bedce62f 100644 --- a/inst/@sym/mldivide.m +++ b/inst/@sym/mldivide.m @@ -55,7 +55,6 @@ %% @example %% @group %% A = sym([5 2]); -%% @c doctest: +XFAIL_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% x = A \ 10 %% @result{} x = (sym 2×1 matrix) %% ⎡ 2⋅c₁⎤ diff --git a/inst/@sym/rewrite.m b/inst/@sym/rewrite.m index d7b74881a..ca0f6aafb 100644 --- a/inst/@sym/rewrite.m +++ b/inst/@sym/rewrite.m @@ -1,4 +1,4 @@ -%% Copyright (C) 2016, 2019 Colin Macdonald +%% Copyright (C) 2016, 2019, 2022 Colin Macdonald %% %% This file is part of OctSymPy. %% @@ -59,7 +59,6 @@ %% The argument @var{f} can be a matrix: %% @example %% @group -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% rewrite([exp(x) cos(x) asin(x)], 'log') %% @result{} ans = (sym 1×3 matrix) %% ⎡ ⎛ ________⎞⎤ diff --git a/inst/@sym/symprod.m b/inst/@sym/symprod.m index fa494a5dc..caea9b0d5 100644 --- a/inst/@sym/symprod.m +++ b/inst/@sym/symprod.m @@ -47,7 +47,6 @@ %% @example %% @group %% syms x m -%% @c doctest: +SKIP_UNLESS(pycall_sympy__ ('return Version(spver) > Version("1.3")')) %% symprod(sin(x), x, [1 m]) %% @result{} (sym) %% m diff --git a/inst/@symfun/diff.m b/inst/@symfun/diff.m index 293b9ec1c..2d5fb887d 100644 --- a/inst/@symfun/diff.m +++ b/inst/@symfun/diff.m @@ -1,4 +1,4 @@ -%% Copyright (C) 2014-2016, 2018-2019 Colin B. Macdonald +%% Copyright (C) 2014-2016, 2018-2019, 2022 Colin B. Macdonald %% %% This file is part of OctSymPy. %% @@ -60,7 +60,6 @@ %% %% @group %% syms f(x, y) -%% @c doctest: +SKIP_IF(pycall_sympy__ ('return Version(spver) <= Version("1.3")')) %% diff(f, x, y, y)(3, 2) % a third partial eval at (3, 2) %% @result{} ans = (sym) %% ⎛ 3 ⎞│ diff --git a/inst/@symfun/symfun.m b/inst/@symfun/symfun.m index 42ec9d391..5b58aaa9a 100644 --- a/inst/@symfun/symfun.m +++ b/inst/@symfun/symfun.m @@ -86,7 +86,6 @@ %% syms f(t) g(t) %% F(t) = f(g(t)) %% @result{} F(t) = (symfun) f(g(t)) -%% @c doctest: +SKIP_IF(pycall_sympy__ ('return Version(spver) <= Version("1.3")')) %% diff(F, t) %% @result{} ans(t) = (symfun) %% d d From 76e8e84f0a7555310f466cb48e832416150a94fb Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Sun, 3 Jul 2022 15:41:40 -0700 Subject: [PATCH 2/2] equationsToMatrix: remove old pre 1.3 workaround --- inst/@sym/equationsToMatrix.m | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/inst/@sym/equationsToMatrix.m b/inst/@sym/equationsToMatrix.m index f7beebf18..211114a71 100644 --- a/inst/@sym/equationsToMatrix.m +++ b/inst/@sym/equationsToMatrix.m @@ -118,35 +118,11 @@ ' vars = symvars' ' else:' ' vars = L.pop(-1)' - 'if Version(spver) > Version("1.3"):' - ' if len(L) == 1:' % might be matrix of eqns, don't want [Matrix] - ' L = L[0]' - ' vars = list(vars)' - ' A, B = linear_eq_to_matrix(L, vars)' - ' return True, A, B' - '#' - '# sympy <= 1.3: we do the work ourselves' - '#' - 'vars = list(collections.OrderedDict.fromkeys(vars))' %% Never repeat elements - 'if len(L) == 1 and isinstance(L[0], MatrixBase):' - ' L = [a for a in L[0]]' - 'if len(L) == 0 or len(vars) == 0:' - ' return True, Matrix([]), Matrix([])' - 'A = zeros(len(L), len(vars)); b = zeros(len(L), 1)' - 'for i in range(len(L)):' - ' q = L[i]' - ' for j in range(len(vars)):' - ' p = Poly.from_expr(L[i], vars[j]).all_coeffs()' - ' q = Poly.from_expr(q, vars[j]).all_coeffs()' - ' if len(p) > 2:' - ' return False, 0, 0' - ' p = p[0] if len(p) == 2 else S(0)' - ' q = q[1] if len(q) == 2 else q[0]' - ' if not set(p.free_symbols).isdisjoint(set(vars)):' - ' return False, 0, 0' - ' A[i, j] = p' - ' b[i] = -q' - 'return True, A, b' }; + 'if len(L) == 1:' % might be matrix of eqns, don't want [Matrix] + ' L = L[0]' + 'vars = list(vars)' + 'A, B = linear_eq_to_matrix(L, vars)' + 'return True, A, B' }; for i = 1:length(varargin) varargin{i} = sym (varargin{i});