Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

### Changed

- **Breaking**: `CDF_CHAR`/`CDF_UCHAR` variables have eltype `String` (trailing null padding stripped); `StaticString` is removed. Avoids a recompile for each new string width ([#79]).
- **Breaking**: variable attributes are returned as stored: `LABL_PTR_i` is the label variable's name, no longer resolved to its labels (ISTP conventions live in CDFDatasets). `fillvalue` moved to CDFDatasets.

## [0.4.2] - 2026-10-06

### Fixed

- Sparse and unwritten records read as the pad value, or the previous physical record for previous-record sparse variables, instead of uninitialized memory (e.g. THEMIS `th?_fgm_*_quality`).
- Sparse and unwritten records read as the pad value, or the previous physical record for previous-record sparse variables, instead of uninitialized memory.

## [0.4.0] - 2026-10-06

### Changed

- **Breaking**: `CDF_CHAR`/`CDF_UCHAR` variables have eltype `String` (trailing null padding stripped); `StaticString` is removed. Avoids a recompile for each new string width ([#79]).

## [0.3.0] - 2026-10-02

Expand All @@ -33,7 +41,9 @@

- **Breaking**: Renamed exported enum `DataType` to `CDFDataType` ([#46]) as the old name collided with `Base.DataType`.

[Unreleased]: https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/compare/v0.3.0...HEAD
[Unreleased]: https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/compare/v0.4.5...HEAD
[0.4.2]: https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/compare/v0.4.1...v0.4.2
[0.4.0]: https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/compare/v0.3.2...v0.4.0
[0.3.0]: https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/releases/tag/v0.2.0

Expand Down
Binary file removed data/labl_ptr.cdf
Binary file not shown.
13 changes: 0 additions & 13 deletions data/make_labl_ptr.py

This file was deleted.

1 change: 0 additions & 1 deletion src/CommonDataFormat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ include("parsing.jl")
include("decompress.jl")
include("records/records.jl")
include("variable.jl")
include("vattribute.jl")
include("dataset.jl")
include("loading/attribute.jl")
include("loading/variable.jl")
Expand Down
16 changes: 2 additions & 14 deletions src/loading/attribute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ function Base.iterate(la::LazyVAttrib, offset::Int = Int(la.cdf.gdr.ADRhead))
next_offset = Int(adr.ADRnext)
found = _search_aedr_entries(buffer, _entry_head(la, adr), RecordSizeType, needs_byte_swap, la.varnum)
if !isnothing(found)
name = adr_name(buffer, adr)
return (name => _get_attributes(name, found, la.cdf), next_offset)
return (adr_name(buffer, adr) => found, next_offset)
end
offset = next_offset
end
Expand Down Expand Up @@ -98,7 +97,7 @@ function Base.get(la::LazyVAttrib, name::AbstractString, default = nothing)
name_equals(buffer, _adr_name_pos(offset, RecordSizeType), name_str, RecordSizeType) || continue
adr = ADR{RecordSizeType}(buffer, offset)
found = _search_aedr_entries(buffer, _entry_head(la, adr), RecordSizeType, needs_byte_swap, varnum)
return isnothing(found) ? default : _get_attributes(name, found, cdf)
return isnothing(found) ? default : found
end
return default
end
Expand All @@ -108,17 +107,6 @@ Base.get(la::LazyVAttrib, name, default = nothing) = default
Base.haskey(la::LazyVAttrib, name::AbstractString) = !isnothing(get(la, name, nothing))
Base.haskey(la::LazyVAttrib, name) = false

# Handle pointers like LABL_PTR_1
# https://github.com/SciQLop/PyISTP/blob/0a565c39c73dd800934bc379dd7c2e00c28d23d0/pyistp/_impl.py#L16
function _get_attributes(name, value, cdf)
occursin("LABL_PTR", name) && value isa String || return value
vdr = find_vdr(cdf, value)
# Dangling pointers exist in the wild (e.g. IM_K0_EUV); keep the raw name.
isnothing(vdr) && return value
# `Array` skips DiskArrays indexing
return vec(Array(_variable(cdf, value, vdr)))
end

@inline function _search_aedr_entries(source, aedr_head, ::Type{RecordSizeType}, needs_byte_swap, target_varnum) where {RecordSizeType}
aedr_head == 0 && return nothing
offset = Int(aedr_head)
Expand Down
14 changes: 0 additions & 14 deletions src/vattribute.jl

This file was deleted.

6 changes: 0 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ end
@test ds["CU"][1:3] == Float32[76.23, 78.16, 81.24]
end

@testset "LABL_PTR to a missing variable" begin
ds = CDFDataset(data_path("labl_ptr.cdf"))
@test ds["dangling"].attrib["LABL_PTR_1"] == "CARTESIAN"
@test ds["ok"].attrib["LABL_PTR_1"] == ["Bx", "By", "Bz"]
end

@testset "scalar r-variable" begin
ds = CDFDataset(data_path("scalar_rvar.cdf"))
var = ds["x"]
Expand Down
Loading