knit_script.knit_script_interpreter.scope.gauged_sheet_schema.Sheet module

Module containing the Sheet class.

This module provides the Sheet class, which represents a single sheet in a gauged knitting configuration. A sheet maintains records of loop positions and provides access to needles that belong to the sheet based on the gauge spacing.

The Sheet class is fundamental to multi-sheet knitting operations, where different parts of the knitting process are organized across multiple virtual sheets that correspond to different needle positions in a gauged pattern.

class Sheet(sheet_number, gauge, knitting_machine)[source]

Bases: object

Record of the position of loops on a sheet defined by the current gauging schema.

A Sheet represents one layer in a multi-sheet knitting configuration, where needles are organized according to a gauge pattern. Each sheet maintains a record of which needles currently hold loops and provides methods to access needles that belong to this particular sheet.

The sheet system allows for complex knitting patterns where different operations are performed on different subsets of needles in a structured, repeating pattern based on the gauge value.

knitting_machine

The knitting machine that this sheet operates on.

Type:

Knitting_Machine

loop_record

Dictionary mapping in-sheet needle positions to tuples indicating whether loops are recorded on the front and back needles at that position.

Type:

dict[int, tuple[bool, bool]]

__init__(sheet_number, gauge, knitting_machine)[source]

Initialize a sheet with the specified number, gauge, and knitting machine.

Creates a new sheet that will manage a subset of needles on the knitting machine according to the gauge pattern. The sheet records the initial state of all needles that belong to it.

Parameters:
  • sheet_number (int) – The index of this sheet within the gauge configuration. Must be non-negative and less than the gauge value.

  • gauge (int) – The gauge value that determines the spacing pattern for needle organization. Must be positive.

  • knitting_machine (Knitting_Machine) – The knitting machine instance that this sheet will manage needles for.

Raises:

Sheet_Value_Exception – If sheet_number is negative or greater than or equal to the gauge value.

property sheet: int

Returns: int: The position of the sheet in the gauge.

property gauge: int

Returns: int: The number of active sheets.

record_needle(needle)[source]

Record the state of the given sheet needle and its opposite needle.

Updates the loop record for the specified sheet needle position by recording the current loop state of both the front and back needles at that position.

Parameters:

needle (Sheet_Needle) – The sheet needle to record the state of. Must be a valid sheet needle that belongs to this sheet.

Raises:

ValueError – The given needle does not belong to this sheet.

Note

This method records the state of both the specified needle and its opposite bed counterpart, maintaining consistency in the loop record.

record_sheet()[source]

Record the loop locations for needles in the sheet given the current state of the knitting machine.

Updates the entire loop record for this sheet by examining the current state of all needles that belong to the sheet. This method provides a way to synchronize the sheet’s record with the actual machine state.

Note

This operation examines all needle positions in the sheet and updates the loop record accordingly. It’s useful after operations that may have changed the loop distribution across the sheet.

get_matching_needle_on_sheet(other_needle)[source]
Parameters:

other_needle (int | Needle_Specification) – The position on the machine bed (int) or needle specification of the needle in another sheet to find in this sheet.

Returns:

A needle belonging to this sheet at the same position of the given needle in its sheet, with matching characteristics.

Return type:

Needle

Notes

Providing an int for the other needle will result in a front-bed needle.

__eq__(other)[source]

Check equality with another Sheet or integer.

Parameters:

other (Sheet | int) – The object to compare with. Can be another Sheet or an integer representing a sheet number.

Returns:

True if the objects are equal, False otherwise.

Return type:

bool

Note

When comparing with another Sheet, both sheet_number and gauge must match. When comparing with an integer, only the sheet_number is compared.

front_needles()[source]
Returns:

The set of front bed needles on the machine that belong to this sheet, ordered by position. Needles are selected using the gauge spacing pattern starting from this sheet’s offset.

Return type:

list[Needle]

back_needles()[source]
Returns:

The set of back bed needles on the machine that belong to this sheet, ordered by position. Needles are selected using the gauge spacing pattern starting from this sheet’s offset.

Return type:

list[Needle]

front_sliders()[source]
Returns:

The set of front slider needles on the machine that belong to this sheet, ordered by position. Needles are selected using the gauge spacing pattern starting from this sheet’s offset.

Return type:

list[Slider_Needle]

back_sliders()[source]
Returns:

The set of back slider needles on the machine that belong to this sheet, ordered by position. Needles are selected using the gauge spacing pattern starting from this sheet’s offset.

Return type:

list[Slider_Needle]

front_loops()[source]
Returns:

The list of front bed needles that belong to this sheet and currently hold loops, ordered by position.

Return type:

list[Needle]

back_loops()[source]
Returns:

The list of back bed needles that belong to this sheet and currently hold loops, ordered by position.

Return type:

list[Needle]

front_slider_loops()[source]
Returns:

The list of front bed slider needles that belong to this sheet and currently hold loops, ordered by position.

Return type:

list[Slider_Needle]

back_slider_loops()[source]
Returns:

The list of back bed slider needles that belong to this sheet and currently hold loops, ordered by position.

Return type:

list[Slider_Needle]

all_needles()[source]
Returns:

List of all needles on the sheet with front bed needles given first, followed by back bed needles, all ordered by position within their respective beds.

Return type:

list[Needle]

all_sliders()[source]
Returns:

List of all slider needles on the sheet with front bed sliders given first, followed by back bed sliders, all ordered by position within their respective beds.

Return type:

list[Slider_Needle]

all_loops()[source]
Returns:

List of all loop-holding needles on the sheet with front bed needles given first, followed by back bed needles, all ordered by position within their respective beds.

Return type:

list[Needle]

all_slider_loops()[source]
Returns:

List of all loop-holding slider needles on the sheet with front bed sliders given first, followed by back bed sliders, all ordered by position within their respective beds.

Return type:

list[Slider_Needle]