Right, I'm iterating through a large binary file
I need to minimise the time of this loop:
def NB2(self, ID_LEN):
r1=np.fromfile(ReadFile.fid,dTypes.NB_HDR,1)
num_receivers=r1[0][0]
num_channels=r1[0][1]
num_samples=r1[0][5]
blockReturn = np.zeros((num_samples,num_receivers,num_channels))
for rec in range(0,nu...
Imagine I have a .Net application that supports user extensions in the form of Python modules by embedding IronPython. Using Ironclad, I can allow users to make use of the NumPy and SciPy packages from within their modules. How good is the interop provided by Ironclad? My question is: can I use a NumPy array of type T provided by the use...
I'm looking to generate some statistics about a model I created in python. I'd like to generate the t-test on it, but was wondering if there was an easy way to do this with numpy/scipy. Are there any good explanations around?
For example, I have three related datasets that look like this:
[55.0, 55.0, 47.0, 47.0, 55.0, 55.0, 55.0, 6...
I'm trying to convert the following code to Python from MATLAB for an EEG Project (partly because Python's slightly cheaper!)
Hopefully someone can point me in the right direction: I've started to alter it but got bogged down: Particularly trying to find equivalent functions.
Tried scipy.org (NumPy_for_Matlab_Users etc.) but I'm not s...
has anyone used unladen-swallow with numpy/scipy for numeric/scientific applications? Is it significantly faster in your experience? Any opinions would be great.
...
Hi all,
I have two arrays, a1 and a2. Assume len(a2) >> len(a1), and that a1 is a subset of a2.
I would like a quick way to return the a2 indices of all elements in a1. The time-intensive way to do this is obviously:
from operator import indexOf
indices = []
for i in a1:
indices.append(indexOf(a2,i))
This of course takes a long...
In Numpy, ix_() is used to grab rows and columns of a matrix, but it doesn't seem to work with sparse matrices. For instance, this code works because it uses a dense matrix:
>>> import numpy as np
>>> x = np.mat([[1,0,3],[0,4,5],[7,8,0]])
>>> print x
[[1 0 3]
[0 4 5]
[7 8 0]]
>>> print x[np.ix_([0,2],[0,2])]
[[1 3]
[7 0]]
I used ix...
I believe I am having a memory issue using numpy arrays. The following code is being run for hours on end:
new_data = npy.array([new_x, new_y1, new_y2, new_y3])
private.data = npy.row_stack([private.data, new_data])
where new_x, new_y1, new_y2, new_y3 are floats.
After about 5 hours of recording this data every second (more t...
Okay, so basically lets say i have a matrix:
matrix([[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]])
Is it possible to get the area below the diagonal easily when working with numpy matrixs? I looked around and could not find anything. I can do the standard, for loo...
I'm creating a numpy array which is to be filled with objects of a particular class I've made. I'd like to initialize the array such that it will only ever contain objects of that class. For example, here's what I'd like to do, and what happens if I do it.
class Kernel:
pass
>>> L = np.empty(4,dtype=Kernel)
TypeError: data type n...
I'm trying to batch up a bunch of vertices and texture coords in an interleaved array before sending it to pyOpengl's glInterleavedArrays/glDrawArrays. The only problem is that I'm unable to find a suitably fast enough way to append data into a numpy array.
Is there a better way to do this? I would have thought it would be quicker t...
Hi everyone,
I have a question about numpy.matrix class. How can I perform such basic manipulations with matrices as adding, deleting and replacing rows and columns?
p.s. I apologize for the lame question..
...
I've been using Audiolab to import sound files in the past, and it worked quite well. However:
It doesn't support some formats, like mp3, because the underlying libsndfile refuses to support them
It doesn't work in Python 2.6 under Windows, and the author is not around to fix it
-
In [2]: from scikits import audiolab
--------------...
Surely there must be a way to do this... I can't work it out.
I have a (9,4) array, and I want to repeat it along a 3rd axis 4096 times... So it becomes simply (9,4,4096), with each value from the 9,4 array simply repeated 4096 times down the new axis.
If my dubious 3D diagram makes sense (the diagonal is a z-axis)
4| /off to 4096
3...
From an ipy console I can
import ironclad
import numpy
with no problem.
However when I try the same imports with an embedded interpreter the numpy import fails. My Python engines is set up like this:
public PyEngine()
{
//Frames option needed to use sys.__getframe
//used in Numpy and others.
Dictiona...
I'm trying to solve a Poisson equation on a rectangular domain which ends up being a linear problem like
Ax=b
but since I know the boundary conditions, there are nodes where I have the solution values. I guess my question is...
How can I solve the sparse system Ax=b if I know what some of the coordinates of x are and the undetermin...
I have a fairly simple plotting routine that looks like this:
from __future__ import division
import datetime
import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import figure, plot, show, legend, close, savefig, rcParams
import numpy
from globalconstants import *
def plotColumns(columnNumbers, t, out, showFig=False, fil...
The title pretty much says it all: If I am using the sparse.lil_matrix format, how can I remove a column from the matrix easily and efficiently?
Thanks!
...
Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array?
I am looking for something similar to Excel's percentile function.
I looked in NumPy's statistics reference, and couldn't find this. All I could find is the median (50th percentile), but not something more specific.
...
In my installation, numpy's arrayobject.h is located at …/site-packages/numpy/core/include/numpy/arrayobject.h. I wrote a trivial Cython script that uses numpy:
cimport numpy as np
def say_hello_to(name):
print("Hello %s!" % name)
I also have the following distutils setup.py (copied from the Cython user guide):
from distutils.c...