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

DOCS: numpydocs 8 #5722

Merged
merged 4 commits into from
Jan 31, 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
6 changes: 3 additions & 3 deletions lib/iris/_representation/cube_printout.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def add_row(self, cols, aligns, i_col_unlimited=None):
Per-column content. Length must match the other rows (if any).
aligns : list of {'left', 'right'}
Per-column alignments. Length must match 'cols'.
i_col_unlimited : int or None, optional
i_col_unlimited : int, optional
Column beyond which content does not affect the column widths.
( meaning contents will print without limit ).

Expand Down Expand Up @@ -325,10 +325,10 @@ def to_string(self, oneline=False, name_padding=35):

Parameters
----------
oneline : bool, optional, default=False
oneline : bool, default=False
If set, produce a one-line summary.
Default is False = produce full (multiline) summary.
name_padding int, optional, default=35
name_padding : int, default=35
The minimum width for the "name" (#0) column.

Returns
Expand Down
7 changes: 3 additions & 4 deletions lib/iris/common/lenient.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def func():
wrapped by the decorator. This is automatically populated by Python
through the decorator interface. No argument requires to be manually
provided.
services : callable or str or iterable of callable/str, optional, default=None
services : callable or str or iterable of callable/str, optional
Zero or more function/methods, or equivalent fully qualified string names, of
lenient service function/methods.

Expand Down Expand Up @@ -227,7 +227,7 @@ def __init__(self, **kwargs):

Parameters
----------
**kwargs : dict
**kwargs : dict, optional
Mapping of lenient key/value options to enable/disable. Note that,
only the lenient "maths" options is available, which controls
lenient/strict cube arithmetic.
Expand Down Expand Up @@ -298,7 +298,6 @@ def context(self, **kwargs):
applied. On exit from the context manager, the previous lenient
option state is restored.


For example::

with iris.common.Lenient.context(maths=False):
Expand Down Expand Up @@ -555,7 +554,7 @@ def register_client(self, func, services, append=False):
services : callable or str or iterable of callable/str
One or more service function/methods or fully qualified string names
of the required service function/method.
append : bool, optional
append : bool, default=False
If True, append the lenient services to any pre-registered lenient
services for the provided lenient client. Default is False.

Expand Down
6 changes: 3 additions & 3 deletions lib/iris/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def combine(self, other, lenient=None):
----------
other : metadata
A metadata instance of the same type.
lenient : bool
lenient : bool, optional
Enable/disable lenient combination. The default is to automatically
detect whether this lenient operation is enabled.

Expand Down Expand Up @@ -694,7 +694,7 @@ def name(self, default=None, token=False):
default : optional
The fall-back string representing the default name. Defaults to
the string 'unknown'.
token : bool, optional
token : bool, default=False
If True, ensures that the name returned satisfies the criteria for
the characters required by a valid NetCDF name. If it is not
possible to return a valid name, then a ValueError exception is
Expand Down Expand Up @@ -1574,7 +1574,7 @@ def metadata_manager_factory(cls, **kwargs):
cls :
A subclass of :class:`~iris.common.metadata.BaseMetadata`, defining
the metadata to be managed.
**kwargs :
**kwargs : dict, optional
Initial values for the manufactured metadata instance. Unspecified
fields will default to a value of 'None'.

Expand Down
58 changes: 32 additions & 26 deletions lib/iris/common/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ def __init__(self, lhs=None, rhs=None):

Parameters
----------
lhs : :class:`~iris.cube.Cube`
lhs : :class:`~iris.cube.Cube`, optional
The left-hand-side :class:`~iris.cube.Cube` operand.
rhs : :class:`~iris.cube.Cube`
rhs : :class:`~iris.cube.Cube`, optional
The right-hand-side :class:`~iris.cube.Cube` operand.

Examples
Expand Down Expand Up @@ -698,15 +698,15 @@ def _create_prepared_item(
The dimensions that the ``coord`` spans on the resulting resolved
:class:`~iris.cube.Cube`.
(Can also be a single dimension number).
src_metadata :
src_metadata : optional
The coordinate metadata from the ``src`` :class:`~iris.cube.Cube`.
tgt_metadata :
tgt_metadata : optional
The coordinate metadata from the ``tgt`` :class:`~iris.cube.Cube`.
points :
points : optional
Override points array. When not given, use coord.points.
bounds :
bounds : optional
Override bounds array. When not given, use coord.bounds.
container :
container : optional
Override coord type (class constructor).
When not given, use type(coord).

Expand Down Expand Up @@ -1145,34 +1145,40 @@ def _metadata_coverage(self):
def _metadata_mapping(self):
"""Identify equivalent dimensions using metadata.

Ensure that each ``src`` :class:`~iris.cube.Cube` dimension is mapped to an associated
``tgt`` :class:`~iris.cube.Cube` dimension using the common dim and aux coordinate metadata.
Ensure that each ``src`` :class:`~iris.cube.Cube` dimension is mapped to an
associated ``tgt`` :class:`~iris.cube.Cube` dimension using the common dim
and aux coordinate metadata.

If the common metadata does not result in a full mapping of ``src`` to ``tgt`` dimensions
then free dimensions are analysed to determine whether the mapping can be completed.
If the common metadata does not result in a full mapping of ``src`` to ``tgt``
dimensions then free dimensions are analysed to determine whether the mapping
can be completed.

Once the ``src`` has been mapped to the ``tgt``, the cubes are checked to ensure that they
will successfully broadcast, and the ``src`` :class:`~iris.cube.Cube` is transposed appropriately,
if necessary.
Once the ``src`` has been mapped to the ``tgt``, the cubes are checked to
ensure that they will successfully broadcast, and the ``src``
:class:`~iris.cube.Cube` is transposed appropriately, if necessary.

The :attr:`~iris.common.resolve.Resolve._broadcast_shape` is set, along with the
:attr:`~iris.common.resolve.Resolve._src_cube_resolved` and :attr:`~iris.common.resolve.Resolve._tgt_cube_resolved`,
The :attr:`~iris.common.resolve.Resolve._broadcast_shape` is set, along with
the :attr:`~iris.common.resolve.Resolve._src_cube_resolved` and
:attr:`~iris.common.resolve.Resolve._tgt_cube_resolved`,
which are the broadcast/transposed ``src`` and ``tgt``.

.. note::

An exception will be raised if a ``src`` dimension cannot be mapped to a ``tgt`` dimension.
An exception will be raised if a ``src`` dimension cannot be mapped to
a ``tgt`` dimension.

.. note::

An exception will be raised if the full mapped ``src`` :class:`~iris.cube.Cube` cannot be
broadcast or transposed with the ``tgt`` :class:`~iris.cube.Cube`.
An exception will be raised if the full mapped ``src``
:class:`~iris.cube.Cube` cannot be broadcast or transposed with the
``tgt`` :class:`~iris.cube.Cube`.

.. note::

The ``src`` and ``tgt`` may be swapped in the case where they both have equal dimensionality and
the ``tgt`` does have the same shape as the resolved broadcast shape (and the ``src`` does) or
the ``tgt`` has more free dimensions than the ``src``.
The ``src`` and ``tgt`` may be swapped in the case where they both have
equal dimensionality and the ``tgt`` does have the same shape as the
resolved broadcast shape (and the ``src`` does) or the ``tgt`` has more
free dimensions than the ``src``.

"""
# Initialise the state.
Expand Down Expand Up @@ -1629,11 +1635,11 @@ def _get_prepared_item(
The :class:`~iris.common.resolve._CategoryItems` containing the
local metadata of either the ``src`` or ``tgt`` :class:`~iris.cube.Cube`.
See ``from_local``.
from_src : bool, optional
from_src : bool, default=True
Boolean stating whether the ``metadata`` is from the ``src`` (``True``)
or ``tgt`` :class:`~iris.cube.Cube`.
Defaults to ``True``.
from_local: bool, optional
from_local: bool, default=False
Boolean controlling whether the ``metadata`` is used to search the
``category_local`` (``True``) or the :attr:`~iris.common.resolve.Resolve.prepared_category`.
Defaults to ``False``.
Expand Down Expand Up @@ -1710,7 +1716,7 @@ def _prepare_factory_payload(self, cube, category_local, from_src=True):
category_local : :class:`~iris.common.resolve._CategoryItems`
The :class:`~iris.common.resolve._CategoryItems` of all metadata
local to the provided ``cube``.
from_src : bool, optional, default=True
from_src : bool, default=True
Boolean stating whether the provided ``cube`` is either a ``src`` or ``tgt``
:class:`~iris.cube.Cube` - used to retrieve the appropriate metadata from a
:class:`~iris.common.resolve._PreparedMetadata`.
Expand Down Expand Up @@ -2301,7 +2307,7 @@ def cube(self, data, in_place=False):
The data payload for the resultant :class:`~iris.cube.Cube`, which
**must match** the expected resolved
:attr:`~iris.common.resolve.Resolve.shape`.
in_place : optional
in_place : bool, default=False
If ``True``, the ``data`` is inserted into the ``tgt``
:class:`~iris.cube.Cube`. The existing metadata of the ``tgt``
:class:`~iris.cube.Cube` is replaced with the resolved metadata from
Expand Down
10 changes: 4 additions & 6 deletions lib/iris/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def as_cube(

Example usage::

as_cube(series, calendars={0: cf_units.CALENDAR_360_DAY})
as_cube(data_frame, calendars={1: cf_units.CALENDAR_STANDARD})
as_cube(series, calendars={0: cf_units.CALENDAR_360_DAY})
as_cube(data_frame, calendars={1: cf_units.CALENDAR_STANDARD})

Since this function converts to/from a Pandas object, laziness will not be preserved.

Expand Down Expand Up @@ -583,8 +583,6 @@ def as_series(cube, copy=True):
If you have a large array that cannot be copied,
make sure it is not masked and use copy=False.

Notes
-----
Since this function converts to/from a Pandas object, laziness will not be preserved.

"""
Expand Down Expand Up @@ -626,7 +624,7 @@ def as_data_frame(

Parameters
----------
cube: :class:`~iris.cube.Cube`
cube : :class:`~iris.cube.Cube`
The :class:`~iris.cube.Cube` to be converted to a :class:`pandas.DataFrame`.
copy : bool, default=True
Whether the :class:`pandas.DataFrame` is a copy of the the Cube
Expand All @@ -638,7 +636,7 @@ def as_data_frame(
add_cell_measures : bool, default=False
If True, add :attr:`~iris.cube.Cube.cell_measures` to the returned
:class:`pandas.DataFrame`.
add_ancillary_variables: bool, default=False
add_ancillary_variables : bool, default=False
If True, add :attr:`~iris.cube.Cube.ancillary_variables` to the returned
:class:`pandas.DataFrame`.

Expand Down
Loading
Loading