From 1e991caa27d9dd536e0f318a838d6fde03196a10 Mon Sep 17 00:00:00 2001 From: jbusecke Date: Wed, 7 Jun 2023 15:14:59 -0400 Subject: [PATCH 1/4] replace np.float with float --- xarrayutils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarrayutils/utils.py b/xarrayutils/utils.py index dfe7c60..87fca55 100644 --- a/xarrayutils/utils.py +++ b/xarrayutils/utils.py @@ -109,7 +109,7 @@ def linear_trend(obj, dim): trend is in units/yr. """ x = xr.DataArray( - np.arange(len(obj[dim])).astype(np.float), dims=dim, coords={dim: obj[dim]} + np.arange(len(obj[dim])).astype(float), dims=dim, coords={dim: obj[dim]} ) trend = xr_linregress(x, obj, dim=dim) return trend From 679dbc1f38e48d4597fb830fc5c2058c25c58491 Mon Sep 17 00:00:00 2001 From: Julius Busecke Date: Wed, 7 Jun 2023 15:55:30 -0400 Subject: [PATCH 2/4] Merge minimamba changes into this PR --- .github/workflows/ci.yaml | 78 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e22b8d8..70e5111 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,32 +24,24 @@ jobs: python-version: ["3.9", "3.10"] steps: - uses: actions/checkout@v3 - - name: Cache conda - uses: actions/cache@v3 - env: - # Increase this value to reset cache if ci/environment.yml has not changed - CACHE_NUMBER: 0 + - name: Create conda environment + uses: mamba-org/provision-with-micromamba@main with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - mamba-version: "*" - channels: conda-forge, defaults - activate-environment: test_env_xarrayutils # Defined in ci/environment*.yml - auto-update-conda: false - python-version: ${{ matrix.python-version }} + cache-downloads: true + cache-env: true + micromamba-version: 'latest' environment-file: ci/environment.yml - use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! - - name: Set up conda environment + extra-specs: | + python=${{ matrix.python-version }} + - name: Install xarrayutils run: | - python -m pip install -e . + python -m pip install -e . --no-deps conda list - name: Run Tests run: | pytest -n auto --cov=./ --cov-report=xml - name: Upload code coverage to Codecov - uses: codecov/codecov-action@v3.1.1 + uses: codecov/codecov-action@v3.1.3 with: file: ./coverage.xml flags: unittests @@ -63,25 +55,31 @@ jobs: run: shell: bash -l {0} steps: - - uses: actions/checkout@v3 - - name: Cache conda - uses: actions/cache@v3 - env: - # Increase this value to reset cache if ci/environment-upstream-dev.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment-upstream-dev.yml') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: test_env_xarrayutils # Defined in ci/environment-upstream-dev.yml - auto-update-conda: false - environment-file: ci/environment-upstream-dev.yml - use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! - - name: Set up conda environment - run: | - python -m pip install -e . - conda list - - name: Run Tests - run: | - pytest -n auto + - uses: actions/checkout@v3 + - name: Create conda environment + uses: mamba-org/provision-with-micromamba@main + with: + cache-downloads: true + cache-env: true + micromamba-version: 'latest' + environment-file: ci/environment-upstream-dev.yml + extra-specs: | + python=3.10 + - name: Install xarrayutils + run: | + python -m pip install -e . --no-deps + conda list + - name: Run Tests + run: | + pytest -n auto --cov=./ --cov-report=xml + - name: Upload code coverage to Codecov + uses: codecov/codecov-action@v3.1.3 + with: + file: ./coverage.xml + flags: unittests + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: false + - name: Run Tests + run: | + pytest -n auto From ab7707d5093bc00bef2bb212b48c39113da3c1bc Mon Sep 17 00:00:00 2001 From: Julius Busecke Date: Wed, 7 Jun 2023 18:50:37 -0400 Subject: [PATCH 3/4] Fix np.float occurences in datasets.py --- xarrayutils/test/datasets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarrayutils/test/datasets.py b/xarrayutils/test/datasets.py index 02adc5c..73ec301 100644 --- a/xarrayutils/test/datasets.py +++ b/xarrayutils/test/datasets.py @@ -13,10 +13,10 @@ [2, 2, 2, 4, 4, 4, 6, 6], [2, 2, 2, 4, 4, 4, 6, 6], ], - dtype=np.float, + dtype=float, ) -ones_2d = np.ones([6, 8], dtype=np.float) +ones_2d = np.ones([6, 8], dtype=float) ones_2d_nan = ones_2d.copy() ones_2d_nan[2, 2] = np.nan From d50e6b43c7ddb5cc9dd20ec45c0d9b358fb2c0d4 Mon Sep 17 00:00:00 2001 From: Julius Busecke Date: Wed, 7 Jun 2023 19:45:06 -0400 Subject: [PATCH 4/4] Update test_utils.py --- xarrayutils/test/test_utils.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/xarrayutils/test/test_utils.py b/xarrayutils/test/test_utils.py index 48c8636..d763a10 100644 --- a/xarrayutils/test/test_utils.py +++ b/xarrayutils/test/test_utils.py @@ -174,11 +174,8 @@ def _linregress_ufunc(a, b, nanmask=False): ({"x": -1, "y": 1}, "x"), ], ) -# @pytest.mark.parametrize("variant", range(3)) @pytest.mark.parametrize("variant", [0]) -# @pytest.mark.parametrize("dtype", [None, np.float]) @pytest.mark.parametrize("dtype", [None]) -# @pytest.mark.parametrize("nans", [False, True]) @pytest.mark.parametrize("nans", [True, "all"]) @pytest.mark.parametrize( "ni, parameter", enumerate(["slope", "intercept", "r_value", "p_value", "std_err"]) @@ -595,7 +592,7 @@ def test_aggregate_input_da(dataarray_2d_example): def test_aggregate_w_nanmean(dataarray_2d_ones, dataarray_2d_ones_nan): - expected_result = np.array([[1, 1], [1, 1]], dtype=np.float) + expected_result = np.array([[1, 1], [1, 1]], dtype=float) blocks = [("i", 3), ("j", 3)] data = dataarray_2d_ones_nan