Repository navigation
Clean up in-place operations - #452
Conversation
| @@ -6,10 +6,11 @@ | |||
|
|
|||
|
|
|||
| def diff_channels(da: TArray, accum_channels: list[str]) -> TArray: | |||
There was a problem hiding this comment.
This function was a bit weird in that it replaced the data on the input dataarray and then did an isel(). When the input is an xarray.DataAray the isel returns a copy, so we were first changing the data in-place and then returning a copy of that changed data. That was kind of the worst of both worlds. This new version is explicitly out-of-place
| da_dask = xr.DataArray(dask.array.random.random((5, 5))) | ||
|
|
||
| # Create a nested dictionary with dask array | ||
| lazy_data_dict = { |
There was a problem hiding this comment.
We do an in-place operation to load this so I don't think the name makes sense anymore
felix-e-h-p
left a comment
There was a problem hiding this comment.
Small suggestion. Could we have a test that pulls the same sample twice from PVNetDataset (with dropout and a fill value set) and checks that datasets_dict is unchanged? That would lock in the “without modifying the original NumPy arrays” from the new docstring.
Sure, but I'd say that should be a unit test on |
0f48e81 to
104fc22
Compare
Pull Request
Description
This PR cleans up our in-place operations
Nonewhen an operation is done in-place to signify an in-place operationChecklist: