@wafertools/wafermap 0.39.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 (56) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/README.md +2 -2
  3. package/dist/packages/canvas-adapter/charts/commonality.js +4 -1
  4. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +10 -2
  5. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  6. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  7. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  8. package/dist/packages/canvas-adapter/dataTab.d.ts +12 -6
  9. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  10. package/dist/packages/canvas-adapter/drilldown.d.ts +1 -1
  11. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  12. package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
  13. package/dist/packages/canvas-adapter/filterButton.js +1 -1
  14. package/dist/packages/canvas-adapter/identityHeader.js +1 -1
  15. package/dist/packages/canvas-adapter/insightsTab.d.ts +9 -4
  16. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  17. package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
  18. package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
  19. package/dist/packages/canvas-adapter/plotTab.d.ts +1 -1
  20. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  21. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  22. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  23. package/dist/packages/canvas-adapter/summaryPanel.d.ts +2 -2
  24. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  25. package/dist/packages/canvas-adapter/sweepEditor.js +1 -1
  26. package/dist/packages/canvas-adapter/toCanvas.d.ts +1 -0
  27. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  28. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  29. package/dist/packages/canvas-adapter/userGuideHtml.js +61 -38
  30. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  31. package/dist/packages/canvas-adapter/version.js +1 -1
  32. package/dist/packages/canvas-adapter/virtualTable.d.ts +2 -1
  33. package/dist/packages/canvas-adapter/virtualTable.js +1 -1
  34. package/dist/packages/core/compact.js +2 -2
  35. package/dist/packages/core/dieTable.js +1 -1
  36. package/dist/packages/renderer/buildView.js +1 -1
  37. package/dist/packages/renderer/fmt.d.ts +2 -0
  38. package/dist/packages/renderer/fmt.js +1 -1
  39. package/dist/packages/stats/commonality.d.ts +38 -5
  40. package/dist/packages/stats/commonality.js +1 -1
  41. package/dist/packages/stats/dieRegions.d.ts +2 -0
  42. package/dist/packages/stats/dieRegions.js +1 -1
  43. package/dist/packages/stats/examplePicks.d.ts +6 -0
  44. package/dist/packages/stats/examplePicks.js +1 -1
  45. package/dist/packages/stats/groupEffects.d.ts +74 -0
  46. package/dist/packages/stats/groupEffects.js +1 -0
  47. package/dist/packages/stats/plotData.d.ts +7 -2
  48. package/dist/packages/stats/plotData.js +1 -1
  49. package/dist/packages/stats/renderFindingsReport.js +1 -1
  50. package/dist/packages/stats/renderSummaryReport.js +7 -7
  51. package/dist/packages/stats/reportHtml.js +18 -13
  52. package/dist/packages/stats/sweep.d.ts +3 -3
  53. package/dist/packages/stats/sweepXFromName.js +1 -1
  54. package/dist/packages/stats/synthesis.d.ts +21 -1
  55. package/dist/packages/stats/synthesis.js +1 -1
  56. 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-10-31T09:06:32.439Z">v0.39.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
@@ -163,7 +163,7 @@ results with no X/Y coordinates at all, for some or every die on a wafer.</p>
163
163
  fabricated positions would risk being misread as real spatial layout. Instead the card shows a
164
164
  compact summary matching the active plot mode: a <strong>bin breakdown</strong> (coloured the same as a
165
165
  positioned card&#39;s own bin legend) for hard/soft-bin modes, or a <strong>histogram</strong> for value mode \u2014
166
- coloured through the same colour scheme, log-scale, and spec/data-range settings the map itself
166
+ coloured through the same colour scheme, log-scale, and limit/data-range settings the map itself
167
167
  uses, so switching those in the toolbar updates the chart the same way it would a real map. A
168
168
  <strong>View die list</strong> toggle switches to the full per-die table (position/site, hard bin, soft bin,
169
169
  every test value) with its own CSV export; <strong>View chart</strong> switches back.</p>
@@ -415,10 +415,11 @@ highlighting one bin at a time.</p>
415
415
  <p>Use the <strong>Overlays</strong> menu to toggle optional display layers on and off:</p>
416
416
  <ul>
417
417
  <li><strong>Axis labels</strong> \u2014 the die coordinates along the bottom and left edges. They appear when you zoom; this row shows
418
- them all the time, or hides them. <strong>Clear overlays</strong> returns to showing them on zoom</li>
419
- <li><strong>XY axis indicator</strong> \u2014 shows X and Y axis lines through the wafer centre</li>
418
+ them all the time, or hides them. <strong>Clear overlays</strong> returns to showing them on zoom. Labels run across the dies
419
+ and no further, and sit clear of the legend wherever it is placed</li>
420
+ <li><strong>XY axis indicator</strong> \u2014 arrows showing which way the X and Y die coordinates run</li>
420
421
  <li><strong>Ring boundaries</strong> \u2014 concentric ring divisions that match the spatial analysis zones</li>
421
- <li><strong>Quadrant lines</strong> \u2014 divides the wafer into N, S, E, W quadrants</li>
422
+ <li><strong>Quadrant lines</strong> \u2014 divides the wafer into NE, NW, SE and SW quadrants</li>
422
423
  <li><strong>Die coordinate labels</strong> \u2014 draws the (x, y) grid position inside each die (useful at high zoom)</li>
423
424
  <li><strong>Reticle grid</strong> \u2014 stepper field grid (only shown when reticle geometry is configured)</li>
424
425
  <li><strong>Limit pass/fail</strong> \u2014 pass/fail colouring for Test Value mode, judged against the test limits, when the active test defines them</li>
@@ -776,8 +777,8 @@ than measured dies.</li>
776
777
  <strong>Dies</strong>: the selected dies, or the whole wafer, as a table.</p>
777
778
  <hr>
778
779
  <h2 id="wmap-findings-panel">5. Findings panel</h2>
779
- <p>When spatial analysis has been run, the <strong>Findings</strong> panel lists statistically
780
- detected patterns on the wafer. Open it from the toolbar.</p>
780
+ <p>When spatial analysis has been run, the <strong>Findings</strong> section of the Summary panel lists statistically
781
+ detected patterns on the wafer. Open the panel with the toolbar&#39;s <strong>Summary</strong> button.</p>
781
782
  <p>Each finding shows:</p>
782
783
  <ul>
783
784
  <li><strong>Severity</strong> \u2014 Unusual, Notable, or Minor (ordered most to least significant)</li>
@@ -790,7 +791,7 @@ filter. Changing the selection or the legend filter yourself releases the findin
790
791
  <p><strong>Severity</strong> reflects how strong the statistical evidence is. <em>Unusual</em> findings
791
792
  have both a very low adjusted p-value and a large effect size \u2014 they are reliably
792
793
  important. <em>Notable</em> findings are statistically significant with a meaningful
793
- effect but not as extreme. <em>Info</em> findings pass the significance threshold at
794
+ effect but not as extreme. <em>Minor</em> findings pass the significance threshold at
794
795
  lower strength and are worth reviewing but may reflect smaller or noisier patterns.</p>
795
796
  <p><strong>Test-value findings</strong> (a region reading high or low on a test) take the longest to compute, so
796
797
  they are included automatically only when the data is small enough to take about a second. On
@@ -815,7 +816,7 @@ next to other failures (a spot touching a failing edge, say) is still reported a
815
816
  </tr>
816
817
  <tr>
817
818
  <td><strong>Quadrant</strong></td>
818
- <td>Yield or value difference between N, S, E, or W quadrants</td>
819
+ <td>Yield or value difference between NE, NW, SE or SW quadrants</td>
819
820
  </tr>
820
821
  <tr>
821
822
  <td><strong>Sector</strong></td>
@@ -887,7 +888,7 @@ field Group by offers (a process split, a lot, a test program). A group is judge
887
888
  one value, the way Insights compares groups, adjusted over every field and test compared, and its size
888
889
  is the shift in the test&#39;s within-wafer standard deviations, the scale a region&#39;s shift is measured on.
889
890
  A field is one item however many tests it moves (&quot;34 tests differ by Split. Largest: \u2026; next: \u2026&quot;), with the tests
890
- that moved most as its chips, so a corner lot does not fill the list with one split. Its chart is a grid of the field&#39;s values by those tests, in z-scores (and a card that shows a bar per wafer draws the wafers under their group, in the group&#39;s colour, when Group by is on): blue where a group sits below the lot&#39;s average on a test, red where it sits above, so a process corner reads as a pattern of cells. Both are ranked on one scale, the share of the dies an item
891
+ that moved most as its chips, so a corner lot does not fill the list with one split. The same comparison is made on the wafers&#39; yield and on the pass rate of the lot&#39;s weakest ring (&quot;Yield is 4.7 points lower on probe card PC-B than on PC-A&quot;); each set of groups is read after allowing for the strongest other one, and says so, and fields that group the wafers identically are one item that names them together. Groups that differ on two or more measures with no overlap but that the sample is too small to confirm are listed apart, under <em>Possible, not confirmed</em>. Its chart is a grid of the field&#39;s values by those tests, in z-scores (and a card that shows a bar per wafer draws the wafers under their group, in the group&#39;s colour, when Group by is on): blue where a group sits below the lot&#39;s average on a test, red where it sits above, so a process corner reads as a pattern of cells. Both are ranked on one scale, the share of the dies an item
891
892
  affects: a loss by the dies it cost; a shift by its dies, counted in full from two standard deviations
892
893
  and by the square of its size below that (a one-sigma shift counts a quarter of its dies); a trend by
893
894
  how far it moved; a group&#39;s shift by the dies of the wafers that moved, weighted as a shift is; a Ppk under 1.0 by
@@ -906,7 +907,8 @@ it. Click a region or wafer to highlight it, or a test to show the test&#39;s va
906
907
  fails selected; click again to clear. Under the top item&#39;s sentence, chips name its parts (its
907
908
  failing bins, with their legend colours, the pattern, and tests failing or shifted on the same dies),
908
909
  and each chip shows that part alone. With Insights on, each of the top items also has a <strong>Chart</strong>
909
- 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>.
910
912
  A wafer or lot with nothing affecting a yield point&#39;s worth of dies says so: &quot;Nothing stands out&quot;.
911
913
  The reports open with the same section, and <strong>Full report</strong> at the foot of it opens the
912
914
  report; in a report opened from the panel, clicking a finding&#39;s row shows it on the map.</li>
@@ -974,7 +976,7 @@ are the same sentence.</p>
974
976
  still receives every one of them.</p>
975
977
  <p>For <strong>lot-level views</strong> (gallery), the panel shows lot-level findings, and the
976
978
  <strong>Wafer Yield</strong> section badges each wafer with its own findings count \u2014 click a
977
- 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
978
980
  that one list, including the ones with no findings, which is what lets you see a
979
981
  low-yielding wafer that nothing flagged.</p>
980
982
  <hr>
@@ -1054,10 +1056,9 @@ bin 1 (Pass) or bin 2 (Fail) at that location.</em></p>
1054
1056
  <h2 id="wmap-insights-tab">8. Insights tab</h2>
1055
1057
  <p>The <strong>Insights</strong> side of the <strong>Maps | Insights</strong> switch (at the far right of the toolbar row, single map or
1056
1058
  gallery) swaps the wafer view for a chart suite computed from the same die data \u2014 without leaving the
1057
- toolbar. Choose <strong>Maps</strong> to return to the map; the switch stays where it is. Independent of the Findings
1058
- sidebar (see <a href="#wmap-summary-panel" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-summary-panel\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Summary panel</a>) \u2014 the two toggle independently, and opening one never
1059
- hides the other&#39;s toolbar button, since Findings has nothing to highlight
1060
- against once the map is replaced.</p>
1059
+ toolbar. Choose <strong>Maps</strong> to return to the map; the switch stays where it is. While Insights is open the
1060
+ buttons that act on the map, the <strong>Summary</strong> button among them, are hidden, since there is no map for the
1061
+ <a href="#wmap-summary-panel" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-summary-panel\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Summary panel</a> to highlight; <strong>Maps</strong> brings them back.</p>
1061
1062
  <p>The <a href="https://wafertools.github.io/wafermap/charts/">Chart reference</a> describes every chart, plot and table: what it
1062
1063
  shows, how to read it, when to reach for it and where to find it. This section covers how the tab works.</p>
1063
1064
  <p>The <strong>Columns</strong> control beside <strong>Group by</strong> and <strong>Show</strong>, or the keys <strong>1</strong> to <strong>5</strong> (and <strong>0</strong> for Auto), sets how many columns of
@@ -1077,20 +1078,22 @@ own charts and sweeps (see <em>Plots</em> and <em>Sweep cards</em> below):</p>
1077
1078
  <a href="https://wafertools.github.io/wafermap/charts/#reticle-cell-yield">Reticle cell yield</a>. With four or more wafers and wafer fields to compare, <a href="https://wafertools.github.io/wafermap/charts/#what-divides-yield">What divides yield</a>
1078
1079
  ranks the fields by how clearly their groups differ; <strong>Group by</strong> on its row groups the whole tab by that field. With
1079
1080
  Group by on, the yield bar and the pareto draw a bar per group (click a group&#39;s bar to see its wafers, <strong>Back</strong> to return). The
1080
- pass-rate card offers up to three ways of judging, whichever the data supports: <strong>Spec limits</strong>, <strong>Tester flag</strong> and
1081
+ pass-rate card offers up to three ways of judging, whichever the data supports: <strong>Test limits</strong>, <strong>Tester flag</strong> and
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:</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>
@@ -1209,6 +1215,14 @@ onto that pair.</em></p>
1209
1215
  <td>the menu on the dies it counts</td>
1210
1216
  </tr>
1211
1217
  <tr>
1218
+ <td>A cell of a <strong>heatmap</strong> (yield by ring or quadrant and wafer, re-probed dies, tests by wafer), or a bar of <strong>Yield by site</strong></td>
1219
+ <td>the menu on the dies the cell or bar counts (on every die of the wafer, for a cell of tests by wafer)</td>
1220
+ </tr>
1221
+ <tr>
1222
+ <td>The chart on a <strong>Worth a look</strong> card</td>
1223
+ <td>as the same chart anywhere else in Insights</td>
1224
+ </tr>
1225
+ <tr>
1212
1226
  <td>A cell of the correlation matrix</td>
1213
1227
  <td>that pair in the scatter</td>
1214
1228
  </tr>
@@ -1218,16 +1232,16 @@ onto that pair.</em></p>
1218
1232
  </tr>
1219
1233
  <tr>
1220
1234
  <td>A row of the <strong>Wafers</strong> table</td>
1221
- <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>
1222
1236
  </tr>
1223
1237
  <tr>
1224
1238
  <td>A row of the <strong>Dies</strong> table</td>
1225
- <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>
1226
1240
  </tr>
1227
1241
  </tbody></table>
1228
1242
  <p>The menu offers the charts and tables for just those dies (and your own plots), and its heading names
1229
1243
  them, for example &quot;412 dies in hard bin 3, across 13 wafers&quot;. A mark that has no dies behind it does nothing.
1230
- Right-click on any wafer&#39;s bar, box or point opens the same menu for the whole wafer.</p>
1244
+ Right-click on any wafer&#39;s bar, box or point opens the same menu for the whole wafer. The exceptions only move within Insights and have no menu: a test in the process-capability chart and a cell of the correlation matrix.</p>
1231
1245
  <h3 id="wmap-data-tables">Data tables</h3>
1232
1246
  <p>The <strong>Data</strong> sub-tab shows the wafers Insights is scoped to as tables, one at a
1233
1247
  time, chosen with the <strong>Statistics | Wafers | Dies</strong> control. It follows the
@@ -1273,9 +1287,9 @@ copy of the chart. <strong>Edit as plot</strong>, in the \u22EF menu of an Insig
1273
1287
  <em>A chart&#39;s buttons</em> below). The <strong>My plots | Examples</strong> switch above the list shows one or the other, never both: <strong>Examples</strong> shows plots to start from, or to see what each chart and
1274
1288
  setting is for, each marked as an example; none is saved until you add it. They are chosen from the lot in view: the <em>lead</em> test is the one that varies most from wafer to
1275
1289
  wafer (for a single wafer, the one that follows distance from the centre most), its partner the test that tracks it
1276
- best, and the split is the lot field that best explains the lead test. The examples are a scatter of the lead
1290
+ best, and the split is the lot field that best explains the lead test. Each other lot field that divides the wafers&#39; yield (a probe card, a tester) gets a bar of yield by its groups too; fields that group the wafers identically, such as a tester and the handler docked to it, each get one, so you can follow either. The examples are a scatter of the lead
1277
1291
  test against its partner with a fitted line, a histogram with its
1278
- normal curve, a box of the lead test by wafer, a bar of yield by the split, a line over wafer order with a \xB11 SD band, and a probability plot. It shows one of each newer
1292
+ normal curve, a box of the lead test by wafer, a bar of yield by the split, a line over wafer order with a \xB11 SD band, and a probability plot. The examples also show one of each newer
1279
1293
  feature the lot can show: the most telling tests as one set rescaled to z-scores (a box per test, and a heatmap of
1280
1294
  tests by wafer), the lead test by split and by wafer nested in split, panels by ring, the lead test by ranges of its
1281
1295
  partner and of the distance from the centre, a pareto of the hard bins and each wafer&#39;s bin mix, the
@@ -1337,6 +1351,11 @@ button, and the plot is kept as you go.</p>
1337
1351
  <td>every test with both limits as a point: how far off centre and how wide</td>
1338
1352
  <td>the tests (all by default)</td>
1339
1353
  </tr>
1354
+ <tr>
1355
+ <td><strong>Sweep</strong></td>
1356
+ <td>a run of tests read as one response curve, and the pair of curves measured against each other (see <a href="#wmap-sweep-cards" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-sweep-cards\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Sweep cards</a>)</td>
1357
+ <td>the series of tests and where each one&#39;s X comes from</td>
1358
+ </tr>
1340
1359
  </tbody></table>
1341
1360
  <ul>
1342
1361
  <li><strong>X axis</strong> and <strong>Y axis</strong> (a histogram has one <strong>Values</strong> field; a box or bar has
@@ -1538,8 +1557,8 @@ left out, and the line counts them (&quot;12 edge-excluded dies left out&quot;).
1538
1557
  a die without saying so. A plot coloured by hard or soft bin uses the map&#39;s bin colours.</p>
1539
1558
  <p><strong>Hover</strong> a point, bar, box or line to see its values and how many dies or wafers it
1540
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
1541
- test, so its map shows the values the plot is about and not the bins (a plot with no test in it,
1542
- 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
1543
1562
  line point to open the right-click menu on the dies it counts, and <strong>drag</strong> a rectangle over a
1544
1563
  scatter to select the dies (or wafers) inside it. The selection opens the same
1545
1564
  right-click menu as on a map, so a few dies from a plot can be charted and tabulated
@@ -1586,8 +1605,7 @@ questions:</p>
1586
1605
  <p><strong>Plots in the right-click menu.</strong> Every saved plot is also a row in the menu that
1587
1606
  opens on a selection or a wafer (<strong>Plots</strong> section), drawn over just those dies and
1588
1607
  captioned with them.</p>
1589
- <p><img src="images/guide-plot-drilldown.png" alt="The right-click menu on a selection, with the Plots section"> <strong>New plot\u2026</strong> and <strong>New sweep\u2026</strong> in the same menu start a draft on the selection;
1590
- a draft is kept only if you press <strong>Add to my plots</strong>.</p>
1608
+ <p>.</p>
1591
1609
  <p>Every change is kept as you make it. If you make a mistake, <strong>Reset</strong> (under the settings) puts the plot back as it was
1592
1610
  when you opened the editor, and <strong>Cancel</strong> does the same and closes it. Closing the window with its own button keeps what
1593
1611
  you changed.</p>
@@ -1629,7 +1647,7 @@ test numbers and ranges, such as <code>1010, 1011, 1020..1030</code> (a range me
1629
1647
  tests declared between its ends). Then choose where each test&#39;s X comes from:
1630
1648
  <strong>Test order</strong> (the position in the run, labelled by test), <strong>Values</strong> (one
1631
1649
  number per test, in the same order) or <strong>From test name</strong> (a pattern such as
1632
- <code>LRS_STATS_{x}</code>, for programs that record the swept value only in the test
1650
+ <code>LEVEL_{x}</code>, for programs that record the swept value only in the test
1633
1651
  text). The editor lists the first few test names with what your pattern reads
1634
1652
  from each as you type, and <strong>Pattern examples</strong> shows worked ones: <code>@ {x}</code>
1635
1653
  reads 0.55 from <code>Fmax @ 0.55 V</code>, and <code>-{x}</code> reads 5 from <code>1234-5</code>). Text that is not a test number or a range is flagged under the box,
@@ -1713,7 +1731,7 @@ exposure field from the lithography stepper \u2014 the group of dies exposed in
1713
1731
  single step. This lets you correlate failure patterns with specific reticle
1714
1732
  positions \u2014 useful for identifying stepper field signatures, alignment drift, or
1715
1733
  mask defects.</p>
1716
- <div data-wmap-demo="reticle" class="wmap-demo"></div><p>Reticle-position findings in the Findings panel highlight the specific field
1734
+ <div data-wmap-demo="reticle" class="wmap-demo"></div><p>Reticle-position findings in the Summary panel&#39;s Findings section highlight the specific field
1717
1735
  positions that show elevated failure rates. Hovering any die also shows its
1718
1736
  <strong>Reticle (column, row)</strong> position \u2014 its location within its own stepper
1719
1737
  field \u2014 just below the die&#39;s coordinate in the tooltip.</p>
@@ -1750,10 +1768,15 @@ symmetric; the rank p is the check. Nothing here says <em>why</em> groups differ
1750
1768
  </ul>
1751
1769
  <h3 id="wmap-what-divides-yield">10.3 What divides yield</h3>
1752
1770
  <p>The <strong>What divides yield</strong> card makes the comparison <a href="#wmap-comparing-groups-of-wafers" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-comparing-groups-of-wafers\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Comparing groups of wafers</a> describes for every wafer field at once, for yield and for each of the five most
1753
- common fail bins (a bin&#39;s value is its share of a wafer&#39;s judged dies). Rows are ranked by q, so the fields at the top
1754
- separate the wafers more clearly than wafer-to-wafer noise would. The <strong>Group by</strong> button regroups every chart by that
1755
- field. Two limits are stated on the card itself: a field that gives every wafer its own value cannot be tested, and
1756
- two fields that change together (a lot and its start date) cannot be told apart by the wafers. A low q points to where
1771
+ common fail bins (a bin&#39;s value is its share of a wafer&#39;s judged dies). It has one row per field, showing its yield,
1772
+ or a fail bin when that differs more clearly. The <strong>Effect</strong> column draws the worst and the best group as two bars on a
1773
+ scale of 0 to 100%, each with its mean, with a sentence giving the gap in percentage points; hover a bar for the group&#39;s median,
1774
+ spread and wafer count. <strong>Confidence</strong> is <strong>Clear</strong> (q under 0.05),
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
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>
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
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
1757
1780
  to look; it is not a cause. Tool, chamber and probe-card fields appear only when the host supplies them as wafer
1758
1781
  attributes.</p>
1759
1782
  <h3 id="wmap-the-cumulative-probability-plot">10.4 The cumulative probability plot</h3>
@@ -1861,7 +1884,7 @@ wafers; it does not change their limits, and it sees the body of the distributio
1861
1884
  outlier analysis, and lists tests that shall use PAT limits at test (pin leakage, standby supply current, IDDQ, output
1862
1885
  levels, propagation delays and others, in its Appendix 2). Nothing here checks a test&#39;s distribution or matches tests
1863
1886
  to that list.</li>
1864
- <li><strong>A floor of 30 passing values per wafer.</strong> That floor is ours. The guideline&#39;s 1.35 is inexact for under 20 values,
1887
+ <li><strong>A floor of 30 passing values per wafer.</strong> That floor is this library&#39;s own choice. The guideline&#39;s 1.35 is inexact for under 20 values,
1865
1888
  and sets sample sizes only for static limits.</li>
1866
1889
  <li><strong>Quartiles</strong> are found by interpolation between the ranked values, which the guideline does not specify.</li>
1867
1890
  </ul>
@@ -1,3 +1,3 @@
1
- export declare const WMAP_VERSION = "0.39.0";
2
- export declare const WMAP_BUILD_TIME = "2026-11-01T07:39:49.203Z";
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.39.0",WMAP_BUILD_TIME="2026-11-01T07:39:49.203Z";
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,3 +1,3 @@
1
- import{hasPosition as a}from"./dies.js";const h={minRepeats:3,minScore:.75,maxDensity:.8};function w(t,e){const s=t.length-e;if(s<2)return 0;let r=0,o=0,n=0,i=0,d=0;for(let u=0;u<s;u++){const p=t[u],l=t[u+e];r+=p,o+=l,n+=p*p,i+=l*l,d+=p*l}const f=n-r*r/s,c=i-o*o/s;return f<=0||c<=0?0:(d-r*o/s)/Math.sqrt(f*c)}function x(t,e,s){const r=Math.floor(t/e),o=[];if(s!==void 0&&s>=1){const n=Math.floor(s);for(let i=n;i<=r;i+=n)i>=2&&o.push(i)}else for(let n=2;n<=r;n++)o.push(n);return o}function g(t){if(t.length===0)return null;let e=1/0,s=-1/0;for(const n of t)n<e&&(e=n),n>s&&(s=n);const r=new Uint8Array(s-e+1);let o=0;for(const n of t)r[n-e]||(r[n-e]=1,o++);return{signal:r,count:o}}export function detectMpwPeriod(t,e={}){const{minRepeats:s,minScore:r,maxDensity:o}={...h,...e},{expectedPeriod:n}=e,i=g(t);if(!i)return null;const d=i.signal.length,f=i.count/d;if(f>o)return null;for(const c of x(d,s,n)){const u=w(i.signal,c);if(u>=r)return{period:c,score:u,repeats:Math.floor(d/c),occupiedFraction:f}}return null}function m(t,e){const{minRepeats:s,maxDensity:r}={...h,...e},o=detectMpwPeriod(t,e);if(o)return{kind:"periodic",...o};const n=g(t);return n&&n.count>=s&&n.count/n.signal.length>r?{kind:"dense",occupiedFraction:n.count/n.signal.length}:{kind:"none"}}export function detectMpwLayout(t,e={}){const{reticle:s,...r}=e,o=new Set,n=new Set;for(const c of t)a(c)&&(o.add(c.x),n.add(c.y));const i=m([...o],{...r,expectedPeriod:s?.width}),d=m([...n],{...r,expectedPeriod:s?.height}),f=i.kind==="periodic"&&(d.kind==="periodic"||d.kind==="dense")||d.kind==="periodic"&&i.kind==="dense";return{x:i,y:d,offered:f}}function y(t,e){const s=[0,...e,t],r=new Int32Array(t);for(let o=0;o+1<s.length;o++)r.fill(o,s[o],s[o+1]);return{ids:r,bounds:s}}function $(t){const e=[...t].sort((o,n)=>o-n),s=[],r=new Map;return e.forEach((o,n)=>{r.set(o,n),n>0&&o-e[n-1]>1&&s.push(n)}),{sorted:e,breaks:s,indexOf:r}}export function buildCompactMap(t){const e=new Set,s=new Set;for(const c of t)a(c)&&(e.add(c.x),s.add(c.y));const r=$(e),o=$(s),n=y(r.sorted.length,r.breaks),i=y(o.sorted.length,o.breaks),d=new Set;for(const c of t)a(c)&&d.add(n.ids[r.indexOf.get(c.x)]*i.bounds.length+i.ids[o.indexOf.get(c.y)]);return{groups:[...d].sort((c,u)=>c-u).map(c=>{const u=Math.floor(c/i.bounds.length),p=c%i.bounds.length;return{columns:[n.bounds[u],n.bounds[u+1]],rows:[i.bounds[p],i.bounds[p+1]]}}),columns:r.sorted,rows:o.sorted,columnBreaks:r.breaks,rowBreaks:o.breaks,columnOf:c=>r.indexOf.get(c),rowOf:c=>o.indexOf.get(c)}}export function compactDies(t,e){const s=e&&"columnOf"in e?e:buildCompactMap(e??t),r=[];for(const o of t){if(!a(o))continue;const n=s.columnOf(o.x),i=s.rowOf(o.y);if(n===void 0||i===void 0)throw new RangeError(`compactDies: die (${o.x}, ${o.y}) is outside the compact layout`);r.push({die:o,column:n,row:i})}return{placements:r,map:s}}export function compactLayoutOffered(t,e,s={}){return detectMpwLayout(t,{...s,reticle:b(e)}).offered}function b(t){const e=t[0];return e&&t.every(s=>s&&s.width===e.width&&s.height===e.height)?{width:e.width,height:e.height}:void 0}function k(t,e){const{minRepeats:s}={...h,...e},r=g(t);if(!r)return{occupied:0,span:0,runs:0,pattern:{kind:"none"},bestPeriods:[]};let o=0;r.signal.forEach((i,d)=>{i&&!r.signal[d-1]&&o++});const n=[];for(const i of x(r.signal.length,s,e.expectedPeriod))n.push({period:i,score:w(r.signal,i)});return n.sort((i,d)=>d.score-i.score||i.period-d.period),{occupied:r.count,span:r.signal.length,runs:o,pattern:m(t,e),bestPeriods:n.slice(0,5)}}export function diagnoseMpwLayout(t,e,s={}){const r=b(e),o=new Set,n=new Set;let i=0;for(const d of t)a(d)&&(i++,o.add(d.x),n.add(d.y));return{wafers:e.length,positionedDies:i,unpositionedDies:t.length-i,groups:buildCompactMap(t).groups.length,reticle:r,offered:detectMpwLayout(t,{...s,reticle:r}).offered,thresholds:{...h,...s},columns:k([...o],{...s,expectedPeriod:r?.width}),rows:k([...n],{...s,expectedPeriod:r?.height})}}function D(t,e){const s=e.span>0?` (${(100*e.occupied/e.span).toFixed(1)}%)`:"",r=e.pattern.kind==="periodic"?`periodic, period ${e.pattern.period}, score ${e.pattern.score.toFixed(3)}, ${e.pattern.repeats} repeats`:e.pattern.kind==="dense"?"dense, nothing to compact":"no repeating pattern found",o=e.bestPeriods.length?`
2
- best periods: ${e.bestPeriods.map(n=>`${n.period} (${n.score.toFixed(3)})`).join(", ")}`:"";return`${t}: ${e.occupied} occupied of ${e.span}${s}, ${e.runs} runs; ${r}${o}`}export function formatMpwDiagnostics(t,e){return["wafermap compact-layout diagnostics (format 1)",`library: ${e}`,"Counts and scores only: no die coordinates, bins, test values or wafer identity.",`wafers: ${t.wafers}`,`dies: ${t.positionedDies} positioned, ${t.unpositionedDies} without a position`,`reticle size: ${t.reticle?`${t.reticle.width} x ${t.reticle.height} (supplied by every wafer)`:"not supplied"}`,`compact layout offered: ${t.offered?"yes":"no"}`,`groups of dies: ${t.groups}`,`thresholds: minRepeats ${t.thresholds.minRepeats}, minScore ${t.thresholds.minScore}, maxDensity ${t.thresholds.maxDensity}`,D("columns",t.columns),D("rows",t.rows)].join(`
1
+ import{hasPosition as a}from"./dies.js";const h={minRepeats:3,minScore:.75,maxDensity:.8};function x(t,e){const s=t.length-e;if(s<2)return 0;let r=0,o=0,n=0,i=0,d=0;for(let u=0;u<s;u++){const p=t[u],l=t[u+e];r+=p,o+=l,n+=p*p,i+=l*l,d+=p*l}const f=n-r*r/s,c=i-o*o/s;return f<=0||c<=0?0:(d-r*o/s)/Math.sqrt(f*c)}function w(t,e,s){const r=Math.floor(t/e),o=[];if(s!==void 0&&s>=1){const n=Math.floor(s);for(let i=n;i<=r;i+=n)i>=2&&o.push(i)}else for(let n=2;n<=r;n++)o.push(n);return o}function g(t){if(t.length===0)return null;let e=1/0,s=-1/0;for(const n of t)n<e&&(e=n),n>s&&(s=n);const r=new Uint8Array(s-e+1);let o=0;for(const n of t)r[n-e]||(r[n-e]=1,o++);return{signal:r,count:o}}export function detectMpwPeriod(t,e={}){const{minRepeats:s,minScore:r,maxDensity:o}={...h,...e},{expectedPeriod:n}=e,i=g(t);if(!i)return null;const d=i.signal.length,f=i.count/d;if(f>o)return null;for(const c of w(d,s,n)){const u=x(i.signal,c);if(u>=r)return{period:c,score:u,repeats:Math.floor(d/c),occupiedFraction:f}}return null}function m(t,e){const{minRepeats:s,maxDensity:r}={...h,...e},o=detectMpwPeriod(t,e);if(o)return{kind:"periodic",...o};const n=g(t);return n&&n.count>=s&&n.count/n.signal.length>r?{kind:"dense",occupiedFraction:n.count/n.signal.length}:{kind:"none"}}export function detectMpwLayout(t,e={}){const{reticle:s,...r}=e,o=new Set,n=new Set;for(const c of t)a(c)&&(o.add(c.x),n.add(c.y));const i=m([...o],{...r,expectedPeriod:s?.width}),d=m([...n],{...r,expectedPeriod:s?.height}),f=i.kind==="periodic"&&(d.kind==="periodic"||d.kind==="dense")||d.kind==="periodic"&&i.kind==="dense";return{x:i,y:d,offered:f}}function y(t,e){const s=[0,...e,t],r=new Int32Array(t);for(let o=0;o+1<s.length;o++)r.fill(o,s[o],s[o+1]);return{ids:r,bounds:s}}function $(t){const e=[...t].sort((o,n)=>o-n),s=[],r=new Map;return e.forEach((o,n)=>{r.set(o,n),n>0&&o-e[n-1]>1&&s.push(n)}),{sorted:e,breaks:s,indexOf:r}}export function buildCompactMap(t){const e=new Set,s=new Set;for(const c of t)a(c)&&(e.add(c.x),s.add(c.y));const r=$(e),o=$(s),n=y(r.sorted.length,r.breaks),i=y(o.sorted.length,o.breaks),d=new Set;for(const c of t)a(c)&&d.add(n.ids[r.indexOf.get(c.x)]*i.bounds.length+i.ids[o.indexOf.get(c.y)]);return{groups:[...d].sort((c,u)=>c-u).map(c=>{const u=Math.floor(c/i.bounds.length),p=c%i.bounds.length;return{columns:[n.bounds[u],n.bounds[u+1]],rows:[i.bounds[p],i.bounds[p+1]]}}),columns:r.sorted,rows:o.sorted,columnBreaks:r.breaks,rowBreaks:o.breaks,columnOf:c=>r.indexOf.get(c),rowOf:c=>o.indexOf.get(c)}}export function compactDies(t,e){const s=e&&"columnOf"in e?e:buildCompactMap(e??t),r=[];for(const o of t){if(!a(o))continue;const n=s.columnOf(o.x),i=s.rowOf(o.y);if(n===void 0||i===void 0)throw new RangeError(`compactDies: die (${o.x}, ${o.y}) is outside the compact layout`);r.push({die:o,column:n,row:i})}return{placements:r,map:s}}export function compactLayoutOffered(t,e,s={}){return detectMpwLayout(t,{...s,reticle:b(e)}).offered}function b(t){const e=t[0];return e&&t.every(s=>s&&s.width===e.width&&s.height===e.height)?{width:e.width,height:e.height}:void 0}function k(t,e){const{minRepeats:s}={...h,...e},r=g(t);if(!r)return{occupied:0,span:0,runs:0,pattern:{kind:"none"},bestPeriods:[]};let o=0;r.signal.forEach((i,d)=>{i&&!r.signal[d-1]&&o++});const n=[];for(const i of w(r.signal.length,s,e.expectedPeriod))n.push({period:i,score:x(r.signal,i)});return n.sort((i,d)=>d.score-i.score||i.period-d.period),{occupied:r.count,span:r.signal.length,runs:o,pattern:m(t,e),bestPeriods:n.slice(0,5)}}export function diagnoseMpwLayout(t,e,s={}){const r=b(e),o=new Set,n=new Set;let i=0;for(const d of t)a(d)&&(i++,o.add(d.x),n.add(d.y));return{wafers:e.length,positionedDies:i,unpositionedDies:t.length-i,groups:buildCompactMap(t).groups.length,reticle:r,offered:detectMpwLayout(t,{...s,reticle:r}).offered,thresholds:{...h,...s},columns:k([...o],{...s,expectedPeriod:r?.width}),rows:k([...n],{...s,expectedPeriod:r?.height})}}function D(t,e){const s=e.span>0?` (${(100*e.occupied/e.span).toFixed(1)}%)`:"",r=e.pattern.kind==="periodic"?`periodic, period ${e.pattern.period}, score ${e.pattern.score.toFixed(3)}, ${e.pattern.repeats} repeats`:e.pattern.kind==="dense"?"dense, nothing to compact":"no repeating pattern found",o=e.bestPeriods.length?`
2
+ best periods: ${e.bestPeriods.map(n=>`${n.period} (${n.score.toFixed(3)})`).join(", ")}`:"";return`${t}: ${e.occupied} occupied of ${e.span}${s}, ${e.runs} runs; ${r}${o}`}export function formatMpwDiagnostics(t,e){return["compact-layout diagnostics (format 1)",`library: ${e}`,"Counts and scores only: no die coordinates, bins, test values or wafer identity.",`wafers: ${t.wafers}`,`dies: ${t.positionedDies} positioned, ${t.unpositionedDies} without a position`,`reticle size: ${t.reticle?`${t.reticle.width} x ${t.reticle.height} (supplied by every wafer)`:"not supplied"}`,`compact layout offered: ${t.offered?"yes":"no"}`,`groups of dies: ${t.groups}`,`thresholds: minRepeats ${t.thresholds.minRepeats}, minScore ${t.thresholds.minScore}, maxDensity ${t.thresholds.maxDensity}`,D("columns",t.columns),D("rows",t.rows)].join(`
3
3
  `)}
@@ -1 +1 @@
1
- import{hasAnyKey as N}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=P(s,()=>new Float64Array(t).fill(O)),c=P(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),x=Object.values(f);for(let b=0;b<d.length;b++)d[b][u]=x[b]}const i=e[u].testPass;if(i){r[u]|=HAS_VERDICTS;const d=c(i),x=Object.values(i);for(let b=0;b<d.length;b++)d[b][u]=x[b]?VERDICT_PASS:VERDICT_FAIL}}return{rows:t,values:g(s),verdicts:g(o),fields:r}}function P(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 g(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 excludedCountFor(e,t){let s=0,o;for(const r of e){const n=r[l],c=n?.excluded?.get(t);c===void 0||Number.isNaN(c[r[a]])||(s++,o??=n.excludedBy)}return s>0&&o!==void 0?{count:s,by:o}:void 0}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 w(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 v(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(w(this[l],this[a]))}function k(){return Object.freeze(v(this[l],this[a]))}function m(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:j,set:m("testValues"),enumerable:!0,configurable:!0},V={get:k,set:m("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=w(t,s)),o&HAS_VERDICTS&&(n.testPass=v(t,s)),n):(Object.defineProperty(n,l,p(t)),Object.defineProperty(n,a,p(s)),o&HAS_VALUES&&Object.defineProperty(n,"testValues",y),o&HAS_VERDICTS&&Object.defineProperty(n,"testPass",V),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=w(s,o)),r&HAS_VERDICTS&&!("testPass"in t)&&(n.testPass=v(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",y),r&HAS_VERDICTS&&Object.defineProperty(n,"testPass",V),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",y),f&HAS_VERDICTS&&Object.defineProperty(r,"testPass",V)}}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 N(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 N(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)}
1
+ import{hasAnyKey as N}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"),d=Symbol("wmap.dieRow");export function linkDie(e,t,s){return e[l]=t,e[d]=s,e}export function dieLink(e){const t=e[l];return t===void 0?void 0:{table:t,row:e[d]}}export function tableFromRows(e){const t=e.length,s=new Map,o=new Map,r=new Uint8Array(t),n=P(s,()=>new Float64Array(t).fill(O)),c=P(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 a=n(f),x=Object.values(f);for(let b=0;b<a.length;b++)a[b][u]=x[b]}const i=e[u].testPass;if(i){r[u]|=HAS_VERDICTS;const a=c(i),x=Object.values(i);for(let b=0;b<a.length;b++)a[b][u]=x[b]?VERDICT_PASS:VERDICT_FAIL}}return{rows:t,values:g(s),verdicts:g(o),fields:r}}function P(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 g(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[d];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 excludedCountFor(e,t){let s=0,o;for(const r of e){const n=r[l],c=n?.excluded?.get(t);c===void 0||Number.isNaN(c[r[d]])||(s++,o??=n.excludedBy)}return s>0&&o!==void 0?{count:s,by:o}:void 0}export function excludedBy(e){return e[l]?.excludedBy}export function excludedValue(e,t){const o=e[l]?.excluded?.get(t)?.[e[d]];return o===void 0||Number.isNaN(o)?void 0:o}export function rowView(e){const t=linkDie({},e,0);return s=>(t[d]=s,t)}function w(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 v(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(w(this[l],this[d]))}function k(){return Object.freeze(v(this[l],this[d]))}function m(e){return function(){throw new TypeError(`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:j,set:m("testValues"),enumerable:!0,configurable:!0},V={get:k,set:m("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[d],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=w(t,s)),o&HAS_VERDICTS&&(n.testPass=v(t,s)),n):(Object.defineProperty(n,l,p(t)),Object.defineProperty(n,d,p(s)),o&HAS_VALUES&&Object.defineProperty(n,"testValues",y),o&HAS_VERDICTS&&Object.defineProperty(n,"testPass",V),n)}export function copyDie(e,t){const s=e[l];if(s===void 0)return{...e,...t};const o=e[d],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=w(s,o)),r&HAS_VERDICTS&&!("testPass"in t)&&(n.testPass=v(s,o)),Object.assign(n,t)):(Object.assign(n,t),Object.defineProperty(n,l,p(s)),Object.defineProperty(n,d,p(o)),r&HAS_VALUES&&Object.defineProperty(n,"testValues",y),r&HAS_VERDICTS&&Object.defineProperty(n,"testPass",V),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 a=s.get(i.table);a===void 0&&(s.set(i.table,a=t.length),t.push(i.table)),r[n++]=a,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,d,p(c)),f&HAS_VALUES&&Object.defineProperty(r,"testValues",y),f&HAS_VERDICTS&&Object.defineProperty(r,"testPass",V)}}export function testValue(e,t){const s=e[l];if(s===void 0)return e.testValues?.[t];const o=s.values.get(t)?.[e[d]];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[d]];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 N(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 N(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)}
@@ -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)}