On Wed, Mar 17, 2010 at 14:18, Keith Goodman wrote:
> On Wed, Mar 17, 2010 at 12:08 PM, Robert Kern wrote:
>> On Wed, Mar 17, 2010 at 14:03, Keith Goodman wrote:
>>> On Wed, Mar 17, 2010 at 12:04 PM, Christopher Barker
>>> wrote:
Friedrich Romstedt wrote:
> Code:
>
> import num
On Wed, Mar 17, 2010 at 3:11 PM, Robert Kern wrote:
> On Wed, Mar 17, 2010 at 14:07, wrote:
>> On Wed, Mar 17, 2010 at 3:01 PM, Robert Kern wrote:
>>> On Wed, Mar 17, 2010 at 14:04, Christopher Barker
>>> wrote:
Friedrich Romstedt wrote:
> Code:
>
> import numpy
> import
On Wed, Mar 17, 2010 at 12:08 PM, Robert Kern wrote:
> On Wed, Mar 17, 2010 at 14:03, Keith Goodman wrote:
>> On Wed, Mar 17, 2010 at 12:04 PM, Christopher Barker
>> wrote:
>>> Friedrich Romstedt wrote:
Code:
import numpy
import time
a = numpy.random.random((2000, 2
Robert Kern wrote:
> On Wed, Mar 17, 2010 at 14:04, Christopher Barker
> wrote:
>> though last I checked, it's
>> written in Python,
>
> No, it isn't.
>
>> and thus not all that fast.
>
> No, it's reasonably performant.
nice to know -- a good while back, I wrote a small collection of add-ons
On Wed, Mar 17, 2010 at 14:07, wrote:
> On Wed, Mar 17, 2010 at 3:01 PM, Robert Kern wrote:
>> On Wed, Mar 17, 2010 at 14:04, Christopher Barker
>> wrote:
>>> Friedrich Romstedt wrote:
Code:
import numpy
import time
a = numpy.random.random((2000, 2000))
On Wed, Mar 17, 2010 at 14:03, Keith Goodman wrote:
> On Wed, Mar 17, 2010 at 12:04 PM, Christopher Barker
> wrote:
>> Friedrich Romstedt wrote:
>>> Code:
>>>
>>> import numpy
>>> import time
>>>
>>> a = numpy.random.random((2000, 2000))
>>>
>>> start = time.time()
>>> a[abs(a) < 10] = 0
>>> stop
On Wed, Mar 17, 2010 at 3:01 PM, Robert Kern wrote:
> On Wed, Mar 17, 2010 at 14:04, Christopher Barker
> wrote:
>> Friedrich Romstedt wrote:
>>> Code:
>>>
>>> import numpy
>>> import time
>>>
>>> a = numpy.random.random((2000, 2000))
>>>
>>> start = time.time()
>>> a[abs(a) < 10] = 0
>>> stop =
On Wed, Mar 17, 2010 at 12:04 PM, Christopher Barker
wrote:
> Friedrich Romstedt wrote:
>> Code:
>>
>> import numpy
>> import time
>>
>> a = numpy.random.random((2000, 2000))
>>
>> start = time.time()
>> a[abs(a) < 10] = 0
>> stop = time.time()
>
> I highly recommend ipython and its "timeit" funct
On Wed, Mar 17, 2010 at 14:04, Christopher Barker wrote:
> Friedrich Romstedt wrote:
>> Code:
>>
>> import numpy
>> import time
>>
>> a = numpy.random.random((2000, 2000))
>>
>> start = time.time()
>> a[abs(a) < 10] = 0
>> stop = time.time()
>
> I highly recommend ipython and its "timeit" function
Friedrich Romstedt wrote:
> Code:
>
> import numpy
> import time
>
> a = numpy.random.random((2000, 2000))
>
> start = time.time()
> a[abs(a) < 10] = 0
> stop = time.time()
I highly recommend ipython and its "timeit" function --much better for this.
And numpy.clip() may be helpful here, though
Code:
import numpy
import time
a = numpy.random.random((2000, 2000))
start = time.time()
a[abs(a) < 10] = 0
stop = time.time()
print stop - start
a = numpy.random.random((2000, 2000))
start = time.time()
a = a * (abs(a) >= 10)
stop = time.time()
print stop - start
a = numpy.random.random((2
On Wed, Mar 17, 2010 at 11:56 AM, Keith Goodman wrote:
> On Wed, Mar 17, 2010 at 8:51 AM, gerardob wrote:
>>
>> How can i modified all the values of a numpy array whose value is smaller
>> than a given epsilon to zero?
>>
>> Example
>> epsilon=0.01
>> a = [[0.003,2][23,0.0001]]
>>
>> output:
>> [
On Wed, Mar 17, 2010 at 8:51 AM, gerardob wrote:
>
> How can i modified all the values of a numpy array whose value is smaller
> than a given epsilon to zero?
>
> Example
> epsilon=0.01
> a = [[0.003,2][23,0.0001]]
>
> output:
> [[0,2][23,0]]
Here's one way:
>> a = np.array([[0.003,2],[23,0.0001
On Wed, Mar 17, 2010 at 8:51 AM, gerardob wrote:
> How can i modified all the values of a numpy array whose value is smaller
> than a given epsilon to zero?
>
> Example
> epsilon=0.01
> a = [[0.003,2][23,0.0001]]
>
> output:
> [[0,2][23,0]]
Give this a try:
>>> import numpy as np
>>> epsilon=0.0
How can i modified all the values of a numpy array whose value is smaller
than a given epsilon to zero?
Example
epsilon=0.01
a = [[0.003,2][23,0.0001]]
output:
[[0,2][23,0]]
--
View this message in context:
http://old.nabble.com/Setting-small-numbers-to-zero.-tp27933569p27933569.html
Sent f
15 matches
Mail list logo