本文整理匯總了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