Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sanity check for addition operator, to make sure the two spline…
…s added share the same underlying triangle, and the same degree.
- Loading branch information
Showing
2 changed files
with
60 additions
and
15 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,39 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from SSplines import SplineFunction, SplineSpace | ||
|
||
|
||
def test_spline_function_add_validation(): | ||
t1 = np.array([ | ||
[0, 0], | ||
[1, 0], | ||
[0.5, np.sqrt(3) / 2] | ||
]) | ||
t2 = np.array([ | ||
[0, 0], | ||
[1, 0], | ||
[0.6, np.sqrt(3) / 2] | ||
]) | ||
|
||
c1 = np.ones(12) | ||
c2 = np.ones(12) | ||
c3 = np.ones(10) | ||
d1 = 2 | ||
d2 = 2 | ||
d3 = 1 | ||
|
||
s1 = SplineFunction(t1, d1, c1) | ||
s2 = SplineFunction(t2, d2, c2) | ||
s3 = SplineFunction(t2, d3, c3) | ||
|
||
with pytest.raises(ValueError): | ||
s1 + s2 | ||
|
||
with pytest.raises(ValueError): | ||
s2 + s3 | ||
|
||
try: | ||
s1 + s1 | ||
except ValueError: | ||
pytest.fail('An error is raised when the splines are compatible.') |