Implementation of the Ramer-Douglas-Peucker algorithm
Project description
fastrdp
The fastrdp package contains an implementation of the Ramer–Douglas–Peucker algorithm for reducing the number of points in a curve.
Example
There is a single function in the fastrdp package. Here is an example from the Wikipedia page linked to above with a description of the algorithm. The original line is black and the approximating line is red.
import matplotlib.pyplot as plt
import numpy as np
import fastrdp
x = np.linspace(0, 5, 10_000)
y = np.exp(-x) * np.cos(2 * np.pi * x)
x_new, y_new = fastrdp.rdp(x, y, 0.06)
fig, ax = plt.subplots()
ax.plot(x, y, color='black', linewidth=2.0)
ax.plot(x_new, y_new, linestyle='dashed', color='red')
plt.show()
Performance
Here we compare the performance of fastrdp with that of a pure Python implementation. The example above is executed with fastrdp in less than a millisecond on my machine
from timeit import timeit
timeit(lambda: fastrdp.rdp(x, y, 0.1), number=10_000)
0.9878715319791809
The pure Python implementation in the rdp package takes more than a second to finish the same computation
import rdp
z = np.column_stack((x, y))
timeit(lambda: rdp.rdp(z, epsilon=0.1), number=1)
1.6936232760199346
Compilation
To specify package metadata fastrdp is using the contemporary
pyproject.toml
. However, to control compilation of the C++ code a
legacy setup.py
is used.
Execute the following commands to build and install fastrdp
pip install .
If you want an editable installation, then add a -e
to the last
command. To also install the optional dependencies used for development
add a little extra:
pip install -e '.[dev]'
The single quotes are needed in zsh, but is perhaps superfluous in other shells.
Acknowledgements
Setting up the package build using pyproject.toml
was not easy, but
these two blog posts helped tremendeously:
- https://opensource.com/article/22/11/extend-c-python
- https://opensource.com/article/23/1/packaging-python-modules-wheels
In setup.py
there is a bootstrap dependency on
numpy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for fastrdp-0.0.3-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a257374612df1aa54824a018ac3ee9d418479197e9a674e9ecdaf535124adca |
|
MD5 | 6e6cbf2ec51b5c1fc3f67bdc6218c353 |
|
BLAKE2b-256 | 48f8eae9e468a7de6d76c9e3fbb1672956c77d7dfe9d541d3119bbc248adb53b |
Hashes for fastrdp-0.0.3-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06c5dbeac910a00f652418cb8184c90fb2e37142842fced9c6949158e4eb4600 |
|
MD5 | 515813676156a89ba7b1dff41ce65e67 |
|
BLAKE2b-256 | c028b11c7a5ee5fe73c6d1edcee8a5f15f049de15ebb649b2adaa10a2c460016 |
Hashes for fastrdp-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5af76a0838e2a395eb250b1bc766da258768dbcac9575c8b6bfd5c6b5f02f78f |
|
MD5 | bcc4e1238f31ef2aaabe15d28b9fe972 |
|
BLAKE2b-256 | 018dae4e56883151f18b1368946da5c79b14af7afd335d29739336eb713fdc5b |
Hashes for fastrdp-0.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a0792bdf8e4411d144ce329f8ff66f4d8f7e535e82495000ba1fd85be2fa734 |
|
MD5 | c9236aeac7473fc858e1d62fe4dfbbc6 |
|
BLAKE2b-256 | 5cd47ff165788692a21deb9d2cab562e89a661824e87bf955d215c17f63a5dd5 |
Hashes for fastrdp-0.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 455ee5ffe188d7f18d1021f50b941895eaffbf9825fee13d8e24c862b34c1154 |
|
MD5 | f8521c4ed9afa00b983a350610e3fc57 |
|
BLAKE2b-256 | 62628bb69ba7f0da18e23f25a7debc3033aebb05ec1f03675b0074002e831576 |
Hashes for fastrdp-0.0.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3218f1fe14100b7b4ec83ab8bec92a7fb6d565fe0f9cedb159205e0244ce91f |
|
MD5 | 881a657a0230db868e5bf2a154954577 |
|
BLAKE2b-256 | 7fcae8c35de5f54d20d092e31e3759b6d1fd1ef3f2575cdc0d63036a70aeb0d2 |
Hashes for fastrdp-0.0.3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e493b28cf2e9edb486f62fea7322721ce27a0635accd18573a4221228996cabb |
|
MD5 | 6f300f851a62429d91033ef651efaf55 |
|
BLAKE2b-256 | d3220f378ae85f7fa820231082dae5587077fef7278745377fee39669ed118d9 |
Hashes for fastrdp-0.0.3-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30750472dadbf4e8bf5efffacd66d74297ec5a02896e586582ff1ded4aea9f92 |
|
MD5 | 67325235cdd309b85d318e276d842273 |
|
BLAKE2b-256 | 3e1cb40cf3fba1f0eb1745c190c7cb4c3e68742de703bac248249b562e786476 |
Hashes for fastrdp-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 559e928ff74078d87b7558b134f25a889da6bae765ef0a003036876e507e57d8 |
|
MD5 | 86f2280aa51e4eae118c17c900663d63 |
|
BLAKE2b-256 | fb69ad2d45b81395b73d12d1537fbcedd825bbe6b6983a85ff8685fe27657b9f |
Hashes for fastrdp-0.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f251a03f91ba2e66d5c56185088e44a7850f48dca6f8db4cf3b482fc950a2e |
|
MD5 | 31496874146b2b5dd692dc3ec8b8d0d1 |
|
BLAKE2b-256 | ed2be795194a2ec7eb25657ba79e59791fe4383b18e3cb37f5ab5b008f400ff1 |
Hashes for fastrdp-0.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f12b2032ed1ae82c7c8d0207048abeef31f09106e4c5e91b08accd073cda347 |
|
MD5 | 87b29f243aa57d28b488f2b6e5faf378 |
|
BLAKE2b-256 | 2d6a87e14e3e89eaffcdc100316334da6116ed2104b116229e2ee0035892bfee |
Hashes for fastrdp-0.0.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59a93149ffe156e58cd2b22fff245859d14586f8da0870d4c63d523f18c5e186 |
|
MD5 | cfb31617633062abb89230816cbfe022 |
|
BLAKE2b-256 | 7ee9826e5c1c73207fa924116cc7eedeb827a8f46d90f77c4dedc9e28ad9b3ef |
Hashes for fastrdp-0.0.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40bd90f45a034acae762678249483f6d53eeb10f2b451ce26782b3fecb800080 |
|
MD5 | a1228afa7b5624d7399dd355f2bba53c |
|
BLAKE2b-256 | bdaa1272fdb4bf9884426390147da8566607a26f3fa6eb476a35ccf831269124 |
Hashes for fastrdp-0.0.3-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c0fdda4497d7430eefdab0f490295db2a3f6f8d245b17b9d858a2d7a8c4deda |
|
MD5 | 2f84007b61205f5b046a1780ecd721dc |
|
BLAKE2b-256 | 3fdfc66345225defae2c0a6959a2b9146d4b4ea24c2aa7968540d75890e05b1d |
Hashes for fastrdp-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57848c61ffda772c1b35fb3ebd40dcb907503cdd4d70dccb202135057fe134fb |
|
MD5 | 38d0642e5abeed048130dbb90b82adb7 |
|
BLAKE2b-256 | 5da7982de1f3e3e512eeb1affc1e83bb8429e3dea9fe6ca640682f5c6339271a |
Hashes for fastrdp-0.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58638d662d335716579ae112d9c05665055a789c1f7e031d4fac5ae1ec290666 |
|
MD5 | 67fdfdedc1961329f1724dbbec04e8ec |
|
BLAKE2b-256 | 349b1bc81b3f6622e4343feeff2203a5cad40222a8d6da294e5332f3af159e26 |
Hashes for fastrdp-0.0.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb0a9316c66e3b81667f939f18a320d79d0a99c1cab27e6574b96cafc3b24ed8 |
|
MD5 | 60fd97acdfcd39027747763800a0023d |
|
BLAKE2b-256 | c1096984d14f9ff43b4bf1e32f97e1494bc66e57a2d848c0afa971f9144b749f |
Hashes for fastrdp-0.0.3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e4aba4f1491f2637f1582ec0e3be70f7b6bfde658c7fae79ff153c3ce3f8cce |
|
MD5 | 488b919c374480d001a398bb3fb2e55f |
|
BLAKE2b-256 | bcf1e6bbe2a0fa62bd25e057216517d3156eb9457031b79eb9ff7b3e3b98466c |