@@ -252,8 +252,6 @@ def _build_y(self, X, y, sample_weight):
252252        """Build the y_ IsotonicRegression.""" 
253253        check_consistent_length (X , y , sample_weight )
254254        X , y  =  [check_array (x , ensure_2d = False ) for  x  in  [X , y ]]
255-         if  sample_weight  is  not   None :
256-             sample_weight  =  check_array (sample_weight , ensure_2d = False )
257255
258256        y  =  as_float_array (y )
259257        self ._check_fit_data (X , y , sample_weight )
@@ -264,10 +262,16 @@ def _build_y(self, X, y, sample_weight):
264262        else :
265263            self .increasing_  =  self .increasing 
266264
265+         # If sample_weights is passed, removed zero-weight values and clean order 
266+         if  sample_weight  is  not   None :
267+             sample_weight  =  check_array (sample_weight , ensure_2d = False )
268+             mask  =  sample_weight  >  0 
269+             X , y , sample_weight  =  X [mask ], y [mask ], sample_weight [mask ]
270+         else :
271+             sample_weight  =  np .ones (len (y ))
272+ 
267273        order  =  np .lexsort ((y , X ))
268274        order_inv  =  np .argsort (order )
269-         if  sample_weight  is  None :
270-             sample_weight  =  np .ones (len (y ))
271275        X , y , sample_weight  =  [astype (array [order ], np .float64 , copy = False )
272276                               for  array  in  [X , y , sample_weight ]]
273277        unique_X , unique_y , unique_sample_weight  =  _make_unique (X , y , sample_weight )
0 commit comments