Skip to main content

Extensible Splines

PyPI version Package Publish codecov

Python Spline Interpolation. Interactive plot for quick testing of new spline kernels or control point usage.

Why?

If you look at the source of extensible_splines/splines.py you will notice that the most commonly used varieties of spline can be defined with only one or two of four possible overloads or attribute definitions relative to the base class.

  1. The kernel itself. That is, the square matrix by which we will multiply the powers of the parameter--in the form of a vector.
  2. The scaling factor. This defaults to 1.0, but supplying a value on the open unit interval is fine.
  3. Any filter on the segments themselves.
  4. How to transform the knots. In the case of the Hermite spline, this is p0, (δx,δy), p2, (δx,δy). Points p0 and p2 are unchanged, but p1 and p3 are tranformed to relative offsets from p0 and p2, respectively.

Installation

pip install extensible-splines

Usage

bspline_usage

Create an instance of SplineMatrix

For example:

my_kernel = SplineMatrix(np.array([[1, 0, 0, 0],[0, 1, 0, 0],[-3, -2, 3, -1],[2, 1, -2, 1]],float))

Define a Subclass of BaseSpline

This can be as simple as (1) defining the abstract methods with super calls and (2) passing the kernel to the base constructor.

class MySpline(BaseSpline):
    def __init__(self) -> None:
        super().__init__(my_kernel)
    
    def filter_segments(self, raw_segments: Iterable[Tuple[Tuple[int, int]]]):
        return super().filter_segments(raw_segments)

    def transform_control_points(self, points: Tuple[Tuple[int, int]]) -> np.ndarray:
        return super().transform_control_points(points)

Notice that other than super() calls and type hinting, the kernel is the only aspect of the type definition to be handled above.

Test the New Spline Interactively

# Kernel instance and Spline class go here
# ....
##

def main():
    editor = interactive.SplineEditor(MySpline())
    editor.init_figure(caption='Testing New Splines')


if __name__ == '__main__':
    main()

Metadata

Release files for extensible-splines 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extensible-splines 0.2.1
File Size Uploaded Provenance Actions
extensible_splines-0.2.1.tar.gz 9.2 kB Without provenance Details for extensible_splines-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for extensible-splines 0.2.1
File Interpreter ABI Platform Actions
extensible_splines-0.2.1-py3-none-any.whl Python 3 none any Details for extensible_splines-0.2.1-py3-none-any.whl

Total release size: 17.2 kB

Release files / extensible_splines-0.2.1.tar.gz

Download URL extensible_splines-0.2.1.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b98115d3539ae49ebb266d78a8a65ce57b87f1695ab529fe1409475ea995c5fc
BLAKE2b-256 checksum
How to use checksums
96f667d3d353662106f2af5931cda621a6fdd14fe23d48aed74f7edeeff83255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / extensible_splines-0.2.1-py3-none-any.whl

Download URL extensible_splines-0.2.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4070cf8a53941daf0ab2a3fa12a4ea35fc1c59c7e8ac85d7cb193b33105a8fdd
BLAKE2b-256 checksum
How to use checksums
9ed645ac122488c4f5f06ce09cd8f53df8e75335a12950a016c085ae96e72bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for extensible-splines 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page