Skip to content

Commit f70e0e6

Browse files
reoxSebastian Bachmannpre-commit-ci[bot]
authored
Allow any negative number in the knot-vector (#476)
* Allow any negative number in the knot-vector This resolves #475 * use lowest() instead of min() to avoid edge case * adding test case for spline construction with uniform unclamped knots * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Sebastian Bachmann <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5de29f2 commit f70e0e6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/py/py_spline.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SOFTWARE.
2323
*/
2424

2525
#include <algorithm>
26+
#include <limits>
2627
#include <memory>
2728
#include <numeric>
2829
#include <string>
@@ -106,7 +107,7 @@ void PySpline::NewCore(const py::kwargs& kwargs) {
106107
knot_vector.reserve(n_knots);
107108

108109
int nknots{0};
109-
prev_knot = -1.;
110+
prev_knot = std::numeric_limits<double>::lowest();
110111
for (py::handle k : kvs[i_para]) {
111112
this_knot = k.cast<double>();
112113

tests/test_spline_constructors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ def test_BSplines(np_rng):
1414
knot_vectors=[[0, 0, 1, 1], [0, 0, 0.4, 0.5, 0.7, 1, 1]],
1515
control_points=np_rng.random((10, 2)),
1616
)
17+
# No assertion query; unclamped, uniform knot-vector
18+
splinepy.BSpline(
19+
degrees=[2, 2],
20+
knot_vectors=[
21+
[-4, -3, -2, -1, 0, 1, 2, 3, 4],
22+
[-15, -10, -5, 0, 5, 10, 15],
23+
],
24+
control_points=np_rng.random((6 * 4, 2)),
25+
)
1726
# Check control points
1827
with pytest.raises(
1928
RuntimeError,

0 commit comments

Comments
 (0)