Skip to content

Commit

Permalink
Fix type promotion with units (#52)
Browse files Browse the repository at this point in the history
* fix Float32 promote

* v0.5
  • Loading branch information
JeffFessler authored Sep 21, 2022
1 parent c7bafc4 commit ed949c1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ImagePhantoms"
uuid = "71a99df6-f52c-4da1-bd2a-69d6f37f3252"
authors = ["Jeff Fessler <fessler@umich.edu> and contributors"]
version = "0.4.0"
version = "0.5.0"

[deps]
LazyGrids = "7031d0ef-c40d-4431-b2f8-61a8d2f650db"
Expand Down
2 changes: 1 addition & 1 deletion src/object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,5 @@ Determine the element type of the Radon transform of an object
Ensures that its precision is at least `Float32`.
"""
function radon_type(::Object{S, D, V, C, A}) where {S, D, V <: Number, C <: RealU, A <: RealU}
return eltype(oneunit(C) * oneunit(V) * one(A) * one(Float32))
return eltype(oneunit(C) * oneunit(V) * one(A) * 1f0) # at least Float32
end
2 changes: 1 addition & 1 deletion src/object2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function phantom(
y::AbstractVector,
oa::Array{<:Object2d},
oversample::Int ;
T::DataType = promote_type(eltype.(oa)..., Float32),
T::DataType = eltype(1f0 * oneunit(promote_type(eltype.(oa)...))),
)

oversample < 1 && throw(ArgumentError("oversample $oversample"))
Expand Down
2 changes: 1 addition & 1 deletion src/object3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function phantom(
z::AbstractVector,
oa::Array{<:Object3d{S,V}},
oversample::Int;
T::DataType = promote_type(V, Float32),
T::DataType = eltype(oneunit(V) * 1f0), # at least Float32
) where {S, V <: Number}

oversample < 1 && throw(ArgumentError("oversample $oversample"))
Expand Down

2 comments on commit ed949c1

@JeffFessler
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() register

@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/68704

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.5.0 -m "<description of version>" ed949c143a19fd0cdea5024ec491730e6024cc21
git push origin v0.5.0

Please sign in to comment.