MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / allClose

Function allClose

benchmarks/audit/audit.ts:193–199  ·  view source on GitHub ↗
(got: any[], exp: string[], rel = 1e-6)

Source from the content-addressed store, hash-verified

191
192// --- grading (identical for both tools) ------------------------------------
193function allClose(got: any[], exp: string[], rel = 1e-6) {
194 if (!Array.isArray(got) || got.length !== exp.length) return false;
195 return exp.every((e, i) => {
196 const ev = parseFloat(e), gv = Number(got[i]);
197 return got[i] != null && isFinite(gv) && Math.abs(gv - ev) <= rel * (1 + Math.abs(ev)) + 1e-9;
198 });
199}
200function formOk(form: string, text: string) {
201 if (form === 'polynomial') return !/sqrt|√|abs|\|/i.test(text) && !/\^\s*\(?-?\d*\s*\/\s*\d/.test(text) && !/\^-?0?\.\d/.test(text);
202 // "expanded" = no remaining grouped factor. CE's plain-text form

Callers 1

classifyFunction · 0.70

Calls 2

isFiniteFunction · 0.85
absMethod · 0.65

Tested by

no test coverage detected