@wafertools/wafermap 0.35.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +13 -10
- package/CHANGELOG.md +474 -0
- package/README.md +7 -7
- package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
- package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
- package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
- package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
- package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
- package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
- package/dist/packages/canvas-adapter/charts/index.js +1 -1
- package/dist/packages/canvas-adapter/charts/patCard.d.ts +21 -0
- package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
- package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
- package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
- package/dist/packages/canvas-adapter/dieList.js +2 -2
- package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
- package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
- package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
- package/dist/packages/canvas-adapter/filterButton.js +1 -0
- package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
- package/dist/packages/canvas-adapter/filterEditor.js +1 -0
- package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
- package/dist/packages/canvas-adapter/guideWindow.js +1 -1
- package/dist/packages/canvas-adapter/icons.js +1 -1
- package/dist/packages/canvas-adapter/index.d.ts +1 -0
- package/dist/packages/canvas-adapter/index.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +57 -2
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
- package/dist/packages/canvas-adapter/pageFilter.js +2 -0
- package/dist/packages/canvas-adapter/patMaps.d.ts +26 -0
- package/dist/packages/canvas-adapter/patMaps.js +1 -0
- package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
- package/dist/packages/canvas-adapter/plotCard.js +1 -0
- package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
- package/dist/packages/canvas-adapter/plotEditor.js +1 -1
- package/dist/packages/canvas-adapter/plotModal.js +1 -1
- package/dist/packages/canvas-adapter/plotStore.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +71 -37
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +22 -9
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
- package/dist/packages/canvas-adapter/testValueOffer.d.ts +14 -0
- package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +12 -6
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +607 -117
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/warnings.js +1 -1
- package/dist/packages/core/aggregates.d.ts +10 -0
- package/dist/packages/core/aggregates.js +1 -1
- package/dist/packages/core/classify.d.ts +11 -0
- package/dist/packages/core/classify.js +1 -1
- package/dist/packages/core/dieTable.d.ts +5 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/dies.d.ts +2 -0
- package/dist/packages/core/dies.js +1 -1
- package/dist/packages/core/wafer.d.ts +10 -1
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildView.d.ts +5 -0
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +21 -4
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/deprecate.d.ts +2 -8
- package/dist/packages/renderer/deprecate.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.js +1 -1
- package/dist/packages/renderer/fmt.d.ts +10 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +1 -0
- package/dist/packages/renderer/index.js +1 -1
- package/dist/packages/renderer/testLabel.d.ts +0 -11
- package/dist/packages/renderer/testLabel.js +1 -1
- package/dist/packages/renderer/valueFilter.d.ts +1 -1
- package/dist/packages/renderer/valueFilter.js +1 -1
- package/dist/packages/stats/analyzeWaferLot.d.ts +22 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +26 -1
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/binPareto.d.ts +2 -54
- package/dist/packages/stats/binPareto.js +1 -1
- package/dist/packages/stats/binRows.js +1 -1
- package/dist/packages/stats/capability.d.ts +10 -0
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/cardSpec.d.ts +53 -0
- package/dist/packages/stats/cardSpec.js +1 -0
- package/dist/packages/stats/chartCatalogue.d.ts +37 -0
- package/dist/packages/stats/chartCatalogue.js +1 -0
- package/dist/packages/stats/clusterDetection.d.ts +9 -0
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/commonality.d.ts +62 -0
- package/dist/packages/stats/commonality.js +1 -0
- package/dist/packages/stats/connectedComponents.js +1 -1
- package/dist/packages/stats/control.d.ts +21 -0
- package/dist/packages/stats/control.js +1 -0
- package/dist/packages/stats/correlation.d.ts +42 -4
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/dieRegions.d.ts +4 -1
- package/dist/packages/stats/dieRegions.js +1 -1
- package/dist/packages/stats/differenceMap.d.ts +22 -0
- package/dist/packages/stats/differenceMap.js +1 -0
- package/dist/packages/stats/examplePicks.d.ts +22 -0
- package/dist/packages/stats/examplePicks.js +1 -0
- package/dist/packages/stats/filterFile.d.ts +41 -0
- package/dist/packages/stats/filterFile.js +2 -0
- package/dist/packages/stats/filterFindings.d.ts +21 -6
- package/dist/packages/stats/filterFindings.js +1 -1
- package/dist/packages/stats/findingText.d.ts +8 -0
- package/dist/packages/stats/findingText.js +2 -2
- package/dist/packages/stats/groupCompare.d.ts +87 -0
- package/dist/packages/stats/groupCompare.js +1 -0
- package/dist/packages/stats/guideSections.d.ts +55 -0
- package/dist/packages/stats/guideSections.js +1 -0
- package/dist/packages/stats/index.d.ts +5 -2
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/lotDrift.js +1 -1
- package/dist/packages/stats/math.d.ts +29 -4
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/mergeTestDefs.js +1 -1
- package/dist/packages/stats/metadataColumns.d.ts +3 -0
- package/dist/packages/stats/metadataColumns.js +1 -1
- package/dist/packages/stats/pat.d.ts +58 -0
- package/dist/packages/stats/pat.js +1 -0
- package/dist/packages/stats/patSummary.d.ts +45 -0
- package/dist/packages/stats/patSummary.js +1 -0
- package/dist/packages/stats/patternClassification.d.ts +3 -3
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/plotData.d.ts +294 -17
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotId.d.ts +2 -0
- package/dist/packages/stats/plotId.js +1 -1
- package/dist/packages/stats/plotReferences.d.ts +17 -0
- package/dist/packages/stats/plotReferences.js +1 -0
- package/dist/packages/stats/plotSpec.d.ts +239 -3
- package/dist/packages/stats/plotSpec.js +4 -4
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +5 -12
- package/dist/packages/stats/reportHtml.js +98 -40
- package/dist/packages/stats/synthesis.d.ts +48 -16
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/testPassRate.d.ts +7 -0
- package/dist/packages/stats/testPassRate.js +1 -1
- package/dist/packages/stats/testValueBudget.d.ts +15 -0
- package/dist/packages/stats/testValueBudget.js +1 -0
- package/dist/packages/stats/types.d.ts +90 -30
- package/dist/packages/stats/yield.d.ts +3 -11
- package/dist/packages/stats/yield.js +1 -1
- package/llms.txt +1 -1
- package/package.json +2 -1
- package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
- package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
- package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
- package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
- package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
- package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
- package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
- package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
- package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
- package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
- package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
- package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
- package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
- package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
- package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
- package/dist/packages/canvas-adapter/charts/trend.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{isParametricTest as c}from"../buildWaferMap.js";import{hasSpecLimits as l}from"../spec.js";export const DIE_FIELD_CALLS={dieX:"x",dieY:"y",hbin:"hbin",sbin:"sbin",site:"site"},FUNCTIONS={abs:[{arity:1,returns:"number"}],sqrt:[{arity:1,returns:"number"}],ln:[{arity:1,returns:"number"}],log10:[{arity:1,returns:"number"}],exp:[{arity:1,returns:"number"}],floor:[{arity:1,returns:"number"}],ceil:[{arity:1,returns:"number"}],round:[{arity:1,returns:"number"}],sign:[{arity:1,returns:"number"}],pow:[{arity:2,returns:"number"}],min:[{vecOf:"numberVec",returns:"number"},{variadic:!0,returns:"number"}],max:[{vecOf:"numberVec",returns:"number"},{variadic:!0,returns:"number"}],if:[{arity:3,returns:"number"}],all:[{vecOf:"boolVec",returns:"boolean"}],any:[{vecOf:"boolVec",returns:"boolean"}],none:[{vecOf:"boolVec",returns:"boolean"}],countTrue:[{vecOf:"boolVec",returns:"number"}],countFalse:[{vecOf:"boolVec",returns:"number"}],mean:[{vecOf:"numberVec",returns:"number"}],sum:[{vecOf:"numberVec",returns:"number"}],countKnown:[{vecOf:"any",returns:"number"}]};const d=["t","testPass","specPass"],b=["<=",">=","==","!=","..","+","-","*","/","%","^","<",">"],m=["(",")","[","]",","];class o extends Error{position;constructor(t,e){super(t),this.position=e}}function h(r){const t=[];let e=0;for(;e<r.length;){const n=r[e];if(n===" "||n===" "||n===`
|
|
2
|
-
`||n==="\r"){e++;continue}if(n>="0"&&n<="9"){const s=e;for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="."&&r[e+1]!==".")for(e++;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="e"||r[e]==="E"){const a=e;if(e++,(r[e]==="+"||r[e]==="-")&&e++,r[e]>="0"&&r[e]<="9")for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;else e=a}const u=r.slice(s,e);t.push({kind:"num",text:u,pos:s,value:Number(u)});continue}if(/[A-Za-z_]/.test(n)){const s=e;for(;e<r.length&&/[A-Za-z0-9_]/.test(r[e]);)e++;t.push({kind:"ident",text:r.slice(s,e),pos:s});continue}const i=b.find(s=>r.startsWith(s,e));if(i){t.push({kind:"op",text:i,pos:e}),e+=i.length;continue}if(m.includes(n)){t.push({kind:"punc",text:n,pos:e}),e++;continue}throw new o(`Unexpected character ${JSON.stringify(n)} at position ${e}`,e)}return t.push({kind:"eof",text:"",pos:r.length}),t}class f{toks;ctx;p=0;reads=[];usesDiePass=!1;constructor(t,e){this.toks=t,this.ctx=e}peek(){return this.toks[this.p]}next(){return this.toks[this.p++]}at(t){const e=this.peek();return(e.kind==="op"||e.kind==="punc"||e.kind==="ident")&&e.text===t}eat(t){return this.at(t)?(this.p++,!0):!1}expect(t){if(!this.at(t)){const e=this.peek();throw new o(`Expected ${JSON.stringify(t)} but found ${e.kind==="eof"?"end of expression":JSON.stringify(e.text)} at position ${e.pos}`,e.pos)}return this.next()}parse(){const t=this.parseOr();return this.expectEnd(),t}parseTestRefOnly(){const t=this.parseTestRef(this.peek().pos);return this.expectEnd(),t}expectEnd(){const t=this.peek();if(t.kind!=="eof")throw new o(`Unexpected ${JSON.stringify(t.text)} at position ${t.pos}`,t.pos)}requireScalar(t,e,n){if(t.type==="numberVec"||t.type==="boolVec")throw new o(`${e} cannot be applied to a test range at position ${n} \u2014 a range must be reduced first, e.g. mean(t[1010..1015]) or all(testPass[1010..1015])`,n);return t.type}parseOr(){let t=this.parseAnd();for(;this.at("or");){const e=this.next().pos,n=this.parseAnd();this.requireBool(t,"or",e),this.requireBool(n,"or",e),t={node:{k:"binary",op:"or",left:t.node,right:n.node},type:"boolean"}}return t}parseAnd(){let t=this.parseNot();for(;this.at("and");){const e=this.next().pos,n=this.parseNot();this.requireBool(t,"and",e),this.requireBool(n,"and",e),t={node:{k:"binary",op:"and",left:t.node,right:n.node},type:"boolean"}}return t}requireBool(t,e,n){if(this.requireScalar(t,`Operator ${JSON.stringify(e)}`,n),t.type!=="boolean")throw new o(`Operator ${JSON.stringify(e)} needs a true/false operand at position ${n}, but got a number \u2014 compare it first, e.g. t[1020] > 5`,n)}parseNot(){if(this.at("not")){const t=this.next().pos,e=this.parseNot();return this.requireBool(e,"not",t),{node:{k:"unary",op:"not",arg:e.node},type:"boolean"}}return this.parseCompare()}parseCompare(){const t=this.parseAdd(),e=this.peek();if(e.kind==="op"&&["<","<=",">",">=","==","!="].includes(e.text)){this.next();const n=this.parseAdd(),i=this.requireScalar(t,`Operator ${JSON.stringify(e.text)}`,e.pos),s=this.requireScalar(n,`Operator ${JSON.stringify(e.text)}`,e.pos);if(i!==s)throw new o(`Cannot compare a ${i} with a ${s} at position ${e.pos}`,e.pos);if(i==="boolean"&&e.text!=="=="&&e.text!=="!=")throw new o(`Operator ${JSON.stringify(e.text)} cannot order true/false values at position ${e.pos}`,e.pos);return{node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"boolean"}}return t}parseAdd(){let t=this.parseMul();for(;;){const e=this.peek();if(e.kind!=="op"||e.text!=="+"&&e.text!=="-")return t;this.next();const n=this.parseMul();this.requireNum(t,e.text,e.pos),this.requireNum(n,e.text,e.pos),t={node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"number"}}}parseMul(){let t=this.parsePow();for(;;){const e=this.peek();if(e.kind!=="op"||!["*","/","%"].includes(e.text))return t;this.next();const n=this.parsePow();this.requireNum(t,e.text,e.pos),this.requireNum(n,e.text,e.pos),t={node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"number"}}}parsePow(){const t=this.parseUnary(),e=this.peek();if(e.kind==="op"&&e.text==="^"){this.next();const n=this.parsePow();return this.requireNum(t,"^",e.pos),this.requireNum(n,"^",e.pos),{node:{k:"binary",op:"^",left:t.node,right:n.node},type:"number"}}return t}requireNum(t,e,n){if(this.requireScalar(t,`Operator ${JSON.stringify(e)}`,n),t.type!=="number")throw new o(`Operator ${JSON.stringify(e)} needs a numeric operand at position ${n}, but got a true/false value`,n)}parseUnary(){const t=this.peek();if(t.kind==="op"&&t.text==="-"){this.next();const e=this.parseUnary();return this.requireNum(e,"-",t.pos),{node:{k:"unary",op:"-",arg:e.node},type:"number"}}return this.parsePrimary()}parsePrimary(){const t=this.next();if(t.kind==="num")return{node:{k:"num",value:t.value},type:"number"};if(t.kind==="punc"&&t.text==="("){const e=this.parseOr();return this.expect(")"),e}if(t.kind==="ident"){if(d.includes(t.text))return this.parseAccessor(t.text,t.pos);if(t.text==="diePass")return this.expect("("),this.expect(")"),this.usesDiePass=!0,{node:{k:"diePass"},type:"boolean"};if(Object.prototype.hasOwnProperty.call(DIE_FIELD_CALLS,t.text)){if(!this.at("("))throw new o(`${JSON.stringify(t.text)} at position ${t.pos} reads a die's own field and is written with parentheses: ${t.text}().`,t.pos);return this.expect("("),this.expect(")"),{node:{k:"dieField",field:DIE_FIELD_CALLS[t.text]},type:"number"}}if(this.at("("))return this.parseCall(t.text,t.pos);if(Object.prototype.hasOwnProperty.call(this.ctx.constants,t.text)){const e=this.ctx.constants[t.text];if(typeof e!="number"||!Number.isFinite(e))throw new o(`Constant ${JSON.stringify(t.text)} at position ${t.pos} is not a finite number`,t.pos);return{node:{k:"num",value:e},type:"number"}}throw new o(`Unknown name ${JSON.stringify(t.text)} at position ${t.pos}. Test values are read as t[1020], verdicts as testPass[1020] or specPass[1020], a die's own fields as dieX(), dieY(), hbin(), sbin() or site(); other names must be declared in \`constants\`.`,t.pos)}throw new o(`Unexpected ${t.kind==="eof"?"end of expression":JSON.stringify(t.text)} at position ${t.pos}`,t.pos)}parseAccessor(t,e){this.expect("[");const{tests:n,range:i}=this.parseTestRef(e);this.expect("]");for(const u of n)this.checkAccessible(t,u,e);for(const u of n)this.reads.push({kind:t,test:u});const s=t==="t"?"number":"boolean";return i?{node:{k:"vec",kind:t,tests:n},type:s==="number"?"numberVec":"boolVec"}:{node:{k:"acc",kind:t,test:n[0]},type:s}}checkAccessible(t,e,n){const i=this.ctx.testDefs.get(e);if(i===void 0)throw new o(`Test ${e} at position ${n} is not declared in \`testDefs\``,n);if(t==="t"&&!c(i))throw new o(`t[${e}] at position ${n} reads a measured value, but test ${e} is functional (testType 'F') and has no measured value \u2014 use testPass[${e}] for its verdict`,n);if(t==="specPass"){if(!c(i))throw new o(`specPass[${e}] at position ${n} needs test limits, but test ${e} is functional (testType 'F') \u2014 use testPass[${e}] for its recorded verdict`,n);if(!l(i))throw new o(`specPass[${e}] at position ${n} needs \`limitLow\` or \`limitHigh\` on test ${e}, which declares neither`,n)}}parseTestRef(t){const e=this.expectInt();if(!this.eat(".."))return{tests:[e],range:!1};const n=this.expectInt();if(n<e)throw new o(`Test range ${e}..${n} at position ${t} runs backwards`,t);const i=[...this.ctx.testDefs.keys()].filter(s=>s>=e&&s<=n).sort((s,u)=>s-u);if(i.length===0)throw new o(`Test range ${e}..${n} at position ${t} matches no declared test`,t);return{tests:i,range:!0}}expectInt(){const t=this.peek();if(t.kind!=="num"||!Number.isInteger(t.value))throw new o(`Expected a test number at position ${t.pos}`,t.pos);return this.next(),t.value}parseCall(t,e){const n=FUNCTIONS[t];if(n===void 0)throw new o(`Unknown function ${JSON.stringify(t)} at position ${e}. Available: ${Object.keys(FUNCTIONS).sort().join(", ")}`,e);this.expect("(");const i=[];if(!this.at(")"))do i.push(this.parseOr());while(this.eat(","));this.expect(")");const s=i.map(a=>a.type),u={k:"call",name:t,args:i.map(a=>a.node)};for(const a of n){if(a.vecOf!==void 0){if(s.length!==1)continue;const p=s[0];if(!(p==="numberVec"||p==="boolVec")||a.vecOf!=="any"&&a.vecOf!==p)continue;return{node:u,type:a.returns}}if(a.variadic){if(s.length<2||!s.every(p=>p==="number"))continue;return{node:u,type:a.returns}}if(a.arity!==void 0){if(s.length!==a.arity)continue;if(t==="if"){if(s[0]!=="boolean"||s[1]!=="number"||s[2]!=="number")continue;return{node:u,type:"number"}}if(!s.every(p=>p==="number"))continue;return{node:u,type:a.returns}}}throw new o(`${t}(${s.join(", ")}) at position ${e} is not a valid call \u2014 ${x(t,n)}`,e)}}function x(r,t){return`expected ${t.map(n=>n.vecOf==="boolVec"?`${r}(<true/false test range>)`:n.vecOf==="numberVec"?`${r}(<value test range>)`:n.vecOf==="any"?`${r}(<test range>)`:n.variadic?`${r}(number, number, \u2026)`:r==="if"?"if(<true/false>, number, number)":`${r}(${Array.from({length:n.arity??0},()=>"number").join(", ")})`).join(" or ")}`}export function parseExpression(r,t){try{if(r.length>MAX_EXPRESSION_LENGTH)return{ok:!1,message:`Expression is ${r.length} characters, over the ${MAX_EXPRESSION_LENGTH} limit`,position:MAX_EXPRESSION_LENGTH};const e=new f(h(r),t),{node:n,type:i}=e.parse();return i==="numberVec"||i==="boolVec"?{ok:!1,message:"Expression results in a test range, not a single value \u2014 reduce it, e.g. mean(t[1010..1015]) or all(testPass[1010..1015])",position:0}:{ok:!0,ast:n,type:i,reads:e.reads,usesDiePass:e.usesDiePass}}catch(e){if(e instanceof o)return{ok:!1,message:e.message,position:e.position};throw e}}export function parseTestReference(r,t){try{if(r.length>MAX_EXPRESSION_LENGTH)return{ok:!1,message:`Test reference is ${r.length} characters, over the ${MAX_EXPRESSION_LENGTH} limit`,position:MAX_EXPRESSION_LENGTH};const{tests:e,range:n}=new f(h(r),{testDefs:t,constants:{}}).parseTestRefOnly();return{ok:!0,tests:e,range:n}}catch(e){if(e instanceof o)return{ok:!1,message:e.message,position:e.position};throw e}}export const MAX_EXPRESSION_LENGTH=2e3;
|
|
2
|
+
`||n==="\r"){e++;continue}if(n>="0"&&n<="9"){const s=e;for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="."&&r[e+1]!==".")for(e++;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;if(r[e]==="e"||r[e]==="E"){const a=e;if(e++,(r[e]==="+"||r[e]==="-")&&e++,r[e]>="0"&&r[e]<="9")for(;e<r.length&&r[e]>="0"&&r[e]<="9";)e++;else e=a}const u=r.slice(s,e);t.push({kind:"num",text:u,pos:s,value:Number(u)});continue}if(/[A-Za-z_]/.test(n)){const s=e;for(;e<r.length&&/[A-Za-z0-9_]/.test(r[e]);)e++;t.push({kind:"ident",text:r.slice(s,e),pos:s});continue}const i=b.find(s=>r.startsWith(s,e));if(i){t.push({kind:"op",text:i,pos:e}),e+=i.length;continue}if(m.includes(n)){t.push({kind:"punc",text:n,pos:e}),e++;continue}throw new o(`Unexpected character ${JSON.stringify(n)} at position ${e}`,e)}return t.push({kind:"eof",text:"",pos:r.length}),t}class f{toks;ctx;p=0;reads=[];usesDiePass=!1;constructor(t,e){this.toks=t,this.ctx=e}peek(){return this.toks[this.p]}next(){return this.toks[this.p++]}at(t){const e=this.peek();return(e.kind==="op"||e.kind==="punc"||e.kind==="ident")&&e.text===t}eat(t){return this.at(t)?(this.p++,!0):!1}expect(t){if(!this.at(t)){const e=this.peek();throw new o(`Expected ${JSON.stringify(t)} but found ${e.kind==="eof"?"end of expression":JSON.stringify(e.text)} at position ${e.pos}`,e.pos)}return this.next()}parse(){const t=this.parseOr();return this.expectEnd(),t}parseTestRefOnly(){const t=this.parseTestRef(this.peek().pos);return this.expectEnd(),t}expectEnd(){const t=this.peek();if(t.kind!=="eof")throw new o(`Unexpected ${JSON.stringify(t.text)} at position ${t.pos}`,t.pos)}requireScalar(t,e,n){if(t.type==="numberVec"||t.type==="boolVec")throw new o(`${e} cannot be applied to a test range at position ${n} \u2014 a range must be reduced first, e.g. mean(t[1010..1015]) or all(testPass[1010..1015])`,n);return t.type}parseOr(){let t=this.parseAnd();for(;this.at("or");){const e=this.next().pos,n=this.parseAnd();this.requireBool(t,"or",e),this.requireBool(n,"or",e),t={node:{k:"binary",op:"or",left:t.node,right:n.node},type:"boolean"}}return t}parseAnd(){let t=this.parseNot();for(;this.at("and");){const e=this.next().pos,n=this.parseNot();this.requireBool(t,"and",e),this.requireBool(n,"and",e),t={node:{k:"binary",op:"and",left:t.node,right:n.node},type:"boolean"}}return t}requireBool(t,e,n){if(this.requireScalar(t,`Operator ${JSON.stringify(e)}`,n),t.type!=="boolean")throw new o(`Operator ${JSON.stringify(e)} needs a true/false operand at position ${n}, but got a number \u2014 compare it first, e.g. t[1020] > 5`,n)}parseNot(){if(this.at("not")){const t=this.next().pos,e=this.parseNot();return this.requireBool(e,"not",t),{node:{k:"unary",op:"not",arg:e.node},type:"boolean"}}return this.parseCompare()}parseCompare(){const t=this.parseAdd(),e=this.peek();if(e.kind==="op"&&["<","<=",">",">=","==","!="].includes(e.text)){this.next();const n=this.parseAdd(),i=this.requireScalar(t,`Operator ${JSON.stringify(e.text)}`,e.pos),s=this.requireScalar(n,`Operator ${JSON.stringify(e.text)}`,e.pos);if(i!==s)throw new o(`Cannot compare a ${i} with a ${s} at position ${e.pos}`,e.pos);if(i==="boolean"&&e.text!=="=="&&e.text!=="!=")throw new o(`Operator ${JSON.stringify(e.text)} cannot order true/false values at position ${e.pos}`,e.pos);return{node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"boolean"}}return t}parseAdd(){let t=this.parseMul();for(;;){const e=this.peek();if(e.kind!=="op"||e.text!=="+"&&e.text!=="-")return t;this.next();const n=this.parseMul();this.requireNum(t,e.text,e.pos),this.requireNum(n,e.text,e.pos),t={node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"number"}}}parseMul(){let t=this.parsePow();for(;;){const e=this.peek();if(e.kind!=="op"||!["*","/","%"].includes(e.text))return t;this.next();const n=this.parsePow();this.requireNum(t,e.text,e.pos),this.requireNum(n,e.text,e.pos),t={node:{k:"binary",op:e.text,left:t.node,right:n.node},type:"number"}}}parsePow(){const t=this.parseUnary(),e=this.peek();if(e.kind==="op"&&e.text==="^"){this.next();const n=this.parsePow();return this.requireNum(t,"^",e.pos),this.requireNum(n,"^",e.pos),{node:{k:"binary",op:"^",left:t.node,right:n.node},type:"number"}}return t}requireNum(t,e,n){if(this.requireScalar(t,`Operator ${JSON.stringify(e)}`,n),t.type!=="number")throw new o(`Operator ${JSON.stringify(e)} needs a numeric operand at position ${n}, but got a true/false value`,n)}parseUnary(){const t=this.peek();if(t.kind==="op"&&t.text==="-"){this.next();const e=this.parseUnary();return this.requireNum(e,"-",t.pos),{node:{k:"unary",op:"-",arg:e.node},type:"number"}}return this.parsePrimary()}parsePrimary(){const t=this.next();if(t.kind==="num")return{node:{k:"num",value:t.value},type:"number"};if(t.kind==="punc"&&t.text==="("){const e=this.parseOr();return this.expect(")"),e}if(t.kind==="ident"){if(d.includes(t.text))return this.parseAccessor(t.text,t.pos);if(t.text==="diePass")return this.expect("("),this.expect(")"),this.usesDiePass=!0,{node:{k:"diePass"},type:"boolean"};if(Object.prototype.hasOwnProperty.call(DIE_FIELD_CALLS,t.text)&&(this.at("(")||!Object.prototype.hasOwnProperty.call(this.ctx.constants,t.text))){if(!this.at("("))throw new o(`${JSON.stringify(t.text)} at position ${t.pos} reads a die's own field and is written with parentheses: ${t.text}().`,t.pos);return this.expect("("),this.expect(")"),{node:{k:"dieField",field:DIE_FIELD_CALLS[t.text]},type:"number"}}if(this.at("("))return this.parseCall(t.text,t.pos);if(Object.prototype.hasOwnProperty.call(this.ctx.constants,t.text)){const e=this.ctx.constants[t.text];if(typeof e!="number"||!Number.isFinite(e))throw new o(`Constant ${JSON.stringify(t.text)} at position ${t.pos} is not a finite number`,t.pos);return{node:{k:"num",value:e},type:"number"}}throw new o(`Unknown name ${JSON.stringify(t.text)} at position ${t.pos}. Test values are read as t[1020], verdicts as testPass[1020] or specPass[1020], a die's own fields as dieX(), dieY(), hbin(), sbin() or site(); other names must be declared in \`constants\`.`,t.pos)}throw new o(`Unexpected ${t.kind==="eof"?"end of expression":JSON.stringify(t.text)} at position ${t.pos}`,t.pos)}parseAccessor(t,e){this.expect("[");const{tests:n,range:i}=this.parseTestRef(e);this.expect("]");for(const u of n)this.checkAccessible(t,u,e);for(const u of n)this.reads.push({kind:t,test:u});const s=t==="t"?"number":"boolean";return i?{node:{k:"vec",kind:t,tests:n},type:s==="number"?"numberVec":"boolVec"}:{node:{k:"acc",kind:t,test:n[0]},type:s}}checkAccessible(t,e,n){const i=this.ctx.testDefs.get(e);if(i===void 0)throw new o(`Test ${e} at position ${n} is not declared in \`testDefs\``,n);if(t==="t"&&!c(i))throw new o(`t[${e}] at position ${n} reads a measured value, but test ${e} is functional (testType 'F') and has no measured value \u2014 use testPass[${e}] for its verdict`,n);if(t==="specPass"){if(!c(i))throw new o(`specPass[${e}] at position ${n} needs test limits, but test ${e} is functional (testType 'F') \u2014 use testPass[${e}] for its recorded verdict`,n);if(!l(i))throw new o(`specPass[${e}] at position ${n} needs \`limitLow\` or \`limitHigh\` on test ${e}, which declares neither`,n)}}parseTestRef(t){const e=this.expectInt();if(!this.eat(".."))return{tests:[e],range:!1};const n=this.expectInt();if(n<e)throw new o(`Test range ${e}..${n} at position ${t} runs backwards`,t);const i=[...this.ctx.testDefs.keys()].filter(s=>s>=e&&s<=n).sort((s,u)=>s-u);if(i.length===0)throw new o(`Test range ${e}..${n} at position ${t} matches no declared test`,t);return{tests:i,range:!0}}expectInt(){const t=this.peek();if(t.kind!=="num"||!Number.isInteger(t.value))throw new o(`Expected a test number at position ${t.pos}`,t.pos);return this.next(),t.value}parseCall(t,e){const n=FUNCTIONS[t];if(n===void 0)throw new o(`Unknown function ${JSON.stringify(t)} at position ${e}. Available: ${Object.keys(FUNCTIONS).sort().join(", ")}`,e);this.expect("(");const i=[];if(!this.at(")"))do i.push(this.parseOr());while(this.eat(","));this.expect(")");const s=i.map(a=>a.type),u={k:"call",name:t,args:i.map(a=>a.node)};for(const a of n){if(a.vecOf!==void 0){if(s.length!==1)continue;const p=s[0];if(!(p==="numberVec"||p==="boolVec")||a.vecOf!=="any"&&a.vecOf!==p)continue;return{node:u,type:a.returns}}if(a.variadic){if(s.length<2||!s.every(p=>p==="number"))continue;return{node:u,type:a.returns}}if(a.arity!==void 0){if(s.length!==a.arity)continue;if(t==="if"){if(s[0]!=="boolean"||s[1]!=="number"||s[2]!=="number")continue;return{node:u,type:"number"}}if(!s.every(p=>p==="number"))continue;return{node:u,type:a.returns}}}throw new o(`${t}(${s.join(", ")}) at position ${e} is not a valid call \u2014 ${x(t,n)}`,e)}}function x(r,t){return`expected ${t.map(n=>n.vecOf==="boolVec"?`${r}(<true/false test range>)`:n.vecOf==="numberVec"?`${r}(<value test range>)`:n.vecOf==="any"?`${r}(<test range>)`:n.variadic?`${r}(number, number, \u2026)`:r==="if"?"if(<true/false>, number, number)":`${r}(${Array.from({length:n.arity??0},()=>"number").join(", ")})`).join(" or ")}`}export function parseExpression(r,t){try{if(r.length>MAX_EXPRESSION_LENGTH)return{ok:!1,message:`Expression is ${r.length} characters, over the ${MAX_EXPRESSION_LENGTH} limit`,position:MAX_EXPRESSION_LENGTH};const e=new f(h(r),t),{node:n,type:i}=e.parse();return i==="numberVec"||i==="boolVec"?{ok:!1,message:"Expression results in a test range, not a single value \u2014 reduce it, e.g. mean(t[1010..1015]) or all(testPass[1010..1015])",position:0}:{ok:!0,ast:n,type:i,reads:e.reads,usesDiePass:e.usesDiePass}}catch(e){if(e instanceof o)return{ok:!1,message:e.message,position:e.position};throw e}}export function parseTestReference(r,t){try{if(r.length>MAX_EXPRESSION_LENGTH)return{ok:!1,message:`Test reference is ${r.length} characters, over the ${MAX_EXPRESSION_LENGTH} limit`,position:MAX_EXPRESSION_LENGTH};const{tests:e,range:n}=new f(h(r),{testDefs:t,constants:{}}).parseTestRefOnly();return{ok:!0,tests:e,range:n}}catch(e){if(e instanceof o)return{ok:!1,message:e.message,position:e.position};throw e}}export const MAX_EXPRESSION_LENGTH=2e3;
|
|
@@ -19,6 +19,16 @@ export declare function fmtAggregationMethod(method: string | undefined): string
|
|
|
19
19
|
* compact internal terms (they're also machine-consumed and test-asserted).
|
|
20
20
|
*/
|
|
21
21
|
export declare function plainBinTerms(text: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* A stored number as text, in the fewest digits that are still exactly it. STDF
|
|
24
|
+
* stores limits and results as 32-bit floats, so a limit written as 1.6 arrives as
|
|
25
|
+
* 1.600000023841858; a value that is exactly a float32 is written in the shortest
|
|
26
|
+
* digits that are still that float32 ("1.6", "2.0087667"), any other number as it
|
|
27
|
+
* is. For a value shown as itself — a limit, a category of a discrete X — where
|
|
28
|
+
* `fmt`'s rounding to a few figures would hide a real difference. Display only:
|
|
29
|
+
* comparisons keep the exact value.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fmtExact(v: number): string;
|
|
22
32
|
/**
|
|
23
33
|
* Format a numeric value for display (tooltips, overlays, single-value labels).
|
|
24
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{stepDecimals as
|
|
1
|
+
import{stepDecimals as p}from"./axisTicks.js";const M=[[1e12,"T"],[1e9,"G"],[1e6,"M"],[1e3,"k"],[1,""],[.001,"m"],[1e-6,"\xB5"],[1e-9,"n"],[1e-12,"p"],[1e-15,"f"]];export const SI_PREFIX_SCALE={T:1e12,G:1e9,M:1e6,k:1e3,m:.001,\u00B5:1e-6,u:1e-6,n:1e-9,p:1e-12,f:1e-15},KNOWN_BASE_UNITS=["Hz","V","A","W","F","\u03A9","Ohm","ohm","S","H","J","C","s"];function m(t){for(const e of KNOWN_BASE_UNITS)if(t.length===e.length+1&&t.endsWith(e)){const r=t[0];if(r in SI_PREFIX_SCALE)return{preScale:SI_PREFIX_SCALE[r],base:e}}return{preScale:1,base:t}}function F(t,e){const{preScale:r,base:n}=m(e),o=t*r,i=Math.abs(o),[c,h]=M.find(([s])=>i>=s*.9999)??[1e-15,"f"],f=o/c,b=Math.abs(f),u=b>=100?0:b>=10?1:2;return`${f.toFixed(u)} ${h}${n}`}function $(t){const e=Math.abs(t);if(e===0)return"0%";const r=e>=100?0:e>=10?1:e>=1?2:Math.min(6,1-Math.floor(Math.log10(e)));return`${t.toFixed(r)}%`}function E(t){const e=Math.abs(t),r=Math.floor(Math.log10(e)/3)*3,n=Math.max(-15,Math.min(12,r)),o=t/Math.pow(10,n),i=Math.abs(o),c=i>=100?0:i>=10?1:2,h=n===0?"":`E${n>0?"+":""}${n}`;return`${o.toFixed(c)}${h}`}export const AGGREGATION_METHOD_LABELS={mean:"mean",median:"median",stddev:"std dev",min:"min",max:"max",count:"count",countBin:"occurrence count",percent:"occurrence %"};export function fmtAggregationMethod(t){return AGGREGATION_METHOD_LABELS[t??""]??t??"aggregated"}export function plainBinTerms(t){return t.replace(/\bHBin\b/g,"hard bin").replace(/\bSBin\b/g,"soft bin")}export function fmtExact(t){if(!Number.isFinite(t)||Math.fround(t)!==t)return String(t);for(let e=1;e<=9;e++){const r=Number(t.toPrecision(e));if(Math.fround(r)===t)return String(r)}return String(t)}export function fmt(t,e,r){if(!isFinite(t))return String(t);if(e==="%")return $(t);const n=Math.abs(t);return n===0?e?`0 ${e}`:"0":e!==void 0?F(t,e):r==="si"?F(t,""):n>=.1&&n<1e4?n>=1e3?t.toFixed(0):n>=100?t.toFixed(1):n>=10?t.toFixed(2):t.toFixed(3):E(t)}function A(t,e){const r=e!==void 0&&e>0?p(e/t):void 0;return n=>{if(!isFinite(n))return String(n);if(n===0)return"0";const o=n/t;if(r!==void 0)return o.toFixed(r);const i=Math.abs(o),c=i>=100?0:i>=10?1:2;return o.toFixed(c)}}function T(t,e,r){if(e===void 0||!(e>0))return r;const n=p(e/t)+1;return o=>{if(!isFinite(o))return String(o);if(o===0)return"0";const i=(o/t).toFixed(n);return i.endsWith("0")?i.slice(0,n===1?-2:-1):i}}export function fmtColorbarAxis(t,e,r,n="engineering",o){const i=Math.abs(t),c=(s,d,a,x)=>{const g=x&&o===void 0?x:A(s,o);return{tickFmt:g,edgeFmt:T(s,o,g),axisLabel:d,scaledUnit:a}};if(r==="%")return c(1,e?`${e} (%)`:"%","%");if(r){const{preScale:s,base:d}=m(r),a=i*s,[x,g]=a===0?[1,""]:M.find(([S])=>a>=S*.9999)??[1e-15,"f"],l=`${g}${d}`;return c(x/s,e?`${e} (${l})`:l,l)}if(i===0||i>=.1&&i<1e4)return c(1,e??"","",s=>fmt(s,void 0,n));if(n==="si"){const[s]=M.find(([x])=>i>=x*.9999)??[1e-15,"f"],d=Math.round(Math.log10(s)),a=d===0?"":`\xD710E${d}`;return c(s,e?a?`${e} (${a})`:e:a,a)}const h=Math.floor(Math.log10(i)/3)*3,f=Math.max(-15,Math.min(12,h)),b=Math.pow(10,f),u=f===0?"":`\xD710E${f}`;return c(b,e?u?`${e} (${u})`:e:u,u)}
|
|
@@ -9,4 +9,5 @@ export type { ValueColorScheme, BinColorScheme } from './colorSchemes.js';
|
|
|
9
9
|
export type { BinColors, BinColorSource, MapBinColorOptions } from './binColors.js';
|
|
10
10
|
export { binColorsForMaps } from './binColors.js';
|
|
11
11
|
export { DERIVED_MARK, DERIVED_KEY } from './testLabel.js';
|
|
12
|
+
export { fmtExact } from './fmt.js';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{getDieKey}from"./buildView.js";export{buildWaferMap,getTestPassStatus}from"./buildWaferMap.js";export{registerValueColorScheme,listValueColorSchemes,resolveValueColorFn,registerBinColorScheme,listBinColorSchemes}from"./colorSchemes.js";export{binColorsForMaps}from"./binColors.js";export{DERIVED_MARK,DERIVED_KEY}from"./testLabel.js";
|
|
1
|
+
export{getDieKey}from"./buildView.js";export{buildWaferMap,getTestPassStatus}from"./buildWaferMap.js";export{registerValueColorScheme,listValueColorSchemes,resolveValueColorFn,registerBinColorScheme,listBinColorSchemes}from"./colorSchemes.js";export{binColorsForMaps}from"./binColors.js";export{DERIVED_MARK,DERIVED_KEY}from"./testLabel.js";export{fmtExact}from"./fmt.js";
|
|
@@ -140,15 +140,4 @@ export declare function derivedKeyText(entries: ReadonlyArray<{
|
|
|
140
140
|
derived?: true;
|
|
141
141
|
expression?: string;
|
|
142
142
|
}>): string | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* True when any test in this population is derived — the gate for reserving a
|
|
145
|
-
* marker gutter in a view.
|
|
146
|
-
*
|
|
147
|
-
* Reserving it per view rather than per row is what keeps the marker from
|
|
148
|
-
* shifting content relative to itself: every row of a view indents equally, so
|
|
149
|
-
* the markers align in a column instead of leaving a ragged edge, and a
|
|
150
|
-
* population with no derived tests — the common case — is unchanged to the
|
|
151
|
-
* pixel.
|
|
152
|
-
*/
|
|
153
|
-
export declare function hasDerivedTests(defs: readonly TestDef[] | undefined): boolean;
|
|
154
143
|
//# sourceMappingURL=testLabel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DERIVED_MARK="\u2020",DERIVED_KEY="Derived, not measured";export function isDerivedTest(e){return e?.derived===!0}export function testLabel(e,r){const
|
|
1
|
+
export const DERIVED_MARK="\u2020",DERIVED_KEY="Derived, not measured";export function isDerivedTest(e){return e?.derived===!0}export function testLabel(e,r){const n=e?.name;return n!==void 0&&n!==""?n:`Test ${r}`}export function markedTestLabel(e,r){const n=testLabel(e,r);return e?.derived===!0?`\u2020 ${n}`:n}export const DERIVED_LANE_PAD="\u2007\u2009";export function derivedTestNote(e){if(!isDerivedTest(e))return;const r=derivedTestSource(e);return r?`\u2020 ${DERIVED_KEY}: ${r}`:`\u2020 ${DERIVED_KEY}`}export function derivedTestSource(e){if(!(!isDerivedTest(e)||!e?.expression))return e.expression}export function derivedFields(e){return isDerivedTest(e)?e.expression!==void 0?{derived:!0,expression:e.expression}:{derived:!0}:{}}export function unmarkedLabel(e){return e.startsWith("\u2020 ")?e.slice(2):e}export const DERIVED_CSV_HEADER="Derived from";export function derivedCsvCell(e){return isDerivedTest(e)?derivedTestSource(e)??DERIVED_KEY:""}export function derivedKeyText(e){const r=new Map;for(const t of e){if(!isDerivedTest(t))continue;const i=unmarkedLabel(t.label);r.has(i)||r.set(i,t.expression)}if(r.size===0)return;const n=[...r].map(([t,i])=>i?`${t}: ${i}`:t);return`\u2020 ${DERIVED_KEY} \u2014 ${n.join("; ")}`}
|
|
@@ -47,7 +47,7 @@ export declare function applyValueFilter(table: DieTable, testDefs: readonly Tes
|
|
|
47
47
|
* The caption fragment for `testNumber` over `dies`: " · 3 values outside validity limits excluded", or ''
|
|
48
48
|
* when the filter took nothing out of them. One wording for every chart caption.
|
|
49
49
|
*/
|
|
50
|
-
export declare function excludedNote(dies: readonly DieData[], testNumber: number): string;
|
|
50
|
+
export declare function excludedNote(dies: readonly DieData[], testNumber: number | null): string;
|
|
51
51
|
/** Sums per-wafer outcomes into one (a lot is filtered wafer by wafer). */
|
|
52
52
|
export declare function mergeValueFilterTests(parts: readonly ValueFilterTest[][]): ValueFilterTest[];
|
|
53
53
|
/** The log line for an outcome: what was excluded, per test, and under which limits. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{excludedCountFor as m,withExcluded as p}from"../core/dieTable.js";import{isYieldEligibleDie as v}from"../core/dies.js";import{aboveHigh as w,belowLow as N}from"./spec.js";export function limitSetName(e){return e==="validity"?"validity limits":e==="spec"?"specification limits":"test limits"}function x(e,t){const n=t==="validity"?{low:e.validLow,high:e.validHigh}:t==="spec"?{low:e.specLow,high:e.specHigh}:{low:e.limitLow,high:e.limitHigh,lowInclusive:e.limitLowInclusive,highInclusive:e.limitHighInclusive};return n.low===void 0&&n.high===void 0?void 0:n}export function applyValueFilter(e,t,n){if(n==="none"||!t)return{table:e,tests:[]};const o=new Map,l=new Map,s=[];for(const i of t){if(i.testType==="F")continue;const u=x(i,n),c=e.values.get(i.testNumber);if(u===void 0||c===void 0)continue;let r,a,h=0,g=0;for(let d=0;d<c.length;d++){const f=c[d];Number.isNaN(f)||(h++,!(u.low!==void 0&&N(f,u.low,u.lowInclusive)||u.high!==void 0&&w(f,u.high,u.highInclusive)))||(r===void 0&&(r=c.slice(),a=new c.constructor(c.length).fill(NaN)),r[d]=NaN,a[d]=f,g++)}r===void 0||a===void 0||(o.set(i.testNumber,r),l.set(i.testNumber,a),s.push({testNumber:i.testNumber,excluded:g,total:h}))}return s.length===0?{table:e,tests:s}:{table:p(e,o,l,n),tests:s}}export function excludedNote(e,t){const n=t===null?void 0:m(e.filter(o=>v(o)),t);return n?` \xB7 ${n.count.toLocaleString("en-GB")} value${n.count===1?"":"s"} outside ${limitSetName(n.by)} excluded`:""}export function mergeValueFilterTests(e){const t=new Map;for(const n of e)for(const o of n){const l=t.get(o.testNumber);l?(l.excluded+=o.excluded,l.total+=o.total):t.set(o.testNumber,{...o})}return[...t.values()].sort((n,o)=>n.testNumber-o.testNumber)}export function valueFilterWarning(e,t,n){if(t.length===0)return;const o=i=>n?.find(u=>u.testNumber===i)?.name??`test ${i}`,l=t.reduce((i,u)=>i+u.excluded,0),s=t.slice(0,5).map(i=>`${o(i.testNumber)}: ${i.excluded} of ${i.total}`).join("; ")+(t.length>5?`; and ${t.length-5} more tests`:"");return{code:"values-excluded",message:`${l} value${l===1?"":"s"} outside the ${limitSetName(e)} treated as missing (${s}).`,severity:"info"}}
|
|
@@ -30,4 +30,26 @@ export declare function outlierWafers(yields: readonly number[]): {
|
|
|
30
30
|
export declare function analyzeWaferLot(items: AnalyzeWaferLotInput, options?: AnalyzeWaferMapOptions & {
|
|
31
31
|
perWaferSummaries?: StatsSummary[];
|
|
32
32
|
}): LotStatsSummary;
|
|
33
|
+
/** Options of {@link analyzeWaferLotAsync}: the lot's, with progress and cancellation. */
|
|
34
|
+
export interface AnalyzeWaferLotAsyncOptions extends AnalyzeWaferMapOptions {
|
|
35
|
+
perWaferSummaries?: StatsSummary[];
|
|
36
|
+
/** Called after each wafer is analysed, then once more with `done === total` before the lot-level pass. */
|
|
37
|
+
onProgress?: (done: number, total: number) => void;
|
|
38
|
+
/** Abort to stop between wafers; the promise rejects with the signal's reason. */
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `analyzeWaferLot` that hands control back to the browser between wafers, so a
|
|
43
|
+
* large lot does not hang the page while it is analysed — the same result, one
|
|
44
|
+
* test-value decision for the whole lot. It yields whenever about 100 ms of work
|
|
45
|
+
* has passed (a pause costs a frame; one per wafer would add a third to a big lot)
|
|
46
|
+
* and before the lot-level pass.
|
|
47
|
+
*/
|
|
48
|
+
export declare function analyzeWaferLotAsync(items: AnalyzeWaferLotInput, options?: AnalyzeWaferLotAsyncOptions): Promise<LotStatsSummary>;
|
|
49
|
+
/**
|
|
50
|
+
* A lot analysed over some of a caller's wafers, with every wafer index put back to the caller's own: `positions[i]` is
|
|
51
|
+
* where the wafer given i-th sits in the caller's list. A filter's lot analysis covers only the wafers it keeps, yet
|
|
52
|
+
* the gallery's cards, rows and highlights are numbered by the whole list.
|
|
53
|
+
*/
|
|
54
|
+
export declare function remapLotWaferIndices(lot: LotStatsSummary, positions: readonly number[]): LotStatsSummary;
|
|
33
55
|
//# sourceMappingURL=analyzeWaferLot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{waferDisplayLabel as se}from"../core/waferLabel.js";import{requireRingCount as ae}from"../core/ringCount.js";import{analyzeWaferMap as G,candidatesOf as H,describeRegional as U,resolveOptions as re,adjustPValues as oe,twoProportionZ as Q,welchOfSums as X,rateRelativeEffect as ce,passesRateGate as le,severityForFinding as Z,severityForScore as J,collapseRedundantFindings as fe,findContiguousRuns as de,mergedRegionLabel as ue}from"./analyzeWaferMap.js";import{normalizeInput as me}from"./normalizeInput.js";import{poolCapability as ge,poolRegionYield as pe,poolPassRates as he}from"./summaryFigures.js";import{mergeTestDefs as ye}from"./mergeTestDefs.js";import{findingPatternKey as be}from"./filterFindings.js";import{median as ee}from"../core/utils.js";import{robustFence as te,zPValue as K}from"./math.js";import{findLotPattern as we}from"./lotPattern.js";import{buildDriftFindings as ve}from"./lotDrift.js";import{claimForPattern as Se,confirmRegionalFindings as ze,weakestMultiplier as Ie}from"./analyzeWaferMap.js";import{PATTERN_LABELS as ke}from"./patternClassification.js";import{describeWaferPopulation as Re,populationStat as Me}from"./population.js";const W=8,Pe={3:[.97,.994],4:[.829,.926],5:[.71,.821],6:[.625,.74],7:[.568,.68]},xe=3;export function outlierWafers(i){const o=i.length;if(o<3)return null;const r=ee([...i]),s=t=>Math.abs(t-r)>=xe;if(o>=W){const t=te(i,1.5,W),f=te(i,3,W);if(!t||!f)return null;const d=(t.hi-t.lo)/4,b=[];return i.forEach((y,a)=>{if(y>=t.lo&&y<=t.hi||!s(y))return;const e=y<f.lo||y>f.hi?"unusual":"notable";b.push({index:a,severity:e,statistic:(y-r)/d})}),{method:"tukey-fence",outliers:b}}const u=i.map((t,f)=>f).sort((t,f)=>i[t]-i[f]),g=i[u[o-1]]-i[u[0]];if(g===0)return null;const[n,c]=Pe[o],m=[],p=(t,f)=>{const d=Math.abs(i[t]-i[f])/g;d>n&&s(i[t])&&m.push({index:t,severity:d>c?"unusual":"notable",statistic:d})};return p(u[0],u[1]),p(u[o-1],u[o-2]),{method:"dixon-q",outliers:m}}const N=2;function T(i,o){const r={info:0,notable:1,unusual:2};return r[i]>=r[o]?i:o}const $e=new Set(["ring","quadrant","sector"]),Be=new Set(["ring","quadrant","sector","reticle-position","test-site"]),De=new Set(["yield","hardBin","softBin","functionalTest","test"]);function Le(i){return Be.has(i.comparison.family)&&De.has(i.variable.kind)}function Ee(i,o){const r=i.map(n=>n.facts);if(!r.length||r.some(n=>!n))return{coincident:new Set,yieldSoftBin:void 0,passBins:[],sectorCount:o};const[s,...u]=r,g=u.every(n=>n.passBins.length===s.passBins.length&&n.passBins.every(c=>s.passBins.includes(c)));return{coincident:new Set([...s.coincident].filter(n=>u.every(c=>c.coincident.has(n)))),yieldSoftBin:u.every(n=>n.yieldSoftBin===s.yieldSoftBin)?s.yieldSoftBin:void 0,passBins:g?s.passBins:[],sectorCount:o}}function _(i,o){let r=0,s=0,u=0,g=0,n=0,c=0,m=0,p=0,t=0,f=!0,d=0;for(const{waferIndex:a,c:e}of i){const l=o(a,e),h=e.rate??e.mean,S=Math.sqrt(h.n+l.n);if(e.rate)r+=S*Q(e.rate.hits,e.rate.n,l.hits,l.n),u+=e.rate.hits,g+=e.rate.n,n+=l.hits,c+=l.n;else{const v=X(e.mean,l.n,l.sum,l.sq);r+=S*v.z,m+=e.mean.n*v.effectSize,p+=e.mean.n*v.delta,d+=e.mean.n,e.relativeDelta===void 0?f=!1:t+=e.mean.n*e.relativeDelta}s+=S*S}const b=s>0?r/Math.sqrt(s):0,y=i[0].c;if(y.rate){const a=n/c,e=u/g-a;return{z:b,delta:e,relativeDelta:a===0?void 0:e/a,size:ce({hits:u,n:g,restHits:n,restN:c,passRate:y.rate.passRate})}}return{z:b,delta:p/d,relativeDelta:f?t/d:void 0,size:m/d}}function j(i,o,r,s){return i.rate?le(o,r.delta,r.size,s):o<=s.significanceLevel&&Math.abs(r.size)>=s.minimumEffectSize}function qe(i,o,r,s){const u=new Map;for(const{waferIndex:a,byKey:e}of i)for(const l of e.values())(u.get(l.key)??u.set(l.key,[]).get(l.key)).push({waferIndex:a,c:l});const g=new Map(i.map(a=>[a.waferIndex,a.byKey])),n=(a,e)=>e.rate?{hits:e.rate.restHits,n:e.rate.restN,sum:0,sq:0}:{hits:0,n:e.mean.restN,sum:e.mean.restSum,sq:e.mean.restSq},c=[];for(const[a,e]of u){if(e.length<N)continue;const l=_(e,n);if(l.z===0)continue;const h=e[0].c;c.push({key:a,entries:e,combined:l,finding:{id:`lot-region:${a}`,level:"lot",severity:"info",variable:{...h.variable,label:h.label},comparison:{...h.comparison},effect:{direction:l.z>0?"higher":"lower",absoluteDelta:l.delta,relativeDelta:l.relativeDelta,effectSize:h.rate?l.delta:l.size},stats:{method:"stouffer-z",pValue:K(l.z),sampleSizeLeft:0,sampleSizeRight:0},summary:"",highlight:{kind:"wafer",waferIndices:[]}}})}oe(c.map(a=>a.finding));const m=c.filter(a=>j(a.entries[0].c,a.finding.stats.adjustedPValue??1,a.combined,o)),f=ze(m,a=>{const e=a.entries[0].c;return[e.source,e.variable.kind,e.variable.bin??"",e.variable.index??"",e.region.family].join("\0")},(a,e)=>{const l=(M,B)=>{const k=n(M,B);for(const z of e){const R=g.get(M)?.get(z.key);R&&(R.rate?(k.hits-=R.rate.hits,k.n-=R.rate.n):(k.n-=R.mean.n,k.sum-=R.mean.sum,k.sq-=R.mean.sq))}return k},h=a.entries.filter(M=>l(M.waferIndex,M.c).n>=o.minimumSampleSize);if(!h.length)return"baseline-too-small";const S=_(h,l),v=a.finding.stats.pValue??1,$=v>0?(a.finding.stats.adjustedPValue??v)/v:1,w=Math.min(1,K(S.z)*$);return{pValue:w,passes:Math.sign(S.z)===Math.sign(a.combined.z)&&j(a.entries[0].c,w,S,o)}},a=>{const e=a.entries[0].c.rate;return e!==void 0&&(e.passRate?a.combined.z<0:a.combined.z>0)},c),d=[],b=new Map;for(const a of m){if(!f.has(a))continue;const e=a.finding.stats.pValue??1,l=Math.sign(a.combined.z),h=a.entries.filter(z=>Math.sign(z.c.delta)===l),S=i.length,v=a.entries[0].c,$=a.finding.stats.adjustedPValue??e,w=v.rate?Z($,a.combined.delta,a.combined.size):J($,a.combined.size),M=T(w,h.length/S>=.6?"unusual":"info"),B={};for(const z of h)B[z.waferIndex]=[...z.c.region.dieKeys];const k={...a.finding,severity:M,stats:{...a.finding.stats,sampleSizeLeft:h.length,sampleSizeRight:S-h.length},summary:`${U(v,a.combined.delta,a.combined.relativeDelta)} \u2014 ${a.finding.effect.direction} on ${h.length}/${S} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:h.map(z=>z.waferIndex),dieKeysByWafer:B}};d.push(k),b.set(k,a)}const y=Fe(b,g,i.length,o,s,n);return d.splice(0,d.length,...d.filter(a=>!y.replaced.has(a)),...y.findings),fe(d,r),d}function Fe(i,o,r,s,u,g){const n=new Map;for(const[p,t]of i){const f=t.entries[0].c;if(!$e.has(f.region.family))continue;const d=[f.source,f.variable.kind,f.variable.bin??"",f.variable.index??"",f.region.family,p.effect.direction].join("|");(n.get(d)??n.set(d,[]).get(d)).push({finding:p,c:f,key:t.key})}const c=[],m=new Set;for(const p of n.values()){if(p.length<2)continue;const t=p[0].c.region.family;for(const f of de(p,t,s.sectorCount,d=>d.c.region.key)){if(f.length<2)continue;const d=Ke(f,o,r,s,u,g);if(d){c.push(d);for(const b of f)m.add(b.finding)}}}return{findings:c,replaced:m}}function Ke(i,o,r,s,u,g){const n=i[0].c,c=i[0].finding.effect.direction==="higher"?1:-1,m=ue(n.region.family,i.map(w=>w.c.region.key),u),p=[];for(const[w,M]of o){const B=i.map(I=>M.get(I.key));if(B.some(I=>!I))continue;const k=B,z=k[0];let R,A;if(z.rate){const I=k.reduce((x,D)=>x+D.rate.hits,0),P=k.reduce((x,D)=>x+D.rate.n,0),E=z.rate.hits+z.rate.restHits-I,L=z.rate.n+z.rate.restN-P;if(P<s.minimumSampleSize||L<s.minimumSampleSize)continue;R={...z,rate:{hits:I,n:P,restHits:E,restN:L,passRate:z.rate.passRate}},A=Q(I,P,E,L)}else{const I=z.mean,P=k.reduce((q,F)=>q+F.mean.n,0),E=k.reduce((q,F)=>q+F.mean.sum,0),L=k.reduce((q,F)=>q+F.mean.sq,0),x=I.n+I.restN-P,D=I.sum+I.restSum-E,O=I.sq+I.restSq-L;if(P<s.minimumSampleSize||x<s.minimumSampleSize)continue;const V={n:P,sum:E,sq:L,restN:x,restSum:D,restSq:O,shift:I.shift},C=X(V,x,D,O),Y=D/x+I.shift;R={...z,mean:V,relativeDelta:Y!==0?C.delta/Math.abs(Y):void 0},A=C.z}const ie=[...new Set(k.flatMap(I=>[...I.region.dieKeys]))];p.push({waferIndex:w,c:R,z:A,dieKeys:ie})}if(p.length<N)return;const t=_(p,g);if(t.z===0||Math.sign(t.z)!==c)return;const f=K(t.z),d=Ie(i.map(w=>w.finding)),b=Math.min(1,f*d);if(!j(n,b,t,s))return;const y=p.filter(w=>Math.sign(w.z)===c&&K(w.z)<=s.significanceLevel);if(!y.length)return;const a=n.rate?Z(b,t.delta,t.size):J(b,t.size),e=T(a,y.length/r>=.6?"unusual":"info"),l={};for(const w of y)l[w.waferIndex]=w.dieKeys;const h=i.map(w=>w.c.region.key.slice(w.c.region.key.indexOf(":")+1)).join("-"),S={...n,comparison:{...n.comparison,left:m}},v=i[0].finding,$=v.effect.direction;return{...v,id:`lot-region:${i[0].key.split("|").slice(0,-1).join("|")}|${n.region.family}:${h}`,severity:e,comparison:{...v.comparison,left:m},effect:{direction:$,absoluteDelta:t.delta,relativeDelta:t.relativeDelta,effectSize:n.rate?t.delta:t.size},stats:{method:"stouffer-z",pValue:f,adjustedPValue:b,sampleSizeLeft:y.length,sampleSizeRight:r-y.length},summary:`${U(S,t.delta,t.relativeDelta)} \u2014 ${$} on ${y.length}/${r} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:y.map(w=>w.waferIndex),dieKeysByWafer:l},relatedIds:i.map(w=>w.finding.id)}}const ne={"Edge-ring":"edge","Edge-local":"edge","Center cluster":"centre or donut",Donut:"centre or donut"};function Ne(i,o){const r=new Map,s=n=>{const c=n.variable.kind==="spatialPattern"?ne[n.comparison.left]:void 0;return c?`spatialPattern|${c}`:be(n)};for(const n of i){const c=new Set,m=new Map;for(const t of n.summary.findings)if(t.variable.kind==="spatialPattern")for(const f of t.relatedIds??[])m.set(f,s(t));const p=new Set(n.summary.findings.flatMap(t=>t.absorbedIds??[]));for(const t of n.summary.findings){if(p.has(t.id)||Le(t)||t.variable.kind==="spatialPattern"&&o?.carriers.has(n.waferIndex))continue;const f=s(t);if(c.has(f))continue;c.add(f);const d=r.get(f)??{finding:t,waferIndices:[],severity:t.severity,labels:new Map,dieKeysByWafer:{},explainedBy:new Map};d.waferIndices.push(n.waferIndex);const b=m.get(t.id);if(b&&d.explainedBy.set(b,(d.explainedBy.get(b)??0)+1),t.variable.kind==="spatialPattern"){d.labels.set(t.comparison.left,(d.labels.get(t.comparison.left)??0)+1);const y=t.highlight.dieKeys;y&&(d.dieKeysByWafer[n.waferIndex]=y)}d.severity=T(d.severity,t.severity),r.set(f,d)}}const u=[];for(const[n,c]of r){if(c.waferIndices.length<N)continue;const m=c.waferIndices.length/Math.max(1,i.length),p=m>=.6||c.severity==="unusual"?"unusual":"notable",t=c.finding;u.push({id:`lot-repeat:${n}`,level:"lot",severity:p,variable:{...t.variable},comparison:{...t.comparison},effect:{direction:t.effect.direction,absoluteDelta:t.effect.absoluteDelta,relativeDelta:t.effect.relativeDelta,effectSize:t.effect.effectSize},stats:{method:"wafer-finding-frequency",sampleSizeLeft:c.waferIndices.length,sampleSizeRight:i.length-c.waferIndices.length},summary:`${Te(t,c.labels)} \u2014 seen on ${c.waferIndices.length}/${i.length} wafers (${Math.round(m*100)}%)`,highlight:{kind:"wafer",waferIndices:c.waferIndices,...c.labels.size?{dieKeysByWafer:c.dieKeysByWafer}:{}}})}const g=new Map(u.map(n=>[n.id,n]));for(const[n,c]of r){const m=g.get(`lot-repeat:${n}`);if(m)for(const[p,t]of c.explainedBy){const f=g.get(`lot-repeat:${p}`);!f||t!==c.waferIndices.length||(f.relatedIds??=[]).push(m.id)}}return u}function Ae(i,o){const{classification:r,carriers:s}=i,u=ke[r.pattern],g=s.size/Math.max(1,o),n={};for(const[c,m]of s)n[c]=m;return{id:"lot-repeat:spatialPattern|lot",level:"lot",severity:g>=.6||r.confidence==="high"?"unusual":"notable",variable:{kind:"spatialPattern",label:u},comparison:{family:"spatial-pattern",left:u,right:"Wafer"},effect:{direction:"different",effectSize:r.features.globalRdd},stats:{method:"wafer-finding-frequency",sampleSizeLeft:s.size,sampleSizeRight:o-s.size},summary:`Spatial pattern: ${u.toLowerCase()} \u2014 seen on ${s.size}/${o} wafers (${Math.round(g*100)}%)`,highlight:{kind:"wafer",waferIndices:[...s.keys()].sort((c,m)=>c-m),dieKeysByWafer:n}}}function We(i){const o=/^Rings? (\d+)(?:\s*[–-]\s*(\d+))?/.exec(i.comparison.left);if(!o)return[];const r=+o[1],s=o[2]?+o[2]:r;return Array.from({length:Math.max(0,s-r+1)},(u,g)=>r+g)}function Te(i,o){if(!o.size)return i.summary;const r=g=>g.toLowerCase();if(o.size===1)return`Spatial pattern: ${r([...o.keys()][0])}`;const s=ne[i.comparison.left],u=[...o].sort((g,n)=>n[1]-g[1]).map(([g,n])=>`${r(g)} on ${n}`);return`Spatial pattern: ${s} (${u.join(", ")})`}function _e(i,o){const r=Me(o,"median"),s=i.map(m=>({waferIndex:m.waferIndex,yieldPercent:m.summary.stats.yieldPercent})).filter(m=>m.yieldPercent!==null),u=s.map(m=>m.yieldPercent),g=outlierWafers(u);if(!g)return[];const n=ee(u),c=[];for(const{index:m,severity:p,statistic:t}of g.outliers){const f=s[m],d=f.yieldPercent-n,b=se({wafer:{metadata:i.find(y=>y.waferIndex===f.waferIndex)?.summary.wafer}},f.waferIndex);c.push({id:`inter-wafer:yield:${f.waferIndex}`,level:"inter-wafer",severity:p,variable:{kind:"yield",label:"Yield"},comparison:{family:"wafer",left:b,right:r.charAt(0).toUpperCase()+r.slice(1)},effect:{direction:d>0?"higher":"lower",absoluteDelta:d/100,relativeDelta:n===0?void 0:d/n,effectSize:t},stats:{method:g.method,sampleSizeLeft:1,sampleSizeRight:s.length-1},summary:`${b} yield is ${Math.abs(d).toFixed(1)} percentage points ${d>0?"higher":"lower"} than the ${r}`,highlight:{kind:"wafer",waferIndices:[f.waferIndex]}})}return c}export function analyzeWaferLot(i,o={}){const r=i.map(me),s=r.map((e,l)=>({waferIndex:l,summary:o.perWaferSummaries?.[l]??G(e,o)})),u=s.map(({waferIndex:e,summary:l})=>H(l)??H(G(r[e],o))),g=u.map((e,l)=>({waferIndex:l,byKey:new Map(e.candidates.map(h=>[h.key,h]))})),n=re(o).resolved,c=r.length>0?ae(r[0],"analyzeWaferLot"):void 0,m=we(r,n),p=m&&m.carriers.size>=N?m:null,t=[...c===void 0?[]:qe(g,n,Ee(u,n.sectorCount),c),...Ne(s,p),..._e(s,Re(s.map(e=>e.summary.wafer))),...ve(s,n.significanceLevel)];if(p&&c!==void 0){const e=Ae(p,s.length);e.relatedIds=Se([p.classification.pattern],e.severity,t,We,c),e.relatedIds.length||delete e.relatedIds,t.push(e)}t.sort((e,l)=>{const h=e.severity==="unusual"?2:e.severity==="notable"?1:0,S=l.severity==="unusual"?2:l.severity==="notable"?1:0;return h!==S?S-h:e.summary.localeCompare(l.summary,"en")});const f=s.map(e=>e.summary.wafer).filter(e=>!!e),d={},b=[];if(f.length>0){const e=new Set;for(const l of f)for(const h of Object.keys(l))e.add(h);e.delete("wafer"),e.delete("waferId");for(const l of e){const h=f.filter(v=>l in v).map(v=>v[l]);h.every(v=>v===h[0])?d[l]=h[0]:b.push(l)}}const y=s.map(({waferIndex:e,summary:l})=>({waferIndex:e,yieldPercent:l.stats.yieldPercent})),a=s.map(({waferIndex:e,summary:l})=>l.stats.perTestStats?.length?{waferIndex:e,tests:l.stats.perTestStats}:null).filter(e=>e!==null);return{level:"lot",hasNotableFindings:t.some(e=>e.severity!=="info")||s.some(e=>e.summary.hasNotableFindings),findings:t,lot:Object.keys(d).length>0?d:void 0,...b.length>0?{mixedIdentityFields:b}:{},stats:{waferCount:i.length,...je(r,s.map(e=>e.summary))},lotYieldSeries:y,perWafer:s,...a.length>0?{perWaferTestStats:a}:{}}}function je(i,o){const r={...he(o)},s=ge(o,ye(i).defs);s&&(r.capability=s);const u=pe(o,i.map(g=>g.ringCount));return u&&(r.regionYield=u),r}
|
|
1
|
+
import{waferDisplayLabel as oe}from"../core/waferLabel.js";import{requireRingCount as ce}from"../core/ringCount.js";import{analyzeWaferMapDecided as F,candidatesOf as H,describeRegional as U,resolveOptions as le,adjustPValues as fe,testValueSize as de,recordedOptions as ue,twoProportionZ as Q,welchOfSums as X,rateRelativeEffect as me,passesRateGate as pe,severityForFinding as Z,severityForScore as J,collapseRedundantFindings as ge,findContiguousRuns as he,mergedRegionLabel as ye}from"./analyzeWaferMap.js";import{normalizeInput as ee}from"./normalizeInput.js";import{autoDecision as we,lotTestValueStatus as be}from"./testValueBudget.js";import{poolCapability as Se,poolRegionYield as ve,poolPassRates as ze}from"./summaryFigures.js";import{mergeTestDefs as Ie}from"./mergeTestDefs.js";import{findingPatternKey as ke}from"./filterFindings.js";import{median as te}from"../core/utils.js";import{robustFence as ne,zPValue as T}from"./math.js";import{findLotPattern as xe}from"./lotPattern.js";import{buildDriftFindings as Pe}from"./lotDrift.js";import{claimForPattern as Re,confirmRegionalFindings as Me,weakestMultiplier as $e}from"./analyzeWaferMap.js";import{PATTERN_LABELS as De}from"./patternClassification.js";import{describeWaferPopulation as Be,populationStat as We}from"./population.js";const N=8,Le={3:[.97,.994],4:[.829,.926],5:[.71,.821],6:[.625,.74],7:[.568,.68]},Ke=3;export function outlierWafers(e){const o=e.length;if(o<3)return null;const s=te([...e]),t=n=>Math.abs(n-s)>=Ke;if(o>=N){const n=ne(e,1.5,N),d=ne(e,3,N);if(!n||!d)return null;const m=(n.hi-n.lo)/4,w=[];return e.forEach((y,l)=>{if(y>=n.lo&&y<=n.hi||!t(y))return;const f=y<d.lo||y>d.hi?"unusual":"notable";w.push({index:l,severity:f,statistic:(y-s)/m})}),{method:"tukey-fence",outliers:w}}const a=e.map((n,d)=>d).sort((n,d)=>e[n]-e[d]),u=e[a[o-1]]-e[a[0]];if(u===0)return null;const[r,c]=Le[o],p=[],h=(n,d)=>{const m=Math.abs(e[n]-e[d])/u;m>r&&t(e[n])&&p.push({index:n,severity:m>c?"unusual":"notable",statistic:m})};return h(a[0],a[1]),h(a[o-1],a[o-2]),{method:"dixon-q",outliers:p}}const q=2;function O(e,o){const s={info:0,notable:1,unusual:2};return s[e]>=s[o]?e:o}const Ee=new Set(["ring","quadrant","sector"]),Te=new Set(["ring","quadrant","sector","reticle-position","test-site"]),qe=new Set(["yield","hardBin","softBin","functionalTest","test"]);function Ae(e){return Te.has(e.comparison.family)&&qe.has(e.variable.kind)}function Fe(e,o){const s=e.map(r=>r.facts);if(!s.length||s.some(r=>!r))return{coincident:new Set,yieldSoftBin:void 0,passBins:[],sectorCount:o};const[t,...a]=s,u=a.every(r=>r.passBins.length===t.passBins.length&&r.passBins.every(c=>t.passBins.includes(c)));return{coincident:new Set([...t.coincident].filter(r=>a.every(c=>c.coincident.has(r)))),yieldSoftBin:a.every(r=>r.yieldSoftBin===t.yieldSoftBin)?t.yieldSoftBin:void 0,passBins:u?t.passBins:[],sectorCount:o}}function j(e,o){let s=0,t=0,a=0,u=0,r=0,c=0,p=0,h=0,n=0,d=!0,m=0;for(const{waferIndex:l,c:f}of e){const i=o(l,f),g=f.rate??f.mean,b=Math.sqrt(g.n+i.n);if(f.rate)s+=b*Q(f.rate.hits,f.rate.n,i.hits,i.n),a+=f.rate.hits,u+=f.rate.n,r+=i.hits,c+=i.n;else{const v=X(f.mean,i.n,i.sum,i.sq);s+=b*v.z,p+=f.mean.n*v.effectSize,h+=f.mean.n*v.delta,m+=f.mean.n,f.relativeDelta===void 0?d=!1:n+=f.mean.n*f.relativeDelta}t+=b*b}const w=t>0?s/Math.sqrt(t):0,y=e[0].c;if(y.rate){const l=r/c,f=a/u-l;return{z:w,delta:f,relativeDelta:l===0?void 0:f/l,size:me({hits:a,n:u,restHits:r,restN:c,passRate:y.rate.passRate})}}return{z:w,delta:h/m,relativeDelta:d?n/m:void 0,size:p/m}}function V(e,o,s,t){return e.rate?pe(o,s.delta,s.size,t):o<=t.significanceLevel&&Math.abs(s.size)>=t.minimumEffectSize}function Ne(e,o,s,t){const a=new Map;for(const{waferIndex:l,byKey:f}of e)for(const i of f.values())(a.get(i.key)??a.set(i.key,[]).get(i.key)).push({waferIndex:l,c:i});const u=new Map(e.map(l=>[l.waferIndex,l.byKey])),r=(l,f)=>f.rate?{hits:f.rate.restHits,n:f.rate.restN,sum:0,sq:0}:{hits:0,n:f.mean.restN,sum:f.mean.restSum,sq:f.mean.restSq},c=[];for(const[l,f]of a){if(f.length<q)continue;const i=j(f,r);if(i.z===0)continue;const g=f[0].c;c.push({key:l,entries:f,combined:i,finding:{id:`lot-region:${l}`,level:"lot",severity:"info",variable:{...g.variable,label:g.label},comparison:{...g.comparison},effect:{direction:i.z>0?"higher":"lower",absoluteDelta:i.delta,relativeDelta:i.relativeDelta,effectSize:g.rate?i.delta:i.size},stats:{method:"stouffer-z",pValue:T(i.z),sampleSizeLeft:0,sampleSizeRight:0},summary:"",highlight:{kind:"wafer",waferIndices:[]}}})}fe(c.map(l=>l.finding));const p=c.filter(l=>V(l.entries[0].c,l.finding.stats.adjustedPValue??1,l.combined,o)),d=Me(p,l=>{const f=l.entries[0].c;return[f.source,f.variable.kind,f.variable.bin??"",f.variable.index??"",f.region.family].join("\0")},(l,f)=>{const i=(R,D)=>{const k=r(R,D);for(const z of f){const P=u.get(R)?.get(z.key);P&&(P.rate?(k.hits-=P.rate.hits,k.n-=P.rate.n):(k.n-=P.mean.n,k.sum-=P.mean.sum,k.sq-=P.mean.sq))}return k},g=l.entries.filter(R=>i(R.waferIndex,R.c).n>=o.minimumSampleSize);if(!g.length)return"baseline-too-small";const b=j(g,i),v=l.finding.stats.pValue??1,x=v>0?(l.finding.stats.adjustedPValue??v)/v:1,S=Math.min(1,T(b.z)*x);return{pValue:S,passes:Math.sign(b.z)===Math.sign(l.combined.z)&&V(l.entries[0].c,S,b,o)}},l=>{const f=l.entries[0].c.rate;return f!==void 0&&(f.passRate?l.combined.z<0:l.combined.z>0)},c),m=[],w=new Map;for(const l of p){if(!d.has(l))continue;const f=l.finding.stats.pValue??1,i=Math.sign(l.combined.z),g=l.entries.filter(z=>Math.sign(z.c.delta)===i),b=e.length,v=l.entries[0].c,x=l.finding.stats.adjustedPValue??f,S=v.rate?Z(x,l.combined.delta,l.combined.size):J(x,l.combined.size),R=O(S,g.length/b>=.6?"unusual":"info"),D={};for(const z of g)D[z.waferIndex]=[...z.c.region.dieKeys];const k={...l.finding,severity:R,stats:{...l.finding.stats,sampleSizeLeft:g.length,sampleSizeRight:b-g.length},summary:`${U(v,l.combined.delta,l.combined.relativeDelta)} \u2014 ${l.finding.effect.direction} on ${g.length}/${b} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:g.map(z=>z.waferIndex),dieKeysByWafer:D}};m.push(k),w.set(k,l)}const y=Oe(w,u,e.length,o,t,r);return m.splice(0,m.length,...m.filter(l=>!y.replaced.has(l)),...y.findings),ge(m,s),m}function Oe(e,o,s,t,a,u){const r=new Map;for(const[h,n]of e){const d=n.entries[0].c;if(!Ee.has(d.region.family))continue;const m=[d.source,d.variable.kind,d.variable.bin??"",d.variable.index??"",d.region.family,h.effect.direction].join("|");(r.get(m)??r.set(m,[]).get(m)).push({finding:h,c:d,key:n.key})}const c=[],p=new Set;for(const h of r.values()){if(h.length<2)continue;const n=h[0].c.region.family;for(const d of he(h,n,t.sectorCount,m=>m.c.region.key)){if(d.length<2)continue;const m=je(d,o,s,t,a,u);if(m){c.push(m);for(const w of d)p.add(w.finding)}}}return{findings:c,replaced:p}}function je(e,o,s,t,a,u){const r=e[0].c,c=e[0].finding.effect.direction==="higher"?1:-1,p=ye(r.region.family,e.map(S=>S.c.region.key),a),h=[];for(const[S,R]of o){const D=e.map(I=>R.get(I.key));if(D.some(I=>!I))continue;const k=D,z=k[0];let P,A;if(z.rate){const I=k.reduce(($,B)=>$+B.rate.hits,0),M=k.reduce(($,B)=>$+B.rate.n,0),L=z.rate.hits+z.rate.restHits-I,W=z.rate.n+z.rate.restN-M;if(M<t.minimumSampleSize||W<t.minimumSampleSize)continue;P={...z,rate:{hits:I,n:M,restHits:L,restN:W,passRate:z.rate.passRate}},A=Q(I,M,L,W)}else{const I=z.mean,M=k.reduce((K,E)=>K+E.mean.n,0),L=k.reduce((K,E)=>K+E.mean.sum,0),W=k.reduce((K,E)=>K+E.mean.sq,0),$=I.n+I.restN-M,B=I.sum+I.restSum-L,_=I.sq+I.restSq-W;if(M<t.minimumSampleSize||$<t.minimumSampleSize)continue;const Y={n:M,sum:L,sq:W,restN:$,restSum:B,restSq:_,shift:I.shift},C=X(Y,$,B,_),G=B/$+I.shift;P={...z,mean:Y,relativeDelta:G!==0?C.delta/Math.abs(G):void 0},A=C.z}const re=[...new Set(k.flatMap(I=>[...I.region.dieKeys]))];h.push({waferIndex:S,c:P,z:A,dieKeys:re})}if(h.length<q)return;const n=j(h,u);if(n.z===0||Math.sign(n.z)!==c)return;const d=T(n.z),m=$e(e.map(S=>S.finding)),w=Math.min(1,d*m);if(!V(r,w,n,t))return;const y=h.filter(S=>Math.sign(S.z)===c&&T(S.z)<=t.significanceLevel);if(!y.length)return;const l=r.rate?Z(w,n.delta,n.size):J(w,n.size),f=O(l,y.length/s>=.6?"unusual":"info"),i={};for(const S of y)i[S.waferIndex]=S.dieKeys;const g=e.map(S=>S.c.region.key.slice(S.c.region.key.indexOf(":")+1)).join("-"),b={...r,comparison:{...r.comparison,left:p}},v=e[0].finding,x=v.effect.direction;return{...v,id:`lot-region:${e[0].key.split("|").slice(0,-1).join("|")}|${r.region.family}:${g}`,severity:f,comparison:{...v.comparison,left:p},effect:{direction:x,absoluteDelta:n.delta,relativeDelta:n.relativeDelta,effectSize:r.rate?n.delta:n.size},stats:{method:"stouffer-z",pValue:d,adjustedPValue:w,sampleSizeLeft:y.length,sampleSizeRight:s-y.length},summary:`${U(b,n.delta,n.relativeDelta)} \u2014 ${x} on ${y.length}/${s} wafers, all wafers' data combined`,highlight:{kind:"wafer",waferIndices:y.map(S=>S.waferIndex),dieKeysByWafer:i},relatedIds:e.map(S=>S.finding.id)}}const ie={"Edge-ring":"edge","Edge-local":"edge","Center cluster":"centre or donut",Donut:"centre or donut"};function Ve(e,o){const s=new Map,t=r=>{const c=r.variable.kind==="spatialPattern"?ie[r.comparison.left]:void 0;return c?`spatialPattern|${c}`:ke(r)};for(const r of e){const c=new Set,p=new Map;for(const n of r.summary.findings)if(n.variable.kind==="spatialPattern")for(const d of n.relatedIds??[])p.set(d,t(n));const h=new Set(r.summary.findings.flatMap(n=>n.absorbedIds??[]));for(const n of r.summary.findings){if(h.has(n.id)||Ae(n)||n.variable.kind==="spatialPattern"&&o?.carriers.has(r.waferIndex))continue;const d=t(n);if(c.has(d))continue;c.add(d);const m=s.get(d)??{finding:n,waferIndices:[],severity:n.severity,labels:new Map,dieKeysByWafer:{},explainedBy:new Map};m.waferIndices.push(r.waferIndex);const w=p.get(n.id);if(w&&m.explainedBy.set(w,(m.explainedBy.get(w)??0)+1),n.variable.kind==="spatialPattern"){m.labels.set(n.comparison.left,(m.labels.get(n.comparison.left)??0)+1);const y=n.highlight.dieKeys;y&&(m.dieKeysByWafer[r.waferIndex]=y)}m.severity=O(m.severity,n.severity),s.set(d,m)}}const a=[];for(const[r,c]of s){if(c.waferIndices.length<q)continue;const p=c.waferIndices.length/Math.max(1,e.length),h=p>=.6||c.severity==="unusual"?"unusual":"notable",n=c.finding;a.push({id:`lot-repeat:${r}`,level:"lot",severity:h,variable:{...n.variable},comparison:{...n.comparison},effect:{direction:n.effect.direction,absoluteDelta:n.effect.absoluteDelta,relativeDelta:n.effect.relativeDelta,effectSize:n.effect.effectSize},stats:{method:"wafer-finding-frequency",sampleSizeLeft:c.waferIndices.length,sampleSizeRight:e.length-c.waferIndices.length},summary:`${Ce(n,c.labels)} \u2014 seen on ${c.waferIndices.length}/${e.length} wafers (${Math.round(p*100)}%)`,highlight:{kind:"wafer",waferIndices:c.waferIndices,...c.labels.size?{dieKeysByWafer:c.dieKeysByWafer}:{}}})}const u=new Map(a.map(r=>[r.id,r]));for(const[r,c]of s){const p=u.get(`lot-repeat:${r}`);if(p)for(const[h,n]of c.explainedBy){const d=u.get(`lot-repeat:${h}`);!d||n!==c.waferIndices.length||(d.relatedIds??=[]).push(p.id)}}return a}function _e(e,o){const{classification:s,carriers:t}=e,a=De[s.pattern],u=t.size/Math.max(1,o),r={};for(const[c,p]of t)r[c]=p;return{id:"lot-repeat:spatialPattern|lot",level:"lot",severity:u>=.6||s.confidence==="high"?"unusual":"notable",variable:{kind:"spatialPattern",label:a},comparison:{family:"spatial-pattern",left:a,right:"Wafer"},effect:{direction:"different",effectSize:s.features.globalRdd},stats:{method:"wafer-finding-frequency",sampleSizeLeft:t.size,sampleSizeRight:o-t.size},summary:`Spatial pattern: ${a.toLowerCase()} \u2014 seen on ${t.size}/${o} wafers (${Math.round(u*100)}%)`,highlight:{kind:"wafer",waferIndices:[...t.keys()].sort((c,p)=>c-p),dieKeysByWafer:r}}}function Ye(e){const o=/^Rings? (\d+)(?:\s*[–-]\s*(\d+))?/.exec(e.comparison.left);if(!o)return[];const s=+o[1],t=o[2]?+o[2]:s;return Array.from({length:Math.max(0,t-s+1)},(a,u)=>s+u)}function Ce(e,o){if(!o.size)return e.summary;const s=u=>u.toLowerCase();if(o.size===1)return`Spatial pattern: ${s([...o.keys()][0])}`;const t=ie[e.comparison.left],a=[...o].sort((u,r)=>r[1]-u[1]).map(([u,r])=>`${s(u)} on ${r}`);return`Spatial pattern: ${t} (${a.join(", ")})`}function Ge(e,o){const s=We(o,"median"),t=e.map(p=>({waferIndex:p.waferIndex,yieldPercent:p.summary.stats.yieldPercent})).filter(p=>p.yieldPercent!==null),a=t.map(p=>p.yieldPercent),u=outlierWafers(a);if(!u)return[];const r=te(a),c=[];for(const{index:p,severity:h,statistic:n}of u.outliers){const d=t[p],m=d.yieldPercent-r,w=oe({wafer:{metadata:e.find(y=>y.waferIndex===d.waferIndex)?.summary.wafer}},d.waferIndex);c.push({id:`inter-wafer:yield:${d.waferIndex}`,level:"inter-wafer",severity:h,variable:{kind:"yield",label:"Yield"},comparison:{family:"wafer",left:w,right:s.charAt(0).toUpperCase()+s.slice(1)},effect:{direction:m>0?"higher":"lower",absoluteDelta:m/100,relativeDelta:r===0?void 0:m/r,effectSize:n},stats:{method:u.method,sampleSizeLeft:1,sampleSizeRight:t.length-1},summary:`${w} yield is ${Math.abs(m).toFixed(1)} percentage points ${m>0?"higher":"lower"} than the ${s}`,highlight:{kind:"wafer",waferIndices:[d.waferIndex]}})}return c}function se(e,o){if((o.enableTestValueAnalysis??"auto")!=="auto")return;let s=0;for(const t of e){const{tests:a,dies:u}=de(t,o);s+=a*u}return we(s)}export function analyzeWaferLot(e,o={}){const s=e.map(ee),t=se(s,o),a=s.map((i,g)=>({waferIndex:g,summary:o.perWaferSummaries?.[g]??F(i,o,t)})),u=a.map(({waferIndex:i,summary:g})=>H(g)??H(F(s[i],o,t))),r=u.map((i,g)=>({waferIndex:g,byKey:new Map(i.candidates.map(b=>[b.key,b]))})),c=le(o).resolved,p=s.length>0?ce(s[0],"analyzeWaferLot"):void 0,h=xe(s,c),n=h&&h.carriers.size>=q?h:null,d=[...p===void 0?[]:Ne(r,c,Fe(u,c.sectorCount),p),...Ve(a,n),...Ge(a,Be(a.map(i=>i.summary.wafer))),...Pe(a,c.significanceLevel)];if(n&&p!==void 0){const i=_e(n,a.length);i.relatedIds=Re([n.classification.pattern],i.severity,d,Ye,p),i.relatedIds.length||delete i.relatedIds,d.push(i)}d.sort((i,g)=>{const b=i.severity==="unusual"?2:i.severity==="notable"?1:0,v=g.severity==="unusual"?2:g.severity==="notable"?1:0;return b!==v?v-b:i.summary.localeCompare(g.summary,"en")});const m=a.map(i=>i.summary.wafer).filter(i=>!!i),w={},y=[];if(m.length>0){const i=new Set;for(const g of m)for(const b of Object.keys(g))i.add(b);i.delete("wafer"),i.delete("waferId");for(const g of i){const b=m.filter(x=>g in x).map(x=>x[g]);b.every(x=>x===b[0])?w[g]=b[0]:y.push(g)}}const l=a.map(({waferIndex:i,summary:g})=>({waferIndex:i,yieldPercent:g.stats.yieldPercent})),f=a.map(({waferIndex:i,summary:g})=>g.stats.perTestStats?.length?{waferIndex:i,tests:g.stats.perTestStats}:null).filter(i=>i!==null);return{level:"lot",hasNotableFindings:d.some(i=>i.severity!=="info")||a.some(i=>i.summary.hasNotableFindings),findings:d,lot:Object.keys(w).length>0?w:void 0,...y.length>0?{mixedIdentityFields:y}:{},analysisOptions:ue(o),stats:{waferCount:e.length,...He(s,a.map(i=>i.summary)),...Ue(be(a.map(i=>i.summary)))},lotYieldSeries:l,perWafer:a,...f.length>0?{perWaferTestStats:f}:{}}}function He(e,o){const s={...ze(o)},t=Se(o,Ie(e).defs);t&&(s.capability=t);const a=ve(o,e.map(u=>u.ringCount));return a&&(s.regionYield=a),s}const Ue=e=>e?{testValueAnalysis:e}:{},ae=()=>new Promise(e=>setTimeout(e,0));export async function analyzeWaferLotAsync(e,o={}){const{onProgress:s,signal:t,...a}=o,u=e.map(ee),r=se(u,a),c=[];let p=Date.now();for(let h=0;h<u.length;h++)t?.throwIfAborted(),c.push(a.perWaferSummaries?.[h]??F(u[h],a,r)),s?.(h+1,u.length),Date.now()-p>100&&(await ae(),p=Date.now());return await ae(),t?.throwIfAborted(),analyzeWaferLot(u,{...a,perWaferSummaries:c})}export function remapLotWaferIndices(e,o){const s=t=>o[t]??t;return{...e,perWafer:e.perWafer.map(t=>({...t,waferIndex:s(t.waferIndex)})),lotYieldSeries:e.lotYieldSeries.map(t=>({...t,waferIndex:s(t.waferIndex)})),...e.perWaferTestStats?{perWaferTestStats:e.perWaferTestStats.map(t=>({...t,waferIndex:s(t.waferIndex)}))}:{},findings:e.findings.map(t=>{const a=t.highlight;if(!a||a.kind!=="wafer")return t;const u=a.dieKeysByWafer?Object.fromEntries(Object.entries(a.dieKeysByWafer).map(([r,c])=>[s(Number(r)),c])):void 0;return{...t,highlight:{...a,waferIndices:a.waferIndices.map(s),...u?{dieKeysByWafer:u}:{}}}})}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Die } from '../core/dies.js';
|
|
2
|
-
import type { TestDef, WaferWarning } from '../renderer/buildWaferMap.js';
|
|
2
|
+
import type { TestDef, WaferWarning, WaferMapResult } from '../renderer/buildWaferMap.js';
|
|
3
3
|
import type { AnalyzeWaferMapInput, AnalyzeWaferMapOptions, StatsFinding, StatsSeverity, StatsSummary } from './types.js';
|
|
4
4
|
import { type StatsRegion } from './regions.js';
|
|
5
5
|
import { type PatternLabel } from './patternClassification.js';
|
|
@@ -33,6 +33,14 @@ export declare function resolveOptions(options: AnalyzeWaferMapOptions): {
|
|
|
33
33
|
resolved: ResolvedOptions;
|
|
34
34
|
warnings: WaferWarning[];
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Lists under each cluster of one bin (`relatedIds`) the region findings of that bin it explains: a rise in the
|
|
38
|
+
* bin in a ring, quadrant or sector that the cluster's dies make up at least half of, and no more severe than the
|
|
39
|
+
* cluster. Those findings are the same spot seen through a coarser region, and read below it rather than ahead of
|
|
40
|
+
* it; like the rows a pattern claims, they are marked info. A region row more severe than the cluster carries the
|
|
41
|
+
* stronger evidence, so it stands on its own.
|
|
42
|
+
*/
|
|
43
|
+
export declare function claimForBinClusters(findings: StatsFinding[]): void;
|
|
36
44
|
/**
|
|
37
45
|
* Per-test pass rate for functional (`testType: 'F'`) tests — the functional
|
|
38
46
|
* counterpart of `computeTestSpecYield`. Same population convention: partial and
|
|
@@ -185,6 +193,17 @@ export declare function welchFromStats(leftN: number, leftMean: number, leftVar:
|
|
|
185
193
|
delta: number;
|
|
186
194
|
z: number;
|
|
187
195
|
};
|
|
196
|
+
/**
|
|
197
|
+
* The size of one built wafer's test-value analysis under `options`: the tests it
|
|
198
|
+
* would cover and the dies it reads, counted as `analyzeWaferMap` counts them. For
|
|
199
|
+
* `analyzeWaferLot`, which takes the `'auto'` decision over the whole lot.
|
|
200
|
+
*/
|
|
201
|
+
export declare function testValueSize(result: WaferMapResult, options: AnalyzeWaferMapOptions): {
|
|
202
|
+
tests: number;
|
|
203
|
+
dies: number;
|
|
204
|
+
};
|
|
205
|
+
/** The options a summary records (`analysisOptions`): the public ones that were passed. */
|
|
206
|
+
export declare function recordedOptions(options: AnalyzeWaferMapOptions): AnalyzeWaferMapOptions;
|
|
188
207
|
/**
|
|
189
208
|
* A connected set of quadrants in reading order round the wafer, starting after
|
|
190
209
|
* a gap when there is one ("NW, SW & SE", not whatever order the search met
|
|
@@ -217,5 +236,11 @@ export interface RedundancyFacts {
|
|
|
217
236
|
export declare function redundancyFacts(eligibleDies: EligibleDie[], passBins: number[], sectorCount: number): RedundancyFacts;
|
|
218
237
|
export declare function collapseRedundantFindings(findings: RawFinding[], facts: RedundancyFacts): void;
|
|
219
238
|
export declare function analyzeWaferMap(input: AnalyzeWaferMapInput, options?: AnalyzeWaferMapOptions): StatsSummary;
|
|
239
|
+
/**
|
|
240
|
+
* `analyzeWaferMap` with the `'auto'` test-value decision already taken — by
|
|
241
|
+
* `analyzeWaferLot`, over the whole lot, so each wafer follows it rather than its
|
|
242
|
+
* own size. Internal.
|
|
243
|
+
*/
|
|
244
|
+
export declare function analyzeWaferMapDecided(input: AnalyzeWaferMapInput, options?: AnalyzeWaferMapOptions, lotDecision?: 'done' | 'skipped'): StatsSummary;
|
|
220
245
|
export {};
|
|
221
246
|
//# sourceMappingURL=analyzeWaferMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeInput as Ze}from"./normalizeInput.js";import{computeCapability as Je,computeTestFlagYield as et,computeRegionYield as tt}from"./summaryFigures.js";import{binPassSets as xe}from"../renderer/binColors.js";import{diePassStatus as pe,isYieldEligibleDie as ge,getDieKey as be,isPositionedDie as Pe,positionKey as ye}from"../core/dies.js";import{dieHasValues as nt,testsPresent as Ce,testValue as j}from"../core/dieTable.js";import{getTestPassStatus as re,isParametricTest as _}from"../renderer/buildWaferMap.js";import{markedTestLabel as T,derivedFields as fe}from"../renderer/testLabel.js";import{buildQuadrantRegions as it,buildReticlePositionRegions as st,buildRingRegions as ot,buildSectorRegions as at,buildTestSiteRegions as rt,sectorCompassNames as Ve,areQuadrantsAdjacent as ft,parseRegionKey as Q,QUADRANT_CYCLE as Se,regionAngleBins as lt}from"./regions.js";import{buildClusterFindings as ct}from"./clusterDetection.js";import{classifyPattern as ut,patternExplains as dt,patternFailVerdict as mt,PATTERN_LABELS as ht}from"./patternClassification.js";import{requirePassBins as pt}from"../core/passBins.js";import{requireRingCount as gt}from"../core/ringCount.js";import{benjaminiHochberg as bt,fisherExact as yt,fiveNumberSummary as St,sampleVariance as we,zPValue as Ee}from"./math.js";import{mean as le,maxOf as wt}from"../core/utils.js";import{classifySpec as ce,isOutOfSpec as ve}from"../renderer/spec.js";const vt={significanceLevel:{min:1e-6,max:1},minimumEffectSize:{min:0,max:1},minimumRelativeEffect:{min:0,max:Number.MAX_SAFE_INTEGER}},Le=[4,8,16];export function resolveOptions(t){const n=Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)),i={...J,...n},s=[],e=[];for(const r of["significanceLevel","minimumEffectSize","minimumRelativeEffect"]){const{min:c,max:o}=vt[r],u=i[r];if(typeof u!="number"||!Number.isFinite(u)){e.push(`${r}=${String(u)} is not a finite number (using ${J[r]})`),i[r]=J[r];continue}const f=Math.min(o,Math.max(c,u));f!==u&&(e.push(`${r}=${u} is outside ${c}\u2013${o} (using ${f})`),i[r]=f)}if(Le.includes(i.sectorCount)||(e.push(`sectorCount=${i.sectorCount} is not one of ${Le.join(", ")} (using ${J.sectorCount})`),i.sectorCount=J.sectorCount),e.length){const r=`analyzeWaferMap: ${e.join("; ")}. The analysis ran with the corrected values.`;console.warn(`[wafermap] ${r}`),s.push({code:"analysis-option-corrected",message:r,severity:"warning"})}const a=["passBins","ringCount"].filter(r=>n[r]!==void 0);if(a.length){const r=`analyzeWaferMap: ${a.join(" and ")} ${a.length>1?"are":"is"} no longer an analysis option and was ignored. Set ${a.length>1?"them":"it"} on buildWaferMap; the analysis used the value the map was built with.`;console.warn(`[wafermap] ${r}`),s.push({code:"analysis-option-corrected",message:r,severity:"warning"})}const l=["enableYieldAnalysis","enableHardBinAnalysis","enableSoftBinAnalysis","enableReticlePositionAnalysis","enableTestSiteAnalysis","enableClusterAnalysis","enableAngularAnalysis","enablePatternClassification"].filter(r=>n[r]!==void 0);if(l.length){const r=`analyzeWaferMap: ${l.join(", ")} ${l.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] ${r}`),s.push({code:"analysis-option-corrected",message:r,severity:"warning"})}return{resolved:i,warnings:s}}const J={significanceLevel:.05,minimumEffectSize:.2,minimumRelativeEffect:1,minimumSampleSize:5,enableTestValueAnalysis:!1,computePerTestStats:!1,sectorCount:8,minimumClusterSize:5};function $t(t,n){const i={...t};return i.minimumClusterSize=Math.max(5,Math.round(n*.003)),i}function kt(t){return ge(t)?t.hbin!==void 0||t.sbin!==void 0||nt(t):!1}function Rt(t,n,i){if(!t||n)return;const s=(i??[]).filter(e=>_(e)&&(e.limitLow!==void 0||e.limitHigh!==void 0));if(s.length!==0)return e=>{for(const a of s)if(ve(ce(j(e,a.testNumber),a)))return!0;return!1}}function Dt(t,n,i){const s=new Set,e=new Set,a=new Set,l=new Map,r=new Map;for(const c of Ce(t))s.add(c);for(const c of t)c.hbin!==void 0&&e.add(c.hbin),c.sbin!==void 0&&a.add(c.sbin),ge(c)&&(c.hbin!==void 0&&l.set(c.hbin,(l.get(c.hbin)??0)+1),c.sbin!==void 0&&r.set(c.sbin,(r.get(c.sbin)??0)+1));return{totalDies:t.length,analyzedDies:n,excludedDies:t.length-n,yieldPercent:i,testsConsidered:[...s].sort((c,o)=>c-o),hardBinsConsidered:[...e].sort((c,o)=>c-o),softBinsConsidered:[...a].sort((c,o)=>c-o),...l.size?{hardBinCounts:Object.fromEntries(l)}:{},...r.size?{softBinCounts:Object.fromEntries(r)}:{}}}function Mt(t,n,i){if(!n?.length)return;const s=n.filter(a=>_(a)&&(a.limitLow!==void 0||a.limitHigh!==void 0));if(!s.length)return;const e=[];for(const a of s){const l=a.testNumber;let r=0,c=0,o=0,u=0;for(const f of t){if(f.partial||f.edgeExcluded)continue;const h=ce(j(f,l),a);if(h!==null){if(u++,h==="failLow")c++;else if(h==="failHigh")o++;else{r++;continue}i?.(l,f)}}e.push({testNumber:l,label:a.name,passDies:r,failLowDies:c,failHighDies:o,totalDies:u,yieldPercent:u>0?r/u*100:null})}return e.length?e:void 0}export function computeFunctionalYield(t,n,i){if(!n?.length)return;const s=n.filter(a=>!_(a));if(!s.length)return;const e=[];for(const a of s){const l=a.testNumber;let r=0,c=0;for(const u of t){if(u.partial||u.edgeExcluded)continue;const f=re(u,l,a);if(f!==void 0){if(f){r++;continue}c++,i?.(l,u)}}const o=r+c;e.push({testNumber:l,label:T(a,l),...fe(a),passDies:r,failDies:c,totalDies:o,passRatePercent:o>0?r/o*100:null})}return e.length?e:void 0}function zt(t,n,i,s){const e=[];for(const a of n){const l=[];for(const f of t){if(f.partial||f.edgeExcluded)continue;const h=j(f,a);h!==void 0&&Number.isFinite(h)&&l.push(h)}if(l.length<s)continue;const r=le(l),c=Math.sqrt(we(l,r)),o=St(Float64Array.from(l)),u=i?.find(f=>f.testNumber===a)?.name??String(a);e.push({testNumber:a,label:u,count:l.length,min:o.min,max:o.max,mean:r,stddev:c,median:o.median,q1:o.q1,q3:o.q3})}return e.length?e:void 0}export function twoProportionZ(t,n,i,s){const e=(t+i)/(n+s),a=e*(1-e)*(1/n+1/s);return!Number.isFinite(a)||a<=0?0:(t/n-i/s)/Math.sqrt(a)}const Bt=5;function q(t,n,i,s){const e=n+s,a=t+i;if((e>0?Math.min(a,e-a)*Math.min(n,s)/e:0)<Bt)return{pValue:yt(t,n-t,i,s-i),method:"fisher-exact"};const r=twoProportionZ(t,n,i,s);return{pValue:r===0?1:Ee(r),method:"two-proportion-z"}}function Ft(t,n,i,s){return q(t,n,i,s).pValue}export function adjustPValues(t){const n=t.filter(s=>s.stats.pValue!==void 0),i=bt(n.map(s=>s.stats.pValue));return n.forEach((s,e)=>{s.stats.adjustedPValue=i[e]}),t}export function rateRelativeEffect(t){const n=(t.passRate?t.n-t.hits:t.hits)/t.n,i=(t.passRate?t.restN-t.restHits:t.restHits)/t.restN;return i===0?n===0?0:1/0:Math.abs(n-i)/i}export function severityForFinding(t,n,i){const s=Math.abs(n),e=i;return t<=.01&&(s>=.3||e>=2.5)?"unusual":t<=.05&&(s>=.2||e>=1.5)?"notable":"info"}export function severityForScore(t,n){return t<=.01&&Math.abs(n)>=.5?"unusual":t<=.05&&Math.abs(n)>=.15?"notable":"info"}function ue(t){return t==="reticle-position"?"other reticle positions":t==="test-site"?"other test sites":"the rest of the map"}function U(t){return t==="reticle-position"?"Other reticle positions":t==="test-site"?"Other test sites":"Rest of map"}function $e(t,n,i){const s=(Math.abs(n)*100).toFixed(1);return`${t} yield is ${s} percentage points ${n>0?"higher":"lower"} than ${ue(i)}`}function ke(t,n){return n==="quadrant"&&!t.startsWith("Quadrant")?`quadrant ${t}`:t}function Ke(t){return/^(Rings|Sectors|Quadrants)\b/.test(t)?"have":"has"}function Re(t,n,i,s){const e=ke(t,s),a=(Math.abs(i)*100).toFixed(1);return`${e} ${Ke(e)} ${n} occurrence ${a} percentage points ${i>0?"higher":"lower"} than ${ue(s)}`}function De(t,n,i,s){const e=ke(t,s),a=(Math.abs(i)*100).toFixed(1);return`${e} ${Ke(e)} ${n} pass rate ${a} percentage points ${i>0?"higher":"lower"} than ${ue(s)}`}function Me(t,n,i,s,e,a){const l=ke(t,e),r=ue(e),c=i>0?"higher":"lower";if(s!==void 0&&Number.isFinite(s)){const u=(Math.abs(s)*100).toFixed(1);return`${l} mean ${n} is ${u}% ${c} than ${r}`}const o=a?` ${a}`:"";return`${l} mean ${n} is ${Math.abs(i).toPrecision(3)}${o} ${c} than ${r}`}function Oe(t,n,i){const s=n?.find(e=>e.bin===t);return s?.name?`${i} ${t} (${s.name})`:`${i} ${t}`}function Nt(t,n){const i=n?.find(s=>s.testNumber===t);return{label:T(i,t),unit:i?.unit,...fe(i)}}const qe=new WeakMap,Te=new WeakMap,Ae=new WeakMap;function ee(t,n){const i=n.highlight.dieKeys;return i&&Ae.set(i,t),n}let G=null,te;const je=new WeakMap;export function candidatesOf(t){return je.get(t)}function He(t,n,i,s){if(!G)return;const e=Ie(t);if(!e)return;const a=t.id.slice(0,t.id.indexOf(":")),l=a==="specLimit"?"limitFail":a,{kind:r,bin:c,index:o}=t.variable;G.push({key:[l,r,c??"",o??"",e.family,e.key].join("|"),source:l,variable:t.variable,label:t.variable.label,comparison:t.comparison,region:e,z:n,delta:t.effect.absoluteDelta??0,effectSize:t.effect.effectSize??0,relativeDelta:t.effect.relativeDelta,rate:i,mean:s})}export function describeRegional(t,n,i){const s=t.comparison.left,e=t.region.family;switch(t.source){case"yield":return $e(s,n,e);case"hardBin":case"softBin":return Re(s,t.label,n,e);case"functional":return De(s,t.label.replace(/ pass rate$/,""),n,e);case"limitFail":return ze(s,t.label,n);case"test":return Me(s,t.label,n,i,e,t.variable.unit)}}function ze(t,n,i){return`${t} limit fail rate for ${n} is ${(Math.abs(i)*100).toFixed(1)} pp ${i>0?"higher":"lower"} than the rest of the wafer`}const H=new WeakMap;function de(t,n){return H.set(t,n),t}function Ie(t){const n=t.highlight.dieKeys;return n?Ae.get(n):void 0}const We=new WeakMap;function I(t){let n=We.get(t);return n||We.set(t,n=t.map(ye)),n}function xt(t){let n=qe.get(t);return n||qe.set(t,n=t.map(be)),n}function me(t,n){let i=Te.get(t);i||Te.set(t,i={members:new Set(t),byFamily:new WeakMap});const s=i.byFamily.get(n);if(s)return s;const{members:e}=i,a=new Map;for(const l of n)a.set(l.key,l.dies.filter(r=>e.has(r)));return i.byFamily.set(n,a),a}function Pt(t,n){adjustPValues(t);for(const e of t){const a=H.get(e);He(e,twoProportionZ(a.hits,a.n,a.restHits,a.restN),a)}const i=t.filter(e=>passesRateGate(e.stats.adjustedPValue??e.stats.pValue??1,e.effect.absoluteDelta??0,rateRelativeEffect(H.get(e)),n)),s=confirmRegionalFindings(i,Ye,(e,a)=>Ct(e,a,n),e=>isRateLoss(H.get(e)),t);return i.filter(e=>s.has(e)).map(e=>({...e,severity:severityForFinding(e.stats.adjustedPValue??e.stats.pValue??1,e.effect.absoluteDelta??0,rateRelativeEffect(H.get(e)))}))}export function passesRateGate(t,n,i,s){return t<=s.significanceLevel&&(Math.abs(n)>=s.minimumEffectSize||i>=s.minimumRelativeEffect)}export function claimForPattern(t,n,i,s,e){const a=[];for(const l of i){const r=l.comparison.family,c=r==="ring"?s(l):[];t.some(o=>dt(o,r,c,e))&&(a.push(l.id),n!=="info"&&(r==="ring"||r==="quadrant"||r==="sector")&&(l.severity="info"))}return a}export function confirmRegionalFindings(t,n,i,s,e=t){const a=new Map;for(const c of t)(a.get(n(c))??a.set(n(c),[]).get(n(c))).push(c);const l=new Map;if(s)for(const c of e)s(c)&&(l.get(n(c))??l.set(n(c),[]).get(n(c))).push(c);const r=new Set;for(const[c,o]of a){const u=l.get(c)??[],f=(d,p)=>s&&!s(d)?i(d,[...new Set([...p,...u])].filter(m=>m!==d)):i(d,p);if(o.length===1){r.add(o[0]);continue}const h=[];let b=[...o];for(;;){let d;for(const p of b){const m=f(p,h);if(m==="baseline-too-small"||!m.passes)continue;const S=s?.(p)??!1;(!d||S&&!d.loss||S===d.loss&&m.pValue<d.p)&&(d={t:p,p:m.pValue,loss:S})}if(!d)break;h.push(d.t),b=b.filter(p=>p!==d.t)}for(;;){let d;for(const p of h){const m=f(p,h.filter(S=>S!==p));m==="baseline-too-small"||m.passes||(!d||m.pValue>d.p)&&(d={t:p,p:m.pValue})}if(!d)break;h.splice(h.indexOf(d.t),1)}for(const d of h)r.add(d)}return r}function Ye(t){return[t.variable.kind,t.variable.bin??"",t.variable.index??"",t.comparison.family].join("\0")}function _e(t){const n=t.stats.pValue??1;return n>0?(t.stats.adjustedPValue??n)/n:1}export function isRateLoss(t){const n=t.hits/t.n-t.restHits/t.restN;return t.passRate?n<0:n>0}function Ct(t,n,i){const s=H.get(t);let{restHits:e,restN:a}=s;for(const o of n){const u=H.get(o);u&&(e-=u.hits,a-=u.n)}if(a<i.minimumSampleSize)return"baseline-too-small";const l=s.hits/s.n-e/a,r=Math.min(1,Ft(s.hits,s.n,e,a)*_e(t)),c=Math.sign(l)===Math.sign(t.effect.absoluteDelta??0)&&passesRateGate(r,l,rateRelativeEffect({...s,restHits:e,restN:a}),i);return{pValue:r,passes:c}}const Be=new WeakMap;export function welchOfSums(t,n,i,s){const e=(a,l,r)=>r>1?Math.max(0,a-l*l/r)/(r-1):0;return welchFromStats(t.n,t.sum/t.n,e(t.sq,t.sum,t.n),n,i/n,e(s,i,n))}function Vt(t,n,i){const s=Be.get(t);let{restN:e,restSum:a,restSq:l}=s;for(const h of n){const b=Be.get(h);b&&(e-=b.n,a-=b.sum,l-=b.sq)}if(e<i.minimumSampleSize)return"baseline-too-small";const{pValue:r,effectSize:c,delta:o}=welchOfSums(s,e,a,l),u=Math.min(1,r*_e(t)),f=Math.sign(o)===Math.sign(t.effect.absoluteDelta??0)&&u<=i.significanceLevel&&Math.abs(c)>=i.minimumEffectSize;return{pValue:u,passes:f}}function ne(t,n,i,s){const e=new Set(i),a=me(t,n),l=new Map,r=new Map;for(const[o,u]of a){let f=0,h=0;for(const b of u)b.hbin!==void 0&&(h++,e.has(b.hbin)&&f++);l.set(o,f),r.set(o,h)}const c=[];for(const o of n){const u=r.get(o.key)??0,f=l.get(o.key)??0;let h=0,b=0;for(const[w,M]of r)w!==o.key&&(h+=M,b+=l.get(w)??0);if(u<s.minimumSampleSize||h<s.minimumSampleSize)continue;const d=f/u,p=b/h,m=d-p,{pValue:S,method:D}=q(f,u,b,h);c.push(de(ee(o,{id:`yield:${o.key}`,level:"wafer",severity:"info",variable:{kind:"yield",label:"Yield"},comparison:{family:o.family,left:o.label,right:U(o.family)},effect:{direction:m===0?"different":m>0?"higher":"lower",absoluteDelta:m,relativeDelta:p===0?void 0:m/p,effectSize:m},stats:{method:D,pValue:S,sampleSizeLeft:u,sampleSizeRight:h},summary:$e(o.label,m,o.family),highlight:{kind:"region",regionFamily:o.family,regionKeys:[o.key],dieKeys:[...o.dieKeys]}}),{hits:f,n:u,restHits:b,restN:h,passRate:!0}))}return c}function O(t,n,i,s,e,a){const l=d=>i==="soft"?d.sbin:d.hbin,r=[...new Set(t.map(l).filter(d=>d!==void 0))].sort((d,p)=>d-p),c=me(t,n),o=new Map,u=new Map;for(const[d,p]of c){const m=new Map;for(const S of p){const D=l(S);D!==void 0&&m.set(D,(m.get(D)??0)+1)}o.set(d,m),u.set(d,p.length)}const f=[],h=e==="hardBin"?"HBin":"SBin",b=i==="hard"?new Set(a.passBins):a.softPassBins??xe(t,a.passBins).soft;for(const d of n){const p=u.get(d.key)??0,m=o.get(d.key);let S=0;const D=new Map;for(const[w,M]of o)if(w!==d.key){S+=u.get(w)??0;for(const[z,N]of M)D.set(z,(D.get(z)??0)+N)}if(!(p<a.minimumSampleSize||S<a.minimumSampleSize))for(const w of r){const M=m.get(w)??0,z=D.get(w)??0,N=M/p,y=z/S,$=N-y,{pValue:v,method:k}=q(M,p,z,S),R=Oe(w,s,h);f.push(de(ee(d,{id:`${e}:${w}:${d.key}`,level:"wafer",severity:"info",variable:{kind:e,bin:w,label:R},comparison:{family:d.family,left:d.label,right:U(d.family)},effect:{direction:$===0?"different":$>0?"higher":"lower",absoluteDelta:$,relativeDelta:y===0?void 0:$/y,effectSize:$},stats:{method:k,pValue:v,sampleSizeLeft:p,sampleSizeRight:S},summary:Re(d.label,R,$,d.family),highlight:{kind:"bin",bin:w,regionKeys:[d.key],dieKeys:[...d.dieKeys]}}),{hits:M,n:p,restHits:z,restN:S,passRate:b.has(w)}))}}return f}function ie(t,n,i,s){const e=(i??[]).filter(u=>!_(u));if(!e.length)return[];const a=e.map(u=>u.testNumber),l=me(t,n),r=new Map,c=new Map;for(const[u,f]of l){const h=new Uint32Array(e.length),b=new Uint32Array(e.length);for(const d of f)for(let p=0;p<e.length;p++){const m=re(d,a[p],e[p]);m!==void 0&&(b[p]++,m&&h[p]++)}r.set(u,h),c.set(u,b)}const o=[];for(const u of n){const f=r.get(u.key),h=c.get(u.key);for(let b=0;b<e.length;b++){let d=0,p=0;for(const[$,v]of c)$!==u.key&&(p+=v[b],d+=r.get($)[b]);const m=h[b],S=f[b];if(m<s.minimumSampleSize||p<s.minimumSampleSize)continue;const D=S/m,w=d/p,M=D-w,{pValue:z,method:N}=q(S,m,d,p),y=a[b];o.push(de(ee(u,{id:`functional:${y}:${u.key}`,level:"wafer",severity:"info",variable:{kind:"functionalTest",index:y,label:`${T(e[b],y)} pass rate`,...fe(e[b])},comparison:{family:u.family,left:u.label,right:U(u.family)},effect:{direction:M===0?"different":M>0?"higher":"lower",absoluteDelta:M,relativeDelta:w===0?void 0:M/w,effectSize:M},stats:{method:N,pValue:z,sampleSizeLeft:m,sampleSizeRight:p},summary:De(u.label,T(e[b],y),M,u.family),highlight:{kind:"region",regionFamily:u.family,regionKeys:[u.key],dieKeys:[...u.dieKeys]}}),{hits:S,n:m,restHits:d,restN:p,passRate:!0}))}}return o}export function welchFromStats(t,n,i,s,e,a){const l=Math.sqrt(i/t+a/s),r=n-e;if(!Number.isFinite(l)||l===0)return{pValue:1,effectSize:0,delta:r,z:0};const c=r/l,o=Math.sqrt(Math.max(0,(i+a)/2)),u=o===0?r:r/o;return{pValue:Ee(c),effectSize:u,delta:r,z:c}}function Et(t,n){const i=le(t),s=le(n);return welchFromStats(t.length,i,we(t,i),n.length,s,we(n,s))}const Qe=250;function Ue(t,n,i){const s=l=>l.filter(r=>_(i?.find(c=>c.testNumber===r)));if(n)return{testNumbers:s(n.slice().sort((l,r)=>l-r))};const e=Ce(t,"values");if(e.length>Qe){const l=`Test-value analysis was skipped: more than ${Qe} tests were found in the die data, so no test findings were computed. Pass testNumbers: [...] to analyse specific tests.`;return console.warn(`[wafermap] analyzeWaferMap: ${l}`),{testNumbers:[],warning:{code:"test-count-capped",message:l,severity:"warning"}}}return{testNumbers:s(e)}}function se(t,n,i,s){const e=Ue(t,s.testNumbers,i);if(e.warning)return{findings:[],warning:e.warning};const a=e.testNumbers,l=new Map;for(let m=0;m<n.length;m++)for(const S of I(n[m].dies))l.set(S,m);const r=n.length,c=[],o=[];for(const m of t){const S=l.get(ye(m));S!==void 0&&(c.push(m),o.push(S))}const u=[],f=new Float64Array(r),h=new Float64Array(r),b=new Float64Array(r);for(const m of a){f.fill(0),h.fill(0),b.fill(0);let S=0,D=0,w=0,M;for(let z=0;z<c.length;z++){const N=c[z],y=j(N,m);if(y===void 0)continue;M===void 0&&(M=y);const $=y-M,v=o[z];f[v]+=1,h[v]+=$,b[v]+=$*$,S+=1,D+=$,w+=$*$}if(M!==void 0)for(let z=0;z<r;z++){const N=f[z],y=S-N;if(N<s.minimumSampleSize||y<s.minimumSampleSize)continue;const $=h[z]/N,k=(D-h[z])/y,R=$+M,C=k+M,P=N>1?Math.max(0,b[z]-N*$*$)/(N-1):0,V=y>1?Math.max(0,w-b[z]-y*k*k)/(y-1):0,{pValue:E,effectSize:L,delta:g,z:B}=welchFromStats(N,R,P,y,C,V),x=n[z],{label:F,unit:K,...W}=Nt(m,i),ae=C!==0?g/Math.abs(C):void 0,Y=ee(x,{id:`test:${m}:${x.key}`,level:"wafer",severity:"info",variable:{kind:"test",index:m,label:F,unit:K,...W},comparison:{family:x.family,left:x.label,right:U(x.family)},effect:{direction:g===0?"different":g>0?"higher":"lower",absoluteDelta:g,relativeDelta:ae,effectSize:L},stats:{method:"welch-z-approx",pValue:E,sampleSizeLeft:N,sampleSizeRight:y},summary:Me(x.label,F,g,ae,x.family,K),highlight:{kind:"region",regionFamily:x.family,regionKeys:[x.key],dieKeys:[...x.dieKeys]}}),Z={n:N,sum:h[z],sq:b[z],restN:y,restSum:D-h[z],restSq:w-b[z],shift:M};Be.set(Y,Z),He(Y,B,void 0,Z),u.push(Y)}}adjustPValues(u);const d=u.filter(m=>{const S=m.stats.adjustedPValue??m.stats.pValue??1,D=Math.abs(m.effect.effectSize??0);return S<=s.significanceLevel&&D>=s.minimumEffectSize}),p=confirmRegionalFindings(d,Ye,(m,S)=>Vt(m,S,s));return{activeTestNumbers:a,findings:d.filter(m=>p.has(m)).map(m=>({...m,severity:severityForScore(m.stats.adjustedPValue??m.stats.pValue??1,m.effect.effectSize??0)}))}}function Lt(t,n,i,s){if(!i?.length)return[];const e=i.filter(l=>_(l)&&(l.limitLow!==void 0||l.limitHigh!==void 0));if(!e.length)return[];const a=[];for(const l of e){const r=l.testNumber;for(const c of n){const o=me(t,c),u=[],f=new Map;let h=0,b=0;for(const[d,p]of o){let m=0,S=0;for(const D of p){const w=j(D,r);w!==void 0&&(m++,ve(ce(w,l))&&S++)}f.set(d,{valid:m,fail:S}),h+=m,b+=S}for(const d of c){const p=f.get(d.key),m=p.valid,S=h-p.valid;if(m<s.minimumSampleSize||S<s.minimumSampleSize)continue;const D=p.fail,w=b-p.fail,M=D/m,z=w/S,N=M-z,{pValue:y,method:$}=q(D,m,w,S);u.push(de(ee(d,{id:`specLimit:${r}:${d.key}`,level:"wafer",severity:"info",variable:{kind:"test",index:r,label:T(l,r),unit:l.unit,...fe(l)},comparison:{family:d.family,left:d.label,right:U(d.family)},effect:{direction:N===0?"different":N>0?"higher":"lower",absoluteDelta:N,relativeDelta:z===0?void 0:N/z,effectSize:N},stats:{method:$,pValue:y,sampleSizeLeft:m,sampleSizeRight:S},summary:ze(d.label,T(l,r),N),highlight:{kind:"region",regionFamily:d.family,regionKeys:[d.key],dieKeys:[...d.dieKeys]}}),{hits:D,n:m,restHits:w,restN:S,passRate:!1}))}a.push(...u)}}return a}function Fe(t,n){return t==="softBin"?n.softEligibleDies:t==="test"?n.testDies:n.eligibleDies}function Kt(t){return t.id.startsWith("specLimit:")}function oe(t){return t.highlight.regionKeys??[]}function Ot(t){const n=t.variable.bin??t.variable.index??"";return`${t.comparison.family}\0${Ge(t)}\0${t.variable.kind}\0${n}\0${t.effect.direction}`}function qt(t,n){const i=Q(t);return i.family==="ring"?i.ring??0:i.family==="sector"?Ve(n).indexOf(i.sector??""):0}export function inQuadrantOrder(t){const n=new Set(t),i=Se.findIndex((e,a)=>n.has(e)&&!n.has(Se[(a+3)%4])),s=i<0?0:i;return Array.from({length:4},(e,a)=>Se[(s+a)%4]).filter(e=>n.has(e))}export function findContiguousRuns(t,n,i,s){if(n==="quadrant"){const c=new Map;for(const h of t){const b=Q(s(h)).quadrant;b&&c.set(b,h)}const o=[...c.keys()],u=new Set,f=[];for(const h of o){if(u.has(h))continue;const b=[],d=[h];for(u.add(h);d.length;){const p=d.pop();b.push(p);for(const m of o)!u.has(m)&&ft(p,m)&&(u.add(m),d.push(m))}f.push(inQuadrantOrder(b).map(p=>c.get(p)))}return f}const e=c=>qt(s(c),i),a=[...t].sort((c,o)=>e(c)-e(o)),l=[];let r=[];for(const c of a){if(r.length===0){r.push(c);continue}const o=e(r[r.length-1]);e(c)-o===1?r.push(c):(l.push(r),r=[c])}if(r.length&&l.push(r),n==="sector"&&l.length>1){const o=Ve(i).length,u=e(l[0][0]),f=e(l[l.length-1][l[l.length-1].length-1]);if(u===0&&f===o-1){const h=l.pop();l[0]=[...h,...l[0]]}}return l}export function mergedRegionLabel(t,n,i){if(t==="ring"){const e=n.map(c=>Q(c).ring).filter(c=>c!==void 0).sort((c,o)=>c-o),a=e[0],l=e[e.length-1];let r="";return a===l&&a===1&&i>1?r=" (core)":a===l&&a===i&&i>1&&(r=" (edge)"),a===l?`Ring ${a}${r}`:`Rings ${a}\u2013${l}`}if(t==="sector"){const e=n.map(a=>Q(a).sector??"");return e.length===1?`Sector ${e[0]}`:`Sectors ${e[0]}\u2013${e[e.length-1]}`}const s=n.map(e=>Q(e).quadrant??"");return s.length===1?s[0]:s.length===2?`Quadrants ${s[0]} & ${s[1]}`:`Quadrants ${s.slice(0,-1).join(", ")} & ${s[s.length-1]}`}function Ne(t){return[...new Set(t)]}export function weakestMultiplier(t){return wt(t.map(n=>{const i=n.stats.pValue??1;return i>0?(n.stats.adjustedPValue??i)/i:1}))}function X(t,n){return Math.min(1,t*n)}function Tt(t,n){const i=t[0],s=i.comparison.family,e=i.variable.kind,a=Ne(t.flatMap(oe));let l,r;const c=t.map(Ie);if(c.every(y=>y!==void 0)){const y=new Set;l=[];for(const v of c){const k=I(v.dies);for(let R=0;R<k.length;R++)y.has(k[R])||(y.add(k[R]),l.push(v.dieKeys[R]))}const $=I(Fe(i.variable.kind,n));r=v=>y.has($[v])}else{l=Ne(t.flatMap(v=>v.highlight.dieKeys??[]));const y=new Set(l),$=xt(Fe(i.variable.kind,n));r=v=>y.has($[v])}const o=mergedRegionLabel(s,t.map(y=>oe(y)[0]??""),n.ringCount),u=Fe(e,n),f=n.regionDies[s],h=I(u),b=[],d=[];for(let y=0;y<u.length;y++)f.has(h[y])&&(r(y)?b:d).push(u[y]);const p=weakestMultiplier(t);let m,S,D,w,M;if(Kt(i)){const y=i.variable.index,$=n.testDefs?.find(B=>B.testNumber===y),v=B=>{let x=0,F=0;for(const K of B){const W=j(K,y);W!==void 0&&(x++,$&&ve(ce(W,$))&&F++)}return{valid:x,fail:F}},k=v(b),R=v(d),C=k.valid>0?k.fail/k.valid:0,P=R.valid>0?R.fail/R.valid:0,V=C-P,{pValue:E,method:L}=q(k.fail,k.valid,R.fail,R.valid);m={direction:V===0?"different":V>0?"higher":"lower",absoluteDelta:V,relativeDelta:P===0?void 0:V/P,effectSize:V},S={method:L,pValue:E,sampleSizeLeft:k.valid,sampleSizeRight:R.valid};const g=X(E,p);D=severityForFinding(g,V,rateRelativeEffect({hits:k.fail,n:k.valid,restHits:R.fail,restN:R.valid,passRate:!1})),w=ze(o,T($,y),V),M=`specLimit:${y}`}else if(e==="test"){const y=i.variable.index,$=g=>j(g,y),v=b.map($).filter(g=>g!==void 0),k=d.map($).filter(g=>g!==void 0),{pValue:R,effectSize:C,delta:P}=Et(v,k),V=le(k),E=V!==0?P/Math.abs(V):void 0;m={direction:P===0?"different":P>0?"higher":"lower",absoluteDelta:P,relativeDelta:E,effectSize:C},S={method:"welch-z-approx",pValue:R,sampleSizeLeft:v.length,sampleSizeRight:k.length};const L=X(R,p);D=severityForScore(L,C),w=Me(o,i.variable.label,P,E,s,i.variable.unit),M=`test:${y}`}else if(e==="yield"){const y=new Set(n.passBins),$=b.filter(F=>F.hbin!==void 0),v=d.filter(F=>F.hbin!==void 0),k=$.length,R=v.length,C=$.filter(F=>y.has(F.hbin)).length,P=v.filter(F=>y.has(F.hbin)).length,V=k>0?C/k:0,E=R>0?P/R:0,L=V-E,{pValue:g,method:B}=q(C,k,P,R);m={direction:L===0?"different":L>0?"higher":"lower",absoluteDelta:L,relativeDelta:E===0?void 0:L/E,effectSize:L},S={method:B,pValue:g,sampleSizeLeft:k,sampleSizeRight:R};const x=X(g,p);D=severityForFinding(x,L,rateRelativeEffect({hits:C,n:k,restHits:P,restN:R,passRate:!0})),w=$e(o,L,s),M="yield"}else if(e==="functionalTest"){const y=i.variable.index,$=n.testDefs?.find(x=>x.testNumber===y);let v=0,k=0,R=0,C=0;for(const x of b){const F=re(x,y,$);F!==void 0&&(k++,F&&v++)}for(const x of d){const F=re(x,y,$);F!==void 0&&(C++,F&&R++)}const P=k>0?v/k:0,V=C>0?R/C:0,E=P-V,{pValue:L,method:g}=q(v,k,R,C);m={direction:E===0?"different":E>0?"higher":"lower",absoluteDelta:E,relativeDelta:V===0?void 0:E/V,effectSize:E},S={method:g,pValue:L,sampleSizeLeft:k,sampleSizeRight:C};const B=X(L,p);D=severityForFinding(B,E,rateRelativeEffect({hits:v,n:k,restHits:R,restN:C,passRate:!0})),w=De(o,T($,y),E,s),M=`functional:${y}`}else{const y=i.variable.bin,$=B=>e==="softBin"?B.sbin:B.hbin,v=b.filter(B=>$(B)===y).length,k=d.filter(B=>$(B)===y).length,R=v/b.length,C=k/d.length,P=R-C,{pValue:V,method:E}=q(v,b.length,k,d.length);m={direction:P===0?"different":P>0?"higher":"lower",absoluteDelta:P,relativeDelta:C===0?void 0:P/C,effectSize:P},S={method:E,pValue:V,sampleSizeLeft:b.length,sampleSizeRight:d.length};const L=X(V,p);D=severityForFinding(L,P,rateRelativeEffect({hits:v,n:b.length,restHits:k,restN:d.length,passRate:!1}));const g=e==="softBin"?n.sbinDefs:n.hbinDefs;w=Re(o,Oe(y,g,e==="softBin"?"SBin":"HBin"),P,s),M=`${e}:${y}`}S={...S,adjustedPValue:X(S.pValue??1,p)};const z=Ne(a.map(y=>y.replace(`${s}:`,""))).join("-"),N=e==="hardBin"||e==="softBin"?{kind:"bin",bin:i.variable.bin,regionKeys:a,dieKeys:l}:{kind:"region",regionFamily:s,regionKeys:a,dieKeys:l};return{...i,id:`${M}:${s}:${z}`,severity:D,comparison:{family:s,left:o,right:U(s)},effect:m,stats:S,summary:w,highlight:N,relatedIds:t.map(y=>y.id)}}function At(t,n){const i=new Set(["ring","quadrant","sector"]),s=[],e=new Map;for(const l of t){if(!i.has(l.comparison.family)){s.push(l);continue}const r=Ot(l),c=e.get(r)??[];c.push(l),e.set(r,c)}const a=[];for(const l of e.values()){if(l.length===1){a.push(l[0]);continue}const r=l[0].comparison.family;for(const c of findContiguousRuns(l,r,n.sectorCount,o=>oe(o)[0]??""))a.push(c.length===1?c[0]:Tt(c,n))}return[...s,...a]}function jt(t){const n=new Map,i=new Map;for(const e of t){const a=ye(e);e.hbin!==void 0&&e.hbin!==null&&(n.get(e.hbin)??n.set(e.hbin,new Set).get(e.hbin)).add(a),e.sbin!==void 0&&e.sbin!==null&&(i.get(e.sbin)??i.set(e.sbin,new Set).get(e.sbin)).add(a)}const s=new Set;for(const[e,a]of n)for(const[l,r]of i){if(a.size!==r.size)continue;let c=!0;for(const o of a)if(!r.has(o)){c=!1;break}c&&s.add(`${e}:${l}`)}return s}function Ht(t,n){const i=new Set(n);let s;for(const e of t){const a=pe(e,i);if(a!==void 0&&a){if(e.sbin==null||s!==void 0&&e.sbin!==s)return;s=e.sbin}}if(s!==void 0){for(const e of t)if(e.sbin===s&&pe(e,i)!==!0)return;return s}}function It(t){return`${t.comparison.family}\0${t.comparison.left}`}export function redundancyFacts(t,n,i){return{coincident:jt(t),yieldSoftBin:Ht(t,n),passBins:n,sectorCount:i}}const Wt=3/5;function Ge(t){return/^(?:lot-region:)?([^:|]+)/.exec(t.id)?.[1]??t.id}function Yt(t){const n=oe(t);if(n.length)return n;const i=/(ring|sector|quadrant):([^:|]+)$/.exec(t.id);return i?i[2].split("-").map(s=>`${i[1]}:${s}`):[]}function Xe(t,n){const i=new Set;for(const s of Yt(t)){const e=lt(s,n);if(!e)return;for(const a of e)i.add(a)}return i.size?i:void 0}export function collapseRedundantFindings(t,n){const{coincident:i,yieldSoftBin:s,passBins:e}=n,a=(o,u)=>{o.absorbedIds=[...o.absorbedIds??[],u.id]},l=new Map;for(const o of t){const u=It(o);(l.get(u)??l.set(u,[]).get(u)).push(o)}const r=new Set;for(const o of l.values()){for(const f of o)if(!(f.variable.kind!=="hardBin"||f.variable.bin===void 0))for(const h of o){if(h.variable.kind!=="softBin"||h.variable.bin===void 0||r.has(h.id)||!i.has(`${f.variable.bin}:${h.variable.bin}`)||h.effect.direction!==f.effect.direction)continue;a(f,h),r.add(h.id);const b=f.variable.label.replace(/^HBin\s+/,""),d=h.variable.label.replace(/^SBin\s+/,""),p=b===d?`HBin and SBin ${b} (same dies)`:`${f.variable.label} and ${h.variable.label} (same dies)`;f.summary=f.summary.replace(f.variable.label,p),f.variable.label=p;break}const u=o.find(f=>f.variable.kind==="yield");if(u){for(const f of o)if(!(f===u||r.has(f.id)||!(f.variable.kind==="hardBin"&&e.length===1&&f.variable.bin===e[0]||f.variable.kind==="softBin"&&f.variable.bin===s))){a(u,f),r.add(f.id);for(const b of f.absorbedIds??[])u.absorbedIds=[...u.absorbedIds??[],b]}}}const c=new Map;for(const o of t){if(r.has(o.id)||o.comparison.family!=="sector"&&o.comparison.family!=="quadrant")continue;const u=[Ge(o),o.variable.kind,o.variable.bin??"",o.variable.index??"",o.effect.direction].join("\0");(c.get(u)??c.set(u,[]).get(u)).push(o)}for(const o of c.values()){const u=[];for(const f of o.filter(h=>h.comparison.family==="sector")){const h=Xe(f,n.sectorCount);if(h)for(const b of o.filter(d=>d.comparison.family==="quadrant")){const d=Xe(b,n.sectorCount);if(!d)continue;let p=0;for(const S of h)d.has(S)&&p++;const m=h.size+d.size-p;p/m>=Wt-1e-9&&u.push({sector:f,quadrant:b,overlap:p/m})}}u.sort((f,h)=>h.overlap-f.overlap);for(const{sector:f,quadrant:h}of u){if(r.has(f.id)||r.has(h.id))continue;const b=(h.stats.pValue??1)<(f.stats.pValue??1),[d,p]=b?[h,f]:[f,h];a(d,p),r.add(p.id),d.absorbedIds=[...d.absorbedIds??[],...p.absorbedIds??[]]}}}export function analyzeWaferMap(t,n={}){const i=G,s=te,e=[];G=e,te=void 0;try{const a=_t(t,n);return je.set(a,{candidates:e,facts:te}),a}finally{G=i,te=s}}function _t(t,n){const{resolved:i,warnings:s}=resolveOptions(n),e=Ze(t),a={...i,passBins:[...pt(e,"analyzeWaferMap")],ringCount:gt(e,"analyzeWaferMap")},l=e.isLotStack,r=e.aggrMethod,c=!l||r==="mode"||r==="countBin"||r==="percent",o=e.dies.filter(g=>kt(g)),u=o.filter(Pe),f=$t(a,o.length);f.softPassBins=xe(o,f.passBins).soft;const h=e.dies.filter(g=>ge(g)),b=h.filter(Pe),d=ot(b,e.wafer,f.ringCount),p=it(b,e.wafer,f.ringCount),m=st(b,e.reticleConfig),S=rt(h,!1),D=at(b,e.wafer,f.sectorCount),w=[],M=[];c&&M.push(...ne(o,d,f.passBins,f),...ne(o,p,f.passBins,f),...ne(o,m,f.passBins,f),...ne(o,S,f.passBins,f),...ne(o,D,f.passBins,f)),c&&M.push(...O(o,d,"hard",e.hbinDefs,"hardBin",f),...O(o,p,"hard",e.hbinDefs,"hardBin",f),...O(o,m,"hard",e.hbinDefs,"hardBin",f),...O(o,S,"hard",e.hbinDefs,"hardBin",f),...O(o,D,"hard",e.hbinDefs,"hardBin",f));{const g=o.filter(B=>B.sbin!==void 0);M.push(...O(g,d,"soft",e.sbinDefs,"softBin",f),...O(g,p,"soft",e.sbinDefs,"softBin",f),...O(g,m,"soft",e.sbinDefs,"softBin",f),...O(g,S,"soft",e.sbinDefs,"softBin",f),...O(g,D,"soft",e.sbinDefs,"softBin",f))}const z=[...s];let N;if(f.enableTestValueAnalysis){const g=se(o,d,e.testDefs,f),B=se(o,p,e.testDefs,f),x=se(o,m,e.testDefs,f),F=se(o,S,e.testDefs,f),K=se(o,D,e.testDefs,f);w.push(...g.findings,...B.findings,...x.findings,...F.findings,...K.findings),g.warning&&z.push(g.warning),N=g.activeTestNumbers,M.push(...Lt(o,[d,p,m,S,D],e.testDefs,f)),M.push(...ie(o,d,e.testDefs,f),...ie(o,p,e.testDefs,f),...ie(o,m,e.testDefs,f),...ie(o,S,e.testDefs,f),...ie(o,D,e.testDefs,f))}w.push(...Pt(M,f));{const g=Rt(l,c,e.testDefs);(!l||c||g!==void 0)&&w.push(...ct(u,e.wafer,{...f,isFailingDie:g}))}const y=At(w,{eligibleDies:o,softEligibleDies:o.filter(g=>g.sbin!==void 0),testDies:o,passBins:f.passBins,ringCount:f.ringCount,sectorCount:f.sectorCount,regionDies:{ring:new Set(d.flatMap(g=>I(g.dies))),quadrant:new Set(p.flatMap(g=>I(g.dies))),sector:new Set(D.flatMap(g=>I(g.dies)))},hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs});w.length=0,w.push(...y);let $;if(c){const g=ut(u,e.wafer,{passBins:f.passBins,ringCount:f.ringCount});if($=g??void 0,g!==null&&g.pattern!=="random"&&g.pattern!=="none"){const B=ht[g.pattern],x=g.confidence==="high"?"unusual":g.confidence==="medium"?"notable":"info",F=g.features,K=A=>`${(A*100).toFixed(0)}%`,W=g.pattern==="edge-ring"||g.pattern==="edge-local"?`${K(F.edgeRdd)} of edge dies failing`:g.pattern==="center"?`centroid at ${K(F.centroidDistNorm)} of wafer radius from centre`:g.pattern==="donut"?`${K(Math.max(F.radialFailRates[1],F.radialFailRates[2]))} of dies failing at mid-radius, ${K(F.radialFailRates[0])} at the centre`:g.pattern==="scratch"?`a line ${Math.round(F.lineLength)} dies long and about ${Math.max(1,Math.round(F.lineWidth*2))} wide`:`${K(F.globalRdd)} of dies failing`,ae=new Set(f.passBins),Y=o.filter(A=>mt(A,ae)===!0),Z=claimForPattern([g.pattern],x,w,A=>oe(A).map(he=>Q(he).ring).filter(he=>he!==void 0),f.ringCount);w.push({id:`spatial-pattern:${g.pattern}`,level:"wafer",severity:x,variable:{kind:"spatialPattern",label:B},comparison:{family:"spatial-pattern",left:B,right:"Wafer"},effect:{direction:"different",effectSize:F.globalRdd},stats:{method:"geometry",sampleSizeLeft:Y.length,sampleSizeRight:o.length},summary:`Spatial pattern: ${B.toLowerCase()} (${g.confidence} confidence) \u2014 ${W}${g.note?` [${g.note}]`:""}`,highlight:{kind:"dies",dieKeys:Y.map(A=>be(A))},relatedIds:Z.length>0?Z:void 0})}}w.sort((g,B)=>{const x=g.stats.adjustedPValue??g.stats.pValue??1,F=B.stats.adjustedPValue??B.stats.pValue??1;return x!==F?x-F:Math.abs(B.effect.absoluteDelta??0)-Math.abs(g.effect.absoluteDelta??0)});const v=Dt(e.dies,o.length,e.yield.yieldPercent);l&&(v.isLotStack=!0,r&&(v.aggregationMethod=r));const k=new Set(a.passBins),R={},C=(g,B)=>{const x=R[g]??={dieKeys:[],lostDies:0};x.dieKeys.push(be(B)),pe(B,k)!==!0&&x.lostDies++},P=Mt(e.dies,e.testDefs,C);P&&(v.testSpecYield=P);const V=computeFunctionalYield(e.dies,e.testDefs,C);if(V&&(v.functionalYield=V),Object.keys(R).length&&(v.testFailures=R),$&&(v.spatialPattern=$),N===void 0&&f.computePerTestStats){const g=Ue(o,f.testNumbers,e.testDefs);g.warning&&z.push(g.warning),N=g.testNumbers}if(N?.length){const g=zt(e.dies,N,e.testDefs,f.minimumSampleSize);g&&(v.perTestStats=g);const B=Je([{dies:e.dies}],e.testDefs,N);B&&(v.capability=B)}Object.assign(v,et(e.dies,e.testDefs));const E=tt([{dies:e.dies,wafer:e.wafer,passBins:f.passBins,ringCount:f.ringCount}]);E&&(v.regionYield=E),z.length>0&&(v.warnings=z);const L=redundancyFacts(o,f.passBins,f.sectorCount);return collapseRedundantFindings(w,L),G&&(te=L),{level:"wafer",hasNotableFindings:w.some(g=>g.severity==="notable"||g.severity==="unusual"),findings:w,wafer:e.wafer.metadata??void 0,stats:v}}
|
|
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,61 +1,9 @@
|
|
|
1
|
-
import type { Die } from '../core/dies.js';
|
|
2
|
-
import type { ChartDatum } from './yield.js';
|
|
3
|
-
export type BinType = 'hbin' | 'sbin';
|
|
4
|
-
export interface BinItem {
|
|
5
|
-
dies?: Die[];
|
|
6
|
-
/**
|
|
7
|
-
* Precomputed bin counts for this item (e.g. `StatsSummary.stats.hardBinCounts`/
|
|
8
|
-
* `.softBinCounts`, already scoped to the same yield-eligible population).
|
|
9
|
-
* When supplied, used directly instead of re-walking `dies` — avoids
|
|
10
|
-
* re-deriving the same counts `analyzeWaferMap` already computed.
|
|
11
|
-
*/
|
|
12
|
-
hardBinCounts?: Record<number, number>;
|
|
13
|
-
softBinCounts?: Record<number, number>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* One bar per bin, across all `items`, sorted by count descending. Excludes
|
|
17
|
-
* partial/edge-excluded dies via `isYieldEligibleDie` — the same population
|
|
18
|
-
* the adjacent Yield panel uses — so the two panels' totals reconcile for
|
|
19
|
-
* the same wafer/group. Items carrying precomputed `hardBinCounts`/
|
|
20
|
-
* `softBinCounts` (see `BinItem`) contribute those directly, skipping the
|
|
21
|
-
* per-die walk for that item.
|
|
22
|
-
*/
|
|
23
|
-
export declare function buildBinParetoData(items: BinItem[], binType: BinType): ChartDatum[];
|
|
24
|
-
/** One bin's clustered bars: a count per group (aligned to `BinClusterData.groups`). */
|
|
25
|
-
export interface BinCluster {
|
|
26
|
-
binCode: number;
|
|
27
|
-
label: string;
|
|
28
|
-
/** Total dies of this bin across all groups — drives pareto ordering. */
|
|
29
|
-
total: number;
|
|
30
|
-
/** Per-group die counts for this bin, aligned to `BinClusterData.groups`. */
|
|
31
|
-
counts: number[];
|
|
32
|
-
}
|
|
33
|
-
/** Clustered bin pareto: the group list (legend order) plus one cluster per bin. */
|
|
34
|
-
export interface BinClusterData {
|
|
35
|
-
groups: string[];
|
|
36
|
-
bins: BinCluster[];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Clustered bin pareto: every group's bin counts side by side, so groups
|
|
40
|
-
* compare directly bin-by-bin. Unlike the plain pareto, this is never a
|
|
41
|
-
* restrict-to-one-group view — all groups are always shown at once,
|
|
42
|
-
* matching tsmap's actual behavior (a wholly different panel swapped in for
|
|
43
|
-
* bin pareto when grouping is active, not a variant of it).
|
|
44
|
-
*/
|
|
45
|
-
export declare function buildBinClusterData(groups: {
|
|
46
|
-
key: string;
|
|
47
|
-
items: BinItem[];
|
|
48
|
-
}[], binType: BinType): BinClusterData;
|
|
49
1
|
/**
|
|
50
2
|
* Display order for a bin breakdown: pass bins first (in bin order), then failing
|
|
51
3
|
* bins by descending count, ties broken by bin number.
|
|
52
4
|
*
|
|
53
|
-
* The single source of this ordering
|
|
54
|
-
*
|
|
55
|
-
* report's two bin tables (per-wafer and lot) — none of which agreed with this
|
|
56
|
-
* module's own `buildBinParetoData`, which has always been count-descending. The
|
|
57
|
-
* effect was that the same wafer's bins came out in one order in the Insights bin
|
|
58
|
-
* chart and a different one in the panel and the report.
|
|
5
|
+
* The single source of this ordering, for the Summary panel's bin section, the summary report's bin tables (per wafer
|
|
6
|
+
* and lot), the legends and the gallery strip, so a wafer's bins are listed in one order everywhere.
|
|
59
7
|
*
|
|
60
8
|
* Pass bins are pinned to the top rather than competing on count: they are the
|
|
61
9
|
* reference the failures are read against, not themselves a failure mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function sortBinsForDisplay(o,i){const n=new Set(i);return[...o].sort((s,r)=>{const t=n.has(s[0]),e=n.has(r[0]);return t!==e?t?-1:1:t&&e?s[0]-r[0]:r[1]-s[1]||s[0]-r[0]})}
|