diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-12-10 19:12:41 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-12-10 19:12:41 +0000 |
commit | 794a6c4511ced84c74bc8f2dd8cd8f277925a6ac (patch) | |
tree | 406d57b79c829f4ec2f3f7dfc5d28c5b7fa6daca /doc/release | |
parent | 8d24b14a7eed3fba60bab462e873214cc9fa2a1f (diff) | |
download | numpy-794a6c4511ced84c74bc8f2dd8cd8f277925a6ac.tar.gz |
ENH: emit ComplexWarning when casting complex to real (addresses #1319)
Casting complex numbers to real discards the imaginary part, which may
be unexpected. For safety, emit a warning when this occurs.
Diffstat (limited to 'doc/release')
-rw-r--r-- | doc/release/1.5.0-notes.rst | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/release/1.5.0-notes.rst b/doc/release/1.5.0-notes.rst index 7a22620c8..42254b789 100644 --- a/doc/release/1.5.0-notes.rst +++ b/doc/release/1.5.0-notes.rst @@ -2,7 +2,36 @@ NumPy 1.5.0 Release Notes ========================= + +Plans +===== + This release has the following aims: * Python 3 compatibility * :pep:`3118` compatibility + + +Highlights +========== + + +New features +============ + +Warning on casting complex to real +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Numpy now emits a `numpy.ComplexWarning` when a complex number is cast +into a real number. For example: + + >>> x = np.array([1,2,3]) + >>> x[:2] = np.array([1+2j, 1-2j]) + ComplexWarning: Casting complex values to real discards the imaginary part + +The cast indeed discards the imaginary part, and this may not be the +intended behavior in all cases, hence the warning. This warning can be +turned off in the standard way: + + >>> import warnings + >>> warnings.simplefilter("ignore", np.ComplexWarning) |