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, at least without creating a whole new namespace.
Because of this, I propose adding a supports_extension
function and/or supported_extensions
attribute to the spec, so that
from array_api_compat import array_namespace
def cross(x, y):
xp = array_namespace(x, y)
if xp.supports_extension('linalg'):
return xp.linalg.cross(x, y)
is possible.
Alternatively:
from array_api_compat import array_namespace
def cross(x, y):
xp = array_namespace(x, y)
if 'linalg' in xp.extensions:
return xp.linalg.cross(x, y)
In the meantime, I created data-apis/array-api-compat#332 for array-api-compat
to deal with this problem, but I think this makes more sense as part of the spec.