BUG: Don't import helpers in namespaces#302
Conversation
6c4a75d to
65fd5f4
Compare
| 'matrix_transpose', 'svdvals', 'vecdot', 'vector_norm', 'diagonal', | ||
| 'trace'] | ||
|
|
||
| _all_ignore = ['math', 'normalize_axis_tuple', 'get_xp', 'np', 'isdtype'] |
There was a problem hiding this comment.
No idea why test_all wasn't failing before.
There was a problem hiding this comment.
Yeah, test_all is a bit brittle. At a guess, its iterating over sys.modules is meant to be robust against renames/new private submodules in array_api_compat/*. But then it's not easy to know if something was or was not imported.
65fd5f4 to
2c1cb6b
Compare
|
This is ready for review. |
| all = xp.all if library != 'dask.array' else lambda x: xp.all(x).compute() | ||
|
|
||
| if library == 'numpy' and xp.__version__[0] < '2' and not hasattr(xp, '_CopyMode') : | ||
| if library == 'numpy' and xp.__version__[0] < '2' and not hasattr(np, "_CopyMode"): |
There was a problem hiding this comment.
FYI this is for numpy 1.21
ev-br
left a comment
There was a problem hiding this comment.
Looks good. +1 for not needing a deprecation layer. Thanks @crusaderky
| 'matrix_transpose', 'svdvals', 'vecdot', 'vector_norm', 'diagonal', | ||
| 'trace'] | ||
|
|
||
| _all_ignore = ['math', 'normalize_axis_tuple', 'get_xp', 'np', 'isdtype'] |
There was a problem hiding this comment.
Yeah, test_all is a bit brittle. At a guess, its iterating over sys.modules is meant to be robust against renames/new private submodules in array_api_compat/*. But then it's not easy to know if something was or was not imported.
Remove helper functions from wrapped array namespaces.
This was introduced when the numpy namespace was split from the helpers in 2022 (b3a12d9).
This PR prompted by a collision between
array_api_compat.deviceandtorch.device.Re. deprecation layer: unsure if we need one? This was never advertised in the documentation.