Skip to content

Commit

Permalink
metromap: add additional test and adapt conf for interactive plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Marika-K committed Jun 19, 2024
1 parent 57e3133 commit 646f50d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"construction_warning": False,
}
html_favicon = "https://www.gurobi.com/favicon.ico"
html_static_path = ["_static"]

autosectionlabel_prefix_document = True

Expand Down
24 changes: 24 additions & 0 deletions tests/test_metromap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import gurobi_optimods.metromap as map

# to run only the unittests for the metromap optimod use this command
# python -m unittest tests.test_metromap.Testmap

small1_nodes = """
Expand Down Expand Up @@ -73,6 +74,29 @@

@unittest.skipIf(nx is None, "networkx is not installed")
class Testmap(unittest.TestCase):
def test_node_degree_to_high(self):
# create a graph one node in the middle and 9 adjacent nodes
# node degree is 9
G = nx.Graph()
G.add_edge(0, 1)
G.add_edge(0, 2)
G.add_edge(0, 3)
G.add_edge(0, 4)
G.add_edge(0, 5)
G.add_edge(0, 6)
G.add_edge(0, 7)
G.add_edge(0, 8)
G.add_edge(0, 9)

with self.assertRaises(ValueError) as error:
graph_out, edge_directions = map.metromap(G)

self.assertEqual(
str(error.exception),
"Node with number 0 has node degree 9. "
"Octilinear representation is not possible for node degree larger than 8",
)

def test_small_no_geodata_no_lines(self):
edge_data = pd.read_csv(io.StringIO(small1_edges))
node_data = pd.read_csv(io.StringIO(small1_nodes))
Expand Down

0 comments on commit 646f50d

Please sign in to comment.