Skip to content

Reduce in-place cube operations. #3430

@pp-mo

Description

@pp-mo

Like numpy, we now only have a very few "general" operations in the cube API that modify an existing cube rather than returning a new one.
For comprehensibilty, I think those should be reduced to an absolute minimum.
Whereas things like add_dim_coord, and .data = clearly must be in-place operations, other operations like transpose and rename are not.

The following are currently in-place, and perhaps could usefully not be (IMHO) :

  • transpose
  • rename
  • convert_units

FWIW, I think 'transpose' is especially undesirable and unexpected.

Ideally I would both remove in-place operations wherever possible, and make it all as clear as possible by naming, e.g. cube.transposed((2,0,1)), cube.regridded(gribcube).

  • so e.g. that's a vote for renaming regrid to regridded !

Like #3429, this has clear parallels in other processing libraries, especially numpy.
Numpy has very few in-place operations, which makes processing code very much clearer, but their naming is not at all consistent.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions