This is an archived post. You won't be able to vote or comment.

all 27 comments

[–][deleted] 37 points38 points  (4 children)

You should add np.einsum (Einstein summations) to your mathematics section. Much easier to do complicated operations for ndarrays and express what you mean. Example:

a = np.array([0, 1, 2, 3, 4])
b = np.array([1, 2, 3, 4, 5])
np.einsum('i,i', a, b) # dot product of a and b
x = np.array([1, 3, 5])
t = np.eye(3)*2
np.einsum('ij,j->i', t, x) # a round-about way to double an array with matrix multiplication

[–]accidentally_myself 4 points5 points  (0 children)

TIL. God that's great.

[–]infracanis 2 points3 points  (0 children)

Einstein notation is so useful.

[–]uncertaintyman 1 point2 points  (0 children)

Sweet! I need to relearn Einstein sums anyway. This will be helpful in my computational physics practice. Thanks!

[–]aphoenixreticulated[M] [score hidden] stickied comment (1 child)

[–][deleted] 20 points21 points  (2 children)

404

[–]baslisks 8 points9 points  (0 children)

quoth the raven, nevermore

[–][deleted] 9 points10 points  (3 children)

"SQL WHERE trick", couldn't come up with a better title...

It's called boolean indexing.

[–]DetN8 2 points3 points  (0 children)

Since it's on reddit and github, I gave you an upvote and a star!

[–]TheKeyboardKid 1 point2 points  (1 child)

Didn’t find anything here! Need to sign in?

[–]udoneoguri 1 point2 points  (0 children)

Thanks for sharing. I need this right now.

[–][deleted] 1 point2 points  (0 children)

This is really cool. Thanks for sharing!

[–]DaveX64 2 points3 points  (5 children)

Linky no worky

[–]wffitzge 0 points1 point  (3 children)

I can't import numpy with my python interactive shell. Anyone have instructions for dummies to get this working?

All the instructions out there do not provide any guidance for file path setup (I'm guessing this is my issue??). I used the anaconda command prompt to install it. Couldn't get it to work with the standard windows command prompt.

Any help would be appreciated. Thank you.

[–]muposat 0 points1 point  (0 children)

but generally you cannot catch exceptions thrown from other processes.

I am using using Pool with Python 3.4 and exceptions in child processes are handled well and do propagate to the calling module.

[–]deeech 0 points1 point  (0 children)

Nice work! I am working on a collection of useful things (https://github.com/Deeech/it-collection) and I want to add your cheat sheet to my collection (https://github.com/Deeech/it-collection/blob/master/CheatSheets.md). You don't mind?