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)

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/).

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

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='int32')
y = np.random.randint(1000, size=ARRAY_SIZE, dtype='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 = [i for i in 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.

Files for lttbc, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size lttbc-0.2.0-cp35-cp35m-win_amd64.whl (10.4 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size lttbc-0.2.0-cp36-cp36m-manylinux1_x86_64.whl (18.0 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size lttbc-0.2.0-cp36-cp36m-win_amd64.whl (10.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size lttbc-0.2.0-cp37-cp37m-win_amd64.whl (10.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size lttbc-0.2.0-cp38-cp38-win_amd64.whl (10.5 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size lttbc-0.2.0-cp39-cp39-win_amd64.whl (10.4 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size lttbc-0.2.0.tar.gz (91.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page