Skip to content

Commit 0e4f7d8

Browse files
committed
Add more caching everywhere
1 parent 9d73ee8 commit 0e4f7d8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

panel/app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def sensitivity_indices(inputs, output):
6969
return indices
7070

7171

72+
@pn.cache
7273
def sensitivity_indices_table(si, inputs):
7374
var_names = inputs.columns
7475
var_order = np.argsort(si)[::-1]
@@ -128,6 +129,7 @@ def explained_variance_80(sensitivity_indices_table):
128129
return input_names.to_list()[: pos_80 + 1]
129130

130131

132+
@pn.cache
131133
def decomposition(dec_limit, si, inputs, output):
132134
return sd.decomposition(
133135
inputs=inputs,
@@ -138,6 +140,7 @@ def decomposition(dec_limit, si, inputs, output):
138140
)
139141

140142

143+
@pn.cache
141144
def base_colors(res):
142145
all_colors = sd.palette(res.states)
143146
colors = all_colors[:: res.states[0]]
@@ -162,11 +165,13 @@ def create_color_pickers(states, colors):
162165
color_pickers[:] = color_picker_list
163166

164167

168+
@pn.cache
165169
def palette(res, colors_picked):
166170
cmaps = [colormap_from_single_color(color_picked) for color_picked in colors_picked]
167171
return sd.palette(res.states, cmaps=cmaps)
168172

169173

174+
@pn.cache
170175
def n_bins_auto(res):
171176
min_ = np.nanmin(res.bins)
172177
max_ = np.nanmax(res.bins)
@@ -177,6 +182,7 @@ def display_n_bins(kind):
177182
return False if kind != "Stacked histogram" else True
178183

179184

185+
@pn.cache
180186
def figure(res, palette, n_bins, kind, output_name):
181187
kind = "histogram" if kind == "Stacked histogram" else "boxplot"
182188
plt.close("all")
@@ -188,10 +194,12 @@ def figure(res, palette, n_bins, kind, output_name):
188194
return fig
189195

190196

197+
@pn.cache
191198
def states_from_data(res, inputs):
192199
return sd.states_expansion(states=res.states, inputs=inputs)
193200

194201

202+
@pn.cache
195203
def tableau(res, states, palette):
196204
# use a notebook to see the styling
197205
_, styler = sd.tableau(
@@ -204,6 +212,7 @@ def tableau(res, states, palette):
204212
return styler
205213

206214

215+
@pn.cache
207216
def tableau_states(res, states):
208217
data = []
209218
for var_name, states_, bin_edges in zip(res.var_names, states, res.bin_edges):

0 commit comments

Comments
 (0)