Skip to content

Commit

Permalink
replace assert with ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Kleinhenz committed Jun 10, 2024
1 parent 03c5a40 commit bfd87c6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/beignet/special/_faddeeva_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@


def _voigt_v(x, y, n: int = 11):
assert (x >= 0.0).all()
assert (y >= 0.0).all()
if not ((x >= 0.0) & (y >= 0.0)).all():
raise ValueError("_voigt_v only defined for x >= 0 and y >= 0")

h = math.sqrt(math.pi / (n + 1))

phi = (x / h) - torch.floor(x / h)
Expand Down Expand Up @@ -63,8 +64,9 @@ def _voigt_v(x, y, n: int = 11):


def _voigt_l(x, y, n: int = 11):
assert (x >= 0.0).all()
assert (y >= 0.0).all()
if not ((x >= 0.0) & (y >= 0.0)).all():
raise ValueError("_voigt_l only defined for x >= 0 and y >= 0")

h = math.sqrt(math.pi / (n + 1))

phi = (x / h) - torch.floor(x / h)
Expand Down Expand Up @@ -148,8 +150,8 @@ def faddeeva_w(input: Tensor, *, out: Tensor | None = None) -> Tensor:
x = input.real
y = input.imag

assert (x >= 0.0).all()
assert (y >= 0.0).all()
if not ((x >= 0.0) & (y >= 0.0)).all():
raise ValueError("failed to map input to x >= 0, y >= 0")

output = _voigt_v(x, y, n=11) + 1j * _voigt_l(x, y, n=11)

Expand Down

0 comments on commit bfd87c6

Please sign in to comment.