Skip to content

Commit

Permalink
bug fixes in datatools and restructurng callback allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
ikaryss committed Mar 23, 2023
1 parent 74f8fc9 commit dfad192
Show file tree
Hide file tree
Showing 10 changed files with 871 additions and 426 deletions.
14 changes: 6 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,12 @@ poetry.lock
tech_tests.ipynb

/home_tests
/pyquac/ddd.csv
/pyquac/jyp_app.ipynb
/.vscode
/pyquac/good_case.csv
/pyquac/very_good.csv
/pyquac/research.ipynb
/examples/style.css
/pyquac/random_example.py
/pyquac/example_data.csv
/pyquac/raw_test.csv
/pyquac/delete.csv
/pyquac/tts_noisy.csv
/pyquac/tts_fit.csv
/pyquac/sts_default.csv
/pyquac/Showcase.ipynb
/pyquac/app_error_test.py
/pyquac/maindash.py
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ numba = ">=0.54.1"
kaleido = "0.1.0"
pillow = ">=9.1.0"
dash = ">=1.21.0"
jupyter-dash = {git = "https://github.com/plotly/jupyter-dash.git", rev = "master"}
# jupyter-dash = {git = "https://github.com/plotly/jupyter-dash.git", rev = "master"}
jupyter-dash = "^0.4.2"
PeakUtils = ">=1.3.3"
matplotlib = "^3.5.2"
dash-bootstrap-components = "^1.2.1"
dash-bootstrap-templates = "^1.0.7"
dash-daq = "^0.5.0"
dash-iconify = "^0.1.2"
werkzeug = "2.1.2"
notebook = "^6.4.12"
jupyter = "^1.0.0"
pydantic = "^1.10.2"

[tool.poetry.dev-dependencies]
Expand All @@ -36,6 +35,8 @@ pytest-sugar = "^0.9.4"
pytest-clarity = "^1.0.1"
pylint = "2.13.9"
black = "^22.10.0"
notebook = "^6.4.12"
jupyter = "^1.0.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
139 changes: 90 additions & 49 deletions pyquac/components/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"""

from dash.dependencies import Input, Output, State, ClientsideFunction
from dash import dcc, callback, clientside_callback
from dash.exceptions import PreventUpdate
from dash import dcc
import plotly.graph_objects as go
import numpy as np
from pyquac.settings import settings

AXIS_SIZE = 13
Expand Down Expand Up @@ -202,56 +204,95 @@ def figure_layout(
return figure


@callback(
Output("heatmap", "style"),
Input("btn_sidebar", "n_clicks"),
Input("side_click", "data"),
)
def toggle_graph(n, nclick):
"""function to hide and reveal sidebar
# @app.callback(
# Output("heatmap", "style"),
# Input("btn_sidebar", "n_clicks"),
# Input("side_click", "data"),
# )
# def toggle_graph(n, nclick):
# """function to hide and reveal sidebar

Args:
n (int): _description_
nclick (int): _description_
# Args:
# n (int): _description_
# nclick (int): _description_

Returns:
dict: style objects
"""
if n:
if nclick == "SHOW":
graph_style = GRAPH_STYLE
else:
graph_style = GRAPH_HIDEN
else:
graph_style = GRAPH_STYLE

return graph_style


clientside_callback(
ClientsideFunction(namespace="clientside", function_name="refresh_graph"),
Output("heatmap", "figure"),
Input("interval-graph-update", "n_intervals"),
Input("x_click", "data"),
Input("y_click", "data"),
Input("heatmap", "clickData"),
Input("modal_close", "n_clicks"),
Input("modal_db_close", "n_clicks"),
State("x_store", "data"),
State("y_store", "data"),
State("z_store", "data"),
State("heatmap", "figure"),
State("y_scatter", "data"),
State("yz_scatter", "data"),
State("x_scatter", "data"),
State("xz_scatter", "data"),
State("line-switches", "on"),
State("x-title", "value"),
State("y-title", "value"),
prevent_initial_call=True,
)

# clientside_callback(
# Returns:
# dict: style objects
# """
# if n:
# if nclick == "SHOW":
# graph_style = GRAPH_STYLE
# else:
# graph_style = GRAPH_HIDEN
# else:
# graph_style = GRAPH_STYLE

# return graph_style


# app.clientside_callback(
# ClientsideFunction(namespace="clientside", function_name="refresh_graph"),
# Output("heatmap", "figure"),
# Input("interval-graph-update", "n_intervals"),
# Input("x_click", "data"),
# Input("y_click", "data"),
# Input("heatmap", "clickData"),
# Input("modal_close", "n_clicks"),
# Input("modal_db_close", "n_clicks"),
# State("x_store", "data"),
# State("y_store", "data"),
# State("z_store", "data"),
# State("heatmap", "figure"),
# State("y_scatter", "data"),
# State("yz_scatter", "data"),
# State("x_scatter", "data"),
# State("xz_scatter", "data"),
# State("line-switches", "on"),
# State("x-title", "value"),
# State("y-title", "value"),
# prevent_initial_call=True,
# )


# @app.callback(
# Output("x_scatter", "data"),
# Output("y_scatter", "data"),
# Output("xz_scatter", "data"),
# Output("yz_scatter", "data"),
# Output("x_click", "data"),
# Output("y_click", "data"),
# Input("heatmap", "clickData"),
# State("x_raw", "data"),
# State("y_raw", "data"),
# State("z_raw", "data"),
# )
# def update_click_data(click, x_raw, y_raw, z_raw):
# if (click is None) or (click["points"][0]["curveNumber"] != 0):
# raise PreventUpdate

# data_click = click["points"][0]
# x_click = data_click["x"]
# y_click = data_click["y"]

# x_mask = np.equal(np.array(x_raw), np.array(x_click))
# y_mask = np.equal(np.array(y_raw), np.array(y_click))
# x_scatter = np.array(x_raw)[y_mask]
# y_scatter = np.array(y_raw)[x_mask]

# xz_scatter = np.array(z_raw)[y_mask]
# yz_scatter = np.array(z_raw)[x_mask]

# return (
# x_scatter,
# y_scatter,
# xz_scatter,
# yz_scatter,
# x_click,
# y_click,
# )


# app.clientside_callback(
# """
# function(i) {
# const triggered_id = dash_clientside.callback_context.triggered.map(t => t.prop_id)[0];
Expand Down
20 changes: 10 additions & 10 deletions pyquac/components/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from dash.dependencies import Input, Output, State
from dash import html, callback
from dash import html
import dash_bootstrap_components as dbc
from pyquac.settings import settings

Expand Down Expand Up @@ -94,12 +94,12 @@
)


@callback(
Output("modal", "is_open"),
[Input("open_modal", "n_clicks"), Input("modal_close", "n_clicks")],
[State("modal", "is_open")],
)
def toggle_modal(n1, n2, is_open):
if n1 or n2:
return not is_open
return is_open
# @app.callback(
# Output("modal", "is_open"),
# [Input("open_modal", "n_clicks"), Input("modal_close", "n_clicks")],
# [State("modal", "is_open")],
# )
# def toggle_modal(n1, n2, is_open):
# if n1 or n2:
# return not is_open
# return is_open
Loading

0 comments on commit dfad192

Please sign in to comment.