-
-
Notifications
You must be signed in to change notification settings - Fork 324
Return scalar when accessing zero dimensional array #2718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return scalar when accessing zero dimensional array #2718
Conversation
Do we want to return scalars when accessing zero-dimensional arrays? This would mean that the return value of |
To copy what numpy does (see #2713 (comment)), I think we do want to return a scalar. |
@d-v-b what do you think about |
# Conflicts: # src/zarr/api/synchronous.py
# Conflicts: # tests/test_api.py
…2718) * Return scalar when accessing zero dimensional array * returning npt.ArrayLike instead of NDArrayLike because of scalar return values * returning npt.ArrayLike instead of NDArrayLike because of scalar return values * fix mypy in tests * fix mypy in tests * fix mypy in tests * improve test_scalar_array * fix typo * add ScalarWrapper * use ScalarWrapper as NDArrayLike * Revert "fix mypy in tests" * Revert "fix mypy in tests" This reverts commit 75d6cdf. * Revert "fix mypy in tests" This reverts commit 34bf260. * format * Revert "returning npt.ArrayLike instead of NDArrayLike because of scalar return values" This reverts commit 1a290c7. * Revert "returning npt.ArrayLike instead of NDArrayLike because of scalar return values" This reverts commit 3348439 * fix mypy for ScalarWrapper * add missing import NDArrayLike * ignore unavoidable mypy error * format * fix __array__ * extend tests * format * fix typing in test_scalar_array * add dtype to ScalarWrapper * correct dtype type * fix test_basic_indexing * fix test_basic_indexing * fix test_basic_indexing for dtype=datetime64[Y] * increase codecov * fix typing * document changes * move test_scalar_wrapper to test_buffer.py * remove ScalarWrapper usage * create NDArrayOrScalarLike * fix NDArrayOrScalarLike * fix mypy * fix mypy * fix mypy * fix mypy in asynchronous.py * fix mypy in test_api.py * fix mypy in test_api.py and synchronous.py * fix mypy in test_api.py and test_array.py * fix mypy in test_array.py * fix mypy in test_array.py * fix mypy in test_array.py * fix mypy in test_array.py * fix mypy in test_array.py, test_api.py, test_buffer.py, test_sharding.py * add bytes, str and datetime to ScalarType * only support numpy datetime64 in ScalarType * remove ScalarWrapper and update changes * undo wrong code changes * rename ``NDArrayOrScalarLike`` to ``NDArrayLikeOrScalar`` * rename ``NDArrayOrScalarLike`` to ``NDArrayLikeOrScalar`` * fix mypy in test_array.py * fix mypy in test_array.py * handle datetype scalars for different units * fix mypy * fix mypy * format
()
indexing/size behavior from v2->v3 #27130-dimensional arrays are now returning a scalar. Therefore, the return type of
__getitem__
changedto NDArrayOrScalarLike. This change is to make the behavior of 0-dimensional arrays consistent with
numpy
scalars.TODO:
docs/user-guide/*.rst
changes/