diff options
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r-- | Lib/statistics.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py index 632127a..40c72db 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -335,10 +335,7 @@ class _nroot_NS: """Handle nth root of Reals, treated as a float.""" assert isinstance(n, int) and n > 1 if x < 0: - if n%2 == 0: - raise ValueError('domain error: even root of negative number') - else: - return -_nroot_NS.nroot(-x, n) + raise ValueError('domain error: root of negative number') elif x == 0: return math.copysign(0.0, x) elif x > 0: @@ -433,6 +430,8 @@ class _nroot_NS: else: # Preserve the input NAN. return x + if x < 0: + raise ValueError('domain error: root of negative number') if x.is_infinite(): return x # FIXME this hasn't had the extensive testing of the float |