danielutils 0.9.84__tar.gz → 0.9.90__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.84/danielutils.egg-info → danielutils-0.9.90}/PKG-INFO +1 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/worker.py +2 -1
- danielutils-0.9.90/danielutils/context_managers/__init__.py +5 -0
- danielutils-0.9.90/danielutils/context_managers/optional_context.py +18 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/context_managers/temporary_file.py +11 -11
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/custom_types.py +6 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/__init__.py +1 -0
- danielutils-0.9.90/danielutils/data_structures/algorithms.py +44 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/decorate_conditionally.py +1 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/memo.py +21 -2
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/overload.py +2 -2
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/processify.py +3 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/file_specifications/__init__.py +4 -3
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/__init__.py +2 -0
- danielutils-0.9.90/danielutils/functions/factorial.py +5 -0
- danielutils-0.9.90/danielutils/functions/partition.py +37 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/generators/join_generators.py +1 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/progress_bar/ascii_progress_bar.py +24 -12
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/progress_bar/progress_bar.py +1 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/callstack.py +4 -2
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/layered_command.py +3 -3
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/computability_and_complexity/__init__.py +1 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/computability_and_complexity/discreate_finite_automaton.py +21 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/languages/language.py +17 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/languages/sat.py +69 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/turing_machine.py +47 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/databases/all.py +2 -2
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossless/run_length.py +3 -2
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/linear_algebra/matrix.py +5 -5
- danielutils-0.9.90/danielutils/university/probability/conditional_variable/continuous/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/funcs/expected_value.py +1 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/transformation.py +2 -2
- {danielutils-0.9.84 → danielutils-0.9.90/danielutils.egg-info}/PKG-INFO +1 -1
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils.egg-info/SOURCES.txt +8 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/pyproject.toml +1 -1
- danielutils-0.9.84/danielutils/context_managers/__init__.py +0 -3
- {danielutils-0.9.84 → danielutils-0.9.90}/LICENSE +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/MANIFEST.in +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/README.md +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/database/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/database/cached_database.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/database/database.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/database/redis_database.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/multi_id.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/worker_pool.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/repl.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/aliases.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/frange.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/factory.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/tlist.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/tset.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/colors.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/context_managers/attr_context.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/context_managers/multi_context.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/context_managers/state_context.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/convenience.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/conversions/main_conversions.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/conversions/specialized_conversions/to_int.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/comparer.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/graph/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/graph/binary_node.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/graph/graph.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/graph/multinode.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/graph/node.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/heap/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/heap/heap.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/heap/max_heap.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/heap/min_heap.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/queue/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/queue/atomic_queue.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/queue/priority_queue.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/queue/queue.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/stack.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/trees/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/trees/binary_syntax_tree.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/data_structures/trees/binary_tree.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/date.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/date_time.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/atomic.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/attach.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/final.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/limit_recursion.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/partially_implemented.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/singleton.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/timeout.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/total_ordering.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/decorators/validate.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/areoneof.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/flatten.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/foreach.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/isoftype.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/isoneof.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/multiloop.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/parallel_for.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/subseteq.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/functions/types_subseteq.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/generators/generator_from_stream.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/internet.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/io_.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/math_/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/math_/constants.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/math_/functions.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/math_/math_print.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/math_/math_symbols.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/metaclasses/interface.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/mock_/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/mock_/mock_database.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/mock_/mock_module.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/path.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/print_.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/progress_bar/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/progress_bar/progress_bar_pool.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/protocols/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/protocols/dictable.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/protocols/evaluable.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/protocols/serializable.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/py.typed +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/class_/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/class_/class_reflection.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/file/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/file/file_reflection.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/function/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/function/function_reflections.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/get_traceback.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/os_.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/packages.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/python_version.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/signals.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/interpreter/tracer.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/module/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/reflection/module/package_reflection.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/text.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/time.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/__init__.py +0 -0
- {danielutils-0.9.84/danielutils/university/image_proccesing/tansformations → danielutils-0.9.90/danielutils/university/computability_and_complexity/languages}/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/encoding.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossless/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossless/huffman.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossless/lossless_encoding.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossless/lzw.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossy/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/encoding/lossy/lossy_encoding.py +0 -0
- {danielutils-0.9.84/danielutils/university/machine_learning → danielutils-0.9.90/danielutils/university/image_proccesing/tansformations}/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/tansformations/gaussian.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/tansformations/gradient.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/tansformations/hough.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/tansformations/laplacian.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/image_proccesing/tansformations/transformation.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/linear_algebra/__init__.py +0 -0
- {danielutils-0.9.84/danielutils/university/probability/conditional_variable/continuous → danielutils-0.9.90/danielutils/university/machine_learning}/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/machine_learning/activation_functions/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/machine_learning/activation_functions/activation_function.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/machine_learning/activation_functions/relu.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/machine_learning/neuron.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/oop/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/oop/observer.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/oop/strategy.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/conditional_variable.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/bernoulli.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/binomial.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/discrete.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/geometric.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/poisson.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/uniform.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/distributions.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/expressions/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/expressions/accumulation_expression.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/expressions/probability_expression.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/funcs/__init__.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/funcs/covariance.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/funcs/probability_function.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/funcs/variance.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/operator.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/protocols.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/university/probability/supp.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils/versioned_imports.py +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/setup.cfg +0 -0
- {danielutils-0.9.84 → danielutils-0.9.90}/setup.py +0 -0
{danielutils-0.9.84 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/worker.py
RENAMED
|
@@ -12,7 +12,7 @@ class Worker(ABC):
|
|
|
12
12
|
"""A Worker Interface
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
def __init__(self, id: int, pool: "danielutils.
|
|
15
|
+
def __init__(self, id: int, pool: "danielutils.abstractions.multiprogramming.worker_pool.WorkerPool") -> None: # pylint: disable=redefined-builtin #noqa
|
|
16
16
|
self.id = id
|
|
17
17
|
self.pool = pool
|
|
18
18
|
self.thread: Thread = Thread(target=self._loop)
|
|
@@ -57,6 +57,7 @@ class Worker(ABC):
|
|
|
57
57
|
to signal actions if needed
|
|
58
58
|
will call 'notification_function'
|
|
59
59
|
"""
|
|
60
|
+
# TODO
|
|
60
61
|
self.pool._notify_subscribers() # pylint: disable=protected-access
|
|
61
62
|
|
|
62
63
|
def acquire(self) -> Optional[Tuple[Any]]:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import ContextManager
|
|
2
|
+
class OptionalContext(ContextManager):
|
|
3
|
+
def __init__(self, predicate: bool, context: ContextManager):
|
|
4
|
+
self.predicate = predicate
|
|
5
|
+
self.context = context
|
|
6
|
+
|
|
7
|
+
def __enter__(self):
|
|
8
|
+
if self.predicate:
|
|
9
|
+
self.context.__enter__()
|
|
10
|
+
|
|
11
|
+
def __exit__(self, __exc_type, __exc_value, __traceback):
|
|
12
|
+
if self.predicate:
|
|
13
|
+
self.context.__exit__(__exc_type, __exc_value, __traceback)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__=[
|
|
17
|
+
"OptionalContext"
|
|
18
|
+
]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from typing import ContextManager
|
|
2
|
-
from ..io_ import file_exists, delete_file
|
|
3
1
|
import atexit
|
|
2
|
+
from typing import ContextManager, Set, List
|
|
3
|
+
from ..io_ import file_exists, delete_file
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class TemporaryFile(ContextManager):
|
|
7
|
-
_instances:
|
|
7
|
+
_instances: Set['TemporaryFile'] = set()
|
|
8
8
|
|
|
9
9
|
def __init__(self, path: str):
|
|
10
10
|
if file_exists(path):
|
|
@@ -18,22 +18,16 @@ class TemporaryFile(ContextManager):
|
|
|
18
18
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
19
19
|
self.close()
|
|
20
20
|
|
|
21
|
-
@atexit.register
|
|
22
|
-
@staticmethod
|
|
23
|
-
def _global_close():
|
|
24
|
-
for inst in TemporaryFile._instances:
|
|
25
|
-
inst.close()
|
|
26
|
-
|
|
27
21
|
def close(self) -> None:
|
|
28
22
|
delete_file(self.path)
|
|
29
23
|
|
|
30
|
-
def read(self) ->
|
|
24
|
+
def read(self) -> List[str]:
|
|
31
25
|
if not file_exists(self.path):
|
|
32
26
|
return []
|
|
33
27
|
with open(self.path, 'r') as f:
|
|
34
28
|
return f.readlines()
|
|
35
29
|
|
|
36
|
-
def write(self, lines:
|
|
30
|
+
def write(self, lines: List[str]) -> None:
|
|
37
31
|
with open(self.path, 'a') as f:
|
|
38
32
|
f.writelines(lines)
|
|
39
33
|
|
|
@@ -42,6 +36,12 @@ class TemporaryFile(ContextManager):
|
|
|
42
36
|
pass
|
|
43
37
|
|
|
44
38
|
|
|
39
|
+
@atexit.register
|
|
40
|
+
def __close_all():
|
|
41
|
+
for inst in TemporaryFile._instances: # type:ignore #pylint: disable=all
|
|
42
|
+
inst.close()
|
|
43
|
+
|
|
44
|
+
|
|
45
45
|
__all__ = [
|
|
46
46
|
'TemporaryFile'
|
|
47
47
|
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from typing import TypeVar, List, Callable, Dict
|
|
3
|
+
from itertools import product
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
|
|
6
|
+
NodeT = TypeVar("NodeT")
|
|
7
|
+
|
|
8
|
+
DistanceMatrix = Dict[NodeT, Dict[NodeT, float]]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def bellman_ford(nodes: List[NodeT], weight_func: Callable[[NodeT, NodeT], float],
|
|
12
|
+
iteration_callback: Callable[[DistanceMatrix], None],
|
|
13
|
+
poisoned_reverse: bool = False) -> DistanceMatrix:
|
|
14
|
+
dist: Dict[NodeT, Dict[NodeT, float]] = defaultdict(defaultdict)
|
|
15
|
+
prev: Dict[NodeT, Dict[NodeT, NodeT]] = defaultdict(defaultdict)
|
|
16
|
+
|
|
17
|
+
for u, v in product(nodes, nodes):
|
|
18
|
+
dist[u][v] = weight_func(u, v)
|
|
19
|
+
|
|
20
|
+
iteration_callback(dist)
|
|
21
|
+
|
|
22
|
+
for _ in range(len(nodes) - 1):
|
|
23
|
+
tmp = deepcopy(dist)
|
|
24
|
+
for u, v in product(nodes, nodes):
|
|
25
|
+
if u == v:
|
|
26
|
+
continue
|
|
27
|
+
|
|
28
|
+
for mid in nodes:
|
|
29
|
+
if mid == u or mid == v:
|
|
30
|
+
continue
|
|
31
|
+
|
|
32
|
+
if dist[u][v] > dist[u][mid] + dist[mid][v]:
|
|
33
|
+
tmp[u][v] = dist[u][mid] + dist[mid][v]
|
|
34
|
+
prev[u][v] = mid
|
|
35
|
+
|
|
36
|
+
dist = tmp
|
|
37
|
+
iteration_callback(dist)
|
|
38
|
+
|
|
39
|
+
iteration_callback(prev)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"bellman_ford"
|
|
44
|
+
]
|
|
@@ -3,7 +3,7 @@ from typing import Callable, Optional, Union
|
|
|
3
3
|
from .validate import validate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
@validate # type:ignore
|
|
6
|
+
@validate(strict=False) # type:ignore
|
|
7
7
|
def decorate_conditionally(decorator: Callable, predicate: Union[bool, Callable[[], bool]], *,
|
|
8
8
|
decorator_args: Optional[list] = None, decorator_kwargs: Optional[dict] = None):
|
|
9
9
|
"""will decorate a function iff the predicate is True or returns True
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import functools
|
|
2
|
-
from typing import Callable, Any, TypeVar, Dict
|
|
2
|
+
from typing import Callable, Any, TypeVar, Dict, Generator, List, Set, Optional
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
from .validate import validate
|
|
5
5
|
from ..versioned_imports import ParamSpec
|
|
@@ -27,6 +27,25 @@ def memo(func: FuncT) -> FuncT:
|
|
|
27
27
|
return wrapper
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def memo_generator(func: Callable[P, Generator]) -> Callable[P, Generator]:
|
|
31
|
+
cache: Dict[tuple, Any] = {}
|
|
32
|
+
|
|
33
|
+
@functools.wraps(func)
|
|
34
|
+
def wrapper(*args: P.args, **kwargs: P.kwargs) -> Generator:
|
|
35
|
+
args = tuple(args)
|
|
36
|
+
if (args, *kwargs.items()) not in cache:
|
|
37
|
+
lst = []
|
|
38
|
+
for v in func(*args, **kwargs):
|
|
39
|
+
lst.append(v)
|
|
40
|
+
yield v
|
|
41
|
+
cache[(args, *kwargs.items())] = lst
|
|
42
|
+
else:
|
|
43
|
+
yield from cache[(args, *kwargs.items())]
|
|
44
|
+
|
|
45
|
+
return wrapper
|
|
46
|
+
|
|
47
|
+
|
|
30
48
|
__all__ = [
|
|
31
|
-
"memo"
|
|
49
|
+
"memo",
|
|
50
|
+
"memo_generator"
|
|
32
51
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Callable, cast, Any, TypeVar, Dict
|
|
1
|
+
from typing import Callable, cast, Any, TypeVar, Dict, List
|
|
2
2
|
import inspect
|
|
3
3
|
import functools
|
|
4
4
|
from ..reflection import is_function_annotated_properly
|
|
@@ -122,7 +122,7 @@ class overload:
|
|
|
122
122
|
overload._validate(func)
|
|
123
123
|
self._qualname = func.__qualname__
|
|
124
124
|
self._moudle = func.__module__
|
|
125
|
-
self._functions: Dict[int,
|
|
125
|
+
self._functions: Dict[int, List[Callable]] = {}
|
|
126
126
|
self._functions[overload._get_key(func)] = [func]
|
|
127
127
|
functools.wraps(func)(self)
|
|
128
128
|
|
|
@@ -35,12 +35,14 @@ def processify(func):
|
|
|
35
35
|
return wrapper
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
def _run_func(main_pid: int, dct: dict, func_name: str, args, kwargs) -> None:
|
|
40
39
|
return dct[func_name](*args, __main_pid=main_pid, **kwargs)
|
|
41
40
|
|
|
41
|
+
|
|
42
42
|
def debug_info(include_builtins: bool = False) -> dict:
|
|
43
43
|
f = get_prev_frame(2)
|
|
44
|
+
if f is None:
|
|
45
|
+
raise RuntimeError("Failed to get frame")
|
|
44
46
|
g = {k: v for k, v in f.f_globals.items() if k != "__builtins__"} if not include_builtins else dict(f.f_globals)
|
|
45
47
|
return {
|
|
46
48
|
"file": f.f_code.co_filename,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from typing import Optional
|
|
2
|
+
from typing import Optional, List
|
|
3
3
|
from enum import Enum
|
|
4
4
|
|
|
5
5
|
|
|
@@ -29,12 +29,13 @@ class Field:
|
|
|
29
29
|
class Section:
|
|
30
30
|
name: str
|
|
31
31
|
prefix: bytes
|
|
32
|
-
fields: Optional[
|
|
32
|
+
fields: Optional[List[Field]]
|
|
33
33
|
is_optional: bool = False
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class FileSpecification:
|
|
37
|
-
def __init__(self, long_name: str, short_name: str, extension: str, specification: str,
|
|
37
|
+
def __init__(self, long_name: str, short_name: str, extension: str, specification: str,
|
|
38
|
+
sections: List[Section]) -> None:
|
|
38
39
|
"""
|
|
39
40
|
|
|
40
41
|
Args:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from typing import List, Generator, Tuple, Union
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def partitions(n: int, k: int) -> Generator[List[int], None, None]:
|
|
5
|
+
from ..decorators import memo_generator
|
|
6
|
+
|
|
7
|
+
@memo_generator()
|
|
8
|
+
def helper(n: int, target_sum: int, current_sum: int, topLevel: int, arr: Union[List[int], Tuple[int]]) -> \
|
|
9
|
+
Generator[List[int], None, None]:
|
|
10
|
+
arr = list(arr)
|
|
11
|
+
if n == 1:
|
|
12
|
+
if current_sum <= target_sum:
|
|
13
|
+
if topLevel == 1 or (target_sum - current_sum >= arr[-2]):
|
|
14
|
+
arr[-1] = target_sum - current_sum
|
|
15
|
+
yield tuple(arr)
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
start = 0
|
|
19
|
+
if n != topLevel:
|
|
20
|
+
start = arr[-1 * n - 1]
|
|
21
|
+
|
|
22
|
+
for i in range(start, target_sum + 1):
|
|
23
|
+
arr[-1 * n] = i
|
|
24
|
+
yield from helper(n - 1, target_sum, current_sum + i, topLevel, tuple(arr))
|
|
25
|
+
|
|
26
|
+
arr: List[int] = [0] * k
|
|
27
|
+
yield from helper(k, n, 0, k, tuple(arr))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def num_partitions(n: int, k: int) -> int:
|
|
31
|
+
return len(list(partitions(n, k)))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"partitions",
|
|
36
|
+
"num_partitions"
|
|
37
|
+
]
|
|
@@ -44,7 +44,7 @@ def join_generators(*generators) -> Generator[Tuple[int, Any], None, None]:
|
|
|
44
44
|
Yields:
|
|
45
45
|
Generator[Any, None, None]: one generator that combines all of the given ones
|
|
46
46
|
"""
|
|
47
|
-
queue = Queue()
|
|
47
|
+
queue: Queue = Queue()
|
|
48
48
|
edit_queue_semaphore = Semaphore(1)
|
|
49
49
|
queue_status_semaphore = Semaphore(0)
|
|
50
50
|
finished_threads_counter = AtomicCounter()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import time
|
|
2
|
-
from typing import Optional, Iterable, Sized
|
|
2
|
+
from typing import Optional, Iterable, Sized, Iterator
|
|
3
3
|
|
|
4
4
|
from .progress_bar import ProgressBar
|
|
5
5
|
from .progress_bar_pool import ProgressBarPool
|
|
@@ -10,7 +10,7 @@ class AsciiProgressBar(ProgressBar):
|
|
|
10
10
|
|
|
11
11
|
def __init__(
|
|
12
12
|
self,
|
|
13
|
-
|
|
13
|
+
iterator: Iterator,
|
|
14
14
|
position: int,
|
|
15
15
|
*,
|
|
16
16
|
total: Optional[float] = None,
|
|
@@ -18,16 +18,16 @@ class AsciiProgressBar(ProgressBar):
|
|
|
18
18
|
leave: bool = True,
|
|
19
19
|
num_bars: int = 1,
|
|
20
20
|
ncols: int = 50,
|
|
21
|
-
pool: Optional = None,
|
|
21
|
+
pool: Optional[ProgressBarPool] = None,
|
|
22
22
|
**kwargs
|
|
23
23
|
):
|
|
24
24
|
total_ = 1
|
|
25
|
-
if isinstance(
|
|
26
|
-
total_ = len(
|
|
25
|
+
if isinstance(iterator, Sized):
|
|
26
|
+
total_ = len(iterator)
|
|
27
27
|
if total is not None:
|
|
28
28
|
total_ = total
|
|
29
29
|
ProgressBar.__init__(self, total_, position)
|
|
30
|
-
self.
|
|
30
|
+
self.iterator: Iterator = iterator
|
|
31
31
|
self.pool: ProgressBarPool = pool
|
|
32
32
|
self.num_bars: int = num_bars
|
|
33
33
|
self.leave: bool = leave
|
|
@@ -47,16 +47,18 @@ class AsciiProgressBar(ProgressBar):
|
|
|
47
47
|
|
|
48
48
|
def __iter__(self):
|
|
49
49
|
self.bprint_row_index = bprint.current_row
|
|
50
|
-
for v in self.
|
|
50
|
+
for v in self.iterator:
|
|
51
51
|
self.update(0)
|
|
52
52
|
yield v
|
|
53
53
|
bprint.move_up()
|
|
54
54
|
bprint.clear_line()
|
|
55
|
-
bprint.rows
|
|
55
|
+
if len(bprint.rows) > 0:
|
|
56
|
+
bprint.rows.pop()
|
|
56
57
|
self.update(1)
|
|
57
58
|
bprint.move_up()
|
|
58
59
|
bprint.clear_line()
|
|
59
|
-
bprint.rows
|
|
60
|
+
if len(bprint.rows) > 0:
|
|
61
|
+
bprint.rows.pop()
|
|
60
62
|
if self.position > 0:
|
|
61
63
|
self.reset()
|
|
62
64
|
else:
|
|
@@ -79,9 +81,19 @@ class AsciiProgressBar(ProgressBar):
|
|
|
79
81
|
unit=self.unit
|
|
80
82
|
)
|
|
81
83
|
if refresh and self.pool is not None and len(self.pool.bars) > 1:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
i = bprint.rows.index(f"{self.prev_print}\n")
|
|
85
|
+
rows = [to_print]
|
|
86
|
+
for j, row in enumerate(bprint.rows[i + 1:]):
|
|
87
|
+
rows.append(row)
|
|
88
|
+
for row in rows:
|
|
89
|
+
bprint.move_up(1)
|
|
90
|
+
bprint.clear_line()
|
|
91
|
+
bprint.rows.pop()
|
|
92
|
+
for row in rows:
|
|
93
|
+
bprint(row)
|
|
94
|
+
else:
|
|
95
|
+
bprint(to_print)
|
|
96
|
+
self.prev_print = to_print
|
|
85
97
|
|
|
86
98
|
def update(self, amount: float = 1, refresh: bool = False):
|
|
87
99
|
self.prev_value = self.current_value
|
|
@@ -32,7 +32,7 @@ class ProgressBar(ABC):
|
|
|
32
32
|
return len(self.writes)
|
|
33
33
|
|
|
34
34
|
@abstractmethod
|
|
35
|
-
def update(self, amount: float = 1) -> None:
|
|
35
|
+
def update(self, amount: float = 1, **kwargs) -> None:
|
|
36
36
|
"""A function to update the progress-bar's value by a positive relative amount
|
|
37
37
|
"""
|
|
38
38
|
|
|
@@ -25,8 +25,10 @@ def get_prev_frame(n_steps: int = 1) -> Optional[FrameType]:
|
|
|
25
25
|
|
|
26
26
|
def get_prev_line_of_code(n_steps: int = 1) -> Optional[str]:
|
|
27
27
|
frame = get_prev_frame(n_steps + 1)
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if frame is None:
|
|
29
|
+
return None
|
|
30
|
+
file = frame.f_back.f_code.co_filename # type:ignore
|
|
31
|
+
line_number = frame.f_back.f_lineno - 1 # type:ignore
|
|
30
32
|
with open(file, "r", encoding="utf-8") as f:
|
|
31
33
|
lines = f.readlines()
|
|
32
34
|
line = lines[line_number]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import sys, os
|
|
2
|
-
from typing import Optional
|
|
2
|
+
from typing import Optional, Tuple, List
|
|
3
3
|
from ..context_managers import TemporaryFile
|
|
4
4
|
import random
|
|
5
5
|
|
|
@@ -79,7 +79,7 @@ class LayeredCommand:
|
|
|
79
79
|
command_flush_stderr: Optional[bool] = None,
|
|
80
80
|
command_raise_on_fail: Optional[bool] = None,
|
|
81
81
|
command_verbose: Optional[bool] = None
|
|
82
|
-
) ->
|
|
82
|
+
) -> Tuple[int, List[str], List[str]]:
|
|
83
83
|
if not self._has_entered:
|
|
84
84
|
raise RuntimeError(
|
|
85
85
|
"LayeredCommand must be used with a context manager. Use as: `with LayeredCommand(...) as l1:`")
|
|
@@ -109,7 +109,7 @@ class LayeredCommand:
|
|
|
109
109
|
self._error(raise_on_fail and code != 0, command, code, command_verbose)
|
|
110
110
|
return code, stdout.read(), stderr.read()
|
|
111
111
|
|
|
112
|
-
def __call__(self, *args, **kwargs) ->
|
|
112
|
+
def __call__(self, *args, **kwargs) -> Tuple[int, List[str], List[str]]:
|
|
113
113
|
return self.execute(*args, **kwargs)
|
|
114
114
|
|
|
115
115
|
|
|
@@ -51,6 +51,27 @@ class DiscreteFiniteAutomaton(Generic[State, Symbol]):
|
|
|
51
51
|
def random_word(self, k: int) -> Sequence[Symbol]:
|
|
52
52
|
return tuple(random.choices(self.sigma, k=k))
|
|
53
53
|
|
|
54
|
+
def is_described_by(self, language_indicator: Callable[[Sequence[Symbol]], bool], max_word_length: int = 100,
|
|
55
|
+
num_repeats_for_length: int = 1000) -> bool:
|
|
56
|
+
"""
|
|
57
|
+
This function will randomly generate work of all lengths up to k and will check whether this DFA acceptance
|
|
58
|
+
of the word is the same as the result of a function that describes the behaviour of the language
|
|
59
|
+
Args:
|
|
60
|
+
language_indicator: An indicator function to check if a word is a member of a language
|
|
61
|
+
max_word_length: the maximum length of a word to check
|
|
62
|
+
num_repeats_for_length: how many times to repeat the check of any one length (as the words are randomly generated)
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
A boolean result
|
|
66
|
+
"""
|
|
67
|
+
for k in range(max_word_length):
|
|
68
|
+
for _ in range(num_repeats_for_length):
|
|
69
|
+
word = self.random_word(k)
|
|
70
|
+
if not (self.run(word) == language_indicator(word)):
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
return True
|
|
74
|
+
|
|
54
75
|
@staticmethod
|
|
55
76
|
def delta_from_dict(dct: Dict[Tuple[State, Symbol], State]) -> TransitionFunction:
|
|
56
77
|
return lambda state, letter: dct[(state, letter)]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Protocol
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LanguageItem(Protocol): ...
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Language(ABC):
|
|
9
|
+
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def __contains__(self, item: LanguageItem) -> bool: ...
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Language",
|
|
16
|
+
"LanguageItem"
|
|
17
|
+
]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from typing import List, TypeVar
|
|
2
|
+
|
|
3
|
+
from .language import Language
|
|
4
|
+
|
|
5
|
+
CNFVariable_id_type = TypeVar('CNFVariable_id_type', bound=int)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CNFVariable:
|
|
9
|
+
__ID: int = 0
|
|
10
|
+
|
|
11
|
+
def __init__(self, value: bool):
|
|
12
|
+
self.value = value
|
|
13
|
+
self.id = CNFVariable.__ID
|
|
14
|
+
CNFVariable.__ID += 1
|
|
15
|
+
|
|
16
|
+
def __bool__(self):
|
|
17
|
+
return self.value
|
|
18
|
+
|
|
19
|
+
def get_id(self) -> CNFVariable_id_type:
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CNFLiteral:
|
|
24
|
+
def __init__(self, negation: bool):
|
|
25
|
+
self.negation = negation
|
|
26
|
+
|
|
27
|
+
def __call__(self, var: CNFVariable) -> bool:
|
|
28
|
+
return not bool(var) if self.negation else bool(var)
|
|
29
|
+
|
|
30
|
+
def get_corresponding_variable_id(self) -> CNFVariable_id_type:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class CNFClause:
|
|
35
|
+
def __bool__(self, literals: List[CNFLiteral] = None) -> None:
|
|
36
|
+
self.literals = literals or []
|
|
37
|
+
|
|
38
|
+
def add_literal(self, literal: CNFLiteral):
|
|
39
|
+
self.literals.append(literal)
|
|
40
|
+
|
|
41
|
+
def evaluate(self, variables: List[CNFVariable]) -> bool:
|
|
42
|
+
dct = {v.get_id(): v for v in variables}
|
|
43
|
+
|
|
44
|
+
for literal in self.literals:
|
|
45
|
+
if not literal.get_corresponding_variable_id() in dct.keys():
|
|
46
|
+
return False
|
|
47
|
+
if not literal(dct[literal.get_corresponding_variable_id()]):
|
|
48
|
+
return False
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
def __len__(self) -> int:
|
|
52
|
+
return len(self.literals)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class CNFFormula:
|
|
56
|
+
def __init__(self, clauses: List[CNFClause] = None) -> None:
|
|
57
|
+
self.clauses = clauses or []
|
|
58
|
+
|
|
59
|
+
def add_clause(self, clause: CNFClause) -> None:
|
|
60
|
+
self.clauses.append(clause)
|
|
61
|
+
|
|
62
|
+
def evaluate(self, variables: List[CNFVariable]) -> bool:
|
|
63
|
+
for clause in self.clauses:
|
|
64
|
+
if not clause.evaluate(variables):
|
|
65
|
+
return False
|
|
66
|
+
return True
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class SAT(Language): ...
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import TypeVar, Collection, Callable, Set, List, Sequence, Tuple, Union, Literal
|
|
2
|
+
|
|
3
|
+
State = TypeVar('State')
|
|
4
|
+
Symbol = TypeVar('Symbol')
|
|
5
|
+
Alphabet = Collection[Symbol]
|
|
6
|
+
Direction = Union[Literal["L"], Literal["R"]]
|
|
7
|
+
TransitionFunction = Callable[[State, Symbol], Tuple[State, Symbol, Direction]]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TuringMachine:
|
|
11
|
+
def __init__(self, Q: Collection[State], Gamma: Alphabet, Sigma: Alphabet, delta: TransitionFunction, q0: State,
|
|
12
|
+
F_acc: Collection[State], F_rej: Collection[State]) -> None:
|
|
13
|
+
self.Q: Set[State] = set(Q)
|
|
14
|
+
self.Gamma: List[State] = list(Gamma)
|
|
15
|
+
self.Sigma: List[State] = list(Sigma)
|
|
16
|
+
self.delta: TransitionFunction = delta
|
|
17
|
+
self.q0: State = q0
|
|
18
|
+
self.F_acc: Set[State] = set(F_acc)
|
|
19
|
+
self.F_rej: Set[State] = set(F_rej)
|
|
20
|
+
self.tape: List[Symbol] = []
|
|
21
|
+
self.head: int = 0
|
|
22
|
+
|
|
23
|
+
def _should_stop(self, cur_state: State) -> bool:
|
|
24
|
+
return cur_state in self.F_acc or cur_state in self.F_rej
|
|
25
|
+
|
|
26
|
+
def process(self, word: Sequence[Symbol]) -> State:
|
|
27
|
+
for letter in word:
|
|
28
|
+
self.tape.append(letter)
|
|
29
|
+
cur = self.q0
|
|
30
|
+
while not self._should_stop(cur):
|
|
31
|
+
state, symbol, direction = self.delta(cur, self.tape[self.head])
|
|
32
|
+
cur = state
|
|
33
|
+
self.tape[self.head] = symbol
|
|
34
|
+
self.head += 1 if direction == "R" else -1
|
|
35
|
+
|
|
36
|
+
return cur
|
|
37
|
+
|
|
38
|
+
def run(self, word: Sequence[Symbol]) -> bool:
|
|
39
|
+
return self.process(word) in self.F_acc
|
|
40
|
+
|
|
41
|
+
def __call__(self, word: Sequence[Symbol]) -> bool:
|
|
42
|
+
return self.run(word)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
'TuringMachine'
|
|
47
|
+
]
|
|
@@ -417,9 +417,9 @@ class Relation:
|
|
|
417
417
|
"""
|
|
418
418
|
# week 9 page 1 slide 3
|
|
419
419
|
K: Attribute = self.find_key(F)
|
|
420
|
-
KeyQueue = Queue()
|
|
420
|
+
KeyQueue: Queue = Queue()
|
|
421
421
|
KeyQueue.push(K)
|
|
422
|
-
Keys = set([K])
|
|
422
|
+
Keys: Set[Attribute] = set([K])
|
|
423
423
|
while not KeyQueue.is_empty():
|
|
424
424
|
K = KeyQueue.pop()
|
|
425
425
|
for X, Y in F.tuples():
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Generator, Sequence
|
|
1
|
+
from typing import Generator, Sequence, List
|
|
2
2
|
from .lossless_encoding import LosslessEncoding
|
|
3
3
|
from ..encoding import Decodeable, Encodeable
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ from ..encoding import Decodeable, Encodeable
|
|
|
6
6
|
class RunLengthEncoding(LosslessEncoding):
|
|
7
7
|
@staticmethod
|
|
8
8
|
def encode_online(obj: Encodeable) -> Generator[bytes, None, None]:
|
|
9
|
-
buffer:
|
|
9
|
+
buffer: List[int] = []
|
|
10
10
|
for c in obj:
|
|
11
11
|
if len(buffer) > 0:
|
|
12
12
|
if c != buffer[0]:
|
|
@@ -17,6 +17,7 @@ class RunLengthEncoding(LosslessEncoding):
|
|
|
17
17
|
|
|
18
18
|
@staticmethod
|
|
19
19
|
def decode_online(obj: Decodeable) -> Generator[bytes, None, None]:
|
|
20
|
+
# TODO
|
|
20
21
|
pass
|
|
21
22
|
|
|
22
23
|
SEPERATOR = b","
|