knitout_interpreter.knitout_operations.knitout_instruction_factory module
Factory function for building knitout instructions based on instruction type.
- build_two_needle_instruction(instruction_type, first_needle, second_needle, direction=None, carrier_set=None, comment=None)[source]
Builds a knitout instruction based on the specified instruction type and parameters.
This factory function creates the appropriate two needle instruction (xfer or split) based on the instruction type and provided parameters.
- Parameters:
instruction_type (Knitout_Instruction_Type) – The type of knitout instruction to create. Must be a Xfer or Split
first_needle (Needle_Specification) – The primary needle for the operation.
second_needle (Needle_Specification) – The secondary needle loops are transferred to.
direction (Carriage_Pass_Direction, optional) – The carriage pass direction for directed split operations.
carrier_set (Yarn_Carrier_Set, optional) – The carrier set to use for split operations
comment (str | None, optional) – Optional comment to include with the instruction for documentation or debugging purposes.
- Returns:
The constructed xfer or split corresponding to the specified type.
- Return type:
- Raises:
ValueError – If a split instruction is not provided the direction or carrier values.
- build_directed_needle_instruction(instruction_type, first_needle, direction, carrier_set, comment=None)[source]
Builds knitout instructions that operate on one needle in a directed carriage pass (e.g., miss, knit, tuck).
- Parameters:
instruction_type (Knitout_Instruction_Type) – The type of knitout instruction to create.
first_needle (Needle) – The needle for the operation.
direction (Carriage_Pass_Direction) – The carriage pass direction.
carrier_set (Yarn_Carrier_Set) – The carrier set to use for the operation.
comment (str, optional) – Optional comment to include with the instruction for documentation or debugging purposes. Defaults to no comment.
- Returns:
The constructed knitout instruction object corresponding to the specified type.
- Return type:
Knit_Instruction | Tuck_Instruction | Miss_Instruction | Kick_Instruction
- build_needle_instruction(instruction_type, first_needle, direction=None, carrier_set=None, second_needle=None, comment=None)[source]
Builds a knitout instruction that operates on a needle.
- Parameters:
instruction_type (Knitout_Instruction_Type) – The type of knitout instruction to create.
first_needle (Needle_Specification) – The primary needle for the operation.
direction (Carriage_Pass_Direction, optional) – The carriage pass direction for directional operations. Required for operations that involve yarn carrier movement.
carrier_set (Yarn_Carrier_Set , optional) – The carrier set to use for the operation. Required for operations that manipulate yarn.
second_needle (Needle_Specification, optional) – The secondary needle for operations requiring two needles, such as transfers and splits.
comment (str | None, optional) – Optional comment to include with the instruction for documentation or debugging purposes.
- Returns:
The constructed knitout instruction object corresponding to the specified type.
- Return type:
- Raises:
ValueError – If the instruction is not provided the appropriate values
- build_carrier_instruction(instruction_type, carrier_set, comment=None)[source]
- Parameters:
instruction_type (Knitout_Instruction_Type) – The type of knitout instruction to create. Assumed to be a carrier instruction.
carrier_set (Yarn_Carrier) – The yarn-carrier to use for the operation.
comment (str | None, optional) – Optional comment to include with the instruction for documentation or debugging purposes.
- Returns:
The carrier instruction constructed from the given specification.
- Return type:
- build_instruction(instruction_type, first_needle=None, direction=None, carrier_set=None, second_needle=None, racking=None, comment=None)[source]
Builds a knitout instruction based on the specified instruction type and parameters.
This factory function creates the appropriate knitout instruction object based on the instruction type and provided parameters. It handles all supported knitout instruction types including needle operations, carrier operations, and machine control operations.
- Parameters:
instruction_type (Knitout_Instruction_Type) – The type of knitout instruction to create.
first_needle (Needle_Specification, optional) – The primary needle for the operation. Required for needle-based instructions like knit, tuck, drop, etc.
direction (Carriage_Pass_Direction, optional) – The carriage pass direction for directional operations. Required for operations that involve yarn carrier movement.
carrier_set (Yarn_Carrier_Set | Yarn_Carrier, optional) – The yarn carrier or carrier set to use for the operation. Required for operations that manipulate yarn.
second_needle (Needle_Specification, optional) – The secondary needle for operations requiring two needles, such as transfers and splits.
racking (float, optional) – The racking value for rack instructions. Specifies the relative position between needle beds.
comment (str | None, optional) – Optional comment to include with the instruction for documentation or debugging purposes.
- Returns:
The constructed knitout instruction object corresponding to the specified type.
- Return type:
- Raises:
ValueError – If the instruction is not provided the appropriate values