Python traitlets.Unicode() Examples

The following are 6 code examples of traitlets.Unicode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module traitlets , or try the search function .
Example #1
Source File: read.py    From ditto with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def parse_feeder_metadata(self, model):
        PowerSources = self.filter_edges_by_class("substation")

        for node1, node2 in PowerSources:
            print(self.nxGraph[node1][node2])
            Source = PowerSource(model)
            Source.name = self.nxGraph[node1][node2]["name"]
            Source.connecting_element = node1
            Source.nominal_voltage = (
                1.732 * float(self.nxGraph[node1][node2]["kv"]) * 1000
            )
            Source.operating_voltage = float(self.nxGraph[node1][node2]["Vpu"])
            Source.substation = True
            Source.transformer = False
            Source.is_sourcebus = True
            Source.connection_type = (
                "Y" if self.nxGraph[node1][node2]["conn"] == "W" else "D"
            )
            # Source.phases = [Unicode(default_value=x) for x in self.nxGraph[node1][node2]['phases']]

        print("Feeder") 
Example #2
Source File: test_interaction.py    From pySINDy with MIT License 5 votes vote down vote up
def test_get_interact_value():
    from ipywidgets.widgets import ValueWidget
    from traitlets import Unicode
    class TheAnswer(ValueWidget):
        _model_name = Unicode('TheAnswer')
        description = Unicode()
        def get_interact_value(self):
            return 42
    w = TheAnswer()
    c = interactive(lambda v: v, v=w)
    c.update()
    nt.assert_equal(c.result, 42) 
Example #3
Source File: utils.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
def make_layout(layout=None, **kwargs):
    from ipywidgets import Layout
    import traitlets

    if layout is None:
        layout = Layout()
    for key, val in kwargs.items():
        # note that this is the type of the class descriptor, not the instance attribute
        if isinstance(getattr(Layout, key), traitlets.Unicode):
            val = in_pixels(val)
        setattr(layout, key, val)
    return layout 
Example #4
Source File: ros3d.py    From jupyter-ros with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _quick_widget(package_name, version, has_view=True):
    def quick_widget_decorator(cls):
        from traitlets import Unicode
        name = cls.__name__
        if name.endswith('Model'):
            name = name[:-5]

        cls._model_name = Unicode(name + 'Model').tag(sync=True)
        cls._model_name.class_init(cls, '_model_name')

        cls._model_module = Unicode(package_name).tag(sync=True)
        cls._model_module.class_init(cls, '_model_module')

        cls._model_module_version = Unicode(version).tag(sync=True)
        cls._model_module_version.class_init(cls, '_model_module_version')

        if has_view:
            cls._view_module = Unicode(package_name).tag(sync=True)
            cls._view_module.class_init(cls, '_view_module')

            cls._view_module_version = Unicode(version).tag(sync=True)
            cls._view_module_version.class_init(cls, '_view_module_version')

            cls._view_name = Unicode(name + 'View').tag(sync=True)
            cls._view_name.class_init(cls, '_view_name')

        cls = widgets.register(cls)
        return cls

    return quick_widget_decorator 
Example #5
Source File: widget_link.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, **kwargs):
        super(WidgetTraitTuple, self).__init__(Instance(Widget), Unicode(), **kwargs) 
Example #6
Source File: widget_link.py    From pySINDy with MIT License 4 votes vote down vote up
def __init__(self, **kwargs):
        super(WidgetTraitTuple, self).__init__(Instance(Widget), Unicode(), **kwargs)