You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the numpy.array_api namespace because it follows the API standard closely.
Is there a different (better) way of setting values of an array using integer (array) indices that adhere to the 2021.12 version of the array API standard?
For the example I gave, I'm aware that I can do something like this (but not with numpy.array_api namespace, as it only supports v2021.12):
But I have other cases in my codebase that follow the first pattern - looping through array indices and using basic indexing to set array values. For example, using the indices from xp.argsort to mark the top-k values. Is there a better way than looping through the indices?
The text was updated successfully, but these errors were encountered:
There's a plan to add a guide for this sort of thing to the standard data-apis/array-api#668, although there's nothing there yet for alternatives to integer indexing. Most likely your best bet is to just manually use put or integer indexing for libraries that you know have that functionality.
(In NumPy, you could use out=... to force whichever dtype you want on the result, which should be faster when arrays are large, but also adds a fair bit of overhead.)
On a few occasions while using this library, I've bumped against the issue having to set array values using advanced indexing. Here is an example:
I'm using the
numpy.array_api
namespace because it follows the API standard closely.Is there a different (better) way of setting values of an array using integer (array) indices that adhere to the 2021.12 version of the array API standard?
For the example I gave, I'm aware that I can do something like this (but not with
numpy.array_api
namespace, as it only supports v2021.12):But I have other cases in my codebase that follow the first pattern - looping through array indices and using basic indexing to set array values. For example, using the indices from
xp.argsort
to mark the top-k values. Is there a better way than looping through the indices?The text was updated successfully, but these errors were encountered: