# [PYTHON MATRIX-SIG] A problem with slicing

**Hinsen Konrad
**
hinsenk@ere.umontreal.ca

*Fri, 15 Sep 1995 12:28:42 -0400*

My initial idea for higher-dimensional arrays was to use a matrix of
booleans that was the size of the entire higher-d array being indexed, this
fits naturally with the outputs from matrix comparision operators. ie.
a = [[1,2,3], [4,5,6]]
--> a.gt(2) == [[0,0,1], [1,1,1]]
a[a.gt(2)] = 99
--> a == [[1,2,99], [99,99,99]]
That's nice on the left hand side of an assignment, but what is the value
of a[a.gt(2)] in an expression? It can't be an array!
If all you want is some form of selective assignment, that can be done
with mapping, although you have to type a bit more. You could also
achieve the above result (admittedly less efficiently) with
a = (not a > 2)*a + (a > 2)*99. Therefore I am not so sure whether
your proposed feature is that important, except if it were very
common.
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal | Fax: +1-514-343-7586
C.P. 6128, succ. A | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7 | Francais (phase experimentale)
-------------------------------------------------------------------------------
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================