Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi committed Oct 11, 2022
1 parent 8f8e5f4 commit 227b3c3
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions spaghetti/tests/network_test_classes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import copy
import warnings

import numpy
import pytest
Expand Down Expand Up @@ -209,7 +208,6 @@ def test_components(self):
assert observed_graph_edge == known_graph_edge

def test_connected_components(self):
## test warnings
ntw = copy.deepcopy(self.ntw_from_lattice_ring)

# observed values
Expand Down Expand Up @@ -346,19 +344,22 @@ def test_shortest_paths(self):
observed_vertices1 = observed_paths[2][1].vertices
observed_vertices2 = len(observed_paths[3][1].vertices)
# known values
known_vertices1 = [(1.0, 0.5), (1.0, 0.6)]
known_vertices1 = [
cg.Point((0.5, 1.0)),
cg.Point((1.0, 1.0)),
cg.Point((1.0, 0.6)),
]
known_vertices2 = 4
assert observed_vertices1 == observed_vertices1
assert observed_vertices1 == known_vertices1
assert observed_vertices2 == known_vertices2

# test error
with pytest.raises(AttributeError):
lattice = self.spaghetti.regular_lattice((0, 0, 4, 4), 4)
ntw = self.spaghetti.Network(in_data=lattice)
paths = ntw.shortest_paths([], synth_obs)
ntw.shortest_paths([], synth_obs)

@pytest.mark.filterwarnings("ignore:There is a least one point pattern")
@pytest.mark.filterwarnings("ignore:Either one or both")
def test_extract_component(self):
ntw = copy.deepcopy(self.ntw_from_lattice_ring)
s2s, tree = ntw.allneighbordistances("points", gen_tree=True)
Expand All @@ -375,10 +376,7 @@ def test_extract_component(self):
assert observed_napts == known_napts

# test largest component
with pytest.warns(UserWarning, match="Either one or both"):
largest = self.spaghetti.extract_component(
ntw, ntw.network_largest_component
)
largest = self.spaghetti.extract_component(ntw, ntw.network_largest_component)

# observed values
observed_arcs, observed_edges = largest.arcs, largest.edges
Expand Down Expand Up @@ -751,7 +749,6 @@ def setup_method(self):
midpoints.append(mid)
self.mids = "mids"
self.ntw.snapobservations(midpoints, self.mids)
npts = self.ntw.pointpatterns[self.mids].npoints
self.test_permutations = 99
self.test_steps = 10

Expand Down

0 comments on commit 227b3c3

Please sign in to comment.