Skip to content

Commit

Permalink
#168 Fix assign.scan not updating in-place
Browse files Browse the repository at this point in the history
  • Loading branch information
astropenguin committed Jul 13, 2024
1 parent 367bc3d commit abceb3e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions decode/assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ def scan(
DEMS DataArray to which the scan label are assigned.
"""
if not inplace:
# deepcopy except for data
dems = dems.copy(data=dems.data)

is_div = xr.zeros_like(dems.scan, dtype=bool)

ref = dems.coords[by].data
Expand All @@ -45,4 +41,9 @@ def scan(
is_div[1:] |= np.diff(dems.time) >= dt

new_scan = is_div.cumsum().astype(dems.scan.dtype)
return dems.assign_coords(scan=new_scan)

if inplace:
dems.coords["scan"][:] = new_scan
return dems
else:
return dems.assign_coords(scan=new_scan)

0 comments on commit abceb3e

Please sign in to comment.