Skip to content

Commit

Permalink
Merge branch 'main' into feature/add_qq_and_residual_hist_to_comparer…
Browse files Browse the repository at this point in the history
…_collection
  • Loading branch information
jsmariegaard committed Dec 12, 2024
2 parents b791b02 + 3bbb9cf commit 5b00742
Show file tree
Hide file tree
Showing 28 changed files with 532 additions and 235 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install modelskill
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install modelskill
run: pip install .[dev]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/full_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.13"]
python-version: ["3.10", "3.13"]

steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1 # Fail fast if there are any linting errors
- uses: astral-sh/ruff-action@v2 # Fail fast if there are any linting errors
with:
version: 0.6.2
src: "modelskill"
Expand All @@ -35,11 +35,11 @@ jobs:
- name: Install modelskill
run: |
pip install .[test]
- name: Static type check
run: make typecheck
- name: Test with pytest
run: |
pytest --cov=modelskill --ignore tests/notebooks/
- name: Static type check
run: make typecheck
- name: Test docstrings with pytest
run: |
pytest ./modelskill/metrics.py --doctest-modules
2 changes: 1 addition & 1 deletion .github/workflows/notebooks_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'
- name: Install modelskill
run: |
pip install .[test,notebooks]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: [3.9, "3.13"]
python-version: ["3.10", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# ModelSkill: Flexible Model skill evaluation.
![Python version](https://img.shields.io/pypi/pyversions/modelskill.svg)
![Python package](https://github.com/DHI/modelskill/actions/workflows/full_test.yml/badge.svg) [![PyPI version](https://badge.fury.io/py/modelskill.svg)](https://badge.fury.io/py/modelskill)
![Downloads](https://img.shields.io/pypi/dm/modelskill)

[ModelSkill](https://github.com/DHI/modelskill) is a python package for scoring [MIKE](https://www.mikepoweredbydhi.com) models (other models can be evaluated as well).

Expand Down
7 changes: 4 additions & 3 deletions modelskill/comparison/_collection_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def scatter(
Parameters
----------
bins: (int, float, sequence), optional
bins for the 2D histogram on the background. By default 20 bins.
bins for the 2D histogram on the background. By default 120 bins.
if int, represents the number of bins of 2D
if float, represents the bin size
if sequence (list of int or float), represents the bin edges
Expand All @@ -94,8 +94,9 @@ def scatter(
show_density: bool, optional
show the data density as a colormap of the scatter, by default
None. If both `show_density` and `show_hist` are None, then
`show_density` is used by default. For binning the data, the
kword `bins=Float` is used.
`show_density` is used by default. If number of points is less
than 200, then `show_density` is False as default.
For binning the data, the kword `bins=Float` is used.
norm : matplotlib.colors norm
colormap normalization. If None, defaults to
matplotlib.colors.PowerNorm(vmin=1, gamma=0.5)
Expand Down
7 changes: 4 additions & 3 deletions modelskill/comparison/_comparer_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def scatter(
Parameters
----------
bins: (int, float, sequence), optional
bins for the 2D histogram on the background. By default 20 bins.
bins for the 2D histogram on the background. By default 120 bins.
if int, represents the number of bins of 2D
if float, represents the bin size
if sequence (list of int or float), represents the bin edges
Expand All @@ -518,8 +518,9 @@ def scatter(
show_density: bool, optional
show the data density as a colormap of the scatter, by default
None. If both `show_density` and `show_hist` are None, then
`show_density` is used by default. For binning the data, the
kword `bins=Float` is used.
`show_density` is used by default. If number of points is less
than 200, then `show_density` is False as default.
For binning the data, the kword `bins=Float` is used.
norm : matplotlib.colors norm
colormap normalization. If None, defaults to
matplotlib.colors.PowerNorm(vmin=1, gamma=0.5)
Expand Down
21 changes: 21 additions & 0 deletions modelskill/comparison/_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,27 @@ def _matched_data_to_xarray(
cols = list(df.columns)
items = ItemSelection.parse(cols, obs_item, mod_items, aux_items, x_item, y_item)

# check that x and x_item is not both specified (same for y and y_item)
if (x is not None) and (x_item is not None):
raise ValueError("x and x_item cannot both be specified")
if (y is not None) and (y_item is not None):
raise ValueError("y and y_item cannot both be specified")

if x is not None:
try:
x = float(x)
except TypeError:
raise TypeError(
f"x must be scalar, not {type(x)}; if x is a coordinate variable, use x_item"
)
if y is not None:
try:
y = float(y)
except TypeError:
raise TypeError(
f"y must be scalar, not {type(y)}; if y is a coordinate variable, use y_item"
)

# check that items.obs and items.model are numeric
if not np.issubdtype(df[items.obs].dtype, np.number):
raise ValueError(
Expand Down
2 changes: 2 additions & 0 deletions modelskill/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def from_matched(
y_item: str | int | None = None,
) -> Comparer:
"""Create a Comparer from observation and model results that are already matched (aligned)
Parameters
----------
data : [pd.DataFrame, str, Path, mikeio.Dfs0, mikeio.Dataset]
Expand Down Expand Up @@ -129,6 +130,7 @@ def from_matched(
Observation: stn_a, n_points=3
Model: local, rmse=0.100
Model: global, rmse=0.200
"""
# pre-process if dfs0, or mikeio.Dataset
if isinstance(data, (str, Path)):
Expand Down
Loading

0 comments on commit 5b00742

Please sign in to comment.