Skip to content

Commit

Permalink
Delete unnecessary check and add new test with assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
jzwar committed Jul 5, 2023
1 parent 6d651d5 commit d20a60b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
10 changes: 3 additions & 7 deletions cpp/splinepy/py/py_spline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,6 @@ class PySpline {
for (py::handle k : kv) {
this_knot = k.cast<double>();

// can't be negative
if (this_knot < 0) {
splinepy::utils::PrintAndThrowError("Parametric dimension (",
kv_dim,
")",
"includes negative knot.");
}
// must be increasing
if (prev_knot - this_knot > 0) {
splinepy::utils::PrintAndThrowError(
Expand Down Expand Up @@ -204,6 +197,9 @@ class PySpline {
nknots,
"were given.");
}

// Only use closed knot-vectors

// multiply expected control mesh resolution
required_ncps *= nknots - degrees_ptr[kv_dim] - 1;

Expand Down
26 changes: 26 additions & 0 deletions tests/test_spline_constructors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
try:
from . import common as c
except BaseException:
import common as c


class TestSplineConstructors(c.unittest.TestCase):
"""Perform checks and see if spline data is coherent"""

def testBSplines(self):
"""
Perform checks on BSpline class
"""
self.assertRaisesRegex(
RuntimeError,
"SPLINEPY ERROR - Invalid number of control points. 2 exepcted, "
"but 0 were given.",
c.splinepy.BSpline,
degrees=[1],
knot_vectors=[[0, 0, 1, 1]],
control_points=c.np.ones((0, 0)),
)


if __name__ == "__main__":
c.unittest.main()

0 comments on commit d20a60b

Please sign in to comment.