def test_get_exact_h_atom_density_wrong_shape(self): grids = np.linspace(-10, 10, 1001) dx = 0.02 with self.assertRaisesRegex( ValueError, 'displacements is expected to have ndim=2, but got 1'): np_utils._get_exact_h_atom_density(grids, dx)
def test_get_exact_h_atom_density(self): grids = np.linspace(-10, 10, 1001) dx = 0.02 displacements = np.array([ grids, grids - 2, ]) density = np_utils._get_exact_h_atom_density(displacements, dx) self.assertIsInstance(density, np.ndarray) self.assertEqual(density.shape, (2, 1001)) np.testing.assert_allclose(np.sum(density, axis=1) * dx, [1, 1]) self.assertAlmostEqual(density[0][501], 0.40758, places=4) self.assertAlmostEqual(density[1][601], 0.40758, places=4)