-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, indexed assigment ignores bounds:
>>> f = cf.example_field(0)
>>> a = f.dimension_coordinate('X')
>>> a.array
array([ 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5])
>>> a.bounds.array
array([[ 0., 45.],
[ 45., 90.],
[ 90., 135.],
[135., 180.],
[180., 225.],
[225., 270.],
[270., 315.],
[315., 360.]])
>>> a[1:3] = 999
>>> a.array
array([ 22.5, 999. , 999. , 157.5, 202.5, 247.5, 292.5, 337.5])
>>> a.bounds.array
array([[ 0., 45.],
[ 45., 90.],
[ 90., 135.],
[135., 180.],
[180., 225.],
[225., 270.],
[270., 315.],
[315., 360.]])which I think is fine when RHS does not have bounds (like 999), but I don't think it makes sense when the RHS itself has bounds. Currently this happens:
>>> f = cf.example_field(0)
>>> a = f.dimension_coordinate('X')
>>> a[...] = -1 * a
>>> a.array
array([ -22.5, -67.5, -112.5, -157.5, -202.5, -247.5, -292.5, -337.5]) # -ve
>>> a.bounds.array
array([[ 0., 45.], # +ve
[ 45., 90.],
[ 90., 135.],
[135., 180.],
[180., 225.],
[225., 270.],
[270., 315.],
[315., 360.]])I'm not sure why this is so.
I propose extending assigmant to the bounds when both the LHS and RHS have bounds. i.e.:
# Proposed behaviour
>>> f = cf.example_field(0)
>>> a = f.dimension_coordinate('X')
>>> a[...] = -1 * a
>>> a.array
array([ -22.5, -67.5, -112.5, -157.5, -202.5, -247.5, -292.5, -337.5]) # -ve
>>> a.bounds.array
array([[ -0., -45.], # -ve
[ -45., -90.],
[ -90., -135.],
[-135., -180.],
[-180., -225.],
[-225., -270.],
[-270., -315.],
[-315., -360.]])(As an aside, I realise that unary operations also ignore bounds but binary ones don't (always) - that'll be another issue, though.)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request