Skip to main content

coshape

Shape-preserving 1-D spline interpolation, implemented in Rust.

Given concave data the fitted spline passes through the knots exactly, keeps f'' <= 0 everywhere, and is at least C². Convex data gives the mirror image; the tension and variable-degree methods also follow data that changes curvature.

import array
from coshape import EndSlopes, Tension

x = array.array("d", [0.0, 1.0, 2.0, 3.0, 4.0])    # any float64 buffer, e.g. numpy
y = array.array("d", [0.0, 4.0, 7.0, 7.5, 7.9])    # concave

fitter = Tension().with_boundary(EndSlopes.clamped(4.5, 0.3))   # configuration only
spline = fitter.fit(x, y)                                     # a separate, fitted object

spline(2.5)                           # value
spline.second_derivative(2.5)         # <= 0 on concave data

grid = array.array("d", (i / 100 for i in range(401)))
spline.value_batch(grid)                   # a new array.array('d')
out = array.array("d", bytes(8 * len(grid)))
spline.value_batch_into(grid, out)         # fills your buffer, no allocation
Fitter Produces Method
RationalCubic RationalCubicSpline convexity/concavity-preserving C² rational cubic (Abbas–Majid–Ali)
Tension TensionSpline exponential tension spline (Renka, TSPACK); with_uniform_tension(sigma) for a fixed factor
VariableDegree VariableDegreeSpline co-convex C² variable-degree polynomial spline (Kaklis–Pandelis); accepts inflections

Fitters are immutable: each with_* returns a new fitter. Arrays go through the buffer protocol — numpy float64 arrays, array.array('d'), or memoryviews of them — with no numpy dependency, which is why Python 3.11 or newer is required. Invalid data raises ValueError. Type stubs are included.

Dual-licensed under MIT OR Apache-2.0. Source: https://github.com/Feiyang472/coshape

Release files for coshape 0.0.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 coshape 0.0.1
File Size Uploaded
coshape-0.0.1.tar.gz 255.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for coshape 0.0.1
File
coshape-0.0.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
coshape-0.0.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
coshape-0.0.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
coshape-0.0.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
coshape-0.0.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 1.7 MB

Release files / coshape-0.0.1.tar.gz

Download URL coshape-0.0.1.tar.gz
Size 255.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7f0082bdfa68b06cd66c7c88823e7b1e3e15bb009463809261db5f1e67de5222
BLAKE2b-256 checksum
How to use checksums
b2a0ce31b69e8dee5f09f7ae64ccd2e6bdd5236243578fec801c09dee4bbc238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / coshape-0.0.1-cp311-abi3-win_amd64.whl

Download URL coshape-0.0.1-cp311-abi3-win_amd64.whl
Size 202.3 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c2437cd4d045c160c2407ba1d6a687794b784f8e2623090055a2d94cfb76faba
BLAKE2b-256 checksum
How to use checksums
5a3af31bb573d91ad9c89b48af6f882684d9aaabf5cf8dab94ae559a16c8d854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / coshape-0.0.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL coshape-0.0.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 345.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3fba169beb87aeddb1fa7189fe80365c94c103d60f7e4daad2ee092b3614948f
BLAKE2b-256 checksum
How to use checksums
ecbb498f99ccc4e8de42da2fe9fdcd053ffb89471b1d7318dfc23cc92c0f82ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / coshape-0.0.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL coshape-0.0.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 338.7 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8777c8b6103c49b8d62501868c0e673cd2820ddb5477667339d4f5b2aaeb0a23
BLAKE2b-256 checksum
How to use checksums
2a5cfa929a64e594e7b0bac3e625ee4f8b988ddb080e33d705d338e551b9edf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / coshape-0.0.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL coshape-0.0.1-cp311-abi3-macosx_11_0_arm64.whl
Size 301.1 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fa648a10bde647562b54df056e1ce768c81a9057e2e643972d6b513344b6c027
BLAKE2b-256 checksum
How to use checksums
ea76ff236b6a49153bf63ed62e8c557936ab789d65c676d940250fcab2cba309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / coshape-0.0.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL coshape-0.0.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 302.2 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
43ad4165654fb1dc3cfdb4b8184b80140bf649a6789c604d2b6f73a28ec76be1
BLAKE2b-256 checksum
How to use checksums
90b8588ba765d38b7d56b515212e12349c9fe00173f1665d83d7d60d428ee994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.0.1 This release

6 release files

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