Skip to content

Commit 3e4c49d

Browse files
authored
Merge pull request #310 from raybellwaves/fix-clip
2 parents 67b47b9 + 54ff8f2 commit 3e4c49d

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ Internal Changes
2121
:py:func:`~xskillscore.rps` expilicty checks for ``bin_dim`` if
2222
``category_edges==None``. (:pr:`287`) `Aaron Spring`_
2323
- Add doctest on the docstring examples. (:pr:`302`) `Ray Bell`_
24-
- Removed a call to compute weights in testing (:pr:`306`) `Ray Bell`_
24+
- Removed a call to compute weights in testing. (:pr:`306`) `Ray Bell`_
25+
- Use built in ``xarray`` clip method. (:pr:`309`) `Ray Bell`_
2526

2627

2728
xskillscore v0.0.19 (2021-03-12)

ci/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies:
2424
- xarray>=0.16.1
2525
# xhistogram 0.1.3 introduced an error that broke xskillscore
2626
# see https://github.com/xgcm/xhistogram/issues/48
27-
- xhistogram!=0.1.3
27+
- xhistogram==0.1.2
2828
# Package Management
2929
- asv
3030
- black

ci/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ dependencies:
2121
- xarray>=0.16.1
2222
# xhistogram 0.1.3 introduced an error that broke xskillscore
2323
# see https://github.com/xgcm/xhistogram/issues/48
24-
- xhistogram!=0.1.3
24+
- xhistogram==0.1.2
2525
- pip:
2626
- -e ..

ci/docs_notebooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- xarray>=0.16.1
1515
# xhistogram 0.1.3 introduced an error that broke xskillscore
1616
# see https://github.com/xgcm/xhistogram/issues/48
17-
- xhistogram!=0.1.3
17+
- xhistogram==0.1.2
1818
- importlib_metadata
1919
- jupyterlab
2020
- matplotlib-base

ci/minimum-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
- xarray>=0.16.1
1616
# xhistogram 0.1.3 introduced an error that broke xskillscore
1717
# see https://github.com/xgcm/xhistogram/issues/48
18-
- xhistogram!=0.1.3
18+
- xhistogram==0.1.2
1919
- coveralls
2020
- pytest
2121
- pytest-cov

xskillscore/core/probabilistic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,9 @@ def _auc(fpr, tpr, dim="probability_bin"):
11531153
area = xr.apply_ufunc(
11541154
np.trapz, tpr, fpr, input_core_dims=[[dim], [dim]], dask="allowed"
11551155
)
1156-
area = np.abs(area)
1156+
area = abs(area)
11571157
if ((area > 1)).any():
1158-
area = np.clip(area, 0, 1) # allow only values between 0 and 1
1158+
area = area.clip(0, 1) # allow only values between 0 and 1
11591159
return area
11601160

11611161

xskillscore/tests/test_probabilistic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ def test_roc_bin_edges_continuous_against_sklearn(
996996
forecast_1d_long, observation_1d_long, drop_intermediate_bool
997997
):
998998
"""Test xs.roc against sklearn.metrics.roc_curve/auc_score."""
999-
fp = np.clip(forecast_1d_long, 0, 1) # prob
999+
fp = forecast_1d_long.clip(0, 1) # prob
10001000
ob = observation_1d_long > 0 # binary
10011001
# sklearn
10021002
sk_fpr, sk_tpr, _ = roc_curve(ob, fp, drop_intermediate=drop_intermediate_bool)
@@ -1017,7 +1017,7 @@ def test_roc_bin_edges_continuous_against_sklearn(
10171017

10181018
def test_roc_bin_edges_drop_intermediate(forecast_1d_long, observation_1d_long):
10191019
"""Test that drop_intermediate reduces probability_bins in xs.roc ."""
1020-
fp = np.clip(forecast_1d_long, 0, 1) # prob
1020+
fp = forecast_1d_long.clip(0, 1) # prob
10211021
ob = observation_1d_long > 0 # binary
10221022
# xs
10231023
txs_fpr, txs_tpr, txs_area = roc(

0 commit comments

Comments
 (0)