Skip to content

Commit d7cbf87

Browse files
authored
Merge pull request #44 from wx4stg/test-fix
Tests/numpy 2.0
2 parents ed609f1 + 8a28cf2 commit d7cbf87

3 files changed

Lines changed: 35 additions & 18 deletions

File tree

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

4-
name: Python package
4+
name: Run pytests
55

66
on:
77
push:
@@ -10,7 +10,7 @@ on:
1010
branches: [ "master" ]
1111

1212
jobs:
13-
build:
13+
test:
1414

1515
runs-on: ubuntu-latest
1616
strategy:
@@ -19,31 +19,30 @@ jobs:
1919
python-version: ["3.9", "3.10", "3.11", "3.12"]
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v3
24+
uses: actions/setup-python@v5
2525
with:
2626
python-version: ${{ matrix.python-version }}
27-
- name: Install dependencies
28-
run: |
29-
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
30-
eval "$(micromamba shell hook --shell bash)"
31-
micromamba activate base
32-
micromamba install pytest-cov pytest-mpl xarray netcdf4 pandas numpy scikit-learn scipy pyproj cartopy metpy ipywidgets python=${{ matrix.python-version }} -c conda-forge
33-
python -m pip install .
27+
- name: Install environment with micromamba
28+
uses: mamba-org/setup-micromamba@v1
29+
with:
30+
environment-file: tests/test-env.yml
31+
create-args: python=${{ matrix.python-version }}
32+
init-shell: bash
3433
- name: Test with pytest
3534
run: |
3635
eval "$(micromamba shell hook --shell bash)"
37-
micromamba activate base
36+
micromamba activate pyxlma-tests
3837
coverage run --source=pyxlma -m pytest --mpl --mpl-baseline-path=tests/truth/images/ --mpl-generate-summary=html,json --mpl-results-path=tests/mpl-results/ tests/
3938
coverage xml
4039
- name: Upload coverage reports to Codecov
41-
uses: codecov/codecov-action@v3
40+
uses: codecov/codecov-action@v4
4241
env:
4342
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4443
- name: Upload matplotlib test results
4544
if: always()
46-
uses: actions/upload-artifact@v3
45+
uses: actions/upload-artifact@v4
4746
with:
48-
name: matplotlib-results
47+
name: matplotlib-results-${{ matrix.python-version }}
4948
path: tests/mpl-results/

tests/test-env.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: pyxlma-tests
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- pytest-cov
6+
- pytest-mpl
7+
- xarray
8+
- netcdf4
9+
- pandas
10+
- numpy
11+
- scipy
12+
- scikit-learn
13+
- pyproj
14+
- metpy
15+
- ipywidgets
16+
- pip:
17+
- git+https://github.com/deeplycloudy/lmatools
18+
- -e ../

tests/test_flash.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from pyxlma.lmalib.flash.properties import *
88

99

10-
def compare_dataarrays(tocheck, truth, var):
10+
def compare_dataarrays(tocheck, truth, var, rtol=1.e-5, atol=1.e-8):
1111
"""Compare two dataarrays"""
1212
if truth[var].data.dtype == 'datetime64[ns]' or truth[var].data.dtype == 'timedelta64[ns]':
1313
if tocheck[var].data.dtype == 'float64':
1414
truth[var].data = truth[var].data.astype(float)/1e9
15-
np.testing.assert_allclose(tocheck[var].data.astype(float), truth[var].data.astype(float))
15+
np.testing.assert_allclose(tocheck[var].data.astype(float), truth[var].data.astype(float), rtol=rtol, atol=atol, equal_nan=True)
1616
else:
17-
np.testing.assert_allclose(tocheck[var].data, truth[var].data)
17+
np.testing.assert_allclose(tocheck[var].data, truth[var].data, rtol=rtol, atol=atol, equal_nan=True)
1818

1919

2020
def test_cluster_flashes():

0 commit comments

Comments
 (0)