virtual_knitting_machine.machine_components.needles.Slider_Needle module
Module for the Slider_Needle class used in virtual knitting machine operations.
This module provides the Slider_Needle class, which is a specialized type of needle that can only transfer loops but cannot be knit through. Slider needles are commonly used in knitting machines for loop manipulation operations such as transfers and temporary loop storage.
- class Slider_Needle(is_front, position)[source]
Bases:
Needle
A specialized needle subclass for slider needles in knitting machines.
Slider needles are needles that can hold and transfer loops but cannot be knit through. They are used for temporary loop storage and loop manipulation operations such as transfers between beds or complex stitch formations.
This class inherits all functionality from the base Needle class but overrides specific properties to indicate its slider nature.
- __str__()[source]
Return string representation of the slider needle.
- Returns:
String representation with ‘s’ suffix (e.g., ‘fs5’ for front slider at position 5, ‘bs3’ for back slider at position 3).
- Return type:
- property is_slider: bool
Check if the needle is a slider needle.
- Returns:
Always returns True for Slider_Needle instances.
- Return type:
- __add__(other)
Add another needle’s position or an integer to this needle’s position.
- __eq__(other)
Check equality with another needle.
- __hash__()
Return hash value for the needle.
- Returns:
Hash value based on position (negative for back needles).
- Return type:
- __index__()
Return index representation of the needle position.
- Returns:
The needle position as an index.
- Return type:
- __int__()
Return integer representation of the needle position.
- Returns:
The needle position.
- Return type:
- __lshift__(other)
Left shift operation (equivalent to subtraction).
- __lt__(other)
Compare if this needle is less than another needle or number.
- Parameters:
other (Needle | int | float) – The other needle or number to compare with.
- Returns:
True if this needle’s position is less than the other value. If the needles are at the same location but in opposite positions (back vs. front), the front needle is considered less than the back. This orders needles as front-to-back in a leftward carriage pass.
- Return type:
- Raises:
TypeError – If other is not a Needle or number.
- __radd__(other)
Right-hand add operation.
- __repr__()
Return string representation of the needle.
- Returns:
String representation of the needle.
- Return type:
- __rlshift__(other)
Right-hand left shift operation.
- __rrshift__(other)
Right-hand right shift operation.
- __rshift__(other)
Right shift operation (equivalent to addition).
- __rsub__(other)
Right-hand subtract operation.
- __sub__(other)
Subtract another needle’s position or an integer from this needle’s position.
- active_floats()
Get active floats connecting to loops on this needle.
- Returns:
Dictionary of loops that are active keyed to active yarn-wise neighbors. Each key-value pair represents a directed float where key comes before value on the yarns in the system.
- Return type:
- add_loop(loop)
Add a loop to the set of currently held loops.
- Parameters:
loop (Machine_Knit_Loop) – Loop to add onto needle.
- Return type:
- add_loops(loops)
Add multiple loops to the held set.
- Parameters:
loops (list[Machine_Knit_Loop]) – List of loops to place onto needle.
- Return type:
- at_racking_comparison(other, rack=0, all_needle_racking=False)
Compare needle positions at a given racking.
- Parameters:
- Returns:
1 if self > other, 0 if equal, -1 if self < other.
- Return type:
Note
At an all needle racking, the front needle is always < the back needle, regardless of direction.
- drop()
Drop all held loops by releasing them from the needle.
- Returns:
The loops that were dropped.
- Return type:
- float_overlaps_needle(u, v)
Check if a float between two loops overlaps this needle’s position.
- Parameters:
u (Machine_Knit_Loop) – Machine_Knit_Loop at start of float.
v (Machine_Knit_Loop) – Machine_Knit_Loop at end of float.
- Returns:
True if the float between u and v overlaps the position of this needle.
- Return type:
- property has_loops: bool
Check if the needle is currently holding any loops.
- Returns:
True if needle is holding loops, False otherwise.
- Return type:
- property is_back: bool
Check if needle is on the back bed.
- Returns:
True if needle is on the back bed, False otherwise.
- Return type:
- property is_front: bool
Check if needle is on the front bed.
- Returns:
True if needle is on front bed, False otherwise.
- Return type:
- main_needle()
Get the non-slider needle at this needle position.
- Returns:
The non-slider needle at this needle position. If this is not a slider needle, this instance is returned.
- Return type:
- static needle_at_racking_cmp(n1, n2, racking=0, all_needle_racking=False)
Static method to compare two needles at a given racking.
- Parameters:
- Returns:
1 if n1 > n2, 0 if equal, -1 if n1 < n2.
- Return type:
Note
At an all needle racking, the front needle is always < the back needle, regardless of direction.
- offset(offset)
Get a needle offset by the specified amount on the same bed.
- opposite()
Get the needle on the opposite bed at the same position.
- Returns:
The needle on the opposite bed at the same position.
- Return type:
- property position: int
Get the index position of the needle on the machine bed.
- Returns:
The index on the machine bed of the needle.
- Return type:
- property pull_direction: Pull_Direction
Get the direction this needle pulls loops during knit operations.
- Returns:
BtF (Back to Front) for front needles, FtB (Front to Back) for back needles.
- Return type:
Pull_Direction
- racked_position_on_front(rack)
Get the position of the needle on the front bed at a given racking.