@wafertools/wafermap 0.37.1 → 0.38.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/CHANGELOG.md +53 -1
- package/README.md +20 -13
- package/dist/packages/canvas-adapter/chartPopulation.d.ts +8 -3
- package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +27 -17
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.d.ts +0 -7
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/drilldown.d.ts +5 -0
- 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.js +1 -1
- package/dist/packages/canvas-adapter/pinnedTests.d.ts +10 -0
- package/dist/packages/canvas-adapter/pinnedTests.js +1 -0
- package/dist/packages/canvas-adapter/plotCard.d.ts +1 -1
- package/dist/packages/canvas-adapter/plotCard.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +3 -3
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +32 -19
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/derivedTests/apply.d.ts +10 -0
- package/dist/packages/renderer/derivedTests/apply.js +1 -1
- package/dist/packages/renderer/derivedTests/check.d.ts +35 -0
- package/dist/packages/renderer/derivedTests/check.js +1 -0
- package/dist/packages/renderer/fmt.d.ts +5 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +2 -0
- package/dist/packages/renderer/index.js +1 -1
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/chartCatalogue.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/plotData.d.ts +7 -0
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/reportHtml.js +33 -29
- package/dist/packages/stats/synthesis.d.ts +1 -1
- package/dist/packages/stats/synthesis.js +1 -1
- package/package.json +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeInput as dt}from"./normalizeInput.js";import{autoDecision as mt,testValueStatus as ht}from"./testValueBudget.js";import{computeCapability as pt,computeTestFlagYield as gt,computeRegionYield as bt}from"./summaryFigures.js";import{binPassSets as Ke}from"../renderer/binColors.js";import{diePassStatus as oe,isYieldEligibleDie as X,getDieKey as de,isPositionedDie as Ae,positionKey as we}from"../core/dies.js";import{dieHasValues as yt,testsPresent as Te,testValue as W}from"../core/dieTable.js";import{stackBinsAreData as St}from"../core/aggregates.js";import{getTestPassStatus as me,isParametricTest as Z}from"../renderer/buildWaferMap.js";import{markedTestLabel as I,derivedFields as he}from"../renderer/testLabel.js";import{buildQuadrantRegions as vt,buildReticlePositionRegions as wt,buildRingRegions as $t,buildSectorRegions as Rt,buildTestSiteRegions as Dt,sectorCompassNames as qe,areQuadrantsAdjacent as Mt,parseRegionKey as J,QUADRANT_CYCLE as $e,regionAngleBins as kt}from"./regions.js";import{buildClusterFindings as Ie}from"./clusterDetection.js";import{classifyPattern as zt,patternExplains as Bt,patternFailVerdict as Ft,PATTERN_LABELS as Ct}from"./patternClassification.js";import{requirePassBins as Nt}from"../core/passBins.js";import{requireRingCount as xt}from"../core/ringCount.js";import{benjaminiHochberg as Pt,fisherExact as Vt,fiveNumberSummary as Et,sampleVariance as Re,zPValue as je}from"./math.js";import{mean as pe,maxOf as Lt}from"../core/utils.js";import{classifySpec as ge,isOutOfSpec as De}from"../renderer/spec.js";import{ringOf as Ot}from"../core/classify.js";import{SEVERITY_ORDER as He,isOneBinCluster as _e}from"./filterFindings.js";const Kt={significanceLevel:{min:1e-6,max:1},minimumEffectSize:{min:0,max:1},minimumRelativeEffect:{min:0,max:Number.MAX_SAFE_INTEGER}},We=[4,8,16];export function resolveOptions(e){const t=Object.fromEntries(Object.entries(e).filter(([,a])=>a!==void 0)),s={...ae,...t},o=[],i=[];for(const a of["significanceLevel","minimumEffectSize","minimumRelativeEffect"]){const{min:p,max:r}=Kt[a],u=s[a];if(typeof u!="number"||!Number.isFinite(u)){i.push(`${a}=${String(u)} is not a finite number (using ${ae[a]})`),s[a]=ae[a];continue}const c=Math.min(r,Math.max(p,u));c!==u&&(i.push(`${a}=${u} is outside ${p}\u2013${r} (using ${c})`),s[a]=c)}if(We.includes(s.sectorCount)||(i.push(`sectorCount=${s.sectorCount} is not one of ${We.join(", ")} (using ${ae.sectorCount})`),s.sectorCount=ae.sectorCount),i.length){const a=`analyzeWaferMap: ${i.join("; ")}. The analysis ran with the corrected values.`;console.warn(`[wafermap] ${a}`),o.push({code:"analysis-option-corrected",message:a,severity:"warning"})}const n=["passBins","ringCount"].filter(a=>t[a]!==void 0);if(n.length){const a=`analyzeWaferMap: ${n.join(" and ")} ${n.length>1?"are":"is"} no longer an analysis option and was ignored. Set ${n.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 f=["enableYieldAnalysis","enableHardBinAnalysis","enableSoftBinAnalysis","enableReticlePositionAnalysis","enableTestSiteAnalysis","enableClusterAnalysis","enableAngularAnalysis","enablePatternClassification"].filter(a=>t[a]!==void 0);if(f.length){const a=`analyzeWaferMap: ${f.join(", ")} ${f.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 ae={significanceLevel:.05,minimumEffectSize:.2,minimumRelativeEffect:1,minimumSampleSize:5,enableTestValueAnalysis:"auto",computePerTestStats:!1,sectorCount:8,minimumClusterSize:5};function At(e,t){const s={...e};return s.minimumClusterSize=Math.max(5,Math.round(t*.003)),s}function Ye(e){return X(e)?e.hbin!==void 0||e.sbin!==void 0||yt(e):!1}function Tt(e,t,s){if(!e||t)return;const o=(s??[]).filter(i=>Z(i)&&(i.limitLow!==void 0||i.limitHigh!==void 0));if(o.length!==0)return i=>{for(const n of o)if(De(ge(W(i,n.testNumber),n)))return!0;return!1}}const qt=8,It=.8,jt=.8,Ht=.5;function _t(e,t,s,o,i){const n=new Set(o.passBins),f=e.filter(m=>oe(m,n)!==void 0),a=new Map;let p=0;for(const m of f)oe(m,n)||(p++,m.hbin!==void 0&&a.set(m.hbin,(a.get(m.hbin)??0)+1));const r=[...a].filter(([,m])=>m>=o.minimumClusterSize&&m<=It*p).sort((m,l)=>l[1]-m[1]||m[0]-l[0]).slice(0,qt).map(([m])=>m);if(!r.length)return[];const u=i.filter(m=>m.comparison.family==="cluster").map(be),c=[];for(const m of r){const l=Ie(f,t,{...o,significanceLevel:o.significanceLevel/r.length,isFailingDie:d=>d.hbin===m,bin:{bin:m,label:Ce(m,s,"HBin")}});c.push(...l.filter(d=>!u.some(h=>Yt(be(d),h))))}return c}const Wt=.5;export function claimForBinClusters(e){const t=e.filter(s=>(s.comparison.family==="ring"||s.comparison.family==="quadrant"||s.comparison.family==="sector")&&s.variable.kind==="hardBin"&&s.effect.direction==="higher");for(const s of e){if(!_e(s))continue;const o=be(s),i=t.filter(n=>{if(n.variable.bin!==s.variable.bin||He[n.severity]<He[s.severity])return!1;const f=(n.effect.absoluteDelta??0)*n.stats.sampleSizeLeft;let a=0;for(const p of be(n))o.has(p)&&a++;return f>0&&a>=Wt*f});if(s.severity!=="info")for(const n of i)n.severity="info";i.length&&(s.relatedIds=i.map(n=>n.id))}}function be(e){return new Set("dieKeys"in e.highlight?e.highlight.dieKeys??[]:[])}function Yt(e,t){let s=0;for(const o of e)t.has(o)&&s++;return s>=jt*e.size&&e.size>=Ht*t.size}function Ut(e,t,s,o){const i=new Set,n=new Set,f=new Set,a=new Map,p=new Map;for(const r of Te(e))i.add(r);for(const r of o?e:[])r.hbin!==void 0&&n.add(r.hbin),r.sbin!==void 0&&f.add(r.sbin),X(r)&&(r.hbin!==void 0&&a.set(r.hbin,(a.get(r.hbin)??0)+1),r.sbin!==void 0&&p.set(r.sbin,(p.get(r.sbin)??0)+1));return{totalDies:e.length,analyzedDies:t,excludedDies:e.length-t,yieldPercent:s,testsConsidered:[...i].sort((r,u)=>r-u),hardBinsConsidered:[...n].sort((r,u)=>r-u),softBinsConsidered:[...f].sort((r,u)=>r-u),...a.size?{hardBinCounts:Object.fromEntries(a)}:{},...p.size?{softBinCounts:Object.fromEntries(p)}:{}}}function Qt(e,t,s){if(!t?.length)return;const o=t.filter(n=>Z(n)&&(n.limitLow!==void 0||n.limitHigh!==void 0));if(!o.length)return;const i=[];for(const n of o){const f=n.testNumber;let a=0,p=0,r=0,u=0;for(const c of e){if(!X(c))continue;const m=ge(W(c,f),n);if(m!==null){if(u++,m==="failLow")p++;else if(m==="failHigh")r++;else{a++;continue}s?.(f,c)}}i.push({testNumber:f,label:I(n,f),passDies:a,failLowDies:p,failHighDies:r,totalDies:u,yieldPercent:u>0?a/u*100:null})}return i.length?i:void 0}export function computeFunctionalYield(e,t,s){if(!t?.length)return;const o=t.filter(n=>!Z(n));if(!o.length)return;const i=[];for(const n of o){const f=n.testNumber;let a=0,p=0;for(const u of e){if(!X(u))continue;const c=me(u,f,n);if(c!==void 0){if(c){a++;continue}p++,s?.(f,u)}}const r=a+p;i.push({testNumber:f,label:I(n,f),...he(n),passDies:a,failDies:p,totalDies:r,passRatePercent:r>0?a/r*100:null})}return i.length?i:void 0}function Gt(e,t,s,o){const i=[];for(const n of t){const f=[];for(const c of e){if(!X(c))continue;const m=W(c,n);m!==void 0&&Number.isFinite(m)&&f.push(m)}if(f.length<o)continue;const a=pe(f),p=Math.sqrt(Re(f,a)),r=Et(Float64Array.from(f)),u=s?.find(c=>c.testNumber===n)?.name??String(n);i.push({testNumber:n,label:u,count:f.length,min:r.min,max:r.max,mean:a,stddev:p,median:r.median,q1:r.q1,q3:r.q3})}return i.length?i:void 0}export function twoProportionZ(e,t,s,o){const i=(e+s)/(t+o),n=i*(1-i)*(1/t+1/o);return!Number.isFinite(n)||n<=0?0:(e/t-s/o)/Math.sqrt(n)}const Xt=5;function j(e,t,s,o){const i=t+o,n=e+s;if((i>0?Math.min(n,i-n)*Math.min(t,o)/i:0)<Xt)return{pValue:Vt(e,t-e,s,o-s),method:"fisher-exact"};const a=twoProportionZ(e,t,s,o);return{pValue:a===0?1:je(a),method:"two-proportion-z"}}function Zt(e,t,s,o){return j(e,t,s,o).pValue}export function adjustPValues(e){const t=e.filter(o=>o.stats.pValue!==void 0),s=Pt(t.map(o=>o.stats.pValue));return t.forEach((o,i)=>{o.stats.adjustedPValue=s[i]}),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),i=s;return e<=.01&&(o>=.3||i>=2.5)?"unusual":e<=.05&&(o>=.2||i>=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 ye(e){return e==="reticle-position"?"other reticle positions":e==="test-site"?"other test sites":"the rest of the map"}function ee(e){return e==="reticle-position"?"Other reticle positions":e==="test-site"?"Other test sites":"Rest of map"}function Me(e,t,s){const o=(Math.abs(t)*100).toFixed(1);return`${e} yield is ${o} percentage points ${t>0?"higher":"lower"} than ${ye(s)}`}function ke(e,t){return t==="quadrant"&&!e.startsWith("Quadrant")?`quadrant ${e}`:e}function Ue(e){return/^(Rings|Sectors|Quadrants)\b/.test(e)?"have":"has"}function ze(e,t,s,o){const i=ke(e,o),n=(Math.abs(s)*100).toFixed(1);return`${i} ${Ue(i)} ${t} occurrence ${n} percentage points ${s>0?"higher":"lower"} than ${ye(o)}`}function Be(e,t,s,o){const i=ke(e,o),n=(Math.abs(s)*100).toFixed(1);return`${i} ${Ue(i)} ${t} pass rate ${n} percentage points ${s>0?"higher":"lower"} than ${ye(o)}`}function Fe(e,t,s,o,i,n){const f=ke(e,i),a=ye(i),p=s>0?"higher":"lower";if(o!==void 0&&Number.isFinite(o)){const u=(Math.abs(o)*100).toFixed(1);return`${f} mean ${t} is ${u}% ${p} than ${a}`}const r=n?` ${n}`:"";return`${f} mean ${t} is ${Math.abs(s).toPrecision(3)}${r} ${p} than ${a}`}function Ce(e,t,s){const o=t?.find(i=>i.bin===e);return o?.name?`${s} ${e} (${o.name})`:`${s} ${e}`}function Jt(e,t){const s=t?.find(o=>o.testNumber===e);return{label:I(s,e),unit:s?.unit,...he(s)}}const Qe=new WeakMap,Ge=new WeakMap,Xe=new WeakMap;function re(e,t){const s=t.highlight.dieKeys;return s&&Xe.set(s,e),t}let te=null,fe;const Ze=new WeakMap;export function candidatesOf(e){return Ze.get(e)}function Je(e,t,s,o){if(!te)return;const i=et(e);if(!i)return;const n=e.id.slice(0,e.id.indexOf(":")),f=n==="specLimit"?"limitFail":n,{kind:a,bin:p,index:r}=e.variable;te.push({key:[f,a,p??"",r??"",i.family,i.key].join("|"),source:f,variable:e.variable,label:e.variable.label,comparison:e.comparison,region:i,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,i=e.region.family;switch(e.source){case"yield":return Me(o,t,i);case"hardBin":case"softBin":return ze(o,e.label,t,i);case"functional":return Be(o,e.label.replace(/ pass rate$/,""),t,i);case"limitFail":return Ne(o,e.label,t);case"test":return Fe(o,e.label,t,s,i,e.variable.unit)}}function Ne(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 Y=new WeakMap;function Se(e,t){return Y.set(e,t),e}function et(e){const t=e.highlight.dieKeys;return t?Xe.get(t):void 0}const tt=new WeakMap;function U(e){let t=tt.get(e);return t||tt.set(e,t=e.map(we)),t}function en(e){let t=Qe.get(e);return t||Qe.set(e,t=e.map(de)),t}function ve(e,t){let s=Ge.get(e);s||Ge.set(e,s={members:new Set(e),byFamily:new WeakMap});const o=s.byFamily.get(t);if(o)return o;const{members:i}=s,n=new Map;for(const f of t)n.set(f.key,f.dies.filter(a=>i.has(a)));return s.byFamily.set(t,n),n}function tn(e,t){adjustPValues(e);for(const i of e){const n=Y.get(i);Je(i,twoProportionZ(n.hits,n.n,n.restHits,n.restN),n)}const s=e.filter(i=>passesRateGate(i.stats.adjustedPValue??i.stats.pValue??1,i.effect.absoluteDelta??0,rateRelativeEffect(Y.get(i)),t)),o=confirmRegionalFindings(s,nt,(i,n)=>nn(i,n,t),i=>isRateLoss(Y.get(i)),e);return s.filter(i=>o.has(i)).map(i=>({...i,severity:severityForFinding(i.stats.adjustedPValue??i.stats.pValue??1,i.effect.absoluteDelta??0,rateRelativeEffect(Y.get(i)))}))}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,i){const n=[];for(const f of s){const a=f.comparison.family,p=a==="ring"||a==="cluster"?o(f):[];e.some(r=>Bt(r,a,p,i))&&(n.push(f.id),t!=="info"&&(a==="ring"||a==="quadrant"||a==="sector")&&(f.severity="info"))}return n}export function confirmRegionalFindings(e,t,s,o,i=e){const n=new Map;for(const p of e)(n.get(t(p))??n.set(t(p),[]).get(t(p))).push(p);const f=new Map;if(o)for(const p of i)o(p)&&(f.get(t(p))??f.set(t(p),[]).get(t(p))).push(p);const a=new Set;for(const[p,r]of n){const u=f.get(p)??[],c=(d,h)=>o&&!o(d)?s(d,[...new Set([...h,...u])].filter(g=>g!==d)):s(d,h);if(r.length===1&&(!o||o(r[0])||u.length===0)){a.add(r[0]);continue}const m=[];let l=[...r];for(;;){let d;for(const h of l){const g=c(h,m);if(g==="baseline-too-small"||!g.passes)continue;const v=o?.(h)??!1;(!d||v&&!d.loss||v===d.loss&&g.pValue<d.p)&&(d={t:h,p:g.pValue,loss:v})}if(!d)break;m.push(d.t),l=l.filter(h=>h!==d.t)}for(;;){let d;for(const h of m){const g=c(h,m.filter(v=>v!==h));g==="baseline-too-small"||g.passes||(!d||g.pValue>d.p)&&(d={t:h,p:g.pValue})}if(!d)break;m.splice(m.indexOf(d.t),1)}for(const d of m)a.add(d)}return a}function nt(e){return[e.variable.kind,e.variable.bin??"",e.variable.index??"",e.comparison.family].join("\0")}function it(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 nn(e,t,s){const o=Y.get(e);let{restHits:i,restN:n}=o;for(const r of t){const u=Y.get(r);u&&(i-=u.hits,n-=u.n)}if(n<s.minimumSampleSize)return"baseline-too-small";const f=o.hits/o.n-i/n,a=Math.min(1,Zt(o.hits,o.n,i,n)*it(e)),p=Math.sign(f)===Math.sign(e.effect.absoluteDelta??0)&&passesRateGate(a,f,rateRelativeEffect({...o,restHits:i,restN:n}),s);return{pValue:a,passes:p}}const xe=new WeakMap;export function welchOfSums(e,t,s,o){const i=(n,f,a)=>a>1?Math.max(0,n-f*f/a)/(a-1):0;return welchFromStats(e.n,e.sum/e.n,i(e.sq,e.sum,e.n),t,s/t,i(o,s,t))}function sn(e,t,s){const o=xe.get(e);let{restN:i,restSum:n,restSq:f}=o;for(const m of t){const l=xe.get(m);l&&(i-=l.n,n-=l.sum,f-=l.sq)}if(i<s.minimumSampleSize)return"baseline-too-small";const{pValue:a,effectSize:p,delta:r}=welchOfSums(o,i,n,f),u=Math.min(1,a*it(e)),c=Math.sign(r)===Math.sign(e.effect.absoluteDelta??0)&&u<=s.significanceLevel&&Math.abs(p)>=s.minimumEffectSize;return{pValue:u,passes:c}}function le(e,t,s,o){const i=new Set(s),n=ve(e,t),f=new Map,a=new Map;for(const[r,u]of n){let c=0,m=0;for(const l of u)l.hbin!==void 0&&(m++,i.has(l.hbin)&&c++);f.set(r,c),a.set(r,m)}const p=[];for(const r of t){const u=a.get(r.key)??0,c=f.get(r.key)??0;let m=0,l=0;for(const[D,w]of a)D!==r.key&&(m+=w,l+=f.get(D)??0);if(u<o.minimumSampleSize||m<o.minimumSampleSize)continue;const d=c/u,h=l/m,g=d-h,{pValue:v,method:F}=j(c,u,l,m);p.push(Se(re(r,{id:`yield:${r.key}`,level:"wafer",severity:"info",variable:{kind:"yield",label:"Yield"},comparison:{family:r.family,left:r.label,right:ee(r.family)},effect:{direction:g===0?"different":g>0?"higher":"lower",absoluteDelta:g,relativeDelta:h===0?void 0:g/h,effectSize:g},stats:{method:F,pValue:v,sampleSizeLeft:u,sampleSizeRight:m},summary:Me(r.label,g,r.family),highlight:{kind:"region",regionFamily:r.family,regionKeys:[r.key],dieKeys:[...r.dieKeys]}}),{hits:c,n:u,restHits:l,restN:m,passRate:!0}))}return p}function q(e,t,s,o,i,n){const f=d=>s==="soft"?d.sbin:d.hbin,a=[...new Set(e.map(f).filter(d=>d!==void 0))].sort((d,h)=>d-h),p=ve(e,t),r=new Map,u=new Map;for(const[d,h]of p){const g=new Map;for(const v of h){const F=f(v);F!==void 0&&g.set(F,(g.get(F)??0)+1)}r.set(d,g),u.set(d,h.length)}const c=[],m=i==="hardBin"?"HBin":"SBin",l=s==="hard"?new Set(n.passBins):n.softPassBins??Ke(e,n.passBins).soft;for(const d of t){const h=u.get(d.key)??0,g=r.get(d.key);let v=0;const F=new Map;for(const[D,w]of r)if(D!==d.key){v+=u.get(D)??0;for(const[B,z]of w)F.set(B,(F.get(B)??0)+z)}if(!(h<n.minimumSampleSize||v<n.minimumSampleSize))for(const D of a){const w=g.get(D)??0,B=F.get(D)??0,z=w/h,b=B/v,$=z-b,{pValue:M,method:S}=j(w,h,B,v),R=Ce(D,o,m);c.push(Se(re(d,{id:`${i}:${D}:${d.key}`,level:"wafer",severity:"info",variable:{kind:i,bin:D,label:R},comparison:{family:d.family,left:d.label,right:ee(d.family)},effect:{direction:$===0?"different":$>0?"higher":"lower",absoluteDelta:$,relativeDelta:b===0?void 0:$/b,effectSize:$},stats:{method:S,pValue:M,sampleSizeLeft:h,sampleSizeRight:v},summary:ze(d.label,R,$,d.family),highlight:{kind:"bin",bin:D,regionKeys:[d.key],dieKeys:[...d.dieKeys]}}),{hits:w,n:h,restHits:B,restN:v,passRate:l.has(D)}))}}return c}function ce(e,t,s,o){const i=(s??[]).filter(u=>!Z(u));if(!i.length)return[];const n=i.map(u=>u.testNumber),f=ve(e,t),a=new Map,p=new Map;for(const[u,c]of f){const m=new Uint32Array(i.length),l=new Uint32Array(i.length);for(const d of c)for(let h=0;h<i.length;h++){const g=me(d,n[h],i[h]);g!==void 0&&(l[h]++,g&&m[h]++)}a.set(u,m),p.set(u,l)}const r=[];for(const u of t){const c=a.get(u.key),m=p.get(u.key);for(let l=0;l<i.length;l++){let d=0,h=0;for(const[$,M]of p)$!==u.key&&(h+=M[l],d+=a.get($)[l]);const g=m[l],v=c[l];if(g<o.minimumSampleSize||h<o.minimumSampleSize)continue;const F=v/g,D=d/h,w=F-D,{pValue:B,method:z}=j(v,g,d,h),b=n[l];r.push(Se(re(u,{id:`functional:${b}:${u.key}`,level:"wafer",severity:"info",variable:{kind:"functionalTest",index:b,label:`${I(i[l],b)} pass rate`,...he(i[l])},comparison:{family:u.family,left:u.label,right:ee(u.family)},effect:{direction:w===0?"different":w>0?"higher":"lower",absoluteDelta:w,relativeDelta:D===0?void 0:w/D,effectSize:w},stats:{method:z,pValue:B,sampleSizeLeft:g,sampleSizeRight:h},summary:Be(u.label,I(i[l],b),w,u.family),highlight:{kind:"region",regionFamily:u.family,regionKeys:[u.key],dieKeys:[...u.dieKeys]}}),{hits:v,n:g,restHits:d,restN:h,passRate:!0}))}}return r}export function welchFromStats(e,t,s,o,i,n){const f=Math.sqrt(s/e+n/o),a=t-i;if(!Number.isFinite(f)||f===0)return{pValue:1,effectSize:0,delta:a,z:0};const p=a/f,r=Math.sqrt(Math.max(0,(s+n)/2)),u=r===0?a:a/r;return{pValue:je(p),effectSize:u,delta:a,z:p}}function on(e,t){const s=pe(e),o=pe(t);return welchFromStats(e.length,s,Re(e,s),t.length,o,Re(t,o))}function st(e,t,s){const o=new Map;for(const n of s??[])o.has(n.testNumber)||o.set(n.testNumber,n);const i=n=>n.filter(f=>Z(o.get(f)));return i(t?t.slice().sort((n,f)=>n-f):Te(e,"values"))}export function testValueSize(e,t){const s=e.dies.filter(Ye);return{tests:st(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 an(e,t,s,o,i){const n=new Map;for(let h=0;h<t.length;h++)for(const g of U(t[h].dies))n.set(g,h);const f=t.length,a=[],p=[];for(const h of e){const g=n.get(we(h));g!==void 0&&(a.push(h),p.push(g))}const r=[],u=new Float64Array(f),c=new Float64Array(f),m=new Float64Array(f);for(const h of s){u.fill(0),c.fill(0),m.fill(0);let g=0,v=0,F=0,D;for(let w=0;w<a.length;w++){const B=a[w],z=W(B,h);if(z===void 0)continue;D===void 0&&(D=z);const b=z-D,$=p[w];u[$]+=1,c[$]+=b,m[$]+=b*b,g+=1,v+=b,F+=b*b}if(D!==void 0)for(let w=0;w<f;w++){const B=u[w],z=g-B;if(B<i.minimumSampleSize||z<i.minimumSampleSize)continue;const b=c[w]/B,M=(v-c[w])/z,S=b+D,R=M+D,P=B>1?Math.max(0,m[w]-B*b*b)/(B-1):0,C=z>1?Math.max(0,F-m[w]-z*M*M)/(z-1):0,{pValue:V,effectSize:x,delta:k,z:O}=welchFromStats(B,S,P,z,R,C),N=t[w],{label:K,unit:E,...Q}=Jt(h,o),H=R!==0?k/Math.abs(R):void 0,G=re(N,{id:`test:${h}:${N.key}`,level:"wafer",severity:"info",variable:{kind:"test",measure:"mean",index:h,label:K,unit:E,...Q},comparison:{family:N.family,left:N.label,right:ee(N.family)},effect:{direction:k===0?"different":k>0?"higher":"lower",absoluteDelta:k,relativeDelta:H,effectSize:x},stats:{method:"welch-z-approx",pValue:V,sampleSizeLeft:B,sampleSizeRight:z},summary:Fe(N.label,K,k,H,N.family,E),highlight:{kind:"region",regionFamily:N.family,regionKeys:[N.key],dieKeys:[...N.dieKeys]}}),y={n:B,sum:c[w],sq:m[w],restN:z,restSum:v-c[w],restSq:F-m[w],shift:D};xe.set(G,y),Je(G,O,void 0,y),r.push(G)}}adjustPValues(r);const l=r.filter(h=>{const g=h.stats.adjustedPValue??h.stats.pValue??1,v=Math.abs(h.effect.effectSize??0);return g<=i.significanceLevel&&v>=i.minimumEffectSize}),d=confirmRegionalFindings(l,nt,(h,g)=>sn(h,g,i));return l.filter(h=>d.has(h)).map(h=>({...h,severity:severityForScore(h.stats.adjustedPValue??h.stats.pValue??1,h.effect.effectSize??0)}))}function rn(e,t,s,o){if(!s?.length)return[];const i=s.filter(f=>Z(f)&&(f.limitLow!==void 0||f.limitHigh!==void 0));if(!i.length)return[];const n=[];for(const f of i){const a=f.testNumber;for(const p of t){const r=ve(e,p),u=[],c=new Map;let m=0,l=0;for(const[d,h]of r){let g=0,v=0;for(const F of h){const D=W(F,a);D!==void 0&&(g++,De(ge(D,f))&&v++)}c.set(d,{valid:g,fail:v}),m+=g,l+=v}for(const d of p){const h=c.get(d.key),g=h.valid,v=m-h.valid;if(g<o.minimumSampleSize||v<o.minimumSampleSize)continue;const F=h.fail,D=l-h.fail,w=F/g,B=D/v,z=w-B,{pValue:b,method:$}=j(F,g,D,v);u.push(Se(re(d,{id:`specLimit:${a}:${d.key}`,level:"wafer",severity:"info",variable:{kind:"test",measure:"limitFailRate",index:a,label:I(f,a),...he(f)},comparison:{family:d.family,left:d.label,right:ee(d.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:v},summary:Ne(d.label,I(f,a),z),highlight:{kind:"region",regionFamily:d.family,regionKeys:[d.key],dieKeys:[...d.dieKeys]}}),{hits:F,n:g,restHits:D,restN:v,passRate:!1}))}n.push(...u)}}return n}function Pe(e,t){return e==="softBin"?t.softEligibleDies:e==="test"?t.testDies:t.eligibleDies}function fn(e){return e.variable.measure==="limitFailRate"}function ue(e){return e.highlight.regionKeys??[]}function ln(e){const t=e.variable.bin??e.variable.index??"";return`${e.comparison.family}\0${ot(e)}\0${e.variable.kind}\0${t}\0${e.effect.direction}`}function cn(e,t){const s=J(e);return s.family==="ring"?s.ring??0:s.family==="sector"?qe(t).indexOf(s.sector??""):0}export function inQuadrantOrder(e){const t=new Set(e),s=$e.findIndex((i,n)=>t.has(i)&&!t.has($e[(n+3)%4])),o=s<0?0:s;return Array.from({length:4},(i,n)=>$e[(o+n)%4]).filter(i=>t.has(i))}export function findContiguousRuns(e,t,s,o){if(t==="quadrant"){const p=new Map;for(const m of e){const l=J(o(m)).quadrant;l&&p.set(l,m)}const r=[...p.keys()],u=new Set,c=[];for(const m of r){if(u.has(m))continue;const l=[],d=[m];for(u.add(m);d.length;){const h=d.pop();l.push(h);for(const g of r)!u.has(g)&&Mt(h,g)&&(u.add(g),d.push(g))}c.push(inQuadrantOrder(l).map(h=>p.get(h)))}return c}const i=p=>cn(o(p),s),n=[...e].sort((p,r)=>i(p)-i(r)),f=[];let a=[];for(const p of n){if(a.length===0){a.push(p);continue}const r=i(a[a.length-1]);i(p)-r===1?a.push(p):(f.push(a),a=[p])}if(a.length&&f.push(a),t==="sector"&&f.length>1){const r=qe(s).length,u=i(f[0][0]),c=i(f[f.length-1][f[f.length-1].length-1]);if(u===0&&c===r-1){const m=f.pop();f[0]=[...m,...f[0]]}}return f}export function mergedRegionLabel(e,t,s){if(e==="ring"){const i=t.map(p=>J(p).ring).filter(p=>p!==void 0).sort((p,r)=>p-r),n=i[0],f=i[i.length-1];let a="";return n===f&&n===1&&s>1?a=" (core)":n===f&&n===s&&s>1&&(a=" (edge)"),n===f?`Ring ${n}${a}`:`Rings ${n}\u2013${f}`}if(e==="sector"){const i=t.map(n=>J(n).sector??"");return i.length===1?`Sector ${i[0]}`:`Sectors ${i[0]}\u2013${i[i.length-1]}`}const o=t.map(i=>J(i).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 Ve(e){return[...new Set(e)]}export function weakestMultiplier(e){return Lt(e.map(t=>{const s=t.stats.pValue??1;return s>0?(t.stats.adjustedPValue??s)/s:1}))}function ne(e,t){return Math.min(1,e*t)}function un(e,t){const s=e[0],o=s.comparison.family,i=s.variable.kind,n=Ve(e.flatMap(ue));let f,a;const p=e.map(et);if(p.every(b=>b!==void 0)){const b=new Set;f=[];for(const M of p){const S=U(M.dies);for(let R=0;R<S.length;R++)b.has(S[R])||(b.add(S[R]),f.push(M.dieKeys[R]))}const $=U(Pe(s.variable.kind,t));a=M=>b.has($[M])}else{f=Ve(e.flatMap(M=>M.highlight.dieKeys??[]));const b=new Set(f),$=en(Pe(s.variable.kind,t));a=M=>b.has($[M])}const r=mergedRegionLabel(o,e.map(b=>ue(b)[0]??""),t.ringCount),u=Pe(i,t),c=t.regionDies[o],m=U(u),l=[],d=[];for(let b=0;b<u.length;b++)c.has(m[b])&&(a(b)?l:d).push(u[b]);const h=weakestMultiplier(e);let g,v,F,D,w;if(fn(s)){const b=s.variable.index,$=t.testDefs?.find(N=>N.testNumber===b),M=N=>{let K=0,E=0;for(const Q of N){const H=W(Q,b);H!==void 0&&(K++,$&&De(ge(H,$))&&E++)}return{valid:K,fail:E}},S=M(l),R=M(d),P=S.valid>0?S.fail/S.valid:0,C=R.valid>0?R.fail/R.valid:0,V=P-C,{pValue:x,method:k}=j(S.fail,S.valid,R.fail,R.valid);g={direction:V===0?"different":V>0?"higher":"lower",absoluteDelta:V,relativeDelta:C===0?void 0:V/C,effectSize:V},v={method:k,pValue:x,sampleSizeLeft:S.valid,sampleSizeRight:R.valid};const O=ne(x,h);F=severityForFinding(O,V,rateRelativeEffect({hits:S.fail,n:S.valid,restHits:R.fail,restN:R.valid,passRate:!1})),D=Ne(r,I($,b),V),w=`specLimit:${b}`}else if(i==="test"){const b=s.variable.index,$=O=>W(O,b),M=l.map($).filter(O=>O!==void 0),S=d.map($).filter(O=>O!==void 0),{pValue:R,effectSize:P,delta:C}=on(M,S),V=pe(S),x=V!==0?C/Math.abs(V):void 0;g={direction:C===0?"different":C>0?"higher":"lower",absoluteDelta:C,relativeDelta:x,effectSize:P},v={method:"welch-z-approx",pValue:R,sampleSizeLeft:M.length,sampleSizeRight:S.length};const k=ne(R,h);F=severityForScore(k,P),D=Fe(r,s.variable.label,C,x,o,s.variable.unit),w=`test:${b}`}else if(i==="yield"){const b=new Set(t.passBins),$=l.filter(E=>E.hbin!==void 0),M=d.filter(E=>E.hbin!==void 0),S=$.length,R=M.length,P=$.filter(E=>b.has(E.hbin)).length,C=M.filter(E=>b.has(E.hbin)).length,V=S>0?P/S:0,x=R>0?C/R:0,k=V-x,{pValue:O,method:N}=j(P,S,C,R);g={direction:k===0?"different":k>0?"higher":"lower",absoluteDelta:k,relativeDelta:x===0?void 0:k/x,effectSize:k},v={method:N,pValue:O,sampleSizeLeft:S,sampleSizeRight:R};const K=ne(O,h);F=severityForFinding(K,k,rateRelativeEffect({hits:P,n:S,restHits:C,restN:R,passRate:!0})),D=Me(r,k,o),w="yield"}else if(i==="functionalTest"){const b=s.variable.index,$=t.testDefs?.find(K=>K.testNumber===b);let M=0,S=0,R=0,P=0;for(const K of l){const E=me(K,b,$);E!==void 0&&(S++,E&&M++)}for(const K of d){const E=me(K,b,$);E!==void 0&&(P++,E&&R++)}const C=S>0?M/S:0,V=P>0?R/P:0,x=C-V,{pValue:k,method:O}=j(M,S,R,P);g={direction:x===0?"different":x>0?"higher":"lower",absoluteDelta:x,relativeDelta:V===0?void 0:x/V,effectSize:x},v={method:O,pValue:k,sampleSizeLeft:S,sampleSizeRight:P};const N=ne(k,h);F=severityForFinding(N,x,rateRelativeEffect({hits:M,n:S,restHits:R,restN:P,passRate:!0})),D=Be(r,I($,b),x,o),w=`functional:${b}`}else{const b=s.variable.bin,$=N=>i==="softBin"?N.sbin:N.hbin,M=l.filter(N=>$(N)===b).length,S=d.filter(N=>$(N)===b).length,R=M/l.length,P=S/d.length,C=R-P,{pValue:V,method:x}=j(M,l.length,S,d.length);g={direction:C===0?"different":C>0?"higher":"lower",absoluteDelta:C,relativeDelta:P===0?void 0:C/P,effectSize:C},v={method:x,pValue:V,sampleSizeLeft:l.length,sampleSizeRight:d.length};const k=ne(V,h);F=severityForFinding(k,C,rateRelativeEffect({hits:M,n:l.length,restHits:S,restN:d.length,passRate:!1}));const O=i==="softBin"?t.sbinDefs:t.hbinDefs;D=ze(r,Ce(b,O,i==="softBin"?"SBin":"HBin"),C,o),w=`${i}:${b}`}v={...v,adjustedPValue:ne(v.pValue??1,h)};const B=Ve(n.map(b=>b.replace(`${o}:`,""))).join("-"),z=i==="hardBin"||i==="softBin"?{kind:"bin",bin:s.variable.bin,regionKeys:n,dieKeys:f}:{kind:"region",regionFamily:o,regionKeys:n,dieKeys:f};return{...s,id:`${w}:${o}:${B}`,severity:F,comparison:{family:o,left:r,right:ee(o)},effect:g,stats:v,summary:D,highlight:z,relatedIds:e.map(b=>b.id)}}function dn(e,t){const s=new Set(["ring","quadrant","sector"]),o=[],i=new Map;for(const f of e){if(!s.has(f.comparison.family)){o.push(f);continue}const a=ln(f),p=i.get(a)??[];p.push(f),i.set(a,p)}const n=[];for(const f of i.values()){if(f.length===1){n.push(f[0]);continue}const a=f[0].comparison.family;for(const p of findContiguousRuns(f,a,t.sectorCount,r=>ue(r)[0]??""))n.push(p.length===1?p[0]:un(p,t))}return[...o,...n]}function mn(e){const t=new Map,s=new Map;for(const i of e){const n=we(i);i.hbin!==void 0&&i.hbin!==null&&(t.get(i.hbin)??t.set(i.hbin,new Set).get(i.hbin)).add(n),i.sbin!==void 0&&i.sbin!==null&&(s.get(i.sbin)??s.set(i.sbin,new Set).get(i.sbin)).add(n)}const o=new Set;for(const[i,n]of t)for(const[f,a]of s){if(n.size!==a.size)continue;let p=!0;for(const r of n)if(!a.has(r)){p=!1;break}p&&o.add(`${i}:${f}`)}return o}function hn(e,t){const s=new Set(t);let o;for(const i of e){const n=oe(i,s);if(n!==void 0&&n){if(i.sbin==null||o!==void 0&&i.sbin!==o)return;o=i.sbin}}if(o!==void 0){for(const i of e)if(i.sbin===o&&oe(i,s)!==!0)return;return o}}function pn(e){return`${e.comparison.family}\0${e.comparison.left}`}export function redundancyFacts(e,t,s){return{coincident:mn(e),yieldSoftBin:hn(e,t),passBins:t,sectorCount:s}}const gn=3/5;function ot(e){return/^(?:lot-region:)?([^:|]+)/.exec(e.id)?.[1]??e.id}function bn(e){const t=ue(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 at(e,t){const s=new Set;for(const o of bn(e)){const i=kt(o,t);if(!i)return;for(const n of i)s.add(n)}return s.size?s:void 0}export function collapseRedundantFindings(e,t){const{coincident:s,yieldSoftBin:o,passBins:i}=t,n=(r,u)=>{r.absorbedIds=[...r.absorbedIds??[],u.id]},f=new Map;for(const r of e){const u=pn(r);(f.get(u)??f.set(u,[]).get(u)).push(r)}const a=new Set;for(const r of f.values()){for(const c of r)if(!(c.variable.kind!=="hardBin"||c.variable.bin===void 0))for(const m of r){if(m.variable.kind!=="softBin"||m.variable.bin===void 0||a.has(m.id)||!s.has(`${c.variable.bin}:${m.variable.bin}`)||m.effect.direction!==c.effect.direction)continue;n(c,m),a.add(m.id);const l=c.variable.label.replace(/^HBin\s+/,""),d=m.variable.label.replace(/^SBin\s+/,""),h=l===d?`HBin and SBin ${l} (same dies)`:`${c.variable.label} and ${m.variable.label} (same dies)`;c.summary=c.summary.replace(c.variable.label,h),c.variable.label=h;break}const u=r.find(c=>c.variable.kind==="yield");if(u){for(const c of r)if(!(c===u||a.has(c.id)||!(c.variable.kind==="hardBin"&&i.length===1&&c.variable.bin===i[0]||c.variable.kind==="softBin"&&c.variable.bin===o))){n(u,c),a.add(c.id);for(const l of c.absorbedIds??[])u.absorbedIds=[...u.absorbedIds??[],l]}}}const p=new Map;for(const r of e){if(a.has(r.id)||r.comparison.family!=="sector"&&r.comparison.family!=="quadrant")continue;const u=[ot(r),r.variable.kind,r.variable.bin??"",r.variable.index??"",r.effect.direction].join("\0");(p.get(u)??p.set(u,[]).get(u)).push(r)}for(const r of p.values()){const u=[];for(const c of r.filter(m=>m.comparison.family==="sector")){const m=at(c,t.sectorCount);if(m)for(const l of r.filter(d=>d.comparison.family==="quadrant")){const d=at(l,t.sectorCount);if(!d)continue;let h=0;for(const v of m)d.has(v)&&h++;const g=m.size+d.size-h;h/g>=gn-1e-9&&u.push({sector:c,quadrant:l,overlap:h/g})}}u.sort((c,m)=>m.overlap-c.overlap);for(const{sector:c,quadrant:m}of u){if(a.has(c.id)||a.has(m.id))continue;const l=(m.stats.pValue??1)<(c.stats.pValue??1),[d,h]=l?[m,c]:[c,m];n(d,h),a.add(h.id),d.absorbedIds=[...d.absorbedIds??[],...h.absorbedIds??[]]}}}export function analyzeWaferMap(e,t={}){return analyzeWaferMapDecided(e,t)}export function analyzeWaferMapDecided(e,t={},s){const o=te,i=fe,n=[];te=n,fe=void 0;try{const f=yn(e,t,s);return Ze.set(f,{candidates:n,facts:fe}),f}finally{te=o,fe=i}}function yn(e,t,s){const{resolved:o,warnings:i}=resolveOptions(t),n=dt(e),f={...o,passBins:[...Nt(n,"analyzeWaferMap")],ringCount:xt(n,"analyzeWaferMap")},a=n.isLotStack,p=n.aggrMethod,r=St(a,p),u=r,c=n.dies.filter(y=>Ye(y)),m=c.filter(Ae),l=At(f,c.length);l.softPassBins=Ke(c,l.passBins).soft;const d=st(c,l.testNumbers,n.testDefs),h=l.enableTestValueAnalysis,g=h===!1?"off":h===!0?"done":s??mt(d.length*c.length),v=n.dies.filter(y=>X(y)),F=v.filter(Ae),D=r?c.filter(y=>y.sbin!==void 0):[],w=u&&c.some(y=>y.hbin!==void 0)||D.length>0||h!==!1,B=w?$t(F,n.wafer,l.ringCount):[],z=w?vt(F,n.wafer,l.ringCount):[],b=w?wt(F,n.reticleConfig):[],$=w?Dt(v,!1):[],M=w?Rt(F,n.wafer,l.sectorCount):[],S=[],R=[];u&&R.push(...le(c,B,l.passBins,l),...le(c,z,l.passBins,l),...le(c,b,l.passBins,l),...le(c,$,l.passBins,l),...le(c,M,l.passBins,l)),u&&R.push(...q(c,B,"hard",n.hbinDefs,"hardBin",l),...q(c,z,"hard",n.hbinDefs,"hardBin",l),...q(c,b,"hard",n.hbinDefs,"hardBin",l),...q(c,$,"hard",n.hbinDefs,"hardBin",l),...q(c,M,"hard",n.hbinDefs,"hardBin",l));{const y=D;R.push(...q(y,B,"soft",n.sbinDefs,"softBin",l),...q(y,z,"soft",n.sbinDefs,"softBin",l),...q(y,b,"soft",n.sbinDefs,"softBin",l),...q(y,$,"soft",n.sbinDefs,"softBin",l),...q(y,M,"soft",n.sbinDefs,"softBin",l))}const P=[...i];let C;if(h!==!1){if(g==="done"){for(const y of[B,z,b,$,M])S.push(...an(c,y,d,n.testDefs,l));C=d}R.push(...rn(c,[B,z,b,$,M],n.testDefs,l)),R.push(...ce(c,B,n.testDefs,l),...ce(c,z,n.testDefs,l),...ce(c,b,n.testDefs,l),...ce(c,$,n.testDefs,l),...ce(c,M,n.testDefs,l))}S.push(...tn(R,l));{const y=Tt(a,u,n.testDefs);if(!a||u||y!==void 0){const A=Ie(m,n.wafer,{...l,isFailingDie:y});S.push(...A),u&&S.push(..._t(m,n.wafer,n.hbinDefs,l,A))}}const V=dn(S,{eligibleDies:c,softEligibleDies:D,testDies:c,passBins:l.passBins,ringCount:l.ringCount,sectorCount:l.sectorCount,regionDies:{ring:new Set(B.flatMap(y=>U(y.dies))),quadrant:new Set(z.flatMap(y=>U(y.dies))),sector:new Set(M.flatMap(y=>U(y.dies)))},hbinDefs:n.hbinDefs,sbinDefs:n.sbinDefs,testDefs:n.testDefs});S.length=0,S.push(...V),claimForBinClusters(S);let x;if(u){const y=zt(m,n.wafer,{passBins:l.passBins,ringCount:l.ringCount});if(x=y??void 0,y!==null&&y.pattern!=="random"&&y.pattern!=="none"){const A=Ct[y.pattern],_=y.confidence==="high"?"unusual":y.confidence==="medium"?"notable":"info",T=y.features,ie=L=>`${(L*100).toFixed(0)}%`,rt=y.pattern==="edge-ring"||y.pattern==="edge-local"?`${ie(T.edgeRdd)} of edge dies failing`:y.pattern==="center"?`centroid at ${ie(T.centroidDistNorm)} of wafer radius from centre`:y.pattern==="donut"?`${ie(Math.max(T.radialFailRates[1],T.radialFailRates[2]))} of dies failing at mid-radius, ${ie(T.radialFailRates[0])} at the centre`:y.pattern==="scratch"?`a line ${Math.round(T.lineLength)} dies long and about ${Math.max(1,Math.round(T.lineWidth*2))} wide`:`${ie(T.globalRdd)} of dies failing`,ft=new Set(l.passBins),Ee=c.filter(L=>Ft(L,ft)===!0),{center:Le,radius:lt}=n.wafer,ct=new Map(m.map(L=>[de(L),Ot(L.physX-Le.x,L.physY-Le.y,lt,l.ringCount)])),ut=new Set(S.flatMap(L=>_e(L)?L.relatedIds??[]:[])),Oe=claimForPattern([y.pattern],_,S.filter(L=>!ut.has(L.id)),L=>L.comparison.family==="cluster"?[...new Set(L.highlight.kind==="dies"?L.highlight.dieKeys.map(se=>ct.get(se)??0):[])]:ue(L).map(se=>J(se).ring).filter(se=>se!==void 0),l.ringCount);S.push({id:`spatial-pattern:${y.pattern}`,level:"wafer",severity:_,variable:{kind:"spatialPattern",label:A},comparison:{family:"spatial-pattern",left:A,right:"Wafer"},effect:{direction:"different",effectSize:T.globalRdd},stats:{method:"geometry",sampleSizeLeft:Ee.length,sampleSizeRight:c.length},summary:`Spatial pattern: ${A.toLowerCase()} (${y.confidence} confidence) \u2014 ${rt}${y.note?` [${y.note}]`:""}`,highlight:{kind:"dies",dieKeys:Ee.map(L=>de(L))},relatedIds:Oe.length>0?Oe:void 0})}}S.sort((y,A)=>{const _=y.stats.adjustedPValue??y.stats.pValue??1,T=A.stats.adjustedPValue??A.stats.pValue??1;return _!==T?_-T:Math.abs(A.effect.absoluteDelta??0)-Math.abs(y.effect.absoluteDelta??0)});const k=Ut(n.dies,c.length,n.yield.yieldPercent,r);a&&(k.isLotStack=!0,p&&(k.aggregationMethod=p));const O=new Set(f.passBins),N={},K=(y,A)=>{const _=N[y]??={dieKeys:[],lostDies:0};_.dieKeys.push(de(A)),(!r||oe(A,O)!==!0)&&_.lostDies++},E=Qt(n.dies,n.testDefs,K);E&&(k.testSpecYield=E);const Q=computeFunctionalYield(n.dies,n.testDefs,K);if(Q&&(k.functionalYield=Q),Object.keys(N).length&&(k.testFailures=N),x&&(k.spatialPattern=x),C===void 0&&l.computePerTestStats&&(C=d),d.length&&(k.testValueAnalysis=ht(g,d.length,c.length)),C?.length){const y=Gt(n.dies,C,n.testDefs,l.minimumSampleSize);y&&(k.perTestStats=y);const A=pt([{dies:n.dies}],n.testDefs,C);A&&(k.capability=A)}Object.assign(k,gt(n.dies,n.testDefs));const H=bt([{dies:n.dies,wafer:n.wafer,passBins:l.passBins,ringCount:l.ringCount}]);H&&(k.regionYield=H),P.length>0&&(k.warnings=P);const G=redundancyFacts(c,l.passBins,l.sectorCount);return collapseRedundantFindings(S,G),te&&(fe=G),{level:"wafer",hasNotableFindings:S.some(y=>y.severity==="notable"||y.severity==="unusual"),findings:S,wafer:n.wafer.metadata??void 0,analysisOptions:recordedOptions(t),stats:k}}
|
|
1
|
+
import{normalizeInput as pt}from"./normalizeInput.js";import{autoDecision as gt,testValueStatus as bt}from"./testValueBudget.js";import{computeCapability as yt,computeTestFlagYield as St,computeRegionYield as vt}from"./summaryFigures.js";import{binPassSets as Te}from"../renderer/binColors.js";import{diePassStatus as ae,isYieldEligibleDie as Z,getDieKey as re,isPositionedDie as qe,positionKey as Re}from"../core/dies.js";import{dieHasValues as wt,testsPresent as Ie,testValue as Y}from"../core/dieTable.js";import{stackBinsAreData as $t}from"../core/aggregates.js";import{getTestPassStatus as pe,isParametricTest as J}from"../renderer/buildWaferMap.js";import{markedTestLabel as j,derivedFields as ge}from"../renderer/testLabel.js";import{buildQuadrantRegions as Rt,buildReticlePositionRegions as kt,buildRingRegions as Mt,buildSectorRegions as Dt,buildTestSiteRegions as zt,sectorCompassNames as je,areQuadrantsAdjacent as Bt,parseRegionKey as ee,QUADRANT_CYCLE as ke,regionAngleBins as Ft}from"./regions.js";import{buildClusterFindings as He}from"./clusterDetection.js";import{classifyPattern as Ct,classifyFailingDies as Nt,patternExplains as xt,patternFailVerdict as _e,PATTERN_LABELS as Pt}from"./patternClassification.js";import{requirePassBins as Vt}from"../core/passBins.js";import{requireRingCount as Et}from"../core/ringCount.js";import{benjaminiHochberg as Lt,fisherExact as Kt,fiveNumberSummary as Ot,sampleVariance as Me,zPValue as We}from"./math.js";import{mean as be,maxOf as At}from"../core/utils.js";import{classifySpec as ye,isOutOfSpec as De}from"../renderer/spec.js";import{ringOf as Tt}from"../core/classify.js";import{SEVERITY_ORDER as Ye,isOneBinCluster as Ue}from"./filterFindings.js";const qt={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={...fe,...t},o=[],i=[];for(const a of["significanceLevel","minimumEffectSize","minimumRelativeEffect"]){const{min:d,max:r}=qt[a],l=s[a];if(typeof l!="number"||!Number.isFinite(l)){i.push(`${a}=${String(l)} is not a finite number (using ${fe[a]})`),s[a]=fe[a];continue}const u=Math.min(r,Math.max(d,l));u!==l&&(i.push(`${a}=${l} is outside ${d}\u2013${r} (using ${u})`),s[a]=u)}if(Qe.includes(s.sectorCount)||(i.push(`sectorCount=${s.sectorCount} is not one of ${Qe.join(", ")} (using ${fe.sectorCount})`),s.sectorCount=fe.sectorCount),i.length){const a=`analyzeWaferMap: ${i.join("; ")}. The analysis ran with the corrected values.`;console.warn(`[wafermap] ${a}`),o.push({code:"analysis-option-corrected",message:a,severity:"warning"})}const n=["passBins","ringCount"].filter(a=>t[a]!==void 0);if(n.length){const a=`analyzeWaferMap: ${n.join(" and ")} ${n.length>1?"are":"is"} no longer an analysis option and was ignored. Set ${n.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 f=["enableYieldAnalysis","enableHardBinAnalysis","enableSoftBinAnalysis","enableReticlePositionAnalysis","enableTestSiteAnalysis","enableClusterAnalysis","enableAngularAnalysis","enablePatternClassification"].filter(a=>t[a]!==void 0);if(f.length){const a=`analyzeWaferMap: ${f.join(", ")} ${f.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 fe={significanceLevel:.05,minimumEffectSize:.2,minimumRelativeEffect:1,minimumSampleSize:5,enableTestValueAnalysis:"auto",computePerTestStats:!1,sectorCount:8,minimumClusterSize:5};function It(e,t){const s={...e};return s.minimumClusterSize=Math.max(5,Math.round(t*.003)),s}function Ge(e){return Z(e)?e.hbin!==void 0||e.sbin!==void 0||wt(e):!1}function jt(e,t,s){if(!e||t)return;const o=(s??[]).filter(i=>J(i)&&(i.limitLow!==void 0||i.limitHigh!==void 0));if(o.length!==0)return i=>{for(const n of o)if(De(ye(Y(i,n.testNumber),n)))return!0;return!1}}const Ht=8,_t=.8,Wt=.8,Yt=.5;function Ut(e,t,s,o,i){const n=new Set(o.passBins),f=e.filter(m=>ae(m,n)!==void 0),a=new Map;let d=0;for(const m of f)ae(m,n)||(d++,m.hbin!==void 0&&a.set(m.hbin,(a.get(m.hbin)??0)+1));const r=[...a].filter(([,m])=>m>=o.minimumClusterSize&&m<=_t*d).sort((m,c)=>c[1]-m[1]||m[0]-c[0]).slice(0,Ht).map(([m])=>m);if(!r.length)return[];const l=i.filter(m=>m.comparison.family==="cluster").map(Se),u=[];for(const m of r){const c=He(f,t,{...o,significanceLevel:o.significanceLevel/r.length,isFailingDie:h=>h.hbin===m,bin:{bin:m,label:xe(m,s,"HBin")}});u.push(...c.filter(h=>!l.some(p=>Gt(Se(h),p))))}return u}const Qt=.5;export function claimForBinClusters(e){const t=e.filter(s=>(s.comparison.family==="ring"||s.comparison.family==="quadrant"||s.comparison.family==="sector")&&s.variable.kind==="hardBin"&&s.effect.direction==="higher");for(const s of e){if(!Ue(s))continue;const o=Se(s),i=t.filter(n=>{if(n.variable.bin!==s.variable.bin||Ye[n.severity]<Ye[s.severity])return!1;const f=(n.effect.absoluteDelta??0)*n.stats.sampleSizeLeft;let a=0;for(const d of Se(n))o.has(d)&&a++;return f>0&&a>=Qt*f});if(s.severity!=="info")for(const n of i)n.severity="info";i.length&&(s.relatedIds=i.map(n=>n.id))}}function Se(e){return new Set("dieKeys"in e.highlight?e.highlight.dieKeys??[]:[])}function Gt(e,t){let s=0;for(const o of e)t.has(o)&&s++;return s>=Wt*e.size&&e.size>=Yt*t.size}function Xt(e,t,s,o){const i=new Set,n=new Set,f=new Set,a=new Map,d=new Map;for(const r of Ie(e))i.add(r);for(const r of o?e:[])r.hbin!==void 0&&n.add(r.hbin),r.sbin!==void 0&&f.add(r.sbin),Z(r)&&(r.hbin!==void 0&&a.set(r.hbin,(a.get(r.hbin)??0)+1),r.sbin!==void 0&&d.set(r.sbin,(d.get(r.sbin)??0)+1));return{totalDies:e.length,analyzedDies:t,excludedDies:e.length-t,yieldPercent:s,testsConsidered:[...i].sort((r,l)=>r-l),hardBinsConsidered:[...n].sort((r,l)=>r-l),softBinsConsidered:[...f].sort((r,l)=>r-l),...a.size?{hardBinCounts:Object.fromEntries(a)}:{},...d.size?{softBinCounts:Object.fromEntries(d)}:{}}}function Zt(e,t,s){if(!t?.length)return;const o=t.filter(n=>J(n)&&(n.limitLow!==void 0||n.limitHigh!==void 0));if(!o.length)return;const i=[];for(const n of o){const f=n.testNumber;let a=0,d=0,r=0,l=0;for(const u of e){if(!Z(u))continue;const m=ye(Y(u,f),n);if(m!==null){if(l++,m==="failLow")d++;else if(m==="failHigh")r++;else{a++;continue}s?.(f,u)}}i.push({testNumber:f,label:j(n,f),passDies:a,failLowDies:d,failHighDies:r,totalDies:l,yieldPercent:l>0?a/l*100:null})}return i.length?i:void 0}export function computeFunctionalYield(e,t,s){if(!t?.length)return;const o=t.filter(n=>!J(n));if(!o.length)return;const i=[];for(const n of o){const f=n.testNumber;let a=0,d=0;for(const l of e){if(!Z(l))continue;const u=pe(l,f,n);if(u!==void 0){if(u){a++;continue}d++,s?.(f,l)}}const r=a+d;i.push({testNumber:f,label:j(n,f),...ge(n),passDies:a,failDies:d,totalDies:r,passRatePercent:r>0?a/r*100:null})}return i.length?i:void 0}function Jt(e,t,s,o){const i=[];for(const n of t){const f=[];for(const u of e){if(!Z(u))continue;const m=Y(u,n);m!==void 0&&Number.isFinite(m)&&f.push(m)}if(f.length<o)continue;const a=be(f),d=Math.sqrt(Me(f,a)),r=Ot(Float64Array.from(f)),l=s?.find(u=>u.testNumber===n)?.name??String(n);i.push({testNumber:n,label:l,count:f.length,min:r.min,max:r.max,mean:a,stddev:d,median:r.median,q1:r.q1,q3:r.q3})}return i.length?i:void 0}export function twoProportionZ(e,t,s,o){const i=(e+s)/(t+o),n=i*(1-i)*(1/t+1/o);return!Number.isFinite(n)||n<=0?0:(e/t-s/o)/Math.sqrt(n)}const en=5;function H(e,t,s,o){const i=t+o,n=e+s;if((i>0?Math.min(n,i-n)*Math.min(t,o)/i:0)<en)return{pValue:Kt(e,t-e,s,o-s),method:"fisher-exact"};const a=twoProportionZ(e,t,s,o);return{pValue:a===0?1:We(a),method:"two-proportion-z"}}function tn(e,t,s,o){return H(e,t,s,o).pValue}export function adjustPValues(e){const t=e.filter(o=>o.stats.pValue!==void 0),s=Lt(t.map(o=>o.stats.pValue));return t.forEach((o,i)=>{o.stats.adjustedPValue=s[i]}),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),i=s;return e<=.01&&(o>=.3||i>=2.5)?"unusual":e<=.05&&(o>=.2||i>=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 ve(e){return e==="reticle-position"?"other reticle positions":e==="test-site"?"other test sites":"the rest of the map"}function te(e){return e==="reticle-position"?"Other reticle positions":e==="test-site"?"Other test sites":"Rest of map"}function ze(e,t,s){const o=(Math.abs(t)*100).toFixed(1);return`${e} yield is ${o} percentage points ${t>0?"higher":"lower"} than ${ve(s)}`}function Be(e,t){return t==="quadrant"&&!e.startsWith("Quadrant")?`quadrant ${e}`:e}function Xe(e){return/^(Rings|Sectors|Quadrants)\b/.test(e)?"have":"has"}function Fe(e,t,s,o){const i=Be(e,o),n=(Math.abs(s)*100).toFixed(1);return`${i} ${Xe(i)} ${t} occurrence ${n} percentage points ${s>0?"higher":"lower"} than ${ve(o)}`}function Ce(e,t,s,o){const i=Be(e,o),n=(Math.abs(s)*100).toFixed(1);return`${i} ${Xe(i)} ${t} pass rate ${n} percentage points ${s>0?"higher":"lower"} than ${ve(o)}`}function Ne(e,t,s,o,i,n){const f=Be(e,i),a=ve(i),d=s>0?"higher":"lower";if(o!==void 0&&Number.isFinite(o)){const l=(Math.abs(o)*100).toFixed(1);return`${f} mean ${t} is ${l}% ${d} than ${a}`}const r=n?` ${n}`:"";return`${f} mean ${t} is ${Math.abs(s).toPrecision(3)}${r} ${d} than ${a}`}function xe(e,t,s){const o=t?.find(i=>i.bin===e);return o?.name?`${s} ${e} (${o.name})`:`${s} ${e}`}function nn(e,t){const s=t?.find(o=>o.testNumber===e);return{label:j(s,e),unit:s?.unit,...ge(s)}}const Ze=new WeakMap,Je=new WeakMap,et=new WeakMap;function le(e,t){const s=t.highlight.dieKeys;return s&&et.set(s,e),t}let ne=null,ce;const tt=new WeakMap;export function candidatesOf(e){return tt.get(e)}function nt(e,t,s,o){if(!ne)return;const i=it(e);if(!i)return;const n=e.id.slice(0,e.id.indexOf(":")),f=n==="specLimit"?"limitFail":n,{kind:a,bin:d,index:r}=e.variable;ne.push({key:[f,a,d??"",r??"",i.family,i.key].join("|"),source:f,variable:e.variable,label:e.variable.label,comparison:e.comparison,region:i,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,i=e.region.family;switch(e.source){case"yield":return ze(o,t,i);case"hardBin":case"softBin":return Fe(o,e.label,t,i);case"functional":return Ce(o,e.label.replace(/ pass rate$/,""),t,i);case"limitFail":return Pe(o,e.label,t);case"test":return Ne(o,e.label,t,s,i,e.variable.unit)}}function Pe(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 U=new WeakMap;function we(e,t){return U.set(e,t),e}function it(e){const t=e.highlight.dieKeys;return t?et.get(t):void 0}const st=new WeakMap;function Q(e){let t=st.get(e);return t||st.set(e,t=e.map(Re)),t}function sn(e){let t=Ze.get(e);return t||Ze.set(e,t=e.map(re)),t}function $e(e,t){let s=Je.get(e);s||Je.set(e,s={members:new Set(e),byFamily:new WeakMap});const o=s.byFamily.get(t);if(o)return o;const{members:i}=s,n=new Map;for(const f of t)n.set(f.key,f.dies.filter(a=>i.has(a)));return s.byFamily.set(t,n),n}function on(e,t){adjustPValues(e);for(const i of e){const n=U.get(i);nt(i,twoProportionZ(n.hits,n.n,n.restHits,n.restN),n)}const s=e.filter(i=>passesRateGate(i.stats.adjustedPValue??i.stats.pValue??1,i.effect.absoluteDelta??0,rateRelativeEffect(U.get(i)),t)),o=confirmRegionalFindings(s,ot,(i,n)=>an(i,n,t),i=>isRateLoss(U.get(i)),e);return s.filter(i=>o.has(i)).map(i=>({...i,severity:severityForFinding(i.stats.adjustedPValue??i.stats.pValue??1,i.effect.absoluteDelta??0,rateRelativeEffect(U.get(i)))}))}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,i){const n=[];for(const f of s){const a=f.comparison.family,d=a==="ring"||a==="cluster"?o(f):[];e.some(r=>xt(r,a,d,i))&&(n.push(f.id),t!=="info"&&(a==="ring"||a==="quadrant"||a==="sector")&&(f.severity="info"))}return n}export function confirmRegionalFindings(e,t,s,o,i=e){const n=new Map;for(const d of e)(n.get(t(d))??n.set(t(d),[]).get(t(d))).push(d);const f=new Map;if(o)for(const d of i)o(d)&&(f.get(t(d))??f.set(t(d),[]).get(t(d))).push(d);const a=new Set;for(const[d,r]of n){const l=f.get(d)??[],u=(h,p)=>o&&!o(h)?s(h,[...new Set([...p,...l])].filter(g=>g!==h)):s(h,p);if(r.length===1&&(!o||o(r[0])||l.length===0)){a.add(r[0]);continue}const m=[];let c=[...r];for(;;){let h;for(const p of c){const g=u(p,m);if(g==="baseline-too-small"||!g.passes)continue;const S=o?.(p)??!1;(!h||S&&!h.loss||S===h.loss&&g.pValue<h.p)&&(h={t:p,p:g.pValue,loss:S})}if(!h)break;m.push(h.t),c=c.filter(p=>p!==h.t)}for(;;){let h;for(const p of m){const g=u(p,m.filter(S=>S!==p));g==="baseline-too-small"||g.passes||(!h||g.pValue>h.p)&&(h={t:p,p:g.pValue})}if(!h)break;m.splice(m.indexOf(h.t),1)}for(const h of m)a.add(h)}return a}function ot(e){return[e.variable.kind,e.variable.bin??"",e.variable.index??"",e.comparison.family].join("\0")}function at(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 an(e,t,s){const o=U.get(e);let{restHits:i,restN:n}=o;for(const r of t){const l=U.get(r);l&&(i-=l.hits,n-=l.n)}if(n<s.minimumSampleSize)return"baseline-too-small";const f=o.hits/o.n-i/n,a=Math.min(1,tn(o.hits,o.n,i,n)*at(e)),d=Math.sign(f)===Math.sign(e.effect.absoluteDelta??0)&&passesRateGate(a,f,rateRelativeEffect({...o,restHits:i,restN:n}),s);return{pValue:a,passes:d}}const Ve=new WeakMap;export function welchOfSums(e,t,s,o){const i=(n,f,a)=>a>1?Math.max(0,n-f*f/a)/(a-1):0;return welchFromStats(e.n,e.sum/e.n,i(e.sq,e.sum,e.n),t,s/t,i(o,s,t))}function rn(e,t,s){const o=Ve.get(e);let{restN:i,restSum:n,restSq:f}=o;for(const m of t){const c=Ve.get(m);c&&(i-=c.n,n-=c.sum,f-=c.sq)}if(i<s.minimumSampleSize)return"baseline-too-small";const{pValue:a,effectSize:d,delta:r}=welchOfSums(o,i,n,f),l=Math.min(1,a*at(e)),u=Math.sign(r)===Math.sign(e.effect.absoluteDelta??0)&&l<=s.significanceLevel&&Math.abs(d)>=s.minimumEffectSize;return{pValue:l,passes:u}}function ue(e,t,s,o){const i=new Set(s),n=$e(e,t),f=new Map,a=new Map;for(const[r,l]of n){let u=0,m=0;for(const c of l)c.hbin!==void 0&&(m++,i.has(c.hbin)&&u++);f.set(r,u),a.set(r,m)}const d=[];for(const r of t){const l=a.get(r.key)??0,u=f.get(r.key)??0;let m=0,c=0;for(const[k,v]of a)k!==r.key&&(m+=v,c+=f.get(k)??0);if(l<o.minimumSampleSize||m<o.minimumSampleSize)continue;const h=u/l,p=c/m,g=h-p,{pValue:S,method:F}=H(u,l,c,m);d.push(we(le(r,{id:`yield:${r.key}`,level:"wafer",severity:"info",variable:{kind:"yield",label:"Yield"},comparison:{family:r.family,left:r.label,right:te(r.family)},effect:{direction:g===0?"different":g>0?"higher":"lower",absoluteDelta:g,relativeDelta:p===0?void 0:g/p,effectSize:g},stats:{method:F,pValue:S,sampleSizeLeft:l,sampleSizeRight:m},summary:ze(r.label,g,r.family),highlight:{kind:"region",regionFamily:r.family,regionKeys:[r.key],dieKeys:[...r.dieKeys]}}),{hits:u,n:l,restHits:c,restN:m,passRate:!0}))}return d}function q(e,t,s,o,i,n){const f=h=>s==="soft"?h.sbin:h.hbin,a=[...new Set(e.map(f).filter(h=>h!==void 0))].sort((h,p)=>h-p),d=$e(e,t),r=new Map,l=new Map;for(const[h,p]of d){const g=new Map;for(const S of p){const F=f(S);F!==void 0&&g.set(F,(g.get(F)??0)+1)}r.set(h,g),l.set(h,p.length)}const u=[],m=i==="hardBin"?"HBin":"SBin",c=s==="hard"?new Set(n.passBins):n.softPassBins??Te(e,n.passBins).soft;for(const h of t){const p=l.get(h.key)??0,g=r.get(h.key);let S=0;const F=new Map;for(const[k,v]of r)if(k!==h.key){S+=l.get(k)??0;for(const[B,z]of v)F.set(B,(F.get(B)??0)+z)}if(!(p<n.minimumSampleSize||S<n.minimumSampleSize))for(const k of a){const v=g.get(k)??0,B=F.get(k)??0,z=v/p,b=B/S,w=z-b,{pValue:M,method:y}=H(v,p,B,S),$=xe(k,o,m);u.push(we(le(h,{id:`${i}:${k}:${h.key}`,level:"wafer",severity:"info",variable:{kind:i,bin:k,label:$},comparison:{family:h.family,left:h.label,right:te(h.family)},effect:{direction:w===0?"different":w>0?"higher":"lower",absoluteDelta:w,relativeDelta:b===0?void 0:w/b,effectSize:w},stats:{method:y,pValue:M,sampleSizeLeft:p,sampleSizeRight:S},summary:Fe(h.label,$,w,h.family),highlight:{kind:"bin",bin:k,regionKeys:[h.key],dieKeys:[...h.dieKeys]}}),{hits:v,n:p,restHits:B,restN:S,passRate:c.has(k)}))}}return u}function de(e,t,s,o){const i=(s??[]).filter(l=>!J(l));if(!i.length)return[];const n=i.map(l=>l.testNumber),f=$e(e,t),a=new Map,d=new Map;for(const[l,u]of f){const m=new Uint32Array(i.length),c=new Uint32Array(i.length);for(const h of u)for(let p=0;p<i.length;p++){const g=pe(h,n[p],i[p]);g!==void 0&&(c[p]++,g&&m[p]++)}a.set(l,m),d.set(l,c)}const r=[];for(const l of t){const u=a.get(l.key),m=d.get(l.key);for(let c=0;c<i.length;c++){let h=0,p=0;for(const[w,M]of d)w!==l.key&&(p+=M[c],h+=a.get(w)[c]);const g=m[c],S=u[c];if(g<o.minimumSampleSize||p<o.minimumSampleSize)continue;const F=S/g,k=h/p,v=F-k,{pValue:B,method:z}=H(S,g,h,p),b=n[c];r.push(we(le(l,{id:`functional:${b}:${l.key}`,level:"wafer",severity:"info",variable:{kind:"functionalTest",index:b,label:`${j(i[c],b)} pass rate`,...ge(i[c])},comparison:{family:l.family,left:l.label,right:te(l.family)},effect:{direction:v===0?"different":v>0?"higher":"lower",absoluteDelta:v,relativeDelta:k===0?void 0:v/k,effectSize:v},stats:{method:z,pValue:B,sampleSizeLeft:g,sampleSizeRight:p},summary:Ce(l.label,j(i[c],b),v,l.family),highlight:{kind:"region",regionFamily:l.family,regionKeys:[l.key],dieKeys:[...l.dieKeys]}}),{hits:S,n:g,restHits:h,restN:p,passRate:!0}))}}return r}export function welchFromStats(e,t,s,o,i,n){const f=Math.sqrt(s/e+n/o),a=t-i;if(!Number.isFinite(f)||f===0)return{pValue:1,effectSize:0,delta:a,z:0};const d=a/f,r=Math.sqrt(Math.max(0,(s+n)/2)),l=r===0?a:a/r;return{pValue:We(d),effectSize:l,delta:a,z:d}}function fn(e,t){const s=be(e),o=be(t);return welchFromStats(e.length,s,Me(e,s),t.length,o,Me(t,o))}function rt(e,t,s){const o=new Map;for(const n of s??[])o.has(n.testNumber)||o.set(n.testNumber,n);const i=n=>n.filter(f=>J(o.get(f)));return i(t?t.slice().sort((n,f)=>n-f):Ie(e,"values"))}export function testValueSize(e,t){const s=e.dies.filter(Ge);return{tests:rt(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 ln(e,t,s,o,i){const n=new Map;for(let p=0;p<t.length;p++)for(const g of Q(t[p].dies))n.set(g,p);const f=t.length,a=[],d=[];for(const p of e){const g=n.get(Re(p));g!==void 0&&(a.push(p),d.push(g))}const r=[],l=new Float64Array(f),u=new Float64Array(f),m=new Float64Array(f);for(const p of s){l.fill(0),u.fill(0),m.fill(0);let g=0,S=0,F=0,k;for(let v=0;v<a.length;v++){const B=a[v],z=Y(B,p);if(z===void 0)continue;k===void 0&&(k=z);const b=z-k,w=d[v];l[w]+=1,u[w]+=b,m[w]+=b*b,g+=1,S+=b,F+=b*b}if(k!==void 0)for(let v=0;v<f;v++){const B=l[v],z=g-B;if(B<i.minimumSampleSize||z<i.minimumSampleSize)continue;const b=u[v]/B,M=(S-u[v])/z,y=b+k,$=M+k,P=B>1?Math.max(0,m[v]-B*b*b)/(B-1):0,C=z>1?Math.max(0,F-m[v]-z*M*M)/(z-1):0,{pValue:V,effectSize:x,delta:D,z:O}=welchFromStats(B,y,P,z,$,C),N=t[v],{label:A,unit:L,...G}=nn(p,o),_=$!==0?D/Math.abs($):void 0,X=le(N,{id:`test:${p}:${N.key}`,level:"wafer",severity:"info",variable:{kind:"test",measure:"mean",index:p,label:A,unit:L,...G},comparison:{family:N.family,left:N.label,right:te(N.family)},effect:{direction:D===0?"different":D>0?"higher":"lower",absoluteDelta:D,relativeDelta:_,effectSize:x},stats:{method:"welch-z-approx",pValue:V,sampleSizeLeft:B,sampleSizeRight:z},summary:Ne(N.label,A,D,_,N.family,L),highlight:{kind:"region",regionFamily:N.family,regionKeys:[N.key],dieKeys:[...N.dieKeys]}}),R={n:B,sum:u[v],sq:m[v],restN:z,restSum:S-u[v],restSq:F-m[v],shift:k};Ve.set(X,R),nt(X,O,void 0,R),r.push(X)}}adjustPValues(r);const c=r.filter(p=>{const g=p.stats.adjustedPValue??p.stats.pValue??1,S=Math.abs(p.effect.effectSize??0);return g<=i.significanceLevel&&S>=i.minimumEffectSize}),h=confirmRegionalFindings(c,ot,(p,g)=>rn(p,g,i));return c.filter(p=>h.has(p)).map(p=>({...p,severity:severityForScore(p.stats.adjustedPValue??p.stats.pValue??1,p.effect.effectSize??0)}))}function cn(e,t,s,o){if(!s?.length)return[];const i=s.filter(f=>J(f)&&(f.limitLow!==void 0||f.limitHigh!==void 0));if(!i.length)return[];const n=[];for(const f of i){const a=f.testNumber;for(const d of t){const r=$e(e,d),l=[],u=new Map;let m=0,c=0;for(const[h,p]of r){let g=0,S=0;for(const F of p){const k=Y(F,a);k!==void 0&&(g++,De(ye(k,f))&&S++)}u.set(h,{valid:g,fail:S}),m+=g,c+=S}for(const h of d){const p=u.get(h.key),g=p.valid,S=m-p.valid;if(g<o.minimumSampleSize||S<o.minimumSampleSize)continue;const F=p.fail,k=c-p.fail,v=F/g,B=k/S,z=v-B,{pValue:b,method:w}=H(F,g,k,S);l.push(we(le(h,{id:`specLimit:${a}:${h.key}`,level:"wafer",severity:"info",variable:{kind:"test",measure:"limitFailRate",index:a,label:j(f,a),...ge(f)},comparison:{family:h.family,left:h.label,right:te(h.family)},effect:{direction:z===0?"different":z>0?"higher":"lower",absoluteDelta:z,relativeDelta:B===0?void 0:z/B,effectSize:z},stats:{method:w,pValue:b,sampleSizeLeft:g,sampleSizeRight:S},summary:Pe(h.label,j(f,a),z),highlight:{kind:"region",regionFamily:h.family,regionKeys:[h.key],dieKeys:[...h.dieKeys]}}),{hits:F,n:g,restHits:k,restN:S,passRate:!1}))}n.push(...l)}}return n}function Ee(e,t){return e==="softBin"?t.softEligibleDies:t.eligibleDies}function un(e){return e.variable.measure==="limitFailRate"}function dn(e,t,s,o,i,n){if(e.pattern!=="scratch")return;const f=t.filter(l=>l.comparison.family==="reticle-position"&&l.severity!=="info"&&l.highlight.kind==="region");if(!f.length)return;const a=new Set(f.flatMap(l=>l.highlight.kind==="region"?l.highlight.dieKeys??[]:[])),d=Nt(s().filter(l=>!a.has(re(l))),o,i,n);if(!d||d.pattern==="scratch")return;const r=f[0].comparison.left;return{...d,note:`${r.charAt(0).toLowerCase()}${r.slice(1)}'s failures set aside`}}function me(e){return e.highlight.regionKeys??[]}function mn(e){const t=e.variable.bin??e.variable.index??"";return`${e.comparison.family}\0${ft(e)}\0${e.variable.kind}\0${t}\0${e.effect.direction}`}function hn(e,t){const s=ee(e);return s.family==="ring"?s.ring??0:s.family==="sector"?je(t).indexOf(s.sector??""):0}export function inQuadrantOrder(e){const t=new Set(e),s=ke.findIndex((i,n)=>t.has(i)&&!t.has(ke[(n+3)%4])),o=s<0?0:s;return Array.from({length:4},(i,n)=>ke[(o+n)%4]).filter(i=>t.has(i))}export function findContiguousRuns(e,t,s,o){if(t==="quadrant"){const d=new Map;for(const m of e){const c=ee(o(m)).quadrant;c&&d.set(c,m)}const r=[...d.keys()],l=new Set,u=[];for(const m of r){if(l.has(m))continue;const c=[],h=[m];for(l.add(m);h.length;){const p=h.pop();c.push(p);for(const g of r)!l.has(g)&&Bt(p,g)&&(l.add(g),h.push(g))}u.push(inQuadrantOrder(c).map(p=>d.get(p)))}return u}const i=d=>hn(o(d),s),n=[...e].sort((d,r)=>i(d)-i(r)),f=[];let a=[];for(const d of n){if(a.length===0){a.push(d);continue}const r=i(a[a.length-1]);i(d)-r===1?a.push(d):(f.push(a),a=[d])}if(a.length&&f.push(a),t==="sector"&&f.length>1){const r=je(s).length,l=i(f[0][0]),u=i(f[f.length-1][f[f.length-1].length-1]);if(l===0&&u===r-1){const m=f.pop();f[0]=[...m,...f[0]]}}return f}export function mergedRegionLabel(e,t,s){if(e==="ring"){const i=t.map(d=>ee(d).ring).filter(d=>d!==void 0).sort((d,r)=>d-r),n=i[0],f=i[i.length-1];let a="";return n===f&&n===1&&s>1?a=" (core)":n===f&&n===s&&s>1&&(a=" (edge)"),n===f?`Ring ${n}${a}`:`Rings ${n}\u2013${f}`}if(e==="sector"){const i=t.map(n=>ee(n).sector??"");return i.length===1?`Sector ${i[0]}`:`Sectors ${i[0]}\u2013${i[i.length-1]}`}const o=t.map(i=>ee(i).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 Le(e){return[...new Set(e)]}export function weakestMultiplier(e){return At(e.map(t=>{const s=t.stats.pValue??1;return s>0?(t.stats.adjustedPValue??s)/s:1}))}function ie(e,t){return Math.min(1,e*t)}function pn(e,t){const s=e[0],o=s.comparison.family,i=s.variable.kind,n=Le(e.flatMap(me));let f,a;const d=e.map(it);if(d.every(b=>b!==void 0)){const b=new Set;f=[];for(const M of d){const y=Q(M.dies);for(let $=0;$<y.length;$++)b.has(y[$])||(b.add(y[$]),f.push(M.dieKeys[$]))}const w=Q(Ee(s.variable.kind,t));a=M=>b.has(w[M])}else{f=Le(e.flatMap(M=>M.highlight.dieKeys??[]));const b=new Set(f),w=sn(Ee(s.variable.kind,t));a=M=>b.has(w[M])}const r=mergedRegionLabel(o,e.map(b=>me(b)[0]??""),t.ringCount),l=Ee(i,t),u=t.regionDies[o],m=Q(l),c=[],h=[];for(let b=0;b<l.length;b++)u.has(m[b])&&(a(b)?c:h).push(l[b]);const p=weakestMultiplier(e);let g,S,F,k,v;if(un(s)){const b=s.variable.index,w=t.testDefs?.find(N=>N.testNumber===b),M=N=>{let A=0,L=0;for(const G of N){const _=Y(G,b);_!==void 0&&(A++,w&&De(ye(_,w))&&L++)}return{valid:A,fail:L}},y=M(c),$=M(h),P=y.valid>0?y.fail/y.valid:0,C=$.valid>0?$.fail/$.valid:0,V=P-C,{pValue:x,method:D}=H(y.fail,y.valid,$.fail,$.valid);g={direction:V===0?"different":V>0?"higher":"lower",absoluteDelta:V,relativeDelta:C===0?void 0:V/C,effectSize:V},S={method:D,pValue:x,sampleSizeLeft:y.valid,sampleSizeRight:$.valid};const O=ie(x,p);F=severityForFinding(O,V,rateRelativeEffect({hits:y.fail,n:y.valid,restHits:$.fail,restN:$.valid,passRate:!1})),k=Pe(r,j(w,b),V),v=`specLimit:${b}`}else if(i==="test"){const b=s.variable.index,w=O=>Y(O,b),M=c.map(w).filter(O=>O!==void 0),y=h.map(w).filter(O=>O!==void 0),{pValue:$,effectSize:P,delta:C}=fn(M,y),V=be(y),x=V!==0?C/Math.abs(V):void 0;g={direction:C===0?"different":C>0?"higher":"lower",absoluteDelta:C,relativeDelta:x,effectSize:P},S={method:"welch-z-approx",pValue:$,sampleSizeLeft:M.length,sampleSizeRight:y.length};const D=ie($,p);F=severityForScore(D,P),k=Ne(r,s.variable.label,C,x,o,s.variable.unit),v=`test:${b}`}else if(i==="yield"){const b=new Set(t.passBins),w=c.filter(L=>L.hbin!==void 0),M=h.filter(L=>L.hbin!==void 0),y=w.length,$=M.length,P=w.filter(L=>b.has(L.hbin)).length,C=M.filter(L=>b.has(L.hbin)).length,V=y>0?P/y:0,x=$>0?C/$:0,D=V-x,{pValue:O,method:N}=H(P,y,C,$);g={direction:D===0?"different":D>0?"higher":"lower",absoluteDelta:D,relativeDelta:x===0?void 0:D/x,effectSize:D},S={method:N,pValue:O,sampleSizeLeft:y,sampleSizeRight:$};const A=ie(O,p);F=severityForFinding(A,D,rateRelativeEffect({hits:P,n:y,restHits:C,restN:$,passRate:!0})),k=ze(r,D,o),v="yield"}else if(i==="functionalTest"){const b=s.variable.index,w=t.testDefs?.find(A=>A.testNumber===b);let M=0,y=0,$=0,P=0;for(const A of c){const L=pe(A,b,w);L!==void 0&&(y++,L&&M++)}for(const A of h){const L=pe(A,b,w);L!==void 0&&(P++,L&&$++)}const C=y>0?M/y:0,V=P>0?$/P:0,x=C-V,{pValue:D,method:O}=H(M,y,$,P);g={direction:x===0?"different":x>0?"higher":"lower",absoluteDelta:x,relativeDelta:V===0?void 0:x/V,effectSize:x},S={method:O,pValue:D,sampleSizeLeft:y,sampleSizeRight:P};const N=ie(D,p);F=severityForFinding(N,x,rateRelativeEffect({hits:M,n:y,restHits:$,restN:P,passRate:!0})),k=Ce(r,j(w,b),x,o),v=`functional:${b}`}else{const b=s.variable.bin,w=N=>i==="softBin"?N.sbin:N.hbin,M=c.filter(N=>w(N)===b).length,y=h.filter(N=>w(N)===b).length,$=M/c.length,P=y/h.length,C=$-P,{pValue:V,method:x}=H(M,c.length,y,h.length);g={direction:C===0?"different":C>0?"higher":"lower",absoluteDelta:C,relativeDelta:P===0?void 0:C/P,effectSize:C},S={method:x,pValue:V,sampleSizeLeft:c.length,sampleSizeRight:h.length};const D=ie(V,p);F=severityForFinding(D,C,rateRelativeEffect({hits:M,n:c.length,restHits:y,restN:h.length,passRate:!1}));const O=i==="softBin"?t.sbinDefs:t.hbinDefs;k=Fe(r,xe(b,O,i==="softBin"?"SBin":"HBin"),C,o),v=`${i}:${b}`}S={...S,adjustedPValue:ie(S.pValue??1,p)};const B=Le(n.map(b=>b.replace(`${o}:`,""))).join("-"),z=i==="hardBin"||i==="softBin"?{kind:"bin",bin:s.variable.bin,regionKeys:n,dieKeys:f}:{kind:"region",regionFamily:o,regionKeys:n,dieKeys:f};return{...s,id:`${v}:${o}:${B}`,severity:F,comparison:{family:o,left:r,right:te(o)},effect:g,stats:S,summary:k,highlight:z,relatedIds:e.map(b=>b.id)}}function gn(e,t){const s=new Set(["ring","quadrant","sector"]),o=[],i=new Map;for(const f of e){if(!s.has(f.comparison.family)){o.push(f);continue}const a=mn(f),d=i.get(a)??[];d.push(f),i.set(a,d)}const n=[];for(const f of i.values()){if(f.length===1){n.push(f[0]);continue}const a=f[0].comparison.family;for(const d of findContiguousRuns(f,a,t.sectorCount,r=>me(r)[0]??""))n.push(d.length===1?d[0]:pn(d,t))}return[...o,...n]}function bn(e){const t=new Map,s=new Map;for(const i of e){const n=Re(i);i.hbin!==void 0&&i.hbin!==null&&(t.get(i.hbin)??t.set(i.hbin,new Set).get(i.hbin)).add(n),i.sbin!==void 0&&i.sbin!==null&&(s.get(i.sbin)??s.set(i.sbin,new Set).get(i.sbin)).add(n)}const o=new Set;for(const[i,n]of t)for(const[f,a]of s){if(n.size!==a.size)continue;let d=!0;for(const r of n)if(!a.has(r)){d=!1;break}d&&o.add(`${i}:${f}`)}return o}function yn(e,t){const s=new Set(t);let o;for(const i of e){const n=ae(i,s);if(n!==void 0&&n){if(i.sbin==null||o!==void 0&&i.sbin!==o)return;o=i.sbin}}if(o!==void 0){for(const i of e)if(i.sbin===o&&ae(i,s)!==!0)return;return o}}function Sn(e){return`${e.comparison.family}\0${e.comparison.left}`}export function redundancyFacts(e,t,s){return{coincident:bn(e),yieldSoftBin:yn(e,t),passBins:t,sectorCount:s}}const vn=3/5;function ft(e){return/^(?:lot-region:)?([^:|]+)/.exec(e.id)?.[1]??e.id}function wn(e){const t=me(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 lt(e,t){const s=new Set;for(const o of wn(e)){const i=Ft(o,t);if(!i)return;for(const n of i)s.add(n)}return s.size?s:void 0}export function collapseRedundantFindings(e,t){const{coincident:s,yieldSoftBin:o,passBins:i}=t,n=(r,l)=>{r.absorbedIds=[...r.absorbedIds??[],l.id]},f=new Map;for(const r of e){const l=Sn(r);(f.get(l)??f.set(l,[]).get(l)).push(r)}const a=new Set;for(const r of f.values()){for(const u of r)if(!(u.variable.kind!=="hardBin"||u.variable.bin===void 0))for(const m of r){if(m.variable.kind!=="softBin"||m.variable.bin===void 0||a.has(m.id)||!s.has(`${u.variable.bin}:${m.variable.bin}`)||m.effect.direction!==u.effect.direction)continue;n(u,m),a.add(m.id);const c=u.variable.label.replace(/^HBin\s+/,""),h=m.variable.label.replace(/^SBin\s+/,""),p=c===h?`HBin and SBin ${c} (same dies)`:`${u.variable.label} and ${m.variable.label} (same dies)`;u.summary=u.summary.replace(u.variable.label,p),u.variable.label=p;break}const l=r.find(u=>u.variable.kind==="yield");if(l){for(const u of r)if(!(u===l||a.has(u.id)||!(u.variable.kind==="hardBin"&&i.length===1&&u.variable.bin===i[0]||u.variable.kind==="softBin"&&u.variable.bin===o))){n(l,u),a.add(u.id);for(const c of u.absorbedIds??[])l.absorbedIds=[...l.absorbedIds??[],c]}}}const d=new Map;for(const r of e){if(a.has(r.id)||r.comparison.family!=="sector"&&r.comparison.family!=="quadrant")continue;const l=[ft(r),r.variable.kind,r.variable.bin??"",r.variable.index??"",r.effect.direction].join("\0");(d.get(l)??d.set(l,[]).get(l)).push(r)}for(const r of d.values()){const l=[];for(const u of r.filter(m=>m.comparison.family==="sector")){const m=lt(u,t.sectorCount);if(m)for(const c of r.filter(h=>h.comparison.family==="quadrant")){const h=lt(c,t.sectorCount);if(!h)continue;let p=0;for(const S of m)h.has(S)&&p++;const g=m.size+h.size-p;p/g>=vn-1e-9&&l.push({sector:u,quadrant:c,overlap:p/g})}}l.sort((u,m)=>m.overlap-u.overlap);for(const{sector:u,quadrant:m}of l){if(a.has(u.id)||a.has(m.id))continue;const c=(m.stats.pValue??1)<(u.stats.pValue??1),[h,p]=c?[m,u]:[u,m];n(h,p),a.add(p.id),h.absorbedIds=[...h.absorbedIds??[],...p.absorbedIds??[]]}}}export function analyzeWaferMap(e,t={}){return analyzeWaferMapDecided(e,t)}export function analyzeWaferMapDecided(e,t={},s){const o=ne,i=ce,n=[];ne=n,ce=void 0;try{const f=$n(e,t,s);return tt.set(f,{candidates:n,facts:ce}),f}finally{ne=o,ce=i}}function $n(e,t,s){const{resolved:o,warnings:i}=resolveOptions(t),n=pt(e),f={...o,passBins:[...Vt(n,"analyzeWaferMap")],ringCount:Et(n,"analyzeWaferMap")},a=n.isLotStack,d=n.aggrMethod,r=$t(a,d),l=r,u=n.dies.filter(R=>Ge(R)),m=u.filter(qe),c=It(f,u.length);c.softPassBins=Te(u,c.passBins).soft;const h=rt(u,c.testNumbers,n.testDefs),p=c.enableTestValueAnalysis,g=p===!1?"off":p===!0?"done":s??gt(h.length*u.length),S=n.dies.filter(R=>Z(R)),F=S.filter(qe),k=r?u.filter(R=>R.sbin!==void 0):[],v=l&&u.some(R=>R.hbin!==void 0)||k.length>0||p!==!1,B=v?Mt(F,n.wafer,c.ringCount):[],z=v?Rt(F,n.wafer,c.ringCount):[],b=v?kt(F,n.reticleConfig):[],w=v?zt(S,!1):[],M=v?Dt(F,n.wafer,c.sectorCount):[],y=[],$=[];l&&$.push(...ue(u,B,c.passBins,c),...ue(u,z,c.passBins,c),...ue(u,b,c.passBins,c),...ue(u,w,c.passBins,c),...ue(u,M,c.passBins,c)),l&&$.push(...q(u,B,"hard",n.hbinDefs,"hardBin",c),...q(u,z,"hard",n.hbinDefs,"hardBin",c),...q(u,b,"hard",n.hbinDefs,"hardBin",c),...q(u,w,"hard",n.hbinDefs,"hardBin",c),...q(u,M,"hard",n.hbinDefs,"hardBin",c));{const R=k;$.push(...q(R,B,"soft",n.sbinDefs,"softBin",c),...q(R,z,"soft",n.sbinDefs,"softBin",c),...q(R,b,"soft",n.sbinDefs,"softBin",c),...q(R,w,"soft",n.sbinDefs,"softBin",c),...q(R,M,"soft",n.sbinDefs,"softBin",c))}const P=[...i];let C;if(p!==!1){if(g==="done"){for(const R of[B,z,b,w,M])y.push(...ln(u,R,h,n.testDefs,c));C=h}$.push(...cn(u,[B,z,b,w,M],n.testDefs,c)),$.push(...de(u,B,n.testDefs,c),...de(u,z,n.testDefs,c),...de(u,b,n.testDefs,c),...de(u,w,n.testDefs,c),...de(u,M,n.testDefs,c))}y.push(...on($,c));{const R=jt(a,l,n.testDefs);if(!a||l||R!==void 0){const T=He(m,n.wafer,{...c,isFailingDie:R});y.push(...T),l&&y.push(...Ut(m,n.wafer,n.hbinDefs,c,T))}}const V=gn(y,{eligibleDies:u,softEligibleDies:k,passBins:c.passBins,ringCount:c.ringCount,sectorCount:c.sectorCount,regionDies:{ring:new Set(B.flatMap(R=>Q(R.dies))),quadrant:new Set(z.flatMap(R=>Q(R.dies))),sector:new Set(M.flatMap(R=>Q(R.dies)))},hbinDefs:n.hbinDefs,sbinDefs:n.sbinDefs,testDefs:n.testDefs});y.length=0,y.push(...V),claimForBinClusters(y);let x;if(l){const R=Ct(m,n.wafer,{passBins:c.passBins,ringCount:c.ringCount});x=R??void 0;const T=R?dn(R,y,()=>{const W=new Set(c.passBins);return m.filter(he=>_e(he,W)===!0)},m,n.wafer,c.ringCount):void 0,E=T??R;if(T&&(x=T),E!=null&&E.pattern!=="random"&&E.pattern!=="none"){const W=Pt[E.pattern],he=E.confidence==="high"?"unusual":E.confidence==="medium"?"notable":"info",I=E.features,se=K=>`${(K*100).toFixed(0)}%`,ct=E.pattern==="edge-ring"||E.pattern==="edge-local"?`${se(I.edgeRdd)} of edge dies failing`:E.pattern==="center"?`centroid at ${se(I.centroidDistNorm)} of wafer radius from centre`:E.pattern==="donut"?`${se(Math.max(I.radialFailRates[1],I.radialFailRates[2]))} of dies failing at mid-radius, ${se(I.radialFailRates[0])} at the centre`:E.pattern==="scratch"?`a line ${Math.round(I.lineLength)} dies long and about ${Math.max(1,Math.round(I.lineWidth*2))} wide`:`${se(I.globalRdd)} of dies failing`,ut=new Set(c.passBins),Ke=u.filter(K=>_e(K,ut)===!0),{center:Oe,radius:dt}=n.wafer,mt=new Map(m.map(K=>[re(K),Tt(K.physX-Oe.x,K.physY-Oe.y,dt,c.ringCount)])),ht=new Set(y.flatMap(K=>Ue(K)?K.relatedIds??[]:[])),Ae=claimForPattern([E.pattern],he,y.filter(K=>!ht.has(K.id)),K=>K.comparison.family==="cluster"?[...new Set(K.highlight.kind==="dies"?K.highlight.dieKeys.map(oe=>mt.get(oe)??0):[])]:me(K).map(oe=>ee(oe).ring).filter(oe=>oe!==void 0),c.ringCount);y.push({id:`spatial-pattern:${E.pattern}`,level:"wafer",severity:he,variable:{kind:"spatialPattern",label:W},comparison:{family:"spatial-pattern",left:W,right:"Wafer"},effect:{direction:"different",effectSize:I.globalRdd},stats:{method:"geometry",sampleSizeLeft:Ke.length,sampleSizeRight:u.length},summary:`Spatial pattern: ${W.toLowerCase()} (${E.confidence} confidence) \u2014 ${ct}${E.note?` [${E.note}]`:""}`,highlight:{kind:"dies",dieKeys:Ke.map(K=>re(K))},relatedIds:Ae.length>0?Ae:void 0})}}y.sort((R,T)=>{const E=R.stats.adjustedPValue??R.stats.pValue??1,W=T.stats.adjustedPValue??T.stats.pValue??1;return E!==W?E-W:Math.abs(T.effect.absoluteDelta??0)-Math.abs(R.effect.absoluteDelta??0)});const D=Xt(n.dies,u.length,n.yield.yieldPercent,r);a&&(D.isLotStack=!0,d&&(D.aggregationMethod=d));const O=new Set(f.passBins),N={},A=(R,T)=>{const E=N[R]??={dieKeys:[],lostDies:0};E.dieKeys.push(re(T)),(!r||ae(T,O)!==!0)&&E.lostDies++},L=Zt(n.dies,n.testDefs,A);L&&(D.testSpecYield=L);const G=computeFunctionalYield(n.dies,n.testDefs,A);if(G&&(D.functionalYield=G),Object.keys(N).length&&(D.testFailures=N),x&&(D.spatialPattern=x),C===void 0&&c.computePerTestStats&&(C=h),h.length&&(D.testValueAnalysis=bt(g,h.length,u.length)),C?.length){const R=Jt(n.dies,C,n.testDefs,c.minimumSampleSize);R&&(D.perTestStats=R);const T=yt([{dies:n.dies}],n.testDefs,C);T&&(D.capability=T)}Object.assign(D,St(n.dies,n.testDefs));const _=vt([{dies:n.dies,wafer:n.wafer,passBins:c.passBins,ringCount:c.ringCount}]);_&&(D.regionYield=_),P.length>0&&(D.warnings=P);const X=redundancyFacts(u,c.passBins,c.sectorCount);return collapseRedundantFindings(y,X),ne&&(ce=X),{level:"wafer",hasNotableFindings:y.some(R=>R.severity==="notable"||R.severity==="unusual"),findings:y,wafer:n.wafer.metadata??void 0,analysisOptions:recordedOptions(t),stats:D}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GUIDE_SECTIONS as e}from"./guideSections.js";export const CHART_CATALOGUE=[{id:"bin-map",kind:"map",title:"Bin map",mode:["hardBin","softBin"],example:"display-control.html",about:"Each die coloured by its hard or soft bin, passing bins in greens and failing bins in other colours, to show where the failures are.",see:["test-value-map","bin-pareto"]},{id:"test-value-map",kind:"map",title:"Test value map",mode:["value"],example:"test-values.html",about:"Each die coloured by one test\u2019s value on a colour scale, with the test\u2019s limits on the colour bar, to show where on the wafer the value shifts.",see:["bin-map","limit-passfail-map","test-passfail-map","value-histogram"]},{id:"limit-passfail-map",kind:"map",title:"Limit pass/fail map",example:"test-values.html",about:"Each die coloured by whether its value for one test lies inside the test\u2019s limits, with the dies below the low limit and above the high limit marked apart, to show where a test fails its limits.",see:["test-value-map","test-passfail-map","pass-rate-by-test"]},{id:"test-passfail-map",kind:"map",title:"Test pass/fail map",example:"test-values.html",about:"Each die coloured by the pass or fail the tester recorded for one test, to show where a test failed, whether or not it has a measured value.",see:["limit-passfail-map","test-value-map","pass-rate-by-test"]},{id:"die-attribute-map",kind:"map",title:"Die attribute map",mode:["metadata"],example:"metadata-mode.html",about:"Each die coloured by an attribute the data carries (a test site, a probe step, a zone), to show whether a pattern follows it.",see:["bin-map"]},{id:"stacked-map",kind:"map",title:"Stacked map",mode:["stackedBins","stackedSoftBins","stackedValues"],example:"lot-stack-analysis.html",about:"The wafers of a lot laid over one another die by die: how often a bin occurs, or a value\u2019s mean, median or spread at each position, to show what repeats from wafer to wafer.",see:["difference-map","reticle-cell-yield"]},{id:"pat-verdict-map",kind:"map",title:"PAT verdict map",tab:"overview",about:"Each die coloured by its part average testing verdict (within the limits, an outlier or failing), on the map or on every wafer of a gallery, to show where the PAT outliers sit.",see:["part-average-testing-pat","bin-map","test-value-map"]},{id:"difference-map",kind:"map",title:"Difference map",card:"difference-map",tab:"distributions",about:"One group\u2019s wafer map less another\u2019s, die position by die position, to show where on the wafer they differ.",guide:[e.heatmap],see:["stacked-map","comparison-by-group"]},{id:"yield-by-wafer",kind:"chart",title:"Yield by wafer",cards:["card-yield"],tab:"overview",about:"Yield of each wafer or group: passing dies as a share of judged dies, with partial and edge-excluded dies left out. The line is the median bar.",see:["bin-pareto","what-divides-yield"]},{id:"bin-pareto",kind:"chart",title:"Bin pareto",cards:["card-bin-pareto"],tab:"overview",about:"Dies in each bin, largest first, so the bins that cost the most yield lead. Shown alone, the line is the running share of all dies.",see:["bin-map","pareto"]},{id:"pass-rate-by-test",kind:"chart",title:"Pass rate by test",cards:["card-pass-rate"],tab:"overview",about:"The share of judged dies that pass each test, lowest first, so the tests that fail the most dies lead.",see:["process-capability","bin-pareto"]},{id:"ring-yield",kind:"chart",title:"Ring yield",card:"ring-yield",tab:"overview",about:"Yield of each ring, from the wafer centre to its edge, to show a radial pattern.",see:["quadrant-yield","bin-map"]},{id:"quadrant-yield",kind:"chart",title:"Quadrant yield",card:"quadrant-yield",tab:"overview",about:"Yield of each quarter of the wafer, to show a one-sided pattern.",see:["ring-yield","bin-map"]},{id:"reticle-cell-yield",kind:"chart",title:"Reticle cell yield",card:"reticle-yield",tab:"overview",about:"Yield of each position in the reticle, pooled over every shot on every wafer. A cell low everywhere points at the mask rather than the wafer.",see:["stacked-map","ring-yield"]},{id:"test-value-distribution",kind:"chart",title:"Test value distribution",cards:["card-box"],tab:"distributions",about:"How one test\u2019s values spread on each wafer or group: the box holds the middle half of the dies, the line inside it is the median, and the whiskers reach the lowest and highest values.",see:["box-plot","value-histogram"]},{id:"value-histogram",kind:"chart",title:"Value histogram",cards:["card-histogram"],tab:"distributions",about:"How one test\u2019s values are distributed: the number of dies in each value range, with the test\u2019s limits marked.",see:["histogram","probability-plot","test-value-map"]},{id:"histogram-of-the-dies-picked",kind:"chart",title:"Histogram of the dies picked",cards:["drill-histogram"],tab:"drilldown",about:"How one test\u2019s values are distributed over the dies picked: the number of dies in each value range, with the test\u2019s limits marked.",see:["value-histogram"]},{id:"wafer-to-wafer-trend",kind:"chart",title:"Wafer-to-wafer trend",cards:["card-trend"],tab:"distributions",about:"Each wafer\u2019s mean of one test in wafer order, with a band of one standard deviation either side, to show drift through the lot.",guide:[e.bands],see:["control-chart","line-chart"]},{id:"test-scatter",kind:"chart",title:"Test scatter",cards:["card-scatter"],tab:"correlation",about:"One test against another, a point per die, to show whether the two move together. r is the correlation coefficient and n the number of dies.",guide:[e.fit],see:["test-correlation-matrix","scatter-plot"]},{id:"test-correlation-matrix",kind:"chart",title:"Test correlation matrix",card:"correlation",tab:"correlation",about:"The correlation of every pair of tests. A strong colour means two tests move together; click a cell to show the pair in the scatter.",see:["test-scatter","heatmap"]},{id:"process-capability",kind:"chart",title:"Process capability",card:"capability",tab:"distributions",about:"Every test with limits on one scale, the low limit at 0 and the high limit at 1, sorted lowest Ppk first, so the tests closest to their limits lead.",guide:[e.goal],see:["capability-goal-plot","pass-rate-by-test"]},{id:"comparison-by-group",kind:"table",title:"Comparison by group",card:"comparison",tab:"distributions",about:"Yield and each test compared between groups, counting each wafer once, with how likely a difference this large is by chance.",guide:[e.groups],see:["what-divides-yield","difference-map","box-plot"]},{id:"what-divides-yield",kind:"table",title:"What divides yield",card:"commonality",tab:"overview",about:"The wafer and lot fields ranked by how strongly they divide yield, as places to look for a cause.",guide:[e.dividesYield],see:["comparison-by-group","yield-by-wafer"]},{id:"part-average-testing-pat",kind:"table",title:"Part average testing (PAT)",card:"pat",tab:"overview",about:"Dies outside part average testing limits, set from each wafer\u2019s own spread of each test (the AEC-Q001 method), by wafer and by test.",guide:[e.pat],see:["pat-verdict-map","process-capability","scatter-plot"]},{id:"scatter-plot",kind:"chart",title:"Scatter plot",chart:"scatter",tab:"plots",about:"One field against another, a point per die or per wafer, to show whether they move together.",guide:[e.fit],see:["test-scatter","heatmap"]},{id:"histogram",kind:"chart",title:"Histogram",chart:"histogram",tab:"plots",about:"How a value is distributed: the number of dies or wafers in each value range.",see:["value-histogram","probability-plot","box-plot"]},{id:"box-plot",kind:"chart",title:"Box plot",chart:"box",tab:"plots",about:"How a value spreads in each category: the box holds the middle half, the line inside it is the median, and the whiskers reach the lowest and highest values.",guide:[e.groups],see:["test-value-distribution","nested-categories","probability-plot"]},{id:"bar-chart",kind:"chart",title:"Bar chart",chart:"bar",tab:"plots",about:"A count, a share or a summary value for each category, side by side.",see:["pareto","stacked-bars-and-shares","yield-by-wafer"]},{id:"line-chart",kind:"chart",title:"Line chart",chart:"line",tab:"plots",about:"A summary value in order along the X axis (wafer order, a test, a condition), to show a trend.",guide:[e.bands],see:["control-chart","sweep","wafer-to-wafer-trend"]},{id:"sweep",kind:"chart",title:"Sweep",chart:"sweep",tab:"plots",about:"A measured value against a swept condition, a curve per series, to show how the part responds across the range.",see:["line-chart"]},{id:"probability-plot",kind:"chart",title:"Probability plot",chart:"probability",tab:"plots",about:"The share of values at or below each value, a curve per colour, so whole distributions compare, tails included.",guide:[e.probability],see:["histogram","box-plot"]},{id:"control-chart",kind:"chart",title:"Control chart",chart:"control",tab:"plots",about:"One value per wafer in order against its centre line and control limits, with the points that break a Western Electric rule marked.",guide:[e.control],see:["wafer-to-wafer-trend","line-chart","capability-goal-plot"]},{id:"capability-goal-plot",kind:"chart",title:"Capability goal plot",chart:"goal",tab:"plots",about:"Each test with both limits placed by how far its mean is off centre and how wide its spread is, as shares of its limit window. A test outside the solid triangle is short of Ppk 1.33.",guide:[e.goal],see:["process-capability","control-chart"]},{id:"heatmap",kind:"chart",title:"Heatmap",chart:"heatmap",tab:"plots",about:"A value for every pair of two categories, as a colour, to show where the two interact.",guide:[e.heatmap],see:["test-correlation-matrix","difference-map","bar-chart"]},{id:"pareto",kind:"chart",title:"Pareto",tab:"plots",about:"Categories largest first with a line for their running share, to show which few account for most of the total.",see:["bin-pareto","bar-chart"]},{id:"stacked-bars-and-shares",kind:"chart",title:"Stacked bars and shares",tab:"plots",about:"Each bar split into its colours, as counts or as each colour\u2019s share of its own total, to show what a category is made of.",see:["bar-chart"]},{id:"nested-categories",kind:"chart",title:"Nested categories",tab:"plots",about:"A box or bar with categories inside categories, such as lots with their wafers, to show whether variation sits between or within the groups.",guide:[e.ranges],see:["box-plot","bar-chart"]},{id:"panels-small-multiples",kind:"chart",title:"Panels (small multiples)",tab:"plots",about:"One small chart per value of a field, on shared axes, to compare the same view across groups side by side.",guide:[e.ranges],see:["box-plot","scatter-plot","histogram"]},{id:"statistics-table",kind:"table",title:"Statistics table",tab:"data",about:"One row per test and group: the count, mean, spread, extremes, limits and capability, to read the numbers behind the charts.",see:["dies-table","process-capability"]},{id:"dies-table",kind:"table",title:"Dies table",tab:"data",about:"One row per die with its position, bin and values, to see exactly which dies a chart counts; it exports to CSV.",see:["wafers-table","statistics-table"]},{id:"wafers-table",kind:"table",title:"Wafers table",tab:"data",about:"One row per wafer with its attributes and its yield, to check what each wafer is and to compare them.",see:["dies-table","yield-by-wafer"]}];export function catalogueEntry(t){return CHART_CATALOGUE.find(a=>a.id===t)}
|
|
1
|
+
import{GUIDE_SECTIONS as e}from"./guideSections.js";export const CHART_CATALOGUE=[{id:"bin-map",kind:"map",title:"Bin map",mode:["hardBin","softBin"],example:"display-control.html",about:"Each die coloured by its hard or soft bin, passing bins in greens and failing bins in other colours, to show where the failures are.",see:["test-value-map","bin-pareto"]},{id:"test-value-map",kind:"map",title:"Test value map",mode:["value"],example:"test-values.html",about:"Each die coloured by one test\u2019s value on a colour scale, with the test\u2019s limits on the colour bar, to show where on the wafer the value shifts.",see:["bin-map","limit-passfail-map","test-passfail-map","value-histogram"]},{id:"limit-passfail-map",kind:"map",title:"Limit pass/fail map",example:"test-values.html",about:"Each die coloured by whether its value for one test lies inside the test\u2019s limits, with the dies below the low limit and above the high limit marked apart, to show where a test fails its limits.",see:["test-value-map","test-passfail-map","pass-rate-by-test"]},{id:"test-passfail-map",kind:"map",title:"Test pass/fail map",example:"test-values.html",about:"Each die coloured by the pass or fail the tester recorded for one test, to show where a test failed, whether or not it has a measured value.",see:["limit-passfail-map","test-value-map","pass-rate-by-test"]},{id:"die-attribute-map",kind:"map",title:"Die attribute map",mode:["metadata"],example:"metadata-mode.html",about:"Each die coloured by an attribute the data carries (a test site, a probe step, a zone), to show whether a pattern follows it.",see:["bin-map"]},{id:"stacked-map",kind:"map",title:"Stacked map",mode:["stackedBins","stackedSoftBins","stackedValues"],example:"lot-stack-analysis.html",about:"The wafers of a lot laid over one another die by die: how often a bin occurs, or a value\u2019s mean, median or spread at each position, to show what repeats from wafer to wafer.",see:["difference-map","reticle-cell-yield"]},{id:"pat-verdict-map",kind:"map",title:"PAT verdict map",tab:"overview",about:"Each die coloured by its part average testing verdict (within the limits, an outlier or failing), on the map or on every wafer of a gallery, to show where the PAT outliers sit.",see:["part-average-testing-pat","bin-map","test-value-map"]},{id:"difference-map",kind:"map",title:"Difference map",card:"difference-map",tab:"distributions",about:"One group\u2019s wafer map less another\u2019s, die position by die position, to show where on the wafer they differ.",guide:[e.heatmap],see:["stacked-map","comparison-by-group"]},{id:"yield-by-wafer",kind:"chart",title:"Yield by wafer",cards:["card-yield"],tab:"overview",about:"Yield of each wafer or group: passing dies as a share of judged dies, with partial and edge-excluded dies left out. The line is the median bar.",see:["bin-pareto","what-divides-yield"]},{id:"bin-pareto",kind:"chart",title:"Bin pareto",cards:["card-bin-pareto"],tab:"overview",about:"Dies in each bin, largest first, so the bins that cost the most yield lead. Shown alone, the line is the running share of all dies.",see:["bin-map","pareto"]},{id:"pass-rate-by-test",kind:"chart",title:"Pass rate by test",cards:["card-pass-rate"],tab:"overview",about:"The share of judged dies that pass each test, lowest first, so the tests that fail the most dies lead.",see:["process-capability","bin-pareto"]},{id:"ring-yield",kind:"chart",title:"Ring yield",card:"ring-yield",tab:"overview",about:"Yield of each ring, from the wafer centre to its edge, to show a radial pattern.",see:["ring-yield-by-wafer","quadrant-yield","bin-map"]},{id:"ring-yield-by-wafer",kind:"chart",title:"Ring yield by wafer",cards:["card-ring-wafer"],tab:"overview",about:"Yield of each ring on each wafer (or group), as a colour, to show whether a radial pattern is on every wafer or on one.",guide:[e.heatmap],see:["ring-yield","heatmap"]},{id:"quadrant-yield",kind:"chart",title:"Quadrant yield",card:"quadrant-yield",tab:"overview",about:"Yield of each quarter of the wafer, to show a one-sided pattern.",see:["quadrant-yield-by-wafer","ring-yield","bin-map"]},{id:"quadrant-yield-by-wafer",kind:"chart",title:"Quadrant yield by wafer",cards:["card-quadrant-wafer"],tab:"overview",about:"Yield of each quarter of the wafer on each wafer (or group), as a colour, to show whether a one-sided pattern is on every wafer or on one.",guide:[e.heatmap],see:["quadrant-yield","ring-yield-by-wafer","heatmap"]},{id:"reticle-cell-yield",kind:"chart",title:"Reticle cell yield",card:"reticle-yield",tab:"overview",about:"Yield of each position in the reticle, pooled over every shot on every wafer. A cell low everywhere points at the mask rather than the wafer.",see:["stacked-map","ring-yield"]},{id:"test-value-distribution",kind:"chart",title:"Test value distribution",cards:["card-box"],tab:"distributions",about:"How one test\u2019s values spread on each wafer or group: the box holds the middle half of the dies, the line inside it is the median, and the whiskers reach the lowest and highest values.",see:["box-plot","value-histogram"]},{id:"value-histogram",kind:"chart",title:"Value histogram",cards:["card-histogram"],tab:"distributions",about:"How one test\u2019s values are distributed: the number of dies in each value range, with the test\u2019s limits marked.",see:["histogram","probability-plot","test-value-map"]},{id:"histogram-of-the-dies-picked",kind:"chart",title:"Histogram of the dies picked",cards:["drill-histogram"],tab:"drilldown",about:"How one test\u2019s values are distributed over the dies picked: the number of dies in each value range, with the test\u2019s limits marked.",see:["value-histogram"]},{id:"wafer-to-wafer-trend",kind:"chart",title:"Wafer-to-wafer trend",cards:["card-trend"],tab:"distributions",about:"Each wafer\u2019s mean of one test in wafer order, with a band of one standard deviation either side, to show drift through the lot.",guide:[e.bands],see:["control-chart","line-chart"]},{id:"test-scatter",kind:"chart",title:"Test scatter",cards:["card-scatter"],tab:"correlation",about:"One test against another, a point per die, to show whether the two move together. r is the correlation coefficient and n the number of dies.",guide:[e.fit],see:["test-correlation-matrix","scatter-plot"]},{id:"test-correlation-matrix",kind:"chart",title:"Test correlation matrix",card:"correlation",tab:"correlation",about:"The correlation of every pair of tests. A strong colour means two tests move together; click a cell to show the pair in the scatter.",see:["test-scatter","heatmap"]},{id:"process-capability",kind:"chart",title:"Process capability",card:"capability",tab:"distributions",about:"Every test with limits on one scale, the low limit at 0 and the high limit at 1, sorted lowest Ppk first, so the tests closest to their limits lead.",guide:[e.goal],see:["capability-goal-plot","pass-rate-by-test"]},{id:"comparison-by-group",kind:"table",title:"Comparison by group",card:"comparison",tab:"distributions",about:"Yield and each test compared between groups, counting each wafer once, with how likely a difference this large is by chance.",guide:[e.groups],see:["what-divides-yield","difference-map","box-plot"]},{id:"what-divides-yield",kind:"table",title:"What divides yield",card:"commonality",tab:"overview",about:"The wafer and lot fields ranked by how strongly they divide yield, as places to look for a cause.",guide:[e.dividesYield],see:["comparison-by-group","yield-by-wafer"]},{id:"part-average-testing-pat",kind:"table",title:"Part average testing (PAT)",card:"pat",tab:"overview",about:"Dies outside part average testing limits, set from each wafer\u2019s own spread of each test (the AEC-Q001 method), by wafer and by test.",guide:[e.pat],see:["pat-verdict-map","process-capability","scatter-plot"]},{id:"scatter-plot",kind:"chart",title:"Scatter plot",chart:"scatter",tab:"plots",about:"One field against another, a point per die or per wafer, to show whether they move together.",guide:[e.fit],see:["test-scatter","heatmap"]},{id:"histogram",kind:"chart",title:"Histogram",chart:"histogram",tab:"plots",about:"How a value is distributed: the number of dies or wafers in each value range.",see:["value-histogram","probability-plot","box-plot"]},{id:"box-plot",kind:"chart",title:"Box plot",chart:"box",tab:"plots",about:"How a value spreads in each category: the box holds the middle half, the line inside it is the median, and the whiskers reach the lowest and highest values.",guide:[e.groups],see:["test-value-distribution","nested-categories","probability-plot"]},{id:"bar-chart",kind:"chart",title:"Bar chart",chart:"bar",tab:"plots",about:"A count, a share or a summary value for each category, side by side.",see:["pareto","stacked-bars-and-shares","yield-by-wafer"]},{id:"line-chart",kind:"chart",title:"Line chart",chart:"line",tab:"plots",about:"A summary value in order along the X axis (wafer order, a test, a condition), to show a trend.",guide:[e.bands],see:["control-chart","sweep","wafer-to-wafer-trend"]},{id:"sweep",kind:"chart",title:"Sweep",chart:"sweep",tab:"plots",about:"A measured value against a swept condition, a curve per series, to show how the part responds across the range.",see:["line-chart"]},{id:"probability-plot",kind:"chart",title:"Probability plot",chart:"probability",tab:"plots",about:"The share of values at or below each value, a curve per colour, so whole distributions compare, tails included.",guide:[e.probability],see:["histogram","box-plot"]},{id:"control-chart",kind:"chart",title:"Control chart",chart:"control",tab:"plots",about:"One value per wafer in order against its centre line and control limits, with the points that break a Western Electric rule marked.",guide:[e.control],see:["wafer-to-wafer-trend","line-chart","capability-goal-plot"]},{id:"capability-goal-plot",kind:"chart",title:"Capability goal plot",chart:"goal",tab:"plots",about:"Each test with both limits placed by how far its mean is off centre and how wide its spread is, as shares of its limit window. A test outside the solid triangle is short of Ppk 1.33.",guide:[e.goal],see:["process-capability","control-chart"]},{id:"heatmap",kind:"chart",title:"Heatmap",chart:"heatmap",tab:"plots",about:"A value for every pair of two categories, as a colour, to show where the two interact.",guide:[e.heatmap],see:["test-correlation-matrix","difference-map","bar-chart"]},{id:"pareto",kind:"chart",title:"Pareto",tab:"plots",about:"Categories largest first with a line for their running share, to show which few account for most of the total.",see:["bin-pareto","bar-chart"]},{id:"stacked-bars-and-shares",kind:"chart",title:"Stacked bars and shares",tab:"plots",about:"Each bar split into its colours, as counts or as each colour\u2019s share of its own total, to show what a category is made of.",see:["bar-chart"]},{id:"nested-categories",kind:"chart",title:"Nested categories",tab:"plots",about:"A box or bar with categories inside categories, such as lots with their wafers, to show whether variation sits between or within the groups.",guide:[e.ranges],see:["box-plot","bar-chart"]},{id:"panels-small-multiples",kind:"chart",title:"Panels (small multiples)",tab:"plots",about:"One small chart per value of a field, on shared axes, to compare the same view across groups side by side.",guide:[e.ranges],see:["box-plot","scatter-plot","histogram"]},{id:"statistics-table",kind:"table",title:"Statistics table",tab:"data",about:"One row per test and group: the count, mean, spread, extremes, limits and capability, to read the numbers behind the charts.",see:["dies-table","process-capability"]},{id:"dies-table",kind:"table",title:"Dies table",tab:"data",about:"One row per die with its position, bin and values, to see exactly which dies a chart counts; it exports to CSV.",see:["wafers-table","statistics-table"]},{id:"wafers-table",kind:"table",title:"Wafers table",tab:"data",about:"One row per wafer with its attributes and its yield, to check what each wafer is and to compare them.",see:["dies-table","yield-by-wafer"]}];export function catalogueEntry(t){return CHART_CATALOGUE.find(a=>a.id===t)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{seededRandom as
|
|
1
|
+
import{seededRandom as ot}from"./math.js";import{ringOf as at}from"../core/classify.js";import{compassBucket as rt,sectorCompassNames as lt}from"./regions.js";import{diePassStatus as G,getDieKey as ct,gridKey as V}from"../core/dies.js";import{findConnectedComponents as ut,LargestComponentSizer as ft}from"./connectedComponents.js";import{median as H}from"../core/utils.js";function ht(t,i){return lt(16)[rt(t,i,16)]}function mt(t){if(t.length<2)return 0;const i=[...t].sort((s,n)=>s-n);let e=i[0]+2*Math.PI-i[i.length-1];for(let s=1;s<i.length;s++)e=Math.max(e,i[s]-i[s-1]);return 2*Math.PI-e}function dt(t,i,e,s){const n=s!==void 0?Math.abs(s):0;return t<=.01&&(i>=.25||n>=2||e>=.1)?"unusual":t<=.05&&(i>=.15||n>=1||e>=.03)?"notable":"info"}const gt=99,pt=9999,W=10;class yt{sizer;failCount;maxima=[];random;order;failing;constructor(i,e,s,n){this.sizer=i,this.failCount=s,this.random=ot(n),this.order=new Int32Array(e);for(let h=0;h<e;h++)this.order[h]=h;this.failing=new Uint8Array(e)}at(i){const{order:e,failing:s,failCount:n,random:h}=this,g=e.length;for(;this.maxima.length<=i;){for(let a=0;a<n;a++){const S=a+Math.floor(h()*(g-a)),p=e[a];e[a]=e[S],e[S]=p,s[e[a]]=1}this.maxima.push(this.sizer.largest(s));for(let a=0;a<n;a++)s[e[a]]=0}return this.maxima[i]}pValue(i,e){let s=0;for(let n=0;n<e;n++)if(this.at(n)>=i&&++s===W)return W/(n+1);return(1+s)/(1+e)}}function bt(t){let i=0,e=0;for(let s=0;s<t.length;s++){let n=Math.imul(t[s].x|0,2654435761)^Math.imul(t[s].y|0,2246822507);n=Math.imul(n^n>>>16,2146121005),n=Math.imul(n^n>>>15,2221713035),i=i+(n^n>>>16)|0,e=e+Math.imul(n,668265263)+374761393|0}return`${t.length}:${i>>>0}:${e>>>0}`}function xt(t,i){return t<=20?t:Math.min(i,Math.ceil(20*1.05**Math.ceil(Math.log(t/20)/Math.log(1.05))))}const Mt=new Map,$t=new Map;function Z(t,i,e,s){let n=t.get(i);return n===void 0&&(n=s(),t.set(i,n),t.size>e&&t.delete(t.keys().next().value)),n}function St(t,i,e,s){const n=t.length,h=Math.min(pt,Math.max(gt,Math.ceil(1/s))),g=bt(t),a=xt(i,n),S=Z($t,`${g}:${a}`,16,()=>{const p=Z(Mt,g,4,()=>new ft([...t].sort((x,m)=>x.y-m.y||x.x-m.x))),[,F,D]=g.split(":").map(Number);return new yt(p,n,a,(F^Math.imul(D,739982445)^Math.imul(a+1,2246822507))>>>0)});return e.map(p=>S.pValue(p,h))}export function buildClusterFindings(t,i,e){const{passBins:s,significanceLevel:n,minimumEffectSize:h,minimumRelativeEffect:g,minimumSampleSize:a,minimumClusterSize:S,ringCount:p}=e,F=new Set(s);if(e.isFailingDie||(t=t.filter(o=>G(o,F)!==void 0)),t.length<a)return[];const D=e.isFailingDie??(o=>G(o,F)===!1),x=t.filter(D),m=x.length/t.length;if(x.length===0)return[];if(m===1&&h>0&&g>0)return[];const q=Math.max(1,Math.floor(t.length/1001)),R=[],X=[];for(let o=0;o<t.length;o+=q)R.push(t[o].width),X.push(t[o].height);const K=R.length?H(R):10,T=X.length?H(X):10,B=Math.max(K,T)*1.5,Y=new Map;for(const o of t)Y.set(V(o.x,o.y),o);const O=Math.ceil(B/K),U=Math.ceil(B/T),J=ut(x),_=[],v=[],I=i.center.x,A=i.center.y,Q=i.radius;for(const o of J){if(o.length<S)continue;const c=new Set(o.map(f=>V(f.x,f.y)));for(const f of o)for(let r=-U;r<=U;r++)for(let C=-O;C<=O;C++){const w=V(f.x+C,f.y+r);if(c.has(w))continue;const P=Y.get(w);P&&Math.hypot(P.physX-f.physX,P.physY-f.physY)<=B&&c.add(w)}const u=[...c].map(f=>Y.get(f)).filter(Boolean),d=o.length,y=u.length;if(y<a)continue;const M=d/y,z=M-m,$=m>0?z/m:void 0;(z>=h||$!==void 0&&$>=g)&&v.push({component:o,k:d,clusterRate:M,delta:z,relativeDelta:$})}if(!v.length)return[];const tt=St(t,x.length,v.map(o=>o.k),n);for(let o=0;o<v.length;o++){const{component:c,k:u,clusterRate:d,delta:y,relativeDelta:M}=v[o],z=tt[o],$=z;if($>n)continue;const N=c.reduce((l,E)=>l+E.physX,0)/u,f=c.reduce((l,E)=>l+E.physY,0)/u;let r=c[0],C=1/0;for(const l of c){const E=Math.hypot(l.physX-N,l.physY-f);E<C&&(C=E,r=l)}const w=mt(c.map(l=>Math.atan2(l.physY-A,l.physX-I)))*180/Math.PI,k=c.filter(l=>at(l.physX-I,l.physY-A,Q,p)===p).length>u/2&&w<120;if(k&&e.bin)continue;const L=k?"edge-arc":"cluster",j=ht(N-I,f-A),b=e.bin,et=k?`Edge arc ~${j}`:`Cluster at (${r.x}, ${r.y})`,nt=u/t.length,it=dt($,y,nt,M),st=c.map(l=>ct(l));_.push({id:b?`${L}:hardBin:${b.bin}:${r.x},${r.y}`:`${L}:${r.x},${r.y}`,level:"wafer",severity:it,variable:b?{kind:"hardBin",bin:b.bin,label:b.label}:{kind:"yield",label:"Yield"},comparison:{family:L,left:et,right:"Rest of wafer"},effect:b?{direction:"higher",absoluteDelta:y,relativeDelta:M,effectSize:y}:{direction:"lower",absoluteDelta:-y,relativeDelta:M!==void 0?-M:void 0,effectSize:y},stats:{method:"permutation",pValue:z,adjustedPValue:$,sampleSizeLeft:u,sampleSizeRight:t.length-u},summary:k?`Edge arc near ${j}: ${u} contiguous failing dies (${(d*100).toFixed(0)}% vs ${(m*100).toFixed(0)}% background)`:b?`${b.label} cluster at (${r.x}, ${r.y}): ${u} contiguous dies (${(d*100).toFixed(0)}% vs ${(m*100).toFixed(0)}% background)`:`Failure cluster at (${r.x}, ${r.y}): ${u} contiguous failing dies (${(d*100).toFixed(0)}% vs ${(m*100).toFixed(0)}% background)`,highlight:{kind:"dies",dieKeys:st}})}return _.sort((o,c)=>{const u=o.stats.pValue??1,d=c.stats.pValue??1;return u!==d?u-d:Math.abs(c.effect.effectSize??0)-Math.abs(o.effect.effectSize??0)})}
|
|
@@ -29,6 +29,11 @@ export interface PlotContext {
|
|
|
29
29
|
/** The Insights tab's Group by key, which "follow Group by" resolves to. Absent outside the tab. */
|
|
30
30
|
groupBy?: string;
|
|
31
31
|
curation?: Record<string, FacetCuration>;
|
|
32
|
+
/**
|
|
33
|
+
* What the plot's items are, when they are not wafers: a selection and the rest of its wafer, say. The footnote then says
|
|
34
|
+
* "24 dies · selection vs the rest of W07" rather than counting the two groups as wafers.
|
|
35
|
+
*/
|
|
36
|
+
populationLabel?: string;
|
|
32
37
|
/** @internal The dies a rescaling is measured over: a panel's values are scaled as the whole plot's are. */
|
|
33
38
|
scaleDies?: readonly Die[];
|
|
34
39
|
/** @internal The panels divide a set of tests by test, so neither X nor the colour has to. */
|
|
@@ -321,6 +326,8 @@ export interface ResolvedPlot {
|
|
|
321
326
|
wafers: number;
|
|
322
327
|
dies: number;
|
|
323
328
|
};
|
|
329
|
+
/** From `PlotContext.populationLabel`: replaces the wafer count in the footnote. */
|
|
330
|
+
populationLabel?: string;
|
|
324
331
|
/** Marks drawn. */
|
|
325
332
|
plotted: number;
|
|
326
333
|
/** Marks left out because a value was missing, by the field it was missing from. */
|