quilt_knit.swatch.wale_wise_merging.Wale_Merge_Process module

Module containing the class structure for the Vertical Swatch Merge Process.

class Merge_Comment(comment)[source]

Bases: Knitout_Comment_Line

Super class of comments added during the merge process.

Parameters:

comment (Optional[str])

__init__(comment)[source]

Initialize a comment line.

Parameters:

comment (Optional[str]) – The comment text, or a Knitout_Line to convert to a comment.

add_follow_comment(comment_line)

Add a comment line to comments that follow this line.

Parameters:

comment_line (str) – The comment text to add.

Return type:

None

property comment_str: str

Get the comment as a formatted string.

Returns:

The comment formatted as a string with appropriate formatting.

execute(machine_state)

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Return type:

bool

Returns:

True if the process completes an update.

property has_comment: bool

Check if this line has a comment.

Returns:

True if comment is present.

id_str()

Get string representation with original line number if present.

Return type:

str

Returns:

String with original line number added if present.

property injected: bool

Check if instruction was marked as injected.

Returns:

True if instruction was marked as injected by a negative line number.

property interrupts_carriage_pass: bool

Check if this line interrupts a carriage pass.

Returns:

True if this type of line interrupts a carriage pass, False if it is only used for comments or setting information.

class Pre_Merge_Comment[source]

Bases: Merge_Comment

__init__()[source]

Initialize a comment line.

Parameters:

comment – The comment text, or a Knitout_Line to convert to a comment.

add_follow_comment(comment_line)

Add a comment line to comments that follow this line.

Parameters:

comment_line (str) – The comment text to add.

Return type:

None

property comment_str: str

Get the comment as a formatted string.

Returns:

The comment formatted as a string with appropriate formatting.

execute(machine_state)

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Return type:

bool

Returns:

True if the process completes an update.

property has_comment: bool

Check if this line has a comment.

Returns:

True if comment is present.

id_str()

Get string representation with original line number if present.

Return type:

str

Returns:

String with original line number added if present.

property injected: bool

Check if instruction was marked as injected.

Returns:

True if instruction was marked as injected by a negative line number.

property interrupts_carriage_pass: bool

Check if this line interrupts a carriage pass.

Returns:

True if this type of line interrupts a carriage pass, False if it is only used for comments or setting information.

class Post_Merge_Comment[source]

Bases: Merge_Comment

__init__()[source]

Initialize a comment line.

Parameters:

comment – The comment text, or a Knitout_Line to convert to a comment.

add_follow_comment(comment_line)

Add a comment line to comments that follow this line.

Parameters:

comment_line (str) – The comment text to add.

Return type:

None

property comment_str: str

Get the comment as a formatted string.

Returns:

The comment formatted as a string with appropriate formatting.

execute(machine_state)

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Return type:

bool

Returns:

True if the process completes an update.

property has_comment: bool

Check if this line has a comment.

Returns:

True if comment is present.

id_str()

Get string representation with original line number if present.

Return type:

str

Returns:

String with original line number added if present.

property injected: bool

Check if instruction was marked as injected.

Returns:

True if instruction was marked as injected by a negative line number.

property interrupts_carriage_pass: bool

Check if this line interrupts a carriage pass.

Returns:

True if this type of line interrupts a carriage pass, False if it is only used for comments or setting information.

class Wale_Merge_Process(swatch_connection, seam_search_space=None, max_rack=3)[source]

Bases: Merge_Process

Class to manage the vertical merging of two swatches.

Parameters:
__init__(swatch_connection, seam_search_space=None, max_rack=3)[source]
Parameters:
property wale_wise_connection: Wale_Wise_Connection

Returns: Wale_Wise_Connection: The connection between the two swatches being merged.

property seam_search_space: Wale_Seam_Search_Space

Returns: Wale_Seam_Search_Space: The seam search space between entrance-exit instructions along the swatch boundaries being merged.

property top_swatch: Swatch

The top swatch of the merge.

Type:

return

property bottom_swatch: Swatch

The bottom swatch of the merge.

Type:

return

merge_swatches()[source]

Merges the swatches. The resulting program is written to self.merged_instructions and the machine state of the merge program is updated as the merge is completed.

Return type:

None

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.

Parameters:

merge_name (str, optional) – The name of the merged swatch knitout file. Defaults to cwm_<the left_swatch’s name>_to_<the right_swatch’s name>.

Return type:

None

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.

property from_swatch: Swatch

Returns: Swatch: The first swatch in the connection.

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:

bool

property merged_and_current_racks_match: bool

Returns: bool: True if the racking values of the merged program state and the current swatch state match. False, otherwise.

property to_swatch: Swatch

Returns: Swatch: The second swatch in the connection.

write_knitout(merge_name=None)

Creates a knitout file of the given merge name of the merged instructions from this merger.

Parameters:

merge_name (str, optional) – The name of the merged swatch knitout file. Defaults to cwm_<the left_swatch’s name>_to_<the right_swatch’s name>.

Return type:

None