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
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ exclude =
# ignore third-party files
#
gitwash_dumper.py,
#
# convenience imports
#
lib/iris/common/__init__.py
12 changes: 6 additions & 6 deletions lib/iris/_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _CoordMetaData(
Args:

* defn:
The :class:`iris.coords.CoordDefn` metadata that represents a
The :class:`iris.common.CoordMetadata` metadata that represents a
coordinate.

* dims:
Expand All @@ -86,7 +86,7 @@ class _CoordMetaData(

"""

def __new__(cls, coord, dims):
def __new__(mcs, coord, dims):
"""
Create a new :class:`_CoordMetaData` instance.

Expand All @@ -102,7 +102,7 @@ def __new__(cls, coord, dims):
The new class instance.

"""
defn = coord._as_defn()
defn = coord.metadata
points_dtype = coord.points.dtype
bounds_dtype = coord.bounds.dtype if coord.bounds is not None else None
kwargs = {}
Expand All @@ -121,7 +121,7 @@ def __new__(cls, coord, dims):
order = _DECREASING
kwargs["order"] = order
metadata = super().__new__(
cls, defn, dims, points_dtype, bounds_dtype, kwargs
mcs, defn, dims, points_dtype, bounds_dtype, kwargs
)
return metadata

Expand Down Expand Up @@ -331,11 +331,11 @@ def __init__(self, cube):
axes = dict(T=0, Z=1, Y=2, X=3)

# Coordinate sort function - by guessed coordinate axis, then
# by coordinate definition, then by dimensions, in ascending order.
# by coordinate metadata, then by dimensions, in ascending order.
def key_func(coord):
return (
axes.get(guess_coord_axis(coord), len(axes) + 1),
coord._as_defn(),
coord.metadata,
cube.coord_dims(coord),
)

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _coordless_match(self, cube):
if self._name:
# Require to also check against cube.name() for the fallback
# "unknown" default case, when there is no name metadata available.
match = self._name in cube.names or self._name == cube.name()
match = self._name in cube._names or self._name == cube.name()
if match and self._cube_func:
match = self._cube_func(cube)
return match
Expand Down
23 changes: 11 additions & 12 deletions lib/iris/_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
is_lazy_data,
multidim_lazy_stack,
)
import iris.cube
import iris.coords
from iris.common import CoordMetadata, CubeMetadata
import iris.cube
import iris.exceptions
import iris.util

Expand Down Expand Up @@ -115,7 +116,7 @@ class _ScalarCoordPayload(
Args:

* defns:
A list of scalar coordinate definitions :class:`iris.coords.CoordDefn`
A list of scalar coordinate metadata :class:`iris.common.CoordMetadata`
belonging to a :class:`iris.cube.Cube`.

* values:
Expand Down Expand Up @@ -1460,9 +1461,7 @@ def axis_and_name(name):
)
else:
bounds = None
kwargs = dict(
zip(iris.coords.CoordDefn._fields, defns[name])
)
kwargs = dict(zip(CoordMetadata._fields, defns[name]))
kwargs.update(metadata[name].kwargs)

def name_in_independents():
Expand Down Expand Up @@ -1542,7 +1541,7 @@ def name_in_independents():
if bounds is not None:
bounds[index] = name_value.bound

kwargs = dict(zip(iris.coords.CoordDefn._fields, defns[name]))
kwargs = dict(zip(CoordMetadata._fields, defns[name]))
self._aux_templates.append(
_Template(dims, points, bounds, kwargs)
)
Expand Down Expand Up @@ -1576,7 +1575,7 @@ def _get_cube(self, data):
(deepcopy(coord), dims)
for coord, dims in self._aux_coords_and_dims
]
kwargs = dict(zip(iris.cube.CubeMetadata._fields, signature.defn))
kwargs = dict(zip(CubeMetadata._fields, signature.defn))

cms_and_dims = [
(deepcopy(cm), dims) for cm, dims in self._cell_measures_and_dims
Expand Down Expand Up @@ -1767,7 +1766,7 @@ def _extract_coord_payload(self, cube):

# Coordinate sort function.
# NB. This makes use of two properties which don't end up in
# the CoordDefn used by scalar_defns: `coord.points.dtype` and
# the metadata used by scalar_defns: `coord.points.dtype` and
# `type(coord)`.
def key_func(coord):
points_dtype = coord.dtype
Expand All @@ -1778,14 +1777,14 @@ def key_func(coord):
axis_dict.get(
iris.util.guess_coord_axis(coord), len(axis_dict) + 1
),
coord._as_defn(),
coord.metadata,
)

# Order the coordinates by hints, axis, and definition.
for coord in sorted(coords, key=key_func):
if not cube.coord_dims(coord) and coord.shape == (1,):
# Extract the scalar coordinate data and metadata.
scalar_defns.append(coord._as_defn())
scalar_defns.append(coord.metadata)
# Because we know there's a single Cell in the
# coordinate, it's quicker to roll our own than use
# Coord.cell().
Expand Down Expand Up @@ -1817,14 +1816,14 @@ def key_func(coord):

factory_defns = []
for factory in sorted(
cube.aux_factories, key=lambda factory: factory._as_defn()
cube.aux_factories, key=lambda factory: factory.metadata
):
dependency_defns = []
dependencies = factory.dependencies
for key in sorted(dependencies):
coord = dependencies[key]
if coord is not None:
dependency_defns.append((key, coord._as_defn()))
dependency_defns.append((key, coord.metadata))
factory_defn = _FactoryDefn(type(factory), dependency_defns)
factory_defns.append(factory_defn)

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _dimensional_metadata_comparison(*cubes, object_get=None):
eq = (
other_coord is coord
or other_coord.name() == coord.name()
and other_coord._as_defn() == coord._as_defn()
and other_coord.metadata == coord.metadata
)
if eq:
coord_to_add_to_group = other_coord
Expand Down
Loading