quilt_knit.quilt.Swatch_Neighborhood module

The Module containing the Swatch_Neighborhood class.

class Swatch_Neighborhood(swatch)[source]

Bases: object

A data structure organizing the interval trees of course and wale wise connections to a specific swatch.

swatch

The swatch at the center of this neighborhood.

Type:

Swatch

intervals_to_left

The intervals of connections on the left of the swatch.

Type:

Connection_Interval_Tree

intervals_to_right

The intervals of connections on the right of the swatch.

Type:

Connection_Interval_Tree

intervals_below

The intervals of connections below the swatch.

Type:

Connection_Interval_Tree

intervals_above

The intervals of connections above the swatch.

Type:

Connection_Interval_Tree

Parameters:

swatch (Swatch)

__init__(swatch)[source]
Parameters:

swatch (Swatch)

get_all_connections()[source]
Returns:

The set of all connections in this swatch neighborhood.

Return type:

set[Swatch_Connection]

get_connections_to_courses(lower_course=0, upper_course=None, exclude_right_connections=False, exclude_left_connection=False, exclude_bottom_connections=False, exclude_top_connections=False)[source]
Parameters:
  • lower_course (int, optional) – The lowest course to find connections to. If this is 0, the connections will include bottom wale-wise connections. Defaults to 0.

  • upper_course (int, optional) – The highest course to find connections to. If this is the height of the swatch, the connections will include top wale-wise connections. Defaults to the height of the swatch.

  • exclude_right_connections (bool, optional) – Whether to exclude course-wise connections to the right of the swatch. Defaults to False.

  • exclude_left_connection (bool, optional) – Whether to exclude course-wise connections to the left of the swatch. Defaults to False.

  • exclude_bottom_connections (bool, optional) – Whether to exclude connections to the bottom of the swatch. Defaults to False.:

  • exclude_top_connections (bool, optional) – Whether to exclude connections to the top of the swatch. Defaults to False.

Returns:

The set of all connections in this swatch neighborhood that match the given specification.

Return type:

set[Swatch_Connection]

get_interval_tree(connection)[source]
Parameters:

connection (Swatch_Connection) – The connection to find the interval tree for.

Returns:

The interval_tree associated with the given connection.

Return type:

Connection_Interval_Tree

Raises:

ValueError – If the given connection is not in this swatch neighborhood.

enveloped_connections(connection)[source]
Parameters:
  • [Swatch_Connection] (connection) – The swatch connection in the neighborhood to get the enveloped by the given connection.

  • connection (Swatch_Connection)

Returns:

The set of connections that are enveloped by the given connection.

Return type:

set[Swatch_Connection]

blocking_connections(connection)[source]

A connection blocks connections in the neighborhood if they do not connect the same swatches and the intervals of the connections overlap but do not envelop the given connection.

Parameters:
  • [Swatch_Connection] (connection) – The swatch connection in the neighborhood to get the enveloped by the given connection.

  • connection (Swatch_Connection)

Returns:

The set of connections in this neighborhood that are blocked by the given connection.

Return type:

set[Swatch_Connection]

remove_connection(prior_connection)[source]

Remove a given connection from the swatch’s neighborhood if the connection exists in the neighborhood.

Parameters:

prior_connection (Swatch_Connection) – The connection to remove, if present.

Return type:

None

make_connection(connection)[source]

Add the given connection to this neighborhood.

Parameters:

connection (Swatch_Connection) – The connection to add to the swatch neighborhood tree.

Return type:

None

Notes

This method does not verify that the connection should be added to the neighborhood and does not override or overlap an existing connection.