Skip to content
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
36 changes: 26 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ sudo: false
branches:
only:
- master
python:
- "3.5"
- "3.6"

env:
- PYSAL_PLUS=false
- PYSAL_PLUS=true
python:
- 3.5
- 3.6
env:
- PYSAL_PYPI=true PYSAL_PLUS=true
- PYSAL_PYPI=true PYSAL_PLUS=false
- PYSAL_PYPI=false PYSAL_PLUS=true
- PYSAL_PYPI=false PYSAL_PLUS=false

matrix:
allow_failures:
- python: 3.5
env: PYSAL_PYPI=false PYSAL_PLUS=false
- python: 3.5
env: PYSAL_PYPI=false PYSAL_PLUS=true
- python: 3.6
env: PYSAL_PYPI=false PYSAL_PLUS=false
- python: 3.6
env: PYSAL_PYPI=false PYSAL_PLUS=true

before_install:
- wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
Expand All @@ -23,9 +36,12 @@ before_install:
install:
- conda install --yes pip nose
- which pip
- if "$PYSAL_PYPI"; then
echo 'testing pypi libpysal' && pip install libpysal;
else echo 'testing git libpysal'; git clone https://github.com/pysal/libpysal.git; cd libpysal; pip install .; cd ../;
fi;
- conda install --yes --file requirements.txt;
- pip install libpysal
- if [[ PYSAL_PLUS ]]; then conda install --yes numba; fi
- if "$PYSAL_PLUS"; then conda install --yes numba; fi

script:
- pwd
Expand All @@ -38,8 +54,8 @@ notifications:
recipients:
- [email protected]
- [email protected]
on_change: always
on_failure: always
on_success: change
on_failure: change

after_success:
- coveralls
4 changes: 2 additions & 2 deletions esda/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class Gamma(object):

use same example as for join counts to show similarity

>>> import libpysal.api as lps, numpy as np
>>> import libpysal, numpy as np
>>> from esda.gamma import Gamma
>>> w = lps.lat2W(4,4)
>>> w = libpysal.weights.lat2W(4,4)
>>> y=np.ones(16)
>>> y[0:8]=0
>>> np.random.seed(12345)
Expand Down
6 changes: 3 additions & 3 deletions esda/geary.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class Geary(object):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> from esda.geary import Geary
>>> w = lps.open(lps.get_path("book.gal")).read()
>>> f = lps.open(lps.get_path("book.txt"))
>>> w = libpysal.io.open(libpysal.examples.get_path("book.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("book.txt"))
>>> y = np.array(f.by_col['y'])
>>> c = Geary(y,w,permutations=0)
>>> round(c.C,7)
Expand Down
12 changes: 6 additions & 6 deletions esda/getisord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__author__ = "Sergio J. Rey <[email protected]>, Myunghwa Hwang <[email protected]> "
__all__ = ['G', 'G_Local']

from libpysal.common import np, stats, math
from libpysal.common import np, stats
from libpysal.weights.spatial_lag import lag_spatial as slag
from .tabular import _univariate_handler

Expand Down Expand Up @@ -67,15 +67,15 @@ class G(object):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> import numpy
>>> numpy.random.seed(10)

Preparing a point data set
>>> points = [(10, 10), (20, 10), (40, 10), (15, 20), (30, 20), (30, 30)]

Creating a weights object from points
>>> w = lps.DistanceBand(points,threshold=15)
>>> w = libpysal.weights.DistanceBand(points,threshold=15)
>>> w.transform = "B"

Preparing a variable
Expand Down Expand Up @@ -106,7 +106,7 @@ def __init__(self, y, w, permutations=PERMUTATIONS):
y = y.reshape(len(y), 1) # Ensure that y is an n by 1 vector, otherwise y*y.T == y*y
self.den_sum = (y * y.T).sum() - (y * y).sum()
self.G = self.__calc(self.y)
self.z_norm = (self.G - self.EG) / math.sqrt(self.VG)
self.z_norm = (self.G - self.EG) / np.sqrt(self.VG)
self.p_norm = 1.0 - stats.norm.cdf(np.abs(self.z_norm))

if permutations:
Expand Down Expand Up @@ -278,7 +278,7 @@ class G_Local(object):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> import numpy
>>> numpy.random.seed(10)

Expand All @@ -288,7 +288,7 @@ class G_Local(object):

Creating a weights object from points

>>> w = lps.DistanceBand(points,threshold=15)
>>> w = libpysal.weights.DistanceBand(points,threshold=15)

Prepareing a variable

Expand Down
4 changes: 2 additions & 2 deletions esda/join_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class Join_Counts(object):
Replicate example from anselin and rey

>>> import numpy as np
>>> import libpysal.api as lps
>>> w = lps.lat2W(4, 4)
>>> import libpysal
>>> w = libpysal.weights.lat2W(4, 4)
>>> y = np.ones(16)
>>> y[0:8] = 0
>>> np.random.seed(12345)
Expand Down
46 changes: 23 additions & 23 deletions esda/moran.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class Moran(object):

Examples
--------
>>> import libpysal.api as lps
>>> w = lps.open(lps.get_path("stl.gal")).read()
>>> f = lps.open(lps.get_path("stl_hom.txt"))
>>> import libpysal
>>> w = libpysal.io.open(libpysal.examples.get_path("stl.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("stl_hom.txt"))
>>> y = np.array(f.by_col['HR8893'])
>>> from esda.moran import Moran
>>> mi = Moran(y, w)
Expand All @@ -112,8 +112,8 @@ class Moran(object):
0.00027147862770937614

SIDS example replicating OpenGeoda
>>> w = lps.open(lps.get_path("sids2.gal")).read()
>>> f = lps.open(lps.get_path("sids2.dbf"))
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> SIDR = np.array(f.by_col("SIDR74"))
>>> mi = Moran(SIDR, w)
>>> round(mi.I, 3)
Expand Down Expand Up @@ -327,7 +327,7 @@ class Moran_BV(object):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> import numpy as np

Set random number generator seed so we can replicate the example
Expand All @@ -337,13 +337,13 @@ class Moran_BV(object):
Open the sudden infant death dbf file and read in rates for 74 and 79
converting each to a numpy array

>>> f = lps.open(lps.get_path("sids2.dbf"))
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> SIDR74 = np.array(f.by_col['SIDR74'])
>>> SIDR79 = np.array(f.by_col['SIDR79'])

Read a GAL file and construct our spatial weights object

>>> w = lps.open(lps.get_path("sids2.gal")).read()
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()

Create an instance of Moran_BV
>>> from esda.moran import Moran_BV
Expand Down Expand Up @@ -481,8 +481,8 @@ def Moran_BV_matrix(variables, w, permutations=0, varnames=None):

open dbf

>>> import libpysal.api as lps
>>> f = lps.open(lps.get_path("sids2.dbf"))
>>> import libpysal
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))

pull of selected variables from dbf and create numpy arrays for each

Expand All @@ -491,7 +491,7 @@ def Moran_BV_matrix(variables, w, permutations=0, varnames=None):

create a contiguity matrix from an external gal file

>>> w = lps.open(lps.get_path("sids2.gal")).read()
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()

create an instance of Moran_BV_matrix

Expand Down Expand Up @@ -612,9 +612,9 @@ class Moran_Rate(Moran):

Examples
--------
>>> import libpysal.api as lps
>>> w = lps.open(lps.get_path("sids2.gal")).read()
>>> f = lps.open(lps.get_path("sids2.dbf"))
>>> import libpysal
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> e = np.array(f.by_col('SID79'))
>>> b = np.array(f.by_col('BIR79'))
>>> from esda.moran import Moran_Rate
Expand Down Expand Up @@ -788,11 +788,11 @@ class Moran_Local(object):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> import numpy as np
>>> np.random.seed(10)
>>> w = lps.open(lps.get_path("desmith.gal")).read()
>>> f = lps.open(lps.get_path("desmith.txt"))
>>> w = libpysal.io.open(libpysal.examples.get_path("desmith.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("desmith.txt"))
>>> y = np.array(f.by_col['z'])
>>> from esda.moran import Moran_Local
>>> lm = Moran_Local(y, w, transformation = "r", permutations = 99)
Expand Down Expand Up @@ -1020,11 +1020,11 @@ class Moran_Local_BV(object):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> import numpy as np
>>> np.random.seed(10)
>>> w = lps.open(lps.get_path("sids2.gal")).read()
>>> f = lps.open(lps.get_path("sids2.dbf"))
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> x = np.array(f.by_col['SIDR79'])
>>> y = np.array(f.by_col['SIDR74'])
>>> from esda.moran import Moran_Local_BV
Expand Down Expand Up @@ -1265,11 +1265,11 @@ class Moran_Local_Rate(Moran_Local):

Examples
--------
>>> import libpysal.api as lps
>>> import libpysal
>>> import numpy as np
>>> np.random.seed(10)
>>> w = lps.open(lps.get_path("sids2.gal")).read()
>>> f = lps.open(lps.get_path("sids2.dbf"))
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> e = np.array(f.by_col('SID79'))
>>> b = np.array(f.by_col('BIR79'))
>>> from esda.moran import Moran_Local_Rate
Expand Down
Loading