Skip to content

Commit

Permalink
update images and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phobson committed Feb 19, 2024
1 parent c4e0994 commit ebc292d
Show file tree
Hide file tree
Showing 135 changed files with 95 additions and 92 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/python-runtests-img-comp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.11
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .git,docs/*
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
export MPL_IMGCOMP_TOLERANCE=20
python check_wqio.py --strict
python check_wqio.py --strict --verbose
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
[metadata]
description-file = readme.rst

[tool:pytest]
pep8ignore =
E501
E131
check_wqio.py ALL
wqio/examples/* ALL
wqio/tests/* E501
wqio/tests/test_features.py E241
wqio/tests/test_datacollections.py E241
wqio/tests/test_ros.py E241
docs/* ALL

markers =
mpl_image_compare

Expand Down
8 changes: 4 additions & 4 deletions wqio/datacollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ def fxn(g):

def make_tidy(df):
tqdm.pandas(desc="Tidying the DataCollection")
return df.groupby(self.groupcols).progress_apply(fxn)
return df.groupby(self.groupcols).progress_apply(fxn, include_groups=False)

else:

def make_tidy(df):
return df.groupby(self.groupcols).apply(fxn)
return df.groupby(self.groupcols).apply(fxn, include_groups=False)

keep_cols = self.tidy_columns + [self.roscol]
with warnings.catch_warnings():
Expand Down Expand Up @@ -277,9 +277,9 @@ def fxn(x):

if tqdm and self.showpbar:
tqdm.pandas(desc="Computing stats")
vals = groups.progress_apply(fxn)
vals = groups.progress_apply(fxn, include_groups=False)
else:
vals = groups.apply(fxn)
vals = groups.apply(fxn, include_groups=False)

results = (
vals.unstack(level=self.stationcol)
Expand Down
8 changes: 4 additions & 4 deletions wqio/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def probplot(
xlabels = {
"pp": "Theoretical percentiles",
"qq": "Theoretical quantiles",
"prob": r"Non-exceedance probability (\%)",
"prob": r"Non-exceedance probability (%)",
}

ax.set_xlabel(xlabels[axtype])
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def jointplot(self, hist=False, kde=True, rug=True, **scatter_kws):
Toggles showing histograms on the distribution plots
kde : bool, optional (default is True)
Toggles showing KDE plots on the distribution plots
run : bool, optional (default is True)
rug : bool, optional (default is True)
Toggles showing rug plots on the distribution plots
**scatter_kws : keyword arguments
Optionals passed directly to Dataset.scatterplot
Expand All @@ -1405,7 +1405,7 @@ def jointplot(self, hist=False, kde=True, rug=True, **scatter_kws):
--------
seaborn.JointGrid
seaborn.jointplot
seaborn.distplot
seaborn.displot
Dataset.scatterplot
"""
Expand All @@ -1417,7 +1417,7 @@ def jointplot(self, hist=False, kde=True, rug=True, **scatter_kws):
data = self.paired_data.xs("res", level="quantity", axis=1)
jg = seaborn.JointGrid(x="inflow", y="outflow", data=data)
self.scatterplot(ax=jg.ax_joint, showlegend=False, **scatter_kws)
jg.plot_marginals(seaborn.distplot, hist=hist, rug=rug, kde=kde)
jg.plot_marginals(seaborn.displot, rug=rug, kde=kde)

jg.ax_marg_x.set_xscale(scatter_kws.pop("xscale", "log"))
jg.ax_marg_y.set_yscale(scatter_kws.pop("yscale", "log"))
Expand Down
2 changes: 1 addition & 1 deletion wqio/hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ def histogram(self, valuecol, bins, **factoropts):
"""

fg = viz.categorical_histogram(self.storm_stats, valuecol, bins, **factoropts)
fg.fig.tight_layout()
fg.figure.tight_layout()
return fg


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wqio/tests/_baseline_images/features_tests/test_ds_probplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wqio/tests/_baseline_images/features_tests/test_loc_probplot.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test__connect_spines.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_boxplot_basic.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_boxplot_with_mean.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_gridlines_basic.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_gridlines_ylog.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_jointplot_xlabeled.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_log_formatter.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_log_formatter_alt.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_one2one.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_probplot_pp.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_probplot_pp_bestfit.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_probplot_prob.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_probplot_qq.png
Binary file modified wqio/tests/_baseline_images/viz_tests/test_probplot_qq_bestfit.png
6 changes: 3 additions & 3 deletions wqio/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import difflib
import distutils
import os
import re
import subprocess
Expand All @@ -12,6 +11,7 @@
import numpy
import pandas
import pytest
from packaging.version import Version
from pkg_resources import resource_filename


Expand Down Expand Up @@ -189,8 +189,8 @@ def compare_versions(utility="latex"): # pragma: no cover
required = requirements[utility]
present = available[utility]
if present:
present = distutils.version.LooseVersion(present)
required = distutils.version.LooseVersion(required)
present = Version(present)
required = Version(required)
return present >= required

else:
Expand Down
4 changes: 2 additions & 2 deletions wqio/tests/test_datacollections.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from distutils.version import LooseVersion
from io import StringIO
from textwrap import dedent
from unittest import mock
Expand All @@ -8,13 +7,14 @@
import pandas.testing as pdtest
import pytest
import scipy
from packaging.version import Version
from scipy import stats

from wqio.datacollections import DataCollection, _dist_compare
from wqio.features import Dataset, Location
from wqio.tests import helpers

OLD_SCIPY = LooseVersion(scipy.version.version) < LooseVersion("0.19")
OLD_SCIPY = Version(scipy.version.version) < Version("0.19")


def check_stat(expected_csv, result, comp=False):
Expand Down
5 changes: 2 additions & 3 deletions wqio/tests/test_features.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from distutils.version import LooseVersion

import numpy.testing as nptest
import pandas
import pytest
import scipy
from packaging.version import Version

from wqio.features import Dataset, Location
from wqio.tests import helpers

OLD_SCIPY = LooseVersion(scipy.version.version) < LooseVersion("0.19")
OLD_SCIPY = Version(scipy.version.version) < Version("0.19")
TOLERANCE = 0.05


Expand Down
20 changes: 9 additions & 11 deletions wqio/tests/test_features_plotting.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import pytest
from wqio.tests import helpers

import numpy
from matplotlib import pyplot
import pytest
import seaborn
from matplotlib import pyplot

from wqio.features import Location, Dataset

from wqio.features import Dataset, Location
from wqio.tests import helpers

BASELINE_IMAGES = "_baseline_images/features_tests"
TOLERANCE = helpers.get_img_tolerance()
Expand Down Expand Up @@ -699,19 +697,19 @@ def test_ds__plot_NDs_neither(ds_NDs, markerkwargs):
def _do_jointplots(ds, hist=False, kde=False, rug=False):
jg = ds.jointplot(hist=hist, kde=kde, rug=rug)
assert isinstance(jg, seaborn.JointGrid)
return jg.fig
return jg.figure


def test_ds_joint_hist_smoke(ds_NDs):
with seaborn.axes_style("ticks"):
fig1 = _do_jointplots(ds_NDs, hist=True)
return fig1
return fig1


def test_ds_joint_kde_smoke(ds_NDs):
with seaborn.axes_style("ticks"):
fig2 = _do_jointplots(ds_NDs, kde=True)
return fig2
return fig2


def test_ds_joint_rug_smoke(ds_NDs):
Expand All @@ -722,5 +720,5 @@ def test_ds_joint_rug_smoke(ds_NDs):

def test_ds_joint_kde_rug_hist_smoke(ds_NDs):
with seaborn.axes_style("ticks"):
fig4 = _do_jointplots(ds_NDs, hist=True, kde=True, rug=True)
return fig4
fig4 = _do_jointplots(ds_NDs, hist=True, kde=True)
return fig4
25 changes: 14 additions & 11 deletions wqio/tests/test_hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import pandas
import pandas.testing as pdtest
import pytest
import seaborn
from matplotlib import pyplot

from wqio import hydro
from wqio.tests import helpers

BASELINE_IMAGES = "_baseline_images/hydro_tests"
TOLERANCE = helpers.get_img_tolerance()
FIVEMIN = pandas.offsets.Minute(5)


class fakeStormSublcass(hydro.Storm):
Expand All @@ -19,7 +21,7 @@ def hr_simple():
storm_file = helpers.test_data_path("teststorm_simple.csv")
orig_record = (
pandas.read_csv(storm_file, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -44,7 +46,7 @@ def hr_singular():
storm_file = helpers.test_data_path("teststorm_singular.csv")
orig_record = (
pandas.read_csv(storm_file, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -62,7 +64,7 @@ def hr_first_obs():
storm_file = helpers.test_data_path("teststorm_firstobs.csv")
orig_record = (
pandas.read_csv(storm_file, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -80,7 +82,7 @@ def hr_diff_storm_class():
storm_file = helpers.test_data_path("teststorm_simple.csv")
orig_record = (
pandas.read_csv(storm_file, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -100,7 +102,7 @@ def setup_storms(filename, baseflow=None):
storm_file = helpers.test_data_path(filename)
orig_record = (
pandas.read_csv(storm_file, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -127,7 +129,6 @@ def test_wet_first_row(wetcol, expected):
df = pandas.DataFrame(
{"A": [True, True, False], "B": [False, False, True], "Z": [0, 0, 0]}
).pipe(hydro._wet_first_row, wetcol, "Z")

assert df.iloc[0].loc["Z"] == expected


Expand Down Expand Up @@ -187,7 +188,7 @@ def test_HydroRecord_histogram():
stormfile = helpers.test_data_path("teststorm_simple.csv")
orig_record = (
pandas.read_csv(stormfile, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -201,8 +202,9 @@ def test_HydroRecord_histogram():
intereventHours=3,
)

fig = hr.histogram("Total Precip Depth", [4, 6, 8, 10])
return fig.fig
with seaborn.axes_style("ticks"):
fig = hr.histogram("Total Precip Depth", [4, 6, 8, 10])
return fig.figure


def test_HydroRecord_attr(hr_simple_fixture):
Expand Down Expand Up @@ -585,7 +587,7 @@ def single_storm():
storm_file = helpers.test_data_path("teststorm_simple.csv")
orig_record = (
pandas.read_csv(storm_file, index_col="date", parse_dates=True)
.resample("5T")
.resample(FIVEMIN)
.asfreq()
.fillna(0)
)
Expand All @@ -609,7 +611,8 @@ def test_plot_storm_summary(single_storm):
single_storm.inflowcol: "Effluent (l/s)",
single_storm.precipcol: "Precip Depth (mm)",
}
fig, artists, labels = single_storm.summaryPlot(outflow=False, serieslabels=labels)
with seaborn.axes_style("ticks"):
fig, _, labels = single_storm.summaryPlot(outflow=False, serieslabels=labels)
return fig


Expand Down
Loading

0 comments on commit ebc292d

Please sign in to comment.