-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from autotwin/spheres
Spheres
- Loading branch information
Showing
12 changed files
with
251 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
book/examples/spheres/spheres_ball_1_.inp → book/examples/spheres/spheres_sphere_1.inp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
book/examples/spheres/spheres_ball_3_.inp → book/examples/spheres/spheres_sphere_3.inp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
book/examples/spheres/spheres_ball_5_.inp → book/examples/spheres/spheres_sphere_5.inp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
"""This module performs point testing of the sphere module. | ||
Example | ||
------- | ||
> python -m pytest book/examples/spheres/test_spheres.py | ||
""" | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
import spheres as sph | ||
|
||
|
||
def test_sphere(): | ||
"""Unit tests for the sphere function.""" | ||
|
||
# Assure that radius >=1 assert is raised | ||
with pytest.raises(ValueError, match="Radius must be >= 1"): | ||
sph.sphere(radius=0) | ||
|
||
# Assure radius=1 is correct | ||
gold_r1 = np.array( | ||
[ | ||
[[0, 0, 0], [0, 1, 0], [0, 0, 0]], | ||
[[0, 1, 0], [1, 1, 1], [0, 1, 0]], | ||
[[0, 0, 0], [0, 1, 0], [0, 0, 0]], | ||
], | ||
dtype=np.uint8, | ||
) | ||
|
||
result_r1 = sph.sphere(radius=1) | ||
assert np.all(gold_r1 == result_r1) | ||
|
||
# Assure radius=2 is correct | ||
gold_r2 = np.array( | ||
[ | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 1, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[1, 1, 1, 1, 1], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 1, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
], | ||
dtype=np.uint8, | ||
) | ||
|
||
result_r2 = sph.sphere(radius=2) | ||
assert np.all(gold_r2 == result_r2) | ||
|
||
# Assure radius=3 is correct | ||
gold_r3 = np.array( | ||
[ | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 1, 1, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 1, 0, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[1, 1, 1, 1, 1, 1, 1], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 0, 1, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 1, 1, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0], | ||
], | ||
], | ||
dtype=np.uint8, | ||
) | ||
|
||
result_r3 = sph.sphere(radius=3) | ||
assert np.all(gold_r3 == result_r3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ dev = [ | |
'pycodestyle', | ||
'pytest', | ||
'pytest-cov', | ||
'scikit-image', | ||
] | ||
|
||
[project.urls] | ||
|