-
Notifications
You must be signed in to change notification settings - Fork 618
Description
The Array API has had it's first spec release 2021.12
a while now. The next release will add complex numbers, which would be nice to support in extra.array_api
.
We could give make_strategies_namespace()
say a new kwarg called api_version
, to parallel how x.__array_namespace__()
works in returning an Array API namespace of a particular version... I think any solution like this is something we'd like to avoid 😅
Good thing is I think it's okay to just ignore versioning until we need to (which I don't think we ever will, as the parts of the Array API we do use seems pretty stable). I propose we still can only return one namespace, where we
- Generates complex dtype objects in
xps.numeric_dtypes()
, as per how "numeric" is treated in the draft spec. This would still work ifxp
doesn't have complex dtype objects, but would warn and thus is probably considered a breaking change. - Introduce
xps.real_dtypes()
to generate integer and floating-point dtype objects, as per how "real" is treated in the draft spec. This essentially would take over the previous role ofxps.numeric_dtypes()
. - Introduce
xps.complex_dtypes()
to generate complex dtypes. - Support generating complex values in
xps.from_dtype()
. This won't be a breaking change. Allow subnormal in complex_numbers #3409 should mean the hard part is already over with 🚀
First note: There was some explicit deliberation in Array API's semantic model of "numeric" and "real" (data-apis/array-api#418 (comment)). I think it should be safe to follow, and generally makes sense.
Second note: I think it's ultimately okay to make the somewhat breaking change to xps.numeric_dtypes()
, given we note in the extra.array_api
docs that
The Array API standard is not yet finalised, so this module will make breaking changes if necessary to support newer versions of the standard.
Although the Array API now has a finalised first release, we hadn't removed this note, and generally we hadn't settled that extra.array_api
was now "stable". I think we don't have many users beyond array-api-tests
anywho heh.
I do see that the v1 spec doesn't define complex dtypes as "numeric" (they're not listed anyway), or have any "real-valued" category. Still, I think it'll be fine to just clarify in the xps.numeric_dtypes()
docstring what "sub-categories" (ints, uints, floats and complex) are included. I also think after complex support is added in v2 that these categories should be "stable".
Of course I'll be happy to make a PR once we settle on a general direction~