Skip to content

Commit

Permalink
Remove deprecated numpy code
Browse files Browse the repository at this point in the history
  • Loading branch information
catanzaromj committed Mar 16, 2024
1 parent fbc7479 commit 0d31335
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions kmapper/visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ def _build_histogram(data, colorscale=None, nbins=10):
def _graph_data_distribution(
graph, color_values, node_color_function, colorscale, nbins=10
):

node_averages = []
for node_id, member_ids in graph["nodes"].items():
node_color = _node_color_function(member_ids, color_values, node_color_function)
Expand Down Expand Up @@ -411,7 +410,7 @@ def _format_cluster_statistics(member_ids, X, X_names):

above_mean = cluster_X_mean > X_mean

with np.errstate(divide='ignore'):
with np.errstate(divide="ignore"):
std_m = np.sqrt((cluster_X_mean - X_mean) ** 2) / X_std

stat_zip = list(
Expand Down Expand Up @@ -550,7 +549,13 @@ def _format_tooltip(


def _render_d3_vis(
title, mapper_summary, histogram, mapper_data, colorscale, include_searchbar, include_min_intersection_selector
title,
mapper_summary,
histogram,
mapper_data,
colorscale,
include_searchbar,
include_min_intersection_selector,
):
# Find the module absolute path and locate templates
module_root = os.path.join(os.path.dirname(__file__), "templates")
Expand All @@ -572,7 +577,7 @@ def _render_d3_vis(
def my_dumper(obj, **kwargs):
def np_encoder(object, **kwargs):
if isinstance(object, np.generic):
return np.asscalar(object)
return object.item()

return json.dumps(obj, default=np_encoder, **kwargs)

Expand All @@ -589,7 +594,7 @@ def np_encoder(object, **kwargs):
js_text=js_text,
css_text=css_text,
include_searchbar=include_searchbar,
include_min_intersection_selector=include_min_intersection_selector
include_min_intersection_selector=include_min_intersection_selector,
)

return html
Expand Down

0 comments on commit 0d31335

Please sign in to comment.