Python traitlets.Int() Examples
The following are 8
code examples of traitlets.Int().
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: test_dbus_utils.py From uchroma with GNU Lesser General Public License v3.0 | 5 votes |
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)'
Example #2
Source File: test_traits.py From pySINDy with MIT License | 5 votes |
def test_typed_tuple_uninitialized_ints(): class TestCase(HasTraits): value = TypedTuple(trait=Int()) obj = TestCase() assert obj.value == ()
Example #3
Source File: test_traits.py From pySINDy with MIT License | 5 votes |
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)
Example #4
Source File: test_traits.py From pySINDy with MIT License | 5 votes |
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)
Example #5
Source File: test_traits.py From pySINDy with MIT License | 5 votes |
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
Example #6
Source File: test_traits.py From pySINDy with MIT License | 5 votes |
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')
Example #7
Source File: test_set_state.py From pySINDy with MIT License | 5 votes |
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 ))
Example #8
Source File: test_traits.py From ctapipe with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)