Esempio n. 1
0
Plotly
======

The plotly backend.
"""
# from ._presets import *
# from ._templates import *
# from ._user_customs import import_user_plots, import_user_presets, import_user_sessions, import_user_plugins
import os
from sisl._environ import register_environ_variable

try:
    _nprocs = len(os.sched_getaffinity(0))
except Exception:
    _nprocs = 1

register_environ_variable("SISL_VIZ_NUM_PROCS", min(1, _nprocs),
                          description="Maximum number of processors used for parallel plotting",
                          process=int)

from .plot import Plot, Animation, MultiplePlot, SubPlots
from .plots import *
from .session import Session
from .sessions import *
from .plotutils import load
from ._plotables import register_plotable
from ._plotables_register import *

from .backends import load_backends
load_backends()
Esempio n. 2
0
import os
from pathlib import Path
import sys
import importlib

from sisl._environ import register_environ_variable, get_environ_variable

__all__ = [
    "import_user_presets", "import_user_plots", "import_user_sessions",
    "import_user_plugins"
]

# Define the folder where the user will store their stuff
register_environ_variable(
    "SISL_USER",
    Path.home() / ".sisl",
    "Path to the directory where the user stores their custom scripts "
    "to extend sisl.",
    process=Path)
USER_CUSTOM_FOLDER = (get_environ_variable("SISL_USER") / "viz") / "plotly"

# Here we let python know that there are importable files
# in USER_CUSTOM_FOLDER
sys.path.append(str(USER_CUSTOM_FOLDER.resolve()))


def import_user_extension(extension_file):
    """
    Basis for importing users extensions.

    Parameters
    ------------
Esempio n. 3
0
                                depth,
                                case_insensitive=True)

        if sile_files:
            files[rule.cls] = sile_files

    return files


#-------------------------------------
#         Multiprocessing
#-------------------------------------

register_environ_variable(
    "SISL_NPROCS_VIZ",
    max(os.cpu_count() - 1, 1),
    description="Maximum number of processors used for parallel plotting",
    process=int)
_MAX_NPROCS = get_environ_variable("SISL_NPROCS_VIZ")


def _apply_method(args_tuple):
    """ Apply a method to an object. This function is meant for multiprocessing """

    method, obj, args, kwargs = args_tuple

    if args is None:
        args = []

    method(obj, *args, **kwargs)
Esempio n. 4
0
import logging
import sys

from sisl._environ import register_environ_variable, get_environ_variable

from . import api

SESSION = None

SERVER_HOST = None
SERVER_PORT = None

# Register the environment variables that the user can tweak
register_environ_variable(
    "SISL_PLOTLY_API_HOST",
    "localhost",
    "The host where the GUI will run when self-hosted by the user.",
    process=str)
register_environ_variable(
    "SISL_PLOTLY_API_PORT",
    4000,
    "The port where the GUI will run when self-hosted by the user.",
    process=int)


def set_session(new_session, ret_old=False):
    """
    Binds a new session to the GUI.

    The old session is unbound from the GUI. If you want to keep it, store
    it in a variable (or save it to disk with `save`)before setting the new session.