Exemplo n.º 1
0
def test_instiantiate_with_plane():
    """Test that an image layer can be instantiated with plane parameters
    in a Plane.
    """
    plane = SlicingPlane(position=(32, 32, 32), normal=(1, 1, 1), thickness=22)
    image = Image(np.ones((32, 32, 32)), plane=plane)
    for k, v in plane.dict().items():
        assert v == getattr(image.plane, k, v)
Exemplo n.º 2
0
def test_update_slicing_plane_from_dict():
    properties = {
        'position': (0, 0, 0),
        'normal': (1, 0, 0),
    }
    plane = SlicingPlane()
    plane.update(properties)
    for k, v in properties.items():
        assert getattr(plane, k) == v
Exemplo n.º 3
0
def test_plane_3_tuple():
    """Test for failure to instantiate with non 3-sequences of numbers"""
    with pytest.raises(ValidationError):
        plane = SlicingPlane(  # noqa: F841
            position=(32, 32, 32, 32),
            normal=(1, 0, 0, 0),
        )
Exemplo n.º 4
0
def test_plane_from_array():
    pos = (0, 0, 0)
    norm = (0, 0, 1)
    array = np.array([pos, norm])
    plane = SlicingPlane.from_array(array)
    assert isinstance(plane, SlicingPlane)
    assert plane.position == pos
    assert plane.normal == norm
Exemplo n.º 5
0
def test_plane_to_array():
    pos = (0, 0, 0)
    norm = (0, 0, 1)
    array = np.array([pos, norm])
    plane = SlicingPlane(position=pos, normal=norm)
    assert np.allclose(plane.as_array(), array)