knit-graphs 0.0.7__py3-none-any.whl → 0.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. docs/source/api/knit_graphs.Course.rst +7 -0
  2. docs/source/api/knit_graphs.Knit_Graph.rst +7 -0
  3. docs/source/api/knit_graphs.Knit_Graph_Visualizer.rst +7 -0
  4. docs/source/api/knit_graphs.Loop.rst +7 -0
  5. docs/source/api/knit_graphs.Pull_Direction.rst +7 -0
  6. docs/source/api/knit_graphs.Yarn.rst +7 -0
  7. docs/source/api/knit_graphs.artin_wale_braids.Crossing_Direction.rst +7 -0
  8. docs/source/api/knit_graphs.artin_wale_braids.Loop_Braid_Graph.rst +7 -0
  9. docs/source/api/knit_graphs.artin_wale_braids.Wale.rst +7 -0
  10. docs/source/api/knit_graphs.artin_wale_braids.Wale_Braid.rst +7 -0
  11. docs/source/api/knit_graphs.artin_wale_braids.Wale_Braid_Word.rst +7 -0
  12. docs/source/api/knit_graphs.artin_wale_braids.Wale_Group.rst +7 -0
  13. docs/source/api/knit_graphs.artin_wale_braids.rst +11 -46
  14. docs/source/api/knit_graphs.basic_knit_graph_generators.rst +7 -0
  15. docs/source/api/knit_graphs.rst +12 -54
  16. knit_graphs/Course.py +24 -5
  17. knit_graphs/Knit_Graph.py +37 -14
  18. knit_graphs/Knit_Graph_Visualizer.py +188 -193
  19. knit_graphs/Loop.py +62 -12
  20. knit_graphs/Yarn.py +12 -9
  21. knit_graphs/artin_wale_braids/Wale.py +3 -4
  22. knit_graphs/artin_wale_braids/Wale_Group.py +7 -5
  23. knit_graphs/basic_knit_graph_generators.py +24 -75
  24. {knit_graphs-0.0.7.dist-info → knit_graphs-0.0.9.dist-info}/METADATA +5 -5
  25. knit_graphs-0.0.9.dist-info/RECORD +41 -0
  26. knit_graphs/_base_classes.py +0 -173
  27. knit_graphs-0.0.7.dist-info/RECORD +0 -29
  28. {knit_graphs-0.0.7.dist-info → knit_graphs-0.0.9.dist-info}/LICENSE +0 -0
  29. {knit_graphs-0.0.7.dist-info → knit_graphs-0.0.9.dist-info}/WHEEL +0 -0
knit_graphs/Loop.py CHANGED
@@ -5,12 +5,13 @@ Loops are the fundamental building blocks of knitted structures and maintain rel
5
5
  """
6
6
  from __future__ import annotations
7
7
 
8
- from typing import cast
8
+ from typing import TYPE_CHECKING, cast
9
9
 
10
- from knit_graphs._base_classes import _Base_Loop, _Base_Yarn
10
+ if TYPE_CHECKING:
11
+ from knit_graphs.Yarn import Yarn
11
12
 
12
13
 
13
- class Loop(_Base_Loop):
14
+ class Loop:
14
15
  """A class to represent a single loop structure for modeling a single loop in a knitting pattern.
15
16
 
16
17
  The Loop class manages yarn relationships, parent-child connections for stitches, and float positioning for complex knitting structures.
@@ -23,15 +24,17 @@ class Loop(_Base_Loop):
23
24
  back_floats (dict[Loop, set[Loop]]): A dictionary tracking loops that this loop floats behind.
24
25
  """
25
26
 
26
- def __init__(self, loop_id: int, yarn: _Base_Yarn) -> None:
27
+ def __init__(self, loop_id: int, yarn: Yarn) -> None:
27
28
  """Construct a Loop object with the specified identifier and yarn.
28
29
 
29
30
  Args:
30
31
  loop_id (int): A unique identifier for the loop, must be non-negative.
31
- yarn (_Base_Yarn): The yarn that creates and holds this loop.
32
+ yarn (Yarn): The yarn that creates and holds this loop.
32
33
  """
33
- super().__init__(loop_id)
34
- self.yarn: _Base_Yarn = yarn
34
+ if loop_id < 0:
35
+ raise ValueError(f"Loop identifier must be non-negative but got {loop_id}")
36
+ self._loop_id: int = loop_id
37
+ self.yarn: Yarn = yarn
35
38
  self.parent_loops: list[Loop] = []
36
39
  self.front_floats: dict[Loop, set[Loop]] = {}
37
40
  self.back_floats: dict[Loop, set[Loop]] = {}
@@ -102,7 +105,7 @@ class Loop(_Base_Loop):
102
105
  if loop is None:
103
106
  return None
104
107
  else:
105
- return cast(Loop, loop)
108
+ return loop
106
109
 
107
110
  def next_loop_on_yarn(self) -> Loop:
108
111
  """Get the loop that follows this loop on the same yarn.
@@ -132,10 +135,57 @@ class Loop(_Base_Loop):
132
135
  else:
133
136
  self.parent_loops.append(parent)
134
137
 
135
- def __str__(self) -> str:
136
- """Get a string representation of this loop.
138
+ @property
139
+ def loop_id(self) -> int:
140
+ """Get the unique identifier of this loop.
137
141
 
138
142
  Returns:
139
- str: String representation showing the loop ID and associated yarn.
143
+ int: The id of the loop.
140
144
  """
141
- return f"{self.loop_id} on yarn {self.yarn}"
145
+ return self._loop_id
146
+
147
+ def __hash__(self) -> int:
148
+ """Return hash value based on loop_id for use in sets and dictionaries.
149
+
150
+ Returns:
151
+ int: Hash value of the loop_id.
152
+ """
153
+ return self.loop_id
154
+
155
+ def __int__(self) -> int:
156
+ """Convert loop to integer representation using loop_id.
157
+
158
+ Returns:
159
+ int: The loop_id as an integer.
160
+ """
161
+ return self.loop_id
162
+
163
+ def __eq__(self, other: Loop) -> bool:
164
+ """Check equality with another base loop based on loop_id and type.
165
+
166
+ Args:
167
+ other (Loop): The other loop to compare with.
168
+
169
+ Returns:
170
+ bool: True if both loops have the same class and loop_id, False otherwise.
171
+ """
172
+ return isinstance(other, other.__class__) and self.loop_id == other.loop_id
173
+
174
+ def __lt__(self, other: Loop | int) -> bool:
175
+ """Compare loop_id with another loop or integer for ordering.
176
+
177
+ Args:
178
+ other (Loop | int): The other loop or integer to compare with.
179
+
180
+ Returns:
181
+ bool: True if this loop's id is less than the other's id.
182
+ """
183
+ return int(self.loop_id) < int(other)
184
+
185
+ def __repr__(self) -> str:
186
+ """Return string representation of the loop.
187
+
188
+ Returns:
189
+ str: String representation showing "Loop {loop_id}".
190
+ """
191
+ return f"Loop {self.loop_id}"
knit_graphs/Yarn.py CHANGED
@@ -6,13 +6,15 @@ The Yarn class manages the sequence of loops along a yarn and their floating rel
6
6
  from __future__ import annotations
7
7
 
8
8
  from dataclasses import dataclass
9
- from typing import Iterator, cast
9
+ from typing import TYPE_CHECKING, Iterator, cast
10
10
 
11
- from networkx import dfs_edges, dfs_preorder_nodes
11
+ from networkx import DiGraph, dfs_edges, dfs_preorder_nodes
12
12
 
13
- from knit_graphs._base_classes import _Base_Knit_Graph, _Base_Yarn
14
13
  from knit_graphs.Loop import Loop
15
14
 
15
+ if TYPE_CHECKING:
16
+ from knit_graphs.Knit_Graph import Knit_Graph
17
+
16
18
 
17
19
  @dataclass(frozen=True)
18
20
  class Yarn_Properties:
@@ -70,33 +72,34 @@ class Yarn_Properties:
70
72
  return hash((self.name, self.plies, self.weight, self.color))
71
73
 
72
74
 
73
- class Yarn(_Base_Yarn):
75
+ class Yarn:
74
76
  """A class to represent a yarn structure as a sequence of connected loops.
75
77
 
76
78
  The Yarn class manages a directed graph of loops representing the physical yarn path through a knitted structure.
77
79
  It maintains the sequential order of loops and their floating relationships, providing methods for navigation and manipulation of the yarn structure.
78
80
 
79
81
  Attributes:
82
+ loop_graph (DiGraph): The directed graph loops connected by yarn-wise float edges.
80
83
  properties (Yarn_Properties): The physical and visual properties of this yarn.
81
84
  """
82
85
 
83
- def __init__(self, yarn_properties: None | Yarn_Properties = None, knit_graph: None | _Base_Knit_Graph = None):
86
+ def __init__(self, yarn_properties: None | Yarn_Properties = None, knit_graph: None | Knit_Graph = None):
84
87
  """Initialize a yarn with the specified properties and optional knit graph association.
85
88
 
86
89
  Args:
87
90
  yarn_properties (None | Yarn_Properties, optional): The properties defining this yarn. If None, uses default properties. Defaults to standard properties.
88
91
  knit_graph (None | Knit_Graph, optional): The knit graph that will own this yarn. Can be None for standalone yarns. Defaults to None.
89
92
  """
90
- super().__init__()
93
+ self.loop_graph: DiGraph = DiGraph()
91
94
  if yarn_properties is None:
92
95
  yarn_properties = Yarn_Properties.default_yarn()
93
96
  self.properties: Yarn_Properties = yarn_properties
94
97
  self._first_loop: Loop | None = None
95
98
  self._last_loop: Loop | None = None
96
- self._knit_graph: None | _Base_Knit_Graph = knit_graph
99
+ self._knit_graph: None | Knit_Graph = knit_graph
97
100
 
98
101
  @property
99
- def knit_graph(self) -> None | _Base_Knit_Graph:
102
+ def knit_graph(self) -> None | Knit_Graph:
100
103
  """Get the knit graph that owns this yarn.
101
104
 
102
105
  Returns:
@@ -105,7 +108,7 @@ class Yarn(_Base_Yarn):
105
108
  return self._knit_graph
106
109
 
107
110
  @knit_graph.setter
108
- def knit_graph(self, knit_graph: _Base_Knit_Graph) -> None:
111
+ def knit_graph(self, knit_graph: Knit_Graph) -> None:
109
112
  """Set the knit graph that owns this yarn.
110
113
 
111
114
  Args:
@@ -6,14 +6,13 @@ from __future__ import annotations
6
6
 
7
7
  from typing import Iterator, cast
8
8
 
9
- from networkx import dfs_preorder_nodes
9
+ from networkx import DiGraph, dfs_preorder_nodes
10
10
 
11
- from knit_graphs._base_classes import _Base_Wale
12
11
  from knit_graphs.Loop import Loop
13
12
  from knit_graphs.Pull_Direction import Pull_Direction
14
13
 
15
14
 
16
- class Wale(_Base_Wale):
15
+ class Wale:
17
16
  """A data structure representing stitch relationships between loops in a vertical column of a knitted structure.
18
17
 
19
18
  A wale represents a vertical sequence of loops connected by stitch edges, forming a column in the knitted fabric.
@@ -31,7 +30,7 @@ class Wale(_Base_Wale):
31
30
  Args:
32
31
  first_loop (Loop | None, optional): The initial loop to start the wale with. If provided, it will be added as both the first and last loop. Defaults to None.
33
32
  """
34
- super().__init__()
33
+ self.stitches: DiGraph = DiGraph()
35
34
  self.first_loop: None | Loop = first_loop
36
35
  self.last_loop: None | Loop = None
37
36
  if isinstance(self.first_loop, Loop):
@@ -4,14 +4,16 @@ This module provides the Wale_Group class which represents a collection of inter
4
4
  """
5
5
  from __future__ import annotations
6
6
 
7
- from typing import cast
7
+ from typing import TYPE_CHECKING, cast
8
8
 
9
9
  from networkx import DiGraph, dfs_preorder_nodes
10
10
 
11
- from knit_graphs._base_classes import _Base_Knit_Graph
12
11
  from knit_graphs.artin_wale_braids.Wale import Wale
13
12
  from knit_graphs.Loop import Loop
14
13
 
14
+ if TYPE_CHECKING:
15
+ from knit_graphs.Knit_Graph import Knit_Graph
16
+
15
17
 
16
18
  class Wale_Group:
17
19
  """A graph structure maintaining relationships between connected wales through decrease operations.
@@ -27,7 +29,7 @@ class Wale_Group:
27
29
  bottom_loops (dict[Loop, Wale]): Mapping from the first (bottom) loop of each wale to the wale itself.
28
30
  """
29
31
 
30
- def __init__(self, terminal_wale: Wale, knit_graph: _Base_Knit_Graph):
32
+ def __init__(self, terminal_wale: Wale, knit_graph: Knit_Graph):
31
33
  """Initialize a wale group starting from a terminal wale and building downward.
32
34
 
33
35
  Args:
@@ -36,7 +38,7 @@ class Wale_Group:
36
38
  """
37
39
  self.wale_graph: DiGraph = DiGraph()
38
40
  self.stitch_graph: DiGraph = DiGraph()
39
- self._knit_graph: _Base_Knit_Graph = knit_graph
41
+ self._knit_graph: Knit_Graph = knit_graph
40
42
  self.terminal_wale: Wale | None = terminal_wale
41
43
  self.top_loops: dict[Loop, Wale] = {}
42
44
  self.bottom_loops: dict[Loop, Wale] = {}
@@ -79,7 +81,7 @@ class Wale_Group:
79
81
  """
80
82
  added_wales = []
81
83
  for parent_loop in cast(Loop, wale.first_loop).parent_loops:
82
- parent_wales = cast(list[Wale], self._knit_graph.get_wales_ending_with_loop(parent_loop))
84
+ parent_wales = self._knit_graph.get_wales_ending_with_loop(parent_loop)
83
85
  for parent_wale in parent_wales:
84
86
  self.add_wale(parent_wale)
85
87
  added_wales.extend(parent_wales)
@@ -5,6 +5,7 @@ These functions serve as building blocks for testing and demonstration purposes.
5
5
  """
6
6
  from knit_graphs.artin_wale_braids.Crossing_Direction import Crossing_Direction
7
7
  from knit_graphs.Knit_Graph import Knit_Graph
8
+ from knit_graphs.Loop import Loop
8
9
  from knit_graphs.Pull_Direction import Pull_Direction
9
10
  from knit_graphs.Yarn import Yarn
10
11
 
@@ -153,105 +154,53 @@ def seed_swatch(width: int, height: int) -> Knit_Graph:
153
154
  return knit_graph
154
155
 
155
156
 
156
- def kp_mesh_decrease_left_swatch(width: int, height: int) -> Knit_Graph:
157
- """Generate a mesh pattern with left-leaning decreases and yarn overs in knit-purl ribbing.
158
-
159
- This creates an openwork mesh pattern where purl stitches are decreased leftward on even courses and replaced with yarn overs,
160
- creating decorative holes in the fabric while maintaining the overall stitch count.
157
+ def lace_mesh(width: int, height: int) -> Knit_Graph:
158
+ """Generate a mesh pattern with alternating left and right leaning decrease paired to yarn-overs.
159
+ These pairings create a basic lace pattern with eyelets formed around the increases.
161
160
 
162
161
  Args:
163
162
  width (int): The number of stitches per course (horizontal row).
164
163
  height (int): The number of courses (vertical rows) in the swatch.
165
164
 
166
165
  Returns:
167
- Knit_Graph: A knit graph representing a mesh swatch with left-leaning decreases and yarn overs.
166
+ Knit_Graph: A knit graph representing a mesh swatch.
168
167
  """
169
- # k<o k<o k <-: 1->2
170
- # |\ |\
171
- # k p k p k ->: 0->1
172
- # 0 1 2 3 4
173
168
  knit_graph, yarn = co_loops(width)
174
169
  last_course = knit_graph.get_courses()[0]
175
170
  next_course = []
176
- next_pull = Pull_Direction.BtF
177
171
  for parent_loop in reversed(last_course):
178
172
  child_loop = yarn.make_loop_on_end()
179
- knit_graph.connect_loops(parent_loop, child_loop, pull_direction=next_pull)
180
- next_pull = next_pull.opposite()
173
+ knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF)
181
174
  next_course.append(child_loop)
182
175
  last_course = next_course
183
176
  for _ in range(1, height):
177
+ # Make the lace course
184
178
  next_course = []
185
- for parent_loop in reversed(last_course):
179
+ yo_parent = None
180
+ prior_child = None
181
+ for i, parent_loop in enumerate(reversed(last_course)):
186
182
  child_loop = yarn.make_loop_on_end()
187
- grand_parent = parent_loop.parent_loops[0]
188
- parent_pull = knit_graph.get_pull_direction(grand_parent, parent_loop)
189
- if parent_pull is Pull_Direction.BtF: # knits stay in decrease at bottom of stack
183
+ if i % 3 == 0: # Just knit every third stitch
190
184
  knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF, stack_position=0)
191
- prior_parent = yarn.prior_loop(parent_loop)
192
- if prior_parent is not None and prior_parent in last_course:
193
- knit_graph.connect_loops(prior_parent, child_loop, pull_direction=Pull_Direction.FtB, stack_position=1)
194
- next_course.append(child_loop)
195
- last_course = next_course
196
- next_course = []
197
- for parent_loop in reversed(last_course):
198
- child_loop = yarn.make_loop_on_end()
199
- if len(parent_loop.parent_loops) == 0:
200
- knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.FtB)
201
- else:
202
- knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF)
203
- next_course.append(child_loop)
204
- last_course = next_course
205
- return knit_graph
206
-
207
-
208
- def kp_mesh_decrease_right_swatch(width: int, height: int) -> Knit_Graph:
209
- """Generate a mesh pattern with right-leaning decreases and yarn overs in knit-purl ribbing.
210
-
211
- This creates an openwork mesh pattern where purl stitches are decreased rightward on even courses and replaced with yarn overs,
212
- creating decorative holes in the fabric while maintaining the overall stitch count.
213
-
214
- Args:
215
- width (int): The number of stitches per course (horizontal row).
216
- height (int): The number of courses (vertical rows) in the swatch.
217
-
218
- Returns:
219
- Knit_Graph: A knit graph representing a mesh swatch with right-leaning decreases and yarn overs.
220
- """
221
- # k o>k o>k <-: 1->2
222
- # /| /|
223
- # k p k p k ->: 0->1
224
- # 0 1 2 3 4
225
- knit_graph, yarn = co_loops(width)
226
- last_course = knit_graph.get_courses()[0]
227
- next_course = []
228
- next_pull = Pull_Direction.BtF
229
- for parent_loop in reversed(last_course):
230
- child_loop = yarn.make_loop_on_end()
231
- knit_graph.connect_loops(parent_loop, child_loop, pull_direction=next_pull)
232
- next_pull = next_pull.opposite()
233
- next_course.append(child_loop)
234
- last_course = next_course
235
- for _ in range(1, height):
236
- next_course = []
237
- for parent_loop in reversed(last_course):
238
- child_loop = yarn.make_loop_on_end()
239
- grand_parent = parent_loop.parent_loops[0]
240
- parent_pull = knit_graph.get_pull_direction(grand_parent, parent_loop)
241
- if parent_pull is Pull_Direction.BtF: # knits stay in decrease at bottom of stack
185
+ elif i % 6 == 1: # Second of every 6 stitches (0 indexed) is yarn over before a decrease.
186
+ yo_parent = parent_loop
187
+ elif i % 6 == 2: # Third of every 6 stitches is bottom of decrease with prior yarn-over's parent
188
+ knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF, stack_position=0)
189
+ assert isinstance(yo_parent, Loop)
190
+ knit_graph.connect_loops(yo_parent, child_loop, pull_direction=Pull_Direction.BtF, stack_position=1)
191
+ elif i % 6 == 4: # Fifth of every six stitches is bottom of decrease with next yarn-over's parent
242
192
  knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF, stack_position=0)
243
- next_parent = yarn.next_loop(parent_loop)
244
- if next_parent is not None:
245
- knit_graph.connect_loops(next_parent, child_loop, pull_direction=Pull_Direction.FtB, stack_position=1)
193
+ prior_child = child_loop
194
+ elif i % 6 == 5: # The last of six stitches is the top of the prior decrease and new yarn-over
195
+ assert isinstance(prior_child, Loop)
196
+ knit_graph.connect_loops(parent_loop, prior_child, pull_direction=Pull_Direction.BtF, stack_position=1)
246
197
  next_course.append(child_loop)
247
198
  last_course = next_course
199
+ # Make a basic jersey course
248
200
  next_course = []
249
201
  for parent_loop in reversed(last_course):
250
202
  child_loop = yarn.make_loop_on_end()
251
- if len(parent_loop.parent_loops) == 0:
252
- knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.FtB)
253
- else:
254
- knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF)
203
+ knit_graph.connect_loops(parent_loop, child_loop, pull_direction=Pull_Direction.BtF)
255
204
  next_course.append(child_loop)
256
205
  last_course = next_course
257
206
  return knit_graph
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: knit-graphs
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: A graph representation of knitted structures where each loop is a node and edges represent yarn and stitch relationships.
5
- Home-page: https://mhofmann-Khoury.github.io/knit-graphs/
5
+ Home-page: https://mhofmann-khoury.github.io/knit_graph/
6
6
  License: MIT
7
7
  Keywords: ACT Lab,Northeastern University,knit,machine knit,fabrication,textile
8
8
  Author: Megan Hofmann
@@ -21,9 +21,9 @@ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Classifier: Topic :: Scientific/Engineering
23
23
  Requires-Dist: networkx (>=3.5)
24
- Requires-Dist: plotly (>=6.3.0)
25
- Project-URL: Documentation, https://mhofmann-Khoury.github.io/knit-graphs/
26
- Project-URL: Repository, https://github.com/mhofmann-Khoury/knit-graphs
24
+ Requires-Dist: plotly (>=6.3.0,<7.0.0)
25
+ Project-URL: Documentation, https://mhofmann-khoury.github.io/knit_graph/
26
+ Project-URL: Repository, https://github.com/mhofmann-Khoury/knit_graph/
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  # knit_graphs
@@ -0,0 +1,41 @@
1
+ LICENSE,sha256=Oazk3oiRu5ZN7b-EdYNYh0vu-I3Av2uIPQ-9L_cZ6Oo,1070
2
+ README.md,sha256=Hrs3kN8A7hxyel-WhEkzZYY89456vAh3KWbupcOAHsI,3963
3
+ docs/Makefile,sha256=4zv3TVkTACm6JBaKgTES3ZI9cETXgM6ULbZkXZP1as8,638
4
+ docs/make.bat,sha256=0qjrzODegavKd7LLwmr9ADhaYftiTnBgqOVAL9kApyo,769
5
+ docs/source/api/knit_graphs.Course.rst,sha256=k3RxvR2pSYgf_nyLjLgT3J56hjzk4fUU6kIdmp85pEc,144
6
+ docs/source/api/knit_graphs.Knit_Graph.rst,sha256=_VZEniw4cvMz6uUrXrTK1hBuYEZSaDUk1138AbIEZ2s,158
7
+ docs/source/api/knit_graphs.Knit_Graph_Visualizer.rst,sha256=vo7RSxjhWhIAFlKJMlwq48x1j3DszzZmpF-8-09uDaE,193
8
+ docs/source/api/knit_graphs.Loop.rst,sha256=Rgrs-yFP_0Qt6Mxjjt9s_PE4Vzk6gRpmZ_Qo8zHWNVQ,138
9
+ docs/source/api/knit_graphs.Pull_Direction.rst,sha256=Y6z1SBcsBb1Gdr_UnSgjvIawzfjDndBbciQhoNYTKhE,170
10
+ docs/source/api/knit_graphs.Yarn.rst,sha256=S2Vcm0xxVGx_2EvXLex0QusiTRpJEIras5XPOjL3ONQ,138
11
+ docs/source/api/knit_graphs.artin_wale_braids.Crossing_Direction.rst,sha256=C_apeGs2QvSG06jfcimuXGJDMAAZW4L_9fZT3vSnhts,240
12
+ docs/source/api/knit_graphs.artin_wale_braids.Loop_Braid_Graph.rst,sha256=5R0PtnLiAYFtsejQq-KJQYSMLeoGOs4jAAkVTbKtvy0,236
13
+ docs/source/api/knit_graphs.artin_wale_braids.Wale.rst,sha256=L3-9V-_5txjPa-XrBbOCAO4Le5ewSnGrJX9ZyUgWUDQ,196
14
+ docs/source/api/knit_graphs.artin_wale_braids.Wale_Braid.rst,sha256=tHXetyWrArkVBM89fIjCauGfOuVhb0jkZRDIZs5ZAWA,216
15
+ docs/source/api/knit_graphs.artin_wale_braids.Wale_Braid_Word.rst,sha256=NkXO_cCev1XdUwcUVsdb2CivEHm-xqJyFg3ZgHOfmZ0,233
16
+ docs/source/api/knit_graphs.artin_wale_braids.Wale_Group.rst,sha256=bAGHs3s8dW6lbkctyh8VvVNzlYkjwZXhrbXx-VvSKYQ,216
17
+ docs/source/api/knit_graphs.artin_wale_braids.rst,sha256=ESKgE9gg830yJ6w5mKuv3MHgH3tMZ-Ee2y3b-bSnU4Y,547
18
+ docs/source/api/knit_graphs.basic_knit_graph_generators.rst,sha256=OgV2jkEMY0LfRq8v0cNhJUk3fbUOS9VcP8zRv4VBvC4,213
19
+ docs/source/api/knit_graphs.rst,sha256=w9HIhWI8P0_gG0H_efRUMHYBtWbgCprcS9moclgM_3I,499
20
+ docs/source/conf.py,sha256=TZK8Rz0JNgQs2J_cUhVX5_4tmMBvRdGtILJsnAnAFWo,13350
21
+ docs/source/index.rst,sha256=D4KmCX1_d2-WrPgxSeggHHsc9-TeQwSUGYOkehRQWrw,1462
22
+ docs/source/installation.rst,sha256=GyNRk_oXKVgOZ4KFLAgkXLwjHYzDYsx8gcokLRrS0ZI,1247
23
+ knit_graphs/Course.py,sha256=hO768vPM0KFRsjCYsBTUgasqMzlvl0gsuSrsBX0UUSs,6280
24
+ knit_graphs/Knit_Graph.py,sha256=3NUeznjxAJPkvmwl_qxGpwxeN1LbsQBruAzLu551AZQ,11614
25
+ knit_graphs/Knit_Graph_Visualizer.py,sha256=s2zp6Z7-ZF_52x3zTx8oQr__tQScpkGthIoWck57ykE,40227
26
+ knit_graphs/Loop.py,sha256=WQh9ag1lv7_cJndZLGhhoGx1msdLEGixpahdXd2PhGk,7189
27
+ knit_graphs/Pull_Direction.py,sha256=8xRLN-j7V1mExgmt3YjcJcTDa5rLedA2bF4wI8gd-DE,2334
28
+ knit_graphs/Yarn.py,sha256=Stm-_1SRJTdN1hFPjtuBPyY0Ln55zC15FKGu5vyqerA,16000
29
+ knit_graphs/__init__.py,sha256=qzZAOxTqjgLkhoGnKNZwOkuYbKEyzfWKkKpKkV6lVfk,111
30
+ knit_graphs/artin_wale_braids/Crossing_Direction.py,sha256=71ckmEFfL0s25NJb8lfYwH2zku0uM1C5X9gGM7PYC5A,2820
31
+ knit_graphs/artin_wale_braids/Loop_Braid_Graph.py,sha256=2tsE16IzcvgsIKij1JNHWah6hLOgrpXCcjb6eocbfFs,4575
32
+ knit_graphs/artin_wale_braids/Wale.py,sha256=pdzGYdpy88UWPa1ePvu9YUsDkRAB2wGrqCnMA_vIwAA,7135
33
+ knit_graphs/artin_wale_braids/Wale_Braid.py,sha256=Ws0QmU7s63nrBKe69acDza-r-LozDyyaKVDNxQMy10Y,2662
34
+ knit_graphs/artin_wale_braids/Wale_Braid_Word.py,sha256=4YBlVMUZkqp85r46ETQSbFVS_WrT4PsWthHmFv5Ny9M,4587
35
+ knit_graphs/artin_wale_braids/Wale_Group.py,sha256=JJXR5TvLuoC2LXvNfmwbHhvBObn0MONUVE9ZsBcSmUc,6867
36
+ knit_graphs/artin_wale_braids/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ knit_graphs/basic_knit_graph_generators.py,sha256=doDH2MiXbMzGU9b3enEr3KdY8Fw90cssHi_lkts6VpY,11720
38
+ knit_graphs-0.0.9.dist-info/LICENSE,sha256=Oazk3oiRu5ZN7b-EdYNYh0vu-I3Av2uIPQ-9L_cZ6Oo,1070
39
+ knit_graphs-0.0.9.dist-info/METADATA,sha256=XzWrqXe9vJDLKHiA7a3wTNY4foVu6MemvqqWRyuDQ8s,5193
40
+ knit_graphs-0.0.9.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
41
+ knit_graphs-0.0.9.dist-info/RECORD,,
@@ -1,173 +0,0 @@
1
- """Private module containing base classes for Loops and Yarns. Used to resolve circular dependencies."""
2
- from __future__ import annotations
3
-
4
- from networkx import DiGraph
5
-
6
-
7
- class _Base_Loop:
8
- """Base class for Loop objects providing common functionality and interface.
9
-
10
- This class serves as a foundation for Loop implementations and helps resolve circular dependencies between modules. It provides basic loop identification and comparison functionality.
11
- """
12
-
13
- def __init__(self, loop_id: int):
14
- """Initialize a base loop with the given identifier.
15
-
16
- Args:
17
- loop_id (int): The unique identifier for this loop. Must be non-negative.
18
- """
19
- assert loop_id >= 0, f"{loop_id}: Loop_id must be non-negative"
20
- self._loop_id: int = loop_id
21
-
22
- @property
23
- def loop_id(self) -> int:
24
- """Get the unique identifier of this loop.
25
-
26
- Returns:
27
- int: The id of the loop.
28
- """
29
- return self._loop_id
30
-
31
- def __hash__(self) -> int:
32
- """Return hash value based on loop_id for use in sets and dictionaries.
33
-
34
- Returns:
35
- int: Hash value of the loop_id.
36
- """
37
- return self.loop_id
38
-
39
- def __int__(self) -> int:
40
- """Convert loop to integer representation using loop_id.
41
-
42
- Returns:
43
- int: The loop_id as an integer.
44
- """
45
- return self.loop_id
46
-
47
- def __eq__(self, other: _Base_Loop) -> bool:
48
- """Check equality with another base loop based on loop_id and type.
49
-
50
- Args:
51
- other (_Base_Loop): The other loop to compare with.
52
-
53
- Returns:
54
- bool: True if both loops have the same class and loop_id, False otherwise.
55
- """
56
- return isinstance(other, other.__class__) and self.loop_id == other.loop_id
57
-
58
- def __lt__(self, other: _Base_Loop | int) -> bool:
59
- """Compare loop_id with another loop or integer for ordering.
60
-
61
- Args:
62
- other (_Base_Loop | int): The other loop or integer to compare with.
63
-
64
- Returns:
65
- bool: True if this loop's id is less than the other's id.
66
- """
67
- return int(self.loop_id) < int(other)
68
-
69
- def __repr__(self) -> str:
70
- """Return string representation of the loop.
71
-
72
- Returns:
73
- str: String representation showing "Loop {loop_id}".
74
- """
75
- return f"Loop {self.loop_id}"
76
-
77
-
78
- class _Base_Yarn:
79
- """Base class for Yarn objects providing common functionality and interface.
80
-
81
- This class serves as a foundation for Yarn implementations and helps resolve circular dependencies between modules. It maintains a directed graph structure for managing loop relationships.
82
- """
83
-
84
- def __init__(self) -> None:
85
- """Initialize a base yarn with an empty directed graph for loop relationships."""
86
- self.loop_graph: DiGraph = DiGraph()
87
-
88
- def prior_loop(self, loop: _Base_Loop) -> _Base_Loop | None:
89
- """Find the loop that precedes the given loop on this yarn.
90
-
91
- Args:
92
- loop (_Base_Loop): The loop to find the preceding loop of.
93
-
94
- Returns:
95
- _Base_Loop | None: The loop that precedes the given loop on the yarn, or None if there is no prior loop.
96
-
97
- Raises:
98
- NotImplementedError: This is an abstract base class which must be extended with the correct implementation.
99
- """
100
- raise NotImplementedError("Implemented by base class")
101
-
102
- def next_loop(self, loop: _Base_Loop) -> _Base_Loop | None:
103
- """Find the loop that follows the given loop on this yarn.
104
-
105
- Args:
106
- loop (_Base_Loop): The loop to find the next loop of.
107
-
108
- Returns:
109
- _Base_Loop | None: The loop that follows the given loop on the yarn, or None if there is no next loop.
110
-
111
- Raises:
112
- NotImplementedError: This is an abstract base class which must be extended with the correct implementation.
113
- """
114
- raise NotImplementedError("Implemented by base class")
115
-
116
-
117
- class _Base_Wale:
118
- """Base class for Wale objects providing common functionality and interface.
119
-
120
- This class serves as a foundation for Wale implementations and maintains a directed graph structure for managing stitch relationships within a wale (vertical column of stitches).
121
- """
122
-
123
- def __init__(self) -> None:
124
- """Initialize a base wale with an empty directed graph for stitch relationships."""
125
- self.stitches: DiGraph = DiGraph()
126
-
127
-
128
- class _Base_Knit_Graph:
129
- """Base class for Knit Graph objects providing common functionality and interface.
130
-
131
- This class serves as a foundation for Knit Graph implementations and maintains a directed graph structure for managing stitch relationships throughout the entire knitted structure.
132
- """
133
-
134
- def __init__(self) -> None:
135
- """Initialize a base knit graph with an empty directed graph for stitch relationships."""
136
- self.stitch_graph: DiGraph = DiGraph()
137
-
138
- @property
139
- def last_loop(self) -> None | _Base_Loop:
140
- """Get the most recently added loop in the graph.
141
-
142
- Returns:
143
- None | _Base_Loop: The last loop added to the graph, or None if the graph contains no loops.
144
-
145
- Raises:
146
- NotImplementedError: This is an abstract base class which must be extended with the correct implementation.
147
- """
148
- raise NotImplementedError("Implemented by base class")
149
-
150
- def add_loop(self, loop: _Base_Loop) -> None:
151
- """Add a loop to the knit graph structure.
152
-
153
- Args:
154
- loop (_Base_Loop): The loop to add to the graph.
155
-
156
- Raises:
157
- NotImplementedError: This is an abstract base class which must be extended with the correct implementation.
158
- """
159
- raise NotImplementedError("Implemented by base class")
160
-
161
- def get_wales_ending_with_loop(self, last_loop: _Base_Loop) -> list[_Base_Wale]:
162
- """Get all wales (vertical columns) that terminate at the specified loop.
163
-
164
- Args:
165
- last_loop (_Base_Loop): The loop terminating the list of wales to be returned.
166
-
167
- Returns:
168
- list[_Base_Wale]: The list of wales that end at the given loop. This will only be multiple wales if the loop is a child of a decrease stitch.
169
-
170
- Raises:
171
- NotImplementedError: This is an abstract base class which must be extended with the correct implementation.
172
- """
173
- raise NotImplementedError
@@ -1,29 +0,0 @@
1
- LICENSE,sha256=Oazk3oiRu5ZN7b-EdYNYh0vu-I3Av2uIPQ-9L_cZ6Oo,1070
2
- README.md,sha256=Hrs3kN8A7hxyel-WhEkzZYY89456vAh3KWbupcOAHsI,3963
3
- docs/Makefile,sha256=4zv3TVkTACm6JBaKgTES3ZI9cETXgM6ULbZkXZP1as8,638
4
- docs/make.bat,sha256=0qjrzODegavKd7LLwmr9ADhaYftiTnBgqOVAL9kApyo,769
5
- docs/source/api/knit_graphs.artin_wale_braids.rst,sha256=_KUBZld6fAS5OP0k4gd5yKamNGXEqH12XjakmWeJIII,1549
6
- docs/source/api/knit_graphs.rst,sha256=zdmnXipviweW0ZGQsQCZtfOOc_6Fj0yWdg_TwOMafLI,1398
7
- docs/source/conf.py,sha256=TZK8Rz0JNgQs2J_cUhVX5_4tmMBvRdGtILJsnAnAFWo,13350
8
- docs/source/index.rst,sha256=D4KmCX1_d2-WrPgxSeggHHsc9-TeQwSUGYOkehRQWrw,1462
9
- docs/source/installation.rst,sha256=GyNRk_oXKVgOZ4KFLAgkXLwjHYzDYsx8gcokLRrS0ZI,1247
10
- knit_graphs/Course.py,sha256=oT-YghPdAg7A51GI_StdfF8oxYGWGkoad72woEkRKeY,5818
11
- knit_graphs/Knit_Graph.py,sha256=KgcWQPzZJ-Iif7g3zWq6hBy4fdJXkJXnFxGOSMYOn-g,10795
12
- knit_graphs/Knit_Graph_Visualizer.py,sha256=bbWl9iPQR93MtpWMPji4RTFR3Rgon0vzBlS11e2R8Zg,37925
13
- knit_graphs/Loop.py,sha256=zp1ZiVRFSCPL2CnXNxgwNPv7WrcuqFRe3S_ZATxEBAo,5781
14
- knit_graphs/Pull_Direction.py,sha256=8xRLN-j7V1mExgmt3YjcJcTDa5rLedA2bF4wI8gd-DE,2334
15
- knit_graphs/Yarn.py,sha256=wNOmj15dnSA56Qw2D5ksgbmQqug-u5kPPxKGuitQ_qI,15901
16
- knit_graphs/__init__.py,sha256=qzZAOxTqjgLkhoGnKNZwOkuYbKEyzfWKkKpKkV6lVfk,111
17
- knit_graphs/_base_classes.py,sha256=ZEv_jkUglHzkfg-0TD6oonBq7QQmA4G7jrC_A6OubpY,6401
18
- knit_graphs/artin_wale_braids/Crossing_Direction.py,sha256=71ckmEFfL0s25NJb8lfYwH2zku0uM1C5X9gGM7PYC5A,2820
19
- knit_graphs/artin_wale_braids/Loop_Braid_Graph.py,sha256=2tsE16IzcvgsIKij1JNHWah6hLOgrpXCcjb6eocbfFs,4575
20
- knit_graphs/artin_wale_braids/Wale.py,sha256=PK8IQDnTFXk5924QZYiGCqfckS62laG9_XhK7xH2zAo,7171
21
- knit_graphs/artin_wale_braids/Wale_Braid.py,sha256=Ws0QmU7s63nrBKe69acDza-r-LozDyyaKVDNxQMy10Y,2662
22
- knit_graphs/artin_wale_braids/Wale_Braid_Word.py,sha256=4YBlVMUZkqp85r46ETQSbFVS_WrT4PsWthHmFv5Ny9M,4587
23
- knit_graphs/artin_wale_braids/Wale_Group.py,sha256=HTl01PHzFhInhFJuB30OScWx7pIejmo3-HwHN4RB4V4,6868
24
- knit_graphs/artin_wale_braids/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- knit_graphs/basic_knit_graph_generators.py,sha256=_8CbtZ4M5NRp0mXXNdCNDPtIaCKEzmpAJQVNlmV5l8c,13893
26
- knit_graphs-0.0.7.dist-info/LICENSE,sha256=Oazk3oiRu5ZN7b-EdYNYh0vu-I3Av2uIPQ-9L_cZ6Oo,1070
27
- knit_graphs-0.0.7.dist-info/METADATA,sha256=YuT2TGLdupJYXAKbbC-pXi-z0fKbOelNz31STuy7tks,5188
28
- knit_graphs-0.0.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
29
- knit_graphs-0.0.7.dist-info/RECORD,,