Skip to content

Make "stop" optional in arange - #3982

Merged
zcbenz merged 1 commit into
ml-explore:mainfrom
aaishwarymishra:arange-fix
Aug 5, 2026
Merged

Make "stop" optional in arange#3982
zcbenz merged 1 commit into
ml-explore:mainfrom
aaishwarymishra:arange-fix

Conversation

@aaishwarymishra

@aaishwarymishra aaishwarymishra commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Please include a description of the problem or feature this PR is addressing. If there is a corresponding issue, include the issue #.

This pull request updates the arange function in the Python bindings to better match the behavior of NumPy by making the stop parameter optional. If stop is not provided, start is treated as the stopping value and the range starts from zero. The changes also update the function signature, documentation, and add a test to verify the new behavior.

Enhancements to arange argument handling:

  • Changed the arange function so that stop is now optional (std::optional<Scalar>). If only one argument is provided, it is treated as stop and start defaults to zero, matching NumPy's behavior.
  • Updated the function signature in the Python binding to reflect that stop can be None.

Documentation updates:

  • Modified the docstring to indicate that stop is now optional.

Testing improvements:

  • Added a test case to ensure that calling arange with stop=None produces the correct output.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

Part of the data-apis/array-api-compat#452 .

@zcbenz zcbenz changed the title enhancement: added None support for stop in arange Make "stop" optional in arange Aug 4, 2026
@zcbenz
zcbenz merged commit 0268c81 into ml-explore:main Aug 5, 2026
28 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