Posts

Showing posts with the label numpy

Installing matplotlib under Mountain Lion

Follow this steps in order: [carpincho@MacBook-2]$ pip install numpy [carpincho@MacBook-2]$ pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev [carpincho@MacBook-2]$ pip install git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev source and a link to an explanation why numpy and matplotlib can't be installed using pip straightforward

timeit example

An example of how to time a statement >>> import numpy as np >>> arr1 = np.random.randint(0,1600,(3000,3000)) >>> timeit arr1.argmin() 10 loops, best of 3: 34.2 ms per loop Tested under Mac Lion Os proc i7 and Python 2.7.1 r271:86832

Show all values in Numpy array

If an array is too large to be printed, (Scipy)NumPy automatically skips the central part of the array and only prints the corners: >>> print arange(10000) [ 0 1 2 ..., 9997 9998 9999] >>> >>> print arange(10000).reshape(100,100) [[ 0 1 2 ..., 97 98 99] [ 100 101 102 ..., 197 198 199] [ 200 201 202 ..., 297 298 299] ..., [9700 9701 9702 ..., 9797 9798 9799] [9800 9801 9802 ..., 9897 9898 9899] [9900 9901 9902 ..., 9997 9998 9999]] To disable this behaviour and force NumPy to print the entire array, you can change the printing options using set_printoptions . >>> set_printoptions(threshold='nan') from Numpy Tutorial