How to ignore all numpy warnings (not recommended)?
1 | # Suicide mode on |
An equivalent way, with a context manager:
1 | with np.errstate(divide='ignore'): |
Is the following expressions true?
1 | np.sqrt(-1) == np.emath.sqrt(-1) |
How to get the dates of yesterday, today and tomorrow?
1 | yesterday = np.datetime64('today', 'D') - np.timedelta64(1, 'D') |
How to get all the dates corresponding to the month of July 2016?
1 | Z = np.arange('2016-07', '2016-08', dtype='datetime64[D]') |
How to compute ((A+B)*(-A/2)) in place (without copy)?
1 | A = np.ones(3)*1 |
Extract the integer part of a random array using 5 different methods
1 | Z = np.random.uniform(0,10,10) |
Create a 5x5 matrix with row values ranging from 0 to 4
1 | Z = np.zeros((5,5)) |
Consider a generator function that generates 10 integers and use it to build an array
1 | def generate(): |
Create a vector of size 10 with values ranging from 0 to 1, both excluded
1 | Z = np.linspace(0,1,11,endpoint=False)[1:] |
Create a random vector of size 10 and sort it
1 | Z = np.random.random(10) |