Sha256: 68347c7282f8304192529c51649d530026bf2e9b6054a6d6ab66a91182c7dc86

Contents?: true

Size: 673 Bytes

Versions: 11

Compression:

Stored size: 673 Bytes

Contents

module Torch
  module Utils
    module Data
      module DataPipes
        module Iter
          class IterableWrapper < IterDataPipe
            def initialize(iterable, deepcopy: true)
              @iterable = iterable
              @deepcopy = deepcopy
            end

            def each
              source_data = @iterable
              if @deepcopy
                source_data = Marshal.load(Marshal.dump(@iterable))
              end
              source_data.each do |data|
                yield data
              end
            end

            def length
              @iterable.length
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
torch-rb-0.18.0 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.17.1 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.17.0 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.16.0 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.15.0 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.14.1 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.14.0 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.13.2 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.13.1 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.13.0 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
torch-rb-0.12.2 lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb