Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For output readers, make reader_kw default to an empty NamedTuple #3902

Merged
merged 4 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/OutputReaders/field_dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ linearly.

- `grid`: May be specified to override the grid used in the JLD2 file.

- `reader_kw`: A dictionary of keyword arguments to pass to the reader (currently only JLD2)
to be used when opening files.
- `reader_kw`: A named tuple or dictionary of keyword arguments to pass to the reader
(currently only JLD2) to be used when opening files.
"""
function FieldDataset(filepath;
architecture = CPU(),
grid = nothing,
backend = InMemory(),
metadata_paths = ["metadata"],
reader_kw = Dict{Symbol, Any}())
reader_kw = NamedTuple())

file = jldopen(filepath; reader_kw...)

Expand Down
12 changes: 6 additions & 6 deletions src/OutputReaders/field_time_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function FieldTimeSeries(loc, grid, times=();
name = nothing,
time_indexing = Linear(),
boundary_conditions = nothing,
reader_kw = Dict{Symbol, Any}())
reader_kw = NamedTuple())

LX, LY, LZ = loc

Expand Down Expand Up @@ -439,8 +439,8 @@ Keyword arguments
comparison to recorded save times. Defaults to times associated with `iterations`.
Takes precedence over `iterations` if `times` is specified.

- `reader_kw`: A dictionary of keyword arguments to pass to the reader (currently only JLD2)
to be used when opening files.
- `reader_kw`: A named tuple or dictionary of keyword arguments to pass to the reader
(currently only JLD2) to be used when opening files.
"""
function FieldTimeSeries(path::String, name::String;
backend = InMemory(),
Expand All @@ -451,7 +451,7 @@ function FieldTimeSeries(path::String, name::String;
time_indexing = Linear(),
iterations = nothing,
times = nothing,
reader_kw = Dict{Symbol, Any}())
reader_kw = NamedTuple())

file = jldopen(path; reader_kw...)

Expand Down Expand Up @@ -549,7 +549,7 @@ end
architecture = nothing,
indices = (:, :, :),
boundary_conditions = nothing,
reader_kw = Dict{Symbol, Any}())
reader_kw = NamedTuple())

Load a field called `name` saved in a JLD2 file at `path` at `iter`ation.
Unless specified, the `grid` is loaded from `path`.
Expand All @@ -559,7 +559,7 @@ function Field(location, path::String, name::String, iter;
architecture = nothing,
indices = (:, :, :),
boundary_conditions = nothing,
reader_kw = Dict{Symbol, Any}())
reader_kw = NamedTuple())

# Default to CPU if neither architecture nor grid is specified
if isnothing(architecture)
Expand Down
2 changes: 1 addition & 1 deletion test/test_output_readers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ end
@testset "FieldDataset{$Backend} parallel reading" begin
@info " Testing FieldDataset{$Backend} parallel reading..."

reader_kw = Dict(:parallel_read => true)
reader_kw = (parallel_read = true,)
ds = FieldDataset(filepath3d; backend=Backend(), reader_kw)

@test ds isa FieldDataset
Expand Down