@wafertools/wafermap 0.40.0 → 0.40.1

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 (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/packages/canvas-adapter/charts/commonality.js +3 -3
  3. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +5 -2
  4. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  5. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  6. package/dist/packages/canvas-adapter/dataTab.d.ts +12 -6
  7. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  8. package/dist/packages/canvas-adapter/drilldown.d.ts +1 -1
  9. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  10. package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
  11. package/dist/packages/canvas-adapter/filterButton.js +1 -1
  12. package/dist/packages/canvas-adapter/identityHeader.js +1 -1
  13. package/dist/packages/canvas-adapter/insightsTab.d.ts +9 -4
  14. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  15. package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
  16. package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
  17. package/dist/packages/canvas-adapter/plotTab.d.ts +1 -1
  18. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  19. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  20. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  21. package/dist/packages/canvas-adapter/summaryPanel.d.ts +2 -2
  22. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  23. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  24. package/dist/packages/canvas-adapter/userGuideHtml.js +20 -13
  25. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  26. package/dist/packages/canvas-adapter/version.js +1 -1
  27. package/dist/packages/canvas-adapter/virtualTable.d.ts +2 -1
  28. package/dist/packages/canvas-adapter/virtualTable.js +1 -1
  29. package/dist/packages/renderer/buildView.js +1 -1
  30. package/dist/packages/renderer/fmt.d.ts +2 -0
  31. package/dist/packages/renderer/fmt.js +1 -1
  32. package/dist/packages/stats/commonality.d.ts +1 -1
  33. package/dist/packages/stats/commonality.js +1 -1
  34. package/dist/packages/stats/examplePicks.js +1 -1
  35. package/dist/packages/stats/groupEffects.d.ts +8 -0
  36. package/dist/packages/stats/groupEffects.js +1 -1
  37. package/dist/packages/stats/plotData.d.ts +7 -2
  38. package/dist/packages/stats/plotData.js +1 -1
  39. package/dist/packages/stats/synthesis.d.ts +8 -1
  40. package/dist/packages/stats/synthesis.js +1 -1
  41. package/package.json +1 -1
@@ -72,7 +72,7 @@ export const USER_GUIDE_HTML=`<div class="wmap-guide">
72
72
  .wmap-guide-toc{display:none!important}
73
73
  }
74
74
  </style>
75
- <h1 id="wmap-wafer-map-user-guide">Wafer Map \u2014 User Guide<span class="wmap-guide-version" title="Built 2026-11-06T15:52:39.996Z">v0.40.0</span></h1>
75
+ <h1 id="wmap-wafer-map-user-guide">Wafer Map \u2014 User Guide<span class="wmap-guide-version" title="Built 2026-11-06T19:58:17.032Z">v0.40.1</span></h1>
76
76
  <p class="wmap-guide-online-link">This is a quick reference. <a href="https://wafertools.github.io/wafermap/user-guide/" target="_blank" rel="noopener">View the full illustrated guide online \u2197</a></p>
77
77
  <p>This guide describes the display and analysis features of the wafer map viewer.
78
78
  It is written for users who may be semiconductor test engineers, device engineers, and yield engineers
@@ -907,7 +907,8 @@ it. Click a region or wafer to highlight it, or a test to show the test&#39;s va
907
907
  fails selected; click again to clear. Under the top item&#39;s sentence, chips name its parts (its
908
908
  failing bins, with their legend colours, the pattern, and tests failing or shifted on the same dies),
909
909
  and each chip shows that part alone. With Insights on, each of the top items also has a <strong>Chart</strong>
910
- link, which opens Insights at its card under <strong>Worth a look</strong> on the Overview.
910
+ link, which opens Insights at its card under <strong>Worth a look</strong> on the Overview, or, for an item about the yield of
911
+ groups of wafers, at <strong>What divides yield</strong>.
911
912
  A wafer or lot with nothing affecting a yield point&#39;s worth of dies says so: &quot;Nothing stands out&quot;.
912
913
  The reports open with the same section, and <strong>Full report</strong> at the foot of it opens the
913
914
  report; in a report opened from the panel, clicking a finding&#39;s row shows it on the map.</li>
@@ -975,7 +976,7 @@ are the same sentence.</p>
975
976
  still receives every one of them.</p>
976
977
  <p>For <strong>lot-level views</strong> (gallery), the panel shows lot-level findings, and the
977
978
  <strong>Wafer Yield</strong> section badges each wafer with its own findings count \u2014 click a
978
- row to open that wafer. There is no separate wafers tab: every wafer appears in
979
+ row to open that wafer on its bins, as a yield opens everywhere. There is no separate wafers tab: every wafer appears in
979
980
  that one list, including the ones with no findings, which is what lets you see a
980
981
  low-yielding wafer that nothing flagged.</p>
981
982
  <hr>
@@ -1081,16 +1082,18 @@ pass-rate card offers up to three ways of judging, whichever the data supports:
1081
1082
  <strong>Functional</strong>; when the first two disagree it says how many dies they judged differently. The card is the size of the
1082
1083
  others whatever the number of tests: more than fit scroll. With nothing to judge it is left out.</p>
1083
1084
  </li>
1084
- <li><p><strong>Worth a look</strong>, on the Overview below the yield, bin and region cards \u2014 the same items as
1085
+ <li><p><strong>Worth a look</strong>, at the top of the Overview \u2014 the same items as
1085
1086
  <strong>What stands out</strong> beside the map, in the same order and words, each drawn as the chart that shows
1086
1087
  it: a region&#39;s loss as yield by that kind of region (each bar with its value, and the median of the bars as
1087
1088
  a line, as on the yield card), a fail bin as the bins&#39; shares by it, a shifted
1088
1089
  test as a box of the test by it, a failing or too-wide test as its histogram (a pass/fail test as its
1089
- pass rate), a trend as a control chart, an outlier wafer as yield by wafer. Each card says why it is
1090
+ pass rate), a trend as a control chart, an outlier wafer as yield by wafer. An item about the yield of groups
1091
+ of wafers (a probe card, a recipe) is a row of <strong>What divides yield</strong> just below, which reads the same fields
1092
+ the same way, so it has no card here. Each card says why it is
1090
1093
  shown in one sentence (hover it for the whole sentence What stands out gives, with the bins and tests it
1091
1094
  names), and <strong>Show on map</strong> goes back to the map showing it as its row does, with the Summary panel
1092
- open on that row. The rest follow on one &quot;Also&quot; line. It describes the whole lot, so while the Insights
1093
- filter or <strong>Show</strong> narrows the population it says so instead of drawing cards.</p>
1095
+ open on that row. Smaller items are listed under What stands out only. Under a filter it shows the items What stands
1096
+ out lists for what the filter keeps; while <strong>Show</strong> narrows to one group it says so instead of drawing cards.</p>
1094
1097
  </li>
1095
1098
  <li><p><strong>Distributions</strong> \u2014 how values spread: <a href="https://wafertools.github.io/wafermap/charts/#process-capability">Process capability</a>, the <a href="https://wafertools.github.io/wafermap/charts/#test-value-distribution">test-value box plot</a>
1096
1099
  (one box per wafer, or with Group by on one per group: click a group&#39;s box to see its wafers, <strong>Back</strong> to return), the
@@ -1172,7 +1175,10 @@ positive, blue = negative; intensity = strength) and a die-level scatter
1172
1175
  plot coloured by hard bin. Clicking a matrix cell drives the scatter plot
1173
1176
  onto that pair.</em></p>
1174
1177
  <h3 id="wmap-what-a-click-does">What a click does</h3>
1175
- <p>Every mark on an Insights chart stands for something, and a click opens it. A <strong>right-click</strong> on any mark opens the menu on what it counts, so on a mark that stands for dies a click and a right-click do the same; on a wafer&#39;s own mark, a click opens the wafer&#39;s map and a right-click its menu. The tooltip says which.</p>
1178
+ <p>Every mark on an Insights chart stands for something, and a click opens it. A <strong>right-click</strong> on any mark opens the menu on what it counts, so on a mark that stands for dies a click and a right-click do the same; on a wafer&#39;s own mark, a click opens the wafer&#39;s map and a right-click its menu. The tooltip says which. A wafer
1179
+ opens on what was clicked, wherever it was clicked from: a test (a chart of the test, a test&#39;s column in a table) opens
1180
+ it on that test, a yield or bin (a yield bar, the Yield % column) on its bins, and anything else in the mode the maps
1181
+ are in.</p>
1176
1182
  <table>
1177
1183
  <thead>
1178
1184
  <tr>
@@ -1226,11 +1232,11 @@ onto that pair.</em></p>
1226
1232
  </tr>
1227
1233
  <tr>
1228
1234
  <td>A row of the <strong>Wafers</strong> table</td>
1229
- <td>that wafer&#39;s map</td>
1235
+ <td>that wafer&#39;s map, on the test whose mean column you clicked, or on its bins from its yield</td>
1230
1236
  </tr>
1231
1237
  <tr>
1232
1238
  <td>A row of the <strong>Dies</strong> table</td>
1233
- <td>that die, ringed on its wafer&#39;s map</td>
1239
+ <td>that die&#39;s wafer in a window of its own, the die ringed, on the test whose column you clicked (from the Maps view&#39;s tables, the die is ringed on its card)</td>
1234
1240
  </tr>
1235
1241
  </tbody></table>
1236
1242
  <p>The menu offers the charts and tables for just those dies (and your own plots), and its heading names
@@ -1551,8 +1557,8 @@ left out, and the line counts them (&quot;12 edge-excluded dies left out&quot;).
1551
1557
  a die without saying so. A plot coloured by hard or soft bin uses the map&#39;s bin colours.</p>
1552
1558
  <p><strong>Hover</strong> a point, bar, box or line to see its values and how many dies or wafers it
1553
1559
  stands for. <strong>Click</strong> a point (or a wafer&#39;s bar or box) to open that wafer, on the plot&#39;s own
1554
- test, so its map shows the values the plot is about and not the bins (a plot with no test in it,
1555
- like yield against wafer order, opens the default map). Click any other bar, box, histogram bar or
1560
+ test, so its map shows the values the plot is about and not the bins (a plot of yield or bins with no test in it,
1561
+ like yield against wafer order, opens the bins, as a yield bar does everywhere). Click any other bar, box, histogram bar or
1556
1562
  line point to open the right-click menu on the dies it counts, and <strong>drag</strong> a rectangle over a
1557
1563
  scatter to select the dies (or wafers) inside it. The selection opens the same
1558
1564
  right-click menu as on a map, so a few dies from a plot can be charted and tabulated
@@ -1768,7 +1774,8 @@ scale of 0 to 100%, each with its mean, with a sentence giving the gap in percen
1768
1774
  spread and wafer count. <strong>Confidence</strong> is <strong>Clear</strong> (q under 0.05),
1769
1775
  <strong>Possible</strong> (under 0.2) or <strong>Not clear</strong>, so the fields at the top separate the wafers more clearly than wafer-to-wafer
1770
1776
  noise would; hover it for q, Welch&#39;s p and the rank p. A button on a field opens its other measures. The <strong>Group by</strong>
1771
- button regroups every chart by that field. Each field is read after allowing for the strongest other field that explains the same measure (and does not contain it): a probe card on wafers that also differ by recipe is ranked by what the recipe leaves, and its row says &quot;allowing for&quot; that field, with the degrees of freedom the removed means used charged to the p. Two limits are stated on the card itself: a field that gives every wafer its own value cannot be tested, and
1777
+ button regroups every chart by that field. Each field is read after allowing for the strongest other field that explains the same measure (and does not contain it): a probe card on wafers that also differ by recipe is ranked by what the recipe leaves, and its row says &quot;allowing for&quot; that field, with the degrees of freedom the removed means used charged to the p. A field is compared when at least two of its groups have two wafers or more and it has no more groups than half the
1778
+ wafers (two, with fewer than six); What stands out and the example plots compare the same fields. Two limits are stated on the card itself: a field that gives every wafer its own value cannot be tested, and
1772
1779
  fields that change together (a lot and its start date, or a tester and the handler docked to it) cannot be told apart by the wafers; the card names each set of them, and names fields that nearly match (most wafers in matching groups) with how many wafers agree. A low q points to where
1773
1780
  to look; it is not a cause. Tool, chamber and probe-card fields appear only when the host supplies them as wafer
1774
1781
  attributes.</p>
@@ -1,3 +1,3 @@
1
- export declare const WMAP_VERSION = "0.40.0";
2
- export declare const WMAP_BUILD_TIME = "2026-11-06T15:57:00.349Z";
1
+ export declare const WMAP_VERSION = "0.40.1";
2
+ export declare const WMAP_BUILD_TIME = "2026-11-06T20:04:42.615Z";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const WMAP_VERSION="0.40.0",WMAP_BUILD_TIME="2026-11-06T15:57:00.349Z";
1
+ export const WMAP_VERSION="0.40.1",WMAP_BUILD_TIME="2026-11-06T20:04:42.615Z";
@@ -20,7 +20,8 @@ export interface VirtualTableOptions<R> {
20
20
  overscan?: number;
21
21
  /** Viewport height assumed when the element has not been laid out (tests, hidden parents). Default 480. */
22
22
  fallbackViewportHeight?: number;
23
- onRowClick?: (row: R, rowIndex: number) => void;
23
+ /** A row clicked; `columnIndex` is the column of the cell clicked, in `columns` order. */
24
+ onRowClick?: (row: R, rowIndex: number, columnIndex: number) => void;
24
25
  }
25
26
  export interface VirtualTable<R> {
26
27
  /** The scroll container; mount it in a flex column or give it a height. */
@@ -1 +1 @@
1
- import{ensureStylesInjected as _}from"./dieList.js";import{CLR as K,RADIUS as X}from"./toolbar.js";const G=64,J=260,P=7.4;export function createVirtualTable(u){const l=u.ownerDocument??document;_(l);const b=u.rowHeight??24,L=u.overscan??10,w=u.columns;let c=u.rows,y=null,C=-1,x=1,k=0,M=-1;const i=l.createElement("div");Object.assign(i.style,{overflow:"auto",flex:"1",minHeight:"0",minWidth:"0",border:`1px solid ${K.menuBorder}`,borderRadius:X.control}),i.tabIndex=0,i.setAttribute("role","region"),i.setAttribute("aria-label",u.ariaLabel);const d=l.createElement("table");d.className="wmap-dielist-table",d.setAttribute("aria-label",u.ariaLabel),d.style.tableLayout="fixed";const N=l.createElement("colgroup"),q=Math.min(c.length,50);let H=0;w.forEach(t=>{let n=t.header.length+2;for(let o=0;o<q;o++)n=Math.max(n,t.get(c[o]).length);const e=Math.max(G,Math.min(J,Math.round(n*P+20)));H+=e;const a=l.createElement("col");a.style.width=`${e}px`,N.appendChild(a)}),d.style.width=`${H}px`,d.style.minWidth="100%",d.appendChild(N);const R=l.createElement("thead"),O=l.createElement("tr"),S=[];w.forEach((t,n)=>{const e=l.createElement("th");e.className="wmap-dielist-th",e.scope="col",e.textContent=t.header,e.style.cursor="pointer",e.style.overflow="hidden",e.style.textOverflow="ellipsis",t.numeric&&(e.style.textAlign="right"),e.setAttribute("aria-sort","none"),e.tabIndex=0;const a=()=>U(n);e.addEventListener("click",a),e.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),a())}),S.push(e),O.appendChild(e)}),R.appendChild(O),d.appendChild(R);const $=l.createElement("tbody");d.appendChild($),i.appendChild(d);const D=()=>{const t=l.createElement("tr");t.setAttribute("aria-hidden","true");const n=l.createElement("td");return n.colSpan=w.length,n.style.padding="0",n.style.border="none",t.appendChild(n),t},F=D(),I=D(),z=t=>c[y?y[t]:t];function B(){return i.clientHeight>0?i.clientHeight:u.fallbackViewportHeight??480}function E(t=!1){const n=c.length,e=R.offsetHeight||b,a=Math.max(0,i.scrollTop-e),o=Math.max(0,Math.floor(a/b)-L),r=Math.min(n-1,Math.ceil((a+B())/b)+L);if(!t&&o===k&&r===M)return;k=o,M=r;const p=l.createDocumentFragment();F.firstElementChild.style.height=`${o*b}px`,I.firstElementChild.style.height=`${Math.max(0,n-1-r)*b}px`,p.appendChild(F);for(let s=o;s<=r;s++){const h=z(s),m=l.createElement("tr");m.style.height=`${b}px`,m.setAttribute("aria-rowindex",String(s+2));for(const g of w){const f=l.createElement("td");f.className="wmap-dielist-td",f.textContent=g.get(h),f.style.overflow="hidden",f.style.textOverflow="ellipsis",g.numeric&&(f.style.textAlign="right");const j=g.shade?.(h);j&&(f.style.background=j),m.appendChild(f)}if(u.onRowClick){m.style.cursor="pointer";const g=y?y[s]:s;m.addEventListener("click",()=>u.onRowClick(h,g))}p.appendChild(m)}p.appendChild(I),$.replaceChildren(p)}function U(t){C===t?x=x===1?-1:1:(C=t,x=1),S.forEach((n,e)=>n.setAttribute("aria-sort",e!==C?"none":x===1?"ascending":"descending")),S.forEach((n,e)=>{n.textContent=w[e].header+(e===C?x===1?" \u25B2":" \u25BC":"")}),T(),i.scrollTop=0,E(!0)}function T(){const t=c.length;if(C<0||t===0){y=null;return}const n=w[C],e=n.sortKey??n.get,a=new Array(t);for(let r=0;r<t;r++)a[r]=e(c[r]);const o=new Uint32Array(t);for(let r=0;r<t;r++)o[r]=r;o.sort((r,p)=>{const s=a[r],h=a[p],m=s===void 0||s===""||typeof s=="number"&&Number.isNaN(s),g=h===void 0||h===""||typeof h=="number"&&Number.isNaN(h);if(m||g)return m===g?r-p:m?1:-1;const f=typeof s=="number"&&typeof h=="number"?s-h:String(s).localeCompare(String(h),void 0,{numeric:!0});return f!==0?f*x:r-p}),y=o}let v=0;const A=l.defaultView,V=()=>{v||(A&&typeof A.requestAnimationFrame=="function"?v=A.requestAnimationFrame(()=>{v=0,E()}):E())};i.addEventListener("scroll",V);const W=typeof ResizeObserver<"u"?new ResizeObserver(()=>E()):null;return W?.observe(i),d.setAttribute("aria-rowcount",String(c.length+1)),E(!0),{el:i,get length(){return c.length},orderedRows(){const t=c,n=y;return(function*(){for(let e=0;e<t.length;e++)yield t[n?n[e]:e]})()},setRows(t){c=t,d.setAttribute("aria-rowcount",String(c.length+1)),T(),i.scrollTop=0,E(!0)},drawnRange:()=>({first:k,last:M}),destroy(){i.removeEventListener("scroll",V),W?.disconnect(),v&&A&&A.cancelAnimationFrame(v),i.remove()}}}
1
+ import{ensureStylesInjected as _}from"./dieList.js";import{CLR as K,RADIUS as X}from"./toolbar.js";const G=64,J=260,P=7.4;export function createVirtualTable(f){const l=f.ownerDocument??document;_(l);const b=f.rowHeight??24,N=f.overscan??10,w=f.columns;let d=f.rows,y=null,x=-1,C=1,M=0,R=-1;const i=l.createElement("div");Object.assign(i.style,{overflow:"auto",flex:"1",minHeight:"0",minWidth:"0",border:`1px solid ${K.menuBorder}`,borderRadius:X.control}),i.tabIndex=0,i.setAttribute("role","region"),i.setAttribute("aria-label",f.ariaLabel);const h=l.createElement("table");h.className="wmap-dielist-table",h.setAttribute("aria-label",f.ariaLabel),h.style.tableLayout="fixed";const H=l.createElement("colgroup"),q=Math.min(d.length,50);let O=0;w.forEach(t=>{let n=t.header.length+2;for(let o=0;o<q;o++)n=Math.max(n,t.get(d[o]).length);const e=Math.max(G,Math.min(J,Math.round(n*P+20)));O+=e;const a=l.createElement("col");a.style.width=`${e}px`,H.appendChild(a)}),h.style.width=`${O}px`,h.style.minWidth="100%",h.appendChild(H);const S=l.createElement("thead"),$=l.createElement("tr"),L=[];w.forEach((t,n)=>{const e=l.createElement("th");e.className="wmap-dielist-th",e.scope="col",e.textContent=t.header,e.style.cursor="pointer",e.style.overflow="hidden",e.style.textOverflow="ellipsis",t.numeric&&(e.style.textAlign="right"),e.setAttribute("aria-sort","none"),e.tabIndex=0;const a=()=>U(n);e.addEventListener("click",a),e.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),a())}),L.push(e),$.appendChild(e)}),S.appendChild($),h.appendChild(S);const D=l.createElement("tbody");h.appendChild(D),i.appendChild(h);const F=()=>{const t=l.createElement("tr");t.setAttribute("aria-hidden","true");const n=l.createElement("td");return n.colSpan=w.length,n.style.padding="0",n.style.border="none",t.appendChild(n),t},I=F(),T=F(),z=t=>d[y?y[t]:t];function B(){return i.clientHeight>0?i.clientHeight:f.fallbackViewportHeight??480}function E(t=!1){const n=d.length,e=S.offsetHeight||b,a=Math.max(0,i.scrollTop-e),o=Math.max(0,Math.floor(a/b)-N),r=Math.min(n-1,Math.ceil((a+B())/b)+N);if(!t&&o===M&&r===R)return;M=o,R=r;const p=l.createDocumentFragment();I.firstElementChild.style.height=`${o*b}px`,T.firstElementChild.style.height=`${Math.max(0,n-1-r)*b}px`,p.appendChild(I);for(let s=o;s<=r;s++){const u=z(s),m=l.createElement("tr");m.style.height=`${b}px`,m.setAttribute("aria-rowindex",String(s+2));for(const g of w){const c=l.createElement("td");c.className="wmap-dielist-td",c.textContent=g.get(u),c.style.overflow="hidden",c.style.textOverflow="ellipsis",g.numeric&&(c.style.textAlign="right");const k=g.shade?.(u);k&&(c.style.background=k),m.appendChild(c)}if(f.onRowClick){m.style.cursor="pointer";const g=y?y[s]:s;m.addEventListener("click",c=>{const k=c.target?.closest?.("td");f.onRowClick(u,g,k?Array.prototype.indexOf.call(m.children,k):-1)})}p.appendChild(m)}p.appendChild(T),D.replaceChildren(p)}function U(t){x===t?C=C===1?-1:1:(x=t,C=1),L.forEach((n,e)=>n.setAttribute("aria-sort",e!==x?"none":C===1?"ascending":"descending")),L.forEach((n,e)=>{n.textContent=w[e].header+(e===x?C===1?" \u25B2":" \u25BC":"")}),V(),i.scrollTop=0,E(!0)}function V(){const t=d.length;if(x<0||t===0){y=null;return}const n=w[x],e=n.sortKey??n.get,a=new Array(t);for(let r=0;r<t;r++)a[r]=e(d[r]);const o=new Uint32Array(t);for(let r=0;r<t;r++)o[r]=r;o.sort((r,p)=>{const s=a[r],u=a[p],m=s===void 0||s===""||typeof s=="number"&&Number.isNaN(s),g=u===void 0||u===""||typeof u=="number"&&Number.isNaN(u);if(m||g)return m===g?r-p:m?1:-1;const c=typeof s=="number"&&typeof u=="number"?s-u:String(s).localeCompare(String(u),void 0,{numeric:!0});return c!==0?c*C:r-p}),y=o}let v=0;const A=l.defaultView,W=()=>{v||(A&&typeof A.requestAnimationFrame=="function"?v=A.requestAnimationFrame(()=>{v=0,E()}):E())};i.addEventListener("scroll",W);const j=typeof ResizeObserver<"u"?new ResizeObserver(()=>E()):null;return j?.observe(i),h.setAttribute("aria-rowcount",String(d.length+1)),E(!0),{el:i,get length(){return d.length},orderedRows(){const t=d,n=y;return(function*(){for(let e=0;e<t.length;e++)yield t[n?n[e]:e]})()},setRows(t){d=t,h.setAttribute("aria-rowcount",String(d.length+1)),V(),i.scrollTop=0,E(!0)},drawnRange:()=>({first:M,last:R}),destroy(){i.removeEventListener("scroll",W),j?.disconnect(),v&&A&&A.cancelAnimationFrame(v),i.remove()}}}
@@ -1 +1 @@
1
- import{requirePassBins as ye}from"../core/passBins.js";import{requireRingCount as be}from"../core/ringCount.js";import{hasPosition as xe}from"../core/dies.js";import{dieValueEntries as Me,dieVerdictEntries as Se,excludedBy as ve,excludedValue as Be,recordedVerdict as $e,testsPresent as qt}from"../core/dieTable.js";import{limitSetName as ke}from"./valueFilter.js";import{getReticleCell as Ie}from"../core/reticle.js";import{metadataCategoricalValue as Te,metadataDisplayValue as De}from"../core/metadata.js";import{affineRotation as Mt,affineMirror as Kt,affineCompose as rt,affinePoint as U,affineVector as Ve,affineSwapsAxes as Ce}from"../core/transforms.js";import{contrastTextColor as X,SPEC_PASS_FILL as St,SPEC_FAIL_LOW as Fe,SPEC_FAIL_HIGH as vt}from"./colorMap.js";import{resolveValueColorFn as Le}from"./colorSchemes.js";import{resolveBinColors as Re,binColorsCover as Pe}from"./binColors.js";import{NO_DATA_FILL as z}from"./colorMap.js";import{diePassStatus as Ne,isYieldEligibleDie as Q}from"../core/dies.js";import{compactView as Ee}from"./compactView.js";import{buildXYIndicator as Ae}from"./xyIndicator.js";import{getDieTestValue as L,getTestPassStatus as J,isParametricTest as Bt}from"./buildWaferMap.js";import{classifySpec as lt}from"./spec.js";export{lt as classifySpec};import{fmt as ct,fmtColorbarAxis as $t,fmtAggregationMethod as Wt}from"./fmt.js";import{metadataValueColor as _e}from"./colorMap.js";import{asList as zt,clamp01 as jt,compareNatural as Oe,escHtml as R}from"../core/utils.js";import{prettyKey as Gt}from"../core/utils.js";import{testLabel as ut,markedTestLabel as Z,derivedTestNote as Yt,isDerivedTest as He,DERIVED_MARK as we,DERIVED_KEY as qe}from"./testLabel.js";export function resolveTestNumber(t,e){return e?.length?{testNumber:(findTestDef(e,t)??e[0]).testNumber}:{testNumber:t}}export function collectMetadataValues(t,e){const n=new Set;for(const i of t){if(!Q(i))continue;const s=ft(i,e);s!==void 0&&n.add(s)}return[...n].sort(Oe)}export function findTestDef(t,e){return t?.find(n=>n.testNumber===e)}export function getUniqueTestNumbers(t){return qt(t,"values")}const Ke="#d3d6db",Ut="#e8e9ea",We="#d9dcdf",ze="#aab0ba";function ft(t,e){return e?Te(t.metadata?.[e]):void 0}function je(t,e,n){const{x:i,y:s}=t.center,a=Mt(t.orientation,i,s),o=rt(Kt(e?.x??!1,e?.y??!1,i,s),Mt(t.orientation,i,s)),r=rt(Kt(n?.flipX??!1,n?.flipY??!1,i,s),Mt(n?.rotation??0,i,s));return{bakedToScreen:r,physicalToScreen:rt(r,a),gridToScreen:rt(r,o)}}function Y(t,e=!1){return{points:[t],closed:e}}function Ge(t,e){const{center:n,radius:i,notch:s}=t;let a=n.x+i*Math.cos(e),o=n.y+i*Math.sin(e);if(!s)return{x:a,y:o};const r=Math.sqrt(i**2-(s.length/2)**2),h=s.length/2,p=a-n.x,x=o-n.y;return s.type==="bottom"&&x<-r?(o=n.y-r,a=n.x+Math.max(-h,Math.min(h,p))):s.type==="top"&&x>r?(o=n.y+r,a=n.x+Math.max(-h,Math.min(h,p))):s.type==="left"&&p<-r?(a=n.x-r,o=n.y+Math.max(-h,Math.min(h,x))):s.type==="right"&&p>r&&(a=n.x+r,o=n.y+Math.max(-h,Math.min(h,x))),{x:a,y:o}}function Xt(t,e){return t.map(e).join(" / ")}function Ye(t,e=256){const n=Array.from({length:e},(i,s)=>t(s/(e-1)));return i=>n[Math.min(e-1,Math.max(0,Math.round(i*(e-1))))]}function Ue(t,e){const n=Math.max(1,Math.min(t.width,t.height)),i=t.width/Math.max(e.length,1);return Math.max(8,Math.min(16,Math.round(Math.min(n*.55,i*1.8))))}function Xe(t,e,n){if(e?.length){const a=e.flatMap(o=>{const r=o.testNumber;if(!Bt(o)){const p=J(t,r,o);return p===void 0?[]:[{key:r,label:Z(o,r),value:p?"Pass":"Fail"}]}const h=L(t,r);if(h===void 0){const p=Be(t,r);return p===void 0?[]:[{key:r,label:Z(o,r),value:ct(p,o.unit,n),excludedBy:ve(t)}]}return[{key:r,label:Z(o,r),value:ct(h,o.unit,n),recordedFail:$e(t,r)===!1}]});if(a.length)return a}const i=Me(t);if(i.length)return i.map(([a,o])=>({key:a,label:ut(void 0,a),value:ct(o,void 0,n)}));const s=Se(t);return s.length?s.map(([a,o])=>({key:a,label:ut(void 0,a),value:o?"Pass":"Fail"})):[]}export function buildHoverText(t,e,n={}){const{testDefs:i,hbinDefs:s,sbinDefs:a,fallbackFormat:o,aggrMethod:r,lotSize:h,activeTest:p,reticleConfig:x,metadataFields:$}=n,V=s?new Map(s.map(u=>[u.bin,u])):null,I=a?new Map(a.map(u=>[u.bin,u])):null,b=[R(`Die (${t.x}, ${t.y})`)];if(x&&xe(t)){const u=Ie(t,x);b.push(R(`Reticle (${u.column}, ${u.row})`))}if(e==="stackedValues"){const u=L(t,0);if(u!==void 0){const c=i?.[0],m=c?Z(c,c.testNumber):"Value",S=r?` (${r})`:"";b.push(R(`${m}${S}: ${ct(u,c?.unit,o)}`));const d=Yt(c);d&&b.push(`<i>${R(d)}</i>`)}}else if(e==="stackedBins"||e==="stackedSoftBins"){const u=L(t,0),c=e==="stackedSoftBins"?t.sbin:t.hbin;if(u!==void 0){const m=e==="stackedSoftBins"?I:V,S=c!==void 0?m?.get(c)?.name?`${c} \xB7 ${m.get(c).name}`:`Bin ${c}`:"Bin";let d;if(r==="percent")d=`${u.toFixed(0)}%`;else{const D=h?` (${(u/h*100).toFixed(0)}% of stacked wafers)`:"";d=`${u}${D}`}const g=r?` [${Wt(r)}]`:"";b.push(R(`${S}: ${d}${g}`))}}else{const u=Xe(t,i,o);if(e==="value"&&u.length){const{testNumber:c}=resolveTestNumber(p??0,i),m=findTestDef(i,c),S=L(t,c);let d=u.findIndex(A=>A.key===c);d<0&&(d=0);const g=u[d];let D=`<b>${R(`${g.label}: ${g.value}`)}${g.recordedFail?" <i>(recorded fail)</i>":""}</b>`;if(g.key===c&&m){const A=lt(S,m);(A==="failLow"||A==="failHigh")&&(D+=" <i>(outside test limits)</i>")}g.excludedBy&&(D+=` <i>(outside ${ke(g.excludedBy)}, excluded)</i>`),b.push(D);const E=Yt(findTestDef(i,g.key));E&&b.push(`<i>${R(E)}</i>`);const y=u.length-1;y>0&&b.push(`<i>+${y} more test${y===1?"":"s"}</i>`)}else if(u.length){const c=u.length;b.push(`<i>${c} test result${c===1?"":"s"} recorded</i>`)}if(t.hbin!==void 0||t.sbin!==void 0){const c=[];if(t.hbin!==void 0){const m=V?.get(t.hbin)?.name,S=m?`${t.hbin} \xB7 ${m}`:String(t.hbin);c.push(`HBin: ${S}`)}if(t.sbin!==void 0){const m=I?.get(t.sbin)?.name,S=m?`${t.sbin} \xB7 ${m}`:String(t.sbin);c.push(`SBin: ${S}`)}b.push(c.map(R).join(" &nbsp;\xB7&nbsp; "))}}t.retestCount!==void 0&&b.push(R(`Retests: ${t.retestCount}`)),t.siteNum!==void 0&&b.push(R(`Site: ${t.siteNum}`)),t.partId!==void 0&&b.push(R(`Part ID: ${t.partId}`)),t.partial&&b.push("<i>partial die</i>"),t.probeIndex!==void 0&&b.push(R(`Probe: #${t.probeIndex}`));const B={...t.metadata??{}};for(const[u,c]of Object.entries(B)){const m=De(c);if(m===void 0)continue;const S=$?.find(d=>d.key===u)?.label??Gt(u);b.push(R(`${S}: ${m}`))}return b.join("<br>")}function kt(t){return t?.name?Z(t,t.testNumber):void 0}function It(t){return He(t)?{note:`${we} ${qe}`}:{}}export function buildMapTitle(t,e="engineering",n){const i=t.isLotStack&&t.lotSize!==void 0?`stacked (${t.lotSize} ${t.lotSize===1?"wafer":"wafers"})`:"stacked",s=a=>{const o=n?.length===1?n[0]:void 0;return o===void 0?`${a} Bin`:o.name?`${a} Bin ${o.bin} \xB7 ${o.name}`:`${a} Bin ${o.bin}`};switch(t.plotMode){case"hardBin":return{primary:"Hard Bin",secondary:""};case"softBin":return{primary:"Soft Bin",secondary:""};case"stackedBins":return{primary:s("Hard"),secondary:i};case"stackedSoftBins":return{primary:s("Soft"),secondary:i};case"metadata":{const a=t.metadataFields?.find(r=>r.key===t.activeMetadataKey),o=t.activeMetadataKey?Gt(t.activeMetadataKey):"Metadata";return{primary:a?.label??o,secondary:""}}case"stackedValues":{const a=t.testDefs?.[0],o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=$t(o,kt(a),a?.unit,e),h=r||"Value",p=t.aggrMethod?` \xB7 ${Wt(t.aggrMethod)}`:"";return{primary:`${h}${p}`,secondary:i,...It(a)}}default:{const a=findTestDef(t.testDefs,t.activeTest),o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=$t(o,kt(a),a?.unit,e),h=r||kt(a);if(t.passFailDisplay!=="off"){const p=a?.testNumber??t.activeTest,x=h?`${h} \xB7 #${p}`:ut(void 0,p),$=t.passFailDisplay==="spec"?"Limit pass/fail":a!==void 0&&!Bt(a)?"Functional pass/fail":"Tester pass/fail";return{primary:x,secondary:$,...It(a)}}return{primary:h??ut(void 0,t.activeTest),secondary:"",...It(a)}}}}export function generateTextOverlay(t,e,n){const{plotMode:i,colorFns:s,normalize:a,activeTest:o,valueRange:r,testDefs:h,fallbackFormat:p,passFailDisplay:x="off",activeMetadataKey:$,metadataColorMap:V,allIntegerValues:I}=n,b=findTestDef(h,o),{tickFmt:B}=$t(r[1],b?.name,b?.unit,p),u=I?m=>String(Math.round(m)):B,{testNumber:c}=resolveTestNumber(o,h);return t.flatMap((m,S)=>{let d="",g="#111111";if(i==="value"&&x==="test"){const y=J(m,c,b);if(y===void 0)return[];d=y?"P":"F",g=X(y?St:vt)}else if(i==="value"){const y=L(m,c);if(y===void 0)return[];d=Xt([y],u),g=X(s.forValue(a(y)))}else if(i==="hardBin"||i==="softBin"){const y=i==="softBin"?m.sbin:m.hbin;if(y===void 0)return[];d=String(y),g=X(s.forBin(y))}else if(i==="metadata"){const y=ft(m,$);if(y===void 0)return[];d=y,g=X(V?.get(d)??z)}else{const y=L(m,0);if(y===void 0)return[];d=Xt([y],u),g=X(s.forValue(a(y)))}const D=e?e[S*2]:m.physX,E=e?e[S*2+1]:m.physY;return[{x:D,y:E,text:d,fontSize:Ue(m,d),color:g,align:"center"}]})}function Qt(t){return t==="top"?Math.PI/2:t==="bottom"?-Math.PI/2:t==="left"?Math.PI:0}function Qe(t,e,n=720){const{center:i,radius:s,notch:a}=t,o=B=>U(e,B.x,B.y);if(!(a!==void 0&&a.length>0&&t.diameter>150)){const B=[];for(let u=0;u<=n;u++){const c=2*Math.PI*u/n;B.push(o(Ge(t,c)))}return[{kind:"wafer-boundary",...Y(B,!0),lineColor:"#888888",lineWidth:1}]}const h=1.25,p=a.length,x=Qt(a.type),$=Math.atan2(p,s),V=s-h,I=[];let b=!1;for(let B=0;B<=n;B++){const u=2*Math.PI*B/n;let c=u-x;for(;c>Math.PI;)c-=2*Math.PI;for(;c<-Math.PI;)c+=2*Math.PI;if(Math.abs(c)<=$){if(!b){b=!0;const m={x:i.x+s*Math.cos(x-$),y:i.y+s*Math.sin(x-$)},S={x:i.x+V*Math.cos(x),y:i.y+V*Math.sin(x)},d={x:i.x+s*Math.cos(x+$),y:i.y+s*Math.sin(x+$)};I.push(o(m),o(S),o(d))}continue}I.push(o({x:i.x+s*Math.cos(u),y:i.y+s*Math.sin(u)}))}return[{kind:"wafer-boundary",...Y(I,!0),lineColor:"#888888",lineWidth:1}]}function Je(t,e,n,i=360){const s=[],a=Math.max(1,Math.floor(n));for(let o=1;o<a;o++){const r=t.radius*o/a,h=[];for(let p=0;p<=i;p++){const x=2*Math.PI*p/i,$={x:t.center.x+r*Math.cos(x),y:t.center.y+r*Math.sin(x)};h.push(U(e,$.x,$.y))}s.push({kind:"ring-boundary",...Y(h,!0),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5})}return s}function Ze(t,e,n,i){const{x:s,y:a}=t.center,o=t.radius,r=(u,c)=>U(e,u,c),h=n-s,p=Math.sqrt(Math.max(0,o*o-h*h)),x=r(n,a-p),$=r(n,a+p),V=i-a,I=Math.sqrt(Math.max(0,o*o-V*V)),b=r(s-I,i),B=r(s+I,i);return[{kind:"quadrant-boundary",...Y([x,$]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5},{kind:"quadrant-boundary",...Y([b,B]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5}]}function tn(t,e){return t.map(n=>{const i=n.width/2,s=n.height/2;return{kind:"reticle",points:[[[n.x-i,n.y-s],[n.x+i,n.y-s],[n.x+i,n.y+s],[n.x-i,n.y+s]].map(([o,r])=>U(e,o,r))],closed:!0,lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5,fill:"rgba(0,0,0,0)"}})}function en(t){const e=t.filter(n=>n.probeIndex!==void 0).sort((n,i)=>(n.probeIndex??0)-(i.probeIndex??0));return e.length?[{kind:"probe-path",...Y(e.map(n=>({x:n.physX,y:n.physY}))),lineColor:"rgba(220,80,0,0.55)",lineWidth:1}]:[]}function nn(t,e,n,i,s,a,o,r,h,p,x,$,V,I,b="off",B,u,c){const m=e.width-o,S=e.height-o,d=a?S:m,g=a?m:S,D=M=>s==="softBin"?M.sbin:M.hbin,E=M=>ft(M,B);if(e.partial){t.push({x:n,y:i,width:d,height:g,fill:Ke,type:"stacked",metadata:e.metadata});return}if(e.filteredOut){t.push({x:n,y:i,width:d,height:g,fill:We,type:"stacked",metadata:e.metadata});return}if(e.edgeExcluded){t.push({x:n,y:i,width:d,height:g,fill:ze,type:"stacked",metadata:e.metadata});return}if(h!==void 0&&(s==="hardBin"||s==="softBin")&&!h.has(D(e))){t.push({x:n,y:i,width:d,height:g,fill:Ut,type:"hardBin",metadata:e.metadata});return}if(c!==void 0&&s==="metadata"&&!c.has(E(e))){t.push({x:n,y:i,width:d,height:g,fill:Ut,type:"metadata",metadata:e.metadata});return}if(s==="value"){if(b==="test"){const q=J(e,x,I),dt=q===void 0?z:q?St:vt;t.push({x:n,y:i,width:d,height:g,fill:dt,type:"value",metadata:e.metadata});return}const M=L(e,x),P=lt(M,I);let w,tt;M===void 0?w=z:b==="spec"?w=P==="failLow"?Fe:P==="failHigh"?vt:St:(w=r.forValue(p(M)),(P==="failLow"||P==="failHigh")&&(tt=P)),t.push({x:n,y:i,width:d,height:g,fill:w,type:"value",specMark:tt,metadata:e.metadata});return}if(s==="hardBin"||s==="softBin"){const M=D(e),P=M!=null?r.forBin(M):z,w=M!=null&&Ne(e,V)===!1?!0:void 0;t.push({x:n,y:i,width:d,height:g,fill:P,type:s,binFail:w,metadata:e.metadata});return}if(s==="metadata"){const M=E(e),P=M!==void 0?u?.get(M)??z:z;t.push({x:n,y:i,width:d,height:g,fill:P,type:"metadata",metadata:e.metadata});return}const y=L(e,0),A=y!==void 0?r.forValue(p(y)):z;t.push({x:n,y:i,width:d,height:g,fill:A,type:"value",metadata:e.metadata})}function an(t,e,n){const i=t.radius;return Ae(e,i*.15,(s,a)=>({x:t.center.x+s*i*.9,y:t.center.y+a*i*.9}),n).overlays}export function buildView(t,e,n={},i){const s=n.reticles??[],{plotMode:a="value",showDieLabels:o=!1,showReticle:r=!1,showProbePath:h=!1,ringCount:p,showRingBoundaries:x=!1,showQuadrantBoundaries:$=!1,showXYIndicator:V=!1,binColorScheme:I="default",valueColorScheme:b="default",reverseValueScheme:B=!1,useDefinedBinColors:u=!0,binColors:c,passBins:m,highlightBin:S,highlightMetadataValue:d,interactiveTransform:g,valueRange:D,metadataValueOrder:E,testDefs:y,activeTest:A=0,activeMetadataKey:M,fallbackFormat:P="engineering",aggregationMethod:w,lotSize:tt,dataAxisFlip:q,isLotStack:dt=!1,logScale:Jt,colorbarRangeMode:Zt="spec",passFailDisplay:te}=n,Tt=te??"off",ht=i?.hbinDefs,mt=i?.sbinDefs,Dt=i?.metadataFields,ee=Dt?.find(l=>l.key===M),ne={x:(q?.x??!1)!==(g?.flipX??!1),y:(q?.y??!1)!==(g?.flipY??!1)},ae=ht?new Map(ht.map(l=>[l.bin,l])):null,ie=mt?new Map(mt.map(l=>[l.bin,l])):null,se=a==="softBin"?ie:ae,Vt=ye({passBins:m},"buildView"),oe=new Set(Vt),pt=c&&Pe(c,e)?c:Re(e,{passBins:Vt,binColorScheme:I,hbinDefs:ht,sbinDefs:mt,useDefinedBinColors:u}),re=a==="softBin"?pt.soft:pt.hard,Ct={forValue:Ye(Le(b,B)),forBin:l=>re.get(l)??z};let{testNumber:_}=resolveTestNumber(A,y);if(!y?.length&&a==="value"){const l=qt(e,"values");!l.includes(_)&&l.length&&(_=l[0])}let et;if(Array.isArray(D))et=D;else if(D){const{testNumber:l}=resolveTestNumber(D.test,y);et=l===_?D.range:void 0}const T=findTestDef(y,_),Ft=a==="value"&&T!==void 0&&!Bt(T),le=T!==void 0&&(T.limitLow!==void 0||T.limitHigh!==void 0);let H="off";a==="value"&&(Ft?H="test":Tt==="spec"&&le?H="spec":Tt==="test"&&e.some(l=>J(l,_,T)!==void 0)&&(H="test"));const Lt=H==="spec"?"spec":Zt,gt=a==="stackedValues"||a==="stackedBins"||a==="stackedSoftBins";let N,O,nt=!1;if(et){[N,O]=et;let l=!0,f=!1;for(const v of e){const F=gt?L(v,0):L(v,_);if(F!==void 0&&(f=!0,!Number.isInteger(F))){l=!1;break}}nt=f&&l}else{const l=!gt&&a==="value"&&Lt==="spec"&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0);let f=1/0,v=-1/0,F=!0;for(const k of e){const W=gt?L(k,0):L(k,_);W!==void 0&&(W<f&&(f=W),W>v&&(v=W),Number.isInteger(W)||(F=!1))}isFinite(f)||(F=!1),nt=F,l?(N=T.limitLow!==void 0?T.limitLow:isFinite(f)?f:0,O=T.limitHigh!==void 0?T.limitHigh:isFinite(v)?v:1):(N=isFinite(f)?f:0,O=isFinite(v)?v:1)}N===O&&(O=N+1);const Rt=Ft?!1:Jt??T?.logScale??!1,Pt=Rt&&N>0&&O>0,ce=Pt;let at;if(Pt){const l=Math.log10(N),f=Math.log10(O)-l;at=v=>v<=0?0:jt((Math.log10(v)-l)/f)}else at=l=>jt((l-N)/(O-N));const C=je(t,q,g);let Nt=null;if(t.notch){const l=Qt(t.notch.type),f=Ve(C.physicalToScreen,Math.cos(l)*t.radius,Math.sin(l)*t.radius),v=Math.hypot(f.x,f.y);v>0&&(Nt={x:f.x/v,y:f.y/v})}let j=1/0;for(let l=0;l<e.length;l++){const f=e[l];f.width<j&&(j=f.width),f.height<j&&(j=f.height)}const Et=1,At=j!==1/0?Math.min(Et,j*.12):Et,_t=[],yt=[],ue=C.bakedToScreen.a===1&&C.bakedToScreen.b===0&&C.bakedToScreen.c===0&&C.bakedToScreen.d===1&&C.bakedToScreen.e===0&&C.bakedToScreen.f===0;let K=null;if(!ue){K=new Float64Array(e.length*2);for(let l=0;l<e.length;l++){const f=U(C.bakedToScreen,e[l].physX,e[l].physY);K[l*2]=f.x,K[l*2+1]=f.y}}const fe=Ce(C.gridToScreen),de=a==="hardBin"||a==="softBin"||a==="stackedBins"||a==="stackedSoftBins",he=a==="softBin"||a==="stackedSoftBins";let it=de?new Map:void 0;const bt=a==="value"&&H==="spec"?{pass:0,failHigh:0,failLow:0}:void 0,xt=a==="value"&&H==="test"?{pass:0,fail:0}:void 0,Ot=a==="metadata";let st=Ot?new Map:void 0,ot=null;if(Ot&&M){const l=collectMetadataValues(e,M),f=E?.key===M?E.values:void 0,v=f?[...f,...l.filter(F=>!f.includes(F))]:l;ot=new Map(v.map((F,k)=>[F,ee?.values?.find(W=>W.value===F)?.color??_e(k)]))}const me=S===void 0?void 0:new Set(zt(S)),pe=d===void 0?void 0:new Set(zt(d));for(let l=0;l<e.length;l++){const f=e[l],v=K?K[l*2]:f.physX,F=K?K[l*2+1]:f.physY;if(yt.push({x:v,y:F}),it&&Q(f)){const k=he?f.sbin:f.hbin;k!=null&&it.set(k,(it.get(k)??0)+1)}if(bt&&Q(f)){const k=lt(L(f,_),T);k&&bt[k]++}if(xt&&Q(f)){const k=J(f,_,T);k!==void 0&&xt[k?"pass":"fail"]++}if(st&&Q(f)){const k=ft(f,M);k!==void 0&&st.set(k,(st.get(k)??0)+1)}nn(_t,f,v,F,a,fe,At,Ct,me,at,_,se,oe,T,H,M,ot,pe)}const Ht=o?generateTextOverlay(e,K,{plotMode:a,colorFns:Ct,normalize:at,activeTest:A,valueRange:[N,O],testDefs:y,fallbackFormat:P,passFailDisplay:H,activeMetadataKey:M,metadataColorMap:ot,allIntegerValues:nt}):[],G=Qe(t,C.physicalToScreen);x&&G.push(...Je(t,C.physicalToScreen,be({ringCount:p},"buildView"))),$&&G.push(...Ze(t,C.physicalToScreen,t.center.x,t.center.y)),r&&G.push(...tn(s,C.gridToScreen)),h&&G.push(...en(e)),V&&G.push(...an(t,C.gridToScreen,Ht));const ge=yt.length>0?{minX:t.center.x-t.radius,maxX:t.center.x+t.radius,minY:t.center.y-t.radius,maxY:t.center.y+t.radius}:null,wt={rectangles:_t,dieGap:At,hoverPoints:yt,texts:Ht,overlays:G,plotMode:a,binColorScheme:I,valueColorScheme:b,reverseValueScheme:B,binColors:pt,metadata:t.metadata??null,dies:e,valueRange:[N,O],allIntegerValues:nt,testDefs:y,activeTest:A,logScale:ce,logScaleRequested:Rt,aggrMethod:w,lotSize:tt,axisFlip:ne,dataAxisFlip:{x:q?.x??!1,y:q?.y??!1},gridToScreen:C.gridToScreen,rotation:((t.orientation+(g?.rotation??0))%360+360)%360,hasReticle:s.length>0,isLotStack:dt,passFailDisplay:H,colorbarRangeMode:Lt,waferCenter:t.center,waferRadius:t.radius,notchDir:Nt,binCounts:it,metadataCounts:st,metadataColorMap:ot,activeMetadataKey:M,metadataFields:Dt,specCounts:bt,passFailCounts:xt,dieBounds:ge};return n.compact?Ee(wt,n.compact,{showXYIndicator:V}):wt}export{getDieKey}from"../core/dies.js";
1
+ import{requirePassBins as ye}from"../core/passBins.js";import{requireRingCount as be}from"../core/ringCount.js";import{hasPosition as xe}from"../core/dies.js";import{dieValueEntries as Me,dieVerdictEntries as Se,excludedBy as ve,excludedValue as Be,recordedVerdict as $e,testsPresent as Kt}from"../core/dieTable.js";import{limitSetName as ke}from"./valueFilter.js";import{getReticleCell as Ie}from"../core/reticle.js";import{metadataCategoricalValue as Te,metadataDisplayValue as De}from"../core/metadata.js";import{affineRotation as Mt,affineMirror as Wt,affineCompose as rt,affinePoint as U,affineVector as Ve,affineSwapsAxes as Ce}from"../core/transforms.js";import{contrastTextColor as X,SPEC_PASS_FILL as St,SPEC_FAIL_LOW as Fe,SPEC_FAIL_HIGH as vt}from"./colorMap.js";import{resolveValueColorFn as Le}from"./colorSchemes.js";import{resolveBinColors as Re,binColorsCover as Pe}from"./binColors.js";import{NO_DATA_FILL as z}from"./colorMap.js";import{diePassStatus as Ne,isYieldEligibleDie as Q}from"../core/dies.js";import{compactView as Ee}from"./compactView.js";import{buildXYIndicator as Ae}from"./xyIndicator.js";import{getDieTestValue as L,getTestPassStatus as J,isParametricTest as Bt}from"./buildWaferMap.js";import{classifySpec as lt}from"./spec.js";export{lt as classifySpec};import{fmt as ct,fmtColorbarAxis as $t,fmtAggregationMethod as kt}from"./fmt.js";import{metadataValueColor as _e}from"./colorMap.js";import{asList as zt,clamp01 as jt,compareNatural as Oe,escHtml as R}from"../core/utils.js";import{prettyKey as Gt}from"../core/utils.js";import{testLabel as ut,markedTestLabel as Z,derivedTestNote as Yt,isDerivedTest as He,DERIVED_MARK as we,DERIVED_KEY as qe}from"./testLabel.js";export function resolveTestNumber(t,e){return e?.length?{testNumber:(findTestDef(e,t)??e[0]).testNumber}:{testNumber:t}}export function collectMetadataValues(t,e){const n=new Set;for(const i of t){if(!Q(i))continue;const s=ft(i,e);s!==void 0&&n.add(s)}return[...n].sort(Oe)}export function findTestDef(t,e){return t?.find(n=>n.testNumber===e)}export function getUniqueTestNumbers(t){return Kt(t,"values")}const Ke="#d3d6db",Ut="#e8e9ea",We="#d9dcdf",ze="#aab0ba";function ft(t,e){return e?Te(t.metadata?.[e]):void 0}function je(t,e,n){const{x:i,y:s}=t.center,a=Mt(t.orientation,i,s),o=rt(Wt(e?.x??!1,e?.y??!1,i,s),Mt(t.orientation,i,s)),r=rt(Wt(n?.flipX??!1,n?.flipY??!1,i,s),Mt(n?.rotation??0,i,s));return{bakedToScreen:r,physicalToScreen:rt(r,a),gridToScreen:rt(r,o)}}function Y(t,e=!1){return{points:[t],closed:e}}function Ge(t,e){const{center:n,radius:i,notch:s}=t;let a=n.x+i*Math.cos(e),o=n.y+i*Math.sin(e);if(!s)return{x:a,y:o};const r=Math.sqrt(i**2-(s.length/2)**2),h=s.length/2,p=a-n.x,x=o-n.y;return s.type==="bottom"&&x<-r?(o=n.y-r,a=n.x+Math.max(-h,Math.min(h,p))):s.type==="top"&&x>r?(o=n.y+r,a=n.x+Math.max(-h,Math.min(h,p))):s.type==="left"&&p<-r?(a=n.x-r,o=n.y+Math.max(-h,Math.min(h,x))):s.type==="right"&&p>r&&(a=n.x+r,o=n.y+Math.max(-h,Math.min(h,x))),{x:a,y:o}}function Xt(t,e){return t.map(e).join(" / ")}function Ye(t,e=256){const n=Array.from({length:e},(i,s)=>t(s/(e-1)));return i=>n[Math.min(e-1,Math.max(0,Math.round(i*(e-1))))]}function Ue(t,e){const n=Math.max(1,Math.min(t.width,t.height)),i=t.width/Math.max(e.length,1);return Math.max(8,Math.min(16,Math.round(Math.min(n*.55,i*1.8))))}function Xe(t,e,n){if(e?.length){const a=e.flatMap(o=>{const r=o.testNumber;if(!Bt(o)){const p=J(t,r,o);return p===void 0?[]:[{key:r,label:Z(o,r),value:p?"Pass":"Fail"}]}const h=L(t,r);if(h===void 0){const p=Be(t,r);return p===void 0?[]:[{key:r,label:Z(o,r),value:ct(p,o.unit,n),excludedBy:ve(t)}]}return[{key:r,label:Z(o,r),value:ct(h,o.unit,n),recordedFail:$e(t,r)===!1}]});if(a.length)return a}const i=Me(t);if(i.length)return i.map(([a,o])=>({key:a,label:ut(void 0,a),value:ct(o,void 0,n)}));const s=Se(t);return s.length?s.map(([a,o])=>({key:a,label:ut(void 0,a),value:o?"Pass":"Fail"})):[]}export function buildHoverText(t,e,n={}){const{testDefs:i,hbinDefs:s,sbinDefs:a,fallbackFormat:o,aggrMethod:r,lotSize:h,activeTest:p,reticleConfig:x,metadataFields:$}=n,V=s?new Map(s.map(u=>[u.bin,u])):null,I=a?new Map(a.map(u=>[u.bin,u])):null,b=[R(`Die (${t.x}, ${t.y})`)];if(x&&xe(t)){const u=Ie(t,x);b.push(R(`Reticle (${u.column}, ${u.row})`))}if(e==="stackedValues"){const u=L(t,0);if(u!==void 0){const c=i?.[0],m=c?Z(c,c.testNumber):"Value",S=r?` (${kt(r)})`:"";b.push(R(`${m}${S}: ${ct(u,c?.unit,o)}`));const d=Yt(c);d&&b.push(`<i>${R(d)}</i>`)}}else if(e==="stackedBins"||e==="stackedSoftBins"){const u=L(t,0),c=e==="stackedSoftBins"?t.sbin:t.hbin;if(u!==void 0){const m=e==="stackedSoftBins"?I:V,S=c!==void 0?m?.get(c)?.name?`${c} \xB7 ${m.get(c).name}`:`Bin ${c}`:"Bin";let d;if(r==="percent")d=`${u.toFixed(0)}%`;else{const D=h?` (${(u/h*100).toFixed(0)}% of stacked wafers)`:"";d=`${u}${D}`}const g=r?` [${kt(r)}]`:"";b.push(R(`${S}: ${d}${g}`))}}else{const u=Xe(t,i,o);if(e==="value"&&u.length){const{testNumber:c}=resolveTestNumber(p??0,i),m=findTestDef(i,c),S=L(t,c);let d=u.findIndex(A=>A.key===c);d<0&&(d=0);const g=u[d];let D=`<b>${R(`${g.label}: ${g.value}`)}${g.recordedFail?" <i>(recorded fail)</i>":""}</b>`;if(g.key===c&&m){const A=lt(S,m);(A==="failLow"||A==="failHigh")&&(D+=" <i>(outside test limits)</i>")}g.excludedBy&&(D+=` <i>(outside ${ke(g.excludedBy)}, excluded)</i>`),b.push(D);const E=Yt(findTestDef(i,g.key));E&&b.push(`<i>${R(E)}</i>`);const y=u.length-1;y>0&&b.push(`<i>+${y} more test${y===1?"":"s"}</i>`)}else if(u.length){const c=u.length;b.push(`<i>${c} test result${c===1?"":"s"} recorded</i>`)}if(t.hbin!==void 0||t.sbin!==void 0){const c=[];if(t.hbin!==void 0){const m=V?.get(t.hbin)?.name,S=m?`${t.hbin} \xB7 ${m}`:String(t.hbin);c.push(`HBin: ${S}`)}if(t.sbin!==void 0){const m=I?.get(t.sbin)?.name,S=m?`${t.sbin} \xB7 ${m}`:String(t.sbin);c.push(`SBin: ${S}`)}b.push(c.map(R).join(" &nbsp;\xB7&nbsp; "))}}t.retestCount!==void 0&&b.push(R(`Retests: ${t.retestCount}`)),t.siteNum!==void 0&&b.push(R(`Site: ${t.siteNum}`)),t.partId!==void 0&&b.push(R(`Part ID: ${t.partId}`)),t.partial&&b.push("<i>partial die</i>"),t.probeIndex!==void 0&&b.push(R(`Probe: #${t.probeIndex}`));const B={...t.metadata??{}};for(const[u,c]of Object.entries(B)){const m=De(c);if(m===void 0)continue;const S=$?.find(d=>d.key===u)?.label??Gt(u);b.push(R(`${S}: ${m}`))}return b.join("<br>")}function It(t){return t?.name?Z(t,t.testNumber):void 0}function Tt(t){return He(t)?{note:`${we} ${qe}`}:{}}export function buildMapTitle(t,e="engineering",n){const i=t.isLotStack&&t.lotSize!==void 0?`stacked (${t.lotSize} ${t.lotSize===1?"wafer":"wafers"})`:"stacked",s=a=>{const o=n?.length===1?n[0]:void 0;return o===void 0?`${a} Bin`:o.name?`${a} Bin ${o.bin} \xB7 ${o.name}`:`${a} Bin ${o.bin}`};switch(t.plotMode){case"hardBin":return{primary:"Hard Bin",secondary:""};case"softBin":return{primary:"Soft Bin",secondary:""};case"stackedBins":return{primary:s("Hard"),secondary:i};case"stackedSoftBins":return{primary:s("Soft"),secondary:i};case"metadata":{const a=t.metadataFields?.find(r=>r.key===t.activeMetadataKey),o=t.activeMetadataKey?Gt(t.activeMetadataKey):"Metadata";return{primary:a?.label??o,secondary:""}}case"stackedValues":{const a=t.testDefs?.[0],o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=$t(o,It(a),a?.unit,e),h=r||"Value",p=t.aggrMethod?` \xB7 ${kt(t.aggrMethod)}`:"";return{primary:`${h}${p}`,secondary:i,...Tt(a)}}default:{const a=findTestDef(t.testDefs,t.activeTest),o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=$t(o,It(a),a?.unit,e),h=r||It(a);if(t.passFailDisplay!=="off"){const p=a?.testNumber??t.activeTest,x=h?`${h} \xB7 #${p}`:ut(void 0,p),$=t.passFailDisplay==="spec"?"Limit pass/fail":a!==void 0&&!Bt(a)?"Functional pass/fail":"Tester pass/fail";return{primary:x,secondary:$,...Tt(a)}}return{primary:h??ut(void 0,t.activeTest),secondary:"",...Tt(a)}}}}export function generateTextOverlay(t,e,n){const{plotMode:i,colorFns:s,normalize:a,activeTest:o,valueRange:r,testDefs:h,fallbackFormat:p,passFailDisplay:x="off",activeMetadataKey:$,metadataColorMap:V,allIntegerValues:I}=n,b=findTestDef(h,o),{tickFmt:B}=$t(r[1],b?.name,b?.unit,p),u=I?m=>String(Math.round(m)):B,{testNumber:c}=resolveTestNumber(o,h);return t.flatMap((m,S)=>{let d="",g="#111111";if(i==="value"&&x==="test"){const y=J(m,c,b);if(y===void 0)return[];d=y?"P":"F",g=X(y?St:vt)}else if(i==="value"){const y=L(m,c);if(y===void 0)return[];d=Xt([y],u),g=X(s.forValue(a(y)))}else if(i==="hardBin"||i==="softBin"){const y=i==="softBin"?m.sbin:m.hbin;if(y===void 0)return[];d=String(y),g=X(s.forBin(y))}else if(i==="metadata"){const y=ft(m,$);if(y===void 0)return[];d=y,g=X(V?.get(d)??z)}else{const y=L(m,0);if(y===void 0)return[];d=Xt([y],u),g=X(s.forValue(a(y)))}const D=e?e[S*2]:m.physX,E=e?e[S*2+1]:m.physY;return[{x:D,y:E,text:d,fontSize:Ue(m,d),color:g,align:"center"}]})}function Qt(t){return t==="top"?Math.PI/2:t==="bottom"?-Math.PI/2:t==="left"?Math.PI:0}function Qe(t,e,n=720){const{center:i,radius:s,notch:a}=t,o=B=>U(e,B.x,B.y);if(!(a!==void 0&&a.length>0&&t.diameter>150)){const B=[];for(let u=0;u<=n;u++){const c=2*Math.PI*u/n;B.push(o(Ge(t,c)))}return[{kind:"wafer-boundary",...Y(B,!0),lineColor:"#888888",lineWidth:1}]}const h=1.25,p=a.length,x=Qt(a.type),$=Math.atan2(p,s),V=s-h,I=[];let b=!1;for(let B=0;B<=n;B++){const u=2*Math.PI*B/n;let c=u-x;for(;c>Math.PI;)c-=2*Math.PI;for(;c<-Math.PI;)c+=2*Math.PI;if(Math.abs(c)<=$){if(!b){b=!0;const m={x:i.x+s*Math.cos(x-$),y:i.y+s*Math.sin(x-$)},S={x:i.x+V*Math.cos(x),y:i.y+V*Math.sin(x)},d={x:i.x+s*Math.cos(x+$),y:i.y+s*Math.sin(x+$)};I.push(o(m),o(S),o(d))}continue}I.push(o({x:i.x+s*Math.cos(u),y:i.y+s*Math.sin(u)}))}return[{kind:"wafer-boundary",...Y(I,!0),lineColor:"#888888",lineWidth:1}]}function Je(t,e,n,i=360){const s=[],a=Math.max(1,Math.floor(n));for(let o=1;o<a;o++){const r=t.radius*o/a,h=[];for(let p=0;p<=i;p++){const x=2*Math.PI*p/i,$={x:t.center.x+r*Math.cos(x),y:t.center.y+r*Math.sin(x)};h.push(U(e,$.x,$.y))}s.push({kind:"ring-boundary",...Y(h,!0),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5})}return s}function Ze(t,e,n,i){const{x:s,y:a}=t.center,o=t.radius,r=(u,c)=>U(e,u,c),h=n-s,p=Math.sqrt(Math.max(0,o*o-h*h)),x=r(n,a-p),$=r(n,a+p),V=i-a,I=Math.sqrt(Math.max(0,o*o-V*V)),b=r(s-I,i),B=r(s+I,i);return[{kind:"quadrant-boundary",...Y([x,$]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5},{kind:"quadrant-boundary",...Y([b,B]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5}]}function tn(t,e){return t.map(n=>{const i=n.width/2,s=n.height/2;return{kind:"reticle",points:[[[n.x-i,n.y-s],[n.x+i,n.y-s],[n.x+i,n.y+s],[n.x-i,n.y+s]].map(([o,r])=>U(e,o,r))],closed:!0,lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5,fill:"rgba(0,0,0,0)"}})}function en(t){const e=t.filter(n=>n.probeIndex!==void 0).sort((n,i)=>(n.probeIndex??0)-(i.probeIndex??0));return e.length?[{kind:"probe-path",...Y(e.map(n=>({x:n.physX,y:n.physY}))),lineColor:"rgba(220,80,0,0.55)",lineWidth:1}]:[]}function nn(t,e,n,i,s,a,o,r,h,p,x,$,V,I,b="off",B,u,c){const m=e.width-o,S=e.height-o,d=a?S:m,g=a?m:S,D=M=>s==="softBin"?M.sbin:M.hbin,E=M=>ft(M,B);if(e.partial){t.push({x:n,y:i,width:d,height:g,fill:Ke,type:"stacked",metadata:e.metadata});return}if(e.filteredOut){t.push({x:n,y:i,width:d,height:g,fill:We,type:"stacked",metadata:e.metadata});return}if(e.edgeExcluded){t.push({x:n,y:i,width:d,height:g,fill:ze,type:"stacked",metadata:e.metadata});return}if(h!==void 0&&(s==="hardBin"||s==="softBin")&&!h.has(D(e))){t.push({x:n,y:i,width:d,height:g,fill:Ut,type:"hardBin",metadata:e.metadata});return}if(c!==void 0&&s==="metadata"&&!c.has(E(e))){t.push({x:n,y:i,width:d,height:g,fill:Ut,type:"metadata",metadata:e.metadata});return}if(s==="value"){if(b==="test"){const q=J(e,x,I),dt=q===void 0?z:q?St:vt;t.push({x:n,y:i,width:d,height:g,fill:dt,type:"value",metadata:e.metadata});return}const M=L(e,x),P=lt(M,I);let w,tt;M===void 0?w=z:b==="spec"?w=P==="failLow"?Fe:P==="failHigh"?vt:St:(w=r.forValue(p(M)),(P==="failLow"||P==="failHigh")&&(tt=P)),t.push({x:n,y:i,width:d,height:g,fill:w,type:"value",specMark:tt,metadata:e.metadata});return}if(s==="hardBin"||s==="softBin"){const M=D(e),P=M!=null?r.forBin(M):z,w=M!=null&&Ne(e,V)===!1?!0:void 0;t.push({x:n,y:i,width:d,height:g,fill:P,type:s,binFail:w,metadata:e.metadata});return}if(s==="metadata"){const M=E(e),P=M!==void 0?u?.get(M)??z:z;t.push({x:n,y:i,width:d,height:g,fill:P,type:"metadata",metadata:e.metadata});return}const y=L(e,0),A=y!==void 0?r.forValue(p(y)):z;t.push({x:n,y:i,width:d,height:g,fill:A,type:"value",metadata:e.metadata})}function an(t,e,n){const i=t.radius;return Ae(e,i*.15,(s,a)=>({x:t.center.x+s*i*.9,y:t.center.y+a*i*.9}),n).overlays}export function buildView(t,e,n={},i){const s=n.reticles??[],{plotMode:a="value",showDieLabels:o=!1,showReticle:r=!1,showProbePath:h=!1,ringCount:p,showRingBoundaries:x=!1,showQuadrantBoundaries:$=!1,showXYIndicator:V=!1,binColorScheme:I="default",valueColorScheme:b="default",reverseValueScheme:B=!1,useDefinedBinColors:u=!0,binColors:c,passBins:m,highlightBin:S,highlightMetadataValue:d,interactiveTransform:g,valueRange:D,metadataValueOrder:E,testDefs:y,activeTest:A=0,activeMetadataKey:M,fallbackFormat:P="engineering",aggregationMethod:w,lotSize:tt,dataAxisFlip:q,isLotStack:dt=!1,logScale:Jt,colorbarRangeMode:Zt="spec",passFailDisplay:te}=n,Dt=te??"off",ht=i?.hbinDefs,mt=i?.sbinDefs,Vt=i?.metadataFields,ee=Vt?.find(l=>l.key===M),ne={x:(q?.x??!1)!==(g?.flipX??!1),y:(q?.y??!1)!==(g?.flipY??!1)},ae=ht?new Map(ht.map(l=>[l.bin,l])):null,ie=mt?new Map(mt.map(l=>[l.bin,l])):null,se=a==="softBin"?ie:ae,Ct=ye({passBins:m},"buildView"),oe=new Set(Ct),pt=c&&Pe(c,e)?c:Re(e,{passBins:Ct,binColorScheme:I,hbinDefs:ht,sbinDefs:mt,useDefinedBinColors:u}),re=a==="softBin"?pt.soft:pt.hard,Ft={forValue:Ye(Le(b,B)),forBin:l=>re.get(l)??z};let{testNumber:_}=resolveTestNumber(A,y);if(!y?.length&&a==="value"){const l=Kt(e,"values");!l.includes(_)&&l.length&&(_=l[0])}let et;if(Array.isArray(D))et=D;else if(D){const{testNumber:l}=resolveTestNumber(D.test,y);et=l===_?D.range:void 0}const T=findTestDef(y,_),Lt=a==="value"&&T!==void 0&&!Bt(T),le=T!==void 0&&(T.limitLow!==void 0||T.limitHigh!==void 0);let H="off";a==="value"&&(Lt?H="test":Dt==="spec"&&le?H="spec":Dt==="test"&&e.some(l=>J(l,_,T)!==void 0)&&(H="test"));const Rt=H==="spec"?"spec":Zt,gt=a==="stackedValues"||a==="stackedBins"||a==="stackedSoftBins";let N,O,nt=!1;if(et){[N,O]=et;let l=!0,f=!1;for(const v of e){const F=gt?L(v,0):L(v,_);if(F!==void 0&&(f=!0,!Number.isInteger(F))){l=!1;break}}nt=f&&l}else{const l=!gt&&a==="value"&&Rt==="spec"&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0);let f=1/0,v=-1/0,F=!0;for(const k of e){const W=gt?L(k,0):L(k,_);W!==void 0&&(W<f&&(f=W),W>v&&(v=W),Number.isInteger(W)||(F=!1))}isFinite(f)||(F=!1),nt=F,l?(N=T.limitLow!==void 0?T.limitLow:isFinite(f)?f:0,O=T.limitHigh!==void 0?T.limitHigh:isFinite(v)?v:1):(N=isFinite(f)?f:0,O=isFinite(v)?v:1)}N===O&&(O=N+1);const Pt=Lt?!1:Jt??T?.logScale??!1,Nt=Pt&&N>0&&O>0,ce=Nt;let at;if(Nt){const l=Math.log10(N),f=Math.log10(O)-l;at=v=>v<=0?0:jt((Math.log10(v)-l)/f)}else at=l=>jt((l-N)/(O-N));const C=je(t,q,g);let Et=null;if(t.notch){const l=Qt(t.notch.type),f=Ve(C.physicalToScreen,Math.cos(l)*t.radius,Math.sin(l)*t.radius),v=Math.hypot(f.x,f.y);v>0&&(Et={x:f.x/v,y:f.y/v})}let j=1/0;for(let l=0;l<e.length;l++){const f=e[l];f.width<j&&(j=f.width),f.height<j&&(j=f.height)}const At=1,_t=j!==1/0?Math.min(At,j*.12):At,Ot=[],yt=[],ue=C.bakedToScreen.a===1&&C.bakedToScreen.b===0&&C.bakedToScreen.c===0&&C.bakedToScreen.d===1&&C.bakedToScreen.e===0&&C.bakedToScreen.f===0;let K=null;if(!ue){K=new Float64Array(e.length*2);for(let l=0;l<e.length;l++){const f=U(C.bakedToScreen,e[l].physX,e[l].physY);K[l*2]=f.x,K[l*2+1]=f.y}}const fe=Ce(C.gridToScreen),de=a==="hardBin"||a==="softBin"||a==="stackedBins"||a==="stackedSoftBins",he=a==="softBin"||a==="stackedSoftBins";let it=de?new Map:void 0;const bt=a==="value"&&H==="spec"?{pass:0,failHigh:0,failLow:0}:void 0,xt=a==="value"&&H==="test"?{pass:0,fail:0}:void 0,Ht=a==="metadata";let st=Ht?new Map:void 0,ot=null;if(Ht&&M){const l=collectMetadataValues(e,M),f=E?.key===M?E.values:void 0,v=f?[...f,...l.filter(F=>!f.includes(F))]:l;ot=new Map(v.map((F,k)=>[F,ee?.values?.find(W=>W.value===F)?.color??_e(k)]))}const me=S===void 0?void 0:new Set(zt(S)),pe=d===void 0?void 0:new Set(zt(d));for(let l=0;l<e.length;l++){const f=e[l],v=K?K[l*2]:f.physX,F=K?K[l*2+1]:f.physY;if(yt.push({x:v,y:F}),it&&Q(f)){const k=he?f.sbin:f.hbin;k!=null&&it.set(k,(it.get(k)??0)+1)}if(bt&&Q(f)){const k=lt(L(f,_),T);k&&bt[k]++}if(xt&&Q(f)){const k=J(f,_,T);k!==void 0&&xt[k?"pass":"fail"]++}if(st&&Q(f)){const k=ft(f,M);k!==void 0&&st.set(k,(st.get(k)??0)+1)}nn(Ot,f,v,F,a,fe,_t,Ft,me,at,_,se,oe,T,H,M,ot,pe)}const wt=o?generateTextOverlay(e,K,{plotMode:a,colorFns:Ft,normalize:at,activeTest:A,valueRange:[N,O],testDefs:y,fallbackFormat:P,passFailDisplay:H,activeMetadataKey:M,metadataColorMap:ot,allIntegerValues:nt}):[],G=Qe(t,C.physicalToScreen);x&&G.push(...Je(t,C.physicalToScreen,be({ringCount:p},"buildView"))),$&&G.push(...Ze(t,C.physicalToScreen,t.center.x,t.center.y)),r&&G.push(...tn(s,C.gridToScreen)),h&&G.push(...en(e)),V&&G.push(...an(t,C.gridToScreen,wt));const ge=yt.length>0?{minX:t.center.x-t.radius,maxX:t.center.x+t.radius,minY:t.center.y-t.radius,maxY:t.center.y+t.radius}:null,qt={rectangles:Ot,dieGap:_t,hoverPoints:yt,texts:wt,overlays:G,plotMode:a,binColorScheme:I,valueColorScheme:b,reverseValueScheme:B,binColors:pt,metadata:t.metadata??null,dies:e,valueRange:[N,O],allIntegerValues:nt,testDefs:y,activeTest:A,logScale:ce,logScaleRequested:Pt,aggrMethod:w,lotSize:tt,axisFlip:ne,dataAxisFlip:{x:q?.x??!1,y:q?.y??!1},gridToScreen:C.gridToScreen,rotation:((t.orientation+(g?.rotation??0))%360+360)%360,hasReticle:s.length>0,isLotStack:dt,passFailDisplay:H,colorbarRangeMode:Rt,waferCenter:t.center,waferRadius:t.radius,notchDir:Et,binCounts:it,metadataCounts:st,metadataColorMap:ot,activeMetadataKey:M,metadataFields:Vt,specCounts:bt,passFailCounts:xt,dieBounds:ge};return n.compact?Ee(qt,n.compact,{showXYIndicator:V}):qt}export{getDieKey}from"../core/dies.js";
@@ -16,6 +16,8 @@ export declare function nameStatesUnit(name: string | null | undefined, unit: st
16
16
  export declare const AGGREGATION_METHOD_LABELS: Record<string, string>;
17
17
  /** Format an aggregation method for display, falling back to the raw key or "aggregated". */
18
18
  export declare function fmtAggregationMethod(method: string | undefined): string;
19
+ /** A lot stack as the header and the Summary panel name it: "25 wafers stacked · occurrence count". */
20
+ export declare function fmtStackedLabel(lotSize: number, method: string | undefined): string;
19
21
  /**
20
22
  * Map internal bin terms to plain language for display — "HBin 2" →
21
23
  * "hard bin 2" (CLAUDE.md: internal API terms must never appear in the UI).
@@ -1 +1 @@
1
- import{stepDecimals as m}from"./axisTicks.js";const M=[[1e12,"T"],[1e9,"G"],[1e6,"M"],[1e3,"k"],[1,""],[.001,"m"],[1e-6,"\xB5"],[1e-9,"n"],[1e-12,"p"],[1e-15,"f"]];export const SI_PREFIX_SCALE={T:1e12,G:1e9,M:1e6,k:1e3,m:.001,\u00B5:1e-6,u:1e-6,n:1e-9,p:1e-12,f:1e-15},KNOWN_BASE_UNITS=["Hz","V","A","W","F","\u03A9","Ohm","ohm","S","H","J","C","s"];function p(e){for(const t of KNOWN_BASE_UNITS)if(e.length===t.length+1&&e.endsWith(t)){const n=e[0];if(n in SI_PREFIX_SCALE)return{preScale:SI_PREFIX_SCALE[n],base:t}}return{preScale:1,base:e}}export function nameStatesUnit(e,t){if(!e||!t)return!1;let n=e.trimEnd();if((n.endsWith(")")||n.endsWith("]"))&&(n=n.slice(0,-1)),!n.endsWith(t))return!1;const r=n.length===t.length?"":n[n.length-t.length-1];return r===""||/[\s_\-/([]/.test(r)}function S(e,t){const{preScale:n,base:r}=p(t),i=e*n,o=Math.abs(i),[c,u]=M.find(([s])=>o>=s*.9999)??[1e-15,"f"],h=i/c,g=Math.abs(h),a=g>=100?0:g>=10?1:2;return`${h.toFixed(a)} ${u}${r}`}function E(e){const t=Math.abs(e);if(t===0)return"0%";const n=t>=100?0:t>=10?1:t>=1?2:Math.min(6,1-Math.floor(Math.log10(t)));return`${e.toFixed(n)}%`}function A(e){const t=Math.abs(e),n=Math.floor(Math.log10(t)/3)*3,r=Math.max(-15,Math.min(12,n)),i=e/Math.pow(10,r),o=Math.abs(i),c=o>=100?0:o>=10?1:2,u=r===0?"":`E${r>0?"+":""}${r}`;return`${i.toFixed(c)}${u}`}export const AGGREGATION_METHOD_LABELS={mean:"mean",median:"median",stddev:"std dev",min:"min",max:"max",count:"count",countBin:"occurrence count",percent:"occurrence %"};export function fmtAggregationMethod(e){return AGGREGATION_METHOD_LABELS[e??""]??e??"aggregated"}export function plainBinTerms(e){return e.replace(/\bHBin\b/g,"hard bin").replace(/\bSBin\b/g,"soft bin")}export function fmtExact(e){if(!Number.isFinite(e)||Math.fround(e)!==e)return String(e);for(let t=1;t<=9;t++){const n=Number(e.toPrecision(t));if(Math.fround(n)===e)return String(n)}return String(e)}export function fmt(e,t,n){if(!isFinite(e))return String(e);if(t==="%")return E(e);const r=Math.abs(e);return r===0?t?`0 ${t}`:"0":t!==void 0?S(e,t):n==="si"?S(e,""):r>=.1&&r<1e4?r>=1e3?e.toFixed(0):r>=100?e.toFixed(1):r>=10?e.toFixed(2):e.toFixed(3):A(e)}function T(e,t){const n=t!==void 0&&t>0?m(t/e):void 0;return r=>{if(!isFinite(r))return String(r);if(r===0)return"0";const i=r/e;if(n!==void 0)return i.toFixed(n);const o=Math.abs(i),c=o>=100?0:o>=10?1:2;return i.toFixed(c)}}function _(e,t,n){if(t===void 0||!(t>0))return n;const r=m(t/e)+1;return i=>{if(!isFinite(i))return String(i);if(i===0)return"0";const o=(i/e).toFixed(r);return o.endsWith("0")?o.slice(0,r===1?-2:-1):o}}const I={"-":"\u207B",0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"},F=e=>e===0?"":`\xD710${[...String(e)].map(t=>I[t]).join("")}`;export function fmtColorbarAxis(e,t,n,r="engineering",i){const o=Math.abs(e),c=(s,l,f,d)=>{const x=d&&i===void 0?d:T(s,i);return{tickFmt:x,edgeFmt:_(s,i,x),axisLabel:l,scaledUnit:f}};if(n==="%")return c(1,t?`${t} (%)`:"%","%");if(n&&nameStatesUnit(t,n)){const s=o===0||o>=.1&&o<1e4;return p(n).preScale!==1||s?c(1,t,n):fmtColorbarAxis(e,t,void 0,r,i)}if(n){const{preScale:s,base:l}=p(n),f=o*s,[d,x]=f===0?[1,""]:M.find(([$])=>f>=$*.9999)??[1e-15,"f"],b=`${x}${l}`;return c(d/s,t?`${t} (${b})`:b,b)}if(o===0||o>=.1&&o<1e4)return c(1,t??"","",s=>fmt(s,void 0,r));if(r==="si"){const[s]=M.find(([d])=>o>=d*.9999)??[1e-15,"f"],l=Math.round(Math.log10(s)),f=F(l);return c(s,t?f?`${t} (${f})`:t:f,f)}const u=Math.floor(Math.log10(o)/3)*3,h=Math.max(-15,Math.min(12,u)),g=Math.pow(10,h),a=F(h);return c(g,t?a?`${t} (${a})`:t:a,a)}
1
+ import{stepDecimals as m}from"./axisTicks.js";const p=[[1e12,"T"],[1e9,"G"],[1e6,"M"],[1e3,"k"],[1,""],[.001,"m"],[1e-6,"\xB5"],[1e-9,"n"],[1e-12,"p"],[1e-15,"f"]];export const SI_PREFIX_SCALE={T:1e12,G:1e9,M:1e6,k:1e3,m:.001,\u00B5:1e-6,u:1e-6,n:1e-9,p:1e-12,f:1e-15},KNOWN_BASE_UNITS=["Hz","V","A","W","F","\u03A9","Ohm","ohm","S","H","J","C","s"];function M(e){for(const t of KNOWN_BASE_UNITS)if(e.length===t.length+1&&e.endsWith(t)){const n=e[0];if(n in SI_PREFIX_SCALE)return{preScale:SI_PREFIX_SCALE[n],base:t}}return{preScale:1,base:e}}export function nameStatesUnit(e,t){if(!e||!t)return!1;let n=e.trimEnd();if((n.endsWith(")")||n.endsWith("]"))&&(n=n.slice(0,-1)),!n.endsWith(t))return!1;const r=n.length===t.length?"":n[n.length-t.length-1];return r===""||/[\s_\-/([]/.test(r)}function S(e,t){const{preScale:n,base:r}=M(t),i=e*n,o=Math.abs(i),[c,u]=p.find(([s])=>o>=s*.9999)??[1e-15,"f"],h=i/c,x=Math.abs(h),f=x>=100?0:x>=10?1:2;return`${h.toFixed(f)} ${u}${r}`}function E(e){const t=Math.abs(e);if(t===0)return"0%";const n=t>=100?0:t>=10?1:t>=1?2:Math.min(6,1-Math.floor(Math.log10(t)));return`${e.toFixed(n)}%`}function A(e){const t=Math.abs(e),n=Math.floor(Math.log10(t)/3)*3,r=Math.max(-15,Math.min(12,n)),i=e/Math.pow(10,r),o=Math.abs(i),c=o>=100?0:o>=10?1:2,u=r===0?"":`E${r>0?"+":""}${r}`;return`${i.toFixed(c)}${u}`}export const AGGREGATION_METHOD_LABELS={mean:"mean",median:"median",stddev:"std dev",min:"min",max:"max",count:"count",countBin:"occurrence count",percent:"occurrence %"};export function fmtAggregationMethod(e){return AGGREGATION_METHOD_LABELS[e??""]??e??"aggregated"}export function fmtStackedLabel(e,t){return t?`${e} wafers stacked \xB7 ${fmtAggregationMethod(t)}`:`${e} wafers stacked`}export function plainBinTerms(e){return e.replace(/\bHBin\b/g,"hard bin").replace(/\bSBin\b/g,"soft bin")}export function fmtExact(e){if(!Number.isFinite(e)||Math.fround(e)!==e)return String(e);for(let t=1;t<=9;t++){const n=Number(e.toPrecision(t));if(Math.fround(n)===e)return String(n)}return String(e)}export function fmt(e,t,n){if(!isFinite(e))return String(e);if(t==="%")return E(e);const r=Math.abs(e);return r===0?t?`0 ${t}`:"0":t!==void 0?S(e,t):n==="si"?S(e,""):r>=.1&&r<1e4?r>=1e3?e.toFixed(0):r>=100?e.toFixed(1):r>=10?e.toFixed(2):e.toFixed(3):A(e)}function T(e,t){const n=t!==void 0&&t>0?m(t/e):void 0;return r=>{if(!isFinite(r))return String(r);if(r===0)return"0";const i=r/e;if(n!==void 0)return i.toFixed(n);const o=Math.abs(i),c=o>=100?0:o>=10?1:2;return i.toFixed(c)}}function _(e,t,n){if(t===void 0||!(t>0))return n;const r=m(t/e)+1;return i=>{if(!isFinite(i))return String(i);if(i===0)return"0";const o=(i/e).toFixed(r);return o.endsWith("0")?o.slice(0,r===1?-2:-1):o}}const k={"-":"\u207B",0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"},$=e=>e===0?"":`\xD710${[...String(e)].map(t=>k[t]).join("")}`;export function fmtColorbarAxis(e,t,n,r="engineering",i){const o=Math.abs(e),c=(s,l,a,d)=>{const g=d&&i===void 0?d:T(s,i);return{tickFmt:g,edgeFmt:_(s,i,g),axisLabel:l,scaledUnit:a}};if(n==="%")return c(1,t?`${t} (%)`:"%","%");if(n&&nameStatesUnit(t,n)){const s=o===0||o>=.1&&o<1e4;return M(n).preScale!==1||s?c(1,t,n):fmtColorbarAxis(e,t,void 0,r,i)}if(n){const{preScale:s,base:l}=M(n),a=o*s,[d,g]=a===0?[1,""]:p.find(([F])=>a>=F*.9999)??[1e-15,"f"],b=`${g}${l}`;return c(d/s,t?`${t} (${b})`:b,b)}if(o===0||o>=.1&&o<1e4)return c(1,t??"","",s=>fmt(s,void 0,r));if(r==="si"){const[s]=p.find(([d])=>o>=d*.9999)??[1e-15,"f"],l=Math.round(Math.log10(s)),a=$(l);return c(s,t?a?`${t} (${a})`:t:a,a)}const u=Math.floor(Math.log10(o)/3)*3,h=Math.max(-15,Math.min(12,u)),x=Math.pow(10,h),f=$(h);return c(x,t?f?`${t} (${f})`:t:f,f)}
@@ -47,7 +47,7 @@ export interface CommonalityRow {
47
47
  }
48
48
  export interface CommonalityResult {
49
49
  rows: CommonalityRow[];
50
- /** Fields with no two groups of two or more wafers: nothing to compare. */
50
+ /** Fields whose groups cannot be compared: fewer than two groups of two or more wafers, or nearly one group per wafer. */
51
51
  untestable: CommonalityField[];
52
52
  /** The fail bins compared, most dies first. */
53
53
  bins: number[];
@@ -1 +1 @@
1
- import{diePassStatus as _,isYieldEligibleDie as B}from"../core/dies.js";import{benjaminiHochberg as $}from"./math.js";import{compareGroups as I,comparisonP as z}from"./groupCompare.js";import{adjustedFits as D,mergePartitions as H,overlapping as G,partitionId as T}from"./groupEffects.js";import{facetValueOf as V}from"./facets.js";import{yieldCounts as q}from"./yield.js";import{compareNatural as J}from"../core/utils.js";export const COMMONALITY_BINS=5;function K(s,p){let m=0,d=0;for(const l of s.dies)!B(l)||l.hbin===void 0||(d++,l.hbin===p&&m++);return d?m/d*100:NaN}export function rankCommonality(s,p,m){const d=s.map(e=>{const{pass:n,total:o}=q(e.dies,e.passBins);return o?n/o*100:NaN}),l=new Map;for(const e of s){const n=new Set(e.passBins);for(const o of e.dies)B(o)&&o.hbin!==void 0&&_(o,n)===!1&&l.set(o.hbin,(l.get(o.hbin)??0)+1)}const k=[...l].sort((e,n)=>n[1]-e[1]||e[0]-n[0]).slice(0,COMMONALITY_BINS).map(([e])=>e),w=new Map(k.map(e=>[e,s.map(n=>K(n,e))])),t=[],r=[],h=[];for(const e of p){const n=s.map(c=>V(c.metadata,e.key,m)),o=[...new Set(n.filter(c=>c!==void 0))].sort(J);if(o.filter(c=>n.filter(N=>N===c).length>=2).length<2){r.push(e);continue}h.push({field:e,value:n,keys:o})}const u=H(h.map(e=>({key:e.field.key,groupOf:e.value}))),f=new Map(p.map(e=>[e.key,e])),L=[[{kind:"yield"},d],...k.map(e=>[{kind:"bin",bin:e},w.get(e)])];for(const[e,n]of L){const o=new Map(D(n.map(a=>Number.isFinite(a)?a:void 0),u).map(a=>[a.partition.id,a]));for(const{field:a,value:c,keys:N}of h){const F=I(N.map(i=>({key:i,values:n.filter((y,x)=>c[x]===i)}))),j=F.groups.filter(i=>!F.tooSmall.includes(i.key)&&Number.isFinite(i.mean));if(j.length<2)continue;const C=j.reduce((i,y)=>y.mean<i.mean?y:i),O=j.reduce((i,y)=>y.mean>i.mean?y:i),[P,S]=e.kind==="yield"?[C,O]:[O,C],g=o.get(T(c));let b=g?.allowedFor?I(N.map(i=>({key:i,values:g.used.filter((y,x)=>c[x]===i&&y!==void 0)}))):void 0;b?.welch&&g?.fitted&&(b={...b,welch:{...b.welch,p:g.fitted.p}}),t.push({field:a,measure:e,comparison:F,worst:{key:P.key,mean:P.mean},best:{key:S.key,mean:S.mean},spread:O.mean-C.mean,pAdjusted:NaN,...b&&g?.allowedFor?{adjusted:b,allowedFor:g.allowedFor.map(i=>f.get(i)??{key:i,label:i})}:{}})}}const M=e=>z(e.adjusted??e.comparison),v=t.filter(e=>Number.isFinite(M(e))),R=$(v.map(M));v.forEach((e,n)=>{e.pAdjusted=R[n]});const A=e=>Number.isFinite(e.pAdjusted)?e.pAdjusted:1/0;t.sort((e,n)=>A(e)-A(n)||n.spread-e.spread);const Y=u.filter(e=>e.keys.length>1).map(e=>e.keys.map(n=>f.get(n))),E=[];return u.forEach((e,n)=>{for(const o of G(e,u))u.indexOf(o.partition)>n&&E.push({fields:e.keys.map(a=>f.get(a)),with:o.partition.keys.map(a=>f.get(a)),agree:o.agree,of:o.of})}),{rows:t,untestable:r,bins:k,tied:Y,overlapping:E}}export const measureLabel=(s,p)=>s.kind==="yield"?"Yield":`Hard bin ${s.bin}${p?.(s.bin)?` (${p(s.bin)})`:""}`,commonalityConfidence=s=>s<.05?"clear":s<.2?"possible":"none",CONFIDENCE_LABEL={clear:"Clear",possible:"Possible",none:"Not clear"};export function groupCommonalityRows(s,p=[]){const m=new Map;for(const t of s)(m.get(t.field.key)??m.set(t.field.key,[]).get(t.field.key)).push(t);const d=t=>["clear","possible","none"].indexOf(commonalityConfidence(t.pAdjusted)),l=new Map;for(const t of p)for(const r of t)l.set(r.key,t);const k=new Set,w=[];for(const t of m.values()){const r=l.get(t[0].field.key);if(r){if(k.has(r))continue;k.add(r)}const h=t.find(f=>f.measure.kind==="yield"),u=h&&d(h)<=d(t[0])?h:t[0];w.push({field:t[0].field,fields:r?[t[0].field,...r.filter(f=>f.key!==t[0].field.key)]:[t[0].field],primary:u,others:t.filter(f=>f!==u)})}return w.sort((t,r)=>d(t.primary)-d(r.primary)||r.primary.spread-t.primary.spread)}
1
+ import{diePassStatus as _,isYieldEligibleDie as B}from"../core/dies.js";import{benjaminiHochberg as $}from"./math.js";import{compareGroups as I,comparisonP as D}from"./groupCompare.js";import{adjustedFits as G,comparableGrouping as H,mergePartitions as T,overlapping as V,partitionId as q}from"./groupEffects.js";import{facetValueOf as z}from"./facets.js";import{yieldCounts as J}from"./yield.js";import{compareNatural as K}from"../core/utils.js";export const COMMONALITY_BINS=5;function Q(s,f){let c=0,d=0;for(const p of s.dies)!B(p)||p.hbin===void 0||(d++,p.hbin===f&&c++);return d?c/d*100:NaN}export function rankCommonality(s,f,c){const d=s.map(e=>{const{pass:o,total:i}=J(e.dies,e.passBins);return i?o/i*100:NaN}),p=new Map;for(const e of s){const o=new Set(e.passBins);for(const i of e.dies)B(i)&&i.hbin!==void 0&&_(i,o)===!1&&p.set(i.hbin,(p.get(i.hbin)??0)+1)}const k=[...p].sort((e,o)=>o[1]-e[1]||e[0]-o[0]).slice(0,COMMONALITY_BINS).map(([e])=>e),b=new Map(k.map(e=>[e,s.map(o=>Q(o,e))])),t=[],a=[],y=[];for(const e of f){const o=s.map(r=>z(r.metadata,e.key,c)),i=[...new Set(o.filter(r=>r!==void 0))].sort(K);if(!H(o)){a.push(e);continue}y.push({field:e,value:o,keys:i})}const m=T(y.map(e=>({key:e.field.key,groupOf:e.value}))),l=new Map(f.map(e=>[e.key,e])),L=[[{kind:"yield"},d],...k.map(e=>[{kind:"bin",bin:e},b.get(e)])];for(const[e,o]of L){const i=new Map(G(o.map(r=>Number.isFinite(r)?r:void 0),m).map(r=>[r.partition.id,r]));for(const{field:r,value:w,keys:E}of y){const N=I(E.map(n=>({key:n,values:o.filter((u,O)=>w[O]===n)}))),F=N.groups.filter(n=>!N.tooSmall.includes(n.key)&&Number.isFinite(n.mean));if(F.length<2)continue;const j=F.reduce((n,u)=>u.mean<n.mean?u:n),C=F.reduce((n,u)=>u.mean>n.mean?u:n),[P,S]=e.kind==="yield"?[j,C]:[C,j],h=i.get(q(w));let g=h?.allowedFor?I(E.map(n=>({key:n,values:h.used.filter((u,O)=>w[O]===n&&u!==void 0)}))):void 0;g?.welch&&h?.fitted&&(g={...g,welch:{...g.welch,p:h.fitted.p}}),t.push({field:r,measure:e,comparison:N,worst:{key:P.key,mean:P.mean},best:{key:S.key,mean:S.mean},spread:C.mean-j.mean,pAdjusted:NaN,...g&&h?.allowedFor?{adjusted:g,allowedFor:h.allowedFor.map(n=>l.get(n)??{key:n,label:n})}:{}})}}const x=e=>D(e.adjusted??e.comparison),M=t.filter(e=>Number.isFinite(x(e))),R=$(M.map(x));M.forEach((e,o)=>{e.pAdjusted=R[o]});const v=e=>Number.isFinite(e.pAdjusted)?e.pAdjusted:1/0;t.sort((e,o)=>v(e)-v(o)||o.spread-e.spread);const Y=m.filter(e=>e.keys.length>1).map(e=>e.keys.map(o=>l.get(o))),A=[];return m.forEach((e,o)=>{for(const i of V(e,m))m.indexOf(i.partition)>o&&A.push({fields:e.keys.map(r=>l.get(r)),with:i.partition.keys.map(r=>l.get(r)),agree:i.agree,of:i.of})}),{rows:t,untestable:a,bins:k,tied:Y,overlapping:A}}export const measureLabel=(s,f)=>s.kind==="yield"?"Yield":`Hard bin ${s.bin}${f?.(s.bin)?` (${f(s.bin)})`:""}`,commonalityConfidence=s=>s<.05?"clear":s<.2?"possible":"none",CONFIDENCE_LABEL={clear:"Clear",possible:"Possible",none:"Not clear"};export function groupCommonalityRows(s,f=[]){const c=new Map;for(const t of s)(c.get(t.field.key)??c.set(t.field.key,[]).get(t.field.key)).push(t);const d=t=>["clear","possible","none"].indexOf(commonalityConfidence(t.pAdjusted)),p=new Map;for(const t of f)for(const a of t)p.set(a.key,t);const k=new Set,b=[];for(const t of c.values()){const a=p.get(t[0].field.key);if(a){if(k.has(a))continue;k.add(a)}const y=t.find(l=>l.measure.kind==="yield"),m=y&&d(y)<=d(t[0])?y:t[0];b.push({field:t[0].field,fields:a?[t[0].field,...a.filter(l=>l.key!==t[0].field.key)]:[t[0].field],primary:m,others:t.filter(l=>l!==m)})}return b.sort((t,a)=>d(t.primary)-d(a.primary)||a.primary.spread-t.primary.spread)}
@@ -1 +1 @@
1
- import{testValuesReader as z}from"../core/dieTable.js";import{facetValueOf as T}from"./facets.js";import{dieRadialPosition as j}from"./dieRegions.js";import{pearsonOfPairs as B}from"./correlation.js";import{benjaminiHochberg as G,sampleVariance as I}from"./math.js";import{adjustedFits as U,mergePartitions as X}from"./groupEffects.js";import{yieldCounts as C}from"./yield.js";const D=4e3,F=60,q=20,H=.1,O=o=>Math.sqrt(I(o));function P(o,l){const d=Math.min(o.length,l.length);return d<q?0:B(Array.from({length:d},(u,i)=>({x:o[i],y:l[i]}))).r??0}export function pickExamples(o,l,d,u){const i=l.slice(0,F),h=o.reduce((e,t)=>e+t.dies.length,0);if(i.length===0||h===0)return{ranked:[...l],...N(o,d,u)};const w=Math.max(1,Math.ceil(h/D)),_=z(i),g=new Float64Array(i.length),r=i.map(()=>[]),c=[],f=[],n=o.map(()=>[]);let M=0;o.forEach((e,t)=>{for(const s of e.dies){if(M++%w)continue;_(s,g);const a=c.length;c.push(t),n[t].push(a),f.push(j(s,{wafer:e.wafer})??NaN);for(let p=0;p<i.length;p++)r[p].push(g[p])}});const S=e=>r[e].reduce((t,s,a)=>(Number.isFinite(s)&&t.push(a),t),[]),x=e=>n.map(t=>{const s=t.map(a=>r[e][a]).filter(Number.isFinite);return s.length>=3?s.reduce((a,p)=>a+p,0)/s.length:void 0}),b=i.map((e,t)=>{const s=S(t);if(s.length<q)return 0;if(o.length===1)return Math.abs(P(s.map(m=>r[t][m]),s.map(m=>f[m]))||0);const a=O(s.map(m=>r[t][m])),p=x(t).filter(m=>m!==void 0);return a>0&&p.length>=2?Math.min(1,O(p)/a):0}),k=i.map((e,t)=>t).sort((e,t)=>b[t]-b[e]||e-t),R=[...k.map(e=>i[e]),...l.slice(F)],y=k[0];if(b[y]<=0)return{ranked:[...l],...N(o,d,u)};let E,A=.3;const V=S(y);for(const e of k.slice(1)){const t=V.filter(a=>Number.isFinite(r[e][a])),s=Math.abs(P(t.map(a=>r[y][a]),t.map(a=>r[e][a])));s>A&&(A=s,E=i[e])}const v=N(o,d,u,x(y));return{ranked:R,...E!==void 0?{partner:E}:{},...v}}function N(o,l,d,u){if(o.length<4)return{};const i=X(l.flatMap(r=>{const c=o.map(n=>T(n.metadata,r,d)),f=new Map;for(const n of c)n!==void 0&&f.set(n,(f.get(n)??0)+1);return f.size>=2&&f.size<=Math.max(2,Math.floor(o.length/2))&&[...f.values()].every(n=>n>=2)?[{key:r,groupOf:c}]:[]}));if(i.length===0)return{};const h=r=>{const c=U(r,i).filter(n=>n.fitted),f=G(c.map(n=>n.fitted.p));return c.map((n,M)=>({f:n,q:f[M]})).filter(n=>n.q<H).sort((n,M)=>n.f.fitted.p-M.f.fitted.p).map(n=>n.f.partition)},w=u?h(u)[0]?.keys[0]:void 0,_=o.map(r=>{const{pass:c,total:f}=C(r.dies,r.passBins);return f?c/f:void 0}),g=h(_).flatMap(r=>r.keys);return{...w?{splitKey:w}:{},...g.length?{yieldKeys:g}:{}}}
1
+ import{testValuesReader as T}from"../core/dieTable.js";import{facetValueOf as j}from"./facets.js";import{dieRadialPosition as B}from"./dieRegions.js";import{pearsonOfPairs as I}from"./correlation.js";import{benjaminiHochberg as U,sampleVariance as X}from"./math.js";import{adjustedFits as v,comparableGrouping as C,mergePartitions as D}from"./groupEffects.js";import{yieldCounts as H}from"./yield.js";const L=4e3,O=60,q=20,Q=.1,x=r=>Math.sqrt(X(r));function P(r,c){const l=Math.min(r.length,c.length);return l<q?0:I(Array.from({length:l},(u,a)=>({x:r[a],y:c[a]}))).r??0}export function pickExamples(r,c,l,u){const a=c.slice(0,O),h=r.reduce((e,t)=>e+t.dies.length,0);if(a.length===0||h===0)return{ranked:[...c],...N(r,l,u)};const w=Math.max(1,Math.ceil(h/L)),b=T(a),g=new Float64Array(a.length),n=a.map(()=>[]),f=[],d=[],i=r.map(()=>[]);let M=0;r.forEach((e,t)=>{for(const o of e.dies){if(M++%w)continue;b(o,g);const s=f.length;f.push(t),i[t].push(s),d.push(B(o,{wafer:e.wafer})??NaN);for(let p=0;p<a.length;p++)n[p].push(g[p])}});const S=e=>n[e].reduce((t,o,s)=>(Number.isFinite(o)&&t.push(s),t),[]),A=e=>i.map(t=>{const o=t.map(s=>n[e][s]).filter(Number.isFinite);return o.length>=3?o.reduce((s,p)=>s+p,0)/o.length:void 0}),_=a.map((e,t)=>{const o=S(t);if(o.length<q)return 0;if(r.length===1)return Math.abs(P(o.map(m=>n[t][m]),o.map(m=>d[m]))||0);const s=x(o.map(m=>n[t][m])),p=A(t).filter(m=>m!==void 0);return s>0&&p.length>=2?Math.min(1,x(p)/s):0}),k=a.map((e,t)=>t).sort((e,t)=>_[t]-_[e]||e-t),R=[...k.map(e=>a[e]),...c.slice(O)],y=k[0];if(_[y]<=0)return{ranked:[...c],...N(r,l,u)};let E,F=.3;const V=S(y);for(const e of k.slice(1)){const t=V.filter(s=>Number.isFinite(n[e][s])),o=Math.abs(P(t.map(s=>n[y][s]),t.map(s=>n[e][s])));o>F&&(F=o,E=a[e])}const G=N(r,l,u,A(y));return{ranked:R,...E!==void 0?{partner:E}:{},...G}}function N(r,c,l,u){if(r.length<4)return{};const a=D(c.map(n=>({key:n,groupOf:r.map(f=>j(f.metadata,n,l))})).filter(n=>C(n.groupOf)));if(a.length===0)return{};const h=n=>{const f=v(n,a).filter(i=>i.fitted),d=U(f.map(i=>i.fitted.p));return f.map((i,M)=>({f:i,q:d[M]})).filter(i=>i.q<Q).sort((i,M)=>i.f.fitted.p-M.f.fitted.p).map(i=>i.f.partition)},w=u?h(u)[0]?.keys[0]:void 0,b=r.map(n=>{const{pass:f,total:d}=H(n.dies,n.passBins);return d?f/d:void 0}),g=h(b).flatMap(n=>n.keys);return{...w?{splitKey:w}:{},...g.length?{yieldKeys:g}:{}}}
@@ -10,6 +10,14 @@ export interface Partition {
10
10
  }
11
11
  /** The wafers grouped as a number per group in order of first appearance, so equal groupings compare equal whatever their labels. */
12
12
  export declare function partitionId(groupOf: GroupOf): string;
13
+ /** The most groups a field may put `wafers` wafers in and still be compared: past it the field nearly names each wafer. */
14
+ export declare const maxGroups: (wafers: number) => number;
15
+ /**
16
+ * Whether a field's groups can be compared: two groups or more with two wafers or more each, and no more groups than
17
+ * {@link maxGroups}. Every surface that reads groups of wafers takes its fields through here, so a field is read by all of
18
+ * them or by none, and each set of groups is read after allowing for the same others.
19
+ */
20
+ export declare function comparableGrouping(groupOf: GroupOf): boolean;
13
21
  /** Fields that group the wafers identically are one partition. */
14
22
  export declare function mergePartitions(fields: ReadonlyArray<{
15
23
  key: string;
@@ -1 +1 @@
1
- import{compareGroups as k}from"./groupCompare.js";import{fUpperTail as y,tTwoSided as z}from"./math.js";export function partitionId(r){const i=new Map;return r.map(t=>t===void 0?"-":String(i.get(t)??i.set(t,i.size).get(t))).join(",")}export function mergePartitions(r){const i=new Map;for(const t of r){const n=partitionId(t.groupOf),e=i.get(n);e?e.keys.push(t.key):i.set(n,{id:n,keys:[t.key],groupOf:t.groupOf})}return[...i.values()]}export function nested(r,i){const t=new Map;return r.every((n,e)=>n===void 0||(t.has(n)?t.get(n)===i[e]:(t.set(n,i[e]),!0)))}export function fitGroups(r,i,t=0){const n=new Map;if(r.forEach((s,a)=>{const o=i[a];s===void 0||!Number.isFinite(s)||o===void 0||(n.get(o)??n.set(o,[]).get(o)).push(a)}),n.size<2)return;const e=k([...n].map(([s,a])=>({key:s,values:a.map(o=>r[o])})));let p=e.welch?.p??e.kruskal?.p;if(e.welch&&t>0){const s=e.welch.df2-t;p=s<1?1:e.welch.method==="welch-t"?z(e.welch.statistic,s):y(e.welch.statistic,e.welch.df1,s)}return p===void 0||!Number.isFinite(p)?void 0:{byGroup:n,p}}export const ALLOW_FOR_P=.25;function S(r,i){const t=overlapOf(r,i);return!!t&&t.agree/t.of>=MIN_OVERLAP_SHARE}export function adjustedFits(r,i){const t=i.map(e=>({partition:e,fitted:fitGroups(r,e.groupOf)})),n=t.filter(e=>e.fitted).sort((e,p)=>e.fitted.p-p.fitted.p);return t.map(e=>{const p=n.filter(f=>f.partition.id!==e.partition.id&&f.fitted.p<ALLOW_FOR_P&&!nested(f.partition.groupOf,e.partition.groupOf)&&!S(f.partition.groupOf,e.partition.groupOf)),s=p.filter(f=>nested(e.partition.groupOf,f.partition.groupOf)),a=p.find(f=>!nested(e.partition.groupOf,f.partition.groupOf)),o=[...a?[a]:[],...s];let u=[...r],d=e.fitted,w;if(o.length>0){let f=0;for(const g of o){f+=Math.max(0,(g.fitted?.byGroup.size??1)-1);const h=new Map;u.forEach((l,m)=>{const c=g.partition.groupOf[m];l!==void 0&&c!==void 0&&(h.get(c)??h.set(c,[]).get(c)).push(l)});const O=new Map([...h].map(([l,m])=>[l,m.reduce((c,M)=>c+M,0)/m.length]));u=u.map((l,m)=>{const c=g.partition.groupOf[m];return l===void 0||c===void 0?void 0:l-O.get(c)})}d=fitGroups(u,e.partition.groupOf,f)??e.fitted,d!==e.fitted&&(w=o.map(g=>g.partition.keys[0]))}return{partition:e.partition,used:d===e.fitted?[...r]:u,fitted:d,...w?{allowedFor:w}:{}}})}export const MIN_OVERLAP_SHARE=.75;export function overlapOf(r,i){const t=r.flatMap((o,u)=>o!==void 0&&i[u]!==void 0?[[o,i[u]]]:[]),n=new Set(t.map(o=>o[0])),e=new Set(t.map(o=>o[1]));if(t.length===0||n.size<2||n.size!==e.size)return;const p=new Map;for(const[o,u]of t){const d=p.get(o)??p.set(o,new Map).get(o);d.set(u,(d.get(u)??0)+1)}const s=new Map;let a=0;for(const[o,u]of p){const[d,w]=[...u].sort((f,g)=>g[1]-f[1]||(f[0]<g[0]?-1:1))[0];s.set(o,d),a+=w}return new Set(s.values()).size===n.size?{agree:a,of:t.length}:void 0}export function overlapping(r,i){return i.filter(t=>t.id!==r.id).flatMap(t=>{const n=overlapOf(r.groupOf,t.groupOf);return n&&n.agree<n.of&&n.agree/n.of>=MIN_OVERLAP_SHARE?[{partition:t,...n}]:[]}).sort((t,n)=>n.agree/n.of-t.agree/t.of)}
1
+ import{compareGroups as z}from"./groupCompare.js";import{fUpperTail as k,tTwoSided as x}from"./math.js";export function partitionId(i){const o=new Map;return i.map(t=>t===void 0?"-":String(o.get(t)??o.set(t,o.size).get(t))).join(",")}export const maxGroups=i=>Math.max(2,Math.floor(i/2));export function comparableGrouping(i){const o=new Map;for(const e of i)e!==void 0&&o.set(e,(o.get(e)??0)+1);let t=0;for(const e of o.values())e>=2&&t++;return t>=2&&o.size<=maxGroups(i.length)}export function mergePartitions(i){const o=new Map;for(const t of i){const e=partitionId(t.groupOf),n=o.get(e);n?n.keys.push(t.key):o.set(e,{id:e,keys:[t.key],groupOf:t.groupOf})}return[...o.values()]}export function nested(i,o){const t=new Map;return i.every((e,n)=>e===void 0||(t.has(e)?t.get(e)===o[n]:(t.set(e,o[n]),!0)))}export function fitGroups(i,o,t=0){const e=new Map;if(i.forEach((s,u)=>{const r=o[u];s===void 0||!Number.isFinite(s)||r===void 0||(e.get(r)??e.set(r,[]).get(r)).push(u)}),e.size<2)return;const n=z([...e].map(([s,u])=>({key:s,values:u.map(r=>i[r])})));let p=n.welch?.p??n.kruskal?.p;if(n.welch&&t>0){const s=n.welch.df2-t;p=s<1?1:n.welch.method==="welch-t"?x(n.welch.statistic,s):k(n.welch.statistic,n.welch.df1,s)}return p===void 0||!Number.isFinite(p)?void 0:{byGroup:e,p}}export const ALLOW_FOR_P=.25;function y(i,o){const t=overlapOf(i,o);return!!t&&t.agree/t.of>=MIN_OVERLAP_SHARE}export function adjustedFits(i,o){const t=o.map(n=>({partition:n,fitted:fitGroups(i,n.groupOf)})),e=t.filter(n=>n.fitted).sort((n,p)=>n.fitted.p-p.fitted.p);return t.map(n=>{const p=e.filter(f=>f.partition.id!==n.partition.id&&f.fitted.p<ALLOW_FOR_P&&!nested(f.partition.groupOf,n.partition.groupOf)&&!y(f.partition.groupOf,n.partition.groupOf)),s=p.filter(f=>nested(n.partition.groupOf,f.partition.groupOf)),u=p.find(f=>!nested(n.partition.groupOf,f.partition.groupOf)),r=[...u?[u]:[],...s];let a=[...i],d=n.fitted,h;if(r.length>0){let f=0;for(const g of r){f+=Math.max(0,(g.fitted?.byGroup.size??1)-1);const w=new Map;a.forEach((l,m)=>{const c=g.partition.groupOf[m];l!==void 0&&c!==void 0&&(w.get(c)??w.set(c,[]).get(c)).push(l)});const O=new Map([...w].map(([l,m])=>[l,m.reduce((c,M)=>c+M,0)/m.length]));a=a.map((l,m)=>{const c=g.partition.groupOf[m];return l===void 0||c===void 0?void 0:l-O.get(c)})}d=fitGroups(a,n.partition.groupOf,f)??n.fitted,d!==n.fitted&&(h=r.map(g=>g.partition.keys[0]))}return{partition:n.partition,used:d===n.fitted?[...i]:a,fitted:d,...h?{allowedFor:h}:{}}})}export const MIN_OVERLAP_SHARE=.75;export function overlapOf(i,o){const t=i.flatMap((r,a)=>r!==void 0&&o[a]!==void 0?[[r,o[a]]]:[]),e=new Set(t.map(r=>r[0])),n=new Set(t.map(r=>r[1]));if(t.length===0||e.size<2||e.size!==n.size)return;const p=new Map;for(const[r,a]of t){const d=p.get(r)??p.set(r,new Map).get(r);d.set(a,(d.get(a)??0)+1)}const s=new Map;let u=0;for(const[r,a]of p){const[d,h]=[...a].sort((f,g)=>g[1]-f[1]||(f[0]<g[0]?-1:1))[0];s.set(r,d),u+=h}return new Set(s.values()).size===e.size?{agree:u,of:t.length}:void 0}export function overlapping(i,o){return o.filter(t=>t.id!==i.id).flatMap(t=>{const e=overlapOf(i.groupOf,t.groupOf);return e&&e.agree<e.of&&e.agree/e.of>=MIN_OVERLAP_SHARE?[{partition:t,...e}]:[]}).sort((t,e)=>e.agree/e.of-t.agree/t.of)}
@@ -547,11 +547,16 @@ export declare function examplePlots(catalogue: readonly FieldOption[], waferCou
547
547
  items: readonly PlotItem[];
548
548
  ctx?: PlotContext;
549
549
  }): PlotSpec[];
550
+ /**
551
+ * Whether a wafer opened from a plot opens on its bins: a plot of yield or of bins that names no test, as a yield bar does
552
+ * everywhere. A plot that names a test opens on it ({@link plotTestNumber}); any other leaves the map as it is.
553
+ */
554
+ export declare function plotOpensBins(spec: PlotSpec): boolean;
550
555
  /**
551
556
  * The test a click on this plot should open a wafer on: the plot's own measurement, so the map shows the values the
552
557
  * plot is about rather than the bins. A scatter takes its X (as the Insights scatter does), then its Y, then its
553
- * colour; every other chart type its values. `undefined` when the plot has no test in it (yield against wafer order),
554
- * where the wafer's own default map is the right one.
558
+ * colour; every other chart type its values. `undefined` when the plot has no test in it (yield against wafer order):
559
+ * {@link plotOpensBins} then says whether the wafer opens on its bins.
555
560
  */
556
561
  export declare function plotTestNumber(spec: PlotSpec): number | undefined;
557
562
  /**