[cctbxbb] pickling nan values

Robert Oeffner rdo20 at cam.ac.uk
Mon Jun 10 07:09:52 PDT 2019


Hi all,

It seems that a flex.double array containing "nan" values doesn't 
survive pickling as in:

oeffner at grove:~$ cctbx.python
Python 2.7.15 (default, Sep 11 2018, 23:48:45)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>>
 >>> from cctbx.array_family import flex
 >>> import pickle
 >>> flex_nans = flex.double(3, float('nan'))
 >>> list(flex_nans)
[nan, nan, nan]
 >>> list(pickle.loads( pickle.dumps(flex_nans)))
[0.0, 0.0, 0.0]
 >>>
 >>>

If the flex double is cast into a python list then it does survive 
pickling as in:

 >>>
 >>> list(pickle.loads( pickle.dumps(list( flex_nans ))))
[nan, nan, nan]
 >>>

I would like to use nan values to indicate missing or invalid data 
values. Would anyone have a suggestion how to go about this?


Many thanks,


Rob


-- 
Robert Oeffner, Ph.D.
Research Associate, The Read Group
Department of Haematology,
Cambridge Institute for Medical Research
University of Cambridge
Cambridge Biomedical Campus
The Keith Peters Building
Hills Road
Cambridge CB2 0XY

www.cimr.cam.ac.uk/investigators/read/index.html
tel: +44(0)1223 763234



More information about the cctbxbb mailing list