From 288a076a4ac9bb04d1a3403cfc95e4dea422bbff Mon Sep 17 00:00:00 2001 From: Miles Graham Date: Fri, 8 Nov 2024 11:00:43 +0000 Subject: [PATCH 1/2] updated tests --- tests/test_functions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_functions.py b/tests/test_functions.py index 6dd9e6e..a2c384c 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -2,20 +2,20 @@ import numpy as np def test_cone(): - mask = cone(100, 50, 50, 0, 1, "standard") + mask = cone(100, 50, 50, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) assert mask.sum() > np.pi * 24**2 * (50 / 3) # Volume of cone assert mask.sum() < np.pi * 25**2 * 50 # Volume of cylinder def test_cube(): - mask = cube(100, 50, 0, 0, 1, "standard") + mask = cube(100, 50, 0, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) # Test against volume of cube +- center and subpixel issues assert mask.sum() > 48**3 assert mask.sum() < 52**3 def test_cuboid(): - mask = cuboid(100, (50,40,30), 0, 0, 1, "standard") + mask = cuboid(100, (50,40,30), 0, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) # Test against volume of cuboid +- center and subpixel issues assert mask.sum() > 48 * 38 * 28 @@ -28,26 +28,26 @@ def test_cuboid(): # assert mask.sum() < 2 * np.pi * 25 * 50 # Area of cylinder def test_cylinder(): - mask = cylinder(100, 50, 50, 0, 0, 1, "standard") + mask = cylinder(100, 50, 50, 0, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) assert mask.sum() > np.pi * 25**2 * 48 # Volume of cylinder assert mask.sum() < np.pi * 25**2 * 51 # Volume of cylinder def test_ellipsoid(): - mask = ellipsoid(100, (50,40,30), 0, 0, 1, "standard") + mask = ellipsoid(100, (50,40,30), 0, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) # Test against volume of ellipsoid +- center and subpixel issues assert mask.sum() > 24 * 19 * 14 * 4/3 * np.pi assert mask.sum() < 26 * 21 * 16 * 4/3 * np.pi def test_sphere(): - mask = sphere(100, 50, 0, 0, 1, "standard") + mask = sphere(100, 50, 0, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) assert mask.sum() > 4/3 * np.pi * 24**3 # Volume of sphere assert mask.sum() < 4/3 * np.pi * 26**3 # Volume of sphere def test_tube(): - mask = tube(100, 50, 50, 0, 0, 1, "standard") + mask = tube(100, 50, 50, 0, 0, 1, "standard", [50,50,50]) assert mask.shape == (100, 100, 100) assert mask.sum() > np.pi * 24**2 * 48 # Volume of tube - assert mask.sum() < np.pi * 26**2 * 52 # Volume of tube \ No newline at end of file + assert mask.sum() < np.pi * 26**2 * 52 # Volume of tube From ca63aa2438c965dcaad9051335113af7e271ca94 Mon Sep 17 00:00:00 2001 From: Miles Graham Date: Fri, 8 Nov 2024 11:04:20 +0000 Subject: [PATCH 2/2] updated tests and fix to sphere (after the test failed) --- src/ttmask/sphere.py | 2 +- src/ttmask/tube.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ttmask/sphere.py b/src/ttmask/sphere.py index 377ddb3..57bdc29 100644 --- a/src/ttmask/sphere.py +++ b/src/ttmask/sphere.py @@ -22,7 +22,7 @@ def sphere( sphere_radius = sphere_diameter / 2 # establish our coordinate system and empty mask - coordinates_centered, mask, _ = box_setup(sidelength, centering, center) + coordinates_centered, mask = box_setup(sidelength, centering, center) # determine distances of each pixel to the center distance_to_center = np.linalg.norm(coordinates_centered, axis=-1) diff --git a/src/ttmask/tube.py b/src/ttmask/tube.py index 14c2c43..fad20c6 100644 --- a/src/ttmask/tube.py +++ b/src/ttmask/tube.py @@ -24,7 +24,7 @@ def tube( tube_radius = tube_diameter / 2 # establish our coordinate system and empty mask - coordinates_centered, mask, = box_setup(sidelength, centering, center) + coordinates_centered, mask = box_setup(sidelength, centering, center) #converting relative coordinates to xyz distances (i.e. not a negative number) : xyz_distances = np.abs(coordinates_centered)