-
Notifications
You must be signed in to change notification settings - Fork 285
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce in-place cube operations. #3430
Comments
Note: milestone set to v3.0.0, as it's breaking change, but this is probably not practical |
Just stumbled over an old issue : I already noted this one ! #2615 "cube.transpose is an in-place operation" Notably there, the absence of cube data sharing was seen as an obstacle, for performance reasons. See #2549 + its followers |
In my mind, Note that there are equivalent cube.coord("time").convert_units("days since 1970-01-01") has to become new_coord = cube.coord("time").convert_units("days since 1970-01-01")
dims = cube.coord_dims("time")
cube.remove_coord("time")
cube.add_dim_coord(new_coord, dims) Adding lines never feels like a win! Making the cube methods work inconsistently from their equivalent coord methods is not going to help with the comprehensibility though. |
Good spot + a very telling point. |
@pp-mo Whilst we're in this space, it would be a major step forward IMHO if we had a clear statement and enforced strategy for immutable cubes, coords et al, and zero-copy views. For me this all goes hand-in-hand with purging all in-place operations. Just sayin'... |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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 liketranspose
andrename
are not.The following are currently in-place, and perhaps could usefully not be (IMHO) :
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)
.regrid
toregridded
!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.
The text was updated successfully, but these errors were encountered: