knit-graphs 0.0.7__tar.gz → 0.0.9__tar.gz
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.
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/PKG-INFO +5 -5
- knit_graphs-0.0.9/docs/source/api/knit_graphs.Course.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.Knit_Graph.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.Knit_Graph_Visualizer.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.Loop.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.Pull_Direction.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.Yarn.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.Crossing_Direction.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.Loop_Braid_Graph.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.Wale.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.Wale_Braid.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.Wale_Braid_Word.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.Wale_Group.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.artin_wale_braids.rst +23 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.basic_knit_graph_generators.rst +7 -0
- knit_graphs-0.0.9/docs/source/api/knit_graphs.rst +32 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/pyproject.toml +6 -55
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/Course.py +24 -5
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/Knit_Graph.py +37 -14
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/Knit_Graph_Visualizer.py +188 -193
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/Loop.py +62 -12
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/Yarn.py +12 -9
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/Wale.py +3 -4
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/Wale_Group.py +7 -5
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/basic_knit_graph_generators.py +24 -75
- knit_graphs-0.0.7/docs/source/api/knit_graphs.artin_wale_braids.rst +0 -58
- knit_graphs-0.0.7/docs/source/api/knit_graphs.rst +0 -74
- knit_graphs-0.0.7/src/knit_graphs/_base_classes.py +0 -173
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/LICENSE +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/README.md +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/docs/Makefile +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/docs/make.bat +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/docs/source/conf.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/docs/source/index.rst +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/docs/source/installation.rst +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/Pull_Direction.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/__init__.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/Crossing_Direction.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/Loop_Braid_Graph.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/Wale_Braid.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/Wale_Braid_Word.py +0 -0
- {knit_graphs-0.0.7 → knit_graphs-0.0.9}/src/knit_graphs/artin_wale_braids/__init__.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: knit-graphs
|
|
3
|
-
Version: 0.0.
|
|
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-
|
|
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-
|
|
26
|
-
Project-URL: Repository, https://github.com/mhofmann-Khoury/
|
|
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,23 @@
|
|
|
1
|
+
knit\_graphs.artin\_wale\_braids package
|
|
2
|
+
========================================
|
|
3
|
+
|
|
4
|
+
Submodules
|
|
5
|
+
----------
|
|
6
|
+
|
|
7
|
+
.. toctree::
|
|
8
|
+
:maxdepth: 4
|
|
9
|
+
|
|
10
|
+
knit_graphs.artin_wale_braids.Crossing_Direction
|
|
11
|
+
knit_graphs.artin_wale_braids.Loop_Braid_Graph
|
|
12
|
+
knit_graphs.artin_wale_braids.Wale
|
|
13
|
+
knit_graphs.artin_wale_braids.Wale_Braid
|
|
14
|
+
knit_graphs.artin_wale_braids.Wale_Braid_Word
|
|
15
|
+
knit_graphs.artin_wale_braids.Wale_Group
|
|
16
|
+
|
|
17
|
+
Module contents
|
|
18
|
+
---------------
|
|
19
|
+
|
|
20
|
+
.. automodule:: knit_graphs.artin_wale_braids
|
|
21
|
+
:members:
|
|
22
|
+
:undoc-members:
|
|
23
|
+
:show-inheritance:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
knit\_graphs package
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
Subpackages
|
|
5
|
+
-----------
|
|
6
|
+
|
|
7
|
+
.. toctree::
|
|
8
|
+
:maxdepth: 4
|
|
9
|
+
|
|
10
|
+
knit_graphs.artin_wale_braids
|
|
11
|
+
|
|
12
|
+
Submodules
|
|
13
|
+
----------
|
|
14
|
+
|
|
15
|
+
.. toctree::
|
|
16
|
+
:maxdepth: 4
|
|
17
|
+
|
|
18
|
+
knit_graphs.Course
|
|
19
|
+
knit_graphs.Knit_Graph
|
|
20
|
+
knit_graphs.Knit_Graph_Visualizer
|
|
21
|
+
knit_graphs.Loop
|
|
22
|
+
knit_graphs.Pull_Direction
|
|
23
|
+
knit_graphs.Yarn
|
|
24
|
+
knit_graphs.basic_knit_graph_generators
|
|
25
|
+
|
|
26
|
+
Module contents
|
|
27
|
+
---------------
|
|
28
|
+
|
|
29
|
+
.. automodule:: knit_graphs
|
|
30
|
+
:members:
|
|
31
|
+
:undoc-members:
|
|
32
|
+
:show-inheritance:
|
|
@@ -12,15 +12,15 @@ build-backend = "poetry.core.masonry.api" # Use Poetry's build system
|
|
|
12
12
|
# All the information about your project that will appear on PyPI
|
|
13
13
|
[tool.poetry]
|
|
14
14
|
name = "knit-graphs"
|
|
15
|
-
version = "0.0.
|
|
15
|
+
version = "0.0.9"
|
|
16
16
|
description = "A graph representation of knitted structures where each loop is a node and edges represent yarn and stitch relationships."
|
|
17
17
|
authors = ["Megan Hofmann <m.hofmann@northeastern.edu>"]
|
|
18
18
|
maintainers = ["Megan Hofmann <m.hofmann@northeastern.edu>"]
|
|
19
19
|
license = "MIT" # License type (shows up on PyPI)
|
|
20
20
|
readme = "README.md" # File to use as long description on PyPI
|
|
21
|
-
homepage = "https://mhofmann-
|
|
22
|
-
repository = "https://github.com/mhofmann-Khoury/
|
|
23
|
-
documentation = "https://mhofmann-
|
|
21
|
+
homepage = "https://mhofmann-khoury.github.io/knit_graph/"
|
|
22
|
+
repository = "https://github.com/mhofmann-Khoury/knit_graph/"
|
|
23
|
+
documentation = "https://mhofmann-khoury.github.io/knit_graph/"
|
|
24
24
|
keywords = ["ACT Lab", "Northeastern University", "knit", "machine knit", "fabrication", "textile"]
|
|
25
25
|
classifiers = [ # PyPI classifiers for categorization
|
|
26
26
|
"Development Status :: 3 - Alpha", # Update as project matures (Alpha -> Beta -> Production/Stable)
|
|
@@ -79,7 +79,7 @@ exclude = [
|
|
|
79
79
|
[tool.poetry.dependencies]
|
|
80
80
|
python = ">=3.11,<3.14"
|
|
81
81
|
networkx = ">=3.5"
|
|
82
|
-
plotly = "
|
|
82
|
+
plotly = "^6.3.0"
|
|
83
83
|
# Examples:
|
|
84
84
|
# requests = "^2.31.0" # For HTTP requests
|
|
85
85
|
# pydantic = "^2.0.0" # For data validation
|
|
@@ -102,6 +102,7 @@ plotly = ">=6.3.0"
|
|
|
102
102
|
# =============================================================================
|
|
103
103
|
# These packages are only needed during development and testing
|
|
104
104
|
|
|
105
|
+
|
|
105
106
|
[tool.poetry.group.dev.dependencies]
|
|
106
107
|
importlib-resources = ">=6.5.2"
|
|
107
108
|
|
|
@@ -135,21 +136,12 @@ sphinx-autoapi = "^3.0.0" # Automatically generates API documentation
|
|
|
135
136
|
# -------------------------------------------------------------------------
|
|
136
137
|
# DEVELOPMENT TOOLS AND UTILITIES
|
|
137
138
|
# -------------------------------------------------------------------------
|
|
138
|
-
ipython = "^8.14.0" # Enhanced interactive Python shell for debugging
|
|
139
|
-
rich = "^13.5.0" # Beautiful terminal output and debugging
|
|
140
139
|
tox = "^4.11.0" # Test across multiple Python versions locally
|
|
141
140
|
|
|
142
141
|
# -------------------------------------------------------------------------
|
|
143
142
|
# RELEASE AND BUILD TOOLS
|
|
144
143
|
# -------------------------------------------------------------------------
|
|
145
144
|
build = "^0.10.0" # PEP 517 build tool (for creating distributions)
|
|
146
|
-
bump2version = "^1.0.0" # Automated version bumping tool
|
|
147
|
-
|
|
148
|
-
# -------------------------------------------------------------------------
|
|
149
|
-
# PLATFORM-SPECIFIC DEPENDENCIES
|
|
150
|
-
# -------------------------------------------------------------------------
|
|
151
|
-
# Only install on Windows systems (for colored terminal output)
|
|
152
|
-
colorama = {version = "^0.4.6", markers = "sys_platform == 'win32'"}
|
|
153
145
|
|
|
154
146
|
# =============================================================================
|
|
155
147
|
# DOCUMENTATION-SPECIFIC DEPENDENCIES
|
|
@@ -243,12 +235,6 @@ check_untyped_defs = false # Don't type-check untyped test methods
|
|
|
243
235
|
warn_return_any = false # Don't warn about returning 'Any' in tests
|
|
244
236
|
warn_unused_ignores = false # Don't warn about unused type ignores in tests
|
|
245
237
|
|
|
246
|
-
# Add overrides for specific third-party libraries that may have type issues
|
|
247
|
-
# Example:
|
|
248
|
-
# [[tool.mypy.overrides]]
|
|
249
|
-
# module = ["problematic_library.*"]
|
|
250
|
-
# ignore_errors = true
|
|
251
|
-
|
|
252
238
|
# =============================================================================
|
|
253
239
|
# UNITTEST TESTING FRAMEWORK CONFIGURATION
|
|
254
240
|
# =============================================================================
|
|
@@ -277,8 +263,6 @@ omit = [ # Files to exclude from coverage measurement
|
|
|
277
263
|
"*/__pycache__/*", # Ignore Python cache files
|
|
278
264
|
"*/site-packages/*", # Ignore installed packages
|
|
279
265
|
"*/venv/*", # Ignore virtual environment
|
|
280
|
-
"setup.py", # Ignore setup script (if present)
|
|
281
|
-
"update_project_config.py"
|
|
282
266
|
]
|
|
283
267
|
branch = true # Enable branch coverage (more comprehensive)
|
|
284
268
|
|
|
@@ -301,39 +285,6 @@ show_missing = true # Show which lines are missing coverage
|
|
|
301
285
|
skip_covered = false # Show covered files in report
|
|
302
286
|
skip_empty = true # Skip empty files in report
|
|
303
287
|
|
|
304
|
-
# Coverage output formats
|
|
305
|
-
[tool.coverage.html]
|
|
306
|
-
directory = "htmlcov" # Directory for HTML coverage reports
|
|
307
|
-
|
|
308
|
-
[tool.coverage.xml]
|
|
309
|
-
output = "coverage.xml" # XML coverage report (used by CI/CD tools)
|
|
310
|
-
|
|
311
|
-
# =============================================================================
|
|
312
|
-
# VERSION BUMPING CONFIGURATION
|
|
313
|
-
# =============================================================================
|
|
314
|
-
# Configuration for bump2version tool to automate version updates
|
|
315
|
-
[tool.bumpversion]
|
|
316
|
-
current_version = "0.0.7" # Keep this in sync with tool.poetry.version
|
|
317
|
-
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
318
|
-
serialize = ["{major}.{minor}.{patch}"]
|
|
319
|
-
search = "{current_version}"
|
|
320
|
-
replace = "{new_version}"
|
|
321
|
-
commit = true # Automatically commit version changes
|
|
322
|
-
tag = true # Automatically create git tags
|
|
323
|
-
sign_tags = false # Set to true if you want to sign tags with GPG
|
|
324
|
-
|
|
325
|
-
# Files where version numbers should be updated
|
|
326
|
-
[[tool.bumpversion.files]]
|
|
327
|
-
filename = "pyproject.toml"
|
|
328
|
-
search = 'version = "{current_version}"'
|
|
329
|
-
replace = 'version = "{new_version}"'
|
|
330
|
-
|
|
331
|
-
# Add other files that contain version numbers
|
|
332
|
-
# [[tool.bumpversion.files]]
|
|
333
|
-
# filename = "src/your_project_name/__init__.py"
|
|
334
|
-
# search = '__version__ = "{current_version}"'
|
|
335
|
-
# replace = '__version__ = "{new_version}"'
|
|
336
|
-
|
|
337
288
|
# =============================================================================
|
|
338
289
|
# WHEEL BUILDING CONFIGURATION
|
|
339
290
|
# =============================================================================
|
|
@@ -4,11 +4,13 @@ This module contains the Course class which represents a horizontal row of loops
|
|
|
4
4
|
"""
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
-
from typing import Iterator, cast
|
|
7
|
+
from typing import TYPE_CHECKING, Iterator, cast
|
|
8
8
|
|
|
9
|
-
from knit_graphs._base_classes import _Base_Knit_Graph
|
|
10
9
|
from knit_graphs.Loop import Loop
|
|
11
10
|
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from knit_graphs.Knit_Graph import Knit_Graph
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
class Course:
|
|
14
16
|
"""Course object for organizing loops into knitting rows.
|
|
@@ -17,15 +19,32 @@ class Course:
|
|
|
17
19
|
It maintains an ordered list of loops and provides methods for analyzing the structure and relationships between courses in the knitted fabric.
|
|
18
20
|
"""
|
|
19
21
|
|
|
20
|
-
def __init__(self,
|
|
22
|
+
def __init__(self, knit_graph: Knit_Graph) -> None:
|
|
21
23
|
"""Initialize an empty course associated with a knit graph.
|
|
22
24
|
|
|
23
25
|
Args:
|
|
24
|
-
|
|
26
|
+
knit_graph (Knit_Graph): The knit graph that this course belongs to.
|
|
25
27
|
"""
|
|
26
|
-
self.
|
|
28
|
+
self._knit_graph: Knit_Graph = knit_graph
|
|
29
|
+
self._loops_in_order: list[Loop] = []
|
|
27
30
|
self._loop_set: set[Loop] = set()
|
|
28
31
|
|
|
32
|
+
@property
|
|
33
|
+
def loops_in_order(self) -> list[Loop]:
|
|
34
|
+
"""
|
|
35
|
+
Returns:
|
|
36
|
+
list[Loop]: The list of loops in this course.
|
|
37
|
+
"""
|
|
38
|
+
return self._loops_in_order
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def knit_graph(self) -> Knit_Graph:
|
|
42
|
+
"""
|
|
43
|
+
Returns:
|
|
44
|
+
Knit_Graph: The knit graph that this course belongs to.
|
|
45
|
+
"""
|
|
46
|
+
return self._knit_graph
|
|
47
|
+
|
|
29
48
|
def add_loop(self, loop: Loop, index: int | None = None) -> None:
|
|
30
49
|
"""Add a loop to the course at the specified index or at the end.
|
|
31
50
|
|
|
@@ -5,9 +5,10 @@ It manages the relationships between loops, yarns, and structural elements like
|
|
|
5
5
|
"""
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
from typing import Any, cast
|
|
8
|
+
from typing import Any, Iterator, cast
|
|
9
|
+
|
|
10
|
+
from networkx import DiGraph
|
|
9
11
|
|
|
10
|
-
from knit_graphs._base_classes import _Base_Knit_Graph
|
|
11
12
|
from knit_graphs.artin_wale_braids.Crossing_Direction import Crossing_Direction
|
|
12
13
|
from knit_graphs.artin_wale_braids.Loop_Braid_Graph import Loop_Braid_Graph
|
|
13
14
|
from knit_graphs.artin_wale_braids.Wale import Wale
|
|
@@ -17,8 +18,11 @@ from knit_graphs.Loop import Loop
|
|
|
17
18
|
from knit_graphs.Pull_Direction import Pull_Direction
|
|
18
19
|
from knit_graphs.Yarn import Yarn
|
|
19
20
|
|
|
21
|
+
# from knit_graphs.artin_wale_braids.Wale import Wale
|
|
22
|
+
# from knit_graphs.artin_wale_braids.Wale_Group import Wale_Group
|
|
23
|
+
|
|
20
24
|
|
|
21
|
-
class Knit_Graph
|
|
25
|
+
class Knit_Graph:
|
|
22
26
|
"""A representation of knitted structures as connections between loops on yarns.
|
|
23
27
|
|
|
24
28
|
The Knit_Graph class is the main data structure for representing knitted fabrics.
|
|
@@ -28,7 +32,7 @@ class Knit_Graph(_Base_Knit_Graph):
|
|
|
28
32
|
|
|
29
33
|
def __init__(self) -> None:
|
|
30
34
|
"""Initialize an empty knit graph with no loops or yarns."""
|
|
31
|
-
|
|
35
|
+
self.stitch_graph: DiGraph = DiGraph()
|
|
32
36
|
self.braid_graph: Loop_Braid_Graph = Loop_Braid_Graph()
|
|
33
37
|
self._last_loop: None | Loop = None
|
|
34
38
|
self.yarns: set[Yarn] = set()
|
|
@@ -69,7 +73,7 @@ class Knit_Graph(_Base_Knit_Graph):
|
|
|
69
73
|
"""
|
|
70
74
|
self.stitch_graph.add_node(loop)
|
|
71
75
|
if loop.yarn not in self.yarns:
|
|
72
|
-
self.add_yarn(
|
|
76
|
+
self.add_yarn(loop.yarn)
|
|
73
77
|
if self._last_loop is None or loop > self._last_loop:
|
|
74
78
|
self._last_loop = loop
|
|
75
79
|
|
|
@@ -129,12 +133,14 @@ class Knit_Graph(_Base_Knit_Graph):
|
|
|
129
133
|
list[Wale]: The set of wales that end at this loop. Only returns multiple wales if this loop is a child of a decrease stitch.
|
|
130
134
|
"""
|
|
131
135
|
wales = []
|
|
132
|
-
|
|
136
|
+
if len(last_loop.parent_loops) == 0:
|
|
137
|
+
return [Wale(last_loop)]
|
|
138
|
+
for top_stitch_parent in last_loop.parent_loops:
|
|
133
139
|
wale = Wale(last_loop)
|
|
134
140
|
wale.add_loop_to_beginning(top_stitch_parent, cast(Pull_Direction, self.get_pull_direction(top_stitch_parent, last_loop)))
|
|
135
141
|
cur_loop = top_stitch_parent
|
|
136
142
|
while len(cur_loop.parent_loops) == 1: # stop at split for decrease or start of wale
|
|
137
|
-
cur_loop =
|
|
143
|
+
cur_loop = cur_loop.parent_loops[0]
|
|
138
144
|
wale.add_loop_to_beginning(cur_loop, cast(Pull_Direction, self.get_pull_direction(cur_loop, cast(Loop, wale.first_loop))))
|
|
139
145
|
wales.append(wale)
|
|
140
146
|
return wales
|
|
@@ -148,8 +154,8 @@ class Knit_Graph(_Base_Knit_Graph):
|
|
|
148
154
|
"""
|
|
149
155
|
courses = []
|
|
150
156
|
course = Course(self)
|
|
151
|
-
for loop in
|
|
152
|
-
for parent in
|
|
157
|
+
for loop in self.sorted_loops():
|
|
158
|
+
for parent in loop.parent_loops:
|
|
153
159
|
if parent in course: # start a new course
|
|
154
160
|
courses.append(course)
|
|
155
161
|
course = Course(self)
|
|
@@ -165,21 +171,38 @@ class Knit_Graph(_Base_Knit_Graph):
|
|
|
165
171
|
dict[Loop, Wale_Group]: Dictionary mapping terminal loops to the wale groups they terminate. Each wale group represents a collection of wales that end at the same terminal loop.
|
|
166
172
|
"""
|
|
167
173
|
wale_groups = {}
|
|
168
|
-
for loop in self
|
|
174
|
+
for loop in self:
|
|
169
175
|
if self.is_terminal_loop(loop):
|
|
170
176
|
wale_groups.update({loop: Wale_Group(wale, self) for wale in self.get_wales_ending_with_loop(loop)})
|
|
171
177
|
return wale_groups
|
|
172
178
|
|
|
173
|
-
def __contains__(self, item: Loop) -> bool:
|
|
179
|
+
def __contains__(self, item: Loop | tuple[Loop, Loop]) -> bool:
|
|
174
180
|
"""Check if a loop is contained in the knit graph.
|
|
175
181
|
|
|
176
182
|
Args:
|
|
177
|
-
item (Loop): The loop being checked for in the graph.
|
|
183
|
+
item (Loop | tuple[Loop, Loop]): The loop being checked for in the graph or the parent-child stitch edge to check for in the knit graph.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
bool: True if the given loop or stitch edge is in the graph, False otherwise.
|
|
187
|
+
"""
|
|
188
|
+
if isinstance(item, Loop):
|
|
189
|
+
return bool(self.stitch_graph.has_node(item))
|
|
190
|
+
else:
|
|
191
|
+
return bool(self.stitch_graph.has_edge(item[0], item[1]))
|
|
178
192
|
|
|
193
|
+
def __iter__(self) -> Iterator[Loop]:
|
|
194
|
+
"""
|
|
195
|
+
Returns:
|
|
196
|
+
Iterator[Loop]: An iterator over all loops in the knit graph.
|
|
197
|
+
"""
|
|
198
|
+
return cast(Iterator[Loop], iter(self.stitch_graph.nodes))
|
|
199
|
+
|
|
200
|
+
def sorted_loops(self) -> list[Loop]:
|
|
201
|
+
"""
|
|
179
202
|
Returns:
|
|
180
|
-
|
|
203
|
+
list[Loop]: The list of loops in the stitch graph sorted from the earliest formed loop to the latest formed loop.
|
|
181
204
|
"""
|
|
182
|
-
return
|
|
205
|
+
return sorted(list(self.stitch_graph.nodes))
|
|
183
206
|
|
|
184
207
|
def get_pull_direction(self, parent: Loop, child: Loop) -> Pull_Direction | None:
|
|
185
208
|
"""Get the pull direction of the stitch edge between parent and child loops.
|