NumPy is a scientific and numerical computing extension to the Python programming language.

learn more… | top users | synonyms

0
votes
0answers
5 views

OpenCV TypeError: contour is not a numpy array, neither a scalar

I'm trying to use OpenCV to extract tags from Nike images. This is a tutorial code taken from: http://opencv-code.com/tutorials/ocr-ing-nikes-new-rsvp-program/ I've modified few lines of code though ...
4
votes
2answers
13 views

perform varimax rotation in python using numpy

I am working on principal component analysis of a matrix. I have already found the component matrix shown below A = np.array([[-0.73465832 -0.24819766 -0.32045055] [-0.3728976 ...
0
votes
1answer
15 views

numpy - multiply each element in array by a scaling factor

I have a numpy array of values, and a list of scaling factors which I want to scale each value in the array by, down each column values = [[ 0, 1, 2, 3 ], [ 1, 1, 4, 3 ], [ 2, 1, ...
0
votes
1answer
23 views

Exclude enpoints in uniform mesh

I would like to create a uniform 1D mesh with N points over an interval of reals (0, pi). Currently I have the following working code: import numpy as np u = np.linspace(0, np.pi, N+1, endpoint = ...
5
votes
2answers
53 views

Non-trivial sums of outer products without temporaries in numpy

The actual problem I wish to solve is, given a set of N unit vectors and another set of M vectors calculate for each of the unit vectors the average of the absolute value of the dot product of it with ...
3
votes
1answer
34 views

NaNs in pandas.DataFrame not printing to Excel

I have a pandas.DataFrame which contains numpy.nan floats. When using the Excel writer however, the fields where there should be numpy.nan floats are blank. I would expected at least a string ...
2
votes
2answers
16 views

numpy convert row vector to column vector

matrix1 = np.array([[1,2,3],[4,5,6]]) vector1 = matrix1[:,0] # this should have shape (2,1) but actually has (2,) matrix2 = np.array([[2,3],[5,6]]) np.hstack((vector1, matrix2)) ValueError: all the ...
2
votes
4answers
77 views

Python Sigma Sums

I have a list of values x=[1,-1,-1,1,1,-1,1,-1,1,-1] and I have another blank list y=[ ] I am trying to create a function that will take a sigma sum of values in x and store them in y. For ...
0
votes
2answers
28 views

numpy's loadtxt gives error converting to int when string contains decimal

I'm having trouble trying to load a txt file into a structured array. Here's a simple example showing the problem. This works fine: import numpy as np from StringIO import StringIO in1 = ...
0
votes
2answers
38 views

Find all the missing directed edges in an adjacency matrix

I use a numpy matrix to represent a directed graph, like this: 0 0 0 1 0 1 1 0 0 Given such a matrix, I want to find all the missing directed edges for which there exists a directed edge in ...
3
votes
4answers
33 views

How do I combine two numpy arrays element wise in python?

I have two numpy arrays: A = np.array([1, 3, 5, 7]) B = np.array([2, 4, 6, 8]) and I want to get the following from combining the two: C = [1, 2, 3, 4, 5, 6, 7, 8] I'm able to get something ...
3
votes
1answer
31 views

Read a 3d Array from File

Lets say I have a file with the following values: 1 2 3 4 11 12 13 14 and I want to read them as a numpy 2x2x2 array. The standard command np.loadtxt('testfile') reads them in as lots of vectors ...
1
vote
1answer
40 views

Taking up too much memory - python

I wrote a recursive function that exhaustively generates matrices of certain characteristics. The function is as such: def heavies(rowSums,colSums,colIndex,matH): if colIndex == len(colSums) - 1: ...
1
vote
1answer
33 views

Polynomial fitting problems in numpy

I was trying to implement a standard polynomial fitting program, and came across a problem that I could not understand. Here is the code where I have a sample x and y data, which I fit using the ...
3
votes
1answer
26 views

How to invert numpy.roll?

I have a for-loop that repeatedly calls roll and I want to invert the order of the created arrays. I think I have overlooked some trivial way to do it, but so far I only have found 10000 3 5 ways not ...

1 2 3 4 5 424
15 30 50 per page