On Sun, Jun 7, 2009 at 6:19 AM, Bruce Southey wrote:
> On Sun, Jun 7, 2009 at 3:37 AM, Fernando Perez wrote:
>> One more question. For these *_indices() functions, would you want an
>> interface that accepts *either*
>>
>> diag_indices(size,ndim)
>
> As I indicated above, this is unacceptable for
On Sun, Jun 7, 2009 at 3:37 AM, Fernando Perez wrote:
> On Sun, Jun 7, 2009 at 1:28 AM, Fernando Perez wrote:
>>
>> OK. Will send it in when I know whether you'd want the fill_diagonal
>> one, and where that should go.
>>
>
> One more question. For these *_indices() functions, would you want an
On Sun, Jun 7, 2009 at 1:40 AM, Robert Kern wrote:
>> Both can be useful depending on the case, but it means leaving the
>> first argument as an untyped placeholder and typechecking on it. I
>> don't know if numpy has a policy on avoiding that kind of shenanigans.
>
> *I* do.
OK. I'll go for t
On Sun, Jun 7, 2009 at 03:37, Fernando Perez wrote:
> On Sun, Jun 7, 2009 at 1:28 AM, Fernando Perez wrote:
>>
>> OK. Will send it in when I know whether you'd want the fill_diagonal
>> one, and where that should go.
>>
>
> One more question. For these *_indices() functions, would you want an
>
On Sun, Jun 7, 2009 at 1:28 AM, Fernando Perez wrote:
>
> OK. Will send it in when I know whether you'd want the fill_diagonal
> one, and where that should go.
>
One more question. For these *_indices() functions, would you want an
interface that accepts *either*
diag_indices(size,ndim)
or
d
On Sat, Jun 6, 2009 at 2:01 PM, Robert Kern wrote:
> On Sat, Jun 6, 2009 at 13:30, Fernando Perez wrote:
> Oops! Never mind. I thought it was using mask_indices like the others.
> There is a neat trick for accessing the diagonal of an existing array
> (a.flat[::a.shape[1]+1]), but it won't work
On 6/6/2009 6:39 PM Robert Kern apparently wrote:
> Ah, that's the beauty of .flat; it takes care of that for you. .flat
> is not a view onto the memory directly. It is a not-quite-a-view onto
> what the memory *would* be if the array were contiguous and the memory
> directly reflected the layout a
On Sat, Jun 6, 2009 at 17:34, Alan G Isaac wrote:
> On 6/6/2009 6:02 PM Keith Goodman apparently wrote:
>>> def fill_diag(arr, value):
>> if arr.ndim != 2:
>> raise ValueError, "Input must be 2-d."
>> if arr.shape[0] != arr.shape[1]:
>> raise ValueError, 'Input must be squar
On 6/6/2009 6:02 PM Keith Goodman apparently wrote:
>> def fill_diag(arr, value):
> if arr.ndim != 2:
> raise ValueError, "Input must be 2-d."
> if arr.shape[0] != arr.shape[1]:
> raise ValueError, 'Input must be square.'
> arr.flat[::arr.shape[1]+1] = value
You might
On Sat, Jun 6, 2009 at 2:01 PM, Robert Kern wrote:
> There is a neat trick for accessing the diagonal of an existing array
> (a.flat[::a.shape[1]+1]), but it won't work to implement
> diag_indices().
Perfect. That's 3x faster.
def fill_diag(arr, value):
if arr.ndim != 2:
raise Value
On Sat, Jun 6, 2009 at 13:30, Fernando Perez wrote:
> On Sat, Jun 6, 2009 at 12:09 AM, Robert Kern wrote:
>
>> +1
>
> OK, thanks. I'll try to get it ready.
>
>> diag_indices() can be made more efficient, but these are fine.
>
> Suggestion? Right now it's not obvious to me...
Oops! Never mind. I
On Sat, Jun 6, 2009 at 15:31, Bruce Southey wrote:
> While not trying to be negative, this raises important questions that
> need to be covered because the user should not have to do trial and
> error to find what actually works and what that does not. While
> certain features can be fixed within
On Sat, Jun 6, 2009 at 2:01 AM, Fernando Perez wrote:
[snip]
>
>
> def mask_indices(n,mask_func,k=0):
> """Return the indices for an array, given a masking function like
> tri{u,l}."""
> m = np.ones((n,n),int)
> a = mask_func(m,k)
> return np.where(a != 0)
>
>
> def diag_indices(n,
On Sat, Jun 6, 2009 at 11:35 AM, Gael
Varoquaux wrote:
> I think they need examples. Right now, it is not clear at all to me what
> they do.
Cheers,
f
# With doctests, set to be repeatable by seeding the rng.
def structured_rand_arr(size, sample_func=np.random.random,
lt
On Sat, Jun 6, 2009 at 11:46 AM, Keith Goodman wrote:
> On Sat, Jun 6, 2009 at 11:30 AM, Fernando Perez wrote:
>> On Sat, Jun 6, 2009 at 12:09 AM, Robert Kern wrote:
>>> diag_indices() can be made more efficient, but these are fine.
>>
>> Suggestion? Right now it's not obvious to me...
>
> I'm i
On Sat, Jun 6, 2009 at 11:30 AM, Fernando Perez wrote:
> On Sat, Jun 6, 2009 at 12:09 AM, Robert Kern wrote:
>> diag_indices() can be made more efficient, but these are fine.
>
> Suggestion? Right now it's not obvious to me...
I'm interested in a more efficient way too. Here's how I plan to adap
On Sat, Jun 06, 2009 at 11:30:37AM -0700, Fernando Perez wrote:
> On Sat, Jun 6, 2009 at 12:09 AM, Robert Kern wrote:
> - Any interest in also having the stuff below? I'm needing to build
> structured random arrays a lot (symmetric, anti-symmetric, symmetric
> with a particular diagonal, etc), an
On Sat, Jun 6, 2009 at 8:27 AM, Keith Goodman wrote:
> What do you think of passing in the array a instead of n and ndim
> (diag_indices_list_2 below)?
Yes, I thought of that too. I see use cases for both though. Would
people prefer both, or rather a flexible interface that tries to
introspect t
On Sat, Jun 6, 2009 at 12:09 AM, Robert Kern wrote:
> +1
OK, thanks. I'll try to get it ready.
> diag_indices() can be made more efficient, but these are fine.
Suggestion? Right now it's not obvious to me...
A few more questions:
- Are doctests considered enough testing for numpy, or are se
On Sat, Jun 6, 2009 at 12:01 AM, Fernando Perez wrote:
> def diag_indices(n,ndim=2):
> """Return the indices to index into a diagonal.
>
> Examples
>
> >>> a = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
> >>> a
> array([[ 1, 2, 3, 4],
> [ 5,
On Sat, Jun 6, 2009 at 02:01, Fernando Perez wrote:
> Howdy,
>
> I'm finding myself often having to index *into* arrays to set values.
> As best I can see, in numpy functions/methods like diag or tri{u,l}
> provide for the extraction of values from arrays, but I haven't found
> their counterparts
Howdy,
I'm finding myself often having to index *into* arrays to set values.
As best I can see, in numpy functions/methods like diag or tri{u,l}
provide for the extraction of values from arrays, but I haven't found
their counterparts for generating the equivalent indices.
Their implementations ar
22 matches
Mail list logo