Skip to content

Commit

Permalink
progressbar - make more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
keflavich committed Oct 13, 2024
1 parent 46fc6ad commit 26a1aba
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spectral_cube/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3491,9 +3491,10 @@ def makeslice_local(startpoint, axis=axis, nsteps=factor):
newshape = tuple(newshape)

if progressbar:
progressbar = ProgressBar
progressbar = ProgressBar(newshape[axis], desc='Downsample: ')
pbu = progressbar.update
else:
progressbar = lambda x, desc: x
pbu = lambda: True

# Create a view that will add a blank newaxis at the right spot
view_newaxis = [slice(None) for ii in range(self.ndim)]
Expand All @@ -3504,7 +3505,7 @@ def makeslice_local(startpoint, axis=axis, nsteps=factor):
dsarr = np.memmap(ntf, mode='w+', shape=newshape, dtype=float)
ntf2 = tempfile.NamedTemporaryFile()
mask = np.memmap(ntf2, mode='w+', shape=newshape, dtype=bool)
for ii in progressbar(range(newshape[axis]), desc='Downsample: '):
for ii in range(newshape[axis]):
view_fulldata = makeslice_local(ii*factor)
view_newdata = makeslice_local(ii, nsteps=1)

Expand All @@ -3513,6 +3514,7 @@ def makeslice_local(startpoint, axis=axis, nsteps=factor):

dsarr[view_newdata] = estimator(to_average, axis)[view_newaxis]
mask[view_newdata] = np.any(to_anyfy, axis).astype('bool')[view_newaxis]
pbu()


# the slice should just start at zero; we had factor//2 here earlier,
Expand Down

0 comments on commit 26a1aba

Please sign in to comment.