[BUG] Indexing inconsistencies
Describe the bug
mlx.core.newaxisis missing:
>>> mx.array([1])[mx.newaxis]
AttributeError: module 'mlx.core' has no attribute 'newaxis'
- Cannot index with
Ellipsis/...:
>>> mx.array([1])[...]
ValueError: Cannot index mlx array using the given type.
To Reproduce
See above.
Expected behavior
Consistency with NumPy.
Desktop (please complete the following information): v0.0.7
Cool, I don't mind adding that though I find it a bit odd how numpy has different syntax for the same thing.
In mx we went with None for adding new axes (which numpy aslo has). So you can do:
mx.array([1])[None]`
I think for this we could bind a little axis type in pybind11 and then use it in the same place we us None.
No need. np.newaxis is an alias for None, meaning that np.newaxis is None returns True. All we have to do is add an alias as mx.newaxis = None if we want full numpy compatibility.
@awni @angeloskath Hi, can I pick this up?
Yes sure!
@awni should I add all the constant that numpy offers? https://numpy.org/doc/stable/reference/constants.html
I was thinking of adding a init_constants(m) in mlx/python/src/mlx.cpp
@awni @angeloskath fixed in https://github.com/ml-explore/mlx/pull/428
can you folks take a look at the PR
Sent a comment, but o/w looks great, thanks for adding thos!