Skip to content

Conversation

@bashtage
Copy link

Add closed option to randint to simplify some cases

Add closed option to randint to simplify some cases
@mattip
Copy link
Owner

mattip commented Apr 16, 2019

Can we hold off on this until after we first merge randomgen to numpy? I would hate for the merge to get bogged down in discussions of the merit of this enhancement. Or was there consensus around adding this kwarg to randint?

@bashtage
Copy link
Author

bashtage commented Apr 16, 2019 via email

@bashtage
Copy link
Author

bashtage commented Apr 16, 2019 via email

raise ValueError('high is out of bounds for {{nptype}}')
if np.any(np.greater_equal(low_arr, high_arr)):
if np.any(low_high_comp(low_arr, high_arr)):
raise ValueError('low >= high')

Choose a reason for hiding this comment

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

This error message doesn't match the comparator

Copy link
Author

Choose a reason for hiding this comment

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

I think that string probably needs to be dynamic and change depending on whether closed or not.

Copy link
Author

Choose a reason for hiding this comment

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

low=high is ok for closed, but only low<high for open.

Copy link
Author

Choose a reason for hiding this comment

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

This has been fixed.

Use correct error message when usign a closed interval
@bashtage
Copy link
Author

I pushed some small changes in response to the feedback above. This is needed since the closed interval is in the API through integers(low, high, endpoint=True), which is just a refactor once this is in.

@mattip
Copy link
Owner

mattip commented May 13, 2019

In light of the discussion, I would like to put this in now. Any objections?

@bashtage
Copy link
Author

It failed on my Travis, FWIW. It is failing due to changes in pytest.

https://travis-ci.org/bashtage/numpy/builds/531943929

@mattip
Copy link
Owner

mattip commented May 13, 2019

FWIW. It is failing due to changes in pytest.

numpy#13550 should fix that

@mattip mattip merged commit 6857219 into mattip:randomgen May 13, 2019
@bashtage bashtage deleted the closed-interval branch May 16, 2019 10:36
mattip pushed a commit that referenced this pull request Nov 15, 2023
Merge in numpy-hpy from ss/array_array3 to labs-hpy-port

* commit 'a197852c5099cec81ed8cdfde0a59a29316db2a3':
  hpy_raw_array_assign_scalar
  HPyArray_AssignRawScalar and HPyArray_EquivTypes
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.

3 participants