quality-house 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ManavA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ recursive-include examples *.json *.py
2
+ recursive-include tests *.py
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: quality-house
3
+ Version: 0.1.0
4
+ Summary: Build, score, and draw a House of Quality.
5
+ Author: Manav Agarwal
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 ManavA
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: qfd,house-of-quality,engineering,requirements
29
+ Classifier: Topic :: Scientific/Engineering :: Visualization
30
+ Requires-Python: >=3.10
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: matplotlib>=3.7
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest>=8; extra == "test"
36
+ Dynamic: license-file
37
+
38
+ # Quality House
39
+
40
+ Build a House of Quality from Python or JSON. Score engineering responses against weighted criteria, draw the matrix and correlation roof, and carry scores into the next design stage.
41
+
42
+ ## Run an example
43
+
44
+ Install the package from the project root with \`python -m pip install .\`, then run the example from the same directory.
45
+
46
+ quality-house score examples/reusable-case.json
47
+ quality-house render examples/reusable-case.json case.pdf --bars
48
+ python examples/deployment.py
49
+
50
+ Use a PDF, SVG, or PNG output filename. Add `--no-roof` to hide the roof. Cell strengths are 0 (none), 1 (weak), 3 (moderate), and 9 (strong). Bar lengths scale to the highest score. The share under each score is its fraction of the total.
51
+
52
+ ## Create and deploy a house
53
+
54
+ \`\`\`python
55
+ from quality_house import Correlation, Criterion, House, Response, render
56
+
57
+ house = House(
58
+ criteria=[Criterion("open", "Easy to open", 5), Criterion("clean", "Easy to clean", 3)],
59
+ responses=[Response("latch", "Latch force"), Response("seal", "Seal compression")],
60
+ matrix=[[9, 1], [1, 9]],
61
+ correlations=[Correlation("latch", "seal", -1, "More compression raises opening force.")],
62
+ )
63
+ assert house.scores == (48, 32)
64
+
65
+ parts = house.deploy([Response("spring", "Latch spring")], [[1], [3]])
66
+ assert parts.scores == (144,)
67
+ render(house, bars=True).savefig("case.pdf")
68
+ \`\`\`
69
+
70
+ The score of a column is the sum of each relationship strength multiplied by its row weight. A deployment uses the exact previous scores in response order. To build a second study from the same original needs, pass \`house.criteria\` to its constructor.
71
+
72
+ ## Inputs and revisions
73
+
74
+ - Use \`House.from_relationships(criteria, responses, relations)\` for sparse entries. Each entry contains a criterion ID, a response ID, and a strength. Omitted entries are zero.
75
+ - Give each criterion and response an ID that stays stable when its label or position changes. \`compare(before, after)\` reports additions, removals, definition changes, and changed relationships and correlations.
76
+ - Supply a revision to \`render(after, revision=compare(before, after))\` or use \`quality-house render after.json after.pdf --compare-with before.json\` to outline changed cells.
77
+ - Add \`Benchmark(label, ratings)\` for an external reference with one rating per criterion. Use \`None\` when a rating is unavailable. Benchmark ratings and roof signs stay separate from weighted scoring.
78
+ - Load a JSON file with \`load(path)\` and save a definition with \`save(house, path)\`. Use \`quality-house diff before.json after.json\` to inspect the model changes as JSON.
79
+
80
+ The package includes Python and JSON examples. The [example JSON](examples/reusable-case.json) shows targets, directions, correlations and benchmarks together.
@@ -0,0 +1,43 @@
1
+ # Quality House
2
+
3
+ Build a House of Quality from Python or JSON. Score engineering responses against weighted criteria, draw the matrix and correlation roof, and carry scores into the next design stage.
4
+
5
+ ## Run an example
6
+
7
+ Install the package from the project root with \`python -m pip install .\`, then run the example from the same directory.
8
+
9
+ quality-house score examples/reusable-case.json
10
+ quality-house render examples/reusable-case.json case.pdf --bars
11
+ python examples/deployment.py
12
+
13
+ Use a PDF, SVG, or PNG output filename. Add `--no-roof` to hide the roof. Cell strengths are 0 (none), 1 (weak), 3 (moderate), and 9 (strong). Bar lengths scale to the highest score. The share under each score is its fraction of the total.
14
+
15
+ ## Create and deploy a house
16
+
17
+ \`\`\`python
18
+ from quality_house import Correlation, Criterion, House, Response, render
19
+
20
+ house = House(
21
+ criteria=[Criterion("open", "Easy to open", 5), Criterion("clean", "Easy to clean", 3)],
22
+ responses=[Response("latch", "Latch force"), Response("seal", "Seal compression")],
23
+ matrix=[[9, 1], [1, 9]],
24
+ correlations=[Correlation("latch", "seal", -1, "More compression raises opening force.")],
25
+ )
26
+ assert house.scores == (48, 32)
27
+
28
+ parts = house.deploy([Response("spring", "Latch spring")], [[1], [3]])
29
+ assert parts.scores == (144,)
30
+ render(house, bars=True).savefig("case.pdf")
31
+ \`\`\`
32
+
33
+ The score of a column is the sum of each relationship strength multiplied by its row weight. A deployment uses the exact previous scores in response order. To build a second study from the same original needs, pass \`house.criteria\` to its constructor.
34
+
35
+ ## Inputs and revisions
36
+
37
+ - Use \`House.from_relationships(criteria, responses, relations)\` for sparse entries. Each entry contains a criterion ID, a response ID, and a strength. Omitted entries are zero.
38
+ - Give each criterion and response an ID that stays stable when its label or position changes. \`compare(before, after)\` reports additions, removals, definition changes, and changed relationships and correlations.
39
+ - Supply a revision to \`render(after, revision=compare(before, after))\` or use \`quality-house render after.json after.pdf --compare-with before.json\` to outline changed cells.
40
+ - Add \`Benchmark(label, ratings)\` for an external reference with one rating per criterion. Use \`None\` when a rating is unavailable. Benchmark ratings and roof signs stay separate from weighted scoring.
41
+ - Load a JSON file with \`load(path)\` and save a definition with \`save(house, path)\`. Use \`quality-house diff before.json after.json\` to inspect the model changes as JSON.
42
+
43
+ The package includes Python and JSON examples. The [example JSON](examples/reusable-case.json) shows targets, directions, correlations and benchmarks together.
@@ -0,0 +1,22 @@
1
+ from dataclasses import replace
2
+ from pathlib import Path
3
+
4
+ from quality_house import Correlation, Response, compare, load, render
5
+
6
+ source = Path(__file__).with_name("reusable-case.json")
7
+ first = load(source)
8
+ second = first.deploy(
9
+ [
10
+ Response("spring", "Latch spring"),
11
+ Response("gasket", "Gasket"),
12
+ Response("tray", "Insert tray"),
13
+ ],
14
+ [[9, 3, 0], [1, 9, 0], [0, 1, 9]],
15
+ correlations=[Correlation("spring", "gasket", -1)],
16
+ title="Reusable field case: measures to parts",
17
+ )
18
+ revised = first.responses[:2] + (Response("liner", "Tool-free liner removal"),)
19
+ draft = replace(first, responses=revised)
20
+ print("Revised response IDs:", compare(first, draft).changed_responses)
21
+ print("Component priorities:", second.scores)
22
+ render(second, bars=True).savefig("case-components.pdf")
@@ -0,0 +1,23 @@
1
+ {
2
+ "title": "Reusable field case",
3
+ "criteria": [
4
+ {"id": "open", "label": "Open with gloved hands", "weight": 5},
5
+ {"id": "clean", "label": "Clean after field use", "weight": 3},
6
+ {"id": "protect", "label": "Keep out rain", "weight": 4}
7
+ ],
8
+ "responses": [
9
+ {"id": "latch", "label": "Latch force", "target": "Below 10 N", "direction": "decrease"},
10
+ {"id": "seal", "label": "Seal compression", "target": "2 mm", "direction": "target"},
11
+ {"id": "liner", "label": "Liner removal", "target": "Under 30 s", "direction": "decrease"}
12
+ ],
13
+ "matrix": [
14
+ [9, 3, 0],
15
+ [1, 1, 9],
16
+ [3, 9, 0]
17
+ ],
18
+ "correlations": [
19
+ {"first": "latch", "second": "seal", "strength": -1, "note": "Higher compression can raise opening force."},
20
+ {"first": "seal", "second": "liner", "strength": 1, "note": "A removable liner exposes the seal for cleaning."}
21
+ ],
22
+ "benchmarks": [{"label": "Current case", "ratings": [3, 2, 4]}]
23
+ }
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "quality-house"
7
+ version = "0.1.0"
8
+ description = "Build, score, and draw a House of Quality."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {file = "LICENSE"}
12
+ authors = [{name = "Manav Agarwal"}]
13
+ dependencies = ["matplotlib>=3.7"]
14
+ keywords = ["qfd", "house-of-quality", "engineering", "requirements"]
15
+ classifiers = ["Topic :: Scientific/Engineering :: Visualization"]
16
+
17
+ [project.optional-dependencies]
18
+ test = ["pytest>=8"]
19
+
20
+ [project.scripts]
21
+ quality-house = "quality_house.cli:main"
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
25
+
26
+ [tool.pytest.ini_options]
27
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ """Model, score, and draw Houses of Quality."""
2
+
3
+ from .drawing import render
4
+ from .jsonio import load, save
5
+ from .model import Benchmark, Correlation, Criterion, House, Response
6
+ from .revision import CorrelationChange, RelationshipChange, Revision, compare
7
+
8
+ __all__ = [
9
+ "Benchmark",
10
+ "Correlation",
11
+ "CorrelationChange",
12
+ "Criterion",
13
+ "House",
14
+ "RelationshipChange",
15
+ "Response",
16
+ "Revision",
17
+ "compare",
18
+ "load",
19
+ "render",
20
+ "save",
21
+ ]
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,68 @@
1
+ """Command-line interface for JSON houses and rendered charts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ from dataclasses import asdict
8
+ from pathlib import Path
9
+
10
+ from .drawing import render
11
+ from .jsonio import load
12
+ from .revision import compare
13
+
14
+
15
+ def main(argv: list[str] | None = None) -> None:
16
+ parser = argparse.ArgumentParser(description="Score and draw a House of Quality.")
17
+ commands = parser.add_subparsers(dest="command", required=True)
18
+ score = commands.add_parser("score", help="print weighted scores and shares")
19
+ draw = commands.add_parser("render", help="write a diagram to PDF, SVG, or PNG")
20
+ revision = commands.add_parser("diff", help="compare two JSON houses by ID")
21
+ for command in (score, draw, revision):
22
+ command.add_argument("input", type=Path)
23
+ draw.add_argument("output", type=Path)
24
+ draw.add_argument("--bars", action="store_true", help="show weighted score bars")
25
+ draw.add_argument("--no-roof", action="store_true")
26
+ draw.add_argument(
27
+ "--compare-with", type=Path, help="outline changes from an earlier house"
28
+ )
29
+ revision.add_argument("after", type=Path)
30
+
31
+ args = parser.parse_args(argv)
32
+ try:
33
+ house = load(args.input)
34
+ if args.command == "score":
35
+ result = [
36
+ {
37
+ "id": response.id,
38
+ "label": response.label,
39
+ "score": score,
40
+ "share": share,
41
+ }
42
+ for response, score, share in zip(
43
+ house.responses, house.scores, house.shares
44
+ )
45
+ ]
46
+ print(json.dumps(result, indent=2, ensure_ascii=False, allow_nan=False))
47
+ elif args.command == "diff":
48
+ print(
49
+ json.dumps(
50
+ asdict(compare(house, load(args.after))),
51
+ indent=2,
52
+ ensure_ascii=False,
53
+ )
54
+ )
55
+ else:
56
+ if args.output.suffix.lower() not in {".pdf", ".svg", ".png"}:
57
+ raise ValueError("output filename must end in .pdf, .svg, or .png")
58
+ change = (
59
+ compare(load(args.compare_with), house) if args.compare_with else None
60
+ )
61
+ render(
62
+ house,
63
+ bars=args.bars,
64
+ show_roof=False if args.no_roof else None,
65
+ revision=change,
66
+ ).savefig(args.output, dpi=180)
67
+ except (OSError, ValueError, OverflowError) as exc:
68
+ parser.error(str(exc))
@@ -0,0 +1,229 @@
1
+ """Draw a House of Quality as a standalone Matplotlib figure."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from textwrap import fill
6
+ from matplotlib.axes import Axes
7
+ from matplotlib.figure import Figure
8
+ from matplotlib.patches import Polygon, Rectangle
9
+
10
+ from .model import House, _indices
11
+ from .revision import Revision
12
+
13
+ _INK = "#203b4f"
14
+ _GRID = "#a7b7bf"
15
+ _STRENGTHS = {0: "#ffffff", 1: "#f2f5f6", 3: "#e2edf2", 9: "#c9e0ec"}
16
+ _DIRECTIONS = {"increase": "↑", "decrease": "↓", "target": "◎", "": ""}
17
+
18
+
19
+ def render(
20
+ house: House,
21
+ *,
22
+ bars: bool = False,
23
+ show_roof: bool | None = None,
24
+ revision: Revision | None = None,
25
+ ) -> Figure:
26
+ """Render scores, an optional correlation roof, and any benchmark profiles.
27
+
28
+ Bars are proportional to the largest score in this house. Pass a revision
29
+ from compare() to outline changed cells and newly added rows and columns.
30
+ """
31
+ roof = bool(house.correlations) if show_roof is None else show_roof
32
+ cols = len(house.responses)
33
+ row_labels = [fill(item.label, width=28) for item in house.criteria]
34
+ headers = [fill(item.label, width=14) for item in house.responses]
35
+ targets = [fill(item.target, width=14) for item in house.responses]
36
+ benchmark_labels = [fill(item.label, width=13) for item in house.benchmarks]
37
+ heights = [max(0.30, 0.16 * len(label.splitlines()) + 0.11) for label in row_labels]
38
+ roof_height = (cols - 1) * 0.235 + 0.09 if roof and cols > 1 else 0
39
+ header_height = (
40
+ 0.17 * (max(len(i.splitlines()) for i in headers + benchmark_labels) + 1) + 0.18
41
+ )
42
+ target_height = (
43
+ 0.17 * max(len(item.splitlines()) for item in targets) + 0.15
44
+ if any(targets)
45
+ else 0
46
+ )
47
+ left, pitch = 2.96, 0.96
48
+ bench_start = left + cols * pitch
49
+ width = bench_start + len(benchmark_labels) * pitch + 0.20
50
+ title_size = 14 if len(house.title) <= 45 else 11
51
+ title = fill(house.title, width=max(19, int(width * 10)))
52
+ title_space = 0.68 + 0.17 * (len(title.splitlines()) - 1)
53
+ table_y = title_space + roof_height + header_height
54
+ height = table_y + sum(heights) + target_height + (0.97 if bars else 0.82)
55
+ figure = Figure(figsize=(width, height), facecolor="white")
56
+ axis = figure.add_axes((0, 0, 1, 1))
57
+ axis.set(xlim=(0, width), ylim=(height, 0))
58
+ axis.axis("off")
59
+
60
+ def label(x, y, value, *, size=8, weight="normal", align="left", color=_INK):
61
+ axis.text(
62
+ x,
63
+ y,
64
+ value,
65
+ fontsize=size,
66
+ fontweight=weight,
67
+ color=color,
68
+ ha=align,
69
+ va="center",
70
+ usetex=False,
71
+ parse_math=False,
72
+ )
73
+
74
+ def box(x, y, w, h, fill_color, edge=_GRID, line=0.55):
75
+ axis.add_patch(
76
+ Rectangle(
77
+ (x, y), w, h, facecolor=fill_color, edgecolor=edge, linewidth=line
78
+ )
79
+ )
80
+
81
+ label(0.2, title_space / 2, title, size=title_size, weight="semibold")
82
+ header_y = table_y - header_height
83
+ if roof and cols > 1:
84
+ _draw_roof(axis, house, left, pitch, header_y, label)
85
+ for j, response in enumerate(house.responses):
86
+ x = left + j * pitch
87
+ marked = revision is not None and response.id in revision.added_responses
88
+ box(x, header_y, pitch, header_height, "#e5f2eb" if marked else "#e3edf3")
89
+ label(
90
+ x + pitch / 2,
91
+ header_y + header_height / 2,
92
+ headers[j] + f"\n{_DIRECTIONS[response.direction]}",
93
+ weight="semibold",
94
+ align="center",
95
+ )
96
+ for j, header in enumerate(benchmark_labels):
97
+ x = bench_start + j * pitch
98
+ box(x, header_y, pitch, header_height, "#ebeff2")
99
+ label(
100
+ x + pitch / 2,
101
+ header_y + header_height / 2,
102
+ header,
103
+ weight="semibold",
104
+ align="center",
105
+ )
106
+ label(0.22, header_y + header_height / 2, "Criterion", weight="semibold")
107
+ label(
108
+ left - 0.32,
109
+ header_y + header_height / 2,
110
+ "Weight",
111
+ weight="semibold",
112
+ align="center",
113
+ )
114
+
115
+ altered = (
116
+ {(c.criterion_id, c.response_id) for c in revision.relationships}
117
+ if revision
118
+ else set()
119
+ )
120
+ y = table_y
121
+ for i, (criterion, row, row_height) in enumerate(
122
+ zip(house.criteria, house.matrix, heights)
123
+ ):
124
+ mark = revision is not None and criterion.id in revision.added_criteria
125
+ if mark:
126
+ box(0.12, y, left - 0.12, row_height, "#e5f2eb", edge="none")
127
+ label(0.22, y + row_height / 2, row_labels[i])
128
+ label(left - 0.32, y + row_height / 2, f"{criterion.weight:g}", align="center")
129
+ for j, (response, value) in enumerate(zip(house.responses, row)):
130
+ x = left + j * pitch
131
+ changed = (criterion.id, response.id) in altered
132
+ box(
133
+ x,
134
+ y,
135
+ pitch,
136
+ row_height,
137
+ _STRENGTHS[value],
138
+ "#96632d" if changed else _GRID,
139
+ 1.6 if changed else 0.55,
140
+ )
141
+ label(x + pitch / 2, y + row_height / 2, str(value), align="center")
142
+ for j, benchmark in enumerate(house.benchmarks):
143
+ x = bench_start + j * pitch
144
+ box(x, y, pitch, row_height, "#f8fafb")
145
+ score = benchmark.ratings[i]
146
+ label(
147
+ x + pitch / 2,
148
+ y + row_height / 2,
149
+ "—" if score is None else f"{score:g}",
150
+ align="center",
151
+ )
152
+ y += row_height
153
+
154
+ if target_height:
155
+ label(0.22, y + target_height / 2, "Target", weight="semibold")
156
+ for j, target in enumerate(targets):
157
+ label(
158
+ left + (j + 0.5) * pitch, y + target_height / 2, target, align="center"
159
+ )
160
+ y += target_height
161
+ label(0.22, y + 0.19, "Weighted score", weight="semibold")
162
+ label(0.22, y + 0.42, "Share of score")
163
+ scores = house.scores
164
+ maximum = max(scores)
165
+ for j, (score, share) in enumerate(zip(scores, house.shares)):
166
+ x = left + j * pitch
167
+ label(
168
+ x + pitch / 2, y + 0.19, f"{score:,.6g}", weight="semibold", align="center"
169
+ )
170
+ label(x + pitch / 2, y + 0.42, f"{share:.2%}", align="center")
171
+ if bars and maximum:
172
+ box(x + 0.15, y + 0.58, pitch - 0.30, 0.06, "#e0e9ee", edge="none")
173
+ box(
174
+ x + 0.15,
175
+ y + 0.58,
176
+ (pitch - 0.30) * score / maximum,
177
+ 0.06,
178
+ "#366c85",
179
+ edge="none",
180
+ )
181
+ legend = "9 strong 3 moderate 1 weak 0 none"
182
+ if roof and cols > 1:
183
+ legend += " | Roof: + reinforces − conflicts"
184
+ label(0.22, height - 0.15, legend, size=7)
185
+ return figure
186
+
187
+
188
+ def _draw_roof(
189
+ axis: Axes, house: House, left: float, pitch: float, header_y: float, label
190
+ ) -> None:
191
+ ids = _indices(house.responses)
192
+ correlations = {
193
+ tuple(
194
+ sorted((ids[correlation.first], ids[correlation.second]))
195
+ ): correlation.strength
196
+ for correlation in house.correlations
197
+ }
198
+ for i in range(len(house.responses)):
199
+ for j in range(i + 1, len(house.responses)):
200
+ x = left + (i + j + 1) * pitch / 2
201
+ y = header_y - 0.245 - (j - i - 1) * 0.235
202
+ strength = correlations.get((i, j), 0)
203
+ fill_color = (
204
+ "#dceee7" if strength > 0 else "#f4e5de" if strength < 0 else "#f9fafb"
205
+ )
206
+ axis.add_patch(
207
+ Polygon(
208
+ [
209
+ (x - pitch / 2, y),
210
+ (x, y - 0.235),
211
+ (x + pitch / 2, y),
212
+ (x, y + 0.235),
213
+ ],
214
+ closed=True,
215
+ facecolor=fill_color,
216
+ edgecolor=_GRID,
217
+ linewidth=0.5,
218
+ )
219
+ )
220
+ if strength:
221
+ sign = "+" if strength > 0 else "−"
222
+ label(
223
+ x,
224
+ y,
225
+ sign * abs(strength),
226
+ align="center",
227
+ weight="semibold",
228
+ color="#135b45" if strength > 0 else "#93402d",
229
+ )
@@ -0,0 +1,43 @@
1
+ """Read and write portable House of Quality data."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from dataclasses import asdict
7
+ from pathlib import Path
8
+
9
+ from .model import Benchmark, Correlation, Criterion, House, Response
10
+
11
+
12
+ def load(path: str | Path) -> House:
13
+ """Read a JSON house with either a dense matrix or sparse relationships."""
14
+ data = json.loads(Path(path).read_text(encoding="utf-8"))
15
+ if not isinstance(data, dict):
16
+ raise ValueError("house JSON must contain an object")
17
+ if ("matrix" in data) == ("relationships" in data):
18
+ raise ValueError("provide exactly one of matrix or relationships")
19
+ try:
20
+ criteria = tuple(Criterion(**item) for item in data["criteria"])
21
+ responses = tuple(Response(**item) for item in data["responses"])
22
+ correlations = tuple(
23
+ Correlation(**item) for item in data.get("correlations", [])
24
+ )
25
+ benchmarks = tuple(Benchmark(**item) for item in data.get("benchmarks", []))
26
+ options = {"correlations": correlations, "benchmarks": benchmarks}
27
+ if "title" in data:
28
+ options["title"] = data["title"]
29
+ if "matrix" in data:
30
+ return House(criteria, responses, data["matrix"], **options)
31
+ return House.from_relationships(
32
+ criteria, responses, data["relationships"], **options
33
+ )
34
+ except (KeyError, TypeError) as exc:
35
+ raise ValueError(f"invalid house JSON: {exc}") from exc
36
+
37
+
38
+ def save(house: House, path: str | Path) -> None:
39
+ """Write the house as UTF-8 JSON with a dense relationship matrix."""
40
+ Path(path).write_text(
41
+ json.dumps(asdict(house), ensure_ascii=False, indent=2, allow_nan=False) + "\n",
42
+ encoding="utf-8",
43
+ )
@@ -0,0 +1,222 @@
1
+ """Validated inputs and weighted priorities for a House of Quality."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from math import fsum, isfinite
7
+ from numbers import Integral, Real
8
+ from typing import Iterable, Sequence
9
+
10
+
11
+ def _name(value: str, field: str) -> None:
12
+ if not isinstance(value, str) or not value.strip():
13
+ raise ValueError(f"{field} must be a nonempty string")
14
+
15
+
16
+ def _number(value: Real, field: str) -> None:
17
+ if (
18
+ isinstance(value, bool)
19
+ or not isinstance(value, Real)
20
+ or not isfinite(value)
21
+ or value < 0
22
+ ):
23
+ raise ValueError(f"{field} must be a finite, nonnegative number")
24
+
25
+
26
+ @dataclass(frozen=True, slots=True)
27
+ class Criterion:
28
+ id: str
29
+ label: str
30
+ weight: float
31
+
32
+ def __post_init__(self) -> None:
33
+ _name(self.id, "criterion ID")
34
+ _name(self.label, "criterion label")
35
+ _number(self.weight, "weight")
36
+ object.__setattr__(self, "weight", float(self.weight))
37
+
38
+
39
+ @dataclass(frozen=True, slots=True)
40
+ class Response:
41
+ id: str
42
+ label: str
43
+ target: str = ""
44
+ direction: str = ""
45
+
46
+ def __post_init__(self) -> None:
47
+ _name(self.id, "response ID")
48
+ _name(self.label, "response label")
49
+ if not isinstance(self.target, str):
50
+ raise ValueError("target must be a string")
51
+ if self.direction not in ("", "increase", "decrease", "target"):
52
+ raise ValueError("direction must be increase, decrease, target, or empty")
53
+
54
+
55
+ @dataclass(frozen=True, slots=True)
56
+ class Correlation:
57
+ first: str
58
+ second: str
59
+ strength: int
60
+ note: str = ""
61
+
62
+ def __post_init__(self) -> None:
63
+ _name(self.first, "first response ID")
64
+ _name(self.second, "second response ID")
65
+ if self.first == self.second:
66
+ raise ValueError("a response cannot have a correlation with itself")
67
+ if (
68
+ isinstance(self.strength, bool)
69
+ or not isinstance(self.strength, Integral)
70
+ or self.strength not in (-2, -1, 1, 2)
71
+ ):
72
+ raise ValueError("correlation strength must be -2, -1, 1, or 2")
73
+ if not isinstance(self.note, str):
74
+ raise ValueError("correlation note must be a string")
75
+ object.__setattr__(self, "strength", int(self.strength))
76
+
77
+
78
+ @dataclass(frozen=True, slots=True)
79
+ class Benchmark:
80
+ """Ratings for an external reference on the house's criterion rows."""
81
+
82
+ label: str
83
+ ratings: tuple[float | None, ...]
84
+
85
+ def __post_init__(self) -> None:
86
+ _name(self.label, "benchmark label")
87
+ ratings = tuple(self.ratings)
88
+ for rating in ratings:
89
+ if rating is not None:
90
+ _number(rating, "benchmark rating")
91
+ object.__setattr__(
92
+ self, "ratings", tuple(float(r) if r is not None else None for r in ratings)
93
+ )
94
+
95
+
96
+ @dataclass(frozen=True, slots=True)
97
+ class House:
98
+ """The criteria, response columns, and assessed relationships for one stage.
99
+
100
+ Relationships use 0, 1, 3, and 9. Correlations are unordered pairs of
101
+ response IDs and are separate from weighted scoring.
102
+ """
103
+
104
+ criteria: tuple[Criterion, ...]
105
+ responses: tuple[Response, ...]
106
+ matrix: tuple[tuple[int, ...], ...]
107
+ correlations: tuple[Correlation, ...] = ()
108
+ benchmarks: tuple[Benchmark, ...] = ()
109
+ title: str = "House of Quality"
110
+
111
+ def __post_init__(self) -> None:
112
+ _name(self.title, "title")
113
+ for field in ("criteria", "responses", "correlations", "benchmarks"):
114
+ object.__setattr__(self, field, tuple(getattr(self, field)))
115
+ matrix = tuple(tuple(row) for row in self.matrix)
116
+ if not self.criteria or not self.responses:
117
+ raise ValueError("a house needs at least one criterion and one response")
118
+ _indices(self.criteria)
119
+ responses = _indices(self.responses)
120
+ if len(matrix) != len(self.criteria) or any(
121
+ len(row) != len(responses) for row in matrix
122
+ ):
123
+ raise ValueError("matrix dimensions must match criteria and responses")
124
+ for row in matrix:
125
+ for score in row:
126
+ if (
127
+ isinstance(score, bool)
128
+ or not isinstance(score, Integral)
129
+ or score not in (0, 1, 3, 9)
130
+ ):
131
+ raise ValueError("relationship strength must be 0, 1, 3, or 9")
132
+ object.__setattr__(
133
+ self, "matrix", tuple(tuple(map(int, row)) for row in matrix)
134
+ )
135
+ pairs: set[frozenset[str]] = set()
136
+ for correlation in self.correlations:
137
+ pair = frozenset((correlation.first, correlation.second))
138
+ if pair - responses.keys():
139
+ raise ValueError(
140
+ "correlations must refer to response IDs in this house"
141
+ )
142
+ if pair in pairs:
143
+ raise ValueError("duplicate correlation pair")
144
+ pairs.add(pair)
145
+ labels: set[str] = set()
146
+ for benchmark in self.benchmarks:
147
+ if len(benchmark.ratings) != len(self.criteria):
148
+ raise ValueError("each benchmark needs one rating per criterion")
149
+ if benchmark.label in labels:
150
+ raise ValueError("duplicate benchmark label")
151
+ labels.add(benchmark.label)
152
+
153
+ @classmethod
154
+ def from_relationships(
155
+ cls,
156
+ criteria: Sequence[Criterion],
157
+ responses: Sequence[Response],
158
+ relationships: Iterable[tuple[str, str, int]],
159
+ **options,
160
+ ) -> House:
161
+ """Build from (criterion ID, response ID, strength) entries. Omitted cells are zero."""
162
+ rows, columns = _indices(criteria), _indices(responses)
163
+ matrix = [[0] * len(columns) for _ in rows]
164
+ seen: set[tuple[int, int]] = set()
165
+ for criterion_id, response_id, strength in relationships:
166
+ try:
167
+ i, j = rows[criterion_id], columns[response_id]
168
+ except KeyError as exc:
169
+ raise ValueError(f"unknown relationship ID: {exc.args[0]}") from exc
170
+ if (i, j) in seen:
171
+ raise ValueError(
172
+ f"duplicate relationship: {criterion_id}/{response_id}"
173
+ )
174
+ seen.add((i, j))
175
+ matrix[i][j] = strength
176
+ return cls(criteria, responses, matrix, **options)
177
+
178
+ @property
179
+ def scores(self) -> tuple[float, ...]:
180
+ try:
181
+ scores = tuple(
182
+ fsum(
183
+ criterion.weight * value
184
+ for criterion, value in zip(self.criteria, column)
185
+ )
186
+ for column in zip(*self.matrix)
187
+ )
188
+ except OverflowError as exc:
189
+ raise ValueError("weighted scores must be finite") from exc
190
+ if not all(map(isfinite, scores)):
191
+ raise ValueError("weighted scores must be finite")
192
+ return scores
193
+
194
+ @property
195
+ def shares(self) -> tuple[float, ...]:
196
+ """Column fractions of total score. All-zero scores yield zero shares."""
197
+ scores = self.scores
198
+ maximum = max(scores)
199
+ if maximum == 0:
200
+ return scores
201
+ scaled = tuple(score / maximum for score in scores)
202
+ total = fsum(scaled)
203
+ return tuple(score / total for score in scaled)
204
+
205
+ def deploy(
206
+ self, responses: Sequence[Response], matrix: Sequence[Sequence[int]], **options
207
+ ) -> House:
208
+ """Use this house's responses and unrounded scores as the next stage's criteria."""
209
+ criteria = tuple(
210
+ Criterion(response.id, response.label, score)
211
+ for response, score in zip(self.responses, self.scores)
212
+ )
213
+ return House(criteria, responses, matrix, **options)
214
+
215
+
216
+ def _indices(items: Sequence[Criterion | Response]) -> dict[str, int]:
217
+ result: dict[str, int] = {}
218
+ for index, item in enumerate(items):
219
+ if item.id in result:
220
+ raise ValueError(f"duplicate ID: {item.id}")
221
+ result[item.id] = index
222
+ return result
@@ -0,0 +1,90 @@
1
+ """Compare two house definitions using their stable row and column IDs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from .model import Correlation, House, _indices
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class RelationshipChange:
12
+ criterion_id: str
13
+ response_id: str
14
+ before: int
15
+ after: int
16
+
17
+
18
+ @dataclass(frozen=True, slots=True)
19
+ class CorrelationChange:
20
+ responses: tuple[str, str]
21
+ before: Correlation | None
22
+ after: Correlation | None
23
+
24
+
25
+ @dataclass(frozen=True, slots=True)
26
+ class Revision:
27
+ added_criteria: tuple[str, ...]
28
+ removed_criteria: tuple[str, ...]
29
+ changed_criteria: tuple[str, ...]
30
+ added_responses: tuple[str, ...]
31
+ removed_responses: tuple[str, ...]
32
+ changed_responses: tuple[str, ...]
33
+ relationships: tuple[RelationshipChange, ...]
34
+ correlations: tuple[CorrelationChange, ...]
35
+
36
+
37
+ def compare(before: House, after: House) -> Revision:
38
+ """Find definition and relationship changes by ID."""
39
+ old_rows, new_rows = _indices(before.criteria), _indices(after.criteria)
40
+ old_cols, new_cols = _indices(before.responses), _indices(after.responses)
41
+ relations = []
42
+ for criterion_id, i in old_rows.items():
43
+ if criterion_id not in new_rows:
44
+ continue
45
+ for response_id, j in old_cols.items():
46
+ if response_id not in new_cols:
47
+ continue
48
+ old = before.matrix[i][j]
49
+ new = after.matrix[new_rows[criterion_id]][new_cols[response_id]]
50
+ if old != new:
51
+ relations.append(
52
+ RelationshipChange(criterion_id, response_id, old, new)
53
+ )
54
+ old_pairs = _pairs(before)
55
+ new_pairs = _pairs(after)
56
+ correlations = tuple(
57
+ CorrelationChange(pair, old_pairs.get(pair), new_pairs.get(pair))
58
+ for pair in sorted(old_pairs.keys() | new_pairs.keys())
59
+ if old_pairs.get(pair) != new_pairs.get(pair)
60
+ )
61
+ return Revision(
62
+ tuple(key for key in new_rows if key not in old_rows),
63
+ tuple(key for key in old_rows if key not in new_rows),
64
+ tuple(
65
+ key
66
+ for key in old_rows
67
+ if key in new_rows
68
+ and before.criteria[old_rows[key]] != after.criteria[new_rows[key]]
69
+ ),
70
+ tuple(key for key in new_cols if key not in old_cols),
71
+ tuple(key for key in old_cols if key not in new_cols),
72
+ tuple(
73
+ key
74
+ for key in old_cols
75
+ if key in new_cols
76
+ and before.responses[old_cols[key]] != after.responses[new_cols[key]]
77
+ ),
78
+ tuple(relations),
79
+ correlations,
80
+ )
81
+
82
+
83
+ def _pairs(house: House) -> dict[tuple[str, str], Correlation]:
84
+ result = {}
85
+ for correlation in house.correlations:
86
+ first, second = sorted((correlation.first, correlation.second))
87
+ result[first, second] = Correlation(
88
+ first, second, correlation.strength, correlation.note
89
+ )
90
+ return result
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: quality-house
3
+ Version: 0.1.0
4
+ Summary: Build, score, and draw a House of Quality.
5
+ Author: Manav Agarwal
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 ManavA
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: qfd,house-of-quality,engineering,requirements
29
+ Classifier: Topic :: Scientific/Engineering :: Visualization
30
+ Requires-Python: >=3.10
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: matplotlib>=3.7
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest>=8; extra == "test"
36
+ Dynamic: license-file
37
+
38
+ # Quality House
39
+
40
+ Build a House of Quality from Python or JSON. Score engineering responses against weighted criteria, draw the matrix and correlation roof, and carry scores into the next design stage.
41
+
42
+ ## Run an example
43
+
44
+ Install the package from the project root with \`python -m pip install .\`, then run the example from the same directory.
45
+
46
+ quality-house score examples/reusable-case.json
47
+ quality-house render examples/reusable-case.json case.pdf --bars
48
+ python examples/deployment.py
49
+
50
+ Use a PDF, SVG, or PNG output filename. Add `--no-roof` to hide the roof. Cell strengths are 0 (none), 1 (weak), 3 (moderate), and 9 (strong). Bar lengths scale to the highest score. The share under each score is its fraction of the total.
51
+
52
+ ## Create and deploy a house
53
+
54
+ \`\`\`python
55
+ from quality_house import Correlation, Criterion, House, Response, render
56
+
57
+ house = House(
58
+ criteria=[Criterion("open", "Easy to open", 5), Criterion("clean", "Easy to clean", 3)],
59
+ responses=[Response("latch", "Latch force"), Response("seal", "Seal compression")],
60
+ matrix=[[9, 1], [1, 9]],
61
+ correlations=[Correlation("latch", "seal", -1, "More compression raises opening force.")],
62
+ )
63
+ assert house.scores == (48, 32)
64
+
65
+ parts = house.deploy([Response("spring", "Latch spring")], [[1], [3]])
66
+ assert parts.scores == (144,)
67
+ render(house, bars=True).savefig("case.pdf")
68
+ \`\`\`
69
+
70
+ The score of a column is the sum of each relationship strength multiplied by its row weight. A deployment uses the exact previous scores in response order. To build a second study from the same original needs, pass \`house.criteria\` to its constructor.
71
+
72
+ ## Inputs and revisions
73
+
74
+ - Use \`House.from_relationships(criteria, responses, relations)\` for sparse entries. Each entry contains a criterion ID, a response ID, and a strength. Omitted entries are zero.
75
+ - Give each criterion and response an ID that stays stable when its label or position changes. \`compare(before, after)\` reports additions, removals, definition changes, and changed relationships and correlations.
76
+ - Supply a revision to \`render(after, revision=compare(before, after))\` or use \`quality-house render after.json after.pdf --compare-with before.json\` to outline changed cells.
77
+ - Add \`Benchmark(label, ratings)\` for an external reference with one rating per criterion. Use \`None\` when a rating is unavailable. Benchmark ratings and roof signs stay separate from weighted scoring.
78
+ - Load a JSON file with \`load(path)\` and save a definition with \`save(house, path)\`. Use \`quality-house diff before.json after.json\` to inspect the model changes as JSON.
79
+
80
+ The package includes Python and JSON examples. The [example JSON](examples/reusable-case.json) shows targets, directions, correlations and benchmarks together.
@@ -0,0 +1,21 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ examples/deployment.py
6
+ examples/reusable-case.json
7
+ src/quality_house/__init__.py
8
+ src/quality_house/__main__.py
9
+ src/quality_house/cli.py
10
+ src/quality_house/drawing.py
11
+ src/quality_house/jsonio.py
12
+ src/quality_house/model.py
13
+ src/quality_house/revision.py
14
+ src/quality_house.egg-info/PKG-INFO
15
+ src/quality_house.egg-info/SOURCES.txt
16
+ src/quality_house.egg-info/dependency_links.txt
17
+ src/quality_house.egg-info/entry_points.txt
18
+ src/quality_house.egg-info/requires.txt
19
+ src/quality_house.egg-info/top_level.txt
20
+ tests/test_house.py
21
+ tests/test_output.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ quality-house = quality_house.cli:main
@@ -0,0 +1,4 @@
1
+ matplotlib>=3.7
2
+
3
+ [test]
4
+ pytest>=8
@@ -0,0 +1 @@
1
+ quality_house
@@ -0,0 +1,64 @@
1
+ import pytest
2
+
3
+ from quality_house import Criterion, House, Response, compare
4
+
5
+
6
+ def example():
7
+ return House(
8
+ criteria=[
9
+ Criterion("easy", "Easy to open", 5),
10
+ Criterion("clean", "Easy to clean", 3),
11
+ ],
12
+ responses=[Response("latch", "Latch"), Response("seal", "Seal")],
13
+ matrix=[[9, 1], [1, 9]],
14
+ )
15
+
16
+
17
+ def test_scores_feed_next_stage_in_response_order():
18
+ first = example()
19
+ assert first.scores == (48, 32)
20
+ assert first.shares == pytest.approx((0.60, 0.40))
21
+ second = first.deploy([Response("spring", "Spring")], [[1], [3]])
22
+ assert [criterion.id for criterion in second.criteria] == ["latch", "seal"]
23
+ assert second.scores == (144,)
24
+
25
+
26
+ def test_sparse_relationships_and_revision_follow_ids():
27
+ before = example()
28
+ after = House.from_relationships(
29
+ list(reversed(before.criteria)),
30
+ [Response("seal", "Removable seal"), Response("shell", "Shell")],
31
+ [("easy", "seal", 3), ("clean", "seal", 9)],
32
+ )
33
+ change = compare(before, after)
34
+ assert change.removed_responses == ("latch",)
35
+ assert change.added_responses == ("shell",)
36
+ assert change.changed_responses == ("seal",)
37
+ assert [
38
+ (e.criterion_id, e.response_id, e.before, e.after) for e in change.relationships
39
+ ] == [("easy", "seal", 1, 3)]
40
+
41
+
42
+ @pytest.mark.parametrize(
43
+ "matrix",
44
+ [
45
+ [[9], [1]],
46
+ [[9, 2], [1, 3]],
47
+ [[9, True], [1, 3]],
48
+ ],
49
+ )
50
+ def test_invalid_matrix_is_rejected_at_construction(matrix):
51
+ first = example()
52
+ with pytest.raises(ValueError):
53
+ House(first.criteria, first.responses, matrix)
54
+
55
+
56
+ def test_large_finite_column_totals_can_have_finite_shares():
57
+ large = House(
58
+ [Criterion("load", "Load", 1e308)],
59
+ [Response("a", "A"), Response("b", "B")],
60
+ [[1, 1]],
61
+ )
62
+ assert large.shares == (0.5, 0.5)
63
+ with pytest.raises(ValueError, match="finite"):
64
+ House(large.criteria, large.responses, [[9, 1]]).scores
@@ -0,0 +1,43 @@
1
+ import json
2
+
3
+ from matplotlib.backends.backend_agg import FigureCanvasAgg
4
+
5
+ from quality_house import (
6
+ Benchmark,
7
+ Correlation,
8
+ Criterion,
9
+ House,
10
+ Response,
11
+ load,
12
+ render,
13
+ save,
14
+ )
15
+
16
+
17
+ def test_json_round_trip_and_pdf(tmp_path):
18
+ house = House(
19
+ [Criterion("a", "Easy to open", 5), Criterion("b", "Easy to clean", 2)],
20
+ [
21
+ Response("latch", "Spring-loaded latch", "Under 10 N", "decrease"),
22
+ Response("seal", "Seal"),
23
+ ],
24
+ [[9, 1], [3, 9]],
25
+ correlations=[
26
+ Correlation(
27
+ "seal", "latch", -1, "Opening force increases with seal pressure."
28
+ )
29
+ ],
30
+ benchmarks=[Benchmark("Current design", [3, None])],
31
+ title="Reusable case",
32
+ )
33
+ path = tmp_path / "case.json"
34
+ save(house, path)
35
+ assert json.loads(path.read_text())["matrix"] == [[9, 1], [3, 9]]
36
+ assert load(path) == house
37
+ chart = render(house, bars=True)
38
+ FigureCanvasAgg(chart).draw()
39
+ labels = [" ".join(t.get_text().split()) for axis in chart.axes for t in axis.texts]
40
+ assert "51" in labels and "−" in labels and "Current design" in labels
41
+ pdf = tmp_path / "case.pdf"
42
+ chart.savefig(pdf)
43
+ assert pdf.read_bytes().startswith(b"%PDF-")