How to use the traitlets.Enum function in traitlets

To help you get started, we’ve selected a few traitlets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter / jupyter_kernel_test / jupyter_kernel_test / messagespec.py View on Github external
class IsCompleteReplyIncomplete(Reference):
    indent = Unicode()


# IOPub messages

class ExecuteInput(Reference):
    code = Unicode()
    execution_count = Integer()


Error = ExecuteReplyError


class Stream(Reference):
    name = Enum((u'stdout', u'stderr'))
    text = Unicode()


class DisplayData(MimeBundle):
    pass


class ExecuteResult(MimeBundle):
    execution_count = Integer()

class HistoryReply(Reference):
    history = List(List())

class ClearOutput(Reference):
    wait = Bool()
github creare-com / podpac / podpac / datalib / terraintiles.py View on Github external
----------
    zoom : int
        Zoom level of tiles. Defaults to 6.
    tile_format : str
        One of ['geotiff', 'terrarium', 'normal']. Defaults to 'geotiff'
        PODPAC node can only evaluate 'geotiff' formats.
        Other tile_formats can be specified for :meth:`download`
        No support for 'skadi' formats at this time.
    bucket : str
        Bucket of the terrain tiles.
        Defaults to 'elevation-tiles-prod'
    """

    # parameters
    zoom = tl.Int(default_value=6).tag(attr=True)
    tile_format = tl.Enum(["geotiff", "terrarium", "normal"], default_value="geotiff").tag(attr=True)
    bucket = tl.Unicode(default_value="elevation-tiles-prod").tag(attr=True)
    sources = None  # these are loaded as needed
    dims = ["lat", "lon"]
    anon = tl.Bool(True)

    def select_sources(self, coordinates):
        # get all the tile sources for the requested zoom level and coordinates
        sources = get_tile_urls(self.tile_format, self.zoom, coordinates)
        urls = ["s3://{}/{}".format(self.bucket, s) for s in sources]

        # create TerrainTilesSource classes for each url source
        self.sources = self._create_composite(urls)
        if self.trait_is_defined("interpolation") and self.interpolation is not None:
            for s in sources:
                if s.has_trait("interpolation"):
                    s.set_trait("interpolation", self.interpolation)
github jupyter / qtconsole / qtconsole / console_widget.py View on Github external
by the arrow keys, and from which you can select
                                completion by pressing Return.
                    'ncurses' : Show the completion as a text list which is navigable by
                                `tab` and arrow keys.
                    """
    )
    # NOTE: this value can only be specified during initialization.
    kind = Enum(['plain', 'rich'], default_value='plain', config=True,
        help="""
        The type of underlying text widget to use. Valid values are 'plain',
        which specifies a QPlainTextEdit, and 'rich', which specifies a
        QTextEdit.
        """
    )
    # NOTE: this value can only be specified during initialization.
    paging = Enum(['inside', 'hsplit', 'vsplit', 'custom', 'none'],
                  default_value='inside', config=True,
        help="""
        The type of paging to use. Valid values are:

        'inside'
           The widget pages like a traditional terminal.
        'hsplit'
           When paging is requested, the widget is split horizontally. The top
           pane contains the console, and the bottom pane contains the paged text.
        'vsplit'
           Similar to 'hsplit', except that a vertical splitter is used.
        'custom'
           No action is taken by the widget beyond emitting a
           'custom_page_requested(str)' signal.
        'none'
           The text is written directly to the console.
github bloomberg / bqplot / bqplot / marks.py View on Github external
curves_subset = List().tag(sync=True)
    line_style = Enum(['solid', 'dashed', 'dotted', 'dash_dotted'],
                      default_value='solid')\
        .tag(sync=True, display_name='Line style')
    interpolation = Enum(['linear', 'basis', 'basis-open',
                          'basis-closed', 'bundle',
                          'cardinal', 'cardinal-open',
                          'cardinal-closed', 'monotone', 'step-before',
                          'step-after'],
                         default_value='linear')\
        .tag(sync=True, display_name='Interpolation')
    close_path = Bool().tag(sync=True, display_name='Close path')
    fill = Enum(['none', 'bottom', 'top', 'inside', 'between'],
                default_value='none')\
        .tag(sync=True, display_name='Fill')
    marker = Enum(['circle', 'cross', 'diamond', 'square', 'triangle-down',
                   'triangle-up', 'arrow', 'rectangle', 'ellipse'],
                  default_value=None, allow_none=True)\
        .tag(sync=True, display_name='Marker')
    marker_size = Int(64).tag(sync=True, display_name='Default size')

    opacities = List().tag(sync=True, display_name='Opacity')
    fill_opacities = List().tag(sync=True, display_name='Fill Opacity')
    _view_name = Unicode('Lines').tag(sync=True)
    _model_name = Unicode('LinesModel').tag(sync=True)


@register_mark('bqplot.FlexLine')
class FlexLine(Mark):

    """Flexible Lines mark.
github microsoft / jupyter-Kqlmagic / azure / Kqlmagic / kql_magic.py View on Github external
from .results import ResultSet

kql_core_obj = None

@magics_class
class Kqlmagic(Magics, Configurable):

    auto_limit = Int(
        default_value=0, 
        config=True, 
        allow_none=True, 
        help="""Automatically limit the size of the returned result sets.\n
        Abbreviation: 'al'"""
    )

    prettytable_style = Enum(
        ["DEFAULT", "MSWORD_FRIENDLY", "PLAIN_COLUMNS", "RANDOM"],
        default_value="DEFAULT",
        config=True,
        help="""Set the table printing style to any of prettytable's defined styles.\n
        Abbreviation: 'ptst'"""
    )

    short_errors = Bool(
        default_value=True, 
        config=True, 
        help="""Don't display the full traceback on KQL Programming Error.\n
        Abbreviation: 'se'"""
    )

    display_limit = Int(
        default_value=None,
github martinRenou / Odysis / odysis / odysis.py View on Github external
if d.name == data_name:
                for c in d.components:
                    if c.name == component_name:
                        return (c.min, c.max)
        raise RuntimeError('Unknown component {}.{}'.format(
            data_name, component_name))


@register
class ColorMapping(PluginBlock):
    _view_name = Unicode('ColorMappingView').tag(sync=True)
    _model_name = Unicode('ColorMappingModel').tag(sync=True)

    _input_data_dim = Int(1)

    colormap = Enum(('viridis', 'plasma', 'magma', 'inferno'), default_value='viridis').tag(sync=True)
    colormap_min = Float().tag(sync=True)
    colormap_max = Float().tag(sync=True)

    def interact(self):
        if not self.initialized_widgets:
            self._init_colormapping_widgets()
            self.initialized_widgets = True

        return HBox(
            self._interact() + (VBox((self.colormap_wid, self.colormapslider_wid)), )
        )

    def __init__(self, *args, **kwargs):
        super(ColorMapping, self).__init__(*args, **kwargs)
        self.initialized_widgets = False
        self.colormap_wid = None
github creare-com / podpac / podpac / core / coordinates / coordinates1d.py View on Github external
See Also
    --------
    :class:`ArrayCoordinates1d`, :class:`UniformCoordinates1d`
    """

    #:str: Dimension name, one of 'lat', 'lon', 'time', or 'alt'.
    name = tl.Enum(['lat', 'lon', 'time', 'alt'], allow_none=True)

    #: Units : Coordinate units.
    units = tl.Instance(Units, allow_none=True)

    #: str : Coordinate reference system.
    coord_ref_sys = tl.Enum(['WGS84', 'SPHER_MERC'], allow_none=True)

    #: str : Coordinates type, one of 'point', 'left', 'right', or 'midpoint'.
    ctype = tl.Enum(['point', 'left', 'right', 'midpoint'])

    #: : *To be replaced.*
    extents = tl.Instance(np.ndarray, allow_none=True, default_value=None)

    #: bool : Are the coordinate values unique and sorted.
    is_monotonic = tl.CBool(allow_none=True, readonly=True)
    
    #: bool : Are the coordinate values sorted in descending order.
    is_descending = tl.CBool(allow_none=True, readonly=True)

    #: bool : Are the coordinate values uniformly-spaced.
    is_uniform = tl.CBool(allow_none=True, readonly=True)

    def __init__(self, name=None, ctype=None, units=None, extents=None, coord_ref_sys=None, **kwargs):
        """*Do not use.*"""

github pylada / pylada-light / espresso / pwscf_namelists.py View on Github external
raise error.ValueError("ecutwfc has not been set. It is a required parameter")


class Electrons(Namelist):
    """ Electrons namelist """
    electron_maxstep = Integer(default_value=None, allow_none=True,
                               help="Maximum number of scf iterations")
    itermax = alias(electron_maxstep)
    conv_thr = Float(allow_none=True, default_value=None,
                     help="Convergence criteria for self consistency")
    mixing_ndim = Integer(allow_none=True, default_value=None, min=0,
                          help="Number of iterations used in mixing")
    mixing_mode = Enum(['plain', 'TF', 'local-TF'], allow_none=True, default_value=None,
                       help="Mixing mode")
    mixing_beta = Float(allow_none=True, default_value=None, help="Mixing factor")
    diagonalization = Enum(['david', 'cg', 'cg-serial'], allow_none=True, default_value=None,
                           help="Diagonalization method")
    diago_cg_max_iter = Integer(allow_none=True, default_value=None, min=0,
                                help="Max number of iterations for CG diagonalization")
    diago_david_ndim = Integer(allow_none=True, default_value=None, min=2,
                               help="Dimension of workspace in David diagonalization")
    diago_full_acc = Bool(allow_none=True, default_value=None,
                          help="Whether to diagonalize empty-states at the same level"
                          "as occupied states")
    startingpot = CaselessStringEnum(['file', 'atomic'], default_value=None, allow_none=True,
                                     help="Start from existing charge density file\n\n"
                                     "Generally, pylada will handle this value on its own."
                                     "Users are unlikely to need set it themselves.")
    startingwfc = CaselessStringEnum(['atomic', 'atomic+random', 'random', 'file'],
                                     default_value=None, allow_none=True,
                                     help="Start from existing charge density file\n\n"
                                     "When restarting/continuing a calculation, this parameter is "
github allenai / citeomatic / citeomatic / scripts / evaluate.py View on Github external
from citeomatic.common import DatasetPaths
from citeomatic.config import App
from traitlets import Int, Unicode, Enum

from citeomatic.corpus import Corpus
from citeomatic.neighbors import EmbeddingModel, ANN
from citeomatic.ranker import NoneRanker, Ranker
from citeomatic.serialization import model_from_directory
from citeomatic.training import eval_text_model, EVAL_DATASET_KEYS
import os


class Evaluate(App):
    dataset_type = Enum(('dblp', 'pubmed', 'oc'), default_value='pubmed')
    candidate_selector_type = Enum(('bm25', 'ann', 'oracle'), default_value='bm25')
    metric = Enum(('precision', 'recall', 'f1'), default_value='recall')
    split = Enum(('train', 'test', 'valid'), default_value='valid')

    # ann options
    paper_embedder_dir = Unicode(default_value=None, allow_none=True)

    # Candidate selector options
    num_candidates = Int(default_value=None, allow_none=True)

    ranker_type = Enum(('none', 'neural'), default_value='none')
    n_eval = Int(default_value=None, allow_none=True)

    # ranker options
    citation_ranker_dir = Unicode(default_value=None, allow_none=True)

    _embedder = None
    _ann = None
github creare-com / podpac / podpac / core / coordinates / array_coordinates1d.py View on Github external
See Also
    --------
    :class:`Coordinates1d`, :class:`UniformCoordinates1d`
    """

    #: array : User-defined coordinate values
    coords = tl.Instance(np.ndarray)

    #:str: Dimension name, one of 'lat', 'lon', 'time', or 'alt'.
    name = tl.Enum(['lat', 'lon', 'time', 'alt'], allow_none=True)

    #: Units : Coordinate units.
    units = tl.Instance(Units, allow_none=True)

    #: str : Coordinate reference system.
    coord_ref_sys = tl.Enum(['WGS84', 'SPHER_MERC'], allow_none=True)

    #: str : Coordinates type, on of 'point', 'left', 'right', or 'midpoint'.
    ctype = tl.Enum(['point', 'left', 'right', 'midpoint'])

    #: : *To be replaced.*
    extents = tl.Instance(np.ndarray, allow_none=True, default_value=None)

    #: bool : Are the coordinate values unique and sorted.
    is_monotonic = tl.CBool(allow_none=True, readonly=True)
    
    #: bool : Are the coordinate values sorted in descending order.
    is_descending = tl.CBool(allow_none=True, readonly=True)

    #: bool : Are the coordinate values uniformly-spaced.
    is_uniform = tl.CBool(allow_none=True, readonly=True)