Skip to content

Commit

Permalink
Resolves #84
Browse files Browse the repository at this point in the history
Signed-off-by: Chaichontat Sriworarat <csriwor1@jh.edu>
  • Loading branch information
chaichontat committed Nov 18, 2023
1 parent c937411 commit 24da5f3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/data/objects/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface FeatureData {

// TODO Set spec.
export const convertCategoricalToNumber = keyLRU((arr: (number | string)[]) => {
console.debug("Converting categorical to number")
const unique = [...new Set(arr)];
const legend = {} as Record<number | string, number>;
const legendArr = [] as (number | string)[];
Expand All @@ -45,6 +46,9 @@ export const convertCategoricalToNumber = keyLRU((arr: (number | string)[]) => {
});

export const stats = keyLRU((arr: (number | string)[]) => {
if (typeof arr[0] !== 'number') {
return [0, 1];
}
for (let i = 0; i < arr.length; i++) {
arr[i] = Number(arr[i]) || 0; // Convert NaN to 0.
}
Expand Down

0 comments on commit 24da5f3

Please sign in to comment.