コード例 #1
0
 def test__eq__not_match_values(self):
     self.assertFalse(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == {
             0: {
                 1: [0, 2]
             },
             1: {}
         })
コード例 #2
0
 def test__eq__match(self):
     self.assertTrue(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == {
             0: {
                 1: [0, 1]
             },
             1: {}
         })
コード例 #3
0
 def test__eq__not_match_keys(self):
     self.assertFalse(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == {
             2: {
                 2: [0, 1]
             },
             1: {}
         })
コード例 #4
0
 def test_str(self):
     res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)
     # Since run in parallel the order is not deterministic
     expected_valid = [
         "AllPairsPathMapping{1: PathMapping{}, 0: PathMapping{1: [0, 1]}}",
         "AllPairsPathMapping{0: PathMapping{1: [0, 1]}, 1: PathMapping{}}",
     ]
     self.assertIn(str(res), expected_valid)
コード例 #5
0
 def test__ne__match(self):
     self.assertFalse(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) != {
             0: {
                 1: [0, 1]
             },
             1: {}
         })
コード例 #6
0
 def test_items(self):
     items = retworkx.all_pairs_dijkstra_shortest_paths(self.dag,
                                                        self.fn).items()
     # Since run in parallel the order is not deterministic
     expected_valid = [
         [(0, {
             1: [0, 1]
         }), (1, {})],
         [(1, {}), (0, {
             1: [0, 1]
         })],
     ]
     self.assertIn(list(items), expected_valid)
コード例 #7
0
 def test_not_contains(self):
     res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)
     self.assertNotIn(2, res)
コード例 #8
0
 def test__ne__invalid_type(self):
     self.assertTrue(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) !=
         {"a": {}})
コード例 #9
0
 def test__eq__invalid_type(self):
     self.assertFalse(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) ==
         {"a": []})
コード例 #10
0
 def test_keys(self):
     keys = retworkx.all_pairs_dijkstra_shortest_paths(self.dag,
                                                       self.fn).keys()
     self.assertEqual([0, 1], list(sorted(keys)))
コード例 #11
0
 def test_index_error(self):
     res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)
     with self.assertRaises(IndexError):
         res[42]
コード例 #12
0
 def test_hash(self):
     res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)
     hash_res = hash(res)
     self.assertIsInstance(hash_res, int)
     # Assert hash is stable
     self.assertEqual(hash_res, hash(res))
コード例 #13
0
 def test_pickle(self):
     paths = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)
     paths_pickle = pickle.dumps(paths)
     paths_copy = pickle.loads(paths_pickle)
     self.assertEqual(paths, paths_copy)
コード例 #14
0
 def test_deepcopy(self):
     paths = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)
     paths_copy = copy.deepcopy(paths)
     self.assertEqual(paths, paths_copy)
コード例 #15
0
 def test__gt__not_implemented(self):
     with self.assertRaises(NotImplementedError):
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) > {
             1: [0, 2]
         }
コード例 #16
0
 def test__eq__different_length(self):
     self.assertFalse(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == {
             1: [0, 1],
             2: [0, 2]
         })
コード例 #17
0
 def test_eq__same_type(self):
     self.assertEqual(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn),
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn),
     )
コード例 #18
0
 def test_values(self):
     values = retworkx.all_pairs_dijkstra_shortest_paths(self.dag,
                                                         self.fn).values()
     # Since run in parallel the order is not deterministic
     expected_valid = [[{1: [0, 1]}, {}], [{}, {1: [0, 1]}]]
     self.assertIn(list(values), expected_valid)
コード例 #19
0
 def test__eq__invalid_inner_type(self):
     self.assertFalse(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) ==
         {0: {
             1: None
         }})
コード例 #20
0
 def test_iter(self):
     mapping_iter = iter(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn))
     output = list(sorted(mapping_iter))
     self.assertEqual(output, [0, 1])
コード例 #21
0
 def test_all_pairs_dijkstra_shortest_paths(self):
     res = retworkx.all_pairs_dijkstra_shortest_paths(
         self.graph, lambda _: 1)
     self.assertIsInstance(res, retworkx.AllPairsPathMapping)
コード例 #22
0
 def test__ne__not_match_values(self):
     self.assertTrue(
         retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) !=
         {1: [0, 2]})