From 42d4cb5b8c2ec918ac6be565b7d2b9032a4ad3f5 Mon Sep 17 00:00:00 2001 From: ali-ramadhan Date: Tue, 5 Nov 2024 14:59:36 -0700 Subject: [PATCH 1/2] For output readers, make `reader_kw` default to an empty `NamedTuple` --- src/OutputReaders/field_dataset.jl | 6 +++--- src/OutputReaders/field_time_series.jl | 12 ++++++------ test/test_output_readers.jl | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OutputReaders/field_dataset.jl b/src/OutputReaders/field_dataset.jl index cf22389ce2..9dbe0433f4 100644 --- a/src/OutputReaders/field_dataset.jl +++ b/src/OutputReaders/field_dataset.jl @@ -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...) diff --git a/src/OutputReaders/field_time_series.jl b/src/OutputReaders/field_time_series.jl index a07377e22c..c9188f9c9d 100644 --- a/src/OutputReaders/field_time_series.jl +++ b/src/OutputReaders/field_time_series.jl @@ -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 @@ -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(), @@ -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...) @@ -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`. @@ -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) diff --git a/test/test_output_readers.jl b/test/test_output_readers.jl index 7d4657cd81..a9435123bb 100644 --- a/test/test_output_readers.jl +++ b/test/test_output_readers.jl @@ -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 From 6f32f8eb57adcefe67373365a0bc4d47e328bb50 Mon Sep 17 00:00:00 2001 From: Ali Ramadhan Date: Tue, 5 Nov 2024 16:17:23 -0700 Subject: [PATCH 2/2] Update test/test_output_readers.jl Co-authored-by: Gregory L. Wagner --- test/test_output_readers.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_output_readers.jl b/test/test_output_readers.jl index a9435123bb..592cd21fc5 100644 --- a/test/test_output_readers.jl +++ b/test/test_output_readers.jl @@ -390,7 +390,7 @@ end @testset "FieldDataset{$Backend} parallel reading" begin @info " Testing FieldDataset{$Backend} parallel reading..." - reader_kw = (parallel_read = true,) + reader_kw = (; parallel_read = true) ds = FieldDataset(filepath3d; backend=Backend(), reader_kw) @test ds isa FieldDataset