當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。