knit_graphs.knit_graph_builder module
Module containing the Knit_Graph_Builder class.
- class Knit_Graph_Builder(loop_class: type[LoopT] | None = None, yarn_class: type[Yarn[LoopT]] | None = None)[source]
Bases:
Generic[LoopT]A general framework for building Knit_Graphs from standard knitting operations.
- __init__(loop_class: type[LoopT] | None = None, yarn_class: type[Yarn[LoopT]] | None = None)[source]
- add_yarn(yarn_properties: Yarn_Properties | None = None, **yarn_kwargs: Any) Yarn[LoopT][source]
Create and add a new yarn to the Knit_Graph with the given properties. :param yarn_properties: The properties of the yarn. Defaults to standard yarn-properties. :type yarn_properties: Yarn_Properties, optional :param **yarn_kwargs: Additional keyword arguments for forming the yarn. Defaults to no keyword arguments. :type **yarn_kwargs: Any, optional
- Returns:
The new yarn in the Knit_Graph.
- Return type:
Yarn[LoopT]
- cut_yarn(yarn: Yarn[LoopT]) Yarn[LoopT][source]
Cut yarn to make it no longer active and create a new yarn instance of the same type.
- Returns:
New yarn of the same type after cutting this yarn.
- Return type:
Yarn[LoopT]
- static position_float(first_loop: LoopT, loops_behind_float: Sequence[LoopT] | None = None, loops_in_front_of_float: Sequence[LoopT] | None = None) None[source]
Position the float exiting the given loop relative to the given sets of loops. :param first_loop: First loop in the float to position. :type first_loop: LoopT :param loops_behind_float: The loops in front of the float to position. :type loops_behind_float: Sequence[LoopT] :param loops_in_front_of_float: The loops behind the float to position. :type loops_in_front_of_float: Sequence[LoopT]
- tuck(yarn: Yarn[LoopT], **loop_kwargs: Any) LoopT[source]
Forms a new loop at the end of the yarn with no parent loops. :param yarn: The yarn to form the loop from in the knitgraph. :type yarn: Yarn[LoopT] :param **loop_kwargs: Additional keywords to support base-classes of Loop. Defaults to None. :type **loop_kwargs: Any, optional
- Returns:
The new loop formed by the tuck.
- Return type:
LoopT
- knit(yarn: Yarn[LoopT], parent_loops: Sequence[LoopT], pull_direction: Pull_Direction | None = None, **loop_kwargs: Any) LoopT[source]
- Parameters:
yarn (Yarn[LoopT]) – The yarn to form the loop from in the knitgraph.
parent_loops (Sequence[LoopT]) – The parent loops of stitch in their stacking order.
pull_direction (Pull_Direction, optional) – Pull direction of the stitch. Defaults to the dominant pull direction of a loop or Back-to-front (i.e., knit-stitch) if the loop has no parents.
**loop_kwargs (Any, optional) – Additional keywords to support base-classes of Loop. Defaults to None.
- Returns:
The new loop formed by the knit.
- Return type:
LoopT
- xfer(loop: LoopT, over_loops_to_right: Sequence[LoopT] | None = None, over_loops_to_left: Sequence[LoopT] | None = None, under_loops_to_right: Sequence[LoopT] | None = None, under_loops_to_left: Sequence[LoopT] | None = None) None[source]
Cross the given loop over neighboring loops in the braid graph. :param loop: The loop to cross over neighbors :type loop: LoopT :param over_loops_to_right: The loops to cross over to the right. Defaults to no loops. :type over_loops_to_right: Sequence[LoopT], optional :param over_loops_to_left: The loops to cross over to the left. Defaults to no loops. :type over_loops_to_left: Sequence[LoopT], optional :param under_loops_to_right: The loops to cross under to the right. Defaults to no loops. :type under_loops_to_right: Sequence[LoopT], optional :param under_loops_to_left: The loops to cross under to the left. Defaults to no loops. :type under_loops_to_left: Sequence[LoopT], optional
- split(yarn: Yarn[LoopT], parent_loops: Sequence[LoopT], pull_direction: Pull_Direction | None = None, over_loops_to_right: Sequence[LoopT] | None = None, over_loops_to_left: Sequence[LoopT] | None = None, under_loops_to_right: Sequence[LoopT] | None = None, under_loops_to_left: Sequence[LoopT] | None = None, **loop_kwargs: Any) LoopT[source]
- Parameters:
yarn (Yarn[LoopT]) – The yarn to form the loop from in the knitgraph.
parent_loops (Sequence[LoopT]) – The parent loops of stitch in their stacking order.
pull_direction (Pull_Direction, optional) – Pull direction of the stitch. Defaults to the dominant pull direction of a loop or Back-to-front (i.e., knit-stitch) if the loop has no parents.
over_loops_to_right (Sequence[LoopT], optional) – The loops to cross over to the right. Defaults to no loops.
over_loops_to_left (Sequence[LoopT], optional) – The loops to cross over to the left. Defaults to no loops.
under_loops_to_right (Sequence[LoopT], optional) – The loops to cross under to the right. Defaults to no loops.
under_loops_to_left (Sequence[LoopT], optional) – The loops to cross under to the left. Defaults to no loops.
**loop_kwargs (Any, optional) – Additional keyword arguments for forming the loop. Defaults to no keyword arguments.
- Returns:
The loop formed in the split.
- Return type:
LoopT
- classmethod __class_getitem__(params)
Parameterizes a generic class.
At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.
However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….