Skip to content

Commit

Permalink
Added test and docs for exception that is raised for invalid dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
babbush committed Jul 4, 2017
1 parent d5457ab commit 1640040
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fermilib/utils/_plane_wave_hamiltonian.py
Expand Up @@ -36,6 +36,9 @@ def wigner_seitz_length_scale(wigner_seitz_radius, n_particles, dimension):
Returns:
length_scale (float): The length scale for the simulation.
Raises:
ValueError: System dimension must be 1, 2 or 3.
"""
if dimension == 1:
volume_per_particle = 2. * numpy.pi * wigner_seitz_radius
Expand Down
3 changes: 3 additions & 0 deletions src/fermilib/utils/_plane_wave_hamiltonian_test.py
Expand Up @@ -49,6 +49,9 @@ def test_wigner_seitz_radius(self):
self.assertAlmostEqual(
three_d_test, n_particles * (4. * numpy.pi / 3. *
wigner_seitz_radius ** 3.))
with self.assertRaises(ValueError):
wigner_seitz_length_scale(
wigner_seitz_radius, n_particles, 4)

def test_fourier_transform(self):
grid = Grid(dimensions=1, scale=1.5, length=3)
Expand Down

0 comments on commit 1640040

Please sign in to comment.