@@ -250,6 +250,24 @@ where
250
250
A : ' a ,
251
251
F : FnMut ( B , & ' a A :: NotNan ) -> B ;
252
252
253
+ /// Visit each non-NaN element in the array by calling `f` on each element.
254
+ ///
255
+ /// Elements are visited in arbitrary order.
256
+ fn visit_skipnan < ' a , F > ( & ' a self , f : F )
257
+ where
258
+ A : ' a ,
259
+ F : FnMut ( & ' a A :: NotNan ) ;
260
+
261
+ /// Fold non-NaN values along an axis.
262
+ ///
263
+ /// Combine the non-NaN elements of each subview with the previous using
264
+ /// the fold function and initial value init.
265
+ fn fold_axis_skipnan < B , F > ( & self , axis : Axis , init : B , fold : F ) -> Array < B , D :: Smaller >
266
+ where
267
+ D : RemoveAxis ,
268
+ F : FnMut ( & B , & A :: NotNan ) -> B ,
269
+ B : Clone ;
270
+
253
271
/// Reduce the values along an axis into just one value, producing a new
254
272
/// array with one less dimension.
255
273
///
@@ -293,6 +311,33 @@ where
293
311
} )
294
312
}
295
313
314
+ fn visit_skipnan < ' a , F > ( & ' a self , mut f : F )
315
+ where
316
+ A : ' a ,
317
+ F : FnMut ( & ' a A :: NotNan ) ,
318
+ {
319
+ self . visit ( |elem| {
320
+ if let Some ( not_nan) = elem. try_as_not_nan ( ) {
321
+ f ( not_nan)
322
+ }
323
+ } )
324
+ }
325
+
326
+ fn fold_axis_skipnan < B , F > ( & self , axis : Axis , init : B , mut fold : F ) -> Array < B , D :: Smaller >
327
+ where
328
+ D : RemoveAxis ,
329
+ F : FnMut ( & B , & A :: NotNan ) -> B ,
330
+ B : Clone ,
331
+ {
332
+ self . fold_axis ( axis, init, |acc, elem| {
333
+ if let Some ( not_nan) = elem. try_as_not_nan ( ) {
334
+ fold ( acc, not_nan)
335
+ } else {
336
+ acc. clone ( )
337
+ }
338
+ } )
339
+ }
340
+
296
341
fn map_axis_skipnan_mut < ' a , B , F > (
297
342
& ' a mut self ,
298
343
axis : Axis ,
0 commit comments