Skip to content

BUG: torch.maximum: does not accept float for x1 #410

@lucascolley

Description

@lucascolley
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions