Description
Right now, the dask library has a linalg
attribute, but doesn't currently implement the entire linalg extension spec. The lack of full support is mentioned here: https://data-apis.org/array-api-compat/supported-array-libraries.html
This means that an array api library consumer can't do
if hasattr(xp, 'linalg'):
xp.linalg.cross(x, y)
as recommended here,
and work with dask. I suppose this is hard to change for existing array libraries that have such an attribute already. I'm generally thinking that this is best added as part of the array api spec(see data-apis/array-api#950), but in the meantime, a supports_extension(xp, extension_name: str)
in array_api_compat
would be helpful, so that
from array_api_compat import supports_extension
if supports_extension(xp, 'linalg'):
xp.linalg.cross(x, y)
is possible.
Alternatively(or additionally), returning a list might be a good idea:
from array_api_compat import get_supported_extensions
print(get_supported_extensions(xp)) # ['linalg', 'fft'], or [] for dask
if 'linalg' in get_supported_extensions(xp):
xp.linalg.cross(x, y)
(discussed in magpylib/magpylib#844)