-
Notifications
You must be signed in to change notification settings - Fork 67
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
Create a cast method for Arrays? #291
Comments
Probably should be called The numpy method has a ‘no’ means the data types should not be cast at all. [Not sure what the point of this option is!] From experimentation, if it doesn't have room to store the full value it simple truncates the binary representation, so for example an int of 2000 becomes an uint8 of 208, which is not exactly obvious or helpful (but admittedly will be fast!) If you ask for Maybe our options should be:
The others are more checks on the dtypes, rather than the data, which the user can easily do themselves. If there are two options that boils down to a flag:
Which is back to where we started. |
It might be cool to allow the clip to happen as a function call. This would allow it to be used more widely, for example when performing other ops on Arrays. Right now it's hard to add a flag to a
Perhaps better would be If we could, the astype would be just |
is perhaps more obvious and easier to actually code. |
|
Changing the dtype of an Array just changes the interpretation of the underlying data. This is fine, and is a O(1) operation which fits with changing a property, but some users might want or expect it to recast the data to the new type.
To cast to a new dtype you need to do this:
which is OK, and explicit, but adding a new method could make it clearer and give more options:
I don't think it's good to do it in place - there's no performance gain. We can now also deal with things like overflows better:
so the user can choose whether to get a
ValueError
or to clip values or whatever (divide by zero would be another one).The text was updated successfully, but these errors were encountered: