Skip to content

Commit

Permalink
Merge branch 'main' into release-please--branches--main--components--…
Browse files Browse the repository at this point in the history
…ktch
  • Loading branch information
noshita authored Mar 10, 2024
2 parents 658775a + b0d6150 commit 834828b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###############################################################################
# NOTE: This file has been auto-generated by poetry2conda
# poetry2conda version = 0.3.0
# date: Fri Feb 9 00:53:13 2024
# date: Sun Mar 10 22:20:31 2024
###############################################################################
# If you want to change the contents of this file, you should probably change
# the pyproject.toml file and then use poetry2conda again to update this file.
Expand Down
28 changes: 28 additions & 0 deletions ktch/landmark/tests/test_Procrustes_analysis.py
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)
20 changes: 13 additions & 7 deletions ktch/outline/tests/test_elliptic_Fourier_analysis.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import numpy as np

from numpy.testing import assert_array_almost_equal
import pytest
from numpy.testing import assert_array_almost_equal

from ktch.datasets import (
load_outline_bottles,
load_coefficient_bottles,
convert_coords_df_to_list,
)
from ktch.datasets import load_coefficient_bottles, load_outline_bottles
from ktch.outline import EllipticFourierAnalysis

bottles = load_outline_bottles()
Expand All @@ -31,6 +26,17 @@ def test_data_prep_align():
assert_array_almost_equal(x_frame, x_list)


@pytest.mark.parametrize("norm", [False, True])
def test_efa_shape(norm):
n_harmonics = 6

X = bottles.coords
efa = EllipticFourierAnalysis(n_harmonics=n_harmonics)
X_transformed = efa.fit_transform(X, norm=norm)

assert X_transformed.shape == (len(X), 4 * (n_harmonics + 1))


@pytest.mark.parametrize("norm", [False, True])
@pytest.mark.parametrize("set_output", [None, "pandas"])
def test_efa(norm, set_output):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ license = "Apache-2.0"
name = "ktch"
readme = "README.md"
repository = "https://github.com/noshita/ktch"
version = "0.3.3"
version = "0.4.0"

[tool.poetry.dependencies]
numpy = ">=1.22"
Expand Down

0 comments on commit 834828b

Please sign in to comment.