knit_graphs.artin_wale_braids.Wale module
Module containing the Wale Class.
This module defines the Wale class which represents a vertical column of stitches in a knitted structure, maintaining the sequence and relationships between loops in that column.
- class Wale(first_loop, knit_graph, end_loop=None)[source]
Bases:
object
A data structure representing stitch relationships between loops in a vertical column of a knitted structure.
A wale represents a vertical sequence of loops connected by stitch edges, forming a column in the knitted fabric. This class manages the sequential relationships between loops and tracks the pull directions of stitches within the wale.
- stitches
Stores the directed graph of stitch connections within this wale.
- Type:
DiGraph
- Parameters:
first_loop (
Loop
)knit_graph (
Knit_Graph
)
- __init__(first_loop, knit_graph, end_loop=None)[source]
Initialize a wale optionally starting with a specified loop.
- Parameters:
first_loop (Loop) – The initial loop to start the wale with.
knit_graph (Knit_Graph) – The knit graph that owns this wale.
end_loop (Loop, optional) – The loop to terminate the wale with. If no loop is provided or this loop is not found, the wale will terminate at the first loop with no child.
- add_loop_to_end(loop)[source]
Add a loop to the end (top) of the wale with the specified pull direction.
- get_stitch_pull_direction(u, v)[source]
Get the pull direction of the stitch edge between two loops in this wale.
- Parameters:
- Returns:
The pull direction of the stitch between loops u and v.
- Return type:
- split_wale(split_loop)[source]
Split this wale at the specified loop into two separate wales.
The split loop becomes the last loop of the first wale and the first loop of the second wale.
- Parameters:
split_loop (Loop) – The loop at which to split the wale. This loop will appear in both resulting wales.
- Returns:
A tuple containing: * The first wale (from start to split_loop). This will be the whole wale if the split_loop is not found. * The second wale (from split_loop to end). This will be None if the split_loop is not found.
- Return type:
- __len__()[source]
Get the number of loops in this wale.
- Returns:
The total number of loops in this wale.
- Return type:
- __iter__()[source]
Iterate over loops in this wale from first to last.
- Returns:
An iterator over the loops in this wale in their sequential order from bottom to top.
- Return type:
Iterator[Loop]