mema 0.1.0__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.
mema-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: mema
3
+ Version: 0.1.0
4
+ Summary: MEMA
5
+ Author-email: Sam Griesemer <git@olog.io>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://doc.olog.io/mema
8
+ Project-URL: Documentation, https://doc.olog.io/mema
9
+ Project-URL: Repository, https://git.olog.io/olog/mema
10
+ Project-URL: Issues, https://git.olog.io/olog/mema/issues
11
+ Keywords: machine-learning
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: End Users/Desktop
17
+ Requires-Python: >=3.13
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: colorama>=0.4.6
20
+ Requires-Dist: matplotlib>=3.10.8
21
+ Requires-Dist: numpy>=2.4.1
22
+ Requires-Dist: sbi>=0.25.0
23
+ Requires-Dist: tensorboard>=2.20.0
24
+ Requires-Dist: torch>=2.5.1
25
+ Requires-Dist: tqdm>=4.67.1
26
+ Provides-Extra: dev
27
+ Requires-Dist: ipykernel; extra == "dev"
28
+ Provides-Extra: doc
29
+ Requires-Dist: furo; extra == "doc"
30
+ Requires-Dist: myst-parser; extra == "doc"
31
+ Requires-Dist: sphinx; extra == "doc"
32
+ Requires-Dist: sphinx-togglebutton; extra == "doc"
33
+ Requires-Dist: sphinx-autodoc-typehints; extra == "doc"
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest; extra == "test"
36
+
37
+ # Overview
38
+ Package summary goes here, ideally with a diagram
39
+
40
+ # Install
41
+ Installation instructions
42
+
43
+ ```sh
44
+ pip install <package>
45
+ ```
46
+
47
+ or as a CLI tool
48
+
49
+ ```sh
50
+ uv tool install <package>
51
+ ```
52
+
53
+ # Development
54
+ - Initialize/synchronize the project with `uv sync`, creating a virtual
55
+ environment with base package dependencies.
56
+ - Depending on needs, install the development dependencies with `uv sync
57
+ --extra dev`.
58
+
59
+ # Testing
60
+ - To run the unit tests, make sure to first have the test dependencies
61
+ installed with `uv sync --extra test`, then run `make test`.
62
+ - For notebook testing, run `make install-kernel` to make the environment
63
+ available as a Jupyter kernel (to be selected when running notebooks).
64
+
65
+ # Documentation
66
+ - Install the documentation dependencies with `uv sync --extra doc`.
67
+ - Run `make docs-build` (optionally preceded by `make docs-clean`), and serve
68
+ locally with `docs-serve`.
69
+
70
+ # Development remarks
71
+ - Across `Trainer` / `Estimator` / `Dataset`, I've considered a
72
+ `ParamSpec`-based typing scheme to better orchestrate alignment in the
73
+ `Trainer.train()` loop, e.g., so we can statically check whether a dataset
74
+ appears to be fulfilling the argument requirements for the estimator's
75
+ `loss()` / `metrics()` methods. Something like
76
+
77
+ ```py
78
+ class Estimator[**P](nn.Module):
79
+ def loss(
80
+ self,
81
+ input: Tensor,
82
+ *args: P.args,
83
+ **kwargs: P.kwargs,
84
+ ) -> Generator:
85
+ ...
86
+
87
+ class Trainer[**P]:
88
+ def __init__(
89
+ self,
90
+ estimator: Estimator[P],
91
+ ...
92
+ ): ...
93
+ ```
94
+
95
+ might be how we begin threading signatures. But ensuring dataset items can
96
+ match `P` is challenging. You can consider a "packed" object where we
97
+ obfuscate passing data through `P`-signatures:
98
+
99
+ ```py
100
+ class PackedItem[**P]:
101
+ def __init__(self, *args: P.args, **kwargs: P.kwargs) -> None:
102
+ self._args = args
103
+ self._kwargs = kwargs
104
+
105
+ def apply[R](self, func: Callable[P, R]) -> R:
106
+ return func(*self._args, **self._kwargs)
107
+
108
+
109
+ class BatchedDataset[U, R, I, **P](Dataset):
110
+ @abstractmethod
111
+ def _process_item_data(
112
+ self,
113
+ item_data: I,
114
+ item_index: int,
115
+ ) -> PackedItem[P]:
116
+ ...
117
+
118
+ def __iter__(self) -> Iterator[PackedItem[P]]:
119
+ ...
120
+ ```
121
+
122
+ Meaningfully shaping those signatures is what remains, but you can't really
123
+ do this, not with typical type expression flexibility. For instance, if I'm
124
+ trying to appropriately type my base `TupleDataset`:
125
+
126
+ ```py
127
+ class SequenceDataset[I, **P](HomogenousDataset[int, I, I, P]):
128
+ ...
129
+
130
+ class TupleDataset[I](SequenceDataset[tuple[I, ...], ??]):
131
+ ...
132
+ ```
133
+
134
+ Here there's no way for me to shape a `ParamSpec` to indicate arbitrarily
135
+ many arguments of a fixed type (`I` in this case) to allow me to unpack my
136
+ item tuples into an appropriate `PackedItem`.
137
+
138
+ Until this (among other issues) becomes clearer, I'm setting up around a
139
+ simpler `TypedDict` type variable. We won't have particularly strong static
140
+ checks for item alignment inside `Trainer`, but this seems about as good as I
141
+ can get around the current infrastructure.
mema-0.1.0/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Overview
2
+ Package summary goes here, ideally with a diagram
3
+
4
+ # Install
5
+ Installation instructions
6
+
7
+ ```sh
8
+ pip install <package>
9
+ ```
10
+
11
+ or as a CLI tool
12
+
13
+ ```sh
14
+ uv tool install <package>
15
+ ```
16
+
17
+ # Development
18
+ - Initialize/synchronize the project with `uv sync`, creating a virtual
19
+ environment with base package dependencies.
20
+ - Depending on needs, install the development dependencies with `uv sync
21
+ --extra dev`.
22
+
23
+ # Testing
24
+ - To run the unit tests, make sure to first have the test dependencies
25
+ installed with `uv sync --extra test`, then run `make test`.
26
+ - For notebook testing, run `make install-kernel` to make the environment
27
+ available as a Jupyter kernel (to be selected when running notebooks).
28
+
29
+ # Documentation
30
+ - Install the documentation dependencies with `uv sync --extra doc`.
31
+ - Run `make docs-build` (optionally preceded by `make docs-clean`), and serve
32
+ locally with `docs-serve`.
33
+
34
+ # Development remarks
35
+ - Across `Trainer` / `Estimator` / `Dataset`, I've considered a
36
+ `ParamSpec`-based typing scheme to better orchestrate alignment in the
37
+ `Trainer.train()` loop, e.g., so we can statically check whether a dataset
38
+ appears to be fulfilling the argument requirements for the estimator's
39
+ `loss()` / `metrics()` methods. Something like
40
+
41
+ ```py
42
+ class Estimator[**P](nn.Module):
43
+ def loss(
44
+ self,
45
+ input: Tensor,
46
+ *args: P.args,
47
+ **kwargs: P.kwargs,
48
+ ) -> Generator:
49
+ ...
50
+
51
+ class Trainer[**P]:
52
+ def __init__(
53
+ self,
54
+ estimator: Estimator[P],
55
+ ...
56
+ ): ...
57
+ ```
58
+
59
+ might be how we begin threading signatures. But ensuring dataset items can
60
+ match `P` is challenging. You can consider a "packed" object where we
61
+ obfuscate passing data through `P`-signatures:
62
+
63
+ ```py
64
+ class PackedItem[**P]:
65
+ def __init__(self, *args: P.args, **kwargs: P.kwargs) -> None:
66
+ self._args = args
67
+ self._kwargs = kwargs
68
+
69
+ def apply[R](self, func: Callable[P, R]) -> R:
70
+ return func(*self._args, **self._kwargs)
71
+
72
+
73
+ class BatchedDataset[U, R, I, **P](Dataset):
74
+ @abstractmethod
75
+ def _process_item_data(
76
+ self,
77
+ item_data: I,
78
+ item_index: int,
79
+ ) -> PackedItem[P]:
80
+ ...
81
+
82
+ def __iter__(self) -> Iterator[PackedItem[P]]:
83
+ ...
84
+ ```
85
+
86
+ Meaningfully shaping those signatures is what remains, but you can't really
87
+ do this, not with typical type expression flexibility. For instance, if I'm
88
+ trying to appropriately type my base `TupleDataset`:
89
+
90
+ ```py
91
+ class SequenceDataset[I, **P](HomogenousDataset[int, I, I, P]):
92
+ ...
93
+
94
+ class TupleDataset[I](SequenceDataset[tuple[I, ...], ??]):
95
+ ...
96
+ ```
97
+
98
+ Here there's no way for me to shape a `ParamSpec` to indicate arbitrarily
99
+ many arguments of a fixed type (`I` in this case) to allow me to unpack my
100
+ item tuples into an appropriate `PackedItem`.
101
+
102
+ Until this (among other issues) becomes clearer, I'm setting up around a
103
+ simpler `TypedDict` type variable. We won't have particularly strong static
104
+ checks for item alignment inside `Trainer`, but this seems about as good as I
105
+ can get around the current infrastructure.
File without changes