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

enh: add doctests to travis (#2) #112

Merged
merged 1 commit into from
Oct 7, 2018
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ install:
script:
- python setup.py sdist >/dev/null
- echo "check_stable=False" >libpysal/config.py
- nosetests --verbose --with-coverage --cover-package=libpysal;
- nosetests --with-doctest --verbose --with-coverage --cover-package=libpysal -I shapely_ext.py;
#- cd doc; make pickle; make doctest
notifications:
email:
Expand Down
27 changes: 7 additions & 20 deletions libpysal/cg/alpha_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_faces(triangle):
Example
-------

>>> triangle = np.array([3, 1, 4], dtype=int32)
>>> triangle = np.array([3, 1, 4], dtype=np.int32)
>>> faces = get_faces(triangle)
>>> faces
array([[3., 1.],
Expand Down Expand Up @@ -215,11 +215,7 @@ def build_faces(faces, triangles_is,
Example
-------
>>> import scipy.spatial as spat
>>> pts = np.array([[0, 1],
[3, 5],
[4, 1],
[6, 7],
[9, 3]])
>>> pts = np.array([[0, 1], [3, 5], [4, 1], [6, 7], [9, 3]])
>>> triangulation = spat.Delaunay(pts)
>>> triangulation.simplices
array([[3, 1, 4],
Expand All @@ -229,9 +225,8 @@ def build_faces(faces, triangles_is,
>>> num_triangles = triangulation.simplices.shape[0]
>>> num_faces = num_triangles * num_faces_single
>>> faces = np.zeros((num_faces, 2), dtype=np.int_)
>>> mask = np.ones((num_faces,), dtype=np.bool_)
>>> faces = build_faces(faces, triangulation.simplices,
num_triangles, num_faces_single)
>>> mask = np.ones((num_faces,), dtype=np.bool_)
>>> faces = build_faces(faces, triangulation.simplices, num_triangles, num_faces_single)
>>> faces
array([[3, 1],
[1, 4],
Expand Down Expand Up @@ -273,17 +268,9 @@ def nb_mask_faces(mask, faces):

Example
-------

>>> faces = array([[0, 1],
[0, 2],
[1, 2],
[1, 2],
[1, 3],
[1, 4],
[1, 4],
[2, 4],
[3, 4]])
>>> mask = np.ones((faces.shape[0], ), dtype=bool_)
>>> import numpy as np
>>> faces = np.array([[0, 1], [0, 2], [1, 2], [1, 2], [1, 3], [1, 4], [1, 4], [2, 4], [3, 4]])
>>> mask = np.ones((faces.shape[0], ), dtype=np.bool_)
>>> masked = nb_mask_faces(mask, faces)
>>> masked
array([[0, 1],
Expand Down
4 changes: 2 additions & 2 deletions libpysal/io/iohandlers/gal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def _read(self):
>>> w = testfile.read()
>>> w.n == 100
True
>>> w.sd == 1.5151237573214935
True
>>> print(round(w.sd,6))
1.515124
>>> testfile = pysal.open(pysal.examples.get_path('sids2.gal'),'r')

Return a sparse matrix for the w information
Expand Down
4 changes: 2 additions & 2 deletions libpysal/weights/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,8 +1486,8 @@ def fuzzy_contiguity(gdf, tolerance=0.005, buffering=False, drop=True):
>>> wf = fuzzy_contiguity(rs_df)
>>> wf.islands
[]
>>> wf[0]
{239: 1.0, 59: 1.0, 152: 1.0, 23: 1.0, 107: 1.0}
>>> wf[0] == dict({239: 1.0, 59: 1.0, 152: 1.0, 23: 1.0, 107: 1.0})
True

Example needing to use buffering

Expand Down