def test_creation_softbounds(): """Test Number - correct initilization""" value = [-42.0, 0] softbounds = [-100, 100] num_a = param.Range(value=value, softbounds=softbounds) assert num_a.value == value assert num_a.softbounds == softbounds
def test_creation_bounds_not_inclusive_upper(): """Test Number - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = [-42, 120] __ = param.Range(value=value, hardbounds=[-42, 100], inclusive_bounds=[True, False])
def test_creation_softbounds_tuple(): """Test Number - correct initilization""" value = [-42.0, 150] softbounds = (-100, 100) num_a = param.Range(value=value, softbounds=softbounds) assert num_a.value == value assert num_a.softbounds == list(softbounds)
def test_getitem(): value = [0.0, 100.0] num_a = param.Range(value=value) assert num_a.value == value assert num_a[0] == value[0] assert num_a[1] == value[1]
def test_creation_set_hardbounds_get_hardbounds(): """Test Number - correct initilization""" value = [99, 0] hardbounds = [-100, 100] num_a = param.Range(value=value, hardbounds=hardbounds) assert num_a.get_soft_bounds() == hardbounds
def test_creation_hardbounds(): """Test Number - correct initilization""" value = [-100, 50] hardbounds = [-100, 100] num_a = param.Range(value=value, hardbounds=hardbounds) assert num_a.value == value assert num_a.hardbounds == hardbounds
def test_creation_doc(): """Test Number - correct initilization""" value = [0.0, 100.0] doc = "I am a range" num_a = param.Range(value=value, doc=doc) assert num_a.value == value assert num_a.doc == doc
def test_creation_set_softbounds_get_softbounds(): """Test Number - correct initilization""" value = [42.01, 999] softbounds = [-100, 100] num_a = param.Range(value=value, softbounds=softbounds) assert num_a.softbounds == softbounds assert num_a.get_soft_bounds() == softbounds
def test_creation_hardbounds_autobound(): """Test Number - correct initilization""" value = [-150.0, 999] hardbounds = [-100, 100] num_a = param.Range(value=value, hardbounds=hardbounds, auto_bound=True) assert num_a.value == [-100, 100]
def test_creation_hardbounds_inclusive(): """Test Number - correct initilization""" value = [-42, 100] hardbounds = [-42, 100] num_a = param.Range(value=value, hardbounds=hardbounds, inclusive_bounds=[True, True]) assert num_a.value == value assert num_a.hardbounds == hardbounds
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])
def test_kind(): """Test Number - correct initilization""" value = [11.01474, 0] num_a = param.Range(value=value) assert num_a.kind == "Range"
def test_getitem_none(): with pytest.raises(ValueError) as __: value = None num_a = param.Range(value=value) assert num_a.value == value num_a[0]
def test_creation_outside_bounds_upper(): """Test Number - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = [42, -41] __ = param.Range(value=value, hardbounds=[0, 41])
def test_creation_float(): """Test Number - correct initilization""" value = [0.0, 100.0] num_a = param.Range(value=value) assert num_a.value == value
def test_allow_none(): """Test Number - correct initilization""" value = None num_a = param.Range(value=value, allow_None=True) assert num_a.value == value
def test_creation_float_not_range(): """Test Number - throw error due to incorrect initilization""" with pytest.raises(TypeError) as __: value = 1412.0 __ = param.Range(value=value, allow_None=False)
def test_creation_nohardbounds_autobound(): """Test Number - correct initilization""" value = [0, 42] num_a = param.Range(value=value, auto_bound=True) assert num_a.value == value
def test_creation_list(): """Test Number - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = list() __ = param.Range(value=value)
def test_creation_too_many(): """Test Number - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = [0, 100, 150] __ = param.Range(value=value)
def test_creation_all_numeric(): """Test Number - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = [0, None] __ = param.Range(value=value, allow_None=True)
def test_creation_set_none_get_none(): """Test Number - correct initilization""" value = [11.01474, 4] num_a = param.Range(value=value) assert num_a.get_soft_bounds() == [None, None]