Skip to content

Conversation

@alastair-gemmell
Copy link
Contributor

Although labelled as a bug I don't think #3081 is a bug strictly speaking. As far as I can tell its behaviour is as expected from the reference docs at https://scitools.org.uk/iris/docs/latest/iris/iris/cube.html#iris.cube.Cube.remove_cell_measure. In as much as the argument to the method is documented as having to be a CellMeasure instance (not a name of a cell measure).

Having said that it could be a bit misleading as other public Cube methods such as Cube.cell_measure take either a CellMeasure object OR the name of a cell measure (https://scitools.org.uk/iris/docs/latest/iris/iris/cube.html#iris.cube.Cube.cell_measure), and currently if you attempt to pass in the name of a cell measure to be removed it isn't removed, silently

So although maybe not a bug in the strict sense it seemed a good candidate for a minor new feature to accept a name of a cell measure when calling the Cube.remove_cell_measure method

Especially as I'm a newbie contributor let me know what you think, and if I've forgotten anything here (I've updated the docstring, added new tests and added a 'whats new' entry but I may have missed something?)

@pp-mo
Copy link
Member

pp-mo commented Mar 11, 2019

Welcome to Iris-devs !!!

I think this is a bug : The docstring says you can pass a name, but you can't.
I think all it needs is a "cell_measure = self.cell_measure(cell_measure)" at the start of the function.
It should also be worth creating a bug-style 'whatsnew' entry
( as described here,
but as usual easier to copy existing stuff ! )

Send us a PR, if you fancy having a go ??

@mo-g
Copy link

mo-g commented Mar 12, 2019

Tests look ok at first glance, either way. Most important part of any PR. 😉

@bjlittle bjlittle self-assigned this Jul 9, 2019
@bjlittle bjlittle added this to the v2.3.0 milestone Sep 27, 2019
Copy link
Member

@bjlittle bjlittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alastair-gemmell Thanks for the PR, and apologies for the tardy response.

Just one minor comment to address, then we'll get this merged! 👍

lib/iris/cube.py Outdated
factory.update(coord)

def remove_cell_measure(self, cell_measure):
def remove_cell_measure(self, name_or_cell_measure):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alastair-gemmell I think that keeping the cell_measure positional argument "as is" is good enough, and is in keeping with other remove_ methods that allow a mixture of different types of inputs to match on i.e., see iris.cube.Cube.remove_coord for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bjlittle . I've made this change now and the tests have passed.

It's good to have this consistency with other remove methods, although there is already inconsistency because the cell_measures and cell_measure methods do have the argument listed as 'name_or_cell_measure' (which is what I based my original change on!)

(a) a :attr:`standard_name`, :attr:`long_name`, or
:attr:`var_name`. Defaults to value of `default`
(which itself defaults to `unknown`) as defined in
:class:`iris._cube_coord_common.CFVariableMixin`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alastair-gemmell A lovely piece of clarification, which explains that cell_measure can be an actual CellMeasure instance or an appropriate string name 😄

@bjlittle
Copy link
Member

Awesome work, thanks @alastair-gemmell 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants