Skip to content

Commit 6cf77e9

Browse files
authored
replace np.float with float (#162)
* replace np.float with float * Merge minimamba changes into this PR * Fix np.float occurences in datasets.py * Update test_utils.py
1 parent 11e13da commit 6cf77e9

File tree

4 files changed

+42
-47
lines changed

4 files changed

+42
-47
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,24 @@ jobs:
2424
python-version: ["3.9", "3.10"]
2525
steps:
2626
- uses: actions/checkout@v3
27-
- name: Cache conda
28-
uses: actions/cache@v3
29-
env:
30-
# Increase this value to reset cache if ci/environment.yml has not changed
31-
CACHE_NUMBER: 0
27+
- name: Create conda environment
28+
uses: mamba-org/provision-with-micromamba@main
3229
with:
33-
path: ~/conda_pkgs_dir
34-
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }}
35-
- uses: conda-incubator/setup-miniconda@v2
36-
with:
37-
mamba-version: "*"
38-
channels: conda-forge, defaults
39-
activate-environment: test_env_xarrayutils # Defined in ci/environment*.yml
40-
auto-update-conda: false
41-
python-version: ${{ matrix.python-version }}
30+
cache-downloads: true
31+
cache-env: true
32+
micromamba-version: 'latest'
4233
environment-file: ci/environment.yml
43-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
44-
- name: Set up conda environment
34+
extra-specs: |
35+
python=${{ matrix.python-version }}
36+
- name: Install xarrayutils
4537
run: |
46-
python -m pip install -e .
38+
python -m pip install -e . --no-deps
4739
conda list
4840
- name: Run Tests
4941
run: |
5042
pytest -n auto --cov=./ --cov-report=xml
5143
- name: Upload code coverage to Codecov
52-
uses: codecov/[email protected].1
44+
uses: codecov/[email protected].3
5345
with:
5446
file: ./coverage.xml
5547
flags: unittests
@@ -63,25 +55,31 @@ jobs:
6355
run:
6456
shell: bash -l {0}
6557
steps:
66-
- uses: actions/checkout@v3
67-
- name: Cache conda
68-
uses: actions/cache@v3
69-
env:
70-
# Increase this value to reset cache if ci/environment-upstream-dev.yml has not changed
71-
CACHE_NUMBER: 0
72-
with:
73-
path: ~/conda_pkgs_dir
74-
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment-upstream-dev.yml') }}
75-
- uses: conda-incubator/setup-miniconda@v2
76-
with:
77-
activate-environment: test_env_xarrayutils # Defined in ci/environment-upstream-dev.yml
78-
auto-update-conda: false
79-
environment-file: ci/environment-upstream-dev.yml
80-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
81-
- name: Set up conda environment
82-
run: |
83-
python -m pip install -e .
84-
conda list
85-
- name: Run Tests
86-
run: |
87-
pytest -n auto
58+
- uses: actions/checkout@v3
59+
- name: Create conda environment
60+
uses: mamba-org/provision-with-micromamba@main
61+
with:
62+
cache-downloads: true
63+
cache-env: true
64+
micromamba-version: 'latest'
65+
environment-file: ci/environment-upstream-dev.yml
66+
extra-specs: |
67+
python=3.10
68+
- name: Install xarrayutils
69+
run: |
70+
python -m pip install -e . --no-deps
71+
conda list
72+
- name: Run Tests
73+
run: |
74+
pytest -n auto --cov=./ --cov-report=xml
75+
- name: Upload code coverage to Codecov
76+
uses: codecov/[email protected]
77+
with:
78+
file: ./coverage.xml
79+
flags: unittests
80+
env_vars: OS,PYTHON
81+
name: codecov-umbrella
82+
fail_ci_if_error: false
83+
- name: Run Tests
84+
run: |
85+
pytest -n auto

xarrayutils/test/datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
[2, 2, 2, 4, 4, 4, 6, 6],
1414
[2, 2, 2, 4, 4, 4, 6, 6],
1515
],
16-
dtype=np.float,
16+
dtype=float,
1717
)
1818

19-
ones_2d = np.ones([6, 8], dtype=np.float)
19+
ones_2d = np.ones([6, 8], dtype=float)
2020

2121
ones_2d_nan = ones_2d.copy()
2222
ones_2d_nan[2, 2] = np.nan

xarrayutils/test/test_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,8 @@ def _linregress_ufunc(a: np.ndarray, b: np.ndarray, nanmask: bool = False):
176176
({"x": -1, "y": 1}, "x"),
177177
],
178178
)
179-
# @pytest.mark.parametrize("variant", range(3))
180179
@pytest.mark.parametrize("variant", [0])
181-
# @pytest.mark.parametrize("dtype", [None, np.float])
182180
@pytest.mark.parametrize("dtype", [None])
183-
# @pytest.mark.parametrize("nans", [False, True])
184181
@pytest.mark.parametrize("nans", [True, "all"])
185182
@pytest.mark.parametrize(
186183
"ni, parameter", enumerate(["slope", "intercept", "r_value", "p_value", "std_err"])
@@ -599,7 +596,7 @@ def test_aggregate_input_da(dataarray_2d_example):
599596

600597

601598
def test_aggregate_w_nanmean(dataarray_2d_ones, dataarray_2d_ones_nan):
602-
expected_result = np.array([[1, 1], [1, 1]], dtype=np.float)
599+
expected_result = np.array([[1, 1], [1, 1]], dtype=float)
603600
blocks = [("i", 3), ("j", 3)]
604601

605602
data = dataarray_2d_ones_nan

xarrayutils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def linear_trend(obj, dim):
109109
trend is in units/yr.
110110
"""
111111
x = xr.DataArray(
112-
np.arange(len(obj[dim])).astype(np.float), dims=dim, coords={dim: obj[dim]}
112+
np.arange(len(obj[dim])).astype(float), dims=dim, coords={dim: obj[dim]}
113113
)
114114
trend = xr_linregress(x, obj, dim=dim)
115115
return trend

0 commit comments

Comments
 (0)