knit_graphs.Course module
Course representation of a section of knitting with no parent loops.
This module contains the Course class which represents a horizontal row of loops in a knitting pattern.
- class Course(knit_graph)[source]
Bases:
object
Course object for organizing loops into knitting rows.
A Course represents a horizontal row of loops in a knitting pattern. It maintains an ordered list of loops and provides methods for analyzing the structure and relationships between courses in the knitted fabric.
- Parameters:
knit_graph (
Knit_Graph
)
- __init__(knit_graph)[source]
Initialize an empty course associated with a knit graph.
- Parameters:
knit_graph (Knit_Graph) – The knit graph that this course belongs to.
- property knit_graph: Knit_Graph
Returns: Knit_Graph: The knit graph that this course belongs to.
- has_increase()[source]
Check if this course contains any yarn overs that start new wales.
- Returns:
True if the course has at least one yarn over (loop with no parent loops) to start new wales.
- Return type:
- has_decrease()[source]
Check if this course contains any decrease stitches that merge wales.
- Returns:
True if the course has at least one decrease stitch (loop with multiple parent loops) merging two or more wales.
- Return type:
- in_round_with(next_course)[source]
Check if the next course connects to this course in a circular pattern.
This method determines if the courses are connected in the round (circular knitting) by checking if the next course starts at the beginning of this course.
- in_row_with(next_course)[source]
Check if the next course connects to this course in a flat/row pattern.
This method determines if the courses are connected in flat knitting (back and forth) by checking if the next course starts at the end of this course.
- __iter__()[source]
Iterate over loops in this course in order.
- Returns:
An iterator over the loops in this course in their natural order.
- Return type:
Iterator[Loop]
- __reversed__()[source]
Iterate over loops in this course in reverse order.
- Returns:
An iterator over the loops in this course in reverse order.
- Return type:
Iterator[Loop]
- __len__()[source]
Get the number of loops in this course.
- Returns:
The total number of loops in this course.
- Return type: