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 12, 2024
1 parent a1d0679 commit f1167db
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 @@ -3479,9 +3479,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 @@ -3492,7 +3493,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 @@ -3501,6 +3502,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 f1167db

Please sign in to comment.