uplot-python 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uplot/__init__.py +1 -3
- uplot/color_picker.py +1 -3
- uplot/exceptions.py +0 -2
- uplot/generate_html.py +1 -2
- uplot/plot.py +4 -3
- uplot/plot2.py +39 -2
- uplot/utils.py +9 -8
- uplot/write_html_tempfile.py +0 -2
- {uplot_python-1.0.0.dist-info → uplot_python-1.1.1.dist-info}/METADATA +15 -11
- uplot_python-1.1.1.dist-info/RECORD +16 -0
- {uplot_python-1.0.0.dist-info → uplot_python-1.1.1.dist-info}/WHEEL +1 -1
- uplot_python-1.0.0.dist-info/RECORD +0 -16
- {uplot_python-1.0.0.dist-info → uplot_python-1.1.1.dist-info/licenses}/LICENSE +0 -0
uplot/__init__.py
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
# Copyright 2022 Stéphane Caron
|
|
6
|
-
# Copyright 2023-2024 Inria
|
|
7
5
|
|
|
8
6
|
"""Python wrapper for μPlot time series."""
|
|
9
7
|
|
|
10
|
-
__version__ = "1.
|
|
8
|
+
__version__ = "1.1.1"
|
|
11
9
|
|
|
12
10
|
from .plot import plot
|
|
13
11
|
from .plot2 import plot2
|
uplot/color_picker.py
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
# Copyright 2022 Stéphane Caron
|
|
6
|
-
# Copyright 2023-2024 Inria
|
|
7
5
|
|
|
8
6
|
"""Pick plot colors from a circular list."""
|
|
9
7
|
|
|
@@ -38,7 +36,7 @@ class ColorPicker:
|
|
|
38
36
|
Returns:
|
|
39
37
|
Color string.
|
|
40
38
|
"""
|
|
41
|
-
color = self.COLORS[self.__next_color]
|
|
39
|
+
color = self.COLORS[self.__next_color % len(self.COLORS)]
|
|
42
40
|
self.__next_color += 1
|
|
43
41
|
return color
|
|
44
42
|
|
uplot/exceptions.py
CHANGED
uplot/generate_html.py
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
# Copyright 2022 Stéphane Caron
|
|
6
|
-
# Copyright 2023 Inria
|
|
7
5
|
|
|
8
6
|
"""Generate an HTML page containing the output plot."""
|
|
9
7
|
|
|
@@ -23,6 +21,7 @@ def generate_html(opts: dict, data: List[np.ndarray], resize: bool) -> str:
|
|
|
23
21
|
Args:
|
|
24
22
|
opts: uPlot option dictionary.
|
|
25
23
|
data: List of NumPy arrays, one for each series in the plot.
|
|
24
|
+
resize: If set, add a resize event listener to fit the window.
|
|
26
25
|
|
|
27
26
|
Returns:
|
|
28
27
|
HTML contents of the page.
|
uplot/plot.py
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
# Copyright 2024 Inria
|
|
6
5
|
|
|
7
6
|
"""Main plot function."""
|
|
8
7
|
|
|
9
8
|
import webbrowser
|
|
10
|
-
from typing import
|
|
9
|
+
from typing import List
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
11
12
|
|
|
12
13
|
from .generate_html import generate_html
|
|
13
14
|
from .write_html_tempfile import write_html_tempfile
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
def plot(opts: dict, data: List[
|
|
17
|
+
def plot(opts: dict, data: List[np.ndarray]) -> None:
|
|
17
18
|
"""Plot function with the same API as uPlot's `plot`.
|
|
18
19
|
|
|
19
20
|
Args:
|
uplot/plot2.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
# Copyright 2024 Inria
|
|
6
5
|
|
|
7
6
|
"""Additional plot function."""
|
|
8
7
|
|
|
@@ -18,7 +17,21 @@ from .utils import js
|
|
|
18
17
|
from .write_html_tempfile import write_html_tempfile
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
def prepare_data(
|
|
20
|
+
def prepare_data(
|
|
21
|
+
x: np.ndarray,
|
|
22
|
+
left: List[np.ndarray],
|
|
23
|
+
right: Optional[List[np.ndarray]],
|
|
24
|
+
) -> List[np.ndarray]:
|
|
25
|
+
"""Prepare the data list from x-axis, left, and right series.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
x: Values for the x-axis.
|
|
29
|
+
left: Left y-axis series (single array or list of arrays).
|
|
30
|
+
right: Optional right y-axis series.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Combined list of arrays for all series.
|
|
34
|
+
"""
|
|
22
35
|
if isinstance(left, np.ndarray) and left.ndim == 1:
|
|
23
36
|
left = [left]
|
|
24
37
|
data = [x, *left]
|
|
@@ -28,6 +41,11 @@ def prepare_data(x, left, right):
|
|
|
28
41
|
|
|
29
42
|
|
|
30
43
|
def add_default_options(opts: dict) -> None:
|
|
44
|
+
"""Add default cursor and plugin options if not already set.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
opts: uPlot option dictionary to update in place.
|
|
48
|
+
"""
|
|
31
49
|
if "cursor" not in opts:
|
|
32
50
|
opts["cursor"] = {
|
|
33
51
|
"drag": {
|
|
@@ -49,6 +67,18 @@ def add_series(
|
|
|
49
67
|
left_labels: Optional[List[str]],
|
|
50
68
|
right_labels: Optional[List[str]],
|
|
51
69
|
) -> None:
|
|
70
|
+
"""Build the uPlot series list and attach it to opts.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
opts: uPlot option dictionary to update in place.
|
|
74
|
+
data: List of data arrays (x-axis followed by series).
|
|
75
|
+
nb_left: Number of left-axis series.
|
|
76
|
+
left_labels: Optional labels for left-axis series.
|
|
77
|
+
right_labels: Optional labels for right-axis series.
|
|
78
|
+
|
|
79
|
+
Raises:
|
|
80
|
+
UplotException: If left_labels has fewer entries than nb_left.
|
|
81
|
+
"""
|
|
52
82
|
if left_labels is not None and len(left_labels) < nb_left:
|
|
53
83
|
raise UplotException(
|
|
54
84
|
f"Not enough labels in left_labels ({len(left_labels)}) "
|
|
@@ -95,6 +125,11 @@ def add_series(
|
|
|
95
125
|
|
|
96
126
|
|
|
97
127
|
def add_axes(opts: dict) -> None:
|
|
128
|
+
"""Add default left and right axis definitions to opts.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
opts: uPlot option dictionary to update in place.
|
|
132
|
+
"""
|
|
98
133
|
opts["axes"] = [
|
|
99
134
|
{},
|
|
100
135
|
{
|
|
@@ -133,6 +168,8 @@ def plot2(
|
|
|
133
168
|
timestamped: If set, x-axis values are treated as timestamps.
|
|
134
169
|
width: Plot width in pixels.
|
|
135
170
|
height: Plot height in pixels.
|
|
171
|
+
left_labels: Labels for the left-axis series, in order.
|
|
172
|
+
right_labels: Labels for the right-axis series, in order.
|
|
136
173
|
kwargs: Other keyword arguments are forward to uPlot as options.
|
|
137
174
|
"""
|
|
138
175
|
data = prepare_data(x, left, right)
|
uplot/utils.py
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
"""Array and JavaScript code utilities."""
|
|
7
|
+
|
|
8
|
+
import json
|
|
6
9
|
|
|
7
10
|
import numpy as np
|
|
8
11
|
|
|
@@ -16,13 +19,11 @@ def array2string(array: np.ndarray) -> str:
|
|
|
16
19
|
Returns:
|
|
17
20
|
String representation of the array.
|
|
18
21
|
"""
|
|
19
|
-
|
|
20
|
-
array
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
return array_str.replace("nan", "null")
|
|
22
|
+
if array.dtype.kind in "iu":
|
|
23
|
+
return json.dumps(array.tolist())
|
|
24
|
+
# tolist() unboxes to Python floats; ``v != v`` is true only for NaN.
|
|
25
|
+
values = array.tolist()
|
|
26
|
+
return json.dumps([None if v != v else v for v in values])
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
def js(code: str) -> str:
|
uplot/write_html_tempfile.py
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: uplot-python
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Python wrapper for μPlot time series.
|
|
5
5
|
Keywords: json,time,series,plot
|
|
6
6
|
Author-email: Stéphane Caron <stephane.caron@normalesup.org>
|
|
7
7
|
Maintainer-email: Stéphane Caron <stephane.caron@normalesup.org>
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
|
-
Classifier: Development Status ::
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
17
|
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
18
|
+
License-File: LICENSE
|
|
20
19
|
Requires-Dist: ipython >=8.0.1
|
|
21
20
|
Requires-Dist: msgpack >=1.0.4
|
|
22
21
|
Requires-Dist: numpy >=1.15.4
|
|
23
|
-
Project-URL: Changelog, https://
|
|
24
|
-
Project-URL: Homepage, https://
|
|
25
|
-
Project-URL: Source, https://
|
|
26
|
-
Project-URL: Tracker, https://
|
|
22
|
+
Project-URL: Changelog, https://codeberg.org/stephane-caron/uplot-python/src/branch/main/CHANGELOG.md
|
|
23
|
+
Project-URL: Homepage, https://codeberg.org/stephane-caron/uplot-python
|
|
24
|
+
Project-URL: Source, https://codeberg.org/stephane-caron/uplot-python
|
|
25
|
+
Project-URL: Tracker, https://codeberg.org/stephane-caron/uplot-python/issues
|
|
27
26
|
|
|
28
27
|
# uplot-python
|
|
29
28
|
|
|
29
|
+
[](https://ci.codeberg.org/repos/17009)
|
|
30
|
+
[](https://anaconda.org/conda-forge/uplot-python)
|
|
31
|
+
[](https://pypi.org/project/uplot-python/)
|
|
32
|
+
|
|
30
33
|
Python wrapper for [μPlot](https://github.com/leeoniya/uPlot) 📈
|
|
31
34
|
|
|
32
35
|
## Installation
|
|
@@ -75,6 +78,7 @@ uplot.plot2(
|
|
|
75
78
|
## See also
|
|
76
79
|
|
|
77
80
|
- [µPlot](https://github.com/leeoniya/uPlot): A small (~45 KB min), fast chart for time series, lines, areas, ohlc & bars.
|
|
81
|
+
- [foxplot](https://codeberg.org/stephane-caron/foxplot): Plot time series from MessagePack or line-delimited JSON.
|
|
78
82
|
- [Matplotlib](https://matplotlib.org/stable/): Comprehensive library for creating static, animated, and interactive visualizations.
|
|
79
|
-
- [matplotlive](https://
|
|
83
|
+
- [matplotlive](https://codeberg.org/stephane-caron/matplotlive): Stream live plots to a Matplotlib figure.
|
|
80
84
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
uplot/__init__.py,sha256=P8nHtlHy0naNFymrwMmGEVksGKV9z1v1QU_nwtffD2s,245
|
|
2
|
+
uplot/color_picker.py,sha256=TgE1o8V5zGor0Znasmm6zggXdgqh0nk9L1I4wtxOpug,920
|
|
3
|
+
uplot/exceptions.py,sha256=8_2xggNkMpMF-pRsfA8kLWT81l_t2cZ4cfOkwbPql_4,192
|
|
4
|
+
uplot/generate_html.py,sha256=NruX2zDzzTIOuJW4lQ6N60kg05MAH61eWEAijcFKhr0,3713
|
|
5
|
+
uplot/plot.py,sha256=MOGxCDlYdH-n6f380_3wmYCdfjwtU438AtcFYZ4gdiQ,643
|
|
6
|
+
uplot/plot2.py,sha256=oZMruYuAMPQL6-FDv5m2wAy_NVa74PmkjXHN1i1Dln8,5723
|
|
7
|
+
uplot/utils.py,sha256=Tl6ZDtMdtE27PuX3Vje_IQjhZZg40BcfmlXcU02o_Nc,880
|
|
8
|
+
uplot/write_html_tempfile.py,sha256=B68PrF3rQ3mC3i6ujKgHy8cf8V64h4D9DxIqkGdLRQI,661
|
|
9
|
+
uplot/static/__init__.py,sha256=1mykIjCDK2TC5EfbjCTNxfOtJx3P-hIFgbHQEtBfM_o,71
|
|
10
|
+
uplot/static/uPlot.iife.js,sha256=ZVvIqjN4Hochxa9rWfFpnAPJvalRqnSmq1GKwgzEMm0,120184
|
|
11
|
+
uplot/static/uPlot.min.css,sha256=PxIc1KmXtjTgeoh2WIUAGOR1wm8L3dh0EJqNOCwZ3oc,1839
|
|
12
|
+
uplot/static/uPlot.mousewheel.js,sha256=p2CcCwxxafvNqXsxw-zrqUUogxZ1URZhxWK59B0-tgw,4543
|
|
13
|
+
uplot_python-1.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
+
uplot_python-1.1.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
15
|
+
uplot_python-1.1.1.dist-info/METADATA,sha256=fixZpQvCiTf3bI1cYRvF2GpRJeLt6QA94gcKxHuATvM,2933
|
|
16
|
+
uplot_python-1.1.1.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
uplot/__init__.py,sha256=cNNmW1r6MVagQ85Otp-Ms55B63KoVTutayVYDDt4Q40,306
|
|
2
|
-
uplot/color_picker.py,sha256=tBcc4t1gN2spSBqmy7gY827GvpzPE2u8N8-6xUMv-YY,962
|
|
3
|
-
uplot/exceptions.py,sha256=iMQrMn8yzcU95-g0vL1Lg03M5FB8vo4ckJpZXEb0TyE,248
|
|
4
|
-
uplot/generate_html.py,sha256=CiwaJZtIShSNAufidH74OCzdJB-7lrm9-f4MDi_AR60,3698
|
|
5
|
-
uplot/plot.py,sha256=GugDtmx2nqcxmwZ20LEbaX06lX0Swvncb9-136tTXqM,654
|
|
6
|
-
uplot/plot2.py,sha256=PmEsGyBEFD0vvvfvD5LYah-hV2Lp48saviqhkGqtWDE,4504
|
|
7
|
-
uplot/utils.py,sha256=0cuQ8XWcDCm0hFvhtUHtt2OeLWf6ujwfSvKokTxuiCQ,775
|
|
8
|
-
uplot/write_html_tempfile.py,sha256=gYbp-btAItW4CX1Wjt2ufhcptdlA0ckFK-xFXA92tGw,722
|
|
9
|
-
uplot/static/__init__.py,sha256=1mykIjCDK2TC5EfbjCTNxfOtJx3P-hIFgbHQEtBfM_o,71
|
|
10
|
-
uplot/static/uPlot.iife.js,sha256=ZVvIqjN4Hochxa9rWfFpnAPJvalRqnSmq1GKwgzEMm0,120184
|
|
11
|
-
uplot/static/uPlot.min.css,sha256=PxIc1KmXtjTgeoh2WIUAGOR1wm8L3dh0EJqNOCwZ3oc,1839
|
|
12
|
-
uplot/static/uPlot.mousewheel.js,sha256=p2CcCwxxafvNqXsxw-zrqUUogxZ1URZhxWK59B0-tgw,4543
|
|
13
|
-
uplot_python-1.0.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
-
uplot_python-1.0.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
15
|
-
uplot_python-1.0.0.dist-info/METADATA,sha256=b9XQy0hZ17t7ks58s_wIYSOGBDqGwNJHGSIEHAOAh4g,2537
|
|
16
|
-
uplot_python-1.0.0.dist-info/RECORD,,
|
|
File without changes
|