Skip to content

Commit 219a070

Browse files
committed
Minor improvements
1 parent 1bf67c9 commit 219a070

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

app/streamlit_app.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ def mode(arr):
211211

212212

213213
def quantile(q):
214-
return lambda agg: np.nanquantile(agg, q=q)
214+
215+
def _quantile_q(agg):
216+
return np.nanquantile(agg, q=q)
217+
218+
return _quantile_q
215219

216220

217221
@st.cache_data
@@ -565,12 +569,12 @@ def plot_agg_input_section():
565569
return agg, agg_name
566570

567571

572+
def _hash_networkx_graph(graph):
573+
return _encode_graph(_get_graph_no_attribs(graph))
574+
575+
568576
@st.cache_data(
569-
hash_funcs={
570-
"networkx.classes.graph.Graph": lambda g: _encode_graph(
571-
_get_graph_no_attribs(g)
572-
)
573-
},
577+
hash_funcs={"networkx.classes.graph.Graph": _hash_networkx_graph},
574578
show_spinner="Generating Mapper Layout",
575579
)
576580
def compute_mapper_plot(mapper_graph, dim, seed, iterations):
@@ -610,8 +614,12 @@ def mapper_plot_section(mapper_graph):
610614
return mapper_plot
611615

612616

617+
def _hash_mapper_plot(mapper_plot):
618+
return mapper_plot.positions
619+
620+
613621
@st.cache_data(
614-
hash_funcs={"tdamapper.plot.MapperPlot": lambda mp: mp.positions},
622+
hash_funcs={"tdamapper.plot.MapperPlot": _hash_mapper_plot},
615623
show_spinner="Rendering Mapper",
616624
)
617625
def compute_mapper_fig(mapper_plot, colors, node_size, cmap, _agg, agg_name):

tests/test_bench_metrics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ def eval_dist(X, d):
4747

4848
def run_dist_bench(X, d):
4949
eval_dist(X, d)
50-
return timeit.timeit(lambda: eval_dist(X, d), number=200)
50+
51+
def _eval():
52+
eval_dist(X, d)
53+
54+
return timeit.timeit(_eval, number=200)
5155

5256

5357
def run_euclidean_bench(X):

0 commit comments

Comments
 (0)