Class: Torch::Utils::Data::DataPipes::Iter::FileLister

Inherits:
Torch::Utils::Data::DataPipes::IterDataPipe show all
Defined in:
lib/torch/utils/data/data_pipes/iter/file_lister.rb

Instance Method Summary collapse

Methods inherited from Torch::Utils::Data::DataPipes::IterDataPipe

functional_datapipe, functions, register_datapipe_as_function, #reset

Constructor Details

#initialize(root = ".", masks = "", recursive: false, abspath: false, non_deterministic: false, length: -1) ⇒ FileLister

Returns a new instance of FileLister.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/torch/utils/data/data_pipes/iter/file_lister.rb', line 7

def initialize(
  root = ".",
  masks = "",
  recursive: false,
  abspath: false,
  non_deterministic: false,
  length: -1
)
  super()
  if root.is_a?(String)
    root = [root]
  end
  if !root.is_a?(IterDataPipe)
    root = IterableWrapper.new(root)
  end
  @datapipe = root
  @masks = masks
  @recursive = recursive
  @abspath = abspath
  @non_deterministic = non_deterministic
  @length = length
end

Instance Method Details

#each(&block) ⇒ Object



30
31
32
33
34
# File 'lib/torch/utils/data/data_pipes/iter/file_lister.rb', line 30

def each(&block)
  @datapipe.each do |path|
    get_file_pathnames_from_root(path, @masks, recursive: @recursive, abspath: @abspath, non_deterministic: @non_deterministic, &block)
  end
end