Skip to content

Commit

Permalink
updated unit_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CalystaT committed Aug 18, 2023
1 parent 0970469 commit 465f4b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion macrodensity/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def density_2_grid(Density: np.ndarray, nx: int, ny: int, nz: int, Charge: bool=
nz (int): Number of grid points along the z-axis.
Charge (bool, optional): If True, convert charge density to the number of electrons. Default is False.
Volume (float, optional): Volume of the grid cell. Used to convert charge density to electrons. Default is 1.
Format (str, optional): Format of the density data (e.g., 'VASP', 'GULP'). Default is 'GULP'.
Format (str, optional): Format of the density data (e.g., 'VASP', 'GULP'). Default is 'VASP'.
Returns:
tuple: A tuple containing:
Expand Down
Binary file modified tests/__pycache__/unit_tests.cpython-311.pyc
Binary file not shown.
18 changes: 10 additions & 8 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ def test_plot_planar_average(self):
'''Tests the plot_planar_average function'''
Locpot = pkg_resources.resource_filename(
__name__, path_join('../tests', 'LOCPOT.test'))
out = md.plot_planar_average(lattice_vector=5.41,input_file=Locpot)[0]
self.assertAlmostEqual(out[0][0],0.14555565)
self.assertAlmostEqual(out[0][10],4.61454537)
self.assertAlmostEqual(out[0][-1],-0.87290696)
out = md.plot_planar_average(lattice_vector=5.41,input_file=Locpot)
res = out[0]
self.assertAlmostEqual(res[0][0],0.14555565)
self.assertAlmostEqual(res[0][10],4.61454537)
self.assertAlmostEqual(res[0][-1],-0.87290696)
self.addCleanup(os.remove, 'PlanarAverage.csv')
self.addCleanup(os.remove, 'PlanarAverage.png')

Expand All @@ -292,10 +293,11 @@ def test_plot_gulp_potential(self):
'''Tests the plot_gulp_potential function'''
gulpcar = pkg_resources.resource_filename(
__name__, path_join('../tests', 'gulp.out'))
out = md.plot_planar_average(lattice_vector=3.0,input_file=gulpcar)[0]
self.assertEqual(out[0][0],-23.16678352)
self.assertAlmostEqual(out[0][10],-1.59508152)
self.assertEqual(out[0][-1],-23.16678352)
out = md.plot_planar_average(lattice_vector=3.0,input_file=gulpcar)
res = out[0]
self.assertEqual(res[0][0],-23.16678352)
self.assertAlmostEqual(res[0][10],-1.59508152)
self.assertEqual(res[0][-1],-23.16678352)
self.addCleanup(os.remove, 'GulpPotential.csv')
self.addCleanup(os.remove, 'GulpPotential.png')

Expand Down

0 comments on commit 465f4b2

Please sign in to comment.