Skip to content

Commit

Permalink
add test for unaltered utils._split_line()
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi committed Dec 8, 2020
1 parent 4136694 commit 7d67f19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
19 changes: 15 additions & 4 deletions tigernet/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from .. import utils

import copy
import geopandas
import numpy
import operator
import pandas
import unittest
from shapely.geometry import MultiLineString
from shapely.geometry import LineString, MultiLineString

from .network_objects import network_lattice_1x1_no_args

Expand Down Expand Up @@ -87,9 +88,6 @@ def test_record_filter_sval(self):


class TestUtilRsestrictionWelder(unittest.TestCase):
def setUp(self):
pass

def test_restriction_welder_key_error_synth(self):
known_return = None
_net = copy.deepcopy(network_lattice_1x1_no_args)
Expand All @@ -104,5 +102,18 @@ def test_restriction_welder_key_error_synth(self):
self.assertEqual(observed_return, known_return)


class TestUtilSplitLine(unittest.TestCase):
def test_split_line_unaltered(self):
known_unaltered = LineString(((0, 1), (1, 1)))
tgeoms = [LineString(((0, 0), (0, 2)))] + [known_unaltered]
tcase = geopandas.GeoDataFrame(geometry=tgeoms)
idx, geom = 1, "geometry"
loi = tcase.loc[idx, geom]
observed_unaltered = utils._split_line(loi, idx, df=tcase, geo_col=geom)
for eidx, xy in enumerate(known_unaltered.xy):
for cidx, coord in enumerate(xy):
self.assertEqual(observed_unaltered[0].xy[eidx][cidx], coord)


if __name__ == "__main__":
unittest.main()
5 changes: 3 additions & 2 deletions tigernet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,11 +1549,12 @@ def _split_line(loi, idx, df=None, geo_col=None, ring_road=False):

if unaltered:
return unaltered

""" ############################################### REMOVE AFTER FULL LEON COUNTY TEST
# Line breaking
if not type(breaks) == list:
print("[breaks]")
breaks = [breaks]

"""
new_lines = _create_split_lines(
breaks=breaks,
loi=loi,
Expand Down

0 comments on commit 7d67f19

Please sign in to comment.