mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
fix fmean/fsum ValueError and test_inv_cdf
This commit is contained in:
9
Lib/test/test_statistics.py
vendored
9
Lib/test/test_statistics.py
vendored
@@ -1950,8 +1950,6 @@ class TestFMean(unittest.TestCase):
|
||||
with self.assertRaises(TypeError):
|
||||
fmean([10, 20, 60], 70) # too many arguments
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_special_values(self):
|
||||
# Rules for special values are inherited from math.fsum()
|
||||
fmean = statistics.fmean
|
||||
@@ -2913,12 +2911,7 @@ class TestNormalDistPython(unittest.TestCase, TestNormalDist):
|
||||
|
||||
def tearDown(self):
|
||||
sys.modules['statistics'] = statistics
|
||||
|
||||
# TODO: RUSTPYTHON, ValueError: math domain error
|
||||
@unittest.expectedFailure
|
||||
def test_inv_cdf(self): # TODO: RUSTPYTHON, remove when this passes
|
||||
super().test_inv_cdf() # TODO: RUSTPYTHON, remove when this passes
|
||||
|
||||
|
||||
|
||||
@unittest.skipUnless(c_statistics, 'requires _statistics')
|
||||
class TestNormalDistC(unittest.TestCase, TestNormalDist):
|
||||
|
||||
@@ -211,6 +211,9 @@ mod math {
|
||||
#[pyfunction]
|
||||
fn sqrt(value: ArgIntoFloat, vm: &VirtualMachine) -> PyResult<f64> {
|
||||
let value = *value;
|
||||
if value.is_nan() {
|
||||
return Ok(value);
|
||||
}
|
||||
if value.is_sign_negative() {
|
||||
return Err(vm.new_value_error("math domain error".to_owned()));
|
||||
}
|
||||
@@ -664,7 +667,7 @@ mod math {
|
||||
}
|
||||
if special_sum != 0.0 {
|
||||
return if inf_sum.is_nan() {
|
||||
Err(vm.new_overflow_error("-inf + inf in fsum".to_owned()))
|
||||
Err(vm.new_value_error("-inf + inf in fsum".to_owned()))
|
||||
} else {
|
||||
Ok(special_sum)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user