Skip to content

cube printout incorrectly displays a masked scalar coord #5158

@lbdreyer

Description

@lbdreyer

🐛 Bug Report

My cube has a scalar coordinate with a masked point. When I print out the coordinate, it displays the point as masked (i.e. --) as expected, but if I print the whole cube, it displays the underlaying data under the mask.

I have only tested this with scalar coordinates but it may also be applicable to cell measure/ancillary variables.

How To Reproduce

>>> from iris.cube import Cube
>>> from iris.coords import AuxCoord
>>> import numpy.ma as ma
>>> cube = Cube([1])
>>> coord = AuxCoord(ma.masked, 'height')
>>> cube.add_aux_coord(coord)
>>> print(cube.coord('height'))
AuxCoord :  height / (unknown)
    points: [--]
    shape: (1,)
    dtype: float64
    standard_name: 'height'
>>> print(cube)
unknown / (unknown)                 (-- : 1)
    Scalar coordinates:
        height                      0.0

In the above you can see that when I just print the height coordinate it is displayed as -- but printing the cube displays it as 0

Expected behaviour

I would expect that printing the above would return:

>>> print(cube)
unknown / (unknown)                 (-- : 1)
    Scalar coordinates:
        height                      --

And the same goes for scalar cell measures and ancillary variables

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueA good issue to take on if you're just getting started with Iris developmentType: Bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions