pamoja-kit 0.1.17__tar.gz

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.
@@ -0,0 +1,13 @@
1
+ # Native extensions are built per platform, not committed.
2
+ *.so
3
+ *.pyd
4
+ *.dylib
5
+
6
+ # Build and packaging output.
7
+ dist/
8
+ wheels/
9
+ target/
10
+
11
+ # Local virtual environments.
12
+ .venv/
13
+ venv/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anthony Wiedman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.5
2
+ Name: pamoja-kit
3
+ Version: 0.1.17
4
+ Summary: Plain-language helper math: smoothing, calibration, PID and thermostat control, trend and surge prediction, rolling windows, kinematics, and geo.
5
+ Project-URL: Repository, https://github.com/molexxxx/pamoja
6
+ Project-URL: Documentation, https://pamoja.molex.cloud/docs/guides/kit.html
7
+ Author: molexxxx
8
+ License: MIT
9
+ License-File: LICENSE-MIT
10
+ Keywords: iot,kit,pamoja,robotics
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: pamoja-native==0.1.17
17
+ Description-Content-Type: text/markdown
18
+
19
+ # pamoja-kit
20
+
21
+ Plain-language helper math: smoothing, calibration, PID and thermostat control, trend and surge prediction, rolling windows, kinematics, and geo. One capability of [pamoja](https://github.com/molexxxx/pamoja), one memory-safe Rust core with bindings for TypeScript, Python, and C#.
22
+
23
+ [![API reference](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-api.svg)](https://pamoja.molex.cloud/docs/reference/python/pamoja/kit.html)
24
+ [![read the guide](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-guide.svg)](https://pamoja.molex.cloud/docs/guides/kit.html)
25
+ [![documentation](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-docs.svg)](https://pamoja.molex.cloud/docs/)
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install pamoja-kit
31
+ ```
32
+
33
+ ```python
34
+ from pamoja import kit
35
+ ```
36
+
37
+ This pulls in `pamoja-native`, the compiled engine. `pip install pamoja` is the whole framework in one package.
38
+
39
+ ## Example
40
+
41
+ The script the test suite runs, spliced here as it ran.
42
+
43
+ From [`bindings/python/guides/kit.py`](https://github.com/molexxxx/pamoja/blob/main/bindings/python/guides/kit.py):
44
+
45
+ ```python
46
+ from pamoja.kit import Calibration, Median, Thermostat
47
+
48
+ # A 4-20 mA process loop carries the level as a current: 4 mA is empty and 20 mA is full,
49
+ # so the span is 16 mA and mid-scale is 12 mA, not 10.
50
+ level = Calibration.two_point(4.0, 0.0, 20.0, 100.0)
51
+ print(f"12 mA is {level.apply(12.0)}% full, 4 mA is {level.apply(4.0)}%")
52
+
53
+ # The live zero is what makes a broken loop detectable: 0 mA is off the bottom of the
54
+ # scale rather than an empty tank.
55
+ broken = level.apply(0.0)
56
+ print(f"a dead loop reads {broken}%, which is not a level at all")
57
+
58
+ # A median window drops that sample outright, where an average would blend a quarter of
59
+ # the range into every reading after it.
60
+ filtered = Median()
61
+ percent = 0.0
62
+ for milliamps in (12.0, 12.0, 0.0, 12.0, 12.0):
63
+ percent = level.apply(filtered.update(milliamps))
64
+ print(f"through the dropout, the level held at {percent}%")
65
+
66
+ # A refill pump runs when the level falls below the deadband, which is the direction
67
+ # heating names; nothing about it is specific to temperature. The deadband stops a level
68
+ # sitting on the threshold from chattering the contactor.
69
+ pump = Thermostat.heating(50.0, 10.0)
70
+ for reading in (percent, 38.0, 45.0, 62.0):
71
+ running = "on" if pump.update(reading) else "off"
72
+ print(f"at {reading}% the pump is {running}")
73
+ ```
74
+
75
+ ## The same capability in every language
76
+
77
+ | Language | Package | Reference |
78
+ | --- | --- | --- |
79
+ | Rust | [`pamoja-kit`](https://crates.io/crates/pamoja-kit) | [reference](https://pamoja.molex.cloud/docs/reference/rust/pamoja_kit/index.html), [docs.rs](https://docs.rs/pamoja-kit), [install](https://pamoja.molex.cloud/docs/reference/rust.html#rust-kit) |
80
+ | TypeScript | [`@pamoja/kit`](https://www.npmjs.com/package/@pamoja/kit) | [reference](https://pamoja.molex.cloud/docs/reference/node/modules/_pamoja_kit.html), [install](https://pamoja.molex.cloud/docs/reference/node.html#node-kit) |
81
+ | Python | [`pamoja-kit`](https://pypi.org/project/pamoja-kit/) | [reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/kit.html), [install](https://pamoja.molex.cloud/docs/reference/python.html#python-kit) |
82
+ | C# | [`Pamoja.Kit`](https://www.nuget.org/packages/Pamoja.Kit) | [reference](https://pamoja.molex.cloud/docs/reference/dotnet/api/Pamoja.Kit.html), [install](https://pamoja.molex.cloud/docs/reference/dotnet.html#dotnet-kit) |
83
+
84
+ ## Documentation
85
+
86
+ - [`pamoja.kit` reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/kit.html), every class and function in this module.
87
+ - [The Helpers guide](https://pamoja.molex.cloud/docs/guides/kit.html), with the same example in Rust, TypeScript, and C#.
88
+ - [Every capability](https://pamoja.molex.cloud/docs/), and the [install page](https://pamoja.molex.cloud/docs/install.html).
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,74 @@
1
+ # pamoja-kit
2
+
3
+ Plain-language helper math: smoothing, calibration, PID and thermostat control, trend and surge prediction, rolling windows, kinematics, and geo. One capability of [pamoja](https://github.com/molexxxx/pamoja), one memory-safe Rust core with bindings for TypeScript, Python, and C#.
4
+
5
+ [![API reference](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-api.svg)](https://pamoja.molex.cloud/docs/reference/python/pamoja/kit.html)
6
+ [![read the guide](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-guide.svg)](https://pamoja.molex.cloud/docs/guides/kit.html)
7
+ [![documentation](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-docs.svg)](https://pamoja.molex.cloud/docs/)
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pip install pamoja-kit
13
+ ```
14
+
15
+ ```python
16
+ from pamoja import kit
17
+ ```
18
+
19
+ This pulls in `pamoja-native`, the compiled engine. `pip install pamoja` is the whole framework in one package.
20
+
21
+ ## Example
22
+
23
+ The script the test suite runs, spliced here as it ran.
24
+
25
+ From [`bindings/python/guides/kit.py`](https://github.com/molexxxx/pamoja/blob/main/bindings/python/guides/kit.py):
26
+
27
+ ```python
28
+ from pamoja.kit import Calibration, Median, Thermostat
29
+
30
+ # A 4-20 mA process loop carries the level as a current: 4 mA is empty and 20 mA is full,
31
+ # so the span is 16 mA and mid-scale is 12 mA, not 10.
32
+ level = Calibration.two_point(4.0, 0.0, 20.0, 100.0)
33
+ print(f"12 mA is {level.apply(12.0)}% full, 4 mA is {level.apply(4.0)}%")
34
+
35
+ # The live zero is what makes a broken loop detectable: 0 mA is off the bottom of the
36
+ # scale rather than an empty tank.
37
+ broken = level.apply(0.0)
38
+ print(f"a dead loop reads {broken}%, which is not a level at all")
39
+
40
+ # A median window drops that sample outright, where an average would blend a quarter of
41
+ # the range into every reading after it.
42
+ filtered = Median()
43
+ percent = 0.0
44
+ for milliamps in (12.0, 12.0, 0.0, 12.0, 12.0):
45
+ percent = level.apply(filtered.update(milliamps))
46
+ print(f"through the dropout, the level held at {percent}%")
47
+
48
+ # A refill pump runs when the level falls below the deadband, which is the direction
49
+ # heating names; nothing about it is specific to temperature. The deadband stops a level
50
+ # sitting on the threshold from chattering the contactor.
51
+ pump = Thermostat.heating(50.0, 10.0)
52
+ for reading in (percent, 38.0, 45.0, 62.0):
53
+ running = "on" if pump.update(reading) else "off"
54
+ print(f"at {reading}% the pump is {running}")
55
+ ```
56
+
57
+ ## The same capability in every language
58
+
59
+ | Language | Package | Reference |
60
+ | --- | --- | --- |
61
+ | Rust | [`pamoja-kit`](https://crates.io/crates/pamoja-kit) | [reference](https://pamoja.molex.cloud/docs/reference/rust/pamoja_kit/index.html), [docs.rs](https://docs.rs/pamoja-kit), [install](https://pamoja.molex.cloud/docs/reference/rust.html#rust-kit) |
62
+ | TypeScript | [`@pamoja/kit`](https://www.npmjs.com/package/@pamoja/kit) | [reference](https://pamoja.molex.cloud/docs/reference/node/modules/_pamoja_kit.html), [install](https://pamoja.molex.cloud/docs/reference/node.html#node-kit) |
63
+ | Python | [`pamoja-kit`](https://pypi.org/project/pamoja-kit/) | [reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/kit.html), [install](https://pamoja.molex.cloud/docs/reference/python.html#python-kit) |
64
+ | C# | [`Pamoja.Kit`](https://www.nuget.org/packages/Pamoja.Kit) | [reference](https://pamoja.molex.cloud/docs/reference/dotnet/api/Pamoja.Kit.html), [install](https://pamoja.molex.cloud/docs/reference/dotnet.html#dotnet-kit) |
65
+
66
+ ## Documentation
67
+
68
+ - [`pamoja.kit` reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/kit.html), every class and function in this module.
69
+ - [The Helpers guide](https://pamoja.molex.cloud/docs/guides/kit.html), with the same example in Rust, TypeScript, and C#.
70
+ - [Every capability](https://pamoja.molex.cloud/docs/), and the [install page](https://pamoja.molex.cloud/docs/install.html).
71
+
72
+ ## License
73
+
74
+ MIT
@@ -0,0 +1,137 @@
1
+ """Idiomatic helper-math facade.
2
+
3
+ The helpers are named for the goal rather than the technique, with the real
4
+ algorithm one layer down: smooth a noisy reading, hold a value with a PID, warn
5
+ before a tank runs dry, and notice when a tracked point leaves its area.
6
+
7
+ They are synchronous and allocation-free in the core, so this module re-exports
8
+ the generated classes rather than wrapping them. What it adds is a
9
+ :class:`Coordinate` for the geo helpers, so a fix travels as one value instead of
10
+ a pair of loose floats, and a :class:`Boundary` enum for the crossing states.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import enum
16
+ from typing import NamedTuple
17
+
18
+ from pamoja._native import Anomaly, Median, Trend, Window
19
+ from pamoja._native import window_capacity as _window_capacity
20
+ from pamoja._native import Calibration, Debounce, Depletion, Kalman, Pid, Ramp, Smoother, Surge, Thermostat
21
+ from pamoja._native import Geofence as _NativeGeofence
22
+ from pamoja._native import bearing_between as _bearing_between
23
+ from pamoja._native import deadband
24
+ from pamoja._native import distance_between as _distance_between
25
+
26
+ #: How many readings a windowed helper keeps.
27
+ WINDOW_CAPACITY = _window_capacity()
28
+
29
+ __all__ = [
30
+ "Window",
31
+ "WINDOW_CAPACITY",
32
+ "Trend",
33
+ "Median",
34
+ "Anomaly",
35
+ "Boundary",
36
+ "Calibration",
37
+ "Coordinate",
38
+ "Debounce",
39
+ "Depletion",
40
+ "Geofence",
41
+ "Kalman",
42
+ "Pid",
43
+ "Ramp",
44
+ "Smoother",
45
+ "Surge",
46
+ "Thermostat",
47
+ "bearing_between",
48
+ "deadband",
49
+ "distance_between",
50
+ ]
51
+
52
+
53
+ class Coordinate(NamedTuple):
54
+ """A latitude and longitude in degrees."""
55
+
56
+ #: Degrees north of the equator, negative for south.
57
+ latitude: float
58
+ #: Degrees east of the prime meridian, negative for west.
59
+ longitude: float
60
+
61
+
62
+ class Boundary(str, enum.Enum):
63
+ """Where a fix sits relative to a :class:`Geofence`, including a crossing."""
64
+
65
+ #: The fix is inside the fence and was inside before, or is the first fix inside.
66
+ INSIDE = "Inside"
67
+ #: The fix is outside the fence and was outside before, or is the first fix outside.
68
+ OUTSIDE = "Outside"
69
+ #: The fix just crossed from inside to outside: the moment to raise a breach alert.
70
+ EXITED = "Exited"
71
+ #: The fix just crossed from outside back inside.
72
+ ENTERED = "Entered"
73
+
74
+
75
+ class Geofence:
76
+ """Keeps a tracked point inside an area, and notices when it leaves.
77
+
78
+ A fence is a centre and a radius; feeding it successive fixes reports whether
79
+ each is inside or outside and, crucially, the single fix that crossed, so an
80
+ alert fires once on the crossing rather than on every fix while away.
81
+
82
+ Example::
83
+
84
+ pen = Geofence(Coordinate(-1.2921, 36.8219), 50.0)
85
+ pen.update(Coordinate(-1.2921, 36.8219)) # Boundary.INSIDE
86
+ pen.update(Coordinate(-1.2930, 36.8219)) # Boundary.EXITED
87
+ """
88
+
89
+ __slots__ = ("_native",)
90
+
91
+ def __init__(self, center: Coordinate, radius_m: float) -> None:
92
+ """Create a circular fence around a centre fix.
93
+
94
+ :param center: The centre of the fence.
95
+ :param radius_m: The fence radius, in metres.
96
+ """
97
+ self._native = _NativeGeofence(center.latitude, center.longitude, radius_m)
98
+
99
+ def update(self, point: Coordinate) -> Boundary:
100
+ """Feed a fix in and report where it sits, including a single crossing.
101
+
102
+ :param point: The latest fix.
103
+ :returns: The boundary state for this fix.
104
+ """
105
+ return Boundary(self._native.update(point.latitude, point.longitude))
106
+
107
+ def contains(self, point: Coordinate) -> bool:
108
+ """Report whether a fix lies inside, without recording a crossing.
109
+
110
+ :param point: The fix to test.
111
+ :returns: ``True`` if the fix is inside the fence.
112
+ """
113
+ return self._native.contains(point.latitude, point.longitude)
114
+
115
+
116
+ def distance_between(origin: Coordinate, destination: Coordinate) -> float:
117
+ """Return the great-circle distance between two coordinates, in metres.
118
+
119
+ :param origin: The coordinate to measure from.
120
+ :param destination: The coordinate to measure to.
121
+ :returns: The distance in metres.
122
+ """
123
+ return _distance_between(
124
+ origin.latitude, origin.longitude, destination.latitude, destination.longitude
125
+ )
126
+
127
+
128
+ def bearing_between(origin: Coordinate, destination: Coordinate) -> float:
129
+ """Return the initial bearing from one coordinate to another, in degrees.
130
+
131
+ :param origin: The coordinate to measure from.
132
+ :param destination: The coordinate to measure to.
133
+ :returns: The bearing in degrees, clockwise from north.
134
+ """
135
+ return _bearing_between(
136
+ origin.latitude, origin.longitude, destination.latitude, destination.longitude
137
+ )
File without changes
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pamoja-kit"
7
+ version = "0.1.17"
8
+ description = "Plain-language helper math: smoothing, calibration, PID and thermostat control, trend and surge prediction, rolling windows, kinematics, and geo."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ license-files = ["LICENSE-MIT"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "molexxxx" }]
14
+ keywords = ["pamoja", "iot", "robotics", "kit"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Typing :: Typed",
20
+ ]
21
+ dependencies = [
22
+ "pamoja-native==0.1.17",
23
+ ]
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/molexxxx/pamoja"
27
+ Documentation = "https://pamoja.molex.cloud/docs/guides/kit.html"
28
+
29
+ [tool.hatch.build.targets.wheel]
30
+ packages = ["pamoja"]