differt 0.1.0__tar.gz → 0.1.2__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.1.0 → differt-0.1.2}/PKG-INFO +14 -5
- {differt-0.1.0 → differt-0.1.2}/README.md +11 -2
- {differt-0.1.0 → differt-0.1.2}/pyproject.toml +2 -2
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_interaction_type.py +1 -1
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_material.py +3 -1
- {differt-0.1.0 → differt-0.1.2}/src/differt/geometry/_paths.py +79 -14
- {differt-0.1.0 → differt-0.1.2}/src/differt/geometry/_triangle_mesh.py +3 -2
- {differt-0.1.0 → differt-0.1.2}/src/differt/geometry/_utils.py +2 -2
- {differt-0.1.0 → differt-0.1.2}/src/differt/plotting/_core.py +1 -1
- differt-0.1.2/src/differt/plugins/__init__.py +4 -0
- differt-0.1.2/src/differt/plugins/_deepmimo_types.py +9 -0
- differt-0.1.2/src/differt/plugins/deepmimo.py +577 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/rt/_fermat.py +99 -39
- {differt-0.1.0 → differt-0.1.2}/src/differt/rt/_image_method.py +13 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/rt/_utils.py +2 -1
- {differt-0.1.0 → differt-0.1.2}/src/differt/scene/_triangle_scene.py +111 -16
- {differt-0.1.0 → differt-0.1.2}/src/differt/utils.py +20 -75
- {differt-0.1.0 → differt-0.1.2}/.gitignore +0 -0
- {differt-0.1.0 → differt-0.1.2}/LICENSE.md +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/__init__.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/_version.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/__init__.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_antenna.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_constants.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_fresnel.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_utd.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/em/_utils.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/geometry/__init__.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/plotting/__init__.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/plotting/_utils.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/py.typed +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/rt/__init__.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/scene/__init__.py +0 -0
- {differt-0.1.0 → differt-0.1.2}/src/differt/scene/_sionna.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
@@ -21,10 +21,10 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
21
21
|
Classifier: Topic :: Scientific/Engineering
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.1.
|
|
24
|
+
Requires-Dist: differt-core==0.1.2
|
|
25
25
|
Requires-Dist: equinox>=0.12.2
|
|
26
26
|
Requires-Dist: filelock>=3.15.4
|
|
27
|
-
Requires-Dist: jax
|
|
27
|
+
Requires-Dist: jax>=0.4.32
|
|
28
28
|
Requires-Dist: jaxtyping>=0.3.2
|
|
29
29
|
Requires-Dist: numpy>=1.26.1
|
|
30
30
|
Requires-Dist: optax>=0.1.7
|
|
@@ -132,8 +132,17 @@ for a detailed step-by-step procedure.
|
|
|
132
132
|
|
|
133
133
|
## Citing
|
|
134
134
|
|
|
135
|
-
If you use this software, please cite it as
|
|
136
|
-
|
|
135
|
+
If you use this software, please cite it as:
|
|
136
|
+
|
|
137
|
+
```bibtex
|
|
138
|
+
@software{Eertmans_Differentiable_Ray_Tracing,
|
|
139
|
+
title = {{DiffeRT: A Differentiable Ray Tracing Toolbox for Radio Propagation Simulations}},
|
|
140
|
+
author = {Eertmans, Jérome},
|
|
141
|
+
url = {https://github.com/jeertmans/DiffeRT},
|
|
142
|
+
license = {MIT},
|
|
143
|
+
version = {v0.1.2}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
137
146
|
|
|
138
147
|
[pypi-version-badge]: https://img.shields.io/pypi/v/DiffeRT?label=DiffeRT&color=blueviolet
|
|
139
148
|
[pypi-version-url]: https://pypi.org/project/DiffeRT/
|
|
@@ -75,8 +75,17 @@ for a detailed step-by-step procedure.
|
|
|
75
75
|
|
|
76
76
|
## Citing
|
|
77
77
|
|
|
78
|
-
If you use this software, please cite it as
|
|
79
|
-
|
|
78
|
+
If you use this software, please cite it as:
|
|
79
|
+
|
|
80
|
+
```bibtex
|
|
81
|
+
@software{Eertmans_Differentiable_Ray_Tracing,
|
|
82
|
+
title = {{DiffeRT: A Differentiable Ray Tracing Toolbox for Radio Propagation Simulations}},
|
|
83
|
+
author = {Eertmans, Jérome},
|
|
84
|
+
url = {https://github.com/jeertmans/DiffeRT},
|
|
85
|
+
license = {MIT},
|
|
86
|
+
version = {v0.1.2}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
80
89
|
|
|
81
90
|
[pypi-version-badge]: https://img.shields.io/pypi/v/DiffeRT?label=DiffeRT&color=blueviolet
|
|
82
91
|
[pypi-version-url]: https://pypi.org/project/DiffeRT/
|
|
@@ -16,10 +16,10 @@ classifiers = [
|
|
|
16
16
|
]
|
|
17
17
|
dependencies = [
|
|
18
18
|
"chex>=0.1.86",
|
|
19
|
-
"differt-core==0.1.
|
|
19
|
+
"differt-core==0.1.2",
|
|
20
20
|
"equinox>=0.12.2",
|
|
21
21
|
"filelock>=3.15.4",
|
|
22
|
-
"jax>=0.4.32
|
|
22
|
+
"jax>=0.4.32", # TODO: fixme, issue with pmap
|
|
23
23
|
"jaxtyping>=0.3.2",
|
|
24
24
|
"numpy>=1.26.1",
|
|
25
25
|
"optax>=0.1.7",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ruff: noqa: FURB152
|
|
2
|
+
|
|
2
3
|
import operator
|
|
4
|
+
import os
|
|
3
5
|
from collections.abc import Callable
|
|
4
6
|
from functools import partial
|
|
5
7
|
from typing import TYPE_CHECKING, Any
|
|
@@ -9,7 +11,7 @@ import jax
|
|
|
9
11
|
import jax.numpy as jnp
|
|
10
12
|
from jaxtyping import Array, ArrayLike, Float
|
|
11
13
|
|
|
12
|
-
if TYPE_CHECKING:
|
|
14
|
+
if TYPE_CHECKING or "READTHEDOCS" in os.environ:
|
|
13
15
|
import sys
|
|
14
16
|
|
|
15
17
|
if sys.version_info >= (3, 11):
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import os
|
|
1
3
|
import warnings
|
|
2
4
|
from collections.abc import Callable, Iterator, Sequence
|
|
3
5
|
from dataclasses import KW_ONLY
|
|
@@ -10,7 +12,7 @@ from jaxtyping import Array, ArrayLike, Bool, Float, Int, Num, Shaped
|
|
|
10
12
|
|
|
11
13
|
from differt.plotting import PlotOutput, draw_paths, reuse
|
|
12
14
|
|
|
13
|
-
if TYPE_CHECKING:
|
|
15
|
+
if TYPE_CHECKING or "READTHEDOCS" in os.environ:
|
|
14
16
|
import sys
|
|
15
17
|
|
|
16
18
|
if sys.version_info >= (3, 11):
|
|
@@ -133,6 +135,16 @@ class Paths(eqx.Module):
|
|
|
133
135
|
)
|
|
134
136
|
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
135
137
|
|
|
138
|
+
@property
|
|
139
|
+
def shape(self) -> tuple[int, ...]:
|
|
140
|
+
"""
|
|
141
|
+
Return the batch shape of the paths.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
The shape of paths' batch dimensions.
|
|
145
|
+
"""
|
|
146
|
+
return self.vertices.shape[:-2]
|
|
147
|
+
|
|
136
148
|
def reshape(self, *batch: int) -> Self:
|
|
137
149
|
"""
|
|
138
150
|
Return a copy with reshaped paths' batch dimensions to match a given shape.
|
|
@@ -270,16 +282,26 @@ class Paths(eqx.Module):
|
|
|
270
282
|
for _ in range(max(ndim - 1, 0)):
|
|
271
283
|
f = jax.vmap(f)
|
|
272
284
|
|
|
273
|
-
|
|
285
|
+
non_duplicates = f(objects)
|
|
286
|
+
non_duplicates = jnp.moveaxis(non_duplicates, -1, axis)
|
|
274
287
|
|
|
275
|
-
mask
|
|
276
|
-
|
|
277
|
-
|
|
288
|
+
if self.mask is not None:
|
|
289
|
+
return eqx.tree_at(
|
|
290
|
+
lambda p: p.mask,
|
|
291
|
+
self,
|
|
292
|
+
self.mask & non_duplicates,
|
|
293
|
+
)
|
|
294
|
+
if self.confidence is not None:
|
|
295
|
+
return eqx.tree_at(
|
|
296
|
+
lambda p: p.confidence,
|
|
297
|
+
self,
|
|
298
|
+
self.confidence * non_duplicates,
|
|
299
|
+
)
|
|
278
300
|
|
|
279
301
|
return eqx.tree_at(
|
|
280
302
|
lambda p: p.mask,
|
|
281
303
|
self,
|
|
282
|
-
|
|
304
|
+
non_duplicates,
|
|
283
305
|
is_leaf=lambda x: x is None,
|
|
284
306
|
)
|
|
285
307
|
|
|
@@ -291,7 +313,7 @@ class Paths(eqx.Module):
|
|
|
291
313
|
@property
|
|
292
314
|
def order(self) -> int:
|
|
293
315
|
"""The length (i.e., number of vertices) of each individual path, excluding start and end vertices."""
|
|
294
|
-
return self.
|
|
316
|
+
return self.path_length - 2
|
|
295
317
|
|
|
296
318
|
@property
|
|
297
319
|
def num_valid_paths(self) -> int | Int[Array, " "]:
|
|
@@ -303,7 +325,7 @@ class Paths(eqx.Module):
|
|
|
303
325
|
return self.mask.sum()
|
|
304
326
|
if self.confidence is not None:
|
|
305
327
|
return (self.confidence >= self.confidence_threshold).sum()
|
|
306
|
-
return self.objects[
|
|
328
|
+
return math.prod(self.objects.shape[:-1])
|
|
307
329
|
|
|
308
330
|
@property
|
|
309
331
|
def masked_vertices(
|
|
@@ -340,6 +362,51 @@ class Paths(eqx.Module):
|
|
|
340
362
|
return objects[mask, ...]
|
|
341
363
|
return objects
|
|
342
364
|
|
|
365
|
+
def masked(self) -> Self:
|
|
366
|
+
"""Return a flattened copy of this object that only keeps valid paths.
|
|
367
|
+
|
|
368
|
+
The returned object has all batch dimensions flattened into one,
|
|
369
|
+
keeping only the paths where :attr:`mask` is :data:`True` (or where :attr:`confidence` is greater than or equal to :attr:`confidence_threshold`), and :attr:`mask` and :attr:`confidence` attributes are set to :data:`None`.
|
|
370
|
+
|
|
371
|
+
Returns:
|
|
372
|
+
A new paths instance with flattened batch dimensions and only valid paths.
|
|
373
|
+
"""
|
|
374
|
+
batch_len = len(self.vertices.shape) - 2
|
|
375
|
+
self = jax.tree.map( # noqa: PLW0642
|
|
376
|
+
lambda arr: arr.reshape(-1, *arr.shape[batch_len:])
|
|
377
|
+
if jnp.ndim(arr) >= batch_len
|
|
378
|
+
else arr,
|
|
379
|
+
self,
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
if self.mask is not None:
|
|
383
|
+
mask = self.mask.reshape(-1)
|
|
384
|
+
elif self.confidence is not None:
|
|
385
|
+
mask = self.confidence.reshape(-1) >= self.confidence_threshold
|
|
386
|
+
else:
|
|
387
|
+
mask = slice(None, None, None)
|
|
388
|
+
|
|
389
|
+
return eqx.tree_at(
|
|
390
|
+
lambda p: (
|
|
391
|
+
p.vertices,
|
|
392
|
+
p.objects,
|
|
393
|
+
p.mask,
|
|
394
|
+
p.interaction_types,
|
|
395
|
+
p.confidence,
|
|
396
|
+
),
|
|
397
|
+
self,
|
|
398
|
+
(
|
|
399
|
+
self.vertices[mask, ...],
|
|
400
|
+
self.objects[mask, ...],
|
|
401
|
+
None,
|
|
402
|
+
self.interaction_types[mask, ...]
|
|
403
|
+
if self.interaction_types is not None
|
|
404
|
+
else None,
|
|
405
|
+
None,
|
|
406
|
+
),
|
|
407
|
+
is_leaf=lambda x: x is None,
|
|
408
|
+
)
|
|
409
|
+
|
|
343
410
|
@eqx.filter_jit
|
|
344
411
|
def multipath_cells(
|
|
345
412
|
self,
|
|
@@ -390,7 +457,8 @@ class Paths(eqx.Module):
|
|
|
390
457
|
if self.mask is not None:
|
|
391
458
|
mask = jnp.moveaxis(self.mask, axis, -1)
|
|
392
459
|
else:
|
|
393
|
-
|
|
460
|
+
# Looks like Pyright is not able to infer this
|
|
461
|
+
mask = jnp.moveaxis(self.confidence >= self.confidence_threshold, axis, -1) # type: ignore[reportOperatorIssue]
|
|
394
462
|
*partial_batch, last_axis = mask.shape
|
|
395
463
|
|
|
396
464
|
return _cell_ids(mask.reshape(-1, last_axis)).reshape(partial_batch)
|
|
@@ -568,11 +636,8 @@ class SBRPaths(Paths):
|
|
|
568
636
|
)
|
|
569
637
|
|
|
570
638
|
def plot(self, **kwargs: Any) -> PlotOutput:
|
|
571
|
-
|
|
572
|
-
"backend", None
|
|
573
|
-
) # TODO: check if kwargs may not cause issues
|
|
574
|
-
with reuse(backend=backend) as output:
|
|
639
|
+
with reuse(**kwargs, pass_all_kwargs=True) as output:
|
|
575
640
|
for order in range(self.order + 1):
|
|
576
|
-
self.get_paths(order).plot(
|
|
641
|
+
self.get_paths(order).plot()
|
|
577
642
|
|
|
578
643
|
return output
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# ruff: noqa: ERA001
|
|
2
2
|
|
|
3
|
+
import os
|
|
3
4
|
from collections.abc import Callable, Iterator, Mapping
|
|
4
5
|
from dataclasses import replace
|
|
5
6
|
from typing import TYPE_CHECKING, Any, Generic, TypeVar, overload
|
|
@@ -14,7 +15,7 @@ from differt.plotting import PlotOutput, draw_mesh, draw_paths, draw_rays, reuse
|
|
|
14
15
|
|
|
15
16
|
from ._utils import normalize, orthogonal_basis, rotation_matrix_along_axis
|
|
16
17
|
|
|
17
|
-
if TYPE_CHECKING:
|
|
18
|
+
if TYPE_CHECKING or "READTHEDOCS" in os.environ:
|
|
18
19
|
import sys
|
|
19
20
|
|
|
20
21
|
if sys.version_info >= (3, 11):
|
|
@@ -278,7 +279,7 @@ class TriangleMesh(eqx.Module):
|
|
|
278
279
|
|
|
279
280
|
def iter_objects(self) -> Iterator[Self]:
|
|
280
281
|
"""
|
|
281
|
-
|
|
282
|
+
Return an iterator over sub meshes (i.e., objects) defined by :attr:`object_bounds`.
|
|
282
283
|
|
|
283
284
|
If :attr:`object_bounds` is :data:`None`, then yield ``self``.
|
|
284
285
|
|
|
@@ -802,8 +802,8 @@ def cartesian_to_spherical(
|
|
|
802
802
|
xyz = jnp.asarray(xyz)
|
|
803
803
|
r = jnp.linalg.norm(xyz, axis=-1)
|
|
804
804
|
r: Array = jnp.where(r == 0.0, jnp.ones_like(r), r)
|
|
805
|
-
p = jnp.
|
|
806
|
-
a = jnp.
|
|
805
|
+
p = jnp.acos(xyz[..., -1] / r)
|
|
806
|
+
a = jnp.atan2(xyz[..., 1], xyz[..., 0])
|
|
807
807
|
|
|
808
808
|
return jnp.stack((r, p, a), axis=-1)
|
|
809
809
|
|