Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esmvalcore/cmor/_fixes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Automatic fixes for input data
Automatic fixes for input data.

Module to apply automatic fixes at different levels to input data for known
errors.
Expand Down
4 changes: 2 additions & 2 deletions esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AllVars(BaseAllVars):


class Areacello(Fix):
"""Fixes for areacello"""
"""Fixes for areacello."""

def fix_metadata(self, cubes):
"""
Expand Down Expand Up @@ -56,7 +56,7 @@ def fix_data(self, cube):


class Tos(Fix):
"""Fixes for tos"""
"""Fixes for tos."""

def fix_metadata(self, cubes):
"""
Expand Down
4 changes: 3 additions & 1 deletion esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def fix_metadata(self, cubes):


class Areacello(Fix):
"""Fixes for areacello"""
"""Fixes for areacello."""

def fix_metadata(self, cubes):
"""
Expand Down Expand Up @@ -116,6 +116,7 @@ def fix_metadata(self, cubes):
Parameters
----------
cubes: iris.cube.CubeList

Returns
-------
iris.cube.CubeList
Expand All @@ -137,6 +138,7 @@ def fix_metadata(self, cubes):
Parameters
----------
cubes: iris.cube.CubeList

Returns
-------
iris.cube.CubeList
Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AllVars(BaseAllVars):


class Areacello(Fix):
"""Fixes for areacello"""
"""Fixes for areacello."""

def fix_metadata(self, cubes):
"""
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ line-length = 79
[tool.ruff.lint]
select = [
"B",
"D", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"I", # isort
Expand All @@ -42,10 +43,19 @@ select = [
]
ignore = [
"E501", # Disable line-too-long as this is taken care of by the formatter.
"D105", # Disable Missing docstring in magic method as these are well defined.
]
[tool.ruff.lint.per-file-ignores]
"tests/**.py" = [
"B011", # `assert False` is valid test code.
# Docstrings in tests are only needed if the code is not self-explanatory.
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
]
[tool.ruff.lint.isort]
known-first-party = ["esmvalcore"]
[tool.ruff.lint.pydocstyle]
convention = "numpy"
6 changes: 1 addition & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ class Test(unittest.TestCase):
"""Provides esmvaltool specific testing functionality."""

def _remove_testcase_patches(self):
"""
Helper method to remove per-testcase patches installed by
:meth:`patch`.

"""
"""Remove per-testcase patches installed by :meth:`patch`."""
# Remove all patches made, ignoring errors.
for patch in self.testcase_patches:
patch.stop()
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@pytest.fixture
def cfg_default(mocker):
"""Configuration object with defaults."""
"""Create a configuration object with default values."""
cfg = deepcopy(CFG)
cfg.load_from_dirs([])
return cfg
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setUp(self):
self.fix = Cl(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
fix = Fix.get_fixes("CMIP5", "BNU-ESM", "Amon", "cl")
assert fix == [Cl(None), GenericFix(None)]

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
self.fix = Msftmyz(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "CNRM-CM5", "Amon", "msftmyz"),
[Msftmyz(None), GenericFix(None)],
Expand All @@ -41,7 +41,7 @@ def setUp(self):
self.fix = Msftmyzba(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "CNRM-CM5", "Amon", "msftmyzba"),
[Msftmyzba(None), GenericFix(None)],
Expand Down
16 changes: 5 additions & 11 deletions tests/integration/cmor/_fixes/cmip5/test_ec_earth.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):
self.fix = Sic(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "sic"),
[Sic(None), GenericFix(None)],
Expand All @@ -50,7 +50,7 @@ def setUp(self):
self.fix = Sftlf(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "sftlf"),
[Sftlf(None), GenericFix(None)],
Expand All @@ -68,7 +68,6 @@ class TestTas(unittest.TestCase):

def setUp(self):
"""Prepare tests."""

height_coord = DimCoord(
2.0,
standard_name="height",
Expand Down Expand Up @@ -99,15 +98,14 @@ def setUp(self):
self.fix = Tas(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "tas"),
[Tas(None), GenericFix(None)],
)

def test_tas_fix_metadata(self):
"""Test metadata fix."""

out_cube_without = self.fix.fix_metadata(self.cube_without)

# make sure this does not raise an error
Expand All @@ -131,7 +129,6 @@ class TestAreacello(unittest.TestCase):

def setUp(self):
"""Prepare tests."""

latitude = Cube(
np.ones((2, 2)),
standard_name="latitude",
Expand Down Expand Up @@ -163,15 +160,14 @@ def setUp(self):
self.fix = Areacello(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "EC-EARTH", "Omon", "areacello"),
[Areacello(None), GenericFix(None)],
)

def test_areacello_fix_metadata(self):
"""Test metadata fix."""

out_cube = self.fix.fix_metadata(self.cubes)
assert len(out_cube) == 1

Expand All @@ -184,7 +180,6 @@ class TestPr(unittest.TestCase):

def setUp(self):
"""Prepare tests."""

wrong_time_coord = AuxCoord(
points=[1.0, 2.0, 1.0, 2.0, 3.0],
var_name="time",
Expand Down Expand Up @@ -226,15 +221,14 @@ def setUp(self):
self.fix = Pr(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "pr"),
[Pr(None), GenericFix(None)],
)

def test_pr_fix_metadata(self):
"""Test metadata fix."""

out_wrong_cube = self.fix.fix_metadata(self.wrong_cube)
out_correct_cube = self.fix.fix_metadata(self.correct_cube)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/cmor/_fixes/cmip5/test_fio_esm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def setUp(self):
self.fix = Ch4(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "FIO-ESM", "Amon", "ch4"),
[Ch4(None), GenericFix(None)],
Expand All @@ -53,7 +53,7 @@ def setUp(self):
self.fix = Co2(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "FIO-ESM", "Amon", "co2"),
[Co2(None), GenericFix(None)],
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setUp(self):
self.fix = Sftof(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-CM2P1", "fx", "sftof"),
[Sftof(None), AllVars(None), GenericFix(None)],
Expand All @@ -67,7 +67,7 @@ def setUp(self):
self.fix = Areacello(self.vardef)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-CM2P1", "Amon", "areacello"),
[
Expand Down Expand Up @@ -114,7 +114,7 @@ def setUp(self):
self.fix = Sit(self.var_info_mock)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-CM2P1", "OImon", "sit"),
[Sit(self.var_info_mock), AllVars(None), GenericFix(None)],
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUp(self):
self.fix = Sftof(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-CM3", "fx", "sftof"),
[Sftof(None), AllVars(None), GenericFix(None)],
Expand All @@ -43,7 +43,7 @@ def setUp(self):
self.fix = Areacello(self.vardef)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-CM3", "Amon", "areacello"),
[
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setUp(self):
self.fix = Co2(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2G", "Amon", "co2"),
[Co2(None), AllVars(None), GenericFix(None)],
Expand All @@ -102,7 +102,7 @@ def setUp(self):
self.fix = Usi(self.vardef)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2G", "day", "usi"),
[Usi(self.vardef), AllVars(self.vardef), GenericFix(self.vardef)],
Expand All @@ -124,7 +124,7 @@ def setUp(self):
self.fix = Vsi(self.vardef)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2G", "day", "vsi"),
[Vsi(self.vardef), AllVars(self.vardef), GenericFix(self.vardef)],
Expand All @@ -146,7 +146,7 @@ def setUp(self):
self.fix = Areacello(self.vardef)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2G", "fx", "areacello"),
[
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUp(self):
self.fix = Sftof(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2M", "fx", "sftof"),
[Sftof(None), AllVars(None), GenericFix(None)],
Expand All @@ -47,7 +47,7 @@ def setUp(self):
self.fix = Co2(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2M", "Amon", "co2"),
[Co2(None), AllVars(None), GenericFix(None)],
Expand All @@ -70,7 +70,7 @@ def setUp(self):
self.fix = Areacello(self.vardef)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "GFDL-ESM2M", "fx", "areacello"),
[
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestAllVars(unittest.TestCase):
"""Test allvars fixes."""

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "HADGEM2-CC", "Amon", "tas"),
[AllVars(None), GenericFix(None)],
Expand All @@ -22,7 +22,7 @@ class TestO2(unittest.TestCase):
"""Test o2 fixes."""

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "HADGEM2-CC", "Amon", "o2"),
[O2(None), AllVars(None), GenericFix(None)],
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
self.fix = Tro3(None)

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "MIROC-ESM-CHEM", "Amon", "tro3"),
[Tro3(None), GenericFix(None)],
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestMsftmyz(unittest.TestCase):
"""Test msftmyz fixes."""

def test_get(self):
"""Test fix get"""
"""Test fix get."""
self.assertListEqual(
Fix.get_fixes("CMIP5", "MRI-ESM1", "Amon", "msftmyz"),
[Msftmyz(None), GenericFix(None)],
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_tas(cubes_in, cubes_out):


def test_get():
"""Test fix get"""
"""Test fix get."""
assert Fix.get_fixes("CMIP5", "NORESM1-ME", "Amon", "tas") == [
Tas(None),
GenericFix(None),
Expand Down
Loading