@wafertools/wafermap 0.35.0 → 0.35.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 (60) hide show
  1. package/AGENTS.md +7 -1
  2. package/CHANGELOG.md +129 -0
  3. package/README.md +6 -3
  4. package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
  5. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  6. package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
  7. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  8. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +14 -1
  9. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  10. package/dist/packages/canvas-adapter/summaryPanel.d.ts +31 -8
  11. package/dist/packages/canvas-adapter/summaryPanel.js +4 -2
  12. package/dist/packages/canvas-adapter/summaryToggle.d.ts +11 -0
  13. package/dist/packages/canvas-adapter/summaryToggle.js +1 -0
  14. package/dist/packages/canvas-adapter/toolbar.d.ts +8 -0
  15. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  16. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  17. package/dist/packages/canvas-adapter/userGuideHtml.js +37 -21
  18. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  19. package/dist/packages/canvas-adapter/version.js +1 -1
  20. package/dist/packages/canvas-adapter/warnings.js +1 -1
  21. package/dist/packages/core/classify.d.ts +5 -0
  22. package/dist/packages/core/classify.js +1 -1
  23. package/dist/packages/core/dieTable.d.ts +26 -0
  24. package/dist/packages/core/dieTable.js +1 -1
  25. package/dist/packages/core/passBins.d.ts +6 -0
  26. package/dist/packages/core/passBins.js +1 -1
  27. package/dist/packages/renderer/buildView.js +1 -1
  28. package/dist/packages/renderer/buildWaferMap.d.ts +32 -1
  29. package/dist/packages/renderer/buildWaferMap.js +1 -1
  30. package/dist/packages/renderer/spec.d.ts +4 -0
  31. package/dist/packages/renderer/spec.js +1 -1
  32. package/dist/packages/renderer/valueFilter.d.ts +55 -0
  33. package/dist/packages/renderer/valueFilter.js +1 -0
  34. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  35. package/dist/packages/stats/analyzeWaferMap.d.ts +44 -3
  36. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  37. package/dist/packages/stats/capability.d.ts +5 -0
  38. package/dist/packages/stats/capability.js +1 -1
  39. package/dist/packages/stats/clusterDetection.js +1 -1
  40. package/dist/packages/stats/connectedComponents.d.ts +19 -0
  41. package/dist/packages/stats/connectedComponents.js +1 -1
  42. package/dist/packages/stats/lotPattern.js +1 -1
  43. package/dist/packages/stats/math.d.ts +25 -3
  44. package/dist/packages/stats/math.js +1 -1
  45. package/dist/packages/stats/patternClassification.d.ts +44 -18
  46. package/dist/packages/stats/patternClassification.js +1 -1
  47. package/dist/packages/stats/plotData.d.ts +11 -0
  48. package/dist/packages/stats/plotData.js +1 -1
  49. package/dist/packages/stats/regions.d.ts +6 -0
  50. package/dist/packages/stats/regions.js +1 -1
  51. package/dist/packages/stats/renderSummaryReport.js +33 -33
  52. package/dist/packages/stats/reportHtml.d.ts +7 -6
  53. package/dist/packages/stats/reportHtml.js +39 -37
  54. package/dist/packages/stats/synthesis.d.ts +44 -17
  55. package/dist/packages/stats/synthesis.js +1 -1
  56. package/dist/packages/stats/types.d.ts +12 -0
  57. package/llms.txt +2 -2
  58. package/package.json +1 -1
  59. package/dist/packages/canvas-adapter/summaryRail.d.ts +0 -7
  60. package/dist/packages/canvas-adapter/summaryRail.js +0 -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="wafer-map-user-guide">Wafer Map \u2014 User Guide<span class="wmap-guide-version" title="Built 2026-10-06T15:43:33.651Z">v0.35.0</span></h1>
75
+ <h1 id="wafer-map-user-guide">Wafer Map \u2014 User Guide<span class="wmap-guide-version" title="Built 2026-10-09T18:16:23.713Z">v0.35.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
@@ -247,6 +247,16 @@ the tester&#39;s own recorded verdict rather than a limit judgement (there is
247
247
  no gradient to fall back to). <strong>Test pass/fail</strong> is also available as an
248
248
  Overlays option on an ordinary parametric test when it carries recorded
249
249
  verdicts, as an alternative to limit judgement.</p>
250
+ <h3 id="values-outside-a-limit-set">Values outside a limit set</h3>
251
+ <p>A tester that runs out of range records its rail instead of a reading: a current held at the compliance clamp, a voltage at the supply, an
252
+ open-circuit value. A test can carry <strong>validity limits</strong>, the range a real measurement lies in, and a value outside them is not a reading. It
253
+ is <strong>missing</strong> for that test on that die: grey on the map, and left out of the statistics and every chart, so one clamp cannot stretch the colour
254
+ scale or move the mean, \u03C3 and Cpk. Which limit set a value must lie inside is the host&#39;s choice. The usual one is the validity limits, which only
255
+ affect tests that have them; a host can instead keep only values inside the specification limits or the test limits, or filter nothing.</p>
256
+ <p>Nothing is hidden. Hover a grey die and the tooltip names the excluded value and the limit set. The Summary panel&#39;s Test Values table shows the
257
+ total beside <strong>N</strong> and an <strong>Excl.</strong> column, and the same count appears in the histogram and box plot captions, the capability tooltip and caption,
258
+ the Plot tab&#39;s footnote, the report and the CSV exports. The build also lists it among the data warnings. The bin map and each die&#39;s pass/fail are
259
+ the tester&#39;s own and do not change, so yield is the same with the filter on or off.</p>
250
260
  <div data-wmap-demo="value-heatmap" class="wmap-demo"></div><div data-wmap-demo="spec-passfail" class="wmap-demo"></div><hr>
251
261
  <h3 id="derived-tests">Derived tests (\u2020)</h3>
252
262
  <p>A test name marked <strong>\u2020</strong> in front is a <em>derived</em> test: its value was calculated
@@ -357,11 +367,6 @@ shows die tooltips \u2014 a separate thing from the toolbar, which is always pre
357
367
  <td>Downloads the current map view as a PNG. Captures the canvas as displayed, including all active overlays and the legend.</td>
358
368
  </tr>
359
369
  <tr>
360
- <td><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMzNzQxNTEiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNOCAydjQiLz48cGF0aCBkPSJNMTIgMnY0Ii8+PHBhdGggZD0iTTE2IDJ2NCIvPjxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxOCIgeD0iNCIgeT0iNCIgcng9IjIiLz48cGF0aCBkPSJNOCAxMGg2Ii8+PHBhdGggZD0iTTggMTRoOCIvPjxwYXRoIGQ9Ik04IDE4aDUiLz48L3N2Zz4K" width="20" height="20"></td>
361
- <td>Findings</td>
362
- <td>Opens or closes the Summary panel (see <a href="#6-summary-panel" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'6-summary-panel\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Section 6</a>).</td>
363
- </tr>
364
- <tr>
365
370
  <td><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMzNzQxNTEiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMTAuMjkgMy44NiAxLjgyIDE4YTIgMiAwIDAgMCAxLjcxIDNoMTYuOTRhMiAyIDAgMCAwIDEuNzEtM0wxMy43MSAzLjg2YTIgMiAwIDAgMC0zLjQyIDB6Ii8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4K" width="20" height="20"></td>
366
371
  <td>Data warnings</td>
367
372
  <td>Appears <strong>only when there is something to report</strong> about the data behind the map. Click it for the details. A red \u26D4 means the map may be positionally wrong \u2014 usually that wafer geometry was guessed rather than supplied, so dies may not sit where they appear to. An amber \u26A0 means something expected is missing or was skipped, but what is drawn is correct.</td>
@@ -547,11 +552,6 @@ it as a file and send it to whoever supports this software.</p>
547
552
  <td>Test Value mode with test limits only. Toggles all cards between the limit range and the data range. Leave it on the test limits when comparing wafers \u2014 the data range rescales per view.</td>
548
553
  </tr>
549
554
  <tr>
550
- <td><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMzNzQxNTEiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNOCAydjQiLz48cGF0aCBkPSJNMTIgMnY0Ii8+PHBhdGggZD0iTTE2IDJ2NCIvPjxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxOCIgeD0iNCIgeT0iNCIgcng9IjIiLz48cGF0aCBkPSJNOCAxMGg2Ii8+PHBhdGggZD0iTTggMTRoOCIvPjxwYXRoIGQ9Ik04IDE4aDUiLz48L3N2Zz4K" width="20" height="20"></td>
551
- <td>Summary panel</td>
552
- <td>Opens or closes the Summary panel covering every wafer in the gallery.</td>
553
- </tr>
554
- <tr>
555
555
  <td><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMzNzQxNTEiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMTAuMjkgMy44NiAxLjgyIDE4YTIgMiAwIDAgMCAxLjcxIDNoMTYuOTRhMiAyIDAgMCAwIDEuNzEtM0wxMy43MSAzLjg2YTIgMiAwIDAgMC0zLjQyIDB6Ii8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4K" width="20" height="20"></td>
556
556
  <td>Data warnings</td>
557
557
  <td>Appears only when something is worth reporting about the wafers shown. Collected across every wafer and de-duplicated, so a problem affecting all of them is stated once rather than repeated per card.</td>
@@ -751,8 +751,10 @@ supporting detail.</p>
751
751
  <h2 id="6-summary-panel">6. Summary panel</h2>
752
752
  <p>The Summary panel docks next to the map and gives you the wafer or lot at a
753
753
  glance, with findings sitting directly under the headline numbers so a clicked
754
- finding can highlight the affected dies right there. Open it from the toolbar, or from
755
- the <strong>Summary</strong> tab on the edge of the map area, which shows while the panel is closed.</p>
754
+ finding can highlight the affected dies right there. The <strong>Summary</strong> button in the row
755
+ above the map, just before Map | Insights, opens and closes it, and shows as pressed while
756
+ it is open. The <strong>\u25B8</strong> button at the end of the panel&#39;s title closes it too, and stays in
757
+ view as the panel scrolls.</p>
756
758
  <div data-wmap-demo="summary-panel" class="wmap-demo"></div><p><em>The Summary panel open alongside a single wafer. Click any finding to
757
759
  highlight the affected dies.</em></p>
758
760
  <p>Sections, top to bottom:</p>
@@ -774,18 +776,29 @@ its shortfall; a test is an item when it is outside its limits (or a functional
774
776
  fails) on a share of the dies that clears the same floor. Its three dots and word (High, Moderate or Low impact) say how
775
777
  much of the lot it costs: the higher of its share of all the dies (2% moderate, 4% high)
776
778
  and its share of the dies that fail (15% moderate, 40% high), so a small area that is most
777
- of a good lot&#39;s loss still reads as high. Click a name to highlight that finding on the map.
779
+ of a good lot&#39;s loss still reads as high.
780
+ A test is costed by the dies it fails that also fail yield: dies outside its limits but binned
781
+ as passing cost nothing. A test whose failures lie mostly in a region is said as part of that
782
+ region&#39;s item rather than listed again beside it.
783
+ <strong>Every item is a row, and every row shows its dies on the map</strong> \u2014 a wafer icon at its end marks
784
+ it. Click a region or wafer to highlight it, or a test to show the test&#39;s values with the dies it
785
+ fails selected; click again to clear. Under the top item&#39;s sentence, chips name its parts (its
786
+ failing bins, with their legend colours, the pattern, and tests failing on the same dies), and
787
+ each chip shows that part alone.
778
788
  A <strong>Watch</strong> line (at most two) follows for things that cost no dies yet: a lot of five or more
779
789
  wafers whose yield, or a test&#39;s mean, trends up or down across the wafers <em>in the order given</em>
780
- (said as &quot;input order&quot;: the order is only a physical one if you know it is), and a test whose
781
- Ppk against its limits is under 1.0.
790
+ (said as &quot;input order&quot;: the order is only a physical one if you know it is), a test outside its
791
+ limits on dies that were binned as passing, and a test whose Ppk against its limits is under 1.0.
792
+ Watch lines are rows too.
782
793
  A wafer or lot with nothing over a yield point says so: &quot;Nothing stands out&quot;.
783
794
  The reports open with the same section, and <strong>Full report</strong> at the foot of it opens the
784
795
  report; in a report opened from the panel, clicking a finding&#39;s row shows it on the map.</li>
785
796
  <li><strong>Findings</strong> \u2014 detected anomalies, most severe first, each group marked with
786
- three dots filled by severity (Unusual, Notable, Minor). Severity chips narrow
787
- the list; Kind and Region dropdowns appear once there are enough findings to
788
- be worth narrowing. <strong>Detail</strong> opens the same sentences above a readable list.</li>
797
+ three dots filled by severity (Unusual, Notable, Minor). The header says how
798
+ many are unusual or notable, even when the section is collapsed, and the
799
+ severity chips narrow the list. Click a finding to show it on the map. A spatial
800
+ pattern has a <strong>Show N supporting findings</strong> line under it that lists the
801
+ regional findings it explains.</li>
789
802
  <li><strong>Bin breakdown</strong> \u2014 bars as a share of dies, pass bins first and then failing
790
803
  bins by descending count, so the dominant failure mode is at the top. It
791
804
  follows the map&#39;s plot mode: a soft-bin map gets a soft-bin breakdown. When a
@@ -823,8 +836,9 @@ table with Cp/Cpk/Pp/Ppk, and the findings list \u2014 and can be saved as a PDF
823
836
  from your browser&#39;s print dialog. It opens with <strong>What stands out</strong>: the yield,
824
837
  up to three regions, fail bins or wafers ranked by how many dies each costs, and a
825
838
  line saying what was compared. An item is listed only when it costs at least one
826
- yield point of the dies analysed; a lot with none says so. Each figure links to its
827
- row in the Findings table below. Severity is drawn as three dots and a word, so it reads in a
839
+ yield point of the dies analysed; a lot with none says so. Each item links to its
840
+ evidence: a finding to its row in the Findings table below, a test to the Test Values
841
+ or Functional Tests section. Severity is drawn as three dots and a word, so it reads in a
828
842
  black-and-white print; yields carry a bar, and a wafer or region is tinted only when it is
829
843
  at least a point below the rest.</p>
830
844
  <p>A <strong>Data tables</strong> button beside it opens the same tables as Insights&#39; Data tab (<a href="#data-tables" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'data-tables\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Data tables</a>) over this wafer, or over the whole lot in a gallery: Statistics, every die, and, for a lot, one row per wafer \u2014 each with Export CSV and Copy. It does not need Insights to be switched on.</p>
@@ -990,6 +1004,8 @@ offer one.</p>
990
1004
  </li>
991
1005
  <li><p><strong>Correlation</strong> \u2014 a test-to-test correlation matrix and a die-level scatter
992
1006
  plot, both stating the sample size the coefficients are computed over.
1007
+ <strong>Max tests</strong> (5 to 100, 20 by default) sets how many tests the matrix shows, and
1008
+ <strong>Correlation CSV</strong> saves the matrix as a table.
993
1009
  Clicking a matrix cell drives the scatter plot onto that pair, where <code>r</code> and
994
1010
  <code>n</code> for that pair are printed and update as you filter the legend. Hover a
995
1011
  point to see which wafer and die it is; <strong>click</strong> it to open that wafer on the
@@ -1,3 +1,3 @@
1
- export declare const WMAP_VERSION = "0.35.0";
2
- export declare const WMAP_BUILD_TIME = "2026-10-06T15:45:50.394Z";
1
+ export declare const WMAP_VERSION = "0.35.1";
2
+ export declare const WMAP_BUILD_TIME = "2026-10-09T18:19:45.271Z";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const WMAP_VERSION="0.35.0",WMAP_BUILD_TIME="2026-10-06T15:45:50.394Z";
1
+ export const WMAP_VERSION="0.35.1",WMAP_BUILD_TIME="2026-10-09T18:19:45.271Z";
@@ -1 +1 @@
1
- import{SHADOW as C,TRACKING as O,SPACE as r,RADIUS as v,FONT as y,CLR as d,Z_BASE as B}from"./toolbar.js";const E={error:0,warning:1,info:2};export function severityOf(t){return t.severity??"warning"}export function collectWarnings(t){const s=[],i=new Set,n=e=>{if(!e?.message)return;const o=`${e.code}\0${e.message}`;i.has(o)||(i.add(o),s.push(e))};for(const e of t.result?.warnings??[])n(e);for(const e of t.statsSummary?.stats.warnings??[])n(e);for(const e of t.lotStatsSummary?.perWafer??[])for(const o of e.summary.stats.warnings??[])n(o);for(const e of t.extra??[])n(e);return s.sort((e,o)=>E[severityOf(e)]-E[severityOf(o)])}function $(t){return t==="error"?{bg:d.errBg,border:d.errBorder,text:d.errText}:{bg:d.warnBg,border:d.warnBorder,text:d.warnText}}function S(t){return t==="error"?"\u26D4":t==="info"?"\u2139":"\u26A0"}export const SHORT_LABEL={"partial-coverage":"Partial wafer coverage","geometry-conflict":"Geometry conflict","non-standard-diameter":"Non-standard wafer diameter","diameter-exceeds-die-extent":"Diameter exceeds die extent","edge-exclusion-exceeds-radius":"Edge exclusion exceeds radius","test-count-capped":"Test analysis skipped","test-def-collision":"Test definitions disagree","analysis-option-corrected":"Analysis option corrected","bin-colors-shared":"Bins share a colour","pass-bins-mixed":"Pass bins differ by wafer","ring-count-mixed":"Ring counts differ by wafer","input-field-removed":"Removed input name ignored","input-values-not-numbers":"Bins or test values are text","input-values-outside-stdf":"Values outside STDF ranges","retests-by-part-id":"Retests matched by part ID","derived-test-invalid":"Derived test not applied"};function w(t){const s=t.code?SHORT_LABEL[t.code]:void 0;if(s)return s;const i=t.message.split(/(?<=\.)\s/)[0]??t.message;return i.length>60?`${i.slice(0,57)}\u2026`:i}export function buildWarningsBanner(t,s=document){const i=s.createElement("div");Object.assign(i.style,{marginBottom:r.lg});for(const n of t){const e=severityOf(n),o=$(e),m=s.createElement("div");Object.assign(m.style,{background:o.bg,border:`1px solid ${o.border}`,borderRadius:v.control,marginBottom:r.sm,fontSize:y.body,color:o.text,lineHeight:"1.5"}),m.setAttribute("role","status");const a=s.createElement("button");a.type="button",Object.assign(a.style,{display:"flex",alignItems:"center",gap:r.sm,width:"100%",background:"none",border:"none",font:"inherit",color:"inherit",textAlign:"left",padding:`${r.sm} ${r.lg}`,cursor:"pointer"});const p=s.createElement("span");Object.assign(p.style,{flex:"1",minWidth:"0"}),p.textContent=`${S(e)} ${w(n)}`;const l=s.createElement("span");Object.assign(l.style,{flexShrink:"0"}),a.append(p,l);const g=s.createElement("div");Object.assign(g.style,{padding:`0 ${r.lg} ${r.sm}`}),g.textContent=n.message;let c=!1;const f=()=>{l.textContent=c?"\u25B4":"\u25BE",g.style.display=c?"block":"none",a.setAttribute("aria-expanded",String(c)),a.setAttribute("aria-label",`${w(n)}. ${c?"Click to collapse.":"Click to expand for detail."}`)};f(),a.addEventListener("click",()=>{c=!c,f()}),a.addEventListener("mouseenter",()=>{l.style.opacity="0.65"}),a.addEventListener("mouseleave",()=>{l.style.opacity="1"}),m.append(a,g),i.appendChild(m)}return i}export function buildWarningsMenuEl(t,s,i=window){const n=i.document,e=n.createElement("div"),o=280,a=t.left+o<=(i.innerWidth??1/0)?t.left:Math.max(4,t.right-o);Object.assign(e.style,{position:"fixed",top:`${t.bottom+4}px`,left:`${a}px`,background:d.menuBg,border:`1px solid ${d.menuBorder}`,borderRadius:v.control,boxShadow:C.menu,zIndex:B,width:`${o}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"}),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Data warnings");const p=n.createElement("div");Object.assign(p.style,{padding:`${r.sm} ${r.xl} ${r.xs}`,fontSize:y.body,fontWeight:"700",letterSpacing:O,textTransform:"uppercase",color:d.label}),p.textContent=s.length===1?"1 warning":`${s.length} warnings`,e.appendChild(p);for(const l of s){const g=severityOf(l),c=$(g),f=n.createElement("div");Object.assign(f.style,{display:"flex",gap:r.md,padding:`${r.md} ${r.xl}`,fontSize:y.body,lineHeight:"1.5",color:d.text,borderTop:`1px solid ${d.menuBorder}`,alignItems:"flex-start"});const u=n.createElement("span");Object.assign(u.style,{color:c.text,flexShrink:"0"}),u.textContent=S(g),f.appendChild(u);const x=n.createElement("div"),b=n.createElement("div");Object.assign(b.style,{fontWeight:"700",color:c.text,marginBottom:r.xxs}),b.textContent=l.code,x.appendChild(b);const h=n.createElement("div");h.textContent=l.message,x.appendChild(h),f.appendChild(x),e.appendChild(f)}return e}
1
+ import{SHADOW as C,TRACKING as O,SPACE as r,RADIUS as v,FONT as y,CLR as d,Z_BASE as B}from"./toolbar.js";const E={error:0,warning:1,info:2};export function severityOf(t){return t.severity??"warning"}export function collectWarnings(t){const s=[],i=new Set,n=e=>{if(!e?.message)return;const o=`${e.code}\0${e.message}`;i.has(o)||(i.add(o),s.push(e))};for(const e of t.result?.warnings??[])n(e);for(const e of t.statsSummary?.stats.warnings??[])n(e);for(const e of t.lotStatsSummary?.perWafer??[])for(const o of e.summary.stats.warnings??[])n(o);for(const e of t.extra??[])n(e);return s.sort((e,o)=>E[severityOf(e)]-E[severityOf(o)])}function $(t){return t==="error"?{bg:d.errBg,border:d.errBorder,text:d.errText}:{bg:d.warnBg,border:d.warnBorder,text:d.warnText}}function S(t){return t==="error"?"\u26D4":t==="info"?"\u24D8":"\u26A0"}export const SHORT_LABEL={"partial-coverage":"Partial wafer coverage","geometry-conflict":"Geometry conflict","non-standard-diameter":"Non-standard wafer diameter","diameter-exceeds-die-extent":"Diameter exceeds die extent","edge-exclusion-exceeds-radius":"Edge exclusion exceeds radius","test-count-capped":"Test analysis skipped","test-def-collision":"Test definitions disagree","analysis-option-corrected":"Analysis option corrected","bin-colors-shared":"Bins share a colour","pass-bins-mixed":"Pass bins differ by wafer","ring-count-mixed":"Ring counts differ by wafer","input-field-removed":"Removed input name ignored","input-values-not-numbers":"Bins or test values are text","input-values-outside-stdf":"Values outside STDF ranges","retests-by-part-id":"Retests matched by part ID","derived-test-invalid":"Derived test not applied","values-excluded":"Values excluded by limits"};function w(t){const s=t.code?SHORT_LABEL[t.code]:void 0;if(s)return s;const i=t.message.split(/(?<=\.)\s/)[0]??t.message;return i.length>60?`${i.slice(0,57)}\u2026`:i}export function buildWarningsBanner(t,s=document){const i=s.createElement("div");Object.assign(i.style,{marginBottom:r.lg});for(const n of t){const e=severityOf(n),o=$(e),u=s.createElement("div");Object.assign(u.style,{background:o.bg,border:`1px solid ${o.border}`,borderRadius:v.control,marginBottom:r.sm,fontSize:y.body,color:o.text,lineHeight:"1.5"}),u.setAttribute("role","status");const a=s.createElement("button");a.type="button",Object.assign(a.style,{display:"flex",alignItems:"center",gap:r.sm,width:"100%",background:"none",border:"none",font:"inherit",color:"inherit",textAlign:"left",padding:`${r.sm} ${r.lg}`,cursor:"pointer"});const p=s.createElement("span");Object.assign(p.style,{flex:"1",minWidth:"0"}),p.textContent=`${S(e)} ${w(n)}`;const l=s.createElement("span");Object.assign(l.style,{flexShrink:"0"}),a.append(p,l);const g=s.createElement("div");Object.assign(g.style,{padding:`0 ${r.lg} ${r.sm}`}),g.textContent=n.message;let c=!1;const f=()=>{l.textContent=c?"\u25B4":"\u25BE",g.style.display=c?"block":"none",a.setAttribute("aria-expanded",String(c)),a.setAttribute("aria-label",`${w(n)}. ${c?"Click to collapse.":"Click to expand for detail."}`)};f(),a.addEventListener("click",()=>{c=!c,f()}),a.addEventListener("mouseenter",()=>{l.style.opacity="0.65"}),a.addEventListener("mouseleave",()=>{l.style.opacity="1"}),u.append(a,g),i.appendChild(u)}return i}export function buildWarningsMenuEl(t,s,i=window){const n=i.document,e=n.createElement("div"),o=280,a=t.left+o<=(i.innerWidth??1/0)?t.left:Math.max(4,t.right-o);Object.assign(e.style,{position:"fixed",top:`${t.bottom+4}px`,left:`${a}px`,background:d.menuBg,border:`1px solid ${d.menuBorder}`,borderRadius:v.control,boxShadow:C.menu,zIndex:B,width:`${o}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"}),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Data warnings");const p=n.createElement("div");Object.assign(p.style,{padding:`${r.sm} ${r.xl} ${r.xs}`,fontSize:y.body,fontWeight:"700",letterSpacing:O,textTransform:"uppercase",color:d.label}),p.textContent=s.length===1?"1 warning":`${s.length} warnings`,e.appendChild(p);for(const l of s){const g=severityOf(l),c=$(g),f=n.createElement("div");Object.assign(f.style,{display:"flex",gap:r.md,padding:`${r.md} ${r.xl}`,fontSize:y.body,lineHeight:"1.5",color:d.text,borderTop:`1px solid ${d.menuBorder}`,alignItems:"flex-start"});const m=n.createElement("span");Object.assign(m.style,{color:c.text,flexShrink:"0"}),m.textContent=S(g),f.appendChild(m);const x=n.createElement("div"),b=n.createElement("div");Object.assign(b.style,{fontWeight:"700",color:c.text,marginBottom:r.xxs}),b.textContent=l.code,x.appendChild(b);const h=n.createElement("div");h.textContent=l.message,x.appendChild(h),f.appendChild(x),e.appendChild(f)}return e}
@@ -9,6 +9,11 @@ export interface ClassifyOptions {
9
9
  /** The map's own ring count (`WaferMapResult.ringCount`). Required: there is no default ring count to classify by. */
10
10
  ringCount: number;
11
11
  }
12
+ /**
13
+ * The ring (1 = innermost, `ringCount` = the edge) of a point `dx, dy` from the wafer centre: equal widths of
14
+ * the radius, a point on a boundary in the outer ring. The one ring rule; the edge ring is `ringCount`.
15
+ */
16
+ export declare function ringOf(dx: number, dy: number, radius: number, ringCount: number): number;
12
17
  /**
13
18
  * Classify a die by its radial ring (1 = innermost) and physical wafer quadrant.
14
19
  *
@@ -1 +1 @@
1
- import{requireRingCount as u}from"./ringCount.js";export function classifyDie(t,e,s){const o=Math.max(1,u(s,"classifyDie")),n=t.physX-e.center.x,r=t.physY-e.center.y,a=Math.sqrt(n*n+r*r)/e.radius,c=Math.min(o,Math.max(1,Math.floor(a*o)+1));let i;return n>=0&&r>=0?i="NE":n<0&&r>=0?i="NW":n<0&&r<0?i="SW":i="SE",{ring:c,quadrant:i}}export function getRingLabel(t,e){return e===1?"Full Wafer":t===1?"Ring 1 (core)":t===e?`Ring ${t} (edge)`:`Ring ${t}`}
1
+ import{requireRingCount as h}from"./ringCount.js";export function ringOf(t,n,e,r){const a=Math.sqrt(t*t+n*n)/e;return Math.min(r,Math.max(1,Math.floor(a*r)+1))}const u=["NE","NW","SW","SE"];export function classifyDie(t,n,e){const r=Math.max(1,h(e,"classifyDie")),a=t.physX-n.center.x,o=t.physY-n.center.y,i=ringOf(a,o,n.radius,r),c=(Math.atan2(o,a)+2*Math.PI)%(2*Math.PI),s=u[Math.min(3,Math.floor(c/(Math.PI/2)))];return{ring:i,quadrant:s}}export function getRingLabel(t,n){return n===1?"Full Wafer":t===1?"Ring 1 (core)":t===n?`Ring ${t} (edge)`:`Ring ${t}`}
@@ -19,6 +19,14 @@ export interface DieTable {
19
19
  * with no verdicts has no `testPass`, exactly as before.
20
20
  */
21
21
  readonly fields: Uint8Array;
22
+ /**
23
+ * Test number → the value that was taken out of `values` by the value filter
24
+ * (`WaferMapInput.valueFilter`), per row; `NaN` = nothing was excluded there.
25
+ * Kept so a tooltip can say what was excluded and why. Absent when nothing was.
26
+ */
27
+ readonly excluded?: ReadonlyMap<number, Float32Array | Float64Array>;
28
+ /** The limit set `excluded` values were outside of (the value filter's mode). */
29
+ readonly excludedBy?: 'validity' | 'spec' | 'test';
22
30
  }
23
31
  /** What the readers need of a die. A `DieResult` qualifies. */
24
32
  export type DieData = Pick<Die, 'testValues' | 'testPass'>;
@@ -47,6 +55,24 @@ export declare function tableFromRows(rows: readonly Row[]): DieTable;
47
55
  export declare function extendTable(table: DieTable, values: ReadonlyMap<number, Float32Array | Float64Array>, verdicts: ReadonlyMap<number, Int8Array>): DieTable & {
48
56
  fields: Uint8Array;
49
57
  };
58
+ /**
59
+ * A copy of `table` with the value filter's outcome: `values` columns replaced
60
+ * (excluded entries now `NaN`) and `excluded` holding what was taken out.
61
+ */
62
+ export declare function withExcluded(table: DieTable, values: ReadonlyMap<number, Float32Array | Float64Array>, excluded: ReadonlyMap<number, Float32Array | Float64Array>, excludedBy: 'validity' | 'spec' | 'test'): DieTable;
63
+ /**
64
+ * How many of `dies`' values the value filter excluded, per test, and the limit set it used.
65
+ * Counts the dies given (so a die a retest policy dropped is not counted). `undefined`
66
+ * when none of them has an excluded value.
67
+ */
68
+ export declare function excludedCounts(dies: readonly DieData[]): {
69
+ counts: Map<number, number>;
70
+ by: 'validity' | 'spec' | 'test';
71
+ } | undefined;
72
+ /** The limit set the value filter excluded `die`'s values against, when it excluded any in its table. */
73
+ export declare function excludedBy(die: DieData): 'validity' | 'spec' | 'test' | undefined;
74
+ /** The value the filter excluded from `die` for `testNumber`, or `undefined` when none was. */
75
+ export declare function excludedValue(die: DieData, testNumber: number): number | undefined;
50
76
  /**
51
77
  * One reusable die-shaped view over `table`: `at(row)` points it at a row and
52
78
  * returns it, so a rule that takes a die (`getTestPassStatus`) can be applied
@@ -1 +1 @@
1
- import{hasAnyKey as O}from"./utils.js";const k=NaN;export const VERDICT_NONE=-1,VERDICT_FAIL=0,VERDICT_PASS=1,HAS_VALUES=1,HAS_VERDICTS=2;const a=Symbol("wmap.dieTable"),u=Symbol("wmap.dieRow");export function linkDie(e,t,s){return e[a]=t,e[u]=s,e}export function dieLink(e){const t=e[a];return t===void 0?void 0:{table:t,row:e[u]}}export function tableFromRows(e){const t=e.length,s=new Map,r=new Map,o=new Uint8Array(t),n=g(s,()=>new Float64Array(t).fill(k)),i=g(r,()=>new Int8Array(t).fill(VERDICT_NONE));for(let f=0;f<t;f++){const c=e[f].testValues;if(c){o[f]|=HAS_VALUES;const d=n(c),w=Object.values(c);for(let b=0;b<d.length;b++)d[b][f]=w[b]}const l=e[f].testPass;if(l){o[f]|=HAS_VERDICTS;const d=i(l),w=Object.values(l);for(let b=0;b<d.length;b++)d[b][f]=w[b]?VERDICT_PASS:VERDICT_FAIL}}return{rows:t,values:m(s),verdicts:m(r),fields:o}}function g(e,t){let s=[],r=[];return o=>{const n=Object.keys(o);let i=n.length===s.length;for(let f=0;i&&f<n.length;f++)i=n[f]===s[f];return i||(s=n,r=n.map(f=>{let c=e.get(f);return c===void 0&&e.set(f,c=t()),c})),r}}function m(e){return new Map([...e].map(([t,s])=>[Number(t),s]).sort((t,s)=>t[0]-s[0]))}export function extendTable(e,t,s){const r=new Map(e.values),o=new Map(e.verdicts);for(const[n,i]of t)r.set(n,i);for(const[n,i]of s)o.set(n,i);return{rows:e.rows,values:new Map([...r].sort((n,i)=>n[0]-i[0])),verdicts:new Map([...o].sort((n,i)=>n[0]-i[0])),fields:e.fields.slice()}}export function rowView(e){const t=linkDie({},e,0);return s=>(t[u]=s,t)}function v(e,t){const s={},r=[...e.values];for(let o=r.length-1;o>=0;o--){const n=r[o][1][t];Number.isNaN(n)||(s[r[o][0]]=n)}return s}function V(e,t){const s={},r=[...e.verdicts];for(let o=r.length-1;o>=0;o--){const n=r[o][1][t];n!==VERDICT_NONE&&(s[r[o][0]]=n===VERDICT_PASS)}return s}function x(){return Object.freeze(v(this[a],this[u]))}function N(){return Object.freeze(V(this[a],this[u]))}function j(e){return function(){throw new TypeError(`wafermap: die.${e} is read-only on a die built by buildWaferMap (die ${this.id}). Pass the values you want to buildWaferMap, or copy the die: { ...die, ${e}: yours }.`)}}const y={get:x,set:j("testValues"),enumerable:!0,configurable:!0},P={get:N,set:j("testPass"),enumerable:!0,configurable:!0},p=e=>({value:e,writable:!0,enumerable:!1,configurable:!0});export function finaliseDie(e){const t=e[a];if(t===void 0)return e;const s=e[u],r=t.fields[s],o=e.testValues!==void 0&&!(r&HAS_VALUES)||e.testPass!==void 0&&!(r&HAS_VERDICTS),n={};for(const i of Object.keys(e))i==="testValues"&&r&HAS_VALUES||i==="testPass"&&r&HAS_VERDICTS||(n[i]=e[i]);return o?(r&HAS_VALUES&&(n.testValues=v(t,s)),r&HAS_VERDICTS&&(n.testPass=V(t,s)),n):(Object.defineProperty(n,a,p(t)),Object.defineProperty(n,u,p(s)),r&HAS_VALUES&&Object.defineProperty(n,"testValues",y),r&HAS_VERDICTS&&Object.defineProperty(n,"testPass",P),n)}export function copyDie(e,t){const s=e[a];if(s===void 0)return{...e,...t};const r=e[u],o=s.fields[r],n={};for(const i of Object.keys(e))i!=="testValues"&&i!=="testPass"&&(n[i]=e[i]);return"testValues"in t||"testPass"in t?(o&HAS_VALUES&&!("testValues"in t)&&(n.testValues=v(s,r)),o&HAS_VERDICTS&&!("testPass"in t)&&(n.testPass=V(s,r)),Object.assign(n,t)):(Object.assign(n,t),Object.defineProperty(n,a,p(s)),Object.defineProperty(n,u,p(r)),o&HAS_VALUES&&Object.defineProperty(n,"testValues",y),o&HAS_VERDICTS&&Object.defineProperty(n,"testPass",P),n)}export function detachTables(e){const t=[],s=new Map,r=e.reduce((f,c)=>f+c.length,0),o=new Int32Array(r*2);let n=0;for(const f of e)for(const c of f){const l=dieLink(c);if(l===void 0){o[n++]=-1,o[n++]=0;continue}let d=s.get(l.table);d===void 0&&(s.set(l.table,d=t.length),t.push(l.table)),o[n++]=d,o[n++]=l.row,delete c.testValues,delete c.testPass}const i=new Set;for(const f of t){for(const c of f.values.values())i.add(c.buffer);for(const c of f.verdicts.values())i.add(c.buffer);i.add(f.fields.buffer)}return{tables:t,links:o,transfer:[...i]}}export function attachTables(e,t){let s=0;for(const r of e)for(const o of r){const n=t.links[s++],i=t.links[s++];if(n<0)continue;const f=t.tables[n],c=f.fields[i];Object.defineProperty(o,a,p(f)),Object.defineProperty(o,u,p(i)),c&HAS_VALUES&&Object.defineProperty(o,"testValues",y),c&HAS_VERDICTS&&Object.defineProperty(o,"testPass",P)}}export function testValue(e,t){const s=e[a];if(s===void 0)return e.testValues?.[t];const r=s.values.get(t)?.[e[u]];return r===void 0||Number.isNaN(r)?void 0:r}export function recordedVerdict(e,t){const s=e[a];if(s===void 0)return e.testPass?.[t];const r=s.verdicts.get(t)?.[e[u]];return r===void 0||r===VERDICT_NONE?void 0:r===VERDICT_PASS}export function dieHasAnyTestData(e){return dieHasValues(e)||dieHasVerdicts(e)}export function dieHasValues(e){const t=dieLink(e);if(t===void 0)return O(e.testValues);for(const s of t.table.values.values())if(!Number.isNaN(s[t.row]))return!0;return!1}export function dieHasVerdicts(e){const t=dieLink(e);if(t===void 0)return O(e.testPass);for(const s of t.table.verdicts.values())if(s[t.row]!==VERDICT_NONE)return!0;return!1}export function dieValueEntries(e){const t=dieLink(e);if(t===void 0){const r=e.testValues;return r===void 0?[]:Object.keys(r).map(o=>[Number(o),r[Number(o)]])}const s=[];for(const[r,o]of t.table.values){const n=o[t.row];Number.isNaN(n)||s.push([r,n])}return s}export function dieVerdictEntries(e){const t=dieLink(e);if(t===void 0){const r=e.testPass;return r===void 0?[]:Object.keys(r).map(o=>[Number(o),r[Number(o)]])}const s=[];for(const[r,o]of t.table.verdicts){const n=o[t.row];n!==VERDICT_NONE&&s.push([r,n===VERDICT_PASS])}return s}export function testValuesReader(e){let t,s=[];return function(o,n){const i=dieLink(o);if(i===void 0){const f=o.testValues;for(let c=0;c<e.length;c++){const l=f?.[e[c]];n[c]=l===void 0?NaN:l}return n}i.table!==t&&(t=i.table,s=e.map(f=>i.table.values.get(f)));for(let f=0;f<s.length;f++){const c=s[f];n[f]=c===void 0?NaN:c[i.row]}return n}}export function recordedVerdictsReader(e){let t,s=[];return function(o,n){const i=dieLink(o);if(i===void 0){const f=o.testPass;for(let c=0;c<e.length;c++){const l=f?.[e[c]];n[c]=l===void 0?VERDICT_NONE:l?VERDICT_PASS:VERDICT_FAIL}return n}i.table!==t&&(t=i.table,s=e.map(f=>i.table.verdicts.get(f)));for(let f=0;f<s.length;f++){const c=s[f];n[f]=c===void 0?VERDICT_NONE:c[i.row]}return n}}export function testsPresent(e,t="all"){const s=new Set,r=new Map;for(const o of e){const n=dieLink(o);if(n===void 0){if(o.testValues)for(const f in o.testValues)s.add(Number(f));if(t==="all"&&o.testPass)for(const f in o.testPass)s.add(Number(f));continue}let i=r.get(n.table);i===void 0&&r.set(n.table,i=[]),i.push(n.row)}for(const[o,n]of r){for(const[i,f]of o.values)!s.has(i)&&n.some(c=>!Number.isNaN(f[c]))&&s.add(i);if(t!=="values")for(const[i,f]of o.verdicts)!s.has(i)&&n.some(c=>f[c]!==VERDICT_NONE)&&s.add(i)}return[...s].sort((o,n)=>o-n)}
1
+ import{hasAnyKey as P}from"./utils.js";const O=NaN;export const VERDICT_NONE=-1,VERDICT_FAIL=0,VERDICT_PASS=1,HAS_VALUES=1,HAS_VERDICTS=2;const l=Symbol("wmap.dieTable"),a=Symbol("wmap.dieRow");export function linkDie(e,t,s){return e[l]=t,e[a]=s,e}export function dieLink(e){const t=e[l];return t===void 0?void 0:{table:t,row:e[a]}}export function tableFromRows(e){const t=e.length,s=new Map,o=new Map,r=new Uint8Array(t),n=g(s,()=>new Float64Array(t).fill(O)),c=g(o,()=>new Int8Array(t).fill(VERDICT_NONE));for(let u=0;u<t;u++){const f=e[u].testValues;if(f){r[u]|=HAS_VALUES;const d=n(f),w=Object.values(f);for(let b=0;b<d.length;b++)d[b][u]=w[b]}const i=e[u].testPass;if(i){r[u]|=HAS_VERDICTS;const d=c(i),w=Object.values(i);for(let b=0;b<d.length;b++)d[b][u]=w[b]?VERDICT_PASS:VERDICT_FAIL}}return{rows:t,values:m(s),verdicts:m(o),fields:r}}function g(e,t){let s=[],o=[];return r=>{const n=Object.keys(r);let c=n.length===s.length;for(let u=0;c&&u<n.length;u++)c=n[u]===s[u];return c||(s=n,o=n.map(u=>{let f=e.get(u);return f===void 0&&e.set(u,f=t()),f})),o}}function m(e){return new Map([...e].map(([t,s])=>[Number(t),s]).sort((t,s)=>t[0]-s[0]))}export function extendTable(e,t,s){const o=new Map(e.values),r=new Map(e.verdicts);for(const[n,c]of t)o.set(n,c);for(const[n,c]of s)r.set(n,c);return{rows:e.rows,values:new Map([...o].sort((n,c)=>n[0]-c[0])),verdicts:new Map([...r].sort((n,c)=>n[0]-c[0])),fields:e.fields.slice(),...e.excluded?{excluded:e.excluded,excludedBy:e.excludedBy}:{}}}export function withExcluded(e,t,s,o){const r=new Map(e.values);for(const[c,u]of t)r.set(c,u);const n=new Map(e.excluded??[]);for(const[c,u]of s)n.set(c,u);return{...e,values:r,excluded:n,excludedBy:o}}export function excludedCounts(e){const t=new Map;let s;for(const o of e){const r=o[l];if(r?.excluded===void 0)continue;const n=o[a];for(const[c,u]of r.excluded)Number.isNaN(u[n])||(t.set(c,(t.get(c)??0)+1),s??=r.excludedBy)}return t.size===0||s===void 0?void 0:{counts:t,by:s}}export function excludedBy(e){return e[l]?.excludedBy}export function excludedValue(e,t){const o=e[l]?.excluded?.get(t)?.[e[a]];return o===void 0||Number.isNaN(o)?void 0:o}export function rowView(e){const t=linkDie({},e,0);return s=>(t[a]=s,t)}function v(e,t){const s={},o=[...e.values];for(let r=o.length-1;r>=0;r--){const n=o[r][1][t];Number.isNaN(n)||(s[o[r][0]]=n)}return s}function x(e,t){const s={},o=[...e.verdicts];for(let r=o.length-1;r>=0;r--){const n=o[r][1][t];n!==VERDICT_NONE&&(s[o[r][0]]=n===VERDICT_PASS)}return s}function j(){return Object.freeze(v(this[l],this[a]))}function k(){return Object.freeze(x(this[l],this[a]))}function N(e){return function(){throw new TypeError(`wafermap: die.${e} is read-only on a die built by buildWaferMap (die ${this.id}). Pass the values you want to buildWaferMap, or copy the die: { ...die, ${e}: yours }.`)}}const V={get:j,set:N("testValues"),enumerable:!0,configurable:!0},y={get:k,set:N("testPass"),enumerable:!0,configurable:!0},p=e=>({value:e,writable:!0,enumerable:!1,configurable:!0});export function finaliseDie(e){const t=e[l];if(t===void 0)return e;const s=e[a],o=t.fields[s],r=e.testValues!==void 0&&!(o&HAS_VALUES)||e.testPass!==void 0&&!(o&HAS_VERDICTS),n={};for(const c of Object.keys(e))c==="testValues"&&o&HAS_VALUES||c==="testPass"&&o&HAS_VERDICTS||(n[c]=e[c]);return r?(o&HAS_VALUES&&(n.testValues=v(t,s)),o&HAS_VERDICTS&&(n.testPass=x(t,s)),n):(Object.defineProperty(n,l,p(t)),Object.defineProperty(n,a,p(s)),o&HAS_VALUES&&Object.defineProperty(n,"testValues",V),o&HAS_VERDICTS&&Object.defineProperty(n,"testPass",y),n)}export function copyDie(e,t){const s=e[l];if(s===void 0)return{...e,...t};const o=e[a],r=s.fields[o],n={};for(const c of Object.keys(e))c!=="testValues"&&c!=="testPass"&&(n[c]=e[c]);return"testValues"in t||"testPass"in t?(r&HAS_VALUES&&!("testValues"in t)&&(n.testValues=v(s,o)),r&HAS_VERDICTS&&!("testPass"in t)&&(n.testPass=x(s,o)),Object.assign(n,t)):(Object.assign(n,t),Object.defineProperty(n,l,p(s)),Object.defineProperty(n,a,p(o)),r&HAS_VALUES&&Object.defineProperty(n,"testValues",V),r&HAS_VERDICTS&&Object.defineProperty(n,"testPass",y),n)}export function detachTables(e){const t=[],s=new Map,o=e.reduce((u,f)=>u+f.length,0),r=new Int32Array(o*2);let n=0;for(const u of e)for(const f of u){const i=dieLink(f);if(i===void 0){r[n++]=-1,r[n++]=0;continue}let d=s.get(i.table);d===void 0&&(s.set(i.table,d=t.length),t.push(i.table)),r[n++]=d,r[n++]=i.row,delete f.testValues,delete f.testPass}const c=new Set;for(const u of t){for(const f of u.values.values())c.add(f.buffer);for(const f of u.verdicts.values())c.add(f.buffer);if(c.add(u.fields.buffer),u.excluded)for(const f of u.excluded.values())c.add(f.buffer)}return{tables:t,links:r,transfer:[...c]}}export function attachTables(e,t){let s=0;for(const o of e)for(const r of o){const n=t.links[s++],c=t.links[s++];if(n<0)continue;const u=t.tables[n],f=u.fields[c];Object.defineProperty(r,l,p(u)),Object.defineProperty(r,a,p(c)),f&HAS_VALUES&&Object.defineProperty(r,"testValues",V),f&HAS_VERDICTS&&Object.defineProperty(r,"testPass",y)}}export function testValue(e,t){const s=e[l];if(s===void 0)return e.testValues?.[t];const o=s.values.get(t)?.[e[a]];return o===void 0||Number.isNaN(o)?void 0:o}export function recordedVerdict(e,t){const s=e[l];if(s===void 0)return e.testPass?.[t];const o=s.verdicts.get(t)?.[e[a]];return o===void 0||o===VERDICT_NONE?void 0:o===VERDICT_PASS}export function dieHasAnyTestData(e){return dieHasValues(e)||dieHasVerdicts(e)}export function dieHasValues(e){const t=dieLink(e);if(t===void 0)return P(e.testValues);for(const s of t.table.values.values())if(!Number.isNaN(s[t.row]))return!0;return!1}export function dieHasVerdicts(e){const t=dieLink(e);if(t===void 0)return P(e.testPass);for(const s of t.table.verdicts.values())if(s[t.row]!==VERDICT_NONE)return!0;return!1}export function dieValueEntries(e){const t=dieLink(e);if(t===void 0){const o=e.testValues;return o===void 0?[]:Object.keys(o).map(r=>[Number(r),o[Number(r)]])}const s=[];for(const[o,r]of t.table.values){const n=r[t.row];Number.isNaN(n)||s.push([o,n])}return s}export function dieVerdictEntries(e){const t=dieLink(e);if(t===void 0){const o=e.testPass;return o===void 0?[]:Object.keys(o).map(r=>[Number(r),o[Number(r)]])}const s=[];for(const[o,r]of t.table.verdicts){const n=r[t.row];n!==VERDICT_NONE&&s.push([o,n===VERDICT_PASS])}return s}export function testValuesReader(e){let t,s=[];return function(r,n){const c=dieLink(r);if(c===void 0){const u=r.testValues;for(let f=0;f<e.length;f++){const i=u?.[e[f]];n[f]=i===void 0?NaN:i}return n}c.table!==t&&(t=c.table,s=e.map(u=>c.table.values.get(u)));for(let u=0;u<s.length;u++){const f=s[u];n[u]=f===void 0?NaN:f[c.row]}return n}}export function recordedVerdictsReader(e){let t,s=[];return function(r,n){const c=dieLink(r);if(c===void 0){const u=r.testPass;for(let f=0;f<e.length;f++){const i=u?.[e[f]];n[f]=i===void 0?VERDICT_NONE:i?VERDICT_PASS:VERDICT_FAIL}return n}c.table!==t&&(t=c.table,s=e.map(u=>c.table.verdicts.get(u)));for(let u=0;u<s.length;u++){const f=s[u];n[u]=f===void 0?VERDICT_NONE:f[c.row]}return n}}export function testsPresent(e,t="all"){const s=new Set,o=new Map;for(const r of e){const n=dieLink(r);if(n===void 0){if(r.testValues)for(const u in r.testValues)s.add(Number(u));if(t==="all"&&r.testPass)for(const u in r.testPass)s.add(Number(u));continue}let c=o.get(n.table);c===void 0&&o.set(n.table,c=[]),c.push(n.row)}for(const[r,n]of o){for(const[c,u]of r.values)!s.has(c)&&n.some(f=>!Number.isNaN(u[f]))&&s.add(c);if(t!=="values")for(const[c,u]of r.verdicts)!s.has(c)&&n.some(f=>u[f]!==VERDICT_NONE)&&s.add(c)}return[...s].sort((r,n)=>r-n)}
@@ -36,6 +36,12 @@ export declare function itemPassBins(item: {
36
36
  } | null | undefined, fallback?: readonly number[]): readonly number[];
37
37
  /** Same bins, in any order. */
38
38
  export declare function sameBins(a: readonly number[], b: readonly number[]): boolean;
39
+ /**
40
+ * Whether a hard or soft bin number is a pass bin. Pass bins are hard-bin numbers; they judge a soft bin only
41
+ * when the dies carry no hard bin, when a die's verdict is its soft bin's (`diePassStatus`). Otherwise a soft
42
+ * bin's verdict is not known from the pass bins, and it is not called a pass bin.
43
+ */
44
+ export declare function isPassBin(kind: 'hardBin' | 'softBin', bin: number, passBins: readonly number[], hasHardBins: boolean): boolean;
39
45
  /**
40
46
  * The pass bins every wafer is judged by, or `undefined` when they differ (or there are none to
41
47
  * ask). For a surface that must name one set — a headline, or which bins count as failures — and
@@ -1 +1 @@
1
- const r=[1];export function normalizePassBins(s){return[...s??r]}export function requirePassBins(s,n){const e=s?.passBins;if(!e)throw new Error(`${n}: no pass bins (WaferMapResult.passBins); a map not built by buildWaferMap must state them.`);return e}export function itemPassBins(s,n){return s?.passBins??n??requirePassBins(void 0,"itemPassBins")}export function sameBins(s,n){const e=new Set(s),t=new Set(n);return e.size===t.size&&[...e].every(i=>t.has(i))}export function commonPassBins(s){let n;for(const e of s){if(e===void 0)return;if(n===void 0)n=e;else if(!sameBins(n,e))return}return n}export function passBinsLabel(s){const n=[];for(const t of s)n.some(i=>sameBins(i,t))||n.push(t);const e=t=>t.length===0?"no bins":t.length===1?`bin ${t[0]}`:`bins ${t.join(", ")}`;return n.length===0?"no wafers":n.length===1?e(n[0]):`per wafer: ${n.map(e).join(" \xB7 ")}`}
1
+ const r=[1];export function normalizePassBins(s){return[...s??r]}export function requirePassBins(s,n){const e=s?.passBins;if(!e)throw new Error(`${n}: no pass bins (WaferMapResult.passBins); a map not built by buildWaferMap must state them.`);return e}export function itemPassBins(s,n){return s?.passBins??n??requirePassBins(void 0,"itemPassBins")}export function sameBins(s,n){const e=new Set(s),t=new Set(n);return e.size===t.size&&[...e].every(i=>t.has(i))}export function isPassBin(s,n,e,t){return(s==="hardBin"||!t)&&e.includes(n)}export function commonPassBins(s){let n;for(const e of s){if(e===void 0)return;if(n===void 0)n=e;else if(!sameBins(n,e))return}return n}export function passBinsLabel(s){const n=[];for(const t of s)n.some(i=>sameBins(i,t))||n.push(t);const e=t=>t.length===0?"no bins":t.length===1?`bin ${t[0]}`:`bins ${t.join(", ")}`;return n.length===0?"no wafers":n.length===1?e(n[0]):`per wafer: ${n.map(e).join(" \xB7 ")}`}
@@ -1 +1 @@
1
- import{requirePassBins as ge}from"../core/passBins.js";import{requireRingCount as ye}from"../core/ringCount.js";import{hasPosition as be}from"../core/dies.js";import{dieValueEntries as xe,dieVerdictEntries as Me,recordedVerdict as Se,testsPresent as Ot}from"../core/dieTable.js";import{getReticleCell as ve}from"../core/reticle.js";import{metadataCategoricalValue as Be,metadataDisplayValue as ke}from"../core/metadata.js";import{affineRotation as bt,affineMirror as wt,affineCompose as st,affinePoint as G,affineVector as $e,affineSwapsAxes as Ie}from"../core/transforms.js";import{contrastTextColor as Q,SPEC_PASS_FILL as xt,SPEC_FAIL_LOW as Te,SPEC_FAIL_HIGH as Mt}from"./colorMap.js";import{resolveValueColorFn as De}from"./colorSchemes.js";import{resolveBinColors as Ce,binColorsCover as Ve}from"./binColors.js";import{NO_DATA_FILL as z}from"./colorMap.js";import{diePassStatus as Fe}from"../core/dies.js";import{compactView as Le}from"./compactView.js";import{buildXYIndicator as Re}from"./xyIndicator.js";import{getDieTestValue as L,getTestPassStatus as U,isParametricTest as St}from"./buildWaferMap.js";import{classifySpec as ot}from"./spec.js";export{ot as classifySpec};import{fmt as vt,fmtColorbarAxis as Bt,fmtAggregationMethod as qt}from"./fmt.js";import{metadataValueColor as Pe}from"./colorMap.js";import{asList as Kt,clamp01 as Wt,compareNatural as Ne,escHtml as R}from"../core/utils.js";import{prettyKey as zt}from"../core/utils.js";import{testLabel as rt,markedTestLabel as lt,derivedTestNote as jt,isDerivedTest as Ee,DERIVED_MARK as Ae,DERIVED_KEY as He}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(i.partial||i.edgeExcluded)continue;const s=ct(i,e);s!==void 0&&n.add(s)}return[...n].sort(Ne)}export function findTestDef(t,e){return t?.find(n=>n.testNumber===e)}export function getUniqueTestNumbers(t){return Ot(t,"values")}const _e="#d3d6db",Xt="#e8e9ea",Oe="#aab0ba";function ct(t,e){return e?Be(t.metadata?.[e]):void 0}function we(t,e,n){const{x:i,y:s}=t.center,a=bt(t.orientation,i,s),o=st(wt(e?.x??!1,e?.y??!1,i,s),bt(t.orientation,i,s)),r=st(wt(n?.flipX??!1,n?.flipY??!1,i,s),bt(n?.rotation??0,i,s));return{bakedToScreen:r,physicalToScreen:st(r,a),gridToScreen:st(r,o)}}function Y(t,e=!1){return{points:[t],closed:e}}function qe(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),d=s.length/2,y=a-n.x,b=o-n.y;return s.type==="bottom"&&b<-r?(o=n.y-r,a=n.x+Math.max(-d,Math.min(d,y))):s.type==="top"&&b>r?(o=n.y+r,a=n.x+Math.max(-d,Math.min(d,y))):s.type==="left"&&y<-r?(a=n.x-r,o=n.y+Math.max(-d,Math.min(d,b))):s.type==="right"&&y>r&&(a=n.x+r,o=n.y+Math.max(-d,Math.min(d,b))),{x:a,y:o}}function Yt(t,e){return t.map(e).join(" / ")}function Ke(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 We(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 ze(t,e,n){if(e?.length){const a=e.flatMap(o=>{const r=o.testNumber;if(!St(o)){const y=U(t,r,o);return y===void 0?[]:[{key:r,label:lt(o,r),value:y?"Pass":"Fail"}]}const d=L(t,r);return d===void 0?[]:[{key:r,label:lt(o,r),value:vt(d,o.unit,n),recordedFail:Se(t,r)===!1}]});if(a.length)return a}const i=xe(t);if(i.length)return i.map(([a,o])=>({key:a,label:rt(void 0,a),value:vt(o,void 0,n)}));const s=Me(t);return s.length?s.map(([a,o])=>({key:a,label:rt(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:d,activeTest:y,reticleConfig:b,metadataFields:k}=n,D=s?new Map(s.map(f=>[f.bin,f])):null,I=a?new Map(a.map(f=>[f.bin,f])):null,g=[R(`Die (${t.x}, ${t.y})`)];if(b&&be(t)){const f=ve(t,b);g.push(R(`Reticle (${f.column}, ${f.row})`))}if(e==="stackedValues"){const f=L(t,0);if(f!==void 0){const u=i?.[0],m=u?lt(u,u.testNumber):"Value",S=r?` (${r})`:"";g.push(R(`${m}${S}: ${vt(f,u?.unit,o)}`));const h=jt(u);h&&g.push(`<i>${R(h)}</i>`)}}else if(e==="stackedBins"||e==="stackedSoftBins"){const f=L(t,0),u=e==="stackedSoftBins"?t.sbin:t.hbin;if(f!==void 0){const m=e==="stackedSoftBins"?I:D,S=u!==void 0?m?.get(u)?.name?`${u} \xB7 ${m.get(u).name}`:`Bin ${u}`:"Bin";let h;if(r==="percent")h=`${f.toFixed(0)}%`;else{const C=d?` (${(f/d*100).toFixed(0)}% of stacked wafers)`:"";h=`${f}${C}`}const x=r?` [${qt(r)}]`:"";g.push(R(`${S}: ${h}${x}`))}}else{const f=ze(t,i,o);if(e==="value"&&f.length){const{testNumber:u}=resolveTestNumber(y??0,i),m=findTestDef(i,u),S=L(t,u);let h=f.findIndex(A=>A.key===u);h<0&&(h=0);const x=f[h];let C=`<b>${R(`${x.label}: ${x.value}`)}${x.recordedFail?" <i>(recorded fail)</i>":""}</b>`;if(x.key===u&&m){const A=ot(S,m);(A==="failLow"||A==="failHigh")&&(C+=" <i>(outside test limits)</i>")}g.push(C);const E=jt(findTestDef(i,x.key));E&&g.push(`<i>${R(E)}</i>`);const p=f.length-1;p>0&&g.push(`<i>+${p} more test${p===1?"":"s"}</i>`)}else if(f.length){const u=f.length;g.push(`<i>${u} test result${u===1?"":"s"} recorded</i>`)}if(t.hbin!==void 0||t.sbin!==void 0){const u=[];if(t.hbin!==void 0){const m=D?.get(t.hbin)?.name,S=m?`${t.hbin} \xB7 ${m}`:String(t.hbin);u.push(`HBin: ${S}`)}if(t.sbin!==void 0){const m=I?.get(t.sbin)?.name,S=m?`${t.sbin} \xB7 ${m}`:String(t.sbin);u.push(`SBin: ${S}`)}g.push(u.map(R).join(" &nbsp;\xB7&nbsp; "))}}t.retestCount!==void 0&&g.push(R(`Retests: ${t.retestCount}`)),t.siteNum!==void 0&&g.push(R(`Site: ${t.siteNum}`)),t.partId!==void 0&&g.push(R(`Part ID: ${t.partId}`)),t.partial&&g.push("<i>partial die</i>"),t.probeIndex!==void 0&&g.push(R(`Probe: #${t.probeIndex}`));const B={...t.metadata??{}};for(const[f,u]of Object.entries(B)){const m=ke(u);if(m===void 0)continue;const S=k?.find(h=>h.key===f)?.label??zt(f);g.push(R(`${S}: ${m}`))}return g.join("<br>")}function kt(t){return t?.name?lt(t,t.testNumber):void 0}function $t(t){return Ee(t)?{note:`${Ae} ${He}`}:{}}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?zt(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}=Bt(o,kt(a),a?.unit,e),d=r||"Value",y=t.aggrMethod?` \xB7 ${qt(t.aggrMethod)}`:"";return{primary:`${d}${y}`,secondary:i,...$t(a)}}default:{const a=findTestDef(t.testDefs,t.activeTest),o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=Bt(o,kt(a),a?.unit,e),d=r||kt(a);if(t.passFailDisplay!=="off"){const y=a?.testNumber??t.activeTest,b=d?`${d} \xB7 #${y}`:rt(void 0,y),k=t.passFailDisplay==="spec"?"Limit pass/fail":a!==void 0&&!St(a)?"Functional pass/fail":"Tester pass/fail";return{primary:b,secondary:k,...$t(a)}}return{primary:d??rt(void 0,t.activeTest),secondary:"",...$t(a)}}}}export function generateTextOverlay(t,e,n){const{plotMode:i,colorFns:s,normalize:a,activeTest:o,valueRange:r,testDefs:d,fallbackFormat:y,passFailDisplay:b="off",activeMetadataKey:k,metadataColorMap:D,allIntegerValues:I}=n,g=findTestDef(d,o),{tickFmt:B}=Bt(r[1],g?.name,g?.unit,y),f=I?m=>String(Math.round(m)):B,{testNumber:u}=resolveTestNumber(o,d);return t.flatMap((m,S)=>{let h="",x="#111111";if(i==="value"&&b==="test"){const p=U(m,u,g);if(p===void 0)return[];h=p?"P":"F",x=Q(p?xt:Mt)}else if(i==="value"){const p=L(m,u);if(p===void 0)return[];h=Yt([p],f),x=Q(s.forValue(a(p)))}else if(i==="hardBin"||i==="softBin"){const p=i==="softBin"?m.sbin:m.hbin;if(p===void 0)return[];h=String(p),x=Q(s.forBin(p))}else if(i==="metadata"){const p=ct(m,k);if(p===void 0)return[];h=p,x=Q(D?.get(h)??z)}else{const p=L(m,0);if(p===void 0)return[];h=Yt([p],f),x=Q(s.forValue(a(p)))}const C=e?e[S*2]:m.physX,E=e?e[S*2+1]:m.physY;return[{x:C,y:E,text:h,fontSize:We(m,h),color:x,align:"center"}]})}function Gt(t){return t==="top"?Math.PI/2:t==="bottom"?-Math.PI/2:t==="left"?Math.PI:0}function je(t,e,n=720){const{center:i,radius:s,notch:a}=t,o=B=>G(e,B.x,B.y);if(!(a!==void 0&&t.diameter>150)){const B=[];for(let f=0;f<=n;f++){const u=2*Math.PI*f/n;B.push(o(qe(t,u)))}return[{kind:"wafer-boundary",...Y(B,!0),lineColor:"#888888",lineWidth:1}]}const d=1.25,y=a.length,b=Gt(a.type),k=Math.atan2(y,s),D=s-d,I=[];let g=!1;for(let B=0;B<=n;B++){const f=2*Math.PI*B/n;let u=f-b;for(;u>Math.PI;)u-=2*Math.PI;for(;u<-Math.PI;)u+=2*Math.PI;if(Math.abs(u)<=k){if(!g){g=!0;const m={x:i.x+s*Math.cos(b-k),y:i.y+s*Math.sin(b-k)},S={x:i.x+D*Math.cos(b),y:i.y+D*Math.sin(b)},h={x:i.x+s*Math.cos(b+k),y:i.y+s*Math.sin(b+k)};I.push(o(m),o(S),o(h))}continue}I.push(o({x:i.x+s*Math.cos(f),y:i.y+s*Math.sin(f)}))}return[{kind:"wafer-boundary",...Y(I,!0),lineColor:"#888888",lineWidth:1}]}function Xe(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,d=[];for(let y=0;y<=i;y++){const b=2*Math.PI*y/i,k={x:t.center.x+r*Math.cos(b),y:t.center.y+r*Math.sin(b)};d.push(G(e,k.x,k.y))}s.push({kind:"ring-boundary",...Y(d,!0),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5})}return s}function Ye(t,e,n,i){const{x:s,y:a}=t.center,o=t.radius,r=(f,u)=>G(e,f,u),d=n-s,y=Math.sqrt(Math.max(0,o*o-d*d)),b=r(n,a-y),k=r(n,a+y),D=i-a,I=Math.sqrt(Math.max(0,o*o-D*D)),g=r(s-I,i),B=r(s+I,i);return[{kind:"quadrant-boundary",...Y([b,k]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5},{kind:"quadrant-boundary",...Y([g,B]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5}]}function Ge(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])=>G(e,o,r))],closed:!0,lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5,fill:"rgba(0,0,0,0)"}})}function Qe(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 Ue(t,e,n,i,s,a,o,r,d,y,b,k,D,I,g="off",B,f,u){const m=e.width-o,S=e.height-o,h=a?S:m,x=a?m:S,C=M=>s==="softBin"?M.sbin:M.hbin,E=M=>ct(M,B);if(e.partial){t.push({x:n,y:i,width:h,height:x,fill:_e,type:"stacked",metadata:e.metadata});return}if(e.edgeExcluded){t.push({x:n,y:i,width:h,height:x,fill:Oe,type:"stacked",metadata:e.metadata});return}if(d!==void 0&&(s==="hardBin"||s==="softBin")&&!d.has(C(e))){t.push({x:n,y:i,width:h,height:x,fill:Xt,type:"hardBin",metadata:e.metadata});return}if(u!==void 0&&s==="metadata"&&!u.has(E(e))){t.push({x:n,y:i,width:h,height:x,fill:Xt,type:"metadata",metadata:e.metadata});return}if(s==="value"){if(g==="test"){const q=U(e,b,I),ut=q===void 0?z:q?xt:Mt;t.push({x:n,y:i,width:h,height:x,fill:ut,type:"value",metadata:e.metadata});return}const M=L(e,b),P=ot(M,I);let w,J;M===void 0?w=z:g==="spec"?w=P==="failLow"?Te:P==="failHigh"?Mt:xt:(w=r.forValue(y(M)),(P==="failLow"||P==="failHigh")&&(J=P)),t.push({x:n,y:i,width:h,height:x,fill:w,type:"value",specMark:J,metadata:e.metadata});return}if(s==="hardBin"||s==="softBin"){const M=C(e),P=M!=null?r.forBin(M):z,w=M!=null&&Fe(e,D)===!1?!0:void 0;t.push({x:n,y:i,width:h,height:x,fill:P,type:s,binFail:w,metadata:e.metadata});return}if(s==="metadata"){const M=E(e),P=M!==void 0?f?.get(M)??z:z;t.push({x:n,y:i,width:h,height:x,fill:P,type:"metadata",metadata:e.metadata});return}const p=L(e,0),A=p!==void 0?r.forValue(y(p)):z;t.push({x:n,y:i,width:h,height:x,fill:A,type:"value",metadata:e.metadata})}function Je(t,e,n){const i=t.radius;return Re(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:d=!1,ringCount:y,showRingBoundaries:b=!1,showQuadrantBoundaries:k=!1,showXYIndicator:D=!1,binColorScheme:I="default",valueColorScheme:g="default",reverseValueScheme:B=!1,useDefinedBinColors:f=!0,binColors:u,passBins:m,highlightBin:S,highlightMetadataValue:h,interactiveTransform:x,valueRange:C,metadataValueOrder:E,testDefs:p,activeTest:A=0,activeMetadataKey:M,fallbackFormat:P="engineering",aggregationMethod:w,lotSize:J,dataAxisFlip:q,isLotStack:ut=!1,logScale:Qt,colorbarRangeMode:Ut="spec",passFailDisplay:Jt}=n,It=Jt??"off",ft=i?.hbinDefs,dt=i?.sbinDefs,Tt=i?.metadataFields,Zt=Tt?.find(l=>l.key===M),te={x:(q?.x??!1)!==(x?.flipX??!1),y:(q?.y??!1)!==(x?.flipY??!1)},ee=ft?new Map(ft.map(l=>[l.bin,l])):null,ne=dt?new Map(dt.map(l=>[l.bin,l])):null,ae=a==="softBin"?ne:ee,Dt=ge({passBins:m},"buildView"),ie=new Set(Dt),ht=u&&Ve(u,e)?u:Ce(e,{passBins:Dt,binColorScheme:I,hbinDefs:ft,sbinDefs:dt,useDefinedBinColors:f}),se=a==="softBin"?ht.soft:ht.hard,Ct={forValue:Ke(De(g,B)),forBin:l=>se.get(l)??z};let{testNumber:H}=resolveTestNumber(A,p);if(!p?.length&&a==="value"){const l=Ot(e,"values");!l.includes(H)&&l.length&&(H=l[0])}let Z;if(Array.isArray(C))Z=C;else if(C){const{testNumber:l}=resolveTestNumber(C.test,p);Z=l===H?C.range:void 0}const T=findTestDef(p,H),Vt=a==="value"&&T!==void 0&&!St(T),oe=T!==void 0&&(T.limitLow!==void 0||T.limitHigh!==void 0);let O="off";a==="value"&&(Vt?O="test":It==="spec"&&oe?O="spec":It==="test"&&e.some(l=>U(l,H,T)!==void 0)&&(O="test"));const Ft=O==="spec"?"spec":Ut,mt=a==="stackedValues"||a==="stackedBins"||a==="stackedSoftBins";let N,_,tt=!1;if(Z){[N,_]=Z;let l=!0,c=!1;for(const v of e){const F=mt?L(v,0):L(v,H);if(F!==void 0&&(c=!0,!Number.isInteger(F))){l=!1;break}}tt=c&&l}else{const l=!mt&&a==="value"&&Ft==="spec"&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0);let c=1/0,v=-1/0,F=!0;for(const $ of e){const W=mt?L($,0):L($,H);W!==void 0&&(W<c&&(c=W),W>v&&(v=W),Number.isInteger(W)||(F=!1))}isFinite(c)||(F=!1),tt=F,l?(N=T.limitLow!==void 0?T.limitLow:isFinite(c)?c:0,_=T.limitHigh!==void 0?T.limitHigh:isFinite(v)?v:1):(N=isFinite(c)?c:0,_=isFinite(v)?v:1)}N===_&&(_=N+1);const Lt=Vt?!1:Qt??T?.logScale??!1,Rt=Lt&&N>0&&_>0,re=Rt;let et;if(Rt){const l=Math.log10(N),c=Math.log10(_)-l;et=v=>v<=0?0:Wt((Math.log10(v)-l)/c)}else et=l=>Wt((l-N)/(_-N));const V=we(t,q,x);let Pt=null;if(t.notch){const l=Gt(t.notch.type),c=$e(V.physicalToScreen,Math.cos(l)*t.radius,Math.sin(l)*t.radius),v=Math.hypot(c.x,c.y);v>0&&(Pt={x:c.x/v,y:c.y/v})}let j=1/0;for(let l=0;l<e.length;l++){const c=e[l];c.width<j&&(j=c.width),c.height<j&&(j=c.height)}const Nt=1,le=j!==1/0?Math.min(Nt,j*.12):Nt,Et=[],pt=[],ce=V.bakedToScreen.a===1&&V.bakedToScreen.b===0&&V.bakedToScreen.c===0&&V.bakedToScreen.d===1&&V.bakedToScreen.e===0&&V.bakedToScreen.f===0;let K=null;if(!ce){K=new Float64Array(e.length*2);for(let l=0;l<e.length;l++){const c=G(V.bakedToScreen,e[l].physX,e[l].physY);K[l*2]=c.x,K[l*2+1]=c.y}}const ue=Ie(V.gridToScreen),fe=a==="hardBin"||a==="softBin"||a==="stackedBins"||a==="stackedSoftBins",de=a==="softBin"||a==="stackedSoftBins";let nt=fe?new Map:void 0;const gt=a==="value"&&O==="spec"?{pass:0,failHigh:0,failLow:0}:void 0,yt=a==="value"&&O==="test"?{pass:0,fail:0}:void 0,At=a==="metadata";let at=At?new Map:void 0,it=null;if(At&&M){const l=collectMetadataValues(e,M),c=E?.key===M?E.values:void 0,v=c?[...c,...l.filter(F=>!c.includes(F))]:l;it=new Map(v.map((F,$)=>[F,Zt?.values?.find(W=>W.value===F)?.color??Pe($)]))}const he=S===void 0?void 0:new Set(Kt(S)),me=h===void 0?void 0:new Set(Kt(h));for(let l=0;l<e.length;l++){const c=e[l],v=K?K[l*2]:c.physX,F=K?K[l*2+1]:c.physY;if(pt.push({x:v,y:F}),nt&&!c.partial&&!c.edgeExcluded){const $=de?c.sbin:c.hbin;$!=null&&nt.set($,(nt.get($)??0)+1)}if(gt&&!c.partial&&!c.edgeExcluded){const $=ot(L(c,H),T);$&&gt[$]++}if(yt&&!c.partial&&!c.edgeExcluded){const $=U(c,H,T);$!==void 0&&yt[$?"pass":"fail"]++}if(at&&!c.partial&&!c.edgeExcluded){const $=ct(c,M);$!==void 0&&at.set($,(at.get($)??0)+1)}Ue(Et,c,v,F,a,ue,le,Ct,he,et,H,ae,ie,T,O,M,it,me)}const Ht=o?generateTextOverlay(e,K,{plotMode:a,colorFns:Ct,normalize:et,activeTest:A,valueRange:[N,_],testDefs:p,fallbackFormat:P,passFailDisplay:O,activeMetadataKey:M,metadataColorMap:it,allIntegerValues:tt}):[],X=je(t,V.physicalToScreen);b&&X.push(...Xe(t,V.physicalToScreen,ye({ringCount:y},"buildView"))),k&&X.push(...Ye(t,V.physicalToScreen,t.center.x,t.center.y)),r&&X.push(...Ge(s,V.gridToScreen)),d&&X.push(...Qe(e)),D&&X.push(...Je(t,V.gridToScreen,Ht));const pe=pt.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,_t={rectangles:Et,hoverPoints:pt,texts:Ht,overlays:X,plotMode:a,binColorScheme:I,valueColorScheme:g,reverseValueScheme:B,binColors:ht,metadata:t.metadata??null,dies:e,valueRange:[N,_],allIntegerValues:tt,testDefs:p,activeTest:A,logScale:re,logScaleRequested:Lt,aggrMethod:w,lotSize:J,axisFlip:te,dataAxisFlip:{x:q?.x??!1,y:q?.y??!1},gridToScreen:V.gridToScreen,rotation:((t.orientation+(x?.rotation??0))%360+360)%360,hasReticle:s.length>0,isLotStack:ut,passFailDisplay:O,colorbarRangeMode:Ft,waferCenter:t.center,waferRadius:t.radius,notchDir:Pt,binCounts:nt,metadataCounts:at,metadataColorMap:it,activeMetadataKey:M,metadataFields:Tt,specCounts:gt,passFailCounts:yt,dieBounds:pe};return n.compact?Le(_t,n.compact,{showXYIndicator:D}):_t}export{getDieKey}from"../core/dies.js";
1
+ import{requirePassBins as ge}from"../core/passBins.js";import{requireRingCount as ye}from"../core/ringCount.js";import{hasPosition as be}from"../core/dies.js";import{dieValueEntries as xe,dieVerdictEntries as Me,excludedBy as Se,excludedValue as ve,recordedVerdict as Be,testsPresent as Ot}from"../core/dieTable.js";import{limitSetName as $e}from"./valueFilter.js";import{getReticleCell as ke}from"../core/reticle.js";import{metadataCategoricalValue as Ie,metadataDisplayValue as Te}from"../core/metadata.js";import{affineRotation as xt,affineMirror as wt,affineCompose as ot,affinePoint as G,affineVector as De,affineSwapsAxes as Ve}from"../core/transforms.js";import{contrastTextColor as Q,SPEC_PASS_FILL as Mt,SPEC_FAIL_LOW as Ce,SPEC_FAIL_HIGH as St}from"./colorMap.js";import{resolveValueColorFn as Fe}from"./colorSchemes.js";import{resolveBinColors as Le,binColorsCover as Re}from"./binColors.js";import{NO_DATA_FILL as z}from"./colorMap.js";import{diePassStatus as Pe}from"../core/dies.js";import{compactView as Ne}from"./compactView.js";import{buildXYIndicator as Ee}from"./xyIndicator.js";import{getDieTestValue as L,getTestPassStatus as U,isParametricTest as vt}from"./buildWaferMap.js";import{classifySpec as rt}from"./spec.js";export{rt as classifySpec};import{fmt as lt,fmtColorbarAxis as Bt,fmtAggregationMethod as qt}from"./fmt.js";import{metadataValueColor as Ae}from"./colorMap.js";import{asList as Kt,clamp01 as Wt,compareNatural as He,escHtml as R}from"../core/utils.js";import{prettyKey as zt}from"../core/utils.js";import{testLabel as ct,markedTestLabel as J,derivedTestNote as jt,isDerivedTest as _e,DERIVED_MARK as Oe,DERIVED_KEY as we}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(i.partial||i.edgeExcluded)continue;const s=ut(i,e);s!==void 0&&n.add(s)}return[...n].sort(He)}export function findTestDef(t,e){return t?.find(n=>n.testNumber===e)}export function getUniqueTestNumbers(t){return Ot(t,"values")}const qe="#d3d6db",Xt="#e8e9ea",Ke="#aab0ba";function ut(t,e){return e?Ie(t.metadata?.[e]):void 0}function We(t,e,n){const{x:i,y:s}=t.center,a=xt(t.orientation,i,s),o=ot(wt(e?.x??!1,e?.y??!1,i,s),xt(t.orientation,i,s)),r=ot(wt(n?.flipX??!1,n?.flipY??!1,i,s),xt(n?.rotation??0,i,s));return{bakedToScreen:r,physicalToScreen:ot(r,a),gridToScreen:ot(r,o)}}function Y(t,e=!1){return{points:[t],closed:e}}function ze(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),d=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(-d,Math.min(d,p))):s.type==="top"&&x>r?(o=n.y+r,a=n.x+Math.max(-d,Math.min(d,p))):s.type==="left"&&p<-r?(a=n.x-r,o=n.y+Math.max(-d,Math.min(d,x))):s.type==="right"&&p>r&&(a=n.x+r,o=n.y+Math.max(-d,Math.min(d,x))),{x:a,y:o}}function Yt(t,e){return t.map(e).join(" / ")}function je(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 Xe(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 Ye(t,e,n){if(e?.length){const a=e.flatMap(o=>{const r=o.testNumber;if(!vt(o)){const p=U(t,r,o);return p===void 0?[]:[{key:r,label:J(o,r),value:p?"Pass":"Fail"}]}const d=L(t,r);if(d===void 0){const p=ve(t,r);return p===void 0?[]:[{key:r,label:J(o,r),value:lt(p,o.unit,n),excludedBy:Se(t)}]}return[{key:r,label:J(o,r),value:lt(d,o.unit,n),recordedFail:Be(t,r)===!1}]});if(a.length)return a}const i=xe(t);if(i.length)return i.map(([a,o])=>({key:a,label:ct(void 0,a),value:lt(o,void 0,n)}));const s=Me(t);return s.length?s.map(([a,o])=>({key:a,label:ct(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:d,activeTest:p,reticleConfig:x,metadataFields:$}=n,V=s?new Map(s.map(f=>[f.bin,f])):null,I=a?new Map(a.map(f=>[f.bin,f])):null,y=[R(`Die (${t.x}, ${t.y})`)];if(x&&be(t)){const f=ke(t,x);y.push(R(`Reticle (${f.column}, ${f.row})`))}if(e==="stackedValues"){const f=L(t,0);if(f!==void 0){const u=i?.[0],m=u?J(u,u.testNumber):"Value",S=r?` (${r})`:"";y.push(R(`${m}${S}: ${lt(f,u?.unit,o)}`));const h=jt(u);h&&y.push(`<i>${R(h)}</i>`)}}else if(e==="stackedBins"||e==="stackedSoftBins"){const f=L(t,0),u=e==="stackedSoftBins"?t.sbin:t.hbin;if(f!==void 0){const m=e==="stackedSoftBins"?I:V,S=u!==void 0?m?.get(u)?.name?`${u} \xB7 ${m.get(u).name}`:`Bin ${u}`:"Bin";let h;if(r==="percent")h=`${f.toFixed(0)}%`;else{const D=d?` (${(f/d*100).toFixed(0)}% of stacked wafers)`:"";h=`${f}${D}`}const b=r?` [${qt(r)}]`:"";y.push(R(`${S}: ${h}${b}`))}}else{const f=Ye(t,i,o);if(e==="value"&&f.length){const{testNumber:u}=resolveTestNumber(p??0,i),m=findTestDef(i,u),S=L(t,u);let h=f.findIndex(A=>A.key===u);h<0&&(h=0);const b=f[h];let D=`<b>${R(`${b.label}: ${b.value}`)}${b.recordedFail?" <i>(recorded fail)</i>":""}</b>`;if(b.key===u&&m){const A=rt(S,m);(A==="failLow"||A==="failHigh")&&(D+=" <i>(outside test limits)</i>")}b.excludedBy&&(D+=` <i>(outside ${$e(b.excludedBy)}, excluded)</i>`),y.push(D);const E=jt(findTestDef(i,b.key));E&&y.push(`<i>${R(E)}</i>`);const g=f.length-1;g>0&&y.push(`<i>+${g} more test${g===1?"":"s"}</i>`)}else if(f.length){const u=f.length;y.push(`<i>${u} test result${u===1?"":"s"} recorded</i>`)}if(t.hbin!==void 0||t.sbin!==void 0){const u=[];if(t.hbin!==void 0){const m=V?.get(t.hbin)?.name,S=m?`${t.hbin} \xB7 ${m}`:String(t.hbin);u.push(`HBin: ${S}`)}if(t.sbin!==void 0){const m=I?.get(t.sbin)?.name,S=m?`${t.sbin} \xB7 ${m}`:String(t.sbin);u.push(`SBin: ${S}`)}y.push(u.map(R).join(" &nbsp;\xB7&nbsp; "))}}t.retestCount!==void 0&&y.push(R(`Retests: ${t.retestCount}`)),t.siteNum!==void 0&&y.push(R(`Site: ${t.siteNum}`)),t.partId!==void 0&&y.push(R(`Part ID: ${t.partId}`)),t.partial&&y.push("<i>partial die</i>"),t.probeIndex!==void 0&&y.push(R(`Probe: #${t.probeIndex}`));const B={...t.metadata??{}};for(const[f,u]of Object.entries(B)){const m=Te(u);if(m===void 0)continue;const S=$?.find(h=>h.key===f)?.label??zt(f);y.push(R(`${S}: ${m}`))}return y.join("<br>")}function $t(t){return t?.name?J(t,t.testNumber):void 0}function kt(t){return _e(t)?{note:`${Oe} ${we}`}:{}}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?zt(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}=Bt(o,$t(a),a?.unit,e),d=r||"Value",p=t.aggrMethod?` \xB7 ${qt(t.aggrMethod)}`:"";return{primary:`${d}${p}`,secondary:i,...kt(a)}}default:{const a=findTestDef(t.testDefs,t.activeTest),o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=Bt(o,$t(a),a?.unit,e),d=r||$t(a);if(t.passFailDisplay!=="off"){const p=a?.testNumber??t.activeTest,x=d?`${d} \xB7 #${p}`:ct(void 0,p),$=t.passFailDisplay==="spec"?"Limit pass/fail":a!==void 0&&!vt(a)?"Functional pass/fail":"Tester pass/fail";return{primary:x,secondary:$,...kt(a)}}return{primary:d??ct(void 0,t.activeTest),secondary:"",...kt(a)}}}}export function generateTextOverlay(t,e,n){const{plotMode:i,colorFns:s,normalize:a,activeTest:o,valueRange:r,testDefs:d,fallbackFormat:p,passFailDisplay:x="off",activeMetadataKey:$,metadataColorMap:V,allIntegerValues:I}=n,y=findTestDef(d,o),{tickFmt:B}=Bt(r[1],y?.name,y?.unit,p),f=I?m=>String(Math.round(m)):B,{testNumber:u}=resolveTestNumber(o,d);return t.flatMap((m,S)=>{let h="",b="#111111";if(i==="value"&&x==="test"){const g=U(m,u,y);if(g===void 0)return[];h=g?"P":"F",b=Q(g?Mt:St)}else if(i==="value"){const g=L(m,u);if(g===void 0)return[];h=Yt([g],f),b=Q(s.forValue(a(g)))}else if(i==="hardBin"||i==="softBin"){const g=i==="softBin"?m.sbin:m.hbin;if(g===void 0)return[];h=String(g),b=Q(s.forBin(g))}else if(i==="metadata"){const g=ut(m,$);if(g===void 0)return[];h=g,b=Q(V?.get(h)??z)}else{const g=L(m,0);if(g===void 0)return[];h=Yt([g],f),b=Q(s.forValue(a(g)))}const D=e?e[S*2]:m.physX,E=e?e[S*2+1]:m.physY;return[{x:D,y:E,text:h,fontSize:Xe(m,h),color:b,align:"center"}]})}function Gt(t){return t==="top"?Math.PI/2:t==="bottom"?-Math.PI/2:t==="left"?Math.PI:0}function Ge(t,e,n=720){const{center:i,radius:s,notch:a}=t,o=B=>G(e,B.x,B.y);if(!(a!==void 0&&t.diameter>150)){const B=[];for(let f=0;f<=n;f++){const u=2*Math.PI*f/n;B.push(o(ze(t,u)))}return[{kind:"wafer-boundary",...Y(B,!0),lineColor:"#888888",lineWidth:1}]}const d=1.25,p=a.length,x=Gt(a.type),$=Math.atan2(p,s),V=s-d,I=[];let y=!1;for(let B=0;B<=n;B++){const f=2*Math.PI*B/n;let u=f-x;for(;u>Math.PI;)u-=2*Math.PI;for(;u<-Math.PI;)u+=2*Math.PI;if(Math.abs(u)<=$){if(!y){y=!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)},h={x:i.x+s*Math.cos(x+$),y:i.y+s*Math.sin(x+$)};I.push(o(m),o(S),o(h))}continue}I.push(o({x:i.x+s*Math.cos(f),y:i.y+s*Math.sin(f)}))}return[{kind:"wafer-boundary",...Y(I,!0),lineColor:"#888888",lineWidth:1}]}function Qe(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,d=[];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)};d.push(G(e,$.x,$.y))}s.push({kind:"ring-boundary",...Y(d,!0),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5})}return s}function Ue(t,e,n,i){const{x:s,y:a}=t.center,o=t.radius,r=(f,u)=>G(e,f,u),d=n-s,p=Math.sqrt(Math.max(0,o*o-d*d)),x=r(n,a-p),$=r(n,a+p),V=i-a,I=Math.sqrt(Math.max(0,o*o-V*V)),y=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([y,B]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5}]}function Je(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])=>G(e,o,r))],closed:!0,lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5,fill:"rgba(0,0,0,0)"}})}function Ze(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 tn(t,e,n,i,s,a,o,r,d,p,x,$,V,I,y="off",B,f,u){const m=e.width-o,S=e.height-o,h=a?S:m,b=a?m:S,D=M=>s==="softBin"?M.sbin:M.hbin,E=M=>ut(M,B);if(e.partial){t.push({x:n,y:i,width:h,height:b,fill:qe,type:"stacked",metadata:e.metadata});return}if(e.edgeExcluded){t.push({x:n,y:i,width:h,height:b,fill:Ke,type:"stacked",metadata:e.metadata});return}if(d!==void 0&&(s==="hardBin"||s==="softBin")&&!d.has(D(e))){t.push({x:n,y:i,width:h,height:b,fill:Xt,type:"hardBin",metadata:e.metadata});return}if(u!==void 0&&s==="metadata"&&!u.has(E(e))){t.push({x:n,y:i,width:h,height:b,fill:Xt,type:"metadata",metadata:e.metadata});return}if(s==="value"){if(y==="test"){const q=U(e,x,I),ft=q===void 0?z:q?Mt:St;t.push({x:n,y:i,width:h,height:b,fill:ft,type:"value",metadata:e.metadata});return}const M=L(e,x),P=rt(M,I);let w,Z;M===void 0?w=z:y==="spec"?w=P==="failLow"?Ce:P==="failHigh"?St:Mt:(w=r.forValue(p(M)),(P==="failLow"||P==="failHigh")&&(Z=P)),t.push({x:n,y:i,width:h,height:b,fill:w,type:"value",specMark:Z,metadata:e.metadata});return}if(s==="hardBin"||s==="softBin"){const M=D(e),P=M!=null?r.forBin(M):z,w=M!=null&&Pe(e,V)===!1?!0:void 0;t.push({x:n,y:i,width:h,height:b,fill:P,type:s,binFail:w,metadata:e.metadata});return}if(s==="metadata"){const M=E(e),P=M!==void 0?f?.get(M)??z:z;t.push({x:n,y:i,width:h,height:b,fill:P,type:"metadata",metadata:e.metadata});return}const g=L(e,0),A=g!==void 0?r.forValue(p(g)):z;t.push({x:n,y:i,width:h,height:b,fill:A,type:"value",metadata:e.metadata})}function en(t,e,n){const i=t.radius;return Ee(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:d=!1,ringCount:p,showRingBoundaries:x=!1,showQuadrantBoundaries:$=!1,showXYIndicator:V=!1,binColorScheme:I="default",valueColorScheme:y="default",reverseValueScheme:B=!1,useDefinedBinColors:f=!0,binColors:u,passBins:m,highlightBin:S,highlightMetadataValue:h,interactiveTransform:b,valueRange:D,metadataValueOrder:E,testDefs:g,activeTest:A=0,activeMetadataKey:M,fallbackFormat:P="engineering",aggregationMethod:w,lotSize:Z,dataAxisFlip:q,isLotStack:ft=!1,logScale:Qt,colorbarRangeMode:Ut="spec",passFailDisplay:Jt}=n,It=Jt??"off",dt=i?.hbinDefs,ht=i?.sbinDefs,Tt=i?.metadataFields,Zt=Tt?.find(l=>l.key===M),te={x:(q?.x??!1)!==(b?.flipX??!1),y:(q?.y??!1)!==(b?.flipY??!1)},ee=dt?new Map(dt.map(l=>[l.bin,l])):null,ne=ht?new Map(ht.map(l=>[l.bin,l])):null,ae=a==="softBin"?ne:ee,Dt=ge({passBins:m},"buildView"),ie=new Set(Dt),mt=u&&Re(u,e)?u:Le(e,{passBins:Dt,binColorScheme:I,hbinDefs:dt,sbinDefs:ht,useDefinedBinColors:f}),se=a==="softBin"?mt.soft:mt.hard,Vt={forValue:je(Fe(y,B)),forBin:l=>se.get(l)??z};let{testNumber:H}=resolveTestNumber(A,g);if(!g?.length&&a==="value"){const l=Ot(e,"values");!l.includes(H)&&l.length&&(H=l[0])}let tt;if(Array.isArray(D))tt=D;else if(D){const{testNumber:l}=resolveTestNumber(D.test,g);tt=l===H?D.range:void 0}const T=findTestDef(g,H),Ct=a==="value"&&T!==void 0&&!vt(T),oe=T!==void 0&&(T.limitLow!==void 0||T.limitHigh!==void 0);let O="off";a==="value"&&(Ct?O="test":It==="spec"&&oe?O="spec":It==="test"&&e.some(l=>U(l,H,T)!==void 0)&&(O="test"));const Ft=O==="spec"?"spec":Ut,pt=a==="stackedValues"||a==="stackedBins"||a==="stackedSoftBins";let N,_,et=!1;if(tt){[N,_]=tt;let l=!0,c=!1;for(const v of e){const F=pt?L(v,0):L(v,H);if(F!==void 0&&(c=!0,!Number.isInteger(F))){l=!1;break}}et=c&&l}else{const l=!pt&&a==="value"&&Ft==="spec"&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0);let c=1/0,v=-1/0,F=!0;for(const k of e){const W=pt?L(k,0):L(k,H);W!==void 0&&(W<c&&(c=W),W>v&&(v=W),Number.isInteger(W)||(F=!1))}isFinite(c)||(F=!1),et=F,l?(N=T.limitLow!==void 0?T.limitLow:isFinite(c)?c:0,_=T.limitHigh!==void 0?T.limitHigh:isFinite(v)?v:1):(N=isFinite(c)?c:0,_=isFinite(v)?v:1)}N===_&&(_=N+1);const Lt=Ct?!1:Qt??T?.logScale??!1,Rt=Lt&&N>0&&_>0,re=Rt;let nt;if(Rt){const l=Math.log10(N),c=Math.log10(_)-l;nt=v=>v<=0?0:Wt((Math.log10(v)-l)/c)}else nt=l=>Wt((l-N)/(_-N));const C=We(t,q,b);let Pt=null;if(t.notch){const l=Gt(t.notch.type),c=De(C.physicalToScreen,Math.cos(l)*t.radius,Math.sin(l)*t.radius),v=Math.hypot(c.x,c.y);v>0&&(Pt={x:c.x/v,y:c.y/v})}let j=1/0;for(let l=0;l<e.length;l++){const c=e[l];c.width<j&&(j=c.width),c.height<j&&(j=c.height)}const Nt=1,le=j!==1/0?Math.min(Nt,j*.12):Nt,Et=[],gt=[],ce=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(!ce){K=new Float64Array(e.length*2);for(let l=0;l<e.length;l++){const c=G(C.bakedToScreen,e[l].physX,e[l].physY);K[l*2]=c.x,K[l*2+1]=c.y}}const ue=Ve(C.gridToScreen),fe=a==="hardBin"||a==="softBin"||a==="stackedBins"||a==="stackedSoftBins",de=a==="softBin"||a==="stackedSoftBins";let at=fe?new Map:void 0;const yt=a==="value"&&O==="spec"?{pass:0,failHigh:0,failLow:0}:void 0,bt=a==="value"&&O==="test"?{pass:0,fail:0}:void 0,At=a==="metadata";let it=At?new Map:void 0,st=null;if(At&&M){const l=collectMetadataValues(e,M),c=E?.key===M?E.values:void 0,v=c?[...c,...l.filter(F=>!c.includes(F))]:l;st=new Map(v.map((F,k)=>[F,Zt?.values?.find(W=>W.value===F)?.color??Ae(k)]))}const he=S===void 0?void 0:new Set(Kt(S)),me=h===void 0?void 0:new Set(Kt(h));for(let l=0;l<e.length;l++){const c=e[l],v=K?K[l*2]:c.physX,F=K?K[l*2+1]:c.physY;if(gt.push({x:v,y:F}),at&&!c.partial&&!c.edgeExcluded){const k=de?c.sbin:c.hbin;k!=null&&at.set(k,(at.get(k)??0)+1)}if(yt&&!c.partial&&!c.edgeExcluded){const k=rt(L(c,H),T);k&&yt[k]++}if(bt&&!c.partial&&!c.edgeExcluded){const k=U(c,H,T);k!==void 0&&bt[k?"pass":"fail"]++}if(it&&!c.partial&&!c.edgeExcluded){const k=ut(c,M);k!==void 0&&it.set(k,(it.get(k)??0)+1)}tn(Et,c,v,F,a,ue,le,Vt,he,nt,H,ae,ie,T,O,M,st,me)}const Ht=o?generateTextOverlay(e,K,{plotMode:a,colorFns:Vt,normalize:nt,activeTest:A,valueRange:[N,_],testDefs:g,fallbackFormat:P,passFailDisplay:O,activeMetadataKey:M,metadataColorMap:st,allIntegerValues:et}):[],X=Ge(t,C.physicalToScreen);x&&X.push(...Qe(t,C.physicalToScreen,ye({ringCount:p},"buildView"))),$&&X.push(...Ue(t,C.physicalToScreen,t.center.x,t.center.y)),r&&X.push(...Je(s,C.gridToScreen)),d&&X.push(...Ze(e)),V&&X.push(...en(t,C.gridToScreen,Ht));const pe=gt.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,_t={rectangles:Et,hoverPoints:gt,texts:Ht,overlays:X,plotMode:a,binColorScheme:I,valueColorScheme:y,reverseValueScheme:B,binColors:mt,metadata:t.metadata??null,dies:e,valueRange:[N,_],allIntegerValues:et,testDefs:g,activeTest:A,logScale:re,logScaleRequested:Lt,aggrMethod:w,lotSize:Z,axisFlip:te,dataAxisFlip:{x:q?.x??!1,y:q?.y??!1},gridToScreen:C.gridToScreen,rotation:((t.orientation+(b?.rotation??0))%360+360)%360,hasReticle:s.length>0,isLotStack:ft,passFailDisplay:O,colorbarRangeMode:Ft,waferCenter:t.center,waferRadius:t.radius,notchDir:Pt,binCounts:at,metadataCounts:it,metadataColorMap:st,activeMetadataKey:M,metadataFields:Tt,specCounts:yt,passFailCounts:bt,dieBounds:pe};return n.compact?Ne(_t,n.compact,{showXYIndicator:V}):_t}export{getDieKey}from"../core/dies.js";
@@ -6,6 +6,7 @@ import type { DieColumns } from './columnarInput.js';
6
6
  import { type DerivedTestDef } from './derivedTests/apply.js';
7
7
  export type { DerivedTestDef } from './derivedTests/apply.js';
8
8
  import type { PlotMode } from './buildView.js';
9
+ import { type ValueFilterMode, type ValueFilterSummary } from './valueFilter.js';
9
10
  /**
10
11
  * Test result for a single die position, as output by the prober.
11
12
  * `x` and `y` are **die grid positions** (prober step coordinates) — integers
@@ -246,6 +247,16 @@ export interface TestDef {
246
247
  specLow?: number;
247
248
  /** Upper specification limit (STDF `HI_SPEC`). See `specLow`. */
248
249
  specHigh?: number;
250
+ /**
251
+ * Lower **validity limit**: the lowest value that is a real measurement. A value
252
+ * below it is a tester clamp (a range overflow, an open-circuit rail), not a
253
+ * reading, and `WaferMapInput.valueFilter` treats it as no value for this test
254
+ * on that die. Separate from the test and spec limits, which judge good against
255
+ * bad; a clamped value is neither.
256
+ */
257
+ validLow?: number;
258
+ /** Upper validity limit. See `validLow`. */
259
+ validHigh?: number;
249
260
  /**
250
261
  * Test kind: `'P'` (parametric — a continuous measured value) or `'F'`
251
262
  * (functional — a pass/fail outcome, conventionally recorded as 1 = pass,
@@ -355,6 +366,20 @@ export interface WaferMapInputBase {
355
366
  * 3 rings on 28-die wafers that produce correct findings.
356
367
  */
357
368
  ringCount?: number;
369
+ /**
370
+ * Which limit set a test value must lie inside to be used. A value outside it is
371
+ * treated as missing for that test on that die, and counted
372
+ * (`WaferMapResult.valueFilter`) so every population label can say so.
373
+ *
374
+ * - `'validity'` (default) — the validity limits (`TestDef.validLow`/`validHigh`);
375
+ * only tests that define them are affected.
376
+ * - `'spec'` / `'test'` — keep only values inside the specification / test limits.
377
+ * - `'none'` — filter nothing.
378
+ *
379
+ * Only values change: bins and each die's recorded verdict (`testPass`) are the
380
+ * tester's own and stay as recorded.
381
+ */
382
+ valueFilter?: ValueFilterMode;
358
383
  /**
359
384
  * Wafer diameters (mm) treated as standard when sanity-checking an *inferred*
360
385
  * diameter. Default `[100, 125, 150, 200, 300]`.
@@ -616,7 +641,7 @@ export interface WaferWarning {
616
641
  * The union is intentionally open to string so future advisory codes can be
617
642
  * added without a breaking change; switch with a `default` branch.
618
643
  */
619
- code: 'partial-coverage' | 'geometry-conflict' | 'non-standard-diameter' | 'diameter-exceeds-die-extent' | 'test-count-capped' | 'edge-exclusion-exceeds-radius' | 'analysis-option-corrected' | 'bin-colors-shared' | 'pass-bins-mixed' | 'ring-count-mixed' | 'input-field-removed' | 'input-values-not-numbers' | 'input-values-outside-stdf' | 'retests-by-part-id' | 'derived-test-invalid' | (string & {});
644
+ code: 'partial-coverage' | 'geometry-conflict' | 'non-standard-diameter' | 'diameter-exceeds-die-extent' | 'test-count-capped' | 'edge-exclusion-exceeds-radius' | 'analysis-option-corrected' | 'bin-colors-shared' | 'pass-bins-mixed' | 'ring-count-mixed' | 'input-field-removed' | 'input-values-not-numbers' | 'input-values-outside-stdf' | 'retests-by-part-id' | 'derived-test-invalid' | 'values-excluded' | (string & {});
620
645
  /** Human-readable explanation, suitable for direct display. */
621
646
  message: string;
622
647
  /**
@@ -732,6 +757,12 @@ export interface WaferMapResult {
732
757
  * states them in this same field.
733
758
  */
734
759
  passBins: number[];
760
+ /**
761
+ * What the value filter took out (`WaferMapInput.valueFilter`): the limit set it
762
+ * used and, per test, how many values were excluded. Absent when nothing was
763
+ * excluded. Counts are across every wafer of a lot build.
764
+ */
765
+ valueFilter?: ValueFilterSummary;
735
766
  /**
736
767
  * Rings the wafer is divided into (`WaferMapInput.ringCount`, default 4). The
737
768
  * renderers, `analyzeWaferMap`, panels and reports read it and none has a ring