Skip to content

Commit fe42841

Browse files
committed
fixing up formatting for lint
1 parent 90a5488 commit fe42841

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tests/experiment/test_map_vars_to_terms.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from dataclasses import dataclass
22
import json
3+
from os.path import join
34
from pathlib import Path
45
import pandas as pd
56
import pytest
67
from nidm.experiment.Utils import map_variables_to_terms, write_json_mapping_file
7-
from os.path import join
8+
89

910
@dataclass
1011
class Setup:
@@ -153,7 +154,7 @@ def setup() -> Setup:
153154
data=data,
154155
reproschema_json_map=reproschema_json_map,
155156
bids_sidecar=bids_sidecar,
156-
bids_sidecar_simple = bids_sidecar_simple,
157+
bids_sidecar_simple=bids_sidecar_simple,
157158
)
158159

159160

@@ -172,8 +173,6 @@ def test_map_vars_to_terms_BIDS(setup: Setup, tmp_path: Path) -> None:
172173
bids=True,
173174
)
174175

175-
176-
177176
# check whether JSON mapping structure returned from map_variables_to_terms matches the
178177
# reproshema structure
179178
assert "DD(source='test', variable='age')" in column_to_terms
@@ -228,7 +227,9 @@ def test_map_vars_to_terms_BIDS(setup: Setup, tmp_path: Path) -> None:
228227
# original.
229228

230229
# write annotations to json file since data element annotations are complete
231-
write_json_mapping_file(column_to_terms, join(str(tmp_path), "nidm_annotations.json"), True)
230+
write_json_mapping_file(
231+
column_to_terms, join(str(tmp_path), "nidm_annotations.json"), True
232+
)
232233

233234
# now check the JSON sidecar file created by map_variables_to_terms which should match BIDS format
234235
with open(tmp_path / "nidm_annotations.json", encoding="utf-8") as fp:
@@ -270,6 +271,7 @@ def test_map_vars_to_terms_BIDS(setup: Setup, tmp_path: Path) -> None:
270271

271272
assert len(results) == 20
272273

274+
273275
def test_map_vars_to_terms_BIDS_simple(setup: Setup, tmp_path: Path) -> None:
274276
"""
275277
This function will test the Utils.py "map_vars_to_terms" function with a BIDS-formatted
@@ -286,33 +288,32 @@ def test_map_vars_to_terms_BIDS_simple(setup: Setup, tmp_path: Path) -> None:
286288
bids=True,
287289
)
288290

289-
290-
291291
# check whether JSON mapping structure returned from map_variables_to_terms matches the
292292
# reproshema structure
293293
assert "DD(source='test', variable='age')" in column_to_terms
294294
assert "DD(source='test', variable='sex')" in column_to_terms
295295
assert "description" in column_to_terms["DD(source='test', variable='age')"]
296296
assert "description" in column_to_terms["DD(source='test', variable='sex')"]
297297

298-
299298
# force writing of column_to_terms structure because here we're not doing annotations and so
300299
# map_variables_to_terms won't write it out since we supplied one for it to open...thus it already exists
301300
# and no annotations were made so it should exist in its original form.
302301
# By explicitly writing it out here, after running map_variables_to_terms, we can assure it's the same as the
303302
# original.
304303

305304
# write annotations to json file since data element annotations are complete
306-
write_json_mapping_file(column_to_terms, join(str(tmp_path), "nidm_annotations.json"), True)
305+
write_json_mapping_file(
306+
column_to_terms, join(str(tmp_path), "nidm_annotations.json"), True
307+
)
307308

308309
# now check the JSON sidecar file created by map_variables_to_terms which should match BIDS format
309310
with open(tmp_path / "nidm_annotations.json", encoding="utf-8") as fp:
310311
bids_sidecar = json.load(fp)
311312

312313
assert "age" in bids_sidecar.keys()
313314
assert "sex" in bids_sidecar.keys()
314-
assert "description" in bids_sidecar['age']
315-
assert "description" in bids_sidecar['sex']
315+
assert "description" in bids_sidecar["age"]
316+
assert "description" in bids_sidecar["sex"]
316317

317318
# check the CDE dataelement graph for correct information
318319
query = """
@@ -333,6 +334,7 @@ def test_map_vars_to_terms_BIDS_simple(setup: Setup, tmp_path: Path) -> None:
333334

334335
assert len(results) == 16
335336

337+
336338
def test_map_vars_to_terms_reproschema(setup: Setup, tmp_path: Path) -> None:
337339
"""
338340
This function will test the Utils.py "map_vars_to_terms" function with a reproschema-formatted
@@ -400,7 +402,9 @@ def test_map_vars_to_terms_reproschema(setup: Setup, tmp_path: Path) -> None:
400402
# original.
401403

402404
# write annotations to json file since data element annotations are complete
403-
write_json_mapping_file(column_to_terms, join(str(tmp_path), "nidm_annotations.json"), False)
405+
write_json_mapping_file(
406+
column_to_terms, join(str(tmp_path), "nidm_annotations.json"), False
407+
)
404408

405409
# now check the JSON mapping file created by map_variables_to_terms which should match Reproschema format
406410
with open(tmp_path / "nidm_annotations_annotations.json", encoding="utf-8") as fp:

0 commit comments

Comments
 (0)