Mesh Module¶
This module contains the meshes of the knit work.
-
class
knittingpattern.Mesh.Mesh[source]¶ Bases:
objectA mesh that is either consumed or produced by an instruction.
assert mesh.is_produced() or mesh.is_consumed()
Since this is an abstract base class you will only get instances of
ProducedMeshandConsumedMesh.-
__repr__()[source]¶ This mesh as string.
Returns: the string representation of this mesh. Return type: str This is useful for
print()and class:str
-
__weakref__¶ list of weak references to the object (if defined)
-
as_produced_mesh()[source]¶ The produced part to this mesh.
If meshes are split up, it may be important which row the mesh is connected to afterwards. This method returns the mesh that is connected to the
producing row.If you got this mesh from
InstructionInRow.produced_meshesorRow.produced_meshes, this returns the same object.See also
as_consumed_mesh(),knittinpattern.Instruction.InstructionInRow.produced_meshes,knittinpattern.Row.Row.produced_meshes
-
connect_to(other_mesh)[source]¶ Create a connection to an other mesh.
Warning
Both meshes need to be disocnnected and one needs to be a consumed and the other a produced mesh. You can check if a connection is possible using
can_connect_to().See also
-
consuming_instruction¶ Instruction which consumes this mesh.
Returns: the instruction that consumes this mesh Return type: knittingpattern.Instruction.InstructionInRow Warning
Check with
is_consumed()before!
-
consuming_row¶ Row which consumes this mesh.
Returns: the row that consumes this mesh Return type: knittingpattern.Row.Row Warning
Check with
is_consumed()before!
-
disconnect()[source]¶ Remove the connection between two rows through this mesh.
After disconnecting this mesh, it can be connected anew.
-
index_in_consuming_instruction¶ Index in instruction as consumed mesh.
Returns: the index of the mesh in the list of meshes that consuming_instructionconsumesReturn type: int instruction = mesh.consuming_instruction index = mesh.index_in_consuming_instruction assert instruction.consumed_meshes[index] == mesh
Warning
Check with
is_consumed()before!
-
index_in_consuming_row¶ Index in row as consumed mesh.
Returns: the index of the mesh in the list of meshes that consuming_rowconsumesReturn type: int row = mesh.consuming_row index = mesh.index_in_consuming_row assert row.consumed_meshes[index] == mesh
See also
Warning
Check with
is_consumed()before!
-
index_in_producing_instruction¶ Index in instruction as a produced mesh.
Returns: the index of the mesh in the list of meshes that producing_instructionproducesReturn type: int instruction = mesh.producing_instruction index = mesh.index_in_producing_instruction assert instruction.produced_meshes[index] == mesh
Warning
Check with
is_produced()before!
-
index_in_producing_row¶ Index in row as produced mesh.
Returns: the index of the mesh in the producing_rowReturn type: int row = mesh.producing_row index = mesh.index_in_producing_row assert row[index] == mesh
See also
Warning
Check with
is_produced()before!
-
is_connected()[source]¶ Returns whether this mesh is already connected.
Returns: whether this mesh is connected to an other. Return type: bool
-
is_consumed()[source]¶ Whether the mesh has an instruction that consumed it.
Returns: whether the mesh is consumed by an instruction Return type: bool If you get this mesh from
knittingpattern.Instruction.InstructionInRow.consumed_meshesorknittingpattern.Row.Row.consumed_meshes, this should beTrue.Warning
Before you use any methods on how the mesh is consumed, you should check with
mesh.is_consumed().
-
is_knit()[source]¶ Whether the mesh is produced by a knit instruction.
Returns: whether the mesh is knit by an instruction Return type: bool See also
-
is_produced()[source]¶ Whether the mesh has an instruction that produces it.
Returns: whether the mesh is produced by an instruction Return type: bool If you get this mesh from
knittingpattern.Instruction.InstructionInRow.produced_meshesorknittingpattern.Row.Row.produced_meshes, this should beTrue.Warning
Before you use any methods on how the mesh is produced, you should check with
mesh.is_produced().
-
producing_instruction¶ Instruction which produces this mesh.
Returns: the instruction that produces this mesh Return type: knittingpattern.Instruction.InstructionInRow Warning
Check with
is_produced()before!
-
producing_row¶ Row which produces this mesh.
Returns: the row of the instruction that produces this mesh Return type: knittingpattern.Row.Row Warning
Check with
is_produced()before!
-
-
class
knittingpattern.Mesh.ProducedMesh(producing_instruction, index_in_producing_instruction)[source]¶ Bases:
knittingpattern.Mesh.MeshA
Meshthat has a producing instruction-
__init__(producing_instruction, index_in_producing_instruction)[source]¶ Parameters: - producing_instruction¶ – the
instructionthat produces the mesh - index_in_producing_instruction¶ (int) – the index of the mesh
in the list of meshes that
producing_instructionproduces
Note
There should be no necessity to create instances of this directly. You should be able to use
instruction.produced_meshesorinstruction.consumed_meshesto access themeshes.- producing_instruction¶ – the
-
-
class
knittingpattern.Mesh.ConsumedMesh(consuming_instruction, index_in_consuming_instruction)[source]¶ Bases:
knittingpattern.Mesh.MeshA mesh that is only consumed by an instruction
-
__init__(consuming_instruction, index_in_consuming_instruction)[source]¶ Parameters: - consuming_instruction¶ – the
instructionthat consumes the mesh - index_in_consuming_instruction¶ (int) – the index of the mesh
in the list of meshes that
consuming_instructionconsumes
Note
There should be no necessity to create instances of this directly. You should be able to use
instruction.produced_meshesorinstruction.consumed_meshesto access themeshes.- consuming_instruction¶ – the
-