cubed icon indicating copy to clipboard operation
cubed copied to clipboard

Move main array namespace

Open tomwhite opened this issue 2 years ago • 4 comments

Currently all the array functions are in cubed.array_api. This was created to follow the naming pattern for the new array API in numpy.array_api. Since then, however, there has been a change in emphasis to view numpy.array_api as a reference implementation so downstream libraries can test if they are using only array API functions - it is no longer recommended for end users to use it directly, since array libraries are slowly migrating their main namespaces to implement the array API. This includes NumPy in version 2.0, and in the meantime there is array-api-compat to ease migration for users of NumPy, CuPy, and PyTorch.

The upshot for Cubed is that we should probably move away from cubed.array_api for the above reasons, but also so we can add new functions that are not yet standardised, such as nansum (see #153).

The two options I see are:

  1. cubed
  2. cubed.array

Thoughts?

tomwhite avatar Sep 13 '23 09:09 tomwhite

The two options I see are:

  1. cubed
  2. cubed.array

Thoughts?

Either seems fine. (2) might be slightly better, because it would follow dask.array, and separate out the namespace for cubed things that aren't actually array operations (e.g. Spec).

EDIT: On the other hand dask.array only really exists because you can have dask collections that are not arrays, which wouldn't make sense for cubed...

TomNicholas avatar Sep 18 '23 14:09 TomNicholas

I went through the same thought process: cubed.array following dask.array, but then thinking that actually cubed is appropriate as Cubed is just an array library.

tomwhite avatar Sep 19 '23 08:09 tomwhite

Another very good explanation of the decision to move away from the separate array_api namespace pattern: https://github.com/numpy/numpy/issues/23883#issuecomment-1851429299

tomwhite avatar Dec 12 '23 20:12 tomwhite

That's really interesting.

Related: I would like to test cubed(/pint/sparse/every other array library) by using hypothesis.extra.array_api.make_strategies_namespace, which requires passing in the array-API-compliant namespace directly. See these docs (just released in the latest version of xarray) for an explanation of what I'm talking about.

TomNicholas avatar Dec 13 '23 19:12 TomNicholas