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

RFC: allow scalars and 0D arrays in `concat`

Open
#946 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start by reading the existing Array API specification for concat and compare its shape requirements with the scalar and 0D-array examples in this issue. Determine and document the intended behavior and wording for those inputs; the work is done when the RFC reaches an agreed specification change.

Written by the indexing model from the issue text.

Description

API change RFC

The following patterns are quite common [1]: x = np.r_(x[0], x, x[-1]) and x = np.r_[0, x]. Neither of these can be directly replaced by xp.concat because the latter requires that The arrays must have the same shape, except in the dimension specified by axis.
The most common case IME is that x is a 1D array, which gets appended or prepended by a scalar.

An Array API replacement is something along the lines of

def npr(xp, *arys):
    arys = [xp.asarray(a) for a in arys]
    arys = [xpx.atleast_nd(a, ndim=1, xp=xp) for a in arys]
    return xp.concat(arys)

which requires array_api_extra and is generally a bit clunky. There was at least one case where a scipy change which was missing atleast_1d broke jax.scipy.

Allowing 0D arrays and python scalars in concat would obviate the need for these sorts of helpers.

[1] At least in scipy,

$ git grep "np.r_"  |wc -l
169
Dominant language
Python
Stars
281
Forks
52
PR merge metrics
No merged PRs in 30d

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

All issues in data-apis/array-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.