[NumPy-Tickets] [NumPy] #1657: np.ma.masked_invalid and precision

NumPy Trac numpy-tickets@scipy....
Mon Nov 1 14:44:49 CDT 2010


#1657: np.ma.masked_invalid and precision
----------------------+-----------------------------------------------------
 Reporter:  bevanj    |       Owner:  pierregm
     Type:  defect    |      Status:  new     
 Priority:  normal    |   Milestone:  1.5.1   
Component:  numpy.ma  |     Version:  1.5.0   
 Keywords:            |  
----------------------+-----------------------------------------------------
 It seems that the use of np.ma.masked_invalid results in arrays printing
 precision of 12 regardless of the default setting or any subsequent
 setting.  Generating masked arrays does not seem to have this behaviour.

 In [1]: eg = np.random.random(1)
 In [2]: eg_mask = np.ma.masked_array(eg)
 In [3]: eg_mask_invalid = np.ma.masked_invalid(eg)
 In [4]: eg
 Out[4]: array([ 0.78592569])
 In [5]: eg_mask
 Out[5]:
 masked_array(data = [ 0.78592569],
             mask = False,
       fill_value = 1e+20)

 In [6]: eg_mask_invalid
 Out[6]:
 masked_array(data = [0.785925693305],
             mask = [False],
       fill_value = 1e+20)

 In [7]: np.set_printoptions(precision=3)

 In [8]: eg
 Out[8]: array([ 0.786])
 In [9]: eg_mask
 Out[9]:
 masked_array(data = [ 0.786],
             mask = False,
       fill_value = 1e+20)
 In [10]: eg_mask_invalid
 Out[10]:
 masked_array(data = [0.785925693305],
             mask = [False],
       fill_value = 1e+20)

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1657>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list