Skip to content

Commit 2c22b12

Browse files
committed
Make black
1 parent 943f7fd commit 2c22b12

File tree

4 files changed

+36
-30
lines changed

4 files changed

+36
-30
lines changed

scripts/test_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def import_submodules(package_name):
1313
package = importlib.import_module(package_name)
1414

1515
for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
16-
full_name = package.__name__ + '.' + name
16+
full_name = package.__name__ + "." + name
1717
importlib.import_module(full_name)
1818
if is_pkg:
1919
import_submodules(full_name)

src/netcdf_scm/iris_cube_wrappers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ class MarbleCMIP5Cube(_CMIPCube):
10101010
recommended CMIP5 directory structure described in section 3.1 of the
10111011
`CMIP5 Data Reference Syntax <https://cmip.llnl.gov/cmip5/docs/cmip5_data_reference_syntax_v1-00_clean.pdf>`_.
10121012
"""
1013+
10131014
def process_filename(self, filename):
10141015
"""Cut a filename into its identifiers
10151016
@@ -1236,6 +1237,7 @@ class CMIP6Input4MIPsCube(_CMIPCube):
12361237
The data must match the CMIP6 Forcing Datasets Summary, specifically the
12371238
`Forcing Dataset Specifications <https://docs.google.com/document/d/1pU9IiJvPJwRvIgVaSDdJ4O0Jeorv_2ekEtted34K9cA/edit#heading=h.cn9f7982ycw6>`_.
12381239
"""
1240+
12391241
def process_filename(self, filename):
12401242
"""Cut a filename into its identifiers
12411243
@@ -1489,7 +1491,6 @@ def _get_metadata_load_arguments(self, metadata_variable):
14891491
"file_ext": self.file_ext,
14901492
}
14911493

1492-
14931494
def _get_data_filename(self):
14941495
bits_to_join = [
14951496
self.variable_id,
@@ -1527,6 +1528,7 @@ class CMIP6OutputCube(_CMIPCube):
15271528
template' and 'Directory structure template' sections of the
15281529
`CMIP6 Data Reference Syntax <https://goo.gl/v1drZl>`_.
15291530
"""
1531+
15301532
def process_filename(self, filename):
15311533
"""Cut a filename into its identifiers
15321534
@@ -1762,7 +1764,6 @@ def _get_metadata_load_arguments(self, metadata_variable):
17621764
"file_ext": self.file_ext,
17631765
}
17641766

1765-
17661767
def _get_data_filename(self):
17671768
bits_to_join = [
17681769
self.variable_id,

tests/integration/test_integrated_behaviour_scmcube.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ def test_load_gregorian_calendar_with_pre_zero_years(self, test_cube):
387387
class TestMarbleCMIP5Cube(_SCMCubeIntegrationTester):
388388
tclass = MarbleCMIP5Cube
389389

390-
391390
def test_load_and_concatenate_files_in_directory_same_time(self, test_cube):
392391
tdir = join(
393392
TEST_DATA_MARBLE_CMIP5_DIR,
@@ -501,17 +500,18 @@ def test_get_load_data_from_identifiers_args_from_filepath_no_root_dir(
501500

502501
@pytest.mark.parametrize(
503502
"tpath",
504-
[
505-
"cmip5/1pctCO2/fx/sftlf/CanESM2/r0i0p0/sftlf_fx_HadGem3_1pctCO2_r0i0p0.nc"
506-
],
503+
["cmip5/1pctCO2/fx/sftlf/CanESM2/r0i0p0/sftlf_fx_HadGem3_1pctCO2_r0i0p0.nc"],
507504
)
508505
def test_get_load_data_from_identifiers_args_from_filepath_errors(
509506
self, test_cube, tpath
510507
):
511508
error_msg = (
512-
re.escape("Path and filename do not agree:") + "\n"
513-
+ re.escape(" - path model: CanESM2") + "\n"
514-
+ re.escape(" - filename model: HadGem3") + "\n"
509+
re.escape("Path and filename do not agree:")
510+
+ "\n"
511+
+ re.escape(" - path model: CanESM2")
512+
+ "\n"
513+
+ re.escape(" - filename model: HadGem3")
514+
+ "\n"
515515
)
516516
with pytest.raises(ValueError, match=error_msg):
517517
test_cube.get_load_data_from_identifiers_args_from_filepath(tpath)
@@ -520,7 +520,6 @@ def test_get_load_data_from_identifiers_args_from_filepath_errors(
520520
class TestCMIP6Input4MIPsCube(_SCMCubeIntegrationTester):
521521
tclass = CMIP6Input4MIPsCube
522522

523-
524523
def test_load_gregorian_calendar_with_pre_zero_years(self, test_cube):
525524
expected_warn = (
526525
"Your calendar is gregorian yet has units of 'days since 0-1-1'. We "
@@ -627,16 +626,19 @@ def test_get_load_data_from_identifiers_args_from_filepath_no_root_dir(
627626
@pytest.mark.parametrize(
628627
"tpath",
629628
[
630-
"input4MIPs/CMIP6/CMIP/PCMDI/PCMDI-AMIP-1-1-4/ocean/mon/tas/gn/v20180427/tos_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-4_gn_187001-201712.nc",
629+
"input4MIPs/CMIP6/CMIP/PCMDI/PCMDI-AMIP-1-1-4/ocean/mon/tas/gn/v20180427/tos_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-4_gn_187001-201712.nc"
631630
],
632631
)
633632
def test_get_load_data_from_identifiers_args_from_filepath_errors(
634633
self, test_cube, tpath
635634
):
636635
error_msg = (
637-
re.escape("Path and filename do not agree:") + "\n"
638-
+ re.escape(" - path variable_id: tas") + "\n"
639-
+ re.escape(" - filename variable_id: tos") + "\n"
636+
re.escape("Path and filename do not agree:")
637+
+ "\n"
638+
+ re.escape(" - path variable_id: tas")
639+
+ "\n"
640+
+ re.escape(" - filename variable_id: tos")
641+
+ "\n"
640642
)
641643
with pytest.raises(ValueError, match=error_msg):
642644
test_cube.get_load_data_from_identifiers_args_from_filepath(tpath)
@@ -645,7 +647,6 @@ def test_get_load_data_from_identifiers_args_from_filepath_errors(
645647
class TestCMIP6OutputCube(_SCMCubeIntegrationTester):
646648
tclass = CMIP6OutputCube
647649

648-
649650
def test_get_load_data_from_identifiers_args_from_filepath(self, test_cube):
650651
tpath = "tests/test_data/cmip6-output/CMIP6/DCPP/CNRM-CERFACS/CNRM-CM6-1/dcppA-hindcast/s1960-r2i1p1f3/day/pr/gn/v20160215/pr_day_CNRM-CM6-1_dcppA-hindcast_s1960-r2i1p1f3_gn_198001-198412.nc"
651652
expected = {
@@ -721,9 +722,12 @@ def test_get_load_data_from_identifiers_args_from_filepath_errors(
721722
self, test_cube, tpath
722723
):
723724
error_msg = (
724-
re.escape("Path and filename do not agree:") + "\n"
725-
+ re.escape(" - path experiment_id: dcppA-hindcast") + "\n"
726-
+ re.escape(" - filename experiment_id: dcppA") + "\n"
725+
re.escape("Path and filename do not agree:")
726+
+ "\n"
727+
+ re.escape(" - path experiment_id: dcppA-hindcast")
728+
+ "\n"
729+
+ re.escape(" - filename experiment_id: dcppA")
730+
+ "\n"
727731
)
728732
with pytest.raises(ValueError, match=error_msg):
729733
test_cube.get_load_data_from_identifiers_args_from_filepath(tpath)

tests/unit/test_scmcube.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,7 @@ def test_load_data_from_path(self, test_cube):
711711
)
712712
test_cube.load_data_from_identifiers.assert_called_with(**tids)
713713

714-
def test_get_load_data_from_identifiers_args_from_filepath(
715-
self, test_cube
716-
):
714+
def test_get_load_data_from_identifiers_args_from_filepath(self, test_cube):
717715
tpath = "/tpath/file.ext"
718716
test_cube.process_path = MagicMock(return_value={"a": "b"})
719717
test_cube.process_filename = MagicMock(return_value={"c": "d"})
@@ -725,16 +723,17 @@ def test_get_load_data_from_identifiers_args_from_filepath(
725723
test_cube.process_path.assert_called_with(dirname(tpath))
726724
test_cube.process_filename.assert_called_with(basename(tpath))
727725

728-
def test_get_load_data_from_identifiers_args_from_filepath_errors(
729-
self, test_cube
730-
):
726+
def test_get_load_data_from_identifiers_args_from_filepath_errors(self, test_cube):
731727
tpath = "/tpath/file.ext"
732728
test_cube.process_path = MagicMock(return_value={"model": "CanESM2"})
733729
test_cube.process_filename = MagicMock(return_value={"model": "HadGem3"})
734730
error_msg = (
735-
re.escape("Path and filename do not agree:") + "\n"
736-
+ re.escape(" - path model: CanESM2") + "\n"
737-
+ re.escape(" - filename model: HadGem3") + "\n"
731+
re.escape("Path and filename do not agree:")
732+
+ "\n"
733+
+ re.escape(" - path model: CanESM2")
734+
+ "\n"
735+
+ re.escape(" - filename model: HadGem3")
736+
+ "\n"
738737
)
739738
with pytest.raises(ValueError, match=error_msg):
740739
test_cube.get_load_data_from_identifiers_args_from_filepath(tpath)
@@ -865,7 +864,9 @@ def test_process_filename_errors(self, test_cube, tname):
865864
test_cube.process_filename(tname)
866865

867866
def test_process_path(self, test_cube):
868-
tpath = "/tests/test_data/marble_cmip5/cmip5/1pctCO2/Amon/fco2antt/CanESM2/r1i1p1/"
867+
tpath = (
868+
"/tests/test_data/marble_cmip5/cmip5/1pctCO2/Amon/fco2antt/CanESM2/r1i1p1/"
869+
)
869870
result = test_cube.process_path(tpath)
870871
expected = {
871872
"root_dir": "/tests/test_data/marble_cmip5",
@@ -1435,7 +1436,7 @@ def test_process_filename(self, test_cube):
14351436
[
14361437
"pr_day_CNRM-CM6-1_dcppA-hindcast_s1960-r2i1p1f3_gn_.nc",
14371438
"dcppA-hindcast_s1960-r2i1p1f3_gn_198001-198412.nc"
1438-
"pr_day_CNRM-CM6-1_dcppA-hindcast_s1960-r2i1p1f3.nc"
1439+
"pr_day_CNRM-CM6-1_dcppA-hindcast_s1960-r2i1p1f3.nc",
14391440
],
14401441
)
14411442
def test_process_filename_errors(self, test_cube, tname):

0 commit comments

Comments
 (0)