Ahaa,,
Thanks Gaël. That method is more elegance than the previous inputs, and the
simplest of all.
Although one line of "import this" says:
There should be one-- and preferably only one --obvious way to do it.
I always find many different ways of implementing ideas in Python world.
Gökhan
O
On Wed, Apr 22, 2009 at 04:21:05PM -0500, Gökhan SEVER wrote:
>Could you please give me some hints about how to mask an array using
>another arrays like in the following example.
>In [14]: a = arange(5)
>In [15]: a
>Out[15]: array([0, 1, 2, 3, 4])
>and my secondary array
On Wed, Apr 22, 2009 at 10:45 PM, Pierre GM wrote:
>
> On Apr 22, 2009, at 9:03 PM, josef.p...@gmail.com wrote:
>>
>> I prefer broad casting to list comprehension in numpy:
>
> Pretty neat! I still dont have the broadcasting reflex. Now, any idea
> which one is more efficient in terms of speed? in
On Apr 22, 2009, at 9:03 PM, josef.p...@gmail.com wrote:
>
> I prefer broad casting to list comprehension in numpy:
Pretty neat! I still dont have the broadcasting reflex. Now, any idea
which one is more efficient in terms of speed? in terms of temporaries?
On Wed, Apr 22, 2009 at 8:18 PM, Gökhan SEVER wrote:
> Yes Pierre,
>
> I like this one line of elegances in Python a lot. I was thinking that the
> answer lies in somewhere in masked array operations, but I proved wrong.
>
> Thanks for your input on this small riddle.
>
> Here is another way of do
Yes Pierre,
I like this one line of elegances in Python a lot. I was thinking that the
answer lies in somewhere in masked array operations, but I proved wrong.
Thanks for your input on this small riddle.
Here is another way of doing that. (That's what I thought of initially and
what Matthias Mic
On Apr 22, 2009, at 5:21 PM, Gökhan SEVER wrote:
> Hello,
>
> Could you please give me some hints about how to mask an array using
> another arrays like in the following example.
What about that ?
numpy.logical_or.reduce([a==i for i in b])
___
Nump
Hello,
Could you please give me some hints about how to mask an array using another
arrays like in the following example.
In [14]: a = arange(5)
In [15]: a
Out[15]: array([0, 1, 2, 3, 4])
and my secondary array is "b"
In [16]: b = array([2,3])
What I want to do is to mask a with b values and
Wed, 22 Apr 2009 15:12:20 -0400, josef.pktd wrote:
> On Wed, Apr 22, 2009 at 2:37 PM, Pauli Virtanen wrote:
[clip]
>> If you want to ensure no-copy, assign to shape:
>>
>> a.shape = (6,)
[clip]
> Is the difference between assigning to the attribute and using the
> method call explained
> somewhere
On Wed, Apr 22, 2009 at 2:37 PM, Pauli Virtanen wrote:
> Wed, 22 Apr 2009 20:18:14 +0200, Fabrice Pardo wrote:
> [clip]
>> The reshape function is unpredictable and its behaviour is not
>> documented.
>>
>> It cannot be used safely.
>
> It is documented and it can be used safely. The manual, howev
Wed, 22 Apr 2009 13:51:45 -0400, josef.pktd wrote:
[clip]
> change your line to
> b = a.reshape((6,), order=order)
>
> then the reshaped array is just a view.
This has the effect that the unravelling is done in Fortran order (when
order='F') rather than C-order, which can be confusing at times.
On Wed, Apr 22, 2009 at 08:18:14PM +0200, Fabrice Pardo wrote:
> It cannot be used safely.
use:
b = a.view()
b.shape = (2, 3)
This will return a view, or raise an exception.
Gaël
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail
Wed, 22 Apr 2009 20:18:14 +0200, Fabrice Pardo wrote:
[clip]
> The reshape function is unpredictable and its behaviour is not
> documented.
>
> It cannot be used safely.
It is documented and it can be used safely. The manual, however, has
currently no section on views that would explain these is
josef.p...@gmail.com wrote:
>
> from help:
> """
> Returns:
> reshaped_array : ndarray
> This will be a new view object if possible; otherwise, it will be a copy.
> """
>
> " if possible" and "otherwise" are not very precise
> I guess reshape tries to return an array that is contiguous, if you do
>
On Wed, Apr 22, 2009 at 1:13 PM, Fabrice Pardo
wrote:
>
> After reshaping a Fortran array, the new array doesn't share data
> with original array.
> I will be glad if someone can explain the strange behaviour of this
> program. Is it a numpy bug ?
>
> #v
After reshaping a Fortran array, the new array doesn't share data
with original array.
I will be glad if someone can explain the strange behaviour of this
program. Is it a numpy bug ?
#v
def check_bug(order):
a = numpy.ndarray((3,2),order=order,
On Wed, Apr 22, 2009 at 11:48 AM, Mathew Yeates wrote:
> well, this isn't a perfect solution. polyfit is better because it
> determines rank based on condition values. Finds the eigenvalues ...
> etc. But, unless it can vectorized without Python looping, it's too slow
> for me to use
>
rank i
On Wed, Apr 22, 2009 at 8:48 AM, Mathew Yeates wrote:
> well, this isn't a perfect solution. polyfit is better because it
> determines rank based on condition values. Finds the eigenvalues ...
> etc. But, unless it can vectorized without Python looping, it's too slow
> for me to use
I liked your
well, this isn't a perfect solution. polyfit is better because it
determines rank based on condition values. Finds the eigenvalues ...
etc. But, unless it can vectorized without Python looping, it's too slow
for me to use
Mathew
josef.p...@gmail.com wrote:
>
>
>
> If you remove the mean f
19 matches
Mail list logo