virtual_knitting_machine.machine_components.yarn_management.Yarn_Carrier_Set module
Representation module for yarn carrier sets on knitting machines. This module provides the Yarn_Carrier_Set class which represents a collection of yarn carriers that can be operated together in knitting operations. It manages multiple carriers as a single unit for positioning and operations.
- class Yarn_Carrier_Set(carrier_ids)[source]
-
A structure to represent a collection of yarn carriers that operate together as a single unit. This class manages multiple carriers for coordinated operations, positioning, and state management. It provides methods for accessing carrier positions, managing duplicates, and converting to various representation formats.
- __init__(carrier_ids)[source]
Initialize a yarn carrier set with one or more carrier identifiers.
- Parameters:
carrier_ids (Sequence[int | Yarn_Carrier_State] | int | Yarn_Carrier_State) – The carrier IDs for this yarn carrier set, can be a single carrier or list of carriers.
- Warns:
Duplicate_Carriers_In_Set – If duplicate carrier IDs are found in the input list.
- get_carriers(carrier_system)[source]
Get the actual carrier objects that correspond to the IDs in this carrier set.
- Parameters:
carrier_system (Yarn_Insertion_System) – Carrier system referenced by set.
- Returns:
Carriers that correspond to the ids in the carrier set.
- Return type:
- position_carriers_at_needle(carrier_system, needle, direction=None)[source]
Set the position of all involved carriers to the given position.
- Parameters:
carrier_system (Yarn_Insertion_System) – Carrier system referenced by set.
needle (int | None) – The needle to move the carrier set to, if None this means the carrier is not active.
direction (Carriage_Pass_Direction, optional) – The direction of the carrier movement. If this is not provided, the direction will be inferred.
- property many_carriers: bool
Check if this carrier set involves multiple carriers.
- Returns:
True if this carrier set involves multiple carriers, False if single carrier.
- Return type:
- __str__()[source]
Return string representation of the carrier set.
- Returns:
String representation showing all carrier IDs separated by spaces.
- Return type:
- __hash__()[source]
Return hash value for the carrier set.
- Returns:
Hash value based on single carrier ID or string representation for multiple carriers.
- Return type:
- __repr__()[source]
Return string representation of the carrier set.
- Returns:
String representation of the carrier set.
- Return type:
- __eq__(other)[source]
Check equality with another carrier set, carrier, or list of carriers.
- Parameters:
other (None | Yarn_Carrier | int | list[Yarn_Carrier | int] | Yarn_Carrier_Set) – The object to compare with.
- Returns:
True if the carrier sets contain the same carrier IDs, False otherwise.
- Return type:
- __iter__()[source]
Iterate over the carrier IDs in this set.
- Returns:
Iterator over carrier IDs.
- Return type:
Iterator[int]
- __getitem__(index: int) int[source]
- __getitem__(index: slice) list[int]
Get carrier ID(s) by index or slice.
- __len__()[source]
Get the number of carriers in this set.
- Returns:
Number of carriers in the set.
- Return type:
- count(value) integer -- return number of occurrences of value
- 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.
- __contains__(carrier_id)[source]
Check if a carrier ID is contained in this set.
- Parameters:
carrier_id (int | Yarn_Carrier_State | Sequence[int | Yarn_Carrier_State]) – Carrier ID to check for membership. If a sequence is provided, all members are checked for.
- Returns:
True if carrier ID(s) is in this set, False otherwise.
- Return type: