xy-scale 1.4.45 → 1.4.47

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.
@@ -1 +1 @@
1
- var XY_Scale;(()=>{"use strict";var e={d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{arrayShuffle:()=>t,arrayShuffleXY:()=>n,arrayToTimesteps:()=>b,parseProductionX:()=>g,parseTrainingXY:()=>w});const t=e=>{const r=[...e];for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r},n=(e,r)=>{if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Both X and Y must be arrays");if(e.length!==r.length)throw new Error("X and Y must have the same length");const t=[...e],n=[...r];for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]],[n[e],n[r]]=[n[r],n[e]]}return{X:t,Y:n}},o=e=>"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):!!Array.isArray(e)&&e.every(o)),a=({random:e,seed:r}={})=>"function"==typeof e?e:Number.isInteger(r)?(e=>{let r=e>>>0;return()=>{r+=1831565813;let e=Math.imul(r^r>>>15,1|r);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}})(r):Math.random,l=(e,r=Math.random)=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(r()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e},i=(e,r,t=Math.random)=>{if(r>e.length)throw new Error("Cannot sample more items than available without replacement.");const n=[...e];return l(n,t),n.slice(0,r)},s=(e,r,t=Math.random)=>{if(0===e.length)throw new Error("Cannot sample from an empty array.");const n=[];for(let o=0;o<r;o++){const r=Math.floor(t()*e.length);n.push(e[r])}return n},u=(e,r)=>r?structuredClone(e):e,c=(e,r,{cloneX:t=!1}={})=>{((e,r)=>{if(!Array.isArray(e)||!Array.isArray(r))throw new Error("X and Y must be arrays.");if(e.length!==r.length)throw new Error("X and Y must have the same length.");if(0===e.length)throw new Error("X and Y cannot be empty.")})(e,r);const n=new Map;return r.forEach(((r,a)=>{const l=(e=>{if(!o(e))throw new Error("Invalid Y label. Allowed types: finite numbers, strings, booleans, or nested arrays of those.");return JSON.stringify(e)})(r);n.has(l)||n.set(l,[]),n.get(l).push({x:u(e[a],t),y:r})})),n},f=e=>null!=e&&Number.isFinite(e),h=e=>null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0,d=(e,{min:r=-1/0,max:t=1/0},n)=>{if(!Array.isArray(e))throw new Error(`Invalid property. "${n}" expected an array.`);if(e.length<r)throw new Error(`Invalid property value. Array "${n}" expected at least ${r} items.`);if(e.length>t)throw new Error(`Invalid property value. Array "${n}" expected at max ${t} items.`);return!0},y=e=>{if(!h(e))throw new Error("The first item in arrObj is expeted to be a key par object.");const r={},t={};for(const[n,o]of Object.entries(e))"number"==typeof o?r[n]=o:t[n]=o;if(Object.keys(r).length>0&&m(r,"validateFirstRow"))throw new Error("Invalid numeric value at index 0.");if(Object.keys(t).length>0&&p(t,"validateFirstRow"))throw new Error("Invalid non-numeric value at index 0.");return!0},m=(e,r)=>{if(null==r)throw new Error('[hasInvalidNumbers] Missing required param "callerName".');if(!h(e))throw new Error(`[${r}:hasInvalidNumbers] Received an invalid "list" param — expected a non-empty key-pair object, got: ${JSON.stringify(e)}.`);for(const[t,n]of Object.entries(e))if(!f(n))return console.error(`[${r}:hasInvalidNumbers] property "${t}" only accept numbers. Invalid value is "${n}" and invalid type is "${typeof n}".`),!0;return!1},p=(e,r)=>{if(null==r)throw new Error('[hasNullOrUndefined] Missing required param "callerName".');if(!h(e))throw new Error(`[${r}:hasNullOrUndefined] Received an invalid "list" param — expected a non-empty key-pair object, got: ${JSON.stringify(e)}.`);for(const[t,n]of Object.entries(e))if(h(n)){for(const[e,o]of Object.entries(n))if(null==o)return console.error(`[${r}:hasNullOrUndefined] Null or undefined value detected for key "${t}.${e}".\n${String(o)}`),!0}else if(null==n)return console.error(`[${r}:hasNullOrUndefined] Null or undefined value detected for key "${t}".\n${String(n)}`),!0;return!1},w=({arrObj:e=[],trainingSplit:r=.8,yCallbackFunc:n=e=>e,xCallbackFunc:o=e=>e,validateRows:f=()=>!0,shuffle:h=!1,balancing:p="",state:w={}})=>{d(e,{min:2},"parseTrainingXY"),y(e[0]);let g=[],b=[],v=null,x=null;const X={};for(let r=0;r<e.length;r++)try{if(!f({objRow:e,index:r,state:w}))continue;const t=o({objRow:e,index:r,state:w}),a=n({objRow:e,index:r,state:w});if(null==t||null==a)continue;if(m(t,"parseTrainingXY"))throw new Error('Invalid numeric value returned from "xCallbackFunc".');if(null===v&&(v=Object.keys(t)),null===x){x=Object.keys(a);for(let e=0;e<x.length;e++)X[x[e]]={}}const l=v.length,i=x.length,s=new Array(l),u=new Array(i);for(let e=0;e<l;e++){const r=v[e];s[e]=t[r]}for(let e=0;e<i;e++){const r=x[e],t=a[r];u[e]=t;const n=Array.isArray(t)?JSON.stringify(t):String(t);X[r][n]=(X[r][n]??0)+1}g.push(s),b.push(u)}catch(e){throw new Error(`[BUG] - Skipped row index=${r}: ${e.message}`)}if(h){const e=new Array(g.length);for(let r=0;r<g.length;r++)e[r]={x:g[r],y:b[r]};const r=t(e);g=new Array(r.length),b=new Array(r.length);for(let e=0;e<r.length;e++)g[e]=r[e].x,b[e]=r[e].y}const E={keyNames:v??[]},A={keyNames:x??[],labelCounts:X},j=Math.floor(g.length*r);let O=g.slice(0,j),$=b.slice(0,j),k=g.slice(j),N=b.slice(j);if(p){let e;if("oversample"===p)e=((e,r,t={})=>{const{random:n,seed:o,shuffleResult:i=!0,cloneX:f=!1}=t,h=a({random:n,seed:o}),d=c(e,r,{cloneX:f}),y=[...d.values()].map((e=>e.length)),m=Math.max(...y),p=[];for(const e of d.values()){const r=[...e],t=m-r.length,n=t>0?s(e,t,h).map((e=>({x:u(e.x,f),y:e.y}))):[];p.push(...r,...n)}return i&&l(p,h),{X:p.map((({x:e})=>e)),Y:p.map((({y:e})=>e))}})(O,$),O=e.X,$=e.Y;else{if("undersample"!==p)throw Error('balancing argument only accepts "", "oversample" and "undersample". Defaults to "".');e=((e,r,t={})=>{const{random:n,seed:o,shuffleResult:s=!0,cloneX:f=!1}=t,h=a({random:n,seed:o}),d=c(e,r,{cloneX:f}),y=[...d.values()].map((e=>e.length)),m=Math.min(...y),p=[];for(const e of d.values()){const r=i(e,m,h).map((e=>({x:u(e.x,f),y:e.y})));p.push(...r)}return s&&l(p,h),{X:p.map((({x:e})=>e)),Y:p.map((({y:e})=>e))}})(O,$),O=e.X,$=e.Y}}return{trainX:O,trainY:$,testX:k,testY:N,configX:E,configY:A}},g=({arrObj:e=[],xCallbackFunc:r=e=>e,yCallbackFunc:n=null,validateRows:o=()=>!0,shuffle:a=!1,state:l={}})=>{let i=[],s=null;if(d(e,{min:1},"parseProductionX"),y(e[0]),null!=n)throw new Error('The property "yCallbackFunc" must not be set in "parseProductionX".');for(let t=0;t<e.length;t++)try{if(!o({objRow:e,index:t,state:l}))continue;const n=r({objRow:e,index:t,state:l});if(null==n)continue;if(m(n,"parseProductionX"))throw new Error('Invalid numeric value returned from "xCallbackFunc".');null===s&&(s=Object.keys(n));const a=s.length,u=new Array(a);for(let e=0;e<a;e++){const r=s[e];u[e]=n[r]}i.push(u)}catch(e){throw new Error(`[BUG] - Skipped row index=${t}: ${e.message}`)}return a&&(i=t(i)),{X:i,configX:{keyNames:s??[]}}},b=(e,r,t=1)=>{if(!Array.isArray(e))throw new Error("arr must be an array");if(!Number.isInteger(r)||r<=0)throw new Error("timeSteps must be a positive integer");if(!Number.isInteger(t)||t<=0)throw new Error("step must be a positive integer");if(r>e.length)return[];const n=[];for(let o=0;o<=e.length-r;o+=t)n.push(e.slice(o,o+r));return n};XY_Scale=r})();
1
+ var XY_Scale;(()=>{"use strict";var e={d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{arrayShuffle:()=>t,arrayToTimesteps:()=>h,parseProductionX:()=>w,parseTrainingXY:()=>d,zscore:()=>f});const t=e=>{const r=[...e];for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r},n=e=>null!=e&&Number.isFinite(e),o=e=>Number.isInteger(e)&&e>0,a=e=>null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0,i=(e,{min:r=-1/0,max:t=1/0},n)=>{if(!Array.isArray(e))throw new Error(`Invalid property. "${n}" expected an array.`);if(e.length<r)throw new Error(`Invalid property value. Array "${n}" expected at least ${r} items.`);if(e.length>t)throw new Error(`Invalid property value. Array "${n}" expected at max ${t} items.`);return!0},l=e=>{if(!a(e))throw new Error("The first item in arrObj is expeted to be a key par object.");const r={},t={};for(const[n,o]of Object.entries(e))"number"==typeof o?r[n]=o:t[n]=o;if(Object.keys(r).length>0&&s(r,"validateFirstRow"))throw new Error("Invalid numeric value at index 0.");if(Object.keys(t).length>0&&c(t,"validateFirstRow"))throw new Error("Invalid non-numeric value at index 0.");return!0},s=(e,r)=>{if(null==r)throw new Error('[hasInvalidNumbers] Missing required param "callerName".');if(!a(e))throw new Error(`[${r}:hasInvalidNumbers] Received an invalid "list" param — expected a non-empty key-pair object, got: ${JSON.stringify(e)}.`);for(const[t,o]of Object.entries(e))if(!n(o))return console.error(`[${r}:hasInvalidNumbers] property "${t}" only accept numbers. Invalid value is "${o}" and invalid type is "${typeof o}".`),!0;return!1},c=(e,r)=>{if(null==r)throw new Error('[hasNullOrUndefined] Missing required param "callerName".');if(!a(e))throw new Error(`[${r}:hasNullOrUndefined] Received an invalid "list" param — expected a non-empty key-pair object, got: ${JSON.stringify(e)}.`);for(const[t,n]of Object.entries(e))if(a(n)){for(const[e,o]of Object.entries(n))if(null==o)return console.error(`[${r}:hasNullOrUndefined] Null or undefined value detected for key "${t}.${e}".\n${String(o)}`),!0}else if(null==n)return console.error(`[${r}:hasNullOrUndefined] Null or undefined value detected for key "${t}".\n${String(n)}`),!0;return!1},u=e=>Array.from(e),y=(e,r)=>{const t=new Float64Array(r),n=new Float64Array(r),o=new Float64Array(r),a=new Uint32Array(r),i=Array.isArray(e?.mean)?e.mean:[],l=Array.isArray(e?.std)?e.std:[],s=Array.isArray(e?.scale)?e.scale:[],c=Array.isArray(e?.count)?e.count:[];for(let e=0;e<r;e++){const r=Number(i[e]),u=Number(l[e]),y=Number(s[e]),f=Number(c[e]);t[e]=Number.isFinite(r)?r:0,n[e]=Number.isFinite(u)&&u>0?u:0,a[e]=Number.isFinite(f)&&f>0?f:0,Number.isFinite(y)&&y>0?(o[e]=y,n[e]>0||(n[e]=1/y)):n[e]>0?o[e]=1/n[e]:o[e]=0}return{mean:t,std:n,scale:o,count:a}},f=(e,r=null)=>{if(!Array.isArray(e))throw new TypeError('[zscore] "arr" must be a 2D array.');if(0===e.length){const e=y(r??{},0);return{stats:{mean:u(e.mean),std:u(e.std),scale:u(e.scale),count:u(e.count)},data:[]}}const t=e[0];if(!Array.isArray(t))throw new TypeError('[zscore] "arr" must be a 2D array of rows.');const n=t.length,o=r?y(r,n):((e,r)=>{const t=e.length,n=new Float64Array(r),o=new Float64Array(r),a=new Uint32Array(r);for(let i=0;i<t;i++){const t=e[i];if(!Array.isArray(t))throw new TypeError(`[zscore] Invalid row at index=${i}. Expected an array.`);if(t.length!==r)throw new Error(`[zscore] Inconsistent row size at index=${i}. Expected ${r}, got ${t.length}.`);for(let e=0;e<r;e++){const r=Number(t[e]);if(!Number.isFinite(r))continue;a[e]++;const i=r-n[e];n[e]+=i/a[e],o[e]+=i*(r-n[e])}}const i=new Float64Array(r),l=new Float64Array(r);for(let e=0;e<r;e++){const r=a[e]>1?o[e]/a[e]:0,t=r>0?Math.sqrt(r):0;i[e]=t,l[e]=t>0?1/t:0}return{mean:n,std:i,scale:l,count:a}})(e,n),a=((e,r)=>{const t=e.length,n=r.mean.length,o=new Array(t);for(let a=0;a<t;a++){const t=e[a];if(!Array.isArray(t))throw new TypeError(`[zscore] Invalid row at index=${a}. Expected an array.`);if(t.length!==n)throw new Error(`[zscore] Inconsistent row size at index=${a}. Expected ${n}, got ${t.length}.`);const i=new Array(n);for(let e=0;e<n;e++){const n=Number(t[e]),o=r.scale[e];i[e]=Number.isFinite(n)&&o>0?(n-r.mean[e])*o:0}o[a]=i}return o})(e,o);return{stats:{mean:u(o.mean),std:u(o.std),scale:u(o.scale),count:u(o.count)},data:a}},d=({arrObj:e=[],trainSize:r=null,testSize:n=null,yCallbackFunc:a=e=>e,xCallbackFunc:c=e=>e,validateRows:u=()=>!0,shuffle:y=!1,state:d={},showSource:w=!1,scaling:h=null})=>{i(e,{min:2},"parseTrainingXY"),l(e[0]);const p=e.length;if((({arrObjSize:e,trainSize:r,testSize:t})=>{if(!o(r))throw new Error(`Invalid property: "trainSize" (${r}) must be a non-negative integer.`);if(!o(t))throw new Error(`Invalid property: "testSize" (${t}) must be a non-negative integer.`);if(!Number.isInteger(e)||e<0)throw new Error(`Invalid property: "arrObjSize" (${e}) must be a non-negative integer.`);if(e<r+t)throw new Error(`Invalid property: The sum of "trainSize" + "testSize" (${r+t}) must not be larger than "arrObj.length" (${e}).`)})({arrObjSize:p,trainSize:r,testSize:n}),![null,"zscore"].includes(h))throw new Error('Invalid "scaling" property. Accepting null or "zscore".');const g=r+n;let m=[],b=[],A=[],v=null,$=null;const E={};for(let r=0;r<e.length;r++)try{if(!u({objRow:e,index:r,state:d}))continue;const t=c({objRow:e,index:r,state:d}),n=a({objRow:e,index:r,state:d});if(null==t||null==n)continue;if(s(t,"parseTrainingXY"))throw new Error('Invalid numeric value returned from "xCallbackFunc".');if(null===v&&(v=Object.keys(t)),null===$){$=Object.keys(n);for(let e=0;e<$.length;e++)E[$[e]]={}}const o=v.length,i=$.length,l=new Array(o),y=new Array(i);for(let e=0;e<o;e++){const r=v[e];l[e]=t[r]}for(let e=0;e<i;e++){const r=$[e],t=n[r];y[e]=t;const o=Array.isArray(t)?JSON.stringify(t):String(t);E[r][o]=(E[r][o]??0)+1}m.push(l),b.push(y),w&&A.push(e[r])}catch(e){throw new Error(`[BUG] - Skipped row index=${r}: ${e.message}`)}if(y){const e=new Array(m.length);for(let r=0;r<m.length;r++)e[r]={x:m[r],y:b[r]},w&&(e[r].source=A[r]);const r=t(e);m=new Array(r.length),b=new Array(r.length),w&&(A=new Array(r.length));for(let e=0;e<r.length;e++)m[e]=r[e].x,b[e]=r[e].y,w&&(A[e]=r[e].source)}const N={keyNames:v??[]},S={keyNames:$??[],labelCounts:E},x=p-g;m.splice(0,x),b.splice(0,x);let j=m.slice(0,r),z=b.slice(0,r),O=null;if("zscore"===h){let e=f(j);O=e.stats,j=e.data,e=null}let I=m.slice(-n);"zscore"===h&&(I=f(I,O).data);let k,F,T=b.slice(-n);return m=null,b=null,w&&(A.splice(0,x),k=A.slice(0,r),F=A.slice(-n),A=null),{trainX:j,trainY:z,testX:I,testY:T,configX:N,configY:S,trainSource:k,testSource:F,stats:O}},w=({arrObj:e=[],xCallbackFunc:r=e=>e,yCallbackFunc:n=null,validateRows:o=()=>!0,shuffle:a=!1,state:c={},showSource:u=!1,scaling:y=null,stats:d})=>{let w=[],h=[],p=null;if(i(e,{min:1},"parseProductionX"),l(e[0]),![null,"zscore"].includes(y))throw new Error('Invalid "scaling" property. Accepting null or "zscore".');if(e.length,null!=n)throw new Error('The property "yCallbackFunc" must not be set in "parseProductionX".');for(let t=0;t<e.length;t++)try{if(!o({objRow:e,index:t,state:c}))continue;const n=r({objRow:e,index:t,state:c});if(null==n)continue;if(s(n,"parseProductionX"))throw new Error('Invalid numeric value returned from "xCallbackFunc".');null===p&&(p=Object.keys(n));const a=p.length,i=new Array(a);for(let e=0;e<a;e++){const r=p[e];i[e]=n[r]}w.push(i),u&&h.push(e[t])}catch(e){throw new Error(`[BUG] - Skipped row index=${t}: ${e.message}`)}if(a){const e=new Array(w.length);for(let r=0;r<w.length;r++)e[r]={x:w[r]},u&&(e[r].source=h[r]);const r=t(e);w=new Array(r.length),u&&(h=new Array(r.length));for(let e=0;e<r.length;e++)w[e]=r[e].x,u&&(h[e]=r[e].source)}const g={keyNames:p??[]};return"zscore"===y&&(w=f(w,d).data),{X:w,source:h,configX:g}},h=(e,r,t=1)=>{if(!Array.isArray(e))throw new Error("arr must be an array");if(!Number.isInteger(r)||r<=0)throw new Error("timeSteps must be a positive integer");if(!Number.isInteger(t)||t<=0)throw new Error("step must be a positive integer");if(r>e.length)return[];const n=[];for(let o=0;o<=e.length-r;o+=t)n.push(e.slice(o,o+r));return n};XY_Scale=r})();
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { parseTrainingXY, parseProductionX } from "./src/datasets.js"
2
2
  import {arrayToTimesteps } from "./src/timeSteps.js"
3
3
  import { arrayShuffle } from "./src/utilities.js"
4
+ import { zscore } from "./src/zscore.js"
4
5
 
5
- export { parseTrainingXY, parseProductionX, arrayToTimesteps, arrayShuffle }
6
+ export { parseTrainingXY, parseProductionX, arrayToTimesteps, arrayShuffle, zscore }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xy-scale",
3
- "version": "1.4.45",
3
+ "version": "1.4.47",
4
4
  "main": "./index.js",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/datasets.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { arrayShuffle } from "./utilities.js";
2
2
  import { validateFirstRow, validateArray, hasInvalidNumbers, validateSizes } from "./validators.js";
3
- import {zscore2d} from './zscore2.js'
3
+ import {zscore} from './zscore.js'
4
4
 
5
5
  export const parseTrainingXY = ({
6
6
  arrObj = [],
@@ -152,7 +152,7 @@ export const parseTrainingXY = ({
152
152
  let stats = null
153
153
 
154
154
  if(scaling === 'zscore') {
155
- let trainNormalized = zscore2d(trainX)
155
+ let trainNormalized = zscore(trainX)
156
156
  stats = trainNormalized.stats
157
157
  trainX = trainNormalized.data
158
158
  trainNormalized = null
@@ -161,7 +161,7 @@ export const parseTrainingXY = ({
161
161
  let testX = flatX.slice(-testSize);
162
162
 
163
163
  if(scaling === 'zscore') {
164
- testX = zscore2d(testX, stats).data
164
+ testX = zscore(testX, stats).data
165
165
  }
166
166
 
167
167
  let testY = flatY.slice(-testSize);
@@ -292,7 +292,7 @@ export const parseProductionX = ({
292
292
  };
293
293
 
294
294
  if(scaling === 'zscore') {
295
- flatX = zscore2d(flatX, stats).data
295
+ flatX = zscore(flatX, stats).data
296
296
  }
297
297
 
298
298
  return {
package/src/validators.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  export const isNumber = v => v != null && Number.isFinite(v)
3
3
 
4
- export const isPositiveInteger = value => Number.isInteger(value) && value > 0
4
+ export const isPositiveInteger = value => Number.isInteger(value) && value >= 0
5
5
 
6
6
  export const isKeyPairObject = param => {
7
7
  return (
@@ -138,7 +138,7 @@ export const arraysAreNotEqualSize = (list, callerName) => {
138
138
 
139
139
  export const validateSizes = ({arrObjSize, trainSize, testSize}) => {
140
140
 
141
- if(!isPositiveInteger(trainSize)) {
141
+ if(!isPositiveInteger(trainSize) || trainSize === 0) {
142
142
  throw new Error(`Invalid property: "trainSize" (${trainSize}) must be a non-negative integer.`)
143
143
  }
144
144
  if(!isPositiveInteger(testSize)) {
@@ -44,10 +44,10 @@ const fitStats = (arr, cols) => {
44
44
  const row = arr[i];
45
45
 
46
46
  if (!Array.isArray(row)) {
47
- throw new TypeError(`[zscore2d] Invalid row at index=${i}. Expected an array.`);
47
+ throw new TypeError(`[zscore] Invalid row at index=${i}. Expected an array.`);
48
48
  }
49
49
  if (row.length !== cols) {
50
- throw new Error(`[zscore2d] Inconsistent row size at index=${i}. Expected ${cols}, got ${row.length}.`);
50
+ throw new Error(`[zscore] Inconsistent row size at index=${i}. Expected ${cols}, got ${row.length}.`);
51
51
  }
52
52
 
53
53
  for (let j = 0; j < cols; j++) {
@@ -84,10 +84,10 @@ const scaleFromStats = (arr, normalizedStats) => {
84
84
  const row = arr[i];
85
85
 
86
86
  if (!Array.isArray(row)) {
87
- throw new TypeError(`[zscore2d] Invalid row at index=${i}. Expected an array.`);
87
+ throw new TypeError(`[zscore] Invalid row at index=${i}. Expected an array.`);
88
88
  }
89
89
  if (row.length !== cols) {
90
- throw new Error(`[zscore2d] Inconsistent row size at index=${i}. Expected ${cols}, got ${row.length}.`);
90
+ throw new Error(`[zscore] Inconsistent row size at index=${i}. Expected ${cols}, got ${row.length}.`);
91
91
  }
92
92
 
93
93
  const normalized = new Array(cols);
@@ -106,9 +106,9 @@ const scaleFromStats = (arr, normalizedStats) => {
106
106
  return out;
107
107
  };
108
108
 
109
- export const zscore2d = (arr, stats = null) => {
109
+ export const zscore = (arr, stats = null) => {
110
110
  if (!Array.isArray(arr)) {
111
- throw new TypeError('[zscore2d] "arr" must be a 2D array.');
111
+ throw new TypeError('[zscore] "arr" must be a 2D array.');
112
112
  }
113
113
 
114
114
  if (arr.length === 0) {
@@ -126,7 +126,7 @@ export const zscore2d = (arr, stats = null) => {
126
126
 
127
127
  const firstRow = arr[0];
128
128
  if (!Array.isArray(firstRow)) {
129
- throw new TypeError('[zscore2d] "arr" must be a 2D array of rows.');
129
+ throw new TypeError('[zscore] "arr" must be a 2D array of rows.');
130
130
  }
131
131
 
132
132
  const cols = firstRow.length;