On Thursday, July 23, 2015 at 1:43:00 PM UTC+2, Jeremy Sanders wrote:
> Heli Nix wrote:
>
> > Is there any way that I can optimize this if statement.
>
> Array processing is much faster in numpy. Maybe this is close to what you
> want
>
> import numpy as N
> # input data
> vals = N.array([42, 1
Heli Nix wrote:
> Is there any way that I can optimize this if statement.
Array processing is much faster in numpy. Maybe this is close to what you
want
import numpy as N
# input data
vals = N.array([42, 1, 5, 3.14, 53, 1, 12, 11, 1])
# list of items to exclude
exclude = [1]
# convert to a bool
Take a look at the sorted collection recipe:
http://code.activestate.com/recipes/577197-sortedcollection/
You want myList to be a sorted List. You want lookups to be fast.
See if that improves things enough for you. It may be possible to
have better speedups if instead of myList you write myTre
On 2015-07-23 10:21, Heli Nix wrote:
Dear all,
I have the following piece of code. I am reading a numpy dataset from an hdf5
file and I am changing values to a new value if they equal 1.
There is 90 percent chance that (if id not in myList:) is true and in 10
percent of time is false.
with
Dear all,
I have the following piece of code. I am reading a numpy dataset from an hdf5
file and I am changing values to a new value if they equal 1.
There is 90 percent chance that (if id not in myList:) is true and in 10
percent of time is false.
with h5py.File(inputFile, 'r') as f1: