Last active
July 29, 2016 08:19
-
-
Save gdementen/64cfa3eb5ca5aebd460fe338510c84c1 to your computer and use it in GitHub Desktop.
Strange sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> l = [4873.40374783, | |
5821.07686377, | |
5781.99852348, | |
5555.53769711, | |
0.0, | |
0.0, | |
0.0, | |
0.0] | |
>>> a = np.array(l) | |
>>> b = np.empty((8, 2)) | |
>>> b[:] = a[:, np.newaxis] | |
>>> b | |
array([[ 4873.40374783, 4873.40374783], | |
[ 5821.07686377, 5821.07686377], | |
[ 5781.99852348, 5781.99852348], | |
[ 5555.53769711, 5555.53769711], | |
[ 0. , 0. ], | |
[ 0. , 0. ], | |
[ 0. , 0. ], | |
[ 0. , 0. ]]) | |
>>> b.sum(0)[0] == b[:,0].sum() | |
False | |
>>> b.sum(0)[0] | |
22032.016832190002 | |
>>> b[:,0].sum() | |
22032.016832189998 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment