From: Perry G. <pe...@st...> - 2002-09-16 21:47:54
|
Konrad Hinsen writes: > "Chris Barker" <Chr...@no...> writes: > > > use one as an index? Personally, this is what has bit me in the past: I > > At least up to Python 1.5, no, indices have to be of integer type. I > don't know if that condition was extended in later versions. > > > could use A[3,2] as an index if A was type "Int" but not if it was > > "Int16" for example. > > Ehmmm... Are you sure that is the right example? The restriction is on > the type of the index, not on the type of the array. > I think Chris is referring to the fact that Numeric returns a rank-0 array for A[3,2] if A is of type Int16, and that value cannot be used as in index in Python sequences (at least for now; nothing technical prevents it from being implemented to accept object that have an __int__ method). This is the odd inconsistency Numeric has now. If A were a 1-d Int16 array then A[2] would not be a rank-0 array, nor is A[3,2] a rank-0 array if A is of type Int32 (apparently because a Python scalar type suffices). Why it gives rank-0 for 2-d and not 1-d I have no idea. > |