[PYTHON MATRIX-SIG] Handling null data points
Konrad Hinsen
hinsen@ibs.ibs.fr
Wed, 8 Jan 1997 10:23:48 +0100
> I have two numeric arrays called A and B containing some real data.
> Missing data has been replaced with a constant 'null' value of 100
>
> A = ( 20 10 100 6 )
> B = ( 100 1 2 1 )
>
> Now if I use Python to calculate A divided by B:
>
> C = ( 0.2 10 50 6 )
>
> But when A or B is null I would like the answer to be null:
>
> C = ( 100 10 100 6 )
>
The cleanest solution to your problem would be to define a new
data type, "number with special null value", and define all
the arithmetic operations on it. You could even do that in Python,
or if speed matters as a C extension. But even with a C extension
you would not get the full speed of array operations, since your
arrays would be of "general object" type.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.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
=================