-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add cohorts snapshot tests with syrupy (#379)
* Add cohorts snapshot tests with syrupy * Fix. * fix again * Rework CI * [revery] * improve * fix mypy? * Revert "[revery]" This reverts commit 7664e5e. * Try again * fix mypy
Showing
13 changed files
with
22,362 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,8 @@ jobs: | |
- name: Run mypy | ||
run: | | ||
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report | ||
mkdir .mypy_cache | ||
python -m mypy --install-types --non-interactive --cache-dir=.mypy_cache/ --cobertura-xml-report mypy_report | ||
- name: Upload mypy coverage to Codecov | ||
uses: codecov/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ concurrency: | |
|
||
jobs: | ||
test: | ||
name: Test (${{ matrix.python-version }}, ${{ matrix.os }}) | ||
name: Test (${{matrix.env}}, ${{ matrix.python-version }}, ${{ matrix.os }}) | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
|
@@ -25,10 +25,18 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
env: ["environment"] | ||
python-version: ["3.9", "3.12"] | ||
include: | ||
- os: "windows-latest" | ||
env: "environment" | ||
python-version: "3.12" | ||
- os: "ubuntu-latest" | ||
env: "no-dask" # "no-xarray", "no-numba" | ||
python-version: "3.12" | ||
- os: "ubuntu-latest" | ||
env: "minimal-requirements" | ||
python-version: "3.9" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
|
@@ -39,7 +47,7 @@ jobs: | |
- name: Set up conda environment | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: ci/environment.yml | ||
environment-file: ci/${{ matrix.env }}.yml | ||
environment-name: flox-tests | ||
init-shell: bash | ||
cache-environment: true | ||
|
@@ -81,48 +89,6 @@ jobs: | |
path: .hypothesis/ | ||
key: cache-hypothesis-${{ runner.os }}-${{ matrix.python-version }}-${{ github.run_id }} | ||
|
||
optional-deps: | ||
name: ${{ matrix.env }} | ||
runs-on: "ubuntu-latest" | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.12"] | ||
env: ["no-dask"] # "no-xarray", "no-numba" | ||
include: | ||
- env: "minimal-requirements" | ||
python-version: "3.9" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all branches and tags. | ||
- name: Set up conda environment | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: ci/${{ matrix.env }}.yml | ||
environment-name: flox-tests | ||
init-shell: bash | ||
cache-environment: true | ||
create-args: | | ||
python=${{ matrix.python-version }} | ||
- name: Install flox | ||
run: | | ||
python -m pip install --no-deps -e . | ||
- name: Run tests | ||
run: | | ||
python -m pytest -n auto --cov=./ --cov-report=xml | ||
- name: Upload code coverage to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
file: ./coverage.xml | ||
flags: unittests | ||
env_vars: RUNNER_OS | ||
name: codecov-umbrella | ||
fail_ci_if_error: false | ||
|
||
xarray-groupby: | ||
name: xarray-groupby | ||
runs-on: ubuntu-latest | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ dependencies: | |
- pytest-cov | ||
- pytest-pretty | ||
- pytest-xdist | ||
- syrupy | ||
- xarray | ||
- numpydoc | ||
- pre-commit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Snapshot tests for cohorts detection | ||
|
||
import pytest | ||
|
||
pytest.importorskip("dask") | ||
|
||
from asv_bench.benchmarks import cohorts | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"testcase", | ||
[ | ||
cohorts.ERA5DayOfYear, | ||
cohorts.ERA5Google, | ||
cohorts.ERA5MonthHour, | ||
cohorts.ERA5MonthHourRechunked, | ||
cohorts.OISST, | ||
cohorts.PerfectBlockwiseResampling, | ||
cohorts.PerfectMonthly, | ||
cohorts.RandomBigArray, | ||
cohorts.SingleChunk, | ||
cohorts.NWMMidwest, | ||
], | ||
) | ||
def test_snapshot_cohorts(testcase, snapshot): | ||
problem = testcase() | ||
problem.setup() | ||
chunks_cohorts = problem.chunks_cohorts() | ||
assert chunks_cohorts == snapshot |