Sha256: c5090aa5aa220fb31d9867a61d8cc004951359bf0d942ebb3f8478998b4d0a6a
Contents?: true
Size: 806 Bytes
Versions: 11
Compression:
Stored size: 806 Bytes
Contents
module Torch module Utils module Data module DataPipes class FilterIterDataPipe < IterDataPipe functional_datapipe :filter def initialize(datapipe, &block) @datapipe = datapipe @filter_fn = block end def each @datapipe.each do |data| filtered = return_if_true(data) if non_empty?(filtered) yield filtered else Iter::StreamWrapper.close_streams(data) end end end def return_if_true(data) condition = @filter_fn.call(data) data if condition end def non_empty?(data) !data.nil? end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems