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

tests for arrays with units #3238

Merged
merged 117 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
ebcbdaf
create the empty test file
keewis Aug 21, 2019
663d0a2
add tests for data array aggregation functions
keewis Aug 21, 2019
5638c88
include pint in the ci
keewis Aug 22, 2019
46b878f
ignore missing type annotations for pint
keewis Aug 22, 2019
828777f
really skip the tests if pint is not available
keewis Aug 22, 2019
4454331
remove the reason from the importorskip call
keewis Aug 22, 2019
52e4259
test that the dataarray constructor does not strip the unit
keewis Aug 22, 2019
e8ed329
convert every unit stripped warning to an error
keewis Aug 23, 2019
cfee29e
work around pint not implementing np.allclose yet
keewis Aug 23, 2019
4d36292
remove the now unnecessary filterwarnings decorator
keewis Aug 24, 2019
8ab46b7
xfail all tests that depend on pint having a __array_function__
keewis Aug 24, 2019
84002a4
treat nans as equal
keewis Aug 25, 2019
bde6db2
implement tests for simple arithmetic operations
keewis Aug 25, 2019
26bee76
use param's id argument to assign readable names
keewis Aug 25, 2019
e4a44a8
add tests for sel() and isel()
keewis Aug 25, 2019
e087865
add more readable names for the unary arithmetics
keewis Aug 25, 2019
c0fddf6
xfail every test that is not yet xfailing
keewis Aug 25, 2019
a3539a0
only xfail if pint is not the current development version
keewis Aug 25, 2019
f1f21cf
always use lists instead of tuples for indexing
keewis Aug 25, 2019
648087f
add tests for loc and squeeze
keewis Aug 25, 2019
d02cf40
black
keewis Aug 25, 2019
7603ea2
add names and xfail marks to the parameters
keewis Aug 25, 2019
a43313a
add tests for interp and interp_like
keewis Aug 25, 2019
b36041d
implement tests for reindex
keewis Aug 26, 2019
a7f88a2
remove the xfail marks where it is not clear yet that pint is to blame
keewis Aug 26, 2019
32562fe
add tests for reindex_like
keewis Aug 27, 2019
9b51812
don't pass the new DataArray to a kwarg
keewis Aug 27, 2019
2eb12c4
xfail if not on pint dev
keewis Aug 27, 2019
6c27a87
refactor the tests
keewis Aug 30, 2019
da2904a
add tests for univariate and bivariate ufuncs
keewis Aug 30, 2019
e4a006f
black
keewis Aug 30, 2019
c20989d
xfail aggregation only if pint does not implement __array_function__ yet
keewis Sep 1, 2019
ad143f1
Merge branch 'master' into array-with-units-tests
keewis Sep 2, 2019
179baaa
remove the global filterwarnings mark
keewis Sep 3, 2019
927fd9e
add a test case for the repr
keewis Sep 3, 2019
c163aef
create a pytest mark that explicitly requires pint's __array_function__
keewis Sep 3, 2019
1318093
also check the string representation in addition to the repr
keewis Sep 3, 2019
10ee1ae
add helpers for creating method tests
keewis Sep 3, 2019
aa45f5c
check that simple aggregation methods work
keewis Sep 3, 2019
ce2ab54
use format() instead of format strings
keewis Sep 3, 2019
effeffb
make sure the repr of method calls is different from functions
keewis Sep 3, 2019
1fc5f5f
merge the two aggregation tests
keewis Sep 3, 2019
c951ff1
explicitly check whether pint supports __array_function__
keewis Sep 13, 2019
e4e5056
provide a fallback for the new base quantity
keewis Sep 13, 2019
1521d15
check that no warning is raised for both with and without coords
keewis Sep 13, 2019
52e32fe
Merge branch 'master' into array-with-units-tests
keewis Sep 13, 2019
1ecbb37
also check that the repr works both with and without coords
keewis Sep 13, 2019
0fdb011
wrap all aggregation function calls
keewis Sep 13, 2019
67ca69b
xfail every call that fails because of something outside xarray
keewis Sep 13, 2019
0dbf715
xfail tests related to dimension coordinates and indexes
keewis Sep 13, 2019
5908eb6
use the dimensions from the original array
keewis Sep 14, 2019
1140006
allow passing arguments to the method on call
keewis Sep 14, 2019
b4f3516
add tests for comparisons
keewis Sep 14, 2019
3d746f9
add tests for detecting, filling and dropping missing values
keewis Sep 14, 2019
5d5480d
mark the missing value tests as requiring pint to support duck arrays
keewis Sep 15, 2019
3e6de2d
add tests for isin, where and interpolate_na
keewis Sep 15, 2019
190a2f1
reformat unit ids and add a test parameter for compatible units
keewis Sep 15, 2019
55bdcda
remove an unnecessary xfail
keewis Sep 15, 2019
c596572
add tests for the top-level replication functions (*_like)
keewis Sep 15, 2019
98a1f3a
Merge branch 'master' into array-with-units-tests
keewis Sep 15, 2019
f0892ce
check for whatever pint does with *_like functions
keewis Sep 15, 2019
c2dd40a
add tests for combine_first
keewis Sep 15, 2019
a7b0450
xfail the bivariate ufunc tests
keewis Sep 15, 2019
22419c0
xfail the call to np.median
keewis Sep 15, 2019
0d9b6d8
move the top-level function tests out of the DataArray namespace class
keewis Sep 17, 2019
2d8da57
add cumsum and cumprod to the list of aggregation functions
keewis Sep 17, 2019
2015909
add tests for the numpy methods
keewis Sep 17, 2019
0abac1a
check for equal units directly after checking the magnitude
keewis Sep 18, 2019
9f918b8
add tests for content manipulation methods
keewis Sep 18, 2019
38c791b
add tests for comparing DataArrays (equals, indentical)
keewis Sep 19, 2019
4fe23d9
add a test for broadcast_equals
keewis Sep 19, 2019
bc85c3b
Merge branch 'master' into array-with-units-tests
keewis Sep 19, 2019
c5ae6a7
refactor the comparison operation tests
keewis Sep 21, 2019
a04128e
rewrite the strip, attach and assert_equal functions and add extract
keewis Sep 21, 2019
534e329
preserve multiindex in strip and attach
keewis Sep 22, 2019
c556416
attach the unit from element "data" as fallback
keewis Sep 22, 2019
f60326f
fix some small typos
keewis Sep 22, 2019
51d24c7
compare QuantityScalar and QuantitySequence based on their values
keewis Sep 22, 2019
f45ac4d
make the isel test more robust
keewis Sep 22, 2019
56fd07d
add tests for reshaping and reordering
keewis Sep 22, 2019
c97f6da
unify the structure of the tests
keewis Sep 26, 2019
71cb403
mark the remaining tests as requiring a recent pint version, too
keewis Sep 26, 2019
e1f095e
explicitly handle quantities as parameters
keewis Sep 30, 2019
f93ed6d
change the repr of the function / method wrappers
keewis Sep 30, 2019
65f1e80
check whether __init__ and repr / str handle units in data and coords
keewis Oct 1, 2019
328a1de
Merge branch 'master' into array-with-units-tests
keewis Oct 1, 2019
244f6a6
generalize array_attach_units
keewis Oct 3, 2019
e5e31f8
move the redefinition of DimensionalityError
keewis Oct 3, 2019
d613a8a
Merge branch 'master' into array-with-units-tests
keewis Oct 3, 2019
c92972f
identify quantities using isinstance
keewis Oct 3, 2019
90593fd
typo
keewis Oct 3, 2019
20ca149
skip tests with a pint version without __array_function__
keewis Oct 5, 2019
fbb00da
compare DataArrays where possible
keewis Oct 5, 2019
4846de8
mark only the compatible unit as xfailing
keewis Oct 5, 2019
603c554
preserve the name of data arrays
keewis Oct 8, 2019
6e18c67
also attach units to x_mm
keewis Oct 8, 2019
4b4605d
Merge branch 'master' into array-with-units-tests
keewis Oct 8, 2019
ba81871
Test in more CI environments; documentation
crusaderky Oct 9, 2019
52154cc
What's New
crusaderky Oct 9, 2019
10e3249
remove a stale function
keewis Oct 10, 2019
f307ca5
use Quantity directly for instance tests
keewis Oct 10, 2019
ea45c7c
explicitly set roll_coords to silence a deprecation warning
keewis Oct 13, 2019
7252ada
skip the whole module if pint does not implement __array_function__
keewis Oct 14, 2019
cb8d586
allow to attach units using the mapping from extract_units
keewis Oct 14, 2019
9b3473c
add tests for computation methods
keewis Oct 15, 2019
788d6ff
add tests for grouped operations
keewis Oct 15, 2019
a90af42
Merge branch 'master' into array-with-units-tests
keewis Oct 15, 2019
cb8b642
add a test for rolling_exp
keewis Oct 15, 2019
22ba57c
add a todo note for the module level skip on __array_function__
keewis Oct 15, 2019
b321d45
add a test for dot
keewis Oct 15, 2019
c499e5c
use attach_units instead of manually attaching
keewis Oct 15, 2019
1897159
modify the resample test to actually work
keewis Oct 15, 2019
d3f6773
add a test for to_unstacked_dataset
keewis Oct 15, 2019
0ab6a82
update whats-new.rst and installing.rst
keewis Oct 16, 2019
f949321
Merge branch 'master' into array-with-units-tests
keewis Oct 16, 2019
a9916ef
reformat the whats-new.rst entry
keewis Oct 16, 2019
21853d7
What's New
crusaderky Oct 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/requirements/py36-min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
- numba=0.44
- numpy=1.14
- pandas=0.24
# - pint # See py36-min-nep18.yml
- pip
- pseudonetcdf=3.0
- pydap=3.2
Expand Down
3 changes: 2 additions & 1 deletion ci/requirements/py36-min-nep18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ name: xarray-tests
channels:
- conda-forge
dependencies:
# Optional dependencies that require NEP18, such as sparse,
# Optional dependencies that require NEP18, such as sparse and pint,
# require drastically newer packages than everything else
- python=3.6
- coveralls
- dask=2.4
- distributed=2.4
- numpy=1.17
- pandas=0.24
- pint=0.9
- pytest
- pytest-cov
- pytest-env
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
- numba
- numpy
- pandas
- pint
- pip
- pseudonetcdf
- pydap
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/py37-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
- numba
- numpy
- pandas
- pint
- pip
- pseudonetcdf
- pydap
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
- numba
- numpy
- pandas
- pint
- pip
- pseudonetcdf
- pydap
Expand Down
3 changes: 2 additions & 1 deletion doc/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ For plotting
Alternative data containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- `sparse <https://sparse.pydata.org/>`_: for sparse arrays
- `pint <https://pint.readthedocs.io/>`_: for units of measure
- Any numpy-like objects that support
`NEP-18 <https://numpy.org/neps/nep-0018-array-function-protocol.html>`_.
Note that while such libraries theoretically should work, they are untested.
Expand All @@ -85,7 +86,7 @@ dependencies:
(`NEP-29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_)
- **pandas:** 12 months
- **scipy:** 12 months
- **sparse** and other libraries that rely on
- **sparse, pint** and other libraries that rely on
`NEP-18 <https://numpy.org/neps/nep-0018-array-function-protocol.html>`_
for integration: very latest available versions only, until the technology will have
matured. This extends to dask when used in conjunction with any of these libraries.
Expand Down
8 changes: 6 additions & 2 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ Breaking changes
(:issue:`3222`, :issue:`3293`, :issue:`3340`, :issue:`3346`, :issue:`3358`).
By `Guido Imperiale <https://github.com/crusaderky>`_.

New functions/methods
~~~~~~~~~~~~~~~~~~~~~
New features
~~~~~~~~~~~~
- Added integration tests against `pint <https://pint.readthedocs.io/>`_.
Note that, at the moment of writing, there are issues when pint interacts
with non-numpy array libraries, e.g. dask or sparse.
(:pull:`3238`) by `Justus Magin <https://github.com/keewis>`_.

Enhancements
~~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-pandas.*]
ignore_missing_imports = True
[mypy-pint.*]
ignore_missing_imports = True
[mypy-PseudoNetCDF.*]
ignore_missing_imports = True
[mypy-pydap.*]
Expand Down
Loading