knitout_interpreter.knitout_operations.needle_instructions module
Needle operations
- class Needle_Instruction(*args, **kwargs)[source]
Bases:
Knitout_InstructionThe base class for all instructions that execute on a needle.
- _made_loops
The list of loops that were made by this instruction.
- Type:
- _moved_loops
The list of loops that transferred by this instruction.
- Type:
- _dropped_loops
The list of loops that dropped by this instruction.
- Type:
- __init__(needle, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- compatible_in_carriage_pass(other_instruction)[source]
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- shift_needle_position(delta)[source]
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- 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 machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Dropping_Instruction(*args, **kwargs)[source]
Bases:
Needle_Instruction- __init__(needle, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- property dropped_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops dropped from the needle bed by this instruction during its last execution.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Directed_Instruction(*args, **kwargs)[source]
Bases:
Needle_Instruction- __init__(needle, direction, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Soft_Kick_Instruction(*args, **kwargs)[source]
Bases:
Directed_InstructionMarks kickbacks added in dat-complication process.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'kick'
- __init__(position, direction, comment=None)[source]
Initialize a kick instruction for a specific needle position.
- execute(machine_state)[source]
Soft kickbacks occur for things like releasehook management in dat files.
- Returns:
True indicating the operation completed successfully.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- class Yarn_to_Needle_Instruction(*args, **kwargs)[source]
Bases:
Directed_Instruction- __init__(needle, direction, carrier_set, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Miss_Instruction(*args, **kwargs)[source]
Bases:
Yarn_to_Needle_InstructionInstruction for positioning carriers above a needle without forming loops.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'miss'
- __init__(needle, direction, carrier_set, comment=None)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- execute(machine_state)[source]
Position the carrier above the given needle.
- Parameters:
machine_state (Knitting_Machine[Knitout_LoopT]) – The machine state to update.
- Returns:
True indicating the operation completed successfully.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- class Knit_Pass_Instruction(*args, **kwargs)[source]
Bases:
Yarn_to_Needle_Instruction- __init__(needle, direction, carrier_set, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- compatible_in_carriage_pass(other_instruction)[source]
All subclasses of Knit_Pass_Instructions can share a carriage pass (i.e., Knit and Tuck)
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Kick_Instruction(*args, **kwargs)[source]
Bases:
Knit_Pass_Instruction,Miss_InstructionMarks kickbacks added in dat-complication process.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'kick'
- __init__(position, direction, carrier_set, comment=None)[source]
Initialize a kick instruction for a specific needle position.
- Parameters:
position (int | Needle_Specification) – The needle position for the kickback (must be between 0 and 540).
direction (str | Carriage_Pass_Direction) – The direction of the carriage pass.
carrier_set (Yarn_Carrier_Set) – The yarn carrier set to use.
comment (str | None, optional) – Optional comment for the instruction. Defaults to None.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
All subclasses of Knit_Pass_Instructions can share a carriage pass (i.e., Knit and Tuck)
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Position the carrier above the given needle.
- Parameters:
machine_state (Knitting_Machine[Knitout_LoopT]) – The machine state to update.
- Returns:
True indicating the operation completed successfully.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- class Loop_Making_Instruction(*args, **kwargs)[source]
Bases:
Yarn_to_Needle_InstructionBase class for instructions that create loops.
- __init__(needle, direction, carrier_set, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- property made_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops made by this instruction during its last execution.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Knit_Instruction(*args, **kwargs)[source]
Bases:
Knit_Pass_Instruction,Loop_Making_Instruction,Dropping_InstructionInstruction for knitting a loop on a needle.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'knit'
- __init__(needle, direction, cs, comment=None)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- execute(machine_state)[source]
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
All subclasses of Knit_Pass_Instructions can share a carriage pass (i.e., Knit and Tuck)
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property dropped_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops dropped from the needle bed by this instruction during its last execution.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property made_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops made by this instruction during its last execution.
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- class Tuck_Instruction(*args, **kwargs)[source]
Bases:
Knit_Pass_Instruction,Loop_Making_InstructionInstruction for tucking yarn on a needle without dropping existing loops.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'tuck'
- __init__(needle, direction, cs, comment=None)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- execute(machine_state)[source]
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
All subclasses of Knit_Pass_Instructions can share a carriage pass (i.e., Knit and Tuck)
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property made_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops made by this instruction during its last execution.
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- class Two_Needle_Instruction(*args, **kwargs)[source]
Bases:
Needle_Instruction- __init__(needle, needle_2, comment=None, **_kwargs)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- property needle_2: Needle_Specification
Returns: Needle_Specification: The needle that loops are moved to.
- property moved_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops moved by this instruction during its last execution.
- property implied_racking: None | int
Returns: int | None: The racking required for this operation. None if no specific racking is required, or the required racking value to complete this operation.
- shift_needle_position(delta)[source]
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- add_loop_crossing(left_loop, right_loop)[source]
Update loop crossing to show transfers crossing loops.
- Parameters:
left_loop (Knitout_Loop) – The left loop involved in the crossing.
right_loop (Knitout_Loop) – The right loop involved in the crossing.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- execute(machine_state)
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type]
- class Split_Instruction(*args, **kwargs)[source]
Bases:
Loop_Making_Instruction,Two_Needle_InstructionInstruction for splitting a loop between two needles.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'split'
- __init__(needle, direction, n2, cs, comment=None)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- execute(machine_state)[source]
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- add_loop_crossing(left_loop, right_loop)
Update loop crossing to show transfers crossing loops.
- Parameters:
left_loop (Knitout_Loop) – The left loop involved in the crossing.
right_loop (Knitout_Loop) – The right loop involved in the crossing.
- property carrier_set: Yarn_Carrier_Set
Returns: Yarn_Carrier_Set: The carrier_set that this instruction executes with.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction that this instruction executes on.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property implied_racking: None | int
Returns: int | None: The racking required for this operation. None if no specific racking is required, or the required racking value to complete this operation.
- property made_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops made by this instruction during its last execution.
- property moved_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops moved by this instruction during its last execution.
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property needle_2: Needle_Specification
Returns: Needle_Specification: The needle that loops are moved to.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- loop_crossings_made: dict[Knitout_Loop, list[Knitout_Loop]]
- class Xfer_Instruction(*args, **kwargs)[source]
Bases:
Two_Needle_InstructionInstruction for transferring loops between needles.
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'xfer'
- __init__(needle, n2, comment=None)[source]
- Parameters:
comment (str, optional) – The comment following this instruction. Defaults to no comment.
- execute(machine_state)[source]
Execute the instruction on the machine state.
- Parameters:
machine_state (Knitting_Machine) – The machine state to update.
- Returns:
True if the process completes an update to the machine state. False, otherwise.
- Return type:
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- add_loop_crossing(left_loop, right_loop)
Update loop crossing to show transfers crossing loops.
- Parameters:
left_loop (Knitout_Loop) – The left loop involved in the crossing.
right_loop (Knitout_Loop) – The right loop involved in the crossing.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property implied_racking: None | int
Returns: int | None: The racking required for this operation. None if no specific racking is required, or the required racking value to complete this operation.
- property moved_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops moved by this instruction during its last execution.
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property needle_2: Needle_Specification
Returns: Needle_Specification: The needle that loops are moved to.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type:
- loop_crossings_made: dict[Knitout_Loop, list[Knitout_Loop]]
- class Drop_Instruction(*args, **kwargs)[source]
Bases:
Dropping_InstructionInstruction for dropping loops from a needle.
- __hash__()
- Returns:
Unique integer based on the time that this instruction was created in the execution.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- compatible_in_carriage_pass(other_instruction)
By default, instructions are compatible if they are of the same subclass type (i.e., xfers can only share a pass with xfers, splits with splits, drops with drops).
- Parameters:
other_instruction (Needle_Instruction) – The other instruction to test.
- Returns:
True if the other instruction can be performed in the same carriage pass as this instruction.
- Return type:
- property dropped_loops: list[Knitout_Loop]
Returns: list[Knitout_Loop]: The list of loops dropped from the needle bed by this instruction during its last execution.
- property effected_loops: bool
Returns: bool: True if this instruction effected loops by creating them, dropping them, or moving them in the last execution.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- instruction_type: ClassVar[Knitout_Instruction_Type] = 'drop'
- property needle: Needle_Specification
Returns: Needle_Specification: The needle that this operation executes on.
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- shift_needle_position(delta)
- Parameters:
delta (int) – The amount to shift the needle position by.
- Returns:
A copy of this instruction with the needle position shifted by the given delta value.
- Return type:
Self
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- will_update_machine_state(machine_state)
- Parameters:
machine_state (Knitting_Machine) – The machine state to test if this instruction will update it.
- Returns:
True if this instruction will update the machine state. False, otherwise.
- Return type: