danielutils 0.9.83__tar.gz → 0.9.84__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.
- {danielutils-0.9.83/danielutils.egg-info → danielutils-0.9.84}/PKG-INFO +2 -2
- {danielutils-0.9.83 → danielutils-0.9.84}/README.md +1 -1
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/__init__.py +2 -1
- danielutils-0.9.84/danielutils/context_managers/__init__.py +3 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/context_managers/attr_context.py +2 -1
- danielutils-0.9.84/danielutils/context_managers/multi_context.py +23 -0
- danielutils-0.9.84/danielutils/context_managers/state_context.py +16 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/context_managers/temporary_file.py +2 -1
- danielutils-0.9.84/danielutils/custom_types.py +17 -0
- danielutils-0.9.84/danielutils/file_specifications/__init__.py +70 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/__init__.py +2 -1
- danielutils-0.9.84/danielutils/functions/foreach.py +14 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/print_.py +20 -17
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/progress_bar/ascii_progress_bar.py +47 -10
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/progress_bar/progress_bar.py +16 -6
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/progress_bar/progress_bar_pool.py +21 -3
- danielutils-0.9.84/danielutils/protocols/__init__.py +3 -0
- danielutils-0.9.84/danielutils/protocols/serializable.py +28 -0
- danielutils-0.9.84/danielutils/university/__init__.py +7 -0
- danielutils-0.9.84/danielutils/university/computability_and_complexity/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/computability_and_complexity/discreate_finite_automaton.py +68 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/__init__.py +3 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/encoding.py +35 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/__init__.py +4 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/lossless_encoding.py +10 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/lzw.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/run_length.py +22 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossy/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossy/lossy_encoding.py +10 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/__init__.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/gaussian.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/gradient.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/hough.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/laplacian.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/transformation.py +10 -0
- danielutils-0.9.84/danielutils/university/linear_algebra/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/linear_algebra/matrix.py +398 -0
- danielutils-0.9.84/danielutils/university/machine_learning/__init__.py +0 -0
- danielutils-0.9.84/danielutils/university/machine_learning/activation_functions/__init__.py +2 -0
- danielutils-0.9.84/danielutils/university/machine_learning/activation_functions/activation_function.py +11 -0
- danielutils-0.9.84/danielutils/university/machine_learning/activation_functions/relu.py +11 -0
- danielutils-0.9.84/danielutils/university/machine_learning/neuron.py +15 -0
- danielutils-0.9.84/danielutils/university/probability/conditional_variable/continuous/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84/danielutils.egg-info}/PKG-INFO +2 -2
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils.egg-info/SOURCES.txt +31 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/pyproject.toml +1 -1
- danielutils-0.9.83/danielutils/context_managers/__init__.py +0 -2
- danielutils-0.9.83/danielutils/protocols/__init__.py +0 -2
- danielutils-0.9.83/danielutils/university/__init__.py +0 -3
- {danielutils-0.9.83 → danielutils-0.9.84}/LICENSE +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/MANIFEST.in +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/database/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/database/cached_database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/database/database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/database/redis_database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/multi_id.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/worker.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/worker_pool.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/abstractions/repl.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/aliases.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/frange.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/factory.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/tlist.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/tset.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/colors.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/convenience.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/conversions/main_conversions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/conversions/specialized_conversions/to_int.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/comparer.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/graph/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/graph/binary_node.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/graph/graph.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/graph/multinode.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/graph/node.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/heap/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/heap/heap.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/heap/max_heap.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/heap/min_heap.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/queue/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/queue/atomic_queue.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/queue/priority_queue.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/queue/queue.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/stack.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/trees/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/trees/binary_syntax_tree.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/data_structures/trees/binary_tree.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/date.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/date_time.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/atomic.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/attach.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/decorate_conditionally.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/final.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/limit_recursion.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/memo.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/overload.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/partially_implemented.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/processify.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/singleton.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/timeout.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/total_ordering.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/decorators/validate.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/areoneof.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/flatten.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/isoftype.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/isoneof.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/multiloop.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/parallel_for.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/subseteq.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/functions/types_subseteq.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/generators/generator_from_stream.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/generators/join_generators.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/internet.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/io_.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/math_/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/math_/constants.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/math_/functions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/math_/math_print.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/math_/math_symbols.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/metaclasses/interface.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/mock_/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/mock_/mock_database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/mock_/mock_module.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/path.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/progress_bar/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/protocols/dictable.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/protocols/evaluable.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/py.typed +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/class_/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/class_/class_reflection.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/file/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/file/file_reflection.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/function/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/function/function_reflections.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/callstack.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/get_traceback.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/os_.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/packages.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/python_version.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/signals.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/interpreter/tracer.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/module/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/reflection/module/package_reflection.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/layered_command.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/text.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/time.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/databases/all.py +0 -0
- /danielutils-0.9.83/danielutils/university/probability/conditional_variable/continuous/__init__.py → /danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/huffman.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/oop/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/oop/observer.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/oop/strategy.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/conditional_variable.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/bernoulli.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/binomial.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/discrete.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/geometric.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/poisson.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/uniform.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/distributions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/expressions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/expressions/accumulation_expression.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/expressions/probability_expression.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/funcs/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/funcs/covariance.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/funcs/expected_value.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/funcs/probability_function.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/funcs/variance.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/operator.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/protocols.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/supp.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/university/probability/transformation.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils/versioned_imports.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/setup.cfg +0 -0
- {danielutils-0.9.83 → danielutils-0.9.84}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.84
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Author-email: danielnachumdev <danielnachumdev@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -41,7 +41,7 @@ License-File: LICENSE
|
|
|
41
41
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
42
42
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
43
43
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
44
|
-
# danielutils v=0.9.
|
|
44
|
+
# danielutils v=0.9.84
|
|
45
45
|
A utils library for things that I find useful for my coding workflow.\
|
|
46
46
|
Feel free to use and / or contribute / improve my code :)
|
|
47
47
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
5
5
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
6
6
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
7
|
-
# danielutils v=0.9.
|
|
7
|
+
# danielutils v=0.9.84
|
|
8
8
|
A utils library for things that I find useful for my coding workflow.\
|
|
9
9
|
Feel free to use and / or contribute / improve my code :)
|
|
10
10
|
|
|
@@ -18,11 +18,11 @@ from .protocols import *
|
|
|
18
18
|
from .reflection import *
|
|
19
19
|
from .decorators import *
|
|
20
20
|
# ========== NEEDS REFLECTION ==========
|
|
21
|
-
from .progress_bar import *
|
|
22
21
|
# ========== NEEDS DECORATORS ==========
|
|
23
22
|
from .colors import *
|
|
24
23
|
# ========== NEEDS BOTH ==========
|
|
25
24
|
|
|
25
|
+
from .progress_bar import *
|
|
26
26
|
from .functions import *
|
|
27
27
|
from .io_ import *
|
|
28
28
|
from .system import *
|
|
@@ -40,3 +40,4 @@ from .generators import *
|
|
|
40
40
|
from .university import *
|
|
41
41
|
from .mock_ import *
|
|
42
42
|
from .context_managers import *
|
|
43
|
+
from .file_specifications import *
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import ContextManager
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MultiContext(ContextManager):
|
|
5
|
+
def __init__(self, *contexts: ContextManager):
|
|
6
|
+
self.contexts = contexts
|
|
7
|
+
|
|
8
|
+
def __enter__(self):
|
|
9
|
+
for context in self.contexts:
|
|
10
|
+
context.__enter__()
|
|
11
|
+
return self
|
|
12
|
+
|
|
13
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
14
|
+
for context in self.contexts:
|
|
15
|
+
context.__exit__(exc_type, exc_val, exc_tb)
|
|
16
|
+
|
|
17
|
+
def __getitem__(self, index):
|
|
18
|
+
return self.contexts[index]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"MultiContext",
|
|
23
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from contextlib import contextmanager
|
|
2
|
+
from ..custom_types import Procedure
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@contextmanager
|
|
6
|
+
def StateContext(set_state: Procedure, restore_state: Procedure):
|
|
7
|
+
try:
|
|
8
|
+
set_state()
|
|
9
|
+
yield
|
|
10
|
+
finally:
|
|
11
|
+
restore_state()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
'StateContext'
|
|
16
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeAlias, Callable, TypeVar, Generic
|
|
2
|
+
|
|
3
|
+
T = TypeVar('T')
|
|
4
|
+
U = TypeVar('U')
|
|
5
|
+
Procedure: TypeAlias = Callable[[], None]
|
|
6
|
+
Supplier: TypeAlias = Callable[[], T]
|
|
7
|
+
Consumer: TypeAlias = Callable[[T], None]
|
|
8
|
+
Predicate: TypeAlias = Callable[[], bool]
|
|
9
|
+
Mapper: TypeAlias = Callable[[T], U]
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
'Procedure',
|
|
13
|
+
'Supplier',
|
|
14
|
+
'Consumer',
|
|
15
|
+
'Predicate',
|
|
16
|
+
'Mapper'
|
|
17
|
+
]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class Field:
|
|
8
|
+
"""
|
|
9
|
+
A Field object for a Section in a file
|
|
10
|
+
|
|
11
|
+
Params:
|
|
12
|
+
name (str): The name of the field
|
|
13
|
+
size (int): The size of the field in bytes
|
|
14
|
+
type (Field.Type): The type of the field
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
class Type(Enum):
|
|
18
|
+
INTEGER = "INTEGER"
|
|
19
|
+
FLOAT = "FLOAT"
|
|
20
|
+
STRING = "STRING"
|
|
21
|
+
BOOL = "BOOL"
|
|
22
|
+
|
|
23
|
+
name: str
|
|
24
|
+
size: int
|
|
25
|
+
type: Type = Type.INTEGER
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class Section:
|
|
30
|
+
name: str
|
|
31
|
+
prefix: bytes
|
|
32
|
+
fields: Optional[list[Field]]
|
|
33
|
+
is_optional: bool = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FileSpecification:
|
|
37
|
+
def __init__(self, long_name: str, short_name: str, extension: str, specification: str, sections: list[Section]):
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
long_name:
|
|
42
|
+
short_name:
|
|
43
|
+
extension:
|
|
44
|
+
specification:
|
|
45
|
+
sections:
|
|
46
|
+
"""
|
|
47
|
+
self.long_name = long_name
|
|
48
|
+
self.short_name = short_name
|
|
49
|
+
self.extension = extension
|
|
50
|
+
self.specification = specification
|
|
51
|
+
self.sections = sections
|
|
52
|
+
|
|
53
|
+
def open(self, path: str):
|
|
54
|
+
if not path.endswith(self.extension):
|
|
55
|
+
raise ValueError(f"Invalid file extension, expected {self.extension}")
|
|
56
|
+
with open(path, "rb") as f:
|
|
57
|
+
lines = f.readlines()
|
|
58
|
+
for line in lines:
|
|
59
|
+
for b in line:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
return lines
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
"Field",
|
|
67
|
+
"Section",
|
|
68
|
+
"FileSpecification",
|
|
69
|
+
"FileSpecification",
|
|
70
|
+
]
|
|
@@ -26,7 +26,7 @@ def mprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
|
26
26
|
stream.write(sep.join([mprint_parse_one(s) for s in args]) + end)
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
@deprecate("The built-in 'print' function has an argument called 'file', use this instead")
|
|
29
|
+
@deprecate("The built-in 'print' function has an argument called 'file', use this instead") # type:ignore
|
|
30
30
|
def sprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
31
31
|
"""Writes a string representation of the given arguments to the specified stream.
|
|
32
32
|
|
|
@@ -42,7 +42,7 @@ def sprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
|
42
42
|
stream.write(sep.join(args) + end)
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
@atomic
|
|
45
|
+
@atomic # type:ignore
|
|
46
46
|
def aprint(*args, sep=" ", end="\n") -> None:
|
|
47
47
|
"""Prints a string representation of the given arguments to the console.
|
|
48
48
|
|
|
@@ -58,17 +58,18 @@ def aprint(*args, sep=" ", end="\n") -> None:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
class BetterPrinter:
|
|
61
|
-
def __init__(self, thread_safe: bool = False):
|
|
61
|
+
def __init__(self, stream: IO = sys.stdout, thread_safe: bool = False):
|
|
62
|
+
self.stream: IO = stream
|
|
62
63
|
if thread_safe:
|
|
63
|
-
self.__call__ = atomic(self.__call__)
|
|
64
|
+
self.__call__ = atomic(self.__call__) # type:ignore
|
|
64
65
|
self._current_row: int = 0
|
|
65
66
|
self.rows: list[str] = []
|
|
66
67
|
|
|
67
|
-
def clear(self,
|
|
68
|
-
if not stream.isatty():
|
|
69
|
-
warning(f"Cannot clear because {stream} is not a terminal stream")
|
|
68
|
+
def clear(self, flush: bool = True) -> None:
|
|
69
|
+
if not self.stream.isatty():
|
|
70
|
+
warning(f"Cannot clear because {self.stream} is not a terminal stream")
|
|
70
71
|
return
|
|
71
|
-
self.write("\033[2J",
|
|
72
|
+
self.write("\033[2J", flush=flush)
|
|
72
73
|
self.rows.pop()
|
|
73
74
|
|
|
74
75
|
def clear_line(self) -> None:
|
|
@@ -80,27 +81,29 @@ class BetterPrinter:
|
|
|
80
81
|
self.rows.pop()
|
|
81
82
|
self._current_row -= 1
|
|
82
83
|
|
|
83
|
-
def write(self, *args, sep: str = " ", end: str = "\n",
|
|
84
|
+
def write(self, *args, sep: str = " ", end: str = "\n", flush: bool = True):
|
|
84
85
|
text = sep.join(args) + end
|
|
85
86
|
self._current_row += text.count("\n")
|
|
86
87
|
self.rows.extend([f"{s}\n" for s in text.splitlines() if len(s) > 0])
|
|
87
|
-
stream.write(text)
|
|
88
|
+
self.stream.write(text)
|
|
88
89
|
if flush:
|
|
89
|
-
stream.flush()
|
|
90
|
+
self.stream.flush()
|
|
90
91
|
|
|
91
|
-
def __call__(self, *args,
|
|
92
|
-
self.write(*args,
|
|
92
|
+
def __call__(self, *args, sep: str = " ", end: str = "\n", flush: bool = True) -> None:
|
|
93
|
+
self.write(*args, sep=sep, end=end, flush=flush)
|
|
93
94
|
|
|
94
95
|
@property
|
|
95
96
|
def current_row(self) -> int:
|
|
96
97
|
return self._current_row
|
|
97
98
|
|
|
98
99
|
def insert(self, text: str, row: int) -> None:
|
|
100
|
+
for _ in range(len(self.rows)):
|
|
101
|
+
bprint.move_up()
|
|
102
|
+
bprint.clear_line()
|
|
99
103
|
self.rows.insert(row, text)
|
|
100
|
-
|
|
101
|
-
self.
|
|
102
|
-
|
|
103
|
-
for _ in range(num_rows):
|
|
104
|
+
num = len(self.rows)
|
|
105
|
+
self.write(*self.rows, end="")
|
|
106
|
+
for _ in range(num):
|
|
104
107
|
self.rows.pop()
|
|
105
108
|
|
|
106
109
|
|
|
@@ -2,6 +2,7 @@ import time
|
|
|
2
2
|
from typing import Optional, Iterable, Sized
|
|
3
3
|
|
|
4
4
|
from .progress_bar import ProgressBar
|
|
5
|
+
from .progress_bar_pool import ProgressBarPool
|
|
5
6
|
from ..print_ import bprint
|
|
6
7
|
|
|
7
8
|
|
|
@@ -17,14 +18,17 @@ class AsciiProgressBar(ProgressBar):
|
|
|
17
18
|
leave: bool = True,
|
|
18
19
|
num_bars: int = 1,
|
|
19
20
|
ncols: int = 50,
|
|
21
|
+
pool: Optional = None,
|
|
20
22
|
**kwargs
|
|
21
23
|
):
|
|
22
|
-
|
|
23
|
-
if isinstance(
|
|
24
|
-
total_ = len(
|
|
24
|
+
total_ = 1
|
|
25
|
+
if isinstance(iterable, Sized):
|
|
26
|
+
total_ = len(iterable)
|
|
25
27
|
if total is not None:
|
|
26
28
|
total_ = total
|
|
27
29
|
ProgressBar.__init__(self, total_, position)
|
|
30
|
+
self.iterable: Iterable = iterable
|
|
31
|
+
self.pool: ProgressBarPool = pool
|
|
28
32
|
self.num_bars: int = num_bars
|
|
29
33
|
self.leave: bool = leave
|
|
30
34
|
self.desc: str = desc
|
|
@@ -44,16 +48,21 @@ class AsciiProgressBar(ProgressBar):
|
|
|
44
48
|
def __iter__(self):
|
|
45
49
|
self.bprint_row_index = bprint.current_row
|
|
46
50
|
for v in self.iterable:
|
|
47
|
-
self.update(
|
|
51
|
+
self.update(0)
|
|
48
52
|
yield v
|
|
49
53
|
bprint.move_up()
|
|
50
54
|
bprint.clear_line()
|
|
55
|
+
bprint.rows.pop()
|
|
56
|
+
self.update(1)
|
|
57
|
+
bprint.move_up()
|
|
58
|
+
bprint.clear_line()
|
|
59
|
+
bprint.rows.pop()
|
|
51
60
|
if self.position > 0:
|
|
52
61
|
self.reset()
|
|
53
62
|
else:
|
|
54
63
|
self.draw()
|
|
55
64
|
|
|
56
|
-
def draw(self) -> None:
|
|
65
|
+
def draw(self, *, refresh: bool = False) -> None:
|
|
57
66
|
percent = self.current_value / self.total
|
|
58
67
|
num_to_fill = int(percent * self.ncols)
|
|
59
68
|
progress_str = num_to_fill * "#" + (self.ncols - num_to_fill) * " "
|
|
@@ -69,22 +78,49 @@ class AsciiProgressBar(ProgressBar):
|
|
|
69
78
|
postfix="/s",
|
|
70
79
|
unit=self.unit
|
|
71
80
|
)
|
|
81
|
+
if refresh and self.pool is not None and len(self.pool.bars) > 1:
|
|
82
|
+
for w in self.writes:
|
|
83
|
+
bprint(w, end="")
|
|
72
84
|
bprint(to_print)
|
|
73
85
|
|
|
74
|
-
def update(self, amount: float = 1):
|
|
86
|
+
def update(self, amount: float = 1, refresh: bool = False):
|
|
75
87
|
self.prev_value = self.current_value
|
|
76
88
|
self.current_value = min(
|
|
77
89
|
self.current_value + amount, self.total) # type:ignore
|
|
78
90
|
current_time = time.time()
|
|
79
91
|
self.delta = current_time - self.prev_update
|
|
80
92
|
self.prev_update = current_time
|
|
81
|
-
self.draw()
|
|
93
|
+
self.draw(refresh=refresh)
|
|
82
94
|
|
|
83
95
|
def _write(self, *args: str, sep: str = " ", end: str = "\n") -> None:
|
|
84
|
-
bprint.move_up()
|
|
85
|
-
bprint.clear_line()
|
|
86
96
|
if not end.endswith("\n"):
|
|
87
97
|
end += "\n"
|
|
98
|
+
if self.pool is not None and len(self.pool.bars) > 0:
|
|
99
|
+
succeeding_bars = self.pool.bars[self.position + 1:]
|
|
100
|
+
if succeeding_bars:
|
|
101
|
+
for succeeding_bar in succeeding_bars:
|
|
102
|
+
# clear child
|
|
103
|
+
bprint.move_up()
|
|
104
|
+
bprint.clear_line()
|
|
105
|
+
bprint.rows.pop()
|
|
106
|
+
for _ in range(succeeding_bar.num_writes):
|
|
107
|
+
# clear child's writes
|
|
108
|
+
bprint.move_up()
|
|
109
|
+
bprint.clear_line()
|
|
110
|
+
bprint.rows.pop()
|
|
111
|
+
# clear self
|
|
112
|
+
bprint.move_up()
|
|
113
|
+
bprint.clear_line()
|
|
114
|
+
bprint.rows.pop()
|
|
115
|
+
bprint(sep.join(map(str, args)), end=end)
|
|
116
|
+
self.draw()
|
|
117
|
+
for succeeding_bar in succeeding_bars:
|
|
118
|
+
succeeding_bar.update(0, refresh=True)
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
bprint.move_up()
|
|
122
|
+
bprint.clear_line()
|
|
123
|
+
bprint.rows.pop()
|
|
88
124
|
bprint(sep.join(map(str, args)), end=end)
|
|
89
125
|
self.draw()
|
|
90
126
|
|
|
@@ -96,7 +132,8 @@ class AsciiProgressBar(ProgressBar):
|
|
|
96
132
|
for _ in range(self.num_writes):
|
|
97
133
|
bprint.move_up()
|
|
98
134
|
bprint.clear_line()
|
|
99
|
-
|
|
135
|
+
bprint.rows.pop()
|
|
136
|
+
self.writes.clear()
|
|
100
137
|
|
|
101
138
|
|
|
102
139
|
__all__ = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import math
|
|
2
2
|
import time
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
|
-
from typing import Optional, Type, List, Iterable
|
|
4
|
+
from typing import Optional, Type, List, Iterable, Any
|
|
5
5
|
|
|
6
6
|
try:
|
|
7
7
|
from tqdm import tqdm
|
|
@@ -25,7 +25,11 @@ class ProgressBar(ABC):
|
|
|
25
25
|
self.position = position
|
|
26
26
|
self.unit = unit
|
|
27
27
|
self.bar_format = bar_format
|
|
28
|
-
self.
|
|
28
|
+
self.writes: list[str] = []
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def num_writes(self):
|
|
32
|
+
return len(self.writes)
|
|
29
33
|
|
|
30
34
|
@abstractmethod
|
|
31
35
|
def update(self, amount: float = 1) -> None:
|
|
@@ -35,11 +39,12 @@ class ProgressBar(ABC):
|
|
|
35
39
|
@abstractmethod
|
|
36
40
|
def _write(self, *args: str, sep: str = " ", end: str = "\n") -> None: ...
|
|
37
41
|
|
|
38
|
-
def write(self, *args:
|
|
42
|
+
def write(self, *args: Any, sep: str = " ", end: str = "\n") -> None:
|
|
39
43
|
"""A function to write additional text with the progress bar
|
|
40
44
|
"""
|
|
41
|
-
|
|
42
|
-
self.
|
|
45
|
+
processed = list(map(str, args))
|
|
46
|
+
self._write(*processed, sep=sep, end=end)
|
|
47
|
+
self.writes.append(sep.join(processed) + end)
|
|
43
48
|
|
|
44
49
|
@abstractmethod
|
|
45
50
|
def reset(self) -> None:
|
|
@@ -47,7 +52,12 @@ class ProgressBar(ABC):
|
|
|
47
52
|
"""
|
|
48
53
|
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
try:
|
|
56
|
+
from tqdm import tqdm
|
|
57
|
+
|
|
58
|
+
ProgressBar.register(tqdm)
|
|
59
|
+
except ImportError:
|
|
60
|
+
pass
|
|
51
61
|
|
|
52
62
|
__all__ = [
|
|
53
63
|
'ProgressBar',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
from typing import Type, List, Optional
|
|
1
|
+
from typing import Type, List, Optional, Iterator
|
|
2
2
|
from .progress_bar import ProgressBar
|
|
3
|
+
from ..print_ import bprint
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class ProgressBarPool:
|
|
@@ -30,15 +31,32 @@ class ProgressBarPool:
|
|
|
30
31
|
final_options["desc"] = final_options["desc"].ljust(max_desc_length, " ")
|
|
31
32
|
t = pbar_class(
|
|
32
33
|
position=i,
|
|
34
|
+
pool=self,
|
|
33
35
|
**final_options
|
|
34
36
|
)
|
|
35
37
|
self.bars.append(t)
|
|
38
|
+
self.writes: list[str] = []
|
|
36
39
|
|
|
37
40
|
def __getitem__(self, index: int) -> ProgressBar:
|
|
38
41
|
return self.bars[index]
|
|
39
42
|
|
|
40
|
-
def write(self,
|
|
41
|
-
|
|
43
|
+
def write(self, msg: str, end: str = "\n") -> None:
|
|
44
|
+
prev_rows = bprint.rows.copy()
|
|
45
|
+
for w in self.writes:
|
|
46
|
+
prev_rows.remove(w)
|
|
47
|
+
self.writes.append(msg + end)
|
|
48
|
+
rows = self.writes.copy() + prev_rows
|
|
49
|
+
for _ in bprint.rows:
|
|
50
|
+
bprint.move_up()
|
|
51
|
+
bprint.clear_line()
|
|
52
|
+
bprint.rows.clear()
|
|
53
|
+
|
|
54
|
+
for row in rows:
|
|
55
|
+
bprint(row, end="")
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
def __iter__(self) -> Iterator[ProgressBar]:
|
|
59
|
+
return iter(self.bars)
|
|
42
60
|
|
|
43
61
|
|
|
44
62
|
__all__ = [
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Protocol, runtime_checkable, Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@runtime_checkable
|
|
5
|
+
class Serializable(Protocol):
|
|
6
|
+
def serialize(self) -> bytes: ...
|
|
7
|
+
|
|
8
|
+
def deserialize(self, serealized: bytes) -> 'Serializable': ...
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def serialize(obj: Any) -> bytes:
|
|
12
|
+
if isinstance(obj, Serializable):
|
|
13
|
+
return obj.serialize()
|
|
14
|
+
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def deserialize(obj: bytes) -> Any:
|
|
19
|
+
if isinstance(obj, Serializable):
|
|
20
|
+
return obj.deserialize()
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
'Serializable',
|
|
26
|
+
'serialize',
|
|
27
|
+
'deserialize',
|
|
28
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .discreate_finite_automaton import *
|
danielutils-0.9.84/danielutils/university/computability_and_complexity/discreate_finite_automaton.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import random
|
|
2
|
+
from typing import Set, Callable, Sequence, Collection, Tuple, Dict, TypeVar, Generic
|
|
3
|
+
|
|
4
|
+
State = TypeVar('State')
|
|
5
|
+
Symbol = TypeVar('Symbol')
|
|
6
|
+
Alphabet = Collection[Symbol]
|
|
7
|
+
TransitionFunction = Callable[[State, Symbol], State]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DiscreteFiniteAutomaton(Generic[State, Symbol]):
|
|
11
|
+
def __init__(self, Q: Collection[State], sigma: Alphabet, delta: TransitionFunction, q0: State,
|
|
12
|
+
F: Collection[State]):
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
Q: set of possible states
|
|
17
|
+
sigma: the alphabet
|
|
18
|
+
delta: the transition function
|
|
19
|
+
q0: the initial state
|
|
20
|
+
F: the accept states
|
|
21
|
+
"""
|
|
22
|
+
self.Q: Set[State] = set(Q)
|
|
23
|
+
self.sigma: Sequence[Symbol] = list(sigma)
|
|
24
|
+
self.delta: TransitionFunction = delta
|
|
25
|
+
self.q0: State = q0
|
|
26
|
+
self.F: Set[State] = set(F)
|
|
27
|
+
self._verify()
|
|
28
|
+
|
|
29
|
+
def process(self, word: Sequence[Symbol]) -> State:
|
|
30
|
+
cur = self.q0
|
|
31
|
+
for letter in word:
|
|
32
|
+
cur = self.delta(cur, letter)
|
|
33
|
+
return cur
|
|
34
|
+
|
|
35
|
+
def run(self, word: Sequence[Symbol]) -> bool:
|
|
36
|
+
return self.process(word) in self.F
|
|
37
|
+
|
|
38
|
+
def __call__(self, word: Sequence[Symbol]) -> bool:
|
|
39
|
+
return self.run(word)
|
|
40
|
+
|
|
41
|
+
def _verify(self) -> None:
|
|
42
|
+
for letter in self.sigma:
|
|
43
|
+
for state in self.Q:
|
|
44
|
+
try:
|
|
45
|
+
res = self.delta(state, letter)
|
|
46
|
+
except Exception as e:
|
|
47
|
+
raise ValueError(f'delta({state}, {letter}) raised an exception') from e
|
|
48
|
+
if not res in self.Q:
|
|
49
|
+
raise ValueError(f'delta({state}, {letter}) = {state} which is not in F = {self.Q}')
|
|
50
|
+
|
|
51
|
+
def random_word(self, k: int) -> Sequence[Symbol]:
|
|
52
|
+
return tuple(random.choices(self.sigma, k=k))
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def delta_from_dict(dct: Dict[Tuple[State, Symbol], State]) -> TransitionFunction:
|
|
56
|
+
return lambda state, letter: dct[(state, letter)]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
DFA = DiscreteFiniteAutomaton
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
"State",
|
|
63
|
+
"Symbol",
|
|
64
|
+
"Alphabet",
|
|
65
|
+
"TransitionFunction",
|
|
66
|
+
"DiscreteFiniteAutomaton",
|
|
67
|
+
"DFA"
|
|
68
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .encoding import *
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Iterable, Generator, Union
|
|
4
|
+
|
|
5
|
+
Encodeable = Union[bytes, Iterable[bytes]]
|
|
6
|
+
Decodeable = Encodeable
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Encoding(ABC):
|
|
10
|
+
class EncodingType(Enum):
|
|
11
|
+
LOSSY = "LOSSY"
|
|
12
|
+
LOSSLESS = "LOSSLESS"
|
|
13
|
+
|
|
14
|
+
encoding_type: EncodingType
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def encode_online(obj: Encodeable) -> Generator[bytes, None, None]: ...
|
|
19
|
+
|
|
20
|
+
@staticmethod
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def encode_offline(obj: Encodeable) -> bytes: ...
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def decode_online(obj: Decodeable) -> Generator[bytes, None, None]: ...
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def decode_offline(obj: Decodeable) -> bytes: ...
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
'Encoding'
|
|
35
|
+
]
|