knitout_interpreter.knitout_operations.needle_instructions module

Needle operations

class knitout_interpreter.knitout_operations.needle_instructions.Needle_Instruction(instruction_type, needle, direction=None, needle_2=None, carrier_set=None, comment=None)[source]

Bases: Knitout_Instruction

get_yarns(knitting_machine)[source]

Get the yarns currently active on the carriers.

Parameters:

knitting_machine (Knitting_Machine) – The knitting machine to access yarn data from.

Returns:

Dictionary mapping carrier IDs to the yarn that is currently active on them.

Return type:

dict[int, Machine_Knit_Yarn]

get_carriers(knitting_machine)[source]

Get the carriers currently active for this instruction.

Parameters:

knitting_machine (Knitting_Machine) – The knitting machine to access carrier data from.

Returns:

Dictionary mapping carrier IDs to the carrier objects that are currently active.

Return type:

dict[int, Yarn_Carrier]

property has_second_needle: bool

Check if this instruction has a second needle.

Returns:

True if it has a second needle.

property has_direction: bool

Check if this instruction has a direction value.

Returns:

True if it has a direction value.

property has_carrier_set: bool

Check if this instruction has a carrier set.

Returns:

True if it has a carrier set.

property implied_racking: None | int

Get the racking required for this operation.

Returns:

None if no specific racking is required, or the required racking value to complete this operation.

class knitout_interpreter.knitout_operations.needle_instructions.Loop_Making_Instruction(instruction_type, needle, direction=None, needle_2=None, carrier_set=None, comment=None)[source]

Bases: Needle_Instruction

Base class for instructions that create loops.

class knitout_interpreter.knitout_operations.needle_instructions.Knit_Instruction(needle, direction, cs, comment=None)[source]

Bases: Loop_Making_Instruction

Instruction for knitting a loop on a needle.

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.

Return type:

bool

static execute_knit(machine_state, needle, direction, cs, comment=None)[source]

Execute a knit instruction on the machine.

Parameters:
  • machine_state (Knitting_Machine) – The current machine model to update.

  • needle (Needle) – The needle to execute on.

  • direction (str | Carriage_Pass_Direction) – The direction to execute in.

  • cs (Yarn_Carrier_Set) – The yarn carriers set to execute with.

  • comment (str | None) – Additional details to document in the knitout.

Returns:

The instruction that was executed.

Return type:

Knit_Instruction

class knitout_interpreter.knitout_operations.needle_instructions.Tuck_Instruction(needle, direction, cs, comment=None)[source]

Bases: Loop_Making_Instruction

Instruction for tucking yarn on a needle without dropping existing loops.

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.

Return type:

bool

static execute_tuck(machine_state, needle, direction, cs, comment=None)[source]

Execute a tuck instruction on the machine.

Parameters:
  • machine_state (Knitting_Machine) – The current machine model to update.

  • needle (Needle) – The needle to execute on.

  • direction (str | Carriage_Pass_Direction) – The direction to execute in.

  • cs (Yarn_Carrier_Set) – The yarn carriers set to execute with.

  • comment (str | None) – Additional details to document in the knitout.

Returns:

The instruction that was executed.

Return type:

Tuck_Instruction

class knitout_interpreter.knitout_operations.needle_instructions.Split_Instruction(needle, direction, n2, cs, comment=None)[source]

Bases: Loop_Making_Instruction

Instruction for splitting a loop between two needles.

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.

Return type:

bool

static execute_split(machine_state, needle, direction, cs, n2, comment=None)[source]

Execute a split instruction on the machine.

Parameters:
  • machine_state (Knitting_Machine) – The current machine model to update.

  • needle (Needle) – The needle to execute on.

  • direction (str | Carriage_Pass_Direction) – The direction to execute in.

  • cs (Yarn_Carrier_Set) – The yarn carriers set to execute with.

  • n2 (Needle) – The second needle to execute to.

  • comment (str | None) – Additional details to document in the knitout.

Returns:

The instruction that was executed.

Return type:

Split_Instruction

class knitout_interpreter.knitout_operations.needle_instructions.Drop_Instruction(needle, comment=None)[source]

Bases: Needle_Instruction

Instruction for dropping loops from a needle.

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.

Return type:

bool

static execute_Drop(machine_state, needle, comment=None)[source]

Execute a drop instruction on the machine.

Parameters:
  • machine_state (Knitting_Machine) – The current machine model to update.

  • needle (Needle) – The needle to execute on.

  • comment (str | None) – Additional details to document in the knitout.

Returns:

The instruction that was executed.

Return type:

Drop_Instruction

class knitout_interpreter.knitout_operations.needle_instructions.Xfer_Instruction(needle, n2, comment=None, record_location=True)[source]

Bases: Needle_Instruction

Instruction for transferring loops between needles.

add_loop_crossing(left_loop, right_loop)[source]

Update loop crossing to show transfers crossing loops.

Parameters:
  • left_loop (Machine_Knit_Loop) – The left loop involved in the crossing.

  • right_loop (Machine_Knit_Loop) – The right loop involved in the crossing.

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.

Return type:

bool

static execute_xfer(machine_state, needle, n2, comment=None)[source]

Execute a transfer instruction on the machine.

Parameters:
  • machine_state (Knitting_Machine) – The current machine model to update.

  • needle (Needle) – The needle to execute on.

  • n2 (Needle) – The second needle to execute to.

  • comment (str | None) – Additional details to document in the knitout.

Returns:

The instruction that was executed.

Return type:

Xfer_Instruction

class knitout_interpreter.knitout_operations.needle_instructions.Miss_Instruction(needle, direction, cs, comment=None)[source]

Bases: Needle_Instruction

Instruction for positioning carriers above a needle without forming loops.

execute(machine_state)[source]

Position the carrier above the given needle.

Parameters:

machine_state (Knitting_Machine) – The machine state to update.

Returns:

True indicating the operation completed successfully.

Return type:

bool

static execute_miss(machine_state, needle, direction, cs, comment=None)[source]

Execute a miss instruction on the machine.

Parameters:
  • machine_state (Knitting_Machine) – The current machine model to update.

  • needle (Needle) – The needle to execute on.

  • direction (str | Carriage_Pass_Direction) – The direction to execute in.

  • cs (Yarn_Carrier_Set) – The yarn carriers set to execute with.

  • comment (str | None) – Additional details to document in the knitout.

Returns:

The instruction that was executed.

Return type:

Miss_Instruction