Skip to content

Commit

Permalink
Merge branch 'main' into try_doctests_again
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi committed Feb 1, 2024
2 parents ab617f5 + 5ec4601 commit 4aed112
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ matrix.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles(matrix.environment-file) }}
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: 'latest'
channels: conda-forge
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"

Expand All @@ -42,7 +42,7 @@ jobs:
twine check --strict dist/*
- name: Create Release Notes
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
if: matrix.os == 'windows-latest'

- name: codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
Expand Down
34 changes: 18 additions & 16 deletions spreg/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
"Luc Anselin [email protected], Nicholas Malizia [email protected] "
)

from libpysal.common import *
import scipy.sparse as SP
from math import sqrt, pi

from libpysal.common import MISSINGVALUE
import numpy as np
import numpy.linalg as la
import scipy.sparse as SP
from scipy import stats

from .utils import spmultiply, sphstack, spmin, spmax


Expand Down Expand Up @@ -160,12 +165,9 @@ def t_stat(reg, z_stat=False):
vm = reg.vm # (array) coefficients of variance matrix (k x k)
betas = reg.betas # (array) coefficients of the regressors (1 x k)
variance = vm.diagonal()
tStat = (
betas[list(range(0, len(vm)))].reshape(
len(vm),
)
/ np.sqrt(variance)
)
tStat = betas[list(range(0, len(vm)))].reshape(
len(vm),
) / np.sqrt(variance)
ts_result = []
for t in tStat:
if z_stat:
Expand Down Expand Up @@ -678,15 +680,15 @@ def jarque_bera(reg):
"""
n = reg.n # (scalar) number of observations
u = reg.u # (array) residuals from regression
u2 = u ** 2
u3 = u ** 3
u4 = u ** 4
u2 = u**2
u3 = u**3
u4 = u**4
mu2 = np.mean(u2)
mu3 = np.mean(u3)
mu4 = np.mean(u4)
S = mu3 / (mu2 ** (1.5)) # skewness measure
K = mu4 / (mu2 ** 2) # kurtosis measure
jb = n * (((S ** 2) / 6) + ((K - 3) ** 2) / 24)
K = mu4 / (mu2**2) # kurtosis measure
jb = n * (((S**2) / 6) + ((K - 3) ** 2) / 24)
pvalue = stats.chisqprob(jb, 2)
jb_result = {"df": 2, "jb": jb, "pvalue": pvalue}
return jb_result
Expand Down Expand Up @@ -776,7 +778,7 @@ def breusch_pagan(reg, z=None):
0.0193
"""
e2 = reg.u ** 2
e2 = reg.u**2
e = reg.u
n = reg.n
k = reg.k
Expand Down Expand Up @@ -919,7 +921,7 @@ def white(reg):
0.0013
"""
e = reg.u ** 2
e = reg.u**2
k = int(reg.k)
n = int(reg.n)
y = reg.y
Expand Down Expand Up @@ -1084,7 +1086,7 @@ def koenker_bassett(reg, z=None):
"""
# The notation here matches that of Greene (2003).
u = reg.u ** 2
u = reg.u**2
e = reg.u
n = reg.n
k = reg.k
Expand Down
16 changes: 7 additions & 9 deletions spreg/diagnostics_tsls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"Luc Anselin [email protected], Nicholas Malizia [email protected] "
)

from libpysal.common import *
import numpy as np
from scipy import stats
from scipy.stats import pearsonr

__all__ = ["t_stat", "pr2_aspatial", "pr2_spatial"]
Expand Down Expand Up @@ -118,12 +119,9 @@ def t_stat(reg, z_stat=False):
vm = reg.vm # (array) coefficients of variance matrix (k x k)
betas = reg.betas # (array) coefficients of the regressors (1 x k)
variance = vm.diagonal()
tStat = (
betas.reshape(
len(betas),
)
/ np.sqrt(variance)
)
tStat = betas.reshape(
len(betas),
) / np.sqrt(variance)
ts_result = []
for t in tStat:
if z_stat:
Expand Down Expand Up @@ -221,7 +219,7 @@ def pr2_aspatial(tslsreg):
y = tslsreg.y
predy = tslsreg.predy
pr = pearsonr(y.flatten(), predy.flatten())[0]
pr2_result = float(pr ** 2)
pr2_result = float(pr**2)
return pr2_result


Expand Down Expand Up @@ -329,7 +327,7 @@ def pr2_spatial(tslsreg):
y = tslsreg.y
predy_e = tslsreg.predy_e
pr = pearsonr(y.flatten(), predy_e.flatten())[0]
pr2_result = float(pr ** 2)
pr2_result = float(pr**2)
return pr2_result


Expand Down

0 comments on commit 4aed112

Please sign in to comment.