I have a (actually, two) questions regarding Python and showing progress bars. I am writing an algorithm that operates on large datasets (~10^10 elements or more) and the two most time-consuming steps are performing a 2D-FFT (implemented using scipy.fft.fft2
) and sorting the flattened array (implemented using numpy.argsort
). As such, I would love to have some sort of progress indication (preferably using tqdm
), but I am not sure how to implement this on package supplied functions.
As I understand a 2D-FFT is just a 1D-fft on all the rows and then the columns: therefore, I suspect it is possible to show the current row/column on which the FFT is performed? As far as numpy.argsort
goes (which I have implemented using the default QuickSort), I am not sure if the runtime can be determined a priori (or estimated) as I am not really familiar with the algorithm. Any solution, tips or feedback is appreciated!
MWE:
import numpy as np
from scipy.fft import fft2
# Import tqdm << preferably some wrapper for tqdm?
# Create random data
data = np.random.uniform(0, 1E4, (10000, 10000))
# Perform fft2
transform = fft2(data)
print("FFT complete!")
# Sort the array
indices = np.argsort(data.flatten())
print("Sort complete!")
I have not really tried writing my own implementation of 2D-FFT/QuickSort, as that seems like a last resort and has the major disadvantages that subsequent updates/improvements of the former methods are not incorperated.
Ideally, I would (probably) like some kind of wrapper, but I don't know if this is possible without modifying the original methods..