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

Add dtype= parameter to da.random.randint #4753

Merged
merged 2 commits into from Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions dask/array/random.py
Expand Up @@ -331,8 +331,8 @@ def power(self, a, size=None, chunks="auto"):
return self._wrap('power', a, size=size, chunks=chunks)

@doc_wraps(np.random.RandomState.randint)
def randint(self, low, high=None, size=None, chunks="auto"):
return self._wrap('randint', low, high, size=size, chunks=chunks)
def randint(self, low, high=None, size=None, chunks="auto", dtype='l'):
return self._wrap('randint', low, high, size=size, chunks=chunks, dtype=dtype)

@doc_wraps(np.random.RandomState.random_integers)
def random_integers(self, low, high=None, size=None, chunks="auto"):
Expand Down
7 changes: 7 additions & 0 deletions dask/array/tests/test_random.py
Expand Up @@ -318,3 +318,10 @@ def test_auto_chunks():
with dask.config.set({'array.chunk-size': '50 MiB'}):
x = da.random.random((10000, 10000))
assert 4 < x.npartitions < 32


def test_randint_dtype():
x = da.random.randint(0, 255, size=10, dtype='uint8')
assert_eq(x, x)
assert x.dtype == 'uint8'
assert x.compute().dtype == 'uint8'