Skip to content

Commit 4c2b722

Browse files
committed
Check dimensions for toroidal wn
1 parent b16332b commit 4c2b722

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pyrecest/distributions/hypertorus/hypertoroidal_wrapped_normal_distribution.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pyrecest.backend import (
88
allclose,
99
arange,
10+
atleast_2d,
1011
array,
1112
exp,
1213
int32,
@@ -15,7 +16,6 @@
1516
meshgrid,
1617
mod,
1718
random,
18-
reshape,
1919
stack,
2020
zeros,
2121
)
@@ -70,7 +70,9 @@ def pdf(self, xs, m: Union[int, int32, int64] = 3):
7070
:param m: Controls the number of terms in the Fourier series approximation.
7171
:return: PDF values at xs.
7272
"""
73-
xs = reshape(xs, (-1, self.dim))
73+
assert xs.shape[-1] == self.dim, "Last dimension of xs must match the distribution dimension"
74+
xs = atleast_2d(xs) # Ensure xs is at least 2-D for approach below
75+
xs = (xs + pi) % (2 * pi) - pi
7476

7577
# Generate all combinations of offsets for each dimension
7678
offsets = [arange(-m, m + 1) * 2.0 * pi for _ in range(self.dim)]

0 commit comments

Comments
 (0)