Skip to content

Commit

Permalink
Added surface_interpolation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ojeda-e committed Jul 22, 2021
1 parent 70ad891 commit 8206fda
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions membrane_curvature/tests/test_membrane_curvature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import pytest
from membrane_curvature.surface import normalized_grid, derive_surface, get_z_surface
from membrane_curvature.surface import interpolation_by_array, normalized_grid, derive_surface, get_z_surface, surface_interpolation
from membrane_curvature.curvature import mean_curvature, gaussian_curvature
import numpy as np
from numpy.testing import assert_almost_equal
Expand Down Expand Up @@ -208,6 +208,39 @@ def test_get_z_surface(x_bin, y_bin, x_range, y_range, expected_surface):
assert_almost_equal(surface, expected_surface)


@pytest.mark.parametrize('dummy_surface, expected_interpolated_surface', [
# array 3x3 with all 150 and one nan
(np.array(([150., 150., 150.],
[150., np.nan, 150.],
[150., 150., 150.])),
np.full((3, 3), 150.)),
# array 4x3 with all 150 and two nans
(np.array([[150., 150, 150., 150.],
[150., np.nan, np.nan, 150.],
[150., 150., 150., 150.]]),
np.array([[150., 150, 150., 150.],
[150., 150., 150., 150.],
[150., 150., 150., 150.]])),
# array 4x4 ith all 150 and two nans
(np.array([[150., 150, 150., 150.],
[150., np.nan, np.nan, 150.],
[150., 130., 140., 150.],
[150., 150., 150., 150.]]),
np.array([[150., 150, 150., 150.],
[150., 140., 145., 150.],
[150., 130., 140., 150.],
[150., 150., 150., 150.]])),
# array 3x3 with lots of nans)
(np.array([[np.nan, np.nan, 150.],
[150, np.nan, 150.],
[np.nan, 150., np.nan]]),
np.full((3, 3), 150.))
])
def test_surface_interpolation(dummy_surface, expected_interpolated_surface):
surface = surface_interpolation(dummy_surface)
assert_almost_equal(surface, expected_interpolated_surface)


class TestMembraneCurvature(object):
@pytest.fixture()
def universe(self):
Expand Down Expand Up @@ -297,7 +330,6 @@ def test_analysis_mean(self, universe):
avg_mean = mc.results.average_mean
assert_almost_equal(avg_mean, expected_mean)


def test_analysis_mean_default_selection(self, universe):
expected_mean = np.array([[7.50000000e+00, 1.33985392e-01, 2.77315457e-04],
[-2.77315457e-04, -3.53944270e-01, -7.50000000e+00],
Expand All @@ -306,4 +338,4 @@ def test_analysis_mean_default_selection(self, universe):
n_x_bins=3,
n_y_bins=3).run()
avg_mean = mc.results.average_mean
assert_almost_equal(avg_mean, expected_mean)
assert_almost_equal(avg_mean, expected_mean)

0 comments on commit 8206fda

Please sign in to comment.