Changes between Version 7 and Version 8 of ZeroRankArray

Show
Ignore:
Timestamp:
02/17/06 15:18:22 (7 years ago)
Author:
sasha
Comment:

wikify inline code

Legend:

Unmodified
Added
Removed
Modified
  • ZeroRankArray

    v7 v8  
    3434 
    3535[http://www.carabos.com/ Francesc Altet] [http://www.scipy.net/pipermail/scipy-dev/2006-January/005022.html supported] 
    36 the idea of [...] on zero-rank arrays and suggested that [()] be supported as well. 
     36the idea of {{{[...]}}} on zero-rank arrays and suggested that {{{[()]}}} be supported as well. 
    3737 
    3838Francesc's proposal was: 
     
    4848}}} 
    4949 
    50 There is a consensus that for a zero-rank array x, both x[...] and x[()] should be valid, but the question 
    51 remains on what should be the type of the result - zero rank ndarray or x.dtype? 
     50There is a consensus that for a zero-rank array {{{x}}}, both {{{x[...]}}} and {{{x[()]}}} should be valid, but the question 
     51remains on what should be the type of the result - zero rank ndarray or {{{x.dtype}}}? 
    5252 
    53 (Sasha) First, whatever choice is made for x[...] and x[()] they should be the same because ... is just syntactic 
    54 sugar for "as many : as necessary", which in the case of zero rank leads to ... = (:,)*0 = ().  Second, rank zero 
     53(Sasha) First, whatever choice is made for {{{x[...]}}} and {{{x[()]}}} they should be the same because ... is just syntactic 
     54sugar for "as many : as necessary", which in the case of zero rank leads to {{{... = (:,)*0 = ()}}}.  Second, rank zero 
    5555arrays and numpy scalar types are interchangeable within numpy, but numpy scalars can be use in some python constructs 
    5656where ndarrays can't.  For example: 
     
    6464}}} 
    6565Since most if not all numpy function automatically convert zero-rank arrays to scalars on return, there is no reason for 
    66 [...] and [()] operations to be different.  
     66{{{[...]}}} and {{{[()]}}} operations to be different.  
    6767 
    68 See changeset:1864 for implementation of x[...] and x[()] returning numpy scalars. 
     68See changeset:1864 for implementation of {{{x[...]}}} and {{{x[()]}}} returning numpy scalars. 
    6969 
    70 See changeset:1866 for implementation of x[...] = v and x[()] = v.  
     70See changeset:1866 for implementation of {{{x[...] = v}}} and {{{x[()] = v}}}.  
    7171 
    7272=== Increasing rank with newaxis === 
     
    8383 
    8484=== Refactoring === 
    85 Currently all indexing on zero-rank arrays is implemented in a special if (nd == 0) branch of code that used to always 
     85Currently all indexing on zero-rank arrays is implemented in a special {{{if (nd == 0)}}} branch of code that used to always 
    8686raise an index error. This ensures that the changes do not affect any existing usage (except, the usage that relies on exceptions). 
    8787On the other hand part of motivation for these changes was to make behavior of ndarrays more uniform and this should allow to 
    88 eliminate  if (nd == 0) checks alltogether. 
     88eliminate  {{{if (nd == 0)}}} checks alltogether. 
    8989