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

Dask.array tracks dtypes when possible #87

Merged
merged 4 commits into from Mar 24, 2015
Merged

Conversation

mrocklin
Copy link
Member

The Array class now holds a _dtype attribute. Various dask.array functions
propagate dtype information, repeating a bit of numpy logic where necessary.

If this logic fails then we fall back on computation of a small element of the
dask array.

Fixes #64

cc @shoyer

The Array class now holds a `_dtype` attribute.  Various dask.array functions
propagate dtype information, repeating a bit of numpy logic where necessary.

If this logic fails then we fall back on computation of a small element of the
dask array.

Fixes dask#64
@@ -465,6 +469,8 @@ def __len__(self):

@property
def dtype(self):
if self._dtype is not None:
return self._dtype
if self.shape:
return self[(0,) * self.ndim].compute().dtype
Copy link
Member

Choose a reason for hiding this comment

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

Can you cache the dtype if you need to calculate it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Note though that I think we've covered most of the operations. I haven't yet done ones, zeros, and da.random, but I think that this PR covers most things.

mrocklin added a commit that referenced this pull request Mar 24, 2015
Dask.array tracks dtypes when possible
@mrocklin mrocklin merged commit d64928f into dask:master Mar 24, 2015
@mrocklin mrocklin deleted the track-dtypes branch March 24, 2015 23:32
@mrocklin mrocklin mentioned this pull request Mar 25, 2015
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.

Dask.array dtype tracking to match numpy
2 participants