pysal / mgwr

Multiscale Geographically Weighted Regression (MGWR)
https://mgwr.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
368 stars 126 forks source link

progress bar in GWRResults spatial_variability #91

Closed pareyesv closed 3 years ago

pareyesv commented 3 years ago

Considering spatial_variability is very computationally demanding, it'd be nice to add a progress bar (tqdm) to the for-loop here:

https://github.com/pysal/mgwr/blob/5e7fa3f5a2c9bf981c738a4cb011585ab8c516b7/mgwr/gwr.py#L1217-L1225

tqdm is already used here

https://github.com/pysal/mgwr/blob/5e7fa3f5a2c9bf981c738a4cb011585ab8c516b7/mgwr/search.py#L202-L209

so I guess the same code should work:

    try:
        from tqdm.auto import tqdm  #if they have it, let users have a progress bar
    except ImportError:

        def tqdm(x, desc=""):  #otherwise, just passthrough the range
            return x

    for x in tqdm(range(n_iters), desc="Testing"):  # Is "Testing" the right description? ¯\_(ツ)_/¯ 
        # ...

Let me know what you think. I can do the PR (If this is the case, I'd need ideas for the description text: desc="Testing" ?)

TaylorOshan commented 3 years ago

Good idea! PR would be very welcome. Only difference in those two examples is that I believe n_iters here is endogenously set based on the data, whereas it is (or rather can be) exogenously set by the user (default is 200 IIRC).

pareyesv commented 3 years ago

This is how it looks like (example from GWR_MGWR_example notebook)

image

pareyesv commented 3 years ago

@TaylorOshan thanks for your time and help! 👏 🎉 Should we close this issue?