-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
allow formatting the diff of ndarray attributes #3728
Conversation
I think a unit test for the use case is in order? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the test which helped me find the warning raised when comparing arrays with different shapes
def is_array_like(value): | ||
return ( | ||
hasattr(value, "ndim") | ||
and hasattr(value, "shape") | ||
and hasattr(value, "dtype") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure if this is how array_like
is defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable at the moment; unless anyone knows better?
This could move into utils if we get more confident (almost surprised we don't do this test elsewhere...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have mostly been using __array_function__
instead, but that is not really sufficient: pint
defines __array_function__
even if it wraps python scalars. In that case pint.Quantity
is not array-like.
should be ready to merge, too |
Looks great! Thanks! |
Thanks @keewis |
…under * upstream/master: (71 commits) Optimize isel for lazy array equality checking (pydata#3588) pin msgpack (pydata#3793) concat now handles non-dim coordinates only present in one dataset (pydata#3769) Add new h5netcdf backend phony_dims kwarg (pydata#3753) always use dask_array_type for isinstance calls (pydata#3787) allow formatting the diff of ndarray attributes (pydata#3728) Pint support for variables (pydata#3706) Format issue template comment as md comment (pydata#3790) Avoid running test_open_mfdataset_list_attr without dask (pydata#3780) remove seaborn.apionly compatibility (pydata#3749) Python 3.8 CI (pydata#3727) PKG: Explicitly add setuptools dependency (pydata#3628) update whats-new Typo in Universal Functions section (pydata#3663) Release v0.15.0 fix setup.cfg Documentation fixes (pydata#3732) Remove extra && in PR template (pydata#3730) Remove garbage text inserted in DASK_LICENSE (pydata#3729) Avoid unsafe use of pip (pydata#3726) ...
This allows to have
ndarray
instances in attributes, which is the case for the dataset fromxarray/tests/data/example.uamiv
. It won't fix the cause for the error of #3711, though, because that seems to non-deterministic.isort -rc . && black . && mypy . && && flake8
whats-new.rst
for all changes andapi.rst
for new API