@wafertools/wafermap 0.35.1 → 0.37.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 (188) hide show
  1. package/AGENTS.md +13 -10
  2. package/CHANGELOG.md +474 -0
  3. package/README.md +7 -7
  4. package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
  5. package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
  6. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  7. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
  8. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
  9. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
  10. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  11. package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
  12. package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
  13. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
  15. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
  16. package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
  17. package/dist/packages/canvas-adapter/charts/index.js +1 -1
  18. package/dist/packages/canvas-adapter/charts/patCard.d.ts +21 -0
  19. package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
  20. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
  21. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
  23. package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
  24. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  25. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  26. package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
  27. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  28. package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
  29. package/dist/packages/canvas-adapter/dieList.js +2 -2
  30. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
  31. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
  32. package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
  33. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  34. package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
  35. package/dist/packages/canvas-adapter/filterButton.js +1 -0
  36. package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
  37. package/dist/packages/canvas-adapter/filterEditor.js +1 -0
  38. package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
  39. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  40. package/dist/packages/canvas-adapter/icons.js +1 -1
  41. package/dist/packages/canvas-adapter/index.d.ts +1 -0
  42. package/dist/packages/canvas-adapter/index.js +1 -1
  43. package/dist/packages/canvas-adapter/insightsTab.d.ts +57 -2
  44. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  45. package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
  46. package/dist/packages/canvas-adapter/pageFilter.js +2 -0
  47. package/dist/packages/canvas-adapter/patMaps.d.ts +26 -0
  48. package/dist/packages/canvas-adapter/patMaps.js +1 -0
  49. package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
  50. package/dist/packages/canvas-adapter/plotCard.js +1 -0
  51. package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
  52. package/dist/packages/canvas-adapter/plotEditor.js +1 -1
  53. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  54. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  55. package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
  56. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  57. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
  58. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  59. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +71 -37
  60. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  61. package/dist/packages/canvas-adapter/summaryPanel.d.ts +22 -9
  62. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  63. package/dist/packages/canvas-adapter/testValueOffer.d.ts +14 -0
  64. package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
  65. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  66. package/dist/packages/canvas-adapter/toolbar.d.ts +12 -6
  67. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  68. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  69. package/dist/packages/canvas-adapter/userGuideHtml.js +607 -117
  70. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  71. package/dist/packages/canvas-adapter/version.js +1 -1
  72. package/dist/packages/canvas-adapter/warnings.js +1 -1
  73. package/dist/packages/core/aggregates.d.ts +10 -0
  74. package/dist/packages/core/aggregates.js +1 -1
  75. package/dist/packages/core/classify.d.ts +11 -0
  76. package/dist/packages/core/classify.js +1 -1
  77. package/dist/packages/core/dieTable.d.ts +5 -0
  78. package/dist/packages/core/dieTable.js +1 -1
  79. package/dist/packages/core/dies.d.ts +2 -0
  80. package/dist/packages/core/dies.js +1 -1
  81. package/dist/packages/core/wafer.d.ts +10 -1
  82. package/dist/packages/core/wafer.js +1 -1
  83. package/dist/packages/renderer/buildView.d.ts +5 -0
  84. package/dist/packages/renderer/buildView.js +1 -1
  85. package/dist/packages/renderer/buildWaferMap.d.ts +21 -4
  86. package/dist/packages/renderer/buildWaferMap.js +1 -1
  87. package/dist/packages/renderer/deprecate.d.ts +2 -8
  88. package/dist/packages/renderer/deprecate.js +1 -1
  89. package/dist/packages/renderer/derivedTests/parser.js +1 -1
  90. package/dist/packages/renderer/fmt.d.ts +10 -0
  91. package/dist/packages/renderer/fmt.js +1 -1
  92. package/dist/packages/renderer/index.d.ts +1 -0
  93. package/dist/packages/renderer/index.js +1 -1
  94. package/dist/packages/renderer/testLabel.d.ts +0 -11
  95. package/dist/packages/renderer/testLabel.js +1 -1
  96. package/dist/packages/renderer/valueFilter.d.ts +1 -1
  97. package/dist/packages/renderer/valueFilter.js +1 -1
  98. package/dist/packages/stats/analyzeWaferLot.d.ts +22 -0
  99. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  100. package/dist/packages/stats/analyzeWaferMap.d.ts +26 -1
  101. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  102. package/dist/packages/stats/binPareto.d.ts +2 -54
  103. package/dist/packages/stats/binPareto.js +1 -1
  104. package/dist/packages/stats/binRows.js +1 -1
  105. package/dist/packages/stats/capability.d.ts +10 -0
  106. package/dist/packages/stats/capability.js +1 -1
  107. package/dist/packages/stats/cardSpec.d.ts +53 -0
  108. package/dist/packages/stats/cardSpec.js +1 -0
  109. package/dist/packages/stats/chartCatalogue.d.ts +37 -0
  110. package/dist/packages/stats/chartCatalogue.js +1 -0
  111. package/dist/packages/stats/clusterDetection.d.ts +9 -0
  112. package/dist/packages/stats/clusterDetection.js +1 -1
  113. package/dist/packages/stats/commonality.d.ts +62 -0
  114. package/dist/packages/stats/commonality.js +1 -0
  115. package/dist/packages/stats/connectedComponents.js +1 -1
  116. package/dist/packages/stats/control.d.ts +21 -0
  117. package/dist/packages/stats/control.js +1 -0
  118. package/dist/packages/stats/correlation.d.ts +42 -4
  119. package/dist/packages/stats/correlation.js +1 -1
  120. package/dist/packages/stats/dieRegions.d.ts +4 -1
  121. package/dist/packages/stats/dieRegions.js +1 -1
  122. package/dist/packages/stats/differenceMap.d.ts +22 -0
  123. package/dist/packages/stats/differenceMap.js +1 -0
  124. package/dist/packages/stats/examplePicks.d.ts +22 -0
  125. package/dist/packages/stats/examplePicks.js +1 -0
  126. package/dist/packages/stats/filterFile.d.ts +41 -0
  127. package/dist/packages/stats/filterFile.js +2 -0
  128. package/dist/packages/stats/filterFindings.d.ts +21 -6
  129. package/dist/packages/stats/filterFindings.js +1 -1
  130. package/dist/packages/stats/findingText.d.ts +8 -0
  131. package/dist/packages/stats/findingText.js +2 -2
  132. package/dist/packages/stats/groupCompare.d.ts +87 -0
  133. package/dist/packages/stats/groupCompare.js +1 -0
  134. package/dist/packages/stats/guideSections.d.ts +55 -0
  135. package/dist/packages/stats/guideSections.js +1 -0
  136. package/dist/packages/stats/index.d.ts +5 -2
  137. package/dist/packages/stats/index.js +1 -1
  138. package/dist/packages/stats/lotDrift.js +1 -1
  139. package/dist/packages/stats/math.d.ts +29 -4
  140. package/dist/packages/stats/math.js +1 -1
  141. package/dist/packages/stats/mergeTestDefs.js +1 -1
  142. package/dist/packages/stats/metadataColumns.d.ts +3 -0
  143. package/dist/packages/stats/metadataColumns.js +1 -1
  144. package/dist/packages/stats/pat.d.ts +58 -0
  145. package/dist/packages/stats/pat.js +1 -0
  146. package/dist/packages/stats/patSummary.d.ts +45 -0
  147. package/dist/packages/stats/patSummary.js +1 -0
  148. package/dist/packages/stats/patternClassification.d.ts +3 -3
  149. package/dist/packages/stats/patternClassification.js +1 -1
  150. package/dist/packages/stats/plotData.d.ts +294 -17
  151. package/dist/packages/stats/plotData.js +1 -1
  152. package/dist/packages/stats/plotId.d.ts +2 -0
  153. package/dist/packages/stats/plotId.js +1 -1
  154. package/dist/packages/stats/plotReferences.d.ts +17 -0
  155. package/dist/packages/stats/plotReferences.js +1 -0
  156. package/dist/packages/stats/plotSpec.d.ts +239 -3
  157. package/dist/packages/stats/plotSpec.js +4 -4
  158. package/dist/packages/stats/regions.js +1 -1
  159. package/dist/packages/stats/renderSummaryReport.js +33 -33
  160. package/dist/packages/stats/reportHtml.d.ts +5 -12
  161. package/dist/packages/stats/reportHtml.js +98 -40
  162. package/dist/packages/stats/synthesis.d.ts +48 -16
  163. package/dist/packages/stats/synthesis.js +1 -1
  164. package/dist/packages/stats/testPassRate.d.ts +7 -0
  165. package/dist/packages/stats/testPassRate.js +1 -1
  166. package/dist/packages/stats/testValueBudget.d.ts +15 -0
  167. package/dist/packages/stats/testValueBudget.js +1 -0
  168. package/dist/packages/stats/types.d.ts +90 -30
  169. package/dist/packages/stats/yield.d.ts +3 -11
  170. package/dist/packages/stats/yield.js +1 -1
  171. package/llms.txt +1 -1
  172. package/package.json +2 -1
  173. package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
  174. package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
  175. package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
  176. package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
  177. package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
  178. package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
  179. package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
  180. package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
  181. package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
  182. package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
  183. package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
  184. package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
  185. package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
  186. package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
  187. package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
  188. package/dist/packages/canvas-adapter/charts/trend.js +0 -1
@@ -1 +1 @@
1
- import{findConnectedComponents as fn}from"./connectedComponents.js";import{clamp01 as pn}from"../core/utils.js";import{ringOf as yn}from"../core/classify.js";export const DEFAULT_PATTERN_THRESHOLDS={nearFullGlobalRdd:.6,edgeRingEdgeRdd:.18,edgeRingEdgeRddHigh:.3,edgeRingRadialSpread:.45,edgeRingAngularSpread:.6,edgeLocalEdgeRdd:.1,edgeLocalCentroidDist:.76,centerCentroidDist:.22,centerCentroidDistHigh:.1,centerEdgeRdd:.35,scratchMaxLineWidth:.8,scratchMinLineLength:8,scratchMinLineLengthRadius:.3,scratchMinReach:.35,scratchMaxInnerDist:.7,donutHole:.15,donutRim:.15,donutPeak:.15,minimumFailingDies:5};function B(n,t,o){return yn(n.physX-t.center.x,n.physY-t.center.y,t.radius,o)===o}function mn(n,t,o){if(n.length<3)return 0;let s=0,d=0,c=0;for(const M of n){const u=M.physX-t,g=M.physY-o;s+=u*u,d+=g*g,c+=u*g}s/=n.length,d/=n.length,c/=n.length;const a=s+d,i=s*d-c*c,p=Math.max(0,(a/2)**2-i),f=a/2+Math.sqrt(p),m=a/2-Math.sqrt(p);if(f<=0)return 0;const R=pn(m/f);return Math.sqrt(1-R)}function Mn(n,t){if(t===0)return 0;const o=new Map,s=new Map,d=new Map,c=new Map;for(const i of n)o.set(i.y,(o.get(i.y)??0)+1),s.set(i.x,(s.get(i.x)??0)+1),d.set(i.x-i.y,(d.get(i.x-i.y)??0)+1),c.set(i.x+i.y,(c.get(i.x+i.y)??0)+1);let a=0;for(const i of o.values())i>a&&(a=i);for(const i of s.values())i>a&&(a=i);for(const i of d.values())i>a&&(a=i);for(const i of c.values())i>a&&(a=i);return a/t}function xn(n,t,o,s){if(n.length<2)return{width:0,length:0};let d=0,c=0,a=0;for(const u of n){const g=u.physX-t,x=u.physY-o;d+=g*g,c+=x*x,a+=g*x}const i=.5*Math.atan2(2*a,d-c),p=Math.cos(i),f=Math.sin(i);let m=1/0,R=-1/0,M=0;for(const u of n){const g=u.physX-t,x=u.physY-o,D=g*p+x*f,y=x*p-g*f;M+=y*y,D<m&&(m=D),D>R&&(R=D)}return{width:Math.sqrt(M/n.length)/s,length:(R-m)/s}}function K(n){let t=0,o=0;for(const s of n)t+=s.physX,o+=s.physY;return[t/n.length,o/n.length]}const Rn=1.5,Dn=3;function Sn(n,t,o){const s=[...n];if(n.length<2)return s;const d=t.filter(c=>c.length>0);for(;;){const[c,a]=K(s);let i=0,p=0,f=0;for(const l of s){const h=l.physX-c,S=l.physY-a;i+=h*h,p+=S*S,f+=h*S}const m=.5*Math.atan2(2*f,i-p),R=Math.cos(m),M=Math.sin(m),u=l=>(l.physX-c)*R+(l.physY-a)*M;let g=1/0,x=-1/0;for(const l of s){const h=u(l);h<g&&(g=h),h>x&&(x=h)}let D=-1,y=1/0;for(let l=0;l<d.length;l++){let h=1/0,S=-1/0,I=!1;for(const b of d[l]){if(Math.abs((b.physY-a)*R-(b.physX-c)*M)>Rn*o){I=!0;break}const N=u(b);N<h&&(h=N),N>S&&(S=N)}if(I)continue;const L=Math.max(h-x,g-S,0);L<=Dn*o&&L<y&&(D=l,y=L)}if(D<0)return s;s.push(...d[D]),d.splice(D,1)}}function Ln(n,t,o,s){const d=t.length,c=n.length,a=d>0?c/d:0,i=t.filter(e=>B(e,o,s)),p=n.filter(e=>B(e,o,s)),f=i.length>0?p.length/i.length:0,m=fn(n),R=e=>{let r=1/0,A=1/0,_=0,v=0;for(const E of e)_+=E.physX,v+=E.physY,(E.y<r||E.y===r&&E.x<A)&&(r=E.y,A=E.x);const un=Math.hypot(_/e.length-o.center.x,v/e.length-o.center.y);return[Math.round(un*1e6),r,A]},M=m.length>0?m.map(e=>({c:e,k:R(e)})).sort((e,r)=>r.c.length-e.c.length||e.k[0]-r.k[0]||e.k[1]-r.k[1]||e.k[2]-r.k[2]).map(({c:e})=>e):[n],u=M[0],g=M.slice(0,5).flat(),x=u.length,D=c>0?x/c:0,y=o.center.x,l=o.center.y,h=o.radius;let S=0,I=0,L=1/0,b=0;for(const e of u){S+=e.physX,I+=e.physY;const r=Math.sqrt((e.physX-y)**2+(e.physY-l)**2);r<L&&(L=r),r>b&&(b=r)}const N=S/u.length,U=I/u.length,V=Math.sqrt((N-y)**2+(U-l)**2)/h,j=L===1/0?0:L/h,J=Math.min(b/h,1),k=n.map(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h).sort((e,r)=>e-r),Q=k[Math.floor(k.length*.25)]??0,H=t.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h<.5).length,O=t.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h>=.5).length,Z=n.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h<.5).length,$=n.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h>=.5).length,P=H>0?Z/H:0,w=O>0?$/O:0,nn=w>0?P/w:P>0?2:1,tn=g.reduce((e,r)=>e+r.physX,0)/g.length,en=g.reduce((e,r)=>e+r.physY,0)/g.length,on=mn(g,tn,en),sn=Mn(g,g.length),F=16,G=new Set;for(const e of p){const r=(Math.atan2(e.physY-l,e.physX-y)+2*Math.PI)%(2*Math.PI);G.add(Math.floor(r/(2*Math.PI)*F)%F)}const rn=p.length>0?G.size/F:0,T=Math.max(u[0]?.width??1,u[0]?.height??1),X=Sn(u,M.slice(1,12),T),{width:cn,length:an}=xn(X,...K(X),T);let Y=1/0,q=0;for(const e of X){const r=Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h;r<Y&&(Y=r),r>q&&(q=r)}const dn=Y===1/0?0:Y,ln=Math.min(q,1),C=5,W=new Array(C).fill(0),z=new Array(C).fill(0),hn=new Set(n);for(const e of t){const r=Math.min(C-1,Math.floor(Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h*C));W[r]++,hn.has(e)&&z[r]++}const gn=W.map((e,r)=>e>0?z[r]/e:0);return{globalRdd:a,edgeRdd:f,centroidDistNorm:V,minDistNorm:j,maxDistNorm:J,p25DistNorm:Q,eccentricity:on,linearScore:sn,salienceSize:x,salienceFraction:D,edgeAngularSpread:rn,innerOuterRatio:nn,lineWidth:cn,lineLength:an,lineSize:X.length,lineMinDistNorm:dn,lineMaxDistNorm:ln,radialFailRates:gn}}function bn(n,t,o){const s=Math.max(5,Math.round(o*.003)),d=n.salienceSize>=s;if(n.globalRdd<t.nearFullGlobalRdd&&n.p25DistNorm>=t.edgeLocalCentroidDist&&n.edgeAngularSpread>=t.edgeRingAngularSpread&&n.edgeRdd>=t.edgeLocalEdgeRdd)return{pattern:"edge-ring",confidence:n.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};const[c,a,i,,p]=n.radialFailRates,f=Math.max(a,i);if(n.globalRdd<t.nearFullGlobalRdd&&f>=t.donutPeak&&f-c>=t.donutHole&&f-p>=t.donutRim)return{pattern:"donut",confidence:f-c>=2*t.donutHole?"high":"medium"};if(n.globalRdd<t.nearFullGlobalRdd&&n.lineSize>=s&&n.lineWidth<=t.scratchMaxLineWidth&&n.lineLength>=t.scratchMinLineLength&&n.lineLength>=t.scratchMinLineLengthRadius*Math.sqrt(o/Math.PI)&&n.lineMaxDistNorm>=t.scratchMinReach&&n.lineMinDistNorm<t.scratchMaxInnerDist)return{pattern:"scratch",confidence:n.lineWidth<=t.scratchMaxLineWidth/2?"high":"medium"};if(n.globalRdd<t.nearFullGlobalRdd&&n.salienceFraction<.1)return{pattern:"random",confidence:"low"};if(n.globalRdd>=t.nearFullGlobalRdd)return{pattern:"near-full",confidence:n.globalRdd>=.8?"high":"medium"};const m=d&&n.edgeRdd>=t.edgeLocalEdgeRdd&&n.maxDistNorm>=.7;return m&&n.p25DistNorm>=t.edgeLocalCentroidDist&&n.maxDistNorm-n.minDistNorm<=t.edgeRingRadialSpread?{pattern:"edge-ring",confidence:n.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"}:m&&n.p25DistNorm>=.55&&n.p25DistNorm<t.edgeLocalCentroidDist?{pattern:"edge-local",confidence:n.edgeRdd>=t.edgeRingEdgeRdd?"medium":"low"}:d&&n.centroidDistNorm<=t.centerCentroidDist&&n.edgeRdd<=t.centerEdgeRdd?{pattern:"center",confidence:n.centroidDistNorm<=t.centerCentroidDistHigh?"high":"medium"}:{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(n,t){const o=n.hbin??n.sbin;return o===void 0?void 0:!t.has(o)}export function patternExplains(n,t,o,s){if(!{"edge-ring":["ring","edge-arc"],"edge-local":["edge-arc","sector","quadrant"],center:["ring","cluster"],donut:["ring"],scratch:["cluster","sector","quadrant"],"near-full":["ring"]}[n]?.includes(t))return!1;if(t!=="ring"||o.length===0)return!0;const c=o.includes(s),a=o.includes(1);return n==="edge-ring"||n==="edge-local"?c:n==="center"?a:n==="donut"?!c&&!a:!0}export function classifyPattern(n,t,o){const s=new Set(o.passBins),d=n.filter(c=>patternFailVerdict(c,s)===!0);return classifyFailingDies(d,n,t,o.ringCount)}export function classifyFailingDies(n,t,o,s){const d={...DEFAULT_PATTERN_THRESHOLDS},c=Math.max(d.minimumFailingDies,Math.round(t.length*.003));if(n.length<c)return null;const a=Ln(n,t,o,s),{pattern:i,confidence:p,note:f}=bn(a,d,t.length);return{pattern:i,confidence:p,features:a,...f?{note:f}:{}}}
1
+ import{diePassStatus as fn}from"../core/dies.js";import{findConnectedComponents as pn}from"./connectedComponents.js";import{clamp01 as mn}from"../core/utils.js";import{ringOf as yn}from"../core/classify.js";export const DEFAULT_PATTERN_THRESHOLDS={nearFullGlobalRdd:.6,edgeRingEdgeRdd:.18,edgeRingEdgeRddHigh:.3,edgeRingRadialSpread:.45,edgeRingAngularSpread:.6,edgeLocalEdgeRdd:.1,edgeLocalCentroidDist:.76,centerCentroidDist:.22,centerCentroidDistHigh:.1,centerEdgeRdd:.35,scratchMaxLineWidth:.8,scratchMinLineLength:8,scratchMinLineLengthRadius:.3,scratchMinReach:.35,scratchMaxInnerDist:.7,donutHole:.15,donutRim:.15,donutPeak:.15,minimumFailingDies:5};function B(n,t,o){return yn(n.physX-t.center.x,n.physY-t.center.y,t.radius,o)===o}function Mn(n,t,o){if(n.length<3)return 0;let s=0,a=0,c=0;for(const M of n){const u=M.physX-t,g=M.physY-o;s+=u*u,a+=g*g,c+=u*g}s/=n.length,a/=n.length,c/=n.length;const d=s+a,i=s*a-c*c,p=Math.max(0,(d/2)**2-i),f=d/2+Math.sqrt(p),y=d/2-Math.sqrt(p);if(f<=0)return 0;const R=mn(y/f);return Math.sqrt(1-R)}function xn(n,t){if(t===0)return 0;const o=new Map,s=new Map,a=new Map,c=new Map;for(const i of n)o.set(i.y,(o.get(i.y)??0)+1),s.set(i.x,(s.get(i.x)??0)+1),a.set(i.x-i.y,(a.get(i.x-i.y)??0)+1),c.set(i.x+i.y,(c.get(i.x+i.y)??0)+1);let d=0;for(const i of o.values())i>d&&(d=i);for(const i of s.values())i>d&&(d=i);for(const i of a.values())i>d&&(d=i);for(const i of c.values())i>d&&(d=i);return d/t}function Rn(n,t,o,s){if(n.length<2)return{width:0,length:0};let a=0,c=0,d=0;for(const u of n){const g=u.physX-t,x=u.physY-o;a+=g*g,c+=x*x,d+=g*x}const i=.5*Math.atan2(2*d,a-c),p=Math.cos(i),f=Math.sin(i);let y=1/0,R=-1/0,M=0;for(const u of n){const g=u.physX-t,x=u.physY-o,D=g*p+x*f,m=x*p-g*f;M+=m*m,D<y&&(y=D),D>R&&(R=D)}return{width:Math.sqrt(M/n.length)/s,length:(R-y)/s}}function K(n){let t=0,o=0;for(const s of n)t+=s.physX,o+=s.physY;return[t/n.length,o/n.length]}const Dn=1.5,Sn=3;function Ln(n,t,o){const s=[...n];if(n.length<2)return s;const a=t.filter(c=>c.length>0);for(;;){const[c,d]=K(s);let i=0,p=0,f=0;for(const l of s){const h=l.physX-c,S=l.physY-d;i+=h*h,p+=S*S,f+=h*S}const y=.5*Math.atan2(2*f,i-p),R=Math.cos(y),M=Math.sin(y),u=l=>(l.physX-c)*R+(l.physY-d)*M;let g=1/0,x=-1/0;for(const l of s){const h=u(l);h<g&&(g=h),h>x&&(x=h)}let D=-1,m=1/0;for(let l=0;l<a.length;l++){let h=1/0,S=-1/0,I=!1;for(const E of a[l]){if(Math.abs((E.physY-d)*R-(E.physX-c)*M)>Dn*o){I=!0;break}const b=u(E);b<h&&(h=b),b>S&&(S=b)}if(I)continue;const L=Math.max(h-x,g-S,0);L<=Sn*o&&L<m&&(D=l,m=L)}if(D<0)return s;s.push(...a[D]),a.splice(D,1)}}function En(n,t,o,s){const a=t.length,c=n.length,d=a>0?c/a:0,i=t.filter(e=>B(e,o,s)),p=n.filter(e=>B(e,o,s)),f=i.length>0?p.length/i.length:0,y=pn(n),R=e=>{let r=1/0,A=1/0,_=0,v=0;for(const N of e)_+=N.physX,v+=N.physY,(N.y<r||N.y===r&&N.x<A)&&(r=N.y,A=N.x);const un=Math.hypot(_/e.length-o.center.x,v/e.length-o.center.y);return[Math.round(un*1e6),r,A]},M=y.length>0?y.map(e=>({c:e,k:R(e)})).sort((e,r)=>r.c.length-e.c.length||e.k[0]-r.k[0]||e.k[1]-r.k[1]||e.k[2]-r.k[2]).map(({c:e})=>e):[n],u=M[0],g=M.slice(0,5).flat(),x=u.length,D=c>0?x/c:0,m=o.center.x,l=o.center.y,h=o.radius;let S=0,I=0,L=1/0,E=0;for(const e of u){S+=e.physX,I+=e.physY;const r=Math.sqrt((e.physX-m)**2+(e.physY-l)**2);r<L&&(L=r),r>E&&(E=r)}const b=S/u.length,U=I/u.length,V=Math.sqrt((b-m)**2+(U-l)**2)/h,j=L===1/0?0:L/h,J=Math.min(E/h,1),k=n.map(e=>Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h).sort((e,r)=>e-r),Q=k[Math.floor(k.length*.25)]??0,P=t.filter(e=>Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h<.5).length,H=t.filter(e=>Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h>=.5).length,Z=n.filter(e=>Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h<.5).length,$=n.filter(e=>Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h>=.5).length,O=P>0?Z/P:0,w=H>0?$/H:0,nn=w>0?O/w:O>0?2:1,tn=g.reduce((e,r)=>e+r.physX,0)/g.length,en=g.reduce((e,r)=>e+r.physY,0)/g.length,on=Mn(g,tn,en),sn=xn(g,g.length),F=16,G=new Set;for(const e of p){const r=(Math.atan2(e.physY-l,e.physX-m)+2*Math.PI)%(2*Math.PI);G.add(Math.floor(r/(2*Math.PI)*F)%F)}const rn=p.length>0?G.size/F:0,T=Math.max(u[0]?.width??1,u[0]?.height??1),X=Ln(u,M.slice(1,12),T),{width:cn,length:dn}=Rn(X,...K(X),T);let Y=1/0,q=0;for(const e of X){const r=Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h;r<Y&&(Y=r),r>q&&(q=r)}const an=Y===1/0?0:Y,ln=Math.min(q,1),C=5,W=new Array(C).fill(0),z=new Array(C).fill(0),hn=new Set(n);for(const e of t){const r=Math.min(C-1,Math.floor(Math.sqrt((e.physX-m)**2+(e.physY-l)**2)/h*C));W[r]++,hn.has(e)&&z[r]++}const gn=W.map((e,r)=>e>0?z[r]/e:0);return{globalRdd:d,edgeRdd:f,centroidDistNorm:V,minDistNorm:j,maxDistNorm:J,p25DistNorm:Q,eccentricity:on,linearScore:sn,salienceSize:x,salienceFraction:D,edgeAngularSpread:rn,innerOuterRatio:nn,lineWidth:cn,lineLength:dn,lineSize:X.length,lineMinDistNorm:an,lineMaxDistNorm:ln,radialFailRates:gn}}function Nn(n,t,o){const s=Math.max(5,Math.round(o*.003)),a=n.salienceSize>=s;if(n.globalRdd<t.nearFullGlobalRdd&&n.p25DistNorm>=t.edgeLocalCentroidDist&&n.edgeAngularSpread>=t.edgeRingAngularSpread&&n.edgeRdd>=t.edgeLocalEdgeRdd)return{pattern:"edge-ring",confidence:n.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};const[c,d,i,,p]=n.radialFailRates,f=Math.max(d,i);if(n.globalRdd<t.nearFullGlobalRdd&&f>=t.donutPeak&&f-c>=t.donutHole&&f-p>=t.donutRim)return{pattern:"donut",confidence:f-c>=2*t.donutHole?"high":"medium"};if(n.globalRdd<t.nearFullGlobalRdd&&n.lineSize>=s&&n.lineWidth<=t.scratchMaxLineWidth&&n.lineLength>=t.scratchMinLineLength&&n.lineLength>=t.scratchMinLineLengthRadius*Math.sqrt(o/Math.PI)&&n.lineMaxDistNorm>=t.scratchMinReach&&n.lineMinDistNorm<t.scratchMaxInnerDist)return{pattern:"scratch",confidence:n.lineWidth<=t.scratchMaxLineWidth/2?"high":"medium"};if(n.globalRdd<t.nearFullGlobalRdd&&n.salienceFraction<.1)return{pattern:"random",confidence:"low"};if(n.globalRdd>=t.nearFullGlobalRdd)return{pattern:"near-full",confidence:n.globalRdd>=.8?"high":"medium"};const y=a&&n.edgeRdd>=t.edgeLocalEdgeRdd&&n.maxDistNorm>=.7;return y&&n.p25DistNorm>=t.edgeLocalCentroidDist&&n.maxDistNorm-n.minDistNorm<=t.edgeRingRadialSpread?{pattern:"edge-ring",confidence:n.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"}:y&&n.p25DistNorm>=.55&&n.p25DistNorm<t.edgeLocalCentroidDist?{pattern:"edge-local",confidence:n.edgeRdd>=t.edgeRingEdgeRdd?"medium":"low"}:a&&n.centroidDistNorm<=t.centerCentroidDist&&n.edgeRdd<=t.centerEdgeRdd?{pattern:"center",confidence:n.centroidDistNorm<=t.centerCentroidDistHigh?"high":"medium"}:{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(n,t){const o=fn(n,t);return o===void 0?void 0:!o}export function patternExplains(n,t,o,s){if(!{"edge-ring":["ring","edge-arc"],"edge-local":["edge-arc","sector","quadrant"],center:["ring","cluster"],donut:["ring"],scratch:["cluster","sector","quadrant"],"near-full":["ring"]}[n]?.includes(t))return!1;if(t==="cluster")return n!=="center"||o.length===0||o.includes(1);if(t!=="ring"||o.length===0)return!0;const c=o.includes(s),d=o.includes(1);return n==="edge-ring"||n==="edge-local"?c:n==="center"?d:n==="donut"?!c&&!d:!0}export function classifyPattern(n,t,o){const s=new Set(o.passBins),a=n.filter(c=>patternFailVerdict(c,s)===!0);return classifyFailingDies(a,n,t,o.ringCount)}export function classifyFailingDies(n,t,o,s){const a={...DEFAULT_PATTERN_THRESHOLDS},c=Math.max(a.minimumFailingDies,Math.round(t.length*.003));if(n.length<c)return null;const d=En(n,t,o,s),{pattern:i,confidence:p,note:f}=Nn(d,a,t.length);return{pattern:i,confidence:p,features:d,...f?{note:f}:{}}}
@@ -1,9 +1,13 @@
1
+ import { type GuideSection } from './guideSections.js';
1
2
  import type { Die } from '../core/dies.js';
2
3
  import type { Wafer } from '../core/wafer.js';
3
4
  import type { WaferMetadata } from '../core/metadata.js';
4
5
  import { type TestDef } from '../renderer/buildWaferMap.js';
5
6
  import type { FacetCuration } from './facets.js';
6
- import type { PlotSpec, PlotField, PlotAggregate } from './plotSpec.js';
7
+ import type { PlotSpec, PlotCondition, PlotField, PlotValueReference, PlotAggregate, PlotTestSet, PlotJudge } from './plotSpec.js';
8
+ import { type GroupComparison } from './groupCompare.js';
9
+ import { type TestPassKind } from './testPassRate.js';
10
+ import { type ControlLimits, type ControlViolation } from './control.js';
7
11
  /** One wafer of the population. The same shape a drilldown source's items have. */
8
12
  export interface PlotItem {
9
13
  label: string;
@@ -16,6 +20,8 @@ export interface PlotItem {
16
20
  ringCount: number;
17
21
  /** Needed for ring and quadrant. */
18
22
  wafer?: Wafer;
23
+ /** @internal The wafer's whole die list when `dies` is part of it (a panel's ring): PAT limits are the wafer's. */
24
+ allDies?: readonly Die[];
19
25
  }
20
26
  export interface PlotContext {
21
27
  /** The population's reconciled test list (`mergeTestDefs`). */
@@ -23,14 +29,40 @@ export interface PlotContext {
23
29
  /** The Insights tab's Group by key, which "follow Group by" resolves to. Absent outside the tab. */
24
30
  groupBy?: string;
25
31
  curation?: Record<string, FacetCuration>;
32
+ /** @internal The dies a rescaling is measured over: a panel's values are scaled as the whole plot's are. */
33
+ scaleDies?: readonly Die[];
34
+ /** @internal The panels divide a set of tests by test, so neither X nor the colour has to. */
35
+ facetByTest?: boolean;
36
+ /** @internal Partial and edge-excluded dies are already left out (`resolveEligible`). */
37
+ eligibleOnly?: boolean;
38
+ /** @internal The plot's `where` is already applied: these are the dies it keeps. */
39
+ whereApplied?: boolean;
40
+ /** @internal A heatmap resolved as the bar of its two category levels, before it is laid out as a grid. */
41
+ asHeatmap?: boolean;
42
+ /** @internal Resolving one panel (or the whole) of a faceted plot: its facet is already applied. */
43
+ inFacet?: boolean;
44
+ /** @internal The wafers of the whole plot, when this is a panel of it: a followed colour is per wafer when the whole
45
+ * has several, though a panel may hold one. */
46
+ wholeWafers?: number;
47
+ /** @internal The whole population, when this is a panel of it: a binned field's ranges are cut over all of it. */
48
+ wholeItems?: readonly PlotItem[];
49
+ /** @internal The ranges a binned field was cut into, by field, so every panel shares them. */
50
+ binEdges?: Map<string, number[]>;
26
51
  }
27
52
  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. */
53
+ /**
54
+ * A test's limits: the tester's (`limitLow`/`limitHigh`), the specification's (`specLow`/`specHigh`), on a plot of one
55
+ * wafer that wafer's PAT limits (`patLow`/`patHigh`), and proposed what-if limits (`whatIfLow`/`whatIfHigh`). Any may be absent.
56
+ */
29
57
  export interface TestLimits {
30
58
  limitLow?: number;
31
59
  limitHigh?: number;
32
60
  specLow?: number;
33
61
  specHigh?: number;
62
+ patLow?: number;
63
+ patHigh?: number;
64
+ whatIfLow?: number;
65
+ whatIfHigh?: number;
34
66
  }
35
67
  /** A field resolved over the population, one value per die (`level: 'die'`) or per wafer (`'wafer'`). */
36
68
  export interface FieldColumn {
@@ -50,9 +82,38 @@ export interface FieldColumn {
50
82
  limits?: TestLimits;
51
83
  /** 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
84
  perDie?: true;
85
+ /** For a pass rate judged by test limits: per die, −1 failed below the low limit, 1 above the high, 0 otherwise. */
86
+ failSide?: Int8Array;
53
87
  /** Why this field cannot be used on this population. */
54
88
  issue?: string;
89
+ /** For a set of tests: the test each row's value belongs to, by name, so a missing value is reported against its test. */
90
+ labelOf?: (row: number) => string;
55
91
  }
92
+ /** One test of a goal plot: `x` (mean − centre of the window) / window, `y` standard deviation / window, Ppk = (½ − |x|) / 3y. */
93
+ export interface GoalPoint {
94
+ x: number;
95
+ y: number;
96
+ group: number;
97
+ testNumber: number;
98
+ label: string;
99
+ ppk: number;
100
+ n: number;
101
+ basis: 'spec' | 'test';
102
+ }
103
+ /** A line fitted to one colour's points: y = intercept + slope · x. `r2` is the squared Pearson correlation of the points. */
104
+ export interface PlotFit {
105
+ group: number;
106
+ slope: number;
107
+ intercept: number;
108
+ r2: number;
109
+ n: number;
110
+ }
111
+ /**
112
+ * The line through points `xs`, `ys`: least squares of y on x (`linear`), or the line closest to the points at right
113
+ * angles (`orthogonal`, Deming regression with equal error variances), which does not tilt towards horizontal when x
114
+ * is as noisy as y. Undefined with fewer than three points or no spread in x.
115
+ */
116
+ export declare function fitLine(xs: readonly number[], ys: readonly number[], how: 'linear' | 'orthogonal'): Omit<PlotFit, 'group'> | undefined;
56
117
  export interface PlotPoint {
57
118
  x: number;
58
119
  y: number;
@@ -66,9 +127,20 @@ export interface PlotUnit {
66
127
  item: number;
67
128
  die?: Die;
68
129
  }
69
- export type PlotMarks = {
130
+ /**
131
+ * A bar of die pass rates or a yield per die: its cells' values are 100 (pass) and 0 (fail), and, judged by test limits,
132
+ * `failSide[u]` is −1 for a unit that failed below the low limit, 1 above the high, 0 otherwise.
133
+ */
134
+ export interface PassFailCells {
135
+ failSide?: Int8Array;
136
+ }
137
+ export type PlotMarks =
138
+ /** `fits`: a fitted line per colour, when the plot asks for one (`PlotSpec.fit`); `identity`: draw y = x. */
139
+ {
70
140
  type: 'scatter';
71
141
  points: PlotPoint[];
142
+ fits?: PlotFit[];
143
+ identity?: true;
72
144
  }
73
145
  /** `units[g][k]` is the unit behind `values[g][k]`, so a bar can say which dies (or wafers) it counts. */
74
146
  | {
@@ -76,20 +148,72 @@ export type PlotMarks = {
76
148
  values: number[][];
77
149
  units: number[][];
78
150
  unit: (u: number) => PlotUnit;
79
- } | {
151
+ }
152
+ /** Each group's values ascending, `units[g][k]` the unit behind `values[g][k]`; the k-th of n sits at `probabilityPosition(k, n)`. */
153
+ | {
154
+ type: 'probability';
155
+ values: number[][];
156
+ units: number[][];
157
+ unit: (u: number) => PlotUnit;
158
+ }
159
+ /** `nest`, set when X has several levels: each category's value at each level, outer first, with the levels' names. */
160
+ /**
161
+ * `stack`: a bar's colours drawn one on another (`values` then the colours' counts or sums, or their shares in percent);
162
+ * `cumulative`: each category's running share of the whole, in percent, for a pareto line.
163
+ */
164
+ | {
80
165
  type: 'box' | 'bar';
81
166
  categories: string[];
82
167
  cells: number[][][];
83
168
  cellUnits: number[][][];
84
169
  values: number[][];
85
170
  categoryItems?: number[];
171
+ nest?: {
172
+ levels: string[];
173
+ parts: string[][];
174
+ };
175
+ stack?: 'stack' | 'percent';
176
+ cumulative?: number[];
86
177
  unit: (u: number) => PlotUnit;
87
- } | {
178
+ passFail?: PassFailCells;
179
+ }
180
+ /** An individuals chart: one value per wafer (`items[k]` is the wafer of `values[k]`) in X order, its limits and the points breaking a rule. */
181
+ | {
182
+ type: 'control';
183
+ xs: number[];
184
+ values: number[];
185
+ items: number[];
186
+ limits: ControlLimits;
187
+ violations: ControlViolation[];
188
+ }
189
+ /**
190
+ * A heatmap: `values[r][c]` the combined value of the cell at row r and column c (NaN where it holds nothing),
191
+ * `cellUnits[r][c]` the units behind it.
192
+ */
193
+ | {
194
+ type: 'heatmap';
195
+ rows: string[];
196
+ cols: string[];
197
+ values: number[][];
198
+ cellUnits: number[][][];
199
+ unit: (u: number) => PlotUnit;
200
+ }
201
+ /** A goal plot: one point per test (and colour), its mean offset and spread as shares of its limit window. */
202
+ | {
203
+ type: 'goal';
204
+ points: GoalPoint[];
205
+ }
206
+ /** `band`: the spread round each value, per group and X, when the plot asks for one (`PlotSpec.spread`). */
207
+ | {
88
208
  type: 'line';
89
209
  xs: number[];
90
210
  values: number[][];
91
211
  counts: number[][];
92
212
  cellUnits: number[][][];
213
+ band?: {
214
+ lo: number[][];
215
+ hi: number[][];
216
+ };
93
217
  unit: (u: number) => PlotUnit;
94
218
  };
95
219
  /** `label` is the axis title WITHOUT its unit: the chart appends the unit, scaled to the ticks ("µA" for 0.000861 A). */
@@ -102,6 +226,16 @@ export interface ResolvedAxis {
102
226
  reverse?: boolean;
103
227
  /** The limits of the test this axis measures, when it measures one: the chart draws them as lines. */
104
228
  limits?: TestLimits;
229
+ /** A panel of a faceted plot: the data range of every panel, so each panel's axis spans the same range. */
230
+ extent?: [number, number];
231
+ /** The axis's reference lines and bands as values: a median or mean worked out over what the whole plot draws. */
232
+ references?: PlotValueReference[];
233
+ /** The range a clipped axis (`PlotAxis.clip`) draws, over the whole plot's values, and how many lie outside it. */
234
+ clip?: {
235
+ lo: number;
236
+ hi: number;
237
+ outside: number;
238
+ };
105
239
  }
106
240
  export interface ResolvedPlot {
107
241
  spec: PlotSpec;
@@ -122,11 +256,66 @@ export interface ResolvedPlot {
122
256
  label: string;
123
257
  unit?: string;
124
258
  lo: number;
125
- hi: number;
259
+ hi: number; /** Every value is a whole number (a count): shown without decimals. */
260
+ integer?: true;
126
261
  };
127
262
  colorLabel?: string;
263
+ /** Set when the colour is a hard or soft bin: each group takes that bin's colour on the maps (`BinColors`). */
264
+ colorBins?: 'hard' | 'soft';
265
+ /** Set when the colour is one of the X fields: the axis already names every colour, so no legend is needed. */
266
+ colorRepeatsX?: true;
128
267
  /** How values were combined, in words ("mean of Vth per wafer"), when they were. */
129
268
  aggregation?: string;
269
+ /** How the values were rescaled, in words, when they were (`PlotSpec.normalize`). */
270
+ normalization?: string;
271
+ /**
272
+ * For a box or bar of one measured test divided by a wafer field (split, lot): the groups compared with each wafer
273
+ * as one value (the mean of its dies), so n is wafers. `by` names the field.
274
+ */
275
+ comparison?: {
276
+ by: string;
277
+ result: GroupComparison;
278
+ };
279
+ /**
280
+ * A faceted plot: one plot per value of the facet field, in order, each on the whole plot's colours (`groups`) and
281
+ * axis ranges, with its units naming wafers of the population handed in. The fields above describe the whole.
282
+ */
283
+ facets?: Array<{
284
+ label: string;
285
+ plot: ResolvedPlot;
286
+ }>;
287
+ /** The facet field's name, when there are panels. */
288
+ facetLabel?: string;
289
+ /** The plot shows PAT verdicts or PAT limits: its statement says how they are set. */
290
+ usesPat?: true;
291
+ /** A scatter's Pearson r over every point drawn (null when it is undefined: too few points, no spread) and n. */
292
+ correlation?: {
293
+ r: number | null;
294
+ n: number;
295
+ };
296
+ /** What `where` kept, in words ("only dies with Hard bin Bin 1"). */
297
+ filterNote?: string;
298
+ /** Dies left out because a yield does not judge them: partial dies and dies inside the edge exclusion. */
299
+ leftOut?: {
300
+ partial: number;
301
+ edge: number;
302
+ };
303
+ /** Each fitted line as an equation with its R² and n, one per colour. */
304
+ fitNotes?: string[];
305
+ /** The plotted test's pass rate under its own limits and under the proposed ones (`PlotSpec.whatIf`), over the dies it judges. */
306
+ whatIf?: {
307
+ lo?: number;
308
+ hi?: number;
309
+ judged: number;
310
+ passNow: number;
311
+ passThen: number;
312
+ sentence: string;
313
+ };
314
+ /** @internal The tests a set resolved to, and their labels, in order. */
315
+ setTests?: {
316
+ tests: number[];
317
+ labels: string[];
318
+ };
130
319
  /** The scope: every wafer and die handed in. */
131
320
  population: {
132
321
  wafers: number;
@@ -152,7 +341,50 @@ export interface ResolvedPlot {
152
341
  };
153
342
  }
154
343
  /** The reader's name for a field, whether or not the population has it. */
155
- export declare function fieldLabel(field: PlotField, testDefs?: readonly TestDef[]): string;
344
+ export declare function fieldLabel(field: PlotField, testDefs?: readonly TestDef[], curation?: Record<string, FacetCuration>): string;
345
+ /**
346
+ * The order a wafer field's values (a split, a lot) are listed in: by number when every value is one, else naturally
347
+ * (W2 before W10). A plot places and colours them in this order, and Insights' Group by lists its groups in it, so a
348
+ * group has one colour on every card.
349
+ */
350
+ export declare function orderFieldValues(values: readonly string[]): string[];
351
+ /** The bin a category or colour named by `binLabel` stands for; `undefined` for any other label. */
352
+ export declare function binOfLabel(label: string): number | undefined;
353
+ /**
354
+ * How a pass rate judges a die of `def`: a functional test by its recorded verdict, a parametric one by its test limits
355
+ * or (`judge: 'flag'`) by the tester's recorded flag. The Overview pass-rate card's three modes, as one rule.
356
+ */
357
+ export declare function passKindOf(def: TestDef, judge: PlotJudge | undefined): TestPassKind;
358
+ /**
359
+ * The test numbers a set names, in the order written, ranges expanded to the declared tests inside them by the parser a
360
+ * sweep and a derived test use, so the same text names the same tests everywhere. A test named twice is kept once.
361
+ */
362
+ export declare function expandTestSet(set: PlotTestSet, testDefs: readonly TestDef[]): {
363
+ tests: number[];
364
+ problems: string[];
365
+ };
366
+ /**
367
+ * `set` with `names` holding the name each of its tests has in `testDefs`, for the check that the plot is read against
368
+ * the same tests in another lot. A test the definitions do not hold is left out of `names`.
369
+ */
370
+ export declare function withTestSetNames(set: PlotTestSet, testDefs: readonly TestDef[]): PlotTestSet;
371
+ /**
372
+ * The most values a set of tests reads at once (dies × tests). Every value is held by the box or bar that draws it, so a
373
+ * set over a large lot is refused with the numbers rather than stalling the tab.
374
+ */
375
+ export declare const TEST_SET_VALUE_LIMIT = 4000000;
376
+ /**
377
+ * The edges between a binned field's ranges, ascending, interior only (`bins - 1` of them at most; fewer where values
378
+ * repeat so that two ranges would hold the same cut). `count`: each range holds about the same number of values;
379
+ * `width`: each spans the same width between the smallest and largest.
380
+ */
381
+ export declare function binEdges(values: ArrayLike<number>, bins: number, by: 'count' | 'width'): number[];
382
+ /**
383
+ * The cumulative share a probability plot puts the k-th smallest of n values at (k from 0): (k + ½) / n, Hazen's
384
+ * plotting position. It never reaches 0 or 1, so the smallest and largest values have a place on a normal-probability
385
+ * axis, and it puts the median of an odd count at exactly 50%.
386
+ */
387
+ export declare const probabilityPosition: (k: number, n: number) => number;
156
388
  /** One value for a set of numbers. `count` ignores missing values; the rest of an empty set is NaN. */
157
389
  export declare function combine(values: readonly number[], how: PlotAggregate): number;
158
390
  /** What the cross-field rules need to know of a field: its level, whether it is a number, and whether it is a yield. */
@@ -183,13 +415,56 @@ export declare function combinationIssue(mark: PlotSpec['chart'], f: {
183
415
  long: string;
184
416
  short: string;
185
417
  } | undefined;
418
+ /** The values a resolved plot draws along one axis (`markValues`): what a host compares its limits against. */
419
+ export declare const axisValues: (r: ResolvedPlot, role: "x" | "y") => number[];
420
+ /** The unit a condition's numbers are in, for stating its range: a test's own, or a percentage. */
421
+ export declare function conditionUnit(field: PlotField, testDefs?: readonly TestDef[]): string | undefined;
422
+ /**
423
+ * One condition in words, as the card footnote, the filter band and the editor's summary state it: "Ring is Edge or
424
+ * Middle", "Hard bin is not Bin 1", "Vth from 0.4 V to 0.6 V", "Yield below 90%".
425
+ */
426
+ export declare function conditionText(c: PlotCondition, testDefs?: readonly TestDef[], curation?: Record<string, FacetCuration>): string;
427
+ /** What `applyConditions` kept: the items (each with only its kept dies), their places in the input, and counts. */
428
+ export interface ConditionsApplied {
429
+ items: PlotItem[];
430
+ /** For each kept item, its index in the items given. */
431
+ index: number[];
432
+ /** The kept dies over all dies, and the kept wafers over all wafers. */
433
+ dies: {
434
+ kept: number;
435
+ total: number;
436
+ };
437
+ wafers: {
438
+ kept: number;
439
+ total: number;
440
+ };
441
+ /** The filter in words: "only wafers where Split is A; only dies where Ring is Edge". Empty with no conditions. */
442
+ said: string;
443
+ /** Why the conditions cannot be applied (a field the lot lacks, a range on a category); nothing is filtered then. */
444
+ issue?: string;
445
+ }
446
+ /**
447
+ * Keep the wafers and dies that meet every condition: the one filter rule, for a plot's own filter and the Insights
448
+ * population filter alike. Every condition is judged on the population as given, so a wafer condition (yield below
449
+ * 90%) reads the whole wafer, and die conditions then keep dies inside the wafers kept. A unit with no value for a
450
+ * condition's field meets no condition, negated or not. A kept wafer keeps `allDies` (its whole wafer), so a PAT
451
+ * verdict or a whole-wafer figure is still judged on all of it.
452
+ */
453
+ export declare function applyConditions(conditions: readonly PlotCondition[], items: readonly PlotItem[], ctx?: PlotContext): ConditionsApplied;
186
454
  /** Resolves `spec` over `items`. Never throws for a plot that cannot be drawn: it returns the reasons. */
187
455
  export declare function resolvePlot(spec: PlotSpec, items: readonly PlotItem[], ctx?: PlotContext): ResolvedPlot;
188
456
  /** The plot's title: the one the user typed, else the automatic one. */
189
457
  export declare function plotTitle(resolved: ResolvedPlot): string;
190
458
  /** The statement every plot carries about what it shows ("6 wafers · 3,966 dies · 12 dies without Ioff not plotted"). */
191
459
  export declare function plotFootnote(resolved: ResolvedPlot): string;
192
- export type FieldGroup = 'Tests' | 'Verdicts' | 'Die' | 'Wafer';
460
+ /**
461
+ * The user-guide sections that explain what a plot shows, a card linking each after its footnote: its chart type's
462
+ * statistics, and each of these only while the plot uses it: groups compared wafer by wafer, a fit line or the y = x
463
+ * line, a band, rescaled values, ranges of a number, panels, what-if limits. None for a plain chart (its About line
464
+ * says all there is).
465
+ */
466
+ export declare function plotGuideSections(resolved: ResolvedPlot): GuideSection[];
467
+ export type FieldGroup = 'Tests' | 'Verdicts' | 'Pass rates' | 'Die' | 'Wafer';
193
468
  /** One entry of the editor's field list. */
194
469
  export interface FieldOption {
195
470
  field: PlotField;
@@ -213,6 +488,13 @@ export declare function fieldKey(f: PlotField): string;
213
488
  * soft-bin entry for a lot with no soft bins), so the list is the lot's, not the library's.
214
489
  */
215
490
  export declare function fieldCatalogue(items: readonly PlotItem[], ctx?: PlotContext): FieldOption[];
491
+ /**
492
+ * The values a category field takes on this population, in the order every list of them uses (`categoryOrder`): what
493
+ * the editor offers for a plot's `where`. Empty for a field with no categories here.
494
+ */
495
+ /** The smallest and largest value a numeric field takes on the population, or undefined when it has none (or is a category). */
496
+ export declare function fieldExtent(field: PlotField, items: readonly PlotItem[], ctx?: PlotContext): [number, number] | undefined;
497
+ export declare function fieldValues(field: PlotField, items: readonly PlotItem[], ctx?: PlotContext): string[];
216
498
  export type PlotRole = 'x' | 'y' | 'color';
217
499
  /**
218
500
  * The fields that make sense for a role of a mark, so the editor never offers a choice that can only fail:
@@ -245,15 +527,10 @@ export interface TitleDrift {
245
527
  export declare function titleDrift(spec: PlotSpec, catalogue: readonly FieldOption[]): TitleDrift;
246
528
  /** `titleDrift` in a sentence for the reader, or null when the title is fine. */
247
529
  export declare function describeTitleDrift(d: TitleDrift): string | null;
248
- /**
249
- * One example of each chart type that this population can show, so a reader who has not built a plot before has
250
- * something to start from: a scatter of the first two tests, a histogram of the first, a box of the first by wafer, a
251
- * bar of yield by the first lot field that divides the wafers (by wafer when none does), and the first test over wafer
252
- * order as a line, and a sweep of the first few tests in test order. A type is left out when the population cannot
253
- * support it (a line needs two wafers, a sweep two tests). Untitled, so each one is named by what it plots; the sweep,
254
- * which has no fields to name it by, is titled "Example sweep".
255
- */
256
- export declare function examplePlots(catalogue: readonly FieldOption[], waferCount: number, newId: () => string): PlotSpec[];
530
+ export declare function examplePlots(catalogue: readonly FieldOption[], waferCount: number, newId: () => string, data?: {
531
+ items: readonly PlotItem[];
532
+ ctx?: PlotContext;
533
+ }): PlotSpec[];
257
534
  /**
258
535
  * The test a click on this plot should open a wafer on: the plot's own measurement, so the map shows the values the
259
536
  * plot is about rather than the bins. A scatter takes its X (as the Insights scatter does), then its Y, then its