Skip to content

Commit a0301f6

Browse files
author
Joseph Hamman
committed
fix failing test
1 parent 5bf7145 commit a0301f6

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

.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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ 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

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)