quilt_knit.swatch.course_wise_merging.Course_Merge_Process module
Module for linking Swatches by vertical seams
- class Course_Merge_Process(swatch_connection, seam_search_space=None)[source]
Bases:
Merge_ProcessClass to manage a horizontal merge process between two swatches.
- Parameters:
swatch_connection (
Course_Wise_Connection)seam_search_space (
Optional[Course_Seam_Search_Space])
- __init__(swatch_connection, seam_search_space=None)[source]
- Parameters:
swatch_connection (
Course_Wise_Connection)seam_search_space (
Optional[Course_Seam_Search_Space])
- property course_wise_connection: Course_Wise_Connection
Returns: Course_Wise_Connection: The connection between the two swatches being merged.
- property seam_search_space: Course_Seam_Search_Space
Returns: Course_Seam_Search_Space: The seam search space between entrance-exit instructions along the swatch boundaries being merged.
- property current_course_merge_side: Course_Side
Returns: Course_Side: The side of the merge that the program is currently consuming from.
- get_original_cp_index(carriage_pass)[source]
- Parameters:
carriage_pass (Carriage_Pass) – A carriage pass in the swatch resulting from this merge.
- Returns:
A tuple containing the carriage pass indices in the original left and right swatches that created this carriage pass. These indices are None if the carriage pass does not contain instructions from a given side.
- Return type:
- Raises
KeyError: If the carriage pass does not belong to the merged swatch.
- property starting_course_aligned: bool
Returns: bool: True if the starting courses of both swatches are executed in the same carriage pass direction. False, otherwise.
- property next_swatch: Swatch
Returns: Swatch: The next swatch to consume instructions from. This will be the opposite of the current swatch.
- boundary_in_left_swatch(boundary_instruction)[source]
- Parameters:
boundary_instruction (Course_Boundary_Instruction) – The boundary instruction to check which swatch it belongs to.
- Returns:
True if the boundary instruction belongs to the left swatch, False otherwise.
- Return type:
- boundary_in_right_swatch(boundary_instruction)[source]
- Parameters:
boundary_instruction (Course_Boundary_Instruction) – The boundary instruction to check which swatch it belongs to.
- Returns:
True if the boundary instruction belongs to the right swatch, False otherwise.
- Return type:
- property first_course_on_current_side: int
Returns: int: The index of the first course to be merged on the current working swatch.
- property last_course_on_current_side: int
Returns: int: The index of the last course to be merged on the current working swatch.
- property next_index_in_next_swatch: int | None
Returns: int | None: The next index of instructions to consume from the swatch not being consumed or None if that swatch is fully consumed.
- increment_next_index()[source]
Increments the index pointing to the next instruction in the current swatch.
- Return type:
- property next_index: int | None
Returns: int | None: The next index of instructions to consume from the current swatch or None if the current swatch is fully consumed.
- property next_left_index: int | None
Returns: int | None: The next index of instructions to consume from the left swatch or None if the left swatch is fully consumed.
- property next_right_index: int | None
Returns: int | None: The next index of instructions to consume from the right swatch or None if the right swatch is fully consumed.
- get_left_instruction_at_index(index)[source]
- Parameters:
index (int) – The index of the instruction in the left swatch.
- Returns:
The instruction at the given index in the left swatch or None if that index is not in the left swatch.
- Return type:
Knitout_Line | None
- get_right_instruction_at_index(index)[source]
- Parameters:
index (int) – The index of the instruction in the right swatch.
- Returns:
The instruction at the given index in the right swatch or None if that index is not in the right swatch.
- Return type:
Knitout_Line | None
- property next_left_instruction: Knitout_Line | None
Returns: Knitout_Line | None: The next instruction on the left swatch or None if there are no instructions to consume from the left.
- property next_right_instruction: Knitout_Line | None
Returns: Knitout_Line | None: The next instruction on the right swatch or None if there are no instructions to consume from the right.
- property next_left_needle_instruction: Needle_Instruction | None
Returns: Needle_Instruction | None: The next needle instruction that will be encountered in the left swatch program or None if no more needle instructions exist.
- property cp_index_of_next_left_needle_instruction: int | None
Returns: int | None: The index of the carriage pass of the next needle instruction in the left swatch or None if there are no more needle instructions in the swatch.
- property next_right_needle_instruction: Needle_Instruction | None
Returns: Needle_Instruction | None: The next needle instruction that will be encountered in the right swatch program or None if no more needle instructions exist.
- property cp_index_of_next_right_needle_instruction: int | None
Returns: int | None: The index of the carriage pass of the next needle instruction in the right swatch or None if there are no more needle instructions in the swatch.
- property next_needle_instruction_in_next_swatch: Needle_Instruction | None
Returns: Needle_Instruction | None: The next needle instruction that will be encountered in the next (non-current) swatch program or None if no more needle instructions exist in that swatch.
- property cp_index_of_next_needle_instruction_in_next_swatch: int | None
Returns: int | None: The index of the carriage pass of the next needle instruction in the next (non-current) swatch or None if there are no more needle instructions in the swatch.
- property next_needle_instruction_in_current_swatch: Needle_Instruction | None
Returns: Needle_Instruction | None: The next needle instruction that will be encountered in the current swatch program or None if no more needle instructions exist in that swatch.
- property cp_index_of_next_needle_instruction_in_current_swatch: int | None
Returns: int | None: The index of the carriage pass of the next needle instruction in the current swatch or None if there are no more needle instructions in the swatch.
- swap_swatch_sides()[source]
Swaps which swatch is the current swatch vs the next swatch to consume from.
- Return type:
- property current_boundary_side: Course_Side
Returns: Course_Side: The boundary of the current swatch to merge from.
- property next_instruction_is_boundary_entrance: bool
Returns: bool: True if the next instruction is on the relevant boundary entrance of the current swatch. False, otherwise
- property next_instruction_is_boundary_exit: bool
Returns: bool: True if the next instruction is on the relevant boundary exit of the current swatch. False, otherwise
- property current_swatch_is_consumed: bool
Returns: bool: True if the current swatch is consumed, False otherwise.
- property left_swatch_is_consumed: bool
Returns: bool: True if the left swatch is consumed, False otherwise.
- property right_swatch_is_consumed: bool
Returns: bool: True if the right swatch is consumed, False otherwise.
- property next_instruction: Knitout_Line | None
Returns: Knitout_Line | None: The next instruction to consume from the current swatch or None if the current swatch is fully consumed.
- best_connection(boundary_instruction)[source]
- Parameters:
boundary_instruction (Course_Boundary_Instruction) – The boundary instruction to find the best connection from.
- Returns:
The best available connection from the given boundary instruction or None if there are no connections available.
- Return type:
Course_Seam_Connection | None
- preferred_connection(boundary_instruction, excluded_boundaries=None)[source]
- Parameters:
boundary_instruction (boundary_instruction) – The boundary instruction to find the best connection from.
excluded_boundaries (set[Course_Boundary_Instruction], optional) – The set of boundary instructions to exclude from potential connections. Defaults to the empty set.
- Returns:
The lowest cost connection from the given boundary instruction or None if there are no connections available.
- Return type:
Course_Seam_Connection | None
- floats_requires_cut(connection, max_float_length=15)[source]
- Parameters:
connection (Course_Seam_Connection) – The connection to identify the find the number of floats from.
max_float_length (int, optional) – The maximum length of allowed floats. Defaults to 10.
- Returns:
The number of floats that will need to be cut if the given connection is formed.
- Return type:
- compile_to_dat(merge_name=None)
Creates a knitout file and compiled DAT file of the given merge name of the merged instructions from this merger.
- property current_swatch_all_needle_rack: bool
Returns: bool: True if the machine state of the current swatch is set to all needle rack. False, otherwise.
- property current_swatch_rack: int
Returns: int: The rack value of the machine state of the current swatch.
- get_merged_instructions()
Updates the merged instructions with comments specifying the origin swatch and updated line numbers for the merged program.
- Returns:
List of instructions in the merged program.
- Return type:
list[Knitout_Line]
- instruction_requires_release(next_instruction)
- Parameters:
next_instruction (Knitout_Line) – The next instruction to test if it requires a releasehook.
- Returns:
True if the specified next instruction would trigger a releasehook from the current merged program machine state.
- Return type:
- merge_swatches()[source]
Merges the left and right swatch and forms a merged swatch program and updates the machine state according to that merged program.
- Returns:
A list of instructions in the merged program.
- Return type:
list[Knitout_Line]