gnu-octave / symbolic

A Symbolic Package for Octave using SymPy
https://octave.sourceforge.io/symbolic/
GNU General Public License v3.0
152 stars 36 forks source link

draft: Use a SymPy Array not a Matrix for non-Expr #1194

Open cbm755 opened 2 years ago

cbm755 commented 2 years ago

It has mostly the same semantics as Matrix but can contain more general things. There might be some issues about different shapes of empties though... WIP on a fix for #1052 and #1055.

cbm755 commented 2 years ago

@alexvong1995 here's a half-baked idea for Issue #1124: roughly when we have non-Expr to be put in a Matrix, we instead make an Array. This will be important for future SymPy as non-Expr in Matrix is deprecated.

cbm755 commented 2 years ago

@alexvong1995 What do you think of this? Basically in a few places (probably not that many) we return Array instead of Matrix. Specifically we return Matrix greedily whenever everything is a Expr, else Array.

(It will need fixes upstream but I'm less worried about that.)

Maybe you can try doing this in the mat_rclist_ and other helper functions, just to get a feel for the idea.

alexvong243f commented 2 years ago

I think the the test failure is partly due to dbout being defined in inst/private/python_header.py (for non-Pythonic IPC) but not in inst/private/python_ipc_native.m (for Pythonic IPC).

I'm not sure what to do about it. It seems there's more code in inst/private/python_header.py than in inst/private/python_ipc_native.m.

cbm755 commented 2 years ago

that could be true: I haven't looked at pythonic much recently. You can always comment out "dbout()" (it is just debugging). With Pythonic you can probably just print() instead.

Anyway, I think even concentrating on system-based, this idea is not complete.

cbm755 commented 2 years ago

@alexvong1995 you can rebase and force push this on top of main (if you like).

alexvong243f commented 2 years ago

I think what we should do next is to make @sym/horzcat and @sym/vertcat Array-compatible. I haven't done any tests yet but I suspect all those [t t; f f] where t is sym(true) and f is sym(false) are causing many test failures.

alexvong243f commented 2 years ago

------- Original Message ------- On Monday, August 29th, 2022 at 12:04 AM, Colin B. Macdonald @.***> wrote:

@alexvong1995 you can rebase and force push this on top of main (if you like).

rebased onto main and force pushed as a7c44c0d78bd6be66b6795ed339751657b1c3a3d

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

cbm755 commented 2 years ago

I think there was a way to turn an warning into an exception in Python. That might be useful when debugging here... like SymPyDeprecationWarning becomes an exception.

alexvong243f commented 2 years ago

------- Original Message ------- On Friday, September 2nd, 2022 at 4:57 PM, Colin B. Macdonald @.***> wrote:

I think there was a way to turn an warning into an exception in Python. That might be useful when debugging here... like SymPyDeprecationWarning becomes an exception.

The following example works for me:

from sympy import Matrix from sympy.utilities.exceptions import SymPyDeprecationWarning import warnings

warnings.filterwarnings("error", category=SymPyDeprecationWarning) Matrix([[True]])

I figure this out after reading multiple issues https://github.com/sympy/sympy/issues?q=is%3Aissue+is%3Aopen+SymPyDeprecationWarning of sympy.

It would be good to know if this is documented somewhere or not.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.