Ejemplo n.º 1
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_num_bounds = param.Number(value=42.0,
                                          hardbounds=[None, 105])
     self.param_color = param.Color(value="#FFF000")
     self.param_choice = param.Choice(value="boo", choices=["boo", "baa"])
     self.param_str = param.String("hello")
     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])
Ejemplo n.º 2
0
    def test_gt():
        """Test Number - correct initilization"""
        value = 42.01
        num_a = param.Number(value=value)
        assert num_a.value == value

        assert num_a.value > 1
Ejemplo n.º 3
0
 def test_creation_softbounds():
     """Test Number - correct initilization"""
     value = -42.0
     softbounds = [-100, 100]
     num_a = param.Number(value=value, softbounds=softbounds)
     assert num_a.value == value
     assert num_a.softbounds == softbounds
Ejemplo n.º 4
0
    def test_creation_hardbounds_autobound():
        """Test Number - correct initilization"""
        value = -150.0
        hardbounds = [-100, 100]

        num_a = param.Number(value=value, hardbounds=hardbounds, auto_bound=True)
        assert num_a.value == -100
Ejemplo n.º 5
0
 def test_creation_softbounds_tuple():
     """Test Number - correct initilization"""
     value = -42.0
     softbounds = (-100, 100)
     num_a = param.Number(value=value, softbounds=softbounds)
     assert num_a.value == value
     assert num_a.softbounds == list(softbounds)
Ejemplo n.º 6
0
    def test_creation_set_hardbounds_get_hardbounds():
        """Test Number - correct initilization"""
        value = 99
        hardbounds = [-100, 100]

        num_a = param.Number(value=value, hardbounds=hardbounds)
        assert num_a.get_soft_bounds() == hardbounds
Ejemplo n.º 7
0
    def test_creation_hardbounds():
        """Test Number - correct initilization"""
        value = -42.0
        hardbounds = [-100, 100]

        num_a = param.Number(value=value, hardbounds=hardbounds)
        assert num_a.value == value
        assert num_a.hardbounds == hardbounds
Ejemplo n.º 8
0
    def test_creation_hardbounds_inclusive():
        """Test Number - correct initilization"""
        value = -42
        hardbounds = [-42, 100]

        num_a = param.Number(value=value, hardbounds=hardbounds, inclusive_bounds=[True, True])
        assert num_a.value == value
        assert num_a.hardbounds == hardbounds
Ejemplo n.º 9
0
    def test_creation_doc():
        """Test Number - correct initilization"""
        value = 42.01
        doc = "I am a float"

        num_a = param.Number(value=value, doc=doc)
        assert num_a.value == value
        assert num_a.doc == doc
Ejemplo n.º 10
0
    def test_creation_set_softbounds_get_softbounds():
        """Test Number - correct initilization"""
        value = 42.01
        softbounds = [-100, 100]

        num_a = param.Number(value=value, softbounds=softbounds)
        assert num_a.softbounds == softbounds
        assert num_a.get_soft_bounds() == softbounds
Ejemplo n.º 11
0
    def test_sub():
        """Test Number - correct initilization"""
        value = 42.01
        num_a = param.Number(value=value)
        assert num_a.value == value

        new_value = value - 1
        num_a.value -= 1
        assert num_a.value == new_value
Ejemplo n.º 12
0
    def test_lshift():
        """Test Number - correct initilization"""
        value = 42
        num_a = param.Number(value=value)
        assert num_a.value == value

        new_value = operator.lshift(value, 1)
        num_a.value <<= 1
        assert num_a.value == new_value
Ejemplo n.º 13
0
    def test_mod():
        """Test Number - correct initilization"""
        value = 42.01
        num_a = param.Number(value=value)
        assert num_a.value == value

        new_value = value % 2
        num_a.value %= 2
        assert num_a.value == new_value
Ejemplo n.º 14
0
    def test_floordiv():
        """Test Number - correct initilization"""
        value = 42.01
        num_a = param.Number(value=value)
        assert num_a.value == value

        new_value = value // 2
        num_a.value //= 2
        assert num_a.value == new_value
Ejemplo n.º 15
0
 def test_allow_none():
     """Test Number - correct initilization"""
     value = None
     num_a = param.Number(value=value, allow_None=True)
     assert num_a.value == value
Ejemplo n.º 16
0
    def test_creation_nohardbounds_autobound():
        """Test Number - correct initilization"""
        value = -150.0

        num_a = param.Number(value=value, auto_bound=True)
        assert num_a.value == value
Ejemplo n.º 17
0
 def test_creation_notallow_none():
     """Test Number - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = None
         __ = param.Number(value=value, allow_None=False)
Ejemplo n.º 18
0
 def test_pos():
     """Test Number - correct initilization"""
     value = -42.01
     num_a = param.Number(value=value)
     assert +num_a.value == +value
Ejemplo n.º 19
0
    def test_creation_float():
        """Test Number - correct initilization"""
        value = 1.0

        num_a = param.Number(value=value)
        assert num_a.value == value
Ejemplo n.º 20
0
 def test_creation_set_none_get_none():
     """Test Number - correct initilization"""
     value = 11.01474
     num_a = param.Number(value=value)
     assert num_a.get_soft_bounds() == [None, None]
Ejemplo n.º 21
0
 def test_creation_bounds_not_inclusive_upper():
     """Test Number - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = 120
         __ = param.Number(value=value, hardbounds=[-42, 100], inclusive_bounds=[False, False])
Ejemplo n.º 22
0
 def test_abs():
     """Test Number - correct initilization"""
     value = -42.01
     num_a = param.Number(value=value)
     assert abs(num_a.value) == abs(value)
Ejemplo n.º 23
0
 def test_creation_outside_bounds_upper():
     """Test Number - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = 42
         __ = param.Number(value=value, hardbounds=[0, 41])
Ejemplo n.º 24
0
 def test_neg():
     """Test Number - correct initilization"""
     value = -42.01
     num_a = param.Number(value=value)
     assert -num_a.value == -value
Ejemplo n.º 25
0
    def test_kind():
        """Test Number - correct initilization"""
        value = 11.01474
        num_a = param.Number(value=value)

        assert num_a.kind == "Number"
Ejemplo n.º 26
0
 def test_creation_list():
     """Test Number - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = list()
         __ = param.Number(value=value)