Skip to content

Commit ed949c1

Browse files
authored
Fix type promotion with units (#52)
* fix Float32 promote * v0.5
1 parent c7bafc4 commit ed949c1

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ImagePhantoms"
22
uuid = "71a99df6-f52c-4da1-bd2a-69d6f37f3252"
33
authors = ["Jeff Fessler <[email protected]> and contributors"]
4-
version = "0.4.0"
4+
version = "0.5.0"
55

66
[deps]
77
LazyGrids = "7031d0ef-c40d-4431-b2f8-61a8d2f650db"

src/object.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,5 @@ Determine the element type of the Radon transform of an object
239239
Ensures that its precision is at least `Float32`.
240240
"""
241241
function radon_type(::Object{S, D, V, C, A}) where {S, D, V <: Number, C <: RealU, A <: RealU}
242-
return eltype(oneunit(C) * oneunit(V) * one(A) * one(Float32))
242+
return eltype(oneunit(C) * oneunit(V) * one(A) * 1f0) # at least Float32
243243
end

src/object2.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function phantom(
8585
y::AbstractVector,
8686
oa::Array{<:Object2d},
8787
oversample::Int ;
88-
T::DataType = promote_type(eltype.(oa)..., Float32),
88+
T::DataType = eltype(1f0 * oneunit(promote_type(eltype.(oa)...))),
8989
)
9090

9191
oversample < 1 && throw(ArgumentError("oversample $oversample"))

src/object3.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function phantom(
9090
z::AbstractVector,
9191
oa::Array{<:Object3d{S,V}},
9292
oversample::Int;
93-
T::DataType = promote_type(V, Float32),
93+
T::DataType = eltype(oneunit(V) * 1f0), # at least Float32
9494
) where {S, V <: Number}
9595

9696
oversample < 1 && throw(ArgumentError("oversample $oversample"))

0 commit comments

Comments
 (0)