Skip to content

Commit

Permalink
Merge pull request #147 from pedrovma/main
Browse files Browse the repository at this point in the history
Deprecating check_spat_diag
  • Loading branch information
pedrovma authored Aug 28, 2024
2 parents c9565aa + 9c42c02 commit d92edcb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
7 changes: 5 additions & 2 deletions spreg/ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,15 @@ def __init__(
"White test not available when standard errors are estimated by HAC or White correction.",
)
white_test = False
USER.check_spat_diag(spat_diag, w)

x_constant, name_x, warn = USER.check_constant(x, name_x)
set_warn(self, warn)
self.name_x = USER.set_name_x(name_x, x_constant)

w = USER.check_weights(w, y, slx_lags=slx_lags)
if spat_diag or moran:
w = USER.check_weights(w, y, slx_lags=slx_lags, w_required=True)
else:
w = USER.check_weights(w, y, slx_lags=slx_lags)
if slx_lags >0:
# lag_x = get_lags(w, x_constant[:, 1:], slx_lags)
# x_constant = np.hstack((x_constant, lag_x))
Expand Down
7 changes: 5 additions & 2 deletions spreg/ols_regimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,13 @@ def __init__(
"White test not available when standard errors are estimated by HAC or White correction.",
)
white_test = False
USER.check_spat_diag(spat_diag, w)

x_constant, name_x, warn = USER.check_constant(x, name_x, just_rem=True)
name_x = USER.set_name_x(name_x, x_constant, constant=True)
w = USER.check_weights(w, y, slx_lags=slx_lags)
if spat_diag or moran:
w = USER.check_weights(w, y, slx_lags=slx_lags, w_required=True)
else:
w = USER.check_weights(w, y, slx_lags=slx_lags)
if slx_lags > 0:
lag_x = get_lags(w, x_constant, slx_lags)
x_constant = np.hstack((x_constant, lag_x))
Expand Down
4 changes: 2 additions & 2 deletions spreg/twosls.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,10 @@ def __init__(
"Spatial diagnostics are not available for HAC estimation. The spatial diagnostics have been disabled for this model.",
)
spat_diag = False
USER.check_spat_diag(spat_diag, w)

x_constant, name_x, warn = USER.check_constant(x, name_x)
self.name_x = USER.set_name_x(name_x, x_constant)
w = USER.check_weights(w, y, slx_lags=slx_lags)
w = USER.check_weights(w, y, slx_lags=slx_lags, w_required=spat_diag)
if slx_lags>0:
# lag_x = get_lags(w, x_constant[:, 1:], slx_lags)
# x_constant = np.hstack((x_constant, lag_x))
Expand Down
3 changes: 1 addition & 2 deletions spreg/twosls_regimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,10 @@ def __init__(
"Spatial diagnostics are not available for HAC estimation. The spatial diagnostics have been disabled for this model.",
)
spat_diag = False
USER.check_spat_diag(spat_diag, w)
x_constant, name_x, warn = USER.check_constant(x, name_x, just_rem=True)
set_warn(self, warn)
name_x = USER.set_name_x(name_x, x_constant, constant=True)
w = USER.check_weights(w, y, slx_lags=slx_lags)
w = USER.check_weights(w, y, slx_lags=slx_lags, w_required=spat_diag)
if slx_lags > 0:
lag_x = get_lags(w, x_constant, slx_lags)
x_constant = np.hstack((x_constant, lag_x))
Expand Down
1 change: 0 additions & 1 deletion spreg/twosls_sp_regimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ def __init__(
"Spatial diagnostics are not available for HAC estimation. The spatial diagnostics have been disabled for this model.",
)
spat_diag = False
USER.check_spat_diag(spat_diag, w)
x_constant, name_x, warn = USER.check_constant(x, name_x, just_rem=True)
set_warn(self, warn)
name_x = USER.set_name_x(name_x, x_constant, constant=True)
Expand Down
6 changes: 3 additions & 3 deletions spreg/user_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def check_weights(w, y, w_required=False, time=False, slx_lags=0):
# should not raise an exception
"""
if w_required == True or w != None or slx_lags > 0:
if w_required == True or (w is not None) or slx_lags > 0:
if isinstance(w, graph.Graph):
w = w.to_W()

Expand Down Expand Up @@ -644,7 +644,7 @@ def check_robust(robust, wk):
"invalid value passed to robust, see docs for valid options"
)


''' Deprecated in 1.6.1
def check_spat_diag(spat_diag, w):
"""Check if there is a w parameter passed by the user if the user also
requests spatial diagnostics.
Expand Down Expand Up @@ -684,7 +684,7 @@ def check_spat_diag(spat_diag, w):
if spat_diag:
if not isinstance(w, weights.W):
raise Exception("w must be a libpysal.W object to run spatial diagnostics")

'''

def check_reg_list(regimes, name_regimes, n):
"""Check if the regimes parameter passed by the user is a valid list of
Expand Down

0 comments on commit d92edcb

Please sign in to comment.