[PYTHON MATRIX-SIG] scalars and arrays
Chris Chase SRM
chris.chase@jhuapl.edu
Tue, 29 Oct 1996 09:31:01 -0500
KH> But if that's what you want, I suggest the following procedure to
KH> convert anything to a rank-1 array:
KH> a = array(a).flat
Thanks.
>> holding onto my past conceptions - and always require that my
>> functions that can take sequence arguments only allow sequences for
>> those arguments.
KH> I have never felt a need to impose any such restrictions. Could you
KH> give an example of a function that must take a sequence as a parameter?
I have satellite energetic ion measurements that can have a large
number of dimensions, two of which are species and energy channel.
Many of the procedures I write in IDL permit the user to select any
set of energy channels and/or species on which to operate. This is
usually done via a scalar index or an array of indexes. Your
array(a).flat trick (could even use it via map() as an idiom for
converting a tuple of scalars or sequences) will solve the problem and
allow me the function to be coded independent of the users input of a
sequence or scalar.
Thanks,
Chris
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================