How do I install SciPy on my system?
Update 1: for the NumPy part (that SciPy depends on) there is actually an installer for 64 bit Windows: numpy-1.3.0.win-amd64-py2.6.msi (is direct download URL, 2310144 bytes).
Running the SciPy superpack installer results in this
message in a dialog box:
"Cannot install. Python version 2.6 require...
I have a problem installing Numpy and Scipy from
http://www.scipy.org/Installing%5FSciPy/Windows
I went to download page and downloaded .exe files for Python26. I have Python26 on my machine. After installation, I tried
>>> import nympy, scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No modu...
I am working with large matrixes, so I am using NumPy's memmap. However, I am getting an error as apparently the file descriptors used by memmap are not being closed.
import numpy
import tempfile
counter = 0
while True:
temp_fd, temporary_filename = tempfile.mkstemp(suffix='.memmap')
map = numpy.memmap(temporary_filename, dtype...
How can I check which version of Numpy I'm using? I'm using Mac OS X 10.6.1 Snow Leopard.
...
How can I update Numpy into the newest one? Should I download .dmg file from here:
http://sourceforge.net/projects/numpy/files/
This .dmg is only for 10.5? I installed numpy using these instructions:
http://www.scipy.org/Installing_SciPy/Mac_OS_X
My current Numpy is 1.2.1. I'm running on Mac OS X 10.6.1 Snow Leopard. Thanks!
...
I would like to provide "all" mathematical functions for the number-like objects created by a module (the uncertainties.py module, which performs calculations with error propagation)—these objects are numbers with uncertainties.
What is the best way to do this?
Currently, I redefine most of the functions from math in the module uncerta...
I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:
As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array be most efficiently built, row by...
Hi,
Can someone indicate what I am doing wrong here?
import numpy as np
a = np.array([1,2,3,4,5],dtype=int)
b = np.array(['a','b','c','d','e'],dtype='|S1')
np.savetxt('test.txt',zip(a,b),fmt="%i %s")
The output is:
Traceback (most recent call last):
File "loadtxt.py", line 6, in <module>
np.savetxt('test.txt',zip(a,b),fmt="%...
Hello,
Sometimes it is useful to "clone" a row or column vector to a matrix. By cloning I mean converting a row vector such as
[1,2,3]
Into a matrix
[[1,2,3]
[1,2,3]
[1,2,3]
]
or a column vector such as
[1
2
3
]
into
[[1,1,1]
[2,2,2]
[3,3,3]
]
In matlab or octave this is done pretty easily:
x = [1,2,3]
a = ones(3,1) ...
Given a list of tuples, where each tuple represents a row in a table, e.g.
tab = [('a',1),('b',2)]
Is there an easy way to convert this to a record array? I tried
np.recarray(tab,dtype=[('name',str),('value',int)])
which doesn't seem to work.
...
What am I missing:
In [66]: import numpy as np
In [67]: np.float(7.0 / 8)
Out[67]: 0.875 #OK
In [68]: np.float32(7.0 / 8)
Out[68]: 0.875 #OK
In [69]: np.float96(7.0 / 8)
Out[69]: -2.6815615859885194e+154 #WTF
In [70]: sys.version
Out[70]: '2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]'
Edit.
On cygwin the a...
If there is any possibility to make this code simpler, I'd really appreciate it! I am trying to get rid of rows with zeros. The first column is date. If all other columns are zero, they have to be deleted. Number of columns varies.
import numpy as np
condition = [ np.any( list(x)[1:] ) for x in r]
r = np.extract( condition, r )
nump...
I'm using a numpy object_ array to store variable length strings, e.g.
a = np.array(['hello','world','!'],dtype=np.object_)
Is there an easy way to find the length of the longest string in the array without looping over all elements?
...
Hi stack overflow, I have a problem with some numpy stuff. I need a numpy array to behave in an unusual manner by returning a slice as a view of the data I have sliced, not a copy. So heres an example of what I want to do:
Say we have a simple array like this:
a = array([1, 0, 0, 0])
I would like to update consecutive entries in the ...
I am getting recarray from matplotlib.mlab.csv2rec function. My expectation was it would have 2 dimensions like 'x', but it has 1 dimension like 'y'. Is there any way to get x from y?
>>> import numpy as np
>>> from datetime import date
>>> x=np.array([(date(2000,1,1),0,1),
... (date(2000,1,1),1,1),
... (date(...
Is there function to get an iterator over an arbitrary dimension of a numpy array?
Iterating over the first dimension is easy...
In [63]: c = numpy.arange(24).reshape(2,3,4)
In [64]: for r in c :
....: print r
....:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
[[12 13 14 15]
[16 17 18 19]
[20 21 22 23]]
But iterating o...
Is there an easy way to add a record/row to a numpy recarray without creating a new recarray? Let's say I have a recarray that takes 1Gb in memory, I want to be able to add a row to it without having python take up 2Gb of memory temporarily.
...
I have a simple numpy array, for every date there is a data point. Something like this:
>>> import numpy as np
>>> from datetime import date
>>> from datetime import date
>>> x = np.array( [(date(2008,3,5), 4800 ), (date(2008,3,15), 4000 ), (date(2008,3,
20), 3500 ), (date(2008,4,5), 3000 ) ] )
Is there easy way to extrapolate data po...
Hi,
I want to calculate a convex hull around a shape in a binary NxM matrix. The convex hull algorithm expects a list of coordinates, so I take numpy.argwhere(im) to have all shape point coordinates. However, most of those points are not contributing to the convex hull (they lie on the inside of the shape). Because convex hull computati...
Anyone ever come up to this problem? Let's say you have two arrays like the following
a = array([1,2,3,4,5,6])
b = array([1,4,5])
Is there a way to compare what elements in a exist in b? For example,
c = a == b # Wishful example here
print c
array([1,4,5])
# Or even better
array([True, False, False, True, True, False])
I'm trying t...