py2max 0.3.4__tar.gz → 0.3.5__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.
- {py2max-0.3.4 → py2max-0.3.5}/CHANGELOG.md +6 -0
- {py2max-0.3.4 → py2max-0.3.5}/PKG-INFO +1 -1
- {py2max-0.3.4 → py2max-0.3.5}/py2max/__init__.py +1 -1
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/patcher.py +11 -2
- {py2max-0.3.4 → py2max-0.3.5}/pyproject.toml +1 -1
- py2max-0.3.5/tests/test_patcher.py +96 -0
- py2max-0.3.4/tests/test_patcher.py +0 -47
- {py2max-0.3.4 → py2max-0.3.5}/LICENSE +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/README.md +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/__main__.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/cli.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/__init__.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/abstract.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/box.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/colors.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/common.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/factory.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/patchline.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/core/serialization.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/exceptions.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/export/__init__.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/export/converters.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/export/svg.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/__init__.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/base.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/external.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/flow.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/graph.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/grid.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/layout/matrix.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/lint.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/log.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/m4l.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/__init__.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/category.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/data/bundle.json.gz +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/db.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/legacy.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/parser.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/maxref/porttypes.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/py.typed +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/transformers.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/py2max/utils.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/__init__.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/conftest.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/complex.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/desc.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/empty.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/mydevice.amxd +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/mydevice2.amxd +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/nested.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/simple.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/tabular.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/data/umenu.maxref.xml +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/README.md +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/advanced/connection_patterns.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/advanced/custom_extensions.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/advanced/data_containers.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/advanced/error_handling.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/advanced/performance_optimization.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/advanced/subpatchers.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/api/box_api_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/api/patcher_api_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/auto_layout_demo.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/db/category_db_demo.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/db/maxref_db_demo.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/layout/columnar_layout_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/layout/flow_layout_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/layout/grid_layout_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/layout/matrix_layout_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/basic_synth.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/basic_synth.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/complex_synth.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/complex_synth.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/flow_layout.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/flow_layout.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/grid_layout.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/grid_layout.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/horizontal_layout.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/horizontal_layout.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/styled_no_ports.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/styled_no_title.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/styled_patch.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/styled_with_ports.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/svg_preview_demo.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/vertical_layout.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/vertical_layout.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/workflow_demo.maxpat +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/preview/workflow_demo.svg +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/quickstart/basic_patch.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/quickstart/layout_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/tutorial/generative_music.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/tutorial/interactive_controller.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/tutorial/signal_processing_chain.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/examples/tutorial/simple_synthesis.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/graphs/random/v30e33.tglf +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_abstract_coverage.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_abstraction.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_add.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_amxd.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_attrui.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_basic.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_beap.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_bpatcher.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_cli.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_coll.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_colors.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_colors_theme.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_comment.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_connection_validation.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_converters.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_core_coverage.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_db.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_defaults.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_dict.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_edit_operations.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_encapsulate.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_error_handling.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_examples.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_ezdac.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_gen.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_group.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_itable.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_js.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_kwds_filter.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_box_dims.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_builtins.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_coverage.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_flow.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_graph.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_graph_layout.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_graph_manager.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_matrix.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_overlaps.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_layout_vertical.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_linking.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_lint.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_m4l.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_maxref.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_maxref_bundle.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_maxref_lazy.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_maxref_parser.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_maxref_refpages.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_mc_cycle.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_mc_poly.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_message.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_mypatch.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_nested.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_nested_patchers.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_number_tilde.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_numbers.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_param.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_param_placement.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_pitched_osc.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_porttypes.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_presets.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_pydantic.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_rnbo.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_rnbo_subpatcher.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_scripting_name.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_search.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_semantic_ids.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_subpatch.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_svg.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_svg_fidelity.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_table.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_transformers.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_transformers_e4.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_tree.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_tree_builder.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_tutorial_simple_synthesis.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_two_sines.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_umenu.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_utils.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_validate_attrs.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_validation.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_varname.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_wheel_bundle.py +0 -0
- {py2max-0.3.4 → py2max-0.3.5}/tests/test_zl_group.py +0 -0
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.3.5]
|
|
6
|
+
|
|
7
|
+
### Fixed: `Patcher.optimize_layout()` now reaches the incremental layout path
|
|
8
|
+
|
|
9
|
+
- `Patcher.optimize_layout()` gained an optional `changed_objects: Optional[Set[str]]` parameter and forwards it to the layout manager. It previously called the manager with no arguments, silently discarding any change set, so the incremental layout engine (`layout/base.py` `optimize_layout(changed_objects)` / `should_use_incremental` / `_incremental_layout`) was unreachable through the public API -- every call forced a full relayout. Passing a set of object IDs now lets managers that support it (grid, flow) reposition only those objects and their patchline neighbours; `None` (the default) preserves the previous full-relayout behaviour, so the change is backward compatible. Matrix/columnar managers still recompute in full (they ignore the argument by design). This is the core prerequisite for server-side auto-layout, which lives in `py2max-server`.
|
|
10
|
+
|
|
5
11
|
## [0.3.4]
|
|
6
12
|
|
|
7
13
|
### New: Param docking in layouts
|
|
@@ -23,6 +23,7 @@ from typing import (
|
|
|
23
23
|
Iterator,
|
|
24
24
|
List,
|
|
25
25
|
Optional,
|
|
26
|
+
Set,
|
|
26
27
|
Tuple,
|
|
27
28
|
Union,
|
|
28
29
|
cast,
|
|
@@ -656,7 +657,7 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
656
657
|
return self._layout_mgr.get_pos(maxclass)
|
|
657
658
|
return self._layout_mgr.get_pos()
|
|
658
659
|
|
|
659
|
-
def optimize_layout(self) -> None:
|
|
660
|
+
def optimize_layout(self, changed_objects: Optional[Set[str]] = None) -> None:
|
|
660
661
|
"""Optimize object positions based on layout manager type.
|
|
661
662
|
|
|
662
663
|
Calls the layout manager's optimization method to improve object
|
|
@@ -669,9 +670,17 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
669
670
|
|
|
670
671
|
This method should be called after all objects and connections
|
|
671
672
|
have been added to the patch.
|
|
673
|
+
|
|
674
|
+
Args:
|
|
675
|
+
changed_objects: Optional set of object IDs that have changed. When
|
|
676
|
+
provided and small relative to the total, managers that support
|
|
677
|
+
it reposition only those objects and their neighbours
|
|
678
|
+
(incremental layout) instead of recomputing the whole patch;
|
|
679
|
+
when ``None`` a full layout is performed. Managers that do not
|
|
680
|
+
implement incremental layout ignore the argument.
|
|
672
681
|
"""
|
|
673
682
|
if hasattr(self._layout_mgr, "optimize_layout"):
|
|
674
|
-
self._layout_mgr.optimize_layout()
|
|
683
|
+
self._layout_mgr.optimize_layout(changed_objects)
|
|
675
684
|
|
|
676
685
|
# Dock value/UI params next to the object they drive (opt-in).
|
|
677
686
|
if self._param_placement and hasattr(self._layout_mgr, "place_params"):
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from py2max import Patcher
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
DATA_DIR = Path(__file__).parent / "data"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_patcher_basics():
|
|
10
|
+
p = Patcher("outputs/test_patcher_basics.maxpat", title="top notch patcher")
|
|
11
|
+
assert repr(p) == "Patcher(path='outputs/test_patcher_basics.maxpat')"
|
|
12
|
+
assert p._layout_mgr.parent.rect == p.rect
|
|
13
|
+
osc1 = p.add_textbox("cycle~")
|
|
14
|
+
osc2 = p.add_textbox("cycle~ 440")
|
|
15
|
+
assert osc1.id and osc2.id
|
|
16
|
+
assert repr(osc1) == f"Box(id='{osc1.id}', maxclass='newobj')"
|
|
17
|
+
assert osc1.oid == 1
|
|
18
|
+
line1 = p.add_patchline_by_index(osc1.id, osc2.id)
|
|
19
|
+
assert line1
|
|
20
|
+
assert repr(line1)
|
|
21
|
+
assert len(line1.to_tuple()) == 5
|
|
22
|
+
p.save()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_patcher_from_file():
|
|
26
|
+
p = Patcher.from_file(
|
|
27
|
+
DATA_DIR / "complex.maxpat", save_to="outputs/test_complex.maxpat"
|
|
28
|
+
)
|
|
29
|
+
assert len(p._boxes) == len(p.boxes) == 53
|
|
30
|
+
assert len(list(p)) == 60
|
|
31
|
+
assert p.to_json()
|
|
32
|
+
p.save()
|
|
33
|
+
p.save_as("outputs/test_complex2.maxpat")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_optimize_layout_forwards_changed_objects():
|
|
37
|
+
"""Patcher.optimize_layout() must forward ``changed_objects`` to the layout
|
|
38
|
+
manager so the incremental path is reachable through the public API.
|
|
39
|
+
|
|
40
|
+
Regression: the facade previously called ``self._layout_mgr.optimize_layout()``
|
|
41
|
+
with no arguments, silently discarding the change set and always forcing a
|
|
42
|
+
full relayout.
|
|
43
|
+
"""
|
|
44
|
+
p = Patcher("outputs/test_optimize_forwarding.maxpat", layout="grid")
|
|
45
|
+
a = p.add_textbox("cycle~ 440")
|
|
46
|
+
b = p.add_textbox("gain~")
|
|
47
|
+
p.add_line(a, b)
|
|
48
|
+
|
|
49
|
+
received: list = []
|
|
50
|
+
real = p._layout_mgr.optimize_layout
|
|
51
|
+
|
|
52
|
+
def spy(changed_objects=None):
|
|
53
|
+
received.append(changed_objects)
|
|
54
|
+
return real(changed_objects)
|
|
55
|
+
|
|
56
|
+
p._layout_mgr.optimize_layout = spy # type: ignore[method-assign]
|
|
57
|
+
|
|
58
|
+
p.optimize_layout() # full layout
|
|
59
|
+
p.optimize_layout({a.id}) # incremental request
|
|
60
|
+
|
|
61
|
+
assert received == [None, {a.id}]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_optimize_layout_incremental_leaves_untouched_objects_fixed():
|
|
65
|
+
"""A small change set routes through incremental layout, which keeps
|
|
66
|
+
unaffected, unconnected objects at their existing positions."""
|
|
67
|
+
p = Patcher("outputs/test_optimize_incremental.maxpat", layout="grid")
|
|
68
|
+
# Two connected objects plus a pool of disconnected ones so the affected
|
|
69
|
+
# fraction (one object + its neighbour) stays under the incremental threshold.
|
|
70
|
+
a = p.add_textbox("cycle~ 440")
|
|
71
|
+
b = p.add_textbox("gain~")
|
|
72
|
+
p.add_line(a, b)
|
|
73
|
+
others = [p.add_textbox(f"print label{i}") for i in range(12)]
|
|
74
|
+
|
|
75
|
+
p.optimize_layout() # settle everything
|
|
76
|
+
before = {o.id: tuple(o.patching_rect) for o in others}
|
|
77
|
+
|
|
78
|
+
assert p._layout_mgr.should_use_incremental({a.id}) is True
|
|
79
|
+
p.optimize_layout({a.id})
|
|
80
|
+
|
|
81
|
+
after = {o.id: tuple(o.patching_rect) for o in others}
|
|
82
|
+
assert after == before
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_patcher_from_file_comparison_complex():
|
|
86
|
+
pd = Patcher.from_file(DATA_DIR / "complex.maxpat").to_dict()
|
|
87
|
+
with open(DATA_DIR / "complex.maxpat") as f:
|
|
88
|
+
d = json.load(f)
|
|
89
|
+
assert pd == d
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_patcher_from_file_comparison_simple():
|
|
93
|
+
pd = Patcher.from_file(DATA_DIR / "simple.maxpat").to_dict()
|
|
94
|
+
with open(DATA_DIR / "simple.maxpat") as f:
|
|
95
|
+
d = json.load(f)
|
|
96
|
+
assert pd == d
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from py2max import Patcher
|
|
4
|
-
import json
|
|
5
|
-
|
|
6
|
-
DATA_DIR = Path(__file__).parent / "data"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_patcher_basics():
|
|
10
|
-
p = Patcher("outputs/test_patcher_basics.maxpat", title="top notch patcher")
|
|
11
|
-
assert repr(p) == "Patcher(path='outputs/test_patcher_basics.maxpat')"
|
|
12
|
-
assert p._layout_mgr.parent.rect == p.rect
|
|
13
|
-
osc1 = p.add_textbox("cycle~")
|
|
14
|
-
osc2 = p.add_textbox("cycle~ 440")
|
|
15
|
-
assert osc1.id and osc2.id
|
|
16
|
-
assert repr(osc1) == f"Box(id='{osc1.id}', maxclass='newobj')"
|
|
17
|
-
assert osc1.oid == 1
|
|
18
|
-
line1 = p.add_patchline_by_index(osc1.id, osc2.id)
|
|
19
|
-
assert line1
|
|
20
|
-
assert repr(line1)
|
|
21
|
-
assert len(line1.to_tuple()) == 5
|
|
22
|
-
p.save()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def test_patcher_from_file():
|
|
26
|
-
p = Patcher.from_file(
|
|
27
|
-
DATA_DIR / "complex.maxpat", save_to="outputs/test_complex.maxpat"
|
|
28
|
-
)
|
|
29
|
-
assert len(p._boxes) == len(p.boxes) == 53
|
|
30
|
-
assert len(list(p)) == 60
|
|
31
|
-
assert p.to_json()
|
|
32
|
-
p.save()
|
|
33
|
-
p.save_as("outputs/test_complex2.maxpat")
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_patcher_from_file_comparison_complex():
|
|
37
|
-
pd = Patcher.from_file(DATA_DIR / "complex.maxpat").to_dict()
|
|
38
|
-
with open(DATA_DIR / "complex.maxpat") as f:
|
|
39
|
-
d = json.load(f)
|
|
40
|
-
assert pd == d
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def test_patcher_from_file_comparison_simple():
|
|
44
|
-
pd = Patcher.from_file(DATA_DIR / "simple.maxpat").to_dict()
|
|
45
|
-
with open(DATA_DIR / "simple.maxpat") as f:
|
|
46
|
-
d = json.load(f)
|
|
47
|
-
assert pd == d
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|