differt 0.0.31__tar.gz → 0.0.33__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 (31) hide show
  1. {differt-0.0.31 → differt-0.0.33}/PKG-INFO +4 -4
  2. {differt-0.0.31 → differt-0.0.33}/README.md +2 -2
  3. {differt-0.0.31 → differt-0.0.33}/pyproject.toml +1 -1
  4. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_material.py +2 -0
  5. {differt-0.0.31 → differt-0.0.33}/src/differt/geometry/_paths.py +24 -8
  6. {differt-0.0.31 → differt-0.0.33}/src/differt/geometry/_triangle_mesh.py +142 -6
  7. {differt-0.0.31 → differt-0.0.33}/src/differt/scene/_sionna.py +24 -3
  8. {differt-0.0.31 → differt-0.0.33}/src/differt/scene/_triangle_scene.py +3 -0
  9. {differt-0.0.31 → differt-0.0.33}/src/differt/utils.py +13 -36
  10. {differt-0.0.31 → differt-0.0.33}/.gitignore +0 -0
  11. {differt-0.0.31 → differt-0.0.33}/LICENSE.md +0 -0
  12. {differt-0.0.31 → differt-0.0.33}/src/differt/__init__.py +0 -0
  13. {differt-0.0.31 → differt-0.0.33}/src/differt/_version.py +0 -0
  14. {differt-0.0.31 → differt-0.0.33}/src/differt/em/__init__.py +0 -0
  15. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_antenna.py +0 -0
  16. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_constants.py +0 -0
  17. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_fresnel.py +0 -0
  18. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_interaction_type.py +0 -0
  19. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_utd.py +0 -0
  20. {differt-0.0.31 → differt-0.0.33}/src/differt/em/_utils.py +0 -0
  21. {differt-0.0.31 → differt-0.0.33}/src/differt/geometry/__init__.py +0 -0
  22. {differt-0.0.31 → differt-0.0.33}/src/differt/geometry/_utils.py +0 -0
  23. {differt-0.0.31 → differt-0.0.33}/src/differt/plotting/__init__.py +0 -0
  24. {differt-0.0.31 → differt-0.0.33}/src/differt/plotting/_core.py +0 -0
  25. {differt-0.0.31 → differt-0.0.33}/src/differt/plotting/_utils.py +0 -0
  26. {differt-0.0.31 → differt-0.0.33}/src/differt/py.typed +0 -0
  27. {differt-0.0.31 → differt-0.0.33}/src/differt/rt/__init__.py +0 -0
  28. {differt-0.0.31 → differt-0.0.33}/src/differt/rt/_fermat.py +0 -0
  29. {differt-0.0.31 → differt-0.0.33}/src/differt/rt/_image_method.py +0 -0
  30. {differt-0.0.31 → differt-0.0.33}/src/differt/rt/_utils.py +0 -0
  31. {differt-0.0.31 → differt-0.0.33}/src/differt/scene/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DiffeRT
3
- Version: 0.0.31
3
+ Version: 0.0.33
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,7 +21,7 @@ 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.0.31
24
+ Requires-Dist: differt-core==0.0.33
25
25
  Requires-Dist: equinox>=0.11.5
26
26
  Requires-Dist: filelock>=3.15.4
27
27
  Requires-Dist: jax>=0.4.32
@@ -139,7 +139,7 @@ If you use this software, please cite it as
139
139
  [pypi-python-version-badge]: https://img.shields.io/pypi/pyversions/DiffeRT?color=orange
140
140
  [documentation-badge]: https://readthedocs.org/projects/differt/badge/?version=latest
141
141
  [documentation-url]: https://differt.readthedocs.io/latest/?badge=latest
142
- [doi-badge]: https://zenodo.org/badge/DOI/10.5281/zenodo.13895021.svg
143
- [doi-url]: https://doi.org/10.5281/zenodo.13895021
142
+ [doi-badge]: https://zenodo.org/badge/DOI/10.5281/zenodo.11386432.svg
143
+ [doi-url]: https://doi.org/10.5281/zenodo.11386432
144
144
  [codecov-badge]: https://codecov.io/gh/jeertmans/DiffeRT/branch/main/graph/badge.svg?token=v63alnTWzu
145
145
  [codecov-url]: https://codecov.io/gh/jeertmans/DiffeRT
@@ -82,7 +82,7 @@ If you use this software, please cite it as
82
82
  [pypi-python-version-badge]: https://img.shields.io/pypi/pyversions/DiffeRT?color=orange
83
83
  [documentation-badge]: https://readthedocs.org/projects/differt/badge/?version=latest
84
84
  [documentation-url]: https://differt.readthedocs.io/latest/?badge=latest
85
- [doi-badge]: https://zenodo.org/badge/DOI/10.5281/zenodo.13895021.svg
86
- [doi-url]: https://doi.org/10.5281/zenodo.13895021
85
+ [doi-badge]: https://zenodo.org/badge/DOI/10.5281/zenodo.11386432.svg
86
+ [doi-url]: https://doi.org/10.5281/zenodo.11386432
87
87
  [codecov-badge]: https://codecov.io/gh/jeertmans/DiffeRT/branch/main/graph/badge.svg?token=v63alnTWzu
88
88
  [codecov-url]: https://codecov.io/gh/jeertmans/DiffeRT
@@ -16,7 +16,7 @@ classifiers = [
16
16
  ]
17
17
  dependencies = [
18
18
  "chex>=0.1.86",
19
- "differt-core==0.0.31",
19
+ "differt-core==0.0.33",
20
20
  "equinox>=0.11.5",
21
21
  "filelock>=3.15.4",
22
22
  "jax>=0.4.32",
@@ -42,6 +42,8 @@ class Material(eqx.Module):
42
42
  Returns:
43
43
  A tuple containing the relative permittivity and conductivity of the material.
44
44
  """
45
+ thickness: Float[ArrayLike, ""] | None = eqx.field(default=None)
46
+ """The thickness of the material."""
45
47
  aliases: tuple[str, ...] = eqx.field(default=(), static=True)
46
48
  """
47
49
  A tuple of name aliases for the material.
@@ -1,7 +1,7 @@
1
1
  import warnings
2
2
  from collections.abc import Callable, Iterator, Sequence
3
3
  from dataclasses import KW_ONLY
4
- from typing import TYPE_CHECKING, Any
4
+ from typing import TYPE_CHECKING, Any, overload
5
5
 
6
6
  import equinox as eqx
7
7
  import jax
@@ -265,7 +265,7 @@ class Paths(eqx.Module):
265
265
  @property
266
266
  def masked_vertices(
267
267
  self,
268
- ) -> Float[Array, "{self.num_valid_paths} {self.path_length} 3"]:
268
+ ) -> Float[Array, "num_valid_paths path_length 3"]:
269
269
  """The array of masked vertices, with batched dimensions flattened into one.
270
270
 
271
271
  If :attr:`mask` is :data:`None`, then the returned array is simply
@@ -280,7 +280,7 @@ class Paths(eqx.Module):
280
280
  @property
281
281
  def masked_objects(
282
282
  self,
283
- ) -> Int[Array, "{self.num_valid_paths} {self.path_length}"]:
283
+ ) -> Int[Array, "num_valid_paths path_length"]:
284
284
  """The array of masked objects, with batched dimensions flattened into one.
285
285
 
286
286
  Similar to :attr:`masked_vertices`, but for :data:`objects`.
@@ -398,20 +398,36 @@ class Paths(eqx.Module):
398
398
  ):
399
399
  yield cls(vertices=vertices, objects=objects, mask=None)
400
400
 
401
- @eqx.filter_jit
401
+ @overload
402
+ def reduce(
403
+ self,
404
+ fun: Callable[[Num[Array, "*batch path_length 3"]], Num[Array, " *batch"]],
405
+ axis: None = None,
406
+ ) -> Num[Array, " "]: ...
407
+
408
+ @overload
402
409
  def reduce(
403
- self, fun: Callable[[Num[Array, "*batch path_length 3"]], Num[Array, " *batch"]]
404
- ) -> Num[Array, " "]:
405
- """Apply a function on all path vertices and accumulate the result into a scalar value.
410
+ self,
411
+ fun: Callable[[Num[Array, "*batch path_length 3"]], Num[Array, " *batch"]],
412
+ axis: int | Sequence[int],
413
+ ) -> Num[Array, " *reduced_batch"]: ...
414
+
415
+ def reduce(
416
+ self,
417
+ fun: Callable[[Num[Array, "*batch path_length 3"]], Num[Array, " *batch"]],
418
+ axis: int | Sequence[int] | None = None,
419
+ ) -> Num[Array, " "] | Num[Array, " *reduced_batch"]:
420
+ """Apply a function on all path vertices and accumulate the result into a scalar value (or an array if ``axis`` is provided).
406
421
 
407
422
  Args:
408
423
  fun: The function to be called on all path vertices.
424
+ axis: See :func:`jax.numpy.sum` for allowed values.
409
425
 
410
426
  Returns:
411
427
  The sum of the results, with contributions from
412
428
  invalid paths that are set to zero.
413
429
  """
414
- return jnp.sum(fun(self.vertices), where=self.mask)
430
+ return jnp.sum(fun(self.vertices), axis=axis, where=self.mask)
415
431
 
416
432
  def plot(self, **kwargs: Any) -> PlotOutput:
417
433
  """
@@ -115,7 +115,7 @@ class TriangleMesh(eqx.Module):
115
115
  material_names: tuple[str, ...] = eqx.field(
116
116
  converter=tuple, default_factory=tuple, static=True
117
117
  )
118
- """The list of material names."""
118
+ """The list of material names (must be unique)."""
119
119
  object_bounds: Int[Array, "num_objects 2"] | None = eqx.field(
120
120
  converter=lambda x: jnp.asarray(x) if x is not None else None, default=None
121
121
  )
@@ -143,6 +143,9 @@ class TriangleMesh(eqx.Module):
143
143
  if self.assume_quads and (self.triangles.shape[0] % 2) != 0:
144
144
  msg = "You cannot set 'assume_quads' to 'True' if the number of triangles is not even!"
145
145
  raise ValueError(msg)
146
+ if len(set(self.material_names)) != len(self.material_names):
147
+ msg = f"Material names must be unique, got {self.material_names!r}."
148
+ raise ValueError(msg)
146
149
 
147
150
  def __getitem__(self, key: slice | Int[ArrayLike, " n"]) -> Self:
148
151
  """Return a copy of this mesh, taking only specific triangles.
@@ -220,7 +223,7 @@ class TriangleMesh(eqx.Module):
220
223
  return self.num_quads if self.assume_quads else self.num_triangles
221
224
 
222
225
  @property
223
- def triangle_vertices(self) -> Float[Array, "{self.num_triangles} 3 3"]:
226
+ def triangle_vertices(self) -> Float[Array, "num_triangles 3 3"]:
224
227
  """The array of indexed triangle vertices."""
225
228
  if self.triangles.size == 0:
226
229
  return jnp.empty_like(self.vertices, shape=(0, 3, 3))
@@ -267,7 +270,7 @@ class TriangleMesh(eqx.Module):
267
270
  )
268
271
 
269
272
  @property
270
- def normals(self) -> Float[Array, "{self.num_triangles} 3"]:
273
+ def normals(self) -> Float[Array, "num_triangles 3"]:
271
274
  """The triangle normals."""
272
275
  vectors = jnp.diff(self.triangle_vertices, axis=1)
273
276
  normals = jnp.cross(vectors[:, 0, :], vectors[:, 1, :])
@@ -275,7 +278,7 @@ class TriangleMesh(eqx.Module):
275
278
  return normalize(normals)[0]
276
279
 
277
280
  @property
278
- def diffraction_edges(self) -> Int[Array, "{self.num_edges} 3"]:
281
+ def diffraction_edges(self) -> Int[Array, "num_edges 3"]:
279
282
  """The diffraction edges."""
280
283
  raise NotImplementedError
281
284
 
@@ -347,10 +350,143 @@ class TriangleMesh(eqx.Module):
347
350
  """
348
351
  return cls(vertices=jnp.empty((0, 3)), triangles=jnp.empty((0, 3), dtype=int))
349
352
 
353
+ def append(self, other: "TriangleMesh") -> "TriangleMesh":
354
+ """
355
+ Return a new mesh by appending another mesh to this one.
356
+
357
+ .. tip::
358
+
359
+ For convenience, you can also use the ``+`` operator.
360
+
361
+ .. todo::
362
+
363
+ Document how optional arguments are merged,
364
+ as well as the behavior of :attr:`assume_quads`,
365
+ and the specific case of empty meshes.
366
+
367
+ Args:
368
+ other: The mesh to append.
369
+
370
+ Returns:
371
+ The new mesh.
372
+
373
+ Examples:
374
+ The following example shows how to create a mesh of nested cubes.
375
+
376
+ .. plotly::
377
+
378
+ >>> from differt.geometry import TriangleMesh
379
+ >>>
380
+ >>> mesh = TriangleMesh.empty()
381
+ >>> for i in range(3):
382
+ ... size = 1.0 / (i + 1)
383
+ ... mesh += TriangleMesh.box(length=size, width=size, height=size)
384
+ >>> mesh = mesh.set_assume_quads().set_face_colors(
385
+ ... key=jax.random.key(1234)
386
+ ... )
387
+ >>> fig = mesh.plot(opacity=0.5, backend="plotly")
388
+ >>> fig # doctest: +SKIP
389
+ """
390
+ if self.is_empty:
391
+ return eqx.tree_at(lambda _: (), other, ())
392
+ if other.is_empty:
393
+ return eqx.tree_at(lambda _: (), self, ())
394
+
395
+ vertices = jnp.concatenate((self.vertices, other.vertices), axis=0)
396
+ triangles = jnp.concatenate(
397
+ (self.triangles, other.triangles + self.vertices.shape[0]), axis=0
398
+ )
399
+
400
+ if self.face_colors is not None and other.face_colors is not None:
401
+ face_colors = jnp.concatenate((self.face_colors, other.face_colors), axis=0)
402
+ elif self.face_colors is not None:
403
+ face_colors = jnp.concatenate(
404
+ (
405
+ self.face_colors,
406
+ jnp.zeros_like(self.face_colors, shape=(other.num_triangles, 3)),
407
+ ),
408
+ axis=0,
409
+ )
410
+ elif other.face_colors is not None:
411
+ face_colors = jnp.concatenate(
412
+ (
413
+ jnp.zeros_like(other.face_colors, shape=(self.num_triangles, 3)),
414
+ other.face_colors,
415
+ ),
416
+ axis=0,
417
+ )
418
+ else:
419
+ face_colors = None
420
+
421
+ material_names = dict.fromkeys(self.material_names) | dict.fromkeys(
422
+ other.material_names
423
+ )
424
+ material_indices = {
425
+ material_name: i for i, material_name in enumerate(material_names)
426
+ }
427
+ other_face_materials_renumbered = jnp.array([
428
+ material_indices[name] for name in other.material_names
429
+ ])
430
+ material_names = tuple(material_names)
431
+
432
+ if self.face_materials is not None and other.face_materials is not None:
433
+ face_materials = jnp.concatenate(
434
+ (
435
+ self.face_materials,
436
+ jnp.where(
437
+ other.face_materials != -1,
438
+ other_face_materials_renumbered[other.face_materials],
439
+ other.face_materials,
440
+ ),
441
+ ),
442
+ axis=0,
443
+ )
444
+ elif self.face_materials is not None:
445
+ face_materials = jnp.concatenate(
446
+ (
447
+ self.face_materials,
448
+ jnp.full_like(self.face_materials, -1, shape=other.num_triangles),
449
+ ),
450
+ axis=0,
451
+ )
452
+ elif other.face_materials is not None:
453
+ face_materials = jnp.concatenate(
454
+ (
455
+ jnp.full_like(other.face_materials, -1, shape=self.num_triangles),
456
+ jnp.where(
457
+ other.face_materials != -1,
458
+ other_face_materials_renumbered[other.face_materials],
459
+ other.face_materials,
460
+ ),
461
+ ),
462
+ axis=0,
463
+ )
464
+ else:
465
+ face_materials = None
466
+
467
+ object_bounds = (
468
+ jnp.concatenate(
469
+ (self.object_bounds, other.object_bounds + other.num_triangles), axis=0
470
+ )
471
+ if (self.object_bounds is not None and other.object_bounds is not None)
472
+ else None
473
+ )
474
+ assume_quads = self.assume_quads and other.assume_quads
475
+ return TriangleMesh(
476
+ vertices=vertices,
477
+ triangles=triangles,
478
+ face_colors=face_colors,
479
+ face_materials=face_materials,
480
+ object_bounds=object_bounds,
481
+ assume_quads=assume_quads,
482
+ )
483
+
484
+ __add__ = append
485
+
350
486
  @overload
351
487
  def set_face_colors(
352
488
  self,
353
- colors: Float[ArrayLike, "#{self.num_triangles} 3"] | Float[ArrayLike, "3"],
489
+ colors: Float[ArrayLike, "#num_triangles 3"] | Float[ArrayLike, "3"],
354
490
  *,
355
491
  key: None = None,
356
492
  ) -> Self: ...
@@ -365,7 +501,7 @@ class TriangleMesh(eqx.Module):
365
501
 
366
502
  def set_face_colors(
367
503
  self,
368
- colors: Float[ArrayLike, "#{self.num_triangles} 3"]
504
+ colors: Float[ArrayLike, "#num_triangles 3"]
369
505
  | Float[ArrayLike, "3"]
370
506
  | None = None,
371
507
  *,
@@ -22,6 +22,8 @@ SIONNA_SCENES_FOLDER = Path(__file__).parent / "scenes"
22
22
 
23
23
  def download_sionna_scenes(
24
24
  branch_or_tag: str = "main",
25
+ repo: str = "NVlabs/sionna-rt",
26
+ scenes_folder: str = "src/sionna/rt/scenes/",
25
27
  *,
26
28
  folder: str | Path = SIONNA_SCENES_FOLDER,
27
29
  cached: bool = True,
@@ -44,6 +46,11 @@ def download_sionna_scenes(
44
46
 
45
47
  Args:
46
48
  branch_or_tag: The branch or tag version of the Sionna repository.
49
+ repo: The repository ``{owner}/{name}`` on GitHub from which to download the scenes.
50
+
51
+ E.g., you can change this if you want to use a fork instead.
52
+ scenes_folder: The folder where the scenes are stored in the
53
+ repository.
47
54
  folder: Where to extract the scene files, i.e., the content
48
55
  of ``sionna/rt/scenes/``.
49
56
  cached: Whether to avoid downloading again if the target folder
@@ -66,7 +73,7 @@ def download_sionna_scenes(
66
73
 
67
74
  folder.rmdir()
68
75
 
69
- url = f"https://codeload.github.com/NVlabs/sionna/tar.gz/{branch_or_tag}"
76
+ url = f"https://codeload.github.com/{repo}/tar.gz/{branch_or_tag}"
70
77
 
71
78
  response = requests.get(url, stream=True, timeout=timeout)
72
79
 
@@ -75,8 +82,8 @@ def download_sionna_scenes(
75
82
 
76
83
  def members(tar: tarfile.TarFile) -> Iterator[tarfile.TarInfo]:
77
84
  for member in tar.getmembers():
78
- if (index := member.path.find("sionna/rt/scenes/")) >= 0:
79
- member.path = member.path[index + 17 :]
85
+ if (index := member.path.find(scenes_folder)) >= 0:
86
+ member.path = member.path[index + len(scenes_folder) :]
80
87
  yield member
81
88
 
82
89
  with (
@@ -181,6 +188,20 @@ def main() -> None: # pragma: no cover
181
188
  nargs="?",
182
189
  help="branch or tag version of the Sionna repository.",
183
190
  )
191
+ parser.add_argument(
192
+ "-r",
193
+ "--repo",
194
+ type=str,
195
+ default="NVlabs/sionna-rt",
196
+ help="the repository '{owner}/{name}' on GitHub from which to download the scenes.",
197
+ )
198
+ parser.add_argument(
199
+ "-s",
200
+ "--scenes-folder",
201
+ type=Path,
202
+ default="src/sionna/rt/scenes",
203
+ help="the folder where the scenes are stored in the repository.",
204
+ )
184
205
  parser.add_argument(
185
206
  "--folder",
186
207
  type=Path,
@@ -189,6 +189,9 @@ def _compute_paths(
189
189
  axis=-1
190
190
  ) # Any path segment being too small
191
191
 
192
+ # TODO: check if we should invalidate non-finite paths
193
+ # is_finite = jnp.isfinite(full_paths).all(axis=(-1, -2))
194
+
192
195
  mask = inside_triangles & valid_reflections & ~blocked & ~too_small
193
196
 
194
197
  return full_paths, mask
@@ -1,8 +1,8 @@
1
1
  """General purpose utilities."""
2
2
 
3
- from collections.abc import Callable, Iterable, Mapping
3
+ from collections.abc import Callable
4
4
  from functools import partial
5
- from typing import Any, Concatenate, ParamSpec, overload
5
+ from typing import Any, Concatenate, ParamSpec
6
6
 
7
7
  import chex
8
8
  import equinox as eqx
@@ -108,19 +108,21 @@ def sorted_array2(array: Shaped[ArrayLike, "m n"]) -> Shaped[Array, "m n"]:
108
108
  if array.size == 0:
109
109
  return array
110
110
 
111
- return array[jnp.lexsort(array.T[::-1])] # type: ignore[reportArgumentType]
111
+ return array[jnp.lexsort(array.T[::-1])]
112
112
 
113
113
 
114
114
  # Redefined here, because chex uses deprecated type hints
115
115
  # TODO: fixme when google/chex#361 is resolved.
116
- _OptState = chex.Array | Iterable["_OptState"] | Mapping[Any, "_OptState"]
116
+ # TODO: changme because beartype>=0.20 complains that it cannot import ArrayTree,
117
+ # and I don't see how to fix it.
118
+ OptState = Any
117
119
  # TODO: fixme when Python >= 3.11
118
- _P = ParamSpec("_P")
120
+ P = ParamSpec("P")
119
121
 
120
122
 
121
123
  @eqx.filter_jit
122
124
  def minimize(
123
- fun: Callable[Concatenate[Num[Array, " n"], _P], Num[Array, " "]],
125
+ fun: Callable[Concatenate[Num[Array, " n"], P], Num[Array, " "]],
124
126
  x0: Num[ArrayLike, "*batch n"],
125
127
  args: tuple[Any, ...] = (),
126
128
  steps: int = 1000,
@@ -255,9 +257,9 @@ def minimize(
255
257
  opt_state = optimizer.init(x0)
256
258
 
257
259
  def f(
258
- carry: tuple[Num[Array, "*batch n"], _OptState],
260
+ carry: tuple[Num[Array, "*batch n"], OptState],
259
261
  _: None,
260
- ) -> tuple[tuple[Num[Array, "*batch n"], _OptState], Num[Array, " *batch"]]:
262
+ ) -> tuple[tuple[Num[Array, "*batch n"], OptState], Num[Array, " *batch"]]:
261
263
  x, opt_state = carry
262
264
  loss, grads = f_and_df(x, *args)
263
265
  updates, opt_state = optimizer.update(grads, opt_state)
@@ -270,41 +272,19 @@ def minimize(
270
272
  return x, losses[-1]
271
273
 
272
274
 
273
- @overload
274
- def sample_points_in_bounding_box(
275
- bounding_box: Float[ArrayLike, "2 3"],
276
- shape: None = None,
277
- *,
278
- key: PRNGKeyArray,
279
- ) -> Float[Array, "3"]: ...
280
-
281
-
282
- @overload
283
- def sample_points_in_bounding_box(
284
- bounding_box: Float[ArrayLike, "2 3"],
285
- shape: tuple[int, ...],
286
- *,
287
- key: PRNGKeyArray,
288
- ) -> Float[Array, "3"]: ...
289
-
290
-
291
275
  @partial(jax.jit, static_argnames=("shape",))
292
276
  def sample_points_in_bounding_box(
293
277
  bounding_box: Float[ArrayLike, "2 3"],
294
- shape: tuple[int, ...] | None = None,
278
+ shape: tuple[int, ...] = (),
295
279
  *,
296
280
  key: PRNGKeyArray,
297
- ) -> (
298
- Float[Array, "*shape 3"] | Float[Array, "3"]
299
- ): # TODO: use symbolic expression to link to 'shape' parameter
281
+ ) -> Float[Array, "*shape 3"]:
300
282
  """
301
283
  Sample point(s) in a 3D bounding box.
302
284
 
303
285
  Args:
304
286
  bounding_box: The bounding box (min. and max. coordinates).
305
- shape: The sample shape or :data:`None`. If :data:`None`,
306
- the returned array is 1D. Otherwise, the shape
307
- of the returned array is ``(*shape, 3)``.
287
+ shape: The sample shape.
308
288
  key: The :func:`jax.random.PRNGKey` to be used.
309
289
 
310
290
  Returns:
@@ -315,9 +295,6 @@ def sample_points_in_bounding_box(
315
295
  amax = bounding_box[1, :]
316
296
  scale = amax - amin
317
297
 
318
- if shape is None:
319
- shape = ()
320
-
321
298
  r = jax.random.uniform(key, shape=(*shape, 3))
322
299
 
323
300
  return r * scale + amin
File without changes
File without changes
File without changes