Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progress bar in GWRResults spatial_variability #91

Closed
pareyesv opened this issue Apr 25, 2021 · 3 comments
Closed

progress bar in GWRResults spatial_variability #91

pareyesv opened this issue Apr 25, 2021 · 3 comments

Comments

@pareyesv
Copy link
Contributor

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

mgwr/mgwr/gwr.py

Lines 1217 to 1225 in 5e7fa3f

for x in range(n_iters):
temp_coords = np.random.permutation(self.model.coords)
temp_sel.coords = temp_coords
temp_bw = temp_sel.search(**search_params)
temp_gwr.bw = temp_bw
temp_gwr.coords = temp_coords
temp_params = temp_gwr.fit(**fit_params).params
temp_sd = np.std(temp_params, axis=0)
SDs.append(temp_sd)

tqdm is already used here

mgwr/mgwr/search.py

Lines 202 to 209 in 5e7fa3f

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 iters in tqdm(range(1, max_iter + 1), desc='Backfitting'):

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
Copy link
Collaborator

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 added a commit to pareyesv/mgwr that referenced this issue Apr 27, 2021
* add progress bar in spatial_variability GWRResults and MGWRResults

Close progress bar in GWRResults spatial_variability pysal#91
@pareyesv
Copy link
Contributor Author

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

image

@pareyesv
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants