Skip to content

Commit

Permalink
[graph model] try to cast in quantitative test
Browse files Browse the repository at this point in the history
better message
fixes #162
  • Loading branch information
paulgirard committed Jun 18, 2024
1 parent 0c07c15 commit 9c41081
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/core/graph/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Graph, { MultiGraph } from "graphology";
import { Attributes } from "graphology-types";
import { forEach, isNumber, keys, mapValues, omit, sortBy, take, uniq, values } from "lodash";
import { forEach, isNil, isNumber, keys, mapValues, omit, sortBy, take, uniq, values } from "lodash";

import { ItemType, Scalar } from "../types";
import { toNumber, toScalar } from "../utils/casting";
Expand Down Expand Up @@ -328,11 +328,12 @@ export function countExistingValues(
let nbCastIssues = 0;
let nbMissingValues = 0;
items.forEach((item) => {
if (item[fm.id] !== undefined) {
if (!isNil(item[fm.id])) {
// attribute exists
nbItems += 1;
// is format correct?
if (fm.quantitative && typeof item[fm.id] !== "number") nbCastIssues += 1;
const value = item[fm.id];
if (fm.quantitative && typeof item[fm.id] !== "number" && !isNil(value) && isNaN(+value)) nbCastIssues += 1;
} else nbMissingValues += 1;
});
return {
Expand Down
2 changes: 1 addition & 1 deletion src/locales/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
},
"warnings": {
"missing": "{{nbValues}} missing values",
"wrong": "{{nbValues}} wrong values",
"wrong": "{{nbValues}} values are not quantitative",
"allMissing": "No values in the graph"
}
},
Expand Down

0 comments on commit 9c41081

Please sign in to comment.