Skip to content

Commit

Permalink
Make showing of daf objects use the describe function.
Browse files Browse the repository at this point in the history
  • Loading branch information
orenbenkiki committed Mar 28, 2024
1 parent b14ada4 commit 2f1433c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/v0.1.0/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-27T17:36:40","documenter_version":"1.3.0"}}
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-28T10:11:10","documenter_version":"1.3.0"}}
5 changes: 5 additions & 0 deletions src/formats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ All the functions for this type are provided based on the functions required for
"""
abstract type DafWriter <: FormatWriter end

function Base.show(io::IO, format_reader::FormatReader)::Nothing
print(io, describe(format_reader))
return nothing
end

"""
format_has_scalar(format::FormatReader, name::AbstractString)::Bool
Expand Down
32 changes: 16 additions & 16 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2920,9 +2920,9 @@ nested_test("data") do
nested_test("memory") do
daf = MemoryDaf(; name = "memory!")
@test daf.name == "memory!"
@test describe(daf) == "MemoryDaf memory!"
@test describe(read_only(daf)) == "ReadOnly MemoryDaf memory!"
@test describe(read_only(daf; name = "read-only memory!")) == "ReadOnly MemoryDaf read-only memory!"
@test string(daf) == "MemoryDaf memory!"
@test string(read_only(daf)) == "ReadOnly MemoryDaf memory!"
@test string(read_only(daf; name = "read-only memory!")) == "ReadOnly MemoryDaf read-only memory!"
@test description(daf) == dedent("""
name: memory!
type: MemoryDaf
Expand Down Expand Up @@ -2962,17 +2962,17 @@ nested_test("data") do
mktempdir() do path
daf = H5df("$(path)/test.h5df", "w+"; name = "h5df!")
@test daf.name == "h5df!"
@test describe(daf) == "H5df h5df!"
@test describe(read_only(daf)) == "ReadOnly H5df h5df!"
@test describe(read_only(daf; name = "renamed!")) == "ReadOnly H5df renamed!"
@test string(daf) == "H5df h5df!"
@test string(read_only(daf)) == "ReadOnly H5df h5df!"
@test string(read_only(daf; name = "renamed!")) == "ReadOnly H5df renamed!"
@test description(daf) == dedent("""
name: h5df!
type: H5df
""") * "\n"
test_format(daf)
daf = H5df(path * "/test.h5df", "r+")
@test daf.name == "$(path)/test.h5df"
@test describe(daf) == "H5df $(path)/test.h5df"
@test string(daf) == "H5df $(path)/test.h5df"
return nothing
end
end
Expand All @@ -2982,9 +2982,9 @@ nested_test("data") do
h5open(path * "/test.h5df", "w"; fapl = HDF5.FileAccessProperties(; alignment = (1, 8))) do h5file
HDF5.create_group(h5file, "root")
daf = H5df(h5file["root"], "w+")
@test describe(daf) == "H5df $(path)/test.h5df:/root"
@test describe(read_only(daf)) == "ReadOnly H5df $(path)/test.h5df:/root"
@test describe(read_only(daf; name = "renamed!")) == "ReadOnly H5df renamed!"
@test string(daf) == "H5df $(path)/test.h5df:/root"
@test string(read_only(daf)) == "ReadOnly H5df $(path)/test.h5df:/root"
@test string(read_only(daf; name = "renamed!")) == "ReadOnly H5df renamed!"
@test description(daf) == dedent("""
name: $(path)/test.h5df:/root
type: H5df
Expand All @@ -3000,7 +3000,7 @@ nested_test("data") do

daf = H5df(h5file["root"], "w"; name = "h5df!")
@test daf.name == "h5df!"
@test describe(daf) == "H5df h5df!"
@test string(daf) == "H5df h5df!"
@assert length(attributes(h5file["root"])) == 0
return nothing
end
Expand Down Expand Up @@ -3031,9 +3031,9 @@ nested_test("data") do
path = path * "/test"
daf = FilesDaf(path, "w+"; name = "files!")
@test daf.name == "files!"
@test describe(daf) == "FilesDaf files!"
@test describe(read_only(daf)) == "ReadOnly FilesDaf files!"
@test describe(read_only(daf; name = "renamed!")) == "ReadOnly FilesDaf renamed!"
@test string(daf) == "FilesDaf files!"
@test string(read_only(daf)) == "ReadOnly FilesDaf files!"
@test string(read_only(daf; name = "renamed!")) == "ReadOnly FilesDaf renamed!"
@test description(daf) == dedent("""
name: files!
type: FilesDaf
Expand All @@ -3045,9 +3045,9 @@ nested_test("data") do
write(path * "/scalars/name.json", "{\"type\":\"String\",\"value\":\"files!\"}\n")
daf = FilesDaf(path, "r")
@assert isdir(path * "/deleted")
@test describe(daf) == "ReadOnly FilesDaf files!"
@test string(daf) == "ReadOnly FilesDaf files!"
daf = FilesDaf(path, "w"; name = "empty!")
@test describe(daf) == "FilesDaf empty!"
@test string(daf) == "FilesDaf empty!"
@assert !ispath(path * "/deleted")
return nothing
end
Expand Down

0 comments on commit 2f1433c

Please sign in to comment.