Skip to content

Commit 78f93e3

Browse files
committed
Add xarray dependencies for doctest
1 parent 45ab3c4 commit 78f93e3

File tree

4 files changed

+155
-4
lines changed

4 files changed

+155
-4
lines changed

.github/workflows/ci-osx.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: OSX CI
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
build:
11+
runs-on: macos-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- name: Checkout source
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Set up Conda
24+
uses: conda-incubator/[email protected]
25+
with:
26+
channels: conda-forge
27+
miniforge-version: latest
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Show info about `base` environment
31+
shell: "bash -l {0}"
32+
run: |
33+
conda info
34+
conda config --show-sources
35+
conda list --show-channel-urls
36+
37+
- name: Set up `env`
38+
shell: "bash -l {0}"
39+
run: >
40+
conda create -n env
41+
c-compiler cxx-compiler 'clang>=12.0.1'
42+
python=${{matrix.python-version}} wheel pip
43+
44+
- name: Show info about `env` environment
45+
shell: "bash -l {0}"
46+
run: |
47+
conda list --show-channel-urls -n env
48+
49+
- name: Install numcodecs
50+
shell: "bash -l {0}"
51+
run: |
52+
conda activate env
53+
export DISABLE_NUMCODECS_AVX2=""
54+
python -m pip install -v -e .[test,test_extras,doctest,msgpack,zfpy,pcodec]
55+
56+
- name: List installed packages
57+
shell: "bash -l {0}"
58+
run: |
59+
conda activate env
60+
python -m pip list
61+
62+
- name: Run tests
63+
shell: "bash -l {0}"
64+
run: |
65+
conda activate env
66+
pytest -v
67+
68+
- uses: codecov/codecov-action@v3
69+
with:
70+
#token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
71+
#files: ./coverage1.xml,./coverage2.xml # optional
72+
#flags: unittests # optional
73+
#name: codecov-umbrella # optional
74+
#fail_ci_if_error: true # optional (default = false)
75+
verbose: true # optional (default = false)

.github/workflows/ci-windows.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Windows CI
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- name: Checkout source
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Set up Conda
24+
uses: conda-incubator/[email protected]
25+
with:
26+
channels: conda-forge
27+
miniforge-version: latest
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Set up `env`
31+
shell: "bash -l {0}"
32+
run: >
33+
conda create -n env
34+
c-compiler cxx-compiler
35+
python=${{matrix.python-version}} wheel pip
36+
37+
- name: Show info about `env` environment
38+
shell: "bash -l {0}"
39+
run: |
40+
conda list --show-channel-urls -n env
41+
42+
- name: Install numcodecs
43+
shell: "bash -l {0}"
44+
run: |
45+
conda activate env
46+
python -m pip install -v -e .[test,test_extras,doctest,msgpack,zfpy,pcodec]
47+
48+
- name: List installed packages
49+
shell: "bash -l {0}"
50+
run: |
51+
conda activate env
52+
python -m pip list
53+
54+
- name: Run tests
55+
shell: "bash -l {0}"
56+
run: |
57+
conda activate env
58+
pytest -v
59+
60+
- uses: codecov/codecov-action@v3
61+
with:
62+
#token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
63+
#files: ./coverage1.xml,./coverage2.xml # optional
64+
#flags: unittests # optional
65+
#name: codecov-umbrella # optional
66+
#fail_ci_if_error: true # optional (default = false)
67+
verbose: true # optional (default = false)

numcodecs/bitinfo.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,20 @@ class BitInfo(BitRound):
3333
3434
Examples
3535
--------
36+
This example applies the BitInfo codec to an xarray dataset and
37+
writes the data out using xarray's `to_zarr` method. Using this pattern, the
38+
information content is computed chunkwise, which is recommended for
39+
datasets with variable information content. Note that these data have
40+
been quantized creating erroneous results, which is apparent in
41+
the output. Do not use with quantized data in practice.
42+
3643
>>> import xarray as xr
3744
>>> ds = xr.tutorial.open_dataset("air_temperature")
38-
>>> # Note these data have already undergone lossy compression,
39-
>>> # which should not be combined with bitinformation in practice
40-
4145
>>> from numcodecs import Blosc, BitInfo
4246
>>> compressor = Blosc(cname="zstd", clevel=3)
4347
>>> filters = [BitInfo(info_level=0.99)]
4448
>>> encoding = {"air": {"compressor": compressor, "filters": filters}}
45-
>>> ds.to_zarr('xbit.zarr', mode="w", encoding=encoding)
49+
>>> _ = ds.to_zarr('xbit.zarr', mode="w", encoding=encoding)
4650
"""
4751

4852
codec_id = 'bitinfo'

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ test = [
5959
]
6060
test_extras = [
6161
"importlib_metadata",
62+
]
63+
doctest = [
6264
"xarray",
65+
"pooch",
66+
"netCDF4",
67+
"zarr",
6368
]
6469
msgpack = [
6570
"msgpack",

0 commit comments

Comments
 (0)