From f6214640cf12f077cf31745b1340642f39ed6bc0 Mon Sep 17 00:00:00 2001 From: blue-j Date: Mon, 17 Jun 2024 20:42:10 -0700 Subject: [PATCH] Update visuals.py np.isscalar is no longer available in numpy --- kmapper/visuals.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kmapper/visuals.py b/kmapper/visuals.py index 94b87651..73ce318d 100644 --- a/kmapper/visuals.py +++ b/kmapper/visuals.py @@ -570,9 +570,12 @@ def _render_d3_vis( # Jinja default json serializer can't handle np arrays; provide custom encoding def my_dumper(obj, **kwargs): - def np_encoder(object, **kwargs): + def np_encoder(object): if isinstance(object, np.generic): - return np.asscalar(object) + return object.item() + if isinstance(object, np.ndarray): + return object.tolist() + return json.JSONEncoder().default(object) return json.dumps(obj, default=np_encoder, **kwargs)