diff --git a/src/loading/variable.jl b/src/loading/variable.jl index c412ad8..97d596c 100644 --- a/src/loading/variable.jl +++ b/src/loading/variable.jl @@ -71,30 +71,6 @@ end @inline _construct(cdf, name, vdr, dims::NTuple{N, Int}, ::Type{T}) where {N, T} = CDFVariable{T, N, typeof(vdr), typeof(cdf)}(name, vdr, cdf, dims) -""" - read!(ds::CDFDataset, name, dest::AbstractArray{T, N}) -> dest - -Read the full contents of variable `name` into the preallocated `dest`. -""" -function Base.read!(ds::CDFDataset, name::String, dest::AbstractArray{T, N}) where {T, N} - vdr = find_vdr(ds, name) - isnothing(vdr) && throw(KeyError(name)) - return _read_full!(dest, ds, name, vdr) -end - -""" - read(ds::CDFDataset, name, ::Type{Array{T, N}}) -> Array{T, N} - -Allocating variant of [`read!`](@ref): read the full contents of variable `name` into a -freshly allocated `Array{T, N}`. -""" -function Base.read(ds::CDFDataset, name::String, ::Type{Array{T, N}}) where {T, N} - vdr = find_vdr(ds, name) - isnothing(vdr) && throw(KeyError(name)) - dims = (map(Int, record_sizes(vdr, ds, Val(N - 1)))..., Int(vdr.max_rec) + 1) - return _read_full!(Array{T, N}(undef, dims), ds, name, vdr) -end - function _read_full!(dest::AbstractArray{T, N}, ds, name, vdr) where {T, N} Base.require_one_based_indexing(dest) Tfile = julia_type(vdr.data_type, vdr.num_elems) diff --git a/src/records/vdr.jl b/src/records/vdr.jl index 4513fcf..36f8652 100644 --- a/src/records/vdr.jl +++ b/src/records/vdr.jl @@ -74,9 +74,6 @@ Load an r-Variable Descriptor Record from the buffer at the specified offset. return rVDR{FieldSizeT}(fields..., pos) end - -# Static-arity variants for the typed `read!` path: the caller supplies the dimension -# count via `Val`, so tuple lengths stay inferable under `juliac --trim`. function record_sizes(vdr::VDR, cdf, ::Val{M}) where {M} vdr.num_dims == M || throw(DimensionMismatch("variable has $(vdr.num_dims) dimensions, expected $M")) diff --git a/test/cdf_trim_probe.jl b/test/cdf_trim_probe.jl index 7bf6323..c62ee91 100644 --- a/test/cdf_trim_probe.jl +++ b/test/cdf_trim_probe.jl @@ -7,11 +7,5 @@ function (@main)(args::Vector{String}) ds.majority == CDF.Row && ds.compression == CDF.NoCompression && length(keys(ds)) > 0 - # Typed data reads: z-variable (VDR) 1D + 2D with row-major swap. - v = read!(ds, "var", Vector{Float64}(undef, 101)) - ok &= v[1] == 1.0 - m = read!(ds, "var2d_counter", Matrix{Float64}(undef, 10, 10)) - ok &= m[1, 1] == 0.0 && m[2, 1] == 1.0 && m[10, 10] == 99.0 - ok &= read(ds, "var2d_counter", Matrix{Float64}) == m return ok ? 0 : 1 end diff --git a/test/runtests.jl b/test/runtests.jl index 6b6fcf8..0b499d1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -71,30 +71,6 @@ end @test occursin("attributes: ", sprint(show, MIME("text/plain"), ds["var"])) end -@testset "read! typed entry point" begin - ds = CDFDataset(data_path("a_cdf.cdf")) - v = read!(ds, "var", Vector{Float64}(undef, 101)) - @test v == ds["var"][:] - m = read!(ds, "var2d_counter", Matrix{Float64}(undef, 10, 10)) - @test m == reshape(0.0:99.0, 10, 10) - @test_throws KeyError read!(ds, "nonexistent", zeros(1)) - @test_throws ArgumentError read!(ds, "var", zeros(Float32, 101)) - @test_throws DimensionMismatch read!(ds, "var", zeros(100)) - @test_throws DimensionMismatch read!(ds, "var", zeros(101, 1)) - - @test read(ds, "var", Vector{Float64}) == v - @test read(ds, "var2d_counter", Matrix{Float64}) == m - @test_throws KeyError read(ds, "nonexistent", Vector{Float64}) - @test_throws ArgumentError read(ds, "var", Vector{Float32}) - @test_throws DimensionMismatch read(ds, "var", Matrix{Float64}) - - rds = CDFDataset(data_path("ac_h0_mfi_20230102_v07.cdf")) - rvar = rds["BGSEc"] - b = read!(rds, "BGSEc", Matrix{eltype(rvar)}(undef, size(rvar))) - @test b == rvar[:, :] - @test read(rds, "BGSEc", Matrix{eltype(rvar)}) == b -end - @testset "Compressed cdf file (gzip)" begin compressed = CDFDataset(data_path("a_compressed_cdf.cdf")) reference = CDFDataset(data_path("a_cdf.cdf")) diff --git a/test/trim.jl b/test/trim.jl index 72614c0..22c8664 100644 --- a/test/trim.jl +++ b/test/trim.jl @@ -5,10 +5,8 @@ # stray dynamic dispatch (e.g. a record-size type passed as a value instead of `::Type{T}`, # or `getproperty` dragging in the heterogeneous attribute machinery) fails the verifier. # -# Data reading is covered through the typed entry point `read!(ds, name, dest)`, where -# eltype/ndims come from `dest` instead of the file. The generic `ds[name]` path stays -# out of scope: its element type is only known at runtime, so it cannot be statically -# resolved. +# The generic `ds[name]` path stays out of scope: its element type is only known at runtime, +# so it cannot be statically resolved. using Test