MCPcopy
hub / github.com/tum-pbs/PhiFlow / test_slice

Method test_slice

tests/commit/geom/test__graph.py:11–23  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9class TestGraph(TestCase):
10
11 def test_slice(self):
12 points = wrap([(0, 0), (1.2, 0), (2, 0), (2, 1), (.8, 1), (0, 1)], instance('points'), channel(vector='x,y'))
13 dense_edges = math.vec_length(math.pairwise_distances(points, 1.5))
14 dense_graph = graph(points, dense_edges, {})
15 dense_subgraph = dense_graph[{'points': slice(0, 2)}]
16 self.assertEqual(4, math.stored_indices(dense_subgraph.edges).entries.size)
17 self.assertEqual((2, 2), dense_subgraph.edges.shape.sizes)
18 # --- Sparse ---
19 sparse_edges = math.vec_length(math.pairwise_distances(points, 1.5, format='csr'))
20 sparse_graph = graph(points, sparse_edges, {})
21 sparse_subgraph = sparse_graph[{'points': slice(0, 2)}]
22 self.assertEqual(4, math.stored_indices(sparse_subgraph.edges).entries.size)
23 self.assertEqual((2, 2), sparse_subgraph.edges.shape.sizes)
24
25 def test_batch_slice(self):
26 x = vec(x=[0, 1, 2], y=0)

Callers

nothing calls this directly

Calls 1

graphFunction · 0.90

Tested by

no test coverage detected