virtual_knitting_machine.Knitting_Machine_Specification module
A module containing the class structures needed to define a knitting machine specification.
This module provides enumerations for machine types and knitting positions, as well as a dataclass specification that defines all the parameters and constraints for configuring a virtual knitting machine.
- class Knitting_Machine_Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumAn enumeration of supported knitting machine types that can be represented by this library.
Currently, supports the SWG091N2 whole garment knitting machine model with potential for additional machine types in the future.
- SWG091N2 = 'SWG091N2'
- __str__()[source]
Return string representation of the machine type.
- Returns:
The name of the machine type.
- Return type:
- __repr__()[source]
Return string representation of the machine type.
- Returns:
String representation of the machine type.
- Return type:
- __hash__()[source]
Return hash value for the machine type.
- Returns:
Hash value based on string representation.
- Return type:
- classmethod __contains__(member)
Return True if member is a member of this enum raises TypeError if member is not an enum member
note: in 3.12 TypeError will no longer be raised, and True will also be returned if member is the value of a member in this enum
- classmethod __getitem__(name)
Return the member matching name.
- classmethod __iter__()
Return members in definition order.
- classmethod __len__()
Return the number of members (no aliases)
- class Knitting_Position(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumThe position configuration for knitting operations executed on the virtual machine.
This enumeration defines where knitting operations are positioned on the machine bed, affecting how the machine interprets needle positions and carriage movements.
- Left = 'Left'
- Right = 'Right'
- Center = 'Center'
- Keep = 'Keep'
- __str__()[source]
Return string representation of the knitting position.
- Returns:
The name of the knitting position.
- Return type:
- __repr__()[source]
Return string representation of the knitting position.
- Returns:
String representation of the knitting position.
- Return type:
- __hash__()[source]
Return hash value for the knitting position.
- Returns:
Hash value based on string representation.
- Return type:
- classmethod __contains__(member)
Return True if member is a member of this enum raises TypeError if member is not an enum member
note: in 3.12 TypeError will no longer be raised, and True will also be returned if member is the value of a member in this enum
- classmethod __getitem__(name)
Return the member matching name.
- classmethod __iter__()
Return members in definition order.
- classmethod __len__()
Return the number of members (no aliases)
- class Knitting_Machine_Specification(machine=SWG091N2, gauge=15, position=Right, carrier_count=10, needle_count=540, maximum_rack=4, maximum_float=20, maximum_loop_hold=4, hook_size=5, carrier_colors=('firebrick', 'navy', 'darkgreen', 'indigo', 'darkgoldenrod', 'saddlebrown', 'darkcyan', 'purple', 'darkorange', 'darkslateblue'), loop_class=<class 'virtual_knitting_machine.machine_constructed_knit_graph.Machine_Knit_Loop.Machine_Knit_Loop'>)[source]
Bases:
Generic[Machine_LoopT]The complete specification of a knitting machine including machine type, physical constraints, and operational parameters.
This dataclass defines all the configurable parameters that determine machine capabilities, limitations, and behavior during knitting operations.
- machine: Knitting_Machine_Type = 'SWG091N2'
- position: Knitting_Position = 'Right'
- carrier_colors: tuple[str, ...] = ('firebrick', 'navy', 'darkgreen', 'indigo', 'darkgoldenrod', 'saddlebrown', 'darkcyan', 'purple', 'darkorange', 'darkslateblue')
A tuple containing the default names of colors to assign to yarns based on the carrier id.
- loop_class
alias of
Machine_Knit_Loop
- get_yarn_color(carrier_id)[source]
- Parameters:
carrier_id (int) – The carrier id of the carrier.
- Returns:
A string for a color to assign to the yarn of a carrier.
- Return type:
Notes
If the carrier id is greater than the given number of carrier colors, black will be the carrier color.
- 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]): ….
- __init__(machine=SWG091N2, gauge=15, position=Right, carrier_count=10, needle_count=540, maximum_rack=4, maximum_float=20, maximum_loop_hold=4, hook_size=5, carrier_colors=('firebrick', 'navy', 'darkgreen', 'indigo', 'darkgoldenrod', 'saddlebrown', 'darkcyan', 'purple', 'darkorange', 'darkslateblue'), loop_class=<class 'virtual_knitting_machine.machine_constructed_knit_graph.Machine_Knit_Loop.Machine_Knit_Loop'>)
- make_loop(**loop_kwargs)[source]
- Parameters:
**loop_kwargs (Any) – Open signature support specialized loop types in subclasses.
- Expected Args:
source_needle (Needle[Machine_LoopT]): The needle that the loop is formed on. yarn (Machine_Knit_Yarn[Machine_LoopT]): The yarn that the loop is formed from.
- Returns:
The type of loop that will be instantiated on a knitting machine.
- Return type:
Machine_LoopT