knit_graphs.artin_wale_braids.Wale_Group module

Module containing the Wale_Group class and its methods.

This module provides the Wale_Group class which represents a collection of interconnected wales that are joined through decrease operations, forming a tree-like structure of vertical stitch columns.

class Wale_Group(terminal_loop, knit_graph)[source]

Bases: object

A graph structure maintaining relationships between connected wales through decrease operations.

This class represents a collection of wales that are connected through decrease stitches, where multiple wales merge into fewer wales as the knitting progresses upward. It maintains both the wale-to-wale relationships and the individual stitch connections within the group.

wale_graph

A directed graph representing the relationships between wales in this group.

Type:

DiGraph

stitch_graph

A directed graph of all individual stitch connections within this wale group.

Type:

DiGraph

top_loops

Mapping from the last (top) loop of each wale to the wale itself.

Type:

dict[Loop, Wale]

bottom_loops

Mapping from the first (bottom) loop of each wale to the wale itself.

Type:

dict[Loop, Wale]

Parameters:
__init__(terminal_loop, knit_graph)[source]

Initialize a wale group starting from a terminal wale and building downward.

Parameters:
  • terminal_loop (Loop) – The terminal loop of this wale-group. All the wales in the group connect up to this loop.

  • knit_graph (Knit_Graph) – The parent knit graph that contains this wale group.

property terminal_loop: Loop

Returns: Loop: The loop that terminates all wales in this group.

get_loops_over_courses()[source]

Get loops organized by their course (horizontal row) within this wale group.

This method traces through the stitch connections starting from the terminal wale’s top loop and groups loops by their vertical position (course) in the knitted structure.

Returns:

A list where each inner list contains all loops that belong to the same course, ordered from top to bottom courses. Returns empty list if there is no terminal wale.

Return type:

list[list[Loop]]

__len__()[source]

Get the height of the wale group measured as the maximum number of loops from base to terminal.

This method calculates the total length by summing all loops in all wales that can be reached from each bottom wale, returning the maximum total length found.

Returns:

The height of the wale group from the base loops to the tallest terminal, measured in total number of loops.

Return type:

int

__hash__()[source]
Returns:

Hash value of the terminal loop of this group.

Return type:

int

__contains__(item)[source]
Parameters:

item (Loop | int | Wale) – The item to check for in the wale group.

Returns:

True if the given loop, loop_id (int), or wale is in this group.

Return type:

bool

__str__()[source]
Returns:

The string representation of this wale group.

Return type:

str

__repr__()[source]
Returns:

The string representation of this wale group.

Return type:

str