BUG: torch.maximum: does not accept `float` for `x1`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start at scipy/sparse/linalg/_isolve/iterative.py:_get_atol_rtol and trace the vendored array-api-compat 1.14 torch.maximum wrapper shown in the traceback. Reproduce xp.maximum(0.0, tensor) with the affected PyTorch backend and compare its behavior with the linked Array API specification. Done means the documented scalar-and-array call no longer raises this TypeError.
Written by the indexing model from the issue text.
Description
scipy/sparse/linalg/_isolve/iterative.py:25: in _get_atol_rtol
atol = xp.maximum(atol, rtol * b_norm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
atol = 0.0
b_norm = tensor([], size=(0, 1), dtype=torch.float32)
name = 'cg'
rtol = 0.0015
xp = <module 'scipy._external.array_api_compat.torch' from '/Users/lucascolley/ghq/github.com/scipy/scipy/build-cpu-install/usr/lib/python3.13/site-packages/scipy/_external/array_api_compat/torch/__init__.py'>
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x1 = 0.0, x2 = tensor([], size=(0, 1), dtype=torch.float32), kwargs = {}
@_wraps(f)
def _f(x1, x2, /, **kwargs):
x1, x2 = _fix_promotion(x1, x2)
> return f(x1, x2, **kwargs)
^^^^^^^^^^^^^^^^^^^
E TypeError: maximum(): argument 'input' (position 1) must be Tensor, not float
This is with array-api-compat at the vendored 1.14 tag in SciPy.
This contradicts https://data-apis.org/array-api/2025.12/API_specification/generated/array_api.maximum.html#maximum.
- Dominant language
- Python
- Stars
- 131
- Forks
- 49
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 6
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.
More from data-apis/array-api-compat
-
blocked by upstream
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
data-apis/array-api-compat#439 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
data-apis/array-api-compat#395 · 2 comments ·
-
Release 1.16 Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
data-apis/array-api-compat#476 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
data-apis/array-api-compat#473 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
data-apis/array-api-compat#465 · 3 comments ·
All issues in data-apis/array-api-compat
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100