Skip to content

Commit

Permalink
Added test for SimplexSpline.__call__ using both cartesian and
Browse files Browse the repository at this point in the history
barycentric coordinates. Made a modification to __call__
in order to support evaluation at single points.
  • Loading branch information
qTipTip committed Aug 16, 2018
1 parent ea67077 commit 7c12128
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SSplines/simplex_spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from SSplines.dicts import KNOT_CONFIGURATION_TO_FACE_INDICES
from SSplines.helper_functions import barycentric_coordinates, determine_sub_triangle, \
points_from_barycentric_coordinates
points_from_barycentric_coordinates, simplex_spline_graphic_small
from SSplines.symbolic import polynomial_pieces


Expand Down Expand Up @@ -40,3 +40,9 @@ def __call__(self, y, exact=False, barycentric=False):
else:
return np.array([self.polynomial_pieces[k[i]].subs({'X': x[i][0], 'Y': x[i][1]}) for i in range(len(x))],
dtype=np.float)

def display(self):
"""
Displays the SimplexSpline using graphical notation.
"""
simplex_spline_graphic_small(self.knot_multiplicities)
18 changes: 18 additions & 0 deletions tests/test_exact_arithmetic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np

from SSplines import barycentric_coordinates


def test_barycentric_coordinates():
triangle = np.array([
[0, 0],
[1, 0],
[0, 1]
])
x = np.array([0.5, 0.5])

b_numerical = barycentric_coordinates(triangle, x, exact=False)
b_exact = barycentric_coordinates(triangle, x, exact=True)

for num, exac in zip(b_numerical, b_exact):
np.testing.assert_almost_equal(num, exac)

0 comments on commit 7c12128

Please sign in to comment.