Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

several `torch` binary functions don't accept scalars for one argument

Open
#271 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, pytorch
Domain
api

Research direction

Start with the torch-backed xp.minimum, xp.maximum, and xp.copysign entry points shown in the issue, then compare their scalar handling with the 2024.12 Array API standard. Check the related binary functions for the same mismatch; done means scalar arguments work in either position without the reported TypeErrors.

Written by the indexing model from the issue text.

Description

blocked by upstream

Per the 2024.12 standard, these should work, but don't:

from array_api_compat import torch as xp
xp.minimum(xp.asarray(1), 2)  # TypeError: minimum(): argument 'other' (position 2) must be Tensor, not int
xp.minimum(2, xp.asarray(1))  # TypeError: minimum(): argument 'input' (position 1) must be Tensor, not int
xp.copysign(xp.asarray(1.), 2)  # OK
xp.copysign(2, xp.asarray(1.))
# TypeError: copysign() received an invalid combination of arguments - got (int, Tensor), but expected one of:
#  * (Tensor input, Tensor other, *, Tensor out = None)
#  * (Tensor input, Number other, *, Tensor out = None)

Looks like maximum also has trouble. Haven't checked the rest of the functions that now accept scalars, but I assume others may have trouble.

Dominant language
Python
Stars
131
Forks
49
Avg merge
2d 8h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api-compat

All issues in data-apis/array-api-compat

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.