Skip to content

Commit 363cd66

Browse files
authored
Fix CI tests (#146)
* fix tqdm.auto frontend test * try fix CI lint * CI lint: show black diff * update black 20.x and apply
1 parent d26c9e4 commit 363cd66

File tree

8 files changed

+34
-13
lines changed

8 files changed

+34
-13
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Set up Python 3.8
18-
uses: actions/setup-python@v1
18+
uses: actions/setup-python@v2
1919
with:
2020
python-version: 3.8
2121
- name: Lint with flake8
@@ -28,4 +28,4 @@ jobs:
2828
- name: Check formatting with black
2929
run: |
3030
pip install black
31-
black --check .
31+
black --check --diff .

versioneer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,11 +1237,15 @@ def versions_from_file(filename):
12371237
except EnvironmentError:
12381238
raise NotThisMethod("unable to read _version.py")
12391239
mo = re.search(
1240-
r"version_json = '''\n(.*)''' # END VERSION_JSON", contents, re.M | re.S,
1240+
r"version_json = '''\n(.*)''' # END VERSION_JSON",
1241+
contents,
1242+
re.M | re.S,
12411243
)
12421244
if not mo:
12431245
mo = re.search(
1244-
r"version_json = '''\r\n(.*)''' # END VERSION_JSON", contents, re.M | re.S,
1246+
r"version_json = '''\r\n(.*)''' # END VERSION_JSON",
1247+
contents,
1248+
re.M | re.S,
12451249
)
12461250
if not mo:
12471251
raise NotThisMethod("no version_json in _version.py")

xsimlab/stores.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def _create_zarr_dataset(
246246
self.consolidated = False
247247

248248
def _maybe_resize_zarr_dataset(
249-
self, model: Model, var_key: VarKey,
249+
self,
250+
model: Model,
251+
var_key: VarKey,
250252
):
251253
# Maybe increases the length of one or more dimensions of
252254
# the zarr array (only increases, never shrinks dimensions).

xsimlab/tests/test_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ def test_create_variable_cache(self, model):
6262
},
6363
{},
6464
),
65-
("add", {"offset": ("add", "offset")}, {"u_diff": ("add", "u_diff")},),
65+
(
66+
"add",
67+
{"offset": ("add", "offset")},
68+
{"u_diff": ("add", "u_diff")},
69+
),
6670
],
6771
)
6872
def test_set_process_keys(

xsimlab/tests/test_monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@pytest.mark.parametrize(
1111
"frontend,tqdm_module",
1212
[
13-
("auto", "tqdm"), # assume tests are run in a terminal evironment
13+
("auto", "tqdm.auto"),
1414
("console", "tqdm"),
1515
("gui", "tqdm.gui"),
1616
("notebook", "tqdm.notebook"),

xsimlab/tests/test_stores.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ class P:
198198
model = xs.Model({"p": P})
199199

200200
in_ds = xs.create_setup(
201-
model=model, clocks={"clock": [0, 1, 2]}, output_vars={"p__arr": "clock"},
201+
model=model,
202+
clocks={"clock": [0, 1, 2]},
203+
output_vars={"p__arr": "clock"},
202204
)
203205

204206
store = ZarrSimulationStore(in_ds, model)

xsimlab/tests/test_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def test_frozen():
142142
with pytest.raises(AttributeError):
143143
x.update({"c": "C", "b": "B"})
144144
assert x.mapping == mapping
145-
assert repr(x) in ("Frozen({'a': 'A', 'b': 'B'})", "Frozen({'b': 'B', 'a': 'A'})",)
145+
assert repr(x) in (
146+
"Frozen({'a': 'A', 'b': 'B'})",
147+
"Frozen({'b': 'B', 'a': 'A'})",
148+
)
146149
# test iter
147150
assert set(x) == set(mapping)
148151
assert len(x) == 2

xsimlab/tests/test_xr_accessor.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def test_update_clocks(self, model):
240240
ds = xr.Dataset()
241241
with pytest.raises(ValueError) as excinfo:
242242
ds.xsimlab.update_clocks(
243-
model=model, clocks={"clock": ("x", [0, 1, 2])},
243+
model=model,
244+
clocks={"clock": ("x", [0, 1, 2])},
244245
)
245246
assert "Invalid dimension" in str(excinfo.value)
246247

@@ -274,7 +275,9 @@ def test_update_clocks(self, model):
274275
assert ds.clock.attrs[self._output_vars_key] == "profile__u"
275276

276277
new_ds = ds.xsimlab.update_clocks(
277-
model=model, clocks={"clock2": [0, 0.5, 1, 1.5, 2]}, master_clock="clock2",
278+
model=model,
279+
clocks={"clock2": [0, 0.5, 1, 1.5, 2]},
280+
master_clock="clock2",
278281
)
279282
assert new_ds.xsimlab.master_clock_dim == "clock2"
280283

@@ -296,7 +299,8 @@ def test_update_vars_promote_to_coords(self, model, in_dataset):
296299
# label that cooresponds to its name (turned into a coordinate). This
297300
# should not raise any merge conflict error
298301
ds = in_dataset.xsimlab.update_vars(
299-
model=model, input_vars={"roll__shift": ("roll__shift", [1, 2])},
302+
model=model,
303+
input_vars={"roll__shift": ("roll__shift", [1, 2])},
300304
)
301305

302306
assert "roll__shift" in ds.coords
@@ -392,7 +396,9 @@ def test_output_vars_by_clock(self, model):
392396
o_vars = {("roll", "u_diff"): "clock", ("add", "u_diff"): None}
393397

394398
ds = xs.create_setup(
395-
model=model, clocks={"clock": [0, 2, 4, 6, 8]}, output_vars=o_vars,
399+
model=model,
400+
clocks={"clock": [0, 2, 4, 6, 8]},
401+
output_vars=o_vars,
396402
)
397403

398404
expected = {"clock": [("roll", "u_diff")], None: [("add", "u_diff")]}

0 commit comments

Comments
 (0)