Skip to content

Commit ff435b2

Browse files
ali-ramadhanglwagnernavidcy
authored
For output readers, make reader_kw default to an empty NamedTuple (#3902)
* For output readers, make `reader_kw` default to an empty `NamedTuple` * Update test/test_output_readers.jl Co-authored-by: Gregory L. Wagner <[email protected]> --------- Co-authored-by: Gregory L. Wagner <[email protected]> Co-authored-by: Navid C. Constantinou <[email protected]>
1 parent ec4ac22 commit ff435b2

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/OutputReaders/field_dataset.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ linearly.
2424
2525
- `grid`: May be specified to override the grid used in the JLD2 file.
2626
27-
- `reader_kw`: A dictionary of keyword arguments to pass to the reader (currently only JLD2)
28-
to be used when opening files.
27+
- `reader_kw`: A named tuple or dictionary of keyword arguments to pass to the reader
28+
(currently only JLD2) to be used when opening files.
2929
"""
3030
function FieldDataset(filepath;
3131
architecture = CPU(),
3232
grid = nothing,
3333
backend = InMemory(),
3434
metadata_paths = ["metadata"],
35-
reader_kw = Dict{Symbol, Any}())
35+
reader_kw = NamedTuple())
3636

3737
file = jldopen(filepath; reader_kw...)
3838

src/OutputReaders/field_time_series.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ function FieldTimeSeries(loc, grid, times=();
370370
name = nothing,
371371
time_indexing = Linear(),
372372
boundary_conditions = nothing,
373-
reader_kw = Dict{Symbol, Any}())
373+
reader_kw = NamedTuple())
374374

375375
LX, LY, LZ = loc
376376

@@ -439,8 +439,8 @@ Keyword arguments
439439
comparison to recorded save times. Defaults to times associated with `iterations`.
440440
Takes precedence over `iterations` if `times` is specified.
441441
442-
- `reader_kw`: A dictionary of keyword arguments to pass to the reader (currently only JLD2)
443-
to be used when opening files.
442+
- `reader_kw`: A named tuple or dictionary of keyword arguments to pass to the reader
443+
(currently only JLD2) to be used when opening files.
444444
"""
445445
function FieldTimeSeries(path::String, name::String;
446446
backend = InMemory(),
@@ -451,7 +451,7 @@ function FieldTimeSeries(path::String, name::String;
451451
time_indexing = Linear(),
452452
iterations = nothing,
453453
times = nothing,
454-
reader_kw = Dict{Symbol, Any}())
454+
reader_kw = NamedTuple())
455455

456456
file = jldopen(path; reader_kw...)
457457

@@ -551,7 +551,7 @@ end
551551
architecture = nothing,
552552
indices = (:, :, :),
553553
boundary_conditions = nothing,
554-
reader_kw = Dict{Symbol, Any}())
554+
reader_kw = NamedTuple())
555555
556556
Load a field called `name` saved in a JLD2 file at `path` at `iter`ation.
557557
Unless specified, the `grid` is loaded from `path`.
@@ -561,7 +561,7 @@ function Field(location, path::String, name::String, iter;
561561
architecture = nothing,
562562
indices = (:, :, :),
563563
boundary_conditions = nothing,
564-
reader_kw = Dict{Symbol, Any}())
564+
reader_kw = NamedTuple())
565565

566566
# Default to CPU if neither architecture nor grid is specified
567567
if isnothing(architecture)

test/test_output_readers.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ end
424424
@testset "FieldDataset{$Backend} parallel reading" begin
425425
@info " Testing FieldDataset{$Backend} parallel reading..."
426426

427-
reader_kw = Dict(:parallel_read => true)
427+
reader_kw = (; parallel_read = true)
428428
ds = FieldDataset(filepath3d; backend=Backend(), reader_kw)
429429

430430
@test ds isa FieldDataset

0 commit comments

Comments
 (0)