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

fix xarray related tests #1726

Merged
merged 3 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* Fix `legend` argument in `plot_separation` ([1701](https://github.com/arviz-devs/arviz/pull/1701))
* Removed testing dependency on http download for radon dataset ([1717](https://github.com/arviz-devs/arviz/pull/1717))
* Fixed plot_kde to take labels with kwargs. ([1710](https://github.com/arviz-devs/arviz/pull/1710))
* Fixed xarray related tests. ([1726](https://github.com/arviz-devs/arviz/pull/1726))


### Deprecation
* Deprecated `index_origin` and `order` arguments in `az.summary` ([1201](https://github.com/arviz-devs/arviz/pull/1201))
Expand Down
20 changes: 12 additions & 8 deletions arviz/tests/base_tests/test_plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,18 @@ def test_xarray_sel_data_array(sample_dataset): # pylint: disable=invalid-name

class TestCoordsExceptions:
# test coord exceptions on datasets
@pytest.mark.skipif(
True, reason="Skip test until we figure out how to handle the new xarray errors"
)
def test_invalid_coord_name(self, sample_dataset): # pylint: disable=invalid-name
"""Assert that nicer exception appears when user enters wrong coords name"""
_, _, data = sample_dataset
coords = {"NOT_A_COORD_NAME": [1]}

with pytest.raises(
ValueError, match="Coords {'NOT_A_COORD_NAME'} are invalid coordinate keys"
(KeyError, ValueError),
match=(
r"Coords "
r"({'NOT_A_COORD_NAME'} are invalid coordinate keys"
r"|should follow mapping format {coord_name:\[dim1, dim2\]})"
),
):
get_coords(data, coords)

Expand All @@ -168,16 +170,18 @@ def test_invalid_coord_structure(self, sample_dataset): # pylint: disable=inval
get_coords(data, coords)

# test coord exceptions on dataset list
@pytest.mark.skipif(
True, reason="Skip test until we figure out how to handle the new xarray errors"
)
def test_invalid_coord_name_list(self, sample_dataset): # pylint: disable=invalid-name
"""Assert that nicer exception appears when user enters wrong coords name"""
_, _, data = sample_dataset
coords = {"NOT_A_COORD_NAME": [1]}

with pytest.raises(
ValueError, match=r"data\[1\]:.+Coords {'NOT_A_COORD_NAME'} are invalid coordinate keys"
(KeyError, ValueError),
match=(
r"data\[1\]:.+Coords "
r"({'NOT_A_COORD_NAME'} are invalid coordinate keys"
r"|should follow mapping format {coord_name:\[dim1, dim2\]})"
),
):
get_coords((data, data), ({"draw": [0, 1]}, coords))

Expand Down