virtual_knitting_machine.machine_components.carriage_system.Carriage_Pass_Direction module

Enumerator module for possible carriage pass directions on knitting machines.

This module defines the two directions a carriage can move across the needle bed and provides utility functions for needle positioning, comparison, and sorting operations relative to carriage movement direction.

class Carriage_Pass_Direction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

An enumerator for the two directions the carriage can pass on the knitting machine.

Needles are oriented on the machine left to right in ascending order: Left -> 0 1 2 … N <- Right. This enum provides methods for needle comparison, positioning, and sorting operations relative to carriage movement direction.

Leftward = '-'
Rightward = '+'
opposite()[source]

Get the opposite pass direction of this direction.

Returns:

The opposite pass direction of this direction.

Return type:

Carriage_Pass_Direction

sort_needles(needles, racking=None)[source]

Return needles sorted in this direction at given racking.

Parameters:
  • needles (Iterable[Needle_Specification]) – Needles to be sorted in pass direction.

  • racking (int, optional) – The racking to sort needles in, sets back bed offset. Defaults to the racking of the first Needle with a specified machine or 0 if no needle on a machine is included.

Returns:

List of needles sorted in the pass direction.

Return type:

list[Needle_Specification]

__str__()[source]

Return string representation of the carriage pass direction.

Returns:

String representation of the direction value.

Return type:

str

__repr__()[source]

Return string representation of the carriage pass direction.

Returns:

String representation of the direction value.

Return type:

str

__neg__()[source]

Get the opposite direction using unary minus operator.

Returns:

The opposite pass direction.

Return type:

Carriage_Pass_Direction

__invert__()[source]

Get the opposite direction using bitwise invert operator.

Returns:

The opposite pass direction.

Return type:

Carriage_Pass_Direction

static get_direction(dir_str)[source]

Return a Pass direction enum given a valid string representation.

Parameters:

dir_str (str) – String to convert to direction (“-” for Leftward, anything else for Rightward).

Returns:

Pass direction corresponding to the string.

Return type:

Carriage_Pass_Direction

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)