quilt_knit.swatch.course_wise_merging.Course_Wise_Connection module
Module containing the Course Wise Connection class.
- class Course_Wise_Connection(left_swatch, right_swatch, first_carriage_pass_on_left=0, last_carriage_pass_on_left=None, first_carriage_pass_on_right=0, last_carriage_pass_on_right=None)[source]
Bases:
Swatch_ConnectionClass representing the course-wise alignment of two swatches in a quilt.
- Parameters:
- __init__(left_swatch, right_swatch, first_carriage_pass_on_left=0, last_carriage_pass_on_left=None, first_carriage_pass_on_right=0, last_carriage_pass_on_right=None)[source]
- Parameters:
left_swatch (Swatch) – The left swatch in the connection.
right_swatch (Swatch) – The right swatch in the connection.
first_carriage_pass_on_left (int, optional) – The first carriage pass to merge from on the left side. Defaults to 0.
last_carriage_pass_on_left (int, optional) – The last carriage pass to merge from on the left side. Defaults to the height of the left swatch.
first_carriage_pass_on_right (int, optional) – The first carriage pass to merge from on the right side. Defaults to 0.
last_carriage_pass_on_right (int, optional) – The last carriage pass to merge from on the right side. Defaults to the height of the right swatch.
- property merge_left_to_end: bool
Returns: bool: True if the connection goes all the way to the end of the left swatch, False otherwise.
- property merge_left_from_beginning: bool
Returns: bool: True if the connection starts at the beginning of the left swatch, False otherwise.
- property merge_right_to_end: bool
Returns: bool: True if the connection goes all the way to the end of the right swatch, False otherwise.
- property merge_right_from_beginning: bool
Returns: bool: True if the connection starts at the beginning of the right swatch, False otherwise.
- property left_start_direction: Carriage_Pass_Direction | None
Returns: Carriage_Pass_Direction | None : The direction of the first carriage pass to merge from on the left side, or None if the first carriage pass is a transfer pass.
- property right_start_direction: Carriage_Pass_Direction | None
Returns: Carriage_Pass_Direction | None : The direction of the first carriage pass to merge from on the left side, or None if the first carriage pass is a transfer pass.
- swap_from_swatch(new_swatch, interval_shift=0)[source]
- Parameters:
- Returns:
A new connection with the same intervals and the from-swatch swapped for the new given swatch.
- Return type:
- swap_to_swatch(new_swatch, interval_shift=0)[source]
- Parameters:
- Returns:
A new connection with the same intervals and the from-swatch swapped for the new given swatch.
- Return type:
- swap_from_swatch_by_carriage_pass_alignment(new_swatch, interval_shift)[source]
- Parameters:
- Returns:
The connection formed by swapping the left swatch with the given new swatch and adjusting the interval by the given specification.
- Return type:
- swap_to_swatch_by_carriage_pass_alignment(new_swatch, interval_shift)[source]
- Parameters:
- Returns:
The connection formed by swapping the right swatch with the given new swatch and adjusting the interval by the given specification.
- Return type:
- swap_matching_swatch_by_carriage_pass_alignment(new_swatch, matching_swatch, interval_shift)[source]
- Parameters:
- Returns:
The swatch connection formed by swapping the new swatch into place of the matched swatch and shifting it by the given interval. If this connection does not contain the matching swatch, this connection is returned unchanged.
- Return type:
- property left_swatch: Swatch
Returns: Swatch: The swatch that is merged from course-wise forming the left side of the connection.
- property right_swatch: Swatch
Returns: Swatch: The swatch that is merged to course-wise forming the right side of the connection.
- property right_bottom_course: int
Returns: int: The bottom carriage pass index of the right swatch.
- __contains__(swatch)
- __eq__(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other swatch connection to compare to.
- Returns:
True if other_connection is of the same type and connects the same swatches and has the same intervals. False, otherwise.
- Return type:
- __hash__()
- Returns:
Hash of the tuple of the from_swatch, to_swatch, from_interval, and to_interval.
- Return type:
- __post_init__()
Checks that the intervals are correct after the connection has been initialized.
- connects_same_swatches(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other swatch connection to compare to.
- Returns:
True if this and the other connection connect the same swatches. False, otherwise.
- Return type:
- envelops(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other swatch connection to compare to.
- Returns:
True if the range of needle connections of this swatch’s intervals envelops the intervals in the other connection. False otherwise.
- Return type:
Notes
This method does not test for equality of the swatches in this and the other connection.
- property from_interval: Interval
Returns: Interval: The interval of connection on the from-swatch.
- merged_connection(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other connection to merge with.
- Returns:
The merged swatch connection.
- Return type:
- Raises:
NotImplementedError – Implemented in subclass.
Notes
This method does not test for equality of the swatches merged into the interval.
This method does not test for overlap or gaps between the intervals.
- overlaps(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other swatch connection to compare to.
- Returns:
True if the range of needle connections overlaps the intervals in the other connection. False otherwise.
- Return type:
Notes
This method does not test for equality of the swatches in this and the other connection.
- range_matches(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other swatch connection to compare to.
- Returns:
True if the range of needle connections to and from intervals are identical. False otherwise.
- Return type:
Notes
This method does not test for equality of the swatches in this and the other connection.
- swap_matching_swatch(new_swatch, matching_swatch, interval_shift=0)
- Parameters:
new_swatch (Swatch) – The new swatch to swap into the place of the matching swatch.
matching_swatch (Swatch) – The matching swatch to swap out of the connection.
interval_shift (int, optional) – The amount to shift the interval on the matching swatch side. Negative will shift the interval down. Defaults to 0.
- Returns:
The swatch connection formed by swapping the new swatch into place of the matched swatch and shifting it by the given interval. If this connection does not contain the matching swatch, this connection is returned unchanged.
- Return type:
- property to_interval: Interval
Returns: Interval: The interval of connection on the to-swatch.
- touches(other_connection)
- Parameters:
other_connection (Swatch_Connection) – The other swatch connection to compare to.
- Returns:
True if the range of needle connections of this connection touches the intervals in the other connection. False otherwise.
- Return type:
Notes
This method does not test for equality of the swatches in this and the other connection.
- update_connection(prior_connection)
- Parameters:
prior_connection (Swatch_Connection | None) – The prior connection to consider replacing this connection with.
- Returns:
The connection to replace the prior connection given this connection. * If the prior connection is None or does not involve these swatches, this connection is returned unchanged. * If the prior connection subsumes this connection, None is returned and no updated connection is needed. * If the prior connection overlaps this connection, a connection that merges both connection is returned. * Otherwise, the two connections do not touch and this connection is returned unchanged to replace the prior connection.
- Return type:
Swatch_Connection | None