Skip to content

Return an empty vector from linspace with zero samples - #949

Merged
tomwhite merged 1 commit into
cubed-dev:mainfrom
dajiaohuang:fix/linspace-empty
Oct 15, 2026
Merged

tomwhite merged 1 commit into
cubed-dev:mainfrom
dajiaohuang:fix/linspace-empty

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

Problem

xp.linspace(2, 8, 0) currently returns a scalar 0.0 with shape () rather than an empty array of shape (0,). This also affects explicit float32 output: the empty result must preserve the requested dtype.

Change

Return an empty one-dimensional array using the existing empty creation function, retaining the normalized chunks, dtype and spec. Add regression coverage for both endpoint settings and float32/float64, checking the public shape, computed shape, dtype and values.

Validation

Python 3.12, NumPy backend, local single-threaded executor:

  • New regression: 4 failures on main, passes with this change.
  • CUBED_SPEC__EXECUTOR_NAME=single-threaded uv run pytest cubed/tests/test_array_api.py cubed/tests/test_indexing.py cubed/tests/test_ops.py cubed/tests/test_store.py -q: 292 passed, 2 skipped.
  • git diff --check: passed.

Broader core/optimization testing was attempted but is not green in this environment: Graphviz's dot executable is unavailable, and tests explicitly selecting the threaded executor can exceed the configured aggregate memory budget on this machine. No cloud or optional backend testing was performed.

@tomwhite tomwhite left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The test failures are unrelated.

@tomwhite
tomwhite merged commit efa8d5a into cubed-dev:main Oct 15, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants