示例#1
0
 def func(shape, xreflection, yreflection):
     actual = create_grid(shape,
                          spacing,
                          xreflection=xreflection,
                          yreflection=yreflection,
                          center=origin)
     expected = create_grid_slow(shape,
                                 spacing,
                                 xreflection=xreflection,
                                 yreflection=yreflection,
                                 center=origin)
     assert_same(actual, expected)
示例#2
0
def test_layout_grid():
    shape = (3, 2)
    spacing = Quantity(0.1, 'mm')
    xreflection = True
    yreflection = True
    origin = (1, 1)
    angle = 10
    center = create_grid(shape, spacing, center=origin,
                         xreflection=xreflection, yreflection=yreflection,
                         angle=angle)
    layout = LayoutGrid(
        shape, spacing, origin=origin, xreflection=xreflection,
        yreflection=yreflection, angle=angle)
    assert not hasattr(layout, 'nvertices')
    assert_same(layout.all.center, center)
    assert_same(layout.all.removed, np.zeros(shape, bool))
示例#3
0
def test_layout_grid_circles():
    shape = (3, 2)
    spacing = 0.1
    xreflection = True
    yreflection = True
    origin = (1, 1)
    angle = 10
    center = create_grid(
        shape, spacing, center=origin, xreflection=xreflection,
        yreflection=yreflection, angle=angle)
    layout = LayoutGrid(
        shape, spacing, origin=origin, xreflection=xreflection,
        yreflection=yreflection, angle=angle, radius=spacing/2)
    assert not hasattr(layout, 'nvertices')
    assert_same(layout.radius, spacing / 2)
    assert_same(layout.all.center, center)
    assert_same(layout.all.removed, np.zeros(shape, bool))
示例#4
0
def test_layout_grid():
    shape = (3, 2)
    spacing = Quantity(0.1, 'mm')
    xreflection = True
    yreflection = True
    origin = (1, 1)
    angle = 10
    center = create_grid(shape,
                         spacing,
                         center=origin,
                         xreflection=xreflection,
                         yreflection=yreflection,
                         angle=angle)
    layout = LayoutGrid(shape,
                        spacing,
                        origin=origin,
                        xreflection=xreflection,
                        yreflection=yreflection,
                        angle=angle)
    assert not hasattr(layout, 'nvertices')
    assert_same(layout.all.center, center)
    assert_same(layout.all.removed, np.zeros(shape, bool))
示例#5
0
def test_layout():
    shape = (4, 4)
    center = create_grid(shape, 0.1)
    get_center = lambda: center.reshape(-1, 2)

    class Spatial1(Layout):
        @property
        def center(self):
            return get_center()

    class Spatial2(Layout):
        def center(self):
            return get_center()

    layouts = (Layout(shape, center=center),
               Layout(shape, center=get_center),
               Spatial1(shape), Spatial2(shape))

    def func(layout):
        assert_same(layout.center, center.reshape(-1, 2))
        assert_same(layout.all.center, center)
    for layout in layouts:
        yield func, layout
示例#6
0
def test_layout():
    shape = (4, 4)
    center = create_grid(shape, 0.1)
    get_center = lambda: center.reshape(-1, 2)

    class Spatial1(Layout):
        @property
        def center(self):
            return get_center()

    class Spatial2(Layout):
        def center(self):
            return get_center()

    layouts = (Layout(shape, center=center), Layout(shape, center=get_center),
               Spatial1(shape), Spatial2(shape))

    def func(layout):
        assert_same(layout.center, center.reshape(-1, 2))
        assert_same(layout.all.center, center)

    for layout in layouts:
        yield func, layout
示例#7
0
def test_layout_grid_circles():
    shape = (3, 2)
    spacing = 0.1
    xreflection = True
    yreflection = True
    origin = (1, 1)
    angle = 10
    center = create_grid(shape,
                         spacing,
                         center=origin,
                         xreflection=xreflection,
                         yreflection=yreflection,
                         angle=angle)
    layout = LayoutGrid(shape,
                        spacing,
                        origin=origin,
                        xreflection=xreflection,
                        yreflection=yreflection,
                        angle=angle,
                        radius=spacing / 2)
    assert not hasattr(layout, 'nvertices')
    assert_same(layout.radius, spacing / 2)
    assert_same(layout.all.center, center)
    assert_same(layout.all.removed, np.zeros(shape, bool))
示例#8
0
 def func(shape, xreflection, yreflection):
     actual = create_grid(shape, spacing, xreflection=xreflection,
                          yreflection=yreflection, center=origin)
     expected = create_grid_slow(shape, spacing, xreflection=xreflection,
                                 yreflection=yreflection, center=origin)
     assert_same(actual, expected)