@@ -46,20 +46,29 @@ def test_check_dist_params_lognormal():
4646 assert dists ._check_dist_params_lognormal ([0 , 0 ])[0 ] # edge case
4747
4848
49- def test_check_dist_params_uniform ():
50- """Test lognormal dist param checker"""
51- assert not dists ._check_dist_params_uniform ([])[0 ]
52- assert not dists ._check_dist_params_uniform (())[0 ]
53-
54- assert not dists ._check_dist_params_uniform ([0 ])[0 ]
55- assert not dists ._check_dist_params_uniform ([0 , 0 , 0 ])[0 ]
49+ def test_parse_and_validate_uniform_params ():
50+ """Test uniform distribution parameter validation"""
51+ # Test wrong number of parameters
52+ with pytest .raises (ValueError , match = "requires exactly 2 parameters" ):
53+ dists .parse_and_validate_uniform_params ([])
54+ with pytest .raises (ValueError , match = "requires exactly 2 parameters" ):
55+ dists .parse_and_validate_uniform_params (())
56+ with pytest .raises (ValueError , match = "requires exactly 2 parameters" ):
57+ dists .parse_and_validate_uniform_params ([0 ])
58+ with pytest .raises (ValueError , match = "requires exactly 2 parameters" ):
59+ dists .parse_and_validate_uniform_params ([0 , 0 , 0 ])
5660
57- assert not dists ._check_dist_params_uniform (["mean" , "mu" ])[0 ]
61+ # Test non-numeric parameters
62+ with pytest .raises (ValueError , match = "must be convertible to numbers" ):
63+ dists .parse_and_validate_uniform_params (["mean" , "mu" ])
5864
59- assert dists ._check_dist_params_uniform ([0 , 1 ])[0 ]
60- assert not dists ._check_dist_params_uniform ([0 , - 1 ])[0 ]
65+ # Test invalid parameter ordering
66+ with pytest .raises (ValueError , match = "must satisfy low <= high" ):
67+ dists .parse_and_validate_uniform_params ([0 , - 1 ])
6168
62- assert dists ._check_dist_params_uniform ([0 , 0 ])[0 ] # edge case
69+ # Test valid parameters
70+ assert dists .parse_and_validate_uniform_params ([0 , 1 ]) == (0.0 , 1.0 )
71+ assert dists .parse_and_validate_uniform_params ([0 , 0 ]) == (0.0 , 0.0 ) # edge case
6372
6473
6574def test_validate_triangular_params ():
@@ -188,20 +197,17 @@ def test_draw_values_uniform():
188197 assert all (isinstance (value , numbers .Number ) for value in values )
189198 assert all (10 <= value <= 100 for value in values )
190199
200+ # Updated to match new error messages
191201 with pytest .raises (
192202 ValueError ,
193- match = "Uniform distribution must have 2 parameters, but had 3 parameters. " ,
203+ match = "requires exactly 2 parameters, got 3 " ,
194204 ):
195205 values = dists .draw_values_uniform ([10 , 50 , 100 ], 10 , rng )
196206
197- with pytest .raises (
198- ValueError , match = "Uniform distribution must have dist_param2 >= dist_param1"
199- ):
207+ with pytest .raises (ValueError , match = "must satisfy low <= high" ):
200208 values = dists .draw_values_uniform ([50 , 10 ], 10 , rng )
201209
202- with pytest .raises (
203- ValueError , match = "Parameters for uniform distribution must be numbers."
204- ):
210+ with pytest .raises (ValueError , match = "must be convertible to numbers" ):
205211 values = dists .draw_values_uniform (["a" , 10 ], 10 , rng )
206212
207213 with pytest .raises (ValueError , match = "numreal must be a positive integer" ):
0 commit comments