relib 1.1.0__tar.gz → 1.1.1__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.
- {relib-1.1.0 → relib-1.1.1}/.gitignore +1 -1
- {relib-1.1.0 → relib-1.1.1}/PKG-INFO +3 -3
- {relib-1.1.0 → relib-1.1.1}/pyproject.toml +3 -3
- {relib-1.1.0 → relib-1.1.1}/relib/__init__.py +4 -0
- {relib-1.1.0 → relib-1.1.1}/relib/utils.py +21 -6
- {relib-1.1.0 → relib-1.1.1}/LICENSE +0 -0
- {relib-1.1.0 → relib-1.1.1}/README.md +0 -0
- {relib-1.1.0 → relib-1.1.1}/relib/hashing.py +0 -0
- {relib-1.1.0 → relib-1.1.1}/relib/measure_duration.py +0 -0
- {relib-1.1.0 → relib-1.1.1}/relib/raypipe.py +0 -0
- {relib-1.1.0 → relib-1.1.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: relib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.1
|
4
4
|
Project-URL: Repository, https://github.com/Reddan/relib.git
|
5
5
|
Author: Hampus Hallman
|
6
6
|
License: Copyright 2023 Hampus Hallman
|
@@ -12,5 +12,5 @@ License: Copyright 2023 Hampus Hallman
|
|
12
12
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Python: >=3.12
|
15
|
-
Requires-Dist: numpy
|
16
|
-
Requires-Dist: termcolor
|
15
|
+
Requires-Dist: numpy
|
16
|
+
Requires-Dist: termcolor
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from typing import TypeVar, Iterable, Callable, Any, cast, overload
|
2
2
|
from itertools import chain
|
3
3
|
import numpy as np
|
4
|
+
import os
|
4
5
|
import re
|
5
6
|
|
6
7
|
T = TypeVar('T')
|
@@ -8,6 +9,9 @@ U = TypeVar('U')
|
|
8
9
|
K = TypeVar('K')
|
9
10
|
K1, K2, K3, K4, K5, K6 = TypeVar('K1'), TypeVar('K2'), TypeVar('K3'), TypeVar('K4'), TypeVar('K5'), TypeVar('K6')
|
10
11
|
|
12
|
+
def clear_console():
|
13
|
+
os.system("cls" if os.name == "nt" else "clear")
|
14
|
+
|
11
15
|
def non_none(obj: T | None) -> T:
|
12
16
|
assert obj is not None
|
13
17
|
return obj
|
@@ -129,23 +133,34 @@ def deepen_dict(d: dict[tuple[K1, K2, K3, K4, K5, K6], U]) -> dict[K1, dict[K2,
|
|
129
133
|
|
130
134
|
def deepen_dict(d: dict[tuple[Any, ...], Any]) -> dict:
|
131
135
|
output = {}
|
136
|
+
if () in d:
|
137
|
+
return d[()]
|
132
138
|
for (*tail, head), value in d.items():
|
133
139
|
curr = output
|
134
140
|
for key in tail:
|
135
|
-
|
136
|
-
curr[key] = {}
|
137
|
-
curr = curr[key]
|
141
|
+
curr = curr.setdefault(key, {})
|
138
142
|
curr[head] = value
|
139
143
|
return output
|
140
144
|
|
145
|
+
def flatten_dict_inner(d, prefix=()):
|
146
|
+
for key, value in d.items():
|
147
|
+
if not isinstance(value, dict) or value == {}:
|
148
|
+
yield prefix + (key,), value
|
149
|
+
else:
|
150
|
+
yield from flatten_dict_inner(value, prefix + (key,))
|
151
|
+
|
152
|
+
def flatten_dict(deep_dict: dict, prefix=()) -> dict:
|
153
|
+
return dict(flatten_dict_inner(deep_dict, prefix))
|
154
|
+
|
141
155
|
def group(pairs: Iterable[tuple[K, T]]) -> dict[K, list[T]]:
|
142
156
|
values_by_key = {}
|
143
157
|
for key, value in pairs:
|
144
|
-
|
145
|
-
values_by_key[key] = []
|
146
|
-
values_by_key[key].append(value)
|
158
|
+
values_by_key.setdefault(key, []).append(value)
|
147
159
|
return values_by_key
|
148
160
|
|
161
|
+
def reversed_enumerate(l: list[T] | tuple[T, ...]) -> Iterable[tuple[int, T]]:
|
162
|
+
return zip(reversed(range(len(l))), reversed(l))
|
163
|
+
|
149
164
|
def get_at(d: dict, keys: Iterable[Any], default: T) -> T:
|
150
165
|
try:
|
151
166
|
for key in keys:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|