Skip to content

Commit

Permalink
Merge pull request #156 from jGaboardi/_round_sig_test
Browse files Browse the repository at this point in the history
Round sig test
  • Loading branch information
jGaboardi committed Nov 24, 2018
2 parents 58a503d + 8dc35c0 commit bb295db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spaghetti/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ def test_element_as_gdf(self):
obs_edge = edges.loc[(edges['id'] == (0,1)), 'geometry'].squeeze()
obs_edge_wkt = obs_edge.wkt
self.assertEqual(obs_edge_wkt, known_edge_wkt)

def test_round_sig(self):
# round to 2 significant digits test
x_round2, y_round2 = 1200, 1900
self.ntw_from_shp.node_sig = 2
obs_xy_round2 = self.ntw_from_shp._round_sig((1215, 1865))
self.assertEqual(obs_xy_round2, (x_round2, y_round2))

# round to no significant digits test
x_roundNone, y_roundNone = 1215, 1865
self.ntw_from_shp.node_sig = None
obs_xy_roundNone = self.ntw_from_shp._round_sig((1215, 1865))
self.assertEqual(obs_xy_roundNone, (x_roundNone, y_roundNone))


@unittest.skipIf(GEOPANDAS_EXTINCT, 'Missing Geopandas')
Expand Down
13 changes: 13 additions & 0 deletions spaghetti/tests/test_network_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ def test_element_as_gdf(self):
obs_edge = edges.loc[(edges['id'] == (0,1)), 'geometry'].squeeze()
obs_edge_wkt = obs_edge.wkt
self.assertEqual(obs_edge_wkt, known_edge_wkt)

def test_round_sig(self):
# round to 2 significant digits test
x_round2, y_round2 = 1200, 1900
self.ntw_from_shp.node_sig = 2
obs_xy_round2 = self.ntw_from_shp._round_sig((1215, 1865))
self.assertEqual(obs_xy_round2, (x_round2, y_round2))

# round to no significant digits test
x_roundNone, y_roundNone = 1215, 1865
self.ntw_from_shp.node_sig = None
obs_xy_roundNone = self.ntw_from_shp._round_sig((1215, 1865))
self.assertEqual(obs_xy_roundNone, (x_roundNone, y_roundNone))


@unittest.skipIf(GEOPANDAS_EXTINCT, 'Missing Geopandas')
Expand Down

0 comments on commit bb295db

Please sign in to comment.