knit_graphs.course_face module
Module containing the Course_Face class
- class Course_Face(first_loop: LoopT, parent_course: Course[LoopT])[source]
Bases:
Loop_Sequence[LoopT]A series of loops in a common course that are on the same face of a knit structure.
A face is a continuous series of loops where no floats cross other loops already in the face.
- property last_index_in_course: int
Returns: int: The last index in the parent course of the last loop.
- property is_full_course: bool
Returns: bool: True if the face is its full parent course. False otherwise.
- property knit_graph: Knit_Graph[LoopT]
Returns: Knit_Graph[LoopT]: The knitgraph that owns this face.
- index_in_course(loop: int | LoopT) int[source]
- Parameters:
loop (int | LoopT) – The index of the loop or the loop in this face.
- Returns:
The index of the loop in the parent course.
- Return type:
- Raises:
ValueError – If the loop is not a loop in this face.
- __str__() str[source]
- Returns:
String representation showing the ordered list of loops.
- Return type:
- __repr__() str[source]
- Returns:
String representation showing the ordered list of loops.
- Return type:
- __iter__() Iterator[LoopT]
- Returns:
An iterator over the loops in the series in their natural order.
- Return type:
Iterator[Loop]
- __len__() int
O(1) length backed by the internal loop set.
- Returns:
The total number of loops in the series.
- Return type:
- __reversed__() Iterator[LoopT]
Iterate over loops in reverse sequence order.
Enables
reversed(seq)and communicates that the sequence has a meaningful direction — relevant for knitting since course direction (e.g. left-to-right vs. right-to-left passes) matters structurally.- Returns:
An iterator over the loops in reverse order.
- Return type:
Iterator[LoopT]
- behind_loops(other: Sequence[LoopT]) bool
- Parameters:
other (Sequence[LoopT]) – The series of loop to compare to.
- Returns:
True if all loops in the other series cross behind a float in this series.
- Return type:
- property floats: Iterator[Float_Edge[LoopT]]
Returns: set[Float_Edge[LoopT]]: The set of yarn-floats between loops in this sequence.
- following_float_in_sequence(loop: int | LoopT) Float_Edge[LoopT] | None
- Parameters:
loop (int | LoopT) – The index of the loop to find the following float of or the loop to find the next loop in the series.
- Returns:
The float-edge initiated at the given loop and going to a loop in the sequence or None if there is no following loop along the yarn in this sequence.
- Return type:
Float_Edge[LoopT] | None
- property has_decrease: bool
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:
- property has_increase: bool
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:
- in_front_of_loops(other: Sequence[LoopT]) bool
- Parameters:
other (Sequence[LoopT]) – The series of loop to compare to.
- Returns:
True if all loops in the other series cross in front of a float in this series.
- Return type:
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- isdisjoint(other: Iterable[LoopT]) bool
- Parameters:
other (Iterable[LoopT]) – The sequence to test against.
- Returns:
True if the two sequences have no loops in common.
- Return type:
- loop_crosses_floats(loop: LoopT) bool
- Parameters:
[LoopT] (loop) – The loop to check for crossing floats.
- Returns:
True if the given loop crosses at least one float in this sequence.
- Return type:
- property loop_ids: list[int]
Returns: list[int]: The loop ids in the course in the order they occur.
- loop_is_behind(loop: LoopT) bool
- Parameters:
loop (LoopT) – The loop to check for.
- Returns:
True if the loop is behind any float in this sequence.
- Return type:
- loop_is_in_front(loop: LoopT) bool
- Parameters:
loop (LoopT) – The loop to check for.
- Returns:
True if the loop is in front of any float in this sequence.
- Return type:
- property loops_behind_floats: set[LoopT]
Returns: set[LoopT]: The set of loops behind of at least one float in this sequence.
- property loops_in_front_of_floats: set[LoopT]
Returns: set[LoopT]: The set of loops in front of at least one float in this sequence.
- next_loop_in_sequence(loop: int | LoopT) LoopT | None
- Parameters:
loop (int | LoopT) – The index of the loop to find the following loop in the series or the loop to find the next loop in the series.
- Returns:
The loop that follows the given loop in this series or None if the given loop is the last loop in the series.
- Return type:
LoopT | None
- Raises:
ValueError – If the given loop is not a loop in the series.