Skip to main content

Largest triangle three buckets module for Python written in C

Project description

lttbc: Largest-Triangle-Three-Buckets (Python using a c implementation) PyPi PyPI Downloads Conda Downloads

This is a low-level implementation of the Largest-Triangle-Three-Buckets (LTTB) downsampling algorithm written in Python.

The code has been translated from the work of Sveinn Steinarsson (https://github.com/sveinn-steinarsson/flot-downsample/).

Demo and 'Known Issues'

The examples show the efficiency of the downsampling algorithm with a data set set of 5000 data points down sampled to 500 and 250 points.

SampleView

Known features and requirements:

  • The algorithm requires monotonically increasing x data (finite)
  • The algorithm requires finite y data (otherwise problems might occur)
  • x and y data have to be of same length (of course)
  • The algorithm returns arrays of dtype double

Installing

You can also install it from PyPI to use in other environments with Python 3.5 or later:

pip install lttbc

How to use on the field

The module lttbc differs in the standard input from other largest triangle three buckets implementations. The downsample function takes an input for x and y in addition to the threshold:

import lttbc
import numpy as np

ARRAY_SIZE = 10000
THRESHOLD = 1000

x = np.arange(ARRAY_SIZE, dtype=np.int32)
y = np.random.randint(1000, size=ARRAY_SIZE, dtype=np.uint64)

nx, ny = lttbc.downsample(x, y, THRESHOLD)

assert len(nx) == THRESHOLD
assert len(ny) == THRESHOLD
assert nx.dtype == np.double
assert ny.dtype == np.double

# List data or a mixture is accepted as well ...
x = list(range(ARRAY_SIZE))
y = [np.random.uniform(0, 1000) for _ in range(ARRAY_SIZE)]

assert isinstance(x, list)
assert isinstance(y, list)

nx, ny = lttbc.downsample(x, y, THRESHOLD)

assert len(nx) == THRESHOLD
assert len(ny) == THRESHOLD
assert nx.dtype == np.double
assert ny.dtype == np.double

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lttbc-0.3.0.tar.gz (93.9 kB view details)

Uploaded Source

Built Distributions

lttbc-0.3.0-cp312-cp312-win_amd64.whl (10.7 kB view details)

Uploaded CPython 3.12 Windows x86-64

lttbc-0.3.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl (92.4 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.5+ x86-64

lttbc-0.3.0-cp311-cp311-win_amd64.whl (10.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

lttbc-0.3.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl (92.2 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.5+ x86-64

lttbc-0.3.0-cp310-cp310-win_amd64.whl (10.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

File details

Details for the file lttbc-0.3.0.tar.gz.

File metadata

  • Download URL: lttbc-0.3.0.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for lttbc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eecffefddf8883091070cbde460011c5301c9291ab61b707c87260071588a897
MD5 1fb85e3f73194686c749fab9bf79f8fd
BLAKE2b-256 1aa2a5a2b4f7839ca9ed5e226fbd6062e0f279449bd83fd9f0faf55123b2b0b0

See more details on using hashes here.

File details

Details for the file lttbc-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: lttbc-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for lttbc-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 640163f7337c43cdb4b3545d8f7670a18a29bcc8a9e1c7f2182a2d5d07055b51
MD5 07718331787dff0ea9079f6ce56ac4ed
BLAKE2b-256 f807412ac37f4560768048d73476ddf0a654cf6bd4910d32377def0d51988023

See more details on using hashes here.

File details

Details for the file lttbc-0.3.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for lttbc-0.3.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e626ae7ab2a046303fb5663ee02c079637dad243ad90b54a3d84ec69d357469c
MD5 b638454b8ec98ede5907aad56708d091
BLAKE2b-256 4a2296bb74852f49c7b85450f48b2de1464022b53d016874ad7dc42fd26ca7e2

See more details on using hashes here.

File details

Details for the file lttbc-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lttbc-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for lttbc-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 573daf16ef466bce59c0e357534766db96ec99b18021db58bd9b80a8843a730f
MD5 ead559bdcd93edf623a159eb8ac53e11
BLAKE2b-256 fcfcd6c3c5a9dadf9c6bbba1520329e142d0d0b182ad2c333ae9de482f0894eb

See more details on using hashes here.

File details

Details for the file lttbc-0.3.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for lttbc-0.3.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9b7865e705f590d6dca2e2e7ed64a763bbcf1a3c47daff94ec1deb3646bb2513
MD5 0b3894d62e660ea3be578cf0f5631363
BLAKE2b-256 07ba859878518dbc14d92e06835c8a05e0909068f072492b9dcb6b1b728e5f96

See more details on using hashes here.

File details

Details for the file lttbc-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lttbc-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for lttbc-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a2bc3dfdf8f7bed57803e90e52ab9dc07dd889d3962ca03095eef0037199234d
MD5 02b72a2893577cecf0b55f8e4aac59ed
BLAKE2b-256 69f31549df12144a914dddd0e7dd1fd709da9e9408033d31351bbb719b4fa763

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page