@@ -424,9 +424,7 @@ def _best_attachment_position_2d(
424424) -> np .ndarray :
425425 leaf_node_ids = {node_id for node_id , _ in component .trimmed_leaf_parents }
426426 direction_options = (
427- candidates
428- if component .structure_kind == "chain"
429- else (* candidates , axis , - axis )
427+ candidates if component .structure_kind == "chain" else (* candidates , axis , - axis )
430428 )
431429 used_dirs = []
432430 for neighbor_id in component .contraction_graph .neighbors (parent_id ):
@@ -458,13 +456,10 @@ def _best_attachment_position_2d(
458456 candidate = origin + direction * distance
459457 score = 0.8 * float (np .dot (direction [:2 ], outward_dir ))
460458 score -= 2.5 * sum (
461- max (0.0 , float (np .dot (direction [:2 ], used_dir )))
462- for used_dir in used_dirs
459+ max (0.0 , float (np .dot (direction [:2 ], used_dir ))) for used_dir in used_dirs
463460 )
464461 score -= 2.0 * sum (
465- 1.0
466- for target in assigned_targets
467- if np .linalg .norm (candidate [:2 ] - target [:2 ]) < 0.3
462+ 1.0 for target in assigned_targets if np .linalg .norm (candidate [:2 ] - target [:2 ]) < 0.3
468463 )
469464 score -= 4.0 * sum (
470465 1.0
@@ -722,9 +717,7 @@ def _compute_free_directions_3d(
722717 components = _analyze_layout_components (graph )
723718 assigned_segments : list [tuple [np .ndarray , np .ndarray ]] = []
724719 component_by_node = {
725- node_id : component
726- for component in components
727- for node_id in component .node_ids
720+ node_id : component for component in components for node_id in component .node_ids
728721 }
729722
730723 for node_id , node in graph .nodes .items ():
@@ -772,9 +765,7 @@ def _compute_free_directions_3d(
772765 break
773766 else :
774767 fallback = (
775- named_direction
776- if named_direction is not None
777- else _orthogonal_unit (axis )
768+ named_direction if named_direction is not None else _orthogonal_unit (axis )
778769 )
779770 if not _direction_has_space (fallback , used_dirs ):
780771 fallback = - fallback
@@ -825,8 +816,7 @@ def _used_axis_directions(
825816
826817def _direction_has_space (direction : np .ndarray , used_dirs : list [np .ndarray ]) -> bool :
827818 overlap = sum (
828- max (0.0 , float (np .dot (direction , used_direction )))
829- for used_direction in used_dirs
819+ max (0.0 , float (np .dot (direction , used_direction ))) for used_direction in used_dirs
830820 )
831821 return overlap < _FREE_DIR_OVERLAP_THRESHOLD
832822
0 commit comments