Skip to content

Commit

Permalink
Make extra ugrid option non-optional; modify repr test
Browse files Browse the repository at this point in the history
  • Loading branch information
lbdreyer committed Mar 20, 2020
1 parent 8cefdf4 commit bbecf2f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
20 changes: 8 additions & 12 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2553,18 +2553,14 @@ def vector_summary(
)
summary += "\n ugrid information:\n"
summary += "\n".join(ugrid_mesh_summary)
if ugrid_mesh.topology_dimension:
summary += "\n{pad:{width}}topology_dimension: {val}".format(
pad=" ",
width=indent,
val=ugrid_mesh.topology_dimension,
)
if ugrid_mesh.node_coordinates:
summary += "\n{pad:{width}}node_coordinates: {val}".format(
pad=" ",
width=indent,
val=" ".join(ugrid_mesh.node_coordinates),
)
summary += "\n{pad:{width}}topology_dimension: {val}".format(
pad=" ", width=indent, val=ugrid_mesh.topology_dimension,
)
summary += "\n{pad:{width}}node_coordinates: {val}".format(
pad=" ",
width=indent,
val=" ".join(ugrid_mesh.node_coordinates),
)

#
# Generate textual summary of cube scalar coordinates.
Expand Down
22 changes: 9 additions & 13 deletions lib/iris/fileformats/ugrid_cf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class CubeUgrid(
"topology_dimension",
"node_coordinates",
],
defaults=(None,) * 2,
)
):
"""
Expand All @@ -74,12 +73,11 @@ class CubeUgrid(
Which element of the mesh the cube is mapped to.
Can be 'face', 'edge' or 'node'. A 'volume' is not supported.
Optional:
* topology_dimension (int):
The highest dimensionality of the geometric elements in the mesh. Defaults to None.
The highest dimensionality of the geometric elements in the mesh.
* node_coordinates (string):
A list of the names of the spatial coordinates, used to geolocate the nodes. Defaults to None.
* node_coordinates (set):
A set of the names of the spatial coordinates, used to geolocate the nodes.
"""

Expand All @@ -88,14 +86,12 @@ def __str__(self):
result += "\n cube dimension = {}".format(self.cube_dim)
result += '\n mesh_location = "{}"'.format(self.mesh_location)
result += '\n mesh "{}" :'.format(self.grid.mesh_name)
if self.topology_dimension:
result += '\n topology_dimension "{}" :'.format(
self.topology_dimension
)
if self.node_coordinates:
result += '\n node_coordinates "{}" :\n'.format(
" ".join(self.node_coordinates)
)
result += '\n topology_dimension "{}" :'.format(
self.topology_dimension
)
result += '\n node_coordinates "{}" :\n'.format(
" ".join(self.node_coordinates)
)
try:
mesh_str = str(self.grid.info)
except TypeError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ def setUp(self):
self.representer._get_bits(self.representer._get_lines())

def test_population(self):
for v in self.representer.str_headings.values():
self.assertIsNotNone(v)
for k, v in self.representer.str_headings.items():
if k == "ugrid information:":
self.assertIsNone(v)
else:
self.assertIsNotNone(v)

def test_headings__dimcoords(self):
contents = self.representer.str_headings["Dimension coordinates:"]
Expand Down

0 comments on commit bbecf2f

Please sign in to comment.