differt 0.0.25__tar.gz → 0.0.27__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.
- {differt-0.0.25 → differt-0.0.27}/.gitignore +2 -0
- {differt-0.0.25 → differt-0.0.27}/PKG-INFO +5 -5
- {differt-0.0.25 → differt-0.0.27}/pyproject.toml +3 -2
- differt-0.0.27/src/differt/_version.py +6 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/em/_special.py +0 -14
- {differt-0.0.25 → differt-0.0.27}/src/differt/em/_utd.py +0 -6
- {differt-0.0.25 → differt-0.0.27}/src/differt/em/_utils.py +0 -2
- {differt-0.0.25 → differt-0.0.27}/src/differt/geometry/__init__.py +11 -1
- {differt-0.0.25 → differt-0.0.27}/src/differt/geometry/_paths.py +102 -8
- {differt-0.0.25 → differt-0.0.27}/src/differt/geometry/_triangle_mesh.py +24 -6
- {differt-0.0.25 → differt-0.0.27}/src/differt/geometry/_utils.py +346 -13
- {differt-0.0.25 → differt-0.0.27}/src/differt/plotting/_core.py +174 -73
- {differt-0.0.25 → differt-0.0.27}/src/differt/plotting/_utils.py +7 -7
- {differt-0.0.25 → differt-0.0.27}/src/differt/rt/__init__.py +2 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/rt/_fermat.py +37 -33
- {differt-0.0.25 → differt-0.0.27}/src/differt/rt/_image_method.py +18 -16
- {differt-0.0.25 → differt-0.0.27}/src/differt/rt/_utils.py +91 -39
- {differt-0.0.25 → differt-0.0.27}/src/differt/scene/_sionna.py +23 -3
- {differt-0.0.25 → differt-0.0.27}/src/differt/scene/_triangle_scene.py +376 -48
- {differt-0.0.25 → differt-0.0.27}/src/differt/utils.py +83 -24
- differt-0.0.25/src/differt/_version.py +0 -8
- {differt-0.0.25 → differt-0.0.27}/LICENSE.md +0 -0
- {differt-0.0.25 → differt-0.0.27}/README.md +0 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/__init__.py +0 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/em/__init__.py +0 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/em/_constants.py +0 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/plotting/__init__.py +0 -0
- {differt-0.0.25 → differt-0.0.27}/src/differt/scene/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.27
|
|
4
4
|
Summary: Differentiable Ray Tracing Toolbox for Radio Propagation Simulations
|
|
5
5
|
Project-URL: Changelog, https://github.com/jeertmans/DiffeRT/releases
|
|
6
6
|
Project-URL: Documentation, https://eertmans.be/DiffeRT
|
|
@@ -8,8 +8,7 @@ Project-URL: Founding, https://github.com/sponsors/jeertmans
|
|
|
8
8
|
Project-URL: Homepage, https://github.com/jeertmans/DiffeRT
|
|
9
9
|
Project-URL: Repository, https://github.com/jeertmans/DiffeRT
|
|
10
10
|
Author-email: Jérome Eertmans <jeertmans@icloud.com>
|
|
11
|
-
License
|
|
12
|
-
License-File: LICENSE.md
|
|
11
|
+
License: MIT
|
|
13
12
|
Keywords: differentiable,jax,propagation,radio,ray tracing
|
|
14
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
@@ -17,11 +16,12 @@ Classifier: Programming Language :: Python :: 3
|
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
20
|
Classifier: Topic :: Scientific/Engineering
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
|
-
Requires-Dist: beartype>=0.
|
|
22
|
+
Requires-Dist: beartype>=0.19.0
|
|
23
23
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.0.
|
|
24
|
+
Requires-Dist: differt-core==0.0.27
|
|
25
25
|
Requires-Dist: equinox>=0.11.5
|
|
26
26
|
Requires-Dist: filelock>=3.15.4
|
|
27
27
|
Requires-Dist: jax>=0.4.32
|
|
@@ -9,14 +9,15 @@ classifiers = [
|
|
|
9
9
|
"Programming Language :: Python :: 3.10",
|
|
10
10
|
"Programming Language :: Python :: 3.11",
|
|
11
11
|
"Programming Language :: Python :: 3.12",
|
|
12
|
+
"Programming Language :: Python :: 3.13",
|
|
12
13
|
"License :: OSI Approved :: MIT License",
|
|
13
14
|
"Operating System :: OS Independent",
|
|
14
15
|
"Topic :: Scientific/Engineering",
|
|
15
16
|
]
|
|
16
17
|
dependencies = [
|
|
17
|
-
"beartype>=0.
|
|
18
|
+
"beartype>=0.19.0",
|
|
18
19
|
"chex>=0.1.86",
|
|
19
|
-
"differt-core==0.0.
|
|
20
|
+
"differt-core==0.0.27",
|
|
20
21
|
"equinox>=0.11.5",
|
|
21
22
|
"filelock>=3.15.4",
|
|
22
23
|
"jax>=0.4.32",
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Special functions.
|
|
3
|
-
|
|
4
|
-
This module extends the :mod:`jax.scipy.special` module
|
|
5
|
-
by adding missing function from :mod:`scipy.special`,
|
|
6
|
-
or by extending already implemented function to the
|
|
7
|
-
complex domain.
|
|
8
|
-
|
|
9
|
-
Those new implementation are needed to keep the ability
|
|
10
|
-
of differentating code, otherwise we could just
|
|
11
|
-
call the SciPy function and wrap their output
|
|
12
|
-
with :func:`jnp.asarray<jax.numpy.asarray>`.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
1
|
import jax
|
|
16
2
|
import jax.numpy as jnp
|
|
17
3
|
from beartype import beartype as typechecker
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
__all__ = (
|
|
4
4
|
"Paths",
|
|
5
|
+
"SBRPaths",
|
|
5
6
|
"TriangleMesh",
|
|
6
7
|
"assemble_paths",
|
|
8
|
+
"cartesian_to_spherical",
|
|
7
9
|
"fibonacci_lattice",
|
|
10
|
+
"merge_cell_ids",
|
|
11
|
+
"min_distance_between_cells",
|
|
8
12
|
"normalize",
|
|
9
13
|
"orthogonal_basis",
|
|
10
14
|
"path_lengths",
|
|
@@ -13,17 +17,21 @@ __all__ = (
|
|
|
13
17
|
"rotation_matrix_along_x_axis",
|
|
14
18
|
"rotation_matrix_along_y_axis",
|
|
15
19
|
"rotation_matrix_along_z_axis",
|
|
20
|
+
"spherical_to_cartesian",
|
|
16
21
|
"triangles_contain_vertices_assuming_inside_same_plane",
|
|
22
|
+
"viewing_frustum",
|
|
17
23
|
)
|
|
18
24
|
|
|
19
|
-
from ._paths import Paths
|
|
25
|
+
from ._paths import Paths, SBRPaths, merge_cell_ids
|
|
20
26
|
from ._triangle_mesh import (
|
|
21
27
|
TriangleMesh,
|
|
22
28
|
triangles_contain_vertices_assuming_inside_same_plane,
|
|
23
29
|
)
|
|
24
30
|
from ._utils import (
|
|
25
31
|
assemble_paths,
|
|
32
|
+
cartesian_to_spherical,
|
|
26
33
|
fibonacci_lattice,
|
|
34
|
+
min_distance_between_cells,
|
|
27
35
|
normalize,
|
|
28
36
|
orthogonal_basis,
|
|
29
37
|
path_lengths,
|
|
@@ -31,4 +39,6 @@ from ._utils import (
|
|
|
31
39
|
rotation_matrix_along_x_axis,
|
|
32
40
|
rotation_matrix_along_y_axis,
|
|
33
41
|
rotation_matrix_along_z_axis,
|
|
42
|
+
spherical_to_cartesian,
|
|
43
|
+
viewing_frustum,
|
|
34
44
|
)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"""Ray paths utilities."""
|
|
2
|
-
|
|
3
1
|
import sys
|
|
2
|
+
import warnings
|
|
4
3
|
from collections.abc import Callable, Iterator
|
|
4
|
+
from dataclasses import KW_ONLY
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
import equinox as eqx
|
|
8
8
|
import jax
|
|
9
9
|
import jax.numpy as jnp
|
|
10
10
|
from beartype import beartype as typechecker
|
|
11
|
-
from jaxtyping import Array, ArrayLike, Bool, Float, Int, Shaped, jaxtyped
|
|
11
|
+
from jaxtyping import Array, ArrayLike, Bool, Float, Int, Num, Shaped, jaxtyped
|
|
12
12
|
|
|
13
|
-
from differt.plotting import PlotOutput, draw_paths
|
|
13
|
+
from differt.plotting import PlotOutput, draw_paths, reuse
|
|
14
14
|
|
|
15
15
|
if sys.version_info >= (3, 11):
|
|
16
16
|
from typing import Self
|
|
@@ -20,7 +20,9 @@ else:
|
|
|
20
20
|
|
|
21
21
|
@jax.jit
|
|
22
22
|
@jaxtyped(typechecker=typechecker)
|
|
23
|
-
def _cell_ids(
|
|
23
|
+
def _cell_ids(
|
|
24
|
+
array: Shaped[Array, "batch n"],
|
|
25
|
+
) -> Int[Array, " batch"]:
|
|
24
26
|
@jaxtyped(typechecker=typechecker)
|
|
25
27
|
def scan_fun(
|
|
26
28
|
indices: Int[Array, " batch"],
|
|
@@ -55,6 +57,8 @@ def merge_cell_ids(
|
|
|
55
57
|
arrays. Of course, this method handles multiple dimensions
|
|
56
58
|
and will reshape the output array to match initial shape.
|
|
57
59
|
|
|
60
|
+
For an actual application example, see :ref:`multipath_lifetime_map`.
|
|
61
|
+
|
|
58
62
|
Warning:
|
|
59
63
|
The indices used in the returned array have nothing to
|
|
60
64
|
do with the ones used in individual arrays.
|
|
@@ -130,6 +134,12 @@ class Paths(eqx.Module):
|
|
|
130
134
|
"""The length (i.e., number of vertices) of each individual path."""
|
|
131
135
|
return self.objects.shape[-1]
|
|
132
136
|
|
|
137
|
+
@property
|
|
138
|
+
@jaxtyped(typechecker=typechecker)
|
|
139
|
+
def order(self) -> int:
|
|
140
|
+
"""The length (i.e., number of vertices) of each individual path, excluding start and end vertices."""
|
|
141
|
+
return self.objects.shape[-1] - 2
|
|
142
|
+
|
|
133
143
|
@property
|
|
134
144
|
@jax.jit
|
|
135
145
|
@jaxtyped(typechecker=typechecker)
|
|
@@ -297,9 +307,9 @@ class Paths(eqx.Module):
|
|
|
297
307
|
@eqx.filter_jit
|
|
298
308
|
@jaxtyped(typechecker=typechecker)
|
|
299
309
|
def reduce(
|
|
300
|
-
self, fun: Callable[[
|
|
301
|
-
) ->
|
|
302
|
-
"""Apply a function on all
|
|
310
|
+
self, fun: Callable[[Num[Array, "*batch path_length 3"]], Num[Array, " *batch"]]
|
|
311
|
+
) -> Num[Array, " "]:
|
|
312
|
+
"""Apply a function on all path vertices and accumulate the result into a scalar value.
|
|
303
313
|
|
|
304
314
|
Args:
|
|
305
315
|
fun: The function to be called on all path vertices.
|
|
@@ -322,3 +332,87 @@ class Paths(eqx.Module):
|
|
|
322
332
|
The resulting plot output.
|
|
323
333
|
"""
|
|
324
334
|
return draw_paths(self.masked_vertices, **kwargs)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
@jaxtyped(typechecker=typechecker)
|
|
338
|
+
class SBRPaths(Paths):
|
|
339
|
+
"""
|
|
340
|
+
Paths method generated with shooting-and-bouncing method.
|
|
341
|
+
|
|
342
|
+
Like :class:`Paths`, but holds information of lower-order
|
|
343
|
+
paths too.
|
|
344
|
+
|
|
345
|
+
E.g., second-order paths also contain information for line-of-sight (``order = 0``)
|
|
346
|
+
and first-order paths.
|
|
347
|
+
|
|
348
|
+
Warning:
|
|
349
|
+
The ``mask`` argument is ignored as it will automatically
|
|
350
|
+
by overwritten with the last array in :attr:`masks`.
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
_: KW_ONLY
|
|
354
|
+
masks: Bool[Array, " *batch path_length-1"] = eqx.field(converter=jnp.asarray)
|
|
355
|
+
"""An array of masks.
|
|
356
|
+
|
|
357
|
+
Extends :attr:`mask`, with one mask for each path order.
|
|
358
|
+
"""
|
|
359
|
+
|
|
360
|
+
def __post_init__(self) -> None:
|
|
361
|
+
if self.mask is not None:
|
|
362
|
+
msg = (
|
|
363
|
+
"Setting 'mask' argument is ignored for this class, "
|
|
364
|
+
"as it is overwritten by 'masks' argument."
|
|
365
|
+
)
|
|
366
|
+
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
367
|
+
|
|
368
|
+
self.mask = self.masks[..., -1]
|
|
369
|
+
|
|
370
|
+
def get_paths(self, order: int) -> Paths:
|
|
371
|
+
"""
|
|
372
|
+
Return the :class:`Paths` class instance corresponding to the given path order.
|
|
373
|
+
|
|
374
|
+
Args:
|
|
375
|
+
order: The order of the path to index.
|
|
376
|
+
|
|
377
|
+
Returns:
|
|
378
|
+
The corresponding paths class.
|
|
379
|
+
|
|
380
|
+
Raises:
|
|
381
|
+
ValueError: If the provided order is out-of-bounds.
|
|
382
|
+
"""
|
|
383
|
+
if order < 0 or order > self.order:
|
|
384
|
+
msg = (
|
|
385
|
+
f"Paths order must be strictly between 0 and {self.order} (incl.), "
|
|
386
|
+
f"but you provided {order}."
|
|
387
|
+
)
|
|
388
|
+
raise ValueError(msg)
|
|
389
|
+
|
|
390
|
+
vertices = jnp.concatenate(
|
|
391
|
+
(self.vertices[..., : order + 1, :], self.vertices[..., -1:, :]),
|
|
392
|
+
axis=-2,
|
|
393
|
+
)
|
|
394
|
+
objects = jnp.concatenate(
|
|
395
|
+
(self.objects[..., : order + 1], self.objects[..., -1:]),
|
|
396
|
+
axis=-1,
|
|
397
|
+
)
|
|
398
|
+
return Paths(vertices=vertices, objects=objects, mask=self.masks[..., order])
|
|
399
|
+
|
|
400
|
+
@jaxtyped(
|
|
401
|
+
typechecker=None
|
|
402
|
+
) # typing.Self is (currently) not compatible with jaxtyping and beartype
|
|
403
|
+
def reshape(self, *batch: int) -> Self:
|
|
404
|
+
return eqx.tree_at(
|
|
405
|
+
lambda p: p.masks,
|
|
406
|
+
super().reshape(*batch),
|
|
407
|
+
self.masks.reshape(*batch, self.masks.shape[-1]),
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
def plot(self, **kwargs: Any) -> PlotOutput:
|
|
411
|
+
backend = kwargs.pop(
|
|
412
|
+
"backend", None
|
|
413
|
+
) # TODO: check if kwargs may not cause issues
|
|
414
|
+
with reuse(backend=backend) as output:
|
|
415
|
+
for order in range(self.order + 1):
|
|
416
|
+
self.get_paths(order).plot(**kwargs)
|
|
417
|
+
|
|
418
|
+
return output
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"""Mesh geometry made of triangles and utilities."""
|
|
2
1
|
# ruff: noqa: ERA001
|
|
3
2
|
|
|
4
3
|
import sys
|
|
5
|
-
from
|
|
4
|
+
from collections.abc import Iterator
|
|
5
|
+
from typing import Any, overload
|
|
6
6
|
|
|
7
7
|
import equinox as eqx
|
|
8
8
|
import jax
|
|
@@ -169,6 +169,21 @@ class TriangleMesh(eqx.Module):
|
|
|
169
169
|
is_leaf=lambda x: x is None,
|
|
170
170
|
)
|
|
171
171
|
|
|
172
|
+
def iter_objects(self) -> Iterator[Self]:
|
|
173
|
+
"""
|
|
174
|
+
Iterator over sub meshes (i.e., objects) defined by :attr:`object_bounds`.
|
|
175
|
+
|
|
176
|
+
If :attr:`object_bounds` is :data:`None`, then yield ``self``.
|
|
177
|
+
|
|
178
|
+
Yields:
|
|
179
|
+
One or more sub meshes.
|
|
180
|
+
"""
|
|
181
|
+
if self.object_bounds is None:
|
|
182
|
+
yield self
|
|
183
|
+
else:
|
|
184
|
+
for start, stop in self.object_bounds:
|
|
185
|
+
yield self[start:stop]
|
|
186
|
+
|
|
172
187
|
@property
|
|
173
188
|
def num_triangles(self) -> int:
|
|
174
189
|
"""The number of triangles."""
|
|
@@ -378,7 +393,7 @@ class TriangleMesh(eqx.Module):
|
|
|
378
393
|
vertex_b: Float[Array, "3"],
|
|
379
394
|
vertex_c: Float[Array, "3"],
|
|
380
395
|
*,
|
|
381
|
-
normal:
|
|
396
|
+
normal: None = None,
|
|
382
397
|
side_length: Float[ArrayLike, " "] = 1.0,
|
|
383
398
|
rotate: Float[ArrayLike, " "] | None = None,
|
|
384
399
|
) -> Self: ...
|
|
@@ -388,8 +403,8 @@ class TriangleMesh(eqx.Module):
|
|
|
388
403
|
def plane(
|
|
389
404
|
cls,
|
|
390
405
|
vertex_a: Float[Array, "3"],
|
|
391
|
-
vertex_b:
|
|
392
|
-
vertex_c:
|
|
406
|
+
vertex_b: None = None,
|
|
407
|
+
vertex_c: None = None,
|
|
393
408
|
*,
|
|
394
409
|
normal: Float[Array, "3"],
|
|
395
410
|
side_length: Float[ArrayLike, " "] = 1.0,
|
|
@@ -537,7 +552,10 @@ class TriangleMesh(eqx.Module):
|
|
|
537
552
|
(triangles, jnp.asarray([[0, 3, 5], [0, 5, 7]])),
|
|
538
553
|
axis=0,
|
|
539
554
|
)
|
|
540
|
-
|
|
555
|
+
|
|
556
|
+
indices = jnp.arange(0, triangles.shape[0] + 1, 2)
|
|
557
|
+
object_bounds = jnp.column_stack((indices[:-1], indices[+1:]))
|
|
558
|
+
return cls(vertices=vertices, triangles=triangles, object_bounds=object_bounds)
|
|
541
559
|
|
|
542
560
|
@property
|
|
543
561
|
def is_empty(self) -> bool:
|