Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #2525

Merged
merged 2 commits into from
Sep 26, 2024
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude: |

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -24,16 +24,16 @@ repos:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/adrienverge/yamllint
rev: 'v1.31.0'
rev: 'v1.35.1'
hooks:
- id: yamllint
- repo: https://github.com/codespell-project/codespell
rev: 'v2.2.4'
rev: 'v2.3.0'
hooks:
- id: codespell
additional_dependencies: [tomli] # required for Python 3.10
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.10"
rev: "v0.6.8"
hooks:
- id: ruff
args: [--fix]
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
level of experience, education, socioeconomic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards
Expand Down
2 changes: 1 addition & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ Highlights
~~~~~~~~~~

- ESMValCore now has the ability to automatically download missing data from ESGF. For details, see :ref:`Data Retrieval<data-retrieval>`.
- ESMValCore now also can resume an earlier run. This is useful to re-use expensive preprocessor results. For details, see :ref:`Running<running>`.
- ESMValCore now also can resume an earlier run. This is useful to reuse expensive preprocessor results. For details, see :ref:`Running<running>`.

This release includes

Expand Down
2 changes: 1 addition & 1 deletion doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Please keep the following considerations in mind when programming:
code.
- If you find yourself copy-pasting a piece of code and making minor changes
to every copy, instead put the repeated bit of code in a function that you can
re-use, and provide the changed bits as function arguments.
reuse, and provide the changed bits as function arguments.
- Be careful when changing existing unit tests to make your new feature work.
You might be breaking existing features if you have to change existing tests.

Expand Down
2 changes: 1 addition & 1 deletion doc/quickstart/find_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ Key Description Default value if not
recipe if default DRS is used)
```special_attr`` A special attribute in the filename No default
`ACCESS-ESM` raw data, it's related to
frquency of raw data
frequency of raw data
``sub_dataset`` Part of the ACCESS-ESM raw dataset No default
root, need to specify if you want to
use the cmoriser
Expand Down
4 changes: 2 additions & 2 deletions doc/quickstart/run.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ Possible values are:
- `default`: fail if there are any errors.
- `strict`: fail if there are any warnings.

To re-use pre-processed files from a previous run of the same recipe, you can
To reuse pre-processed files from a previous run of the same recipe, you can
use

.. code:: bash

esmvaltool run recipe_example.yml --resume_from ~/esmvaltool_output/recipe_python_20210930_123907

Multiple directories can be specified for re-use, make sure to quote them:
Multiple directories can be specified for reuse, make sure to quote them:

.. code:: bash

Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AllVars(Fix):
def fix_metadata(self, cubes):
"""Fix metadata.

Remove unnecessary spaces in metadat and rename ``var_name`` of
Remove unnecessary spaces in metadata and rename ``var_name`` of
latitude and longitude and fix longitude boundary description may be
wrong (lons=[0, ..., 356.25]; on_bnds=[[-1.875, 1.875], ..., [354.375,
360]]).
Expand Down
45 changes: 23 additions & 22 deletions notebooks/composing-recipes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"metadata": {},
"outputs": [],
"source": [
"import yaml\n",
"\n",
"from esmvalcore.config import CFG\n",
"from esmvalcore.dataset import Dataset, datasets_to_recipe\n",
"import yaml"
"from esmvalcore.dataset import Dataset, datasets_to_recipe"
]
},
{
Expand All @@ -38,7 +39,7 @@
"metadata": {},
"outputs": [],
"source": [
"CFG['search_esgf'] = 'always'"
"CFG[\"search_esgf\"] = \"always\""
]
},
{
Expand Down Expand Up @@ -84,18 +85,18 @@
],
"source": [
"tas = Dataset(\n",
" short_name='tas',\n",
" mip='Amon',\n",
" project='CMIP6',\n",
" dataset='CanESM5-1',\n",
" ensemble='r1i1p1f1',\n",
" exp='historical',\n",
" grid='gn',\n",
" timerange='2000/2002',\n",
" short_name=\"tas\",\n",
" mip=\"Amon\",\n",
" project=\"CMIP6\",\n",
" dataset=\"CanESM5-1\",\n",
" ensemble=\"r1i1p1f1\",\n",
" exp=\"historical\",\n",
" grid=\"gn\",\n",
" timerange=\"2000/2002\",\n",
")\n",
"tas['diagnostic'] = 'diagnostic_name'\n",
"tas[\"diagnostic\"] = \"diagnostic_name\"\n",
"\n",
"pr = tas.copy(short_name='pr')\n",
"pr = tas.copy(short_name=\"pr\")\n",
"\n",
"print(yaml.safe_dump(datasets_to_recipe([tas, pr])))"
]
Expand Down Expand Up @@ -127,14 +128,14 @@
],
"source": [
"dataset_template = Dataset(\n",
" short_name='tas',\n",
" mip='Amon',\n",
" project='CMIP6',\n",
" exp='historical',\n",
" dataset='*',\n",
" institute='*',\n",
" ensemble='*',\n",
" grid='*',\n",
" short_name=\"tas\",\n",
" mip=\"Amon\",\n",
" project=\"CMIP6\",\n",
" exp=\"historical\",\n",
" dataset=\"*\",\n",
" institute=\"*\",\n",
" ensemble=\"*\",\n",
" grid=\"*\",\n",
")\n",
"datasets = list(dataset_template.from_files())\n",
"len(datasets)"
Expand Down Expand Up @@ -584,7 +585,7 @@
],
"source": [
"for dataset in datasets:\n",
" dataset.facets['diagnostic'] = 'diagnostic_name'\n",
" dataset.facets[\"diagnostic\"] = \"diagnostic_name\"\n",
"print(yaml.safe_dump(datasets_to_recipe(datasets)))"
]
}
Expand Down
27 changes: 13 additions & 14 deletions notebooks/discovering-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"outputs": [],
"source": [
"from esmvalcore.config import CFG\n",
"from esmvalcore.dataset import Dataset, datasets_to_recipe\n",
"from esmvalcore.esgf import download\n",
"import yaml"
"from esmvalcore.dataset import Dataset\n",
"from esmvalcore.esgf import download"
]
},
{
Expand All @@ -40,7 +39,7 @@
"metadata": {},
"outputs": [],
"source": [
"CFG['search_esgf'] = 'always'"
"CFG[\"search_esgf\"] = \"always\""
]
},
{
Expand All @@ -60,14 +59,14 @@
"outputs": [],
"source": [
"dataset_template = Dataset(\n",
" short_name='tas',\n",
" mip='Amon',\n",
" project='CMIP6',\n",
" exp='historical',\n",
" dataset='*',\n",
" institute='*',\n",
" ensemble='*',\n",
" grid='*',\n",
" short_name=\"tas\",\n",
" mip=\"Amon\",\n",
" project=\"CMIP6\",\n",
" exp=\"historical\",\n",
" dataset=\"*\",\n",
" institute=\"*\",\n",
" ensemble=\"*\",\n",
" grid=\"*\",\n",
")"
]
},
Expand Down Expand Up @@ -292,7 +291,7 @@
}
],
"source": [
"dataset.files[0].download(CFG['download_dir'])"
"dataset.files[0].download(CFG[\"download_dir\"])"
]
},
{
Expand All @@ -311,7 +310,7 @@
"metadata": {},
"outputs": [],
"source": [
"download(dataset.files, CFG['download_dir'])"
"download(dataset.files, CFG[\"download_dir\"])"
]
}
],
Expand Down
32 changes: 16 additions & 16 deletions notebooks/loading-and-processing-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"source": [
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import iris.quickplot\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from esmvalcore.config import CFG\n",
"from esmvalcore.dataset import Dataset\n",
"from esmvalcore.esgf import download, ESGFFile\n",
"from esmvalcore.preprocessor import area_statistics, annual_statistics"
"from esmvalcore.esgf import ESGFFile, download\n",
"from esmvalcore.preprocessor import annual_statistics, area_statistics"
]
},
{
Expand All @@ -43,7 +43,7 @@
"metadata": {},
"outputs": [],
"source": [
"CFG['search_esgf'] = 'when_missing'"
"CFG[\"search_esgf\"] = \"when_missing\""
]
},
{
Expand Down Expand Up @@ -80,13 +80,13 @@
],
"source": [
"tas = Dataset(\n",
" short_name='tas',\n",
" mip='Amon',\n",
" project='CMIP5',\n",
" dataset='MPI-ESM-MR',\n",
" ensemble='r1i1p1',\n",
" exp='historical',\n",
" timerange='1850/2000',\n",
" short_name=\"tas\",\n",
" mip=\"Amon\",\n",
" project=\"CMIP5\",\n",
" dataset=\"MPI-ESM-MR\",\n",
" ensemble=\"r1i1p1\",\n",
" exp=\"historical\",\n",
" timerange=\"1850/2000\",\n",
")\n",
"tas"
]
Expand Down Expand Up @@ -124,7 +124,7 @@
}
],
"source": [
"tas.add_supplementary(short_name='areacella', mip='fx', ensemble='r0i0p0')\n",
"tas.add_supplementary(short_name=\"areacella\", mip=\"fx\", ensemble=\"r0i0p0\")\n",
"tas.supplementaries"
]
},
Expand Down Expand Up @@ -247,7 +247,7 @@
"for supplementary_ds in tas.supplementaries:\n",
" files.extend(supplementary_ds.files)\n",
"files = [file for file in files if isinstance(file, ESGFFile)]\n",
"download(files, CFG['download_dir'])\n",
"download(files, CFG[\"download_dir\"])\n",
"tas.find_files()\n",
"print(tas.files)\n",
"for supplementary_ds in tas.supplementaries:\n",
Expand Down Expand Up @@ -548,9 +548,9 @@
"metadata": {},
"outputs": [],
"source": [
"cube = area_statistics(cube, operator='mean')\n",
"cube = annual_statistics(cube, operator='mean')\n",
"cube.convert_units('degrees_C')"
"cube = area_statistics(cube, operator=\"mean\")\n",
"cube = annual_statistics(cube, operator=\"mean\")\n",
"cube.convert_units(\"degrees_C\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version_scheme = "release-branch-semver"

[tool.codespell]
skip = "*.ipynb,esmvalcore/config/extra_facets/ipslcm-mappings.yml"
ignore-words-list = "vas,hist"
ignore-words-list = "vas,hist,oce"

[tool.pylint.main]
jobs = 1 # Running more than one job in parallel crashes prospector.
Expand Down
32 changes: 13 additions & 19 deletions tests/unit/preprocessor/_volume/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,46 +657,42 @@ def test_volume_statistics_invalid_bounds(self):

with self.assertRaises(ValueError) as err:
volume_statistics(self.grid_invalid_z_bounds, "mean")
self.assertIn(
assert (
"Z axis bounds shape found (3, 2, 2, 4). Bounds should be "
"2 in the last dimension to compute the thickness.",
str(err.exception),
)
"2 in the last dimension to compute the thickness."
) in str(err.exception)

def test_volume_statistics_invalid_units(self):
"""Test z-axis units cannot be converted to m"""

with self.assertRaises(ValueError) as err:
volume_statistics(self.grid_4d_sigma_space, "mean")
self.assertIn(
assert (
"Cannot compute volume using the Z-axis. "
"Unable to convert from 'Unit('kg m-3')' to 'Unit('m')'.",
str(err.exception),
)
"Unable to convert from 'Unit('kg m-3')' to 'Unit('m')'."
) in str(err.exception)

def test_volume_statistics_z_axis_time_error(self):
# Fails because depth z-axis coord depends on time dimensions
# which would aggregate also along that dimension
with self.assertRaises(ValueError) as err:
volume_statistics(self.grid_4d_z, "mean")
self.assertIn(
assert (
"X and Y axis coordinates depend on (2, 3) dimensions, "
"while X, Y, and Z axis depends on (0, 1, 2, 3) dimensions. "
"This may indicate Z axis depending on other dimension than "
"space that could provoke invalid aggregation...",
str(err.exception),
)
"space that could provoke invalid aggregation..."
) in str(err.exception)

grid_3d_no_x = self.grid_4d_z[..., 0]
with self.assertRaises(ValueError) as err:
volume_statistics(grid_3d_no_x, "mean")
self.assertIn(
assert (
"X and Y axis coordinates depend on (2,) dimensions, "
"while X, Y, and Z axis depends on (0, 1, 2) dimensions. "
"This may indicate Z axis depending on other dimension than "
"space that could provoke invalid aggregation...",
str(err.exception),
)
"space that could provoke invalid aggregation..."
) in str(err.exception)

def test_volume_statistics_missing_axis(self):
# x axis is missing
Expand All @@ -711,9 +707,7 @@ def test_volume_statistics_missing_axis(self):
grid_no_z = self.grid_4d[:, 0]
with self.assertRaises(ValueError) as err:
volume_statistics(grid_no_z, "mean")
self.assertIn(
"Cannot compute volume with scalar Z-axis", str(err.exception)
)
assert "Cannot compute volume with scalar Z-axis" in str(err.exception)

def test_volume_statistics_2d_depth(self):
# Create new 2D depth coord
Expand Down
Loading