cutcutcodec 1.0.post3__py3-none-any.whl
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.
Potentially problematic release.
This version of cutcutcodec might be problematic. Click here for more details.
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__main__.py +38 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/c_build.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/_helper_properties.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/duration.py +83 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/ffprobe.py +637 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/find.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/time_backprop.py +68 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_audio.py +239 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_video.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/shape.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/time_backprop.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/duration.py +162 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/nb_frames.py +159 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/rate.py +102 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/timestamps.py +194 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/container.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/encoder.py +152 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/filter.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame.py +127 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_audio.py +205 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_video.py +322 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/layout.py +206 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/meta_filter.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/muxer.py +184 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/node.py +164 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream.py +182 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_audio.py +130 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_video.py +193 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/__init__.py +7 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/ast_to_file.py +125 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/compatibility.py +734 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/default.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/encodec.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/muxer.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/rate.py +133 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_ast.py +477 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_json.py +104 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_tree.py +190 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/json_to_graph.py +114 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/parse.py +123 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/__init__.py +15 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/dynamic.py +544 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/lambdify.py +612 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/preprocess.py +698 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/printer.py +926 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/tree_to_graph.py +168 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/decision/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/add.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/remove.py +476 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/exceptions.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/add.py +170 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cut.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/delay.py +85 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/equation.py +261 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/fir.py +231 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/resample.py +451 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/cut.py +74 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/audio_cast.py +208 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/video_cast.py +197 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/subclip.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/add.py +331 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cut.py +113 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/delay.py +84 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/equation.py +265 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/pad.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/empty.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/equation.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/noise.py +243 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/c_fractal.cpython-312-x86_64-linux-gnu.so +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/empty.py +69 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/equation.py +109 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/fractal.c +116 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/geometry.py +100 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/mandelbrot.py +176 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/noise.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/seedable.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_ffmpeg.py +904 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_svg.py +145 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/scheduler.py +356 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/write.py +340 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/basic.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/graph.py +80 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/graph.py +81 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/singleton.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cuda/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/proba.py +189 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/delay_to_fir.py +88 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/graph.py +17 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/buffer.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/utils.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/audio_5.1_narration.oga +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/intro.webm +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/logo.svg +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/project.json +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/video.mp4 +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__main__.py +25 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/actions.py +63 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/app.py +248 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/base.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/container_input_ffmpeg.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_equation.py +45 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_fir.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_cut.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_delay.py +20 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_subclip.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_equation.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_equation.py +14 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_noise.py +19 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_equation.py +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_mandelbrot.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_noise.py +18 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/base.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/default.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/documentation.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/general.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/interface.py +305 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/loader.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/main.py +62 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edition_tabs.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/base.py +122 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/filters.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/generators.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry_tabs.py +46 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/_helper.py +54 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/container.py +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/doc.py +67 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/encodec.py +289 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/main.py +173 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/edge_properties.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/main.py +280 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/node.py +44 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/main.py +151 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/menu.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/audio_settings.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/main.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/video_settings.py +257 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/run.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/main.py +30 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/slider.py +286 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/track.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/view.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/toolbar.py +29 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/tools.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/audio_player.py +103 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/control.py +96 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/frame_extractor.py +254 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/main.py +115 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__main__.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/coding_style.py +49 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/generation.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/install.py +72 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/run.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/abstract.py +215 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_cast.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_equation.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/c_memory.py +132 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compatibility.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compile.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/encoder.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_cut.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_delay.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_empty.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/fir.py +143 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/hashes.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/initialisation.py +24 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/muxer.py +22 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/nan_snapshot.py +39 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/read.py +192 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/serialization_equality.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/snapshot_shape.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/sympy_to_torch.py +135 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/thread_safe.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/time_range.py +55 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/video_equation.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/write.py +95 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/utils.py +40 -0
- cutcutcodec-1.0.post3.dist-info/LICENSE +7 -0
- cutcutcodec-1.0.post3.dist-info/METADATA +271 -0
- cutcutcodec-1.0.post3.dist-info/RECORD +233 -0
- cutcutcodec-1.0.post3.dist-info/WHEEL +5 -0
- cutcutcodec-1.0.post3.dist-info/entry_points.txt +6 -0
- cutcutcodec-1.0.post3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Compile an assembly graph into an evaluable tree."""
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
import networkx
|
|
8
|
+
|
|
9
|
+
from cutcutcodec.core.classes.container import ContainerOutput
|
|
10
|
+
from cutcutcodec.core.classes.node import Node
|
|
11
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
12
|
+
from cutcutcodec.core.opti.cache.clean.graph import clean_graph
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _tree_from_node(node_name: str, graph: networkx.MultiDiGraph) -> None:
|
|
16
|
+
"""Recursively retrieve the node corresponding to the node of the graph.
|
|
17
|
+
|
|
18
|
+
Complete the ``tree`` attribute for this node and for the out streams of this node.
|
|
19
|
+
This function is recursive, so all ancestors are also completed.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
node_name : str
|
|
24
|
+
The name of the node that allows to determine the corresponding subgraph.
|
|
25
|
+
graph : networkx.MultiDiGraph
|
|
26
|
+
The complete assembly graph.
|
|
27
|
+
|
|
28
|
+
Notes
|
|
29
|
+
-----
|
|
30
|
+
If the node is a terminal node, it is the complete dynamic tree.
|
|
31
|
+
"""
|
|
32
|
+
assert isinstance(graph, networkx.MultiDiGraph), graph.__class__.__name__
|
|
33
|
+
assert isinstance(node_name, str), node_name.__class__.__name__
|
|
34
|
+
assert node_name in graph.nodes, sorted(graph.nodes)
|
|
35
|
+
|
|
36
|
+
# create node and recursively the parent nodes
|
|
37
|
+
node = graph.nodes[node_name]
|
|
38
|
+
if "tree" not in node["cache"][1]:
|
|
39
|
+
for pred in graph.predecessors(node_name):
|
|
40
|
+
_tree_from_node(pred, graph) # editing by pointer
|
|
41
|
+
in_edges = graph.in_edges(node_name, keys=True)
|
|
42
|
+
if sorted(int(k.split("->")[1]) for _, _, k in in_edges) != list(range(len(in_edges))):
|
|
43
|
+
raise IndexError(
|
|
44
|
+
f"the streams ({in_edges}) arriving on {node_name} are not correctly incremented"
|
|
45
|
+
)
|
|
46
|
+
in_streams = [
|
|
47
|
+
graph.edges[edge_name]["cache"][1]["tree"] for edge_name in
|
|
48
|
+
sorted(in_edges, key=lambda src_dst_key: int(src_dst_key[2].split("->")[1]))
|
|
49
|
+
] # the streams that arrive on the current node
|
|
50
|
+
node["cache"][1]["tree"] = new_node(node["class"], in_streams, node["state"])
|
|
51
|
+
assert node["cache"][1]["tree"].in_streams == tuple(in_streams), \
|
|
52
|
+
f"the node {node_name} does not have the specified input streams"
|
|
53
|
+
|
|
54
|
+
# complete out streams
|
|
55
|
+
for out_edge_name in graph.out_edges(node_name, keys=True):
|
|
56
|
+
out_edge = graph.edges[out_edge_name]
|
|
57
|
+
if "tree" not in out_edge["cache"][1]:
|
|
58
|
+
index = int(out_edge_name[2].split("->")[0])
|
|
59
|
+
assert index < len(node["cache"][1]["tree"].out_streams), (
|
|
60
|
+
f"the {out_edge_name[0]} node has only {len(node['cache'][1]['tree'].out_streams)} "
|
|
61
|
+
f"output streams, impossible to access stream index {index}"
|
|
62
|
+
)
|
|
63
|
+
out_edge["cache"][1]["tree"] = node["cache"][1]["tree"].out_streams[index]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def graph_to_tree(graph: networkx.MultiDiGraph) -> ContainerOutput:
|
|
67
|
+
"""Create the dynamic tree from the assembly graph.
|
|
68
|
+
|
|
69
|
+
The abstract dynamic tree alows the evaluation of the complete pipeline.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
graph : networkx.MultiDiGraph
|
|
74
|
+
The assembly graph.
|
|
75
|
+
|
|
76
|
+
Returns
|
|
77
|
+
-------
|
|
78
|
+
container_out : cutcutcodec.core.classes.container.ContainerOutput
|
|
79
|
+
An evaluable multimedia muxer.
|
|
80
|
+
|
|
81
|
+
Examples
|
|
82
|
+
--------
|
|
83
|
+
>>> from cutcutcodec.core.classes.container import ContainerOutput
|
|
84
|
+
>>> from cutcutcodec.core.compilation.graph_to_tree import graph_to_tree
|
|
85
|
+
>>> from cutcutcodec.core.compilation.tree_to_graph import tree_to_graph
|
|
86
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
87
|
+
>>> tree = tree_to_graph(ContainerOutput(GeneratorAudioNoise(0).out_streams))
|
|
88
|
+
>>> graph_to_tree(tree) # doctest: +ELLIPSIS
|
|
89
|
+
<cutcutcodec.core.classes.container.ContainerOutput object at ...>
|
|
90
|
+
>>>
|
|
91
|
+
"""
|
|
92
|
+
# verification and extraction of the termination node
|
|
93
|
+
assert isinstance(graph, networkx.MultiDiGraph), graph.__class__.__name__
|
|
94
|
+
out_nodes = [n for n in graph.nodes if issubclass(graph.nodes[n]["class"], ContainerOutput)]
|
|
95
|
+
assert len(out_nodes) == 1, f"only one output node is possible, not {len(out_nodes)}"
|
|
96
|
+
out_node = out_nodes.pop()
|
|
97
|
+
assert issubclass(graph.nodes[out_node]["class"], ContainerOutput), \
|
|
98
|
+
graph.nodes[out_node]["class"].__name__
|
|
99
|
+
|
|
100
|
+
# fill
|
|
101
|
+
update_trees(graph) # compute and add missing "tree" nodes
|
|
102
|
+
container_out = graph.nodes[out_node]["cache"][1]["tree"]
|
|
103
|
+
return container_out
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def new_node(node_class: type, in_streams: typing.Iterable[Stream], state: dict) -> Node:
|
|
107
|
+
"""Instantiate and initialize a new node.
|
|
108
|
+
|
|
109
|
+
Parameters
|
|
110
|
+
----------
|
|
111
|
+
node_class : type
|
|
112
|
+
The uninstantiated class describing the node to be created.
|
|
113
|
+
This class must be inherited from the ``cutcutcodec.core.classes.node.Node`` class.
|
|
114
|
+
in_streams : typing.Iterable[Stream]
|
|
115
|
+
See ``cutcutcodec.core.classes.node.Node.setstate``.
|
|
116
|
+
state : dict
|
|
117
|
+
See ``cutcutcodec.core.classes.node.Node.setstate``.
|
|
118
|
+
|
|
119
|
+
Returns
|
|
120
|
+
-------
|
|
121
|
+
node : Node
|
|
122
|
+
A new instantiated and initialized node.
|
|
123
|
+
"""
|
|
124
|
+
assert isinstance(node_class, type), f"{node_class} must be a class, not an object"
|
|
125
|
+
assert issubclass(node_class, Node), f"{node_class.__name__} class does not inherit from Node"
|
|
126
|
+
|
|
127
|
+
node = node_class.__new__(node_class)
|
|
128
|
+
node.setstate(in_streams, state)
|
|
129
|
+
return node
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def update_trees(graph: networkx.MultiDiGraph) -> None:
|
|
133
|
+
"""Update on each node the ``tree`` attribute.
|
|
134
|
+
|
|
135
|
+
From the assembly graph, this function reconstructs the dynamic instances
|
|
136
|
+
and is able to perform the calculations.
|
|
137
|
+
By adding to each node the attribute ``tree``,
|
|
138
|
+
it allows not only to keep the graph structure but also
|
|
139
|
+
to recalculate only the parts that need to be changed.
|
|
140
|
+
|
|
141
|
+
The operation are applies in-place.
|
|
142
|
+
|
|
143
|
+
Parameters
|
|
144
|
+
----------
|
|
145
|
+
graph : networkx.MultiDiGraph
|
|
146
|
+
The assembly graph who is going to have the updated ``tree`` attributes.
|
|
147
|
+
|
|
148
|
+
Examples
|
|
149
|
+
--------
|
|
150
|
+
>>> from pprint import pprint
|
|
151
|
+
>>> from cutcutcodec.core.classes.container import ContainerOutput
|
|
152
|
+
>>> from cutcutcodec.core.compilation.graph_to_tree import update_trees
|
|
153
|
+
>>> from cutcutcodec.core.compilation.tree_to_graph import tree_to_graph
|
|
154
|
+
>>> from cutcutcodec.core.filters.audio.subclip import FilterAudioSubclip
|
|
155
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
156
|
+
>>> container_out = ContainerOutput(
|
|
157
|
+
... FilterAudioSubclip(GeneratorAudioNoise(0).out_streams, 1, 2).out_streams
|
|
158
|
+
... )
|
|
159
|
+
>>> graph = tree_to_graph(container_out)
|
|
160
|
+
>>> update_trees(graph)
|
|
161
|
+
>>> pprint(dict(graph.nodes("cache"))) # doctest: +ELLIPSIS
|
|
162
|
+
{'container_output_1': ('b1c67b749185174850a2d5cdce2bcb82',
|
|
163
|
+
{'tree': <cutcutcodec.core.classes.container.ContainerOutput...>}),
|
|
164
|
+
'filter_audio_subclip_1': ('ab86b53fe424b58e755eac50d87a77f0',
|
|
165
|
+
{'tree': <...FilterAudioSubclip...>}),
|
|
166
|
+
'generator_audio_noise_1': ('4dc3de85c734bfd23024c381599bfe3f',
|
|
167
|
+
{'tree': <...GeneratorAudioNoise...>})}
|
|
168
|
+
>>> pprint(list(graph.edges(keys=True, data=True))) # doctest: +ELLIPSIS
|
|
169
|
+
[('filter_audio_subclip_1',
|
|
170
|
+
'container_output_1',
|
|
171
|
+
'0->0',
|
|
172
|
+
{'cache': ('ab86b53fe424b58e755eac50d87a77f0|0',
|
|
173
|
+
{'tree': <cutcutcodec.core.filters.audio.cut._StreamAudioCut...>})}),
|
|
174
|
+
('generator_audio_noise_1',
|
|
175
|
+
'filter_audio_subclip_1',
|
|
176
|
+
'0->0',
|
|
177
|
+
{'cache': ('4dc3de85c734bfd23024c381599bfe3f|0',
|
|
178
|
+
{'tree': <cutcutcodec.core.generation.audio.noise._StreamAudioNoiseUniform...>})})]
|
|
179
|
+
>>>
|
|
180
|
+
"""
|
|
181
|
+
assert isinstance(graph, networkx.MultiDiGraph), graph.__class__.__name__
|
|
182
|
+
|
|
183
|
+
# delete obsolete cache and create field ["cache"][1]
|
|
184
|
+
graph = clean_graph(graph)
|
|
185
|
+
|
|
186
|
+
# complete graph
|
|
187
|
+
out_nodes = [node for node in graph.nodes if graph.out_degree(node) == 0]
|
|
188
|
+
assert out_nodes, "the graph is empty or contains cycle"
|
|
189
|
+
for node_name in out_nodes:
|
|
190
|
+
_tree_from_node(node_name, graph)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Help for deserialisation of a json representation of an assembly graph."""
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import inspect
|
|
7
|
+
import re
|
|
8
|
+
|
|
9
|
+
import networkx
|
|
10
|
+
|
|
11
|
+
from cutcutcodec.core.classes.node import Node
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _string_to_node_cls(string: str) -> Node:
|
|
15
|
+
"""Convert node string representation in Node class.
|
|
16
|
+
|
|
17
|
+
Bijection with ``cutcutcodec.core.compilation.graph_to_json._node_cls_to_string`` function.
|
|
18
|
+
|
|
19
|
+
Parameters
|
|
20
|
+
----------
|
|
21
|
+
string : str
|
|
22
|
+
The relative import path of the class.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
cls : type
|
|
27
|
+
The cutcutcodec.core.classes.node.Node subclass associate to the string.
|
|
28
|
+
|
|
29
|
+
Examples
|
|
30
|
+
--------
|
|
31
|
+
>>> from cutcutcodec.core.compilation.json_to_graph import _string_to_node_cls
|
|
32
|
+
>>> _string_to_node_cls('classes.node.Node')
|
|
33
|
+
<class 'cutcutcodec.core.classes.node.Node'>
|
|
34
|
+
>>>
|
|
35
|
+
"""
|
|
36
|
+
assert isinstance(string, str), string.__class__.__name__
|
|
37
|
+
mod = importlib.import_module("cutcutcodec.core." + ".".join(string.split(".")[:-1]))
|
|
38
|
+
node_cls = dict(inspect.getmembers(mod))[string.split(".")[-1]]
|
|
39
|
+
return node_cls
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def json_to_graph(json_graph: dict[str]) -> networkx.MultiDiGraph:
|
|
43
|
+
"""Create the graph from a json dictionary.
|
|
44
|
+
|
|
45
|
+
Reverse operation with ``cutcutcodec.core.compilation.graph_to_json.graph_to_json`` function.
|
|
46
|
+
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
json_graph : dict[str]
|
|
50
|
+
The complete representation of the graph.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
assembly_graph : networkx.MultiDiGraph
|
|
55
|
+
The strictly equivalent assembly graph.
|
|
56
|
+
|
|
57
|
+
Examples
|
|
58
|
+
--------
|
|
59
|
+
>>> from pprint import pprint
|
|
60
|
+
>>> from cutcutcodec.core.compilation.json_to_graph import json_to_graph
|
|
61
|
+
>>> json_graph = {
|
|
62
|
+
... 'edges': [['generator_audio_noise_1', 'container_output_1', '0->0']],
|
|
63
|
+
... 'nodes': {
|
|
64
|
+
... 'container_output_1': {
|
|
65
|
+
... 'class': 'classes.container.ContainerOutput',
|
|
66
|
+
... 'state': {},
|
|
67
|
+
... },
|
|
68
|
+
... 'generator_audio_noise_1': {
|
|
69
|
+
... 'class': 'generation.audio.noise.GeneratorAudioNoise',
|
|
70
|
+
... 'display': {'position': [0, 0]},
|
|
71
|
+
... 'state': {'seed': 0.0},
|
|
72
|
+
... },
|
|
73
|
+
... },
|
|
74
|
+
... }
|
|
75
|
+
>>> graph = json_to_graph(json_graph)
|
|
76
|
+
>>> pprint(sorted(graph.nodes))
|
|
77
|
+
['container_output_1', 'generator_audio_noise_1']
|
|
78
|
+
>>> pprint(sorted(graph.edges))
|
|
79
|
+
[('generator_audio_noise_1', 'container_output_1', '0->0')]
|
|
80
|
+
>>> pprint(graph.nodes["container_output_1"])
|
|
81
|
+
{'class': <class 'cutcutcodec.core.classes.container.ContainerOutput'>,
|
|
82
|
+
'state': {}}
|
|
83
|
+
>>> pprint(graph.nodes["generator_audio_noise_1"])
|
|
84
|
+
{'class': <class 'cutcutcodec.core.generation.audio.noise.GeneratorAudioNoise'>,
|
|
85
|
+
'display': {'position': [0, 0]},
|
|
86
|
+
'state': {'seed': 0.0}}
|
|
87
|
+
>>>
|
|
88
|
+
"""
|
|
89
|
+
assert isinstance(json_graph, dict), json_graph.__class__.__name__
|
|
90
|
+
assert all(isinstance(key, str) for key in json_graph), json_graph
|
|
91
|
+
assert json_graph.keys() == {"edges", "nodes"}, set(json_graph)
|
|
92
|
+
assert isinstance(json_graph["edges"], list), json_graph["edges"].__class__.__name__
|
|
93
|
+
assert isinstance(json_graph["nodes"], dict), json_graph["nodes"].__class__.__name__
|
|
94
|
+
|
|
95
|
+
graph = networkx.MultiDiGraph(title="assembly graph")
|
|
96
|
+
for node, data in json_graph["nodes"].items():
|
|
97
|
+
assert isinstance(node, str), (node, node.__class__.__name__)
|
|
98
|
+
assert isinstance(data, dict), (node, data)
|
|
99
|
+
assert {"class", "state"}.issubset(data), (node, data) # issubset(dict) <=> issubset(set)
|
|
100
|
+
data["class"] = _string_to_node_cls(data["class"])
|
|
101
|
+
graph.add_node(node, **data)
|
|
102
|
+
for edge in json_graph["edges"]:
|
|
103
|
+
assert isinstance(edge, list), (edge, edge.__class__.__name__)
|
|
104
|
+
assert len(edge) == 3, edge
|
|
105
|
+
src, dst, key = edge
|
|
106
|
+
assert isinstance(src, str), (edge, src, src.__class__.__name__)
|
|
107
|
+
assert isinstance(dst, str), (edge, dst, dst.__class__.__name__)
|
|
108
|
+
assert src in json_graph["nodes"], (edge, src, sorted(json_graph["nodes"]))
|
|
109
|
+
assert dst in json_graph["nodes"], (edge, dst, sorted(json_graph["nodes"]))
|
|
110
|
+
assert isinstance(key, str), (edge, key, key.__class__.__name__)
|
|
111
|
+
assert re.fullmatch(r"\d+->\d+", key), (edge, key)
|
|
112
|
+
graph.add_edge(src, dst, key)
|
|
113
|
+
|
|
114
|
+
return graph
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Extracting information from string."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import math
|
|
7
|
+
import numbers
|
|
8
|
+
import tokenize
|
|
9
|
+
import typing
|
|
10
|
+
|
|
11
|
+
from sympy.core.basic import Basic
|
|
12
|
+
from sympy.core.symbol import Symbol
|
|
13
|
+
from sympy.core.sympify import sympify, SympifyError
|
|
14
|
+
from sympy.parsing.sympy_parser import parse_expr, standard_transformations, implicit_multiplication
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def parse_to_number(number: typing.Union[str, numbers.Real]) -> typing.Union[Fraction, float]:
|
|
18
|
+
"""Convert the number into fraction, or inf float.
|
|
19
|
+
|
|
20
|
+
Raises
|
|
21
|
+
------
|
|
22
|
+
ValueError
|
|
23
|
+
If is not correct.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
--------
|
|
27
|
+
>>> import math
|
|
28
|
+
>>> import numpy as np
|
|
29
|
+
>>> from cutcutcodec.core.compilation.parse import parse_to_number
|
|
30
|
+
>>> parse_to_number("0")
|
|
31
|
+
Fraction(0, 1)
|
|
32
|
+
>>> parse_to_number("2/3")
|
|
33
|
+
Fraction(2, 3)
|
|
34
|
+
>>> parse_to_number("-1e-3")
|
|
35
|
+
Fraction(-1, 1000)
|
|
36
|
+
>>> parse_to_number(1)
|
|
37
|
+
Fraction(1, 1)
|
|
38
|
+
>>> parse_to_number(1.0)
|
|
39
|
+
Fraction(1, 1)
|
|
40
|
+
>>> parse_to_number("inf")
|
|
41
|
+
inf
|
|
42
|
+
>>> parse_to_number("oo")
|
|
43
|
+
inf
|
|
44
|
+
>>> parse_to_number(math.inf)
|
|
45
|
+
inf
|
|
46
|
+
>>> parse_to_number("1k")
|
|
47
|
+
Fraction(1000, 1)
|
|
48
|
+
>>> parse_to_number("2.3M")
|
|
49
|
+
Fraction(2300000, 1)
|
|
50
|
+
>>>
|
|
51
|
+
"""
|
|
52
|
+
if isinstance(number, str):
|
|
53
|
+
number = number.replace("k", "e3").replace("M", "e6")
|
|
54
|
+
try:
|
|
55
|
+
return Fraction(number)
|
|
56
|
+
except ValueError as err_frac:
|
|
57
|
+
number = number.replace("oo", "inf")
|
|
58
|
+
try:
|
|
59
|
+
return float(number)
|
|
60
|
+
except ValueError as err_float:
|
|
61
|
+
raise err_float from err_frac
|
|
62
|
+
if isinstance(number, numbers.Real):
|
|
63
|
+
try:
|
|
64
|
+
return Fraction(number)
|
|
65
|
+
except OverflowError:
|
|
66
|
+
return math.inf if number > 0 else -math.inf
|
|
67
|
+
raise TypeError(f"only str and numbers type can be cast, not {number.__class__.__name__}")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def parse_to_sympy(
|
|
71
|
+
expr: typing.Union[str, Basic, numbers.Complex], symbols: dict[str, Symbol] = None
|
|
72
|
+
) -> Basic:
|
|
73
|
+
"""Convert the expression in sympy compilable expression.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
expr : str or sympy.Expr
|
|
78
|
+
The string representation of the equation.
|
|
79
|
+
Some operators like multiplication can be implicit.
|
|
80
|
+
symbols : dict[str, sympy.Symbol]
|
|
81
|
+
A dictionary of local variables to use when parsing.
|
|
82
|
+
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
sympy.core.expr.Expr
|
|
86
|
+
The version sympy of the expression.
|
|
87
|
+
|
|
88
|
+
Raises
|
|
89
|
+
------
|
|
90
|
+
SyntaxError
|
|
91
|
+
If the entered expression does not allow to properly define an equation.
|
|
92
|
+
|
|
93
|
+
Examples
|
|
94
|
+
--------
|
|
95
|
+
>>> from cutcutcodec.core.compilation.parse import parse_to_sympy
|
|
96
|
+
>>> parse_to_sympy(0)
|
|
97
|
+
0
|
|
98
|
+
>>> parse_to_sympy("1/2 + 1/2*cos(2pi(t - i*j))")
|
|
99
|
+
1*cos(2*pi*(-i*j + t))/2 + 1/2
|
|
100
|
+
>>>
|
|
101
|
+
"""
|
|
102
|
+
if symbols is not None:
|
|
103
|
+
assert isinstance(symbols, dict), symbols.__class__.__name__
|
|
104
|
+
assert all(isinstance(k, str) for k in symbols), symbols
|
|
105
|
+
if isinstance(expr, str):
|
|
106
|
+
if not expr:
|
|
107
|
+
raise SyntaxError("impossible to parse an empty expr")
|
|
108
|
+
transformations = standard_transformations + (implicit_multiplication,)
|
|
109
|
+
try:
|
|
110
|
+
expr = parse_expr(
|
|
111
|
+
expr, local_dict=symbols, transformations=transformations, evaluate=False
|
|
112
|
+
)
|
|
113
|
+
except (SympifyError, tokenize.TokenError, TypeError) as err:
|
|
114
|
+
raise SyntaxError(f"failed to parse {expr}") from err
|
|
115
|
+
elif isinstance(expr, numbers.Complex):
|
|
116
|
+
expr = sympify(expr, locals=symbols, evaluate=True)
|
|
117
|
+
if not isinstance(expr, Basic):
|
|
118
|
+
raise SyntaxError(f"need to be expression, not {expr.__class__.__name__}")
|
|
119
|
+
try:
|
|
120
|
+
str(expr)
|
|
121
|
+
except AttributeError as err: # ex "1+()"
|
|
122
|
+
raise SyntaxError("expression parsing is corrupted") from err
|
|
123
|
+
return expr
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""The folowing optimisations are performed.
|
|
4
|
+
|
|
5
|
+
* Compute in place as possible.
|
|
6
|
+
* Compatible with gpu input tensor.
|
|
7
|
+
* Conserve the type: float32, float64 or complex.
|
|
8
|
+
* Factorisation of redondant patern for minimizing operations.
|
|
9
|
+
* Cached the constants paterns.
|
|
10
|
+
* Prealocate the internal tensors taken in account the broadcasting of shapes.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from cutcutcodec.core.compilation.sympy_to_torch.lambdify import Lambdify
|
|
14
|
+
|
|
15
|
+
__all__ = ["Lambdify"]
|