Skip to content

Commit

Permalink
Merge pull request #1146 from alexvong1995/fixes-1109
Browse files Browse the repository at this point in the history
Fixes #1109
  • Loading branch information
cbm755 committed Jun 22, 2022
2 parents ae791ae + d6da7b8 commit 323b5c6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ jobs:
fail-fast: true
matrix:
octave: [7.1.0]
sympy: [1.4, 1.5.1, 1.6.2, 1.7.1, 1.8, 1.10.1]
sympy: [1.4, 1.5.1, 1.6.2, 1.7.1, 1.8, 1.9, 1.10.1]
include:
- octave: 5.1.0
sympy: 1.8
- octave: 5.2.0
sympy: 1.8
- octave: 6.1.0
sympy: 1.9
- octave: 6.2.0
sympy: 1.9
- octave: 6.3.0
sympy: 1.9
- octave: 6.4.0
sympy: 1.9
- octave: 6.1.0
sympy: 1.10.1
- octave: 6.2.0
Expand Down Expand Up @@ -114,12 +122,14 @@ jobs:
fail-fast: true
matrix:
octave: [7.1.0]
sympy: [1.4, 1.5.1, 1.6.2, 1.7.1, 1.8, 1.10.1]
sympy: [1.4, 1.5.1, 1.6.2, 1.7.1, 1.8, 1.9, 1.10.1]
include:
- octave: 5.1.0
sympy: 1.8
- octave: 5.2.0
sympy: 1.8
- octave: 6.4.0
sympy: 1.9
- octave: 6.4.0
sympy: 1.10.1
steps:
Expand Down Expand Up @@ -167,10 +177,10 @@ jobs:
bist-pythonic:
runs-on: ubuntu-latest
strategy:
fail-fast: false
fail-fast: true
matrix:
octave: [7.1.0]
sympy: [1.10.1]
sympy: [1.9, 1.10.1]
steps:
- uses: actions/checkout@v2
- name:
Expand Down Expand Up @@ -244,10 +254,10 @@ jobs:
doctests-pythonic:
runs-on: ubuntu-latest
strategy:
fail-fast: false
fail-fast: true
matrix:
octave: [7.1.0]
sympy: [1.10.1]
sympy: [1.9, 1.10.1]
steps:
- uses: actions/checkout@v2
- name:
Expand Down
11 changes: 10 additions & 1 deletion inst/@sym/rdivide.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%% Copyright (C) 2014, 2016, 2018-2019 Colin B. Macdonald
%% Copyright (C) 2022 Alex Vong
%%
%% This file is part of OctSymPy.
%%
Expand Down Expand Up @@ -92,10 +93,18 @@
return
end

%% 2022-06: TODO cannot simply call hadamard_product for sympy <1.9,
%% see upstream: https://github.com/sympy/sympy/issues/8557

cmd = { '(x,y) = _ins'
'if x.is_Matrix and y.is_Matrix:'
' return x.multiply_elementwise(y.applyfunc(lambda a: 1/a)),'
' y_eltwise_recip = y.applyfunc(lambda a: 1/a)'
' if Version(spver) < Version("1.9"):'
' try:'
' return x.multiply_elementwise(y_eltwise_recip)'
' except:'
' pass'
' return hadamard_product(x, y_eltwise_recip)'
'if not x.is_Matrix and y.is_Matrix:'
' return y.applyfunc(lambda a: x/a),'
'else:'
Expand Down
15 changes: 9 additions & 6 deletions inst/@sym/times.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%% Copyright (C) 2014, 2016, 2018-2019, 2022 Colin B. Macdonald
%% Copyright (C) 2022 Alex Vong
%%
%% This file is part of OctSymPy.
%%
Expand Down Expand Up @@ -58,17 +59,19 @@
return
end

% 2018-01: TODO cannot simply call hadamard_product, see upstream:
% https://github.com/sympy/sympy/issues/8557
%% 2022-06: TODO cannot simply call hadamard_product for sympy <1.9,
%% see upstream: https://github.com/sympy/sympy/issues/8557

cmd = { '(x,y) = _ins'
'if x is None or y is None:'
' return x*y'
'if x.is_Matrix and y.is_Matrix:'
' try:'
' return x.multiply_elementwise(y)'
' except (AttributeError, TypeError):'
' return hadamard_product(x, y)'
' if Version(spver) < Version("1.9"):'
' try:'
' return x.multiply_elementwise(y)'
' except (AttributeError, TypeError):'
' pass'
' return hadamard_product(x, y)'
'return x*y' };

z = pycall_sympy__ (cmd, sym(x), sym(y));
Expand Down

0 comments on commit 323b5c6

Please sign in to comment.