当前位置: 首页>>代码示例>>Python>>正文


Python traitlets.Int方法代码示例

本文整理汇总了Python中traitlets.Int方法的典型用法代码示例。如果您正苦于以下问题:Python traitlets.Int方法的具体用法?Python traitlets.Int怎么用?Python traitlets.Int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在traitlets的用法示例。


在下文中一共展示了traitlets.Int方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_special_types

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_special_types():
    obj, sig = dbus_prepare(Color.NewFromHtml('black'))
    assert obj == '#000000'
    assert sig == 's'

    obj, sig = dbus_prepare(Int(5))
    assert isinstance(obj, dict)
    assert sig == 'a{sv}'
    for value in obj.values():
        assert isinstance(value, GLib.Variant)

    obj, sig = dbus_prepare(EnumTest)
    assert isinstance(obj, tuple)
    assert sig == '(sss)' 
开发者ID:cyanogen,项目名称:uchroma,代码行数:16,代码来源:test_dbus_utils.py

示例2: test_typed_tuple_uninitialized_ints

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_typed_tuple_uninitialized_ints():
    class TestCase(HasTraits):
        value = TypedTuple(trait=Int())

    obj = TestCase()
    assert obj.value == () 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:8,代码来源:test_traits.py

示例3: test_typed_tuple_init_ints

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_typed_tuple_init_ints():
    class TestCase(HasTraits):
        value = TypedTuple(trait=Int())

    obj = TestCase(value=(1, 2, 3))
    assert obj.value == (1, 2, 3) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:8,代码来源:test_traits.py

示例4: test_typed_tuple_set_ints

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_typed_tuple_set_ints():
    class TestCase(HasTraits):
        value = TypedTuple(trait=Int())

    obj = TestCase()
    obj.value = (1, 2, 3)
    assert obj.value == (1, 2, 3) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:9,代码来源:test_traits.py

示例5: test_typed_tuple_bad_default

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_typed_tuple_bad_default():
    class TestCase(HasTraits):
        value = TypedTuple(trait=Int(), default_value=(1, 2, 'foobar'))


    with nt.assert_raises(TraitError):
        obj = TestCase()
        a = obj.value   # a read might be needed to trigger default validation 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:10,代码来源:test_traits.py

示例6: test_typed_tuple_bad_set

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_typed_tuple_bad_set():
    class TestCase(HasTraits):
        value = TypedTuple(trait=Int())

    obj = TestCase()
    with nt.assert_raises(TraitError):
        obj.value = (1, 2, 'foobar') 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:9,代码来源:test_traits.py

示例7: test_set_state_int_to_float

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_set_state_int_to_float():
    w = NumberWidget()

    # Set Int to float
    with nt.assert_raises(TraitError):
        w.set_state(dict(
            i = 3.5
        )) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:10,代码来源:test_set_state.py

示例8: test_has_traits

# 需要导入模块: import traitlets [as 别名]
# 或者: from traitlets import Int [as 别名]
def test_has_traits():
    """ test the has_traits func """

    class WithoutTraits(HasTraits):
        """ a traits class that has no traits """

        pass

    class WithATrait(HasTraits):
        """ a traits class that has a trait """

        my_trait = Int()

    assert not has_traits(WithoutTraits)
    assert has_traits(WithATrait) 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:17,代码来源:test_traits.py


注:本文中的traitlets.Int方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。