Skip to content

Commit

Permalink
Added phi_at_x unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjmorgan committed Jul 5, 2021
1 parent 51c184b commit 9695872
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
from pyscses.grid import Grid, delta_x_from_grid
from pyscses.grid import closest_index, index_of_grid_at_x, energy_at_x
from pyscses.grid import (closest_index,
index_of_grid_at_x,
energy_at_x,
phi_at_x)
from pyscses.grid_point import GridPoint
from pyscses.set_of_sites import SetOfSites
from pyscses.site import Site
Expand Down Expand Up @@ -45,6 +48,21 @@ def test_energy_at_x(self):
coordinates=coordinates,
x=0.6), 0.4)

def test_phi_at_x(self):
energy = np.array([0.1, 0.2, 0.3, 0.4, 0.5])
coordinates = np.array([-2.0, -1.0, 0.0, 1.0, 2.0])
with patch('pyscses.grid.index_of_grid_at_x') as mock_index_of_grid_at_x:
mock_index_of_grid_at_x.side_effect = [0, 2, 3]
self.assertEqual(phi_at_x(phi=energy,
coordinates=coordinates,
x=-1.5), 0.1)
self.assertEqual(phi_at_x(phi=energy,
coordinates=coordinates,
x=-0.1), 0.3)
self.assertEqual(phi_at_x(phi=energy,
coordinates=coordinates,
x=0.6), 0.4)


class TestGrid(unittest.TestCase):
@patch('pyscses.grid.index_of_grid_at_x')
Expand Down

0 comments on commit 9695872

Please sign in to comment.