Skip to content

Commit

Permalink
Merge pull request #184 from aplavin/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mileslucas authored Aug 31, 2022
2 parents 6f7aef2 + 77e0b4f commit 9d6ce04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FITSIO"
uuid = "525bcba6-941b-5504-bd06-fd0dc1a4d2eb"
version = "0.16.12"
version = "0.17.0"

[deps]
CFITSIO = "3b1b4be9-1499-4b22-8d78-7db3344d1961"
Expand Down
1 change: 1 addition & 0 deletions src/FITSIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Base: getindex,
close,
ndims,
size,
get,
getkey,
haskey,
keys,
Expand Down
5 changes: 3 additions & 2 deletions src/header.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,9 @@ Array of values in header of HDU (not a copy).
"""
values(hdr::FITSHeader) = hdr.values

getkey(hdr::FITSHeader, key::String, def) =
(haskey(hdr, key) ? getindex(hdr, key) : def)
getkey(hdr::FITSHeader, key::String, default) = haskey(hdr, key) ? key : default
get(hdr::FITSHeader, key::String, default) = haskey(hdr, key) ? hdr[key] : default
get(f::Function, hdr::FITSHeader, key::String) = haskey(hdr, key) ? hdr[key] : f()

getindex(hdr::FITSHeader, key::String) = hdr.values[hdr.map[key]]
getindex(hdr::FITSHeader, i::Integer) = hdr.values[i]
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,11 @@ HISTORY this is a history"""
# Test reading possibly missing keyword
@test_throws KeyError inhdr["BADKEY"]
@test getkey(inhdr, "BADKEY", nothing) === nothing
@test getkey(inhdr, "INTKEY", nothing) == inhdr["INTKEY"]
@test getkey(inhdr, "INTKEY", nothing) == "INTKEY"
@test get(inhdr, "BADKEY", nothing) === nothing
@test get(inhdr, "INTKEY", nothing) == inhdr["INTKEY"]
@test get(() -> nothing, inhdr, "BADKEY") == nothing
@test get(() -> nothing, inhdr, "INTKEY") == inhdr["INTKEY"]

indata = reshape(Float32[1:100;], 5, 20)
write(f, indata; header=inhdr)
Expand Down

2 comments on commit 9d6ce04

@mileslucas
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/67451

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.17.0 -m "<description of version>" 9d6ce04d9d32041ecd562d7c2e6f7e527c39bfeb
git push origin v0.17.0

Please sign in to comment.