xy-scale 1.4.46 → 1.4.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xy-scale",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
4
4
  "main": "./index.js",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/datasets.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { arrayShuffle } from "./utilities.js";
2
- import { validateFirstRow, validateArray, hasInvalidNumbers, validateSizes } from "./validators.js";
2
+ import { validateFirstRow, validateArray, hasInvalidNumbers, validateSizes, isNumber } from "./validators.js";
3
3
  import {zscore} from './zscore.js'
4
4
 
5
5
  export const parseTrainingXY = ({
@@ -46,7 +46,10 @@ export const parseTrainingXY = ({
46
46
  if (parsedX == null || parsedY == null) continue;
47
47
 
48
48
  if (hasInvalidNumbers(parsedX, 'parseTrainingXY')) {
49
- throw new Error(`Invalid numeric value returned from "xCallbackFunc".`);
49
+
50
+ const invalids = Object.entries(parsedX).find(arr => !isNumber(arr[1]))
51
+
52
+ throw new Error(`Invalid numeric value returned from "xCallbackFunc": ${JSON.stringify(invalids)}`);
50
53
  }
51
54
 
52
55
  if (keyNamesX === null) {
@@ -229,7 +232,10 @@ export const parseProductionX = ({
229
232
  if (parsedX == null) continue;
230
233
 
231
234
  if (hasInvalidNumbers(parsedX, 'parseProductionX')) {
232
- throw new Error(`Invalid numeric value returned from "xCallbackFunc".`);
235
+
236
+ const invalids = Object.entries(parsedX).find(arr => !isNumber(arr[1]))
237
+
238
+ throw new Error(`Invalid numeric value returned from "xCallbackFunc": ${JSON.stringify(invalids)}`);
233
239
  }
234
240
 
235
241
  if (keyNamesX === null) {
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)) {