2008/8/29 Christopher Barker <[EMAIL PROTECTED]>:
> How can I do this without another line of code special casing the 0,
> which isn't that big I deal, but it seems kind of ugly...
>
> >>> a[a==0] = min_value
> >>> np.sign(a) * np.maximum(np.abs(a), min_value)
> array([ 2, 2, 2, 3, 4, -5])
M
Alan G Isaac wrote:
Alan G Isaac wrote:
> Does this do what you want?
> idx = np.abs(a) a[idx] = min_value
>
> Christopher Barker wrote:
>> -1 should go to -2
>
> ok then:
> a[idx] = min_value*np.sign(a[idx])
> I think that's what you are saying?
nope:
>>> a = np.array((0, 1
I tested all three offered solutions :
t = table[:] # convert to structured array
collections = np.unique(t['collection'])
for collection in collections:
cond = t['collection'] == collection
energy_this_collection = t['energy'][cond]
--
energies = {}
for ro
>>> Alan G Isaac wrote:
Does this do what you want?
idx = np.abs(a)>>> a[idx] = min_value
Christopher Barker wrote:
> -1 should go to -2
ok then:
a[idx] = min_value*np.sign(a[idx])
I think that's what you are saying?
Cheers,
Alan Isaac
__
Keith Goodman wrote:
>> Alan G Isaac wrote:
>>> Does this do what you want?
>>> idx = np.abs(a)>> a[idx] = min_value
>> Keith Goodman wrote:
>>> If you only have integers then
>>>
> x
>>>array([ 1, 2, -5, -1, 0])
> np.sign(x+1e-16) * np.maximum(np.abs(x), 2)
>>>array([ 2., 2., -
On Fri, Aug 29, 2008 at 3:08 PM, Christopher Barker
<[EMAIL PROTECTED]> wrote:
> Alan G Isaac wrote:
>> Does this do what you want?
>> idx = np.abs(a)> a[idx] = min_value
>
> yup, that's it. I had forgotten about that kind of indexing, even though
> I used it for: a[a==0] = min_value
>
> Keith Good
Alan G Isaac wrote:
> Does this do what you want?
> idx = np.abs(a) a[idx] = min_value
out of interest, is there any performance difference between:
a[np.abs(a)http://projects.scipy.org/mailman/listinfo/numpy-discussion
Alan G Isaac wrote:
> Does this do what you want?
> idx = np.abs(a) a[idx] = min_value
yup, that's it. I had forgotten about that kind of indexing, even though
I used it for: a[a==0] = min_value
Keith Goodman wrote:
> If you only have integers then
>
>>> x
>array([ 1, 2, -5, -1, 0])
>>> n
On Sat, Aug 30, 2008 at 2:44 AM, Christopher Burns <[EMAIL PROTECTED]> wrote:
> I reopened Ticket 816:
> http://scipy.org/scipy/numpy/ticket/816
>
Hi Chris,
Could you try to do a clean install, because when Travis and me (well,
mostly Travis) look at that problem, we were both on mac os X, and I
On Fri, Aug 29, 2008 at 2:52 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 29, 2008 at 2:49 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
>> On Fri, Aug 29, 2008 at 2:35 PM, Christopher Barker
>> <[EMAIL PROTECTED]> wrote:
>>> HI all,
>>>
>>> I need to do something I thought would be si
Christopher Barker wrote:
> I need to do something I thought would be simple -- set
> all the values of an array to some minimum. so I did this:
Does this do what you want?
idx = np.abs(a)http://projects.scipy.org/mailman/listinfo/numpy-discussion
On Fri, Aug 29, 2008 at 2:35 PM, Christopher Barker
<[EMAIL PROTECTED]> wrote:
> HI all,
>
> I need to do something I thought would be simple -- set all the values
> of an array to some minimum. so I did this:
>
> >>> min_value = 2
> >>> a = np.array((1, 2, 3, 4, 5,))
> >>> np.maximum(a, min_val
On Fri, Aug 29, 2008 at 2:49 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 29, 2008 at 2:35 PM, Christopher Barker
> <[EMAIL PROTECTED]> wrote:
>> HI all,
>>
>> I need to do something I thought would be simple -- set all the values
>> of an array to some minimum. so I did this:
>>
>>
HI all,
I need to do something I thought would be simple -- set all the values
of an array to some minimum. so I did this:
>>> min_value = 2
>>> a = np.array((1, 2, 3, 4, 5,))
>>> np.maximum(a, min_value)
array([2, 2, 3, 4, 5])
all was well... then I realized that a could have negative numbe
On Fri, Aug 29, 2008 at 3:03 PM, Alan G Isaac <[EMAIL PROTECTED]> wrote:
> Stéfan van der Walt wrote:
> > At first, I also thought it might be more intuitive to return the
> > output array, but then I realised that it would make it more difficult
> > to realise that the operation is being performe
Stéfan van der Walt wrote:
> At first, I also thought it might be more intuitive to return the
> output array, but then I realised that it would make it more difficult
> to realise that the operation is being performed in-place. Maybe it
> is good to remind programmers of what happens under the
2008/8/29 Charles R Harris <[EMAIL PROTECTED]>:
>> I like that idea. A lot of numpy functions return a reference to the
>> modified array when the output array (out) is specified.
>
> Google up the various discussions of python sort to see why Guido doesn't
> like that sort of thing. We've had that
I suppose all the discussion on comp.lang.python
about list methods (especially sort) is becoming
relevant to this thread.
Cheers,
Alan Isaac
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-d
Keith Goodman wrote:
> On Fri, Aug 29, 2008 at 10:51 AM, Keith Goodman <[EMAIL PROTECTED]> wrote:
>
>> On Fri, Aug 29, 2008 at 10:42 AM, dmitrey <[EMAIL PROTECTED]> wrote:
>>
>>> Keith Goodman wrote:
>>>
Yeah, I do stuff like that too. fill works in place so it returns None.
>>>
On Fri, Aug 29, 2008 at 11:51 AM, Keith Goodman <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 29, 2008 at 10:42 AM, dmitrey <[EMAIL PROTECTED]>
> wrote:
> >
> > Keith Goodman wrote:
> >> Yeah, I do stuff like that too. fill works in place so it returns None.
> >>
> >>
> x = np.array([1,2])
>
On Fri, Aug 29, 2008 at 10:51 AM, Keith Goodman <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 29, 2008 at 10:42 AM, dmitrey <[EMAIL PROTECTED]> wrote:
>>
>> Keith Goodman wrote:
>>> Yeah, I do stuff like that too. fill works in place so it returns None.
>>>
>>>
> x = np.array([1,2])
> x.fill(10)
On Fri, Aug 29, 2008 at 10:42 AM, dmitrey <[EMAIL PROTECTED]> wrote:
>
> Keith Goodman wrote:
>> Yeah, I do stuff like that too. fill works in place so it returns None.
>>
>>
x = np.array([1,2])
x.fill(10)
x
>>array([10, 10])
>>
x = x.fill(10) # <-- Danger!
print
Keith Goodman wrote:
> Yeah, I do stuff like that too. fill works in place so it returns None.
>
>
>>> x = np.array([1,2])
>>> x.fill(10)
>>> x
>>>
>array([10, 10])
>
>>> x = x.fill(10) # <-- Danger!
>>> print x
>>>
> None
>
Since result "None" is never used it would be
I reopened Ticket 816:
http://scipy.org/scipy/numpy/ticket/816
Running numpy.test() causes a bus error on OSX.
--
Christopher Burns
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
_
On Fri, Aug 29, 2008 at 10:19 AM, dmitrey <[EMAIL PROTECTED]> wrote:
> hi all,
> isn't it a bug
> (latest numpy from svn, as well as my older version)
>
> from numpy import array
> print array((1,2,3)).fill(10)
> None
Yeah, I do stuff like that too. fill works in place so it returns None.
>> x =
sorry, it isn't a bug, it's my fault, fill() returns None and do
in-place modification.
D.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
hi all,
isn't it a bug
(latest numpy from svn, as well as my older version)
from numpy import array
print array((1,2,3)).fill(10)
None
Regards, D.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/nu
I have a program that imports numpy and scipy. When I try to use
PyInstaller, I get the following error:
File "", line 21, in
NameError: name 'io' is not defined
The code up to line 21 is (line numbers differ becasue of comments):
from numpy import *
from numpy import random
from scipy import
A Friday 29 August 2008, Francesc Alted escrigué:
> A Friday 29 August 2008, Alan Jackson escrigué:
> > Looking for advice on a good way to handle this problem.
> >
> > I'm dealing with large tables (Gigabyte large). I would like to
> > efficiently subset values from one column based on the values
A Friday 29 August 2008, Alan Jackson escrigué:
> Looking for advice on a good way to handle this problem.
>
> I'm dealing with large tables (Gigabyte large). I would like to
> efficiently subset values from one column based on the values in
> another column, and get arrays out of the operation. Fo
30 matches
Mail list logo