@wafertools/wafermap 0.33.0 → 0.35.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 (158) hide show
  1. package/AGENTS.md +6 -6
  2. package/CHANGELOG.md +271 -0
  3. package/README.md +5 -5
  4. package/dist/packages/canvas-adapter/chartPopulation.d.ts +15 -10
  5. package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
  6. package/dist/packages/canvas-adapter/charts/barPanel.d.ts +8 -1
  7. package/dist/packages/canvas-adapter/charts/barPanel.js +1 -1
  8. package/dist/packages/canvas-adapter/charts/binCluster.d.ts +7 -1
  9. package/dist/packages/canvas-adapter/charts/binCluster.js +1 -1
  10. package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
  11. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  12. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +72 -5
  13. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/correlation.js +1 -2
  15. package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +2 -0
  16. package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +1 -1
  17. package/dist/packages/canvas-adapter/charts/histogram.d.ts +16 -0
  18. package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
  19. package/dist/packages/canvas-adapter/charts/palette.d.ts +2 -0
  20. package/dist/packages/canvas-adapter/charts/palette.js +1 -1
  21. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +27 -0
  22. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -0
  23. package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +45 -0
  24. package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -0
  25. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +8 -1
  26. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  27. package/dist/packages/canvas-adapter/charts/scatter.d.ts +19 -0
  28. package/dist/packages/canvas-adapter/charts/scatter.js +1 -1
  29. package/dist/packages/canvas-adapter/charts/sweep.d.ts +12 -0
  30. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  31. package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +7 -0
  32. package/dist/packages/canvas-adapter/charts/testPassRate.js +1 -1
  33. package/dist/packages/canvas-adapter/charts/trend.d.ts +11 -0
  34. package/dist/packages/canvas-adapter/charts/trend.js +1 -1
  35. package/dist/packages/canvas-adapter/confirmDialog.d.ts +13 -0
  36. package/dist/packages/canvas-adapter/confirmDialog.js +1 -0
  37. package/dist/packages/canvas-adapter/dataTab.d.ts +137 -0
  38. package/dist/packages/canvas-adapter/dataTab.js +1 -0
  39. package/dist/packages/canvas-adapter/dieList.d.ts +39 -4
  40. package/dist/packages/canvas-adapter/dieList.js +6 -7
  41. package/dist/packages/canvas-adapter/drilldown.d.ts +23 -3
  42. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  43. package/dist/packages/canvas-adapter/guideWindow.d.ts +96 -0
  44. package/dist/packages/canvas-adapter/guideWindow.js +1 -0
  45. package/dist/packages/canvas-adapter/identityHeader.d.ts +19 -0
  46. package/dist/packages/canvas-adapter/identityHeader.js +1 -1
  47. package/dist/packages/canvas-adapter/index.d.ts +3 -3
  48. package/dist/packages/canvas-adapter/index.js +1 -1
  49. package/dist/packages/canvas-adapter/insightsTab.d.ts +75 -54
  50. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  51. package/dist/packages/canvas-adapter/maplessSummary.d.ts +2 -2
  52. package/dist/packages/canvas-adapter/plotEditor.d.ts +29 -0
  53. package/dist/packages/canvas-adapter/plotEditor.js +1 -0
  54. package/dist/packages/canvas-adapter/plotItems.d.ts +32 -0
  55. package/dist/packages/canvas-adapter/plotItems.js +1 -0
  56. package/dist/packages/canvas-adapter/plotModal.d.ts +30 -0
  57. package/dist/packages/canvas-adapter/plotModal.js +1 -0
  58. package/dist/packages/canvas-adapter/plotStore.d.ts +52 -0
  59. package/dist/packages/canvas-adapter/plotStore.js +1 -0
  60. package/dist/packages/canvas-adapter/plotTab.d.ts +33 -0
  61. package/dist/packages/canvas-adapter/plotTab.js +1 -0
  62. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +11 -2
  63. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  64. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +29 -2
  65. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  66. package/dist/packages/canvas-adapter/summaryPanel.d.ts +34 -10
  67. package/dist/packages/canvas-adapter/summaryPanel.js +2 -4
  68. package/dist/packages/canvas-adapter/summaryRail.d.ts +7 -0
  69. package/dist/packages/canvas-adapter/summaryRail.js +1 -0
  70. package/dist/packages/canvas-adapter/sweepEditor.d.ts +17 -0
  71. package/dist/packages/canvas-adapter/sweepEditor.js +1 -0
  72. package/dist/packages/canvas-adapter/tableExport.d.ts +22 -0
  73. package/dist/packages/canvas-adapter/tableExport.js +3 -0
  74. package/dist/packages/canvas-adapter/toolbar.d.ts +25 -97
  75. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  76. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  77. package/dist/packages/canvas-adapter/userGuideHtml.js +354 -45
  78. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  79. package/dist/packages/canvas-adapter/version.js +1 -1
  80. package/dist/packages/canvas-adapter/viewSwitch.d.ts +13 -0
  81. package/dist/packages/canvas-adapter/viewSwitch.js +1 -0
  82. package/dist/packages/canvas-adapter/virtualTable.d.ts +44 -0
  83. package/dist/packages/canvas-adapter/virtualTable.js +1 -0
  84. package/dist/packages/core/classify.d.ts +3 -2
  85. package/dist/packages/core/classify.js +1 -1
  86. package/dist/packages/core/index.d.ts +1 -1
  87. package/dist/packages/core/index.js +1 -1
  88. package/dist/packages/core/passBins.d.ts +17 -4
  89. package/dist/packages/core/passBins.js +1 -1
  90. package/dist/packages/core/reticle.d.ts +20 -0
  91. package/dist/packages/core/reticle.js +1 -1
  92. package/dist/packages/core/ringCount.d.ts +22 -0
  93. package/dist/packages/core/ringCount.js +1 -0
  94. package/dist/packages/core/tableCsv.d.ts +43 -0
  95. package/dist/packages/core/tableCsv.js +3 -0
  96. package/dist/packages/core/wafer.d.ts +15 -0
  97. package/dist/packages/core/wafer.js +1 -1
  98. package/dist/packages/renderer/binColors.d.ts +6 -6
  99. package/dist/packages/renderer/binColors.js +1 -1
  100. package/dist/packages/renderer/buildView.d.ts +1 -1
  101. package/dist/packages/renderer/buildView.js +1 -1
  102. package/dist/packages/renderer/buildWaferMap.js +1 -1
  103. package/dist/packages/renderer/derivedTests/apply.js +1 -1
  104. package/dist/packages/renderer/derivedTests/evaluate.d.ts +3 -1
  105. package/dist/packages/renderer/derivedTests/evaluate.js +1 -1
  106. package/dist/packages/renderer/derivedTests/parser.d.ts +7 -0
  107. package/dist/packages/renderer/derivedTests/parser.js +2 -2
  108. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  109. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  110. package/dist/packages/stats/binPareto.d.ts +1 -1
  111. package/dist/packages/stats/binPareto.js +1 -1
  112. package/dist/packages/stats/dieRegions.d.ts +42 -0
  113. package/dist/packages/stats/dieRegions.js +1 -0
  114. package/dist/packages/stats/facets.d.ts +8 -0
  115. package/dist/packages/stats/facets.js +1 -1
  116. package/dist/packages/stats/histogram.d.ts +27 -0
  117. package/dist/packages/stats/histogram.js +1 -1
  118. package/dist/packages/stats/index.d.ts +4 -1
  119. package/dist/packages/stats/index.js +1 -1
  120. package/dist/packages/stats/lotDrift.js +1 -1
  121. package/dist/packages/stats/lotPattern.js +1 -1
  122. package/dist/packages/stats/math.d.ts +9 -6
  123. package/dist/packages/stats/math.js +1 -1
  124. package/dist/packages/stats/metadataColumns.js +1 -1
  125. package/dist/packages/stats/patternClassification.d.ts +1 -1
  126. package/dist/packages/stats/patternClassification.js +1 -1
  127. package/dist/packages/stats/plotData.d.ts +258 -0
  128. package/dist/packages/stats/plotData.js +1 -0
  129. package/dist/packages/stats/plotId.d.ts +3 -0
  130. package/dist/packages/stats/plotId.js +1 -0
  131. package/dist/packages/stats/plotSpec.d.ts +119 -0
  132. package/dist/packages/stats/plotSpec.js +4 -0
  133. package/dist/packages/stats/presentation.d.ts +2 -0
  134. package/dist/packages/stats/presentation.js +1 -1
  135. package/dist/packages/stats/regions.d.ts +15 -0
  136. package/dist/packages/stats/regions.js +1 -1
  137. package/dist/packages/stats/renderSummaryReport.d.ts +8 -3
  138. package/dist/packages/stats/renderSummaryReport.js +15 -15
  139. package/dist/packages/stats/reportHtml.d.ts +1 -1
  140. package/dist/packages/stats/reportHtml.js +36 -29
  141. package/dist/packages/stats/scatter.d.ts +6 -0
  142. package/dist/packages/stats/scatter.js +1 -1
  143. package/dist/packages/stats/sweep.d.ts +37 -1
  144. package/dist/packages/stats/sweep.js +1 -1
  145. package/dist/packages/stats/sweepText.d.ts +14 -0
  146. package/dist/packages/stats/sweepText.js +1 -0
  147. package/dist/packages/stats/sweepXFromName.d.ts +14 -0
  148. package/dist/packages/stats/sweepXFromName.js +1 -1
  149. package/dist/packages/stats/synthesis.d.ts +14 -4
  150. package/dist/packages/stats/synthesis.js +1 -1
  151. package/dist/packages/stats/testPassRate.d.ts +6 -0
  152. package/dist/packages/stats/testPassRate.js +1 -1
  153. package/dist/packages/stats/trend.js +1 -1
  154. package/dist/packages/stats/types.d.ts +1 -1
  155. package/dist/packages/stats/yield.d.ts +15 -6
  156. package/dist/packages/stats/yield.js +1 -1
  157. package/llms.txt +15 -3
  158. package/package.json +3 -3
@@ -0,0 +1,42 @@
1
+ import type { Die } from '../core/dies.js';
2
+ import type { Wafer, WaferReticle } from '../core/wafer.js';
3
+ export declare const DIE_REGION_KEYS: readonly ["ring", "quadrant", "reticleCell", "reticleShot"];
4
+ export type DieRegionKey = (typeof DIE_REGION_KEYS)[number];
5
+ /** What a region needs to place a die. */
6
+ export interface RegionContext {
7
+ /** The wafer's geometry. Its `reticle`, when the host gave a stepper field, is what makes the reticle regions exist. */
8
+ wafer?: Wafer;
9
+ ringCount: number;
10
+ /** A stepper field to use instead of `wafer.reticle`, for a caller that was handed the config on its own. */
11
+ reticle?: WaferReticle;
12
+ }
13
+ /** The families findings and region yield group dies by. Reticle shot has none: no finding is made per shot. */
14
+ export type RegionFamily = 'ring' | 'quadrant' | 'reticle-position';
15
+ /** How findings and region yield group dies into this region: the key a finding carries, its words, and the order of the rows. */
16
+ export interface RegionGrouping {
17
+ family: RegionFamily;
18
+ place(die: Die, ctx: RegionContext): {
19
+ key: string;
20
+ label: string;
21
+ } | undefined;
22
+ /** Order of two region keys. */
23
+ order(a: string, b: string): number;
24
+ }
25
+ export interface DieRegionDef {
26
+ key: DieRegionKey;
27
+ /** The field's name wherever it is listed. */
28
+ label: string;
29
+ /** Whether this population can place a die in the region at all. */
30
+ available(ctx: RegionContext, anyPositioned: boolean): boolean;
31
+ /** The die's value as text on screen and in a chart (`Ring 2`, `NE`, `Reticle cell (1, 3)`), or undefined when it has none. */
32
+ valueOf(die: Die, ctx: RegionContext): string | undefined;
33
+ /** The same value as a spreadsheet wants it: a bare number or a short code. Defaults to `valueOf`. */
34
+ rawOf?(die: Die, ctx: RegionContext): string | undefined;
35
+ /** Present when findings and region yield group dies by this region. */
36
+ grouping?: RegionGrouping;
37
+ }
38
+ export declare const DIE_REGIONS: Record<DieRegionKey, DieRegionDef>;
39
+ /** The regions this population offers, in the order they are listed. */
40
+ export declare function availableRegions(ctx: RegionContext, anyPositioned: boolean): DieRegionDef[];
41
+ export declare const isDieRegionKey: (k: string) => k is DieRegionKey;
42
+ //# sourceMappingURL=dieRegions.d.ts.map
@@ -0,0 +1 @@
1
+ import{classifyDie as c}from"../core/classify.js";import{getReticleCell as f,getReticleShot as d}from"../core/reticle.js";import{requireRingCount as g}from"../core/ringCount.js";import{hasPosition as l}from"../core/dies.js";import{getRingLabel as s}from"../core/classify.js";export const DIE_REGION_KEYS=["ring","quadrant","reticleCell","reticleShot"];function p(e,r){return!!r.wafer&&l(e)&&e.physX!==void 0&&e.physY!==void 0}function i(e,r,n){if(p(e,r))return c(e,r.wafer,{ringCount:g(r,n)})}const t=new Map([["quadrant:NE",0],["quadrant:NW",1],["quadrant:SE",2],["quadrant:SW",3]]);function a(e,r){const n=r.reticle??r.wafer?.reticle;return n&&l(e)?f(e,n):void 0}export const DIE_REGIONS={ring:{key:"ring",label:"Ring",available:(e,r)=>!!e.wafer&&r,valueOf:(e,r)=>{const n=i(e,r,"a ring of a plot");return n?`Ring ${n.ring}`:void 0},rawOf:(e,r)=>{const n=i(e,r,"a ring of a plot");return n?String(n.ring):void 0},grouping:{family:"ring",place:(e,r)=>{const n=i(e,r,"a ring");return n?{key:`ring:${n.ring}`,label:s(n.ring,r.ringCount)}:void 0},order:(e,r)=>e.localeCompare(r)}},quadrant:{key:"quadrant",label:"Quadrant",available:(e,r)=>!!e.wafer&&r,valueOf:(e,r)=>i(e,r,"a quadrant of a plot")?.quadrant,grouping:{family:"quadrant",place:(e,r)=>{const n=i(e,r,"a quadrant");return n?{key:`quadrant:${n.quadrant}`,label:n.quadrant}:void 0},order:(e,r)=>(t.get(e)??4)-(t.get(r)??4)}},reticleCell:{key:"reticleCell",label:"Reticle cell",available:(e,r)=>!!(e.reticle??e.wafer?.reticle)&&r,valueOf:(e,r)=>{const n=a(e,r);return n?`Reticle cell (${n.column}, ${n.row})`:void 0},grouping:{family:"reticle-position",place:(e,r)=>{const n=a(e,r);return n?{key:`reticle-position:cell:${n.column},${n.row}`,label:`Reticle cell (${n.column}, ${n.row})`}:void 0},order:(e,r)=>e.localeCompare(r,void 0,{numeric:!0})}},reticleShot:{key:"reticleShot",label:"Reticle shot",available:(e,r)=>!!(e.reticle??e.wafer?.reticle)&&r,valueOf:(e,r)=>{const n=r.reticle??r.wafer?.reticle;if(!n||!l(e))return;const{column:o,row:u}=d(e,n);return`Reticle shot (${o}, ${u})`}}};export function availableRegions(e,r){return DIE_REGION_KEYS.map(n=>DIE_REGIONS[n]).filter(n=>n.available(e,r))}export const isDieRegionKey=e=>DIE_REGION_KEYS.includes(e);
@@ -29,6 +29,8 @@ export interface FacetField {
29
29
  /** True when the field has more than one distinct value — i.e. splitting on it actually partitions the data. */
30
30
  splittable: boolean;
31
31
  }
32
+ /** What a host says about one wafer attribute (`attributes` on the render options): its label, whether it is a Group by and Compare by choice, and whether it is a date. The same shape as a curation entry. */
33
+ export type WaferAttributeDef = FacetCuration;
32
34
  /** Curation for one metadata key: label + whether it's offered as a facet by default + date handling. */
33
35
  export interface FacetCuration {
34
36
  label: string;
@@ -41,6 +43,12 @@ export interface FacetCuration {
41
43
  * (not replace) this via `buildFacetTable`'s `curation` option — their own
42
44
  * app-specific extra keys layer on top rather than needing to redeclare these. */
43
45
  export declare const DEFAULT_FACET_CURATION: Record<string, FacetCuration>;
46
+ /**
47
+ * A wafer attribute's name wherever it is listed or headed: the curated label when the key has one, else the key spelled out
48
+ * (`prettyKey`). The ONE label for an attribute, so Group by, the plot fields, the Wafers table, the header strip and the
49
+ * reports cannot name it differently. `curation` is the host's own on top of the defaults (`insights.attributes`).
50
+ */
51
+ export declare function attributeLabel(key: string, curation?: Record<string, FacetCuration>): string;
44
52
  /** The faceting value of one metadata key for one wafer's metadata — the raw
45
53
  * value, except date-curated fields are truncated to date-only so grouping
46
54
  * is by day, not timestamp. */
@@ -1 +1 @@
1
- import{metadataDisplayValue as b}from"../core/metadata.js";import{compareNatural as y,prettyKey as C}from"../core/utils.js";export const FACET_NONE_VALUE="(none)";export{prettyKey}from"../core/utils.js";export const DEFAULT_FACET_CURATION={split:{label:"Split"},lot:{label:"Lot"},product:{label:"Product"},testProgram:{label:"Program"},temperature:{label:"Temperature"},testDate:{label:"Test date",date:!0},operator:{label:"Operator"},waferId:{label:"Wafer",facet:!1}};function O(e){const t=e.indexOf("T");return t>0?e.slice(0,t):e}export function facetValueOf(e,t,o=DEFAULT_FACET_CURATION){const l=b(e?.[t]);if(l!==void 0)return o[t]?.date?O(l):l}export function commonMetadata(e){if(!e.length)return{};const t=e[0].metadata??{},o={};for(const[l,r]of Object.entries(t))r==null||r===""||e.every(d=>(d.metadata??{})[l]===r)&&(o[l]=r);return o}export function buildFacetTable(e,t={}){const o={...DEFAULT_FACET_CURATION,...t.curation},l=t.facetableOnly??!0,r=new Set;for(const n of e)for(const c of Object.keys(n.metadata??{}))r.add(c);const m=[...Object.keys(o).filter(n=>r.has(n)),...[...r].filter(n=>!(n in o))],p=[];for(const n of m){const c=o[n];if(l&&c&&c.facet===!1)continue;const u=new Map;for(const f of e){const a=facetValueOf(f.metadata,n,o)??FACET_NONE_VALUE,i=u.get(a)??{waferCount:0,dieCount:0};i.waferCount+=1,i.dieCount+=f.dieCount??0,u.set(a,i)}if(u.size===0)continue;const s=Array.from(u,([f,a])=>({value:f,waferCount:a.waferCount,dieCount:a.dieCount}));s.sort((f,a)=>(f.value===FACET_NONE_VALUE?1:0)-(a.value===FACET_NONE_VALUE?1:0)||a.waferCount-f.waferCount||y(f.value,a.value)),p.push({key:n,label:c?.label??C(n),values:s,splittable:s.length>1})}return p}
1
+ import{metadataDisplayValue as C}from"../core/metadata.js";import{compareNatural as y,prettyKey as b}from"../core/utils.js";export const FACET_NONE_VALUE="(none)";export{prettyKey}from"../core/utils.js";export const DEFAULT_FACET_CURATION={split:{label:"Split"},lot:{label:"Lot"},product:{label:"Product"},testProgram:{label:"Test Program"},temperature:{label:"Temperature"},testDate:{label:"Test Date",date:!0},operator:{label:"Operator"},waferId:{label:"Wafer Id",facet:!1}};export function attributeLabel(t,e){return e?.[t]?.label??DEFAULT_FACET_CURATION[t]?.label??b(t)}function O(t){const e=t.indexOf("T");return e>0?t.slice(0,e):t}export function facetValueOf(t,e,o=DEFAULT_FACET_CURATION){const l=C(t?.[e]);if(l!==void 0)return o[e]?.date?O(l):l}export function commonMetadata(t){if(!t.length)return{};const e=t[0].metadata??{},o={};for(const[l,r]of Object.entries(e))r==null||r===""||t.every(d=>(d.metadata??{})[l]===r)&&(o[l]=r);return o}export function buildFacetTable(t,e={}){const o={...DEFAULT_FACET_CURATION,...e.curation},l=e.facetableOnly??!0,r=new Set;for(const n of t)for(const u of Object.keys(n.metadata??{}))r.add(u);const m=[...Object.keys(o).filter(n=>r.has(n)),...[...r].filter(n=>!(n in o))],p=[];for(const n of m){const u=o[n];if(l&&u&&u.facet===!1)continue;const c=new Map;for(const f of t){const a=facetValueOf(f.metadata,n,o)??FACET_NONE_VALUE,i=c.get(a)??{waferCount:0,dieCount:0};i.waferCount+=1,i.dieCount+=f.dieCount??0,c.set(a,i)}if(c.size===0)continue;const s=Array.from(c,([f,a])=>({value:f,waferCount:a.waferCount,dieCount:a.dieCount}));s.sort((f,a)=>(f.value===FACET_NONE_VALUE?1:0)-(a.value===FACET_NONE_VALUE?1:0)||a.waferCount-f.waferCount||y(f.value,a.value)),p.push({key:n,label:u?.label??b(n),values:s,splittable:s.length>1})}return p}
@@ -6,6 +6,8 @@ export interface HistogramBucket {
6
6
  }
7
7
  export interface HistogramItem {
8
8
  label?: string;
9
+ /** The wafer this item is, when it is one (an Insights wafer index): lets a click on a bucket say which wafers its dies are on. */
10
+ key?: number;
9
11
  dies?: Die[];
10
12
  }
11
13
  /** One overlaid series in a faceted histogram — per-group counts over the shared bucket ranges. */
@@ -59,6 +61,31 @@ clip?: {
59
61
  lo: number;
60
62
  hi: number;
61
63
  }): HistogramBucket[];
64
+ /**
65
+ * The width the buckets were laid out with, read back from them. Every count AND every pick of a bucket's dies bins with
66
+ * this one number, so the dies a click selects are exactly the bar's count: recomputing the width from the span in one
67
+ * place and from the bucket edges in another can differ by a rounding error, which moves a die on an edge to the next bar.
68
+ */
69
+ export declare function bucketWidthOf(buckets: ReadonlyArray<{
70
+ rangeLow: number;
71
+ rangeHigh: number;
72
+ }>): number;
73
+ /** The bucket a value falls in: equal widths from `min`, the last bucket closed at the top. THE binning rule. */
74
+ export declare function bucketIndexOf(v: number, min: number, width: number, bucketCount: number): number;
75
+ /**
76
+ * The dies behind one bucket of a histogram built by `buildTestHistogramData` over `items`, per item: every die whose
77
+ * value lands in it by the same rule that counted it (so the dies a click picks out are exactly the bar's `count`).
78
+ * Values outside the buckets' range, which a clipped axis dropped, are not in any bucket.
79
+ */
80
+ export declare function diesInBucket(items: HistogramItem[], testNumber: number, buckets: ReadonlyArray<Pick<HistogramBucket, 'rangeLow' | 'rangeHigh'>>, index: number,
81
+ /** The clip the buckets were built with, if any: values outside it were not counted, so they are not picked. */
82
+ clip?: {
83
+ lo: number;
84
+ hi: number;
85
+ }): Array<{
86
+ item: HistogramItem;
87
+ dies: Die[];
88
+ }>;
62
89
  /**
63
90
  * Faceted histogram: one count-series per group over a *shared* set of
64
91
  * buckets, so the series overlay and compare directly. The bucket range
@@ -1 +1 @@
1
- import{testValue as v}from"../core/dieTable.js";export function collectTestValues(d,u){const t=[];for(const i of d)for(const f of i.dies??[]){const o=v(f,u);o!==void 0&&Number.isFinite(o)&&t.push(o)}return t}export function testValueExtent(d,u){let t=1/0,i=-1/0;for(const f of d)for(const o of f.dies??[]){const n=v(o,u);n!==void 0&&Number.isFinite(n)&&(n<t&&(t=n),n>i&&(i=n))}return t===1/0?{min:NaN,max:NaN}:{min:t,max:i}}export function buildTestHistogramData(d,u,t=16,i,f,o){let n=collectTestValues(d,u);if(o&&(n=n.filter(e=>e>=o.lo&&e<=o.hi)),n.length===0)return[];let r=n[0],a=n[0];for(let e=1;e<n.length;e++)n[e]<r&&(r=n[e]),n[e]>a&&(a=n[e]);const l=i!==void 0?Math.min(r,i):r,M=((f!==void 0?Math.max(a,f):a)-l||1)/t,h=Array.from({length:t},(e,x)=>({rangeLow:l+x*M,rangeHigh:l+(x+1)*M,count:0}));for(const e of n){const x=Math.min(t-1,Math.floor((e-l)/M));h[x].count++}return h}export function buildTestHistogramSeries(d,u,t=16,i,f,o){const n=new Map;let r=1/0,a=-1/0;for(const s of d){const m=[];for(const y of s.items)for(const p of y.dies??[]){const c=v(p,u);if(c!==void 0&&Number.isFinite(c)){if(o&&(c<o.lo||c>o.hi))continue;m.push(c),c<r&&(r=c),c>a&&(a=c)}}n.set(s.key,m)}const l=d.map(s=>s.key).filter(s=>n.get(s).length>0);if(l.length===0)return{ranges:[],series:[]};const g=i!==void 0?Math.min(r,i):r,h=((f!==void 0?Math.max(a,f):a)-g||1)/t,e=Array.from({length:t},(s,m)=>({rangeLow:g+m*h,rangeHigh:g+(m+1)*h})),x=l.map(s=>{const m=new Array(t).fill(0);for(const y of n.get(s)){const p=Math.min(t-1,Math.floor((y-g)/h));m[p]++}return{groupKey:s,counts:m}});return{ranges:e,series:x}}
1
+ import{testValue as v}from"../core/dieTable.js";export function collectTestValues(o,r){const n=[];for(const e of o)for(const s of e.dies??[]){const i=v(s,r);i!==void 0&&Number.isFinite(i)&&n.push(i)}return n}export function testValueExtent(o,r){let n=1/0,e=-1/0;for(const s of o)for(const i of s.dies??[]){const t=v(i,r);t!==void 0&&Number.isFinite(t)&&(t<n&&(n=t),t>e&&(e=t))}return n===1/0?{min:NaN,max:NaN}:{min:n,max:e}}export function buildTestHistogramData(o,r,n=16,e,s,i){let t=collectTestValues(o,r);if(i&&(t=t.filter(f=>f>=i.lo&&f<=i.hi)),t.length===0)return[];let c=t[0],a=t[0];for(let f=1;f<t.length;f++)t[f]<c&&(c=t[f]),t[f]>a&&(a=t[f]);const u=e!==void 0?Math.min(c,e):c,d=((s!==void 0?Math.max(a,s):a)-u||1)/n,x=Array.from({length:n},(f,M)=>({rangeLow:u+M*d,rangeHigh:u+(M+1)*d,count:0})),y=bucketWidthOf(x);for(const f of t)x[bucketIndexOf(f,u,y,n)].count++;return x}export function bucketWidthOf(o){const r=o.length;return(o[r-1].rangeHigh-o[0].rangeLow)/r||1}export function bucketIndexOf(o,r,n,e){return Math.min(e-1,Math.floor((o-r)/n))}export function diesInBucket(o,r,n,e,s){if(n.length===0||e<0||e>=n.length)return[];const i=n[0].rangeLow,t=n[n.length-1].rangeHigh,c=bucketWidthOf(n),a=[];for(const u of o){const m=[];for(const p of u.dies??[]){const d=v(p,r);d===void 0||!Number.isFinite(d)||d<i||d>t||s&&(d<s.lo||d>s.hi)||bucketIndexOf(d,i,c,n.length)===e&&m.push(p)}m.length&&a.push({item:u,dies:m})}return a}export function buildTestHistogramSeries(o,r,n=16,e,s,i){const t=new Map;let c=1/0,a=-1/0;for(const h of o){const l=[];for(const N of h.items)for(const w of N.dies??[]){const g=v(w,r);if(g!==void 0&&Number.isFinite(g)){if(i&&(g<i.lo||g>i.hi))continue;l.push(g),g<c&&(c=g),g>a&&(a=g)}}t.set(h.key,l)}const u=o.map(h=>h.key).filter(h=>t.get(h).length>0);if(u.length===0)return{ranges:[],series:[]};const m=e!==void 0?Math.min(c,e):c,x=((s!==void 0?Math.max(a,s):a)-m||1)/n,y=Array.from({length:n},(h,l)=>({rangeLow:m+l*x,rangeHigh:m+(l+1)*x})),f=bucketWidthOf(y),M=u.map(h=>{const l=new Array(n).fill(0);for(const N of t.get(h))l[bucketIndexOf(N,m,f,n)]++;return{groupKey:h,counts:l}});return{ranges:y,series:M}}
@@ -8,9 +8,12 @@ export { setReportOpener } from './renderFindingsReport.js';
8
8
  export { renderWaferReportHtml, renderLotReportHtml } from './renderSummaryReport.js';
9
9
  export type { ReportMap } from './renderSummaryReport.js';
10
10
  export type { SummaryReportParams } from './renderSummaryReport.js';
11
- export { buildFacetTable, facetValueOf, FACET_NONE_VALUE } from './facets.js';
11
+ export { buildFacetTable, facetValueOf, attributeLabel, FACET_NONE_VALUE } from './facets.js';
12
+ export type { WaferAttributeDef } from './facets.js';
12
13
  export type { FacetField, FacetValue, FacetCuration, FacetItem, BuildFacetTableOptions } from './facets.js';
13
14
  export type { MetadataKeySelection } from './metadataColumns.js';
14
15
  export { mergeTestDefs } from './mergeTestDefs.js';
15
16
  export type { MergedTestDefs, TestDefConflict, TestDefConflictKind } from './mergeTestDefs.js';
17
+ export { readPlotsFile, writePlotsFile } from './plotSpec.js';
18
+ export type { PlotSpec, ReadPlotsResult } from './plotSpec.js';
16
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- export*from"./types.js";export{analyzeWaferMap}from"./analyzeWaferMap.js";export{analyzeWaferLot}from"./analyzeWaferLot.js";export{filterFindings,visibleFindings}from"./filterFindings.js";export{setReportOpener}from"./renderFindingsReport.js";export{renderWaferReportHtml,renderLotReportHtml}from"./renderSummaryReport.js";export{buildFacetTable,facetValueOf,FACET_NONE_VALUE}from"./facets.js";export{mergeTestDefs}from"./mergeTestDefs.js";
1
+ export*from"./types.js";export{analyzeWaferMap}from"./analyzeWaferMap.js";export{analyzeWaferLot}from"./analyzeWaferLot.js";export{filterFindings,visibleFindings}from"./filterFindings.js";export{setReportOpener}from"./renderFindingsReport.js";export{renderWaferReportHtml,renderLotReportHtml}from"./renderSummaryReport.js";export{buildFacetTable,facetValueOf,attributeLabel,FACET_NONE_VALUE}from"./facets.js";export{mergeTestDefs}from"./mergeTestDefs.js";export{readPlotsFile,writePlotsFile}from"./plotSpec.js";
@@ -1 +1 @@
1
- import{benjaminiHochberg as v,mannKendall as b}from"./math.js";import{fmt as y}from"../renderer/fmt.js";export const DRIFT_MIN_WAFERS=5;const N=2,M=.5,S=5,x=1;function _(u){const d=[],a=u.map(n=>({waferIndex:n.waferIndex,y:n.summary.stats.yieldPercent})).filter(n=>n.y!==null&&n.y!==void 0);if(a.length>=DRIFT_MIN_WAFERS){const n=b(a.map(e=>e.y));n&&d.push({kind:"yield",label:"Yield",values:a.map(e=>e.y),waferIndices:a.map(e=>e.waferIndex),mk:n})}const r=new Map;for(const{waferIndex:n,summary:e}of u)for(const t of e.stats.perTestStats??[]){if(!Number.isFinite(t.mean)||!(t.count>0))continue;const l=r.get(t.testNumber)??{label:t.label,rows:[]};l.rows.push({waferIndex:n,mean:t.mean,n:t.count,sd:t.stddev}),r.set(t.testNumber,l)}for(const[n,{label:e,rows:t}]of r){if(t.length<DRIFT_MIN_WAFERS)continue;const l=b(t.map(s=>s.mean));if(!l)continue;const m=t.reduce((s,f)=>s+f.n,0),o=Math.sqrt(t.reduce((s,f)=>s+f.n*f.sd**2,0)/m);d.push({kind:"test",testNumber:n,label:e,values:t.map(s=>s.mean),waferIndices:t.map(s=>s.waferIndex),sigma:o,mk:l})}return d}export function buildDriftFindings(u,d){const a=_(u);if(!a.length)return[];const r=v(a.map(e=>e.mk.pValue)),n=[];return a.forEach((e,t)=>{if(r[t]>d)return;const{slope:l,intercept:m,n:o}=e.mk,s=m,i=m+l*(o-1)-s,p=i>0,h=e.kind==="test"&&e.sigma&&e.sigma>0?Math.abs(i)/e.sigma:void 0;if(e.kind==="yield"?Math.abs(i)<N:h===void 0||h<M)return;const g=(e.kind==="yield"?Math.abs(i)>=S:(h??0)>=x)&&r[t]<=.01?"unusual":"notable",k=p?"rises":"falls",c={first:e.values[0],last:e.values[e.values.length-1]},I=e.kind==="yield"?`${c.first.toFixed(1)}% \u2192 ${c.last.toFixed(1)}%`:`${y(c.first)} \u2192 ${y(c.last)}`,w=e.kind==="yield"?"on successive wafers":"across the wafers";n.push({id:e.kind==="yield"?"drift:yield":`drift:test:${e.testNumber}`,level:"inter-wafer",severity:g,variable:e.kind==="yield"?{kind:"yield",label:"Yield"}:{kind:"test",index:e.testNumber,label:e.label},comparison:{family:"wafer",left:"Wafers in input order",right:"a constant level"},effect:{direction:p?"higher":"lower",absoluteDelta:e.kind==="yield"?i/100:i,...e.kind==="yield"?{}:{relativeDelta:s!==0?i/Math.abs(s):void 0},effectSize:e.kind==="yield"?i/100:i/(e.sigma||1)},stats:{method:"mann-kendall",pValue:e.mk.pValue,adjustedPValue:r[t],sampleSizeLeft:o,sampleSizeRight:0},summary:`${e.label} ${k} ${w}: ${I} over ${o} wafers (input order)`,highlight:{kind:"wafer",waferIndices:e.waferIndices}})}),n}
1
+ import{benjaminiHochberg as v,mannKendall as b}from"./math.js";import{fmt as y}from"../renderer/fmt.js";export const DRIFT_MIN_WAFERS=5;const M=2,N=.5,x=5,S=1;function _(m){const d=[],i=m.map(n=>({waferIndex:n.waferIndex,y:n.summary.stats.yieldPercent})).filter(n=>n.y!==null&&n.y!==void 0);if(i.length>=DRIFT_MIN_WAFERS){const n=b(i.map(e=>e.y));n&&d.push({kind:"yield",label:"Yield",values:i.map(e=>e.y),waferIndices:i.map(e=>e.waferIndex),mk:n})}const r=new Map;for(const{waferIndex:n,summary:e}of m)for(const t of e.stats.perTestStats??[]){if(!Number.isFinite(t.mean)||!(t.count>0))continue;const l=r.get(t.testNumber)??{label:t.label,rows:[]};l.rows.push({waferIndex:n,mean:t.mean,n:t.count,sd:t.stddev}),r.set(t.testNumber,l)}for(const[n,{label:e,rows:t}]of r){if(t.length<DRIFT_MIN_WAFERS)continue;const l=b(t.map(s=>s.mean));if(!l)continue;const o=t.reduce((s,u)=>s+Math.max(0,u.n-1),0),f=o>0?Math.sqrt(t.reduce((s,u)=>s+Math.max(0,u.n-1)*u.sd**2,0)/o):0;d.push({kind:"test",testNumber:n,label:e,values:t.map(s=>s.mean),waferIndices:t.map(s=>s.waferIndex),sigma:f,mk:l})}return d}export function buildDriftFindings(m,d){const i=_(m);if(!i.length)return[];const r=v(i.map(e=>e.mk.pValue)),n=[];return i.forEach((e,t)=>{if(r[t]>d)return;const{slope:l,intercept:o,n:f}=e.mk,s=o,a=o+l*(f-1)-s,p=a>0,h=e.kind==="test"&&e.sigma&&e.sigma>0?Math.abs(a)/e.sigma:void 0;if(e.kind==="yield"?Math.abs(a)<M:h===void 0||h<N)return;const g=(e.kind==="yield"?Math.abs(a)>=x:(h??0)>=S)&&r[t]<=.01?"unusual":"notable",k=p?"rises":"falls",c={first:e.values[0],last:e.values[e.values.length-1]},I=e.kind==="yield"?`${c.first.toFixed(1)}% \u2192 ${c.last.toFixed(1)}%`:`${y(c.first)} \u2192 ${y(c.last)}`,w=e.kind==="yield"?"on successive wafers":"across the wafers";n.push({id:e.kind==="yield"?"drift:yield":`drift:test:${e.testNumber}`,level:"inter-wafer",severity:g,variable:e.kind==="yield"?{kind:"yield",label:"Yield"}:{kind:"test",index:e.testNumber,label:e.label},comparison:{family:"wafer",left:"Wafers in input order",right:"a constant level"},effect:{direction:p?"higher":"lower",absoluteDelta:e.kind==="yield"?a/100:a,...e.kind==="yield"?{}:{relativeDelta:s!==0?a/Math.abs(s):void 0},effectSize:e.kind==="yield"?a/100:a/(e.sigma||1)},stats:{method:"mann-kendall",pValue:e.mk.pValue,adjustedPValue:r[t],sampleSizeLeft:f,sampleSizeRight:0},summary:`${e.label} ${k} ${w}: ${I} over ${f} wafers (input order)`,highlight:{kind:"wafer",waferIndices:e.waferIndices}})}),n}
@@ -1 +1 @@
1
- import{getDieKey as R,isPositionedDie as v,isYieldEligibleDie as L,positionKey as h}from"../core/dies.js";import{itemPassBins as j}from"../core/passBins.js";import{classifyFailingDies as C,patternFailVerdict as K}from"./patternClassification.js";import{benjaminiHochberg as D,binomialUpperTail as F}from"./math.js";import{passesRateGate as G,rateRelativeEffect as T,twoProportionZ as V,zPValue as W}from"./analyzeWaferMap.js";const q=.01;export function findLotPattern(H,c){const l=[];let f,k=0,w=0;if(H.forEach((e,n)=>{if(e.isLotStack)return;const s=new Set(j(e)),i=[],t=[];for(const a of e.dies){if(!L(a)||!v(a))continue;const o=K(a,s);o!==void 0&&(i.push(a),t.push(o))}if(!i.length)return;const r=(a,o)=>Math.abs(a-o)<=q*Math.max(Math.abs(a),Math.abs(o));if(!f)f=e,k=i[0].width,w=i[0].height;else if(!r(e.wafer.radius,f.wafer.radius)||!r(i[0].width,k)||!r(i[0].height,w))return;l.push({index:n,dies:i,fails:t})}),!f||l.length<2)return null;const d=new Map;let z=0,m=0;for(const e of l)e.dies.forEach((n,s)=>{const i=h(n);let t=d.get(i);t||d.set(i,t={die:n,n:0,k:0}),t.n++,e.fails[s]&&(t.k++,m++),z++});if(m===0)return null;const E=m/z,p=[...d.values()],M=p.map(e=>{let n=0,s=0;for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){const r=i===0&&t===0?e:d.get(h({x:e.die.x+i,y:e.die.y+t}));r&&(n+=r.n,s+=r.k)}return{n,k:s}}),N=D(M.map(e=>F(e.k,e.n,E))),x=new Set,S=[];p.forEach((e,n)=>{N[n]>c.significanceLevel||e.k/e.n<=E||(x.add(h(e.die)),S.push(e.die))});const u=C(S,p.map(e=>e.die),f.wafer,f.ringCount??c.ringCount);if(!u||u.pattern==="random"||u.pattern==="none")return null;const b=l.map(e=>{let n=0,s=0,i=0,t=0;const r=[];e.dies.forEach((o,y)=>{x.has(h(o))?(s++,e.fails[y]&&(n++,r.push(R(o)))):(t++,e.fails[y]&&i++)});const a=s>=c.minimumSampleSize&&t>=c.minimumSampleSize?V(n,s,i,t):0;return{index:e.index,z:a,hits:n,n:s,restHits:i,restN:t,inside:r}}),P=D(b.map(e=>e.z>0?W(e.z):1)),g=new Map;return b.forEach((e,n)=>{if(e.z<=0)return;const s=e.hits/e.n-e.restHits/e.restN,i=T({hits:e.hits,n:e.n,restHits:e.restHits,restN:e.restN,passRate:!1});G(P[n],s,i,c)&&g.set(e.index,e.inside)}),g.size?{classification:u,carriers:g}:null}
1
+ import{requireRingCount as P}from"../core/ringCount.js";import{getDieKey as v,isPositionedDie as L,isYieldEligibleDie as j,positionKey as h}from"../core/dies.js";import{itemPassBins as K}from"../core/passBins.js";import{classifyFailingDies as q,patternFailVerdict as C}from"./patternClassification.js";import{benjaminiHochberg as D,binomialUpperTail as F}from"./math.js";import{passesRateGate as G,rateRelativeEffect as T,twoProportionZ as V,zPValue as W}from"./analyzeWaferMap.js";const A=.01;export function findLotPattern(H,c){const l=[];let f,k=0,w=0;if(H.forEach((e,n)=>{if(e.isLotStack)return;const s=new Set(K(e)),t=[],i=[];for(const o of e.dies){if(!j(o)||!L(o))continue;const a=C(o,s);a!==void 0&&(t.push(o),i.push(a))}if(!t.length)return;const r=(o,a)=>Math.abs(o-a)<=A*Math.max(Math.abs(o),Math.abs(a));if(!f)f=e,k=t[0].width,w=t[0].height;else if(!r(e.wafer.radius,f.wafer.radius)||!r(t[0].width,k)||!r(t[0].height,w))return;l.push({index:n,dies:t,fails:i})}),!f||l.length<2)return null;const d=new Map;let z=0,p=0;for(const e of l)e.dies.forEach((n,s)=>{const t=h(n);let i=d.get(t);i||d.set(t,i={die:n,n:0,k:0}),i.n++,e.fails[s]&&(i.k++,p++),z++});if(p===0)return null;const E=p/z,m=[...d.values()],M=m.map(e=>{let n=0,s=0;for(let t=-1;t<=1;t++)for(let i=-1;i<=1;i++){const r=t===0&&i===0?e:d.get(h({x:e.die.x+t,y:e.die.y+i}));r&&(n+=r.n,s+=r.k)}return{n,k:s}}),N=D(M.map(e=>F(e.k,e.n,E))),x=new Set,S=[];m.forEach((e,n)=>{N[n]>c.significanceLevel||e.k/e.n<=E||(x.add(h(e.die)),S.push(e.die))});const u=q(S,m.map(e=>e.die),f.wafer,P(f,"the lot pattern"));if(!u||u.pattern==="random"||u.pattern==="none")return null;const b=l.map(e=>{let n=0,s=0,t=0,i=0;const r=[];e.dies.forEach((a,y)=>{x.has(h(a))?(s++,e.fails[y]&&(n++,r.push(v(a)))):(i++,e.fails[y]&&t++)});const o=s>=c.minimumSampleSize&&i>=c.minimumSampleSize?V(n,s,t,i):0;return{index:e.index,z:o,hits:n,n:s,restHits:t,restN:i,inside:r}}),R=D(b.map(e=>e.z>0?W(e.z):1)),g=new Map;return b.forEach((e,n)=>{if(e.z<=0)return;const s=e.hits/e.n-e.restHits/e.restN,t=T({hits:e.hits,n:e.n,restHits:e.restHits,restN:e.restN,passRate:!1});G(R[n],s,t,c)&&g.set(e.index,e.inside)}),g.size?{classification:u,carriers:g}:null}
@@ -41,13 +41,18 @@ export declare function robustFence(values: ArrayLike<number>, k?: number, minCo
41
41
  lo: number;
42
42
  hi: number;
43
43
  } | null;
44
+ /** The one variance rule: the sample variance, Σ(x − mean)² / (n − 1); 0 for fewer than two values.
45
+ * `mean` is the values' mean when the caller already has it. Two-pass, not `Σx² − n·x̄²`: the moments
46
+ * form loses most of its significant digits when the variance is small beside the mean, which is the
47
+ * normal shape of a passing parametric test. */
48
+ export declare function sampleVariance(values: ArrayLike<number>, mean?: number): number;
44
49
  /** Descriptive statistics of one population of values — see {@link describeValues}. */
45
50
  export interface DescriptiveStats {
46
51
  min: number;
47
52
  max: number;
48
53
  mean: number;
49
54
  count: number;
50
- /** Population standard deviation (divide by n) — see {@link describeValues}. */
55
+ /** Sample standard deviation (divide by n−1; 0 for fewer than two values) — see {@link sampleVariance}. */
51
56
  stddev: number;
52
57
  median: number;
53
58
  q1: number;
@@ -63,11 +68,9 @@ export interface DescriptiveStats {
63
68
  * up almost all of a large lot panel's time. The mean and σ sum in whatever
64
69
  * order `values` arrives in.
65
70
  *
66
- * σ is the POPULATION standard deviation (divide by n), which is what this
67
- * table has always shown; the capability indices next to it deliberately use
68
- * the sample form (n−1) and say so. Two-pass, not `Σx² − n·x̄²`: the moments
69
- * form loses most of its significant digits when the variance is small beside
70
- * the mean, which is the normal shape of a passing parametric test. */
71
+ * σ is the sample standard deviation (divide by n−1), the same rule as the
72
+ * capability indices and every other σ in the library — see
73
+ * {@link sampleVariance}. */
71
74
  export declare function describeValues(values: Float64Array): DescriptiveStats;
72
75
  /** Min, quartiles and max of `values` — what sorting them and reading the
73
76
  * ends and {@link quantile}s would give — by selection. **Reorders `values`.** */
@@ -1 +1 @@
1
- export function errorFunction(t){const o=t<0?-1:1,n=Math.abs(t),e=.254829592,r=-.284496736,c=1.421413741,i=-1.453152027,s=1.061405429,l=1/(1+.3275911*n),u=1-((((s*l+i)*l+c)*l+r)*l+e)*l*Math.exp(-n*n);return o*u}export function normalCdf(t){return .5*(1+errorFunction(t/Math.sqrt(2)))}export function binomialUpperTail(t,o,n){if(t<=0)return 1;if(t>o||n<=0)return 0;if(n>=1)return 1;let e=t*Math.log(n)+(o-t)*Math.log1p(-n);for(let s=0;s<t;s++)e+=Math.log(o-s)-Math.log(s+1);let r=Math.exp(e),c=0;const i=n/(1-n);for(let s=t;s<=o;s++)c+=r,r*=(o-s)/(s+1)*i;return Math.min(1,c)}export function benjaminiHochberg(t){const o=t.length,n=t.map((c,i)=>i).sort((c,i)=>t[c]-t[i]),e=new Array(o);let r=1;for(let c=o-1;c>=0;c--){const i=n[c];r=Math.min(r,t[i]*o/(c+1),1),e[i]=r}return e}export function quantile(t,o){if(t.length===0)return NaN;const n=o*(t.length-1),e=Math.floor(n),r=Math.ceil(n);return t[e]+(t[r]-t[e])*(n-e)}export function robustFence(t,o=1.5,n=8){const e=Float64Array.from(Array.from(t).filter(s=>Number.isFinite(s)));if(e.length<n)return null;const{q1:r,q3:c}=fiveNumberSummary(e),i=c-r;return i===0?null:{lo:r-o*i,hi:c+o*i}}export function describeValues(t){const o=t.length;let n=0;for(let u=0;u<o;u++)n+=t[u];const e=n/o;let r=0;for(let u=0;u<o;u++)r+=(t[u]-e)**2;const{min:c,q1:i,median:s,q3:h,max:l}=fiveNumberSummary(t);return{min:c,max:l,mean:e,count:o,stddev:Math.sqrt(r/o),median:s,q1:i,q3:h}}export function fiveNumberSummary(t){let o=1/0,n=-1/0;for(let i=0;i<t.length;i++){const s=t[i];s<o&&(o=s),s>n&&(n=s)}t.length===0&&(o=NaN,n=NaN);const{q1:e,median:r,q3:c}=b(t);return{min:o,q1:e,median:r,q3:c,max:n}}function b(t){const o=t.length;if(o===0)return{q1:NaN,median:NaN,q3:NaN};const n=o-1,e=(p,g,f)=>{const a=p*n,m=Math.floor(a),q=N(t,m,g,f);if(a===m)return q;let M=1/0;for(let x=m+1;x<=f;x++)t[x]<M&&(M=t[x]);return q+(M-q)*(a-m)},r=Math.floor(.5*n),c=e(.5,0,n),i=Math.floor(.25*n),s=i===r?e(.25,r,n):u(.25,i,r),l=Math.floor(.75*n)===r?e(.75,r,n):e(.75,r+1,n);return{q1:s,median:c,q3:l};function u(p,g,f){const a=p*n,m=N(t,g,0,f-1);if(a===g)return m;let q=t[f];for(let M=g+1;M<f;M++)t[M]<q&&(q=t[M]);return m+(q-m)*(a-g)}}function N(t,o,n,e){for(;n<e;){const r=t[n],c=t[n+e>>>1],i=t[e],s=r<c?c<i?c:r<i?i:r:r<i?r:c<i?i:c;let h=n,l=e;for(;h<=l;){for(;t[h]<s;)h++;for(;t[l]>s;)l--;if(h<=l){const u=t[h];t[h]=t[l],t[l]=u,h++,l--}}if(o<=l)e=l;else if(o>=h)n=h;else break}return t[o]}export function mannKendall(t){const o=t.length;if(o<3)return null;let n=0;const e=[];for(let f=0;f<o-1;f++)for(let a=f+1;a<o;a++){const m=t[a]-t[f];n+=m>0?1:m<0?-1:0,e.push(m/(a-f))}const r=new Map;for(const f of t)r.set(f,(r.get(f)??0)+1);let c=o*(o-1)*(2*o+5)/18;for(const f of r.values())f>1&&(c-=f*(f-1)*(2*f+5)/18);if(c<=0)return null;const i=n===0?0:(n-Math.sign(n))/Math.sqrt(c),s=Math.min(1,2*(1-normalCdf(Math.abs(i))));e.sort((f,a)=>f-a);const h=e.length>>1,l=e.length%2?e[h]:(e[h-1]+e[h])/2,u=t.map((f,a)=>f-l*a).sort((f,a)=>f-a),p=u.length>>1,g=u.length%2?u[p]:(u[p-1]+u[p])/2;return{n:o,s:n,z:i,pValue:s,slope:l,intercept:g}}
1
+ export function errorFunction(t){const o=t<0?-1:1,n=Math.abs(t),r=.254829592,e=-.284496736,i=1.421413741,c=-1.453152027,s=1.061405429,l=1/(1+.3275911*n),a=1-((((s*l+c)*l+i)*l+e)*l+r)*l*Math.exp(-n*n);return o*a}export function normalCdf(t){return .5*(1+errorFunction(t/Math.sqrt(2)))}export function binomialUpperTail(t,o,n){if(t<=0)return 1;if(t>o||n<=0)return 0;if(n>=1)return 1;let r=t*Math.log(n)+(o-t)*Math.log1p(-n);for(let s=0;s<t;s++)r+=Math.log(o-s)-Math.log(s+1);let e=Math.exp(r),i=0;const c=n/(1-n);for(let s=t;s<=o;s++)i+=e,e*=(o-s)/(s+1)*c;return Math.min(1,i)}export function benjaminiHochberg(t){const o=t.length,n=t.map((i,c)=>c).sort((i,c)=>t[i]-t[c]),r=new Array(o);let e=1;for(let i=o-1;i>=0;i--){const c=n[i];e=Math.min(e,t[c]*o/(i+1),1),r[c]=e}return r}export function quantile(t,o){if(t.length===0)return NaN;const n=o*(t.length-1),r=Math.floor(n),e=Math.ceil(n);return t[r]+(t[e]-t[r])*(n-r)}export function robustFence(t,o=1.5,n=8){const r=Float64Array.from(Array.from(t).filter(s=>Number.isFinite(s)));if(r.length<n)return null;const{q1:e,q3:i}=fiveNumberSummary(r),c=i-e;return c===0?null:{lo:e-o*c,hi:i+o*c}}export function sampleVariance(t,o){const n=t.length;if(n<2)return 0;if(o===void 0){let e=0;for(let i=0;i<n;i++)e+=t[i];o=e/n}let r=0;for(let e=0;e<n;e++)r+=(t[e]-o)**2;return r/(n-1)}export function describeValues(t){const o=t.length;let n=0;for(let a=0;a<o;a++)n+=t[a];const r=n/o,e=Math.sqrt(sampleVariance(t,r)),{min:i,q1:c,median:s,q3:u,max:l}=fiveNumberSummary(t);return{min:i,max:l,mean:r,count:o,stddev:e,median:s,q1:c,q3:u}}export function fiveNumberSummary(t){let o=1/0,n=-1/0;for(let c=0;c<t.length;c++){const s=t[c];s<o&&(o=s),s>n&&(n=s)}t.length===0&&(o=NaN,n=NaN);const{q1:r,median:e,q3:i}=d(t);return{min:o,q1:r,median:e,q3:i,max:n}}function d(t){const o=t.length;if(o===0)return{q1:NaN,median:NaN,q3:NaN};const n=o-1,r=(M,g,f)=>{const h=M*n,m=Math.floor(h),x=N(t,m,g,f);if(h===m)return x;let p=1/0;for(let q=m+1;q<=f;q++)t[q]<p&&(p=t[q]);return x+(p-x)*(h-m)},e=Math.floor(.5*n),i=r(.5,0,n),c=Math.floor(.25*n),s=c===e?r(.25,e,n):a(.25,c,e),l=Math.floor(.75*n)===e?r(.75,e,n):r(.75,e+1,n);return{q1:s,median:i,q3:l};function a(M,g,f){const h=M*n,m=N(t,g,0,f-1);if(h===g)return m;let x=t[f];for(let p=g+1;p<f;p++)t[p]<x&&(x=t[p]);return m+(x-m)*(h-g)}}function N(t,o,n,r){for(;n<r;){const e=t[n],i=t[n+r>>>1],c=t[r],s=e<i?i<c?i:e<c?c:e:e<c?e:i<c?c:i;let u=n,l=r;for(;u<=l;){for(;t[u]<s;)u++;for(;t[l]>s;)l--;if(u<=l){const a=t[u];t[u]=t[l],t[l]=a,u++,l--}}if(o<=l)r=l;else if(o>=u)n=u;else break}return t[o]}export function mannKendall(t){const o=t.length;if(o<3)return null;let n=0;const r=[];for(let f=0;f<o-1;f++)for(let h=f+1;h<o;h++){const m=t[h]-t[f];n+=m>0?1:m<0?-1:0,r.push(m/(h-f))}const e=new Map;for(const f of t)e.set(f,(e.get(f)??0)+1);let i=o*(o-1)*(2*o+5)/18;for(const f of e.values())f>1&&(i-=f*(f-1)*(2*f+5)/18);if(i<=0)return null;const c=n===0?0:(n-Math.sign(n))/Math.sqrt(i),s=Math.min(1,2*(1-normalCdf(Math.abs(c))));r.sort((f,h)=>f-h);const u=r.length>>1,l=r.length%2?r[u]:(r[u-1]+r[u])/2,a=t.map((f,h)=>f-l*h).sort((f,h)=>f-h),M=a.length>>1,g=a.length%2?a[M]:(a[M-1]+a[M])/2;return{n:o,s:n,z:c,pValue:s,slope:l,intercept:g}}
@@ -1 +1 @@
1
- import{metadataDisplayValue as k}from"../core/metadata.js";import{compareNatural as w,prettyKey as A}from"../core/utils.js";import{DEFAULT_FACET_CURATION as K}from"./facets.js";const b=64;export function discoverDieMetadataKeys(e,n,s=b){const d=new Set;for(const c of e)if(c.metadata)for(const i of Object.keys(c.metadata))d.add(i);const t=[];for(const c of n??[])d.has(c.key)&&!t.includes(c.key)&&t.push(c.key);const y=[...d].filter(c=>!t.includes(c)).sort(w),a=[...t,...y];return{keys:a.slice(0,s),truncated:a.slice(s)}}function v(e){const n=Object.keys(e).filter(t=>k(e[t])!==void 0),s=Object.keys(K).filter(t=>n.includes(t)),d=n.filter(t=>!s.includes(t)).sort(w);return[...s,...d]}const h=(e,n)=>e==="none"?[]:Array.isArray(e)?e.filter(s=>n.includes(s)):e==="identity"?n.filter(s=>s in K):n;export function resolveMetadataColumns(e){const n=e.waferMetadata??{},s=e.waferPlacement??"csv",d=discoverDieMetadataKeys(e.dies??[],e.metadataFields,e.maxDieKeys??b),t=h(e.dieKeys,d.keys),y=s==="none"?[]:h(e.waferKeys,v(n)).filter(r=>!t.includes(r)),a=new Set(e.reservedLabels??[]),c=(r,o)=>{const f=e.metadataFields?.find(u=>u.key===r)?.label??A(r);if(!a.has(f))return a.add(f),f;const m=o==="die"?`${f} (metadata)`:`${f} (wafer metadata)`;if(!a.has(m))return a.add(m),m;const l=`${f} (${r})`;if(!a.has(l))return a.add(l),l;for(let u=2;;u++){const p=`${l} (${u})`;if(!a.has(p))return a.add(p),p}},i=[];for(const r of t)i.push({key:r,label:c(r,"die"),scope:"die",get:o=>k(o.metadata?.[r])??"",csvOnly:!1});for(const r of y){const o=k(n[r])??"";i.push({key:r,label:c(r,"wafer"),scope:"wafer",get:()=>o,constant:o,csvOnly:s==="csv"})}return{columns:i,truncatedKeys:d.truncated}}
1
+ import{metadataDisplayValue as w}from"../core/metadata.js";import{compareNatural as K,prettyKey as A}from"../core/utils.js";import{DEFAULT_FACET_CURATION as b,attributeLabel as v}from"./facets.js";const k=64;export function discoverDieMetadataKeys(e,n,s=k){const d=new Set;for(const c of e)if(c.metadata)for(const i of Object.keys(c.metadata))d.add(i);const r=[];for(const c of n??[])d.has(c.key)&&!r.includes(c.key)&&r.push(c.key);const y=[...d].filter(c=>!r.includes(c)).sort(K),a=[...r,...y];return{keys:a.slice(0,s),truncated:a.slice(s)}}function D(e){const n=Object.keys(e).filter(r=>w(e[r])!==void 0),s=Object.keys(b).filter(r=>n.includes(r)),d=n.filter(r=>!s.includes(r)).sort(K);return[...s,...d]}const h=(e,n)=>e==="none"?[]:Array.isArray(e)?e.filter(s=>n.includes(s)):e==="identity"?n.filter(s=>s in b):n;export function resolveMetadataColumns(e){const n=e.waferMetadata??{},s=e.waferPlacement??"csv",d=discoverDieMetadataKeys(e.dies??[],e.metadataFields,e.maxDieKeys??k),r=h(e.dieKeys,d.keys),y=s==="none"?[]:h(e.waferKeys,D(n)).filter(t=>!r.includes(t)),a=new Set(e.reservedLabels??[]),c=(t,o)=>{const f=e.metadataFields?.find(u=>u.key===t)?.label??(o==="wafer"?v(t):A(t));if(!a.has(f))return a.add(f),f;const m=o==="die"?`${f} (metadata)`:`${f} (wafer metadata)`;if(!a.has(m))return a.add(m),m;const l=`${f} (${t})`;if(!a.has(l))return a.add(l),l;for(let u=2;;u++){const p=`${l} (${u})`;if(!a.has(p))return a.add(p),p}},i=[];for(const t of r)i.push({key:t,label:c(t,"die"),scope:"die",get:o=>w(o.metadata?.[t])??"",csvOnly:!1});for(const t of y){const o=w(n[t])??"";i.push({key:t,label:c(t,"wafer"),scope:"wafer",get:()=>o,constant:o,csvOnly:s==="csv"})}return{columns:i,truncatedKeys:d.truncated}}
@@ -129,7 +129,7 @@ export declare function patternExplains(pattern: PatternLabel, family: string, r
129
129
  */
130
130
  export declare function classifyPattern(dies: PositionedDie[], wafer: Wafer, options: {
131
131
  passBins: number[];
132
- ringCount?: number;
132
+ ringCount: number;
133
133
  }): PatternClassification | null;
134
134
  /**
135
135
  * {@link classifyPattern} over a failing set already chosen — a wafer's failing
@@ -1 +1 @@
1
- import{findConnectedComponents as j}from"./connectedComponents.js";import{clamp01 as J}from"../core/utils.js";export const DEFAULT_PATTERN_THRESHOLDS={nearFullGlobalRdd:.6,edgeRingEdgeRdd:.18,edgeRingEdgeRddHigh:.3,edgeRingRadialSpread:.45,edgeRingAngularSpread:.6,edgeLocalEdgeRdd:.1,edgeLocalCentroidDist:.76,donutP25Dist:.4,centerCentroidDist:.22,centerCentroidDistHigh:.1,centerEdgeRdd:.35,donutEdgeRdd:.22,scratchLinearScore:.25,scratchLinearScoreHigh:.45,scratchEccentricity:.75,scratchMinReach:.35,minimumFailingDies:5};function q(e,t,r){const d=e.physX-t.center.x,i=e.physY-t.center.y,s=Math.sqrt(d*d+i*i)/t.radius;return Math.min(r,Math.max(1,Math.floor(s*r)+1))===r}function K(e,t,r){if(e.length<3)return 0;let d=0,i=0,s=0;for(const f of e){const g=f.physX-t,R=f.physY-r;d+=g*g,i+=R*R,s+=g*R}d/=e.length,i/=e.length,s/=e.length;const c=d+i,n=d*i-s*s,a=Math.max(0,(c/2)**2-n),h=c/2+Math.sqrt(a),y=c/2-Math.sqrt(a);if(h<=0)return 0;const D=J(y/h);return Math.sqrt(1-D)}function Q(e,t){if(t===0)return 0;const r=new Map,d=new Map,i=new Map,s=new Map;for(const n of e)r.set(n.y,(r.get(n.y)??0)+1),d.set(n.x,(d.get(n.x)??0)+1),i.set(n.x-n.y,(i.get(n.x-n.y)??0)+1),s.set(n.x+n.y,(s.get(n.x+n.y)??0)+1);let c=0;for(const n of r.values())n>c&&(c=n);for(const n of d.values())n>c&&(c=n);for(const n of i.values())n>c&&(c=n);for(const n of s.values())n>c&&(c=n);return c/t}function W(e,t,r,d){const i=t.length,s=e.length,c=i>0?s/i:0,n=t.filter(o=>q(o,r,d)),a=e.filter(o=>q(o,r,d)),h=n.length>0?a.length/n.length:0,y=j(e),D=y.length>0?[...y].sort((o,l)=>l.length-o.length):[e],f=D[0],g=D.slice(0,5).flat(),R=f.length,T=s>0?R/s:0,u=r.center.x,m=r.center.y,p=r.radius;let S=0,N=0,M=1/0,x=0;for(const o of f){S+=o.physX,N+=o.physY;const l=Math.sqrt((o.physX-u)**2+(o.physY-m)**2);l<M&&(M=l),l>x&&(x=l)}const H=S/f.length,O=N/f.length,P=Math.sqrt((H-u)**2+(O-m)**2)/p,A=M===1/0?0:M/p,I=Math.min(x/p,1),C=e.map(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p).sort((o,l)=>o-l),v=C[Math.floor(C.length*.25)]??0,b=t.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p<.5).length,L=t.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p>=.5).length,_=e.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p<.5).length,w=e.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p>=.5).length,F=b>0?_/b:0,X=L>0?w/L:0,z=X>0?F/X:F>0?2:1,G=g.reduce((o,l)=>o+l.physX,0)/g.length,k=g.reduce((o,l)=>o+l.physY,0)/g.length,B=K(g,G,k),U=Q(g,g.length),E=16,Y=new Set;for(const o of a){const l=(Math.atan2(o.physY-m,o.physX-u)+2*Math.PI)%(2*Math.PI);Y.add(Math.floor(l/(2*Math.PI)*E)%E)}const V=a.length>0?Y.size/E:0;return{globalRdd:c,edgeRdd:h,centroidDistNorm:P,minDistNorm:A,maxDistNorm:I,p25DistNorm:v,eccentricity:B,linearScore:U,salienceSize:R,salienceFraction:T,edgeAngularSpread:V,innerOuterRatio:z}}function Z(e,t,r){const d=Math.max(5,Math.round(r*.003)),i=e.salienceSize>=d;if(e.globalRdd<t.nearFullGlobalRdd&&e.p25DistNorm>=t.edgeLocalCentroidDist&&e.edgeAngularSpread>=t.edgeRingAngularSpread&&e.edgeRdd>=t.edgeLocalEdgeRdd)return{pattern:"edge-ring",confidence:e.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};if(e.globalRdd<t.nearFullGlobalRdd&&e.salienceFraction<.1)return{pattern:"random",confidence:"low"};if(e.globalRdd>=t.nearFullGlobalRdd)return{pattern:"near-full",confidence:e.globalRdd>=.8?"high":"medium"};if(i&&e.linearScore>=t.scratchLinearScore&&e.eccentricity>=t.scratchEccentricity&&e.maxDistNorm>=t.scratchMinReach){const a=e.linearScore>=t.scratchLinearScoreHigh?"high":"medium";return{pattern:"scratch",confidence:a,note:a==="medium"?"Scratch detection is less reliable for fragmented or diagonal patterns":void 0}}const s=i&&e.edgeRdd>=t.edgeLocalEdgeRdd&&e.maxDistNorm>=.7;if(s&&e.p25DistNorm>=t.edgeLocalCentroidDist&&e.maxDistNorm-e.minDistNorm<=t.edgeRingRadialSpread)return{pattern:"edge-ring",confidence:e.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};if(s&&e.p25DistNorm>=.55&&e.p25DistNorm<t.edgeLocalCentroidDist)return{pattern:"edge-local",confidence:e.edgeRdd>=t.edgeRingEdgeRdd?"medium":"low"};const c=i&&e.centroidDistNorm<=t.centerCentroidDist&&e.edgeRdd<=t.centerEdgeRdd,n="Center and donut patterns have similar geometry; classification may be imprecise";if(c&&e.p25DistNorm<t.donutP25Dist){const a=e.centroidDistNorm<=t.centerCentroidDistHigh?"high":"medium";return{pattern:"center",confidence:a,note:a!=="high"?n:void 0}}return c&&e.p25DistNorm>=t.donutP25Dist&&e.p25DistNorm<.55?{pattern:"donut",confidence:"medium",note:n}:{pattern:"random",confidence:"low"}}export const PATTERN_LABELS={center:"Center cluster",donut:"Donut","edge-ring":"Edge-ring","edge-local":"Edge-local",scratch:"Scratch","near-full":"Near-full",random:"Random",none:"None"};export function patternFailVerdict(e,t){const r=e.hbin??e.sbin;return r===void 0?void 0:!t.has(r)}export function patternExplains(e,t,r,d){if(!{"edge-ring":["ring","edge-arc"],"edge-local":["edge-arc","sector","quadrant"],center:["ring","cluster"],donut:["ring"],scratch:["cluster","sector","quadrant"],"near-full":["ring"]}[e]?.includes(t))return!1;if(t!=="ring"||r.length===0)return!0;const s=r.includes(d),c=r.includes(1);return e==="edge-ring"||e==="edge-local"?s:e==="center"?c:e==="donut"?!s&&!c:!0}export function classifyPattern(e,t,r){const d=new Set(r.passBins),i=e.filter(s=>patternFailVerdict(s,d)===!0);return classifyFailingDies(i,e,t,r.ringCount??4)}export function classifyFailingDies(e,t,r,d){const i={...DEFAULT_PATTERN_THRESHOLDS},s=Math.max(i.minimumFailingDies,Math.round(t.length*.003));if(e.length<s)return null;const c=W(e,t,r,d),{pattern:n,confidence:a,note:h}=Z(c,i,t.length);return{pattern:n,confidence:a,features:c,...h?{note:h}:{}}}
1
+ import{findConnectedComponents as j}from"./connectedComponents.js";import{clamp01 as J}from"../core/utils.js";export const DEFAULT_PATTERN_THRESHOLDS={nearFullGlobalRdd:.6,edgeRingEdgeRdd:.18,edgeRingEdgeRddHigh:.3,edgeRingRadialSpread:.45,edgeRingAngularSpread:.6,edgeLocalEdgeRdd:.1,edgeLocalCentroidDist:.76,donutP25Dist:.4,centerCentroidDist:.22,centerCentroidDistHigh:.1,centerEdgeRdd:.35,donutEdgeRdd:.22,scratchLinearScore:.25,scratchLinearScoreHigh:.45,scratchEccentricity:.75,scratchMinReach:.35,minimumFailingDies:5};function q(e,t,r){const d=e.physX-t.center.x,i=e.physY-t.center.y,s=Math.sqrt(d*d+i*i)/t.radius;return Math.min(r,Math.max(1,Math.floor(s*r)+1))===r}function K(e,t,r){if(e.length<3)return 0;let d=0,i=0,s=0;for(const f of e){const g=f.physX-t,R=f.physY-r;d+=g*g,i+=R*R,s+=g*R}d/=e.length,i/=e.length,s/=e.length;const c=d+i,n=d*i-s*s,a=Math.max(0,(c/2)**2-n),h=c/2+Math.sqrt(a),y=c/2-Math.sqrt(a);if(h<=0)return 0;const D=J(y/h);return Math.sqrt(1-D)}function Q(e,t){if(t===0)return 0;const r=new Map,d=new Map,i=new Map,s=new Map;for(const n of e)r.set(n.y,(r.get(n.y)??0)+1),d.set(n.x,(d.get(n.x)??0)+1),i.set(n.x-n.y,(i.get(n.x-n.y)??0)+1),s.set(n.x+n.y,(s.get(n.x+n.y)??0)+1);let c=0;for(const n of r.values())n>c&&(c=n);for(const n of d.values())n>c&&(c=n);for(const n of i.values())n>c&&(c=n);for(const n of s.values())n>c&&(c=n);return c/t}function W(e,t,r,d){const i=t.length,s=e.length,c=i>0?s/i:0,n=t.filter(o=>q(o,r,d)),a=e.filter(o=>q(o,r,d)),h=n.length>0?a.length/n.length:0,y=j(e),D=y.length>0?[...y].sort((o,l)=>l.length-o.length):[e],f=D[0],g=D.slice(0,5).flat(),R=f.length,T=s>0?R/s:0,u=r.center.x,m=r.center.y,p=r.radius;let S=0,N=0,M=1/0,x=0;for(const o of f){S+=o.physX,N+=o.physY;const l=Math.sqrt((o.physX-u)**2+(o.physY-m)**2);l<M&&(M=l),l>x&&(x=l)}const H=S/f.length,O=N/f.length,P=Math.sqrt((H-u)**2+(O-m)**2)/p,A=M===1/0?0:M/p,I=Math.min(x/p,1),C=e.map(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p).sort((o,l)=>o-l),v=C[Math.floor(C.length*.25)]??0,b=t.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p<.5).length,L=t.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p>=.5).length,_=e.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p<.5).length,w=e.filter(o=>Math.sqrt((o.physX-u)**2+(o.physY-m)**2)/p>=.5).length,F=b>0?_/b:0,X=L>0?w/L:0,z=X>0?F/X:F>0?2:1,G=g.reduce((o,l)=>o+l.physX,0)/g.length,k=g.reduce((o,l)=>o+l.physY,0)/g.length,B=K(g,G,k),U=Q(g,g.length),E=16,Y=new Set;for(const o of a){const l=(Math.atan2(o.physY-m,o.physX-u)+2*Math.PI)%(2*Math.PI);Y.add(Math.floor(l/(2*Math.PI)*E)%E)}const V=a.length>0?Y.size/E:0;return{globalRdd:c,edgeRdd:h,centroidDistNorm:P,minDistNorm:A,maxDistNorm:I,p25DistNorm:v,eccentricity:B,linearScore:U,salienceSize:R,salienceFraction:T,edgeAngularSpread:V,innerOuterRatio:z}}function Z(e,t,r){const d=Math.max(5,Math.round(r*.003)),i=e.salienceSize>=d;if(e.globalRdd<t.nearFullGlobalRdd&&e.p25DistNorm>=t.edgeLocalCentroidDist&&e.edgeAngularSpread>=t.edgeRingAngularSpread&&e.edgeRdd>=t.edgeLocalEdgeRdd)return{pattern:"edge-ring",confidence:e.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};if(e.globalRdd<t.nearFullGlobalRdd&&e.salienceFraction<.1)return{pattern:"random",confidence:"low"};if(e.globalRdd>=t.nearFullGlobalRdd)return{pattern:"near-full",confidence:e.globalRdd>=.8?"high":"medium"};if(i&&e.linearScore>=t.scratchLinearScore&&e.eccentricity>=t.scratchEccentricity&&e.maxDistNorm>=t.scratchMinReach){const a=e.linearScore>=t.scratchLinearScoreHigh?"high":"medium";return{pattern:"scratch",confidence:a,note:a==="medium"?"Scratch detection is less reliable for fragmented or diagonal patterns":void 0}}const s=i&&e.edgeRdd>=t.edgeLocalEdgeRdd&&e.maxDistNorm>=.7;if(s&&e.p25DistNorm>=t.edgeLocalCentroidDist&&e.maxDistNorm-e.minDistNorm<=t.edgeRingRadialSpread)return{pattern:"edge-ring",confidence:e.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};if(s&&e.p25DistNorm>=.55&&e.p25DistNorm<t.edgeLocalCentroidDist)return{pattern:"edge-local",confidence:e.edgeRdd>=t.edgeRingEdgeRdd?"medium":"low"};const c=i&&e.centroidDistNorm<=t.centerCentroidDist&&e.edgeRdd<=t.centerEdgeRdd,n="Center and donut patterns have similar geometry; classification may be imprecise";if(c&&e.p25DistNorm<t.donutP25Dist){const a=e.centroidDistNorm<=t.centerCentroidDistHigh?"high":"medium";return{pattern:"center",confidence:a,note:a!=="high"?n:void 0}}return c&&e.p25DistNorm>=t.donutP25Dist&&e.p25DistNorm<.55?{pattern:"donut",confidence:"medium",note:n}:{pattern:"random",confidence:"low"}}export const PATTERN_LABELS={center:"Center cluster",donut:"Donut","edge-ring":"Edge-ring","edge-local":"Edge-local",scratch:"Scratch","near-full":"Near-full",random:"Random",none:"None"};export function patternFailVerdict(e,t){const r=e.hbin??e.sbin;return r===void 0?void 0:!t.has(r)}export function patternExplains(e,t,r,d){if(!{"edge-ring":["ring","edge-arc"],"edge-local":["edge-arc","sector","quadrant"],center:["ring","cluster"],donut:["ring"],scratch:["cluster","sector","quadrant"],"near-full":["ring"]}[e]?.includes(t))return!1;if(t!=="ring"||r.length===0)return!0;const s=r.includes(d),c=r.includes(1);return e==="edge-ring"||e==="edge-local"?s:e==="center"?c:e==="donut"?!s&&!c:!0}export function classifyPattern(e,t,r){const d=new Set(r.passBins),i=e.filter(s=>patternFailVerdict(s,d)===!0);return classifyFailingDies(i,e,t,r.ringCount)}export function classifyFailingDies(e,t,r,d){const i={...DEFAULT_PATTERN_THRESHOLDS},s=Math.max(i.minimumFailingDies,Math.round(t.length*.003));if(e.length<s)return null;const c=W(e,t,r,d),{pattern:n,confidence:a,note:h}=Z(c,i,t.length);return{pattern:n,confidence:a,features:c,...h?{note:h}:{}}}
@@ -0,0 +1,258 @@
1
+ import type { Die } from '../core/dies.js';
2
+ import type { Wafer } from '../core/wafer.js';
3
+ import type { WaferMetadata } from '../core/metadata.js';
4
+ import { type TestDef } from '../renderer/buildWaferMap.js';
5
+ import type { FacetCuration } from './facets.js';
6
+ import type { PlotSpec, PlotField, PlotAggregate } from './plotSpec.js';
7
+ /** One wafer of the population. The same shape a drilldown source's items have. */
8
+ export interface PlotItem {
9
+ label: string;
10
+ dies: readonly Die[];
11
+ waferIndex?: number;
12
+ metadata?: WaferMetadata;
13
+ /** This wafer's own pass bins, from its built result: every yield the plot states judges by them. */
14
+ passBins: readonly number[];
15
+ /** This wafer's own ring count, from its built result: a ring or quadrant of its dies is the map's ring. */
16
+ ringCount: number;
17
+ /** Needed for ring and quadrant. */
18
+ wafer?: Wafer;
19
+ }
20
+ export interface PlotContext {
21
+ /** The population's reconciled test list (`mergeTestDefs`). */
22
+ testDefs?: readonly TestDef[];
23
+ /** The Insights tab's Group by key, which "follow Group by" resolves to. Absent outside the tab. */
24
+ groupBy?: string;
25
+ curation?: Record<string, FacetCuration>;
26
+ }
27
+ export type FieldKind = 'numeric' | 'categorical';
28
+ /** A test's limits: the tester's (`limitLow`/`limitHigh`) and the specification's (`specLow`/`specHigh`). Any may be absent. */
29
+ export interface TestLimits {
30
+ limitLow?: number;
31
+ limitHigh?: number;
32
+ specLow?: number;
33
+ specHigh?: number;
34
+ }
35
+ /** A field resolved over the population, one value per die (`level: 'die'`) or per wafer (`'wafer'`). */
36
+ export interface FieldColumn {
37
+ field: PlotField;
38
+ /** The reader's name for it ("Vth", "Split", "Yield"). */
39
+ label: string;
40
+ unit?: string;
41
+ level: 'die' | 'wafer';
42
+ kind: FieldKind;
43
+ /** Numeric values; NaN is missing. Present for a numeric field, and for a metadata field whose every value is a number. */
44
+ num?: Float64Array;
45
+ /** Category text; undefined is missing. Present for a categorical field and for metadata (numbers as text). */
46
+ cat?: (string | undefined)[];
47
+ /** Judged dies behind each value (a wafer's yield), or 1 per judged die (a die's pass), so a yield can be pooled. */
48
+ weights?: Float64Array;
49
+ /** The limits of a measured test, as the population's reconciled test list states them. */
50
+ limits?: TestLimits;
51
+ /** Set on a yield taken per die (100 for a passing die, 0 for a failing one): its mean over any set of dies is their yield. */
52
+ perDie?: true;
53
+ /** Why this field cannot be used on this population. */
54
+ issue?: string;
55
+ }
56
+ export interface PlotPoint {
57
+ x: number;
58
+ y: number;
59
+ group: number;
60
+ item: number;
61
+ die?: Die; /** The colour field's value, when it is continuous. */
62
+ value?: number;
63
+ }
64
+ /** What one mark stands for: the wafer it is on, and the die when it is one die (not a wafer's aggregate). */
65
+ export interface PlotUnit {
66
+ item: number;
67
+ die?: Die;
68
+ }
69
+ export type PlotMarks = {
70
+ type: 'scatter';
71
+ points: PlotPoint[];
72
+ }
73
+ /** `units[g][k]` is the unit behind `values[g][k]`, so a bar can say which dies (or wafers) it counts. */
74
+ | {
75
+ type: 'histogram';
76
+ values: number[][];
77
+ units: number[][];
78
+ unit: (u: number) => PlotUnit;
79
+ } | {
80
+ type: 'box' | 'bar';
81
+ categories: string[];
82
+ cells: number[][][];
83
+ cellUnits: number[][][];
84
+ values: number[][];
85
+ categoryItems?: number[];
86
+ unit: (u: number) => PlotUnit;
87
+ } | {
88
+ type: 'line';
89
+ xs: number[];
90
+ values: number[][];
91
+ counts: number[][];
92
+ cellUnits: number[][][];
93
+ unit: (u: number) => PlotUnit;
94
+ };
95
+ /** `label` is the axis title WITHOUT its unit: the chart appends the unit, scaled to the ticks ("µA" for 0.000861 A). */
96
+ export interface ResolvedAxis {
97
+ label: string;
98
+ unit?: string;
99
+ scale: 'linear' | 'log';
100
+ min?: number;
101
+ max?: number;
102
+ reverse?: boolean;
103
+ /** The limits of the test this axis measures, when it measures one: the chart draws them as lines. */
104
+ limits?: TestLimits;
105
+ }
106
+ export interface ResolvedPlot {
107
+ spec: PlotSpec;
108
+ /** Reasons the plot cannot be drawn on this population. Empty when `marks` is set. */
109
+ issues: string[];
110
+ /** Non-blocking things the reader should be told (a log axis that fell back to linear). */
111
+ notes: string[];
112
+ marks?: PlotMarks;
113
+ level: 'die' | 'wafer';
114
+ /** The title the plot has until the user types one. */
115
+ autoTitle: string;
116
+ x?: ResolvedAxis;
117
+ y?: ResolvedAxis;
118
+ /** Colour groups in legend order; `['']` when there is no colour (or the colour is continuous, see `colorScale`). */
119
+ groups: string[];
120
+ /** Set when a scatter is coloured by a continuous field: the range its colourbar covers. */
121
+ colorScale?: {
122
+ label: string;
123
+ unit?: string;
124
+ lo: number;
125
+ hi: number;
126
+ };
127
+ colorLabel?: string;
128
+ /** How values were combined, in words ("mean of Vth per wafer"), when they were. */
129
+ aggregation?: string;
130
+ /** The scope: every wafer and die handed in. */
131
+ population: {
132
+ wafers: number;
133
+ dies: number;
134
+ };
135
+ /** Marks drawn. */
136
+ plotted: number;
137
+ /** Marks left out because a value was missing, by the field it was missing from. */
138
+ omitted: Array<{
139
+ field: string;
140
+ count: number;
141
+ }>;
142
+ }
143
+ /** The reader's name for a field, whether or not the population has it. */
144
+ export declare function fieldLabel(field: PlotField, testDefs?: readonly TestDef[]): string;
145
+ /** One value for a set of numbers. `count` ignores missing values; the rest of an empty set is NaN. */
146
+ export declare function combine(values: readonly number[], how: PlotAggregate): number;
147
+ /** What the cross-field rules need to know of a field: its level, whether it is a number, and whether it is a yield. */
148
+ export interface FieldFacts {
149
+ label: string;
150
+ level: 'die' | 'wafer';
151
+ kind: FieldKind;
152
+ yield: boolean;
153
+ }
154
+ /**
155
+ * Whether the chosen fields can be drawn together, as the reason in two lengths: `long` for the chart card, `short` for the
156
+ * editor's field list, where a choice that would break the plot is greyed with it. ONE function, so the list and the chart
157
+ * can never disagree about what is allowed. Only rules that name two fields are here; a missing field is never a conflict.
158
+ *
159
+ * A yield is passing dies over judged dies, so it can be taken over any set of dies, but it is held per wafer: splitting it
160
+ * by a die-level field (ring, quadrant, bin, die position) needs the verdict per die, which a bar of pooled yield and a line
161
+ * have. Every other chart of it would be one wafer figure pretending to be per die.
162
+ */
163
+ export declare function combinationIssue(mark: PlotSpec['chart'], f: {
164
+ x?: FieldFacts;
165
+ y?: FieldFacts;
166
+ color?: FieldFacts;
167
+ }, o?: {
168
+ aggregate?: PlotAggregate;
169
+ level?: 'die' | 'wafer';
170
+ continuousColor?: boolean;
171
+ }): {
172
+ long: string;
173
+ short: string;
174
+ } | undefined;
175
+ /** Resolves `spec` over `items`. Never throws for a plot that cannot be drawn: it returns the reasons. */
176
+ export declare function resolvePlot(spec: PlotSpec, items: readonly PlotItem[], ctx?: PlotContext): ResolvedPlot;
177
+ /** The plot's title: the one the user typed, else the automatic one. */
178
+ export declare function plotTitle(resolved: ResolvedPlot): string;
179
+ /** The statement every plot carries about what it shows ("6 wafers · 3,966 dies · 12 dies without Ioff not plotted"). */
180
+ export declare function plotFootnote(resolved: ResolvedPlot): string;
181
+ export type FieldGroup = 'Tests' | 'Verdicts' | 'Die' | 'Wafer';
182
+ /** One entry of the editor's field list. */
183
+ export interface FieldOption {
184
+ field: PlotField;
185
+ /** The list text: the name, plus the test number so a filter box finds either. */
186
+ label: string;
187
+ /** The name alone ("Vth"), as a title would write it. */
188
+ name: string;
189
+ /** For a lot field: how many different values the wafers in view carry. */
190
+ distinct?: number;
191
+ group: FieldGroup;
192
+ kind: FieldKind;
193
+ level: 'die' | 'wafer';
194
+ /** Can divide the data into series or categories (a colour, a bar's X). */
195
+ categorical: boolean;
196
+ }
197
+ /** A stable string for a field, for list values and comparisons. */
198
+ export declare function fieldKey(f: PlotField): string;
199
+ /**
200
+ * Everything a plot could put on an axis or a colour over this population: its parametric tests, the die fields it
201
+ * has data for, and the wafer and lot fields. Offered only when the population has something to show for it (no
202
+ * soft-bin entry for a lot with no soft bins), so the list is the lot's, not the library's.
203
+ */
204
+ export declare function fieldCatalogue(items: readonly PlotItem[], ctx?: PlotContext): FieldOption[];
205
+ export type PlotRole = 'x' | 'y' | 'color';
206
+ /**
207
+ * The fields that make sense for a role of a mark, so the editor never offers a choice that can only fail:
208
+ * values must be numeric; a bar or box groups by a category (or a lot field with a handful of values); a colour is
209
+ * always a category, since a continuous colour is not drawn yet.
210
+ */
211
+ export declare function fieldsForRole(catalogue: readonly FieldOption[], mark: PlotSpec['chart'], role: PlotRole): FieldOption[];
212
+ /**
213
+ * A first plot for this population: the scatter of the first two tests, a histogram when there is one, a bar of
214
+ * yield by wafer when there are none. Never an empty editor.
215
+ */
216
+ export declare function defaultPlot(catalogue: readonly FieldOption[], id: string): PlotSpec;
217
+ export interface TitleDrift {
218
+ /** Fields the title names that the plot does not use: the title is describing something else. */
219
+ names: string[];
220
+ /** Fields the plot plots that the title leaves out, when the title does describe its fields. */
221
+ omits: string[];
222
+ }
223
+ /**
224
+ * Whether a title the reader TYPED still describes its plot. A title written for one pair of tests goes on naming them
225
+ * after the fields change, and nothing else would tell the reader the chart is no longer what it says. Two checks:
226
+ *
227
+ * - the title names a test (or another measured field) the plot does not use;
228
+ * - the title names one of the plot's X or Y fields but not the other, so it is half a description.
229
+ *
230
+ * A title that names none of the plot's fields is free text ("Process check") and is left alone. Lot fields are not
231
+ * checked for the first, since their names are everyday words and a followed colour changes with Group by. An
232
+ * automatic title is always accurate and is never checked.
233
+ */
234
+ export declare function titleDrift(spec: PlotSpec, catalogue: readonly FieldOption[]): TitleDrift;
235
+ /** `titleDrift` in a sentence for the reader, or null when the title is fine. */
236
+ export declare function describeTitleDrift(d: TitleDrift): string | null;
237
+ /**
238
+ * One example of each chart type that this population can show, so a reader who has not built a plot before has
239
+ * something to start from: a scatter of the first two tests, a histogram of the first, a box of the first by wafer, a
240
+ * bar of yield by the first lot field that divides the wafers (by wafer when none does), and the first test over wafer
241
+ * order as a line, and a sweep of the first few tests in test order. A type is left out when the population cannot
242
+ * support it (a line needs two wafers, a sweep two tests). Untitled, so each one is named by what it plots; the sweep,
243
+ * which has no fields to name it by, is titled "Example sweep".
244
+ */
245
+ export declare function examplePlots(catalogue: readonly FieldOption[], waferCount: number, newId: () => string): PlotSpec[];
246
+ /**
247
+ * The test a click on this plot should open a wafer on: the plot's own measurement, so the map shows the values the
248
+ * plot is about rather than the bins. A scatter takes its X (as the Insights scatter does), then its Y, then its
249
+ * colour; every other chart type its values. `undefined` when the plot has no test in it (yield against wafer order),
250
+ * where the wafer's own default map is the right one.
251
+ */
252
+ export declare function plotTestNumber(spec: PlotSpec): number | undefined;
253
+ /**
254
+ * A new sweep to start from: one series of the lot's first few parametric tests, in test order, on the ordinal axis
255
+ * (no X scale is claimed). Never an empty editor; the reader edits the tests and adds the series they meant.
256
+ */
257
+ export declare function defaultSweep(testDefs: readonly TestDef[], id: string): PlotSpec;
258
+ //# sourceMappingURL=plotData.d.ts.map