コード例 #1
0
 def test_side_effects(self):
     """ Test that mesh arrays are not written to in pelectrostatic """
     xx, yy = np.meshgrid(np.linspace(-10, 10, 32),
                          np.linspace(-10, 10, 32))
     xx.setflags(write=False)
     yy.setflags(write=False)
     potential = pelectrostatic(self.crystal, xx, yy)
コード例 #2
0
    def test_return_shape(self):
        """ Test that the return shape of pelectrostatic is the same as input arrays """
        xx, yy = np.meshgrid(np.linspace(-10, 10, 32),
                             np.linspace(-10, 10, 32))
        potential = pelectrostatic(self.crystal, xx, yy)

        self.assertSequenceEqual(xx.shape, potential.shape)
コード例 #3
0
def test_side_effects():
    """ Test that mesh arrays are not written to in pelectrostatic """
    crystal = Crystal.from_database("C")
    xx, yy = np.meshgrid(np.linspace(-10, 10, 32), np.linspace(-10, 10, 32))
    xx.setflags(write=False)
    yy.setflags(write=False)
    potential = pelectrostatic(crystal, xx, yy)
コード例 #4
0
def test_return_shape():
    """ Test that the return shape of pelectrostatic is the same as input arrays """
    crystal = Crystal.from_database("C")
    xx, yy = np.meshgrid(np.linspace(-10, 10, 32), np.linspace(-10, 10, 32))
    potential = pelectrostatic(crystal, xx, yy)

    assert xx.shape == potential.shape
コード例 #5
0
 def test_trivial(self):
     """ Test that the projected electrostatic potential from an empty slice of crystal is zero"""
     xx, yy = np.meshgrid(np.linspace(-10, 10, 32), np.linspace(-10, 10, 32))
     potential = pelectrostatic(self.crystal, xx, yy, bounds=(0, 1))
     self.assertTrue(np.allclose(potential, 0))
コード例 #6
0
def test_trivial():
    """ Test that the projected electrostatic potential from an empty slice of crystal is zero"""
    crystal = Crystal.from_database("C")
    xx, yy = np.meshgrid(np.linspace(-10, 10, 32), np.linspace(-10, 10, 32))
    potential = pelectrostatic(crystal, xx, yy, bounds=(0, 1))
    assert np.allclose(potential, 0)