Skip to content

Commit

Permalink
Merge pull request #217 from sjsrey/seed
Browse files Browse the repository at this point in the history
Seed testing
  • Loading branch information
sjsrey committed Apr 14, 2020
2 parents bca1fbd + b946963 commit 25ce29b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ install:
- python geosnap/tests/get_data.py



script:
- if [[ $TRAVIS_JOB_NAME == python-* ]]; then
travis_wait 45 pytest --ignore=examples/ --ignore=geosnap/util/ --ignore=geosnap/visualize/ --cov geosnap;
Expand Down
10 changes: 10 additions & 0 deletions geosnap/tests/test_clusters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from geosnap import Community, io
import numpy as np

reno = Community.from_census(msa_fips="39900")
columns = ["median_household_income", "p_poverty_rate", "p_unemployment_rate"]
Expand Down Expand Up @@ -72,3 +73,12 @@ def test_skater():
def test_azp():
r = reno.cluster_spatial(columns=columns, method="azp", n_clusters=7)
assert len(r.gdf.azp.unique()) == 8


# Test seeding

def test_seed():
np.random.seed(12345)
r = reno.cluster(columns=columns, method='ward')
card = r.gdf.groupby('ward').count()['geoid'].values
np.testing.assert_array_equal(card, [27, 83, 19, 51, 38, 7])

0 comments on commit 25ce29b

Please sign in to comment.