Skip to main content

bpf4

wheels

About

bpf4 is a python library to operate with curves in 2D space.

Curves can be defined via breakpoints (break-point functions, hence the name) or using functions. Moreover, curves can be used to build other curves. bpf4 can be used to perform curve fitting, data analysis, plotting, etc. Its core is programmed in cython for efficiency.

Installation

pip install --upgrade bpf4

Documentation

The documentation is hosted at https://bpf4.readthedocs.io


Example

Find the intersection between two curves

from bpf4 import bpf  # this imports the api
a = bpf.spline((0, 0), (1, 5), (2, 3), (5, 10))  # each point (x, y)
b = bpf.expon((0, -10), (2,15), (5, 3), exp=3)
a.plot() # uses matplotlib
b.plot() 
zeros = (a - b).zeros()
import pylab
pylab.plot(zeros, a.map(zeros), 'o')

1

Features

Many interpolation types besides linear:

  • spline
  • univariate splie
  • pchip (hermite)
  • cosine
  • exponential
  • logarithmic
  • etc.

With the exception of curve-fitting bpfs (splines), interpolation types can be mixed, so that each segment has a different interpolation. Following from the example above:

c = (a + b).sin().abs()
# plot only the range (1.5, 4)
c[1.5:4].plot()  

2

Syntax support for shifting, scaling and slicing a bpf

a >> 2        # a shifted to the right
(a * 5) ^ 2   # scale the x coord by 2, scale the y coord by 5
a[2:2.5]      # slice only a portion of the bpf
a[::0.01]     # sample the bpf with an interval of 0.01

Derivation / Integration

from bpf4 import *
a = spline((0, 0), (1, 5), (2, 3), (5, 10))
deriv = a.derivative()
integr = a.integrated()

import matplotlib.pyplot as plt 
fig, axs = plt.subplots(3, 1, sharex=True, figsize=(16, 8), tight_layout=True)
a.plot(axes=axs[0], show=False)
deriv.plot(axes=axs[1], show=False)
integr.plot(axes=axs[2])


Mathematical operations

Max / Min

a = linear(0, 0, 1, 0.5, 2, 0)
b = expon(0, 0, 2, 1, exp=3)
a.plot(show=False, color="red", linewidth=4, alpha=0.3)
b.plot(show=False, color="blue", linewidth=4, alpha=0.3)
core.Max((a, b)).plot(color="black", linewidth=4, alpha=0.8, linestyle='dotted')

a = linear(0, 0, 1, 0.5, 2, 0)
b = expon(0, 0, 2, 1, exp=3)
a.plot(show=False, color="red", linewidth=4, alpha=0.3)
b.plot(show=False, color="blue", linewidth=4, alpha=0.3)
core.Min((a, b)).plot(color="black", linewidth=4, alpha=0.8, linestyle='dotted')

+, -, *, /

a = linear(0, 0, 1, 0.5, 2, 0)
b = expon(0, 0, 2, 1, exp=3)
a.plot(show=False, color="red", linewidth=4, alpha=0.3)
b.plot(show=False, color="blue", linewidth=4, alpha=0.3)
(a*b).plot(color="black", linewidth=4, alpha=0.8, linestyle='dotted')

a = linear(0, 0, 1, 0.5, 2, 0)
b = expon(0, 0, 2, 1, exp=3)
a.plot(show=False, color="red", linewidth=4, alpha=0.3)
b.plot(show=False, color="blue", linewidth=4, alpha=0.3)
(a**b).plot(color="black", linewidth=4, alpha=0.8, linestyle='dotted')

a = linear(0, 0, 1, 0.5, 2, 0)
b = expon(0, 0, 2, 1, exp=3)
a.plot(show=False, color="red", linewidth=4, alpha=0.3)
b.plot(show=False, color="blue", linewidth=4, alpha=0.3)
((a+b)/2).plot(color="black", linewidth=4, alpha=0.8, linestyle='dotted')

Building functions

A bpf can be used to build complex formulas

Fresnel's Integral: ( S(x) = \int_0^x {sin(t^2)} dt )

t = slope(1)
f = (t**2).sin()[0:10:0.001].integrated()
f.plot()

Polar plots

Any kind of matplotlib plot can be used. For example, polar plots are possible by creating an axes with polar=True

Cardiod: (\rho = 1 + sin(-\theta) )

from math import *
theta = slope(1, bounds=(0, 2*pi))
r = 1 + (-theta).sin()

ax = plt.axes(polar=True)
ax.set_rticks([0.5, 1, 1.5, 2]); ax.set_rlabel_position(38)
r.plot(axes=ax)

Flower 5: (\rho = 3 + cos(5 * \theta) )

theta = core.Slope(1, bounds=(0, 2*pi))
r = 3 + (5*theta).cos()

ax = plt.axes(polar=True)
r.plot(axes=ax)

Metadata

Release files for bpf4 1.14.0

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

Built distributions (wheels)

Table of built distributions (wheels) for bpf4 1.14.0
File
bpf4-1.14.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
bpf4-1.14.0-cp313-cp313-win32.whl CPython 3.13 CPython 3.13 Windows x86-32 Details
bpf4-1.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
bpf4-1.14.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
bpf4-1.14.0-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
bpf4-1.14.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
bpf4-1.14.0-cp312-cp312-win32.whl CPython 3.12 CPython 3.12 Windows x86-32 Details
bpf4-1.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
bpf4-1.14.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
bpf4-1.14.0-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
bpf4-1.14.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
bpf4-1.14.0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details
bpf4-1.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
bpf4-1.14.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
bpf4-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
bpf4-1.14.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
bpf4-1.14.0-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
bpf4-1.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
bpf4-1.14.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
bpf4-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details

Total release size: 17.9 MB

Release files / bpf4-1.14.0-cp313-cp313-win_amd64.whl

Download URL bpf4-1.14.0-cp313-cp313-win_amd64.whl
Size 446.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
c2787a3fda99c3f3525613e8305a6e4389520d0f09301ab0c269b9e256fe756d
BLAKE2b-256 checksum
How to use checksums
a5fa879d5453d0092830bc245880d06d4eada36994de74c168faf85e2a5b2a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp313-cp313-win32.whl

Download URL bpf4-1.14.0-cp313-cp313-win32.whl
Size 392.1 kB
Tags CPython 3.13 Windows x86-32
SHA-256 checksum
How to use checksums
274e152e873a0700cbce1c49b3cc16cdb9e07c9383bce5a228b8f9af954ccae9
BLAKE2b-256 checksum
How to use checksums
af6b6cb30fee1d7bb0803de0cc6c2b635c24ff62edf81b4070b5bc5e09b0881b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bpf4-1.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.7 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0b8b6fe2f2e1bd6fe31c80504756a58ea2490e625e9ab10aba8d8ab3033374b2
BLAKE2b-256 checksum
How to use checksums
50ea7e27acc7e29a6fb656fc04278678fd35570d5d2b4971b7b0684ab631cd9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL bpf4-1.14.0-cp313-cp313-macosx_11_0_arm64.whl
Size 461.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
612eea75b27e47d7529b638b9dcc5686141c4982e504374732ec75c118f95ee6
BLAKE2b-256 checksum
How to use checksums
5941fada1ea0677614274fb42b0222feaeff0878339fa5d0e4754276f9c1e456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp313-cp313-macosx_10_13_x86_64.whl

Download URL bpf4-1.14.0-cp313-cp313-macosx_10_13_x86_64.whl
Size 511.0 kB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
1486d26e98565571e5e49453233ffb9454b0c625c097386546ac5b052741b068
BLAKE2b-256 checksum
How to use checksums
d342d27aaff7e53af0a31921d81f771c4661c6081944d3cf265cdad018388074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp312-cp312-win_amd64.whl

Download URL bpf4-1.14.0-cp312-cp312-win_amd64.whl
Size 446.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
679ecf3db8614d75a4dad5a08cf52e086de08bf179800a784af3ab18724f3d2a
BLAKE2b-256 checksum
How to use checksums
8e87bd472226068ee132566cf4f7eefac3ffc1ad63dc5229c7c2130ea367f73c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp312-cp312-win32.whl

Download URL bpf4-1.14.0-cp312-cp312-win32.whl
Size 391.8 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
3652baf5819a795cd55e3ea9927ad5d67d4788aca1edb299dce10567f2fa551a
BLAKE2b-256 checksum
How to use checksums
de9bbe03b7467b1a5f2740dd555a14430ef4f3f2ec3857bed4aae2e63334d70e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bpf4-1.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.7 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3cbcaaa89297aa6890d52ac645ce3458eadb0a97446e192394c81cb6cfc058f3
BLAKE2b-256 checksum
How to use checksums
c86aa99add017dfa046cc2635cc20f614e5f7187a853aeb36440287351b901d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL bpf4-1.14.0-cp312-cp312-macosx_11_0_arm64.whl
Size 464.1 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28ffe800da12181b76555c8fe861a3971b0c329337f92b3cb7cd181662c411eb
BLAKE2b-256 checksum
How to use checksums
f589d0293d4cab2e293bedb34c1844af8facdfac12e92236fa543aaf301fef99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp312-cp312-macosx_10_13_x86_64.whl

Download URL bpf4-1.14.0-cp312-cp312-macosx_10_13_x86_64.whl
Size 513.8 kB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
a73d83ddd4803b9d0c9eb6cdb4f458bc98af6bfa2c2e77dd228547b0608c319c
BLAKE2b-256 checksum
How to use checksums
c42e6100130757baea0164c7fbaf201d7beeed6cc714db8d4ab0bbf7aae5ce0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp311-cp311-win_amd64.whl

Download URL bpf4-1.14.0-cp311-cp311-win_amd64.whl
Size 451.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
0c66963f8910a7427c5a770bc62b5110d11bfbc1c0ed366373b3b979c3c06424
BLAKE2b-256 checksum
How to use checksums
2e2b8bdf2a8f1c0c652a205dacc3e6adb502dd095ed50467392fcffa1db0b2bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp311-cp311-win32.whl

Download URL bpf4-1.14.0-cp311-cp311-win32.whl
Size 397.8 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
737e3bf0a8694dbbc45b10e2c07fd5985818843c135b10f6fd32b10633df29f2
BLAKE2b-256 checksum
How to use checksums
858596f4dbd109f016dac5d26623fd446ae32fdb541ecc85f22697a28eeae6da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bpf4-1.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.8 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e266ebbc8bfce04b8c034d60f1196e0e30e77bd6b6a2a8c00e272278fc4b8597
BLAKE2b-256 checksum
How to use checksums
283debf0e10205dd1fa3caebd3cb7c8b28390908f8df6277b8b52300e7b61cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL bpf4-1.14.0-cp311-cp311-macosx_11_0_arm64.whl
Size 462.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c72d3bbdf066c8e3453891f5a4953515dfc884c35d1803b7b2b7481068238bcc
BLAKE2b-256 checksum
How to use checksums
21596375826d254c72bdc417a7e7e61483fdffd919727a0806d40f42eda0eca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl

Download URL bpf4-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl
Size 512.8 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
3766555285c76178208233a719f59cecc7316e85932fc8da403eedb8739f150c
BLAKE2b-256 checksum
How to use checksums
7899e544d1aa3288459fc2512614e555c1752f103b4d0ea6cf2e3e936b5e884c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp310-cp310-win_amd64.whl

Download URL bpf4-1.14.0-cp310-cp310-win_amd64.whl
Size 446.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
b6e0f6ee2e3fdbcab97c20c3072a76a2dadb7248069ad221c41c00544297b4d1
BLAKE2b-256 checksum
How to use checksums
0f8439d5fadab3abb03f44b46332ee9eb59d0623b7d76ead8a0e8e4c51bc2c35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp310-cp310-win32.whl

Download URL bpf4-1.14.0-cp310-cp310-win32.whl
Size 396.5 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
3bc3d16aa1663db4b82b1808f4af3c65ca29896ceaa0f31d68a55227639d8aa1
BLAKE2b-256 checksum
How to use checksums
36a84894f320b5aafd1b9c60c0fd2a36f2d8287be11173e4a7dd6ea18b8f3c17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bpf4-1.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
96456c44cfa22158c03f7dd5949092e4af1dba41ad83191c18d3b617efc84ee1
BLAKE2b-256 checksum
How to use checksums
4aceb0808923dcc010e37329103d4da1bdd689bae333620e61791013509deee2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL bpf4-1.14.0-cp310-cp310-macosx_11_0_arm64.whl
Size 460.4 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
53201ca52c0ebfa1c4002add02e47726e591dc33c91395ba5f725d2aa28c55fc
BLAKE2b-256 checksum
How to use checksums
28920cedd3b5bee81d2d3cc1443bbdeb0926561a1c758fa5923e5bf53ae72967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / bpf4-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl

Download URL bpf4-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl
Size 509.7 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4f1a2592ad9c1ec47d677678bee13a77849623bbf95d2b415ba61a6e148cc570
BLAKE2b-256 checksum
How to use checksums
62b74cf20b9d3836c748274d27e2c1d7800575630c845bbdc6bdc208e3011b0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

1.14.0 This release

20 release files

1.9.1

20 release files

1.8.8

15 release files

1.8.5

16 release files

1.8.4

16 release files

1.8.3

12 release files

1.8.2

12 release files

1.8.1

13 release files

1.8.0

13 release files

1.7.2

13 release files

1.7.1

12 release files

1.7.0

13 release files

1.6.1

12 release files

1.5.3

12 release files

1.5.2

12 release files

1.4.2

12 release files

1.4.1

12 release files

1.4.0

12 release files

1.3.1

12 release files

1.3.0

13 release files

1.2.0

13 release files

1.1.0

15 release files

1.0.1

9 release files

1.0.0

9 release files

0.10.0

8 release files

0.9.3

10 release files

0.9.2

7 release files

0.9.0

3 release files

0.8.2

7 release files

0.8.1

1 release file

0.8.0

4 release files

0.7.4

2 release files

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.6.6

1 release file

0.6.5

1 release file

0.6.4

0.6.3

1 release file

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