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

Deprecating check_spat_diag #147

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"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)

Check warning on line 445 in spreg/ols_regimes.py

View check run for this annotation

Codecov / codecov/patch

spreg/ols_regimes.py#L445

Added line #L445 was not covered by tests
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