I am trying to build a list with the following format:
(t,dt,array)
Where t is time -float-, dt is also a float an array is an array of ints that represents the state of my system. I want to have elements ordered in an array by the first element, that is t. So my take on it is to use the heap structure provided by Python.
What I am trying is:
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import heapq
popsize = 10
populat = [ (0,0,np.random.randint(0,2,Nsize)) for count in range(popsize)]
heapq.heapify(populat) # Structure to order efficiently
However this returns the following:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
So does anybody knows how could it do that? or where does the error comes from?
I am using Ubuntu 12.04, running python 2.7 and also ipython 1.1.
I will be very grateful, thanks a lot.