@wafertools/wafermap 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +18 -9
- package/CHANGELOG.md +246 -0
- package/README.md +7 -4
- package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
- package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
- 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/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/index.d.ts +1 -0
- package/dist/packages/canvas-adapter/index.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +7 -0
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +85 -38
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +38 -12
- 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/testValueOffer.d.ts +14 -0
- package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +2 -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 +46 -23
- 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/aggregates.d.ts +10 -0
- package/dist/packages/core/aggregates.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 +31 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/passBins.d.ts +6 -0
- package/dist/packages/core/passBins.js +1 -1
- package/dist/packages/core/wafer.d.ts +10 -1
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildView.d.ts +5 -0
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +50 -4
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.js +1 -1
- package/dist/packages/renderer/fmt.d.ts +10 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +1 -0
- package/dist/packages/renderer/index.js +1 -1
- 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.d.ts +16 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +62 -4
- 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/correlation.d.ts +36 -4
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/filterFindings.d.ts +1 -1
- package/dist/packages/stats/filterFindings.js +1 -1
- package/dist/packages/stats/findingText.d.ts +8 -0
- package/dist/packages/stats/findingText.js +2 -2
- package/dist/packages/stats/index.d.ts +2 -1
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/lotDrift.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/mergeTestDefs.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 +11 -0
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/regions.d.ts +6 -0
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +12 -18
- package/dist/packages/stats/reportHtml.js +112 -48
- package/dist/packages/stats/synthesis.d.ts +48 -17
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/testPassRate.js +1 -1
- package/dist/packages/stats/testValueBudget.d.ts +15 -0
- package/dist/packages/stats/testValueBudget.js +1 -0
- package/dist/packages/stats/types.d.ts +89 -22
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Die } from '../core/dies.js';
|
|
2
|
-
import type { TestDef, WaferWarning } from '../renderer/buildWaferMap.js';
|
|
2
|
+
import type { TestDef, WaferWarning, WaferMapResult } from '../renderer/buildWaferMap.js';
|
|
3
3
|
import type { AnalyzeWaferMapInput, AnalyzeWaferMapOptions, StatsFinding, StatsSeverity, StatsSummary } from './types.js';
|
|
4
4
|
import { type StatsRegion } from './regions.js';
|
|
5
5
|
import { type PatternLabel } from './patternClassification.js';
|
|
@@ -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;
|
|
@@ -144,6 +185,17 @@ export declare function welchFromStats(leftN: number, leftMean: number, leftVar:
|
|
|
144
185
|
delta: number;
|
|
145
186
|
z: number;
|
|
146
187
|
};
|
|
188
|
+
/**
|
|
189
|
+
* The size of one built wafer's test-value analysis under `options`: the tests it
|
|
190
|
+
* would cover and the dies it reads, counted as `analyzeWaferMap` counts them. For
|
|
191
|
+
* `analyzeWaferLot`, which takes the `'auto'` decision over the whole lot.
|
|
192
|
+
*/
|
|
193
|
+
export declare function testValueSize(result: WaferMapResult, options: AnalyzeWaferMapOptions): {
|
|
194
|
+
tests: number;
|
|
195
|
+
dies: number;
|
|
196
|
+
};
|
|
197
|
+
/** The options a summary records (`analysisOptions`): the public ones that were passed. */
|
|
198
|
+
export declare function recordedOptions(options: AnalyzeWaferMapOptions): AnalyzeWaferMapOptions;
|
|
147
199
|
/**
|
|
148
200
|
* A connected set of quadrants in reading order round the wafer, starting after
|
|
149
201
|
* a gap when there is one ("NW, SW & SE", not whatever order the search met
|
|
@@ -176,5 +228,11 @@ export interface RedundancyFacts {
|
|
|
176
228
|
export declare function redundancyFacts(eligibleDies: EligibleDie[], passBins: number[], sectorCount: number): RedundancyFacts;
|
|
177
229
|
export declare function collapseRedundantFindings(findings: RawFinding[], facts: RedundancyFacts): void;
|
|
178
230
|
export declare function analyzeWaferMap(input: AnalyzeWaferMapInput, options?: AnalyzeWaferMapOptions): StatsSummary;
|
|
231
|
+
/**
|
|
232
|
+
* `analyzeWaferMap` with the `'auto'` test-value decision already taken — by
|
|
233
|
+
* `analyzeWaferLot`, over the whole lot, so each wafer follows it rather than its
|
|
234
|
+
* own size. Internal.
|
|
235
|
+
*/
|
|
236
|
+
export declare function analyzeWaferMapDecided(input: AnalyzeWaferMapInput, options?: AnalyzeWaferMapOptions, lotDecision?: 'done' | 'skipped'): StatsSummary;
|
|
179
237
|
export {};
|
|
180
238
|
//# sourceMappingURL=analyzeWaferMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeInput as Ge}from"./normalizeInput.js";import{computeCapability as Xe,computeTestFlagYield as Ze,computeRegionYield as Je}from"./summaryFigures.js";import{binPassSets as Me}from"../renderer/binColors.js";import{diePassStatus as Be,isYieldEligibleDie as de,getDieKey as Ne,isPositionedDie as Fe,positionKey as me}from"../core/dies.js";import{dieHasValues as et,testsPresent as Pe,testValue as j}from"../core/dieTable.js";import{getTestPassStatus as se,isParametricTest as W}from"../renderer/buildWaferMap.js";import{markedTestLabel as T,derivedFields as oe}from"../renderer/testLabel.js";import{buildQuadrantRegions as tt,buildReticlePositionRegions as nt,buildRingRegions as it,buildSectorRegions as st,buildTestSiteRegions as ot,sectorCompassNames as xe,areQuadrantsAdjacent as at,parseRegionKey as Y,QUADRANT_CYCLE as pe,regionAngleBins as rt}from"./regions.js";import{buildClusterFindings as ft}from"./clusterDetection.js";import{classifyPattern as lt,patternExplains as ct,patternFailVerdict as ut,PATTERN_LABELS as dt}from"./patternClassification.js";import{requirePassBins as mt}from"../core/passBins.js";import{requireRingCount as pt}from"../core/ringCount.js";import{benjaminiHochberg as ht,fiveNumberSummary as gt,normalCdf as Ce,sampleVariance as he}from"./math.js";import{mean as ae,clamp01 as Ve,maxOf as bt}from"../core/utils.js";import{classifySpec as re,isOutOfSpec as ge}from"../renderer/spec.js";const yt={significanceLevel:{min:1e-6,max:1},minimumEffectSize:{min:0,max:1},minimumRelativeEffect:{min:0,max:Number.MAX_SAFE_INTEGER}},Le=[4,8,16];export function resolveOptions(t){const i=Object.fromEntries(Object.entries(t).filter(([,f])=>f!==void 0)),s={...X,...i},n=[],e=[];for(const f of["significanceLevel","minimumEffectSize","minimumRelativeEffect"]){const{min:c,max:o}=yt[f],u=s[f];if(typeof u!="number"||!Number.isFinite(u)){e.push(`${f}=${String(u)} is not a finite number (using ${X[f]})`),s[f]=X[f];continue}const a=Math.min(o,Math.max(c,u));a!==u&&(e.push(`${f}=${u} is outside ${c}\u2013${o} (using ${a})`),s[f]=a)}if(Le.includes(s.sectorCount)||(e.push(`sectorCount=${s.sectorCount} is not one of ${Le.join(", ")} (using ${X.sectorCount})`),s.sectorCount=X.sectorCount),e.length){const f=`analyzeWaferMap: ${e.join("; ")}. The analysis ran with the corrected values.`;console.warn(`[wafermap] ${f}`),n.push({code:"analysis-option-corrected",message:f,severity:"warning"})}const l=["passBins","ringCount"].filter(f=>i[f]!==void 0);if(l.length){const f=`analyzeWaferMap: ${l.join(" and ")} ${l.length>1?"are":"is"} no longer an analysis option and was ignored. Set ${l.length>1?"them":"it"} on buildWaferMap; the analysis used the value the map was built with.`;console.warn(`[wafermap] ${f}`),n.push({code:"analysis-option-corrected",message:f,severity:"warning"})}const r=["enableYieldAnalysis","enableHardBinAnalysis","enableSoftBinAnalysis","enableReticlePositionAnalysis","enableTestSiteAnalysis","enableClusterAnalysis","enableAngularAnalysis","enablePatternClassification"].filter(f=>i[f]!==void 0);if(r.length){const f=`analyzeWaferMap: ${r.join(", ")} ${r.length>1?"are":"is"} no longer an option and was ignored: every analysis now runs. Filter the findings (filterFindings) to show fewer.`;console.warn(`[wafermap] ${f}`),n.push({code:"analysis-option-corrected",message:f,severity:"warning"})}return{resolved:s,warnings:n}}const X={significanceLevel:.05,minimumEffectSize:.2,minimumRelativeEffect:1,minimumSampleSize:5,enableTestValueAnalysis:!1,computePerTestStats:!1,sectorCount:8,minimumClusterSize:5};function St(t,i){const s={...t};return s.minimumClusterSize=Math.max(5,Math.round(i*.003)),s}function wt(t){return de(t)?t.hbin!==void 0||t.sbin!==void 0||et(t):!1}function vt(t,i,s){if(!t||i)return;const n=(s??[]).filter(e=>W(e)&&(e.limitLow!==void 0||e.limitHigh!==void 0));if(n.length!==0)return e=>{for(const l of n)if(ge(re(j(e,l.testNumber),l)))return!0;return!1}}function $t(t,i,s){const n=new Set,e=new Set,l=new Set,r=new Map,f=new Map;for(const c of Pe(t))n.add(c);for(const c of t)c.hbin!==void 0&&e.add(c.hbin),c.sbin!==void 0&&l.add(c.sbin),de(c)&&(c.hbin!==void 0&&r.set(c.hbin,(r.get(c.hbin)??0)+1),c.sbin!==void 0&&f.set(c.sbin,(f.get(c.sbin)??0)+1));return{totalDies:t.length,analyzedDies:i,excludedDies:t.length-i,yieldPercent:s,testsConsidered:[...n].sort((c,o)=>c-o),hardBinsConsidered:[...e].sort((c,o)=>c-o),softBinsConsidered:[...l].sort((c,o)=>c-o),...r.size?{hardBinCounts:Object.fromEntries(r)}:{},...f.size?{softBinCounts:Object.fromEntries(f)}:{}}}function zt(t,i){if(!i?.length)return;const s=i.filter(e=>W(e)&&(e.limitLow!==void 0||e.limitHigh!==void 0));if(!s.length)return;const n=[];for(const e of s){const l=e.testNumber;let r=0,f=0,c=0,o=0;for(const u of t){if(u.partial||u.edgeExcluded)continue;const a=re(j(u,l),e);a!==null&&(o++,a==="failLow"?f++:a==="failHigh"?c++:r++)}n.push({testNumber:l,label:e.name,passDies:r,failLowDies:f,failHighDies:c,totalDies:o,yieldPercent:o>0?r/o*100:null})}return n.length?n:void 0}export function computeFunctionalYield(t,i){if(!i?.length)return;const s=i.filter(e=>!W(e));if(!s.length)return;const n=[];for(const e of s){const l=e.testNumber;let r=0,f=0;for(const o of t){if(o.partial||o.edgeExcluded)continue;const u=se(o,l,e);u!==void 0&&(u?r++:f++)}const c=r+f;n.push({testNumber:l,label:T(e,l),...oe(e),passDies:r,failDies:f,totalDies:c,passRatePercent:c>0?r/c*100:null})}return n.length?n:void 0}function kt(t,i,s,n){const e=[];for(const l of i){const r=[];for(const a of t){if(a.partial||a.edgeExcluded)continue;const h=j(a,l);h!==void 0&&Number.isFinite(h)&&r.push(h)}if(r.length<n)continue;const f=ae(r),c=Math.sqrt(he(r,f)),o=gt(Float64Array.from(r)),u=s?.find(a=>a.testNumber===l)?.name??String(l);e.push({testNumber:l,label:u,count:r.length,min:o.min,max:o.max,mean:f,stddev:c,median:o.median,q1:o.q1,q3:o.q3})}return e.length?e:void 0}export function twoProportionZ(t,i,s,n){const e=(t+s)/(i+n),l=e*(1-e)*(1/i+1/n);return!Number.isFinite(l)||l<=0?0:(t/i-s/n)/Math.sqrt(l)}export function zPValue(t){return Ve(2*(1-Ce(Math.abs(t))))}function O(t,i,s,n){const e=twoProportionZ(t,i,s,n);return e===0?1:zPValue(e)}export function adjustPValues(t){const i=new Map;for(const s of t){const n=`${s.variable.kind}:${s.comparison.family}`,e=i.get(n)??[];e.push(s),i.set(n,e)}for(const s of i.values()){const n=s.filter(l=>l.stats.pValue!==void 0),e=ht(n.map(l=>l.stats.pValue));n.forEach((l,r)=>{l.stats.adjustedPValue=e[r]})}return t}export function rateRelativeEffect(t){const i=(t.passRate?t.n-t.hits:t.hits)/t.n,s=(t.passRate?t.restN-t.restHits:t.restHits)/t.restN;return s===0?i===0?0:1/0:Math.abs(i-s)/s}export function severityForFinding(t,i,s){const n=Math.abs(i),e=s;return t<=.01&&(n>=.3||e>=2.5)?"unusual":t<=.05&&(n>=.2||e>=1.5)?"notable":"info"}export function severityForScore(t,i){return t<=.01&&Math.abs(i)>=.5?"unusual":t<=.05&&Math.abs(i)>=.15?"notable":"info"}function fe(t){return t==="reticle-position"?"other reticle positions":t==="test-site"?"other test sites":"the rest of the map"}function _(t){return t==="reticle-position"?"Other reticle positions":t==="test-site"?"Other test sites":"Rest of map"}function be(t,i,s){const n=(Math.abs(i)*100).toFixed(1);return`${t} yield is ${n} percentage points ${i>0?"higher":"lower"} than ${fe(s)}`}function ye(t,i){return i==="quadrant"&&!t.startsWith("Quadrant")?`quadrant ${t}`:t}function Ke(t){return/^(Rings|Sectors|Quadrants)\b/.test(t)?"have":"has"}function Se(t,i,s,n){const e=ye(t,n),l=(Math.abs(s)*100).toFixed(1);return`${e} ${Ke(e)} ${i} occurrence ${l} percentage points ${s>0?"higher":"lower"} than ${fe(n)}`}function we(t,i,s,n){const e=ye(t,n),l=(Math.abs(s)*100).toFixed(1);return`${e} ${Ke(e)} ${i} pass rate ${l} percentage points ${s>0?"higher":"lower"} than ${fe(n)}`}function ve(t,i,s,n,e,l){const r=ye(t,e),f=fe(e),c=s>0?"higher":"lower";if(n!==void 0&&Number.isFinite(n)){const u=(Math.abs(n)*100).toFixed(1);return`${r} mean ${i} is ${u}% ${c} than ${f}`}const o=l?` ${l}`:"";return`${r} mean ${i} is ${Math.abs(s).toPrecision(3)}${o} ${c} than ${f}`}function Ee(t,i,s){const n=i?.find(e=>e.bin===t);return n?.name?`${s} ${t} (${n.name})`:`${s} ${t}`}function Dt(t,i){const s=i?.find(n=>n.testNumber===t);return{label:T(s,t),unit:s?.unit,...oe(s)}}const Oe=new WeakMap,Te=new WeakMap,qe=new WeakMap;function Z(t,i){const s=i.highlight.dieKeys;return s&&qe.set(s,t),i}let Q=null,J;const He=new WeakMap;export function candidatesOf(t){return He.get(t)}function Ae(t,i,s,n){if(!Q)return;const e=je(t);if(!e)return;const l=t.id.slice(0,t.id.indexOf(":")),r=l==="specLimit"?"limitFail":l,{kind:f,bin:c,index:o}=t.variable;Q.push({key:[r,f,c??"",o??"",e.family,e.key].join("|"),source:r,variable:t.variable,label:t.variable.label,comparison:t.comparison,region:e,z:i,delta:t.effect.absoluteDelta??0,effectSize:t.effect.effectSize??0,relativeDelta:t.effect.relativeDelta,rate:s,mean:n})}export function describeRegional(t,i,s){const n=t.comparison.left,e=t.region.family;switch(t.source){case"yield":return be(n,i,e);case"hardBin":case"softBin":return Se(n,t.label,i,e);case"functional":return we(n,t.label.replace(/ pass rate$/,""),i,e);case"limitFail":return $e(n,t.label,i);case"test":return ve(n,t.label,i,s,e,t.variable.unit)}}function $e(t,i,s){return`${t} limit fail rate for ${i} is ${(Math.abs(s)*100).toFixed(1)} pp ${s>0?"higher":"lower"} than the rest of the wafer`}const U=new WeakMap;function le(t,i){return U.set(t,i),t}function je(t){const i=t.highlight.dieKeys;return i?qe.get(i):void 0}const Ie=new WeakMap;function I(t){let i=Ie.get(t);return i||Ie.set(t,i=t.map(me)),i}function Rt(t){let i=Oe.get(t);return i||Oe.set(t,i=t.map(Ne)),i}function ce(t,i){let s=Te.get(t);s||Te.set(t,s={members:new Set(t),byFamily:new WeakMap});const n=s.byFamily.get(i);if(n)return n;const{members:e}=s,l=new Map;for(const r of i)l.set(r.key,r.dies.filter(f=>e.has(f)));return s.byFamily.set(i,l),l}function ue(t,i){adjustPValues(t);for(const n of t){const e=U.get(n);Ae(n,twoProportionZ(e.hits,e.n,e.restHits,e.restN),e)}const s=t.filter(n=>passesRateGate(n.stats.adjustedPValue??n.stats.pValue??1,n.effect.absoluteDelta??0,rateRelativeEffect(U.get(n)),i));return s.filter(n=>!Mt(n,s,i)).map(n=>({...n,severity:severityForFinding(n.stats.adjustedPValue??n.stats.pValue??1,n.effect.absoluteDelta??0,rateRelativeEffect(U.get(n)))}))}export function passesRateGate(t,i,s,n){return t<=n.significanceLevel&&(Math.abs(i)>=n.minimumEffectSize||s>=n.minimumRelativeEffect)}export function claimForPattern(t,i,s,n,e){const l=[];for(const r of s){const f=r.comparison.family,c=f==="ring"?n(r):[];t.some(o=>ct(o,f,c,e))&&(l.push(r.id),i!=="info"&&(f==="ring"||f==="quadrant"||f==="sector")&&(r.severity="info"))}return l}function Mt(t,i,s){const n=U.get(t);if(!n)return!1;const e=t.stats.pValue??1;let{restHits:l,restN:r}=n;for(const u of We(t,i)){const a=U.get(u);a&&(l-=a.hits,r-=a.n)}if(r===n.restN)return!1;if(r<s.minimumSampleSize)return!0;const f=n.hits/n.n-l/r;if(Math.sign(f)!==Math.sign(t.effect.absoluteDelta??0))return!0;const c=e>0?(t.stats.adjustedPValue??e)/e:1,o=Math.min(1,O(n.hits,n.n,l,r)*c);return!passesRateGate(o,f,rateRelativeEffect({...n,restHits:l,restN:r}),s)}function We(t,i){const s=t.stats.pValue??1;return i.filter(n=>n!==t&&n.effect.direction!==t.effect.direction&&n.variable.kind===t.variable.kind&&n.variable.bin===t.variable.bin&&n.variable.index===t.variable.index&&n.comparison.family===t.comparison.family&&(n.stats.pValue??1)<s)}const ze=new WeakMap;export function welchOfSums(t,i,s,n){const e=(l,r,f)=>f>1?Math.max(0,l-r*r/f)/(f-1):0;return welchFromStats(t.n,t.sum/t.n,e(t.sq,t.sum,t.n),i,s/i,e(n,s,i))}function Bt(t,i,s){const n=ze.get(t);if(!n)return!1;let{restN:e,restSum:l,restSq:r}=n;for(const h of We(t,i)){const g=ze.get(h);g&&(e-=g.n,l-=g.sum,r-=g.sq)}if(e===n.restN)return!1;if(e<s.minimumSampleSize)return!0;const{pValue:f,effectSize:c,delta:o}=welchOfSums(n,e,l,r);if(Math.sign(o)!==Math.sign(t.effect.absoluteDelta??0))return!0;const u=t.stats.pValue??1,a=u>0?(t.stats.adjustedPValue??u)/u:1;return!(Math.min(1,f*a)<=s.significanceLevel&&Math.abs(c)>=s.minimumEffectSize)}function ee(t,i,s,n){const e=new Set(s),l=ce(t,i),r=new Map,f=new Map;for(const[o,u]of l){let a=0,h=0;for(const g of u)g.hbin!==void 0&&(h++,e.has(g.hbin)&&a++);r.set(o,a),f.set(o,h)}const c=[];for(const o of i){const u=f.get(o.key)??0,a=r.get(o.key)??0;let h=0,g=0;for(const[k,S]of f)k!==o.key&&(h+=S,g+=r.get(k)??0);if(u<n.minimumSampleSize||h<n.minimumSampleSize)continue;const p=a/u,d=g/h,y=p-d,w=O(a,u,g,h);c.push(le(Z(o,{id:`yield:${o.key}`,level:"wafer",severity:"info",variable:{kind:"yield",label:"Yield"},comparison:{family:o.family,left:o.label,right:_(o.family)},effect:{direction:y===0?"different":y>0?"higher":"lower",absoluteDelta:y,relativeDelta:d===0?void 0:y/d,effectSize:y},stats:{method:"two-proportion-z",pValue:w,sampleSizeLeft:u,sampleSizeRight:h},summary:be(o.label,y,o.family),highlight:{kind:"region",regionFamily:o.family,regionKeys:[o.key],dieKeys:[...o.dieKeys]}}),{hits:a,n:u,restHits:g,restN:h,passRate:!0}))}return ue(c,n)}function E(t,i,s,n,e,l){const r=p=>s==="soft"?p.sbin:p.hbin,f=[...new Set(t.map(r).filter(p=>p!==void 0))].sort((p,d)=>p-d),c=ce(t,i),o=new Map,u=new Map;for(const[p,d]of c){const y=new Map;for(const w of d){const k=r(w);k!==void 0&&y.set(k,(y.get(k)??0)+1)}o.set(p,y),u.set(p,d.length)}const a=[],h=e==="hardBin"?"HBin":"SBin",g=s==="hard"?new Set(l.passBins):l.softPassBins??Me(t,l.passBins).soft;for(const p of i){const d=u.get(p.key)??0,y=o.get(p.key);let w=0;const k=new Map;for(const[S,$]of o)if(S!==p.key){w+=u.get(S)??0;for(const[N,F]of $)k.set(N,(k.get(N)??0)+F)}if(!(d<l.minimumSampleSize||w<l.minimumSampleSize))for(const S of f){const $=y.get(S)??0,N=k.get(S)??0,F=$/d,b=N/w,v=F-b,M=O($,d,N,w),z=Ee(S,n,h);a.push(le(Z(p,{id:`${e}:${S}:${p.key}`,level:"wafer",severity:"info",variable:{kind:e,bin:S,label:z},comparison:{family:p.family,left:p.label,right:_(p.family)},effect:{direction:v===0?"different":v>0?"higher":"lower",absoluteDelta:v,relativeDelta:b===0?void 0:v/b,effectSize:v},stats:{method:"two-proportion-z",pValue:M,sampleSizeLeft:d,sampleSizeRight:w},summary:Se(p.label,z,v,p.family),highlight:{kind:"bin",bin:S,regionKeys:[p.key],dieKeys:[...p.dieKeys]}}),{hits:$,n:d,restHits:N,restN:w,passRate:g.has(S)}))}}return ue(a,l)}function te(t,i,s,n){const e=(s??[]).filter(u=>!W(u));if(!e.length)return[];const l=e.map(u=>u.testNumber),r=ce(t,i),f=new Map,c=new Map;for(const[u,a]of r){const h=new Uint32Array(e.length),g=new Uint32Array(e.length);for(const p of a)for(let d=0;d<e.length;d++){const y=se(p,l[d],e[d]);y!==void 0&&(g[d]++,y&&h[d]++)}f.set(u,h),c.set(u,g)}const o=[];for(const u of i){const a=f.get(u.key),h=c.get(u.key);for(let g=0;g<e.length;g++){let p=0,d=0;for(const[b,v]of c)b!==u.key&&(d+=v[g],p+=f.get(b)[g]);const y=h[g],w=a[g];if(y<n.minimumSampleSize||d<n.minimumSampleSize)continue;const k=w/y,S=p/d,$=k-S,N=O(w,y,p,d),F=l[g];o.push(le(Z(u,{id:`functional:${F}:${u.key}`,level:"wafer",severity:"info",variable:{kind:"functionalTest",index:F,label:`${T(e[g],F)} pass rate`,...oe(e[g])},comparison:{family:u.family,left:u.label,right:_(u.family)},effect:{direction:$===0?"different":$>0?"higher":"lower",absoluteDelta:$,relativeDelta:S===0?void 0:$/S,effectSize:$},stats:{method:"two-proportion-z",pValue:N,sampleSizeLeft:y,sampleSizeRight:d},summary:we(u.label,T(e[g],F),$,u.family),highlight:{kind:"region",regionFamily:u.family,regionKeys:[u.key],dieKeys:[...u.dieKeys]}}),{hits:w,n:y,restHits:p,restN:d,passRate:!0}))}}return ue(o,n)}export function welchFromStats(t,i,s,n,e,l){const r=Math.sqrt(s/t+l/n),f=i-e;if(!Number.isFinite(r)||r===0)return{pValue:1,effectSize:0,delta:f,z:0};const c=f/r,o=Math.sqrt(Math.max(0,(s+l)/2)),u=o===0?f:f/o;return{pValue:Ve(2*(1-Ce(Math.abs(c)))),effectSize:u,delta:f,z:c}}function Nt(t,i){const s=ae(t),n=ae(i);return welchFromStats(t.length,s,he(t,s),i.length,n,he(i,n))}const Ye=250;function _e(t,i,s){const n=r=>r.filter(f=>W(s?.find(c=>c.testNumber===f)));if(i)return{testNumbers:n(i.slice().sort((r,f)=>r-f))};const e=Pe(t,"values");if(e.length>Ye){const r=`Test-value analysis was skipped: more than ${Ye} tests were found in the die data, so no test findings were computed. Pass testNumbers: [...] to analyse specific tests.`;return console.warn(`[wafermap] analyzeWaferMap: ${r}`),{testNumbers:[],warning:{code:"test-count-capped",message:r,severity:"warning"}}}return{testNumbers:n(e)}}function ne(t,i,s,n){const e=_e(t,n.testNumbers,s);if(e.warning)return{findings:[],warning:e.warning};const l=e.testNumbers,r=new Map;for(let d=0;d<i.length;d++)for(const y of I(i[d].dies))r.set(y,d);const f=i.length,c=[],o=[];for(const d of t){const y=r.get(me(d));y!==void 0&&(c.push(d),o.push(y))}const u=[],a=new Float64Array(f),h=new Float64Array(f),g=new Float64Array(f);for(const d of l){a.fill(0),h.fill(0),g.fill(0);let y=0,w=0,k=0,S;for(let $=0;$<c.length;$++){const N=c[$],F=j(N,d);if(F===void 0)continue;S===void 0&&(S=F);const b=F-S,v=o[$];a[v]+=1,h[v]+=b,g[v]+=b*b,y+=1,w+=b,k+=b*b}if(S!==void 0)for(let $=0;$<f;$++){const N=a[$],F=y-N;if(N<n.minimumSampleSize||F<n.minimumSampleSize)continue;const b=h[$]/N,M=(w-h[$])/F,z=b+S,D=M+S,C=N>1?Math.max(0,g[$]-N*b*b)/(N-1):0,m=F>1?Math.max(0,k-g[$]-F*M*M)/(F-1):0,{pValue:R,effectSize:P,delta:B,z:x}=welchFromStats(N,z,C,F,D,m),V=i[$],{label:L,unit:q,...H}=Dt(d,s),K=D!==0?B/Math.abs(D):void 0,A=Z(V,{id:`test:${d}:${V.key}`,level:"wafer",severity:"info",variable:{kind:"test",index:d,label:L,unit:q,...H},comparison:{family:V.family,left:V.label,right:_(V.family)},effect:{direction:B===0?"different":B>0?"higher":"lower",absoluteDelta:B,relativeDelta:K,effectSize:P},stats:{method:"welch-z-approx",pValue:R,sampleSizeLeft:N,sampleSizeRight:F},summary:ve(V.label,L,B,K,V.family,q),highlight:{kind:"region",regionFamily:V.family,regionKeys:[V.key],dieKeys:[...V.dieKeys]}}),Re={n:N,sum:h[$],sq:g[$],restN:F,restSum:w-h[$],restSq:k-g[$],shift:S};ze.set(A,Re),Ae(A,x,void 0,Re),u.push(A)}}adjustPValues(u);const p=u.filter(d=>{const y=d.stats.adjustedPValue??d.stats.pValue??1,w=Math.abs(d.effect.effectSize??0);return y<=n.significanceLevel&&w>=n.minimumEffectSize});return{activeTestNumbers:l,findings:p.filter(d=>!Bt(d,p,n)).map(d=>({...d,severity:severityForScore(d.stats.adjustedPValue??d.stats.pValue??1,d.effect.effectSize??0)}))}}function Ft(t,i,s,n){if(!s?.length)return[];const e=s.filter(r=>W(r)&&(r.limitLow!==void 0||r.limitHigh!==void 0));if(!e.length)return[];const l=[];for(const r of e){const f=r.testNumber;for(const c of i){const o=ce(t,c),u=[],a=new Map;let h=0,g=0;for(const[p,d]of o){let y=0,w=0;for(const k of d){const S=j(k,f);S!==void 0&&(y++,ge(re(S,r))&&w++)}a.set(p,{valid:y,fail:w}),h+=y,g+=w}for(const p of c){const d=a.get(p.key),y=d.valid,w=h-d.valid;if(y<n.minimumSampleSize||w<n.minimumSampleSize)continue;const k=d.fail,S=g-d.fail,$=k/y,N=S/w,F=$-N,b=O(k,y,S,w);u.push(le(Z(p,{id:`specLimit:${f}:${p.key}`,level:"wafer",severity:"info",variable:{kind:"test",index:f,label:T(r,f),unit:r.unit,...oe(r)},comparison:{family:p.family,left:p.label,right:_(p.family)},effect:{direction:F===0?"different":F>0?"higher":"lower",absoluteDelta:F,relativeDelta:N===0?void 0:F/N,effectSize:F},stats:{method:"two-proportion-z",pValue:b,sampleSizeLeft:y,sampleSizeRight:w},summary:$e(p.label,T(r,f),F),highlight:{kind:"region",regionFamily:p.family,regionKeys:[p.key],dieKeys:[...p.dieKeys]}}),{hits:k,n:y,restHits:S,restN:w,passRate:!1}))}l.push(...ue(u,n))}}return l}function ke(t,i){return t==="softBin"?i.softEligibleDies:t==="test"?i.testDies:i.eligibleDies}function Pt(t){return t.id.startsWith("specLimit:")}function ie(t){return t.highlight.regionKeys??[]}function xt(t){const i=t.variable.bin??t.variable.index??"";return`${t.comparison.family}\0${Qe(t)}\0${t.variable.kind}\0${i}\0${t.effect.direction}`}function Ct(t,i){const s=Y(t);return s.family==="ring"?s.ring??0:s.family==="sector"?xe(i).indexOf(s.sector??""):0}export function inQuadrantOrder(t){const i=new Set(t),s=pe.findIndex((e,l)=>i.has(e)&&!i.has(pe[(l+3)%4])),n=s<0?0:s;return Array.from({length:4},(e,l)=>pe[(n+l)%4]).filter(e=>i.has(e))}export function findContiguousRuns(t,i,s,n){if(i==="quadrant"){const c=new Map;for(const h of t){const g=Y(n(h)).quadrant;g&&c.set(g,h)}const o=[...c.keys()],u=new Set,a=[];for(const h of o){if(u.has(h))continue;const g=[],p=[h];for(u.add(h);p.length;){const d=p.pop();g.push(d);for(const y of o)!u.has(y)&&at(d,y)&&(u.add(y),p.push(y))}a.push(inQuadrantOrder(g).map(d=>c.get(d)))}return a}const e=c=>Ct(n(c),s),l=[...t].sort((c,o)=>e(c)-e(o)),r=[];let f=[];for(const c of l){if(f.length===0){f.push(c);continue}const o=e(f[f.length-1]);e(c)-o===1?f.push(c):(r.push(f),f=[c])}if(f.length&&r.push(f),i==="sector"&&r.length>1){const o=xe(s).length,u=e(r[0][0]),a=e(r[r.length-1][r[r.length-1].length-1]);if(u===0&&a===o-1){const h=r.pop();r[0]=[...h,...r[0]]}}return r}export function mergedRegionLabel(t,i,s){if(t==="ring"){const e=i.map(c=>Y(c).ring).filter(c=>c!==void 0).sort((c,o)=>c-o),l=e[0],r=e[e.length-1];let f="";return l===r&&l===1&&s>1?f=" (core)":l===r&&l===s&&s>1&&(f=" (edge)"),l===r?`Ring ${l}${f}`:`Rings ${l}\u2013${r}`}if(t==="sector"){const e=i.map(l=>Y(l).sector??"");return e.length===1?`Sector ${e[0]}`:`Sectors ${e[0]}\u2013${e[e.length-1]}`}const n=i.map(e=>Y(e).quadrant??"");return n.length===1?n[0]:n.length===2?`Quadrants ${n[0]} & ${n[1]}`:`Quadrants ${n.slice(0,-1).join(", ")} & ${n[n.length-1]}`}function De(t){return[...new Set(t)]}export function weakestMultiplier(t){return bt(t.map(i=>{const s=i.stats.pValue??1;return s>0?(i.stats.adjustedPValue??s)/s:1}))}function G(t,i){return Math.min(1,t*i)}function Vt(t,i){const s=t[0],n=s.comparison.family,e=s.variable.kind,l=De(t.flatMap(ie));let r,f;const c=t.map(je);if(c.every(b=>b!==void 0)){const b=new Set;r=[];for(const M of c){const z=I(M.dies);for(let D=0;D<z.length;D++)b.has(z[D])||(b.add(z[D]),r.push(M.dieKeys[D]))}const v=I(ke(s.variable.kind,i));f=M=>b.has(v[M])}else{r=De(t.flatMap(M=>M.highlight.dieKeys??[]));const b=new Set(r),v=Rt(ke(s.variable.kind,i));f=M=>b.has(v[M])}const o=mergedRegionLabel(n,t.map(b=>ie(b)[0]??""),i.ringCount),u=ke(e,i),a=i.regionDies[n],h=I(u),g=[],p=[];for(let b=0;b<u.length;b++)a.has(h[b])&&(f(b)?g:p).push(u[b]);const d=weakestMultiplier(t);let y,w,k,S,$;if(Pt(s)){const b=s.variable.index,v=i.testDefs?.find(x=>x.testNumber===b),M=x=>{let V=0,L=0;for(const q of x){const H=j(q,b);H!==void 0&&(V++,v&&ge(re(H,v))&&L++)}return{valid:V,fail:L}},z=M(g),D=M(p),C=z.valid>0?z.fail/z.valid:0,m=D.valid>0?D.fail/D.valid:0,R=C-m,P=O(z.fail,z.valid,D.fail,D.valid);y={direction:R===0?"different":R>0?"higher":"lower",absoluteDelta:R,relativeDelta:m===0?void 0:R/m,effectSize:R},w={method:"two-proportion-z",pValue:P,sampleSizeLeft:z.valid,sampleSizeRight:D.valid};const B=G(P,d);k=severityForFinding(B,R,rateRelativeEffect({hits:z.fail,n:z.valid,restHits:D.fail,restN:D.valid,passRate:!1})),S=$e(o,T(v,b),R),$=`specLimit:${b}`}else if(e==="test"){const b=s.variable.index,v=x=>j(x,b),M=g.map(v).filter(x=>x!==void 0),z=p.map(v).filter(x=>x!==void 0),{pValue:D,effectSize:C,delta:m}=Nt(M,z),R=ae(z),P=R!==0?m/Math.abs(R):void 0;y={direction:m===0?"different":m>0?"higher":"lower",absoluteDelta:m,relativeDelta:P,effectSize:C},w={method:"welch-z-approx",pValue:D,sampleSizeLeft:M.length,sampleSizeRight:z.length};const B=G(D,d);k=severityForScore(B,C),S=ve(o,s.variable.label,m,P,n,s.variable.unit),$=`test:${b}`}else if(e==="yield"){const b=new Set(i.passBins),v=g.filter(L=>L.hbin!==void 0),M=p.filter(L=>L.hbin!==void 0),z=v.length,D=M.length,C=v.filter(L=>b.has(L.hbin)).length,m=M.filter(L=>b.has(L.hbin)).length,R=z>0?C/z:0,P=D>0?m/D:0,B=R-P,x=O(C,z,m,D);y={direction:B===0?"different":B>0?"higher":"lower",absoluteDelta:B,relativeDelta:P===0?void 0:B/P,effectSize:B},w={method:"two-proportion-z",pValue:x,sampleSizeLeft:z,sampleSizeRight:D};const V=G(x,d);k=severityForFinding(V,B,rateRelativeEffect({hits:C,n:z,restHits:m,restN:D,passRate:!0})),S=be(o,B,n),$="yield"}else if(e==="functionalTest"){const b=s.variable.index,v=i.testDefs?.find(V=>V.testNumber===b);let M=0,z=0,D=0,C=0;for(const V of g){const L=se(V,b,v);L!==void 0&&(z++,L&&M++)}for(const V of p){const L=se(V,b,v);L!==void 0&&(C++,L&&D++)}const m=z>0?M/z:0,R=C>0?D/C:0,P=m-R,B=O(M,z,D,C);y={direction:P===0?"different":P>0?"higher":"lower",absoluteDelta:P,relativeDelta:R===0?void 0:P/R,effectSize:P},w={method:"two-proportion-z",pValue:B,sampleSizeLeft:z,sampleSizeRight:C};const x=G(B,d);k=severityForFinding(x,P,rateRelativeEffect({hits:M,n:z,restHits:D,restN:C,passRate:!0})),S=we(o,T(v,b),P,n),$=`functional:${b}`}else{const b=s.variable.bin,v=x=>e==="softBin"?x.sbin:x.hbin,M=g.filter(x=>v(x)===b).length,z=p.filter(x=>v(x)===b).length,D=M/g.length,C=z/p.length,m=D-C,R=O(M,g.length,z,p.length);y={direction:m===0?"different":m>0?"higher":"lower",absoluteDelta:m,relativeDelta:C===0?void 0:m/C,effectSize:m},w={method:"two-proportion-z",pValue:R,sampleSizeLeft:g.length,sampleSizeRight:p.length};const P=G(R,d);k=severityForFinding(P,m,rateRelativeEffect({hits:M,n:g.length,restHits:z,restN:p.length,passRate:!1}));const B=e==="softBin"?i.sbinDefs:i.hbinDefs;S=Se(o,Ee(b,B,e==="softBin"?"SBin":"HBin"),m,n),$=`${e}:${b}`}w={...w,adjustedPValue:G(w.pValue??1,d)};const N=De(l.map(b=>b.replace(`${n}:`,""))).join("-"),F=e==="hardBin"||e==="softBin"?{kind:"bin",bin:s.variable.bin,regionKeys:l,dieKeys:r}:{kind:"region",regionFamily:n,regionKeys:l,dieKeys:r};return{...s,id:`${$}:${n}:${N}`,severity:k,comparison:{family:n,left:o,right:_(n)},effect:y,stats:w,summary:S,highlight:F,relatedIds:t.map(b=>b.id)}}function Lt(t,i){const s=new Set(["ring","quadrant","sector"]),n=[],e=new Map;for(const r of t){if(!s.has(r.comparison.family)){n.push(r);continue}const f=xt(r),c=e.get(f)??[];c.push(r),e.set(f,c)}const l=[];for(const r of e.values()){if(r.length===1){l.push(r[0]);continue}const f=r[0].comparison.family;for(const c of findContiguousRuns(r,f,i.sectorCount,o=>ie(o)[0]??""))l.push(c.length===1?c[0]:Vt(c,i))}return[...n,...l]}function Kt(t){const i=new Map,s=new Map;for(const e of t){const l=me(e);e.hbin!==void 0&&e.hbin!==null&&(i.get(e.hbin)??i.set(e.hbin,new Set).get(e.hbin)).add(l),e.sbin!==void 0&&e.sbin!==null&&(s.get(e.sbin)??s.set(e.sbin,new Set).get(e.sbin)).add(l)}const n=new Set;for(const[e,l]of i)for(const[r,f]of s){if(l.size!==f.size)continue;let c=!0;for(const o of l)if(!f.has(o)){c=!1;break}c&&n.add(`${e}:${r}`)}return n}function Et(t,i){const s=new Set(i);let n;for(const e of t){const l=Be(e,s);if(l!==void 0&&l){if(e.sbin==null||n!==void 0&&e.sbin!==n)return;n=e.sbin}}if(n!==void 0){for(const e of t)if(e.sbin===n&&Be(e,s)!==!0)return;return n}}function Ot(t){return`${t.comparison.family}\0${t.comparison.left}`}export function redundancyFacts(t,i,s){return{coincident:Kt(t),yieldSoftBin:Et(t,i),passBins:i,sectorCount:s}}const Tt=3/5;function Qe(t){return/^(?:lot-region:)?([^:|]+)/.exec(t.id)?.[1]??t.id}function qt(t){const i=ie(t);if(i.length)return i;const s=/(ring|sector|quadrant):([^:|]+)$/.exec(t.id);return s?s[2].split("-").map(n=>`${s[1]}:${n}`):[]}function Ue(t,i){const s=new Set;for(const n of qt(t)){const e=rt(n,i);if(!e)return;for(const l of e)s.add(l)}return s.size?s:void 0}export function collapseRedundantFindings(t,i){const{coincident:s,yieldSoftBin:n,passBins:e}=i,l=(o,u)=>{o.absorbedIds=[...o.absorbedIds??[],u.id]},r=new Map;for(const o of t){const u=Ot(o);(r.get(u)??r.set(u,[]).get(u)).push(o)}const f=new Set;for(const o of r.values()){for(const a of o)if(!(a.variable.kind!=="hardBin"||a.variable.bin===void 0))for(const h of o){if(h.variable.kind!=="softBin"||h.variable.bin===void 0||f.has(h.id)||!s.has(`${a.variable.bin}:${h.variable.bin}`)||h.effect.direction!==a.effect.direction)continue;l(a,h),f.add(h.id);const g=a.variable.label.replace(/^HBin\s+/,""),p=h.variable.label.replace(/^SBin\s+/,""),d=g===p?`HBin and SBin ${g} (same dies)`:`${a.variable.label} and ${h.variable.label} (same dies)`;a.summary=a.summary.replace(a.variable.label,d),a.variable.label=d;break}const u=o.find(a=>a.variable.kind==="yield");if(u){for(const a of o)if(!(a===u||f.has(a.id)||!(a.variable.kind==="hardBin"&&e.length===1&&a.variable.bin===e[0]||a.variable.kind==="softBin"&&a.variable.bin===n))){l(u,a),f.add(a.id);for(const g of a.absorbedIds??[])u.absorbedIds=[...u.absorbedIds??[],g]}}}const c=new Map;for(const o of t){if(f.has(o.id)||o.comparison.family!=="sector"&&o.comparison.family!=="quadrant")continue;const u=[Qe(o),o.variable.kind,o.variable.bin??"",o.variable.index??"",o.effect.direction].join("\0");(c.get(u)??c.set(u,[]).get(u)).push(o)}for(const o of c.values()){const u=[];for(const a of o.filter(h=>h.comparison.family==="sector")){const h=Ue(a,i.sectorCount);if(h)for(const g of o.filter(p=>p.comparison.family==="quadrant")){const p=Ue(g,i.sectorCount);if(!p)continue;let d=0;for(const w of h)p.has(w)&&d++;const y=h.size+p.size-d;d/y>=Tt-1e-9&&u.push({sector:a,quadrant:g,overlap:d/y})}}u.sort((a,h)=>h.overlap-a.overlap);for(const{sector:a,quadrant:h}of u){if(f.has(a.id)||f.has(h.id))continue;const g=(h.stats.pValue??1)<(a.stats.pValue??1),[p,d]=g?[h,a]:[a,h];l(p,d),f.add(d.id),p.absorbedIds=[...p.absorbedIds??[],...d.absorbedIds??[]]}}}export function analyzeWaferMap(t,i={}){const s=Q,n=J,e=[];Q=e,J=void 0;try{const l=Ht(t,i);return He.set(l,{candidates:e,facts:J}),l}finally{Q=s,J=n}}function Ht(t,i){const{resolved:s,warnings:n}=resolveOptions(i),e=Ge(t),l={...s,passBins:[...mt(e,"analyzeWaferMap")],ringCount:pt(e,"analyzeWaferMap")},r=e.isLotStack,f=e.aggrMethod,c=!r||f==="mode"||f==="countBin"||f==="percent",o=e.dies.filter(m=>wt(m)),u=o.filter(Fe),a=St(l,o.length);a.softPassBins=Me(o,a.passBins).soft;const h=e.dies.filter(m=>de(m)),g=h.filter(Fe),p=it(g,e.wafer,a.ringCount),d=tt(g,e.wafer,a.ringCount),y=nt(g,e.reticleConfig),w=ot(h,!1),k=st(g,e.wafer,a.sectorCount),S=[];c&&S.push(...ee(o,p,a.passBins,a),...ee(o,d,a.passBins,a),...ee(o,y,a.passBins,a),...ee(o,w,a.passBins,a),...ee(o,k,a.passBins,a)),c&&S.push(...E(o,p,"hard",e.hbinDefs,"hardBin",a),...E(o,d,"hard",e.hbinDefs,"hardBin",a),...E(o,y,"hard",e.hbinDefs,"hardBin",a),...E(o,w,"hard",e.hbinDefs,"hardBin",a),...E(o,k,"hard",e.hbinDefs,"hardBin",a));{const m=o.filter(R=>R.sbin!==void 0);S.push(...E(m,p,"soft",e.sbinDefs,"softBin",a),...E(m,d,"soft",e.sbinDefs,"softBin",a),...E(m,y,"soft",e.sbinDefs,"softBin",a),...E(m,w,"soft",e.sbinDefs,"softBin",a),...E(m,k,"soft",e.sbinDefs,"softBin",a))}const $=[...n];let N;if(a.enableTestValueAnalysis){const m=ne(o,p,e.testDefs,a),R=ne(o,d,e.testDefs,a),P=ne(o,y,e.testDefs,a),B=ne(o,w,e.testDefs,a),x=ne(o,k,e.testDefs,a);S.push(...m.findings,...R.findings,...P.findings,...B.findings,...x.findings),m.warning&&$.push(m.warning),N=m.activeTestNumbers,S.push(...Ft(o,[p,d,y,w,k],e.testDefs,a)),S.push(...te(o,p,e.testDefs,a),...te(o,d,e.testDefs,a),...te(o,y,e.testDefs,a),...te(o,w,e.testDefs,a),...te(o,k,e.testDefs,a))}{const m=vt(r,c,e.testDefs);(!r||c||m!==void 0)&&S.push(...ft(u,e.wafer,{...a,isFailingDie:m}))}const F=Lt(S,{eligibleDies:o,softEligibleDies:o.filter(m=>m.sbin!==void 0),testDies:o,passBins:a.passBins,ringCount:a.ringCount,sectorCount:a.sectorCount,regionDies:{ring:new Set(p.flatMap(m=>I(m.dies))),quadrant:new Set(d.flatMap(m=>I(m.dies))),sector:new Set(k.flatMap(m=>I(m.dies)))},hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs});S.length=0,S.push(...F);let b;if(c){const m=lt(u,e.wafer,{passBins:a.passBins,ringCount:a.ringCount});if(b=m??void 0,m!==null&&m.pattern!=="random"&&m.pattern!=="none"){const R=dt[m.pattern],P=m.confidence==="high"?"unusual":m.confidence==="medium"?"notable":"info",B=m.features,x=K=>`${(K*100).toFixed(0)}%`,V=m.pattern==="edge-ring"||m.pattern==="edge-local"?`${x(B.edgeRdd)} of edge dies failing`:m.pattern==="center"||m.pattern==="donut"?`centroid at ${x(B.centroidDistNorm)} of wafer radius from centre`:m.pattern==="scratch"?`linear score ${B.linearScore.toFixed(2)}, eccentricity ${B.eccentricity.toFixed(2)}`:`${x(B.globalRdd)} of dies failing`,L=new Set(a.passBins),q=o.filter(K=>ut(K,L)===!0),H=claimForPattern([m.pattern],P,S,K=>ie(K).map(A=>Y(A).ring).filter(A=>A!==void 0),a.ringCount);S.push({id:`spatial-pattern:${m.pattern}`,level:"wafer",severity:P,variable:{kind:"spatialPattern",label:R},comparison:{family:"spatial-pattern",left:R,right:"Wafer"},effect:{direction:"different",effectSize:B.globalRdd},stats:{method:"geometry",sampleSizeLeft:q.length,sampleSizeRight:o.length},summary:`Spatial pattern: ${R.toLowerCase()} (${m.confidence} confidence) \u2014 ${V}${m.note?` [${m.note}]`:""}`,highlight:{kind:"dies",dieKeys:q.map(K=>Ne(K))},relatedIds:H.length>0?H:void 0})}}S.sort((m,R)=>{const P=m.stats.adjustedPValue??m.stats.pValue??1,B=R.stats.adjustedPValue??R.stats.pValue??1;return P!==B?P-B:Math.abs(R.effect.absoluteDelta??0)-Math.abs(m.effect.absoluteDelta??0)});const v=$t(e.dies,o.length,e.yield.yieldPercent);r&&(v.isLotStack=!0,f&&(v.aggregationMethod=f));const M=zt(e.dies,e.testDefs);M&&(v.testSpecYield=M);const z=computeFunctionalYield(e.dies,e.testDefs);if(z&&(v.functionalYield=z),b&&(v.spatialPattern=b),N===void 0&&a.computePerTestStats){const m=_e(o,a.testNumbers,e.testDefs);m.warning&&$.push(m.warning),N=m.testNumbers}if(N?.length){const m=kt(e.dies,N,e.testDefs,a.minimumSampleSize);m&&(v.perTestStats=m);const R=Xe([{dies:e.dies}],e.testDefs,N);R&&(v.capability=R)}Object.assign(v,Ze(e.dies,e.testDefs));const D=Je([{dies:e.dies,wafer:e.wafer,passBins:a.passBins,ringCount:a.ringCount}]);D&&(v.regionYield=D),$.length>0&&(v.warnings=$);const C=redundancyFacts(o,a.passBins,a.sectorCount);return collapseRedundantFindings(S,C),Q&&(J=C),{level:"wafer",hasNotableFindings:S.some(m=>m.severity==="notable"||m.severity==="unusual"),findings:S,wafer:e.wafer.metadata??void 0,stats:v}}
|
|
1
|
+
import{normalizeInput as st}from"./normalizeInput.js";import{autoDecision as ot,testValueStatus as at}from"./testValueBudget.js";import{computeCapability as rt,computeTestFlagYield as ft,computeRegionYield as lt}from"./summaryFigures.js";import{binPassSets as Ee}from"../renderer/binColors.js";import{diePassStatus as be,isYieldEligibleDie as ye,getDieKey as Se,isPositionedDie as Ke,positionKey as ve}from"../core/dies.js";import{dieHasValues as ct,testsPresent as Oe,testValue as Y}from"../core/dieTable.js";import{stackBinsAreData as ut}from"../core/aggregates.js";import{getTestPassStatus as le,isParametricTest as X}from"../renderer/buildWaferMap.js";import{markedTestLabel as I,derivedFields as ce}from"../renderer/testLabel.js";import{buildQuadrantRegions as dt,buildReticlePositionRegions as mt,buildRingRegions as ht,buildSectorRegions as pt,buildTestSiteRegions as gt,sectorCompassNames as Le,areQuadrantsAdjacent as bt,parseRegionKey as Z,QUADRANT_CYCLE as we,regionAngleBins as yt}from"./regions.js";import{buildClusterFindings as St}from"./clusterDetection.js";import{classifyPattern as vt,patternExplains as wt,patternFailVerdict as $t,PATTERN_LABELS as Rt}from"./patternClassification.js";import{requirePassBins as kt}from"../core/passBins.js";import{requireRingCount as Mt}from"../core/ringCount.js";import{benjaminiHochberg as Dt,fisherExact as zt,fiveNumberSummary as Bt,sampleVariance as $e,zPValue as Ae}from"./math.js";import{mean as ue,maxOf as Ft}from"../core/utils.js";import{classifySpec as de,isOutOfSpec as Re}from"../renderer/spec.js";const xt={significanceLevel:{min:1e-6,max:1},minimumEffectSize:{min:0,max:1},minimumRelativeEffect:{min:0,max:Number.MAX_SAFE_INTEGER}},qe=[4,8,16];export function resolveOptions(e){const t=Object.fromEntries(Object.entries(e).filter(([,a])=>a!==void 0)),s={...ie,...t},o=[],n=[];for(const a of["significanceLevel","minimumEffectSize","minimumRelativeEffect"]){const{min:u,max:l}=xt[a],d=s[a];if(typeof d!="number"||!Number.isFinite(d)){n.push(`${a}=${String(d)} is not a finite number (using ${ie[a]})`),s[a]=ie[a];continue}const f=Math.min(l,Math.max(u,d));f!==d&&(n.push(`${a}=${d} is outside ${u}\u2013${l} (using ${f})`),s[a]=f)}if(qe.includes(s.sectorCount)||(n.push(`sectorCount=${s.sectorCount} is not one of ${qe.join(", ")} (using ${ie.sectorCount})`),s.sectorCount=ie.sectorCount),n.length){const a=`analyzeWaferMap: ${n.join("; ")}. The analysis ran with the corrected values.`;console.warn(`[wafermap] ${a}`),o.push({code:"analysis-option-corrected",message:a,severity:"warning"})}const i=["passBins","ringCount"].filter(a=>t[a]!==void 0);if(i.length){const a=`analyzeWaferMap: ${i.join(" and ")} ${i.length>1?"are":"is"} no longer an analysis option and was ignored. Set ${i.length>1?"them":"it"} on buildWaferMap; the analysis used the value the map was built with.`;console.warn(`[wafermap] ${a}`),o.push({code:"analysis-option-corrected",message:a,severity:"warning"})}const r=["enableYieldAnalysis","enableHardBinAnalysis","enableSoftBinAnalysis","enableReticlePositionAnalysis","enableTestSiteAnalysis","enableClusterAnalysis","enableAngularAnalysis","enablePatternClassification"].filter(a=>t[a]!==void 0);if(r.length){const a=`analyzeWaferMap: ${r.join(", ")} ${r.length>1?"are":"is"} no longer an option and was ignored: every analysis now runs. Filter the findings (filterFindings) to show fewer.`;console.warn(`[wafermap] ${a}`),o.push({code:"analysis-option-corrected",message:a,severity:"warning"})}return{resolved:s,warnings:o}}const ie={significanceLevel:.05,minimumEffectSize:.2,minimumRelativeEffect:1,minimumSampleSize:5,enableTestValueAnalysis:"auto",computePerTestStats:!1,sectorCount:8,minimumClusterSize:5};function Pt(e,t){const s={...e};return s.minimumClusterSize=Math.max(5,Math.round(t*.003)),s}function Te(e){return ye(e)?e.hbin!==void 0||e.sbin!==void 0||ct(e):!1}function Nt(e,t,s){if(!e||t)return;const o=(s??[]).filter(n=>X(n)&&(n.limitLow!==void 0||n.limitHigh!==void 0));if(o.length!==0)return n=>{for(const i of o)if(Re(de(Y(n,i.testNumber),i)))return!0;return!1}}function Ct(e,t,s){const o=new Set,n=new Set,i=new Set,r=new Map,a=new Map;for(const u of Oe(e))o.add(u);for(const u of e)u.hbin!==void 0&&n.add(u.hbin),u.sbin!==void 0&&i.add(u.sbin),ye(u)&&(u.hbin!==void 0&&r.set(u.hbin,(r.get(u.hbin)??0)+1),u.sbin!==void 0&&a.set(u.sbin,(a.get(u.sbin)??0)+1));return{totalDies:e.length,analyzedDies:t,excludedDies:e.length-t,yieldPercent:s,testsConsidered:[...o].sort((u,l)=>u-l),hardBinsConsidered:[...n].sort((u,l)=>u-l),softBinsConsidered:[...i].sort((u,l)=>u-l),...r.size?{hardBinCounts:Object.fromEntries(r)}:{},...a.size?{softBinCounts:Object.fromEntries(a)}:{}}}function Vt(e,t,s){if(!t?.length)return;const o=t.filter(i=>X(i)&&(i.limitLow!==void 0||i.limitHigh!==void 0));if(!o.length)return;const n=[];for(const i of o){const r=i.testNumber;let a=0,u=0,l=0,d=0;for(const f of e){if(f.partial||f.edgeExcluded)continue;const p=de(Y(f,r),i);if(p!==null){if(d++,p==="failLow")u++;else if(p==="failHigh")l++;else{a++;continue}s?.(r,f)}}n.push({testNumber:r,label:i.name,passDies:a,failLowDies:u,failHighDies:l,totalDies:d,yieldPercent:d>0?a/d*100:null})}return n.length?n:void 0}export function computeFunctionalYield(e,t,s){if(!t?.length)return;const o=t.filter(i=>!X(i));if(!o.length)return;const n=[];for(const i of o){const r=i.testNumber;let a=0,u=0;for(const d of e){if(d.partial||d.edgeExcluded)continue;const f=le(d,r,i);if(f!==void 0){if(f){a++;continue}u++,s?.(r,d)}}const l=a+u;n.push({testNumber:r,label:I(i,r),...ce(i),passDies:a,failDies:u,totalDies:l,passRatePercent:l>0?a/l*100:null})}return n.length?n:void 0}function Et(e,t,s,o){const n=[];for(const i of t){const r=[];for(const f of e){if(f.partial||f.edgeExcluded)continue;const p=Y(f,i);p!==void 0&&Number.isFinite(p)&&r.push(p)}if(r.length<o)continue;const a=ue(r),u=Math.sqrt($e(r,a)),l=Bt(Float64Array.from(r)),d=s?.find(f=>f.testNumber===i)?.name??String(i);n.push({testNumber:i,label:d,count:r.length,min:l.min,max:l.max,mean:a,stddev:u,median:l.median,q1:l.q1,q3:l.q3})}return n.length?n:void 0}export function twoProportionZ(e,t,s,o){const n=(e+s)/(t+o),i=n*(1-n)*(1/t+1/o);return!Number.isFinite(i)||i<=0?0:(e/t-s/o)/Math.sqrt(i)}const Kt=5;function T(e,t,s,o){const n=t+o,i=e+s;if((n>0?Math.min(i,n-i)*Math.min(t,o)/n:0)<Kt)return{pValue:zt(e,t-e,s,o-s),method:"fisher-exact"};const a=twoProportionZ(e,t,s,o);return{pValue:a===0?1:Ae(a),method:"two-proportion-z"}}function Ot(e,t,s,o){return T(e,t,s,o).pValue}export function adjustPValues(e){const t=e.filter(o=>o.stats.pValue!==void 0),s=Dt(t.map(o=>o.stats.pValue));return t.forEach((o,n)=>{o.stats.adjustedPValue=s[n]}),e}export function rateRelativeEffect(e){const t=(e.passRate?e.n-e.hits:e.hits)/e.n,s=(e.passRate?e.restN-e.restHits:e.restHits)/e.restN;return s===0?t===0?0:1/0:Math.abs(t-s)/s}export function severityForFinding(e,t,s){const o=Math.abs(t),n=s;return e<=.01&&(o>=.3||n>=2.5)?"unusual":e<=.05&&(o>=.2||n>=1.5)?"notable":"info"}export function severityForScore(e,t){return e<=.01&&Math.abs(t)>=.5?"unusual":e<=.05&&Math.abs(t)>=.15?"notable":"info"}function me(e){return e==="reticle-position"?"other reticle positions":e==="test-site"?"other test sites":"the rest of the map"}function J(e){return e==="reticle-position"?"Other reticle positions":e==="test-site"?"Other test sites":"Rest of map"}function ke(e,t,s){const o=(Math.abs(t)*100).toFixed(1);return`${e} yield is ${o} percentage points ${t>0?"higher":"lower"} than ${me(s)}`}function Me(e,t){return t==="quadrant"&&!e.startsWith("Quadrant")?`quadrant ${e}`:e}function je(e){return/^(Rings|Sectors|Quadrants)\b/.test(e)?"have":"has"}function De(e,t,s,o){const n=Me(e,o),i=(Math.abs(s)*100).toFixed(1);return`${n} ${je(n)} ${t} occurrence ${i} percentage points ${s>0?"higher":"lower"} than ${me(o)}`}function ze(e,t,s,o){const n=Me(e,o),i=(Math.abs(s)*100).toFixed(1);return`${n} ${je(n)} ${t} pass rate ${i} percentage points ${s>0?"higher":"lower"} than ${me(o)}`}function Be(e,t,s,o,n,i){const r=Me(e,n),a=me(n),u=s>0?"higher":"lower";if(o!==void 0&&Number.isFinite(o)){const d=(Math.abs(o)*100).toFixed(1);return`${r} mean ${t} is ${d}% ${u} than ${a}`}const l=i?` ${i}`:"";return`${r} mean ${t} is ${Math.abs(s).toPrecision(3)}${l} ${u} than ${a}`}function He(e,t,s){const o=t?.find(n=>n.bin===e);return o?.name?`${s} ${e} (${o.name})`:`${s} ${e}`}function Lt(e,t){const s=t?.find(o=>o.testNumber===e);return{label:I(s,e),unit:s?.unit,...ce(s)}}const Ie=new WeakMap,We=new WeakMap,Ye=new WeakMap;function se(e,t){const s=t.highlight.dieKeys;return s&&Ye.set(s,e),t}let ee=null,oe;const _e=new WeakMap;export function candidatesOf(e){return _e.get(e)}function Qe(e,t,s,o){if(!ee)return;const n=Ue(e);if(!n)return;const i=e.id.slice(0,e.id.indexOf(":")),r=i==="specLimit"?"limitFail":i,{kind:a,bin:u,index:l}=e.variable;ee.push({key:[r,a,u??"",l??"",n.family,n.key].join("|"),source:r,variable:e.variable,label:e.variable.label,comparison:e.comparison,region:n,z:t,delta:e.effect.absoluteDelta??0,effectSize:e.effect.effectSize??0,relativeDelta:e.effect.relativeDelta,rate:s,mean:o})}export function describeRegional(e,t,s){const o=e.comparison.left,n=e.region.family;switch(e.source){case"yield":return ke(o,t,n);case"hardBin":case"softBin":return De(o,e.label,t,n);case"functional":return ze(o,e.label.replace(/ pass rate$/,""),t,n);case"limitFail":return Fe(o,e.label,t);case"test":return Be(o,e.label,t,s,n,e.variable.unit)}}function Fe(e,t,s){return`${e} limit fail rate for ${t} is ${(Math.abs(s)*100).toFixed(1)} pp ${s>0?"higher":"lower"} than the rest of the wafer`}const _=new WeakMap;function he(e,t){return _.set(e,t),e}function Ue(e){const t=e.highlight.dieKeys;return t?Ye.get(t):void 0}const Ge=new WeakMap;function Q(e){let t=Ge.get(e);return t||Ge.set(e,t=e.map(ve)),t}function At(e){let t=Ie.get(e);return t||Ie.set(e,t=e.map(Se)),t}function pe(e,t){let s=We.get(e);s||We.set(e,s={members:new Set(e),byFamily:new WeakMap});const o=s.byFamily.get(t);if(o)return o;const{members:n}=s,i=new Map;for(const r of t)i.set(r.key,r.dies.filter(a=>n.has(a)));return s.byFamily.set(t,i),i}function qt(e,t){adjustPValues(e);for(const n of e){const i=_.get(n);Qe(n,twoProportionZ(i.hits,i.n,i.restHits,i.restN),i)}const s=e.filter(n=>passesRateGate(n.stats.adjustedPValue??n.stats.pValue??1,n.effect.absoluteDelta??0,rateRelativeEffect(_.get(n)),t)),o=confirmRegionalFindings(s,Xe,(n,i)=>Tt(n,i,t),n=>isRateLoss(_.get(n)),e);return s.filter(n=>o.has(n)).map(n=>({...n,severity:severityForFinding(n.stats.adjustedPValue??n.stats.pValue??1,n.effect.absoluteDelta??0,rateRelativeEffect(_.get(n)))}))}export function passesRateGate(e,t,s,o){return e<=o.significanceLevel&&(Math.abs(t)>=o.minimumEffectSize||s>=o.minimumRelativeEffect)}export function claimForPattern(e,t,s,o,n){const i=[];for(const r of s){const a=r.comparison.family,u=a==="ring"?o(r):[];e.some(l=>wt(l,a,u,n))&&(i.push(r.id),t!=="info"&&(a==="ring"||a==="quadrant"||a==="sector")&&(r.severity="info"))}return i}export function confirmRegionalFindings(e,t,s,o,n=e){const i=new Map;for(const u of e)(i.get(t(u))??i.set(t(u),[]).get(t(u))).push(u);const r=new Map;if(o)for(const u of n)o(u)&&(r.get(t(u))??r.set(t(u),[]).get(t(u))).push(u);const a=new Set;for(const[u,l]of i){const d=r.get(u)??[],f=(h,m)=>o&&!o(h)?s(h,[...new Set([...m,...d])].filter(g=>g!==h)):s(h,m);if(l.length===1&&(!o||o(l[0])||d.length===0)){a.add(l[0]);continue}const p=[];let c=[...l];for(;;){let h;for(const m of c){const g=f(m,p);if(g==="baseline-too-small"||!g.passes)continue;const S=o?.(m)??!1;(!h||S&&!h.loss||S===h.loss&&g.pValue<h.p)&&(h={t:m,p:g.pValue,loss:S})}if(!h)break;p.push(h.t),c=c.filter(m=>m!==h.t)}for(;;){let h;for(const m of p){const g=f(m,p.filter(S=>S!==m));g==="baseline-too-small"||g.passes||(!h||g.pValue>h.p)&&(h={t:m,p:g.pValue})}if(!h)break;p.splice(p.indexOf(h.t),1)}for(const h of p)a.add(h)}return a}function Xe(e){return[e.variable.kind,e.variable.bin??"",e.variable.index??"",e.comparison.family].join("\0")}function Ze(e){const t=e.stats.pValue??1;return t>0?(e.stats.adjustedPValue??t)/t:1}export function isRateLoss(e){const t=e.hits/e.n-e.restHits/e.restN;return e.passRate?t<0:t>0}function Tt(e,t,s){const o=_.get(e);let{restHits:n,restN:i}=o;for(const l of t){const d=_.get(l);d&&(n-=d.hits,i-=d.n)}if(i<s.minimumSampleSize)return"baseline-too-small";const r=o.hits/o.n-n/i,a=Math.min(1,Ot(o.hits,o.n,n,i)*Ze(e)),u=Math.sign(r)===Math.sign(e.effect.absoluteDelta??0)&&passesRateGate(a,r,rateRelativeEffect({...o,restHits:n,restN:i}),s);return{pValue:a,passes:u}}const xe=new WeakMap;export function welchOfSums(e,t,s,o){const n=(i,r,a)=>a>1?Math.max(0,i-r*r/a)/(a-1):0;return welchFromStats(e.n,e.sum/e.n,n(e.sq,e.sum,e.n),t,s/t,n(o,s,t))}function jt(e,t,s){const o=xe.get(e);let{restN:n,restSum:i,restSq:r}=o;for(const p of t){const c=xe.get(p);c&&(n-=c.n,i-=c.sum,r-=c.sq)}if(n<s.minimumSampleSize)return"baseline-too-small";const{pValue:a,effectSize:u,delta:l}=welchOfSums(o,n,i,r),d=Math.min(1,a*Ze(e)),f=Math.sign(l)===Math.sign(e.effect.absoluteDelta??0)&&d<=s.significanceLevel&&Math.abs(u)>=s.minimumEffectSize;return{pValue:d,passes:f}}function ae(e,t,s,o){const n=new Set(s),i=pe(e,t),r=new Map,a=new Map;for(const[l,d]of i){let f=0,p=0;for(const c of d)c.hbin!==void 0&&(p++,n.has(c.hbin)&&f++);r.set(l,f),a.set(l,p)}const u=[];for(const l of t){const d=a.get(l.key)??0,f=r.get(l.key)??0;let p=0,c=0;for(const[k,w]of a)k!==l.key&&(p+=w,c+=r.get(k)??0);if(d<o.minimumSampleSize||p<o.minimumSampleSize)continue;const h=f/d,m=c/p,g=h-m,{pValue:S,method:F}=T(f,d,c,p);u.push(he(se(l,{id:`yield:${l.key}`,level:"wafer",severity:"info",variable:{kind:"yield",label:"Yield"},comparison:{family:l.family,left:l.label,right:J(l.family)},effect:{direction:g===0?"different":g>0?"higher":"lower",absoluteDelta:g,relativeDelta:m===0?void 0:g/m,effectSize:g},stats:{method:F,pValue:S,sampleSizeLeft:d,sampleSizeRight:p},summary:ke(l.label,g,l.family),highlight:{kind:"region",regionFamily:l.family,regionKeys:[l.key],dieKeys:[...l.dieKeys]}}),{hits:f,n:d,restHits:c,restN:p,passRate:!0}))}return u}function q(e,t,s,o,n,i){const r=h=>s==="soft"?h.sbin:h.hbin,a=[...new Set(e.map(r).filter(h=>h!==void 0))].sort((h,m)=>h-m),u=pe(e,t),l=new Map,d=new Map;for(const[h,m]of u){const g=new Map;for(const S of m){const F=r(S);F!==void 0&&g.set(F,(g.get(F)??0)+1)}l.set(h,g),d.set(h,m.length)}const f=[],p=n==="hardBin"?"HBin":"SBin",c=s==="hard"?new Set(i.passBins):i.softPassBins??Ee(e,i.passBins).soft;for(const h of t){const m=d.get(h.key)??0,g=l.get(h.key);let S=0;const F=new Map;for(const[k,w]of l)if(k!==h.key){S+=d.get(k)??0;for(const[B,z]of w)F.set(B,(F.get(B)??0)+z)}if(!(m<i.minimumSampleSize||S<i.minimumSampleSize))for(const k of a){const w=g.get(k)??0,B=F.get(k)??0,z=w/m,b=B/S,$=z-b,{pValue:M,method:v}=T(w,m,B,S),R=He(k,o,p);f.push(he(se(h,{id:`${n}:${k}:${h.key}`,level:"wafer",severity:"info",variable:{kind:n,bin:k,label:R},comparison:{family:h.family,left:h.label,right:J(h.family)},effect:{direction:$===0?"different":$>0?"higher":"lower",absoluteDelta:$,relativeDelta:b===0?void 0:$/b,effectSize:$},stats:{method:v,pValue:M,sampleSizeLeft:m,sampleSizeRight:S},summary:De(h.label,R,$,h.family),highlight:{kind:"bin",bin:k,regionKeys:[h.key],dieKeys:[...h.dieKeys]}}),{hits:w,n:m,restHits:B,restN:S,passRate:c.has(k)}))}}return f}function re(e,t,s,o){const n=(s??[]).filter(d=>!X(d));if(!n.length)return[];const i=n.map(d=>d.testNumber),r=pe(e,t),a=new Map,u=new Map;for(const[d,f]of r){const p=new Uint32Array(n.length),c=new Uint32Array(n.length);for(const h of f)for(let m=0;m<n.length;m++){const g=le(h,i[m],n[m]);g!==void 0&&(c[m]++,g&&p[m]++)}a.set(d,p),u.set(d,c)}const l=[];for(const d of t){const f=a.get(d.key),p=u.get(d.key);for(let c=0;c<n.length;c++){let h=0,m=0;for(const[$,M]of u)$!==d.key&&(m+=M[c],h+=a.get($)[c]);const g=p[c],S=f[c];if(g<o.minimumSampleSize||m<o.minimumSampleSize)continue;const F=S/g,k=h/m,w=F-k,{pValue:B,method:z}=T(S,g,h,m),b=i[c];l.push(he(se(d,{id:`functional:${b}:${d.key}`,level:"wafer",severity:"info",variable:{kind:"functionalTest",index:b,label:`${I(n[c],b)} pass rate`,...ce(n[c])},comparison:{family:d.family,left:d.label,right:J(d.family)},effect:{direction:w===0?"different":w>0?"higher":"lower",absoluteDelta:w,relativeDelta:k===0?void 0:w/k,effectSize:w},stats:{method:z,pValue:B,sampleSizeLeft:g,sampleSizeRight:m},summary:ze(d.label,I(n[c],b),w,d.family),highlight:{kind:"region",regionFamily:d.family,regionKeys:[d.key],dieKeys:[...d.dieKeys]}}),{hits:S,n:g,restHits:h,restN:m,passRate:!0}))}}return l}export function welchFromStats(e,t,s,o,n,i){const r=Math.sqrt(s/e+i/o),a=t-n;if(!Number.isFinite(r)||r===0)return{pValue:1,effectSize:0,delta:a,z:0};const u=a/r,l=Math.sqrt(Math.max(0,(s+i)/2)),d=l===0?a:a/l;return{pValue:Ae(u),effectSize:d,delta:a,z:u}}function Ht(e,t){const s=ue(e),o=ue(t);return welchFromStats(e.length,s,$e(e,s),t.length,o,$e(t,o))}function Je(e,t,s){const o=n=>n.filter(i=>X(s?.find(r=>r.testNumber===i)));return o(t?t.slice().sort((n,i)=>n-i):Oe(e,"values"))}export function testValueSize(e,t){const s=e.dies.filter(Te);return{tests:Je(s,t.testNumbers,e.testDefs).length,dies:s.length}}export function recordedOptions(e){const t={};return e.enableTestValueAnalysis!==void 0&&(t.enableTestValueAnalysis=e.enableTestValueAnalysis),e.computePerTestStats!==void 0&&(t.computePerTestStats=e.computePerTestStats),e.sectorCount!==void 0&&(t.sectorCount=e.sectorCount),e.testNumbers!==void 0&&(t.testNumbers=[...e.testNumbers]),t}function It(e,t,s,o,n){const i=new Map;for(let m=0;m<t.length;m++)for(const g of Q(t[m].dies))i.set(g,m);const r=t.length,a=[],u=[];for(const m of e){const g=i.get(ve(m));g!==void 0&&(a.push(m),u.push(g))}const l=[],d=new Float64Array(r),f=new Float64Array(r),p=new Float64Array(r);for(const m of s){d.fill(0),f.fill(0),p.fill(0);let g=0,S=0,F=0,k;for(let w=0;w<a.length;w++){const B=a[w],z=Y(B,m);if(z===void 0)continue;k===void 0&&(k=z);const b=z-k,$=u[w];d[$]+=1,f[$]+=b,p[$]+=b*b,g+=1,S+=b,F+=b*b}if(k!==void 0)for(let w=0;w<r;w++){const B=d[w],z=g-B;if(B<n.minimumSampleSize||z<n.minimumSampleSize)continue;const b=f[w]/B,M=(S-f[w])/z,v=b+k,R=M+k,C=B>1?Math.max(0,p[w]-B*b*b)/(B-1):0,x=z>1?Math.max(0,F-p[w]-z*M*M)/(z-1):0,{pValue:V,effectSize:N,delta:D,z:K}=welchFromStats(B,v,C,z,R,x),P=t[w],{label:O,unit:E,...U}=Lt(m,o),j=R!==0?D/Math.abs(R):void 0,G=se(P,{id:`test:${m}:${P.key}`,level:"wafer",severity:"info",variable:{kind:"test",measure:"mean",index:m,label:O,unit:E,...U},comparison:{family:P.family,left:P.label,right:J(P.family)},effect:{direction:D===0?"different":D>0?"higher":"lower",absoluteDelta:D,relativeDelta:j,effectSize:N},stats:{method:"welch-z-approx",pValue:V,sampleSizeLeft:B,sampleSizeRight:z},summary:Be(P.label,O,D,j,P.family,E),highlight:{kind:"region",regionFamily:P.family,regionKeys:[P.key],dieKeys:[...P.dieKeys]}}),y={n:B,sum:f[w],sq:p[w],restN:z,restSum:S-f[w],restSq:F-p[w],shift:k};xe.set(G,y),Qe(G,K,void 0,y),l.push(G)}}adjustPValues(l);const c=l.filter(m=>{const g=m.stats.adjustedPValue??m.stats.pValue??1,S=Math.abs(m.effect.effectSize??0);return g<=n.significanceLevel&&S>=n.minimumEffectSize}),h=confirmRegionalFindings(c,Xe,(m,g)=>jt(m,g,n));return c.filter(m=>h.has(m)).map(m=>({...m,severity:severityForScore(m.stats.adjustedPValue??m.stats.pValue??1,m.effect.effectSize??0)}))}function Wt(e,t,s,o){if(!s?.length)return[];const n=s.filter(r=>X(r)&&(r.limitLow!==void 0||r.limitHigh!==void 0));if(!n.length)return[];const i=[];for(const r of n){const a=r.testNumber;for(const u of t){const l=pe(e,u),d=[],f=new Map;let p=0,c=0;for(const[h,m]of l){let g=0,S=0;for(const F of m){const k=Y(F,a);k!==void 0&&(g++,Re(de(k,r))&&S++)}f.set(h,{valid:g,fail:S}),p+=g,c+=S}for(const h of u){const m=f.get(h.key),g=m.valid,S=p-m.valid;if(g<o.minimumSampleSize||S<o.minimumSampleSize)continue;const F=m.fail,k=c-m.fail,w=F/g,B=k/S,z=w-B,{pValue:b,method:$}=T(F,g,k,S);d.push(he(se(h,{id:`specLimit:${a}:${h.key}`,level:"wafer",severity:"info",variable:{kind:"test",measure:"limitFailRate",index:a,label:I(r,a),...ce(r)},comparison:{family:h.family,left:h.label,right:J(h.family)},effect:{direction:z===0?"different":z>0?"higher":"lower",absoluteDelta:z,relativeDelta:B===0?void 0:z/B,effectSize:z},stats:{method:$,pValue:b,sampleSizeLeft:g,sampleSizeRight:S},summary:Fe(h.label,I(r,a),z),highlight:{kind:"region",regionFamily:h.family,regionKeys:[h.key],dieKeys:[...h.dieKeys]}}),{hits:F,n:g,restHits:k,restN:S,passRate:!1}))}i.push(...d)}}return i}function Pe(e,t){return e==="softBin"?t.softEligibleDies:e==="test"?t.testDies:t.eligibleDies}function Yt(e){return e.variable.measure==="limitFailRate"}function fe(e){return e.highlight.regionKeys??[]}function _t(e){const t=e.variable.bin??e.variable.index??"";return`${e.comparison.family}\0${et(e)}\0${e.variable.kind}\0${t}\0${e.effect.direction}`}function Qt(e,t){const s=Z(e);return s.family==="ring"?s.ring??0:s.family==="sector"?Le(t).indexOf(s.sector??""):0}export function inQuadrantOrder(e){const t=new Set(e),s=we.findIndex((n,i)=>t.has(n)&&!t.has(we[(i+3)%4])),o=s<0?0:s;return Array.from({length:4},(n,i)=>we[(o+i)%4]).filter(n=>t.has(n))}export function findContiguousRuns(e,t,s,o){if(t==="quadrant"){const u=new Map;for(const p of e){const c=Z(o(p)).quadrant;c&&u.set(c,p)}const l=[...u.keys()],d=new Set,f=[];for(const p of l){if(d.has(p))continue;const c=[],h=[p];for(d.add(p);h.length;){const m=h.pop();c.push(m);for(const g of l)!d.has(g)&&bt(m,g)&&(d.add(g),h.push(g))}f.push(inQuadrantOrder(c).map(m=>u.get(m)))}return f}const n=u=>Qt(o(u),s),i=[...e].sort((u,l)=>n(u)-n(l)),r=[];let a=[];for(const u of i){if(a.length===0){a.push(u);continue}const l=n(a[a.length-1]);n(u)-l===1?a.push(u):(r.push(a),a=[u])}if(a.length&&r.push(a),t==="sector"&&r.length>1){const l=Le(s).length,d=n(r[0][0]),f=n(r[r.length-1][r[r.length-1].length-1]);if(d===0&&f===l-1){const p=r.pop();r[0]=[...p,...r[0]]}}return r}export function mergedRegionLabel(e,t,s){if(e==="ring"){const n=t.map(u=>Z(u).ring).filter(u=>u!==void 0).sort((u,l)=>u-l),i=n[0],r=n[n.length-1];let a="";return i===r&&i===1&&s>1?a=" (core)":i===r&&i===s&&s>1&&(a=" (edge)"),i===r?`Ring ${i}${a}`:`Rings ${i}\u2013${r}`}if(e==="sector"){const n=t.map(i=>Z(i).sector??"");return n.length===1?`Sector ${n[0]}`:`Sectors ${n[0]}\u2013${n[n.length-1]}`}const o=t.map(n=>Z(n).quadrant??"");return o.length===1?o[0]:o.length===2?`Quadrants ${o[0]} & ${o[1]}`:`Quadrants ${o.slice(0,-1).join(", ")} & ${o[o.length-1]}`}function Ne(e){return[...new Set(e)]}export function weakestMultiplier(e){return Ft(e.map(t=>{const s=t.stats.pValue??1;return s>0?(t.stats.adjustedPValue??s)/s:1}))}function te(e,t){return Math.min(1,e*t)}function Ut(e,t){const s=e[0],o=s.comparison.family,n=s.variable.kind,i=Ne(e.flatMap(fe));let r,a;const u=e.map(Ue);if(u.every(b=>b!==void 0)){const b=new Set;r=[];for(const M of u){const v=Q(M.dies);for(let R=0;R<v.length;R++)b.has(v[R])||(b.add(v[R]),r.push(M.dieKeys[R]))}const $=Q(Pe(s.variable.kind,t));a=M=>b.has($[M])}else{r=Ne(e.flatMap(M=>M.highlight.dieKeys??[]));const b=new Set(r),$=At(Pe(s.variable.kind,t));a=M=>b.has($[M])}const l=mergedRegionLabel(o,e.map(b=>fe(b)[0]??""),t.ringCount),d=Pe(n,t),f=t.regionDies[o],p=Q(d),c=[],h=[];for(let b=0;b<d.length;b++)f.has(p[b])&&(a(b)?c:h).push(d[b]);const m=weakestMultiplier(e);let g,S,F,k,w;if(Yt(s)){const b=s.variable.index,$=t.testDefs?.find(P=>P.testNumber===b),M=P=>{let O=0,E=0;for(const U of P){const j=Y(U,b);j!==void 0&&(O++,$&&Re(de(j,$))&&E++)}return{valid:O,fail:E}},v=M(c),R=M(h),C=v.valid>0?v.fail/v.valid:0,x=R.valid>0?R.fail/R.valid:0,V=C-x,{pValue:N,method:D}=T(v.fail,v.valid,R.fail,R.valid);g={direction:V===0?"different":V>0?"higher":"lower",absoluteDelta:V,relativeDelta:x===0?void 0:V/x,effectSize:V},S={method:D,pValue:N,sampleSizeLeft:v.valid,sampleSizeRight:R.valid};const K=te(N,m);F=severityForFinding(K,V,rateRelativeEffect({hits:v.fail,n:v.valid,restHits:R.fail,restN:R.valid,passRate:!1})),k=Fe(l,I($,b),V),w=`specLimit:${b}`}else if(n==="test"){const b=s.variable.index,$=K=>Y(K,b),M=c.map($).filter(K=>K!==void 0),v=h.map($).filter(K=>K!==void 0),{pValue:R,effectSize:C,delta:x}=Ht(M,v),V=ue(v),N=V!==0?x/Math.abs(V):void 0;g={direction:x===0?"different":x>0?"higher":"lower",absoluteDelta:x,relativeDelta:N,effectSize:C},S={method:"welch-z-approx",pValue:R,sampleSizeLeft:M.length,sampleSizeRight:v.length};const D=te(R,m);F=severityForScore(D,C),k=Be(l,s.variable.label,x,N,o,s.variable.unit),w=`test:${b}`}else if(n==="yield"){const b=new Set(t.passBins),$=c.filter(E=>E.hbin!==void 0),M=h.filter(E=>E.hbin!==void 0),v=$.length,R=M.length,C=$.filter(E=>b.has(E.hbin)).length,x=M.filter(E=>b.has(E.hbin)).length,V=v>0?C/v:0,N=R>0?x/R:0,D=V-N,{pValue:K,method:P}=T(C,v,x,R);g={direction:D===0?"different":D>0?"higher":"lower",absoluteDelta:D,relativeDelta:N===0?void 0:D/N,effectSize:D},S={method:P,pValue:K,sampleSizeLeft:v,sampleSizeRight:R};const O=te(K,m);F=severityForFinding(O,D,rateRelativeEffect({hits:C,n:v,restHits:x,restN:R,passRate:!0})),k=ke(l,D,o),w="yield"}else if(n==="functionalTest"){const b=s.variable.index,$=t.testDefs?.find(O=>O.testNumber===b);let M=0,v=0,R=0,C=0;for(const O of c){const E=le(O,b,$);E!==void 0&&(v++,E&&M++)}for(const O of h){const E=le(O,b,$);E!==void 0&&(C++,E&&R++)}const x=v>0?M/v:0,V=C>0?R/C:0,N=x-V,{pValue:D,method:K}=T(M,v,R,C);g={direction:N===0?"different":N>0?"higher":"lower",absoluteDelta:N,relativeDelta:V===0?void 0:N/V,effectSize:N},S={method:K,pValue:D,sampleSizeLeft:v,sampleSizeRight:C};const P=te(D,m);F=severityForFinding(P,N,rateRelativeEffect({hits:M,n:v,restHits:R,restN:C,passRate:!0})),k=ze(l,I($,b),N,o),w=`functional:${b}`}else{const b=s.variable.bin,$=P=>n==="softBin"?P.sbin:P.hbin,M=c.filter(P=>$(P)===b).length,v=h.filter(P=>$(P)===b).length,R=M/c.length,C=v/h.length,x=R-C,{pValue:V,method:N}=T(M,c.length,v,h.length);g={direction:x===0?"different":x>0?"higher":"lower",absoluteDelta:x,relativeDelta:C===0?void 0:x/C,effectSize:x},S={method:N,pValue:V,sampleSizeLeft:c.length,sampleSizeRight:h.length};const D=te(V,m);F=severityForFinding(D,x,rateRelativeEffect({hits:M,n:c.length,restHits:v,restN:h.length,passRate:!1}));const K=n==="softBin"?t.sbinDefs:t.hbinDefs;k=De(l,He(b,K,n==="softBin"?"SBin":"HBin"),x,o),w=`${n}:${b}`}S={...S,adjustedPValue:te(S.pValue??1,m)};const B=Ne(i.map(b=>b.replace(`${o}:`,""))).join("-"),z=n==="hardBin"||n==="softBin"?{kind:"bin",bin:s.variable.bin,regionKeys:i,dieKeys:r}:{kind:"region",regionFamily:o,regionKeys:i,dieKeys:r};return{...s,id:`${w}:${o}:${B}`,severity:F,comparison:{family:o,left:l,right:J(o)},effect:g,stats:S,summary:k,highlight:z,relatedIds:e.map(b=>b.id)}}function Gt(e,t){const s=new Set(["ring","quadrant","sector"]),o=[],n=new Map;for(const r of e){if(!s.has(r.comparison.family)){o.push(r);continue}const a=_t(r),u=n.get(a)??[];u.push(r),n.set(a,u)}const i=[];for(const r of n.values()){if(r.length===1){i.push(r[0]);continue}const a=r[0].comparison.family;for(const u of findContiguousRuns(r,a,t.sectorCount,l=>fe(l)[0]??""))i.push(u.length===1?u[0]:Ut(u,t))}return[...o,...i]}function Xt(e){const t=new Map,s=new Map;for(const n of e){const i=ve(n);n.hbin!==void 0&&n.hbin!==null&&(t.get(n.hbin)??t.set(n.hbin,new Set).get(n.hbin)).add(i),n.sbin!==void 0&&n.sbin!==null&&(s.get(n.sbin)??s.set(n.sbin,new Set).get(n.sbin)).add(i)}const o=new Set;for(const[n,i]of t)for(const[r,a]of s){if(i.size!==a.size)continue;let u=!0;for(const l of i)if(!a.has(l)){u=!1;break}u&&o.add(`${n}:${r}`)}return o}function Zt(e,t){const s=new Set(t);let o;for(const n of e){const i=be(n,s);if(i!==void 0&&i){if(n.sbin==null||o!==void 0&&n.sbin!==o)return;o=n.sbin}}if(o!==void 0){for(const n of e)if(n.sbin===o&&be(n,s)!==!0)return;return o}}function Jt(e){return`${e.comparison.family}\0${e.comparison.left}`}export function redundancyFacts(e,t,s){return{coincident:Xt(e),yieldSoftBin:Zt(e,t),passBins:t,sectorCount:s}}const en=3/5;function et(e){return/^(?:lot-region:)?([^:|]+)/.exec(e.id)?.[1]??e.id}function tn(e){const t=fe(e);if(t.length)return t;const s=/(ring|sector|quadrant):([^:|]+)$/.exec(e.id);return s?s[2].split("-").map(o=>`${s[1]}:${o}`):[]}function tt(e,t){const s=new Set;for(const o of tn(e)){const n=yt(o,t);if(!n)return;for(const i of n)s.add(i)}return s.size?s:void 0}export function collapseRedundantFindings(e,t){const{coincident:s,yieldSoftBin:o,passBins:n}=t,i=(l,d)=>{l.absorbedIds=[...l.absorbedIds??[],d.id]},r=new Map;for(const l of e){const d=Jt(l);(r.get(d)??r.set(d,[]).get(d)).push(l)}const a=new Set;for(const l of r.values()){for(const f of l)if(!(f.variable.kind!=="hardBin"||f.variable.bin===void 0))for(const p of l){if(p.variable.kind!=="softBin"||p.variable.bin===void 0||a.has(p.id)||!s.has(`${f.variable.bin}:${p.variable.bin}`)||p.effect.direction!==f.effect.direction)continue;i(f,p),a.add(p.id);const c=f.variable.label.replace(/^HBin\s+/,""),h=p.variable.label.replace(/^SBin\s+/,""),m=c===h?`HBin and SBin ${c} (same dies)`:`${f.variable.label} and ${p.variable.label} (same dies)`;f.summary=f.summary.replace(f.variable.label,m),f.variable.label=m;break}const d=l.find(f=>f.variable.kind==="yield");if(d){for(const f of l)if(!(f===d||a.has(f.id)||!(f.variable.kind==="hardBin"&&n.length===1&&f.variable.bin===n[0]||f.variable.kind==="softBin"&&f.variable.bin===o))){i(d,f),a.add(f.id);for(const c of f.absorbedIds??[])d.absorbedIds=[...d.absorbedIds??[],c]}}}const u=new Map;for(const l of e){if(a.has(l.id)||l.comparison.family!=="sector"&&l.comparison.family!=="quadrant")continue;const d=[et(l),l.variable.kind,l.variable.bin??"",l.variable.index??"",l.effect.direction].join("\0");(u.get(d)??u.set(d,[]).get(d)).push(l)}for(const l of u.values()){const d=[];for(const f of l.filter(p=>p.comparison.family==="sector")){const p=tt(f,t.sectorCount);if(p)for(const c of l.filter(h=>h.comparison.family==="quadrant")){const h=tt(c,t.sectorCount);if(!h)continue;let m=0;for(const S of p)h.has(S)&&m++;const g=p.size+h.size-m;m/g>=en-1e-9&&d.push({sector:f,quadrant:c,overlap:m/g})}}d.sort((f,p)=>p.overlap-f.overlap);for(const{sector:f,quadrant:p}of d){if(a.has(f.id)||a.has(p.id))continue;const c=(p.stats.pValue??1)<(f.stats.pValue??1),[h,m]=c?[p,f]:[f,p];i(h,m),a.add(m.id),h.absorbedIds=[...h.absorbedIds??[],...m.absorbedIds??[]]}}}export function analyzeWaferMap(e,t={}){return analyzeWaferMapDecided(e,t)}export function analyzeWaferMapDecided(e,t={},s){const o=ee,n=oe,i=[];ee=i,oe=void 0;try{const r=nn(e,t,s);return _e.set(r,{candidates:i,facts:oe}),r}finally{ee=o,oe=n}}function nn(e,t,s){const{resolved:o,warnings:n}=resolveOptions(t),i=st(e),r={...o,passBins:[...kt(i,"analyzeWaferMap")],ringCount:Mt(i,"analyzeWaferMap")},a=i.isLotStack,u=i.aggrMethod,l=ut(a,u),d=l,f=i.dies.filter(y=>Te(y)),p=f.filter(Ke),c=Pt(r,f.length);c.softPassBins=Ee(f,c.passBins).soft;const h=Je(f,c.testNumbers,i.testDefs),m=c.enableTestValueAnalysis,g=m===!1?"off":m===!0?"done":s??ot(h.length*f.length),S=i.dies.filter(y=>ye(y)),F=S.filter(Ke),k=l?f.filter(y=>y.sbin!==void 0):[],w=d&&f.some(y=>y.hbin!==void 0)||k.length>0||m!==!1,B=w?ht(F,i.wafer,c.ringCount):[],z=w?dt(F,i.wafer,c.ringCount):[],b=w?mt(F,i.reticleConfig):[],$=w?gt(S,!1):[],M=w?pt(F,i.wafer,c.sectorCount):[],v=[],R=[];d&&R.push(...ae(f,B,c.passBins,c),...ae(f,z,c.passBins,c),...ae(f,b,c.passBins,c),...ae(f,$,c.passBins,c),...ae(f,M,c.passBins,c)),d&&R.push(...q(f,B,"hard",i.hbinDefs,"hardBin",c),...q(f,z,"hard",i.hbinDefs,"hardBin",c),...q(f,b,"hard",i.hbinDefs,"hardBin",c),...q(f,$,"hard",i.hbinDefs,"hardBin",c),...q(f,M,"hard",i.hbinDefs,"hardBin",c));{const y=k;R.push(...q(y,B,"soft",i.sbinDefs,"softBin",c),...q(y,z,"soft",i.sbinDefs,"softBin",c),...q(y,b,"soft",i.sbinDefs,"softBin",c),...q(y,$,"soft",i.sbinDefs,"softBin",c),...q(y,M,"soft",i.sbinDefs,"softBin",c))}const C=[...n];let x;if(m!==!1){if(g==="done"){for(const y of[B,z,b,$,M])v.push(...It(f,y,h,i.testDefs,c));x=h}R.push(...Wt(f,[B,z,b,$,M],i.testDefs,c)),R.push(...re(f,B,i.testDefs,c),...re(f,z,i.testDefs,c),...re(f,b,i.testDefs,c),...re(f,$,i.testDefs,c),...re(f,M,i.testDefs,c))}v.push(...qt(R,c));{const y=Nt(a,d,i.testDefs);(!a||d||y!==void 0)&&v.push(...St(p,i.wafer,{...c,isFailingDie:y}))}const V=Gt(v,{eligibleDies:f,softEligibleDies:k,testDies:f,passBins:c.passBins,ringCount:c.ringCount,sectorCount:c.sectorCount,regionDies:{ring:new Set(B.flatMap(y=>Q(y.dies))),quadrant:new Set(z.flatMap(y=>Q(y.dies))),sector:new Set(M.flatMap(y=>Q(y.dies)))},hbinDefs:i.hbinDefs,sbinDefs:i.sbinDefs,testDefs:i.testDefs});v.length=0,v.push(...V);let N;if(d){const y=vt(p,i.wafer,{passBins:c.passBins,ringCount:c.ringCount});if(N=y??void 0,y!==null&&y.pattern!=="random"&&y.pattern!=="none"){const L=Rt[y.pattern],H=y.confidence==="high"?"unusual":y.confidence==="medium"?"notable":"info",A=y.features,ne=W=>`${(W*100).toFixed(0)}%`,nt=y.pattern==="edge-ring"||y.pattern==="edge-local"?`${ne(A.edgeRdd)} of edge dies failing`:y.pattern==="center"?`centroid at ${ne(A.centroidDistNorm)} of wafer radius from centre`:y.pattern==="donut"?`${ne(Math.max(A.radialFailRates[1],A.radialFailRates[2]))} of dies failing at mid-radius, ${ne(A.radialFailRates[0])} at the centre`:y.pattern==="scratch"?`a line ${Math.round(A.lineLength)} dies long and about ${Math.max(1,Math.round(A.lineWidth*2))} wide`:`${ne(A.globalRdd)} of dies failing`,it=new Set(c.passBins),Ce=f.filter(W=>$t(W,it)===!0),Ve=claimForPattern([y.pattern],H,v,W=>fe(W).map(ge=>Z(ge).ring).filter(ge=>ge!==void 0),c.ringCount);v.push({id:`spatial-pattern:${y.pattern}`,level:"wafer",severity:H,variable:{kind:"spatialPattern",label:L},comparison:{family:"spatial-pattern",left:L,right:"Wafer"},effect:{direction:"different",effectSize:A.globalRdd},stats:{method:"geometry",sampleSizeLeft:Ce.length,sampleSizeRight:f.length},summary:`Spatial pattern: ${L.toLowerCase()} (${y.confidence} confidence) \u2014 ${nt}${y.note?` [${y.note}]`:""}`,highlight:{kind:"dies",dieKeys:Ce.map(W=>Se(W))},relatedIds:Ve.length>0?Ve:void 0})}}v.sort((y,L)=>{const H=y.stats.adjustedPValue??y.stats.pValue??1,A=L.stats.adjustedPValue??L.stats.pValue??1;return H!==A?H-A:Math.abs(L.effect.absoluteDelta??0)-Math.abs(y.effect.absoluteDelta??0)});const D=Ct(i.dies,f.length,i.yield.yieldPercent);a&&(D.isLotStack=!0,u&&(D.aggregationMethod=u));const K=new Set(r.passBins),P={},O=(y,L)=>{const H=P[y]??={dieKeys:[],lostDies:0};H.dieKeys.push(Se(L)),be(L,K)!==!0&&H.lostDies++},E=Vt(i.dies,i.testDefs,O);E&&(D.testSpecYield=E);const U=computeFunctionalYield(i.dies,i.testDefs,O);if(U&&(D.functionalYield=U),Object.keys(P).length&&(D.testFailures=P),N&&(D.spatialPattern=N),x===void 0&&c.computePerTestStats&&(x=h),h.length&&(D.testValueAnalysis=at(g,h.length,f.length)),x?.length){const y=Et(i.dies,x,i.testDefs,c.minimumSampleSize);y&&(D.perTestStats=y);const L=rt([{dies:i.dies}],i.testDefs,x);L&&(D.capability=L)}Object.assign(D,ft(i.dies,i.testDefs));const j=lt([{dies:i.dies,wafer:i.wafer,passBins:c.passBins,ringCount:c.ringCount}]);j&&(D.regionYield=j),C.length>0&&(D.warnings=C);const G=redundancyFacts(f,c.passBins,c.sectorCount);return collapseRedundantFindings(v,G),ee&&(oe=G),{level:"wafer",hasNotableFindings:v.some(y=>y.severity==="notable"||y.severity==="unusual"),findings:v,wafer:i.wafer.metadata??void 0,analysisOptions:recordedOptions(t),stats:D}}
|
|
@@ -29,6 +29,11 @@ export interface CapabilityDatum {
|
|
|
29
29
|
/** Pooled within-wafer sample stddev. NaN if no item contributed ≥2 values. */
|
|
30
30
|
stdWithin: number;
|
|
31
31
|
n: number;
|
|
32
|
+
/** Dies whose value for this test the value filter excluded (not in `n`), and the limit set they were outside of. */
|
|
33
|
+
excluded?: {
|
|
34
|
+
count: number;
|
|
35
|
+
limitSet: 'validity' | 'spec' | 'test';
|
|
36
|
+
};
|
|
32
37
|
/** Cp/Cpk use `stdWithin`; null when stdWithin is NaN or 0, or when `hasSpec` is false. */
|
|
33
38
|
cp: number | null;
|
|
34
39
|
cpk: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isYieldEligibleDie as
|
|
1
|
+
import{isYieldEligibleDie as v}from"../core/dies.js";import{excludedCounts as H,testValuesReader as E}from"../core/dieTable.js";import{drain as C}from"../core/utils.js";import{isParametricTest as O}from"../renderer/buildWaferMap.js";import{countOutOfSpec as P,hasSpecLimits as V}from"../renderer/spec.js";import{testLabel as _,derivedFields as I}from"../renderer/testLabel.js";import{describeValues as z}from"./math.js";const R=25e4;function j(n){if(n.specLow!==void 0&&n.specHigh!==void 0&&n.specHigh>n.specLow)return{lsl:n.specLow,usl:n.specHigh,basis:"spec"};if(n.limitLow!==void 0&&n.limitHigh!==void 0&&n.limitHigh>n.limitLow)return{lsl:n.limitLow,usl:n.limitHigh,basis:"test"}}function A(n){const s=new Map,e=new Map;for(const l of n){const t=l.testNumber;if(t===void 0||!O(l))continue;e.set(t,l);const i=j(l);i&&s.set(t,i)}return{defByTestNumber:e,specByTest:s}}function*$(n,s,e){const l=[...s.keys()],t=l.length,i=new Float64Array(t),r=new Float64Array(t),o=new Float64Array(t),f=new Float64Array(t),p=new Float64Array(t),S=new Float64Array(t),y=new Float64Array(t),d=new Float64Array(t);let x=0;if(e)for(const m of n)x+=m.dies?.length??0;const g=e?Array.from({length:t},()=>new Float64Array(x)):[],u=E(l),b=new Float64Array(t),M=Math.max(500,Math.floor(R/Math.max(1,t)));let h=0;for(const m of n){S.fill(0),y.fill(0),d.fill(0);for(const c of m.dies??[])if(++h>=M&&(h=0,yield),!!v(c)){u(c,b);for(let a=0;a<t;a++){const w=b[a];Number.isFinite(w)&&(i[a]++,r[a]+=w,o[a]+=w*w,S[a]++,y[a]+=w,d[a]+=w*w,e&&(g[a][i[a]-1]=w))}}for(let c=0;c<t;c++){const a=S[c];if(a<2)continue;const w=y[c]/a,k=(d[c]-a*w*w)/(a-1);f[c]+=(a-1)*Math.max(0,k),p[c]+=a-1}}const N=new Map;for(let m=0;m<t;m++){if(i[m]===0)continue;const c=l[m];N.set(c,{n:i[m],sum:r[m],sumSq:o[m],withinNumerator:f[m],withinDenominator:p[m]}),e&&e.set(c,g[m].subarray(0,i[m]))}return N}function W(n,s,e){return C($(n,s,e))}function L(n,s,e,l){const{n:t,sum:i,sumSq:r,withinNumerator:o,withinDenominator:f}=l,p=i/t,S=t>=2?Math.max(0,(r-t*p*p)/(t-1)):0,y=Math.sqrt(S),d=f>0?Math.sqrt(o/f):NaN;let x=null,g=null,u=null,b=null;if(e){const{lsl:M,usl:h}=e,N=h-M;u=y>0?N/(6*y):null,b=y>0?Math.min((h-p)/(3*y),(p-M)/(3*y)):null,x=Number.isFinite(d)&&d>0?N/(6*d):null,g=Number.isFinite(d)&&d>0?Math.min((h-p)/(3*d),(p-M)/(3*d)):null}return{testNumber:n,label:_(s,n),unit:s.unit,...I(s),hasSpec:e!==void 0,lsl:e?.lsl,usl:e?.usl,...e?{limitBasis:e.basis}:{},mean:p,stdOverall:y,stdWithin:d,n:t,cp:x,cpk:g,pp:u,ppk:b}}function q(n){return n.sort((s,e)=>s.hasSpec!==e.hasSpec?s.hasSpec?-1:1:s.hasSpec?s.ppk===null&&e.ppk===null?0:s.ppk===null?1:e.ppk===null?-1:s.ppk-e.ppk:e.stdOverall-s.stdOverall)}export function buildCapabilityData(n,s){return C(buildCapabilityDataSteps(n,s))}export function*buildCapabilityDataSteps(n,s){return(yield*pooledTestStatsSteps(n,s)).capability.slice()}const F=new Map,Y=4,B=new WeakMap;let K=1;function U(n,s){const e=[];for(const t of n){const i=t.dies;if(!i){e.push(0);continue}let r=B.get(i);r===void 0&&(r=K++,B.set(i,r)),e.push(r)}const l=s.filter(t=>t.testNumber!==void 0&&O(t)).map(t=>`${t.testNumber}${t.testType??"P"}${t.limitLow??""}${t.limitHigh??""}${t.specLow??""}${t.specHigh??""}${t.name??""}${t.unit??""}`);return`${e.join(",")}${l.join("")}`}export function clearPooledTestStatsCache(){F.clear();for(const n of T.values())n.work.return(void 0);T.clear()}export function*pooledTestStatsSteps(n,s){const e=U(n,s),l=F.get(e);if(l)return F.delete(e),F.set(e,l),l;let t=T.get(e);t||(t={work:G(n,s,e),callers:0},T.set(e,t));const i=t;i.callers++;try{for(;;){if(i.result)return i.result;const r=i.work.next();if(r.done)return i.result=r.value,T.delete(e),r.value;yield}}finally{i.callers--,!i.result&&i.callers===0&&(i.work.return(void 0),T.get(e)===i&&T.delete(e))}}const T=new Map;function*G(n,s,e){const l={stats:new Map,specTally:new Map,capability:[]},{defByTestNumber:t,specByTest:i}=A(s);if(t.size===0)return l;const r=new Map,o=yield*$(n,t,r),f=new Map,p=new Map,S=[],y=new Map;let d;for(const g of n){const u=H((g.dies??[]).filter(b=>v(b)));if(u){d??=u.by;for(const[b,M]of u.counts)y.set(b,(y.get(b)??0)+M)}}for(const g of s){yield;const u=g.testNumber;if(u===void 0)continue;const b=o.get(u);if(!b||b.n===0||!t.has(u))continue;const M=r.get(u);r.delete(u),V(g)&&p.set(u,{n:M.length,fail:P(M,g)});const h=z(M);f.set(u,h);const N=i.get(u),m=L(u,g,N,b);let c;if(N){const w=N.usl-N.lsl;c=k=>(k-N.lsl)/w}else{const w=h.min,k=h.max-w;c=k>0?D=>(D-w)/k:()=>.5}const a=y.get(u);S.push({...m,...a&&d?{excluded:{count:a,limitSet:d}}:{},min:c(h.min),q1:c(h.q1),median:c(h.median),q3:c(h.q3),max:c(h.max)})}const x={stats:f,specTally:p,capability:q(S)};return F.set(e,x),F.size>Y&&F.delete(F.keys().next().value),x}export function buildCapabilityFigures(n,s){const{defByTestNumber:e,specByTest:l}=A(s);if(e.size===0)return[];const t=W(n,e,null),i=[];for(const[r,o]of t)o.n!==0&&i.push(L(r,e.get(r),l.get(r),o));return q(i)}export function poolCapabilityFigures(n,s){const{defByTestNumber:e,specByTest:l}=A(s),t=new Map;for(const r of n)for(const o of r){if(!e.has(o.testNumber)||o.n===0)continue;let f=t.get(o.testNumber);f||(f={n:0,sum:0,sumSq:0,withinNumerator:0,withinDenominator:0},t.set(o.testNumber,f));const p=o.stdOverall*o.stdOverall;f.n+=o.n,f.sum+=o.n*o.mean,f.sumSq+=(o.n-1)*p+o.n*o.mean*o.mean,o.n>=2&&(f.withinNumerator+=(o.n-1)*p,f.withinDenominator+=o.n-1)}const i=[];for(const[r,o]of t)i.push(L(r,e.get(r),l.get(r),o));return q(i)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{seededRandom as et}from"./math.js";import{ringOf as nt}from"../core/classify.js";import{compassBucket as it,sectorCompassNames as st}from"./regions.js";import{getDieKey as ot,gridKey as N}from"../core/dies.js";import{findConnectedComponents as rt,LargestComponentSizer as at}from"./connectedComponents.js";function ct(t,n){return st(16)[it(t,n,16)]}function lt(t){if(t.length<2)return 0;const n=[...t].sort((s,e)=>s-e);let i=n[0]+2*Math.PI-n[n.length-1];for(let s=1;s<n.length;s++)i=Math.max(i,n[s]-n[s-1]);return 2*Math.PI-i}function ut(t,n,i,s){const e=s!==void 0?Math.abs(s):0;return t<=.01&&(n>=.25||e>=2||i>=.1)?"unusual":t<=.05&&(n>=.15||e>=1||i>=.03)?"notable":"info"}const ft=99,ht=9999,j=10;class mt{sizer;failCount;maxima=[];random;order;failing;constructor(n,i,s,e){this.sizer=n,this.failCount=s,this.random=et(e),this.order=new Int32Array(i);for(let f=0;f<i;f++)this.order[f]=f;this.failing=new Uint8Array(i)}at(n){const{order:i,failing:s,failCount:e,random:f}=this,m=i.length;for(;this.maxima.length<=n;){for(let r=0;r<e;r++){const M=r+Math.floor(f()*(m-r)),g=i[r];i[r]=i[M],i[M]=g,s[i[r]]=1}this.maxima.push(this.sizer.largest(s));for(let r=0;r<e;r++)s[i[r]]=0}return this.maxima[n]}pValue(n,i){let s=0;for(let e=0;e<i;e++)if(this.at(e)>=n&&++s===j)return j/(e+1);return(1+s)/(1+i)}}function gt(t){let n=0,i=0;for(let s=0;s<t.length;s++){let e=Math.imul(t[s].x|0,2654435761)^Math.imul(t[s].y|0,2246822507);e=Math.imul(e^e>>>16,2146121005),e=Math.imul(e^e>>>15,2221713035),n=n+(e^e>>>16)|0,i=i+Math.imul(e,668265263)+374761393|0}return`${t.length}:${n>>>0}:${i>>>0}`}function pt(t,n){return t<=20?t:Math.min(n,Math.ceil(20*1.05**Math.ceil(Math.log(t/20)/Math.log(1.05))))}const dt=new Map,yt=new Map;function G(t,n,i,s){let e=t.get(n);return e===void 0&&(e=s(),t.set(n,e),t.size>i&&t.delete(t.keys().next().value)),e}function Mt(t,n,i,s){const e=t.length,f=Math.min(ht,Math.max(ft,Math.ceil(1/s))),m=gt(t),r=pt(n,e),M=G(yt,`${m}:${r}`,16,()=>{const g=G(dt,m,4,()=>new at([...t].sort((v,d)=>v.y-d.y||v.x-d.x))),[,P,R]=m.split(":").map(Number);return new mt(g,e,r,(P^Math.imul(R,739982445)^Math.imul(r+1,2246822507))>>>0)});return i.map(g=>M.pValue(g,f))}export function buildClusterFindings(t,n,i){const{passBins:s,significanceLevel:e,minimumEffectSize:f,minimumRelativeEffect:m,minimumSampleSize:r,minimumClusterSize:M,ringCount:g}=i,P=new Set(s);if(t.length<r)return[];const R=o=>{const a=o.hbin??o.sbin;return a===void 0||!P.has(a)},v=i.isFailingDie??R,d=t.filter(v),x=d.length/t.length;if(d.length===0)return[];if(x===1&&f>0&&m>0)return[];const D=t[0],L=D?D.width:10,V=D?D.height:10,X=Math.max(L,V)*1.5,I=new Map;for(const o of t)I.set(N(o.x,o.y),o);const K=Math.ceil(X/L),T=Math.ceil(X/V),Z=rt(d),O=[],E=[],Y=n.center.x,k=n.center.y,q=n.radius;for(const o of Z){if(o.length<M)continue;const a=new Set(o.map(u=>N(u.x,u.y)));for(const u of o)for(let h=-T;h<=T;h++)for(let z=-K;z<=K;z++){const w=N(u.x+z,u.y+h);if(a.has(w))continue;const F=I.get(w);F&&Math.hypot(F.physX-u.physX,F.physY-u.physY)<=X&&a.add(w)}const l=[...a].map(u=>I.get(u)).filter(Boolean),p=o.length,b=l.length;if(b<r)continue;const S=p/b,$=S-x,y=x>0?$/x:void 0;($>=f||y!==void 0&&y>=m)&&E.push({component:o,k:p,clusterRate:S,delta:$,relativeDelta:y})}if(!E.length)return[];const H=Mt(t,d.length,E.map(o=>o.k),e);for(let o=0;o<E.length;o++){const{component:a,k:l,clusterRate:p,delta:b,relativeDelta:S}=E[o],$=H[o],y=$;if(y>e)continue;const A=a.reduce((c,C)=>c+C.physX,0)/l,u=a.reduce((c,C)=>c+C.physY,0)/l;let h=a[0],z=1/0;for(const c of a){const C=Math.hypot(c.physX-A,c.physY-u);C<z&&(z=C,h=c)}const w=lt(a.map(c=>Math.atan2(c.physY-k,c.physX-Y)))*180/Math.PI,B=a.filter(c=>nt(c.physX-Y,c.physY-k,q,g)===g).length>l/2&&w<120,U=B?"edge-arc":"cluster",_=ct(A-Y,u-k),J=B?`Edge arc ~${_}`:`Cluster at (${h.x}, ${h.y})`,Q=l/t.length,W=ut(y,b,Q,S),tt=a.map(c=>ot(c));O.push({id:`${U}:${h.x},${h.y}`,level:"wafer",severity:W,variable:{kind:"yield",label:"Yield"},comparison:{family:U,left:J,right:"Rest of wafer"},effect:{direction:"lower",absoluteDelta:-b,relativeDelta:S!==void 0?-S:void 0,effectSize:b},stats:{method:"permutation",pValue:$,adjustedPValue:y,sampleSizeLeft:l,sampleSizeRight:t.length-l},summary:B?`Edge arc near ${_}: ${l} contiguous failing dies (${(p*100).toFixed(0)}% vs ${(x*100).toFixed(0)}% background)`:`Failure cluster at (${h.x}, ${h.y}): ${l} contiguous failing dies (${(p*100).toFixed(0)}% vs ${(x*100).toFixed(0)}% background)`,highlight:{kind:"dies",dieKeys:tt}})}return O.sort((o,a)=>{const l=o.stats.pValue??1,p=a.stats.pValue??1;return l!==p?l-p:Math.abs(a.effect.effectSize??0)-Math.abs(o.effect.effectSize??0)})}
|
|
@@ -11,4 +11,23 @@ import type { PositionedDie } from '../core/dies.js';
|
|
|
11
11
|
* case this is for, and it is also exactly the case that blows a call stack.
|
|
12
12
|
*/
|
|
13
13
|
export declare function findConnectedComponents(failing: readonly PositionedDie[]): PositionedDie[][];
|
|
14
|
+
/**
|
|
15
|
+
* The size of the largest 8-connected group of failing dies, for many failure sets over one die layout:
|
|
16
|
+
* a permutation null sizes the largest group on every shuffle. The neighbours of each die are found once
|
|
17
|
+
* (by the same steps as {@link findConnectedComponents}) and held as index lists, and
|
|
18
|
+
* each call is a flood fill over typed arrays, with no maps, sets or allocation.
|
|
19
|
+
*/
|
|
20
|
+
export declare class LargestComponentSizer {
|
|
21
|
+
private readonly start;
|
|
22
|
+
private readonly list;
|
|
23
|
+
private readonly seen;
|
|
24
|
+
private readonly stack;
|
|
25
|
+
private stamp;
|
|
26
|
+
constructor(dies: readonly {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
}[]);
|
|
30
|
+
/** The largest group among the dies with `failing[i]` set (indices as given to the constructor). */
|
|
31
|
+
largest(failing: Uint8Array): number;
|
|
32
|
+
}
|
|
14
33
|
//# sourceMappingURL=connectedComponents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{gridKey as
|
|
1
|
+
import{gridKey as m}from"../core/dies.js";const A=[-1,0,1,-1,1,-1,0,1],k=[-1,-1,-1,0,0,1,1,1];export function findConnectedComponents(h){if(h.length===0)return[];const o=S(h);if(o)return o;const s=new Map;for(const n of h)s.set(m(n.x,n.y),n);const u=new Set,c=[];for(const n of h){const t=m(n.x,n.y);if(u.has(t))continue;const r=[],i=[n];for(u.add(t);i.length>0;){const p=i.pop();r.push(p);for(let f=0;f<8;f++){const d=m(p.x+A[f],p.y+k[f]);if(u.has(d))continue;const y=s.get(d);y&&(u.add(d),i.push(y))}}c.push(r)}return c}function S(h){const o=h.length;let s=1/0,u=-1/0,c=1/0,n=-1/0;for(let e=0;e<o;e++){const{x:l,y:a}=h[e];if(!Number.isInteger(l)||!Number.isInteger(a))return;l<s&&(s=l),l>u&&(u=l),a<c&&(c=a),a>n&&(n=a)}const t=u-s+1,r=n-c+1;if(t*r>4*o+1024||t*r>1<<26)return;const i=(e,l)=>(e-s)*r+(l-c),p=new Int32Array(t*r);for(let e=0;e<o;e++)p[i(h[e].x,h[e].y)]=e+1;const f=new Uint8Array(t*r),d=[],y=[];for(let e=0;e<o;e++){const l=h[e],a=i(l.x,l.y);if(f[a])continue;f[a]=1;const C=[];for(y.push(l);y.length>0;){const I=y.pop();C.push(I);for(let x=0;x<8;x++){const b=I.x+A[x],g=I.y+k[x];if(b<s||b>u||g<c||g>n)continue;const w=i(b,g);f[w]||p[w]===0||(f[w]=1,y.push(h[p[w]-1]))}}d.push(C)}return d}export class LargestComponentSizer{start;list;seen;stack;stamp=0;constructor(o){const s=o.length,u=new Map;for(let t=0;t<s;t++)u.set(m(o[t].x,o[t].y),t);const c=new Int32Array(s+1),n=[];for(let t=0;t<s;t++){c[t]=n.length;for(let r=0;r<8;r++){const i=u.get(m(o[t].x+A[r],o[t].y+k[r]));i!==void 0&&n.push(i)}}c[s]=n.length,this.start=c,this.list=Int32Array.from(n),this.seen=new Int32Array(s),this.stack=new Int32Array(s)}largest(o){const{start:s,list:u,seen:c,stack:n}=this,t=++this.stamp;let r=0;for(let i=0;i<o.length;i++){if(!o[i]||c[i]===t)continue;c[i]=t;let p=0;n[p++]=i;let f=0;for(;p>0;){const d=n[--p];f++;for(let y=s[d];y<s[d+1];y++){const e=u[y];o[e]&&c[e]!==t&&(c[e]=t,n[p++]=e)}}f>r&&(r=f)}return r}}
|
|
@@ -57,6 +57,16 @@ export interface CorrelationMatrix {
|
|
|
57
57
|
of: number;
|
|
58
58
|
used: number;
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Present only when the matrix covers a selection of the tests — see
|
|
62
|
+
* `CORRELATION_TEST_BUDGET`. `of` is how many parametric tests there were, `used`
|
|
63
|
+
* how many entered the matrix. Same rule as `sample`: a surface showing the matrix
|
|
64
|
+
* says so (`correlationSampleNote`).
|
|
65
|
+
*/
|
|
66
|
+
testSample?: {
|
|
67
|
+
of: number;
|
|
68
|
+
used: number;
|
|
69
|
+
};
|
|
60
70
|
}
|
|
61
71
|
/**
|
|
62
72
|
* Dies read before `buildCorrelationMatrix` starts sampling.
|
|
@@ -72,11 +82,33 @@ export interface CorrelationMatrix {
|
|
|
72
82
|
* already invisible at two decimal places.
|
|
73
83
|
*/
|
|
74
84
|
export declare const CORRELATION_DIE_BUDGET = 25000;
|
|
75
|
-
/** The sentence a panel puts next to a sampled matrix. */
|
|
76
|
-
export declare function correlationSampleNote(sample: CorrelationMatrix['sample']): string | undefined;
|
|
77
85
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
86
|
+
* Tests entering the pairwise pass of `buildCorrelationMatrix`.
|
|
87
|
+
*
|
|
88
|
+
* The pass is quadratic in tests: 6 accumulators per pair and one cell per ordered
|
|
89
|
+
* pair. A real test program reaches thousands of parametric tests — at 2,002 the
|
|
90
|
+
* matrix took 38 s to build, at 15,000 (112M pairs, ~5 GB of accumulators) it never
|
|
91
|
+
* finished. The panel shows at most 100 tests (20 by default), the strongest pairs
|
|
92
|
+
* first, so the candidates are chosen before pairing instead of after.
|
|
93
|
+
*
|
|
94
|
+
* 300 tests is 44,850 pairs: about a second and a half on a 3,000-die wafer.
|
|
95
|
+
*/
|
|
96
|
+
export declare const CORRELATION_TEST_BUDGET = 300;
|
|
97
|
+
/**
|
|
98
|
+
* Pair updates (test pairs × dies) the pairwise pass may make. Within it the die
|
|
99
|
+
* sample is `CORRELATION_DIE_BUDGET`; past it the dies are thinned, evenly, to fit:
|
|
100
|
+
* 300 tests (44,850 pairs) read about 5,600 dies, where the standard error of r is
|
|
101
|
+
* ~0.013 — while 300 tests over the full 25,000-die budget was 1.1×10⁹ updates and
|
|
102
|
+
* 12 s in a browser.
|
|
103
|
+
*/
|
|
104
|
+
export declare const CORRELATION_WORK_BUDGET = 250000000;
|
|
105
|
+
/** The sentence a panel puts next to a matrix built from a sample of the dies or the tests. */
|
|
106
|
+
export declare function correlationSampleNote(m: Pick<CorrelationMatrix, 'sample' | 'testSample'>): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Pearson correlation matrix for the parametric tests in `testDefs` across the
|
|
109
|
+
* dies in `dies` — every test up to `CORRELATION_TEST_BUDGET` (above it, the
|
|
110
|
+
* chosen ones: `testSample`), every die up to `CORRELATION_DIE_BUDGET` (above it,
|
|
111
|
+
* an even spread: `sample`).
|
|
80
112
|
*
|
|
81
113
|
* Running-accumulator algorithm: one die-walk, 6 Float64 accumulators per
|
|
82
114
|
* upper-triangle pair (count, sumX, sumY, sumXX, sumYY, sumXY). No pair
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dieHasValues as
|
|
1
|
+
import{dieHasValues as O,testValue as _}from"../core/dieTable.js";import{isParametricTest as E}from"../renderer/buildWaferMap.js";import{markedTestLabel as P,derivedFields as k}from"../renderer/testLabel.js";export function pearsonFromSums(e,s,f,m,u,d){if(e<3)return null;const g=s/e,i=f/e,a=d/e-g*i,p=m/e-g*g,b=u/e-i*i,M=Math.sqrt(p*b);return M===0?null:Math.max(-1,Math.min(1,a/M))}export function pearsonOfPairs(e){let s=0,f=0,m=0,u=0,d=0,g=0;for(let i=0;i<e.length;i++){const{x:a,y:p}=e[i];!Number.isFinite(a)||!Number.isFinite(p)||(s++,f+=a,m+=p,u+=a*a,d+=p*p,g+=a*p)}return{r:pearsonFromSums(s,f,m,u,d,g),n:s}}export const CORRELATION_DIE_BUDGET=25e3;function v(e,s){const f=[],m=e/s;for(let u=0;u<s;u++)f.push(Math.floor(u*m));return f}export const CORRELATION_TEST_BUDGET=300,CORRELATION_WORK_BUDGET=25e7;export function correlationSampleNote(e){const s=[];return e.testSample&&s.push(`Among the ${e.testSample.used.toLocaleString()} of ${e.testSample.of.toLocaleString()} tests with the most dies outside their limits, then the widest spread`),e.sample&&s.push(`${s.length?"from":"From"} a ${e.sample.used.toLocaleString()}-die sample of ${e.sample.of.toLocaleString()}, spread evenly across the lot`),s.length?s.join(", "):void 0}function z(e,s,f,m){const u=e.length,d=new Float64Array(u),g=new Float64Array(u),i=new Float64Array(u),a=new Float64Array(u),p=e.map(r=>s.get(r.testNumber)?.limitLow),b=e.map(r=>s.get(r.testNumber)?.limitHigh);for(const r of f)for(let n=0;n<u;n++){const t=_(r,e[n].testNumber);t===void 0||!Number.isFinite(t)||(d[n]++,g[n]+=t,i[n]+=t*t,(p[n]!==void 0&&t<p[n]||b[n]!==void 0&&t>b[n])&&a[n]++)}const M=r=>{if(d[r]<3)return-1;const n=g[r]/d[r],t=Math.sqrt(Math.max(0,i[r]/d[r]-n*n)),c=p[r]!==void 0&&b[r]!==void 0?b[r]-p[r]:Math.abs(n);return c>0?t/c:0},h=e.map((r,n)=>({i:n,fails:d[n]<3?-1:a[n],spread:M(n)}));return h.sort((r,n)=>n.fails-r.fails||n.spread-r.spread||r.i-n.i),h.slice(0,m).map(r=>r.i).sort((r,n)=>r-n).map(r=>e[r])}function D(e){return e.filter(s=>s.testNumber!==void 0&&E(s)).map(s=>({testNumber:s.testNumber,label:P(s,s.testNumber),unit:s.unit,...k(s)}))}export function buildCorrelationMatrix(e,s){const f=D(s);if(f.length<2)return{tests:f,cells:[]};const m=e.filter(O),d=m.length>CORRELATION_DIE_BUDGET?v(m.length,CORRELATION_DIE_BUDGET).map(o=>m[o]):m,g=f.length>CORRELATION_TEST_BUDGET,i=g?z(f,new Map(s.flatMap(o=>o.testNumber===void 0?[]:[[o.testNumber,o]])),d,CORRELATION_TEST_BUDGET):f,a=i.length*(i.length-1)/2,p=Math.max(1,Math.floor(CORRELATION_WORK_BUDGET/Math.max(1,a))),b=d.length>p?v(d.length,p).map(o=>d[o]):d,M=b.length<m.length,h=i.length,r=i.map(o=>o.testNumber),n=h*(h-1)/2,t=new Float64Array(n),c=new Float64Array(h),x=new Float64Array(n),N=new Float64Array(n),y=new Float64Array(n),w=new Float64Array(n),R=new Float64Array(n);function Y(o,l){return o*h-(o*(o+1)>>1)+(l-o-1)}const L=new Float64Array(h),T=new Uint8Array(h);for(const o of b){T.fill(0);for(let l=0;l<h;l++){const I=_(o,r[l]);I!==void 0&&Number.isFinite(I)&&(L[l]=I,T[l]=1)}for(let l=0;l<h;l++){if(!T[l])continue;c[l]++;const I=L[l];for(let F=l+1;F<h;F++){if(!T[F])continue;const A=L[F],S=Y(l,F);t[S]++,x[S]+=I,N[S]+=A,y[S]+=I*I,w[S]+=A*A,R[S]+=I*A}}}const C=o=>pearsonFromSums(t[o],x[o],N[o],y[o],w[o],R[o]),X=[];for(let o=0;o<h;o++)for(let l=0;l<h;l++){if(l===o){X.push({xIndex:l,yIndex:o,r:1,n:c[l]});continue}const I=Math.min(l,o),F=Math.max(l,o),A=Y(I,F);X.push({xIndex:l,yIndex:o,r:C(A),n:t[A]})}return{tests:i,cells:X,...M?{sample:{of:m.length,used:b.length}}:{},...g?{testSample:{of:f.length,used:i.length}}:{}}}export function filterCorrelationMatrix(e,{threshold:s=.3,minTests:f=6,maxTests:m=20}={}){const u=[];let d=0,g=0,i=null;for(const t of e.cells){if(t.xIndex>=t.yIndex||t.r===null)continue;const c=Math.abs(t.r);u.push({xi:t.xIndex,yi:t.yIndex,absR:c}),(i===null||c>Math.abs(i.r))&&(i={xLabel:e.tests[t.xIndex].label,yLabel:e.tests[t.yIndex].label,r:t.r})}u.sort((t,c)=>c.absR-t.absR);const a=new Set;for(const{xi:t,yi:c,absR:x}of u){const N=x<s;a.size>=m||N&&a.size>=f||(a.add(t),a.size<m&&a.add(c))}if(a.size<Math.min(f,e.tests.length))for(let t=0;t<e.tests.length&&a.size<Math.min(m,f,e.tests.length);t++)a.add(t);const p=(()=>{const t=Array.from(a),c=new Map,x=new Map;for(const{xi:y,yi:w,absR:R}of u)!a.has(y)||!a.has(w)||(c.set(y,(c.get(y)??0)+R),c.set(w,(c.get(w)??0)+R),x.set(y,(x.get(y)??0)+1),x.set(w,(x.get(w)??0)+1));const N=y=>(x.get(y)??0)>0?c.get(y)/x.get(y):0;return t.sort((y,w)=>N(w)-N(y))})(),b=p.map(t=>e.tests[t]),M=new Map(p.map((t,c)=>[t,c])),h=new Set(b.map(t=>t.testNumber)),r=e.cells.filter(t=>h.has(e.tests[t.xIndex].testNumber)&&h.has(e.tests[t.yIndex].testNumber)).map(t=>({xIndex:M.get(t.xIndex),yIndex:M.get(t.yIndex),r:t.r,n:t.n}));let n=0;for(const{xi:t,yi:c,absR:x}of u)a.has(t)&&a.has(c)?x>=.7?d++:x>=.4&&g++:x<s&&n++;return{matrix:{tests:b,cells:r},strongPairs:d,moderatePairs:g,hiddenWeakPairs:n,strongestPair:i}}
|
|
@@ -31,7 +31,7 @@ export declare function visibleFindings<T extends {
|
|
|
31
31
|
export declare function findingPatternKey(f: StatsFinding): string;
|
|
32
32
|
/** A findings list as the reader sees it: patterns with the findings they explain, then the rest grouped by region. */
|
|
33
33
|
export interface ArrangedFindings {
|
|
34
|
-
/** Spatial-pattern findings, each with the findings in the list it names as supporting detail. */
|
|
34
|
+
/** Spatial-pattern findings, each with the findings in the list it names as supporting detail, most severe first. */
|
|
35
35
|
patterns: Array<{
|
|
36
36
|
finding: StatsFinding;
|
|
37
37
|
children: StatsFinding[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function s(e){return Array.isArray(e)?e:[e]}export function filterFindings(e,i){let t=e.findings;if(i.severity!==void 0){const r=new Set(s(i.severity));t=t.filter(
|
|
1
|
+
function s(e){return Array.isArray(e)?e:[e]}export function filterFindings(e,i){let t=e.findings;if(i.severity!==void 0){const r=new Set(s(i.severity));t=t.filter(o=>r.has(o.severity))}if(i.kind!==void 0){const r=new Set(s(i.kind));t=t.filter(o=>r.has(o.variable.kind))}if(i.family!==void 0){const r=new Set(s(i.family));t=t.filter(o=>r.has(o.comparison.family))}if(i.level!==void 0){const r=new Set(s(i.level));t=t.filter(o=>r.has(o.level))}return t}export function visibleFindings(e){const i=new Set(e.flatMap(t=>t.absorbedIds??[]));return e.filter(t=>!i.has(t.id))}export function findingPatternKey(e){return[e.variable.kind,e.variable.index??"",e.variable.bin??"",e.comparison.family,e.comparison.left,e.effect.direction].join("|")}const l={unusual:0,notable:1,info:2};export function arrangeFindings(e){const i=e.filter(n=>n.comparison.family==="spatial-pattern"),t=new Set([...i.flatMap(n=>n.relatedIds??[]),...e.flatMap(n=>n.absorbedIds??[])]),r=(n,a)=>l[n.severity]-l[a.severity],o=i.map(n=>({finding:n,children:e.filter(a=>n.relatedIds?.includes(a.id)).sort(r)})),d=new Map;for(const n of e){if(n.comparison.family==="spatial-pattern"||t.has(n.id))continue;const a=`${n.comparison.family}\0${n.comparison.left}`;d.set(a,[...d.get(a)??[],n])}const c=[...d.entries()].map(([n,a])=>{const f=[...a].sort(r),[p,y]=n.split("\0");return{family:p,left:y,worst:f[0].severity,findings:f}});return c.sort((n,a)=>l[n.worst]-l[a.worst]),{patterns:o,groups:c}}
|
|
@@ -6,4 +6,12 @@ import type { StatsFinding } from './types.js';
|
|
|
6
6
|
* line of their own.
|
|
7
7
|
*/
|
|
8
8
|
export declare function formatFindingTooltip(finding: StatsFinding): string;
|
|
9
|
+
/**
|
|
10
|
+
* What a finding measured, for a column headed "Metric": the variable's label,
|
|
11
|
+
* and for a test which statistic of it. A test's mean and its limit fail rate
|
|
12
|
+
* share a label, and without the word a rate reads as a shift in the values.
|
|
13
|
+
*/
|
|
14
|
+
export declare function findingMetricLabel(finding: Pick<StatsFinding, 'variable'>): string;
|
|
15
|
+
/** True when the finding compares a proportion (a fraction of dies), so its `absoluteDelta` is a fraction. */
|
|
16
|
+
export declare function isProportionFinding(finding: Pick<StatsFinding, 'variable'>): boolean;
|
|
9
17
|
//# sourceMappingURL=findingText.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{derivedTestNote as
|
|
2
|
-
${
|
|
1
|
+
import{derivedTestNote as n}from"../renderer/testLabel.js";export function formatFindingTooltip(e){const t=n(e.variable);return t?`${e.summary}
|
|
2
|
+
${t}`:e.summary}export function findingMetricLabel(e){const{kind:t,label:i,measure:r}=e.variable;return t!=="test"?i:r==="limitFailRate"?`${i} limit fail rate`:`${i} mean`}export function isProportionFinding(e){const{kind:t,measure:i}=e.variable;return t==="yield"||t==="hardBin"||t==="softBin"||t==="functionalTest"||t==="test"&&i==="limitFailRate"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export { analyzeWaferMap } from './analyzeWaferMap.js';
|
|
3
|
-
export { analyzeWaferLot } from './analyzeWaferLot.js';
|
|
3
|
+
export { analyzeWaferLot, analyzeWaferLotAsync } from './analyzeWaferLot.js';
|
|
4
|
+
export type { AnalyzeWaferLotAsyncOptions } from './analyzeWaferLot.js';
|
|
4
5
|
export { filterFindings, visibleFindings } from './filterFindings.js';
|
|
5
6
|
export type { FindingsFilter } from './filterFindings.js';
|
|
6
7
|
export type { PatternLabel, PatternClassification, PatternFeatures } from './patternClassification.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types.js";export{analyzeWaferMap}from"./analyzeWaferMap.js";export{analyzeWaferLot}from"./analyzeWaferLot.js";export{filterFindings,visibleFindings}from"./filterFindings.js";export{setReportOpener}from"./renderFindingsReport.js";export{renderWaferReportHtml,renderLotReportHtml}from"./renderSummaryReport.js";export{buildFacetTable,facetValueOf,attributeLabel,FACET_NONE_VALUE}from"./facets.js";export{mergeTestDefs}from"./mergeTestDefs.js";export{readPlotsFile,writePlotsFile}from"./plotSpec.js";
|
|
1
|
+
export*from"./types.js";export{analyzeWaferMap}from"./analyzeWaferMap.js";export{analyzeWaferLot,analyzeWaferLotAsync}from"./analyzeWaferLot.js";export{filterFindings,visibleFindings}from"./filterFindings.js";export{setReportOpener}from"./renderFindingsReport.js";export{renderWaferReportHtml,renderLotReportHtml}from"./renderSummaryReport.js";export{buildFacetTable,facetValueOf,attributeLabel,FACET_NONE_VALUE}from"./facets.js";export{mergeTestDefs}from"./mergeTestDefs.js";export{readPlotsFile,writePlotsFile}from"./plotSpec.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{benjaminiHochberg as v,mannKendall as b}from"./math.js";import{fmt as y}from"../renderer/fmt.js";export const DRIFT_MIN_WAFERS=5;const M=2,N=.5,x=5,S=1;function _(m){const d=[],i=m.map(n=>({waferIndex:n.waferIndex,y:n.summary.stats.yieldPercent})).filter(n=>n.y!==null&&n.y!==void 0);if(i.length>=DRIFT_MIN_WAFERS){const n=b(i.map(e=>e.y));n&&d.push({kind:"yield",label:"Yield",values:i.map(e=>e.y),waferIndices:i.map(e=>e.waferIndex),mk:n})}const r=new Map;for(const{waferIndex:n,summary:e}of m)for(const t of e.stats.perTestStats??[]){if(!Number.isFinite(t.mean)||!(t.count>0))continue;const l=r.get(t.testNumber)??{label:t.label,rows:[]};l.rows.push({waferIndex:n,mean:t.mean,n:t.count,sd:t.stddev}),r.set(t.testNumber,l)}for(const[n,{label:e,rows:t}]of r){if(t.length<DRIFT_MIN_WAFERS)continue;const l=b(t.map(s=>s.mean));if(!l)continue;const o=t.reduce((s,u)=>s+Math.max(0,u.n-1),0),f=o>0?Math.sqrt(t.reduce((s,u)=>s+Math.max(0,u.n-1)*u.sd**2,0)/o):0;d.push({kind:"test",testNumber:n,label:e,values:t.map(s=>s.mean),waferIndices:t.map(s=>s.waferIndex),sigma:f,mk:l})}return d}export function buildDriftFindings(m,d){const i=_(m);if(!i.length)return[];const r=v(i.map(e=>e.mk.pValue)),n=[];return i.forEach((e,t)=>{if(r[t]>d)return;const{slope:l,intercept:o,n:f}=e.mk,s=o,a=o+l*(f-1)-s,p=a>0,h=e.kind==="test"&&e.sigma&&e.sigma>0?Math.abs(a)/e.sigma:void 0;if(e.kind==="yield"?Math.abs(a)<M:h===void 0||h<N)return;const g=(e.kind==="yield"?Math.abs(a)>=x:(h??0)>=S)&&r[t]<=.01?"unusual":"notable",k=p?"rises":"falls",c={first:e.values[0],last:e.values[e.values.length-1]},I=e.kind==="yield"?`${c.first.toFixed(1)}% \u2192 ${c.last.toFixed(1)}%`:`${y(c.first)} \u2192 ${y(c.last)}`,w=e.kind==="yield"?"on successive wafers":"across the wafers";n.push({id:e.kind==="yield"?"drift:yield":`drift:test:${e.testNumber}`,level:"inter-wafer",severity:g,variable:e.kind==="yield"?{kind:"yield",label:"Yield"}:{kind:"test",index:e.testNumber,label:e.label},comparison:{family:"wafer",left:"Wafers in input order",right:"a constant level"},effect:{direction:p?"higher":"lower",absoluteDelta:e.kind==="yield"?a/100:a,...e.kind==="yield"?{}:{relativeDelta:s!==0?a/Math.abs(s):void 0},effectSize:e.kind==="yield"?a/100:a/(e.sigma||1)},stats:{method:"mann-kendall",pValue:e.mk.pValue,adjustedPValue:r[t],sampleSizeLeft:f,sampleSizeRight:0},summary:`${e.label} ${k} ${w}: ${I} over ${f} wafers (input order)`,highlight:{kind:"wafer",waferIndices:e.waferIndices}})}),n}
|
|
1
|
+
import{benjaminiHochberg as v,mannKendall as b}from"./math.js";import{fmt as y}from"../renderer/fmt.js";export const DRIFT_MIN_WAFERS=5;const M=2,N=.5,x=5,S=1;function _(m){const d=[],i=m.map(n=>({waferIndex:n.waferIndex,y:n.summary.stats.yieldPercent})).filter(n=>n.y!==null&&n.y!==void 0);if(i.length>=DRIFT_MIN_WAFERS){const n=b(i.map(e=>e.y));n&&d.push({kind:"yield",label:"Yield",values:i.map(e=>e.y),waferIndices:i.map(e=>e.waferIndex),mk:n})}const r=new Map;for(const{waferIndex:n,summary:e}of m)for(const t of e.stats.perTestStats??[]){if(!Number.isFinite(t.mean)||!(t.count>0))continue;const l=r.get(t.testNumber)??{label:t.label,rows:[]};l.rows.push({waferIndex:n,mean:t.mean,n:t.count,sd:t.stddev}),r.set(t.testNumber,l)}for(const[n,{label:e,rows:t}]of r){if(t.length<DRIFT_MIN_WAFERS)continue;const l=b(t.map(s=>s.mean));if(!l)continue;const o=t.reduce((s,u)=>s+Math.max(0,u.n-1),0),f=o>0?Math.sqrt(t.reduce((s,u)=>s+Math.max(0,u.n-1)*u.sd**2,0)/o):0;d.push({kind:"test",testNumber:n,label:e,values:t.map(s=>s.mean),waferIndices:t.map(s=>s.waferIndex),sigma:f,mk:l})}return d}export function buildDriftFindings(m,d){const i=_(m);if(!i.length)return[];const r=v(i.map(e=>e.mk.pValue)),n=[];return i.forEach((e,t)=>{if(r[t]>d)return;const{slope:l,intercept:o,n:f}=e.mk,s=o,a=o+l*(f-1)-s,p=a>0,h=e.kind==="test"&&e.sigma&&e.sigma>0?Math.abs(a)/e.sigma:void 0;if(e.kind==="yield"?Math.abs(a)<M:h===void 0||h<N)return;const g=(e.kind==="yield"?Math.abs(a)>=x:(h??0)>=S)&&r[t]<=.01?"unusual":"notable",k=p?"rises":"falls",c={first:e.values[0],last:e.values[e.values.length-1]},I=e.kind==="yield"?`${c.first.toFixed(1)}% \u2192 ${c.last.toFixed(1)}%`:`${y(c.first)} \u2192 ${y(c.last)}`,w=e.kind==="yield"?"on successive wafers":"across the wafers";n.push({id:e.kind==="yield"?"drift:yield":`drift:test:${e.testNumber}`,level:"inter-wafer",severity:g,variable:e.kind==="yield"?{kind:"yield",label:"Yield"}:{kind:"test",measure:"mean",index:e.testNumber,label:e.label},comparison:{family:"wafer",left:"Wafers in input order",right:"a constant level"},effect:{direction:p?"higher":"lower",absoluteDelta:e.kind==="yield"?a/100:a,...e.kind==="yield"?{}:{relativeDelta:s!==0?a/Math.abs(s):void 0},effectSize:e.kind==="yield"?a/100:a/(e.sigma||1)},stats:{method:"mann-kendall",pValue:e.mk.pValue,adjustedPValue:r[t],sampleSizeLeft:f,sampleSizeRight:0},summary:`${e.label} ${k} ${w}: ${I} over ${f} wafers (input order)`,highlight:{kind:"wafer",waferIndices:e.waferIndices}})}),n}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{requireRingCount as P}from"../core/ringCount.js";import{getDieKey as v,isPositionedDie as L,isYieldEligibleDie as j,positionKey as h}from"../core/dies.js";import{itemPassBins as K}from"../core/passBins.js";import{classifyFailingDies as q,patternFailVerdict as C}from"./patternClassification.js";import{benjaminiHochberg as D,binomialUpperTail as F}from"./math.js";import{passesRateGate as
|
|
1
|
+
import{requireRingCount as P}from"../core/ringCount.js";import{getDieKey as v,isPositionedDie as L,isYieldEligibleDie as j,positionKey as h}from"../core/dies.js";import{itemPassBins as K}from"../core/passBins.js";import{classifyFailingDies as q,patternFailVerdict as C}from"./patternClassification.js";import{benjaminiHochberg as D,binomialUpperTail as F,zPValue as G}from"./math.js";import{passesRateGate as T,rateRelativeEffect as V,twoProportionZ as W}from"./analyzeWaferMap.js";const A=.01;export function findLotPattern(H,c){const l=[];let f,k=0,w=0;if(H.forEach((e,n)=>{if(e.isLotStack)return;const s=new Set(K(e)),t=[],i=[];for(const o of e.dies){if(!j(o)||!L(o))continue;const a=C(o,s);a!==void 0&&(t.push(o),i.push(a))}if(!t.length)return;const r=(o,a)=>Math.abs(o-a)<=A*Math.max(Math.abs(o),Math.abs(a));if(!f)f=e,k=t[0].width,w=t[0].height;else if(!r(e.wafer.radius,f.wafer.radius)||!r(t[0].width,k)||!r(t[0].height,w))return;l.push({index:n,dies:t,fails:i})}),!f||l.length<2)return null;const d=new Map;let z=0,p=0;for(const e of l)e.dies.forEach((n,s)=>{const t=h(n);let i=d.get(t);i||d.set(t,i={die:n,n:0,k:0}),i.n++,e.fails[s]&&(i.k++,p++),z++});if(p===0)return null;const E=p/z,m=[...d.values()],M=m.map(e=>{let n=0,s=0;for(let t=-1;t<=1;t++)for(let i=-1;i<=1;i++){const r=t===0&&i===0?e:d.get(h({x:e.die.x+t,y:e.die.y+i}));r&&(n+=r.n,s+=r.k)}return{n,k:s}}),N=D(M.map(e=>F(e.k,e.n,E))),x=new Set,S=[];m.forEach((e,n)=>{N[n]>c.significanceLevel||e.k/e.n<=E||(x.add(h(e.die)),S.push(e.die))});const u=q(S,m.map(e=>e.die),f.wafer,P(f,"the lot pattern"));if(!u||u.pattern==="random"||u.pattern==="none")return null;const b=l.map(e=>{let n=0,s=0,t=0,i=0;const r=[];e.dies.forEach((a,y)=>{x.has(h(a))?(s++,e.fails[y]&&(n++,r.push(v(a)))):(i++,e.fails[y]&&t++)});const o=s>=c.minimumSampleSize&&i>=c.minimumSampleSize?W(n,s,t,i):0;return{index:e.index,z:o,hits:n,n:s,restHits:t,restN:i,inside:r}}),R=D(b.map(e=>e.z>0?G(e.z):1)),g=new Map;return b.forEach((e,n)=>{if(e.z<=0)return;const s=e.hits/e.n-e.restHits/e.restN,t=V({hits:e.hits,n:e.n,restHits:e.restHits,restN:e.restN,passRate:!1});T(R[n],s,t,c)&&g.set(e.index,e.inside)}),g.size?{classification:u,carriers:g}:null}
|