aptapy 0.1.1__py3-none-any.whl → 0.3.0__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.
- aptapy/_version.py +1 -1
- aptapy/hist.py +280 -0
- aptapy/modeling.py +576 -96
- aptapy/plotting.py +334 -290
- aptapy/strip.py +92 -0
- {aptapy-0.1.1.dist-info → aptapy-0.3.0.dist-info}/METADATA +10 -2
- aptapy-0.3.0.dist-info/RECORD +12 -0
- aptapy-0.1.1.dist-info/RECORD +0 -10
- {aptapy-0.1.1.dist-info → aptapy-0.3.0.dist-info}/WHEEL +0 -0
- {aptapy-0.1.1.dist-info → aptapy-0.3.0.dist-info}/licenses/LICENSE +0 -0
aptapy/strip.py
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Copyright (C) 2025 Luca Baldini (luca.baldini@pi.infn.it)
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
"""Strip charts.
|
17
|
+
"""
|
18
|
+
|
19
|
+
import collections
|
20
|
+
from typing import Sequence
|
21
|
+
|
22
|
+
import numpy as np
|
23
|
+
|
24
|
+
from .plotting import plt, setup_axes
|
25
|
+
|
26
|
+
|
27
|
+
class StripChart:
|
28
|
+
|
29
|
+
"""Class describing a sliding strip chart, that is, a scatter plot where the
|
30
|
+
number of points is limited to a maximum, so that the thing acts essentially
|
31
|
+
as a sliding window, typically in time.
|
32
|
+
|
33
|
+
Arguments
|
34
|
+
---------
|
35
|
+
max_length : int, optional
|
36
|
+
the maximum number of points to keep in the strip chart. If None (the default),
|
37
|
+
the number of points is unlimited.
|
38
|
+
|
39
|
+
label : str, optional
|
40
|
+
a text label for the data series (default is None).
|
41
|
+
|
42
|
+
xlabel : str, optional
|
43
|
+
the label for the x axis.
|
44
|
+
|
45
|
+
ylabel : str, optional
|
46
|
+
the label for the y axis.
|
47
|
+
|
48
|
+
datetime : bool, optional
|
49
|
+
if True, the x values are treated as POSIX timestamps and converted to
|
50
|
+
datetime objects for plotting purposes (default is False).
|
51
|
+
"""
|
52
|
+
|
53
|
+
def __init__(self, max_length: int = None, label: str = '', xlabel: str = None,
|
54
|
+
ylabel: str = None, datetime: bool = False) -> None:
|
55
|
+
"""Constructor.
|
56
|
+
"""
|
57
|
+
self.label = label
|
58
|
+
self.xlabel = xlabel
|
59
|
+
self.ylabel = ylabel
|
60
|
+
self._datetime = datetime
|
61
|
+
self.x = collections.deque(maxlen=max_length)
|
62
|
+
self.y = collections.deque(maxlen=max_length)
|
63
|
+
|
64
|
+
def clear(self) -> None:
|
65
|
+
"""Reset the strip chart.
|
66
|
+
"""
|
67
|
+
self.x.clear()
|
68
|
+
self.y.clear()
|
69
|
+
|
70
|
+
def append(self, x: float, y: float) -> None:
|
71
|
+
"""Append a data point to the strip chart.
|
72
|
+
"""
|
73
|
+
self.x.append(x)
|
74
|
+
self.y.append(y)
|
75
|
+
|
76
|
+
def extend(self, x: Sequence[float], y: Sequence[float]) -> None:
|
77
|
+
"""Append multiple data points to the strip chart.
|
78
|
+
"""
|
79
|
+
if len(x) != len(y):
|
80
|
+
raise ValueError("x and y must have the same length")
|
81
|
+
self.x.extend(x)
|
82
|
+
self.y.extend(y)
|
83
|
+
|
84
|
+
def plot(self, axes=None, **kwargs) -> None:
|
85
|
+
"""Plot the strip chart.
|
86
|
+
"""
|
87
|
+
kwargs.setdefault("label", self.label)
|
88
|
+
if axes is None:
|
89
|
+
axes = plt.gca()
|
90
|
+
x = np.array(self.x).astype('datetime64[s]') if self._datetime else self.x
|
91
|
+
axes.plot(x, self.y, **kwargs)
|
92
|
+
setup_axes(axes, xlabel=self.xlabel, ylabel=self.ylabel, grids=True)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: aptapy
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: Statistical tools for online monitoring and analysis
|
5
5
|
Project-URL: Homepage, https://github.com/lucabaldini/aptapy
|
6
6
|
Project-URL: Issues, https://github.com/lucabaldini/aptapy/issues
|
@@ -694,9 +694,17 @@ Requires-Dist: pytest; extra == 'dev'
|
|
694
694
|
Requires-Dist: ruff; extra == 'dev'
|
695
695
|
Provides-Extra: docs
|
696
696
|
Requires-Dist: sphinx; extra == 'docs'
|
697
|
+
Requires-Dist: sphinx-gallery; extra == 'docs'
|
697
698
|
Requires-Dist: sphinxawesome-theme; extra == 'docs'
|
698
699
|
Description-Content-Type: text/markdown
|
699
700
|
|
700
701
|
<img src="docs/_static/logo.png" alt="logo" width="175"/>
|
701
702
|
|
702
|
-
|
703
|
+

|
704
|
+
[](https://github.com/lucabaldini/aptapy/actions/workflows/ci.yml)
|
705
|
+
[](https://github.com/lucabaldini/aptapy/actions/workflows/docs.yml)
|
706
|
+
[](https://lucabaldini.github.io/aptapy/)
|
707
|
+
[](https://techforpalestine.org/learn-more)
|
708
|
+
|
709
|
+
Statistical tools for online monitoring and analysis.
|
710
|
+
[Read more](https://lucabaldini.github.io/aptapy/).
|
@@ -0,0 +1,12 @@
|
|
1
|
+
aptapy/__init__.py,sha256=a7Au1ukdeJbjiIZ-UL-qZE1xk-d2WnKKkoqjg_0SzqA,1707
|
2
|
+
aptapy/_version.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
|
3
|
+
aptapy/hist.py,sha256=jvHULR2lW_gyoemNaRI-vpqhFqmLLCB319CaKjwU69E,9752
|
4
|
+
aptapy/modeling.py,sha256=mHHHFMYmMuXTRQD2yR1XLM6E4KaBk8md7Z7dDp5ReD8,32566
|
5
|
+
aptapy/plotting.py,sha256=p9YNdrcFcTimRCtoXcV3zORaEd4EfMtsDd4ETxGKKHM,27483
|
6
|
+
aptapy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
aptapy/strip.py,sha256=qGsVXWp-Dz-lz7KQxktMifUTNkSxh8ZQwYme8_bealQ,3026
|
8
|
+
aptapy/typing_.py,sha256=JIbEqKI8kn_fd90yDt0JmI1AojjmLhAEB_1RfMFxLx4,807
|
9
|
+
aptapy-0.3.0.dist-info/METADATA,sha256=ae7Q-HEWZCiZW8QjbAMNqCwZQVTFv52oH2n4J5tMRfg,42131
|
10
|
+
aptapy-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
+
aptapy-0.3.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
12
|
+
aptapy-0.3.0.dist-info/RECORD,,
|
aptapy-0.1.1.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
aptapy/__init__.py,sha256=a7Au1ukdeJbjiIZ-UL-qZE1xk-d2WnKKkoqjg_0SzqA,1707
|
2
|
-
aptapy/_version.py,sha256=rnObPjuBcEStqSO0S6gsdS_ot8ITOQjVj_-P1LUUYpg,22
|
3
|
-
aptapy/modeling.py,sha256=Ba-kHfvwjSc5oM3XZGsxN5wAONQZaKmICQa-P65qxNE,18234
|
4
|
-
aptapy/plotting.py,sha256=Pv0uo7fqoKYmyFmX2CiSRujzTkYNKiUsW7ZHSBWQowE,25991
|
5
|
-
aptapy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
aptapy/typing_.py,sha256=JIbEqKI8kn_fd90yDt0JmI1AojjmLhAEB_1RfMFxLx4,807
|
7
|
-
aptapy-0.1.1.dist-info/METADATA,sha256=bJ44czUH6kc516OHBIbge9neKPWTm3jAyz2fBEvPUkY,41456
|
8
|
-
aptapy-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
-
aptapy-0.1.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
10
|
-
aptapy-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|