{"id":6249,"library":"splinebox","title":"Splinebox","description":"Splinebox is an open-source Python package for fitting splines. It offers a wide variety of spline types, including Hermite splines, and makes it easy to specify custom loss functions to control spline properties such as smoothness. Currently at version 0.5.1, the library is actively developed with a steady release cadence.","status":"active","version":"0.5.1","language":"en","source_language":"en","source_url":"https://github.com/EPFL-Center-for-Imaging/splinebox","tags":["spline","fitting","interpolation","geometry","numerical","computer-vision"],"install":[{"cmd":"pip install splinebox","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Essential for array manipulation and numerical operations in typical spline fitting workflows.","package":"numpy","optional":true},{"reason":"Commonly used for plotting splines and their properties, as shown in examples.","package":"matplotlib","optional":true},{"reason":"Used for optimization in fitting routines and for comparison with SciPy's spline implementations.","package":"scipy","optional":true}],"imports":[{"symbol":"splinebox","correct":"import splinebox"},{"note":"The Spline class is located within the splinebox.spline_curves submodule, not directly under splinebox.","wrong":"import splinebox.Spline","symbol":"Spline","correct":"from splinebox.spline_curves import Spline"},{"note":"Basis functions like B3 are located within the splinebox.basis_functions submodule.","wrong":"import splinebox.B3","symbol":"B3","correct":"from splinebox.basis_functions import B3"}],"quickstart":{"code":"import splinebox\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Define the number of knots and the basis function\nn_knots = 4\nbasis_function = splinebox.basis_functions.B3()\n\n# Create a closed cubic B-spline with initial knots\nspline = splinebox.spline_curves.Spline(M=n_knots, basis_function=basis_function, closed=True)\nspline.knots = np.array([[1, 2], [3, 2], [4, 3], [1, 1]])\n\n# Evaluate the spline at parameter values\nt = np.linspace(0, n_knots, 100) # Parameter values along the spline\nvals = spline(t, derivative=0) # Get the spline points\n\n# Plot the spline and its knots\nplt.figure(figsize=(6, 6))\nplt.scatter(spline.knots[:, 0], spline.knots[:, 1], color='red', marker='o', label='Knots')\nplt.plot(vals[:, 0], vals[:, 1], color='blue', label='Spline Curve')\nplt.title('Splinebox Quickstart Example')\nplt.xlabel('X-coordinate')\nplt.ylabel('Y-coordinate')\nplt.grid(True)\nplt.legend()\nplt.axis('equal')\nplt.show()","lang":"python","description":"This quickstart demonstrates how to create and visualize a closed cubic B-spline using Splinebox. It defines a set of control points (knots), instantiates a Spline object with a B3 basis function, evaluates the spline along a range of parameter values, and then plots both the knots and the resulting spline curve using Matplotlib."},"warnings":[{"fix":"Replace `spline.eval(t)` with `spline(t)` for evaluating the spline.","message":"The `eval` method on `Spline` and `HermiteSpline` classes is deprecated. Direct calling of the spline object (`spline(t)`) should be used instead.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Code should explicitly handle the expected shape of spline outputs, e.g., by checking `output.shape` or using explicit reshaping, rather than relying on automatic squeezing.","message":"A future warning indicates an upcoming change in the 'squeeze' policy for outputs. This means the default behavior for reshaping single-dimensional outputs might change, potentially affecting code that implicitly relies on the current squeezing behavior.","severity":"breaking","affected_versions":">=0.5.0 (warning issued), future major versions (breaking change)"},{"fix":"Ensure that parameter arrays passed to `moving_frame` are sorted, especially if using older versions. Upgrade to v0.5.1 or newer to benefit from the fix.","message":"When using `moving_frame` for unsorted arrays of parameters, versions prior to 0.5.1 could produce incorrect results. This was fixed in v0.5.1.","severity":"gotcha","affected_versions":"<0.5.1"},{"fix":"When migrating from or comparing with SciPy, be aware that Splinebox simplifies these aspects, so manual pre-computation is generally not needed and can lead to incorrect results if misapplied.","message":"Splinebox automatically handles periodicity and padding for closed splines. This differs from `scipy.interpolate.splprep`, which requires manual pre-computation of parameter values for knots and data points, accounting for padding and periodicity.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}