Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1235594

Browse filesBrowse files
authored
fix fmean/fsum ValueError and test_inv_cdf
1 parent bbd8fb2 commit 1235594
Copy full SHA for 1235594

File tree

Expand file treeCollapse file tree

2 files changed

+5
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-9
lines changed

‎Lib/test/test_statistics.py

Copy file name to clipboardExpand all lines: Lib/test/test_statistics.py
+1-8Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,8 +1950,6 @@ def test_error_cases(self):
19501950
with self.assertRaises(TypeError):
19511951
fmean([10, 20, 60], 70) # too many arguments
19521952

1953-
# TODO: RUSTPYTHON
1954-
@unittest.expectedFailure
19551953
def test_special_values(self):
19561954
# Rules for special values are inherited from math.fsum()
19571955
fmean = statistics.fmean
@@ -2913,12 +2911,7 @@ def setUp(self):
29132911

29142912
def tearDown(self):
29152913
sys.modules['statistics'] = statistics
2916-
2917-
# TODO: RUSTPYTHON, ValueError: math domain error
2918-
@unittest.expectedFailure
2919-
def test_inv_cdf(self): # TODO: RUSTPYTHON, remove when this passes
2920-
super().test_inv_cdf() # TODO: RUSTPYTHON, remove when this passes
2921-
2914+
29222915

29232916
@unittest.skipUnless(c_statistics, 'requires _statistics')
29242917
class TestNormalDistC(unittest.TestCase, TestNormalDist):

‎stdlib/src/math.rs

Copy file name to clipboardExpand all lines: stdlib/src/math.rs
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ mod math {
211211
#[pyfunction]
212212
fn sqrt(value: ArgIntoFloat, vm: &VirtualMachine) -> PyResult<f64> {
213213
let value = *value;
214+
if value.is_nan() {
215+
return Ok(value);
216+
}
214217
if value.is_sign_negative() {
215218
return Err(vm.new_value_error("math domain error".to_owned()));
216219
}
@@ -664,7 +667,7 @@ mod math {
664667
}
665668
if special_sum != 0.0 {
666669
return if inf_sum.is_nan() {
667-
Err(vm.new_overflow_error("-inf + inf in fsum".to_owned()))
670+
Err(vm.new_value_error("-inf + inf in fsum".to_owned()))
668671
} else {
669672
Ok(special_sum)
670673
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.