-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into release-please--branches--main--components--…
…ktch
- Loading branch information
Showing
4 changed files
with
43 additions
and
9 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
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,28 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_array_almost_equal | ||
|
||
from ktch.datasets import load_landmark_mosquito_wings | ||
from ktch.landmark import GeneralizedProcrustesAnalysis, centroid_size | ||
|
||
data_landmark_mosquito_wings = load_landmark_mosquito_wings(as_frame=True) | ||
data_landmark_mosquito_wings.coords | ||
|
||
X = data_landmark_mosquito_wings.coords.to_numpy().reshape(-1, 18 * 2) | ||
|
||
|
||
def test_gpa_shape(): | ||
gpa = GeneralizedProcrustesAnalysis() | ||
gpa.fit_transform(X) | ||
X_transformed = gpa.fit_transform(X) | ||
|
||
assert X.shape == X_transformed.shape | ||
|
||
|
||
@pytest.mark.parametrize("n_dim", [2, 3]) | ||
def test_centroid_size(n_dim): | ||
x = np.random.uniform(0, 100, (10, n_dim)) | ||
cs_r = np.sqrt(np.sum((x - x.mean(axis=0)) ** 2)) | ||
cs_t = centroid_size(x) | ||
|
||
assert_array_almost_equal(cs_r, cs_t) |
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
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