knitout_interpreter.knitout_operations.needle_instructions module

Needle operations

class Needle_Instruction(*args, **kwargs)[source]

Bases: Knitout_Instruction

The base class for all instructions that execute on a needle.

_made_loops

The list of loops that were made by this instruction.

Type:

list[Knitout_Loop]

_moved_loops

The list of loops that transferred by this instruction.

Type:

list[Knitout_Loop]

_dropped_loops

The list of loops that dropped by this instruction.

Type:

list[Knitout_Loop]

__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:

bool

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:

int

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
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:

int

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:

bool

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
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:

int

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:

bool

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
class Soft_Kick_Instruction(*args, **kwargs)[source]

Bases: Directed_Instruction

Marks 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.

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.

  • comment (str | None, optional) – Optional comment for the instruction. Defaults to None.

property position: int

Returns: The position from the front bed to kick the carrier to.

execute(machine_state)[source]

Soft kickbacks occur for things like releasehook management in dat files.

Returns:

True indicating the operation completed successfully.

Return type:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
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:

int

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:

bool

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
class Miss_Instruction(*args, **kwargs)[source]

Bases: Yarn_to_Needle_Instruction

Instruction 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:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
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:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
class Kick_Instruction(*args, **kwargs)[source]

Bases: Knit_Pass_Instruction, Miss_Instruction

Marks 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.

property position: int

Returns: The position from the front bed to kick the carrier to.

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
class Loop_Making_Instruction(*args, **kwargs)[source]

Bases: Yarn_to_Needle_Instruction

Base 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:

int

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:

bool

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
class Knit_Instruction(*args, **kwargs)[source]

Bases: Knit_Pass_Instruction, Loop_Making_Instruction, Dropping_Instruction

Instruction 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:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
class Tuck_Instruction(*args, **kwargs)[source]

Bases: Knit_Pass_Instruction, Loop_Making_Instruction

Instruction 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:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
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:

int

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:

bool

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:

bool

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:

bool

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:

str

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

instruction_type: ClassVar[Knitout_Instruction_Type]
comment: str | None
class Split_Instruction(*args, **kwargs)[source]

Bases: Loop_Making_Instruction, Two_Needle_Instruction

Instruction 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:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

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.

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
loop_crossings_made: dict[Knitout_Loop, list[Knitout_Loop]]
class Xfer_Instruction(*args, **kwargs)[source]

Bases: Two_Needle_Instruction

Instruction 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:

bool

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

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.

interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

loop_crossings_made: dict[Knitout_Loop, list[Knitout_Loop]]
comment: str | None
class Drop_Instruction(*args, **kwargs)[source]

Bases: Dropping_Instruction

Instruction for dropping loops from a needle.

__hash__()
Returns:

Unique integer based on the time that this instruction was created in the execution.

Return type:

int

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:

bool

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:

bool

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:

str

instruction_type: ClassVar[Knitout_Instruction_Type] = 'drop'
interrupts_carriage_pass: ClassVar[bool] = True
property line_number: int

Returns: int: The current position of the line in a program.

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.

Parameters:
  • line_number (int) – The line number of this knitout instruction in a program.

  • source (str, optional) – The optional program name that this line derives from. This value is only set once (usually when setting the original line number). Defaults to None, not setting the program value.

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:

bool

comment: str | None
__init__(needle, 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:

bool