@wafertools/wafermap 0.34.0 → 0.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +7 -1
- package/CHANGELOG.md +189 -1
- package/README.md +6 -3
- package/dist/packages/canvas-adapter/charts/barPanel.d.ts +1 -1
- package/dist/packages/canvas-adapter/charts/binCluster.js +1 -1
- package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +17 -2
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +6 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/scatter.js +1 -1
- package/dist/packages/canvas-adapter/charts/testPassRate.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.d.ts +6 -0
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.js +6 -6
- package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/identityHeader.d.ts +4 -1
- package/dist/packages/canvas-adapter/identityHeader.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +3 -1
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/plotEditor.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.d.ts +3 -0
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +8 -0
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +22 -1
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +39 -11
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -2
- package/dist/packages/canvas-adapter/summaryToggle.d.ts +11 -0
- package/dist/packages/canvas-adapter/summaryToggle.js +1 -0
- package/dist/packages/canvas-adapter/sweepEditor.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +8 -0
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +57 -27
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/warnings.js +1 -1
- package/dist/packages/core/classify.d.ts +5 -0
- package/dist/packages/core/classify.js +1 -1
- package/dist/packages/core/dieTable.d.ts +26 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/index.d.ts +1 -1
- package/dist/packages/core/index.js +1 -1
- package/dist/packages/core/passBins.d.ts +6 -0
- package/dist/packages/core/passBins.js +1 -1
- package/dist/packages/core/reticle.d.ts +20 -0
- package/dist/packages/core/reticle.js +1 -1
- package/dist/packages/core/wafer.d.ts +15 -0
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +32 -1
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/derivedTests/apply.js +1 -1
- package/dist/packages/renderer/derivedTests/evaluate.d.ts +3 -1
- package/dist/packages/renderer/derivedTests/evaluate.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.d.ts +7 -0
- package/dist/packages/renderer/derivedTests/parser.js +2 -2
- package/dist/packages/renderer/spec.d.ts +4 -0
- package/dist/packages/renderer/spec.js +1 -1
- package/dist/packages/renderer/valueFilter.d.ts +55 -0
- package/dist/packages/renderer/valueFilter.js +1 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +44 -3
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/capability.d.ts +5 -0
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/connectedComponents.d.ts +19 -0
- package/dist/packages/stats/connectedComponents.js +1 -1
- package/dist/packages/stats/dieRegions.d.ts +42 -0
- package/dist/packages/stats/dieRegions.js +1 -0
- package/dist/packages/stats/facets.d.ts +8 -0
- package/dist/packages/stats/facets.js +1 -1
- package/dist/packages/stats/index.d.ts +2 -1
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/lotPattern.js +1 -1
- package/dist/packages/stats/math.d.ts +25 -3
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/metadataColumns.js +1 -1
- package/dist/packages/stats/patternClassification.d.ts +44 -18
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/plotData.d.ts +12 -1
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotSpec.d.ts +1 -1
- package/dist/packages/stats/plotSpec.js +1 -1
- package/dist/packages/stats/regions.d.ts +15 -0
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +7 -6
- package/dist/packages/stats/reportHtml.js +39 -37
- package/dist/packages/stats/synthesis.d.ts +44 -17
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/types.d.ts +12 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/dist/packages/canvas-adapter/summaryRail.d.ts +0 -7
- package/dist/packages/canvas-adapter/summaryRail.js +0 -1
|
@@ -6,6 +6,7 @@ import type { DieColumns } from './columnarInput.js';
|
|
|
6
6
|
import { type DerivedTestDef } from './derivedTests/apply.js';
|
|
7
7
|
export type { DerivedTestDef } from './derivedTests/apply.js';
|
|
8
8
|
import type { PlotMode } from './buildView.js';
|
|
9
|
+
import { type ValueFilterMode, type ValueFilterSummary } from './valueFilter.js';
|
|
9
10
|
/**
|
|
10
11
|
* Test result for a single die position, as output by the prober.
|
|
11
12
|
* `x` and `y` are **die grid positions** (prober step coordinates) — integers
|
|
@@ -246,6 +247,16 @@ export interface TestDef {
|
|
|
246
247
|
specLow?: number;
|
|
247
248
|
/** Upper specification limit (STDF `HI_SPEC`). See `specLow`. */
|
|
248
249
|
specHigh?: number;
|
|
250
|
+
/**
|
|
251
|
+
* Lower **validity limit**: the lowest value that is a real measurement. A value
|
|
252
|
+
* below it is a tester clamp (a range overflow, an open-circuit rail), not a
|
|
253
|
+
* reading, and `WaferMapInput.valueFilter` treats it as no value for this test
|
|
254
|
+
* on that die. Separate from the test and spec limits, which judge good against
|
|
255
|
+
* bad; a clamped value is neither.
|
|
256
|
+
*/
|
|
257
|
+
validLow?: number;
|
|
258
|
+
/** Upper validity limit. See `validLow`. */
|
|
259
|
+
validHigh?: number;
|
|
249
260
|
/**
|
|
250
261
|
* Test kind: `'P'` (parametric — a continuous measured value) or `'F'`
|
|
251
262
|
* (functional — a pass/fail outcome, conventionally recorded as 1 = pass,
|
|
@@ -355,6 +366,20 @@ export interface WaferMapInputBase {
|
|
|
355
366
|
* 3 rings on 28-die wafers that produce correct findings.
|
|
356
367
|
*/
|
|
357
368
|
ringCount?: number;
|
|
369
|
+
/**
|
|
370
|
+
* Which limit set a test value must lie inside to be used. A value outside it is
|
|
371
|
+
* treated as missing for that test on that die, and counted
|
|
372
|
+
* (`WaferMapResult.valueFilter`) so every population label can say so.
|
|
373
|
+
*
|
|
374
|
+
* - `'validity'` (default) — the validity limits (`TestDef.validLow`/`validHigh`);
|
|
375
|
+
* only tests that define them are affected.
|
|
376
|
+
* - `'spec'` / `'test'` — keep only values inside the specification / test limits.
|
|
377
|
+
* - `'none'` — filter nothing.
|
|
378
|
+
*
|
|
379
|
+
* Only values change: bins and each die's recorded verdict (`testPass`) are the
|
|
380
|
+
* tester's own and stay as recorded.
|
|
381
|
+
*/
|
|
382
|
+
valueFilter?: ValueFilterMode;
|
|
358
383
|
/**
|
|
359
384
|
* Wafer diameters (mm) treated as standard when sanity-checking an *inferred*
|
|
360
385
|
* diameter. Default `[100, 125, 150, 200, 300]`.
|
|
@@ -616,7 +641,7 @@ export interface WaferWarning {
|
|
|
616
641
|
* The union is intentionally open to string so future advisory codes can be
|
|
617
642
|
* added without a breaking change; switch with a `default` branch.
|
|
618
643
|
*/
|
|
619
|
-
code: 'partial-coverage' | 'geometry-conflict' | 'non-standard-diameter' | 'diameter-exceeds-die-extent' | 'test-count-capped' | 'edge-exclusion-exceeds-radius' | 'analysis-option-corrected' | 'bin-colors-shared' | 'pass-bins-mixed' | 'ring-count-mixed' | 'input-field-removed' | 'input-values-not-numbers' | 'input-values-outside-stdf' | 'retests-by-part-id' | 'derived-test-invalid' | (string & {});
|
|
644
|
+
code: 'partial-coverage' | 'geometry-conflict' | 'non-standard-diameter' | 'diameter-exceeds-die-extent' | 'test-count-capped' | 'edge-exclusion-exceeds-radius' | 'analysis-option-corrected' | 'bin-colors-shared' | 'pass-bins-mixed' | 'ring-count-mixed' | 'input-field-removed' | 'input-values-not-numbers' | 'input-values-outside-stdf' | 'retests-by-part-id' | 'derived-test-invalid' | 'values-excluded' | (string & {});
|
|
620
645
|
/** Human-readable explanation, suitable for direct display. */
|
|
621
646
|
message: string;
|
|
622
647
|
/**
|
|
@@ -732,6 +757,12 @@ export interface WaferMapResult {
|
|
|
732
757
|
* states them in this same field.
|
|
733
758
|
*/
|
|
734
759
|
passBins: number[];
|
|
760
|
+
/**
|
|
761
|
+
* What the value filter took out (`WaferMapInput.valueFilter`): the limit set it
|
|
762
|
+
* used and, per test, how many values were excluded. Absent when nothing was
|
|
763
|
+
* excluded. Counts are across every wafer of a lot build.
|
|
764
|
+
*/
|
|
765
|
+
valueFilter?: ValueFilterSummary;
|
|
735
766
|
/**
|
|
736
767
|
* Rings the wafer is divided into (`WaferMapInput.ringCount`, default 4). The
|
|
737
768
|
* renderers, `analyzeWaferMap`, panels and reports read it and none has a ring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createWafer as U}from"../core/wafer.js";import{isYieldEligibleDie as we,getDieKey as X,hasPosition as F}from"../core/dies.js";import{applyOrientation as te,transformDies as xe,clipDiesToWafer as De}from"../core/transforms.js";import{generateDies as ve}from"../core/dies.js";import{dieHasAnyTestData as Me,dieLink as G,finaliseDie as j,linkDie as Se,recordedVerdict as Ce,recordedVerdictsReader as ke,tableFromRows as Ae,testValue as q,testsPresent as Oe,VERDICT_FAIL as Ne,VERDICT_NONE as $e,VERDICT_PASS as Re}from"../core/dieTable.js";import{isDieColumns as Te,linkColumns as Ee,linkRows as ne,relink as We}from"./columnarInput.js";import{affineRotation as Fe,affineMirror as Ie,affineCompose as _e,affinePoint as Pe}from"../core/transforms.js";import{inferWaferFromXY as Ve}from"../core/inference/wafer.js";import{resolveGridPitch as Be}from"../core/inference/pitch.js";import{assignGridIndices as Le}from"../core/inference/grid.js";import{generateReticleGrid as Ye}from"../core/reticle.js";import{applyDerivedTests as Xe}from"./derivedTests/apply.js";import{isStdfBin as je,isStdfCoord as ie,isStdfTestNumber as se,isStdfSite as Ke,STDF_BIN_MAX as He,STDF_COORD_MAX as re,STDF_TEST_NUM_MAX as ze,STDF_SITE_MAX as Ue}from"../core/stdf.js";import{hasAnyKey as Ge,maxOf as J,minOf as oe,modeOf as qe}from"../core/utils.js";import{aggregateValues as ae,aggregateBinCounts as Je,stackHoldsMeasurements as Qe}from"../core/aggregates.js";import{normalizePassBins as de}from"../core/passBins.js";import{defaultRingCount as Q}from"../core/ringCount.js";export function isParametricTest(t){return t?.testType!=="F"}export function isBuiltMap(t){return"wafer"in t&&"dies"in t&&"dataAxisFlip"in t}function Ze(t){const e=(i,a)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(t)} ${a} (using ${i}).`}});if(t===void 0)return{ringCount:Q(),ringCountWarning:void 0};if(typeof t!="number"||!Number.isFinite(t))return e(Q(),"is not a finite number");const n=Math.max(1,Math.round(t));return n===t?{ringCount:t,ringCountWarning:void 0}:e(n,"is not a whole number of at least 1")}function et(t,e){const n=Array.isArray(t)?{}:t,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let a;const o=(l,b)=>{i[l]++,a??=`${l} ${JSON.stringify(b)}`},s={bins:0,positions:0,values:0,sites:0,orientation:0},r=new Set;let m=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(a??=e.example),s.values+=e.nonFinite;for(const l of e.badTestNumbers)r.add(l)}const h=l=>l==null?!0:typeof l!="number"?!1:Number.isNaN(l)?(m++,!1):je(l)?!0:(s.bins++,!1);function d(l){const b=new Set,w=new Set;for(let O=0;O<l.length;O+=O<50?1:100){const k=l[O];if(!(k===null||typeof k!="object")){if(k.testValues&&typeof k.testValues=="object")for(const M of Object.keys(k.testValues))b.add(M);if(k.testPass&&typeof k.testPass=="object")for(const M of Object.keys(k.testPass))w.add(M)}}const g=[...b],y=[...w],A=O=>se(Number(O));for(const O of new Set([...g,...y]))A(O)||r.add(O);const R=g.map(A),v=y.map(A),N=g.map(Number),B=y.map(Number);let I;for(let O=0;O<l.length;O++){const k=l[O];if(k===null||typeof k!="object")continue;const M=k;let Y;const _=()=>Y??={...M};M.hbin!=null&&typeof M.hbin!="number"&&o("hbin",M.hbin),M.sbin!=null&&typeof M.sbin!="number"&&o("sbin",M.sbin),h(M.hbin)||(_().hbin=void 0),h(M.sbin)||(_().sbin=void 0);const L=typeof M.x=="number"&&!ie(M.x),f=typeof M.y=="number"&&!ie(M.y);if(L||f){s.positions+=(L?1:0)+(f?1:0);const S=_();S.x=void 0,S.y=void 0}M.siteNum!=null&&typeof M.siteNum!="number"?(o("siteNum",M.siteNum),_().siteNum=void 0):typeof M.siteNum=="number"&&!Ke(M.siteNum)&&(s.sites++,_().siteNum=void 0);const C=M.testValues;if(C&&typeof C=="object"){let S;for(let $=0;$<g.length;$++){const E=g[$],W=C[N[$]];if(W!=null){if(!R[$]){S??={...C},delete S[E];continue}typeof W!="number"?(o("testValues",W),S??={...C},delete S[E]):Number.isFinite(W)||(s.values++,S??={...C},delete S[E])}}S&&(_().testValues=S)}const T=M.testPass;if(T&&typeof T=="object"){let S;for(let $=0;$<y.length;$++){const E=y[$],W=T[B[$]];if(W!=null){if(!v[$]){S??={...T},delete S[E];continue}typeof W!="boolean"&&(o("testPass",W),S??={...T},delete S[E])}}S&&(_().testPass=S)}Y&&((I??=l.slice())[O]=Y)}return I}const c={warnings:[]};if(Array.isArray(t))c.results=d(t);else{Array.isArray(n.results)&&(c.results=d(n.results)),Array.isArray(n.dies)&&(c.dies=d(n.dies));const l=n.lotStack?.results;if(Array.isArray(l)){const b=l.map(w=>Array.isArray(w)?d(w):void 0);b.some(Boolean)&&(c.stackResults=b.map((w,g)=>w??l[g]))}}if(Array.isArray(n.testDefs)){const l=n.testDefs,b=l.filter(w=>w==null||typeof w.testNumber!="number"||se(w.testNumber));for(const w of l)b.includes(w)||r.add(String(w.testNumber));b.length!==l.length&&(c.testDefs=b)}const p=n.waferConfig?.orientation;if(typeof p=="number"){const l=Number.isFinite(p)?(p%360+360)%360:NaN;l===0||l===90||l===180||l===270?c.orientation=l:(s.orientation++,c.orientation=0)}const u=(l,b,w=`${b}s`)=>`${l} ${l===1?b:w}`,x=[];if(i.hbin&&x.push(u(i.hbin,"hard bin")),i.sbin&&x.push(u(i.sbin,"soft bin")),i.siteNum&&x.push(u(i.siteNum,"site number")),i.testValues&&x.push(u(i.testValues,"test value")),i.testPass&&x.push(u(i.testPass,"pass/fail verdict")),x.length){const l=`buildWaferMap received ${x.join(", ")} of the wrong type (for example ${a}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${l}`),c.warnings.push({code:"input-values-not-numbers",message:l,severity:"error"})}const D=[];if(s.bins&&D.push(`${u(s.bins,"bin")} (legal: whole numbers 0\u2013${He}) \u2014 those dies have no bin`),s.positions&&D.push(`${u(s.positions,"coordinate")} (legal: whole numbers \u2212${re} to ${re}) \u2014 those dies have no position`),r.size&&D.push(`${u(r.size,"test number")} (legal: whole numbers 0\u2013${ze}) \u2014 those tests are left out`),s.values&&D.push(`${u(s.values,"test value")} that ${s.values===1?"is":"are"} not finite \u2014 left out`),s.sites&&D.push(`${u(s.sites,"site number")} (legal: 0\u2013${Ue}) \u2014 those dies have no site`),s.orientation&&D.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),D.length||m){const l=[];D.length&&l.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${D.join("; ")}.`),m&&l.push(`${u(m,"bin was","bins were")} NaN and ${m===1?"is":"are"} treated as no bin.`);const b=l.join(" ");console.warn(`[wafermap] ${b}`),c.warnings.push({code:"input-values-outside-stdf",message:b,severity:"warning"})}return c}function fe(t){const e=(h,d)=>h!==null&&typeof h=="object"&&h[d]!==void 0,n=Array.isArray(t)?{}:t,i=[],a=(h,d,c)=>{h&&i.push(`\`${d}\` (now \`${c}\`)`)};a(e(n,"data"),"data","results"),a(e(n,"die"),"die","dieConfig"),a(e(n,"stack"),"stack","lotStack"),a(e(n.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),a(e(n.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),a(e(n.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),a(e(n.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),a(Array.isArray(n.testDefs)&&n.testDefs.some(h=>e(h,"index")&&!e(h,"testNumber")),"TestDef.index","TestDef.testNumber");const o=e(n.lotStack,"results")?n.lotStack.results:[],s=(Array.isArray(t)?[t]:[n.results,...Array.isArray(o)?o:[]]).filter(h=>Array.isArray(h));if(a(s.some(h=>h.slice(0,100).some(d=>e(d,"values"))),"values","testValues"),!i.length)return;const r=i.length>1,m=`buildWaferMap ignored ${i.join(", ")}: ${r?"these names were":"that name was"} removed in an earlier release, so what ${r?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${m}`),{code:"input-field-removed",message:m,severity:"error"}}function tt(t){if(t.results!==void 0||t.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=t.waferConfig?.diameter,n=t.dieConfig?.width,i=t.dieConfig?.height;if(!(e>0&&n>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const a=U({diameter:e,notch:t.waferConfig?.notch,orientation:0}),o=De(ve(a,{width:n,height:i}),a,{width:n,height:i}).filter(d=>!d.partial),{flipX:s,flipY:r}=ue(t.dieConfig,{type:"center"}),{layout:m,...h}=t;return{...h,results:o.map(d=>({x:s?-d.x:d.x,y:r?-d.y:d.y})),waferConfig:{...t.waferConfig,center:{x:0,y:0}},dieConfig:{...t.dieConfig,coordinateOrigin:{type:"center"}}}}function nt(t){if(!Array.isArray(t)&&"results"in t&&t.results!==void 0&&"lotStack"in t&&t.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},n=!Array.isArray(t)&&Te(t.results)?{...t,results:Ee(t.results,e).records}:t,i=et(n,e);return Array.isArray(n)?{results:Z(i.results??n),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:de(void 0),ringCount:Q(),ringCountWarning:void 0,removedFieldWarning:fe(n),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:Z(i.results??n.results??[]),waferOpts:i.orientation===void 0||n.waferConfig===void 0?n.waferConfig:{...n.waferConfig,orientation:i.orientation},dieOpts:n.dieConfig,explicitDies:i.dies??n.dies,reticleOpts:n.reticleConfig,lotStackOpts:n.lotStack?{...n.lotStack,results:(i.stackResults??n.lotStack.results).map(Z)}:void 0,passBins:de(n.passBins),...Ze(n.ringCount),removedFieldWarning:fe(n),inputValueWarnings:i.warnings,standardDiameters:n.standardDiameters,testDefs:(i.testDefs??n.testDefs)?.length?i.testDefs??n.testDefs:void 0,hbinDefs:n.hbinDefs,sbinDefs:n.sbinDefs,metadataFields:n.metadataFields,derivedTests:n.derivedTests?.length?n.derivedTests:void 0,retestPolicy:n.retestPolicy??"last",edgeDieYieldMode:n.edgeDieYieldMode??"exclude"}}function Z(t){return t.length>0&&G(t[0])!==void 0?t:ne(t).records}function it(t,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function st(t,e,n){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,a=-1/0,o=1/0,s=-1/0;for(const r of t)r.x<i&&(i=r.x),r.x>a&&(a=r.x),r.y<o&&(o=r.y),r.y>s&&(s=r.y);return{offsetX:Math.round((a+i)/2),offsetY:Math.round((s+o)/2)}}return{offsetX:n.offsetX,offsetY:n.offsetY}}function rt(t,e,n,i,a,o){if(o)return{colMidX:(Math.round(o.x)-e)*i,colMidY:(Math.round(o.y)-n)*a,anchored:!0};if(t.length===0)return{colMidX:0,colMidY:0,anchored:!1};let s=1/0,r=-1/0,m=1/0,h=-1/0;for(const d of t){const c=Math.round(d.x)-e,p=Math.round(d.y)-n;c<s&&(s=c),c>r&&(r=c),p<m&&(m=p),p>h&&(h=p)}return{colMidX:(s+r)/2*i,colMidY:(m+h)/2*a,anchored:!1}}function ot(t,e,n){let i=1/0,a=-1/0,o=1/0,s=-1/0,r=0,m=0;for(const c of t){const p=Math.round(c.x)-e,u=Math.round(c.y)-n;r+=p,m+=u,p<i&&(i=p),p>a&&(a=p),u<o&&(o=u),u>s&&(s=u)}const h=t.length,d=(c,p,u)=>{const x=(u-p)/2;return x<=0?0:Math.abs(c/h-(p+u)/2)/x};return d(r,i,a)>.11||d(m,o,s)>.11}function ue(t,e){let n=t?.xAxisDirection==="left",i=t?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(n=!0),{flipX:n,flipY:i}}function at(t){const e={...t};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function dt(t,e){const{method:n,targetBin:i}=t,a=t.results.map(o=>o.filter(F));if(n==="mean"||n==="median"||n==="stddev"||n==="min"||n==="max"||n==="count"){const o=new Set((e??[]).filter(d=>!isParametricTest(d)).map(d=>d.testNumber)),s=new Set;for(const d of a)for(const c of Oe(d,"values"))o.has(c)||s.add(c);if(s.size===0)return ae(a,n);const r=[...s],m=r.map(d=>ae(a,n,d)),h=new Map;for(let d=0;d<r.length;d++){const c=r[d];for(const p of m[d]){const u=X(p);h.has(u)||h.set(u,{template:p,testValues:{}});const x=h.get(u),D=p.testValues?.[0];D!==void 0&&(x.testValues[c]=D)}}return[...h.values()].map(({template:d,testValues:c})=>({...d,testValues:Ge(c)?c:void 0}))}if(n==="countBin"||n==="percent"){if(i===void 0)return[];const o=Je(a,i,"hard");if(n==="countBin")return o;const s=a.length;return o.map(r=>({...r,testValues:{0:s>0?(r.testValues?.[0]??0)/s*100:0}}))}if(n==="mode"){const o=new Map;for(const r of a)for(const m of r){const h=X(m);o.has(h)||o.set(h,[]),o.get(h).push(m)}const s=[];for(const[r,m]of o){const h=r.split(","),d=Number(h[0]),c=Number(h[1]),p=m.map(x=>x.hbin).filter(x=>x!==void 0),u=qe(p);u!==null&&s.push({x:d,y:c,hbin:u})}return s}return[]}function le(t){const e=t.filter(F),n=e.length,i=e.filter(o=>o.edgeExcluded).length,a=e.filter(o=>o.hbin!==void 0||o.sbin!==void 0||dieHasTestData(o)).length;return{filledDies:a,totalDies:n,edgeExcludedDies:i,unpositionedDies:t.length-e.length,ratio:n>0?a/n:0}}function ce(t,e,n="exclude"){const i=new Set(e),o=t.filter(u=>!u.partial).filter(u=>u.edgeExcluded).length,s=t.filter(u=>u.partial).length;let r=0,m=0,h=!1;for(const u of t){if(!we(u))continue;const x=u.hbin??u.sbin;x!==void 0&&(h=!0,i.has(x)?r++:m++)}const d=r+m,c=h&&d>0?r/d*100:null;let p=null;if(n==="denominator-only"){const u=d+o;p=h&&u>0?r/u*100:null}return{passDies:r,failDies:m,edgeExcludedDies:o,partialDies:s,totalDies:d,yieldPercent:c,yieldPercentGross:p}}function he(t,e,n,i,a,o=0,s=0,r=0,m=0,h=0,d=!1,c=!1){if(!t)return[];const p=t.anchorDie??{x:0,y:0},u=Ye(e,{width:t.width,height:t.height,diePitchX:i,diePitchY:a,anchorDie:{x:p.x-o,y:p.y-s},gridOrigin:{x:-r,y:-m}}),x=_e(Ie(d,c,e.center.x,e.center.y),Fe(h,e.center.x,e.center.y));return u.filter(D=>{const l=D.width/2,b=D.height/2,w=[[D.x-l,D.y-b],[D.x+l,D.y-b],[D.x+l,D.y+b],[D.x-l,D.y+b]].map(([v,N])=>Pe(x,v,N)),g=oe(w.map(v=>v.x)),y=J(w.map(v=>v.x)),A=oe(w.map(v=>v.y)),R=J(w.map(v=>v.y));return n.some(v=>v.physX>=g&&v.physX<y&&v.physY>=A&&v.physY<R)})}function ft(t,e,n){const a=Math.max(0,e.radius-n)**2;return t.map(o=>{const s=o.physX-e.center.x,r=o.physY-e.center.y;return s*s+r*r>a?{...o,edgeExcluded:!0}:o})}const ut=.2;function lt(t,e,n){const i=new Set(n);function a(g,y){if(e==="last")return!0;if(e==="first")return!1;const A=K(g.hbin),R=K(y.hbin);if(A===void 0||R===void 0)return!1;const v=i.has(A),N=i.has(R);return e==="best"?N!==v?N:R<A:N!==v?v:R>A}const o=(g,y)=>y.supersedes!==void 0||a(g,y),s=g=>{const y=g.partId===void 0?"":String(g.partId).trim();return y===""?void 0:y},r=t.filter(g=>!F(g)),m=new Map;for(const g of r){const y=s(g);y!==void 0&&m.set(y,(m.get(y)??0)+1)}const d=(r.length===0?0:Math.max(0,...m.values())/r.length)<=ut,c=new Map,p=[],u=new Map;let x=0,D=0;for(const g of t){const y=s(g);let A;if(F(g)?A=`p:${X(g)}`:d&&y!==void 0?A=`i:${y}`:A=`u:${D++}`,g.supersedes==="partId"&&y!==void 0){const v=u.get(y);v!==void 0&&v!==A&&c.has(v)&&c.delete(v)}const R=c.get(A);R===void 0?(c.set(A,{winner:g,count:1}),p.push(A)):(R.count++,A.startsWith("i:")&&x++,o(R.winner,g)&&(R.winner=g)),y!==void 0&&u.set(y,A)}const l=[],b=[...p.filter(g=>g.startsWith("p:")),...p.filter(g=>!g.startsWith("p:"))];for(const g of b){const y=c.get(g);y!==void 0&&l.push(y.count>1?{...y.winner,retestCount:y.count}:y.winner)}const w=x>0?{code:"retests-by-part-id",severity:"info",message:`${x} record${x===1?"":"s"} with no position shared a part ID with an earlier record and ${x===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:l,warning:w}}export function getDieTestValue(t,e){return q(t,e)}export function getTestPassStatus(t,e,n){const i=Ce(t,e);return i!==void 0?i:n!==void 0&&!isParametricTest(n)?pe(q(t,e)):void 0}function pe(t){return t===0||t===1?t===1:void 0}export function testPassStatusReader(t){const e=t.map(a=>a.testNumber),n=ke(e),i=t.map(a=>!isParametricTest(a));return function(o,s){n(o,s);for(let r=0;r<s.length;r++){if(s[r]!==$e||!i[r])continue;const m=pe(q(o,e[r]));m!==void 0&&(s[r]=m?Re:Ne)}return s}}export function dieHasTestData(t){return Me(t)}function K(t){return t===void 0||Number.isNaN(t)?void 0:t}function H(t,e){const n={},i=K(e.hbin),a=K(e.sbin);i!==void 0&&(n.hbin=i),a!==void 0&&(n.sbin=a),e.retestCount!==void 0&&(n.retestCount=e.retestCount),e.siteNum!==void 0&&(n.siteNum=e.siteNum),e.partId!==void 0&&(n.partId=e.partId),e.metadata!==void 0&&(n.metadata=e.metadata);const o=G(e);return Se({...t,...n},o.table,o.row)}function me(t){return t.some(dieHasTestData)?"value":"hardBin"}function ge(t,e){return t.map(({code:n,message:i})=>({code:n,message:i,severity:n==="non-standard-diameter"||n==="diameter-exceeds-die-extent"?"warning":"error",confidence:e.wafer.confidence}))}const ct="do not fit inside the supplied",ht="Inferred wafer diameter",pt="The probed dies reach only",mt=.75,gt=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const yt=.02;function ye(t,e){return e.reduce((n,i)=>Math.abs(i-t)<Math.abs(n-t)?i:n)}function bt(t,e){if(!e.length)return!0;const n=ye(t,e);return Math.abs(n-t)/n<=yt}function wt(t){return t===void 0?STANDARD_WAFER_DIAMETERS_MM:t.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(t){const e=nt(!Array.isArray(t)&&t.layout?tt(t):t),n=[];if(e.derivedTests){const f=new Set(e.passBins),C=$=>{const E=$.length>0?G($[0]):void 0,W=Xe($,E?.table??Ae([]),e.testDefs,e.derivedTests,f);return E&&We($,W.table),W},S=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(C);e.testDefs=S[0]?.testDefs??e.testDefs,n.push(...S[0]?.warnings??[])}e.lotStackOpts&&!Qe(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(at));const i=e.lotStackOpts?ne(dt(e.lotStackOpts,e.testDefs)).records:e.results;for(let f=0;f<Math.min(5,i.length);f++){const C=i[f];if(typeof C.x=="string"||typeof C.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const f of i)if(f.x==null!=(f.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(f.x)}, y=${String(f.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:a,warning:o}=lt(i,e.retestPolicy,e.passBins),s={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},r=[];if(e.explicitDies){let f=e.explicitDies.filter(F);const C=e.explicitDies.filter(V=>!F(V)),T=a.filter(F),S=a.filter(V=>!F(V));if(T.length>0){const V=new Map(T.map(P=>[X(P),P]));f=f.map(P=>{const ee=V.get(X(P));return ee?H(P,ee):P})}const $=e.waferOpts?.diameter??300,E=U({diameter:$,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata});E.orientation!==0&&(f=te(f,E)),f=f.map(j);const W=he(e.reticleOpts,E,f,1,1,0,0,0,0,E.orientation),be=S.map((V,P)=>j(H({id:`unpositioned_${P}`,width:f[0]?.width??1,height:f[0]?.height??1},V))),z=[...f,...C,...be];return{wafer:E,dies:z,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:s,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...ge(r,s),...n,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:me(a),metadata:E.metadata??null,isLotStack:!1,dataCoverage:le(z),passBins:e.passBins,ringCount:e.ringCount,yield:ce(z,e.passBins,e.edgeDieYieldMode),reticles:W,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const m=a.filter(F),h=a.filter(f=>!F(f)),d=m.map(f=>({x:f.x,y:f.y})),c=Be(d,e.dieOpts,e.waferOpts?.diameter);s.diePitch={confidence:c.confidence,units:c.units};const{pitchX:p,pitchY:u}=c,x=c.units,D=it(m,e.dieOpts),l=Le(d);s.grid={confidence:l.confidence};const{offsetX:b,offsetY:w}=st(d,D,l),{flipX:g,flipY:y}=ue(e.dieOpts,D),{colMidX:A,colMidY:R,anchored:v}=rt(d,b,w,p,u,e.waferOpts?.center);let N=e.waferOpts?.diameter;const B=d.map(f=>({x:(Math.round(f.x)-b)*p-A,y:(Math.round(f.y)-w)*u-R})),I=J(B.map(({x:f,y:C})=>Math.hypot(Math.abs(f)+p/2,Math.abs(C)+u/2)));if(N===void 0)if(d.length>0)if(x==="mm"){const f=Ve(B,{minRadius:I});N=f.diameter,s.wafer={confidence:f.confidence,method:f.method};const C=wt(e.standardDiameters);if(!bt(N,C)){const T=ye(N,C);r.push({code:"non-standard-diameter",message:`${ht} ${N.toFixed(1)} mm is not a standard wafer size (nearest is ${T} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else N=I*2,s.wafer={confidence:c.confidence*.8,method:"extent"};else N=x==="mm"?300:30,s.wafer={confidence:0,method:"default"};if(!v&&d.length>0&&ot(d,b,w)&&(s.wafer.method="inferred-partial",r.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&e.waferOpts.center===void 0&&I>0&&d.length>=gt){const f=I/(N/2);f<mt&&r.push({code:"diameter-exceeds-die-extent",message:`${pt} ${(f*100).toFixed(0)}% of the ${N} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const f=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(f&&I>N/2+1e-9){const C=B.filter(({x:T,y:S})=>Math.hypot(Math.abs(T)+p/2,Math.abs(S)+u/2)>N/2+1e-9).length;r.push({code:"geometry-conflict",message:`${C} of ${B.length} probed die positions ${ct} ${N} mm wafer at the supplied die pitch of ${p} \xD7 ${u} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${(I*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const O=U({diameter:N,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata});let k=m.map(f=>{const C=Math.round(f.x)-b,T=Math.round(f.y)-w,S={id:`${C}_${T}`,x:C,y:T,physX:C*p-A,physY:T*u-R,width:p,height:u,insideWafer:!0,partial:!1};return H(S,f)});(b!==0||w!==0)&&(k=k.map(f=>({...f,x:f.x+b,y:f.y+w,id:`${f.x+b}_${f.y+w}`}))),k=te(k,O),(g||y)&&(k=xe(k,{flipX:g,flipY:y},O.center));const M=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&(k=ft(k,O,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>O.radius&&M.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${O.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),k=k.map(j);const Y=he(e.reticleOpts,O,k,p,u,b,w,A,R,O.orientation,g,y),_=h.map((f,C)=>j(H({id:`unpositioned_${C}`,width:p,height:u},f))),L=[...k,..._];return{wafer:O,dies:L,dataAxisFlip:{x:g,y},reticleConfig:e.reticleOpts,units:x,inference:s,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...ge(r,s),...M,...n,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:me(a),metadata:O.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:le(L),passBins:e.passBins,ringCount:e.ringCount,yield:ce(L,e.passBins,e.edgeDieYieldMode),reticles:Y,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
|
|
1
|
+
import{createWafer as q}from"../core/wafer.js";import{isYieldEligibleDie as De,getDieKey as Y,hasPosition as E}from"../core/dies.js";import{applyOrientation as ne,transformDies as ve,clipDiesToWafer as Me}from"../core/transforms.js";import{generateDies as Se}from"../core/dies.js";import{dieHasAnyTestData as Ce,dieLink as K,finaliseDie as H,linkDie as ke,recordedVerdict as Oe,recordedVerdictsReader as Ae,tableFromRows as Ne,testValue as J,testsPresent as $e,VERDICT_FAIL as Fe,VERDICT_NONE as Re,VERDICT_PASS as Te}from"../core/dieTable.js";import{isDieColumns as Ee,linkColumns as We,linkRows as ie,relink as se}from"./columnarInput.js";import{affineRotation as Ie,affineMirror as _e,affineCompose as Pe,affinePoint as Ve}from"../core/transforms.js";import{inferWaferFromXY as Be}from"../core/inference/wafer.js";import{resolveGridPitch as Le}from"../core/inference/pitch.js";import{assignGridIndices as Ye}from"../core/inference/grid.js";import{generateReticleGrid as Xe}from"../core/reticle.js";import{applyDerivedTests as je}from"./derivedTests/apply.js";import{isStdfBin as Ke,isStdfCoord as re,isStdfTestNumber as oe,isStdfSite as He,STDF_BIN_MAX as ze,STDF_COORD_MAX as ae,STDF_TEST_NUM_MAX as Ue,STDF_SITE_MAX as Ge}from"../core/stdf.js";import{hasAnyKey as qe,maxOf as Q,minOf as de,modeOf as Je}from"../core/utils.js";import{aggregateValues as fe,aggregateBinCounts as Qe,stackHoldsMeasurements as Ze}from"../core/aggregates.js";import{normalizePassBins as le}from"../core/passBins.js";import{defaultRingCount as Z}from"../core/ringCount.js";import{applyValueFilter as et,mergeValueFilterTests as tt,valueFilterWarning as nt}from"./valueFilter.js";export function isParametricTest(t){return t?.testType!=="F"}export function isBuiltMap(t){return"wafer"in t&&"dies"in t&&"dataAxisFlip"in t}function it(t){const e=(i,d)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(t)} ${d} (using ${i}).`}});if(t===void 0)return{ringCount:Z(),ringCountWarning:void 0};if(typeof t!="number"||!Number.isFinite(t))return e(Z(),"is not a finite number");const n=Math.max(1,Math.round(t));return n===t?{ringCount:t,ringCountWarning:void 0}:e(n,"is not a whole number of at least 1")}function st(t,e){const n=Array.isArray(t)?{}:t,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let d;const r=(c,S)=>{i[c]++,d??=`${c} ${JSON.stringify(S)}`},a={bins:0,positions:0,values:0,sites:0,orientation:0},s=new Set;let h=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(d??=e.example),a.values+=e.nonFinite;for(const c of e.badTestNumbers)s.add(c)}const p=c=>c==null?!0:typeof c!="number"?!1:Number.isNaN(c)?(h++,!1):Ke(c)?!0:(a.bins++,!1);function u(c){const S=new Set,D=new Set;for(let $=0;$<c.length;$+=$<50?1:100){const A=c[$];if(!(A===null||typeof A!="object")){if(A.testValues&&typeof A.testValues=="object")for(const w of Object.keys(A.testValues))S.add(w);if(A.testPass&&typeof A.testPass=="object")for(const w of Object.keys(A.testPass))D.add(w)}}const m=[...S],b=[...D],O=$=>oe(Number($));for(const $ of new Set([...m,...b]))O($)||s.add($);const F=m.map(O),M=b.map(O),W=m.map(Number),T=b.map(Number);let P;for(let $=0;$<c.length;$++){const A=c[$];if(A===null||typeof A!="object")continue;const w=A;let B;const I=()=>B??={...w};w.hbin!=null&&typeof w.hbin!="number"&&r("hbin",w.hbin),w.sbin!=null&&typeof w.sbin!="number"&&r("sbin",w.sbin),p(w.hbin)||(I().hbin=void 0),p(w.sbin)||(I().sbin=void 0);const X=typeof w.x=="number"&&!re(w.x),L=typeof w.y=="number"&&!re(w.y);if(X||L){a.positions+=(X?1:0)+(L?1:0);const x=I();x.x=void 0,x.y=void 0}w.siteNum!=null&&typeof w.siteNum!="number"?(r("siteNum",w.siteNum),I().siteNum=void 0):typeof w.siteNum=="number"&&!He(w.siteNum)&&(a.sites++,I().siteNum=void 0);const o=w.testValues;if(o&&typeof o=="object"){let x;for(let k=0;k<m.length;k++){const R=m[k],N=o[W[k]];if(N!=null){if(!F[k]){x??={...o},delete x[R];continue}typeof N!="number"?(r("testValues",N),x??={...o},delete x[R]):Number.isFinite(N)||(a.values++,x??={...o},delete x[R])}}x&&(I().testValues=x)}const C=w.testPass;if(C&&typeof C=="object"){let x;for(let k=0;k<b.length;k++){const R=b[k],N=C[T[k]];if(N!=null){if(!M[k]){x??={...C},delete x[R];continue}typeof N!="boolean"&&(r("testPass",N),x??={...C},delete x[R])}}x&&(I().testPass=x)}B&&((P??=c.slice())[$]=B)}return P}const l={warnings:[]};if(Array.isArray(t))l.results=u(t);else{Array.isArray(n.results)&&(l.results=u(n.results)),Array.isArray(n.dies)&&(l.dies=u(n.dies));const c=n.lotStack?.results;if(Array.isArray(c)){const S=c.map(D=>Array.isArray(D)?u(D):void 0);S.some(Boolean)&&(l.stackResults=S.map((D,m)=>D??c[m]))}}if(Array.isArray(n.testDefs)){const c=n.testDefs,S=c.filter(D=>D==null||typeof D.testNumber!="number"||oe(D.testNumber));for(const D of c)S.includes(D)||s.add(String(D.testNumber));S.length!==c.length&&(l.testDefs=S)}const g=n.waferConfig?.orientation;if(typeof g=="number"){const c=Number.isFinite(g)?(g%360+360)%360:NaN;c===0||c===90||c===180||c===270?l.orientation=c:(a.orientation++,l.orientation=0)}const f=(c,S,D=`${S}s`)=>`${c} ${c===1?S:D}`,y=[];if(i.hbin&&y.push(f(i.hbin,"hard bin")),i.sbin&&y.push(f(i.sbin,"soft bin")),i.siteNum&&y.push(f(i.siteNum,"site number")),i.testValues&&y.push(f(i.testValues,"test value")),i.testPass&&y.push(f(i.testPass,"pass/fail verdict")),y.length){const c=`buildWaferMap received ${y.join(", ")} of the wrong type (for example ${d}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${c}`),l.warnings.push({code:"input-values-not-numbers",message:c,severity:"error"})}const v=[];if(a.bins&&v.push(`${f(a.bins,"bin")} (legal: whole numbers 0\u2013${ze}) \u2014 those dies have no bin`),a.positions&&v.push(`${f(a.positions,"coordinate")} (legal: whole numbers \u2212${ae} to ${ae}) \u2014 those dies have no position`),s.size&&v.push(`${f(s.size,"test number")} (legal: whole numbers 0\u2013${Ue}) \u2014 those tests are left out`),a.values&&v.push(`${f(a.values,"test value")} that ${a.values===1?"is":"are"} not finite \u2014 left out`),a.sites&&v.push(`${f(a.sites,"site number")} (legal: 0\u2013${Ge}) \u2014 those dies have no site`),a.orientation&&v.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),v.length||h){const c=[];v.length&&c.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${v.join("; ")}.`),h&&c.push(`${f(h,"bin was","bins were")} NaN and ${h===1?"is":"are"} treated as no bin.`);const S=c.join(" ");console.warn(`[wafermap] ${S}`),l.warnings.push({code:"input-values-outside-stdf",message:S,severity:"warning"})}return l}function ue(t){const e=(p,u)=>p!==null&&typeof p=="object"&&p[u]!==void 0,n=Array.isArray(t)?{}:t,i=[],d=(p,u,l)=>{p&&i.push(`\`${u}\` (now \`${l}\`)`)};d(e(n,"data"),"data","results"),d(e(n,"die"),"die","dieConfig"),d(e(n,"stack"),"stack","lotStack"),d(e(n.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),d(e(n.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),d(e(n.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),d(e(n.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),d(Array.isArray(n.testDefs)&&n.testDefs.some(p=>e(p,"index")&&!e(p,"testNumber")),"TestDef.index","TestDef.testNumber");const r=e(n.lotStack,"results")?n.lotStack.results:[],a=(Array.isArray(t)?[t]:[n.results,...Array.isArray(r)?r:[]]).filter(p=>Array.isArray(p));if(d(a.some(p=>p.slice(0,100).some(u=>e(u,"values"))),"values","testValues"),!i.length)return;const s=i.length>1,h=`buildWaferMap ignored ${i.join(", ")}: ${s?"these names were":"that name was"} removed in an earlier release, so what ${s?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${h}`),{code:"input-field-removed",message:h,severity:"error"}}function rt(t){if(t.results!==void 0||t.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=t.waferConfig?.diameter,n=t.dieConfig?.width,i=t.dieConfig?.height;if(!(e>0&&n>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const d=q({diameter:e,notch:t.waferConfig?.notch,orientation:0}),r=Me(Se(d,{width:n,height:i}),d,{width:n,height:i}).filter(u=>!u.partial),{flipX:a,flipY:s}=ce(t.dieConfig,{type:"center"}),{layout:h,...p}=t;return{...p,results:r.map(u=>({x:a?-u.x:u.x,y:s?-u.y:u.y})),waferConfig:{...t.waferConfig,center:{x:0,y:0}},dieConfig:{...t.dieConfig,coordinateOrigin:{type:"center"}}}}function ot(t){if(!Array.isArray(t)&&"results"in t&&t.results!==void 0&&"lotStack"in t&&t.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},n=!Array.isArray(t)&&Ee(t.results)?{...t,results:We(t.results,e).records}:t,i=st(n,e);return Array.isArray(n)?{results:ee(i.results??n),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:le(void 0),ringCount:Z(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:ue(n),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ee(i.results??n.results??[]),waferOpts:i.orientation===void 0||n.waferConfig===void 0?n.waferConfig:{...n.waferConfig,orientation:i.orientation},dieOpts:n.dieConfig,explicitDies:i.dies??n.dies,reticleOpts:n.reticleConfig,lotStackOpts:n.lotStack?{...n.lotStack,results:(i.stackResults??n.lotStack.results).map(ee)}:void 0,passBins:le(n.passBins),valueFilter:n.valueFilter??"validity",...it(n.ringCount),removedFieldWarning:ue(n),inputValueWarnings:i.warnings,standardDiameters:n.standardDiameters,testDefs:(i.testDefs??n.testDefs)?.length?i.testDefs??n.testDefs:void 0,hbinDefs:n.hbinDefs,sbinDefs:n.sbinDefs,metadataFields:n.metadataFields,derivedTests:n.derivedTests?.length?n.derivedTests:void 0,retestPolicy:n.retestPolicy??"last",edgeDieYieldMode:n.edgeDieYieldMode??"exclude"}}function ee(t){return t.length>0&&K(t[0])!==void 0?t:ie(t).records}function at(t,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function dt(t,e,n){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,d=-1/0,r=1/0,a=-1/0;for(const s of t)s.x<i&&(i=s.x),s.x>d&&(d=s.x),s.y<r&&(r=s.y),s.y>a&&(a=s.y);return{offsetX:Math.round((d+i)/2),offsetY:Math.round((a+r)/2)}}return{offsetX:n.offsetX,offsetY:n.offsetY}}function ft(t,e,n,i,d,r){if(r)return{colMidX:(Math.round(r.x)-e)*i,colMidY:(Math.round(r.y)-n)*d,anchored:!0};if(t.length===0)return{colMidX:0,colMidY:0,anchored:!1};let a=1/0,s=-1/0,h=1/0,p=-1/0;for(const u of t){const l=Math.round(u.x)-e,g=Math.round(u.y)-n;l<a&&(a=l),l>s&&(s=l),g<h&&(h=g),g>p&&(p=g)}return{colMidX:(a+s)/2*i,colMidY:(h+p)/2*d,anchored:!1}}function lt(t,e,n){let i=1/0,d=-1/0,r=1/0,a=-1/0,s=0,h=0;for(const l of t){const g=Math.round(l.x)-e,f=Math.round(l.y)-n;s+=g,h+=f,g<i&&(i=g),g>d&&(d=g),f<r&&(r=f),f>a&&(a=f)}const p=t.length,u=(l,g,f)=>{const y=(f-g)/2;return y<=0?0:Math.abs(l/p-(g+f)/2)/y};return u(s,i,d)>.11||u(h,r,a)>.11}function ce(t,e){let n=t?.xAxisDirection==="left",i=t?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(n=!0),{flipX:n,flipY:i}}function ut(t){const e={...t};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function ct(t,e){const{method:n,targetBin:i}=t,d=t.results.map(r=>r.filter(E));if(n==="mean"||n==="median"||n==="stddev"||n==="min"||n==="max"||n==="count"){const r=new Set((e??[]).filter(u=>!isParametricTest(u)).map(u=>u.testNumber)),a=new Set;for(const u of d)for(const l of $e(u,"values"))r.has(l)||a.add(l);if(a.size===0)return fe(d,n);const s=[...a],h=s.map(u=>fe(d,n,u)),p=new Map;for(let u=0;u<s.length;u++){const l=s[u];for(const g of h[u]){const f=Y(g);p.has(f)||p.set(f,{template:g,testValues:{}});const y=p.get(f),v=g.testValues?.[0];v!==void 0&&(y.testValues[l]=v)}}return[...p.values()].map(({template:u,testValues:l})=>({...u,testValues:qe(l)?l:void 0}))}if(n==="countBin"||n==="percent"){if(i===void 0)return[];const r=Qe(d,i,"hard");if(n==="countBin")return r;const a=d.length;return r.map(s=>({...s,testValues:{0:a>0?(s.testValues?.[0]??0)/a*100:0}}))}if(n==="mode"){const r=new Map;for(const s of d)for(const h of s){const p=Y(h);r.has(p)||r.set(p,[]),r.get(p).push(h)}const a=[];for(const[s,h]of r){const p=s.split(","),u=Number(p[0]),l=Number(p[1]),g=h.map(y=>y.hbin).filter(y=>y!==void 0),f=Je(g);f!==null&&a.push({x:u,y:l,hbin:f})}return a}return[]}function pe(t){const e=t.filter(E),n=e.length,i=e.filter(r=>r.edgeExcluded).length,d=e.filter(r=>r.hbin!==void 0||r.sbin!==void 0||dieHasTestData(r)).length;return{filledDies:d,totalDies:n,edgeExcludedDies:i,unpositionedDies:t.length-e.length,ratio:n>0?d/n:0}}function he(t,e,n="exclude"){const i=new Set(e),r=t.filter(f=>!f.partial).filter(f=>f.edgeExcluded).length,a=t.filter(f=>f.partial).length;let s=0,h=0,p=!1;for(const f of t){if(!De(f))continue;const y=f.hbin??f.sbin;y!==void 0&&(p=!0,i.has(y)?s++:h++)}const u=s+h,l=p&&u>0?s/u*100:null;let g=null;if(n==="denominator-only"){const f=u+r;g=p&&f>0?s/f*100:null}return{passDies:s,failDies:h,edgeExcludedDies:r,partialDies:a,totalDies:u,yieldPercent:l,yieldPercentGross:g}}function me(t,e,n,i,d,r=0,a=0,s=0,h=0,p=0,u=!1,l=!1){if(!t)return[];const g=t.anchorDie??{x:0,y:0},f=Xe(e,{width:t.width,height:t.height,diePitchX:i,diePitchY:d,anchorDie:{x:g.x-r,y:g.y-a},gridOrigin:{x:-s,y:-h}}),y=Pe(_e(u,l,e.center.x,e.center.y),Ie(p,e.center.x,e.center.y));return f.filter(v=>{const c=v.width/2,S=v.height/2,D=[[v.x-c,v.y-S],[v.x+c,v.y-S],[v.x+c,v.y+S],[v.x-c,v.y+S]].map(([M,W])=>Ve(y,M,W)),m=de(D.map(M=>M.x)),b=Q(D.map(M=>M.x)),O=de(D.map(M=>M.y)),F=Q(D.map(M=>M.y));return n.some(M=>M.physX>=m&&M.physX<b&&M.physY>=O&&M.physY<F)})}function pt(t,e,n){const d=Math.max(0,e.radius-n)**2;return t.map(r=>{const a=r.physX-e.center.x,s=r.physY-e.center.y;return a*a+s*s>d?{...r,edgeExcluded:!0}:r})}const ht=.2;function mt(t,e,n){const i=new Set(n);function d(m,b){if(e==="last")return!0;if(e==="first")return!1;const O=z(m.hbin),F=z(b.hbin);if(O===void 0||F===void 0)return!1;const M=i.has(O),W=i.has(F);return e==="best"?W!==M?W:F<O:W!==M?M:F>O}const r=(m,b)=>b.supersedes!==void 0||d(m,b),a=m=>{const b=m.partId===void 0?"":String(m.partId).trim();return b===""?void 0:b},s=t.filter(m=>!E(m)),h=new Map;for(const m of s){const b=a(m);b!==void 0&&h.set(b,(h.get(b)??0)+1)}const u=(s.length===0?0:Math.max(0,...h.values())/s.length)<=ht,l=new Map,g=[],f=new Map;let y=0,v=0;for(const m of t){const b=a(m);let O;if(E(m)?O=`p:${Y(m)}`:u&&b!==void 0?O=`i:${b}`:O=`u:${v++}`,m.supersedes==="partId"&&b!==void 0){const M=f.get(b);M!==void 0&&M!==O&&l.has(M)&&l.delete(M)}const F=l.get(O);F===void 0?(l.set(O,{winner:m,count:1}),g.push(O)):(F.count++,O.startsWith("i:")&&y++,r(F.winner,m)&&(F.winner=m)),b!==void 0&&f.set(b,O)}const c=[],S=[...g.filter(m=>m.startsWith("p:")),...g.filter(m=>!m.startsWith("p:"))];for(const m of S){const b=l.get(m);b!==void 0&&c.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=y>0?{code:"retests-by-part-id",severity:"info",message:`${y} record${y===1?"":"s"} with no position shared a part ID with an earlier record and ${y===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:c,warning:D}}export function getDieTestValue(t,e){return J(t,e)}export function getTestPassStatus(t,e,n){const i=Oe(t,e);return i!==void 0?i:n!==void 0&&!isParametricTest(n)?ge(J(t,e)):void 0}function ge(t){return t===0||t===1?t===1:void 0}export function testPassStatusReader(t){const e=t.map(d=>d.testNumber),n=Ae(e),i=t.map(d=>!isParametricTest(d));return function(r,a){n(r,a);for(let s=0;s<a.length;s++){if(a[s]!==Re||!i[s])continue;const h=ge(J(r,e[s]));h!==void 0&&(a[s]=h?Te:Fe)}return a}}export function dieHasTestData(t){return Ce(t)}function z(t){return t===void 0||Number.isNaN(t)?void 0:t}function U(t,e){const n={},i=z(e.hbin),d=z(e.sbin);i!==void 0&&(n.hbin=i),d!==void 0&&(n.sbin=d),e.retestCount!==void 0&&(n.retestCount=e.retestCount),e.siteNum!==void 0&&(n.siteNum=e.siteNum),e.partId!==void 0&&(n.partId=e.partId),e.metadata!==void 0&&(n.metadata=e.metadata);const r=K(e);return ke({...t,...n},r.table,r.row)}function ye(t){return t.some(dieHasTestData)?"value":t.some(e=>e.hbin!==void 0&&e.hbin!==null)?"hardBin":t.some(e=>e.sbin!==void 0&&e.sbin!==null)?"softBin":"hardBin"}function be(t,e){return t.map(({code:n,message:i})=>({code:n,message:i,severity:n==="non-standard-diameter"||n==="diameter-exceeds-die-extent"?"warning":"error",confidence:e.wafer.confidence}))}const gt="do not fit inside the supplied",yt="Inferred wafer diameter",bt="The probed dies reach only",wt=.75,xt=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const Dt=.02;function we(t,e){return e.reduce((n,i)=>Math.abs(i-t)<Math.abs(n-t)?i:n)}function vt(t,e){if(!e.length)return!0;const n=we(t,e);return Math.abs(n-t)/n<=Dt}function Mt(t){return t===void 0?STANDARD_WAFER_DIAMETERS_MM:t.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(t){const e=ot(!Array.isArray(t)&&t.layout?rt(t):t),n=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const o=e.valueFilter,C=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(k=>{const R=k.length>0?K(k[0]):void 0;if(!R)return[];const N=et(R.table,e.testDefs,o);return N.tests.length>0&&se(k,N.table),N.tests}),x=tt(C);if(x.length>0){i={mode:o,tests:x};const k=nt(o,x,e.testDefs);k&&n.push(k)}}if(e.derivedTests){const o=new Set(e.passBins),C=R=>{const N=R.length>0?K(R[0]):void 0,j=je(R,N?.table??Ne([]),e.testDefs,e.derivedTests,o);return N&&se(R,j.table),j},k=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(C);e.testDefs=k[0]?.testDefs??e.testDefs,n.push(...k[0]?.warnings??[])}e.lotStackOpts&&!Ze(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(ut));const d=e.lotStackOpts?ie(ct(e.lotStackOpts,e.testDefs)).records:e.results;for(let o=0;o<Math.min(5,d.length);o++){const C=d[o];if(typeof C.x=="string"||typeof C.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const o of d)if(o.x==null!=(o.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(o.x)}, y=${String(o.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:r,warning:a}=mt(d,e.retestPolicy,e.passBins),s={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},h=[];if(e.explicitDies){let o=e.explicitDies.filter(E);const C=e.explicitDies.filter(V=>!E(V)),x=r.filter(E),k=r.filter(V=>!E(V));if(x.length>0){const V=new Map(x.map(_=>[Y(_),_]));o=o.map(_=>{const te=V.get(Y(_));return te?U(_,te):_})}const R=e.waferOpts?.diameter??300,N=q({diameter:R,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});N.orientation!==0&&(o=ne(o,N)),o=o.map(H);const j=me(e.reticleOpts,N,o,1,1,0,0,0,0,N.orientation),xe=k.map((V,_)=>H(U({id:`unpositioned_${_}`,width:o[0]?.width??1,height:o[0]?.height??1},V))),G=[...o,...C,...xe];return{wafer:N,dies:G,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:s,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...a?[a]:[],...be(h,s),...n,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:ye(r),metadata:N.metadata??null,isLotStack:!1,dataCoverage:pe(G),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:he(G,e.passBins,e.edgeDieYieldMode),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const p=r.filter(E),u=r.filter(o=>!E(o)),l=p.map(o=>({x:o.x,y:o.y})),g=Le(l,e.dieOpts,e.waferOpts?.diameter);s.diePitch={confidence:g.confidence,units:g.units};const{pitchX:f,pitchY:y}=g,v=g.units,c=at(p,e.dieOpts),S=Ye(l);s.grid={confidence:S.confidence};const{offsetX:D,offsetY:m}=dt(l,c,S),{flipX:b,flipY:O}=ce(e.dieOpts,c),{colMidX:F,colMidY:M,anchored:W}=ft(l,D,m,f,y,e.waferOpts?.center);let T=e.waferOpts?.diameter;const P=l.map(o=>({x:(Math.round(o.x)-D)*f-F,y:(Math.round(o.y)-m)*y-M})),$=Q(P.map(({x:o,y:C})=>Math.hypot(Math.abs(o)+f/2,Math.abs(C)+y/2)));if(T===void 0)if(l.length>0)if(v==="mm"){const o=Be(P,{minRadius:$});T=o.diameter,s.wafer={confidence:o.confidence,method:o.method};const C=Mt(e.standardDiameters);if(!vt(T,C)){const x=we(T,C);h.push({code:"non-standard-diameter",message:`${yt} ${T.toFixed(1)} mm is not a standard wafer size (nearest is ${x} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else T=$*2,s.wafer={confidence:g.confidence*.8,method:"extent"};else T=v==="mm"?300:30,s.wafer={confidence:0,method:"default"};if(!W&&l.length>0&<(l,D,m)&&(s.wafer.method="inferred-partial",h.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&e.waferOpts.center===void 0&&$>0&&l.length>=xt){const o=$/(T/2);o<wt&&h.push({code:"diameter-exceeds-die-extent",message:`${bt} ${(o*100).toFixed(0)}% of the ${T} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const o=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(o&&$>T/2+1e-9){const C=P.filter(({x,y:k})=>Math.hypot(Math.abs(x)+f/2,Math.abs(k)+y/2)>T/2+1e-9).length;h.push({code:"geometry-conflict",message:`${C} of ${P.length} probed die positions ${gt} ${T} mm wafer at the supplied die pitch of ${f} \xD7 ${y} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${($*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const A=q({diameter:T,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let w=p.map(o=>{const C=Math.round(o.x)-D,x=Math.round(o.y)-m,k={id:`${C}_${x}`,x:C,y:x,physX:C*f-F,physY:x*y-M,width:f,height:y,insideWafer:!0,partial:!1};return U(k,o)});(D!==0||m!==0)&&(w=w.map(o=>({...o,x:o.x+D,y:o.y+m,id:`${o.x+D}_${o.y+m}`}))),w=ne(w,A),(b||O)&&(w=ve(w,{flipX:b,flipY:O},A.center));const B=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&(w=pt(w,A,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>A.radius&&B.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${A.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),w=w.map(H);const I=me(e.reticleOpts,A,w,f,y,D,m,F,M,A.orientation,b,O),X=u.map((o,C)=>H(U({id:`unpositioned_${C}`,width:f,height:y},o))),L=[...w,...X];return{wafer:A,dies:L,dataAxisFlip:{x:b,y:O},reticleConfig:e.reticleOpts,units:v,inference:s,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...a?[a]:[],...be(h,s),...B,...n,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:ye(r),metadata:A.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:pe(L),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:he(L,e.passBins,e.edgeDieYieldMode),reticles:I,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isStdfTestNumber as D,STDF_TEST_NUM_MAX as T}from"../../core/stdf.js";import{diePassStatus as M}from"../../core/dies.js";import{getTestPassStatus as
|
|
1
|
+
import{isStdfTestNumber as D,STDF_TEST_NUM_MAX as T}from"../../core/stdf.js";import{diePassStatus as M}from"../../core/dies.js";import{getTestPassStatus as F,isParametricTest as V}from"../buildWaferMap.js";import{classifySpec as _}from"../spec.js";import{parseExpression as P}from"./parser.js";import{evaluate as A}from"./evaluate.js";import{extendTable as E,rowView as O,testValue as I,HAS_VALUES as k,HAS_VERDICTS as C,VERDICT_FAIL as L,VERDICT_NONE as S,VERDICT_PASS as R}from"../../core/dieTable.js";function l(w){return{code:"derived-test-invalid",message:w,severity:"warning"}}function j(w,p){const m=[],n=r=>{switch(r.k){case"acc":{if(r.kind!=="t")return;const o=p.get(r.test)?.unit;return o?new Set([o]):void 0}case"unary":return r.op==="-"?n(r.arg):void 0;case"binary":{const o=n(r.left),a=n(r.right);if(r.op==="+"||r.op==="-"){if(o&&a){const d=new Set([...o,...a]);return d.size>1&&m.push(`${[...d].join(" and ")} are combined by "${r.op}"`),d}return o??a}return}case"call":{if(r.name==="min"||r.name==="max"||r.name==="mean"||r.name==="sum"){const o=r.args[0];if(o?.k==="vec"&&o.kind==="t"){const a=new Set(o.tests.map(d=>p.get(d)?.unit).filter(d=>!!d));return a.size>1&&m.push(`${[...a].join(" and ")} are combined by "${r.name}"`),a}}return}default:return}};return n(w),m}function B(w,p,m){const n=[],r=new Map((p??[]).map(e=>[e.testNumber,e])),o=e=>`${JSON.stringify(e.name??"")} (test ${e.testNumber})`,a=[],d=new Set;for(const e of w){const s=o(e);if(!D(e.testNumber)){n.push(l(`Derived test ${s} was dropped: \`testNumber\` must be a whole number from 0 to ${T}, as STDF stores it.`));continue}if(m.has(e.testNumber)||r.has(e.testNumber)){n.push(l(`Derived test ${s} was dropped: test number ${e.testNumber} already exists in the data. Measured values are never replaced by a derived test \u2014 give it an unused number.`));continue}if(d.has(e.testNumber)){n.push(l(`Derived test ${s} was dropped: test number ${e.testNumber} is used by an earlier derived test.`));continue}if(typeof e.expression!="string"||e.expression.trim()===""){n.push(l(`Derived test ${s} was dropped: \`expression\` is empty.`));continue}d.add(e.testNumber),a.push(e)}const g=new Map(r);for(const e of a){const{expression:s,constants:u,...c}=e;g.set(e.testNumber,{...c,testType:e.testType??"P"})}const h=new Map,f=new Set;for(const e of a){const s=o(e),u={testDefs:g,constants:e.constants??{}},c=P(e.expression,u);if(!c.ok){n.push(l(`Derived test ${s} was dropped: ${c.message}`)),f.add(e.testNumber);continue}const t=c.type==="boolean",i=!V(e);if(t!==i){n.push(l(t?`Derived test ${s} was dropped: its expression produces a true/false verdict, so it must declare \`testType: 'F'\`.`:`Derived test ${s} was dropped: it declares \`testType: 'F'\` but its expression produces a number. Functional tests carry a verdict, not a measurement.`)),f.add(e.testNumber);continue}if(t&&(e.limitLow!==void 0||e.limitHigh!==void 0)&&n.push(l(`Derived test ${s}: test limits are ignored on a true/false derived test.`)),e.testNumber===void 0)continue;const N=e.testNumber,x=[...new Set(c.reads.map(v=>v.test))].filter(v=>v!==N&&d.has(v));if(c.reads.some(v=>v.test===N)){n.push(l(`Derived test ${s} was dropped: its expression reads itself.`)),f.add(N);continue}for(const v of j(c.ast,g))n.push(l(`Derived test ${s} combines different units \u2014 ${v}. The result is computed as written; set \`unit\` on the derived test to say what it is.`));h.set(N,{raw:e,compiled:{def:{...e,testType:t?"F":"P",derived:!0},ast:c.ast,boolean:t},deps:x})}const y=[],b=new Map,$=(e,s)=>{if(b.get(e)==="done")return!f.has(e);if(b.get(e)==="visiting"){const t=[...s.slice(s.indexOf(e)),e].join(" \u2192 ");for(const i of s.slice(s.indexOf(e)))f.has(i)||(f.add(i),n.push(l(`Derived test ${o(h.get(i).raw)} was dropped: its expression depends on itself through ${t}.`)));return!1}const u=h.get(e);if(u===void 0)return!1;b.set(e,"visiting");let c=!0;for(const t of u.deps)if(!$(t,[...s,e])){if(!f.has(e)){f.add(e);const i=h.get(t)?.raw.name??`test ${t}`;n.push(l(`Derived test ${o(u.raw)} was dropped: it reads ${JSON.stringify(i)} (test ${t}), which was itself dropped.`))}c=!1;break}return b.set(e,"done"),!c||f.has(e)?!1:(y.push(u.compiled),!0)};for(const e of a)$(e.testNumber,[]);return{compiled:y,warnings:n}}export function applyDerivedTests(w,p,m,n,r){if(n===void 0||n.length===0)return{table:p,testDefs:m,warnings:[]};const o=new Set;for(const[e,s]of p.values)s.some(u=>!Number.isNaN(u))&&o.add(e);for(const[e,s]of p.verdicts)s.some(u=>u!==S)&&o.add(e);const{compiled:a,warnings:d}=B(n,m,o);if(a.length===0)return{table:p,testDefs:m,warnings:d};const g=new Map((m??[]).map(e=>[e.testNumber,e]));for(const e of a)g.set(e.def.testNumber,e.def);const h=p.rows,f=new Map,y=new Map;for(const e of a)e.boolean?y.set(e.def.testNumber,new Int8Array(h).fill(S)):f.set(e.def.testNumber,new Float64Array(h).fill(NaN));const b=E(p,f,y),$=O(b);for(let e=0;e<h;e++){const s=$(e),u=t=>I(s,t),c={value:u,testPass:t=>F(s,t,g.get(t)),specPass:t=>{const i=_(u(t),g.get(t));return i===null?void 0:i==="pass"},diePass:()=>M(w[e],r),field:t=>{const i=w[e],N=t==="x"?i.x:t==="y"?i.y:t==="hbin"?i.hbin:t==="sbin"?i.sbin:i.siteNum;return typeof N=="number"&&Number.isFinite(N)?N:void 0}};for(const t of a){const i=A(t.ast,c);i!==void 0&&(t.boolean?(y.get(t.def.testNumber)[e]=i?R:L,b.fields[e]|=C):(f.get(t.def.testNumber)[e]=i,b.fields[e]|=k))}}return{table:b,testDefs:[...m??[],...a.map(e=>e.def)],warnings:d}}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* for the same reason: `NaN` must reach the map as no-data, not as a value that
|
|
22
22
|
* drags a mean toward zero or classifies as in-spec.
|
|
23
23
|
*/
|
|
24
|
-
import type { ExprNode } from './parser.js';
|
|
24
|
+
import type { DieField, ExprNode } from './parser.js';
|
|
25
25
|
/** Per-die data the evaluator is allowed to reach. Deliberately a closed set of
|
|
26
26
|
* functions rather than the die object, so the AST has no path to anything
|
|
27
27
|
* else on the die or in the host. */
|
|
@@ -34,6 +34,8 @@ export interface EvalContext {
|
|
|
34
34
|
specPass(test: number): boolean | undefined;
|
|
35
35
|
/** The die's bin-based pass verdict, via `diePassStatus`. */
|
|
36
36
|
diePass(): boolean | undefined;
|
|
37
|
+
/** One of the die's own recorded fields, or `undefined` when it has none (a die with no position, no bin, no site). */
|
|
38
|
+
field(name: DieField): number | undefined;
|
|
37
39
|
}
|
|
38
40
|
type Scalar = number | boolean | undefined;
|
|
39
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{minOf as c,maxOf as f}from"../../core/utils.js";function s(e){return Number.isFinite(e)?e:void 0}function l(e,t){const n=r=>e.kind==="t"?t.value(r):e.kind==="testPass"?t.testPass(r):t.specPass(r);return e.tests.map(n)}function
|
|
1
|
+
import{minOf as c,maxOf as f}from"../../core/utils.js";function s(e){return Number.isFinite(e)?e:void 0}function l(e,t){const n=r=>e.kind==="t"?t.value(r):e.kind==="testPass"?t.testPass(r):t.specPass(r);return e.tests.map(n)}function d(e,t){const n=t.filter(r=>r!==void 0);if(e==="countKnown")return n.length;if(n.length!==0)switch(e){case"all":return n.every(Boolean);case"any":return n.some(Boolean);case"none":return!n.some(Boolean);case"countTrue":return n.filter(Boolean).length;case"countFalse":return n.filter(r=>!r).length;case"min":return c(n);case"max":return f(n);case"sum":return s(n.reduce((r,a)=>r+a,0));case"mean":return s(n.reduce((r,a)=>r+a,0)/n.length);default:return}}const o={abs:e=>Math.abs(e[0]),sqrt:e=>Math.sqrt(e[0]),ln:e=>Math.log(e[0]),log10:e=>Math.log10(e[0]),exp:e=>Math.exp(e[0]),floor:e=>Math.floor(e[0]),ceil:e=>Math.ceil(e[0]),round:e=>Math.round(e[0]),sign:e=>Math.sign(e[0]),pow:e=>Math.pow(e[0],e[1]),min:e=>c(e),max:e=>f(e)};export function evaluate(e,t){switch(e.k){case"num":return e.value;case"acc":return e.kind==="t"?t.value(e.test):e.kind==="testPass"?t.testPass(e.test):t.specPass(e.test);case"diePass":return t.diePass();case"dieField":return t.field(e.field);case"vec":return;case"unary":{const n=evaluate(e.arg,t);return n===void 0?void 0:e.op==="-"?s(-n):!n}case"binary":{const n=evaluate(e.left,t);if(n===void 0)return;const r=evaluate(e.right,t);if(r===void 0)return;switch(e.op){case"+":return s(n+r);case"-":return s(n-r);case"*":return s(n*r);case"/":return s(n/r);case"%":return s(n%r);case"^":return s(Math.pow(n,r));case"<":return n<r;case"<=":return n<=r;case">":return n>r;case">=":return n>=r;case"==":return n===r;case"!=":return n!==r;case"and":return n&&r;case"or":return n||r}return}case"call":{if(e.name==="if"){const u=evaluate(e.args[0],t);return u===void 0?void 0:evaluate(e.args[u?1:2],t)}const n=e.args[0];if(e.args.length===1&&n!==void 0&&n.k==="vec")return d(e.name,l(n,t));const r=o[e.name];if(r===void 0)return;const a=[];for(const u of e.args){const i=evaluate(u,t);if(i===void 0)return;a.push(i)}return s(r(a))}}}
|
|
@@ -41,6 +41,10 @@ export type ExprType = 'number' | 'boolean' | 'numberVec' | 'boolVec';
|
|
|
41
41
|
* vocabulary exactly: `'test'` is the tester's recorded verdict, `'spec'` is the
|
|
42
42
|
* spec-limit judgement. `t` is the measured value itself. */
|
|
43
43
|
export type AccessorKind = 't' | 'testPass' | 'specPass';
|
|
44
|
+
/** A die's own recorded fields an expression may read: where it is, which bins it landed in, which probe site. */
|
|
45
|
+
export type DieField = 'x' | 'y' | 'hbin' | 'sbin' | 'site';
|
|
46
|
+
/** The call each die field is read with. Call syntax, like `diePass()`, so a name here is never mistaken for a constant. */
|
|
47
|
+
export declare const DIE_FIELD_CALLS: Readonly<Record<string, DieField>>;
|
|
44
48
|
export type ExprNode = {
|
|
45
49
|
k: 'num';
|
|
46
50
|
value: number;
|
|
@@ -54,6 +58,9 @@ export type ExprNode = {
|
|
|
54
58
|
tests: number[];
|
|
55
59
|
} | {
|
|
56
60
|
k: 'diePass';
|
|
61
|
+
} | {
|
|
62
|
+
k: 'dieField';
|
|
63
|
+
field: DieField;
|
|
57
64
|
} | {
|
|
58
65
|
k: 'unary';
|
|
59
66
|
op: '-' | 'not';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isParametricTest as c}from"../buildWaferMap.js";import{hasSpecLimits as l}from"../spec.js";export const FUNCTIONS={abs:[{arity:1,returns:"number"}],sqrt:[{arity:1,returns:"number"}],ln:[{arity:1,returns:"number"}],log10:[{arity:1,returns:"number"}],exp:[{arity:1,returns:"number"}],floor:[{arity:1,returns:"number"}],ceil:[{arity:1,returns:"number"}],round:[{arity:1,returns:"number"}],sign:[{arity:1,returns:"number"}],pow:[{arity:2,returns:"number"}],min:[{vecOf:"numberVec",returns:"number"},{variadic:!0,returns:"number"}],max:[{vecOf:"numberVec",returns:"number"},{variadic:!0,returns:"number"}],if:[{arity:3,returns:"number"}],all:[{vecOf:"boolVec",returns:"boolean"}],any:[{vecOf:"boolVec",returns:"boolean"}],none:[{vecOf:"boolVec",returns:"boolean"}],countTrue:[{vecOf:"boolVec",returns:"number"}],countFalse:[{vecOf:"boolVec",returns:"number"}],mean:[{vecOf:"numberVec",returns:"number"}],sum:[{vecOf:"numberVec",returns:"number"}],countKnown:[{vecOf:"any",returns:"number"}]};const d=["t","testPass","specPass"],
|
|
2
|
-
`||n==="\r"){e++;continue}if(n>="0"&&n<="9"){const s=e;for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="."&&r[e+1]!==".")for(e++;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="e"||r[e]==="E"){const a=e;if(e++,(r[e]==="+"||r[e]==="-")&&e++,r[e]>="0"&&r[e]<="9")for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;else e=a}const u=r.slice(s,e);t.push({kind:"num",text:u,pos:s,value:Number(u)});continue}if(/[A-Za-z_]/.test(n)){const s=e;for(;e<r.length&&/[A-Za-z0-9_]/.test(r[e]);)e++;t.push({kind:"ident",text:r.slice(s,e),pos:s});continue}const i=
|
|
1
|
+
import{isParametricTest as c}from"../buildWaferMap.js";import{hasSpecLimits as l}from"../spec.js";export const DIE_FIELD_CALLS={dieX:"x",dieY:"y",hbin:"hbin",sbin:"sbin",site:"site"},FUNCTIONS={abs:[{arity:1,returns:"number"}],sqrt:[{arity:1,returns:"number"}],ln:[{arity:1,returns:"number"}],log10:[{arity:1,returns:"number"}],exp:[{arity:1,returns:"number"}],floor:[{arity:1,returns:"number"}],ceil:[{arity:1,returns:"number"}],round:[{arity:1,returns:"number"}],sign:[{arity:1,returns:"number"}],pow:[{arity:2,returns:"number"}],min:[{vecOf:"numberVec",returns:"number"},{variadic:!0,returns:"number"}],max:[{vecOf:"numberVec",returns:"number"},{variadic:!0,returns:"number"}],if:[{arity:3,returns:"number"}],all:[{vecOf:"boolVec",returns:"boolean"}],any:[{vecOf:"boolVec",returns:"boolean"}],none:[{vecOf:"boolVec",returns:"boolean"}],countTrue:[{vecOf:"boolVec",returns:"number"}],countFalse:[{vecOf:"boolVec",returns:"number"}],mean:[{vecOf:"numberVec",returns:"number"}],sum:[{vecOf:"numberVec",returns:"number"}],countKnown:[{vecOf:"any",returns:"number"}]};const d=["t","testPass","specPass"],b=["<=",">=","==","!=","..","+","-","*","/","%","^","<",">"],m=["(",")","[","]",","];class o extends Error{position;constructor(t,e){super(t),this.position=e}}function h(r){const t=[];let e=0;for(;e<r.length;){const n=r[e];if(n===" "||n===" "||n===`
|
|
2
|
+
`||n==="\r"){e++;continue}if(n>="0"&&n<="9"){const s=e;for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="."&&r[e+1]!==".")for(e++;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="e"||r[e]==="E"){const a=e;if(e++,(r[e]==="+"||r[e]==="-")&&e++,r[e]>="0"&&r[e]<="9")for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;else e=a}const u=r.slice(s,e);t.push({kind:"num",text:u,pos:s,value:Number(u)});continue}if(/[A-Za-z_]/.test(n)){const s=e;for(;e<r.length&&/[A-Za-z0-9_]/.test(r[e]);)e++;t.push({kind:"ident",text:r.slice(s,e),pos:s});continue}const i=b.find(s=>r.startsWith(s,e));if(i){t.push({kind:"op",text:i,pos:e}),e+=i.length;continue}if(m.includes(n)){t.push({kind:"punc",text:n,pos:e}),e++;continue}throw new o(`Unexpected character ${JSON.stringify(n)} at position ${e}`,e)}return t.push({kind:"eof",text:"",pos:r.length}),t}class f{toks;ctx;p=0;reads=[];usesDiePass=!1;constructor(t,e){this.toks=t,this.ctx=e}peek(){return this.toks[this.p]}next(){return this.toks[this.p++]}at(t){const e=this.peek();return(e.kind==="op"||e.kind==="punc"||e.kind==="ident")&&e.text===t}eat(t){return this.at(t)?(this.p++,!0):!1}expect(t){if(!this.at(t)){const e=this.peek();throw new o(`Expected ${JSON.stringify(t)} but found ${e.kind==="eof"?"end of expression":JSON.stringify(e.text)} at position ${e.pos}`,e.pos)}return this.next()}parse(){const t=this.parseOr();return this.expectEnd(),t}parseTestRefOnly(){const t=this.parseTestRef(this.peek().pos);return this.expectEnd(),t}expectEnd(){const t=this.peek();if(t.kind!=="eof")throw new o(`Unexpected ${JSON.stringify(t.text)} at position ${t.pos}`,t.pos)}requireScalar(t,e,n){if(t.type==="numberVec"||t.type==="boolVec")throw new o(`${e} cannot be applied to a test range at position ${n} \u2014 a range must be reduced first, e.g. mean(t[1010..1015]) or all(testPass[1010..1015])`,n);return t.type}parseOr(){let t=this.parseAnd();for(;this.at("or");){const e=this.next().pos,n=this.parseAnd();this.requireBool(t,"or",e),this.requireBool(n,"or",e),t={node:{k:"binary",op:"or",left:t.node,right:n.node},type:"boolean"}}return t}parseAnd(){let t=this.parseNot();for(;this.at("and");){const e=this.next().pos,n=this.parseNot();this.requireBool(t,"and",e),this.requireBool(n,"and",e),t={node:{k:"binary",op:"and",left:t.node,right:n.node},type:"boolean"}}return t}requireBool(t,e,n){if(this.requireScalar(t,`Operator ${JSON.stringify(e)}`,n),t.type!=="boolean")throw new o(`Operator ${JSON.stringify(e)} needs a true/false operand at position ${n}, but got a number \u2014 compare it first, e.g. t[1020] > 5`,n)}parseNot(){if(this.at("not")){const t=this.next().pos,e=this.parseNot();return this.requireBool(e,"not",t),{node:{k:"unary",op:"not",arg:e.node},type:"boolean"}}return this.parseCompare()}parseCompare(){const t=this.parseAdd(),e=this.peek();if(e.kind==="op"&&["<","<=",">",">=","==","!="].includes(e.text)){this.next();const n=this.parseAdd(),i=this.requireScalar(t,`Operator ${JSON.stringify(e.text)}`,e.pos),s=this.requireScalar(n,`Operator ${JSON.stringify(e.text)}`,e.pos);if(i!==s)throw new o(`Cannot compare a ${i} with a ${s} at position ${e.pos}`,e.pos);if(i==="boolean"&&e.text!=="=="&&e.text!=="!=")throw new o(`Operator ${JSON.stringify(e.text)} cannot order true/false values at position ${e.pos}`,e.pos);return{node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"boolean"}}return t}parseAdd(){let t=this.parseMul();for(;;){const e=this.peek();if(e.kind!=="op"||e.text!=="+"&&e.text!=="-")return t;this.next();const n=this.parseMul();this.requireNum(t,e.text,e.pos),this.requireNum(n,e.text,e.pos),t={node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"number"}}}parseMul(){let t=this.parsePow();for(;;){const e=this.peek();if(e.kind!=="op"||!["*","/","%"].includes(e.text))return t;this.next();const n=this.parsePow();this.requireNum(t,e.text,e.pos),this.requireNum(n,e.text,e.pos),t={node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"number"}}}parsePow(){const t=this.parseUnary(),e=this.peek();if(e.kind==="op"&&e.text==="^"){this.next();const n=this.parsePow();return this.requireNum(t,"^",e.pos),this.requireNum(n,"^",e.pos),{node:{k:"binary",op:"^",left:t.node,right:n.node},type:"number"}}return t}requireNum(t,e,n){if(this.requireScalar(t,`Operator ${JSON.stringify(e)}`,n),t.type!=="number")throw new o(`Operator ${JSON.stringify(e)} needs a numeric operand at position ${n}, but got a true/false value`,n)}parseUnary(){const t=this.peek();if(t.kind==="op"&&t.text==="-"){this.next();const e=this.parseUnary();return this.requireNum(e,"-",t.pos),{node:{k:"unary",op:"-",arg:e.node},type:"number"}}return this.parsePrimary()}parsePrimary(){const t=this.next();if(t.kind==="num")return{node:{k:"num",value:t.value},type:"number"};if(t.kind==="punc"&&t.text==="("){const e=this.parseOr();return this.expect(")"),e}if(t.kind==="ident"){if(d.includes(t.text))return this.parseAccessor(t.text,t.pos);if(t.text==="diePass")return this.expect("("),this.expect(")"),this.usesDiePass=!0,{node:{k:"diePass"},type:"boolean"};if(Object.prototype.hasOwnProperty.call(DIE_FIELD_CALLS,t.text)){if(!this.at("("))throw new o(`${JSON.stringify(t.text)} at position ${t.pos} reads a die's own field and is written with parentheses: ${t.text}().`,t.pos);return this.expect("("),this.expect(")"),{node:{k:"dieField",field:DIE_FIELD_CALLS[t.text]},type:"number"}}if(this.at("("))return this.parseCall(t.text,t.pos);if(Object.prototype.hasOwnProperty.call(this.ctx.constants,t.text)){const e=this.ctx.constants[t.text];if(typeof e!="number"||!Number.isFinite(e))throw new o(`Constant ${JSON.stringify(t.text)} at position ${t.pos} is not a finite number`,t.pos);return{node:{k:"num",value:e},type:"number"}}throw new o(`Unknown name ${JSON.stringify(t.text)} at position ${t.pos}. Test values are read as t[1020], verdicts as testPass[1020] or specPass[1020], a die's own fields as dieX(), dieY(), hbin(), sbin() or site(); other names must be declared in \`constants\`.`,t.pos)}throw new o(`Unexpected ${t.kind==="eof"?"end of expression":JSON.stringify(t.text)} at position ${t.pos}`,t.pos)}parseAccessor(t,e){this.expect("[");const{tests:n,range:i}=this.parseTestRef(e);this.expect("]");for(const u of n)this.checkAccessible(t,u,e);for(const u of n)this.reads.push({kind:t,test:u});const s=t==="t"?"number":"boolean";return i?{node:{k:"vec",kind:t,tests:n},type:s==="number"?"numberVec":"boolVec"}:{node:{k:"acc",kind:t,test:n[0]},type:s}}checkAccessible(t,e,n){const i=this.ctx.testDefs.get(e);if(i===void 0)throw new o(`Test ${e} at position ${n} is not declared in \`testDefs\``,n);if(t==="t"&&!c(i))throw new o(`t[${e}] at position ${n} reads a measured value, but test ${e} is functional (testType 'F') and has no measured value \u2014 use testPass[${e}] for its verdict`,n);if(t==="specPass"){if(!c(i))throw new o(`specPass[${e}] at position ${n} needs test limits, but test ${e} is functional (testType 'F') \u2014 use testPass[${e}] for its recorded verdict`,n);if(!l(i))throw new o(`specPass[${e}] at position ${n} needs \`limitLow\` or \`limitHigh\` on test ${e}, which declares neither`,n)}}parseTestRef(t){const e=this.expectInt();if(!this.eat(".."))return{tests:[e],range:!1};const n=this.expectInt();if(n<e)throw new o(`Test range ${e}..${n} at position ${t} runs backwards`,t);const i=[...this.ctx.testDefs.keys()].filter(s=>s>=e&&s<=n).sort((s,u)=>s-u);if(i.length===0)throw new o(`Test range ${e}..${n} at position ${t} matches no declared test`,t);return{tests:i,range:!0}}expectInt(){const t=this.peek();if(t.kind!=="num"||!Number.isInteger(t.value))throw new o(`Expected a test number at position ${t.pos}`,t.pos);return this.next(),t.value}parseCall(t,e){const n=FUNCTIONS[t];if(n===void 0)throw new o(`Unknown function ${JSON.stringify(t)} at position ${e}. Available: ${Object.keys(FUNCTIONS).sort().join(", ")}`,e);this.expect("(");const i=[];if(!this.at(")"))do i.push(this.parseOr());while(this.eat(","));this.expect(")");const s=i.map(a=>a.type),u={k:"call",name:t,args:i.map(a=>a.node)};for(const a of n){if(a.vecOf!==void 0){if(s.length!==1)continue;const p=s[0];if(!(p==="numberVec"||p==="boolVec")||a.vecOf!=="any"&&a.vecOf!==p)continue;return{node:u,type:a.returns}}if(a.variadic){if(s.length<2||!s.every(p=>p==="number"))continue;return{node:u,type:a.returns}}if(a.arity!==void 0){if(s.length!==a.arity)continue;if(t==="if"){if(s[0]!=="boolean"||s[1]!=="number"||s[2]!=="number")continue;return{node:u,type:"number"}}if(!s.every(p=>p==="number"))continue;return{node:u,type:a.returns}}}throw new o(`${t}(${s.join(", ")}) at position ${e} is not a valid call \u2014 ${x(t,n)}`,e)}}function x(r,t){return`expected ${t.map(n=>n.vecOf==="boolVec"?`${r}(<true/false test range>)`:n.vecOf==="numberVec"?`${r}(<value test range>)`:n.vecOf==="any"?`${r}(<test range>)`:n.variadic?`${r}(number, number, \u2026)`:r==="if"?"if(<true/false>, number, number)":`${r}(${Array.from({length:n.arity??0},()=>"number").join(", ")})`).join(" or ")}`}export function parseExpression(r,t){try{if(r.length>MAX_EXPRESSION_LENGTH)return{ok:!1,message:`Expression is ${r.length} characters, over the ${MAX_EXPRESSION_LENGTH} limit`,position:MAX_EXPRESSION_LENGTH};const e=new f(h(r),t),{node:n,type:i}=e.parse();return i==="numberVec"||i==="boolVec"?{ok:!1,message:"Expression results in a test range, not a single value \u2014 reduce it, e.g. mean(t[1010..1015]) or all(testPass[1010..1015])",position:0}:{ok:!0,ast:n,type:i,reads:e.reads,usesDiePass:e.usesDiePass}}catch(e){if(e instanceof o)return{ok:!1,message:e.message,position:e.position};throw e}}export function parseTestReference(r,t){try{if(r.length>MAX_EXPRESSION_LENGTH)return{ok:!1,message:`Test reference is ${r.length} characters, over the ${MAX_EXPRESSION_LENGTH} limit`,position:MAX_EXPRESSION_LENGTH};const{tests:e,range:n}=new f(h(r),{testDefs:t,constants:{}}).parseTestRefOnly();return{ok:!0,tests:e,range:n}}catch(e){if(e instanceof o)return{ok:!1,message:e.message,position:e.position};throw e}}export const MAX_EXPRESSION_LENGTH=2e3;
|
|
@@ -45,6 +45,10 @@ export interface SpecLimits {
|
|
|
45
45
|
/** A value equal to `limitHigh` passes. Default `true`; STDF `PARM_FLG` bit 7. */
|
|
46
46
|
limitHighInclusive?: boolean;
|
|
47
47
|
}
|
|
48
|
+
/** True when `value` sits below `low` (a value equal to `low` is below only when `inclusive` is `false`). */
|
|
49
|
+
export declare function belowLow(value: number, low: number, inclusive?: boolean): boolean;
|
|
50
|
+
/** True when `value` sits above `high` (a value equal to `high` is above only when `inclusive` is `false`). */
|
|
51
|
+
export declare function aboveHigh(value: number, high: number, inclusive?: boolean): boolean;
|
|
48
52
|
/**
|
|
49
53
|
* Classify `value` against `limits`. Returns `null` when no verdict is possible:
|
|
50
54
|
* no value, a non-finite value, or a test with neither limit defined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function belowLow(n,e,i){return i===!1?n<=e:n<e}export function aboveHigh(n,e,i){return i===!1?n>=e:n>e}export function classifySpec(n,e){return n===void 0||!Number.isFinite(n)||e===void 0||e.limitLow===void 0&&e.limitHigh===void 0?null:e.limitLow!==void 0&&belowLow(n,e.limitLow,e.limitLowInclusive)?"failLow":e.limitHigh!==void 0&&aboveHigh(n,e.limitHigh,e.limitHighInclusive)?"failHigh":"pass"}export function isOutOfSpec(n){return n==="failLow"||n==="failHigh"}export function countOutOfSpec(n,e){let i=0;for(let f=0;f<n.length;f++)isOutOfSpec(classifySpec(n[f],e))&&i++;return i}export function hasSpecLimits(n){return n!==void 0&&(n.limitLow!==void 0||n.limitHigh!==void 0)}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value filter: take values that lie outside a limit set out of a wafer's
|
|
3
|
+
* data, so every map, statistic and chart reads the same population.
|
|
4
|
+
*
|
|
5
|
+
* Runs once, on the raw probe records at the start of `buildWaferMap` (before
|
|
6
|
+
* derived tests, which would otherwise be computed from a clamped reading). An
|
|
7
|
+
* excluded value becomes no value for that test on that die; the value itself is
|
|
8
|
+
* kept in `DieTable.excluded` so the tooltip can say what was excluded and why.
|
|
9
|
+
*
|
|
10
|
+
* Only values change. `die.testPass` and the bins are the tester's own verdict
|
|
11
|
+
* and are left alone.
|
|
12
|
+
*/
|
|
13
|
+
import type { DieTable } from '../core/dieTable.js';
|
|
14
|
+
import { type DieData } from '../core/dieTable.js';
|
|
15
|
+
import type { TestDef, WaferWarning } from './buildWaferMap.js';
|
|
16
|
+
/**
|
|
17
|
+
* Which limit set a value must lie inside to be kept.
|
|
18
|
+
* `'validity'` excludes values outside the validity limits (tester clamps) and
|
|
19
|
+
* only affects tests that have them. `'spec'` and `'test'` keep only values
|
|
20
|
+
* inside the specification or test limits. `'none'` filters nothing.
|
|
21
|
+
*/
|
|
22
|
+
export type ValueFilterMode = 'validity' | 'spec' | 'test' | 'none';
|
|
23
|
+
/** Per-test outcome of the value filter, carried on `WaferMapResult.valueFilter`. */
|
|
24
|
+
export interface ValueFilterTest {
|
|
25
|
+
testNumber: number;
|
|
26
|
+
/** Values excluded across the wafer (or across every wafer of a lot). */
|
|
27
|
+
excluded: number;
|
|
28
|
+
/** Values the test had before filtering. */
|
|
29
|
+
total: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ValueFilterSummary {
|
|
32
|
+
mode: Exclude<ValueFilterMode, 'none'>;
|
|
33
|
+
/** Tests with at least one excluded value. */
|
|
34
|
+
tests: ValueFilterTest[];
|
|
35
|
+
}
|
|
36
|
+
/** Display name of a limit set, as the UI and the log name it. */
|
|
37
|
+
export declare function limitSetName(mode: Exclude<ValueFilterMode, 'none'>): string;
|
|
38
|
+
/**
|
|
39
|
+
* `table` with out-of-range values taken out, and the per-test counts.
|
|
40
|
+
* Parametric tests only: a functional test has no measured value to be out of range.
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyValueFilter(table: DieTable, testDefs: readonly TestDef[] | undefined, mode: ValueFilterMode): {
|
|
43
|
+
table: DieTable;
|
|
44
|
+
tests: ValueFilterTest[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The caption fragment for `testNumber` over `dies`: " · 3 values outside validity limits excluded", or ''
|
|
48
|
+
* when the filter took nothing out of them. One wording for every chart caption.
|
|
49
|
+
*/
|
|
50
|
+
export declare function excludedNote(dies: readonly DieData[], testNumber: number): string;
|
|
51
|
+
/** Sums per-wafer outcomes into one (a lot is filtered wafer by wafer). */
|
|
52
|
+
export declare function mergeValueFilterTests(parts: readonly ValueFilterTest[][]): ValueFilterTest[];
|
|
53
|
+
/** The log line for an outcome: what was excluded, per test, and under which limits. */
|
|
54
|
+
export declare function valueFilterWarning(mode: Exclude<ValueFilterMode, 'none'>, tests: readonly ValueFilterTest[], defs: readonly TestDef[] | undefined): WaferWarning | undefined;
|
|
55
|
+
//# sourceMappingURL=valueFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{excludedCounts as m,withExcluded as p}from"../core/dieTable.js";import{aboveHigh as v,belowLow as N}from"./spec.js";export function limitSetName(e){return e==="validity"?"validity limits":e==="spec"?"specification limits":"test limits"}function w(e,t){const n=t==="validity"?{low:e.validLow,high:e.validHigh}:t==="spec"?{low:e.specLow,high:e.specHigh}:{low:e.limitLow,high:e.limitHigh,lowInclusive:e.limitLowInclusive,highInclusive:e.limitHighInclusive};return n.low===void 0&&n.high===void 0?void 0:n}export function applyValueFilter(e,t,n){if(n==="none"||!t)return{table:e,tests:[]};const i=new Map,l=new Map,s=[];for(const o of t){if(o.testType==="F")continue;const u=w(o,n),c=e.values.get(o.testNumber);if(u===void 0||c===void 0)continue;let r,a,h=0,g=0;for(let d=0;d<c.length;d++){const f=c[d];Number.isNaN(f)||(h++,!(u.low!==void 0&&N(f,u.low,u.lowInclusive)||u.high!==void 0&&v(f,u.high,u.highInclusive)))||(r===void 0&&(r=c.slice(),a=new c.constructor(c.length).fill(NaN)),r[d]=NaN,a[d]=f,g++)}r===void 0||a===void 0||(i.set(o.testNumber,r),l.set(o.testNumber,a),s.push({testNumber:o.testNumber,excluded:g,total:h}))}return s.length===0?{table:e,tests:s}:{table:p(e,i,l,n),tests:s}}export function excludedNote(e,t){const n=m(e),i=n?.counts.get(t)??0;return n&&i>0?` \xB7 ${i.toLocaleString("en-GB")} value${i===1?"":"s"} outside ${limitSetName(n.by)} excluded`:""}export function mergeValueFilterTests(e){const t=new Map;for(const n of e)for(const i of n){const l=t.get(i.testNumber);l?(l.excluded+=i.excluded,l.total+=i.total):t.set(i.testNumber,{...i})}return[...t.values()].sort((n,i)=>n.testNumber-i.testNumber)}export function valueFilterWarning(e,t,n){if(t.length===0)return;const i=o=>n?.find(u=>u.testNumber===o)?.name??`test ${o}`,l=t.reduce((o,u)=>o+u.excluded,0),s=t.slice(0,5).map(o=>`${i(o.testNumber)}: ${o.excluded} of ${o.total}`).join("; ")+(t.length>5?`; and ${t.length-5} more tests`:"");return{code:"values-excluded",message:`${l} value${l===1?"":"s"} outside the ${limitSetName(e)} treated as missing (${s}).`,severity:"info"}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{requireRingCount as se}from"../core/ringCount.js";import{analyzeWaferMap as H,candidatesOf as U,describeRegional as Q,resolveOptions as ae,adjustPValues as re,twoProportionZ as X,zPValue as W,welchOfSums as Z,rateRelativeEffect as oe,passesRateGate as ce,severityForFinding as J,severityForScore as ee,collapseRedundantFindings as le,findContiguousRuns as fe,mergedRegionLabel as de}from"./analyzeWaferMap.js";import{normalizeInput as ue}from"./normalizeInput.js";import{poolCapability as me,poolRegionYield as ge,poolPassRates as pe}from"./summaryFigures.js";import{mergeTestDefs as he}from"./mergeTestDefs.js";import{findingPatternKey as ye}from"./filterFindings.js";import{median as te}from"../core/utils.js";import{robustFence as ne}from"./math.js";import{findLotPattern as be}from"./lotPattern.js";import{buildDriftFindings as we}from"./lotDrift.js";import{claimForPattern as ve,weakestMultiplier as Se}from"./analyzeWaferMap.js";import{PATTERN_LABELS as ze}from"./patternClassification.js";import{describeWaferPopulation as Ie,populationStat as ke}from"./population.js";const T=8,Me={3:[.97,.994],4:[.829,.926],5:[.71,.821],6:[.625,.74],7:[.568,.68]},Re=3;export function outlierWafers(i){const o=i.length;if(o<3)return null;const r=te([...i]),s=e=>Math.abs(e-r)>=Re;if(o>=T){const e=ne(i,1.5,T),l=ne(i,3,T);if(!e||!l)return null;const f=(e.hi-e.lo)/4,a=[];return i.forEach((d,h)=>{if(d>=e.lo&&d<=e.hi||!s(d))return;const t=d<l.lo||d>l.hi?"unusual":"notable";a.push({index:h,severity:t,statistic:(d-r)/f})}),{method:"tukey-fence",outliers:a}}const u=i.map((e,l)=>l).sort((e,l)=>i[e]-i[l]),p=i[u[o-1]]-i[u[0]];if(p===0)return null;const[n,c]=Me[o],g=[],y=(e,l)=>{const f=Math.abs(i[e]-i[l])/p;f>n&&s(i[e])&&g.push({index:e,severity:f>c?"unusual":"notable",statistic:f})};return y(u[0],u[1]),y(u[o-1],u[o-2]),{method:"dixon-q",outliers:g}}const A=2;function _(i,o){const r={info:0,notable:1,unusual:2};return r[i]>=r[o]?i:o}const Pe=new Set(["ring","quadrant","sector"]),xe=new Set(["ring","quadrant","sector","reticle-position","test-site"]),$e=new Set(["yield","hardBin","softBin","functionalTest","test"]);function Be(i){return xe.has(i.comparison.family)&&$e.has(i.variable.kind)}function De(i,o){const r=i.map(n=>n.facts);if(!r.length||r.some(n=>!n))return{coincident:new Set,yieldSoftBin:void 0,passBins:[],sectorCount:o};const[s,...u]=r,p=u.every(n=>n.passBins.length===s.passBins.length&&n.passBins.every(c=>s.passBins.includes(c)));return{coincident:new Set([...s.coincident].filter(n=>u.every(c=>c.coincident.has(n)))),yieldSoftBin:u.every(n=>n.yieldSoftBin===s.yieldSoftBin)?s.yieldSoftBin:void 0,passBins:p?s.passBins:[],sectorCount:o}}function j(i,o){let r=0,s=0,u=0,p=0,n=0,c=0,g=0,y=0,e=0,l=!0,f=0;for(const{waferIndex:h,c:t}of i){const m=o(h,t),S=t.rate??t.mean,M=Math.sqrt(S.n+m.n);if(t.rate)r+=M*X(t.rate.hits,t.rate.n,m.hits,m.n),u+=t.rate.hits,p+=t.rate.n,n+=m.hits,c+=m.n;else{const z=Z(t.mean,m.n,m.sum,m.sq);r+=M*z.z,g+=t.mean.n*z.effectSize,y+=t.mean.n*z.delta,f+=t.mean.n,t.relativeDelta===void 0?l=!1:e+=t.mean.n*t.relativeDelta}s+=M*M}const a=s>0?r/Math.sqrt(s):0,d=i[0].c;if(d.rate){const h=n/c,t=u/p-h;return{z:a,delta:t,relativeDelta:h===0?void 0:t/h,size:oe({hits:u,n:p,restHits:n,restN:c,passRate:d.rate.passRate})}}return{z:a,delta:y/f,relativeDelta:l?e/f:void 0,size:g/f}}function O(i,o,r,s){return i.rate?ce(o,r.delta,r.size,s):o<=s.significanceLevel&&Math.abs(r.size)>=s.minimumEffectSize}function Ee(i,o,r,s){const u=new Map;for(const{waferIndex:a,byKey:d}of i)for(const h of d.values())(u.get(h.key)??u.set(h.key,[]).get(h.key)).push({waferIndex:a,c:h});const p=new Map(i.map(a=>[a.waferIndex,a.byKey])),n=(a,d)=>d.rate?{hits:d.rate.restHits,n:d.rate.restN,sum:0,sq:0}:{hits:0,n:d.mean.restN,sum:d.mean.restSum,sq:d.mean.restSq},c=[];for(const[a,d]of u){if(d.length<A)continue;const h=j(d,n);if(h.z===0)continue;const t=d[0].c;c.push({key:a,entries:d,combined:h,finding:{id:`lot-region:${a}`,level:"lot",severity:"info",variable:{...t.variable,label:t.label},comparison:{...t.comparison},effect:{direction:h.z>0?"higher":"lower",absoluteDelta:h.delta,relativeDelta:h.relativeDelta,effectSize:t.rate?h.delta:h.size},stats:{method:"stouffer-z",pValue:W(h.z),sampleSizeLeft:0,sampleSizeRight:0},summary:"",highlight:{kind:"wafer",waferIndices:[]}}})}re(c.map(a=>a.finding));const g=c.filter(a=>O(a.entries[0].c,a.finding.stats.adjustedPValue??1,a.combined,o)),y=(a,d)=>{const h=a.entries[0].c,t=d.entries[0].c;return h.source===t.source&&h.variable.kind===t.variable.kind&&h.variable.bin===t.variable.bin&&h.variable.index===t.variable.index&&h.region.family===t.region.family},e=[],l=new Map;for(const a of g){const d=a.finding.stats.pValue??1,h=g.filter(b=>b!==a&&y(a,b)&&b.finding.effect.direction!==a.finding.effect.direction&&(b.finding.stats.pValue??1)<d);if(h.length){const b=($,v)=>{const I=n($,v);for(const B of h){const k=p.get($)?.get(B.key);k&&(k.rate?(I.hits-=k.rate.hits,I.n-=k.rate.n):(I.n-=k.mean.n,I.sum-=k.mean.sum,I.sq-=k.mean.sq))}return I},R=a.entries.filter($=>b($.waferIndex,$.c).n>=o.minimumSampleSize);if(!R.length)continue;const x=j(R,b),L=d>0?(a.finding.stats.adjustedPValue??d)/d:1;if(Math.sign(x.z)!==Math.sign(a.combined.z)||!O(a.entries[0].c,Math.min(1,W(x.z)*L),x,o))continue}const t=Math.sign(a.combined.z),m=a.entries.filter(b=>Math.sign(b.c.delta)===t),S=i.length,M=a.entries[0].c,z=a.finding.stats.adjustedPValue??d,K=M.rate?J(z,a.combined.delta,a.combined.size):ee(z,a.combined.size),w=_(K,m.length/S>=.6?"unusual":"info"),N={};for(const b of m)N[b.waferIndex]=[...b.c.region.dieKeys];const E={...a.finding,severity:w,stats:{...a.finding.stats,sampleSizeLeft:m.length,sampleSizeRight:S-m.length},summary:`${Q(M,a.combined.delta,a.combined.relativeDelta)} \u2014 ${a.finding.effect.direction} on ${m.length}/${S} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:m.map(b=>b.waferIndex),dieKeysByWafer:N}};e.push(E),l.set(E,a)}const f=Le(l,p,i.length,o,s,n);return e.splice(0,e.length,...e.filter(a=>!f.replaced.has(a)),...f.findings),le(e,r),e}function Le(i,o,r,s,u,p){const n=new Map;for(const[y,e]of i){const l=e.entries[0].c;if(!Pe.has(l.region.family))continue;const f=[l.source,l.variable.kind,l.variable.bin??"",l.variable.index??"",l.region.family,y.effect.direction].join("|");(n.get(f)??n.set(f,[]).get(f)).push({finding:y,c:l,key:e.key})}const c=[],g=new Set;for(const y of n.values()){if(y.length<2)continue;const e=y[0].c.region.family;for(const l of fe(y,e,s.sectorCount,f=>f.c.region.key)){if(l.length<2)continue;const f=qe(l,o,r,s,u,p);if(f){c.push(f);for(const a of l)g.add(a.finding)}}}return{findings:c,replaced:g}}function qe(i,o,r,s,u,p){const n=i[0].c,c=i[0].finding.effect.direction==="higher"?1:-1,g=de(n.region.family,i.map(w=>w.c.region.key),u),y=[];for(const[w,N]of o){const E=i.map(v=>N.get(v.key));if(E.some(v=>!v))continue;const b=E,R=b[0];let x,L;if(R.rate){const v=b.reduce((P,D)=>P+D.rate.hits,0),I=b.reduce((P,D)=>P+D.rate.n,0),B=R.rate.hits+R.rate.restHits-v,k=R.rate.n+R.rate.restN-I;if(I<s.minimumSampleSize||k<s.minimumSampleSize)continue;x={...R,rate:{hits:v,n:I,restHits:B,restN:k,passRate:R.rate.passRate}},L=X(v,I,B,k)}else{const v=R.mean,I=b.reduce((q,F)=>q+F.mean.n,0),B=b.reduce((q,F)=>q+F.mean.sum,0),k=b.reduce((q,F)=>q+F.mean.sq,0),P=v.n+v.restN-I,D=v.sum+v.restSum-B,C=v.sq+v.restSq-k;if(I<s.minimumSampleSize||P<s.minimumSampleSize)continue;const V={n:I,sum:B,sq:k,restN:P,restSum:D,restSq:C,shift:v.shift},Y=Z(V,P,D,C),G=D/P+v.shift;x={...R,mean:V,relativeDelta:G!==0?Y.delta/Math.abs(G):void 0},L=Y.z}const $=[...new Set(b.flatMap(v=>[...v.region.dieKeys]))];y.push({waferIndex:w,c:x,z:L,dieKeys:$})}if(y.length<A)return;const e=j(y,p);if(e.z===0||Math.sign(e.z)!==c)return;const l=W(e.z),f=Se(i.map(w=>w.finding)),a=Math.min(1,l*f);if(!O(n,a,e,s))return;const d=y.filter(w=>Math.sign(w.z)===c&&W(w.z)<=s.significanceLevel);if(!d.length)return;const h=n.rate?J(a,e.delta,e.size):ee(a,e.size),t=_(h,d.length/r>=.6?"unusual":"info"),m={};for(const w of d)m[w.waferIndex]=w.dieKeys;const S=i.map(w=>w.c.region.key.slice(w.c.region.key.indexOf(":")+1)).join("-"),M={...n,comparison:{...n.comparison,left:g}},z=i[0].finding,K=z.effect.direction;return{...z,id:`lot-region:${i[0].key.split("|").slice(0,-1).join("|")}|${n.region.family}:${S}`,severity:t,comparison:{...z.comparison,left:g},effect:{direction:K,absoluteDelta:e.delta,relativeDelta:e.relativeDelta,effectSize:n.rate?e.delta:e.size},stats:{method:"stouffer-z",pValue:l,adjustedPValue:a,sampleSizeLeft:d.length,sampleSizeRight:r-d.length},summary:`${Q(M,e.delta,e.relativeDelta)} \u2014 ${K} on ${d.length}/${r} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:d.map(w=>w.waferIndex),dieKeysByWafer:m},relatedIds:i.map(w=>w.finding.id)}}const ie={"Edge-ring":"edge","Edge-local":"edge","Center cluster":"centre or donut",Donut:"centre or donut"};function Fe(i,o){const r=new Map,s=n=>{const c=n.variable.kind==="spatialPattern"?ie[n.comparison.left]:void 0;return c?`spatialPattern|${c}`:ye(n)};for(const n of i){const c=new Set,g=new Map;for(const e of n.summary.findings)if(e.variable.kind==="spatialPattern")for(const l of e.relatedIds??[])g.set(l,s(e));const y=new Set(n.summary.findings.flatMap(e=>e.absorbedIds??[]));for(const e of n.summary.findings){if(y.has(e.id)||Be(e)||e.variable.kind==="spatialPattern"&&o?.carriers.has(n.waferIndex))continue;const l=s(e);if(c.has(l))continue;c.add(l);const f=r.get(l)??{finding:e,waferIndices:[],severity:e.severity,labels:new Map,dieKeysByWafer:{},explainedBy:new Map};f.waferIndices.push(n.waferIndex);const a=g.get(e.id);if(a&&f.explainedBy.set(a,(f.explainedBy.get(a)??0)+1),e.variable.kind==="spatialPattern"){f.labels.set(e.comparison.left,(f.labels.get(e.comparison.left)??0)+1);const d=e.highlight.dieKeys;d&&(f.dieKeysByWafer[n.waferIndex]=d)}f.severity=_(f.severity,e.severity),r.set(l,f)}}const u=[];for(const[n,c]of r){if(c.waferIndices.length<A)continue;const g=c.waferIndices.length/Math.max(1,i.length),y=g>=.6||c.severity==="unusual"?"unusual":"notable",e=c.finding;u.push({id:`lot-repeat:${n}`,level:"lot",severity:y,variable:{...e.variable},comparison:{...e.comparison},effect:{direction:e.effect.direction,absoluteDelta:e.effect.absoluteDelta,relativeDelta:e.effect.relativeDelta,effectSize:e.effect.effectSize},stats:{method:"wafer-finding-frequency",sampleSizeLeft:c.waferIndices.length,sampleSizeRight:i.length-c.waferIndices.length},summary:`${We(e,c.labels)} \u2014 seen on ${c.waferIndices.length}/${i.length} wafers (${Math.round(g*100)}%)`,highlight:{kind:"wafer",waferIndices:c.waferIndices,...c.labels.size?{dieKeysByWafer:c.dieKeysByWafer}:{}}})}const p=new Map(u.map(n=>[n.id,n]));for(const[n,c]of r){const g=p.get(`lot-repeat:${n}`);if(g)for(const[y,e]of c.explainedBy){const l=p.get(`lot-repeat:${y}`);!l||e!==c.waferIndices.length||(l.relatedIds??=[]).push(g.id)}}return u}function Ke(i,o){const{classification:r,carriers:s}=i,u=ze[r.pattern],p=s.size/Math.max(1,o),n={};for(const[c,g]of s)n[c]=g;return{id:"lot-repeat:spatialPattern|lot",level:"lot",severity:p>=.6||r.confidence==="high"?"unusual":"notable",variable:{kind:"spatialPattern",label:u},comparison:{family:"spatial-pattern",left:u,right:"Wafer"},effect:{direction:"different",effectSize:r.features.globalRdd},stats:{method:"wafer-finding-frequency",sampleSizeLeft:s.size,sampleSizeRight:o-s.size},summary:`Spatial pattern: ${u.toLowerCase()} \u2014 seen on ${s.size}/${o} wafers (${Math.round(p*100)}%)`,highlight:{kind:"wafer",waferIndices:[...s.keys()].sort((c,g)=>c-g),dieKeysByWafer:n}}}function Ne(i){const o=/^Rings? (\d+)(?:\s*[–-]\s*(\d+))?/.exec(i.comparison.left);if(!o)return[];const r=+o[1],s=o[2]?+o[2]:r;return Array.from({length:Math.max(0,s-r+1)},(u,p)=>r+p)}function We(i,o){if(!o.size)return i.summary;const r=p=>p.toLowerCase();if(o.size===1)return`Spatial pattern: ${r([...o.keys()][0])}`;const s=ie[i.comparison.left],u=[...o].sort((p,n)=>n[1]-p[1]).map(([p,n])=>`${r(p)} on ${n}`);return`Spatial pattern: ${s} (${u.join(", ")})`}function Ae(i,o){const r=ke(o,"median"),s=i.map(g=>({waferIndex:g.waferIndex,yieldPercent:g.summary.stats.yieldPercent})).filter(g=>g.yieldPercent!==null),u=s.map(g=>g.yieldPercent),p=outlierWafers(u);if(!p)return[];const n=te(u),c=[];for(const{index:g,severity:y,statistic:e}of p.outliers){const l=s[g],f=l.yieldPercent-n;c.push({id:`inter-wafer:yield:${l.waferIndex}`,level:"inter-wafer",severity:y,variable:{kind:"yield",label:"Yield"},comparison:{family:"wafer",left:`Wafer ${l.waferIndex+1}`,right:r.charAt(0).toUpperCase()+r.slice(1)},effect:{direction:f>0?"higher":"lower",absoluteDelta:f/100,relativeDelta:n===0?void 0:f/n,effectSize:e},stats:{method:p.method,sampleSizeLeft:1,sampleSizeRight:s.length-1},summary:`Wafer ${l.waferIndex+1} yield is ${Math.abs(f).toFixed(1)} percentage points ${f>0?"higher":"lower"} than the ${r}`,highlight:{kind:"wafer",waferIndices:[l.waferIndex]}})}return c}export function analyzeWaferLot(i,o={}){const r=i.map(ue),s=r.map((t,m)=>({waferIndex:m,summary:o.perWaferSummaries?.[m]??H(t,o)})),u=s.map(({waferIndex:t,summary:m})=>U(m)??U(H(r[t],o))),p=u.map((t,m)=>({waferIndex:m,byKey:new Map(t.candidates.map(S=>[S.key,S]))})),n=ae(o).resolved,c=r.length>0?se(r[0],"analyzeWaferLot"):void 0,g=be(r,n),y=g&&g.carriers.size>=A?g:null,e=[...c===void 0?[]:Ee(p,n,De(u,n.sectorCount),c),...Fe(s,y),...Ae(s,Ie(s.map(t=>t.summary.wafer))),...we(s,n.significanceLevel)];if(y&&c!==void 0){const t=Ke(y,s.length);t.relatedIds=ve([y.classification.pattern],t.severity,e,Ne,c),t.relatedIds.length||delete t.relatedIds,e.push(t)}e.sort((t,m)=>{const S=t.severity==="unusual"?2:t.severity==="notable"?1:0,M=m.severity==="unusual"?2:m.severity==="notable"?1:0;return S!==M?M-S:t.summary.localeCompare(m.summary,"en")});const l=s.map(t=>t.summary.wafer).filter(t=>!!t),f={},a=[];if(l.length>0){const t=new Set;for(const m of l)for(const S of Object.keys(m))t.add(S);t.delete("wafer"),t.delete("waferId");for(const m of t){const S=l.filter(z=>m in z).map(z=>z[m]);S.every(z=>z===S[0])?f[m]=S[0]:a.push(m)}}const d=s.map(({waferIndex:t,summary:m})=>({waferIndex:t,yieldPercent:m.stats.yieldPercent})),h=s.map(({waferIndex:t,summary:m})=>m.stats.perTestStats?.length?{waferIndex:t,tests:m.stats.perTestStats}:null).filter(t=>t!==null);return{level:"lot",hasNotableFindings:e.some(t=>t.severity!=="info")||s.some(t=>t.summary.hasNotableFindings),findings:e,lot:Object.keys(f).length>0?f:void 0,...a.length>0?{mixedIdentityFields:a}:{},stats:{waferCount:i.length,...Te(r,s.map(t=>t.summary))},lotYieldSeries:d,perWafer:s,...h.length>0?{perWaferTestStats:h}:{}}}function Te(i,o){const r={...pe(o)},s=me(o,he(i).defs);s&&(r.capability=s);const u=ge(o,i.map(p=>p.ringCount));return u&&(r.regionYield=u),r}
|
|
1
|
+
import{waferDisplayLabel as se}from"../core/waferLabel.js";import{requireRingCount as ae}from"../core/ringCount.js";import{analyzeWaferMap as G,candidatesOf as H,describeRegional as U,resolveOptions as re,adjustPValues as oe,twoProportionZ as Q,welchOfSums as X,rateRelativeEffect as ce,passesRateGate as le,severityForFinding as Z,severityForScore as J,collapseRedundantFindings as fe,findContiguousRuns as de,mergedRegionLabel as ue}from"./analyzeWaferMap.js";import{normalizeInput as me}from"./normalizeInput.js";import{poolCapability as ge,poolRegionYield as pe,poolPassRates as he}from"./summaryFigures.js";import{mergeTestDefs as ye}from"./mergeTestDefs.js";import{findingPatternKey as be}from"./filterFindings.js";import{median as ee}from"../core/utils.js";import{robustFence as te,zPValue as K}from"./math.js";import{findLotPattern as we}from"./lotPattern.js";import{buildDriftFindings as ve}from"./lotDrift.js";import{claimForPattern as Se,confirmRegionalFindings as ze,weakestMultiplier as Ie}from"./analyzeWaferMap.js";import{PATTERN_LABELS as ke}from"./patternClassification.js";import{describeWaferPopulation as Re,populationStat as Me}from"./population.js";const W=8,Pe={3:[.97,.994],4:[.829,.926],5:[.71,.821],6:[.625,.74],7:[.568,.68]},xe=3;export function outlierWafers(i){const o=i.length;if(o<3)return null;const r=ee([...i]),s=t=>Math.abs(t-r)>=xe;if(o>=W){const t=te(i,1.5,W),f=te(i,3,W);if(!t||!f)return null;const d=(t.hi-t.lo)/4,b=[];return i.forEach((y,a)=>{if(y>=t.lo&&y<=t.hi||!s(y))return;const e=y<f.lo||y>f.hi?"unusual":"notable";b.push({index:a,severity:e,statistic:(y-r)/d})}),{method:"tukey-fence",outliers:b}}const u=i.map((t,f)=>f).sort((t,f)=>i[t]-i[f]),g=i[u[o-1]]-i[u[0]];if(g===0)return null;const[n,c]=Pe[o],m=[],p=(t,f)=>{const d=Math.abs(i[t]-i[f])/g;d>n&&s(i[t])&&m.push({index:t,severity:d>c?"unusual":"notable",statistic:d})};return p(u[0],u[1]),p(u[o-1],u[o-2]),{method:"dixon-q",outliers:m}}const N=2;function T(i,o){const r={info:0,notable:1,unusual:2};return r[i]>=r[o]?i:o}const $e=new Set(["ring","quadrant","sector"]),Be=new Set(["ring","quadrant","sector","reticle-position","test-site"]),De=new Set(["yield","hardBin","softBin","functionalTest","test"]);function Le(i){return Be.has(i.comparison.family)&&De.has(i.variable.kind)}function Ee(i,o){const r=i.map(n=>n.facts);if(!r.length||r.some(n=>!n))return{coincident:new Set,yieldSoftBin:void 0,passBins:[],sectorCount:o};const[s,...u]=r,g=u.every(n=>n.passBins.length===s.passBins.length&&n.passBins.every(c=>s.passBins.includes(c)));return{coincident:new Set([...s.coincident].filter(n=>u.every(c=>c.coincident.has(n)))),yieldSoftBin:u.every(n=>n.yieldSoftBin===s.yieldSoftBin)?s.yieldSoftBin:void 0,passBins:g?s.passBins:[],sectorCount:o}}function _(i,o){let r=0,s=0,u=0,g=0,n=0,c=0,m=0,p=0,t=0,f=!0,d=0;for(const{waferIndex:a,c:e}of i){const l=o(a,e),h=e.rate??e.mean,S=Math.sqrt(h.n+l.n);if(e.rate)r+=S*Q(e.rate.hits,e.rate.n,l.hits,l.n),u+=e.rate.hits,g+=e.rate.n,n+=l.hits,c+=l.n;else{const v=X(e.mean,l.n,l.sum,l.sq);r+=S*v.z,m+=e.mean.n*v.effectSize,p+=e.mean.n*v.delta,d+=e.mean.n,e.relativeDelta===void 0?f=!1:t+=e.mean.n*e.relativeDelta}s+=S*S}const b=s>0?r/Math.sqrt(s):0,y=i[0].c;if(y.rate){const a=n/c,e=u/g-a;return{z:b,delta:e,relativeDelta:a===0?void 0:e/a,size:ce({hits:u,n:g,restHits:n,restN:c,passRate:y.rate.passRate})}}return{z:b,delta:p/d,relativeDelta:f?t/d:void 0,size:m/d}}function j(i,o,r,s){return i.rate?le(o,r.delta,r.size,s):o<=s.significanceLevel&&Math.abs(r.size)>=s.minimumEffectSize}function qe(i,o,r,s){const u=new Map;for(const{waferIndex:a,byKey:e}of i)for(const l of e.values())(u.get(l.key)??u.set(l.key,[]).get(l.key)).push({waferIndex:a,c:l});const g=new Map(i.map(a=>[a.waferIndex,a.byKey])),n=(a,e)=>e.rate?{hits:e.rate.restHits,n:e.rate.restN,sum:0,sq:0}:{hits:0,n:e.mean.restN,sum:e.mean.restSum,sq:e.mean.restSq},c=[];for(const[a,e]of u){if(e.length<N)continue;const l=_(e,n);if(l.z===0)continue;const h=e[0].c;c.push({key:a,entries:e,combined:l,finding:{id:`lot-region:${a}`,level:"lot",severity:"info",variable:{...h.variable,label:h.label},comparison:{...h.comparison},effect:{direction:l.z>0?"higher":"lower",absoluteDelta:l.delta,relativeDelta:l.relativeDelta,effectSize:h.rate?l.delta:l.size},stats:{method:"stouffer-z",pValue:K(l.z),sampleSizeLeft:0,sampleSizeRight:0},summary:"",highlight:{kind:"wafer",waferIndices:[]}}})}oe(c.map(a=>a.finding));const m=c.filter(a=>j(a.entries[0].c,a.finding.stats.adjustedPValue??1,a.combined,o)),f=ze(m,a=>{const e=a.entries[0].c;return[e.source,e.variable.kind,e.variable.bin??"",e.variable.index??"",e.region.family].join("\0")},(a,e)=>{const l=(M,B)=>{const k=n(M,B);for(const z of e){const R=g.get(M)?.get(z.key);R&&(R.rate?(k.hits-=R.rate.hits,k.n-=R.rate.n):(k.n-=R.mean.n,k.sum-=R.mean.sum,k.sq-=R.mean.sq))}return k},h=a.entries.filter(M=>l(M.waferIndex,M.c).n>=o.minimumSampleSize);if(!h.length)return"baseline-too-small";const S=_(h,l),v=a.finding.stats.pValue??1,$=v>0?(a.finding.stats.adjustedPValue??v)/v:1,w=Math.min(1,K(S.z)*$);return{pValue:w,passes:Math.sign(S.z)===Math.sign(a.combined.z)&&j(a.entries[0].c,w,S,o)}},a=>{const e=a.entries[0].c.rate;return e!==void 0&&(e.passRate?a.combined.z<0:a.combined.z>0)},c),d=[],b=new Map;for(const a of m){if(!f.has(a))continue;const e=a.finding.stats.pValue??1,l=Math.sign(a.combined.z),h=a.entries.filter(z=>Math.sign(z.c.delta)===l),S=i.length,v=a.entries[0].c,$=a.finding.stats.adjustedPValue??e,w=v.rate?Z($,a.combined.delta,a.combined.size):J($,a.combined.size),M=T(w,h.length/S>=.6?"unusual":"info"),B={};for(const z of h)B[z.waferIndex]=[...z.c.region.dieKeys];const k={...a.finding,severity:M,stats:{...a.finding.stats,sampleSizeLeft:h.length,sampleSizeRight:S-h.length},summary:`${U(v,a.combined.delta,a.combined.relativeDelta)} \u2014 ${a.finding.effect.direction} on ${h.length}/${S} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:h.map(z=>z.waferIndex),dieKeysByWafer:B}};d.push(k),b.set(k,a)}const y=Fe(b,g,i.length,o,s,n);return d.splice(0,d.length,...d.filter(a=>!y.replaced.has(a)),...y.findings),fe(d,r),d}function Fe(i,o,r,s,u,g){const n=new Map;for(const[p,t]of i){const f=t.entries[0].c;if(!$e.has(f.region.family))continue;const d=[f.source,f.variable.kind,f.variable.bin??"",f.variable.index??"",f.region.family,p.effect.direction].join("|");(n.get(d)??n.set(d,[]).get(d)).push({finding:p,c:f,key:t.key})}const c=[],m=new Set;for(const p of n.values()){if(p.length<2)continue;const t=p[0].c.region.family;for(const f of de(p,t,s.sectorCount,d=>d.c.region.key)){if(f.length<2)continue;const d=Ke(f,o,r,s,u,g);if(d){c.push(d);for(const b of f)m.add(b.finding)}}}return{findings:c,replaced:m}}function Ke(i,o,r,s,u,g){const n=i[0].c,c=i[0].finding.effect.direction==="higher"?1:-1,m=ue(n.region.family,i.map(w=>w.c.region.key),u),p=[];for(const[w,M]of o){const B=i.map(I=>M.get(I.key));if(B.some(I=>!I))continue;const k=B,z=k[0];let R,A;if(z.rate){const I=k.reduce((x,D)=>x+D.rate.hits,0),P=k.reduce((x,D)=>x+D.rate.n,0),E=z.rate.hits+z.rate.restHits-I,L=z.rate.n+z.rate.restN-P;if(P<s.minimumSampleSize||L<s.minimumSampleSize)continue;R={...z,rate:{hits:I,n:P,restHits:E,restN:L,passRate:z.rate.passRate}},A=Q(I,P,E,L)}else{const I=z.mean,P=k.reduce((q,F)=>q+F.mean.n,0),E=k.reduce((q,F)=>q+F.mean.sum,0),L=k.reduce((q,F)=>q+F.mean.sq,0),x=I.n+I.restN-P,D=I.sum+I.restSum-E,O=I.sq+I.restSq-L;if(P<s.minimumSampleSize||x<s.minimumSampleSize)continue;const V={n:P,sum:E,sq:L,restN:x,restSum:D,restSq:O,shift:I.shift},C=X(V,x,D,O),Y=D/x+I.shift;R={...z,mean:V,relativeDelta:Y!==0?C.delta/Math.abs(Y):void 0},A=C.z}const ie=[...new Set(k.flatMap(I=>[...I.region.dieKeys]))];p.push({waferIndex:w,c:R,z:A,dieKeys:ie})}if(p.length<N)return;const t=_(p,g);if(t.z===0||Math.sign(t.z)!==c)return;const f=K(t.z),d=Ie(i.map(w=>w.finding)),b=Math.min(1,f*d);if(!j(n,b,t,s))return;const y=p.filter(w=>Math.sign(w.z)===c&&K(w.z)<=s.significanceLevel);if(!y.length)return;const a=n.rate?Z(b,t.delta,t.size):J(b,t.size),e=T(a,y.length/r>=.6?"unusual":"info"),l={};for(const w of y)l[w.waferIndex]=w.dieKeys;const h=i.map(w=>w.c.region.key.slice(w.c.region.key.indexOf(":")+1)).join("-"),S={...n,comparison:{...n.comparison,left:m}},v=i[0].finding,$=v.effect.direction;return{...v,id:`lot-region:${i[0].key.split("|").slice(0,-1).join("|")}|${n.region.family}:${h}`,severity:e,comparison:{...v.comparison,left:m},effect:{direction:$,absoluteDelta:t.delta,relativeDelta:t.relativeDelta,effectSize:n.rate?t.delta:t.size},stats:{method:"stouffer-z",pValue:f,adjustedPValue:b,sampleSizeLeft:y.length,sampleSizeRight:r-y.length},summary:`${U(S,t.delta,t.relativeDelta)} \u2014 ${$} on ${y.length}/${r} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:y.map(w=>w.waferIndex),dieKeysByWafer:l},relatedIds:i.map(w=>w.finding.id)}}const ne={"Edge-ring":"edge","Edge-local":"edge","Center cluster":"centre or donut",Donut:"centre or donut"};function Ne(i,o){const r=new Map,s=n=>{const c=n.variable.kind==="spatialPattern"?ne[n.comparison.left]:void 0;return c?`spatialPattern|${c}`:be(n)};for(const n of i){const c=new Set,m=new Map;for(const t of n.summary.findings)if(t.variable.kind==="spatialPattern")for(const f of t.relatedIds??[])m.set(f,s(t));const p=new Set(n.summary.findings.flatMap(t=>t.absorbedIds??[]));for(const t of n.summary.findings){if(p.has(t.id)||Le(t)||t.variable.kind==="spatialPattern"&&o?.carriers.has(n.waferIndex))continue;const f=s(t);if(c.has(f))continue;c.add(f);const d=r.get(f)??{finding:t,waferIndices:[],severity:t.severity,labels:new Map,dieKeysByWafer:{},explainedBy:new Map};d.waferIndices.push(n.waferIndex);const b=m.get(t.id);if(b&&d.explainedBy.set(b,(d.explainedBy.get(b)??0)+1),t.variable.kind==="spatialPattern"){d.labels.set(t.comparison.left,(d.labels.get(t.comparison.left)??0)+1);const y=t.highlight.dieKeys;y&&(d.dieKeysByWafer[n.waferIndex]=y)}d.severity=T(d.severity,t.severity),r.set(f,d)}}const u=[];for(const[n,c]of r){if(c.waferIndices.length<N)continue;const m=c.waferIndices.length/Math.max(1,i.length),p=m>=.6||c.severity==="unusual"?"unusual":"notable",t=c.finding;u.push({id:`lot-repeat:${n}`,level:"lot",severity:p,variable:{...t.variable},comparison:{...t.comparison},effect:{direction:t.effect.direction,absoluteDelta:t.effect.absoluteDelta,relativeDelta:t.effect.relativeDelta,effectSize:t.effect.effectSize},stats:{method:"wafer-finding-frequency",sampleSizeLeft:c.waferIndices.length,sampleSizeRight:i.length-c.waferIndices.length},summary:`${Te(t,c.labels)} \u2014 seen on ${c.waferIndices.length}/${i.length} wafers (${Math.round(m*100)}%)`,highlight:{kind:"wafer",waferIndices:c.waferIndices,...c.labels.size?{dieKeysByWafer:c.dieKeysByWafer}:{}}})}const g=new Map(u.map(n=>[n.id,n]));for(const[n,c]of r){const m=g.get(`lot-repeat:${n}`);if(m)for(const[p,t]of c.explainedBy){const f=g.get(`lot-repeat:${p}`);!f||t!==c.waferIndices.length||(f.relatedIds??=[]).push(m.id)}}return u}function Ae(i,o){const{classification:r,carriers:s}=i,u=ke[r.pattern],g=s.size/Math.max(1,o),n={};for(const[c,m]of s)n[c]=m;return{id:"lot-repeat:spatialPattern|lot",level:"lot",severity:g>=.6||r.confidence==="high"?"unusual":"notable",variable:{kind:"spatialPattern",label:u},comparison:{family:"spatial-pattern",left:u,right:"Wafer"},effect:{direction:"different",effectSize:r.features.globalRdd},stats:{method:"wafer-finding-frequency",sampleSizeLeft:s.size,sampleSizeRight:o-s.size},summary:`Spatial pattern: ${u.toLowerCase()} \u2014 seen on ${s.size}/${o} wafers (${Math.round(g*100)}%)`,highlight:{kind:"wafer",waferIndices:[...s.keys()].sort((c,m)=>c-m),dieKeysByWafer:n}}}function We(i){const o=/^Rings? (\d+)(?:\s*[–-]\s*(\d+))?/.exec(i.comparison.left);if(!o)return[];const r=+o[1],s=o[2]?+o[2]:r;return Array.from({length:Math.max(0,s-r+1)},(u,g)=>r+g)}function Te(i,o){if(!o.size)return i.summary;const r=g=>g.toLowerCase();if(o.size===1)return`Spatial pattern: ${r([...o.keys()][0])}`;const s=ne[i.comparison.left],u=[...o].sort((g,n)=>n[1]-g[1]).map(([g,n])=>`${r(g)} on ${n}`);return`Spatial pattern: ${s} (${u.join(", ")})`}function _e(i,o){const r=Me(o,"median"),s=i.map(m=>({waferIndex:m.waferIndex,yieldPercent:m.summary.stats.yieldPercent})).filter(m=>m.yieldPercent!==null),u=s.map(m=>m.yieldPercent),g=outlierWafers(u);if(!g)return[];const n=ee(u),c=[];for(const{index:m,severity:p,statistic:t}of g.outliers){const f=s[m],d=f.yieldPercent-n,b=se({wafer:{metadata:i.find(y=>y.waferIndex===f.waferIndex)?.summary.wafer}},f.waferIndex);c.push({id:`inter-wafer:yield:${f.waferIndex}`,level:"inter-wafer",severity:p,variable:{kind:"yield",label:"Yield"},comparison:{family:"wafer",left:b,right:r.charAt(0).toUpperCase()+r.slice(1)},effect:{direction:d>0?"higher":"lower",absoluteDelta:d/100,relativeDelta:n===0?void 0:d/n,effectSize:t},stats:{method:g.method,sampleSizeLeft:1,sampleSizeRight:s.length-1},summary:`${b} yield is ${Math.abs(d).toFixed(1)} percentage points ${d>0?"higher":"lower"} than the ${r}`,highlight:{kind:"wafer",waferIndices:[f.waferIndex]}})}return c}export function analyzeWaferLot(i,o={}){const r=i.map(me),s=r.map((e,l)=>({waferIndex:l,summary:o.perWaferSummaries?.[l]??G(e,o)})),u=s.map(({waferIndex:e,summary:l})=>H(l)??H(G(r[e],o))),g=u.map((e,l)=>({waferIndex:l,byKey:new Map(e.candidates.map(h=>[h.key,h]))})),n=re(o).resolved,c=r.length>0?ae(r[0],"analyzeWaferLot"):void 0,m=we(r,n),p=m&&m.carriers.size>=N?m:null,t=[...c===void 0?[]:qe(g,n,Ee(u,n.sectorCount),c),...Ne(s,p),..._e(s,Re(s.map(e=>e.summary.wafer))),...ve(s,n.significanceLevel)];if(p&&c!==void 0){const e=Ae(p,s.length);e.relatedIds=Se([p.classification.pattern],e.severity,t,We,c),e.relatedIds.length||delete e.relatedIds,t.push(e)}t.sort((e,l)=>{const h=e.severity==="unusual"?2:e.severity==="notable"?1:0,S=l.severity==="unusual"?2:l.severity==="notable"?1:0;return h!==S?S-h:e.summary.localeCompare(l.summary,"en")});const f=s.map(e=>e.summary.wafer).filter(e=>!!e),d={},b=[];if(f.length>0){const e=new Set;for(const l of f)for(const h of Object.keys(l))e.add(h);e.delete("wafer"),e.delete("waferId");for(const l of e){const h=f.filter(v=>l in v).map(v=>v[l]);h.every(v=>v===h[0])?d[l]=h[0]:b.push(l)}}const y=s.map(({waferIndex:e,summary:l})=>({waferIndex:e,yieldPercent:l.stats.yieldPercent})),a=s.map(({waferIndex:e,summary:l})=>l.stats.perTestStats?.length?{waferIndex:e,tests:l.stats.perTestStats}:null).filter(e=>e!==null);return{level:"lot",hasNotableFindings:t.some(e=>e.severity!=="info")||s.some(e=>e.summary.hasNotableFindings),findings:t,lot:Object.keys(d).length>0?d:void 0,...b.length>0?{mixedIdentityFields:b}:{},stats:{waferCount:i.length,...je(r,s.map(e=>e.summary))},lotYieldSeries:y,perWafer:s,...a.length>0?{perWaferTestStats:a}:{}}}function je(i,o){const r={...he(o)},s=ge(o,ye(i).defs);s&&(r.capability=s);const u=pe(o,i.map(g=>g.ringCount));return u&&(r.regionYield=u),r}
|
|
@@ -40,11 +40,19 @@ export declare function resolveOptions(options: AnalyzeWaferMapOptions): {
|
|
|
40
40
|
* verdict for the test (read via `getTestPassStatus`, so legacy 0/1-encoded
|
|
41
41
|
* functional data is counted identically); dies never tested count as neither.
|
|
42
42
|
*/
|
|
43
|
-
export declare function computeFunctionalYield(dies: Die[], testDefs: TestDef[] | undefined
|
|
43
|
+
export declare function computeFunctionalYield(dies: Die[], testDefs: TestDef[] | undefined,
|
|
44
|
+
/** Called for each die failing a test. */
|
|
45
|
+
onFail?: (testNumber: number, die: Die) => void): StatsSummary['stats']['functionalYield'];
|
|
44
46
|
/** The two-proportion z statistic, signed as left − right; 0 when untestable. */
|
|
45
47
|
export declare function twoProportionZ(leftPass: number, leftTotal: number, rightPass: number, rightTotal: number): number;
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Benjamini–Hochberg over the findings given, as ONE family. Callers pass every comparison of one kind
|
|
50
|
+
* of test that one analysis makes — every rate comparison on a wafer (each region family, each of yield,
|
|
51
|
+
* hard bins, soft bins, functional tests and limit failures), every regional comparison of a lot — so the
|
|
52
|
+
* false-discovery rate holds for what the analysis reports as a whole. Corrected per (variable, region
|
|
53
|
+
* family) group instead, a clean wafer with some twenty such groups reports a false finding more often
|
|
54
|
+
* than not.
|
|
55
|
+
*/
|
|
48
56
|
export declare function adjustPValues(findings: RawFinding[]): RawFinding[];
|
|
49
57
|
/**
|
|
50
58
|
* A rate finding's counts: hits and dies in its region and in the rest of the
|
|
@@ -121,6 +129,39 @@ export declare function passesRateGate(adjustedP: number, delta: number, relEffe
|
|
|
121
129
|
* p-value, an exact die count) and are supporting detail, not a restatement.
|
|
122
130
|
*/
|
|
123
131
|
export declare function claimForPattern<F extends StatsFinding>(patterns: PatternLabel[], severity: StatsSeverity, candidates: readonly F[], ringsOf: (f: F) => number[], ringCount: number): string[];
|
|
132
|
+
/** A re-test of a regional finding against a reduced rest: its p-value (BH multiplier applied) and whether it still passes. */
|
|
133
|
+
export type RegionRetest = {
|
|
134
|
+
pValue: number;
|
|
135
|
+
passes: boolean;
|
|
136
|
+
} | 'baseline-too-small';
|
|
137
|
+
/**
|
|
138
|
+
* Which of the significant regional findings stand when each is compared with the rest of the wafer WITHOUT the
|
|
139
|
+
* others. A region compared with "the rest" looks deviant whenever the rest holds a stronger deviation: with four
|
|
140
|
+
* rings, a large failing area makes its complement look as significant in the other direction, and one failing
|
|
141
|
+
* quadrant makes every other sector look good. Findings are grouped by `groupKey` (same variable, same region
|
|
142
|
+
* family); within a group:
|
|
143
|
+
*
|
|
144
|
+
* 1. Forward: the first finding stands; each further one is re-tested against the rest without those that stand so
|
|
145
|
+
* far, and the first that still passes stands next, until none does. "First" is a loss before a gain where
|
|
146
|
+
* `isLoss` says which direction is a loss (a lower pass rate, more of a fail bin or of a limit failure), then the
|
|
147
|
+
* smallest re-tested p-value: when a failing block and its complement are equally significant, the block is the
|
|
148
|
+
* finding ("Rings 2–3 lower pass rate"), never the complement ("Rings 1 and 4 higher"). A test value has no such
|
|
149
|
+
* direction and is taken strongest first.
|
|
150
|
+
* 2. Backward: each finding that stands is re-tested against the rest without every other one that stands, whatever
|
|
151
|
+
* its direction; the weakest that no longer passes is dropped, until all pass. A finding whose reduced rest is too
|
|
152
|
+
* small to test keeps its place.
|
|
153
|
+
*
|
|
154
|
+
* The baseline is never "the regions that were not significant": a region half inside a failing quadrant is raised
|
|
155
|
+
* but not significant, and against it the clean regions look good. For the same reason a gain (a region better than
|
|
156
|
+
* its rest) is re-tested without every region of its group that leans towards a loss, significant or not (`all`
|
|
157
|
+
* holds the group's comparisons before the gate): a region is better only than the regions that are not worse.
|
|
158
|
+
*
|
|
159
|
+
* `retest` uses the finding's own test, Benjamini–Hochberg multiplier, gates and direction. Shared by the wafer's rate
|
|
160
|
+
* and test-value findings and the lot's pooled findings.
|
|
161
|
+
*/
|
|
162
|
+
export declare function confirmRegionalFindings<T>(findings: readonly T[], groupKey: (t: T) => string, retest: (t: T, without: readonly T[]) => RegionRetest, isLoss?: (t: T) => boolean, all?: readonly T[]): Set<T>;
|
|
163
|
+
/** Whether a rate's region is worse than its rest: a lower pass rate, or a higher fail rate (a fail bin, a limit failure). */
|
|
164
|
+
export declare function isRateLoss(c: RateCounts): boolean;
|
|
124
165
|
/** A test-value finding's per-region sums, in the builder's shifted space. */
|
|
125
166
|
export interface MeanStats {
|
|
126
167
|
n: number;
|