From 3fddaa98163fb1cb95e66382077da891ff309bf4 Mon Sep 17 00:00:00 2001 From: dan_the_3rd <43445237+danthe3rd@users.noreply.github.com> Date: Tue, 14 Apr 2020 15:58:50 +0200 Subject: [PATCH] Bool values are not numeric (#51) Co-authored-by: danthe3rd --- hiplot/fetchers_demo.py | 8 ++++++++ src/infertypes.ts | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hiplot/fetchers_demo.py b/hiplot/fetchers_demo.py index fea200e7..1882a96e 100644 --- a/hiplot/fetchers_demo.py +++ b/hiplot/fetchers_demo.py @@ -152,6 +152,13 @@ def demo_distribution(**kwargs: Any) -> hip.Experiment: return xp +def demo_bool() -> hip.Experiment: + return hip.Experiment.from_iterable([ + {"bool": True}, + {"bool": False} + ]) + + README_DEMOS: Dict[str, Callable[[], hip.Experiment]] = { "demo": demo, "demo_big": lambda: demo(1000), @@ -163,4 +170,5 @@ def demo_distribution(**kwargs: Any) -> hip.Experiment: "demo_distribution_cat": lambda: demo_distribution(axis="cat"), "demo_distribution_num": lambda: demo_distribution(axis="numeric"), "demo_distribution_num_100bins": lambda: demo_distribution(axis="numeric", nbins=100), + "demo_bool": demo_bool, } diff --git a/src/infertypes.ts b/src/infertypes.ts index e86ca16f..bd9cf243 100644 --- a/src/infertypes.ts +++ b/src/infertypes.ts @@ -164,7 +164,9 @@ export function infertypes(url_states: PersistentState, table: Array, } else { setVals.push(v); } - if (typeof v != "number" && !is_special_num && isNaN(v)) { + // Detect non-numeric column + if ((typeof v != "number" && !is_special_num && isNaN(v)) || + v === true || v === false) { numeric = false; return; }