Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New submodule for feret calculations #755

Merged
merged 40 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0dc8519
New submodule for feret calculations
ns-rse Dec 8, 2023
ecebf27
Import annotations from __future__ to support type hints
ns-rse Dec 11, 2023
beb1a98
Merge branch 'main' into ns-rse/748-grain-profiles
ns-rse Dec 11, 2023
0f6333c
Merge branch 'main' into ns-rse/748-grain-profiles
ns-rse Dec 19, 2023
65c9f29
Simplifies tests and adds additional smaller examples
ns-rse Jan 3, 2024
d7c65bc
Merge branch 'main' into ns-rse/748-grain-profiles
ns-rse Jan 3, 2024
222ada2
codespell corrections
ns-rse Jan 4, 2024
83fee0f
Investigating why rotating calipers fail on linear
ns-rse Jan 11, 2024
9b9ef7d
Merge branch 'main' into ns-rse/748-grain-profiles
ns-rse Jan 19, 2024
3f728f9
Restore cmap to config; simpler config of cmap/dpi/image format
ns-rse Jan 12, 2024
e7db2c4
Restore cmap to config; simpler config of cmap/dpi/image format
ns-rse Jan 12, 2024
dd64f6e
Update docs/configuration.md
ns-rse Jan 22, 2024
c3dea45
Update topostats/validation.py
ns-rse Jan 22, 2024
e6259d5
Update topostats/topostats.mplstyle
ns-rse Jan 22, 2024
e843ea4
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Jan 22, 2024
407bf1b
PR Feedback
ns-rse Jan 22, 2024
6336f35
Addressing further PR feedback.
ns-rse Jan 24, 2024
bfc2551
pytest<8.0.0
ns-rse Jan 29, 2024
143884b
[pre-commit.ci] pre-commit-autoupdate
pre-commit-ci[bot] Feb 5, 2024
c2e6223
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Feb 5, 2024
78050b3
Explicitly disable ruff S403; disable ruff preview rules
ns-rse Feb 6, 2024
f86fbdd
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Feb 6, 2024
d6d542d
Adds sort_coords function and updates some tests
ns-rse Jan 23, 2024
035c522
Fixes errors with rotating calipers
ns-rse Jan 24, 2024
8e7cf2c
Merge branch 'main' into ns-rse/748-grain-profiles
ns-rse Feb 13, 2024
0f1f1ab
Fixes errors with rotating calipers
ns-rse Jan 24, 2024
6ddf1f0
Fixes errors with rotating calipers
ns-rse Jan 24, 2024
00e9da6
Fixes errors with rotating calipers
ns-rse Jan 24, 2024
2c1dfaa
Test ValueError raised when axis is incorrectly specified
ns-rse Feb 14, 2024
68beb68
Calculate and test finding mid-point on base of feret triangles
ns-rse Feb 16, 2024
68b3736
Updates tests of min feret coordinates; adds function to plot
ns-rse Feb 16, 2024
6566ea9
Switch to vector projection method for triangle heights
ns-rse Feb 19, 2024
f6e4945
Exclude triangle heights (min feret) if outside hull
ns-rse Feb 26, 2024
1d25dab
Adding Shapely to package dependencies
ns-rse Feb 26, 2024
e464f25
Add tests for `measure.feret.plot_feret()`
ns-rse Feb 27, 2024
3fff00e
Numpydoc validation
ns-rse Mar 6, 2024
066f4c5
Switching to Ray Tracer for points in polygon
ns-rse Mar 12, 2024
f964cf1
Just return min/max feret distances and coordinates
ns-rse Mar 22, 2024
2c50bdb
Just return min/max feret distances and coordinates
ns-rse Mar 22, 2024
4e3db2e
Just return min/max feret distances and coordinates
ns-rse Mar 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,360 changes: 1,360 additions & 0 deletions tests/measure/test_feret.py

Large diffs are not rendered by default.

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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 68 additions & 3 deletions tests/test_grainstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,72 @@ def test_grainstats_get_triangle_height(base_point_1, base_point_2, top_point, e
assert GrainStats.get_triangle_height(base_point_1, base_point_2, top_point) == expected


@pytest.mark.parametrize(("edge_points", "expected"), [([[0, 0], [0, 1], [1, 0], [1, 1]], (1.0, 1.4142135623730951))])
def test_get_min_max_ferets(edge_points, expected) -> None:
@pytest.mark.parametrize(
("edge_points", "min_expected", "max_expected"),
[
pytest.param([[0, 0], [0, 1], [1, 0], [1, 1]], 1.0, 1.4142135623730951, id="square"),
pytest.param([[1, 1], [1, 2], [2, 1]], 0.7071067811865476, 1.4142135623730951, id="triangle (isosceles)"),
pytest.param([[0, 0], [1, 0], [0, 2]], 0.8944271909999159, 2.23606797749979, id="triangle"),
pytest.param([[0, 1], [1, 0], [1, 2], [2, 1]], 1.4142135623730951, 2.0, id="circle"),
pytest.param([[1, 2], [2, 1], [2, 4], [5, 2]], 2.4961508830135313, 4, id="quadrilateral"),
pytest.param(
[
[1, 3],
[1, 4],
[1, 5],
[1, 6],
[1, 7],
[2, 2],
[2, 8],
[3, 1],
[3, 9],
[4, 1],
[4, 9],
[5, 1],
[5, 9],
[6, 2],
[6, 8],
[7, 3],
[7, 4],
[7, 5],
[7, 6],
[7, 7],
],
6.0,
8.246211251235321,
id="horizontal ellipse",
),
pytest.param(
[
[1, 2],
[1, 3],
[1, 4],
[2, 1],
[2, 5],
[3, 2],
[3, 6],
[4, 3],
[4, 7],
[5, 4],
[5, 8],
[6, 5],
[6, 6],
[6, 7],
],
2.82842712474619,
7.615773105863909,
id="angled ellipse",
),
pytest.param(
[[1, 5], [2, 3], [2, 4], [3, 2], [4, 1], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5], [7, 6], [8, 7], [8, 8]],
5.252257314388902,
8.06225774829855,
id="curved line",
),
],
)
def test_get_min_max_ferets(edge_points, min_expected, max_expected) -> None:
"""Tests the GrainStats.get_min_max_ferets method."""
assert GrainStats.get_max_min_ferets(edge_points) == expected
min_feret, max_feret = GrainStats.get_max_min_ferets(edge_points)
np.testing.assert_almost_equal(min_feret, min_expected)
np.testing.assert_almost_equal(max_feret, max_expected)
2 changes: 0 additions & 2 deletions topostats/grainstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,6 @@ def get_max_min_ferets(edge_points: list): # noqa: C901

upper_hull = np.array(upper_hull)
lower_hull = np.array(lower_hull)

# Create list of contact vertices for calipers on the antipodal hulls
contact_points = []
upper_index = 0
Expand Down Expand Up @@ -1081,7 +1080,6 @@ def get_max_min_ferets(edge_points: list): # noqa: C901
min_feret = small_feret

contact_points = np.array(contact_points)

# Find the minimum and maximum distance in the contact points
max_feret = None
for point_pair in contact_points:
Expand Down
Loading
Loading