[PYTHON MATRIX-SIG] Odd behavior of "Numeric.fromfunction"

Konrad Hinsen hinsen@ibs.ibs.fr
Thu, 14 Nov 96 10:23:04 +0100


> Can anyone explain to me whether the following is a feature or a bug?
> 
> Python 1.4 (Oct 31 1996)  [GCC 2.7.2]
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import ni,Numeric
> >>> def g(a):
> ...     return a
> ... 
> >>> x = Numeric.fromfunction(g,[10])
> >>> x
> 0 1 2 3 4 5 6 7 8 9
> >>> len(x)
> 10
> >>>
> >>>
> >>> def g(a):
> ...     return 5
> ... 
> >>> x = Numeric.fromfunction(g,[10])
> >>> x
> 5

Feature, though not a well-known one. fromfunction() works correctly
only if the function
1) uses all its arguments
2) consists only of scalar operations defined on arrays (i.e. elementary
   arithmetic operations and functions from umath).

-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================