@wafertools/wafermap 0.40.0 → 0.41.0

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 (220) hide show
  1. package/AGENTS.md +20 -21
  2. package/CHANGELOG.md +154 -0
  3. package/README.md +6 -6
  4. package/dist/packages/canvas-adapter/canvasTheme.d.ts +12 -0
  5. package/dist/packages/canvas-adapter/canvasTheme.js +1 -1
  6. package/dist/packages/canvas-adapter/cellShade.d.ts +2 -2
  7. package/dist/packages/canvas-adapter/cellShade.js +1 -1
  8. package/dist/packages/canvas-adapter/chartPopulation.d.ts +3 -0
  9. package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
  10. package/dist/packages/canvas-adapter/charts/capability.d.ts +3 -0
  11. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  12. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +2 -1
  13. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +47 -27
  15. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  16. package/dist/packages/canvas-adapter/charts/commonality.js +4 -4
  17. package/dist/packages/canvas-adapter/charts/correlation.d.ts +6 -12
  18. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  19. package/dist/packages/canvas-adapter/charts/divergingScale.d.ts +45 -15
  20. package/dist/packages/canvas-adapter/charts/divergingScale.js +1 -1
  21. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/palette.d.ts +16 -30
  23. package/dist/packages/canvas-adapter/charts/palette.js +1 -1
  24. package/dist/packages/canvas-adapter/charts/patCard.js +1 -1
  25. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +29 -3
  26. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  27. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +3 -0
  28. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  29. package/dist/packages/canvas-adapter/charts/sweep.d.ts +3 -0
  30. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  31. package/dist/packages/canvas-adapter/chromeRow.d.ts +68 -0
  32. package/dist/packages/canvas-adapter/chromeRow.js +1 -0
  33. package/dist/packages/canvas-adapter/chunked.d.ts +6 -0
  34. package/dist/packages/canvas-adapter/chunked.js +1 -1
  35. package/dist/packages/canvas-adapter/columnFilterPopup.d.ts +25 -0
  36. package/dist/packages/canvas-adapter/columnFilterPopup.js +1 -0
  37. package/dist/packages/canvas-adapter/composePng.d.ts +37 -0
  38. package/dist/packages/canvas-adapter/composePng.js +1 -0
  39. package/dist/packages/canvas-adapter/dataTab.d.ts +39 -6
  40. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  41. package/dist/packages/canvas-adapter/dieList.js +1 -1
  42. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +3 -1
  43. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -1
  44. package/dist/packages/canvas-adapter/drilldown.d.ts +20 -1
  45. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  46. package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
  47. package/dist/packages/canvas-adapter/filterButton.js +1 -1
  48. package/dist/packages/canvas-adapter/filterEditor.d.ts +5 -0
  49. package/dist/packages/canvas-adapter/filterEditor.js +1 -1
  50. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  51. package/dist/packages/canvas-adapter/icons.js +1 -1
  52. package/dist/packages/canvas-adapter/identityHeader.d.ts +5 -0
  53. package/dist/packages/canvas-adapter/identityHeader.js +1 -1
  54. package/dist/packages/canvas-adapter/index.d.ts +7 -0
  55. package/dist/packages/canvas-adapter/index.js +1 -1
  56. package/dist/packages/canvas-adapter/insightsTab.d.ts +32 -9
  57. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  58. package/dist/packages/canvas-adapter/maplessSummary.d.ts +4 -2
  59. package/dist/packages/canvas-adapter/maplessSummary.js +1 -1
  60. package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
  61. package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
  62. package/dist/packages/canvas-adapter/panelChart.d.ts +7 -0
  63. package/dist/packages/canvas-adapter/panelChart.js +1 -0
  64. package/dist/packages/canvas-adapter/panelTable.d.ts +50 -0
  65. package/dist/packages/canvas-adapter/panelTable.js +1 -0
  66. package/dist/packages/canvas-adapter/plotCard.js +1 -1
  67. package/dist/packages/canvas-adapter/plotEditor.d.ts +12 -0
  68. package/dist/packages/canvas-adapter/plotEditor.js +10 -10
  69. package/dist/packages/canvas-adapter/plotItems.d.ts +9 -4
  70. package/dist/packages/canvas-adapter/plotItems.js +1 -1
  71. package/dist/packages/canvas-adapter/plotJsonComplete.js +1 -1
  72. package/dist/packages/canvas-adapter/plotModal.d.ts +7 -0
  73. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  74. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  75. package/dist/packages/canvas-adapter/plotTab.d.ts +60 -2
  76. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  77. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +7 -0
  78. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  79. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +41 -9
  80. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  81. package/dist/packages/canvas-adapter/reportCharts.d.ts +41 -0
  82. package/dist/packages/canvas-adapter/reportCharts.js +1 -0
  83. package/dist/packages/canvas-adapter/reportExport.d.ts +91 -0
  84. package/dist/packages/canvas-adapter/reportExport.js +1 -0
  85. package/dist/packages/canvas-adapter/reportFigures.d.ts +29 -0
  86. package/dist/packages/canvas-adapter/reportFigures.js +1 -0
  87. package/dist/packages/canvas-adapter/reportRun.d.ts +9 -0
  88. package/dist/packages/canvas-adapter/reportRun.js +1 -0
  89. package/dist/packages/canvas-adapter/selectionOverlay.d.ts +12 -0
  90. package/dist/packages/canvas-adapter/selectionOverlay.js +1 -0
  91. package/dist/packages/canvas-adapter/summaryPanel.d.ts +152 -111
  92. package/dist/packages/canvas-adapter/summaryPanel.js +7 -4
  93. package/dist/packages/canvas-adapter/summaryToggle.js +1 -1
  94. package/dist/packages/canvas-adapter/tableDrilldown.d.ts +48 -0
  95. package/dist/packages/canvas-adapter/tableDrilldown.js +1 -0
  96. package/dist/packages/canvas-adapter/tableFilter.d.ts +42 -0
  97. package/dist/packages/canvas-adapter/tableFilter.js +1 -0
  98. package/dist/packages/canvas-adapter/tablePlots.d.ts +85 -0
  99. package/dist/packages/canvas-adapter/tablePlots.js +1 -0
  100. package/dist/packages/canvas-adapter/themeWatch.d.ts +7 -0
  101. package/dist/packages/canvas-adapter/themeWatch.js +1 -0
  102. package/dist/packages/canvas-adapter/toCanvas.d.ts +3 -0
  103. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  104. package/dist/packages/canvas-adapter/toolbar.d.ts +125 -36
  105. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  106. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  107. package/dist/packages/canvas-adapter/userGuideHtml.js +530 -414
  108. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  109. package/dist/packages/canvas-adapter/version.js +1 -1
  110. package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
  111. package/dist/packages/canvas-adapter/virtualTable.d.ts +37 -7
  112. package/dist/packages/canvas-adapter/virtualTable.js +1 -1
  113. package/dist/packages/core/aggregates.d.ts +14 -0
  114. package/dist/packages/core/aggregates.js +1 -1
  115. package/dist/packages/core/dies.d.ts +7 -0
  116. package/dist/packages/core/dies.js +1 -1
  117. package/dist/packages/core/utils.d.ts +2 -0
  118. package/dist/packages/core/utils.js +1 -1
  119. package/dist/packages/experimental/charts.d.ts +4 -0
  120. package/dist/packages/experimental/charts.js +1 -0
  121. package/dist/packages/renderer/binColors.d.ts +6 -2
  122. package/dist/packages/renderer/binColors.js +1 -1
  123. package/dist/packages/renderer/buildView.d.ts +36 -14
  124. package/dist/packages/renderer/buildView.js +1 -1
  125. package/dist/packages/renderer/buildWaferMap.d.ts +8 -0
  126. package/dist/packages/renderer/buildWaferMap.js +1 -1
  127. package/dist/packages/renderer/categoryColors.d.ts +3 -0
  128. package/dist/packages/renderer/categoryColors.js +1 -0
  129. package/dist/packages/renderer/colorMap.d.ts +15 -16
  130. package/dist/packages/renderer/colorMap.js +1 -1
  131. package/dist/packages/renderer/colorSchemes.d.ts +34 -30
  132. package/dist/packages/renderer/colorSchemes.js +1 -1
  133. package/dist/packages/renderer/dataColors.d.ts +126 -0
  134. package/dist/packages/renderer/dataColors.js +1 -0
  135. package/dist/packages/renderer/deprecate.js +1 -1
  136. package/dist/packages/renderer/fmt.d.ts +16 -0
  137. package/dist/packages/renderer/fmt.js +1 -1
  138. package/dist/packages/renderer/index.d.ts +2 -0
  139. package/dist/packages/renderer/index.js +1 -1
  140. package/dist/packages/renderer/spec.d.ts +5 -0
  141. package/dist/packages/renderer/spec.js +1 -1
  142. package/dist/packages/renderer/stacks.d.ts +21 -0
  143. package/dist/packages/renderer/stacks.js +1 -0
  144. package/dist/packages/renderer/timeAxis.d.ts +19 -0
  145. package/dist/packages/renderer/timeAxis.js +1 -0
  146. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  147. package/dist/packages/stats/analyzeWaferMap.d.ts +2 -4
  148. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  149. package/dist/packages/stats/binRows.js +1 -1
  150. package/dist/packages/stats/binShifts.d.ts +59 -0
  151. package/dist/packages/stats/binShifts.js +1 -0
  152. package/dist/packages/stats/capability.d.ts +6 -1
  153. package/dist/packages/stats/capability.js +1 -1
  154. package/dist/packages/stats/chartCatalogue.d.ts +3 -0
  155. package/dist/packages/stats/chartCatalogue.js +1 -1
  156. package/dist/packages/stats/clusterDetection.js +1 -1
  157. package/dist/packages/stats/columnPlot.d.ts +38 -0
  158. package/dist/packages/stats/columnPlot.js +1 -0
  159. package/dist/packages/stats/commonality.d.ts +8 -1
  160. package/dist/packages/stats/commonality.js +1 -1
  161. package/dist/packages/stats/correlation.d.ts +7 -2
  162. package/dist/packages/stats/correlation.js +1 -1
  163. package/dist/packages/stats/dataTable.d.ts +44 -0
  164. package/dist/packages/stats/dataTable.js +1 -0
  165. package/dist/packages/stats/dieRegions.js +1 -1
  166. package/dist/packages/stats/examplePicks.js +1 -1
  167. package/dist/packages/stats/facets.d.ts +11 -0
  168. package/dist/packages/stats/facets.js +1 -1
  169. package/dist/packages/stats/filterFindings.d.ts +21 -0
  170. package/dist/packages/stats/filterFindings.js +1 -1
  171. package/dist/packages/stats/groupEffects.d.ts +8 -0
  172. package/dist/packages/stats/groupEffects.js +1 -1
  173. package/dist/packages/stats/math.d.ts +2 -0
  174. package/dist/packages/stats/math.js +1 -1
  175. package/dist/packages/stats/overview.d.ts +114 -0
  176. package/dist/packages/stats/overview.js +1 -0
  177. package/dist/packages/stats/pat.d.ts +0 -2
  178. package/dist/packages/stats/pat.js +1 -1
  179. package/dist/packages/stats/patternClassification.d.ts +20 -3
  180. package/dist/packages/stats/patternClassification.js +1 -1
  181. package/dist/packages/stats/permutationNull.d.ts +16 -0
  182. package/dist/packages/stats/permutationNull.js +1 -0
  183. package/dist/packages/stats/plotData.d.ts +138 -12
  184. package/dist/packages/stats/plotData.js +1 -1
  185. package/dist/packages/stats/plotSpec.d.ts +10 -1
  186. package/dist/packages/stats/plotSpec.js +3 -3
  187. package/dist/packages/stats/plotTable.js +1 -1
  188. package/dist/packages/stats/plotWords.d.ts +52 -0
  189. package/dist/packages/stats/plotWords.js +1 -0
  190. package/dist/packages/stats/presentation.d.ts +63 -14
  191. package/dist/packages/stats/presentation.js +1 -1
  192. package/dist/packages/stats/presentationPresets.d.ts +35 -0
  193. package/dist/packages/stats/presentationPresets.js +1 -0
  194. package/dist/packages/stats/presentationSections.d.ts +83 -0
  195. package/dist/packages/stats/presentationSections.js +1 -0
  196. package/dist/packages/stats/renderSummaryReport.d.ts +80 -2
  197. package/dist/packages/stats/renderSummaryReport.js +1 -67
  198. package/dist/packages/stats/reportBlocks.d.ts +249 -0
  199. package/dist/packages/stats/reportBlocks.js +1 -0
  200. package/dist/packages/stats/reportContents.d.ts +22 -0
  201. package/dist/packages/stats/reportContents.js +1 -0
  202. package/dist/packages/stats/reportDeck.d.ts +245 -0
  203. package/dist/packages/stats/reportDeck.js +212 -0
  204. package/dist/packages/stats/reportHtml.d.ts +44 -43
  205. package/dist/packages/stats/reportHtml.js +82 -46
  206. package/dist/packages/stats/reportMaps.d.ts +67 -0
  207. package/dist/packages/stats/reportMaps.js +1 -0
  208. package/dist/packages/stats/reportSections.d.ts +55 -0
  209. package/dist/packages/stats/reportSections.js +1 -0
  210. package/dist/packages/stats/sweep.d.ts +14 -6
  211. package/dist/packages/stats/sweep.js +1 -1
  212. package/dist/packages/stats/synthesis.d.ts +87 -10
  213. package/dist/packages/stats/synthesis.js +1 -1
  214. package/dist/packages/stats/types.d.ts +22 -0
  215. package/dist/packages/stats/worthItems.d.ts +15 -0
  216. package/dist/packages/stats/worthItems.js +1 -0
  217. package/dist/packages/stats/yield.d.ts +13 -0
  218. package/dist/packages/stats/yield.js +1 -1
  219. package/llms.txt +1 -1
  220. package/package.json +6 -1
@@ -1,5 +1,5 @@
1
1
  import { type FacetCuration } from './facets.js';
2
- import type { LotStatsSummary, StatsSeverity, StatsSummary } from './types.js';
2
+ import type { StatsComparisonFamily, LotStatsSummary, StatsSeverity, StatsSummary } from './types.js';
3
3
  import type { PlotSpec } from './plotSpec.js';
4
4
  /**
5
5
  * What an item shows when it is chosen: a finding (its dies, as the findings list shows them), or a test
@@ -18,6 +18,13 @@ export type SynthesisTarget = {
18
18
  kind: 'group';
19
19
  field: string; /** Every field that gives the same groups, `field` first. */
20
20
  fields: string[];
21
+ /** The wafers of the group the item is about (lot `waferIndex`), which the map outlines. */ waferIndices?: number[];
22
+ }
23
+ /** A finding on one wafer of a lot, which the lot has no finding for: shown by opening that wafer. */
24
+ | {
25
+ kind: 'wafer';
26
+ waferIndex: number;
27
+ findingId: string;
21
28
  };
22
29
  /** One part of an item that can be shown on its own: a fail bin in its region, the pattern, a test on the same dies. */
23
30
  export interface SynthesisChip {
@@ -30,17 +37,40 @@ export interface SynthesisChip {
30
37
  };
31
38
  /** Set for a test whose values shift on the item's dies: the chip shows that region on the test's map. */
32
39
  shift?: true;
40
+ /**
41
+ * Set for a test that differs between groups of wafers: the wafers of the group it differs on (lot `waferIndex`), which
42
+ * the map outlines while it shows the test.
43
+ */
44
+ waferIndices?: number[];
33
45
  }
34
46
  /** How much of the lot an item costs, in three steps. Drawn as a meter, never as colour alone. */
35
47
  export type ImpactTier = 'high' | 'medium' | 'low';
48
+ /**
49
+ * How clear and how large a finding is, in three steps: its severity as the reader sees it (unusual is high, notable
50
+ * medium, info low). An item's is the strongest of its evidence.
51
+ */
52
+ export type StrengthLevel = 'high' | 'medium' | 'low';
53
+ /** A finding's severity as a strength level. */
54
+ export declare const strengthOf: (s: StatsSeverity) => StrengthLevel;
55
+ /**
56
+ * Where an item sits in the Summary panel, Insights and the report: what it is about, as a reader asks it. Set by
57
+ * {@link synthesisCategoryOf}, the one table that sorts items; the order and titles are `SYNTHESIS_CATEGORIES`.
58
+ */
59
+ export type SynthesisCategory = 'groups' | 'tests' | 'patterns' | 'sites' | 'wafers';
36
60
  export interface SynthesisItem {
61
+ /** What the item is about: a group of wafers, a test against its limits, a place on the wafer, a test site, a wafer. */
62
+ category: SynthesisCategory;
37
63
  /**
38
64
  * `loss`: the item costs dies (a region's shortfall, a fail bin, an outlier wafer, a failing test). `signal`: it costs
39
65
  * none of its own but moves the values (a test shifted in a region, a drift across the wafers, a spread too wide for
40
66
  * its limits, dies out of limits yet binned as passing). Both are ranked by `affected`.
41
67
  */
42
68
  kind: 'loss' | 'signal';
43
- /** From the share of the lot the item affects, the same quantity the items are ranked by. */
69
+ /**
70
+ * From the share of the lot the item affects, the same quantity the items are ranked by: for an item that costs dies, 1.5%
71
+ * of the dies is medium and 4% high (or 15% and 40% of the dies that fail); for one that moves values (a shift, a test's
72
+ * trend, a test that differs between groups of wafers), 10% and 25% of the dies it moves, weighted by the shift's size.
73
+ */
44
74
  impact: ImpactTier;
45
75
  /** `affected` as a fraction (0–1) of the analysed dies; set once the items are ranked. */
46
76
  shareOfDies: number;
@@ -75,6 +105,18 @@ export interface SynthesisItem {
75
105
  moreTests?: number;
76
106
  /** The leading finding, then the others that stand on the same dies. */
77
107
  findingIds: string[];
108
+ /**
109
+ * Every finding about the same failure, strongest first: the ones in `findingIds`, the findings whose dies are mostly
110
+ * the item's, findings of the same bin or test in a region that overlaps it, and the findings those explain. A surface
111
+ * lists them under the item, so no finding of strength high or medium stands apart from what it describes.
112
+ */
113
+ evidenceIds: string[];
114
+ /**
115
+ * The strongest of the item's evidence (or its own severity, when it has none): how clear and how large it is. Absent
116
+ * for an item that states a count against limits rather than a test of a difference (a test's failing dies, a Ppk,
117
+ * failing dies binned as passing) and holds no finding: "Strength: Low" would say it is weak, which it is not.
118
+ */
119
+ strength?: StrengthLevel;
78
120
  /** Tests the item names: its own test, or tests whose failing dies lie mostly on its dies. */
79
121
  testNumbers: number[];
80
122
  /**
@@ -83,6 +125,13 @@ export interface SynthesisItem {
83
125
  * histogram, a trend as a control chart, an outlier wafer as yield by wafer. Its title is the plot's own.
84
126
  */
85
127
  chart: Omit<PlotSpec, 'id'>;
128
+ /**
129
+ * A routine fact rather than a comparison: a test's dies outside its limits, a Ppk. The Summary panel shows these in
130
+ * Failing tests and Insights in its Tests section; Worth a look holds the rest (groups, regions, sites, wafers, shifts).
131
+ */
132
+ routine?: true;
133
+ /** A wafer shape (a scratch, a cluster, an edge ring), other than near-full: listed for what it is, see {@link isShapeItem}. */
134
+ shape?: true;
86
135
  }
87
136
  export interface Synthesis {
88
137
  headline: string;
@@ -101,6 +150,14 @@ export interface Synthesis {
101
150
  * from `items` and not counted as what stands out. Absent when there are none.
102
151
  */
103
152
  possible?: SynthesisItem[];
153
+ /**
154
+ * Findings of strength high or medium that no item above holds: each costs under 1% of the dies, but is unlikely to be
155
+ * chance. Grouped by shared dies, strongest first, then by size. On a lot this includes a strength-high finding on one
156
+ * wafer that the lot has no finding for (`target.kind === 'wafer'`). Absent when there are none.
157
+ */
158
+ small?: SynthesisItem[];
159
+ /** Findings of strength low that no item holds: counted, and listed in full in the report. */
160
+ lowStrengthIds: string[];
104
161
  /** Said instead of the items when none is material, so a good lot reads as one rather than as an empty list. */
105
162
  nothing?: string;
106
163
  /** What was compared and not repeated above. Required: a short synthesis must not read as "not analysed". */
@@ -119,6 +176,8 @@ export interface SynthesisContext {
119
176
  */
120
177
  attributes?: Record<string, FacetCuration>;
121
178
  }
179
+ /** Whether a test's groups differ by this adjusted p and standardised shift: the one rule Worth a look and the group comparison slide share. */
180
+ export declare const groupsDiffer: (pAdjusted: number, shiftSd: number) => boolean;
122
181
  /**
123
182
  * A bar of wafers drawn with Group by on takes the group's colours, and the wafers sit under their group on a second level
124
183
  * of the X axis: a pattern that belongs to a group (both low wafers are SS) shows as a colour, and the legend switches
@@ -136,19 +195,37 @@ export declare function synthesisSource(summary: StatsSummary | LotStatsSummary)
136
195
  * lost, and a line saying what was compared. The result is shared between callers, so it is frozen.
137
196
  */
138
197
  export declare function buildSynthesis(input: StatsSummary | LotStatsSummary, ctx?: SynthesisContext): Synthesis;
198
+ /**
199
+ * A wafer shape (a scratch, a cluster, an edge ring, on one wafer or repeated) of medium or high strength: a defect
200
+ * signature the reader acts on whatever it costs, so Worth a look lists it beside the items it ranks by cost.
201
+ */
202
+ export declare function isShapeItem(it: Pick<SynthesisItem, 'shape' | 'strength'>): boolean;
203
+ /**
204
+ * The one table that sorts items into categories, from what the item is about:
205
+ * - a group of wafers, or a test that differs between groups (its chart drawn by a lot field): Groups of wafers;
206
+ * - a test against its limits (failing dies, a Ppk, failing dies binned as passing): Tests outside limits;
207
+ * - a finding: by its family. A test site: Test sites. A wafer (an outlier wafer, a trend across the wafers): Wafers.
208
+ * Every other family is a place on the wafer (ring, quadrant, sector, reticle position, cluster, arc, pattern);
209
+ * - a defect on one wafer of a lot: Wafers.
210
+ */
211
+ export declare function synthesisCategoryOf(it: Pick<SynthesisItem, 'target' | 'chart'>, familyOf: (findingId: string) => StatsComparisonFamily | undefined): SynthesisCategory;
139
212
  /**
140
213
  * A stable key for an item: what it shows, the same in the panel and in Insights, so a row's Chart link finds the item's
141
214
  * card and a card's Show on map finds its row.
142
215
  */
143
- export declare const synthesisKey: (it: Pick<SynthesisItem, "target">) => string;
144
- /** The heading over groups that differ with no overlap but that the sample is too small to confirm. */
145
- export declare const SYNTHESIS_POSSIBLE_HEADING = "Possible, not confirmed";
146
- /** The heading over the compact list of further items: the floor is the same one that admits an item at all. */
147
- export declare const SYNTHESIS_ALSO_HEADING: string;
216
+ export declare const synthesisKey: (it: Pick<SynthesisItem, "target" | "chart">) => string;
217
+ /** The lot field an item's chart is drawn by (a test by split), or undefined when it is not about groups of wafers. */
218
+ export declare const groupedByField: (it: Pick<SynthesisItem, "chart">) => string | undefined;
219
+ /**
220
+ * Whether an item is about the wafers' yield in each group of a field, not a ring's pass rate in each (whose chart keeps to
221
+ * that ring). Such an item is a row of What divides yield, which reads the same fields the same way, so Insights draws it there.
222
+ */
223
+ export declare const isGroupYieldItem: (it: Pick<SynthesisItem, "target" | "chart">) => boolean;
148
224
  /** A compact-list row: the item in a few words, then its size (`2.4%` of the dies, `1.3σ`, `Ppk 0.62`). Plain text. */
149
225
  export declare const synthesisRowShare: (it: SynthesisItem) => string;
150
- /** After an item's chips: the folded tests not shown as one. Undefined when every test is a chip. Plain text. */
151
- export declare const synthesisMoreTests: (it: SynthesisItem) => string | undefined;
152
- /** A synthesis as plain text, one line per item, for tests and for any surface that is not HTML. */
226
+ /**
227
+ * A synthesis as plain text, one line per item, for tests and for any surface that is not HTML: every item that costs or
228
+ * moves 1% of the dies or more in rank order, then the groups too small to confirm, then the smaller items.
229
+ */
153
230
  export declare function synthesisText(s: Synthesis): string;
154
231
  //# sourceMappingURL=synthesis.d.ts.map
@@ -1,2 +1,2 @@
1
- import{maxOf as be,minOf as $e}from"../core/utils.js";import{isPassBin as Ae,passBinsLabel as Te}from"../core/passBins.js";import{DRIFT_MIN_WAFERS as We}from"./lotDrift.js";import{isOneBinCluster as He}from"./filterFindings.js";import{plainBinTerms as Re}from"../renderer/fmt.js";import{benjaminiHochberg as Ce,normalUpperTail as qe}from"./math.js";import{formatP as ye}from"./groupCompare.js";import{adjustedFits as Ke,mergePartitions as Ye,overlapping as Ge}from"./groupEffects.js";import{ringPlotValue as Ue}from"./dieRegions.js";import{parseRegionKey as Ve}from"./regions.js";import{attributeLabel as ie,buildFacetTable as Xe,facetValueOf as Me}from"./facets.js";const Je=1,Qe=2,Ze=.5,Ie=3,xe=5,Q=.01,et=.02,tt=.04,st=.15,it=.4,ue=.5,nt=.1,rt=2,_e=new Set(["ring","quadrant","sector","reticle-position","test-site","cluster","edge-arc"]);function we(e){const s=e.highlight;return"dieKeysByWafer"in s&&s.dieKeysByWafer?Object.values(s.dieKeysByWafer).reduce((i,n)=>i+n.length,0):"dieKeys"in s&&s.dieKeys&&s.dieKeys.length>0?s.dieKeys.length:e.level==="lot"?void 0:e.stats.sampleSizeLeft}function Ne(e){const s=e.highlight,i=new Set;if("dieKeysByWafer"in s&&s.dieKeysByWafer)for(const[n,c]of Object.entries(s.dieKeysByWafer))for(const o of c)i.add(`${n}:${o}`);else if("dieKeys"in s&&s.dieKeys)for(const n of s.dieKeys)i.add(n);return i}const z=e=>Math.abs(e.effect.absoluteDelta??0),K=e=>z(e)*(we(e)??0),W=e=>(e*100).toFixed(1),ae=e=>{const s=e.variable.label.replace(/ \(same dies\)$/,"").replace(/^HBin and SBin (\d+)/,"HBin $1").replace(/^(HBin \d+(?: \([^)]*\))?) and SBin .*$/,"$1");return Re(s)},_=e=>Math.round(e).toLocaleString("en-GB"),H=(e,s,i=`${s}s`)=>`${_(e)} ${e===1?s:i}`;function Z(e){const s=e.comparison.left;return e.comparison.family==="quadrant"&&!/quadrant/i.test(s)?`${s} quadrant`:s}const De=He;function ot(e){const s=e.map((f,a)=>a),i=f=>s[f]===f?f:s[f]=i(s[f]),n=e.map(Ne),c=(f,a)=>{const h=n[f].size<=n[a].size?n[f]:n[a],v=h===n[f]?n[a]:n[f];let N=0;for(const w of h)v.has(w)&&N++;return N},o=e.map((f,a)=>a).filter(f=>De(e[f])),r=e.map((f,a)=>a).filter(f=>!De(e[f]));for(let f=0;f<r.length;f++)for(let a=f+1;a<r.length;a++){const h=Math.min(n[r[f]].size,n[r[a]].size);h>0&&c(r[f],r[a])>=ue*h&&(s[i(r[f])]=i(r[a]))}for(const f of o){let a=-1,h=0;for(const v of r){if(ve(e[v])&&e[v].variable.bin!==e[f].variable.bin)continue;const N=c(f,v);N>h&&N>=ue*n[f].size&&N>=ue*K(e[v])&&(a=v,h=N)}a>=0&&(s[f]=i(a))}const $=new Map;return e.forEach((f,a)=>{const h=i(a);($.get(h)??$.set(h,[]).get(h)).push(a)}),[...$.values()]}const ve=e=>e.variable.kind==="hardBin"||e.variable.kind==="softBin",ke=(e,s)=>e.level===s.level&&e.comparison.family===s.comparison.family&&e.comparison.left===s.comparison.left;function at(e,s,i){const n=o=>s.filter(r=>r.variable.kind===o&&ke(r,e)&&r.effect.direction==="higher"&&i(r));return(n("hardBin").length>0?n("hardBin"):n("softBin")).filter(o=>o!==e).sort((o,r)=>z(r)-z(o))}const lt={ring:"rings",quadrant:"quadrants",sector:"sectors","edge-arc":"edge arcs",cluster:"clusters","reticle-position":"reticle positions","test-site":"test sites"},ft=2;function Be(e){const s=new Map;for(const n of e){const c=n.comparison.family;(s.get(c)??s.set(c,new Set).get(c)).add(Z(n))}const i=[];for(const[n,c]of s)c.size<=ft?i.push(...c):i.push(`${c.size} ${lt[n]??n}`);return i.join(", ")}const dt=e=>e.charAt(0).toUpperCase()+e.slice(1),ee=e=>({kind:"finding",id:e.id}),ct=e=>({label:dt(ae(e)),target:ee(e),...e.variable.bin!==void 0&&(e.variable.kind==="hardBin"||e.variable.kind==="softBin")?{bin:{kind:e.variable.kind,bin:e.variable.bin}}:{}});function he(e){const s=e.comparison.family;return{builtin:s==="quadrant"||s==="sector"?"quadrant":s==="reticle-position"?"reticleCell":s==="test-site"?"site":"ring"}}const Oe=(e,s)=>({chart:"bar",fields:{x:e,y:s,color:{none:!0}},valueLabels:!0,axes:{y:{references:[{stat:"median"}]}}}),pe=e=>({test:e}),Se=(e,s=!1)=>({chart:"histogram",fields:{y:pe(e),color:{none:!0}},...s?{normalCurve:!0}:{}});function ut(e,s,i,n){const c=[...e].sort((u,D)=>K(D)-K(u))[0],o=e.find(u=>n.isPassRate(u)&&ke(u,c))??c,r=e.filter(u=>u!==o),$=o.level==="lot"&&"waferIndices"in o.highlight?o.highlight.waferIndices?.length:void 0,f=$!==void 0&&i?` on ${$}/${i} wafers`:"",a=!n.isPassRate(o),h=o.comparison.family==="sector"?"the other sectors":"the rest of the wafer";let v=a?`${Z(o)}: ${ae(o)} ${W(z(o))} points higher than ${h}${f}`:`${Z(o)}: pass rate ${W(z(o))} points below ${h}${f}`;const N=`${v} \u2014 about ${_(K(o))} dies lost`,w=at(o,s,n.isFailBin).map(u=>({f:u,share:z(u)/(z(o)||1)})).filter(u=>a||u.share>=nt).slice(0,rt);if(a)for(const{f:u}of w)v+=`, ${ae(u)} ${W(z(u))} points higher`;else if(w.length>0){const u=w.reduce((F,R)=>F+R.share,0)<=1.000000001,D=u&&w[0].share>.5?"mostly ":"";w.forEach(({f:F},R)=>{v+=R===0?`; ${u?D:""}`:", ",v+=ae(F)+(R===0?u?` accounts for ${W(z(F))} of those points`:` is ${W(z(F))} points higher`:u?` for ${W(z(F))}`:` ${W(z(F))} points higher`)})}v+=` \u2014 about ${_(K(o))} dies lost`;const B=r.filter(u=>!ke(u,o));B.length>0&&(v+=` (also seen as ${Be(B)})`);const g=a?ae(o):"pass rate";return{kind:"loss",impact:"low",shareOfDies:0,diesLost:K(o),affected:K(o),measure:"",severity:o.severity,text:v,reason:N,brief:`${Z(o)}: ${g}, ${_(K(o))} dies`,subject:Z(o),target:ee(o),chips:[...a?[o]:[],...w.map(({f:u})=>u)].map(ct),findingIds:[o.id,...r.map(u=>u.id)],testNumbers:[],chart:a?{chart:"bar",fields:{x:he(o),color:{builtin:o.variable.kind==="softBin"?"sbin":"hbin"}},stack:"percent"}:o.level==="lot"?{chart:"heatmap",fields:{x:{builtin:"wafer"},rows:he(o),y:{builtin:"yield"}}}:Oe(he(o),{builtin:"yield"})}}function ht(e,s){return e>=tt||s>=it?"high":e>=et||s>=st?"medium":"low"}function pt(e){const s=i=>i.stats.yieldPercent==null?0:i.stats.analyzedDies*(1-i.stats.yieldPercent/100);return e.level==="wafer"?s(e):e.perWafer.reduce((i,n)=>i+s(n.summary),0)}function mt(e){return e.level==="wafer"?e.stats.analyzedDies:e.perWafer.reduce((s,i)=>s+i.summary.stats.analyzedDies,0)}const Fe=e=>e.id.startsWith("inter-wafer:yield:");function gt(e){const s=[];for(const i of e.findings){if(!Fe(i)||i.effect.direction!=="lower")continue;const n="waferIndices"in i.highlight?i.highlight.waferIndices?.[0]:void 0,c=n===void 0?void 0:e.perWafer.find(o=>o.waferIndex===n)?.summary.stats.analyzedDies;c!==void 0&&s.push({kind:"loss",impact:"low",shareOfDies:0,diesLost:z(i)*c,affected:z(i)*c,measure:"",severity:i.severity,text:`${i.summary.replace(/ percentage points lower than the lot median$/," points below the lot median")} \u2014 about ${_(z(i)*c)} dies lost`,reason:`${i.summary.replace(/ percentage points lower than the lot median$/," points below the lot median")} \u2014 about ${_(z(i)*c)} dies lost`,brief:`${i.comparison.left}: yield, ${_(z(i)*c)} dies`,subject:i.comparison.left,target:ee(i),chips:[],findingIds:[i.id],testNumbers:[],chart:{chart:"control",fields:{x:{builtin:"waferOrder"},y:{builtin:"yield"}}}})}return s}function bt(e,s){if(e.level==="wafer"){const o=e.stats.testFailures?.[s];return o?{keys:new Set(o.dieKeys),lost:o.lostDies}:void 0}const i=new Set;let n=0,c=!1;for(const o of e.perWafer){const r=o.summary.stats.testFailures?.[s];if(r){c=!0,n+=r.lostDies;for(const $ of r.dieKeys)i.add(`${o.waferIndex}:${$}`)}}return c?{keys:i,lost:n}:void 0}function $t(e,s){const i=e.stats,n=[],c=r=>Oe({builtin:e.level==="lot"?"wafer":"ring"},{passRate:r}),o=(r,$,f,a,h,v,N=h,w=!1)=>{if(f<=0||a<=0)return;s.add(r);const B=bt(e,r),g=B?Math.min(B.lost,f):f,u=f-g,D=f/a*100;n.push({testNumber:r,label:$,verb:h,plainVerb:N,failDies:f,passingDies:u,keys:B?.keys,item:{kind:"loss",impact:"low",shareOfDies:0,diesLost:g,affected:g,measure:"",severity:"info",text:`${$} ${h} on ${_(f)} of ${_(a)} dies (${D.toFixed(1)}%)`+(u>0?`; ${_(u)} of them are binned as passing, so about ${_(g)} dies lost`:""),reason:`${$} ${h} on ${_(f)} of ${_(a)} dies (${D.toFixed(1)}%)`,brief:u>0?`${$}: ${v}, ${_(g)} dies lost`:`${$}: ${_(f)} dies ${v}`,subject:$,target:{kind:"test",testNumber:r},chips:[],findingIds:[],testNumbers:[r],chart:w||e.level==="lot"?c(r):Se(r)}})};for(const r of i.testSpecYield??[]){const $=r.failHighDies===0?"is below its low limit":r.failLowDies===0?"is above its high limit":`is outside its limits (${_(r.failLowDies)} low, ${_(r.failHighDies)} high)`;o(r.testNumber,r.label,r.failLowDies+r.failHighDies,r.totalDies,$,"outside limits",r.failLowDies>0&&r.failHighDies>0?"is outside its limits":$)}for(const r of i.functionalYield??[])o(r.testNumber,r.label,r.failDies,r.totalDies,"fails","fail","fails",!0);return n}const yt=.5,wt=2,Nt=2,le=5;function vt(e,s,i,n){const c=new Set,o=new Map,r=new Map,$=[...e].sort((f,a)=>a.failDies-f.failDies||f.testNumber-a.testNumber);for(const f of $){const a=f.keys;if(n>0&&f.failDies/n<Q){c.add(f);continue}let h;if(a&&a.size>0&&n>0)for(const w of s){const B=i.get(w);if(!B||B.size===0)continue;let g=0;for(const D of a)B.has(D)&&g++;const u=g/a.size;u>=yt&&u>=wt*(B.size/n)&&(!h||g>h.inside)&&(h={item:w,inside:g})}if(!h){c.add(f);continue}const v=o.get(h.item)??0;if(v<Nt){const w=h.inside===f.failDies?"all":_(h.inside);h.item.text+=`. ${f.label} ${f.verb} on ${H(f.failDies,"die")}, ${w} of them in ${h.item.subject}`,o.set(h.item,v+1)}const N=r.get(h.item)??0;N<le?(h.item.chips.push({label:f.label,target:f.item.target}),r.set(h.item,N+1)):h.item.moreTests=(h.item.moreTests??0)+1,h.item.testNumbers.push(f.testNumber)}return e.filter(f=>c.has(f))}function te(e){return{kind:"signal",impact:"low",shareOfDies:0,diesLost:0,affected:e.affected,measure:e.measure,severity:e.severity,text:e.text,reason:e.reason??e.text,brief:e.brief,subject:e.subject,target:e.target,chips:[],findingIds:e.findingIds??[],testNumbers:e.testNumbers??[],chart:e.chart}}const me=e=>Math.abs(e)<Ze?0:Math.min(1,(Math.abs(e)/Qe)**2),Y=e=>`${Math.abs(e).toFixed(1)}\u03C3`,kt=e=>e.variable.kind==="test"&&e.variable.measure!=="limitFailRate"&&_e.has(e.comparison.family)&&Number.isFinite(e.effect.effectSize??NaN)&&!e.id.startsWith("drift:");function St(e,s,i){const n=new Map;for(const r of e)!kt(r)||r.variable.index===void 0||(n.get(r.variable.index)??n.set(r.variable.index,[]).get(r.variable.index)).push(r);const c=r=>(we(r)??r.stats.sampleSizeLeft)*me(r.effect.effectSize??0),o=[];for(const[r,$]of[...n].sort((f,a)=>f[0]-a[0])){const f=[...$].sort((g,u)=>c(u)-c(g)),a=f[0],h=a.effect.effectSize??0;if(c(a)===0)continue;const v=Ne(a);let N=s.find(g=>g.target.kind==="test"&&g.target.testNumber===r)??s.find(g=>g.testNumbers.includes(r))??s.find(g=>f.some(u=>g.findingIds.includes(u.id))),w=0;for(const g of N?[]:s){const u=i.get(g);if(!u||u.size===0||v.size===0)continue;let D=0;for(const F of v)u.has(F)&&D++;D>=ue*Math.min(u.size,v.size)&&D>w&&(w=D,N=g)}if(N){N.text+=`. ${a.summary}`,N.testNumbers.includes(r)||(N.chips.filter(u=>u.target.kind==="test"||u.shift).length<le?N.chips.push({label:a.variable.label,target:ee(a),shift:!0}):N.moreTests=(N.moreTests??0)+1,N.testNumbers.push(r));for(const g of f)N.findingIds.includes(g.id)||N.findingIds.push(g.id);continue}const B=we(a)??a.stats.sampleSizeLeft;o.push(te({affected:c(a),measure:Y(h),severity:a.severity,text:`${a.summary}: a shift of ${Y(h)} over ${H(B,"die")}`+(f.length>1?` (also seen as ${Be(f.slice(1))})`:""),reason:`${a.summary}: a shift of ${Y(h)} over ${H(B,"die")}`,brief:`${Z(a)}: ${a.variable.label} ${a.effect.direction}`,subject:Z(a),target:ee(a),findingIds:f.map(g=>g.id),testNumbers:[r],chart:{chart:"box",fields:{x:he(a),y:pe(r),color:{none:!0}},axes:{y:{references:[{stat:"median"}]}}}}))}return o}function Mt(e,s){return e.filter(i=>i.id.startsWith("drift:")).map(i=>{const n=i.variable.kind==="yield",c=i.effect.effectSize??0;return te({affected:s*(n?Math.abs(c):me(c)),measure:n?`${W(Math.abs(c))} pts`:Y(c),severity:i.severity,text:i.summary,brief:`${i.variable.label}: drifts across the wafers`,subject:i.variable.label,target:ee(i),findingIds:[i.id],...i.variable.index!==void 0?{testNumbers:[i.variable.index]}:{},chart:{chart:"control",fields:{x:{builtin:"waferOrder"},y:n||i.variable.index===void 0?{builtin:"yield"}:pe(i.variable.index)}}})})}function It(e,s,i){return(e.stats.capability??[]).filter(n=>n.hasSpec&&n.ppk!==null&&n.ppk!==void 0&&n.ppk<Je&&!s.has(n.testNumber)).map(n=>{const c=n.ppk,o=qe(3*c);return te({affected:i*o,measure:`Ppk ${c.toFixed(2)}`,severity:"notable",text:`${n.label} has Ppk ${c.toFixed(2)} against its limits: a spread that would put about ${W(o)}% of the dies outside them`,brief:`${n.label}: Ppk ${c.toFixed(2)}`,subject:n.label,target:{kind:"test",testNumber:n.testNumber},testNumbers:[n.testNumber],chart:Se(n.testNumber,!0)})})}const ge=.05,xt=8,Le=.01,_t=.05,Dt=.25,Bt=1,Ot=3,je=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;function Ft(e,s,i,n=[]){const c={items:[],compared:[],possible:[]},o=e.perWafer;if(o.length<4)return c;const r=Xe(o.map(t=>({metadata:t.summary.wafer,dieCount:t.summary.stats.totalDies})),{facetableOnly:!0,curation:s}).filter(t=>t.splittable&&t.values.length<=Math.max(2,Math.floor(o.length/2)));if(r.length===0)return c;const $=Ye(r.map(t=>({key:t.key,groupOf:o.map(d=>Me(d.summary.wafer,t.key,s))}))),f=t=>e.perWaferTestStats?.find(d=>d.waferIndex===t.waferIndex)?.tests??t.summary.stats.perTestStats??[],a=o.map(t=>new Map(f(t).filter(d=>d.count>=2&&Number.isFinite(d.mean)).map(d=>[d.testNumber,d]))),h=new Map;for(const t of a)for(const[d,p]of t)h.has(d)||h.set(d,p.label);const v=o.map(t=>t.summary.stats.analyzedDies),N=o.map(t=>t.summary.stats.yieldPercent===null?void 0:t.summary.stats.yieldPercent/100),w=o.map(t=>{const d=t.summary.stats.hardBinCounts,p=d?Object.values(d).reduce((m,y)=>m+y,0):0;return d&&p>0?new Map(Object.entries(d).map(([m,y])=>[Number(m),y/p])):void 0}),B=(t,d,p,m)=>{let y;for(const[x,L]of t){const k=L.map(d),j=[...t].filter(([S])=>S!==x).flatMap(([,S])=>S.map(d));if(k.length<2||j.length<2)continue;const A=k.reduce((S,O)=>S+O,0)/k.length-j.reduce((S,O)=>S+O,0)/j.length,b=A/p;(!y||Math.abs(b)>Math.abs(y.d)+1e-9||Math.abs(Math.abs(b)-Math.abs(y.d))<=1e-9&&(L.length<y.groupWafers||L.length===y.groupWafers&&A>0))&&(y=m(x,L,b,A>0))}if(y&&t.size===2){const[x,L]=[...t].find(([k])=>k!==y.group);y.other={group:x,wafers:L.length}}return y},g=[],u=[],D=[];for(const[t,d]of[...h].sort((p,m)=>p[0]-m[0])){const p=a.flatMap(y=>{const x=y.get(t);return x&&Number.isFinite(x.stddev)?[x.stddev**2]:[]}),m=p.length?Math.sqrt(p.reduce((y,x)=>y+x,0)/p.length):NaN;m>0&&D.push({testNumber:t,label:d,values:a.map(y=>y.get(t)?.mean),scale:m})}D.push({testNumber:NaN,label:"Yield",values:N,scale:1,scope:v});const F=[...e.stats.regionYield?.ring??[]].sort((t,d)=>t.yieldPercent-d.yieldPercent)[0];if(F&&o.length>0){const t=o.map(d=>{const p=d.summary.stats.regionYield?.ring?.find(m=>m.key===F.key);return p?p.yieldPercent/100:void 0});if(t.every(d=>d!==void 0)){const d=o.map(p=>p.summary.stats.regionYield?.ring?.find(m=>m.key===F.key)?.n??0);D.push({testNumber:NaN,label:`${F.label} pass rate`,values:t,scale:1,region:F.label,regionValue:Ue(Ve(F.key).ring),scope:d})}}for(const t of D)for(const{partition:d,used:p,fitted:m,allowedFor:y}of Ke(t.values,$)){const x=d.id,L=d.keys;if(!m)continue;const k=B(m.byGroup,b=>p[b],t.scale,(b,P,S,O)=>({part:x,keys:L,testNumber:t.testNumber,label:t.label,group:b,members:P,groupWafers:P.length,groupDies:P.reduce((T,I)=>T+v[I],0),d:S,higher:O,p:m.p,...t.region?{region:t.region,regionValue:t.regionValue}:{},...y?{allowedFor:y}:{}}));if(!k)continue;const j=k.members.map(b=>p[b]),A=[...m.byGroup].filter(([b])=>b!==k.group).flatMap(([,b])=>b.map(P=>p[P]));if(t.scope){const b=S=>S.reduce((O,T)=>O+t.scope[T],0),P=[...m.byGroup].filter(([S])=>S!==k.group).flatMap(([,S])=>S);k.lost=(k.higher?b(P):b(k.members))*Math.abs(k.d)}if(k.separated=$e(j)>be(A)||be(j)<$e(A),Number.isNaN(t.testNumber)){if(i&&!t.region){let b=0;const P=new Set(w.flatMap(O=>O?[...O.keys()]:[])),S=o.map((O,T)=>T).filter(O=>!k.members.includes(O)&&N[O]!==void 0);for(const O of P){if(i.includes(O))continue;const T=U=>U.reduce((ze,Pe)=>ze+(w[Pe]?.get(O)??0),0)/Math.max(1,U.length),I=(T(k.members)-T(S))*(k.higher?-1:1);I>b&&(b=I,k.bin=O)}}u.push(k)}else g.push(k)}const R=Ce([...g,...u].map(t=>t.p)),C=t=>R[t],ne=new Map;g.forEach((t,d)=>{const p=t.groupDies*me(t.d);C(d)>=ge||p===0||(ne.get(t.part)??ne.set(t.part,[]).get(t.part)).push({c:t,q:C(d),weight:p})});const fe=[...new Set([...g,...u].flatMap(t=>t.keys))].map(t=>ie(t,s)),q=t=>je(t.map(d=>ie(d,s))),G=t=>{const d=`${ie(t.keys[0],s)} ${t.group}`;if(t.keys.length===1)return d;const p=o[t.members[0]].summary.wafer,m=t.keys.slice(1).map(y=>`${ie(y,s)} ${Me(p,y,s)??""}`.trim());return`${d} (${je(m)} group${m.length===1?"s":""} the same wafers)`},V=t=>t.allowedFor?`, allowing for ${q(t.allowedFor)}`:"",X=t=>{const d=$.find(m=>m.id===t),p=d?Ge(d,$):[];return p.length===0?"":`. ${p.map(m=>`${q(m.partition.keys.slice(0,1))} puts ${m.agree} of ${m.of} wafers in the same groups`).join("; ")}, so the wafers cannot fully tell ${p.length===1?"the two":"them"} apart`},J=t=>`${ie(t.keys[0],s)} ${t.other.group}`,se=t=>t.other?`${t.label} is ${t.higher?"higher":"lower"} on ${G(t)} than on ${J(t)} (${t.groupWafers} and ${t.other.wafers} wafers)`:`${t.label} is ${t.higher?"higher":"lower"} on ${G(t)} (${t.groupWafers} of ${o.length} wafers) than on the other wafers`,re=[...ne].map(([t,d])=>{d.sort((I,U)=>Math.abs(U.c.d)-Math.abs(I.c.d)||U.weight-I.weight||I.c.testNumber-U.c.testNumber);const p=d.reduce((I,U)=>Math.max(I,U.weight),0),m=d[0].c.keys,y=m[0],x=q(m),[L,...k]=d,j=L.c,A=`${se(j)}: a shift of ${Y(j.d)}${V(j)}`,b=k.slice(0,2).map(({c:I})=>`${I.label} ${I.higher?"higher":"lower"} on ${I.keys.length>1?ie(I.keys[0],s)+" ":""}${I.group} (${Y(I.d)})`),P=k.length-b.length,S=d.length,O=(S===1?`${A}, each wafer one value (q ${ye(L.q)})`:`${S} tests differ by ${x}. Largest: ${A}, each wafer one value (q ${ye(L.q)}); next: ${b.join(", ")}${P>0?`, and ${P} more`:""}`)+X(t),T=te({affected:p,measure:Y(j.d),severity:L.q<.001?"unusual":"notable",text:O,reason:S===1?A:`${S} tests differ by ${x}. Largest: ${A}`,brief:S===1?`${x} ${j.group}: ${j.label} ${j.higher?"higher":"lower"}`:`${x}: ${S} tests differ`,subject:x,target:{kind:"test",testNumber:j.testNumber},testNumbers:d.map(I=>I.c.testNumber),chart:S>1?{chart:"heatmap",level:"wafer",aggregate:"mean",normalize:"zscore",fields:{x:{meta:y},y:{tests:d.slice(0,xt).map(I=>I.c.testNumber)}}}:{chart:"box",level:"wafer",aggregate:"mean",fields:{x:{meta:y},y:pe(j.testNumber),color:{meta:y}}}});return S>1&&(T.chips=d.slice(0,le).map(({c:I})=>({label:`${I.label} ${Y(I.d)}`,target:{kind:"test",testNumber:I.testNumber}})),S>le&&(T.moreTests=S-le)),T});u.forEach((t,d)=>{const p=C(g.length+d),m=t.lost??t.groupDies*Math.abs(t.d);if(p>=ge||Math.abs(t.d)<Le)return;const y=q(t.keys),x=`${(Math.abs(t.d)*100).toFixed(1)} points`,L=`${t.bin!==void 0?`, mostly in hard bin ${t.bin}`:""}${V(t)}`,k=t.other?`${t.label} is ${x} ${t.higher?"higher":"lower"} on ${G(t)} than on ${J(t)} (${t.groupWafers} and ${t.other.wafers} wafers)`:`${t.label} is ${x} ${t.higher?"higher":"lower"} on ${G(t)} (${t.groupWafers} of ${o.length} wafers) than on the other wafers`;re.push(te({affected:m,measure:x,severity:p<.001?"unusual":"notable",text:`${k}${L}, each wafer one value (q ${ye(p)})${X(t.part)}`,reason:`${k}${L}`,brief:`${y} ${t.group}: ${t.region?"ring pass rate":"yield"} ${t.higher?"higher":"lower"}`,subject:y,target:{kind:"group",field:t.keys[0],fields:t.keys},testNumbers:[],chart:{chart:"bar",fields:{x:{meta:t.keys[0]},y:{builtin:"yield"},color:{meta:t.keys[0]}},valueLabels:!0,...t.region?{where:{conditions:[{field:{builtin:"ring"},values:[t.regionValue??t.region]}]}}:{}}}))});const de=v.reduce((t,d)=>t+d,0),oe=new Set([...g.filter((t,d)=>C(d)<ge&&t.groupDies*me(t.d)>0).map(t=>t.part),...u.filter((t,d)=>C(g.length+d)<ge&&Math.abs(t.d)>=Le).map(t=>t.part)]),ce=[...g.filter(t=>Math.abs(t.d)>=Bt),...u.filter(t=>(t.lost??0)>=Math.min(Q*de,...n.map(d=>Dt*d)))].filter(t=>t.separated&&t.p<_t&&!oe.has(t.part)),l=new Map;for(const t of ce)(l.get(`${t.part}|${t.group}`)??l.set(`${t.part}|${t.group}`,[]).get(`${t.part}|${t.group}`)).push(t);const M=[],E=g.length+u.length;for(const t of l.values()){const d=t.find(b=>Number.isNaN(b.testNumber)),p=t.filter(b=>!Number.isNaN(b.testNumber)||!d||b.higher===d.higher);if(p.length<2)continue;const m=p[0],y=b=>Number.isNaN(b.testNumber)?`${b.label} ${b.higher?"higher":"lower"} by ${(Math.abs(b.d)*100).toFixed(1)} points`:`${b.label} ${b.higher?"higher":"lower"} (${Y(b.d)})`,x=m.other?`than on ${J(m)} (${m.groupWafers} and ${m.other.wafers} wafers)`:`than on the other wafers (${m.groupWafers} of ${o.length})`,L=`${G(m)}: ${p.map(y).join("; ")} ${x}`,k=q(m.keys),j=p.reduce((b,P)=>Math.max(b,P.lost??0),0),A=te({affected:j,measure:`${p.length} measures`,severity:"info",text:`Possibly ${L}. No wafer of the group overlaps the others on ${p.length===2?"either":`any of ${p.length}`}, but the sample is too small to confirm it once ${E} comparisons are allowed for`,reason:`Possibly ${L}`,brief:`${k} ${m.group}: possible, not confirmed`,subject:k,target:{kind:"group",field:m.keys[0],fields:m.keys},testNumbers:p.filter(b=>!Number.isNaN(b.testNumber)).map(b=>b.testNumber),chart:{chart:"bar",fields:{x:{meta:m.keys[0]},y:{builtin:"yield"},color:{meta:m.keys[0]}},valueLabels:!0}});M.push(A)}return M.sort((t,d)=>d.affected-t.affected),{items:re,compared:fe,possible:M.slice(0,Ot)}}export function groupColouredChart(e,s){const i=e.fields?.x,n=e.fields?.color;return!s||e.chart!=="bar"||!i||Array.isArray(i)||!("builtin"in i)||i.builtin!=="wafer"||!n||!("none"in n)?e:{...e,fields:{...e.fields,x:[{slot:"groupBy"},{builtin:"wafer"}],color:{follow:"groupBy"}}}}function Lt(e){return e.map(s=>te({affected:s.passingDies,measure:"",severity:"notable",text:`${s.label} ${s.plainVerb} on ${H(s.passingDies,"die")} binned as passing`,brief:`${s.label}: ${_(s.passingDies)} dies out of limits, binned passing`,subject:s.label,target:s.item.target,testNumbers:[s.testNumber],chart:Se(s.testNumber)}))}function jt(e,s){const i=s.passBins&&s.passBins.length>0?`; pass ${Te([s.passBins])}`:"";if(e.level==="wafer"){const a=e.stats.yieldPercent;return a==null?`${_(e.stats.totalDies)} dies, no bin data to judge yield by.`:`Yield ${a.toFixed(1)}% (${_(e.stats.totalDies)} dies${i}).`}const n=e.lotYieldSeries.map(a=>a.yieldPercent).filter(a=>typeof a=="number");if(n.length===0)return`${H(e.stats.waferCount,"wafer")}, no bin data to judge yield by.`;const c=n.reduce((a,h)=>a+h,0)/n.length,o=e.perWafer.reduce((a,h)=>a+h.summary.stats.totalDies,0),[r,$]=[$e(n).toFixed(1),be(n).toFixed(1)],f=r!==$?`, range ${r}\u2013${$}%`:"";return`Yield ${c.toFixed(1)}% (mean of ${H(n.length,"wafer")}, ${_(o)} dies${i})${f}.`}function Et(e,s,i=[]){const n=[],c=e.level==="wafer"?e.stats.testsConsidered.length:new Set(e.perWafer.flatMap(a=>a.summary.stats.testsConsidered)).size,o=e.level==="wafer"?e.stats.hardBinsConsidered.length:new Set(e.perWafer.flatMap(a=>a.summary.stats.hardBinsConsidered)).size,r=e.stats.testValueAnalysis?.state;if(c>0&&r!=="off"&&n.push(H(c,"test")+(r==="skipped"?" (against their limits only)":"")),o>0&&n.push(H(o,"hard bin")),n.push("the ring, quadrant and sector regions"),e.level==="lot"&&e.stats.waferCount>=3){const a=e.findings.filter(Fe);n.push(a.length===0?"wafer-to-wafer yield (no outlier wafers)":`wafer-to-wafer yield (${H(a.length,"outlier wafer")})`),e.stats.waferCount>=We&&n.push("the yield trend across the wafers (input order)"),i.length&&n.push(`the tests between the groups of ${i.join(", ")} (each wafer one value)`)}const $=e.findings.filter(a=>!s.has(a.id)).length,f=$>0?` ${H($,"smaller finding")} not listed above.`:" Nothing else was found.";return`Compared: ${n.join(", ")}.${f}`}export function synthesisSource(e){return e.level==="lot"&&e.perWafer.length===1?e.perWafer[0].summary:e}const Ee=new WeakMap;export function buildSynthesis(e,s={}){const i=`${s.passBins?.join(",")??"-"}|${s.attributes?JSON.stringify(s.attributes):"-"}`;let n=Ee.get(e);n||Ee.set(e,n=new Map);const c=n.get(i),o=e.findings;if(c&&c.findings.length===o.length&&c.findings.every(($,f)=>$===o[f]))return c.synthesis;const r=zt(e,s);return Object.freeze(r.items),r.items.forEach(Object.freeze),r.possible&&(r.possible.forEach(Object.freeze),Object.freeze(r.possible)),r.also&&(Object.freeze(r.also.items),r.also.items.forEach(Object.freeze),Object.freeze(r.also)),n.set(i,{findings:[...o],synthesis:Object.freeze(r)}),r}function zt(e,s){const i=synthesisSource(e),n=i.findings,c=i.level==="lot"?i.stats.waferCount:void 0,o=s.passBins,r=new Map(n.map(l=>[l.id,l])),$=(i.level==="wafer"?[i]:i.perWafer.map(l=>l.summary)).every(l=>(l.stats.hardBinsConsidered??[]).length===0),f=l=>o!==void 0&&ve(l)&&Ae(l.variable.kind,l.variable.bin??NaN,o,!$),a={isPassRate:l=>l.variable.kind==="yield"||o?.length===1&&f(l),isFailBin:l=>o!==void 0&&ve(l)&&!f(l)},h=n.filter(l=>_e.has(l.comparison.family)&&K(l)>0&&(a.isPassRate(l)&&l.effect.direction==="lower"||a.isFailBin(l)&&l.effect.direction==="higher")),N=h.some(l=>l.variable.kind==="hardBin")?h.filter(l=>l.variable.kind!=="softBin"):h,w=[],B=new Map,g=new Set;for(const l of ot(N)){const M=l.map(d=>N[d]),E=ut(M,n,c,a);w.push(E);const t=E.target.kind==="finding"?E.target.id:void 0;B.set(E,Ne(M.find(d=>d.id===t)??M[0]))}for(const l of n.filter(M=>M.variable.kind==="spatialPattern")){const M=new Set((l.relatedIds??[]).filter(p=>r.has(p))),E=w.find(p=>p.findingIds.some(m=>M.has(m)));if(!E)continue;const t=l.level==="lot"&&"waferIndices"in l.highlight?l.highlight.waferIndices?.length:void 0,d=t!==void 0&&c?` on ${t}/${c} wafers`:"";E.text=`${l.variable.label} pattern${d}. ${E.text}`,E.reason=`${l.variable.label} pattern${d}. ${E.reason}`,E.chips.unshift({label:`${l.variable.label} pattern`,target:ee(l)}),E.findingIds.unshift(l.id,...[...M].filter(p=>!w.some(m=>m.findingIds.includes(p))))}const u=mt(i),D=new Set,F=$t(i,D),R=[...w],C=vt(F,R,B,u);i.level==="lot"&&w.push(...gt(i)),w.push(...C.map(l=>l.item));const ne=new Set(C.filter(l=>u>0&&l.item.diesLost/u>=Q).map(l=>l.testNumber));w.push(...St(n,[...R,...C.map(l=>l.item)],B),...Mt(n,u),...It(i,D,u),...Lt(F.filter(l=>l.passingDies>0&&!ne.has(l.testNumber))));let fe=[],q=[];if(i.level==="lot"){const l=Ft(i,s.attributes,s.passBins,w.filter(M=>M.kind==="loss").map(M=>M.diesLost));fe=l.compared,q=l.possible;for(const M of l.items){const E=M.testNumbers[0],t=M.testNumbers.length===1?w.find(d=>d.target.kind==="test"&&d.target.testNumber===E)??w.find(d=>d.testNumbers.includes(E)):void 0;t?t.text+=`. ${M.text}`:w.push(M)}}const G=pt(i),V=w.filter(l=>u>0&&l.affected/u>=Q);for(const l of V)l.shareOfDies=l.affected/u,l.impact=ht(l.shareOfDies,l.kind==="loss"&&G>0?l.diesLost/G:0),l.measure||(l.measure=`${(l.shareOfDies*100).toFixed(1)}%`);const X=l=>`${String(l.testNumbers[0]??"").padStart(10,"0")}${l.findingIds[0]??""}`;V.sort((l,M)=>M.affected-l.affected||(X(l)<X(M)?-1:X(l)>X(M)?1:0));const J=V.slice(0,Ie),se=V.slice(Ie);for(const l of[...J,...se])for(const M of l.findingIds)g.add(M);const re=se.length>0?{items:se.slice(0,xe),more:Math.max(0,se.length-xe)}:void 0,de=i.level==="lot"?"region, fail bin or wafer":"region or fail bin",oe=n.filter(l=>l.severity==="unusual"&&!g.has(l.id)).length,ce=J.length===0?oe>0?`No ${de} costs as much as ${W(Q)} yield points, though ${H(oe,"finding")} below ${oe===1?"is":"are"} marked unusual.`:`Nothing stands out: no ${de} costs as much as ${W(Q)} yield points.`:void 0;return{headline:jt(i,s),items:J,...re?{also:re}:{},...q.length?{possible:q}:{},...ce?{nothing:ce}:{},checked:Et(i,g,fe)}}export const synthesisKey=e=>e.target.kind==="finding"?`finding:${e.target.id}`:e.target.kind==="group"?`group:${e.target.field}`:`test:${e.target.testNumber}`,SYNTHESIS_POSSIBLE_HEADING="Possible, not confirmed",SYNTHESIS_ALSO_HEADING=`Also, each affecting at least ${(Q*100).toFixed(0)}% of the dies`,synthesisRowShare=e=>e.measure,synthesisMoreTests=e=>e.moreTests?`and ${e.moreTests} more test${e.moreTests===1?"":"s"}`:void 0;export function synthesisText(e){return[e.headline,...e.nothing?[e.nothing]:[],...e.items.map((s,i)=>`${i+1}. ${s.text}`),...e.also?[`${SYNTHESIS_ALSO_HEADING}: ${e.also.items.map(s=>`${s.brief} (${synthesisRowShare(s)})`).join("; ")}${e.also.more?`; and ${e.also.more} more`:""}.`]:[],...e.possible?[`${SYNTHESIS_POSSIBLE_HEADING}:`,...e.possible.map(s=>`- ${s.text}`)]:[],e.checked].join(`
1
+ import{listInWords as tt,maxOf as Ne,minOf as Se}from"../core/utils.js";import{isPassBin as st,passBinsLabel as nt}from"../core/passBins.js";import{DRIFT_MIN_WAFERS as it}from"./lotDrift.js";import{isOneBinCluster as rt}from"./filterFindings.js";import{plainBinTerms as Me}from"../renderer/fmt.js";import{isProportionFinding as Ae}from"./findingText.js";import{PATTERN_LABELS as at}from"./patternClassification.js";import{benjaminiHochberg as ot,normalUpperTail as lt}from"./math.js";import{formatP as xe}from"./groupCompare.js";import{adjustedFits as ft,comparableGrouping as ct,mergePartitions as dt,overlapping as ut}from"./groupEffects.js";import{ringPlotValue as ht}from"./dieRegions.js";import{parseRegionKey as mt}from"./regions.js";import{attributeLabel as te,buildFacetTable as pt,facetValueOf as je}from"./facets.js";export const strengthOf=e=>e==="unusual"?"high":e==="notable"?"medium":"low";const Te={high:0,medium:1,low:2},gt=1,bt=2,$t=.5,We=3,oe=.01,yt=.015,wt=.04,vt=.15,kt=.4,It=.1,Nt=.25,Pe=new WeakSet,De=new WeakSet,se=.5,St=.1,Mt=2,Re=new Set(["ring","quadrant","sector","reticle-position","test-site","cluster","edge-arc"]);function le(e){if(e.stats.method==="wafer-finding-frequency")return;const t=e.highlight;return"dieKeysByWafer"in t&&t.dieKeysByWafer?Object.values(t.dieKeysByWafer).reduce((r,o)=>r+o.length,0):"dieKeys"in t&&t.dieKeys&&t.dieKeys.length>0?t.dieKeys.length:e.level==="lot"?void 0:e.stats.sampleSizeLeft}function Q(e){const t=e.highlight??{kind:"none"},r=new Set;if("dieKeysByWafer"in t&&t.dieKeysByWafer)for(const[o,u]of Object.entries(t.dieKeysByWafer))for(const f of u)r.add(`${o}:${f}`);else if("dieKeys"in t&&t.dieKeys)for(const o of t.dieKeys)r.add(o);return r}const E=e=>Math.abs(e.effect.absoluteDelta??0),W=e=>E(e)*(le(e)??0),R=e=>(e*100).toFixed(1),ne=e=>{const t=e.variable.label.replace(/ \(same dies\)$/,"").replace(/^HBin and SBin (\d+)/,"HBin $1").replace(/^(HBin \d+(?: \([^)]*\))?) and SBin .*$/,"$1");return Me(t)},z=e=>Math.round(e).toLocaleString("en-GB"),j=(e,t,r=`${t}s`)=>`${z(e)} ${e===1?t:r}`;function K(e){const t=e.comparison.left;return e.comparison.family==="quadrant"&&!/quadrant/i.test(t)?`${t} quadrant`:t}const Ce=rt;function xt(e){const t=e.map((l,a)=>a),r=l=>t[l]===l?l:t[l]=r(t[l]),o=e.map(Q),u=(l,a)=>{const d=o[l].size<=o[a].size?o[l]:o[a],b=d===o[l]?o[a]:o[l];let y=0;for(const w of d)b.has(w)&&y++;return y},f=e.map((l,a)=>a).filter(l=>Ce(e[l])),s=e.map((l,a)=>a).filter(l=>!Ce(e[l]));for(let l=0;l<s.length;l++)for(let a=l+1;a<s.length;a++){const d=Math.min(o[s[l]].size,o[s[a]].size);d>0&&u(s[l],s[a])>=se*d&&(t[r(s[l])]=r(s[a]))}for(const l of f){let a=-1,d=0;for(const b of s){if(_e(e[b])&&e[b].variable.bin!==e[l].variable.bin)continue;const y=u(l,b);y>d&&y>=se*o[l].size&&y>=se*W(e[b])&&(a=b,d=y)}a>=0&&(t[l]=r(a))}const c=new Map;return e.forEach((l,a)=>{const d=r(a);(c.get(d)??c.set(d,[]).get(d)).push(a)}),[...c.values()]}const _e=e=>e.variable.kind==="hardBin"||e.variable.kind==="softBin",Oe=(e,t)=>e.level===t.level&&e.comparison.family===t.comparison.family&&e.comparison.left===t.comparison.left;function Dt(e,t,r){const o=f=>t.filter(s=>s.variable.kind===f&&Oe(s,e)&&s.effect.direction==="higher"&&r(s));return(o("hardBin").length>0?o("hardBin"):o("softBin")).filter(f=>f!==e).sort((f,s)=>E(s)-E(f))}const _t={ring:"rings",quadrant:"quadrants",sector:"sectors","edge-arc":"edge arcs",cluster:"clusters","reticle-position":"reticle positions","test-site":"test sites"},Ot=2;function He(e){const t=new Map;for(const o of e){const u=o.comparison.family;(t.get(u)??t.set(u,new Set).get(u)).add(K(o))}const r=[];for(const[o,u]of t)u.size<=Ot?r.push(...u):r.push(`${u.size} ${_t[o]??o}`);return r.join(", ")}const zt=e=>e.charAt(0).toUpperCase()+e.slice(1),V=e=>({kind:"finding",id:e.id}),Bt=e=>({label:zt(ne(e)),target:V(e),...e.variable.bin!==void 0&&(e.variable.kind==="hardBin"||e.variable.kind==="softBin")?{bin:{kind:e.variable.kind,bin:e.variable.bin}}:{}});function ie(e){const t=e.comparison.family;return{builtin:t==="quadrant"||t==="sector"?"quadrant":t==="reticle-position"?"reticleCell":t==="test-site"?"site":"ring"}}const ve=(e,t)=>({chart:"bar",fields:{x:e,y:t,color:{none:!0}},valueLabels:!0,axes:{y:{references:[{stat:"median"}]}}}),fe=e=>({test:e}),ze=(e,t=!1)=>({chart:"histogram",fields:{y:fe(e),color:{none:!0}},...t?{normalCurve:!0}:{}});function Et(e,t,r,o){const u=[...e].sort((m,x)=>W(x)-W(m))[0],f=e.find(m=>o.isPassRate(m)&&Oe(m,u))??u,s=e.filter(m=>m!==f),c=f.level==="lot"&&"waferIndices"in f.highlight?f.highlight.waferIndices?.length:void 0,l=c!==void 0&&r?` on ${c}/${r} wafers`:"",a=!o.isPassRate(f),d=f.comparison.family==="sector"?"the other sectors":"the rest of the wafer";let b=a?`${K(f)}: ${ne(f)} ${R(E(f))} points higher than ${d}${l}`:`${K(f)}: pass rate ${R(E(f))} points below ${d}${l}`;const y=`${b}. About ${z(W(f))} dies lost`,w=Dt(f,t,o.isFailBin).map(m=>({f:m,share:E(m)/(E(f)||1)})).filter(m=>a||m.share>=St).slice(0,Mt);if(a)for(const{f:m}of w)b+=`, ${ne(m)} ${R(E(m))} points higher`;else if(w.length>0){const m=w.reduce((S,A)=>S+A.share,0)<=1.000000001,x=m&&w[0].share>.5?"mostly ":"";w.forEach(({f:S},A)=>{b+=A===0?`; ${m?x:""}`:", ",b+=ne(S)+(A===0?m?` accounts for ${R(E(S))} of those points`:` is ${R(E(S))} points higher`:m?` for ${R(E(S))}`:` ${R(E(S))} points higher`)})}b+=`. About ${z(W(f))} dies lost`;const p=s.filter(m=>!Oe(m,f));p.length>0&&(b+=` (also seen as ${He(p)})`);const g=a?ne(f):"pass rate";return{kind:"loss",impact:"low",shareOfDies:0,diesLost:W(f),affected:W(f),measure:"",severity:f.severity,text:b,reason:y,brief:`${K(f)}: ${g}, ${z(W(f))} dies`,subject:K(f),target:V(f),chips:[...a?[f]:[],...w.map(({f:m})=>m)].map(Bt),findingIds:[f.id,...s.map(m=>m.id)],category:ce,evidenceIds:[],strength:strengthOf(f.severity),testNumbers:[],chart:a?{chart:"bar",fields:{x:ie(f),color:{builtin:f.variable.kind==="softBin"?"sbin":"hbin"}},stack:"percent"}:f.level==="lot"?{chart:"heatmap",fields:{x:{builtin:"wafer"},rows:ie(f),y:{builtin:"yield"}}}:ve(ie(f),{builtin:"yield"})}}function Be(e,t,r=!1){return r?e>=Nt?"high":e>=It?"medium":"low":e>=wt||t>=kt?"high":e>=yt||t>=vt?"medium":"low"}function Ft(e){const t=r=>r.stats.yieldPercent==null?0:r.stats.analyzedDies*(1-r.stats.yieldPercent/100);return e.level==="wafer"?t(e):e.perWafer.reduce((r,o)=>r+t(o.summary),0)}function Lt(e){return e.level==="wafer"?e.stats.analyzedDies:e.perWafer.reduce((t,r)=>t+r.summary.stats.analyzedDies,0)}const Ke=e=>e.level==="inter-wafer"&&e.comparison.family==="wafer"&&e.variable.kind==="yield"&&!qe(e),qe=e=>e.level==="inter-wafer"&&e.stats.method==="mann-kendall";function At(e){const t=[];for(const r of e.findings){if(!Ke(r)||r.effect.direction!=="lower")continue;const o="waferIndices"in r.highlight?r.highlight.waferIndices?.[0]:void 0,u=o===void 0?void 0:e.perWafer.find(f=>f.waferIndex===o)?.summary.stats.analyzedDies;u!==void 0&&t.push({kind:"loss",impact:"low",shareOfDies:0,diesLost:E(r)*u,affected:E(r)*u,measure:"",severity:r.severity,text:`${r.summary.replace(/ percentage points lower than the (.*)$/," points below the $1")}. About ${z(E(r)*u)} dies lost`,reason:`${r.summary.replace(/ percentage points lower than the (.*)$/," points below the $1")}. About ${z(E(r)*u)} dies lost`,brief:`${r.comparison.left}: yield, ${z(E(r)*u)} dies`,subject:r.comparison.left,target:V(r),chips:[],findingIds:[r.id],category:ce,evidenceIds:[],strength:strengthOf(r.severity),testNumbers:[],chart:{chart:"control",fields:{x:{builtin:"waferOrder"},y:{builtin:"yield"}}}})}return t}function jt(e,t){if(e.level==="wafer"){const f=e.stats.testFailures?.[t];return f?{keys:new Set(f.dieKeys),lost:f.lostDies}:void 0}const r=new Set;let o=0,u=!1;for(const f of e.perWafer){const s=f.summary.stats.testFailures?.[t];if(s){u=!0,o+=s.lostDies;for(const c of s.dieKeys)r.add(`${f.waferIndex}:${c}`)}}return u?{keys:r,lost:o}:void 0}function Tt(e,t){const r=e.stats,o=[],u=s=>ve({builtin:e.level==="lot"?"wafer":"ring"},{passRate:s}),f=(s,c,l,a,d,b,y=d,w=!1)=>{if(l<=0||a<=0)return;t.add(s);const p=jt(e,s),g=p?Math.min(p.lost,l):l,m=l-g,x=l/a*100;o.push({testNumber:s,label:c,verb:d,plainVerb:y,failDies:l,passingDies:m,keys:p?.keys,item:{kind:"loss",impact:"low",shareOfDies:0,diesLost:g,affected:g,measure:"",severity:"info",text:`${c} ${d} on ${z(l)} of ${z(a)} dies (${x.toFixed(1)}%)`+(m>0?`; ${z(m)} of them are binned as passing, so about ${z(g)} dies lost`:""),reason:`${c} ${d} on ${z(l)} of ${z(a)} dies (${x.toFixed(1)}%)`,brief:m>0?`${c}: ${b}, ${z(g)} dies lost`:`${c}: ${z(l)} dies ${b}`,subject:c,target:{kind:"test",testNumber:s},chips:[],findingIds:[],category:ce,evidenceIds:[],testNumbers:[s],chart:w||e.level==="lot"?u(s):ze(s)}})};for(const s of r.testSpecYield??[]){const c=s.failHighDies===0?"is below its low limit":s.failLowDies===0?"is above its high limit":`is outside its limits (${z(s.failLowDies)} low, ${z(s.failHighDies)} high)`;f(s.testNumber,s.label,s.failLowDies+s.failHighDies,s.totalDies,c,"outside limits",s.failLowDies>0&&s.failHighDies>0?"is outside its limits":c)}for(const s of r.functionalYield??[])f(s.testNumber,s.label,s.failDies,s.totalDies,"fails","fail","fails",!0);return o}const Wt=.5,Pt=2,Rt=2,Ve=5;function Ct(e,t,r,o){const u=new Set,f=new Map,s=new Map,c=[...e].sort((l,a)=>a.failDies-l.failDies||l.testNumber-a.testNumber);for(const l of c){const a=l.keys;if(o>0&&l.failDies/o<oe){u.add(l);continue}let d;if(a&&a.size>0&&o>0)for(const w of t){const p=r.get(w);if(!p||p.size===0)continue;let g=0;for(const x of a)p.has(x)&&g++;const m=g/a.size;m>=Wt&&m>=Pt*(p.size/o)&&(!d||g>d.inside)&&(d={item:w,inside:g})}if(!d){u.add(l);continue}const b=f.get(d.item)??0;if(b<Rt){const w=d.inside===l.failDies?"all":z(d.inside);d.item.text+=`. ${l.label} ${l.verb} on ${j(l.failDies,"die")}, ${w} of them in ${d.item.subject}`,f.set(d.item,b+1)}const y=s.get(d.item)??0;y<Ve?(d.item.chips.push({label:l.label,target:l.item.target}),s.set(d.item,y+1)):d.item.moreTests=(d.item.moreTests??0)+1,d.item.testNumbers.push(l.testNumber)}return e.filter(l=>u.has(l))}function re(e){const t={kind:"signal",impact:"low",shareOfDies:0,diesLost:0,affected:e.affected,measure:e.measure,severity:e.severity,text:e.text,reason:e.reason??e.text,brief:e.brief,subject:e.subject,target:e.target,chips:[],findingIds:e.findingIds??[],category:ce,evidenceIds:[],strength:strengthOf(e.severity),testNumbers:e.testNumbers??[],chart:e.chart};return e.movesValues&&Pe.add(t),t}const pe=e=>Math.abs(e)<$t?0:Math.min(1,(Math.abs(e)/bt)**2),G=e=>`${Math.abs(e).toFixed(1)}\u03C3`,Ht=e=>e.variable.kind==="test"&&e.variable.measure!=="limitFailRate"&&Re.has(e.comparison.family)&&Number.isFinite(e.effect.effectSize??NaN);function Kt(e,t,r){const o=new Map;for(const s of e)!Ht(s)||s.variable.index===void 0||(o.get(s.variable.index)??o.set(s.variable.index,[]).get(s.variable.index)).push(s);const u=s=>(le(s)??s.stats.sampleSizeLeft)*pe(s.effect.effectSize??0),f=[];for(const[s,c]of[...o].sort((l,a)=>l[0]-a[0])){const l=[...c].sort((g,m)=>u(m)-u(g)),a=l[0],d=a.effect.effectSize??0;if(u(a)===0)continue;const b=Q(a);let y=t.find(g=>g.target.kind==="test"&&g.target.testNumber===s)??t.find(g=>g.testNumbers.includes(s))??t.find(g=>l.some(m=>g.findingIds.includes(m.id))),w=0;for(const g of y?[]:t){const m=r.get(g);if(!m||m.size===0||b.size===0)continue;let x=0;for(const S of b)m.has(S)&&x++;x>=se*Math.min(m.size,b.size)&&x>w&&(w=x,y=g)}if(y){y.text+=`. ${a.summary}`,y.testNumbers.includes(s)||(y.chips.filter(m=>m.target.kind==="test"||m.shift).length<Ve?y.chips.push({label:a.variable.label,target:V(a),shift:!0}):y.moreTests=(y.moreTests??0)+1,y.testNumbers.push(s));for(const g of l)y.findingIds.includes(g.id)||y.findingIds.push(g.id);continue}const p=le(a)??a.stats.sampleSizeLeft;f.push(re({affected:u(a),movesValues:!0,measure:G(d),severity:a.severity,text:`${a.summary}: a shift of ${G(d)} over ${j(p,"die")}`+(l.length>1?` (also seen as ${He(l.slice(1))})`:""),reason:`${a.summary}: a shift of ${G(d)} over ${j(p,"die")}`,brief:`${K(a)}: ${a.variable.label} ${a.effect.direction}`,subject:K(a),target:V(a),findingIds:l.map(g=>g.id),testNumbers:[s],chart:{chart:"box",fields:{x:ie(a),y:fe(s),color:{none:!0}},axes:{y:{references:[{stat:"median"}]}}}}))}return f}function qt(e,t){return e.filter(qe).map(r=>{const o=r.variable.kind==="yield",u=r.effect.effectSize??0;return re({affected:t*(o?Math.abs(u):pe(u)),...o?{}:{movesValues:!0},measure:o?`${R(Math.abs(u))} points`:G(u),severity:r.severity,text:r.summary,brief:`${r.variable.label}: drifts across the wafers`,subject:r.variable.label,target:V(r),findingIds:[r.id],...r.variable.index!==void 0?{testNumbers:[r.variable.index]}:{},chart:{chart:"control",fields:{x:{builtin:"waferOrder"},y:o||r.variable.index===void 0?{builtin:"yield"}:fe(r.variable.index)}}})})}function Vt(e,t,r){return(e.stats.capability??[]).filter(o=>o.hasSpec&&o.ppk!==null&&o.ppk!==void 0&&o.ppk<gt&&!t.has(o.testNumber)).map(o=>{const u=o.ppk,f=lt(3*u);return re({affected:r*f,measure:`Ppk ${u.toFixed(2)}`,severity:"notable",text:`${o.label} has Ppk ${u.toFixed(2)} against its limits: a spread that would put about ${R(f)}% of the dies outside them`,brief:`${o.label}: Ppk ${u.toFixed(2)}`,subject:o.label,target:{kind:"test",testNumber:o.testNumber},testNumbers:[o.testNumber],chart:ze(o.testNumber,!0)})})}const ge=.05;export const groupsDiffer=(e,t)=>e<ge&&pe(t)>0;const Yt=8,Ye=.01,Gt=.05,Ut=.25,Xt=1,Jt=3,be=tt;function Qt(e,t,r,o=[]){const u={items:[],compared:[],possible:[]},f=e.perWafer;if(f.length<4)return u;const s=pt(f.map(n=>({metadata:n.summary.wafer,dieCount:n.summary.stats.totalDies})),{facetableOnly:!0,curation:t}).filter(n=>n.splittable).map(n=>({key:n.key,groupOf:f.map(i=>je(i.summary.wafer,n.key,t))})).filter(n=>ct(n.groupOf));if(s.length===0)return u;const c=dt(s),l=n=>e.perWaferTestStats?.find(i=>i.waferIndex===n.waferIndex)?.tests??n.summary.stats.perTestStats??[],a=f.map(n=>new Map(l(n).filter(i=>i.count>=2&&Number.isFinite(i.mean)).map(i=>[i.testNumber,i]))),d=new Map;for(const n of a)for(const[i,h]of n)d.has(i)||d.set(i,h.label);const b=f.map(n=>n.summary.stats.analyzedDies),y=f.map(n=>n.summary.stats.yieldPercent===null?void 0:n.summary.stats.yieldPercent/100),w=f.map(n=>{const i=n.summary.stats.hardBinCounts,h=i?Object.values(i).reduce(($,v)=>$+v,0):0;return i&&h>0?new Map(Object.entries(i).map(([$,v])=>[Number($),v/h])):void 0}),p=(n,i,h,$)=>{let v;for(const[I,D]of n){const N=D.map(i),O=[...n].filter(([_])=>_!==I).flatMap(([,_])=>_.map(i));if(N.length<2||O.length<2)continue;const T=N.reduce((_,B)=>_+B,0)/N.length-O.reduce((_,B)=>_+B,0)/O.length,k=T/h;(!v||Math.abs(k)>Math.abs(v.d)+1e-9||Math.abs(Math.abs(k)-Math.abs(v.d))<=1e-9&&(D.length<v.groupWafers||D.length===v.groupWafers&&T>0))&&(v=$(I,D,k,T>0))}if(v&&n.size===2){const[I,D]=[...n].find(([N])=>N!==v.group);v.other={group:I,wafers:D.length}}return v},g=[],m=[],x=[];for(const[n,i]of[...d].sort((h,$)=>h[0]-$[0])){const h=a.flatMap(v=>{const I=v.get(n);return I&&Number.isFinite(I.stddev)?[I.stddev**2]:[]}),$=h.length?Math.sqrt(h.reduce((v,I)=>v+I,0)/h.length):NaN;$>0&&x.push({testNumber:n,label:i,values:a.map(v=>v.get(n)?.mean),scale:$})}x.push({testNumber:NaN,label:"Yield",values:y,scale:1,scope:b});const S=[...e.stats.regionYield?.ring??[]].sort((n,i)=>n.yieldPercent-i.yieldPercent)[0];if(S&&f.length>0){const n=f.map(i=>{const h=i.summary.stats.regionYield?.ring?.find($=>$.key===S.key);return h?h.yieldPercent/100:void 0});if(n.every(i=>i!==void 0)){const i=f.map(h=>h.summary.stats.regionYield?.ring?.find($=>$.key===S.key)?.n??0);x.push({testNumber:NaN,label:`${S.label} pass rate`,values:n,scale:1,region:S.label,regionValue:ht(mt(S.key).ring),scope:i})}}for(const n of x)for(const{partition:i,used:h,fitted:$,allowedFor:v}of ft(n.values,c)){const I=i.id,D=i.keys;if(!$)continue;const N=p($.byGroup,k=>h[k],n.scale,(k,L,_,B)=>({part:I,keys:D,testNumber:n.testNumber,label:n.label,group:k,members:L,groupWafers:L.length,groupDies:L.reduce((H,M)=>H+b[M],0),d:_,higher:B,p:$.p,...n.region?{region:n.region,regionValue:n.regionValue}:{},...v?{allowedFor:v}:{}}));if(!N)continue;const O=N.members.map(k=>h[k]),T=[...$.byGroup].filter(([k])=>k!==N.group).flatMap(([,k])=>k.map(L=>h[L]));if(n.scope){const k=_=>_.reduce((B,H)=>B+n.scope[H],0),L=[...$.byGroup].filter(([_])=>_!==N.group).flatMap(([,_])=>_);N.lost=(N.higher?k(L):k(N.members))*Math.abs(N.d)}if(N.separated=Se(O)>Ne(T)||Ne(O)<Se(T),Number.isNaN(n.testNumber)){if(r&&!n.region){let k=0;const L=new Set(w.flatMap(B=>B?[...B.keys()]:[])),_=f.map((B,H)=>H).filter(B=>!N.members.includes(B)&&y[B]!==void 0);for(const B of L){if(r.includes(B))continue;const H=q=>q.reduce((Ze,et)=>Ze+(w[et]?.get(B)??0),0)/Math.max(1,q.length),M=(H(N.members)-H(_))*(N.higher?-1:1);M>k&&(k=M,N.bin=B)}}m.push(N)}else g.push(N)}const A=ot([...g,...m].map(n=>n.p)),C=n=>A[n],U=new Map;g.forEach((n,i)=>{const h=n.groupDies*pe(n.d);C(i)>=ge||h===0||(U.get(n.part)??U.set(n.part,[]).get(n.part)).push({c:n,q:C(i),weight:h})});const F=[...new Set([...g,...m].flatMap(n=>n.keys))].map(n=>te(n,t)),P=n=>be(n.map(i=>te(i,t))),X=n=>{const i=`${te(n.keys[0],t)} ${n.group}`;if(n.keys.length===1)return i;const h=f[n.members[0]].summary.wafer,$=n.keys.slice(1).map(v=>`${te(v,t)} ${je(h,v,t)??""}`.trim());return`${i} (${be($)} group${$.length===1?"s":""} the same wafers)`},Z=n=>n.allowedFor?`, allowing for ${P(n.allowedFor)}`:"",ee=n=>{const i=c.find($=>$.id===n),h=i?ut(i,c):[];return h.length===0?"":`. ${h.map($=>`${P($.partition.keys.slice(0,1))} puts ${$.agree} of ${$.of} wafers in the same groups`).join("; ")}, so the wafers cannot fully tell ${h.length===1?"the two":"them"} apart`},J=n=>`${te(n.keys[0],t)} ${n.other.group}`,ae=n=>n.other?`${n.label} is ${n.higher?"higher":"lower"} on ${X(n)} than on ${J(n)} (${n.groupWafers} and ${n.other.wafers} wafers)`:`${n.label} is ${n.higher?"higher":"lower"} on ${X(n)} (${n.groupWafers} of ${f.length} wafers) than on the other wafers`,de=[...U].map(([n,i])=>{i.sort((M,q)=>Math.abs(q.c.d)-Math.abs(M.c.d)||q.weight-M.weight||M.c.testNumber-q.c.testNumber);const h=i.reduce((M,q)=>Math.max(M,q.weight),0),$=i[0].c.keys,v=$[0],I=P($),[D,...N]=i,O=D.c,T=`${ae(O)}: a shift of ${G(O.d)}${Z(O)}`,k=N.slice(0,2).map(({c:M})=>`${M.label} ${M.higher?"higher":"lower"} on ${M.keys.length>1?te(M.keys[0],t)+" ":""}${M.group} (${G(M.d)})`),L=N.length-k.length,_=i.length,B=(_===1?`${T}, more than wafer-to-wafer variation explains (q ${xe(D.q)})`:`${_} tests differ by ${I}. Largest: ${T}, more than wafer-to-wafer variation explains (q ${xe(D.q)}); next: ${k.join(", ")}${L>0?`, and ${L} more`:""}`)+ee(n),H=re({affected:h,movesValues:!0,measure:G(O.d),severity:D.q<.001?"unusual":"notable",text:B,reason:_===1?T:`${_} tests differ by ${I}. Largest: ${T}`,brief:_===1?`${I} ${O.group}: ${O.label} ${O.higher?"higher":"lower"}`:`${I}: ${_} tests differ; largest ${O.label}, ${O.higher?"higher":"lower"} on ${O.group}`,subject:I,target:{kind:"test",testNumber:O.testNumber},testNumbers:i.map(M=>M.c.testNumber),chart:_>1?{chart:"heatmap",level:"wafer",aggregate:"mean",normalize:"zscore",fields:{x:{meta:v},y:{tests:i.slice(0,Yt).map(M=>M.c.testNumber)}}}:{chart:"box",level:"wafer",aggregate:"mean",fields:{x:{meta:v},y:fe(O.testNumber),color:{meta:v}}}});return H.chips=i.map(({c:M})=>({label:`${M.label} ${M.higher?"higher":"lower"} on ${M.keys.length>1?te(M.keys[0],t)+" ":""}${M.group}, ${G(M.d)}`,target:{kind:"test",testNumber:M.testNumber},waferIndices:M.members.map(q=>f[q].waferIndex)})),H});m.forEach((n,i)=>{const h=C(g.length+i),$=n.lost??n.groupDies*Math.abs(n.d);if(h>=ge||Math.abs(n.d)<Ye)return;const v=P(n.keys),I=`${(Math.abs(n.d)*100).toFixed(1)} points`,D=`${n.bin!==void 0?`, mostly in hard bin ${n.bin}`:""}${Z(n)}`,N=n.other?`${n.label} is ${I} ${n.higher?"higher":"lower"} on ${X(n)} than on ${J(n)} (${n.groupWafers} and ${n.other.wafers} wafers)`:`${n.label} is ${I} ${n.higher?"higher":"lower"} on ${X(n)} (${n.groupWafers} of ${f.length} wafers) than on the other wafers`;de.push(re({affected:$,measure:I,severity:h<.001?"unusual":"notable",text:`${N}${D}, more than wafer-to-wafer variation explains (q ${xe(h)})${ee(n.part)}`,reason:`${N}${D}`,brief:`${v} ${n.group}: ${n.region?"ring pass rate":"yield"} ${n.higher?"higher":"lower"}`,subject:v,target:{kind:"group",field:n.keys[0],fields:n.keys,waferIndices:n.members.map(O=>f[O].waferIndex)},testNumbers:[],chart:{chart:"bar",fields:{x:{meta:n.keys[0]},y:{builtin:"yield"},color:{meta:n.keys[0]}},valueLabels:!0,...n.region?{where:{conditions:[{field:{builtin:"ring"},values:[n.regionValue??n.region]}]}}:{}}}))});const ue=b.reduce((n,i)=>n+i,0),ye=new Set([...g.filter((n,i)=>C(i)<ge&&n.groupDies*pe(n.d)>0).map(n=>n.part),...m.filter((n,i)=>C(g.length+i)<ge&&Math.abs(n.d)>=Ye).map(n=>n.part)]),Y=[...g.filter(n=>Math.abs(n.d)>=Xt),...m.filter(n=>(n.lost??0)>=Math.min(oe*ue,...o.map(i=>Ut*i)))].filter(n=>n.separated&&n.p<Gt&&!ye.has(n.part)),he=new Map;for(const n of Y)(he.get(`${n.part}|${n.group}`)??he.set(`${n.part}|${n.group}`,[]).get(`${n.part}|${n.group}`)).push(n);const me=[],we=g.length+m.length;for(const n of he.values()){const i=n.find(k=>Number.isNaN(k.testNumber)),h=n.filter(k=>!Number.isNaN(k.testNumber)||!i||k.higher===i.higher);if(h.length<2)continue;const $=h[0],v=k=>Number.isNaN(k.testNumber)?`${k.label} ${k.higher?"higher":"lower"} by ${(Math.abs(k.d)*100).toFixed(1)} points`:`${k.label} ${k.higher?"higher":"lower"} (${G(k.d)})`,I=$.other?`than on ${J($)} (${$.groupWafers} and ${$.other.wafers} wafers)`:`than on the other wafers (${$.groupWafers} of ${f.length})`,D=`${X($)}: ${h.map(v).join("; ")} ${I}`,N=P($.keys),O=h.reduce((k,L)=>Math.max(k,L.lost??0),0),T=re({affected:O,measure:`${h.length} measures`,severity:"info",text:`Possibly ${D}. No wafer of the group overlaps the others on ${h.length===2?"either":`any of ${h.length}`}, but the sample is too small to confirm it once ${we} comparisons are allowed for`,reason:`Possibly ${D}`,brief:`${N} ${$.group}: possible, not confirmed`,subject:N,target:{kind:"group",field:$.keys[0],fields:$.keys,waferIndices:$.members.map(k=>f[k].waferIndex)},testNumbers:h.filter(k=>!Number.isNaN(k.testNumber)).map(k=>k.testNumber),chart:{chart:"bar",fields:{x:{meta:$.keys[0]},y:{builtin:"yield"},color:{meta:$.keys[0]}},valueLabels:!0}});me.push(T)}return me.sort((n,i)=>i.affected-n.affected),{items:de,compared:F,possible:me.slice(0,Jt)}}export function groupColouredChart(e,t){const r=e.fields?.x,o=e.fields?.color;return!t||e.chart!=="bar"||!r||Array.isArray(r)||!("builtin"in r)||r.builtin!=="wafer"||!o||!("none"in o)?e:{...e,fields:{...e.fields,x:[{slot:"groupBy"},{builtin:"wafer"}],color:{follow:"groupBy"}}}}function Zt(e){return e.map(t=>Ee(re({affected:t.passingDies,measure:"",severity:"notable",text:`${t.label} ${t.plainVerb} on ${j(t.passingDies,"die")} binned as passing`,brief:`${t.label}: ${z(t.passingDies)} dies out of limits, binned passing`,subject:t.label,target:t.item.target,testNumbers:[t.testNumber],chart:ze(t.testNumber)})))}function Ee(e){return De.add(e),e}function es(e,t){const r=t.passBins&&t.passBins.length>0?`; pass ${nt([t.passBins])}`:"";if(e.level==="wafer"){const a=e.stats.yieldPercent;return a==null?`${z(e.stats.totalDies)} dies, no bin data to judge yield by.`:`Yield ${a.toFixed(1)}% (${z(e.stats.totalDies)} dies${r}).`}const o=e.lotYieldSeries.map(a=>a.yieldPercent).filter(a=>typeof a=="number"),u=e.stats.yield;if(o.length===0||!u)return`${j(e.stats.waferCount,"wafer")}, no bin data to judge yield by.`;const f=e.perWafer.reduce((a,d)=>a+d.summary.stats.totalDies,0),[s,c]=[Se(o).toFixed(1),Ne(o).toFixed(1)],l=s!==c?`, wafers ${s}\u2013${c}%`:"";return`Yield ${u.yieldPercent.toFixed(1)}% (${j(o.length,"wafer")}, ${z(f)} dies${r})${l}.`}function ts(e,t,r=[]){const o=[],u=e.level==="wafer"?e.stats.testsConsidered.length:new Set(e.perWafer.flatMap(a=>a.summary.stats.testsConsidered)).size,f=e.level==="wafer"?e.stats.hardBinsConsidered.length:new Set(e.perWafer.flatMap(a=>a.summary.stats.hardBinsConsidered)).size,s=e.stats.testValueAnalysis?.state;if(u>0&&s!=="off"&&o.push(j(u,"test")+(s==="skipped"?" (against their limits only)":"")),f>0&&o.push(j(f,"hard bin")),o.push("the ring, quadrant and sector regions"),e.level==="lot"&&e.stats.waferCount>=3){const a=e.findings.filter(Ke);o.push(a.length===0?"wafer-to-wafer yield (no outlier wafers)":`wafer-to-wafer yield (${j(a.length,"outlier wafer")})`),e.stats.waferCount>=it&&o.push("the yield trend across the wafers (input order)"),r.length&&o.push(`the tests between the groups of ${r.join(", ")} (each wafer one value)`)}const c=Fe(e.findings).filter(a=>!t.has(a.id)).length,l=c>0?` ${j(c,"finding")} of low strength ${c===1?"is":"are"} not listed here.`:" Nothing else was found.";return`Compared: ${o.join(", ")}.${l}`}export function synthesisSource(e){return e.level==="lot"&&e.perWafer.length===1?e.perWafer[0].summary:e}const Ge=new WeakMap;export function buildSynthesis(e,t={}){const r=`${t.passBins?.join(",")??"-"}|${t.attributes?JSON.stringify(t.attributes):"-"}`;let o=Ge.get(e);o||Ge.set(e,o=new Map);const u=o.get(r),f=e.findings;if(u&&u.findings.length===f.length&&u.findings.every((c,l)=>c===f[l]))return u.synthesis;const s=rs(e,t);return Object.freeze(s.items),s.items.forEach(Object.freeze),s.possible&&(s.possible.forEach(Object.freeze),Object.freeze(s.possible)),s.small&&(s.small.forEach(Object.freeze),Object.freeze(s.small)),Object.freeze(s.lowStrengthIds),s.also&&(Object.freeze(s.also.items),s.also.items.forEach(Object.freeze),Object.freeze(s.also)),o.set(r,{findings:[...f],synthesis:Object.freeze(s)}),s}function Fe(e=[]){const t=new Set(e.flatMap(r=>r.absorbedIds??[]));return e.filter(r=>!t.has(r.id))}const ke={unusual:0,notable:1,info:2},$e=(e,t)=>ke[e.severity]-ke[t.severity]||E(t)*(le(t)??0)-E(e)*(le(e)??0),Ue=e=>e.comparison.family==="spatial-pattern"?0:e.comparison.family==="cluster"||e.comparison.family==="edge-arc"?1:2,Ie=e=>`${e.level}|${e.variable.kind}|${e.variable.bin??""}|${e.variable.index??""}`;function ss(e,t){const r=new Map(t.map(a=>[a.id,a])),o=new Map(t.map(a=>[a.id,Q(a)])),u=new Map;e.forEach((a,d)=>{for(const b of a.findingIds)r.has(b)&&!u.has(b)&&u.set(b,d)});const f=e.map(a=>{const d=new Set;for(const b of a.findingIds)for(const y of o.get(b)??[])d.add(y);return d}),s=e.map(a=>new Set(a.findingIds.map(d=>r.get(d)).filter(d=>!!d).map(Ie))),c=e.map(a=>new Set(a.findingIds.map(d=>r.get(d)).filter(d=>!!d).map(d=>`${Ie(d)}|${d.effect.direction}`))),l=a=>a==="higher"?"lower":a==="lower"?"higher":a;for(const a of t){if(u.has(a.id))continue;const d=o.get(a.id);let b=-1,y=0;d.size>0&&f.forEach((w,p)=>{let g=0;for(const x of d)w.has(x)&&g++;(g>=se*d.size||g>0&&s[p].has(Ie(a)))&&g>y&&(b=p,y=g)}),b<0&&(b=c.findIndex(w=>w.has(`${Ie(a)}|${l(a.effect.direction)}`))),b>=0&&u.set(a.id,b)}for(let a=!0;a;){a=!1;for(const d of t){const b=u.get(d.id);if(b!==void 0)for(const y of d.relatedIds??[])r.has(y)&&!u.has(y)&&(u.set(y,b),a=!0)}}return e.forEach((a,d)=>{const b=t.filter(w=>u.get(w.id)===d).sort($e);if(a.evidenceIds=b.map(w=>w.id),De.has(a)&&b.length===0){delete a.strength;return}const y=b.reduce((w,p)=>ke[p.severity]<ke[w]?p.severity:w,De.has(a)?"info":a.severity);a.strength=strengthOf(y)}),t.filter(a=>!u.has(a.id))}function Xe(e){return e.variable.kind==="test"&&e.variable.index!==void 0?fe(e.variable.index):{builtin:"yield"}}function Le(e,t,r,o="",u){if(e.length>1&&e.every(F=>F.comparison.family==="test-site"&&Je(F)))return ns(e,t,r,o);const f=[...e].sort($e),s=[...f].sort((F,P)=>Ue(F)-Ue(P))[0],c=f.filter(F=>F!==s),l=c.length,a=s.stats.method==="wafer-finding-frequency",d=s.comparison.family==="spatial-pattern"&&s.comparison.left===at["near-full"],b=s.level!=="wafer"&&s.comparison.family==="wafer"&&s.variable.kind==="yield"&&s.effect.direction==="lower"&&"waferIndices"in s.highlight&&s.highlight.waferIndices?.length===1?u?.(s.highlight.waferIndices[0]):void 0,y=d?Q(s).size:b!==void 0?E(s)*b:a?0:Ae(s)?W(s):0,w=s.comparison.family==="spatial-pattern"&&!d,p=w?s.detail:void 0,g=s.effect.absoluteDelta,m=a?`${s.stats.sampleSizeLeft}/${s.stats.sampleSizeLeft+(s.stats.sampleSizeRight??0)} wafers`:s.comparison.family==="cluster"||s.comparison.family==="spatial-pattern"||s.comparison.family==="edge-arc"?j(le(s)??s.stats.sampleSizeLeft,"die"):g!==void 0&&Math.abs(g)<=1?`${R(Math.abs(g))} points`:"",x=p??m,S=`${o}${Me(s.summary)}${l>0?`. ${j(l,"more finding")} on the same dies`:""}`,A=ne(s),C=s.comparison.family==="spatial-pattern"?`${o}${s.variable.label} pattern`:s.comparison.family==="cluster"?`${o}${K(s)}`:`${o}${K(s)}: ${/^[A-Z][a-z]/.test(A)?A.charAt(0).toLowerCase()+A.slice(1):A} ${s.effect.direction}`,U=s.variable.kind==="test"&&s.variable.index!==void 0;return{kind:y>0?"loss":"signal",impact:Be(t>0?y/t:0,0),shareOfDies:t>0?y/t:0,diesLost:y,affected:y,measure:x,...w?{shape:!0}:{},severity:s.severity,text:S,reason:S,brief:C,subject:`${o}${K(s)}`,target:r??V(s),chips:[],findingIds:[s,...c].map(F=>F.id),category:ce,evidenceIds:[s,...c].map(F=>F.id),strength:strengthOf(f[0].severity),testNumbers:U?[s.variable.index]:[],chart:U?{chart:"box",fields:{x:ie(s),y:fe(s.variable.index),color:{none:!0}},axes:{y:{references:[{stat:"median"}]}}}:ve(ie(s),Xe(s))}}function Je(e){const t=e.variable.kind==="functionalTest"||e.variable.kind==="yield"||/pass rate/i.test(e.variable.label);return e.effect.direction===(t?"lower":"higher")}function ns(e,t,r,o){const u=e.filter(p=>p.variable.kind==="functionalTest"||p.variable.kind==="test"),f=e.filter(p=>p.variable.kind==="hardBin"),c=[...u.length?u:f.length?f:e].sort((p,g)=>W(g)-W(p)),l=c[0],a=String(l.comparison.left??K(l)),d=c.map(p=>ne(p).replace(/ (pass rate|limit fail rate|fail rate)$/i,"")),b=c.reduce((p,g)=>p+(Ae(g)?W(g):0),0),y=`${o}${a} fails ${be(d)} more often than the other sites: ${c.map(p=>Me(p.summary)).join("; ")}`,w=c.flatMap(p=>p.variable.index!==void 0?[p.variable.index]:[]);return{kind:b>0?"loss":"signal",impact:Be(t>0?b/t:0,0),shareOfDies:t>0?b/t:0,diesLost:b,affected:b,measure:j(b,"die"),severity:[...e].sort($e)[0].severity,text:y,reason:`${o}${a} fails ${be(d)} more often than the other sites.`,brief:`${o}${a} fails ${be(d)} more often`,subject:`${o}${a}`,target:r??V(l),chips:c.map((p,g)=>({label:d[g],target:V(p)})),findingIds:c.map(p=>p.id),evidenceIds:[...c,...e.filter(p=>!c.includes(p))].map(p=>p.id),category:ce,strength:strengthOf([...e].sort($e)[0].severity),testNumbers:w,chart:w.length>=2?{chart:"heatmap",fields:{x:{builtin:"site"},y:{tests:w,passRate:!0}},aggregate:"mean"}:ve(ie(l),Xe(l))}}function Qe(e){const t=e.map((s,c)=>c),r=s=>t[s]===s?s:t[s]=r(t[s]),o=e.map(Q),u=new Map(e.map((s,c)=>[s.id,c]));for(let s=0;s<e.length;s++){for(const c of e[s].relatedIds??[]){const l=u.get(c);l!==void 0&&(t[r(s)]=r(l))}for(let c=s+1;c<e.length;c++){const l=o[s].size<=o[c].size?o[s]:o[c],a=l===o[s]?o[c]:o[s];if(l.size===0)continue;let d=0;for(const b of l)a.has(b)&&d++;d>=se*l.size&&(t[r(s)]=r(c))}}const f=new Map;return e.forEach((s,c)=>{const l=r(c);(f.get(l)??f.set(l,[]).get(l)).push(s)}),[...f.values()]}function is(e,t,r){const o=e.filter(c=>c.severity!=="info"),u=new Map;for(const c of o)if(c.comparison.family==="test-site"){const l=`${c.level}|${c.comparison.left}|${Je(c)?"worse":"better"}`;(u.get(l)??u.set(l,[]).get(l)).push(c)}const f=c=>t.level==="lot"?t.perWafer.find(l=>l.waferIndex===c)?.summary.stats.analyzedDies:void 0,s=[...Qe(o.filter(c=>c.comparison.family!=="test-site")).map(c=>Le(c,r,void 0,"",f)),...[...u.values()].map(c=>Le(c,r))];if(t.level==="lot"){const c=new Set;for(const l of t.findings??[])for(const a of Q(l))c.add(a);for(const l of t.perWafer??[]){const a=Fe(l.summary?.findings??[]).filter(p=>p.level==="wafer"&&(p.severity==="unusual"||p.severity==="notable"&&p.comparison.family==="spatial-pattern")),d=(t.findings??[]).filter(p=>"waferIndices"in p.highlight&&p.highlight.waferIndices?.includes(l.waferIndex)),b=a.filter(p=>{const g=S=>/^edge/i.test(S)?"edge":S;if(d.some(S=>S.variable.kind===p.variable.kind&&S.comparison.family===p.comparison.family&&g(S.comparison.left)===g(p.comparison.left)))return!1;if(p.comparison.family==="spatial-pattern")return!0;const m=Q(p);if(m.size===0)return!1;let x=0;for(const S of m)c.has(`${l.waferIndex}:${S}`)&&x++;return x<se*m.size});if(b.length===0)continue;const y=l.summary.wafer,w=String(y?.waferId??y?.wafer??`Wafer ${l.waferIndex+1}`);for(const p of Qe(b)){const g=[...p].sort($e)[0];s.push(Le(p,r,{kind:"wafer",waferIndex:l.waferIndex,findingId:g.id},`${w}: `))}}}return s.sort((c,l)=>Te[c.strength??"low"]-Te[l.strength??"low"]||l.affected-c.affected)}export function isShapeItem(e){return!!e.shape&&(e.strength==="high"||e.strength==="medium")}const ce="patterns";export function synthesisCategoryOf(e,t){switch(e.target.kind){case"group":return"groups";case"wafer":return"wafers";case"test":return groupedByField(e)!==void 0?"groups":"tests";case"finding":{const r=t(e.target.id);return r==="test-site"?"sites":r==="wafer"?"wafers":"patterns"}}}function rs(e,t){const r=synthesisSource(e),o=r.findings,u=r.level==="lot"?r.stats.waferCount:void 0,f=t.passBins,s=new Map(o.map(i=>[i.id,i])),c=(r.level==="wafer"?[r]:r.perWafer.map(i=>i.summary)).every(i=>(i.stats.hardBinsConsidered??[]).length===0),l=i=>f!==void 0&&_e(i)&&st(i.variable.kind,i.variable.bin??NaN,f,!c),a={isPassRate:i=>i.variable.kind==="yield"||f?.length===1&&l(i),isFailBin:i=>f!==void 0&&_e(i)&&!l(i)},d=o.filter(i=>Re.has(i.comparison.family)&&W(i)>0&&(a.isPassRate(i)&&i.effect.direction==="lower"||a.isFailBin(i)&&i.effect.direction==="higher")),y=d.some(i=>i.variable.kind==="hardBin")?d.filter(i=>i.variable.kind!=="softBin"):d,w=[],p=new Map,g=new Set;for(const i of xt(y)){const h=i.map(I=>y[I]),$=Et(h,o,u,a);w.push($);const v=$.target.kind==="finding"?$.target.id:void 0;p.set($,Q(h.find(I=>I.id===v)??h[0]))}for(const i of o.filter(h=>h.variable.kind==="spatialPattern")){const h=new Set((i.relatedIds??[]).filter(D=>s.has(D))),$=w.find(D=>D.findingIds.some(N=>h.has(N)));if(!$)continue;const v=i.level==="lot"&&"waferIndices"in i.highlight?i.highlight.waferIndices?.length:void 0,I=v!==void 0&&u?` on ${v}/${u} wafers`:"";$.text=`${i.variable.label} pattern${I}. ${$.text}`,$.reason=`${i.variable.label} pattern${I}. ${$.reason}`,$.chips.unshift({label:`${i.variable.label} pattern`,target:V(i)}),$.findingIds.unshift(i.id,...[...h].filter(D=>!w.some(N=>N.findingIds.includes(D))))}const m=Lt(r),x=new Set,S=Tt(r,x);for(const i of S)Ee(i.item),i.item.routine=!0;const A=[...w],C=Ct(S,A,p,m);r.level==="lot"&&w.push(...At(r)),w.push(...C.map(i=>i.item));const U=new Set(C.filter(i=>m>0&&i.item.diesLost/m>=oe).map(i=>i.testNumber));w.push(...Kt(o,[...A,...C.map(i=>i.item)],p),...qt(o,m),...Vt(r,x,m).map(i=>(i.routine=!0,Ee(i))),...Zt(S.filter(i=>i.passingDies>0&&!U.has(i.testNumber))));let F=[],P=[];if(r.level==="lot"){const i=Qt(r,t.attributes,t.passBins,w.filter(h=>h.kind==="loss").map(h=>h.diesLost));F=i.compared,P=i.possible;for(const h of i.items){const $=h.testNumbers[0],v=h.testNumbers.length===1?w.find(I=>I.target.kind==="test"&&I.target.testNumber===$)??w.find(I=>I.testNumbers.includes($)):void 0;v?v.text+=`. ${h.text}`:w.push(h)}}const X=Ft(r),Z=w.filter(i=>m>0&&i.affected/m>=oe);for(const i of Z)i.shareOfDies=i.affected/m,i.impact=Be(i.shareOfDies,i.kind==="loss"&&X>0?i.diesLost/X:0,Pe.has(i)),i.measure||(i.measure=`${(i.shareOfDies*100).toFixed(1)}%`);const ee=i=>`${String(i.testNumbers[0]??"").padStart(10,"0")}${i.findingIds[0]??""}`;Z.sort((i,h)=>h.affected-i.affected||(ee(i)<ee(h)?-1:ee(i)>ee(h)?1:0));const J=Z.slice(0,We),ae=Z.slice(We);for(const i of[...J,...ae])for(const h of i.findingIds)g.add(h);const de=ae.length>0?{items:ae,more:0}:void 0,ue=[...J,...ae,...P],ye=ss(ue,Fe(o)),Y=is(ye,r,m);for(const i of[...ue,...Y])for(const h of i.evidenceIds)g.add(h);const he=ye.filter(i=>i.severity==="info").map(i=>i.id),me=i=>s.get(i)?.comparison.family;for(const i of[...ue,...Y])i.category=synthesisCategoryOf(i,me);const we=r.level==="lot"?"region, fail bin or wafer":"region or fail bin",n=J.length===0?Y.length>0?`No ${we} costs as much as ${R(oe)} yield points. ${j(Y.length,"smaller item")} ${Y.length===1?"is":"are"} listed below.`:`Nothing stands out: no ${we} costs as much as ${R(oe)} yield points.`:void 0;return{headline:es(r,t),items:J,...de?{also:de}:{},...P.length?{possible:P}:{},...Y.length?{small:Y}:{},lowStrengthIds:he,...n?{nothing:n}:{},checked:ts(r,g,F)}}export const synthesisKey=e=>{if(e.target.kind==="finding")return`finding:${e.target.id}`;if(e.target.kind==="group")return`group:${e.target.field}${isGroupYieldItem(e)?"":":ring"}`;if(e.target.kind==="wafer")return`wafer:${e.target.waferIndex}:${e.target.findingId}`;const t=groupedByField(e);return`test:${e.target.testNumber}${t!==void 0?`:by:${t}`:""}`},groupedByField=e=>{const t=e.chart.fields?.x;return t&&!Array.isArray(t)&&"meta"in t?t.meta:void 0},isGroupYieldItem=e=>e.target.kind==="group"&&!e.chart.where,synthesisRowShare=e=>e.measure;export function synthesisText(e){return[e.headline,...e.nothing?[e.nothing]:[],...[...e.items,...e.also?.items??[]].map((t,r)=>`${r+1}. ${t.text}`),...e.possible?["Too few wafers to be sure (confidence: Low):",...e.possible.map(t=>`- ${t.text}`)]:[],...e.small?["Smaller, under 1% of the dies:",...e.small.map(t=>`- ${t.brief} (${synthesisRowShare(t)})`)]:[],e.checked].join(`
2
2
  `)}
@@ -163,6 +163,12 @@ export interface StatsFinding {
163
163
  * and the singular/plural cases.
164
164
  */
165
165
  summary: string;
166
+ /**
167
+ * On a wafer's spatial-pattern finding, how big and what shape the pattern is, as prose
168
+ * ("a line 26 dies long and about 1 wide", "40% of edge dies failing"); absent on every other finding.
169
+ * Read it instead of picking the description out of `summary`.
170
+ */
171
+ detail?: string;
166
172
  /**
167
173
  * What to highlight on the map when the reader selects this finding. Always
168
174
  * carries `dieKeys` in `getDieKey` format (`"x,y"`) — match on those rather
@@ -244,6 +250,10 @@ export interface StatsSummary {
244
250
  excludedDies: number;
245
251
  /** `(passDies / totalDies) × 100` in [0, 100], or `null` when no bin data is present. */
246
252
  yieldPercent: number | null;
253
+ /** The passing dies behind `yieldPercent` (`WaferMapResult.yield.passDies`), so a lot's yield sums dies. */
254
+ yieldPassDies: number;
255
+ /** The tested dies behind `yieldPercent`: yield-eligible dies with a bin (`WaferMapResult.yield.totalDies`). */
256
+ yieldTestedDies: number;
247
257
  testsConsidered: number[];
248
258
  hardBinsConsidered: number[];
249
259
  softBinsConsidered: number[];
@@ -468,6 +478,13 @@ export interface RegionYieldFigures {
468
478
  ring?: RegionYield[];
469
479
  quadrant: RegionYield[];
470
480
  }
481
+ /** A yield over several wafers: their passing and tested dies summed. */
482
+ export interface LotYield {
483
+ passDies: number;
484
+ testedDies: number;
485
+ /** `passDies / testedDies × 100`. */
486
+ yieldPercent: number;
487
+ }
471
488
  export interface LotStatsSummary {
472
489
  /** Discriminant — always `'lot'`. Narrow on this to tell a lot summary from a {@link StatsSummary}. */
473
490
  level: 'lot';
@@ -504,6 +521,11 @@ export interface LotStatsSummary {
504
521
  /** Engine-computed analysis stats for this lot. */
505
522
  stats: {
506
523
  waferCount: number;
524
+ /**
525
+ * The lot's yield: passing dies over tested dies, summed over the wafers, each wafer judged by its own pass bins.
526
+ * THE lot yield every built-in surface shows. Absent when no wafer has a yield.
527
+ */
528
+ yield?: LotYield;
507
529
  /** The lot's test-value analysis: one decision for every wafer, sizes summed over them. */
508
530
  testValueAnalysis?: TestValueAnalysisStatus;
509
531
  /**
@@ -0,0 +1,15 @@
1
+ import type { Die } from '../core/dies.js';
2
+ import { type TestDef } from '../renderer/buildWaferMap.js';
3
+ import type { Synthesis, SynthesisItem } from './synthesis.js';
4
+ import type { StatsFinding } from './types.js';
5
+ /** Every item Worth a look holds (routine ones left out), in its order: High, Medium, Low, each by what it affects. */
6
+ export declare function worthItems(synthesis: Synthesis): SynthesisItem[];
7
+ /**
8
+ * The tests the analysis points at, at most `n`, from `tests`: the test of each item in Worth a look's order (an item about
9
+ * a test, or about a finding on one), then the parametric tests with the lowest Ppk. Never simply the first by number,
10
+ * which nothing may point at. Insights' Distributions opens on the first; a presentation is about the first few.
11
+ */
12
+ export declare function pointedTests(items: readonly SynthesisItem[], findings: readonly StatsFinding[], tests: readonly TestDef[],
13
+ /** The dies of each wafer, for the Ppk the tests fall back to. */
14
+ diesByWafer: readonly (readonly Die[])[], n: number): number[];
15
+ //# sourceMappingURL=worthItems.d.ts.map
@@ -0,0 +1 @@
1
+ import{isParametricTest as m}from"../renderer/buildWaferMap.js";import{buildCapabilityFigures as l}from"./capability.js";import{worthOrder as c}from"./presentation.js";export function worthItems(r){return[...r.items,...r.also?.items??[],...r.small??[]].filter(o=>!o.routine).sort(c)}export function pointedTests(r,o,p,a,d){const u=new Set(p.map(t=>t.testNumber)),f=new Map(o.map(t=>[t.id,t])),i=[],s=t=>{t!==void 0&&u.has(t)&&!i.includes(t)&&i.push(t)};for(const t of r){if(i.length>=d)return i;const e=t.target,n=e.kind==="finding"?f.get(e.id):void 0;s(e.kind==="test"?e.testNumber:n?.variable.kind==="test"?n.variable.index:void 0)}if(i.length<d){const t=p.filter(e=>m(e));l(a.map(e=>({dies:[...e]})),t).filter(e=>e.ppk!==null&&e.ppk!==void 0&&Number.isFinite(e.ppk)).sort((e,n)=>e.ppk-n.ppk).forEach(e=>s(e.testNumber))}return i.slice(0,d)}
@@ -1,4 +1,5 @@
1
1
  import type { Die } from '../core/dies.js';
2
+ import type { LotYield } from './types.js';
2
3
  /** Shared row shape for every bar-chart panel (yield, bin pareto, ...). */
3
4
  export interface ChartDatum {
4
5
  label: string;
@@ -60,4 +61,16 @@ export declare function buildYieldDataCombined(groups: {
60
61
  key: string;
61
62
  items: YieldItem[];
62
63
  }[], sortBy?: YieldSortBy): ChartDatum[];
64
+ /**
65
+ * The yield of several wafers from their summaries: passing dies over tested dies, summed. THE lot yield: the
66
+ * Summary panel, Insights, the reports and `analyzeWaferLot` all read it from here. `undefined` when no wafer has a
67
+ * yield.
68
+ */
69
+ export declare function lotYieldFromSummaries(summaries: ReadonlyArray<{
70
+ stats: {
71
+ yieldPercent: number | null;
72
+ yieldPassDies?: number;
73
+ yieldTestedDies?: number;
74
+ };
75
+ }>): LotYield | undefined;
63
76
  //# sourceMappingURL=yield.d.ts.map
@@ -1 +1 @@
1
- import{requirePassBins as a}from"../core/passBins.js";import{isYieldEligibleDie as f,diePassStatus as p}from"../core/dies.js";import{compareNatural as m}from"../core/utils.js";export function yieldCounts(e,i){let n=0,t=0;const r=new Set(i);for(const o of e){if(!f(o))continue;const l=p(o,r);l!==void 0&&(t++,l&&n++)}return{pass:n,total:t}}function b(e,i){const{pass:n,total:t}=yieldCounts(e,i);return t>0?n/t*100:0}function d(e){return e.yieldPercent!==void 0?e.yieldPercent??0:b(e.dies??[],a(e,"yield"))}function y(e,i){return yieldCounts(e,i).total}function c(e,i){i==="yield"?e.sort((n,t)=>t.value-n.value):e.sort((n,t)=>m(n.label,t.label))}export function buildYieldData(e,i="label"){const n=e.map((t,r)=>{const o=d(t);return{label:t.label??`#${r}`,value:o,percent:o,itemCount:1,key:t.key}});return c(n,i),n}export function buildYieldDataCombined(e,i="label"){const n=e.map(t=>{let r=0,o=0;for(const s of t.items){const u=y(s.dies??[],a(s,"yield"));r+=d(s)*u,o+=u}const l=o>0?r/o:0;return{label:t.key,value:l,percent:l,itemCount:t.items.length}});return c(n,i),n}
1
+ import{requirePassBins as u}from"../core/passBins.js";import{isYieldEligibleDie as f,diePassStatus as p,dieWeight as y}from"../core/dies.js";import{compareNatural as m}from"../core/utils.js";export function yieldCounts(t,i){let n=0,e=0;const o=new Set(i);for(const s of t){if(!f(s))continue;const r=p(s,o);if(r===void 0)continue;const l=y(s);e+=l,r&&(n+=l)}return{pass:n,total:e}}function b(t,i){const{pass:n,total:e}=yieldCounts(t,i);return e>0?n/e*100:0}function a(t){return t.yieldPercent!==void 0?t.yieldPercent??0:b(t.dies??[],u(t,"yield"))}function D(t,i){return yieldCounts(t,i).total}function c(t,i){i==="yield"?t.sort((n,e)=>e.value-n.value):t.sort((n,e)=>m(n.label,e.label))}export function buildYieldData(t,i="label"){const n=t.map((e,o)=>{const s=a(e);return{label:e.label??`#${o}`,value:s,percent:s,itemCount:1,key:e.key}});return c(n,i),n}export function buildYieldDataCombined(t,i="label"){const n=t.map(e=>{let o=0,s=0;for(const l of e.items){const d=D(l.dies??[],u(l,"yield"));o+=a(l)*d,s+=d}const r=s>0?o/s:0;return{label:e.key,value:r,percent:r,itemCount:e.items.length}});return c(n,i),n}export function lotYieldFromSummaries(t){let i=0,n=0;for(const e of t)e.stats.yieldPercent===null||e.stats.yieldPassDies===void 0||e.stats.yieldTestedDies===void 0||(i+=e.stats.yieldPassDies,n+=e.stats.yieldTestedDies);return n>0?{passDies:i,testedDies:n,yieldPercent:i/n*100}:void 0}
package/llms.txt CHANGED
@@ -32,7 +32,7 @@ where repo-relative paths do not resolve.
32
32
  - [Package surface and types](https://wafertools.github.io/wafermap/api/reference/) - exports, helpers, types, limitations.
33
33
  - [Quick start](https://wafertools.github.io/wafermap/quickstart/) - install and first map.
34
34
  - [Troubleshooting](https://wafertools.github.io/wafermap/troubleshooting/) - common failure modes.
35
- - [Examples](https://wafertools.github.io/wafermap/examples/) - 27 runnable demo pages, also downloadable at https://wafertools.github.io/wafermap/wafermap-examples.zip to run offline.
35
+ - [Examples](https://wafertools.github.io/wafermap/examples/) - 30 runnable demo pages, also downloadable at https://wafertools.github.io/wafermap/wafermap-examples.zip to run offline.
36
36
 
37
37
  ## Public package entry points
38
38
  - `@wafertools/wafermap` - `buildWaferMap()`, geometry, colour-scheme registries. Pure, no DOM.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wafertools/wafermap",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Interactive wafer map visualization and yield analysis for semiconductor test data. Hard bins, soft bins, test values, retests, edge exclusion, reticle overlays, spatial statistics, failure clustering, and lot-level trend analysis — pure ES modules, no runtime dependencies, no server required.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -65,6 +65,10 @@
65
65
  "./canvas-adapter": {
66
66
  "types": "./dist/packages/canvas-adapter/index.d.ts",
67
67
  "import": "./dist/packages/canvas-adapter/index.js"
68
+ },
69
+ "./experimental/charts": {
70
+ "types": "./dist/packages/experimental/charts.d.ts",
71
+ "import": "./dist/packages/experimental/charts.js"
68
72
  }
69
73
  },
70
74
  "sideEffects": false,
@@ -82,6 +86,7 @@
82
86
  "check:drift": "node scripts/check-drift.mjs",
83
87
  "dev": "rm -rf docs/dist && cp -r dist docs/dist && ./.venv/bin/zensical serve --dev-addr localhost:8001",
84
88
  "test": "npm run build && node scripts/check-bundle-size.mjs && node --test tests/*.test.mjs",
89
+ "test:affected": "node scripts/test-affected.mjs",
85
90
  "build:site": "rm -rf docs/dist && cp -r dist docs/ && ${ZENSICAL:-.venv/bin/zensical} build --clean && cp -r docs/data site/data && cp llms.txt site/llms.txt && rm -rf docs/dist && node scripts/bundle-docs.mjs && node scripts/build-examples-archive.mjs",
86
91
  "preview:site": "npm run build:site && echo \"\\nServing bundled site at http://localhost:8002/examples/ — Ctrl-C to stop\\n\" && cd site && python3 -m http.server 8002",
87
92
  "prepack": "npm run build && node scripts/minify-dist.mjs",