[SciPy-user] assign to diagonal values?
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Jul 1 13:21:22 EDT 2009
Robert Kern wrote:
> On Sat, May 23, 2009 at 16:26, Alan G Isaac <aisaac at american.edu> wrote:
>>> On Sat, May 23, 2009 at 16:02, Alan G Isaac wrote:
>>>> On 1/31/2008 1:37 AM Anne Archibald apparently wrote:
>>>>> m[range(n),range(n)]=new_diagonal
>>>> Will that work with range objects (in Python 3)?
>> On 5/23/2009 5:05 PM Robert Kern apparently wrote:
>>> No. The automatic conversion to arrays does not consume iterators (nor
>>> will it when we port to Python 3).
>> Sure, but range objects are not iterators.
>> They are "almost" sequences.
>
> The answer is still no. Perhaps someone will write special support for
> that type when we do the Python 3 port, but there's nothing in numpy
> that would make it work automatically. For example, xrange() does not
> work as an index with the current numpy.
Well, ranges are more capable than you think in Python 3:
v = range(25)
print (v[3], v[0], v[22], v)
prints:
3 0 22 range(0, 25)
-Scott
More information about the SciPy-User
mailing list