Skip to content

Commit

Permalink
Fixed a bug in MultilayerFilm.shape and MultilayerMirror.shape wh…
Browse files Browse the repository at this point in the history
…ere a `ValueError` was raised if `layers` was not a sequence.
  • Loading branch information
byrdie committed Nov 6, 2024
1 parent 5f841c6 commit b184e5c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions optika/materials/_multilayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,13 @@ class MultilayerFilm(

@property
def shape(self) -> dict[str, int]:
return na.broadcast_shapes(
*[optika.shape(layer) for layer in self.layers],
)
try:
shape_layer = na.broadcast_shapes(
*[optika.shape(layer) for layer in self.layers],
)
except TypeError:
shape_layer = optika.shape(self.layers)

Check warning on line 891 in optika/materials/_multilayers.py

View check run for this annotation

Codecov / codecov/patch

optika/materials/_multilayers.py#L890-L891

Added lines #L890 - L891 were not covered by tests
return shape_layer


@dataclasses.dataclass(eq=False, repr=False)
Expand Down Expand Up @@ -1099,7 +1103,13 @@ class MultilayerMirror(

@property
def shape(self) -> dict[str, int]:
try:
shape_layer = na.broadcast_shapes(
*[optika.shape(layer) for layer in self.layers],
)
except TypeError:
shape_layer = optika.shape(self.layers)

Check warning on line 1111 in optika/materials/_multilayers.py

View check run for this annotation

Codecov / codecov/patch

optika/materials/_multilayers.py#L1110-L1111

Added lines #L1110 - L1111 were not covered by tests
return na.broadcast_shapes(
*[optika.shape(layer) for layer in self.layers],
shape_layer,
optika.shape(self.substrate),
)

0 comments on commit b184e5c

Please sign in to comment.