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
This RFC proposes to add an API to the standard for querying whether a conforming array library supports behavior which is consider optional in the standard.
Currently, downstream libraries have to use non-standardized workarounds to determine whether optional operations are possible, such as when wanting to use a boolean mask or invoke an API having a data-dependent output shape (e.g., nonzero, unique*, etc).
This RFC proposes to add an API which allows explicitly querying whether an optional operation is supported.
Prior art
As this is a behavior specific to the array API standard, no prior art exists.
If not provided an argument, the function would return a dictionary with the following keys:
boolean_indexing: does an array library support boolean indexing?
data_dependent_shapes: does an array library support data-dependent output shapes?
More keys could be added in the future, depending on evolution of the standard. The corresponding keys would be boolean values indicating whether the respective optional behavior is supported.
If provided an argument, the function would return a boolean indicating whether an array library supports a specific optional behavior. E.g.,
>>>b=xp.capabilities("boolean_indexing")
Notes
Bikeshed: different name than capabilities?
This RFC proposes a function for querying capabilities, rather than attributes, in order to minimize cluttering the main namespace. Additionally, the function can be more readily extended in the future should additional optional behaviors be added to the standard.
The proposed function supports returning a dictionary for easier inspection in scripts, REPL envs, and when wanting to query support for multiple behaviors. The unary function behavior is a convenience API to avoid unnecessary dictionary creation.
In yesterdays consortium meeting @seberg floated the idea of a single function(?) like capabilities() that could encapsulate everything, in the interest of limiting API bloat. This could include: devices, dtypes, library defaults, and indeed these optional capabilities.
I was actually thinking more of a namespace like namespace.__array_api_info__.<entrypoint>. capabilities might then also be a flag enum or so; that can't capture everything, but it would give you a place to encapsulate other things into a function without cluttering things up.
I don't mind a top-level function, but might be hard to convince if unless one of the two constraints is fullfilled:
The function is limited to arr.__array_namespace__ for NumPy and nobody aims for it to be in numpy.<name> proper (I really don't mind those namespaces being different),
or it is really useful for a wide audience (including end-users who would only ever use NumPy).
This RFC proposes to add an API to the standard for querying whether a conforming array library supports behavior which is consider optional in the standard.
Currently, downstream libraries have to use non-standardized workarounds to determine whether optional operations are possible, such as when wanting to use a boolean mask or invoke an API having a data-dependent output shape (e.g.,
nonzero
,unique*
, etc).This RFC proposes to add an API which allows explicitly querying whether an optional operation is supported.
Prior art
As this is a behavior specific to the array API standard, no prior art exists.
Proposal
If not provided an argument, the function would return a dictionary with the following keys:
More keys could be added in the future, depending on evolution of the standard. The corresponding keys would be boolean values indicating whether the respective optional behavior is supported.
If provided an argument, the function would return a boolean indicating whether an array library supports a specific optional behavior. E.g.,
Notes
capabilities
?Related
The text was updated successfully, but these errors were encountered: