BUG: polynomial evaluation functions assume numpy array and work inconsistently with other array types
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
Describe the issue:
The following code works with numpy arrays, lists and tuples but breaks on jax.numpy arrays for example:
Reproduce the code example:
This results in inconsistent behavior:
>>> from numpy.polynomial import polynomial as poly
>>> b = jax.numpy.array(
[[1, 2, 3],
[2, 3, 4]]
)
>>> poly.polyval(np.array(b),np.array(b), tensor=True)
array([[[ 3., 5., 7.],
[ 5., 7., 9.]],
[[ 5., 8., 11.],
[ 8., 11., 14.]],
[[ 7., 11., 15.],
[11., 15., 19.]]])
>>> poly.polyval(b,b, tensor=True)
Array([[ 3., 8., 15.],
[ 5., 11., 19.]], dtype=float32)
Python and NumPy Versions:
>>> import sys, numpy; print(numpy.__version__); print(sys.version)
2.3.2
3.13.7 (v3.13.7:bcee1c32211, Aug 14 2025, 19:10:51) [Clang 16.0.0 (clang-1600.0.26.6)]
Context for the issue:
It may be a better idea to check for the attribute .ndim that is used afterwards or the attribute __array__ to identify an Array-Like.
I would be willing to make a Pull request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at numpy/polynomial/polynomial.py around the linked lines in the polynomial evaluation functions. Reproduce the examples with NumPy and JAX arrays, then inspect the surrounding handling of array-like inputs and existing related tests. Done means array-like inputs receive consistent polynomial evaluation behavior without breaking NumPy arrays, lists, or tuples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100