Skip to content
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

Merged
merged 3 commits into from
Feb 23, 2020

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Jan 29, 2020

This allows to have ndarray instances in attributes, which is the case for the dataset from xarray/tests/data/example.uamiv. It won't fix the cause for the error of #3711, though, because that seems to non-deterministic.

@crusaderky
Copy link
Contributor

I think a unit test for the use case is in order?

Copy link
Collaborator Author

@keewis keewis left a 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

Comment on lines +503 to +508
def is_array_like(value):
return (
hasattr(value, "ndim")
and hasattr(value, "shape")
and hasattr(value, "dtype")
)
Copy link
Collaborator Author

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

Copy link
Collaborator

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...)

Copy link
Collaborator Author

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.

@keewis
Copy link
Collaborator Author

keewis commented Feb 5, 2020

should be ready to merge, too

@max-sixty
Copy link
Collaborator

Looks great! Thanks!

@dcherian dcherian merged commit 858eba6 into pydata:master Feb 23, 2020
@dcherian
Copy link
Contributor

Thanks @keewis

@keewis keewis deleted the fix-diff-attributes branch February 24, 2020 11:23
dcherian added a commit to johnomotani/xarray that referenced this pull request Feb 24, 2020
…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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants