differt 0.8.0__tar.gz → 0.8.1__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.8.0 → differt-0.8.1}/PKG-INFO +4 -4
- {differt-0.8.0 → differt-0.8.1}/README.md +1 -1
- {differt-0.8.0 → differt-0.8.1}/pyproject.toml +2 -2
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_antenna.py +5 -3
- {differt-0.8.0 → differt-0.8.1}/src/differt/geometry/_paths.py +1 -1
- {differt-0.8.0 → differt-0.8.1}/src/differt/geometry/_triangle_mesh.py +3 -3
- {differt-0.8.0 → differt-0.8.1}/src/differt/plotting/_core.py +43 -20
- {differt-0.8.0 → differt-0.8.1}/src/differt/plotting/_utils.py +23 -32
- {differt-0.8.0 → differt-0.8.1}/src/differt/plugins/deepmimo.py +12 -2
- {differt-0.8.0 → differt-0.8.1}/src/differt/rt/_fermat.py +16 -12
- {differt-0.8.0 → differt-0.8.1}/src/differt/scene/_triangle_scene.py +10 -5
- {differt-0.8.0 → differt-0.8.1}/.gitignore +0 -0
- {differt-0.8.0 → differt-0.8.1}/LICENSE.md +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/_version.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_constants.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_fresnel.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_interaction_type.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_material.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_utd.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/em/_utils.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/geometry/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/geometry/_utils.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/plotting/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/plugins/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/plugins/_deepmimo_types.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/py.typed +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/rt/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/rt/_image_method.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/rt/_utils.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/scene/__init__.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/scene/_sionna.py +0 -0
- {differt-0.8.0 → differt-0.8.1}/src/differt/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.1
|
|
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,8 +21,8 @@ Classifier: Programming Language :: Python :: Free Threading
|
|
|
21
21
|
Classifier: Topic :: Scientific/Engineering
|
|
22
22
|
Requires-Python: >=3.11
|
|
23
23
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.8.
|
|
25
|
-
Requires-Dist: equinox>=0.13.
|
|
24
|
+
Requires-Dist: differt-core==0.8.1
|
|
25
|
+
Requires-Dist: equinox>=0.13.7
|
|
26
26
|
Requires-Dist: filelock>=3.15.4
|
|
27
27
|
Requires-Dist: fpt-jax==0.1.0
|
|
28
28
|
Requires-Dist: jax>=0.8.1
|
|
@@ -156,7 +156,7 @@ or:
|
|
|
156
156
|
author = {Eertmans, Jérome},
|
|
157
157
|
url = {https://github.com/jeertmans/DiffeRT},
|
|
158
158
|
license = {MIT},
|
|
159
|
-
version = {v0.8.
|
|
159
|
+
version = {v0.8.1}
|
|
160
160
|
}
|
|
161
161
|
```
|
|
162
162
|
|
|
@@ -645,11 +645,13 @@ class RadiationPattern(BaseAntenna):
|
|
|
645
645
|
|
|
646
646
|
r = self.center + distance * jnp.stack((x, y, z), axis=-1)
|
|
647
647
|
|
|
648
|
-
s = self.
|
|
648
|
+
s, p = self.polarization_vectors(r)
|
|
649
649
|
|
|
650
|
-
|
|
650
|
+
power = jnp.sum(s * s, axis=-1, keepdims=True) + jnp.sum(
|
|
651
|
+
p * p, axis=-1, keepdims=True
|
|
652
|
+
)
|
|
651
653
|
|
|
652
|
-
gain =
|
|
654
|
+
gain = power / power.max()
|
|
653
655
|
|
|
654
656
|
r *= gain
|
|
655
657
|
gain = jnp.squeeze(gain, axis=-1)
|
|
@@ -350,7 +350,7 @@ class Paths(eqx.Module, Generic[_M]):
|
|
|
350
350
|
|
|
351
351
|
if not _is_masked_paths(paths):
|
|
352
352
|
# ty is unable to infer that _M & ~Array implies None
|
|
353
|
-
return paths # type: ignore[invalid-return-type]
|
|
353
|
+
return paths # type: ignore[ty:invalid-return-type]
|
|
354
354
|
|
|
355
355
|
mask = paths.mask
|
|
356
356
|
if mask.dtype == jnp.bool_:
|
|
@@ -1724,8 +1724,8 @@ class TriangleMesh(eqx.Module):
|
|
|
1724
1724
|
if sample_objects:
|
|
1725
1725
|
indices = jnp.arange(self.num_triangles)
|
|
1726
1726
|
indices_inside_bounds = (
|
|
1727
|
-
self.object_bounds[:, 0] <= indices[:, None] # type: ignore[
|
|
1728
|
-
) & (indices[:, None] < self.object_bounds[:, 1]) # type: ignore[
|
|
1727
|
+
self.object_bounds[:, 0] <= indices[:, None] # type: ignore[ty:not-subscriptable]
|
|
1728
|
+
) & (indices[:, None] < self.object_bounds[:, 1]) # type: ignore[ty:not-subscriptable]
|
|
1729
1729
|
triangle_indices = indices_inside_bounds.argmax(
|
|
1730
1730
|
axis=1
|
|
1731
1731
|
) # Exactly one bound should be true for each triangle
|
|
@@ -1757,7 +1757,7 @@ class TriangleMesh(eqx.Module):
|
|
|
1757
1757
|
|
|
1758
1758
|
if sample_objects:
|
|
1759
1759
|
indices = jnp.concatenate([
|
|
1760
|
-
jnp.arange(self.object_bounds[i, 0], self.object_bounds[i, 1]) # type: ignore[
|
|
1760
|
+
jnp.arange(self.object_bounds[i, 0], self.object_bounds[i, 1]) # type: ignore[ty:not-subscriptable]
|
|
1761
1761
|
for i in indices
|
|
1762
1762
|
])
|
|
1763
1763
|
if self.assume_quads:
|
|
@@ -35,7 +35,7 @@ def draw_mesh(
|
|
|
35
35
|
vertices: Real[ArrayLike, "num_vertices 3"],
|
|
36
36
|
triangles: Int[ArrayLike, "num_triangles 3"],
|
|
37
37
|
**kwargs: Any,
|
|
38
|
-
) -> Canvas | MplFigure | Figure:
|
|
38
|
+
) -> Canvas | MplFigure | Figure:
|
|
39
39
|
"""
|
|
40
40
|
Plot a 3D mesh made of triangles.
|
|
41
41
|
|
|
@@ -86,6 +86,7 @@ def draw_mesh(
|
|
|
86
86
|
>>> fig # doctest: +SKIP
|
|
87
87
|
|
|
88
88
|
"""
|
|
89
|
+
raise NotImplementedError
|
|
89
90
|
|
|
90
91
|
|
|
91
92
|
@draw_mesh.register("vispy")
|
|
@@ -98,14 +99,14 @@ def _(
|
|
|
98
99
|
|
|
99
100
|
canvas, view = process_vispy_kwargs(kwargs)
|
|
100
101
|
|
|
101
|
-
if vertices.size == 0 or triangles.size == 0: # type: ignore[reportAttributeAccessIssue] # pragma: no cover
|
|
102
|
-
return canvas
|
|
103
|
-
|
|
104
102
|
kwargs.setdefault("shading", "flat")
|
|
105
103
|
|
|
106
104
|
vertices = np.asarray(vertices)
|
|
107
105
|
triangles = np.asarray(triangles)
|
|
108
106
|
|
|
107
|
+
if vertices.size == 0 or triangles.size == 0:
|
|
108
|
+
return canvas
|
|
109
|
+
|
|
109
110
|
view.add(Mesh(vertices=vertices, faces=triangles, **kwargs))
|
|
110
111
|
view.camera.set_range()
|
|
111
112
|
|
|
@@ -137,6 +138,19 @@ def _(
|
|
|
137
138
|
) -> Figure:
|
|
138
139
|
fig = process_plotly_kwargs(kwargs)
|
|
139
140
|
kwargs.setdefault("flatshading", True)
|
|
141
|
+
kwargs.setdefault(
|
|
142
|
+
"lighting",
|
|
143
|
+
{
|
|
144
|
+
"ambient": 0.5,
|
|
145
|
+
"diffuse": 0.9,
|
|
146
|
+
"fresnel": 0.1,
|
|
147
|
+
"specular": 0.9,
|
|
148
|
+
"roughness": 0.5,
|
|
149
|
+
"facenormalsepsilon": 1e-15,
|
|
150
|
+
"vertexnormalsepsilon": 1e-15,
|
|
151
|
+
},
|
|
152
|
+
)
|
|
153
|
+
kwargs.setdefault("lightposition", {"x": 100000, "y": 100000, "z": 100000})
|
|
140
154
|
|
|
141
155
|
if (
|
|
142
156
|
face_colors := kwargs.pop("face_colors", None)
|
|
@@ -153,7 +167,7 @@ def _(
|
|
|
153
167
|
def draw_paths(
|
|
154
168
|
paths: Real[ArrayLike, "*batch path_length 3"],
|
|
155
169
|
**kwargs: Any,
|
|
156
|
-
) -> Canvas | MplFigure | Figure:
|
|
170
|
+
) -> Canvas | MplFigure | Figure:
|
|
157
171
|
"""
|
|
158
172
|
Plot a batch of paths of the same length.
|
|
159
173
|
|
|
@@ -195,6 +209,7 @@ def draw_paths(
|
|
|
195
209
|
... )
|
|
196
210
|
>>> fig # doctest: +SKIP
|
|
197
211
|
"""
|
|
212
|
+
raise NotImplementedError
|
|
198
213
|
|
|
199
214
|
|
|
200
215
|
@draw_paths.register("vispy")
|
|
@@ -263,7 +278,7 @@ def draw_rays(
|
|
|
263
278
|
*,
|
|
264
279
|
ratio: Float[ArrayLike, ""] = 0.1,
|
|
265
280
|
**kwargs: Any,
|
|
266
|
-
) -> Canvas | MplFigure | Figure:
|
|
281
|
+
) -> Canvas | MplFigure | Figure:
|
|
267
282
|
"""
|
|
268
283
|
Plot a batch of rays.
|
|
269
284
|
|
|
@@ -345,6 +360,7 @@ def draw_rays(
|
|
|
345
360
|
... )
|
|
346
361
|
>>> fig # doctest: +SKIP
|
|
347
362
|
"""
|
|
363
|
+
raise NotImplementedError
|
|
348
364
|
|
|
349
365
|
|
|
350
366
|
@draw_rays.register("vispy")
|
|
@@ -359,14 +375,14 @@ def _(
|
|
|
359
375
|
|
|
360
376
|
canvas, view = process_vispy_kwargs(kwargs)
|
|
361
377
|
|
|
362
|
-
if ray_origins.size == 0 or ray_directions.size == 0: # type: ignore[reportAttributeAccessIssue] # pragma: no cover
|
|
363
|
-
return canvas
|
|
364
|
-
|
|
365
378
|
kwargs.setdefault("width", 3.0)
|
|
366
379
|
kwargs.setdefault("arrow_size", 6.0)
|
|
367
380
|
|
|
368
381
|
ray_origins = np.asarray(ray_origins).reshape(-1, 3)
|
|
369
382
|
ray_directions = np.asarray(ray_directions).reshape(-1, 3)
|
|
383
|
+
|
|
384
|
+
if ray_origins.size == 0 or ray_directions.size == 0:
|
|
385
|
+
return canvas
|
|
370
386
|
ratio = np.asarray(ratio)
|
|
371
387
|
body_ends = ray_origins + (1 - ratio) * ray_directions
|
|
372
388
|
|
|
@@ -394,7 +410,7 @@ def _(
|
|
|
394
410
|
) -> MplFigure:
|
|
395
411
|
fig, ax = process_matplotlib_kwargs(kwargs)
|
|
396
412
|
|
|
397
|
-
kwargs.setdefault("arrow_length_ratio", float(ratio))
|
|
413
|
+
kwargs.setdefault("arrow_length_ratio", float(np.asarray(ratio)))
|
|
398
414
|
|
|
399
415
|
ray_origins = np.asarray(ray_origins).reshape(-1, 3)
|
|
400
416
|
ray_directions = np.asarray(ray_directions).reshape(-1, 3)
|
|
@@ -467,7 +483,7 @@ def draw_markers(
|
|
|
467
483
|
labels: Sequence[str] | None = None,
|
|
468
484
|
text_kwargs: Mapping[str, Any] | None = None,
|
|
469
485
|
**kwargs: Any,
|
|
470
|
-
) -> Canvas | MplFigure | Figure:
|
|
486
|
+
) -> Canvas | MplFigure | Figure:
|
|
471
487
|
"""
|
|
472
488
|
Plot markers and, optionally, their label.
|
|
473
489
|
|
|
@@ -508,6 +524,7 @@ def draw_markers(
|
|
|
508
524
|
>>> fig = draw_markers(markers, labels, backend="plotly")
|
|
509
525
|
>>> fig # doctest: +SKIP
|
|
510
526
|
"""
|
|
527
|
+
raise NotImplementedError
|
|
511
528
|
|
|
512
529
|
|
|
513
530
|
@draw_markers.register("vispy")
|
|
@@ -521,13 +538,16 @@ def _(
|
|
|
521
538
|
|
|
522
539
|
canvas, view = process_vispy_kwargs(kwargs)
|
|
523
540
|
|
|
524
|
-
if markers.size == 0: # type: ignore[reportAttributeAccessIssue] # pragma: no cover
|
|
525
|
-
return canvas
|
|
526
|
-
|
|
527
541
|
kwargs.setdefault("size", 1)
|
|
528
542
|
kwargs.setdefault("edge_width_rel", 0.05)
|
|
529
543
|
kwargs.setdefault("scaling", "scene")
|
|
530
|
-
markers = np.asarray(markers)
|
|
544
|
+
markers = np.asarray(markers)
|
|
545
|
+
|
|
546
|
+
if markers.size == 0:
|
|
547
|
+
return canvas
|
|
548
|
+
|
|
549
|
+
markers = markers.reshape(-1, 3)
|
|
550
|
+
|
|
531
551
|
view.add(Markers(pos=markers, **kwargs))
|
|
532
552
|
|
|
533
553
|
if labels:
|
|
@@ -600,7 +620,7 @@ def draw_image(
|
|
|
600
620
|
y: Real[ArrayLike, " rows"] | Real[ArrayLike, "rows cols 3"] | None = None,
|
|
601
621
|
z0: float = 0.0,
|
|
602
622
|
**kwargs: Any,
|
|
603
|
-
) -> Canvas | MplFigure | Figure:
|
|
623
|
+
) -> Canvas | MplFigure | Figure:
|
|
604
624
|
"""
|
|
605
625
|
Plot a 2D image on a 3D canvas, at a fixed z-coordinate.
|
|
606
626
|
|
|
@@ -651,6 +671,7 @@ def draw_image(
|
|
|
651
671
|
>>> fig2 # doctest: +SKIP
|
|
652
672
|
|
|
653
673
|
"""
|
|
674
|
+
raise NotImplementedError
|
|
654
675
|
|
|
655
676
|
|
|
656
677
|
@draw_image.register("vispy")
|
|
@@ -759,7 +780,7 @@ def draw_contour(
|
|
|
759
780
|
levels: int | Real[ArrayLike, " num_levels"] | None = None,
|
|
760
781
|
fill: bool = False,
|
|
761
782
|
**kwargs: Any,
|
|
762
|
-
) -> Canvas | MplFigure | Figure:
|
|
783
|
+
) -> Canvas | MplFigure | Figure:
|
|
763
784
|
"""
|
|
764
785
|
Plot a 2D contour on a 3D canvas, at a fixed z-coordinate.
|
|
765
786
|
|
|
@@ -810,6 +831,7 @@ def draw_contour(
|
|
|
810
831
|
>>> fig2 # doctest: +SKIP
|
|
811
832
|
|
|
812
833
|
"""
|
|
834
|
+
raise NotImplementedError
|
|
813
835
|
|
|
814
836
|
|
|
815
837
|
@draw_contour.register("vispy")
|
|
@@ -896,7 +918,7 @@ def _(
|
|
|
896
918
|
|
|
897
919
|
y = np.arange(m) if y is None else np.asarray(y)
|
|
898
920
|
|
|
899
|
-
if not
|
|
921
|
+
if levels is not None and not np.isscalar(levels):
|
|
900
922
|
levels = np.asarray(levels)
|
|
901
923
|
|
|
902
924
|
if fill:
|
|
@@ -927,7 +949,7 @@ def _(
|
|
|
927
949
|
if isinstance(levels, int):
|
|
928
950
|
kwargs.setdefault("autocontour", True)
|
|
929
951
|
kwargs.setdefault("ncontours", levels)
|
|
930
|
-
elif
|
|
952
|
+
elif levels is not None and not np.isscalar(levels):
|
|
931
953
|
levels = np.asarray(levels)
|
|
932
954
|
msg = (
|
|
933
955
|
"Plotly does not support arbitrary level values, but only linearly spaced levels. "
|
|
@@ -960,7 +982,7 @@ def draw_surface(
|
|
|
960
982
|
z: Real[ArrayLike, "rows cols"],
|
|
961
983
|
colors: Real[ArrayLike, "rows cols"] | Real[ArrayLike, "rows cols 3"] | None = None,
|
|
962
984
|
**kwargs: Any,
|
|
963
|
-
) -> Canvas | MplFigure | Figure:
|
|
985
|
+
) -> Canvas | MplFigure | Figure:
|
|
964
986
|
"""
|
|
965
987
|
Plot a 3D surface.
|
|
966
988
|
|
|
@@ -1010,6 +1032,7 @@ def draw_surface(
|
|
|
1010
1032
|
>>> fig2 # doctest: +SKIP
|
|
1011
1033
|
|
|
1012
1034
|
"""
|
|
1035
|
+
raise NotImplementedError
|
|
1013
1036
|
|
|
1014
1037
|
|
|
1015
1038
|
@draw_surface.register("vispy")
|
|
@@ -14,6 +14,7 @@ from typing import (
|
|
|
14
14
|
ParamSpec,
|
|
15
15
|
Protocol,
|
|
16
16
|
TypeVar,
|
|
17
|
+
cast,
|
|
17
18
|
get_args,
|
|
18
19
|
no_type_check,
|
|
19
20
|
runtime_checkable,
|
|
@@ -76,7 +77,7 @@ config = _Config()
|
|
|
76
77
|
"""Mutable config object with mutability of default values guarded by a lock."""
|
|
77
78
|
|
|
78
79
|
|
|
79
|
-
def get_backend(backend:
|
|
80
|
+
def get_backend(backend: str | None = None) -> BackendName:
|
|
80
81
|
"""
|
|
81
82
|
Return the name of the backend to use.
|
|
82
83
|
|
|
@@ -113,10 +114,11 @@ def get_backend(backend: LiteralString | None = None) -> BackendName:
|
|
|
113
114
|
if importlib.util.find_spec(backend) is None:
|
|
114
115
|
msg = f"Could not find backend '{backend}', did you install it?"
|
|
115
116
|
raise ImportError(msg)
|
|
116
|
-
|
|
117
|
+
|
|
118
|
+
return cast("BackendName", backend)
|
|
117
119
|
|
|
118
120
|
|
|
119
|
-
def set_defaults(backend:
|
|
121
|
+
def set_defaults(backend: str | None = None, **kwargs: Any) -> BackendName:
|
|
120
122
|
"""
|
|
121
123
|
Set default backend and keyword arguments for future plotting utilities.
|
|
122
124
|
|
|
@@ -184,7 +186,7 @@ def set_defaults(backend: LiteralString | None = None, **kwargs: Any) -> Backend
|
|
|
184
186
|
return backend
|
|
185
187
|
|
|
186
188
|
|
|
187
|
-
def set_backend(backend:
|
|
189
|
+
def set_backend(backend: str) -> None:
|
|
188
190
|
"""
|
|
189
191
|
Set default backend for future plotting utilities.
|
|
190
192
|
|
|
@@ -207,7 +209,7 @@ def set_backend(backend: LiteralString) -> None:
|
|
|
207
209
|
set_defaults(backend=backend)
|
|
208
210
|
|
|
209
211
|
|
|
210
|
-
def update_defaults(backend:
|
|
212
|
+
def update_defaults(backend: str | None = None, **kwargs: Any) -> BackendName:
|
|
211
213
|
"""
|
|
212
214
|
Update default backend and keyword arguments for future plotting utilities.
|
|
213
215
|
|
|
@@ -232,7 +234,7 @@ def update_defaults(backend: LiteralString | None = None, **kwargs: Any) -> Back
|
|
|
232
234
|
|
|
233
235
|
|
|
234
236
|
@contextmanager
|
|
235
|
-
def use(backend:
|
|
237
|
+
def use(backend: str | None = None, **kwargs: Any) -> Iterator[BackendName]:
|
|
236
238
|
"""
|
|
237
239
|
Create a context manager that updates plotting defaults and returns the current default backend.
|
|
238
240
|
|
|
@@ -302,11 +304,11 @@ class _Dispatcher(Protocol[P, T]):
|
|
|
302
304
|
) -> T: ...
|
|
303
305
|
def register(
|
|
304
306
|
self,
|
|
305
|
-
backend:
|
|
307
|
+
backend: str,
|
|
306
308
|
) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
|
|
307
309
|
|
|
308
310
|
|
|
309
|
-
def dispatch(fun: Callable[P,
|
|
311
|
+
def dispatch(fun: Callable[P, T]) -> _Dispatcher[P, T]:
|
|
310
312
|
"""
|
|
311
313
|
Transform a function into a backend dispatcher for plot functions.
|
|
312
314
|
|
|
@@ -373,10 +375,10 @@ def dispatch(fun: Callable[P, PlotOutput]) -> _Dispatcher[P, T]:
|
|
|
373
375
|
Traceback (most recent call last):
|
|
374
376
|
ValueError: Unsupported backend 'numpy', allowed values are: ...
|
|
375
377
|
"""
|
|
376
|
-
registry: dict[str, Callable[P,
|
|
378
|
+
registry: dict[str, Callable[P, T]] = {}
|
|
377
379
|
|
|
378
380
|
def register(
|
|
379
|
-
backend:
|
|
381
|
+
backend: str,
|
|
380
382
|
) -> Callable[[Callable[P, T]], Callable[P, T]]:
|
|
381
383
|
"""
|
|
382
384
|
Return a wrapper that will call the decorated function for the specified backend.
|
|
@@ -431,37 +433,26 @@ def dispatch(fun: Callable[P, PlotOutput]) -> _Dispatcher[P, T]:
|
|
|
431
433
|
*args: P.args,
|
|
432
434
|
**kwargs: P.kwargs,
|
|
433
435
|
) -> T:
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
Returns:
|
|
442
|
-
The result of the call.
|
|
443
|
-
"""
|
|
444
|
-
# We cannot currently add keyword argument to the signature,
|
|
445
|
-
# at least Pyright will not allow that,
|
|
446
|
-
# see: https://github.com/microsoft/pyright/issues/5844.
|
|
447
|
-
#
|
|
448
|
-
# The motivation is detailed in P612:
|
|
449
|
-
# https://peps.python.org/pep-0612/#concatenating-keyword-parameters.
|
|
450
|
-
backend_opt: LiteralString | None = kwargs.pop("backend", None) # type: ignore[reportArgumentType]
|
|
436
|
+
# We cannot add keyword argument to the signature, because ParamSpec does not
|
|
437
|
+
# allow parameters between
|
|
438
|
+
# *args: P.args and **kwargs: P.kwargs.
|
|
439
|
+
backend_opt = kwargs.pop("backend", None)
|
|
440
|
+
if backend_opt is not None and not isinstance(backend_opt, str):
|
|
441
|
+
msg = "Argument 'backend' must be a string."
|
|
442
|
+
raise TypeError(msg)
|
|
451
443
|
backend = get_backend(backend_opt)
|
|
452
444
|
|
|
453
445
|
try:
|
|
454
|
-
return registry[backend](*args, **kwargs)
|
|
446
|
+
return registry[backend](*args, **kwargs)
|
|
455
447
|
except KeyError:
|
|
456
448
|
msg = f"No backend implementation for '{backend}'"
|
|
457
449
|
raise NotImplementedError(
|
|
458
450
|
msg,
|
|
459
451
|
) from None
|
|
460
452
|
|
|
461
|
-
wrapper.register = register # type: ignore[
|
|
462
|
-
wrapper.registry = types.MappingProxyType(registry) # type: ignore[
|
|
463
|
-
|
|
464
|
-
return wrapper # type: ignore[reportReportType]
|
|
453
|
+
wrapper.register = register # type: ignore[ty:unresolved-attribute]
|
|
454
|
+
wrapper.registry = types.MappingProxyType(registry) # type: ignore[ty:unresolved-attribute]
|
|
455
|
+
return wrapper # type: ignore[ty:invalid-return-type]
|
|
465
456
|
|
|
466
457
|
|
|
467
458
|
def view_from_canvas(canvas: Canvas) -> ViewBox:
|
|
@@ -4,7 +4,7 @@ __all__ = ("DeepMIMO", "export")
|
|
|
4
4
|
|
|
5
5
|
from collections.abc import Iterable, Iterator, Mapping
|
|
6
6
|
from dataclasses import KW_ONLY, asdict
|
|
7
|
-
from typing import Any, Generic, Literal, TypeGuard
|
|
7
|
+
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeGuard
|
|
8
8
|
|
|
9
9
|
import equinox as eqx
|
|
10
10
|
import jax
|
|
@@ -33,6 +33,16 @@ from differt.utils import safe_divide
|
|
|
33
33
|
|
|
34
34
|
from ._deepmimo_types import ArrayType
|
|
35
35
|
|
|
36
|
+
if TYPE_CHECKING:
|
|
37
|
+
try:
|
|
38
|
+
import sionna.rt
|
|
39
|
+
except ImportError:
|
|
40
|
+
SionnaPaths = Any
|
|
41
|
+
else:
|
|
42
|
+
SionnaPaths = sionna.rt.Paths
|
|
43
|
+
else:
|
|
44
|
+
SionnaPaths = Any
|
|
45
|
+
|
|
36
46
|
|
|
37
47
|
def _pad_and_concat(
|
|
38
48
|
left: Shaped[Array, "num_tx num_rx num_paths_left num_interactions_left ..."],
|
|
@@ -146,7 +156,7 @@ class DeepMIMO(eqx.Module, Generic[ArrayType]):
|
|
|
146
156
|
|
|
147
157
|
def _sort(
|
|
148
158
|
self,
|
|
149
|
-
paths:
|
|
159
|
+
paths: SionnaPaths,
|
|
150
160
|
) -> "DeepMIMO[Array]":
|
|
151
161
|
"""Utility function to sort the DeepMIMO based on :class:`sionna.rt.Paths`' vertices.""" # noqa: DOC201, DOC501
|
|
152
162
|
if _is_jax_dtype(self):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, no_type_check
|
|
2
2
|
|
|
3
3
|
import equinox as eqx
|
|
4
4
|
import fpt_jax
|
|
@@ -169,17 +169,21 @@ def fermat_path_on_linear_objects(
|
|
|
169
169
|
return jnp.broadcast_to(object_origins, (*batch, num_objects, 3)).astype(dtype)
|
|
170
170
|
|
|
171
171
|
# Needed until https://github.com/jax-ml/jax/issues/34697 is resolved
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
@no_type_check
|
|
173
|
+
def _call_fpt_jax() -> Array:
|
|
174
|
+
return fpt_jax.trace_rays(
|
|
175
|
+
from_vertices,
|
|
176
|
+
to_vertices,
|
|
177
|
+
object_origins,
|
|
178
|
+
object_vectors,
|
|
179
|
+
num_iters=steps,
|
|
180
|
+
unroll=unroll,
|
|
181
|
+
num_iters_linesearch=linesearch_steps,
|
|
182
|
+
unroll_linesearch=unroll_linesearch,
|
|
183
|
+
implicit_diff=implicit_diff,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
return _call_fpt_jax()
|
|
183
187
|
|
|
184
188
|
|
|
185
189
|
@eqx.filter_jit
|
|
@@ -2,7 +2,7 @@ import math
|
|
|
2
2
|
import typing
|
|
3
3
|
import warnings
|
|
4
4
|
from collections.abc import Iterator, Mapping
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Literal, overload
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Literal, cast, overload
|
|
6
6
|
|
|
7
7
|
import equinox as eqx
|
|
8
8
|
import jax
|
|
@@ -1270,15 +1270,18 @@ class TriangleScene(eqx.Module):
|
|
|
1270
1270
|
to = from_ + 1
|
|
1271
1271
|
|
|
1272
1272
|
if chunk_size:
|
|
1273
|
+
# Type checker not able to infer that order is not None in this branch, even with the previous checks, so we need to cast it
|
|
1274
|
+
order = cast("int", order)
|
|
1275
|
+
|
|
1273
1276
|
path_candidates_iter = graph.all_paths_array_chunks(
|
|
1274
1277
|
from_=from_,
|
|
1275
1278
|
to=to,
|
|
1276
|
-
depth=order + 2,
|
|
1279
|
+
depth=order + 2,
|
|
1277
1280
|
include_from_and_to=False,
|
|
1278
1281
|
chunk_size=chunk_size,
|
|
1279
1282
|
)
|
|
1280
1283
|
it = (
|
|
1281
|
-
_compute_paths( # type: ignore[no-matching-overload]
|
|
1284
|
+
_compute_paths( # type: ignore[ty:no-matching-overload]
|
|
1282
1285
|
self.mesh,
|
|
1283
1286
|
tx_vertices,
|
|
1284
1287
|
rx_vertices,
|
|
@@ -1301,11 +1304,13 @@ class TriangleScene(eqx.Module):
|
|
|
1301
1304
|
return it
|
|
1302
1305
|
|
|
1303
1306
|
if path_candidates is None:
|
|
1307
|
+
# Type checker not able to infer that order is not None in this branch, even with the previous checks, so we need to cast it
|
|
1308
|
+
order = cast("int", order)
|
|
1304
1309
|
path_candidates = jnp.asarray(
|
|
1305
1310
|
graph.all_paths_array(
|
|
1306
1311
|
from_=from_,
|
|
1307
1312
|
to=to,
|
|
1308
|
-
depth=order + 2, #
|
|
1313
|
+
depth=order + 2, # order not narrowed in this branch
|
|
1309
1314
|
include_from_and_to=False,
|
|
1310
1315
|
),
|
|
1311
1316
|
dtype=int,
|
|
@@ -1318,7 +1323,7 @@ class TriangleScene(eqx.Module):
|
|
|
1318
1323
|
if self.mesh.assume_quads:
|
|
1319
1324
|
path_candidates -= path_candidates % 2
|
|
1320
1325
|
|
|
1321
|
-
return _compute_paths( # type: ignore[no-matching-overload]
|
|
1326
|
+
return _compute_paths( # type: ignore[ty:no-matching-overload]
|
|
1322
1327
|
self.mesh,
|
|
1323
1328
|
tx_vertices,
|
|
1324
1329
|
rx_vertices,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|