[NumPy-Tickets] [NumPy] #1577: ma.polyfit ignores masks

NumPy Trac numpy-tickets@scipy....
Mon Aug 9 19:00:33 CDT 2010


#1577: ma.polyfit ignores masks
----------------------------+-----------------------------------------------
 Reporter:  gdmcbain        |       Owner:  somebody
     Type:  defect          |      Status:  new     
 Priority:  normal          |   Milestone:  2.0.0   
Component:  Other           |     Version:  1.3.0   
 Keywords:  polyfit masked  |  
----------------------------+-----------------------------------------------
 A masked array of abscissae gives the same results as if unmasked;
 compressing it gives a different result, which is perhaps the expected
 one; e.g., based on the example at
 [http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.polyfit.html?highlight=polyfit#numpy.ma.polyfit],
 the script
 {{{
 import numpy as np
 import numpy.ma as ma

 x = np.array ([0.0, 1.0, 2.0, 3.0,  4.0,  5.0])
 y = np.array ([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])
 print '  unmasked: ', np.polyfit (x, y, 3)

 mask = np.zeros (x.shape, dtype = np.bool)
 mask[2] = True
 mx = ma.array (x, mask = mask)
 my = ma.array (y, mask = mask)
 print '    masked: ', np.polyfit (mx, my, 3)    # ignores mask!
 print 'compressed: ', np.polyfit (mx.compressed (), my.compressed (), 3)
 }}}
 produces

 {{{
   unmasked:  [ 0.08703704 -0.81349206  1.69312169 -0.03968254]
     masked:  [ 0.08703704 -0.81349206  1.69312169 -0.03968254]
 compressed:  [ 0.07941176 -0.74159664  1.5210084  -0.01680672]

 }}}

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


More information about the NumPy-Tickets mailing list