本文整理汇总了Python中traitlets.Unicode方法的典型用法代码示例。如果您正苦于以下问题:Python traitlets.Unicode方法的具体用法?Python traitlets.Unicode怎么用?Python traitlets.Unicode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类traitlets
的用法示例。
在下文中一共展示了traitlets.Unicode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_feeder_metadata
# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Unicode [as 别名]
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")
示例2: __init__
# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Unicode [as 别名]
def __init__(self, **kwargs):
super(WidgetTraitTuple, self).__init__(Instance(Widget), Unicode(), **kwargs)
示例3: test_get_interact_value
# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Unicode [as 别名]
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)
示例4: make_layout
# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Unicode [as 别名]
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
示例5: _quick_widget
# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Unicode [as 别名]
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