Thanks to visit codestin.com
Credit goes to github.com

Skip to content

progress bar in GWRResults spatial_variability #91

@pareyesv

Description

@pareyesv

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" ?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions