Tagged Questions
1
vote
0answers
19 views
Calculating the mean across multiple files
I'm very new to Python and I have also searched a lot to find a question similar to mine. I would like to do something similar as explained in this question
Computing averages of records from multiple ...
1
vote
0answers
14 views
Creating many instances of a class / symbolic variable (Theano)
I have a class 'DeepNetwork' that is comprise of an equal number of 'ConnectionLayer' and 'NeuronLayer' objects, however the amount is variable. Each of those objects also needs a number of Theano ...
1
vote
1answer
33 views
How to get coordinates from a numpy slice object
I have a function which receives an image and a slice object specifying a sub region of that image to operate on. I would like to draw a box around the specified region for debugging purposes. The ...
0
votes
0answers
32 views
Minimize a function of many parameters in iminuit
I am trying to figure out how to extend this:
def f(x,y,z):
return (x-1.)**2 + (y-2*x)**2 + (z-3.*x)**2 -1.
to a variable "x" that is a numpy.array.
I would like to do something like this:
x ...
1
vote
0answers
23 views
Python Can you apply conditional formatting 2 or 3 scale colour to a pdf output
I would like to output a simple table to a pdf file with some conditional formatting of 2 or 3 -scale colouring of cells dependent on the value. Like the red-white-green colour scaling in ms excel ...
1
vote
1answer
19 views
numpy.searchsorted in a multidimensional array
I have got a three dimensional array with air pressure values in the form:
[[[1000 1010]
[1005 990]]
[[950 960]
[955 940]]
[[900 910]
[905 890]]]
The structure represents the pressure at ...
2
votes
2answers
39 views
Changing something from iterating over a numpy array to vectorization
I am trying to speed up the piece of code below by vectorization:
[rows,cols] = flow_direction_np.shape
elevation_gain = np.zeros((rows,cols), np.float)
for [i, j], flow in ...
1
vote
2answers
28 views
split array rows into columns from commas
I had a list consisted of 53 3D points, I converted the list into numpy array and I have a (53,) shape array. Each row is consisted of three float points separated by commas (e.g. ...
1
vote
1answer
24 views
Calculate Similarity of Sparse Matrix
I am using Python with numpy, scipy and scikit-learn module.
I'd like to classify the arrays in very big sparse matrix. (100,000 * 100,000)
The values in the matrix are equal to 0 or 1. The only ...
2
votes
1answer
38 views
Formatting numpy array and save to a *.txt
i want formatting a numpy array and save it in a *.txt file
The numpy array looks like this:
a = [ 0.1 0.2 0.3 0.4 ... ] , [ 1.1 1.2 1.3 1.4 ... ] , ...
and the output *.txt should ...
0
votes
1answer
17 views
variable number of numpy array for loop arguments required to match variable column numbers
I am populating a numpy array with a contents from a csv file. The number of columns in the CSV file may change. I am trying to concatenate the first two string columns (date + time) into a date ...
3
votes
1answer
43 views
wrapping around slices in Python / numpy
I have a numpy array, and I want to get the "neighbourhood" of the i'th point. Usually the arrays I'm using are two-dimensional, but the following 1D example illustrates what I'm looking for. If
A = ...
1
vote
1answer
25 views
Numpy set dtype=None, cannot splice columns and set dtype=object cannot set dtype.names
I am running Python 2.6. I have the following example where I am trying to concatenate the date and time string columns from a csv file. Based on the dtype I set (None vs object), I am seeing some ...
0
votes
2answers
38 views
NumPy load file interspersed with headers
I'm trying to parse files with repeating blocks of the following format:
ITEM: TIMESTEP
5000
ITEM: NUMBER OF ATOMS
4200
ITEM: BOX BOUNDS pp pp ff
0 47.6892
0 41.3
-11.434 84.1378
ITEM: ATOMS id type ...
1
vote
1answer
20 views
imread in pylab vs opencv: returning completely different array values
I'm getting behavior I don't quite understand:
In [1]: import cv2
In [2]: pylab_img=pylab.imread('lena.jpg')
In [3]: cv_img=cv2.imread('lena.jpg')
In [4]: pylab_img[200,200,:]
Out[4]: array([228, ...