-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rm ipython * rm ipython from tests * refactor text repr
- Loading branch information
1 parent
6625d93
commit 8ffa68e
Showing
8 changed files
with
78 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,51 @@ | ||
import pytest | ||
import xarray as xr | ||
from IPython.display import display_html | ||
|
||
from climpred.classes import HindcastEnsemble, PerfectModelEnsemble | ||
|
||
|
||
def assert_repr(pe, display_style): | ||
if display_style == "text": | ||
repr_str = pe.__repr__() | ||
elif display_style == "html": | ||
repr_str = pe._repr_html_() | ||
assert "Ensemble" in repr_str | ||
if display_style == "text": | ||
assert "</pre>" not in repr_str | ||
elif display_style == "html": | ||
assert "icon" in repr_str | ||
|
||
|
||
@pytest.mark.parametrize("display_style", ("html", "text")) | ||
def test_repr_PM(PM_da_initialized_1d, PM_da_control_1d, display_style): | ||
def test_repr_PerfectModelEnsemble( | ||
PM_da_initialized_1d, PM_da_control_1d, display_style | ||
): | ||
"""Test html and text repr.""" | ||
display = print if display_style == "text" else display_html | ||
with xr.set_options(display_style=display_style): | ||
pm = PerfectModelEnsemble(PM_da_initialized_1d) | ||
display(pm) | ||
assert_repr(pm, display_style) | ||
pm = pm.add_control(PM_da_control_1d) | ||
display(pm) | ||
assert_repr(pm, display_style) | ||
pm = pm.generate_uninitialized() | ||
display(pm) | ||
assert_repr(pm, display_style) | ||
|
||
|
||
@pytest.mark.parametrize("display_style", ("html", "text")) | ||
def test_repr_HC( | ||
def test_repr_HindcastEnsemble( | ||
hind_ds_initialized_1d, | ||
hist_ds_uninitialized_1d, | ||
observations_ds_1d, | ||
display_style, | ||
): | ||
"""Test html repr.""" | ||
display = print if display_style == "text" else display_html | ||
with xr.set_options(display_style=display_style): | ||
he = HindcastEnsemble(hind_ds_initialized_1d) | ||
display(he) | ||
assert_repr(he, display_style) | ||
he = he.add_uninitialized(hist_ds_uninitialized_1d) | ||
display(he) | ||
assert_repr(he, display_style) | ||
he = he.add_observations(observations_ds_1d) | ||
display(he) | ||
assert_repr(he, display_style) | ||
# no uninit | ||
he = HindcastEnsemble(hind_ds_initialized_1d) | ||
he = he.add_observations(observations_ds_1d) | ||
display(he) | ||
assert_repr(he, display_style) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
xarray>=0.19.0 | ||
dask>=2021.10.0 | ||
ipython<8.0.0 | ||
toolz | ||
cftime>=1.5.0 | ||
xskillscore>=0.0.20 | ||
|