-
Notifications
You must be signed in to change notification settings - Fork 53
Consistent default integer and floating-point types #151
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
Comments
I can't find any functions that actually permit |
Even without dtype=int, there's still ambiguity for creation functions that can take Python scalars, like Regarding the question of consistency of the same library on different platforms, does it make sense to allow a library to have different defaults depending on what architecture it is compiled on? |
I suppose @asmeurer you are saying in addition to having a default integer type and a float type, each library should also decide if the default (when nothing is given) is an integer or a float?
This is unfortunately what NumPy decides currently, and sometimes users don't even get to say "I don't wanna set |
No, I think asarray(1) should definitely have an integer dtype. But which integer dtype should it be? All it says is "If |
Ah ok, thanks for clarifying Aaron. I agree with your interpretation. Currently the standard only touches the rules mixing a Python type and an array dtype, but doesn't clearly define how to handle them in the creation functions. |
This should be addressed in gh-167. I did put in one exception for default integers: for 32-bit vs. 64-bit Python. It's possible to avoid too of course, but it'd be a fairly large change for limited benefit. So "may vary" on 32-bit seems okay. |
* Update specification for arange Addresses comments in gh-85 and gh-107 * Update the specification for `full` and `full_like` Addresses comments in gh-85 and gh-107 * Update specification for `linspace` Addresses comments in gh-85 and gh-107 * Update specification for `empty`, `ones`, `zeros` Addresses comments in gh-85 and gh-107 * Update specification for `eye` This is useful/needed because `M` is not a descriptive name and that name does not match between different array libraries. * Update specification for `expand_dims`, `roll` and `reshape` Address comment in gh-85 * One more change to `eye`, more descriptive positional arguments * Address the default integer dtype issue for 32/64-bit Python Closes gh-151 * Update signature of `broadcast_to` Address a review comment; makes it consistent with other functions using `shape`.
In today's call we discussed that the current Array API standard does not regulate the default integer and floating-point types across all implementations, only that each implementation should pick one, document clearly and stick to it. However, this is not strong enough, as there could be cross-platform/portability issues.
For example, NumPy is inconsistent in handling the Python integers between Windows and Linux:
Similar issues can be found in other APIs.
It's worth noting that as pointed out by @kgryte, the standard does not permit passing
dtype=int
to most of the functions, so this could eliminate a large class of such inconsistencies. But it's still good to be explicit in the standard to ensure portability.The text was updated successfully, but these errors were encountered: