Skip to content

Commit 1565ae5

Browse files
author
Joe Hamman
authored
Merge pull request #22 from jhamman/fix/ci
fix failing ci
2 parents 26749de + 8df83c1 commit 1565ae5

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

.github/workflows/main.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/[email protected]
16-
- uses: actions/[email protected].1
17-
- uses: pre-commit/[email protected].0
16+
- uses: actions/[email protected].2
17+
- uses: pre-commit/[email protected].3
1818

1919
test:
2020
name: ${{ matrix.python-version }}-build
2121
runs-on: ubuntu-latest
2222
strategy:
2323
matrix:
24-
python-version: [3.7, 3.8]
24+
python-version: [3.7, 3.8, 3.9]
2525
steps:
2626
- uses: actions/[email protected]
2727
- name: Setup Python
28-
uses: actions/[email protected].1
28+
uses: actions/[email protected].2
2929
with:
3030
python-version: ${{ matrix.python-version }}
3131
architecture: x64
@@ -48,11 +48,11 @@ jobs:
4848
runs-on: ubuntu-latest
4949
strategy:
5050
matrix:
51-
python-version: [3.7, 3.8]
51+
python-version: [3.8, 3.9]
5252
steps:
5353
- uses: actions/[email protected]
5454
- name: Setup Python
55-
uses: actions/[email protected].1
55+
uses: actions/[email protected].2
5656
with:
5757
python-version: ${{ matrix.python-version }}
5858
architecture: x64

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.1.0
3+
rev: v4.0.1
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -10,25 +10,26 @@ repos:
1010
- id: double-quote-string-fixer
1111

1212
- repo: https://github.com/ambv/black
13-
rev: 19.10b0
13+
rev: 21.5b2
1414
hooks:
1515
- id: black
1616
args: ["--line-length", "80", "--skip-string-normalization"]
1717

1818
- repo: https://gitlab.com/pycqa/flake8
19-
rev: 3.8.3
19+
rev: 3.9.2
2020
hooks:
2121
- id: flake8
2222
- repo: https://github.com/asottile/seed-isort-config
2323
rev: v2.2.0
2424
hooks:
2525
- id: seed-isort-config
2626
- repo: https://github.com/pre-commit/mirrors-isort
27-
rev: v5.2.1
27+
rev: v5.8.0
2828
hooks:
2929
- id: isort
3030

31-
- repo: https://github.com/prettier/prettier
32-
rev: 2.0.5
31+
- repo: https://github.com/pre-commit/mirrors-prettier
32+
rev: v2.2.0
3333
hooks:
3434
- id: prettier
35+
language_version: system

conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
4+
@pytest.fixture(autouse=True)
5+
def add_standard_imports(doctest_namespace, tmpdir):
6+
import numpy as np
7+
8+
# always seed numpy.random to make the examples deterministic
9+
np.random.seed(0)

xbatcher/generators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def _drop_input_dims(ds, input_dims, suffix='_input'):
4949
out = out.rename({dim: newdim})
5050
# extra steps needed if there is a coordinate
5151
if newdim in out:
52-
out = out.drop(newdim)
52+
out = out.drop_vars(newdim)
5353
out.coords[dim] = newdim, ds[dim].data, ds[dim].attrs
5454
return out
5555

5656

5757
def _maybe_stack_batch_dims(ds, input_dims, stacked_dim_name='sample'):
58-
batch_dims = list(set(ds.dims) - set(input_dims))
58+
batch_dims = [d for d in ds.dims if d not in input_dims]
5959
if len(batch_dims) < 2:
6060
return ds
6161
ds_stack = ds.stack(**{stacked_dim_name: batch_dims})

xbatcher/tests/test_generators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_batch_1d_concat(sample_ds_1d, bsize):
4747
@pytest.mark.parametrize('bsize', [5, 10])
4848
def test_batch_1d_no_coordinate(sample_ds_1d, bsize):
4949
# fix for #3
50-
ds_dropped = sample_ds_1d.drop('x')
50+
ds_dropped = sample_ds_1d.drop_vars('x')
5151
bg = BatchGenerator(ds_dropped, input_dims={'x': bsize})
5252
for n, ds_batch in enumerate(bg):
5353
assert isinstance(ds_batch, xr.Dataset)
@@ -60,7 +60,7 @@ def test_batch_1d_no_coordinate(sample_ds_1d, bsize):
6060
@pytest.mark.parametrize('bsize', [5, 10])
6161
def test_batch_1d_concat_no_coordinate(sample_ds_1d, bsize):
6262
# test for #3
63-
ds_dropped = sample_ds_1d.drop('x')
63+
ds_dropped = sample_ds_1d.drop_vars('x')
6464
bg = BatchGenerator(
6565
ds_dropped, input_dims={'x': bsize}, concat_input_dims=True
6666
)
@@ -118,7 +118,7 @@ def test_batch_3d_1d_input(sample_ds_3d, bsize):
118118
expected_slice = slice(bsize * n, bsize * (n + 1))
119119
ds_batch_expected = (
120120
sample_ds_3d.isel(x=expected_slice)
121-
.stack(sample=['y', 'time'])
121+
.stack(sample=['time', 'y'])
122122
.transpose('sample', 'x')
123123
)
124124
print(ds_batch)

0 commit comments

Comments
 (0)