JuliaPy / JuliaPy/PyCall.jl

sympy matrices, and failed `pyerr_check`

Open
#736 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
1.5k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

After upgrading sympy to 1.5.1, I've noticed an error in sympy's `Matrix` constructor:

```
julia> using PyCall # [438e738f] PyCall v1.91.2
julia> sympy = PyCall.pyimport_conda("sympy", "sympy")
julia> sympy.__version__ # "1.5.1"
julia> sympy.Matrix([[1,1],[2,2]])
ERROR: PyError ($(Expr(:escape, :(ccall(#= /Users/verzani/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw)))))
ValueError('The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()')
File "/Users/verzani/.julia/conda/3/lib/python3.7/site-packages/sympy/matrices/dense.py", line 430, in __new__
return cls._new(*args, **kwargs)
File "/Users/verzani/.julia/conda/3/lib/python3.7/site-packages/sympy/matrices/dense.py", line 442, in _new
rows, cols, flat_list = cls._handle_creation_inputs(*args, **kwargs)
File "/Users/verzani/.julia/conda/3/lib/python3.7/site-packages/sympy/matrices/matrices.py", line 2623, in _handle_creation_inputs
if not row:

Stacktrace:
[1] pyerr_check at /Users/verzani/.julia/packages/PyCall/ttONZ/src/exception.jl:60 [inlined]
[2] pyerr_check at /Users/verzani/.julia/packages/PyCall/ttONZ/src/exception.jl:64 [inlined]
[3] macro expansion at /Users/verzani/.julia/packages/PyCall/ttONZ/src/exception.jl:84 [inlined]
[4] __pycall!(::PyObject, ::Ptr{PyCall.PyObject_struct}, ::PyObject, ::Ptr{Nothing}) at /Users/verzani/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44
[5] _pycall!(::PyObject, ::PyObject, ::Tuple{Array{Array{Int64,1},1}}, ::Int64, ::Ptr{Nothing}) at /Users/verzani/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:29
[6] #_#111 at /Users/verzani/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:11 [inlined]
[7] (::PyObject)(::Array{Array{Int64,1},1}) at /Users/verzani/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89
[8] top-level scope at REPL[9]:1
```

Any chance this can be addressed from `PyCall`?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the Julia reproduction with PyCall v1.91.2 and SymPy 1.5.1, then inspect the stack frames in src/exception.jl and src/pyfncall.jl. Determine whether the failure is in PyCall's argument conversion or error handling; done means the Matrix call has a verified PyCall-side resolution or a clearly documented upstream limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.