Skip to content

Commit

Permalink
add warning when pool is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziqi-Li committed Dec 4, 2023
1 parent 3ecaa64 commit bce101b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 12 additions & 2 deletions mgwr/gwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import copy
import os
from typing import Optional
import warnings
import numpy as np
import numpy.linalg as la
from scipy.stats import t
Expand Down Expand Up @@ -291,7 +292,7 @@ def _local_fit(self, i):
return influ, resid, predy, betas.reshape(-1), w, Si, tr_STS_i, CCT

def fit(self, ini_params=None, tol=1.0e-5, max_iter=20, solve='iwls',
lite=False):
lite=False,pool=None):
"""
Method that fits a model with a particular estimation routine.
Expand All @@ -318,6 +319,7 @@ def fit(self, ini_params=None, tol=1.0e-5, max_iter=20, solve='iwls',
bandwidth selection (could speed up
bandwidth selection for GWR) or to estimate
a full GWR. Default is False.
pool : None, deprecated and not used.
Returns
-------
Expand All @@ -333,6 +335,9 @@ def fit(self, ini_params=None, tol=1.0e-5, max_iter=20, solve='iwls',
self.fit_params['solve'] = solve
self.fit_params['lite'] = lite

if pool:
warnings.warn("The pool parameter is no longer used and will have no effect; parallelization is default and implemented using joblib instead.", RuntimeWarning)

if solve.lower() == 'iwls':

if self.points is None:
Expand Down Expand Up @@ -1604,7 +1609,7 @@ def _chunk_compute_R(self, chunk_id=0):
return ENP_j, CCT, pR
return ENP_j, CCT

def fit(self, n_chunks=1):
def fit(self, n_chunks=1,pool=None):
"""
Compute MGWR inference by chunk to reduce memory footprint.
See Li and Fotheringham, 2020, IJGIS.
Expand All @@ -1615,6 +1620,8 @@ def fit(self, n_chunks=1):
n_chunks : integer, optional
A number of chunks parameter to reduce memory usage.
e.g. n_chunks=2 should reduce overall memory usage by 2.
pool : None, deprecated and not used
Returns
-------
Expand All @@ -1631,6 +1638,9 @@ def tqdm(x, total=0,
desc=''): #otherwise, just passthrough the range
return x

if pool:
warnings.warn("The pool parameter is no longer used and will have no effect; parallelization is default and implemented using joblib instead.", RuntimeWarning)

if self.n_jobs == -1:
max_processors = os.cpu_count()
self.n_chunks = max_processors * n_chunks
Expand Down
8 changes: 7 additions & 1 deletion mgwr/sel_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
__author__ = "Taylor Oshan [email protected]"

import spreg.user_output as USER
import warnings
import numpy as np
from scipy.spatial.distance import pdist
from scipy.optimize import minimize_scalar
Expand Down Expand Up @@ -203,7 +204,7 @@ def search(self, search_method='golden_section', criterion='AICc',
max_iter=200, init_multi=None, tol_multi=1.0e-5,
rss_score=False, max_iter_multi=200, multi_bw_min=[None],
multi_bw_max=[None
], bws_same_times=5, verbose=False):
], bws_same_times=5, verbose=False,pool=None):
"""
Method to select one unique bandwidth for a gwr model or a
bandwidth vector for a mgwr model.
Expand Down Expand Up @@ -251,6 +252,7 @@ def search(self, search_method='golden_section', criterion='AICc',
current set of bandwidths as final bandwidths.
verbose : Boolean
If true, bandwidth searching history is printed out; default is False.
pool : None, deprecated and not used.
Returns
-------
Expand Down Expand Up @@ -290,6 +292,10 @@ def search(self, search_method='golden_section', criterion='AICc',
" a single entry or a list containing an entry for each of k"
" covariates including the intercept")

if pool:
warnings.warn("The pool parameter is no longer used and will have no effect; parallelization is default and implemented using joblib instead.", RuntimeWarning)


self.interval = interval
self.tol = tol
self.max_iter = max_iter
Expand Down

0 comments on commit bce101b

Please sign in to comment.