Skip to content

Commit aa79bba

Browse files
authored
Merge pull request #441 from tataratat/bf-extract-spline
extend allowed input types in `extract.spline()`
2 parents 0b7bedc + 4be0428 commit aa79bba

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

splinepy/helpme/extract.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -433,22 +433,14 @@ def spline(spline, para_dim, split_plane):
433433
"Requested parametric dimension exceeds spline's parametric"
434434
" dimensionality."
435435
)
436-
if isinstance(split_plane, list):
437-
if not (
438-
(len(split_plane) == 2)
439-
and (isinstance(split_plane[0], float))
440-
and (isinstance(split_plane[1], float))
441-
):
442-
raise ValueError(
443-
"Range must be float or tuple of floats with length 2"
444-
)
445-
elif not isinstance(split_plane, float):
446-
raise ValueError(
447-
"Range must be float or tuple of floats with length 2"
448-
)
449-
else:
450-
# Convert float to tuple to facilitate
451-
split_plane = [split_plane]
436+
437+
# create 1d array for easy type / size check
438+
split_plane = _np.asanyarray(split_plane).ravel()
439+
if not _np.issubdtype(split_plane.dtype, _np.floating):
440+
raise ValueError("split_plane must be floating type.")
441+
442+
if split_plane.size > 2:
443+
raise ValueError("split_plane must have size of 1 or 2.")
452444

453445
is_interval = len(split_plane) == 2
454446

0 commit comments

Comments
 (0)