quilt_knit.swatch.Swatch module
Module containing the Swatch Class
- class Swatch(name, knitout_program, prior_machine_state=None)[source]
Bases:
objectClass that associates a knitout program with the resulting knit graph. Used for linking swatches to form Quilts.
- wale_entrances
The instructions on the bottom boundary of the swatch.
- Type:
- wale_exits
The instructions on the top boundary of the swatch.
- Type:
- Parameters:
- get_instruction_pass(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction to find the owning carriage pass.
- Returns:
None if the instruction does not belong to a carriage pass. Otherwise, the carriage pass that owns the instruction.
- Return type:
Carriage_Pass | None
- get_cp_index_of_instruction(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction to find the carriage pass index.
- Returns:
None if the instruction does not belong to a carriage pass. Otherwise, the index of the carriage pass that owns the instruction.
- Return type:
int | None
- get_cp_by_index(index)[source]
- Parameters:
index (int) – The index of the carriage pass.
- Returns:
The carriage pass at the given index.
- Return type:
Carriage_Pass
- property execution_knitting_machine: Knitting_Machine
Returns: Knitting_Machine: The knitting machine state after knitout execution.
- property execution_knit_graph: Knit_Graph
Returns: Knit_Graph: The knitgraph that results from the execution of the knitout program.
- instruction_on_course_boundary(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction to determine if it lies on the course boundary of the swatch.
- Returns:
True if the instruction is on the course boundary of the swatch, False otherwise.
- Return type:
- instruction_on_wale_boundary(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction to determine if it lies on the wale boundary of the swatch.
- Returns:
True if the instruction is on the wale boundary of the swatch, False otherwise.
- Return type:
- get_course_boundary_instruction(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction owned by a boundary instruction.
- Returns:
The course boundary instruction that owns the given instruction or None if the instruction is not on the course boundary.
- Return type:
None | Course_Boundary_Instruction
- get_wale_boundary_instruction(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction owned by a boundary instruction.
- Returns:
The wale boundary instruction that owns the given instruction.
- Return type:
- Raises:
KeyError – If the given instruction is not on the wale boundary.
- instruction_is_left_exit(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction owned by a boundary instruction.
- Returns:
True if the instruction is an exit to the left boundary. False, otherwise.
- Return type:
- instruction_is_left_entrance(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction owned by a boundary instruction.
- Returns:
True if the instruction is an entrance to the left boundary. False, otherwise.
- Return type:
- instruction_is_right_exit(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction owned by a boundary instruction.
- Returns:
True if the instruction is an exit from the right boundary. False, otherwise.
- Return type:
- instruction_is_right_entrance(instruction)[source]
- Parameters:
instruction (Knitout_Line) – The instruction owned by a boundary instruction.
- Returns:
True if the instruction is an entrance to the right boundary. False, otherwise.
- Return type:
- property min_needle: int
Returns: int: The position of the leftmost needle used in swatch construction.
- property max_needle: int
Returns: int: The position of the rightmost needle used in swatch construction.
- property constructed_height: int
Returns: int: The number of carriage passes in the swatch that create new loops. This excludes xfer passes.
- property left_entrances: list[Course_Boundary_Instruction]
Returns: list[Course_Boundary_Instruction]: The boundary entrances of the left side of the swatch.
- property left_exits: list[Course_Boundary_Instruction]
Returns: list[Course_Boundary_Instruction]: The boundary exits of the left side of the swatch.
- property left_boundary: list[Course_Boundary_Instruction]
Returns: list[Course_Boundary_Instruction]: The boundary instructions of the left side of the swatch.
- property right_entrances: list[Course_Boundary_Instruction]
Returns: list[Course_Boundary_Instruction]: The boundary entrances of the right side of the swatch.
- property right_exits: list[Course_Boundary_Instruction]
Returns: list[Course_Boundary_Instruction]: The boundary exits of the right side of the swatch.
- property right_boundary: list[Course_Boundary_Instruction]
Returns: list[Course_Boundary_Instruction]: The boundary instructions of the right side of the swatch.
- get_carriage_pass_index_of_instruction(instruction)[source]
- Parameters:
instruction (
Knitout_Line) – The instruction to find the index of its owning carriage pass.- Returns:
The index of the carriage pass that executes the instruction or None if the instruction does not belong to a carriage pass.
- Return type:
int | None
- split_swatch_at_carriage_pass(carriage_pass_index, bottom_swatch_name, top_swatch_name)[source]
- Parameters:
- Returns:
A tuple containing the following: * The bottom swatch created by the split or None if the split did not create a bottom swatch. * The top swatch created by the split or None if the split did not create a top swatch. * True if the top swatch has initial transfer pass carriage passes removed. False, otherwise.
- Return type:
Notes
If the carriage pass index is less than or equal to 0, then the swatch is not split. The bottom swatch will be None and the top swatch will be this swatch.
If the carriage pass index is greater than the height of the swatch, then teh swatch is not split. The bottom swatch will be this swatch and the top swatch will be None.
- compile_to_knitout(knitout_name=None)[source]
Writes a knitout file of the given name that executes this swatch program. :type knitout_name:
Optional[str] :param knitout_name: The name of the knitout file to write. Defaults to the name of the swatch. :type knitout_name: str, option- Return type:
- compile_to_dat(dat_name=None)[source]
Writes a shima-seiki dat file of the given name that executes this swatch program.
- shift_swatch_rightward_on_needle_bed(shift_needle_count=0)[source]
- Parameters:
shift_needle_count (int, optional) – The number of needles to shift this swatch program rightward by. Defaults to 0.
- Returns:
The shifted swatch program. All needle operations will have their needle slot shifted over by the shift value.
- Return type:
Notes
If the shifted needle count is 0, then this returns this swatch.
- find_carriage_pass_from_course_passes(course_pass_count)[source]
- Parameters:
course_pass_count (int) – The target number of carriage passes that form courses by creating new loops.
- Returns:
The number of carriage passes required to reach the target number of courses. If that course target is not reached, this will be the full height of the swatch.
- Return type: