Tagged Questions
0
votes
1answer
32 views
Round float to the nearest 2/100
I need to take a number like 0.405 and round it to 0.40 while also rounding 0.412 to 0.42. Is there any built in function to do this?
-1
votes
2answers
38 views
python subtraction of zero ranked arrays
I am attempting to subtract two zero ranked numpy arrays a and b.
I would like a-b to return an error when they are not of the same size.
For example, if shape(a)=[300,] and shape(b)=[450,];
a-b ...
0
votes
1answer
48 views
What is the best way to dynamically increase a numpy array in Python?
Say we have an incoming stream of data of size (1,N), it is a numpy array
read_data = [[foo, foo_1, foo_2]]
And we want to do something with that or simply append it to a larger array.
...
2
votes
2answers
39 views
NumPy random.shuffle function
I ran into something strange with numpy.random.shuffle function
from numpy import arange
from numpy.random import shuffle
a = arange(5)
b = a
c = a[:]
shuffle(c)
a and b all changes with c. ...
1
vote
1answer
26 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 ...
6
votes
2answers
36 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 ...
2
votes
1answer
31 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 = ...
6
votes
3answers
90 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
38 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 ...
3
votes
3answers
89 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
30 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
43 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 ...
4
votes
1answer
35 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 ...
2
votes
1answer
42 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
34 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 ...