コード例 #1
0
def get_instructions():
    return html.Ul(children=[
        html.Li("An App that provides suggestions for relocation in Finland"),
        html.Li("Fill the form below and click 'Recommend'"),
        html.Li("Alternatively, click on one area")
    ],
                   className="instructions_sidebar")
コード例 #2
0
 def make_nav(self, current_path, **kwargs):
     nav_items = []
     route_prefix = server.config["ROUTES_PATHNAME_PREFIX"]
     for i, (path, text) in enumerate(self.nav_items):
         href = get_url(path)
         active = (current_path
                   == href) or (i == 0 and current_path == route_prefix)
         nav_item = dbc.NavItem(dbc.NavLink(text, href=href, active=active))
         nav_items.append(nav_item)
     return html.Ul(nav_items, className="navbar-nav", **kwargs)
コード例 #3
0
ファイル: functions.py プロジェクト: AlexMV12/TIMEX
def characteristics_list(
        model_characteristics: dict,
        testing_performances: [ValidationPerformance]) -> html.Div:
    """
    Create and return an HTML Div which contains a list of natural language characteristic
    relative to a prediction model.

    Parameters
    ----------
    model_characteristics : dict
        key-value for each characteristic to write in natural language.

    testing_performances : [ValidationPerformance]
        Useful to write also information about the testing performances.

    Returns
    -------
    html.Div()
    """
    def get_text_char(key: str, value: any) -> str:
        value = str(value)
        switcher = {
            "name":
            _("Model type: ") + value,
            "test_values":
            _('Values used for testing: last ') + value + _(' values'),
            "delta_training_percentage":
            _('The length of the training windows is the ') + value + "%" +
            _(' of the length of the time series.'),
            "delta_training_values":
            _('Training windows are composed of ') + value + _(' values.'),
            "extra_regressors":
            _("The model has used ") + value +
            _(" as extra-regressor(s) to improve the training."),
            "transformation":
            _('The model has used a ') + value +
            _(' transformation on the input data.') if value != "none " else
            _('The model has not used any pre/post transformation on input data.'
              )
        }
        return switcher.get(key, "Invalid choice!")

    elems = [
        html.Div(_('Model characteristics:')),
        html.Ul([
            html.Li(get_text_char(key, model_characteristics[key]))
            for key in model_characteristics
        ]),
        html.Div(
            _("This model, using the best training window, reaches these performances:"
              )),
        show_errors(testing_performances[0])
    ]

    return html.Div(elems)
コード例 #4
0
def make_header(**kwargs):
    return dbc.Navbar(
        id="header",
        className="sticky-top",
        color="dark",
        dark=True,
        children=[
            make_brand(),
            html.Ul(id=server.config["NAVBAR_CONTAINER_ID"],
                    className="navbar-nav ml-auto"),
        ],
        **kwargs,
    )
コード例 #5
0
ファイル: header.py プロジェクト: Dave-Skinner/tav-dash
def getHeader(active):
    header_logo = html.Div([html.A(className="header__logo", href='/')])
    header_items = [
        html.Li(dcc.Link("Team", href="/team", className="header__link"),
                className="header__item {0}".format("is-active" if active ==
                                                    "team" else "")),
        html.Li(dcc.Link("Players", href="/players", className="header__link"),
                className="header__item {0}".format("is-active" if active ==
                                                    "players" else "")),
    ]
    header_list = html.Ul(header_items, className="header__list")

    return html.Div([
        header_logo,
        header_list,
    ], className="header t-sans")
コード例 #6
0
ファイル: layouts.py プロジェクト: munrojm/crystaltoolkit
def get_breadcrumb(parts):

    if not parts:
        return html.Div()

    breadcrumbs = html.Nav(
        html.Ul([
            html.Li(
                dcc.Link(name, href=link),
                className=(None if idx != len(parts) - 1 else "is-active"),
            ) for idx, (name, link) in enumerate(parts.items())
        ]),
        className="breadcrumb",
    )

    return breadcrumbs
コード例 #7
0
def update_entity_div(active_cell):
    if len(filtered_df.columns) == 0:
        return 'Click on a tweet to find the entities'
    else:
        txt = filtered_df['tweet_text'][active_cell['row']]
        txt = txt.replace('@', '')
        txt = txt.replace('#', '')
        txt = re.sub('https\S+', '', txt)
        nlp = spacy.load('en_core_web_sm')
        doc = nlp(txt)
        entlist = []
        for ent in doc.ents:
            entity = ''
            entity = entity + ent.text + '-' + ent.label_
            entlist.append(entity)
        if len(entlist) == 0:
            return 'No Entities present'
        else:
            return html.Ul([html.Li(i) for i in entlist])
コード例 #8
0
ファイル: components.py プロジェクト: mlco2/codecarbon
 def get_references():
     return html.Div([
         html.Br(),
         html.Br(),
         html.H2("References "),
         html.Ul([
             html.Li(
                 html.A(
                     "Energy Usage Reports: Environmental awareness as part of algorithmic accountability",
                     href="https://arxiv.org/pdf/1911.08354.pdf",
                 )),
             html.Li(
                 html.A(
                     "Quantifying the Carbon Emissions of Machine Learning",
                     href="https://arxiv.org/pdf/1910.09700.pdf",
                 )),
         ]),
         html.Br(),
         html.Br(),
     ])
コード例 #9
0
ファイル: functions.py プロジェクト: AlexMV12/TIMEX
def show_errors(testing_performances: ValidationPerformance) -> html.Ul:
    """
    Create an HTML list with each error-metric in `testing_performances`.

    Parameters
    ----------
    testing_performances : ValidationPerformance
        Error metrics to show.

    Returns
    -------
    html.Ul
        HTML list with all the error-metrics.
    """
    import math

    def round_n(n: float):
        dec_part, int_part = math.modf(n)

        if abs(int_part) > 1:
            return str(round(n, 3))
        else:
            return format(n, '.3g')

    def get_text_perf(key: str, value: any) -> str:
        switcher = {
            "MAE": "MAE: " + round_n(value),
            "RMSE": "RMSE: " + round_n(value),
            "MSE": "MSE: " + round_n(value),
            "AM": _('Arithmetic mean of errors:') + round_n(value),
            "SD": _('Standard deviation of errors: ') + round_n(value)
        }
        return switcher.get(key, "Invalid choice!")

    testing_performances = testing_performances.get_dict()
    del testing_performances["first_used_index"]

    return html.Ul([
        html.Li(get_text_perf(key, testing_performances[key]))
        for key in testing_performances
    ])
コード例 #10
0
    html.H2('AntdTabPane(children, id, className, style, *args, **kwargs)',
            style={
                'borderLeft': '4px solid grey',
                'padding': '3px 0 3px 10px',
                'backgroundColor': '#f5f5f5'
            }),
    html.Span('主要参数说明:',
              id='主要参数说明',
              style={
                  'borderLeft': '4px solid grey',
                  'padding': '3px 0 3px 10px',
                  'backgroundColor': '#f5f5f5',
                  'fontWeight': 'bold',
                  'fontSize': '1.2rem'
              }),
    fmc.FefferyMarkdown(
        markdownStr=open('documents/AntdTabPane.md', encoding='utf-8').read()),
    html.Ul([
        html.Li(fac.AntdParagraph([
            fac.AntdText('有关'),
            fac.AntdText('AntdTabPane', strong=True),
            fac.AntdText('的使用示例请移步'),
            fac.AntdText('AntdTabs', strong=True),
            fac.AntdText('对应的文档'),
        ],
                                  style={'paddingTop': '20px'}),
                style={'listStyleType': 'circle'})
    ]),
    html.Div(style={'height': '100px'})
])
コード例 #11
0
ファイル: app_home.py プロジェクト: ltalirz/sycofinder
                           href='https://youtu.be/i8i4HmEEw4Y',
                           target='_blank')),
            ],
                     className="info-container"),
            html.H2("Steps"),
            html.Div(html.Ol([
                html.Li(html.A('Compute diverse set', href='maxdiv/')),
                html.Li(
                    html.A('Genetic Algorithm: compute next generation',
                           href='ga/')),
                html.Li(html.A('Determine importance of variables',
                               href='ml/')),
            ]),
                     className="sycolinks"),
            html.H2("Changelog"),
            html.Ul([
                html.Li([html.B(k + " "), html.Span(v)]) for k, v in changelog
            ], ),
            html.P([
                "Find the code ",
                html.A("on github",
                       href="https://github.com/ltalirz/sycofinder",
                       target='_blank'), "."
            ]),
        ],
        id="container",
        # tag for iframe resizer
        **{'data-iframe-height': ''},
    )
]
コード例 #12
0
    def init_app_layout(
        self,
        update_interval_seconds=3,
        max_monitors=10,
        dashboard_layouts=[],
        network_stylesheet=[],
        hide_default_edge=True,
        **kwargs,
    ):
        """
        Initialises the overall dash app "layout" which has two sub-pages (Agent network and ML experiment)

        Parameters
        ----------
        update_interval_seconds : float or int
            Auto refresh rate which the app queries the states of Agent Network to update the graphs and display

        max_monitors : int
            Due to complexity in managing and instantiating dynamic figures, a maximum number of monitors is specified first and only the
            each Monitor Agent will occupy one of these figures. It is not ideal, but will undergo changes for the better.

        Returns
        -------
        app : Dash app object
        """
        app = dash.Dash(
            __name__,
            external_stylesheets=self.external_stylesheets,
            external_scripts=self.external_scripts,
        )
        app.network_stylesheet = network_stylesheet
        app.update_interval_seconds = update_interval_seconds
        app.num_monitors = max_monitors
        app.hide_default_edge = hide_default_edge

        for key in kwargs.keys():
            setattr(app, key, kwargs[key])

        # initialise dashboard layout objects
        self.dashboard_layouts = [
            dashboard_layout(app) for dashboard_layout in dashboard_layouts
        ]

        app.layout = html.Div(children=[
            # header
            html.Nav(
                [
                    html.Div(
                        [
                            html.A(
                                "Met4FoF Agent Testbed",
                                className="brand-logo center",
                            ),
                            html.Ul([],
                                    className="right hide-on-med-and-down"),
                        ],
                        className="nav-wrapper container",
                    )
                ],
                className="light-blue lighten-1",
            ),
            dcc.Tabs(
                id="main-tabs",
                value="agt-net",
                children=[
                    dashboard_layout.dcc_tab
                    for dashboard_layout in self.dashboard_layouts
                ],
            ),
            html.Div(
                id="page-div",
                children=[
                    dashboard_layout.get_layout()
                    for dashboard_layout in self.dashboard_layouts
                ],
            ),
        ])

        for dashboard_layout in self.dashboard_layouts:
            dashboard_layout.prepare_callbacks(app)

        @app.callback(
            [dash.dependencies.Output("page-div", "children")],
            [dash.dependencies.Input("main-tabs", "value")],
        )
        def render_content(tab):
            for dashboard_layout in self.dashboard_layouts:
                if dashboard_layout.id == tab:
                    return [dashboard_layout.get_layout()]

        return app
コード例 #13
0
ファイル: process.py プロジェクト: modelica/fmu-check
def process_fmu(fmu_filename):

    basename, _ = os.path.splitext(fmu_filename)
    pickle_filename = basename + '.p'
    fmu_hash = os.path.basename(basename)

    try:
        model_description = read_model_description(fmu_filename,
                                                   validate=False)
    except Exception as e:
        alert = dbc.Alert([
            html.I(className='fas fa-times me-3'),
            f"Failed to read model description. {e}"
        ],
                          id='alert',
                          color='danger',
                          className='mt-3')
        with open(pickle_filename, 'wb') as f:
            pickle.dump([alert], f)
        return

    platforms = supported_platforms(fmu_filename)

    with zipfile.ZipFile(fmu_filename, 'r') as zf:
        nl = filter(lambda n: not n.endswith('/'), zf.namelist())

    fmi_types = []

    if model_description.modelExchange:
        fmi_types.append('Model Exchange')

    if model_description.coSimulation:
        fmi_types.append('Co-Simulation')

    def na(attr):
        value = getattr(model_description, attr)
        if value:
            return value
        else:
            return html.Span('n/a', className='text-muted')

    rows = [
        dbc.Row([
            dbc.Col(html.Span("FMI Version"), width=4),
            dbc.Col(html.Span(model_description.fmiVersion), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col("FMI Type", width=4),
            dbc.Col(', '.join(fmi_types), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col("Model Name", width=4),
            dbc.Col(model_description.modelName, width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col("Platforms", width=4),
            dbc.Col(', '.join(platforms), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Continuous States"), width=4),
            dbc.Col(html.Span(model_description.numberOfContinuousStates),
                    width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Event Indicators"), width=4),
            dbc.Col(html.Span(model_description.numberOfEventIndicators),
                    width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Model Variables"), width=4),
            dbc.Col(html.Span(len(model_description.modelVariables)), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Generation Date"), width=4),
            dbc.Col(na('generationDateAndTime'), width=8)
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Generation Tool"), width=4),
            dbc.Col(na('generationTool'), width=8)
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Description"), width=4),
            dbc.Col(na('description'), width=8)
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("SHA256"), width=4),
            dbc.Col(html.Span(fmu_hash), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("File Size"), width=4),
            dbc.Col(html.Span(f'{os.path.getsize(fmu_filename)} bytes'),
                    width=8),
        ],
                className='py-1'),
    ]

    try:
        problems = validate_fmu(fmu_filename)
    except Exception as e:
        problems = [str(e)]

    if problems:
        alert = dbc.Alert([
            html.P([
                html.I(className='fas fa-exclamation-circle me-3'),
                f"Validation failed. {len(problems)} {'problem was' if len(problems) == 1 else 'problems were'} found:"
            ]),
            html.Ul([html.Li(problem) for problem in problems])
        ],
                          id='alert',
                          color='danger',
                          className='mt-3')
    else:
        alert = dbc.Alert([
            html.I(className='fas fa-check me-3'),
            "Validation passed. No problems found."
        ],
                          id='alert',
                          color='success',
                          className='mt-3')

    variables = []

    table_header = [
        html.Thead(
            html.Tr([
                html.Th("Type"),
                html.Th("Name"),
                html.Th("Causality"),
                html.Th("Start", className='text-right'),
                html.Th("Unit"),
                html.Th("Description")
            ]))
    ]

    for variable in model_description.modelVariables:

        unit = variable.unit

        if unit is None and variable.declaredType is not None:
            unit = variable.declaredType.unit

        if variable.type == 'Boolean':
            color = '#c900c9'
        elif variable.type == 'Binary':
            color = '#ab0000'
        elif variable.type.startswith(('Int', 'Enum')):
            color = '#c78f00'
        elif variable.type.startswith(('Real', 'Float')):
            color = '#0000bf'
        else:  # String
            color = '#00a608'

        variables.append(
            html.Tr([
                html.Td(
                    html.Small(variable.type,
                               style={
                                   'color': color,
                                   'border': '1px solid ' + color,
                                   'border-radius': '1em',
                                   'padding': '0 0.5em 0 0.5em',
                               })),
                html.Td(variable.name),
                # html.Td(variable.variability),
                html.Td(variable.causality),
                html.Td(variable.start, className='text-right'),
                html.Td(unit),
                html.Td(variable.description, className='text-muted')
            ]))

    table = dbc.Table(table_header + [html.Tbody(variables)],
                      borderless=True,
                      size='sm')

    tabs = dbc.Tabs([
        dbc.Tab(rows, label="Model Info", className='p-4'),
        dbc.Tab(table, label="Variables", className='p-4'),
        dbc.Tab(html.Pre('\n'.join(nl)), label="Files", className='p-4'),
    ],
                    id='tabs')

    with open(pickle_filename, 'wb') as f:
        pickle.dump([alert, tabs], f)
コード例 #14
0
 ],
          style={
              'display': 'flex',
              'justifyContent': 'center',
              'alignItems': 'center'
          }),
 fac.AntdDivider(),
 fac.AntdParagraph([
     fac.AntdText('🤩', style={'fontSize': '26px'}),
     fac.AntdText('特性', strong=True, style={'fontSize': '26px'}),
 ],
                   id='特性'),
 html.Ul([
     html.Li('🎁 功能丰富,在antd的基础上设计出更多增广功能',
             style={'listStyleType': 'circle'}),
     html.Li('😋 使用简单,开发者上手难度低,无需javascript代码即可实现复杂交互',
             style={'listStyleType': 'circle'}),
     html.Li('💎 文档详实,针对每个组件的主要功能及用法予以丰富案例介绍',
             style={'listStyleType': 'circle'})
 ]),
 fac.AntdParagraph([
     fac.AntdText('🛫', style={'fontSize': '26px'}),
     fac.AntdText('版本', strong=True, style={'fontSize': '26px'}),
 ],
                   id='版本'),
 html.Ul([
     html.Li(fac.AntdParagraph([
         fac.AntdText('pypi最新稳定版本:'),
         fac.AntdTag(content=fac.__version__),
         html.Img(
             src=
             'https://img.shields.io/pypi/v/feffery-antd-components.svg?color=dark-green',
コード例 #15
0
from ts_app.dash_app import app
from ts_app.file_upload import process_upload

input_layout = html.Div(
    [
        dcc.Upload(
            id="file-upload",
            accept=".csv,.xls,.xlsx",
            className="file-upload",
            children=[
                "Click or Drag and Drop",
                html.P("Expected file properties:"),
                html.Ul(
                    children=[
                        html.Li("At most 7MiB"),
                        html.Li("Dates in first column"),
                        html.Li("Numeric data in right-most column"),
                        html.Li("At least 32 rows"),
                    ]
                ),
            ],
            min_size=32,
            max_size=1024**2 * 7,  # 7MiB
        ),
        html.P(id="file-info"),
    ]
)


@app.callback(
    [
        Output("file-info", "children"),
コード例 #16
0
    "width": "16rem",
    "padding": "2rem 1rem",
    "background-color": "#f8f9fa",
}
sidebar = html.Div(
    [
        html.H2("GINAN", className="display-4"),
        html.P("EDA (MongoDB) ", className="lead"),
        html.Hr(),
        html.P(f"{db.MONGO_URL} / {db.MONGO_DB}", className="lead", id="db-info-side"),
        # dcc.NavLink("Change it", href="/dbselect", id="page-dbselect-link"),
        # html.P(f"{PEA_DB_NAME}", className="lead"),
        html.Hr(),
        html.Ul(children=[html.Li(dcc.Link("Db Info",           href="/dbinfo", id="page-dbinfo-link")),
                          html.Li(dcc.Link("States",           href="/states", id="page-states-link")),
                          html.Li(dcc.Link("Measurements",     href="/measurements", id="page-measurements-link")),
                          html.Li(dcc.Link("Measurements Polar",     href="/measurements-polar", id="page-measurements-polar-link"))
                          ]),
    ],
    style=SIDEBAR_STYLE,
)
content = html.Div(id='page-content', children=[], style=CONTENT_STYLE)

app.layout = html.Div([dcc.Location(id='url', refresh=False), sidebar, content ])

@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/measurements':
        return meas.layout()
    if pathname == '/states':
コード例 #17
0
         "What is being checked?"
     ],
            id="what-is-validated-link",
            style={
                'color': '#007bff',
                'cursor': 'pointer'
            })),
 dbc.Collapse([
     html.
     P("FMU Check performs a static analysis of the FMU that validates the following aspects:"
       ),
     html.Ul([
         html.
         Li("validity of the modelDescription.xml w.r.t. the XML schema"
            ),
         html.Li("uniqueness and validity of the variable names"),
         html.Li("completeness and integrity of the Model Structure"),
         html.Li("availability of the required start values"),
         html.Li("combinations of causality and variability"),
         html.Li("definition of units"),
     ]),
     html.P("It does not check the following aspects:"),
     html.Ul([
         html.Li("validity of the binaries"),
         html.Li("validity of the sources"),
         html.Li("any non-standard files inside the FMU"),
     ])
 ],
              id="what-is-validated-paragraph"),
 dbc.InputGroup([
     dbc.Input(id='fmu-input',
               placeholder="Select an FMU",