python-misc-utils 0.21__tar.gz → 0.23__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.
- {python_misc_utils-0.21 → python_misc_utils-0.23}/PKG-INFO +1 -1
- python_misc_utils-0.23/py_misc_utils/enum.py +45 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/np_utils.py +4 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/num_utils.py +12 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/python_misc_utils.egg-info/PKG-INFO +1 -1
- {python_misc_utils-0.21 → python_misc_utils-0.23}/python_misc_utils.egg-info/SOURCES.txt +1 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/setup.py +1 -1
- {python_misc_utils-0.21 → python_misc_utils-0.23}/LICENSE +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/README.md +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/__init__.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/abs_timeout.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/alog.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/app_main.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/archive_streamer.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/assert_checks.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/ast_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/async_manager.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/break_control.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/buffered_iterator.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/cached_file.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/call_limiter.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/call_result_selector.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/cleanups.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/cmd.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/compression.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/cond_waiter.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/context_base.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/context_managers.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/core_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/daemon_process.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/data_cache.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/date_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/debug.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/dyn_modules.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/dynamod.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/env_config.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/executor.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/file_overwrite.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fin_wrap.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fp_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs/__init__.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs/file_fs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs/ftp_fs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs/gcs_fs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs/http_fs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs/s3_fs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs_base.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/fs_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/gcs_fs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/gen_indices.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/gfs.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/git_repo.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/global_namespace.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/http_async_fetcher.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/http_server.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/http_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/img_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/infix_op.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/inspect_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/iostream.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/iter_file.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/key_wrap.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/lazy_import.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/lockfile.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/mem_size.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/mirror_from.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/mmap.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/module_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/moving_average.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/msgpack_streamer.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/multi_wait.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/multiprocessing.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/named_array.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/no_break.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/no_except.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/np_ml_framework.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/ntuple_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/obj.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/object_cache.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/object_tracker.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/ordered_set.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/osfd.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/packet.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/parquet_streamer.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/pd_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/periodic_task.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/pickle_wrap.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/pipeline.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/remap_pickle.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/resource_manager.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/rnd_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/run_once.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/scheduler.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/select_params.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/signal.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/skl_utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/split.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/state.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/std_module.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/stream_dataframe.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/streamed_file.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/tempdir.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/template_replace.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/tensor_stream.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/thread_context.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/throttle.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/time_trigger.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/timegen.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/traceback.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/tracking_executor.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/transform_array.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/uncompress.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/url_fetcher.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/utils.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/varint.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/virt_array.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/weak_call.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/work_results.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/py_misc_utils/writeback_file.py +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/pyproject.toml +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/python_misc_utils.egg-info/dependency_links.txt +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/python_misc_utils.egg-info/requires.txt +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/python_misc_utils.egg-info/top_level.txt +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/setup.cfg +0 -0
- {python_misc_utils-0.21 → python_misc_utils-0.23}/test/test_runner.py +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import types
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class _EnumBase:
|
|
6
|
+
|
|
7
|
+
def __init__(self, fields, base=0):
|
|
8
|
+
enfields = re.split(r'\s*,\s*', fields) if isinstance(fields, str) else fields
|
|
9
|
+
|
|
10
|
+
next_id, values = base, dict()
|
|
11
|
+
for field in enfields:
|
|
12
|
+
if isinstance(field, (list, tuple)):
|
|
13
|
+
fname, fvalue = field
|
|
14
|
+
else:
|
|
15
|
+
m = re.match(r'(\w+)\s*=\s*(\d+)', field)
|
|
16
|
+
if m:
|
|
17
|
+
fname, fvalue = m.group(1), int(m.group(2))
|
|
18
|
+
else:
|
|
19
|
+
fname, fvalue = field, next_id
|
|
20
|
+
|
|
21
|
+
assert fvalue >= next_id, f'{fvalue} < {next_id}'
|
|
22
|
+
|
|
23
|
+
setattr(self, fname, fvalue)
|
|
24
|
+
values[fname] = fvalue
|
|
25
|
+
next_id = max(fvalue, next_id) + 1
|
|
26
|
+
|
|
27
|
+
self._first = base
|
|
28
|
+
self._last = base + len(enfields) - 1
|
|
29
|
+
self._values = values
|
|
30
|
+
self._names = {evalue: fname for fname, evalue in values.items()}
|
|
31
|
+
|
|
32
|
+
def __len__(self):
|
|
33
|
+
return len(self._values)
|
|
34
|
+
|
|
35
|
+
def __repr__(self):
|
|
36
|
+
fields = [f'{k}={v}' for k, v in self._values.items()]
|
|
37
|
+
|
|
38
|
+
return self.__class__.__name__ + '(' + ', '.join(fields) + ')'
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def make_enum(name, fields, base=0):
|
|
42
|
+
cls = types.new_class(name, bases=(_EnumBase,))
|
|
43
|
+
|
|
44
|
+
return cls(fields, base=base)
|
|
45
|
+
|
|
@@ -170,6 +170,10 @@ def normalize(data, axis=None):
|
|
|
170
170
|
return (data - mean) / std
|
|
171
171
|
|
|
172
172
|
|
|
173
|
+
def hasher(value):
|
|
174
|
+
return hash((value.dtype, tuple(value.shape), value.tobytes()))
|
|
175
|
+
|
|
176
|
+
|
|
173
177
|
def moving_average(data, window, include_current=True):
|
|
174
178
|
weights = np.ones(window, dtype=data.dtype) / window
|
|
175
179
|
pdata = np.pad(data, (window, window), mode='edge')
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
1
3
|
|
|
2
4
|
def prime_factors(n):
|
|
3
5
|
i = 2
|
|
@@ -58,3 +60,13 @@ def round_down(v, step):
|
|
|
58
60
|
def mix(a, b, gamma):
|
|
59
61
|
return a * gamma + b * (1.0 - gamma)
|
|
60
62
|
|
|
63
|
+
|
|
64
|
+
def perfect_power(value, base):
|
|
65
|
+
vlog = round(math.log(value, base))
|
|
66
|
+
|
|
67
|
+
return vlog if base ** vlog == value else None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def address_bits(size):
|
|
71
|
+
return (size - 1).bit_length() if size > 1 else 1
|
|
72
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_misc_utils-0.21 → python_misc_utils-0.23}/python_misc_utils.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|