How can I efficiently transfer data from a NumPy array to a QPolygonF when using PySide?
I want do draw polylines with many control points in a PyQt4 / PySide application. The point coordinates come from a NumPy array and must be put into a
QPolygonF in order to be drawn with
With PyQt4, this can be done efficiently e.g. with something like this:
import numpy as np
from PyQt4.QtGui import *
n = 3
qpoints = QPolygonF(n)
vptr = qpoints.data()
aa = np.ndarray( shape=(n,2), dtype=np.float64, buffer=buffer(vptr))
aa[:,0] = np.arange(n)
aa[:,1] = np.arange(n)
for i in range(n):
This works, because, when using PyQt4,
QPolygonF.data() returns something (a
sip.voidptr object) which speaks the Python buffer protocol.
The problem now is that if I try to run the above code using PySide instead of PyQt4,
QPolygonF.data() just returns a
QPointF object (with the coordinates of the first point in the
QPolygonF) and is thus useless.
So my question is: is there any known workaround to this? How can I, with PySide, put data into a
QPolygonF without inserting
QPointF objects, element-wise?
I'm trying to execute the following >> from numpy import * >> x = array([[3,2,3],[4,4,4]]) >> y = set(x) TypeError: unhashable type: 'numpy.ndarray' How can I easily and efficiently
If I have a 1D array that represents the contents of an MxN matrix (where the least significant dimension is contiguous in memory), how do I make the best use of caching when transposing it (to place
I'm looking for the fastest way to select the elements of a numpy array that satisfy several criteria. As an example, say I want to select all elements that lie between 0.2 and 0.8 from an array. I no
Assume we have a numpy.ndarray data, let say with the shape (100,200), and you also have a list of indices which you want to exclude from the data. How would you do that? Something like this: a = nump
I am developing a Firefox extension. And I have injected some js into web page in extension. These js will execute and transfer data to extension. For example, I inject function example(srcElement, ac
Following this: $ adb shell # cat /dev/graphics/fb0 > /sdcard/frame.raw # exit How can I transfer the raw data from /dev/graphics/fb0 to a picture using a python script? what each byte is represe
I have a file with some metadata, and then some actual data consisting of 2 columns with headings. Do I need to separate the two types of data before using genfromtxt in numpy? Or can I somehow split
I'm looking for a good approach for efficiently dividing an image into small regions, processing each region separately, and then re-assembling the results from each process into a single processed im
I am using a Python (via ctypes) wrapped C library to run a series of computation. At different stages of the running, I want to get data into Python, and specifically numpy arrays. The wrapping I am
From the answer to this question (Sort a numpy array by another array, along a particular axis, using less memory), I learned how to sort a multidimensional numpy array a by the values of another nump
I understand how to create a masked array, and I would like to use masking in a record array so that I can access this data using named attributes. The masking seems to be lost when I create a recor
Is it possible to write data line by line using gdal's WriteArray, rather than creating and feeding it an entire array? I've run into a MemoryError when creating an numpy array of size (50539,98357).
The problem is that I want to reduce the amount of data for plots and analysis. Im using Python and Numpy. The data is unevenly sampled, so there is an array of timestamps and an array of correspondin
This question already has an answer here: Numpy array dimensions 2 answers For a numpy matrix in python from numpy import matrix A = matrix([[1,2],[3,4]]) How can I find the length of a row (o
how to transfer elements from 2-d array in 1-d array in same sequence?
I want to remove some entries from a numpy array that is about a million entries long. This code would do it but take a long time: a = np.array([1,45,23,23,1234,3432,-1232,-34,233]) for element in a:
I have an 8gb Macbook Pro and if I create a numpy array like so, it tells me that it is 2Terabytes in size? I'm confused by this because I thought a numpy array allocated contiguous RAM. So how does t
I have a rank-1 numpy.array of which I want to make a boxplot. However, I want to exclude all values equal to zero in the array ... Currently, I solved this by looping the array and copy the value to
I need to write an array to a file using numpy, and I am trying to read in an array as raw input and convert it to an array. My problem seems to be coming from the line inarray = np.array(inlist), bec
I want to add data (read from a file) to the QTableView, but looking over the functions at http://srinikom.github.io/pyside-docs/PySide/QtGui/QTableView.html#qtableview, there doesn't seem to be anyth
I am currently looking at using PySide for mobile app development. I've done a few tutorials for creating desktop applications using Pyside and loving it. I understand PySide/PyQt is a port or mapping
How do I convert a django QuerySet to numpy record array? PS: I know you can iterate and construct it and but is there any other cleaner solution?
I've read through most of Python: convert boolean array to int array , but I was still at loss with, how to (most efficiently) convert a numpy bool array to an int array, but with distinct values. For
Problem: Given an array of positive integers that can contain duplicates, find the minimum number obtained by concatenating the integers. Ex: [3, 32, 321] returns 321323 Aside from trying all n! conca
I am developing a server client application, where Client will send a huge amount of data to server through internet. However I have done some asynchronous socket programing before. Can I use same cod
Is there a more efficient way than using numpy.asarray() to generate an array from output in the form of a list? This appears to be copying everything in memory, which doesn't seem like it would be th
I have a binary file that contains a dense n*m matrix of 32-bit floats. What's the most efficient way to read it into a Fortran-ordered numpy array? The file is multi-gigabyte in size. I get to contro
How can I get the array data from a JSON sent back by my php script? PHP code: <?php //connects to database include 'connect.php'; $callback = $_GET['callback']; $query = mysql_query(SELECT * FROM
I am trying to add a column to a numpy record. This is my code: import numpy import numpy.lib.recfunctions data=[[20140101,'a'],[20140102,'b'],[20140103,'c']] data_array=numpy.array(data) data_dtype=
I want to transfer data from a vertical db layout like this: --------------------- | ID | Type | Value | --------------------- | 1 | 10 | 111 | --------------------- | 1 | 14 | 222 | ----------------
I am relatively new to python and have been trying to learn how to use numpy and scipy. I have a numpy array comprised of LAS data [x, y, z, intensity, classification]. I have created a cKDTree of poi
In my android app i use SQLite database for storing and retrieving data. When user clear the data from application manager the data will be cleared.But my requirement is when user clear's data from ap
For example, I have a variable which point to a vector contains many elements in memory, I want to copy element in vector to a numpy array, what should I do except one by one copy? Thx
I would like to know how I could remove entire rows from an image, preferably based on the color of the row? Example: I have an image that is 5 pixels in height, the top two rows and the bottom two ro
My requirement is to crawl data from HBASE using Nutch, and then index it into Solr. how can i proceed on this?
Using XSLT 1.0, how can I summarize subnodes under a given node while modifiyng the content with data from another set of nodes in an elegant way? Assume I have this xml: <Root> <ExchangeRate
I have a NumPy array that looks like this: arr = [100.10, 200.42, 4.14, 89.00, 34.55, 1.12] How can I get multiple values from this array by index: For example, how can I get the values at the index
How order of numpy array influence on multiplication speed? And how I can auto choose it depending on size of matrices? The question initially comes from code using cudamat: def test_mat(): #need to i
Assume I have 3 teams that each need to play each other once. How can one efficiently iterate through them to schedule matches without duplicates? $teams = range('a', 'c'); $games = array(); foreach
Is there an efficient way to remove Nones from numpy arrays and resize the array to its new size? For example, how would you remove the None from this frame without iterating through it in python. I c
Possible Duplicate: Passing Data between View Controllers I got an array/dictionary needs to transfer from viewController1 to viewController3. Save it into plist or NSUserDefault is too complicate,
On the Python side, I can create new numpy record arrays as follows: numpy.zeros((3,), dtype=[('a', 'i4'), ('b', 'U5')]) How do I do the same from a C program? I suppose I have to call PyArray_Simple
How can I change numpy array into grayscale opencv image in python? After some processing I got an array with following atributes: max value is: 0.99999999988, min value is 8.269656407e-08 and type is
I would like to convert numpy array to some double* or stl vector on the c++ side. I'm actually using PyCXX for this and I can't figure out the way to access the data. I'm currently able to access and
I seem to be hitting a brick wall. No matter what I do, creating a critical error Message Box just doesn't seem to be working. Here's what I've tried thus far: flags = QtGui.QMessageBox.StandardButton
Hello I have a 1000 data series with 1500 points in each. They form a (1000x1500) size Numpy array created using np.zeros((1500, 1000)) and then filled with the data. Now what if I want the array to
How do I efficiently copy an entire queue to a vector/an array in C++? say I have a std::queue and at some point I want to copy it to a vector/an array and then sort it. Thanks for everyone's answers.
I am trying to write a module in python which will draw a numpy array of color data (rgb) to screen. At the moment I am currently using a 3 dimensional color array like this: numpy.ones((10,10,3),dtyp
how can I create a method to play all the data from an array, and to create a while or for to include all records from this array on BD. Since each recodr is consists two columns in the database table
I am using the plist to store the data entered in the UITextFields. But, when I restart my application all the data entered previously was deleted. How can I retain the data in the Plist. I have a UIT