def test_instantiate(default_res, default_trans, has_res, has_trans): if not has_res: default_res = None if not has_trans: default_trans = None assert CoordinateTransformer(default_res, default_trans)
def test_from_catmaid(default_coord_transformer, catmaid_mock): assert CoordinateTransformer.from_catmaid( catmaid_mock, None) == default_coord_transformer
def default_coord_transformer(default_res, default_trans): return CoordinateTransformer(default_res, default_trans)
def test_project_to_stack_orientation_xy(orientation, direction, expected): coord_trans = CoordinateTransformer(orientation=orientation) result = getattr(coord_trans, direction)({'z': 0, 'y': 1, 'x': 2}) assert result == expected
def test_can_validate_orientation_invalid(orientation, expected_exception): with pytest.raises(expected_exception): CoordinateTransformer(orientation=orientation)
def test_can_validate_orientation_valid(orientation): trans = CoordinateTransformer(orientation=orientation) assert trans.orientation == StackOrientation.XY assert trans.depth_dim == 'z'
def get_coord_transformer(self, stack_id_or_title=None): if stack_id_or_title is None: return CoordinateTransformer() else: stack_id = self._get_stack_id(stack_id_or_title) return CoordinateTransformer.from_catmaid(self._catmaid, stack_id)