Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for Python 3.12 #206

Merged
merged 17 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache conda
uses: actions/cache@v2
env:
Expand All @@ -29,24 +29,27 @@ jobs:
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }}
- uses: conda-incubator/setup-miniconda@v2
- uses: mamba-org/setup-micromamba@v1
with:
activate-environment: test_env_xrft # Defined in ci/environment*.yml
auto-update-conda: false
python-version: ${{ matrix.python-version }}
micromamba-version: 'latest'
environment-file: ci/environment.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
environment-name: test_env_xrft
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'
- name: Set up conda environment
shell: bash -l {0}
run: |
python -m pip install -e .
python -m pip install -e . --no-deps
conda list
- name: Run Tests
shell: bash -l {0}
run: |
pytest -n auto --cov=./ --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3.1.4
with:
file: ./coverage.xml
flags: unittests
Expand Down
9 changes: 4 additions & 5 deletions ci/environment.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
name: test_env_xrft
channels:
- conda-forge
- defaults
dependencies:
- codecov
- xarray
- dask
- numpy
- numpy_groupies
- scipy
- pytest
- pytest-cov
- pip
- pytest-xdist
- cftime
- pip:
- codecov
- pytest-xdist
- pip
8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ classifiers =
License :: OSI Approved :: MIT License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Scientific/Engineering
project_urls =
Documentation = https://xrft.readthedocs.io/en/latest/
Expand All @@ -35,7 +35,7 @@ install_requires =
numpy
pandas
scipy
python_requires = >=3.6
python_requires = >=3.8

[bdist_wheel]
universal = 1
Expand Down
6 changes: 3 additions & 3 deletions xrft/tests/test_xrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_data_1d(request):
@pytest.fixture(params=["pandas", "standard", "julian", "365_day", "360_day"])
def time_data(request):
if request.param == "pandas":
return pd.date_range("2000-01-01", "2001-01-01", closed="left")
return pd.date_range("2000-01-01", "2001-01-01", inclusive="left")
else:
units = "days since 2000-01-01 00:00:00"
return cftime.num2date(np.arange(0, 10 * 365), units, request.param)
Expand Down Expand Up @@ -680,7 +680,7 @@ def test_cross_phase_true_phase_2d(self, dask):
phase_offset = np.arctan2(
np.sin(phase_offset), np.cos(phase_offset)
) # Offset in [-pi, pi]
npt.assert_almost_equal(np.float(offset), phase_offset)
npt.assert_almost_equal(float(offset), phase_offset)


@pytest.mark.parametrize("chunks_to_segments", [False, True])
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def test_theoretical_matching(rtol=1e-8, atol=1e-3):
) # Fast Fourier Transform of original signal
f = S.freq_x # Frequency axis
TF_s = xr.DataArray(
(T / 2 * (np.sinc(T * (f - f0)) + np.sinc(T * (f + f0)))).astype(np.complex),
(T / 2 * (np.sinc(T * (f - f0)) + np.sinc(T * (f + f0)))).astype(complex),
dims=("freq_x",),
coords={"freq_x": f},
) # Theoretical expression of the Fourier transform
Expand Down
Loading