Skip to content

Commit

Permalink
fix: spreading function with s not an integer
Browse files Browse the repository at this point in the history
  • Loading branch information
vegard-solum-4ss authored Sep 27, 2022
1 parent 6ecd3ef commit c9c097d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/waveresponse/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ def _spread_fun(self, _, theta, /):

s = self._s
c = 2 ** (2 * s + 1) * gamma(s + 1) ** 2 / gamma(2 * s + 1)
return c * np.cos(theta) ** (2.0 * s)
return c * (np.cos(theta) ** 2.0) ** s


class CosineFullSpreading(BaseSpreading):
Expand Down Expand Up @@ -1465,4 +1465,4 @@ def __init__(self, s=1, degrees=False):
def _spread_fun(self, _, theta, /):
s = self._s
c = 2 ** (2 * s) * gamma(s + 1) ** 2 / gamma(2 * s + 1)
return c * np.cos(theta / 2.0) ** (2.0 * s)
return c * (np.cos(theta / 2.0) ** 2.0) ** s
2 changes: 2 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3149,6 +3149,7 @@ def test__init__(self):
[0, 45, 2, 0.005396691782172398],
[0, -45, 2, 0.005396691782172398],
[0, 45 + 2 * 360, 2, 0.005396691782172398],
[0, 359, 0.5, 0.004363156988011003],
]

@pytest.mark.parametrize("f,d,s,spread_expect", params__call__degrees)
Expand Down Expand Up @@ -3178,6 +3179,7 @@ def test__call__degrees(self, f, d, s, spread_expect):
[0, np.pi / 4, 2, 0.309207662451413],
[0, -np.pi / 4, 2, 0.309207662451413],
[0, np.pi / 4 + 2 * 2.0 * np.pi, 2, 0.309207662451413],
[0, 7 * np.pi / 4.0, 0.5, 0.23096988312782166],
]

@pytest.mark.parametrize("f,d,s,spread_expect", params__call__radians)
Expand Down

0 comments on commit c9c097d

Please sign in to comment.