Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
majafranz committed Nov 15, 2024
1 parent 50d200f commit 0114839
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 157 deletions.
18 changes: 15 additions & 3 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from layouts.app_page_layout import sidebar_top, sidebar_bottom, content
import dash
import dash_bootstrap_components as dbc
from dash import Input, Output, html, callback, State
Expand All @@ -8,13 +9,24 @@


app = dash.Dash(
external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.FONT_AWESOME], use_pages=True
external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.FONT_AWESOME],
use_pages=True,
)

from layouts.app_page_layout import sidebar, content

app.title = "Favicon"

sidebar_page_elements = dbc.Nav(
[
dbc.NavLink(page["name"], href=page["relative_path"], active="exact")
for page in dash.page_registry.values()
],
vertical=True,
pills=True,
fill=False,
)
sidebar_elements = sidebar_top + [sidebar_page_elements] + sidebar_bottom
sidebar = html.Div(sidebar_elements, className="sidebar", id="page-sidebar")


@callback(
Output("main-storage", "data"),
Expand Down
267 changes: 128 additions & 139 deletions app/layouts/app_page_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,145 +9,134 @@
DEFAULT_DATA_REUPLOAD = True
DEFAULT_ANSATZ = "No Ansatz"

sidebar = html.Div(
[
dcc.Store(id="main-storage", storage_type="session"),
html.Div(
[
html.H1(
"Mind",
),
html.H2(
"the",
style={
"padding-left": "6px",
},
),
html.Span(
[
html.Img(
src="assets/underground-sign.svg",
width="42",
style={
"display": "inline-block",
"padding-right": "5px",
"padding-bottom": "20px",
},
className="rotate45",
),
html.H1("App", style={"display": "inline-block"}),
]
),
],
className="infoBox",
),
html.Hr(),
dbc.Nav(
[
dbc.NavLink(page["name"], href=page["relative_path"], active="exact")
for page in dash.page_registry.values()
],
vertical=True,
pills=True,
fill=False,
),
html.Div(
[
html.Div(
[
dbc.Label("# of Qubits (0-10)"),
dbc.Input(
type="number",
min=0,
max=10,
step=1,
value=DEFAULT_N_QUBITS,
id="main-qubits-input",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("# of Layers (0-10)"),
dbc.Input(
type="number",
min=0,
max=10,
step=1,
value=DEFAULT_N_LAYERS,
id="main-layers-input",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("Circuit Type"),
dbc.Select(
options=[
{
"label": fct.__name__.replace("_", " ").title(),
"value": fct.__name__,
}
for fct in Ansaetze.get_available()
],
placeholder=DEFAULT_ANSATZ,
required=True,
id="main-circuit-ident-select",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("Data-Reupload"),
dbc.Switch(
id="main-dru-switch",
value=DEFAULT_DATA_REUPLOAD,
className="fs-4",
),
],
),
# html.Div(
# [
# dbc.Label("Trainable Freqs."),
# dbc.Switch(id="switch-tffm", value=False),
# ],
# ),
html.Div(
[
dbc.Label("Seed"),
dbc.Input(
type="number",
min=100,
max=999,
step=1,
value=DEFAULT_SEED,
id="main-seed-input",
),
],
className="numeric-input",
),
],
className="preferencesBox",
),
html.Hr(),
html.Div(
[
dbc.Spinner(
[html.H6("", id="main-loading-state")],
color="primary",
type="grow",
id="main-loading-spinner",
)
],
className="spinnerBox",
),
],
className="sidebar",
id="page-sidebar",
)
sidebar_top = [
dcc.Store(id="main-storage", storage_type="session"),
html.Div(
[
html.H1(
"Mind",
),
html.H2(
"the",
style={
"padding-left": "6px",
},
),
html.Span(
[
html.Img(
src="assets/underground-sign.svg",
width="42",
style={
"display": "inline-block",
"padding-right": "5px",
"padding-bottom": "20px",
},
className="rotate45",
),
html.H1("App", style={"display": "inline-block"}),
]
),
],
className="infoBox",
),
html.Hr(),
]
sidebar_bottom = [
html.Div(
[
html.Div(
[
dbc.Label("# of Qubits (0-10)"),
dbc.Input(
type="number",
min=0,
max=10,
step=1,
value=DEFAULT_N_QUBITS,
id="main-qubits-input",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("# of Layers (0-10)"),
dbc.Input(
type="number",
min=0,
max=10,
step=1,
value=DEFAULT_N_LAYERS,
id="main-layers-input",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("Circuit Type"),
dbc.Select(
options=[
{
"label": fct.__name__.replace("_", " ").title(),
"value": fct.__name__,
}
for fct in Ansaetze.get_available()
],
placeholder=DEFAULT_ANSATZ,
required=True,
id="main-circuit-ident-select",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("Data-Reupload"),
dbc.Switch(
id="main-dru-switch",
value=DEFAULT_DATA_REUPLOAD,
className="fs-4",
),
],
),
# html.Div(
# [
# dbc.Label("Trainable Freqs."),
# dbc.Switch(id="switch-tffm", value=False),
# ],
# ),
html.Div(
[
dbc.Label("Seed"),
dbc.Input(
type="number",
min=100,
max=999,
step=1,
value=DEFAULT_SEED,
id="main-seed-input",
),
],
className="numeric-input",
),
],
className="preferencesBox",
),
html.Hr(),
html.Div(
[
dbc.Spinner(
[html.H6("", id="main-loading-state")],
color="primary",
type="grow",
id="main-loading-spinner",
)
],
className="spinnerBox",
),
]

content = html.Div(
[
Expand Down
29 changes: 14 additions & 15 deletions app/pages/1-training.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
from layouts.training_page_layout import layout # noqa
from layouts.training_page_layout import (
DEFAULT_N_STEPS,
DEFAULT_N_FREQS,
DEFAULT_STEPSIZE,
)
from layouts.app_page_layout import (
DEFAULT_N_QUBITS,
DEFAULT_N_LAYERS,
DEFAULT_SEED,
DEFAULT_DATA_REUPLOAD,
)
from utils.instructor import Instructor

import dash
import numpy as np
from dash import (
Expand All @@ -11,23 +25,8 @@

from typing import Dict, Any, List, Optional

from utils.instructor import Instructor

dash.register_page(__name__, name="Training")

from layouts.training_page_layout import layout # noqa
from layouts.training_page_layout import (
DEFAULT_N_STEPS,
DEFAULT_N_FREQS,
DEFAULT_STEPSIZE,
)
from layouts.app_page_layout import (
DEFAULT_N_QUBITS,
DEFAULT_N_LAYERS,
DEFAULT_SEED,
DEFAULT_DATA_REUPLOAD,
)


def reset_log() -> Dict[str, list]:
"""
Expand Down

0 comments on commit 0114839

Please sign in to comment.