Skip to content

Commit 20c0c50

Browse files
committed
report for week-3
created the report and filled out my progress on the project
1 parent 75046c6 commit 20c0c50

9 files changed

Lines changed: 221 additions & 2 deletions

File tree

.DS_Store

2 KB
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Python tests
2+
3+
on:
4+
push:
5+
branches: [main, week-1, week-2, week-3]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.13"
16+
17+
- name: Install package and test tools
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install -e ".[dev]"
21+
22+
- name: Run unit tests
23+
run: pytest
32 KB
Binary file not shown.

app_generated_chart.png

-146 KB
Loading
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "73620923-8165-4d80-a81a-cb768294cc6f",
6+
"metadata": {},
7+
"source": [
8+
"Week 3 Assignment: Knitting Pattern Calculator Project Report\n",
9+
"\n",
10+
"1. Project Overview\n",
11+
"Knitting a custom sweater from the top down requires translating physical body measurements into a discrete grid of stitches and rows based on a individual knitting gauge. Manual conversion often leads to structural math errors. Furthermore, knitters wanting to incorporate multi-colored intarsia or stranded motifs (\"alpha patterns\") must manually map those pixel charts onto their specific garment dimensions, which is a slow and error-prone process.\n",
12+
"\n",
13+
"This project automates both tasks. It pairs a Streamlit web interface with a specialized Python backend that accepts pixel-based alpha patterns, calculates necessary fabric grading, and automatically generates a matching color chart, text instructions, and a visual preview of the finalized piece."
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"id": "fea57056-3a79-4bde-a173-4e34421c522b",
19+
"metadata": {},
20+
"source": [
21+
"2. Software Architecture\n",
22+
"The software uses the standard Python src/ layout to isolate core business and graphical logic from the presentation layer.\n",
23+
"knitting_pattern/\n",
24+
"├── src/\n",
25+
"│ ├── knitting_pattern/\n",
26+
"│ │ ├── __init__.py # Exposes core calculation functions\n",
27+
"│ │ ├── app.py # Streamlit web application interface\n",
28+
"│ │ ├── math_engine.py # Math logic, matrix grid creation, and chart operations\n",
29+
"│ │ └── image_engine.py # Visualization logic, plotting chart and recognizing alpha patterns\n",
30+
"│ └── tests/\n",
31+
"│ ├── test_image_engine.py\n",
32+
"│ └── test_math_engine.py \n",
33+
"Stitch and Row Allocation: The engine converts user dimensions (in centimeters) to absolute integers. \n",
34+
"It uses ceiling rounding (math.ceil) since a knitter cannot execute a partial stitch. The underlying formula is:\n",
35+
"stitches = [{width (cm)} * {stitch gauge} / 10)]\n",
36+
"\n",
37+
"Grid Canvas Representation: The backend models the fabric as a two-dimensional grid (nested lists or arrays). Unoccupied background fabric is initialized to 0.\n",
38+
"Alpha Pattern Integration: The system reads pixel-based assets representing the alpha design. It maps these coordinates directly onto the sweater grid, reassigning target cells from background 0 to specific integer color IDs (e.g., 1, 2, 3). This acts as the layout for the color chart."
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"id": "c6508f58-97f2-4e02-ad03-a1d7d445bfcf",
44+
"metadata": {},
45+
"source": [
46+
"3. Current Implementation: Drop-Shoulder Top-Down Construction\n",
47+
"The application currently models a traditional drop-shoulder construction, worked from the top down.\n",
48+
"\n",
49+
"Back Panel Cast-On: The program calculates the back shoulder width and establishes the upper grid boundary.\n",
50+
"\n",
51+
"Short-Row Contour Carving: To create an ergonomic shoulder slope and back-neck contour, the engine calculates short-row steps. It modifies the fabric matrix by marking unknitted coordinates as dead space (-1) while keeping active channels at 0. This allows the application to accurately trace variable-row knitting before mapping the alpha motif.\n",
52+
"\n",
53+
"Straight Body Extension: Once short rows are complete, the body grid expands downward in straight, uniform columns to form the classic drop-shoulder silhouette."
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"id": "b8f45f76-aedd-47be-b76e-461a696b3812",
59+
"metadata": {},
60+
"source": [
61+
"4. Current Limitations and Future Expansion\n",
62+
"While the drop-shoulder math and base grid generation are operational, our development roadmap highlights three areas of expansion:\n",
63+
"\n",
64+
"High-Contrast Visualizations and Text Instructions\n",
65+
"Problem: The current output shows a basic matrix visualization. It works for debugging but does not generate clear, printable charts or row-by-row text patterns for the user.\n",
66+
"\n",
67+
"Solution: Upgrade the visualization component with customized, high-contrast color maps to output downloadable PDF color charts. Concurrently, write a translation loop that reads the matrix rows and outputs automated text instructions (e.g., \"Row 12: K10 Turn; Row 13: P to end of row\").\n",
68+
"\n",
69+
"Geometric Silhouette Expansion\n",
70+
"Problem: The system is limited to drop-shoulder shapes, which utilize straight armhole paths and simple rectangular panels.\n",
71+
"\n",
72+
"Solution: Expand the mathematical backend to calculate complex raglan lines and set-in sleeve caps. This requires developing dynamic decrease formulas to scale diagonal stitch lines across the grid canvas while maintaining the integrity of the centered alpha patterns."
73+
]
74+
}
75+
],
76+
"metadata": {
77+
"kernelspec": {
78+
"display_name": "Python [conda env:base] *",
79+
"language": "python",
80+
"name": "conda-base-py"
81+
},
82+
"language_info": {
83+
"codemirror_mode": {
84+
"name": "ipython",
85+
"version": 3
86+
},
87+
"file_extension": ".py",
88+
"mimetype": "text/x-python",
89+
"name": "python",
90+
"nbconvert_exporter": "python",
91+
"pygments_lexer": "ipython3",
92+
"version": "3.13.9"
93+
}
94+
},
95+
"nbformat": 4,
96+
"nbformat_minor": 5
97+
}

docs/report.ipynb

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "73620923-8165-4d80-a81a-cb768294cc6f",
6+
"metadata": {},
7+
"source": [
8+
"Week 3 Assignment: Knitting Pattern Calculator Project Report\n",
9+
"\n",
10+
"1. Project Overview\n",
11+
"Knitting a custom sweater from the top down requires translating physical body measurements into a discrete grid of stitches and rows based on a individual knitting gauge. Manual conversion often leads to structural math errors. Furthermore, knitters wanting to incorporate multi-colored intarsia or stranded motifs (\"alpha patterns\") must manually map those pixel charts onto their specific garment dimensions, which is a slow and error-prone process.\n",
12+
"\n",
13+
"This project automates both tasks. It pairs a Streamlit web interface with a specialized Python backend that accepts pixel-based alpha patterns, calculates necessary fabric grading, and automatically generates a matching color chart, text instructions, and a visual preview of the finalized piece."
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"id": "fea57056-3a79-4bde-a173-4e34421c522b",
19+
"metadata": {},
20+
"source": [
21+
"2. Software Architecture\n",
22+
"The software uses the standard Python src/ layout to isolate core business and graphical logic from the presentation layer.\n",
23+
"knitting_pattern/\n",
24+
"├── src/\n",
25+
"│ ├── knitting_pattern/\n",
26+
"│ │ ├── __init__.py # Exposes core calculation functions\n",
27+
"│ │ ├── app.py # Streamlit web application interface\n",
28+
"│ │ ├── math_engine.py # Math logic, matrix grid creation, and chart operations\n",
29+
"│ │ └── image_engine.py # Visualization logic, plotting chart and recognizing alpha patterns\n",
30+
"│ └── tests/\n",
31+
"│ ├── test_image_engine.py\n",
32+
"│ └── test_math_engine.py \n",
33+
"Stitch and Row Allocation: The engine converts user dimensions (in centimeters) to absolute integers. \n",
34+
"It uses ceiling rounding (math.ceil) since a knitter cannot execute a partial stitch. The underlying formula is:\n",
35+
"stitches = [{width (cm)} * {stitch gauge} / 10)]\n",
36+
"\n",
37+
"Grid Canvas Representation: The backend models the fabric as a two-dimensional grid (nested lists or arrays). Unoccupied background fabric is initialized to 0.\n",
38+
"Alpha Pattern Integration: The system reads pixel-based assets representing the alpha design. It maps these coordinates directly onto the sweater grid, reassigning target cells from background 0 to specific integer color IDs (e.g., 1, 2, 3). This acts as the layout for the color chart."
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"id": "c6508f58-97f2-4e02-ad03-a1d7d445bfcf",
44+
"metadata": {},
45+
"source": [
46+
"3. Current Implementation: Drop-Shoulder Top-Down Construction\n",
47+
"The application currently models a traditional drop-shoulder construction, worked from the top down.\n",
48+
"\n",
49+
"Back Panel Cast-On: The program calculates the back shoulder width and establishes the upper grid boundary.\n",
50+
"\n",
51+
"Short-Row Contour Carving: To create an ergonomic shoulder slope and back-neck contour, the engine calculates short-row steps. It modifies the fabric matrix by marking unknitted coordinates as dead space (-1) while keeping active channels at 0. This allows the application to accurately trace variable-row knitting before mapping the alpha motif.\n",
52+
"\n",
53+
"Straight Body Extension: Once short rows are complete, the body grid expands downward in straight, uniform columns to form the classic drop-shoulder silhouette."
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"id": "b8f45f76-aedd-47be-b76e-461a696b3812",
59+
"metadata": {},
60+
"source": [
61+
"4. Current Limitations and Future Expansion\n",
62+
"While the drop-shoulder math and base grid generation are operational, our development roadmap highlights three areas of expansion:\n",
63+
"\n",
64+
"High-Contrast Visualizations and Text Instructions\n",
65+
"Problem: The current output shows a basic matrix visualization. It works for debugging but does not generate clear, printable charts or row-by-row text patterns for the user.\n",
66+
"\n",
67+
"Solution: Upgrade the visualization component with customized, high-contrast color maps to output downloadable PDF color charts. Concurrently, write a translation loop that reads the matrix rows and outputs automated text instructions (e.g., \"Row 12: K10 Turn; Row 13: P to end of row\").\n",
68+
"\n",
69+
"Geometric Silhouette Expansion\n",
70+
"Problem: The system is limited to drop-shoulder shapes, which utilize straight armhole paths and simple rectangular panels.\n",
71+
"\n",
72+
"Solution: Expand the mathematical backend to calculate complex raglan lines and set-in sleeve caps. This requires developing dynamic decrease formulas to scale diagonal stitch lines across the grid canvas while maintaining the integrity of the centered alpha patterns."
73+
]
74+
}
75+
],
76+
"metadata": {
77+
"kernelspec": {
78+
"display_name": "Python [conda env:base] *",
79+
"language": "python",
80+
"name": "conda-base-py"
81+
},
82+
"language_info": {
83+
"codemirror_mode": {
84+
"name": "ipython",
85+
"version": 3
86+
},
87+
"file_extension": ".py",
88+
"mimetype": "text/x-python",
89+
"name": "python",
90+
"nbconvert_exporter": "python",
91+
"pygments_lexer": "ipython3",
92+
"version": "3.13.9"
93+
}
94+
},
95+
"nbformat": 4,
96+
"nbformat_minor": 5
97+
}

src/.DS_Store

0 Bytes
Binary file not shown.

src/knitting_pattern/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
# ==========================================
2525
# IMPORTING YOUR BACKEND ENGINES
2626
# ==========================================
27+
2728
from knitting_pattern.math_engine import (
2829
calculate_stitches, calculate_rows, calculate_garment_dimensions,
29-
calculate_top_down_shoulder_shaping, generate_panel_grid, apply_top_down_mountains_to_grid,
30-
calculate_back_neck_shaping, apply_back_short_rows_to_grid
30+
calculate_top_down_shoulder_shaping, generate_panel_grid,
31+
apply_top_down_mountains_to_grid, calculate_back_neck_shaping,
32+
# (and any other functions you have)
3133
)
3234
from knitting_pattern.image_engine import (
3335
get_hardcoded_heart, scale_pattern_matrix_integer, overlay_pattern_on_grid, generate_chart_image

src/tests/test_example.py

Whitespace-only changes.

0 commit comments

Comments
 (0)