-
-
Notifications
You must be signed in to change notification settings - Fork 748
Numpy dtypes #636
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 dtypes #636
Conversation
494d2f5 to
d49dc77
Compare
jreback
left a comment
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.
should test m8 as well (timedelta)
|
Added m8 tests. Thanks @jreback . Any other suggestions? |
| 'strides': x.strides, | ||
| 'shape': x.shape} | ||
|
|
||
| data = x.view('u1').data |
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'm a little nervous about using view with a different dtype itemsize. See this warning from the docs:
For a.view(some_dtype), if some_dtype has a different number of bytes per entry than the previous dtype (for example, converting a regular array to a structured array), then the behavior of the view cannot be predicted just from the superficial appearance of a (shown by print(a)). It also depends on exactly how a is stored in memory. Therefore if a is C-ordered versus fortran-ordered, versus defined as a slice or transpose, etc., the view may give different results.
It might be just fine for merely getting access to the data buffer, though.
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.
Yeah, I think that these would all be tricky situations if the itemsizes were relatively prime or if you actually cared about indexing afterwards. I think we're safe turning it into a view of singleton bytes though.
|
numpy scalars e.g. np.array(5) |
|
maybe big/little endian e.g. >i8 and <i8 |
Fixes #635
cc @shoyer