Changes between Version 7 and Version 8 of ZeroRankArray
- Timestamp:
- 02/17/06 15:18:22 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ZeroRankArray
v7 v8 34 34 35 35 [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.36 the idea of {{{[...]}}} on zero-rank arrays and suggested that {{{[()]}}} be supported as well. 37 37 38 38 Francesc's proposal was: … … 48 48 }}} 49 49 50 There is a consensus that for a zero-rank array x, both x[...] and x[()]should be valid, but the question51 remains on what should be the type of the result - zero rank ndarray or x.dtype?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}}}? 52 52 53 (Sasha) First, whatever choice is made for x[...] and x[()]they should be the same because ... is just syntactic54 sugar for "as many : as necessary", which in the case of zero rank leads to ... = (:,)*0 = (). Second, rank zero53 (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 55 55 arrays and numpy scalar types are interchangeable within numpy, but numpy scalars can be use in some python constructs 56 56 where ndarrays can't. For example: … … 64 64 }}} 65 65 Since 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. 67 67 68 See changeset:1864 for implementation of x[...] and x[()]returning numpy scalars.68 See changeset:1864 for implementation of {{{x[...]}}} and {{{x[()]}}} returning numpy scalars. 69 69 70 See changeset:1866 for implementation of x[...] = v and x[()] = v.70 See changeset:1866 for implementation of {{{x[...] = v}}} and {{{x[()] = v}}}. 71 71 72 72 === Increasing rank with newaxis === … … 83 83 84 84 === Refactoring === 85 Currently all indexing on zero-rank arrays is implemented in a special if (nd == 0)branch of code that used to always85 Currently all indexing on zero-rank arrays is implemented in a special {{{if (nd == 0)}}} branch of code that used to always 86 86 raise an index error. This ensures that the changes do not affect any existing usage (except, the usage that relies on exceptions). 87 87 On 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.88 eliminate {{{if (nd == 0)}}} checks alltogether. 89 89
