Skip to content
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

numpy.random.randint complaints about missing positional argument. #12933

Open
thakkardharmik opened this issue Feb 5, 2019 · 2 comments
Open

Comments

@thakkardharmik
Copy link

When the dtype is specified in the call to numpy.random.randint, we should set the default value for low based on the datatype. Currently the call does not support creating random int just by specifying the datatype of the random value.

RAND_MAPPING = {
    'TINYINT': np.random.randint(dtype=np.int8),
    'SMALLINT': np.random.randint(dtype=np.int16)
}
for k in range(20):
    print(RAND_MAPPING['TINYINT'])

Error stack -

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-79-67fec5a70990> in <module>()
     12 
     13 RAND_MAPPING = {
---> 14     'TINYINT': np.random.randint(dtype=np.int8),
     15     'SMALLINT': np.random.randint(dtype=np.int16)
     16 }

mtrand.pyx in mtrand.RandomState.randint()

TypeError: randint() takes at least 1 positional argument (0 given)

We should be able to generate random number just specifying datatype.

@bashtage
Copy link
Contributor

The default value for low is 0. The one parameter configuration sets high.

If a 0 positional parameter version was possible, it would have to sample on [0,iinfo(dtype).max], not [iinfo(dtype).min, iinfo(dtype).max].

@ihnorton
Copy link
Contributor

ihnorton commented Aug 3, 2019

related to #9573

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

No branches or pull requests

3 participants