-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathREADME.txt
46 lines (32 loc) · 1.57 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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=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