コード例 #1
0
def iter_grids():
    """ generate some test grids """
    yield grids.UnitGrid([2, 2], periodic=[True, False])
    yield grids.CartesianGrid([[0, 1]], [2], periodic=[False])
    yield grids.CylindricalGrid(2, (0, 2), (2, 2), periodic_z=True)
    yield grids.SphericalGrid(2, 2)
    yield grids.PolarGrid(2, 2)
コード例 #2
0
def iter_grids():
    """ generator providing some test grids """
    for periodic in [True, False]:
        yield grids.UnitGrid([3], periodic=periodic)
        yield grids.UnitGrid([3, 3, 3], periodic=periodic)
        yield grids.CartesianGrid([[-1, 2], [0, 3]], [5, 7], periodic=periodic)
        yield grids.CylindricalGrid(3, [-1, 2], [7, 8], periodic_z=periodic)
    yield grids.PolarGrid(3, 4)
    yield grids.SphericalGrid(3, 4)
コード例 #3
0
 def iter_grids():
     """ helper function iterating over different grids """
     for periodic in [True, False]:
         yield grids.UnitGrid([3, 4], periodic=periodic)
         yield grids.CartesianGrid([[0, 1], [-2, 3]], [4, 5],
                                   periodic=periodic)
         yield grids.CylindricalGrid(3, [-1, 2], [5, 7],
                                     periodic_z=periodic)
     yield grids.SphericalGrid(4, 6)
     yield grids.PolarGrid(4, 5)
コード例 #4
0
def test_iter_mirror_points():
    """ test iterating mirror points in grids """
    grid_cart = grids.UnitGrid([2, 2], periodic=[True, False])
    grid_cyl = grids.CylindricalGrid(2, (0, 2), (2, 2), periodic_z=False)
    grid_sph = grids.SphericalGrid(2, 2)
    assert grid_cart._cache_hash() != grid_cyl._cache_hash(
    ) != grid_sph._cache_hash()

    for with_, only_periodic in itertools.product([False, True], repeat=2):
        num_expect = 2 if only_periodic else 8
        num_expect += 1 if with_ else 0
        ps = grid_cart.iter_mirror_points([1, 1], with_, only_periodic)
        assert len(list(ps)) == num_expect

        num_expect = 0 if only_periodic else 2
        num_expect += 1 if with_ else 0
        ps = grid_cyl.iter_mirror_points([0, 0, 1], with_, only_periodic)
        assert len(list(ps)) == num_expect

        num_expect = 1 if with_ else 0
        ps = grid_sph.iter_mirror_points([0, 0, 0], with_, only_periodic)
        assert len(list(ps)) == num_expect