differt-core 0.0.16__tar.gz → 0.0.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {differt_core-0.0.16 → differt_core-0.0.17}/Cargo.lock +1 -1
  2. {differt_core-0.0.16 → differt_core-0.0.17}/PKG-INFO +1 -1
  3. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/Cargo.toml +1 -1
  4. {differt_core-0.0.16 → differt_core-0.0.17/differt-core}/python/differt_core/_lowlevel/rt/graph.pyi +1 -0
  5. {differt_core-0.0.16 → differt_core-0.0.17/differt-core}/python/differt_core/rt/graph.py +1 -1
  6. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/rt/graph.rs +30 -0
  7. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/tests/rt/test_graph.py +34 -0
  8. {differt_core-0.0.16/differt-core → differt_core-0.0.17}/python/differt_core/_lowlevel/rt/graph.pyi +1 -0
  9. {differt_core-0.0.16/differt-core → differt_core-0.0.17}/python/differt_core/rt/graph.py +1 -1
  10. {differt_core-0.0.16 → differt_core-0.0.17}/Cargo.toml +0 -0
  11. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/LICENSE.md +0 -0
  12. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/README.md +0 -0
  13. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/benches/bench_main.rs +0 -0
  14. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/benches/benchmarks/graph_iterators.rs +0 -0
  15. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/benches/benchmarks/mod.rs +0 -0
  16. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/__init__.py +0 -0
  17. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/_lowlevel/__init__.pyi +0 -0
  18. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/_lowlevel/geometry/triangle_mesh.pyi +0 -0
  19. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/_lowlevel/rt/__init__.pyi +0 -0
  20. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/_lowlevel/scene/sionna.pyi +0 -0
  21. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/_lowlevel/scene/triangle_scene.pyi +0 -0
  22. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/geometry/__init__.py +0 -0
  23. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/geometry/triangle_mesh.py +0 -0
  24. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/py.typed +0 -0
  25. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/rt/__init__.py +0 -0
  26. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/scene/__init__.py +0 -0
  27. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/scene/sionna.py +0 -0
  28. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/python/differt_core/scene/triangle_scene.py +0 -0
  29. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/geometry/mod.rs +0 -0
  30. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/geometry/triangle_mesh.rs +0 -0
  31. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/lib.rs +0 -0
  32. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/rt/mod.rs +0 -0
  33. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/scene/mod.rs +0 -0
  34. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/scene/sionna.rs +0 -0
  35. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/src/scene/triangle_scene.rs +0 -0
  36. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/tests/__init__.py +0 -0
  37. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/tests/benchmarks/__init__.py +0 -0
  38. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/tests/benchmarks/conftest.py +0 -0
  39. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/tests/benchmarks/test_graph.py +0 -0
  40. {differt_core-0.0.16 → differt_core-0.0.17}/differt-core/tests/rt/__init__.py +0 -0
  41. {differt_core-0.0.16 → differt_core-0.0.17}/pyproject.toml +0 -0
  42. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/__init__.py +0 -0
  43. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/_lowlevel/__init__.pyi +0 -0
  44. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/_lowlevel/geometry/triangle_mesh.pyi +0 -0
  45. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/_lowlevel/rt/__init__.pyi +0 -0
  46. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/_lowlevel/scene/sionna.pyi +0 -0
  47. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/_lowlevel/scene/triangle_scene.pyi +0 -0
  48. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/geometry/__init__.py +0 -0
  49. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/geometry/triangle_mesh.py +0 -0
  50. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/py.typed +0 -0
  51. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/rt/__init__.py +0 -0
  52. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/scene/__init__.py +0 -0
  53. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/scene/sionna.py +0 -0
  54. {differt_core-0.0.16 → differt_core-0.0.17}/python/differt_core/scene/triangle_scene.py +0 -0
@@ -238,7 +238,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
238
238
 
239
239
  [[package]]
240
240
  name = "differt-core"
241
- version = "0.0.16"
241
+ version = "0.0.17"
242
242
  dependencies = [
243
243
  "criterion",
244
244
  "log",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: differt-core
3
- Version: 0.0.16
3
+ Version: 0.0.17
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.9
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -32,4 +32,4 @@ name = "differt_core"
32
32
  edition = "2021"
33
33
  name = "differt-core"
34
34
  rust-version = "1.75.0"
35
- version = "0.0.16"
35
+ version = "0.0.17"
@@ -31,6 +31,7 @@ class DiGraph:
31
31
  def insert_from_and_to_nodes(
32
32
  self, *, direct_path: bool = True
33
33
  ) -> tuple[int, int]: ...
34
+ def disconnect_nodes(self, *nodes: int, fast_mode: bool = True) -> None: ...
34
35
  def all_paths(
35
36
  self, from_: int, to: int, depth: int, *, include_from_and_to: bool = True
36
37
  ) -> AllPathsFromDiGraphIter: ...
@@ -1,4 +1,4 @@
1
- """TODO."""
1
+ """Graph utilities to generate path candidates, as used by exhaustive Ray Tracing methods, e.g., the Image Method."""
2
2
 
3
3
  __all__ = (
4
4
  "CompleteGraph",
@@ -685,6 +685,36 @@ pub mod directed {
685
685
  (from, to)
686
686
  }
687
687
 
688
+ /// Disconnect one or more nodes from the graph.
689
+ ///
690
+ /// This has two effects:
691
+ ///
692
+ /// - all paths from any of the specified nodes will be removed;
693
+ /// - and all paths to any of the specified nodes will be removed.
694
+ ///
695
+ /// Args:
696
+ /// nodes (int): The nodes to be disconnected.
697
+ /// fast\_mode (bool): Whether to skip removing the path to any
698
+ /// of the specified nodes. In practice, removing paths
699
+ /// from the nodes is sufficient, and faster to perform,
700
+ /// but can lead to a slower graph traversal when
701
+ /// generating all possible paths.
702
+ #[pyo3(signature = (*nodes, fast_mode=true))]
703
+ #[pyo3(text_signature = "(self, *nodes, fast_mode=True)")]
704
+ pub fn disconnect_nodes(&mut self, mut nodes: Vec<usize>, fast_mode: bool) {
705
+ for i in nodes.iter() {
706
+ self.edges_list[*i].clear();
707
+ }
708
+
709
+ if !fast_mode {
710
+ nodes.sort();
711
+
712
+ for edge in self.edges_list.iter_mut() {
713
+ edge.retain(|node| nodes.binary_search(node).is_err());
714
+ }
715
+ }
716
+ }
717
+
688
718
  /// Return an iterator over all paths of length ``depth``
689
719
  /// from node ``from_`` to node ``to``.
690
720
  ///
@@ -1,3 +1,4 @@
1
+ import numpy as np
1
2
  import pytest
2
3
 
3
4
  from differt_core.rt.graph import (
@@ -24,6 +25,39 @@ class TestDiGraph:
24
25
  ):
25
26
  _ = graph.insert_from_and_to_nodes(True) # type: ignore
26
27
 
28
+ @pytest.mark.parametrize("fast_mode", (True, False))
29
+ def test_disconnect_nodes(self, fast_mode: bool) -> None:
30
+ graph = DiGraph.from_complete_graph(CompleteGraph(6))
31
+ from_, to = graph.insert_from_and_to_nodes()
32
+
33
+ nodes = (0, 1, 2, 5)
34
+ graph.disconnect_nodes(*nodes, fast_mode=fast_mode)
35
+
36
+ for depth in range(0, 3):
37
+ for path in graph.all_paths(
38
+ from_, to, depth + 2, include_from_and_to=False
39
+ ):
40
+ for node in nodes:
41
+ assert node not in path
42
+
43
+ @pytest.mark.parametrize("fast_mode", (True, False))
44
+ def test_disconnect_nodes_equivalence(self, fast_mode: bool) -> None:
45
+ complete_graph = CompleteGraph(3)
46
+ di_graph = DiGraph.from_complete_graph(CompleteGraph(6))
47
+ from_, to = di_graph.insert_from_and_to_nodes()
48
+
49
+ nodes = (3, 4, 5)
50
+ di_graph.disconnect_nodes(*nodes, fast_mode=fast_mode)
51
+
52
+ for depth in range(0, 3):
53
+ complete_paths = complete_graph.all_paths_array(
54
+ from_, to, depth + 2, include_from_and_to=False
55
+ )
56
+ di_paths = di_graph.all_paths_array(
57
+ from_, to, depth + 2, include_from_and_to=False
58
+ )
59
+ np.testing.assert_equal(complete_paths, di_paths)
60
+
27
61
  def test_from_graph(self) -> None:
28
62
  graph = CompleteGraph(10)
29
63
  assert isinstance(graph, CompleteGraph)
@@ -31,6 +31,7 @@ class DiGraph:
31
31
  def insert_from_and_to_nodes(
32
32
  self, *, direct_path: bool = True
33
33
  ) -> tuple[int, int]: ...
34
+ def disconnect_nodes(self, *nodes: int, fast_mode: bool = True) -> None: ...
34
35
  def all_paths(
35
36
  self, from_: int, to: int, depth: int, *, include_from_and_to: bool = True
36
37
  ) -> AllPathsFromDiGraphIter: ...
@@ -1,4 +1,4 @@
1
- """TODO."""
1
+ """Graph utilities to generate path candidates, as used by exhaustive Ray Tracing methods, e.g., the Image Method."""
2
2
 
3
3
  __all__ = (
4
4
  "CompleteGraph",
File without changes