-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
randint
accept ints for 'size'
#916
Conversation
Codecov Report
@@ Coverage Diff @@
## master #916 +/- ##
=======================================
Coverage 95.49% 95.49%
=======================================
Files 64 64
Lines 9793 9796 +3
=======================================
+ Hits 9352 9355 +3
Misses 441 441
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @mtar for looking into this right away! I found another inconsistency vs. numpy, see comments.
shape = (int(size),) | ||
else: | ||
if not all(ele > 0 for ele in shape): | ||
raise ValueError("negative dimensions are not allowed") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of addressing this like we do for shape
in ht.reshape()
:
def reshape(a: DNDarray, *shape: Union[int, Tuple[int, ...]], **kwargs) -> DNDarray:
...
Default size
should be 0
, not None
. Here a numpy example:
>>> d = np.random.randint(0,50)
>>> d
1
>>> d = np.random.randint(0,50, 1)
>>> d
array([0])
>>> e = ht.random.randint(0,50)
>>> e
DNDarray([9], dtype=ht.int32, device=cpu:0, split=None) # ndim=1 but should be 0!
# size parameter allows int arguments | ||
a = ht.random.randint(1, size=10, split=0, dtype=ht.int64) | ||
self.assertTrue(ht.equal(a, b)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests where no size is specified and scalar is returned?
run tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks @mtar !
Description
Issue/s resolved: #913
Changes proposed:
Type of change
Memory requirements
n/a
Performance
n/a
Due Diligence
Does this change modify the behaviour of other functions? If so, which?
no