Skip to content

Commit

Permalink
aqua tests & reduction of ambiguities
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasIsensee committed Oct 16, 2024
1 parent 16c3448 commit f8b8190
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# JLD2

| **Documentation** | **Tests** | **CodeCov** | **Downloads** |
|:--------:|:---------------:|:-------:|:---:|
|[![](https://img.shields.io/badge/docs-online-blue.svg)](https://JuliaIO.github.io/JLD2.jl/dev)| [![CI](https://github.com/JuliaIO/JLD2.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/JuliaIO/JLD2.jl/actions/workflows/ci.yml) | [![codecov.io](https://codecov.io/github/JuliaIO/JLD2.jl/coverage.svg?branch=master)](https://codecov.io/github/JuliaIO/JLD2.jl?branch=master) | [![JLD2 Downloads](https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Fmonthly_downloads%2FJLD2&query=total_requests&suffix=%2Fmonth&label=Downloads)](http://juliapkgstats.com/pkg/JLD2) |
[![](https://img.shields.io/badge/docs-online-blue.svg)](https://JuliaIO.github.io/JLD2.jl/dev)
[![CI](https://github.com/JuliaIO/JLD2.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/JuliaIO/JLD2.jl/actions/workflows/ci.yml)
[![codecov.io](https://codecov.io/github/JuliaIO/JLD2.jl/coverage.svg?branch=master)](https://codecov.io/github/JuliaIO/JLD2.jl?branch=master)
[![JLD2 Downloads](https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Fmonthly_downloads%2FJLD2&query=total_requests&suffix=%2Fmonth&label=Downloads)](http://juliapkgstats.com/pkg/JLD2)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)


JLD2 saves and loads Julia data structures in a format comprising a subset of HDF5, without any dependency on the HDF5 C library.
JLD2 is able to read most HDF5 files created by other HDF5 implementations supporting HDF5 File Format Specification Version 3.0 (i.e. libhdf5 1.10 or later) and similarly those should be able to read the files that JLD2 produces. JLD2 provides read-only support for files created with the JLD package.
Expand Down
4 changes: 2 additions & 2 deletions src/data/specialcased_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ end
# convert to an array instead.
const NTUPLE_INLINE_THRESHOLD = 10

function writeas(NT::Type{NTuple{N,T}}) where {N,T}
if N > NTUPLE_INLINE_THRESHOLD
function writeas(NT::Type{Tuple{T, Vararg{T,N}}}) where {N,T}
if (N+1) > NTUPLE_INLINE_THRESHOLD
return Vector{T}
else
return NT
Expand Down
2 changes: 1 addition & 1 deletion src/io/io_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function _read(io::RWBuffer, T::DataType)
end
# needed explicitly for avoiding ambiguities
Base.read(io::RWBuffer, T::Type{UInt8}) = _read(io, T)
Base.read(io::RWBuffer, T::PlainType) = _read(io, T)
#Base.read(io::RWBuffer, T::PlainType) = _read(io, T)
Base.write(io::RWBuffer, x::UInt8) = _write(io, x)
jlwrite(io::RWBuffer, x::String) = _write(io, x)

Expand Down
2 changes: 1 addition & 1 deletion src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function flag2uint(flag::UInt8)
end


jlread(io::IO, ::Type{NTuple{N,T}}) where {N,T} = ntuple(_->jlread(io, T), Val{N}())
jlread(io::IO, ::Type{Tuple{T, Vararg{T,N}}}) where {N,T} = ntuple(_->jlread(io, T), Val{N+1}())
jlread(io::IO, ::Type{Tuple{}}) = ()

function write_nb_int(io::IO, sz::Integer, nb::Integer)
Expand Down
2 changes: 1 addition & 1 deletion src/object_headers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Hmessage{IO}
m::Message{IO}
end

function write_header_message(io, vtype::Val{HMT}, hflags=0x00, size=0; kwargs...) where HMT
function write_header_message(io, vtype::Val{HMT}, hflags::Integer=0x00, size=0; kwargs...) where HMT
kw = (; kwargs...)
size = compute_size(vtype, hflags, size, kw)
jlwrite(io, UInt8(HMT))
Expand Down
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
CodecLz4 = "5ba52731-8f18-5e0d-9241-30f10d1ec561"
Expand All @@ -10,4 +11,5 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
17 changes: 17 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ include("unpack_test.jl")
include("dataset_api.jl")
include("mmap_test.jl")
include("wrapped_io.jl")

using TestItemRunner

@run_package_tests

@testitem "Aqua Testing" begin
using Aqua
Aqua.test_all(JLD2;
ambiguities = (;
# Some jlconvert methods are ambiguous for pathological type combinations
broken=true,
),
deps_compat = (;
ignore = [:Mmap,],
),
)
end

0 comments on commit f8b8190

Please sign in to comment.