Currently, there is a lot of function that manipulate one thing of the OutputVar (like dims or data) and remake the OutputVar with that one thing changed. Because we cannot mutate the OutputVar (since otherwise the interpolant will not change), there is boilerplate code that which involves doing copy or deepcopy of the object to remake the object. Similarly, a lot of the tests involving constructing OutputVar with a single change.
To reduce the amount of boilerplate code, a copy function can be made that takes in var::OutputVar and the keyword arguments attributes, dims, dim_attributes, and data. If no keyword arguments are supplied, then the function return a deepcopy of the OutputVar. If a keyword argument is supplied, then it makes a copy of that object, but with whatever is supplied for the keyword. As such, instead of writing
Currently, there is a lot of function that manipulate one thing of the OutputVar (like dims or data) and remake the OutputVar with that one thing changed. Because we cannot mutate the OutputVar (since otherwise the interpolant will not change), there is boilerplate code that which involves doing copy or deepcopy of the object to remake the object. Similarly, a lot of the tests involving constructing
OutputVar
with a single change.To reduce the amount of boilerplate code, a copy function can be made that takes in
var::OutputVar
and the keyword argumentsattributes
,dims
,dim_attributes
, anddata
. If no keyword arguments are supplied, then the function return a deepcopy of theOutputVar
. If a keyword argument is supplied, then it makes a copy of that object, but with whatever is supplied for the keyword. As such, instead of writingyou can write instead