Skip to content

Commit

Permalink
Merge pull request #645 from jlaura/master
Browse files Browse the repository at this point in the history
Update to weights module documentation for PySAL-REST
  • Loading branch information
sjsrey committed Jun 27, 2015
2 parents 47899f8 + dc3efcd commit 057016f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
6 changes: 3 additions & 3 deletions pysal/spatial_dynamics/ergodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def steady_state(P):
Returns
-------
matrix
: matrix
(k, 1), steady state distribution.
Examples
Expand Down Expand Up @@ -125,12 +125,12 @@ def var_fmpt(P):
Parameters
----------
P : matrix
P : matrix
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
matrix
: matrix
(k, k), elements are the variances for the number of intervals
required for a chain starting in state i to first enter state j.
Expand Down
9 changes: 6 additions & 3 deletions pysal/spatial_dynamics/markov.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def chi2(T1, T2):
Returns
-------
tuple
: tuple
(3 elements).
(chi2 value, pvalue, degrees of freedom).
Expand Down Expand Up @@ -1288,7 +1288,7 @@ def homogeneity(transition_matrices, regime_names=[], class_names=[], \
Returns
-------
implicit
: implicit
an instance of Homogeneity_Results.
"""

Expand All @@ -1314,6 +1314,9 @@ class Homogeneity_Results:
title : string
Title of the table.
Attributes
-----------
Notes
-----
Degrees of freedom adjustment follow the approach in Bickenbach and Bode (2003) [3]_.
Expand Down Expand Up @@ -1506,4 +1509,4 @@ def summary(self, file_name=None, title="Markov Homogeneity Test"):
c.append("\\hline\n")
c.append("\\end{tabular}")
s2 = "".join(c)
f.write(s1+s2)
f.write(s1+s2)
7 changes: 5 additions & 2 deletions pysal/spatial_dynamics/rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _calc(self, x, y):
return tau, pval, Concordant, Discordant, ExtraX, ExtraY


class SpatialTau:
class SpatialTau(object):
"""
Spatial version of Kendall's rank correlation statistic.
Expand Down Expand Up @@ -333,13 +333,16 @@ class SpatialTau:
----------
.. [3] Christensen, D. (2005) "Fast algorithms for the calculation of
Kendall's tau." Computational Statistics, 20: 51-62.
.. [4] Press, W.H, S. A Teukolsky, W.T. Vetterling and B. P. Flannery (2007).
Numerical Recipes: The Art of Scientific Computing. Cambridge. Pg 752.
.. [5] Rey, S.J. (2004) "Spatial dependence in the evolution of regional income
distributions," in A. Getis, J. Mur and H.Zoeller (eds). Spatial
Econometrics and Spatial Statistics. Palgrave, London, pp. 194-213.
.. [6] Rey, S.J. (2014) "Fast algorithms for calculation of a space-time
concordance measure." Computational Statistics, 29(3-4):799811.
concordance measure." Computational Statistics, 29(3-4): 799-811.
Examples
--------
Expand Down
19 changes: 19 additions & 0 deletions pysal/weights/Distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ class Kernel(W):
adjustment to ensure knn distance range is closed on the
knnth observations
Attributes
----------
weights : dict
Dictionary keyed by id with a list of weights for each neighbor
neighbors : dict
of lists of neighbors keyed by observation id
bandwidth : array
array of bandwidths
Examples
--------
Expand Down Expand Up @@ -428,6 +439,14 @@ class DistanceBand(W):
ids : list
values to use for keys of the neighbors and weights dicts
Attributes
----------
weights : dict
of neighbor weights keyed by observation id
neighbors : dict
of neighbors keyed by observation id
Examples
--------
Expand Down
23 changes: 10 additions & 13 deletions pysal/weights/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,15 @@ def higher_order_sp(w, k=2, shortest_path=True, diagonal=False):
Contiguity weights for either a sparse W or pysal.weights.W for order k.
Parameters
==========
----------
w : W, sparse_matrix
spatial weights object or scipy.sparse.csr.csr_instance
w : W
sparse_matrix, spatial weights object or scipy.sparse.csr.csr_instance
k : int
Order of contiguity
shortest_path: boolean
shortest_path : boolean
True: i,j and k-order neighbors if the
shortest path for i,j is k
False: i,j are k-order neighbors if there
Expand All @@ -476,10 +476,8 @@ def higher_order_sp(w, k=2, shortest_path=True, diagonal=False):
Returns
-------
wk: W, WSP
type matches type of w argument
wk : W
WSP, type matches type of w argument
Notes
-----
Expand Down Expand Up @@ -679,10 +677,9 @@ def full(w):
Returns
-------
tuple
first element being the full numpy array and second element
keys being the ids associated with each row in the array.
(fullw, keys) : tuple
first element being the full numpy array and second element
keys being the ids associated with each row in the array.
Examples
--------
Expand Down Expand Up @@ -714,7 +711,6 @@ def full(w):
def full2W(m, ids=None):
'''
Create a PySAL W object from a full array.
...
Parameters
----------
Expand Down Expand Up @@ -781,6 +777,7 @@ def full2W(m, ids=None):


def WSP2W(wsp, silent_island_warning=False):

"""
Convert a pysal WSP object (thin weights matrix) to a pysal W object.
Expand Down

0 comments on commit 057016f

Please sign in to comment.