Skip to content

Commit

Permalink
Merge pull request #201 from jGaboardi/format_repo
Browse files Browse the repository at this point in the history
black format repo
  • Loading branch information
weikang9009 authored Oct 5, 2023
2 parents 92e3bbb + 5944c3f commit b66ca75
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 87 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
21 changes: 15 additions & 6 deletions giddy/ergodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ def steady_state(P, fill_empty_classes=False):


def _fmpt_ergodic(P):
warn('_fmpt_ergodic is deprecated. It will be replaced in giddy 2.5 with _mfpt_',
DeprecationWarning, stacklevel=2)
warn(
"_fmpt_ergodic is deprecated. It will be replaced in giddy 2.5 with _mfpt_",
DeprecationWarning,
stacklevel=2,
)
return _mfpt_ergodic(P)


Expand Down Expand Up @@ -213,8 +216,11 @@ def _mfpt_ergodic(P):


def fmpt(P, fill_empty_classes=False):
warn('fmpt is deprecated. It will be replaced in giddy 2.5 with mfpt',
DeprecationWarning, stacklevel=2)
warn(
"fmpt is deprecated. It will be replaced in giddy 2.5 with mfpt",
DeprecationWarning,
stacklevel=2,
)
return mfpt(P, fill_empty_classes)


Expand Down Expand Up @@ -346,8 +352,11 @@ def mfpt(P, fill_empty_classes=False):


def var_fmpt_ergodic(p):
warn('var_fmpt_ergodic is deprecated. It will be replaced in giddy 2.5 with var_fmpt_ergodic',
DeprecationWarning, stacklevel=2)
warn(
"var_fmpt_ergodic is deprecated. It will be replaced in giddy 2.5 with var_fmpt_ergodic",
DeprecationWarning,
stacklevel=2,
)
return var_mfpt_ergodic(p)


Expand Down
4 changes: 1 addition & 3 deletions giddy/markov.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def __init__(self, class_ids, classes=None, fill_empty_classes=False, summary=Tr

@property
def mfpt(self):
warn('self._mfpt is deprecated. Please use self._mfpt')
warn("self._mfpt is deprecated. Please use self._mfpt")
if not hasattr(self, "_mfpt"):
self._mfpt = mfpt(self.p, fill_empty_classes=True)
return self._mfpt
Expand Down Expand Up @@ -800,7 +800,6 @@ def __init__(
variable_name=None,
fill_empty_classes=False,
):

y = np.asarray(y)
self.fixed = fixed
self.discrete = discrete
Expand Down Expand Up @@ -2038,7 +2037,6 @@ class FullRank_Markov(Markov):
"""

def __init__(self, y, fill_empty_classes=False, summary=True):

y = np.asarray(y)
# resolve ties: All values are given a distinct rank, corresponding
# to the order that the values occur in each cross section.
Expand Down
6 changes: 0 additions & 6 deletions giddy/rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ class SpatialTau(object):
"""

def __init__(self, x, y, w, permutations=0):

w.transform = "b"
self.n = len(x)
res = Tau(x, y)
Expand Down Expand Up @@ -478,7 +477,6 @@ class Tau_Local:
"""

def __init__(self, x, y):

self.n = len(x)
x = np.asarray(x)
y = np.asarray(y)
Expand Down Expand Up @@ -596,7 +594,6 @@ class Tau_Local_Neighbor:
"""

def __init__(self, x, y, w, permutations=0):

x = np.asarray(x)
y = np.asarray(y)
self.n = len(x)
Expand Down Expand Up @@ -751,7 +748,6 @@ class Tau_Local_Neighborhood:
"""

def __init__(self, x, y, w, permutations=0):

x = np.asarray(x)
y = np.asarray(y)
res = Tau_Local(x, y)
Expand Down Expand Up @@ -885,7 +881,6 @@ class Tau_Regional:
"""

def __init__(self, x, y, regime, permutations=0):

x = np.asarray(x)
y = np.asarray(y)
res = Tau_Local(x, y)
Expand Down Expand Up @@ -926,7 +921,6 @@ def __init__(self, x, y, regime, permutations=0):
self.tau_reg_pvalues = pvalues

def _calc(self, W, WH, P, S):

nomi = np.dot(P, np.dot(S, P.T))
denomi = np.dot(P, np.dot(W, P.T)) + np.dot(P, np.dot(WH, P.T))
T = nomi / denomi
Expand Down
6 changes: 4 additions & 2 deletions giddy/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import scipy.spatial.distance as d
from .markov import Markov


class Sequence(object):
"""
Pairwise sequence analysis.
Expand Down Expand Up @@ -153,7 +154,6 @@ class Sequence(object):
"""

def __init__(self, y, subs_mat=None, dist_type=None, indel=None, cluster_type=None):

y = np.asarray(y)
merged = list(itertools.chain.from_iterable(y))
self.classes = np.unique(merged)
Expand Down Expand Up @@ -192,7 +192,9 @@ def __init__(self, y, subs_mat=None, dist_type=None, indel=None, cluster_type=No
"sequences of unequal lengths!"
)

hamming_dist = d.pdist(y_int.astype(int), metric="hamming") * y_int.shape[1]
hamming_dist = (
d.pdist(y_int.astype(int), metric="hamming") * y_int.shape[1]
)
self.seq_dis_mat = d.squareform(hamming_dist)

elif dist_type.lower() == "arbitrary":
Expand Down
19 changes: 14 additions & 5 deletions notebooks/RankBasedMethods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,15 @@
"from libpysal.weights import block_weights\n",
"\n",
"with warnings.catch_warnings():\n",
" warnings.filterwarnings(\"ignore\", message=\"The weights matrix is not fully connected\")\n",
" warnings.filterwarnings(\n",
" \"ignore\", message=\"The weights matrix is not fully connected\"\n",
" )\n",
"\n",
" w = block_weights(complete_table[\"BEA region\"])\n",
" np.random.seed(12345)\n",
" tau_w = giddy.rank.SpatialTau(complete_table[\"1929\"], complete_table[\"2009\"], w, 999)"
" tau_w = giddy.rank.SpatialTau(\n",
" complete_table[\"1929\"], complete_table[\"2009\"], w, 999\n",
" )"
]
},
{
Expand Down Expand Up @@ -1244,11 +1248,16 @@
"outputs": [],
"source": [
"with warnings.catch_warnings():\n",
" warnings.filterwarnings(\"ignore\", message=\"The weights matrix is not fully connected\")\n",
" warnings.filterwarnings(\n",
" \"ignore\", message=\"The weights matrix is not fully connected\"\n",
" )\n",
" np.random.seed(12345)\n",
" \n",
"\n",
" tau_w = giddy.rank.Tau_Regional(\n",
" complete_table[\"1929\"], complete_table[\"2009\"], complete_table[\"BEA region\"], 999\n",
" complete_table[\"1929\"],\n",
" complete_table[\"2009\"],\n",
" complete_table[\"BEA region\"],\n",
" 999,\n",
" )"
]
},
Expand Down
1 change: 0 additions & 1 deletion requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
nbsphinx
nbsphinx-link
numpydoc
sphinx>=1.4.3
sphinxcontrib-bibtex
Expand Down
Loading

0 comments on commit b66ca75

Please sign in to comment.