def test_signed_fit_transform_plot(): SignedDistanceFiltration().fit_transform_plot(images_2D, sample=0)
def test_signed_transform(n_iterations, images, expected): signed = SignedDistanceFiltration(n_iterations=n_iterations) assert_almost_equal(signed.fit_transform(images), expected)
def test_signed_not_fitted(): signed = SignedDistanceFiltration() with pytest.raises(NotFittedError): signed.transform(images_2D)
def test_signed_errors(): n_iterations = 'a' signed = SignedDistanceFiltration(n_iterations=n_iterations) with pytest.raises(TypeError): signed.fit(images_2D)
images_2D = np.stack([np.ones((3, 4)), np.concatenate([np.ones((3, 2)), np.zeros((3, 2))], axis=1), np.zeros((3, 4))], axis=0) images_3D = np.stack([np.ones((3, 4, 2)), np.concatenate([np.ones((3, 2, 2)), np.zeros((3, 2, 2))], axis=1), np.zeros((3, 4, 2))], axis=0) @pytest.mark.parametrize("transformer", [HeightFiltration(), RadialFiltration(), DilationFiltration(), ErosionFiltration(), SignedDistanceFiltration(), DensityFiltration()]) def test_invalid_input_shape(transformer): X = np.ones((1, 1, 1, 1, 1)) with pytest.raises(ValueError, match="Input of `fit`"): transformer.fit(X) def test_height_not_fitted(): height = HeightFiltration() with pytest.raises(NotFittedError): height.transform(images_2D) def test_height_errors(): direction = 'a' height = HeightFiltration(direction=direction)