knitout_interpreter.knitout_execution module

Module containing the knitout executer class

class knitout_interpreter.knitout_execution.Knitout_Executer(instructions, knitting_machine=None, accepted_error_types=None, knitout_version=2)[source]

Bases: object

A class used to execute a set of knitout instructions on a virtual knitting machine.

property version_line: Knitout_Version_Line

Get the version line for the executed knitout.

Returns:

The version line for the executed knitout.

property execution_time: int

Get the execution time as measured by carriage passes.

Returns:

Count of carriage passes in process as a measure of knitting time.

property left_most_position: int | None

Get the leftmost needle position used in execution.

Returns:

The position of the left most needle used in execution, or None if no needles were used.

property right_most_position: int | None

Get the rightmost needle position used in execution.

Returns:

The position of the right most needle used in the execution, or None if no needles were used.

property resulting_knit_graph: Knit_Graph

Get the knit graph resulting from instruction execution.

Returns:

Knit Graph that results from execution of these instructions.

property carriage_passes: list[Carriage_Pass]

Get the carriage passes from this execution.

Returns:

The carriage passes resulting from this execution in execution order.

test_and_organize_instructions(accepted_error_types=None)[source]

Test the given execution and organize the instructions in the class structure.

This method processes all instructions, organizing them into carriage passes and handling any errors that occur during execution.

Parameters:

accepted_error_types (list | None) – A list of exceptions that instructions may throw that can be resolved by commenting them out. Defaults to None.

write_executed_instructions(filename)[source]

Write a file with the organized knitout instructions.

Parameters:

filename (str) – The file path to write the executed instructions to.