Skip to content

Commit cbff4fc

Browse files
committed
Some fixes for states and rename file
1 parent 80e977c commit cbff4fc

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ test: ## Run tests with coverage
4141
# Dashboard commands
4242

4343
serve-dev: ## Serve Panel dashboard - Dev mode
44-
panel serve panel/simdec.py panel/sampling.py \
44+
panel serve panel/simdec_app.py panel/sampling.py \
4545
--index panel/index.html \
4646
--show --autoreload \
4747
--static-dirs _static=docs/_static \
4848
--reuse-sessions --warm
4949

5050
serve-oauth: ## Serve Panel dashboard - Prod mode with OAuth2. Needs: PANEL_OAUTH_REDIRECT_URI, PANEL_OAUTH_KEY, PANEL_OAUTH_SECRET, PANEL_OAUTH_ENCRYPTION
51-
PANEL_OAUTH_SCOPE=email panel serve panel/simdec.py panel/sampling.py \
51+
PANEL_OAUTH_SCOPE=email panel serve panel/simdec_app.py panel/sampling.py \
5252
--index panel/index.html \
5353
--show \
5454
--cookie-secret panel_cookie_secret_oauth \

panel/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ USER app
6262
WORKDIR /app
6363

6464
# Run the web service on container startup.
65-
CMD ["panel", "serve", "panel/simdec.py", "panel/sampling.py", \
65+
CMD ["panel", "serve", "panel/simdec_app.py", "panel/sampling.py", \
6666
"--address", "0.0.0.0", "--port", "8080", \
6767
"--num-procs", "2", \
6868
"--allow-websocket-origin", "simdec.io", \

panel/simdec.py renamed to panel/simdec_app.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def update_colors_select(event):
174174

175175

176176
def create_color_pickers(states, colors):
177+
print(states)
177178
color_picker_list = []
178179
for state, color in zip(states[0], colors):
179180
color_picker = pn.widgets.ColorPicker(name=state, value=color)
@@ -183,10 +184,11 @@ def create_color_pickers(states, colors):
183184

184185

185186
@pn.cache
186-
def palette(res, colors_picked):
187+
def palette_(states: list[list[str]], colors_picked: list[list[float]]):
187188
cmaps = [single_color_to_colormap(color_picked) for color_picked in colors_picked]
188189
# Reverse order as in figures high values take the first colors
189-
return sd.palette(res.states[::-1], cmaps=cmaps[::-1])
190+
states = [len(states_) for states_ in states]
191+
return sd.palette(states[::-1], cmaps=cmaps[::-1])
190192

191193

192194
@pn.cache
@@ -206,7 +208,7 @@ def xlim_auto(output):
206208

207209

208210
@pn.cache
209-
def figure(res, palette, n_bins, xlim, kind, output_name):
211+
def figure_pn(res, palette, n_bins, xlim, kind, output_name):
210212
kind = "histogram" if kind == "Stacked histogram" else "boxplot"
211213
plt.close("all")
212214
fig, ax = plt.subplots()
@@ -224,12 +226,12 @@ def states_from_data(res, inputs):
224226

225227

226228
@pn.cache
227-
def tableau(res, states, palette):
229+
def tableau_pn(res, states, palette):
228230
# use a notebook to see the styling
229231
_, styler = sd.tableau(
230232
statistic=res.statistic,
231233
var_names=res.var_names,
232-
states=states,
234+
states=res.states,
233235
bins=res.bins,
234236
palette=palette,
235237
)
@@ -392,12 +394,10 @@ def callback_xlim(start, end):
392394
colors_select.param.value,
393395
)
394396

395-
interactive_palette = pn.bind(
396-
palette, interactive_decomposition, colors_select.param.value
397-
)
397+
interactive_palette = pn.bind(palette_, interactive_states, colors_select.param.value)
398398

399399
interactive_figure = pn.bind(
400-
figure,
400+
figure_pn,
401401
interactive_decomposition,
402402
interactive_palette,
403403
selector_n_bins,
@@ -407,7 +407,7 @@ def callback_xlim(start, end):
407407
)
408408

409409
interactive_tableau = pn.bind(
410-
tableau, interactive_decomposition, interactive_states, interactive_palette
410+
tableau_pn, interactive_decomposition, interactive_states, interactive_palette
411411
)
412412
interactive_tableau_states = pn.bind(
413413
tableau_states, interactive_decomposition, interactive_states

0 commit comments

Comments
 (0)