コード例 #1
0
    def test_gt():
        """Test Integer - correct operation"""
        value = 42
        num_a = param.Integer(value=value)
        assert num_a.value == value

        assert num_a.value > 1
コード例 #2
0
 def test_creation_softbounds():
     """Test Integer - correct initilization"""
     value = -42
     softbounds = [-100, 100]
     num_a = param.Integer(value=value, softbounds=softbounds)
     assert num_a.value == value
     assert num_a.softbounds == softbounds
コード例 #3
0
 def test_creation_bounds_not_inclusive():
     """Test Integer - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = -42
         __ = param.Integer(value=value,
                            hardbounds=[-42, 100],
                            inclusive_bounds=[False, False])
コード例 #4
0
    def test_creation_set_hardbounds_get_hardbounds():
        """Test Integer - correct initilization"""
        value = 99
        hardbounds = [-100, 100]

        num_a = param.Integer(value=value, hardbounds=hardbounds)
        assert num_a.get_soft_bounds() == hardbounds
コード例 #5
0
    def test_creation_doc():
        """Test Integer - correct initilization"""
        value = 42
        doc = "I am an int"

        num_a = param.Integer(value=value, doc=doc)
        assert num_a.value == value
        assert num_a.doc == doc
コード例 #6
0
    def test_mod_float():
        """Test Integer - incorrect operation"""
        with pytest.raises(ValueError) as __:
            value = 42
            num_a = param.Integer(value=value)
            assert num_a.value == value

            num_a.value %= 1.5
コード例 #7
0
    def test_creation_hardbounds():
        """Test Integer - correct initilization"""
        value = -42
        hardbounds = [-100, 100]

        num_a = param.Integer(value=value, hardbounds=hardbounds)
        assert num_a.value == value
        assert num_a.hardbounds == hardbounds
コード例 #8
0
    def test_mod():
        """Test Integer - correct operation"""
        value = 42
        num_a = param.Integer(value=value)
        assert num_a.value == value

        new_value = value % 2
        num_a.value %= 2
        assert num_a.value == new_value
コード例 #9
0
    def test_floordiv():
        """Test Integer - correct operation"""
        value = 42
        num_a = param.Integer(value=value)
        assert num_a.value == value

        new_value = value // 2
        num_a.value //= 2
        assert num_a.value == new_value
コード例 #10
0
    def test_sub():
        """Test Integer - correct operation"""
        value = 42
        num_a = param.Integer(value=value)
        assert num_a.value == value

        new_value = value - 1
        num_a.value -= 1
        assert num_a.value == new_value
コード例 #11
0
    def test_lshift():
        """Test Integer - correct operation"""
        value = 42
        num_a = param.Integer(value=value)
        assert num_a.value == value

        new_value = operator.lshift(value, 1)
        num_a.value <<= 1
        assert num_a.value == new_value
コード例 #12
0
    def test_creation_hardbounds_autobound():
        """Test Integer - correct initilization"""
        value = -150
        hardbounds = [-100, 100]

        num_a = param.Integer(value=value,
                              hardbounds=hardbounds,
                              auto_bound=True)
        assert num_a.value == -100
コード例 #13
0
    def test_creation_hardbounds_inclusive():
        """Test Integer - correct initilization"""
        value = -42
        hardbounds = [-42, 100]

        num_a = param.Integer(value=value,
                              hardbounds=hardbounds,
                              inclusive_bounds=[True, True])
        assert num_a.value == value
        assert num_a.hardbounds == hardbounds
コード例 #14
0
 def __init__(self):
     param.ParameterStore.__init__(self)
     self.param_int = param.Integer(value=666)
     self.param_num = param.Number(value=42.0)
     self.param_color = param.Color(value="#FFF000")
     self.param_choice = param.Choice(value="boo", choices=["boo", "baa"])
     self.param_str = param.String("hello", doc="Old doc")
     self.param_regex = param.String(value="127.0.0.1", regex=ip_regex)
     self.param_bool = param.Boolean(False)
     self.param_option = param.Option(value=None, choices=[True, False])
     self.param_range = param.Range(value=[-100, 100],
                                    hardbounds=[-200, None])
     self.param_list = param.List(value=[1, 2, 3], hardbounds=[0, 10])
コード例 #15
0
 def __init__(self):
     param.ParameterStore.__init__(self)
     self.param_int = param.Integer(value=666, saveable=False)
コード例 #16
0
 def __init__(self):
     param.ParameterStore.__init__(self)
     self.param_int = param.Integer(value=42)
コード例 #17
0
 def test_creation_set_none_get_none():
     """Test Integer - correct initilization"""
     value = 11
     num_a = param.Integer(value=value)
     assert num_a.get_soft_bounds() == [None, None]
コード例 #18
0
 def __init__(self):
     param.ParameterStore.__init__(self)
     self.const_int = param.Integer(value=666, constant=True)
コード例 #19
0
    def test_creation_int():
        """Test Integer - correct initilization"""
        value = 1

        num_a = param.Integer(value=value)
        assert num_a.value == value
コード例 #20
0
 def test_creation_outside_bounds():
     """Test Integer - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = 42
         __ = param.Integer(value=value, hardbounds=[0, 41])
コード例 #21
0
 def test_creation_notallow_none():
     """Test Integer - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = None
         __ = param.Integer(value=value, allow_None=False)
コード例 #22
0
 def test_allow_none():
     """Test Integer - correct initilization"""
     value = None
     num_a = param.Integer(value=value, allow_None=True)
     assert num_a.value == value
コード例 #23
0
 def test_pos():
     """Test Integer - correct operation"""
     value = -42
     num_a = param.Integer(value=value)
     assert +num_a.value == +value
コード例 #24
0
 def test_creation_list():
     """Test Integer - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = list()
         __ = param.Integer(value=value)
コード例 #25
0
 def test_neg():
     """Test Integer - correct operation"""
     value = -42
     num_a = param.Integer(value=value)
     assert -num_a.value == -value
コード例 #26
0
 def test_abs():
     """Test Integer - correct operation"""
     value = -42
     num_a = param.Integer(value=value)
     assert abs(num_a.value) == abs(value)
コード例 #27
0
 def test_creation_incorrect_softbounds_count():
     """Test Integer - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = 1
         __ = param.Integer(value=value, softbounds=[0, 10, 20])
コード例 #28
0
 def test_creation_incorrect_change_hardbounds():
     """Test Integer - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = 1
         int_a = param.Integer(value=value, hardbounds=[0, 10])
         int_a.hardbounds = [0, 10, 20]
コード例 #29
0
    def test_kind():
        """Test Integer - correct initilization"""
        value = 11
        num_a = param.Integer(value=value)

        assert num_a.kind == "Integer"