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

Code qa refresh #568

Merged
merged 7 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ files: |
(?x)(
benchmarks\/.+\.py|
docs\/.+\.py|
docs\/.+\.rst|
lib\/.+\.py|
noxfile\.py|
pyproject\.toml|
Expand Down Expand Up @@ -97,9 +98,9 @@ repos:
additional_dependencies: ["repo-review[cli]"]
args: ["--show=errskip"]

# TODO: pending the addition of numpydoc, including config file(s).
#- repo: https://github.com/numpy/numpydoc
# rev: v1.7.0
# hooks:
# - id: numpydoc-validation
# types: [file, python]
- repo: https://github.com/numpy/numpydoc
rev: v1.8.0
hooks:
- id: numpydoc-validation
exclude: "src/iris_grib/tests/|noxfile.py"
types: [file, python]
7 changes: 4 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ and ``iris-grib`` installed in your Python environment.
import iris
import iris_grib
import warnings
warnings.simplefilter('ignore')

warnings.simplefilter("ignore")
cube = iris.load_cube(iris.sample_data_path("rotated_pole.nc"))
iris.save(cube, 'testfile.grib', saver='grib2')
iris.save(cube, "testfile.grib", saver="grib2")

For example, to load GRIB data :

Expand Down Expand Up @@ -185,6 +186,7 @@ You can convert Iris cubes to eccodes messages, and modify or filter them before

from iris.coords import DimCoord
import eccodes

cube_height_2m5 = iris.load_cube(iris.sample_data_path("rotated_pole.nc"))
cube_height_2m5.add_aux_coord(DimCoord([2.5], standard_name="height", units="m"), ())

Expand Down Expand Up @@ -255,4 +257,3 @@ See also:
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

1 change: 0 additions & 1 deletion docs/ref/iris_grib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ In this module:
.. autofunction:: iris_grib.save_pairs_from_cube

.. autofunction:: iris_grib.save_messages

1 change: 0 additions & 1 deletion docs/ref/message/message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ In this module:

.. autoclass:: iris_grib.message.Section
:members:

44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,47 @@ known-first-party = ["iris_grib"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.numpydoc_validation]
checks = [
"all", # Enable all numpydoc validation rules, apart from the following:

# -> Docstring text (summary) should start in the line immediately
# after the opening quotes (not in the same line, or leaving a
# blank line in between)
"GL01", # Permit summary line on same line as docstring opening quotes.

# -> Closing quotes should be placed in the line after the last text
# in the docstring (do not close the quotes in the same line as
# the text, or leave a blank line between the last text and the
# quotes)
"GL02", # Permit a blank line before docstring closing quotes.

# -> Double line break found; please use only one blank line to
# separate sections or paragraphs, and do not leave blank lines
# at the end of docstrings
"GL03", # Ignoring.

# -> See Also section not found
"SA01", # Not all docstrings require a "See Also" section.

# -> No extended summary found
"ES01", # Not all docstrings require an "Extended Summary" section.

# -> No examples section found
"EX01", # Not all docstrings require an "Examples" section.

# -> No Yields section found
"YD01", # Not all docstrings require a "Yields" section.

# Record temporarily ignored checks below; will be reviewed at a later date:
# TODO: work to remove these at a later date.
"GL08", # *975 The object does not have a docstring
"PR01", # *149 Parameters ... not documented
"RT01", # *9 No Returns section found
]
exclude = [
'\.__eq__$',
'\.__ne__$',
'\.__repr__$',
]
29 changes: 22 additions & 7 deletions src/iris_grib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,9 @@ def core_data(self):

def phenomenon_points(self, time_unit):
"""
Return the phenomenon time point offset from the epoch time reference
measured in the appropriate time units.
Return the phenomenon time points.

As offsets from the epoch time reference, measured in appropriate time units.

"""
time_reference = "%s since epoch" % time_unit
Expand All @@ -705,8 +706,9 @@ def phenomenon_points(self, time_unit):

def phenomenon_bounds(self, time_unit):
"""
Return the phenomenon time bound offsets from the epoch time reference
measured in the appropriate time units.
Return the phenomenon time bounds.

As offsets from the epoch time reference, measured in appropriate time units.

"""
# TODO #576 Investigate when it's valid to get phenomenon_bounds
Expand Down Expand Up @@ -762,7 +764,7 @@ def _load_generate(filename):

def load_cubes(filenames, callback=None):
"""
Returns an iterator over cubes from the given list of filenames.
Return an iterator over cubes from the given list of filenames.

Args:

Expand All @@ -786,9 +788,21 @@ def load_cubes(filenames, callback=None):

def load_pairs_from_fields(grib_messages):
"""
Convert an iterable of GRIB messages into an iterable of
(Cube, Grib message) tuples.
Convert an GRIB messages into (Cube, Grib message) tuples.

Parameters
----------
grib_messages : iterable on (cube, message)
An iterable of :class:`GribMessage`.

Returns
-------
iterable of (cube, message)
An iterable of (:class:`~iris.Cube`, :class:`GribMessage`),
pairing each message with a corresponding generated cube.

Notes
-----
This capability can be used to filter out fields before they are passed to
the load pipeline, and amend the cubes once they are created, using
GRIB metadata conditions. Where the filtering
Expand Down Expand Up @@ -894,6 +908,7 @@ def save_pairs_from_cube(cube):
def save_messages(messages, target, append=False):
"""
Save messages to a GRIB2 file.

The messages will be released as part of the save.

Args:
Expand Down
2 changes: 1 addition & 1 deletion src/iris_grib/_grib1_load_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def grib1_convert(grib):
"""
Converts a GRIB1 message into the corresponding items of Cube metadata.
Convert a GRIB1 message into the corresponding items of Cube metadata.

Args:

Expand Down
Loading
Loading