theseusplot 0.1.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.
- theseusplot/__init__.py +11 -0
- theseusplot/_config.py +43 -0
- theseusplot/_ship.py +1224 -0
- theseusplot/py.typed +1 -0
- theseusplot-0.1.0.dist-info/METADATA +315 -0
- theseusplot-0.1.0.dist-info/RECORD +7 -0
- theseusplot-0.1.0.dist-info/WHEEL +4 -0
theseusplot/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Public API for TheseusPlot.py."""
|
|
2
|
+
|
|
3
|
+
from theseusplot._config import ContinuousConfig, continuous_config
|
|
4
|
+
from theseusplot._ship import ShipOfTheseus, create_ship
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"ContinuousConfig",
|
|
8
|
+
"ShipOfTheseus",
|
|
9
|
+
"continuous_config",
|
|
10
|
+
"create_ship",
|
|
11
|
+
]
|
theseusplot/_config.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Configuration objects for TheseusPlot.py."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Literal
|
|
7
|
+
|
|
8
|
+
SplitMethod = Literal["count", "width", "rate"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class ContinuousConfig:
|
|
13
|
+
"""Configuration for discretizing continuous variables."""
|
|
14
|
+
|
|
15
|
+
n: int = 10
|
|
16
|
+
pretty: bool = True
|
|
17
|
+
split: SplitMethod = "count"
|
|
18
|
+
breaks: tuple[float, ...] | None = None
|
|
19
|
+
|
|
20
|
+
def __post_init__(self) -> None:
|
|
21
|
+
if self.n <= 0:
|
|
22
|
+
msg = "n must be a positive integer."
|
|
23
|
+
raise ValueError(msg)
|
|
24
|
+
if self.split not in {"count", "width", "rate"}:
|
|
25
|
+
msg = "split must be one of 'count', 'width', or 'rate'."
|
|
26
|
+
raise ValueError(msg)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def continuous_config(
|
|
30
|
+
n: int = 10,
|
|
31
|
+
pretty: bool = True,
|
|
32
|
+
split: SplitMethod = "count",
|
|
33
|
+
breaks: list[float] | tuple[float, ...] | None = None,
|
|
34
|
+
) -> ContinuousConfig:
|
|
35
|
+
"""Create a continuous variable configuration."""
|
|
36
|
+
|
|
37
|
+
normalized_breaks = tuple(breaks) if breaks is not None else None
|
|
38
|
+
return ContinuousConfig(
|
|
39
|
+
n=n,
|
|
40
|
+
pretty=pretty,
|
|
41
|
+
split=split,
|
|
42
|
+
breaks=normalized_breaks,
|
|
43
|
+
)
|