Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def pdf(self, xs):
: Probability density at the given data points.
"""
xs = array(xs)
if xs.shape[-1] != self.input_dim:
if xs.ndim == 0 or xs.shape[-1] != self.input_dim:
raise ValueError("Invalid shape of input data points.")
manifold_size = self.get_manifold_size()
if manifold_size == 0:
Expand Down
17 changes: 17 additions & 0 deletions tests/distributions/test_hypersphere_uniform_scalar_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Regression tests for hyperspherical uniform input validation."""

import unittest

from pyrecest.distributions import HypersphericalUniformDistribution


class HypersphericalUniformScalarPdfTest(unittest.TestCase):
def test_pdf_rejects_scalar_input_with_value_error(self):
dist = HypersphericalUniformDistribution(2)

with self.assertRaisesRegex(ValueError, "Invalid shape"):
dist.pdf(1.0)


if __name__ == "__main__":
unittest.main()
Loading