-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Description
I am using Xubuntu Linux 16.04 (python and numpy versions are included below). Running the following code:
import numpy as np
import sys
print('python:', sys.version)
print('numpy:', np.version.version)
b = np.array([1, 1, 1, 1, 1], dtype=float)
b_neg = (b < 0)
## uncomment the next line and it might behave
# print(b)
#
b = np.negative(b, where=(b_neg))
print(b)
It will print varying, similar, incorrect outputs, two of which from my computer are:
$ python main.py
python: 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0]
numpy: 1.14.0
[0.00000000e+000 4.64016820e-310 5.08395840e-299 1.93322822e-260
2.37151510e-322]
$ python main.py
python: 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0]
numpy: 1.14.0
[0.00000000e+000 4.65820516e-310 5.08395840e-299 1.93322822e-260
2.37151510e-322]
Uncommenting print(b) as noted in the code above fixes the problem in at least one version of python:
$ python main.py
python: 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0]
numpy: 1.14.0
[1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1.]
Other versions are still behaving strangely (even with the print(b) line uncommented):
$ python main.py
('python:', '2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]')
('numpy:', '1.10.4')
[ 1. 1. 1. 1. 1.]
[ 0. 0. 0. 0. 0.]
$ python3 main.py
python: 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609]
numpy: 1.11.0
[ 1. 1. 1. 1. 1.]
[ 0. 0. 0. 0. 0.]
After updating to the latest version, it is still occurring:
With print(b) commented out:
$ python main.py
python: 3.6.5 |Anaconda custom (64-bit)| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0]
numpy: 1.14.2
[ 4.68703220e-310 -8.44120994e-121 6.90939306e-310 6.90938300e-310
5.34349229e+009]
With print(b) uncommented:
$ python main.py
python: 3.6.5 |Anaconda custom (64-bit)| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0]
numpy: 1.14.2
[1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1.]
Metadata
Metadata
Assignees
Labels
No labels