Skip to content

Commit cfccdf4

Browse files
authored
Use Type not DataType (#52)
1 parent 2eebee3 commit cfccdf4

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

docs/lit/examples/2-rotate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jim(image, "Original image")
8181
# Now plan the rotation
8282
# by specifying
8383
# * the image size `nx` (it must be square, so `ny=nx` implicitly)
84-
# * the `DataType` used for the work arrays.
84+
# * the `Type` used for the work arrays.
8585

8686
plan2 = plan_rotate(size(image, 1); T)
8787

docs/lit/examples/3-psf.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Now plan the PSF modeling
7777
by specifying
7878
* the image size (must be square)
7979
* the PSF size: must be `px × pz × ny × nview`
80-
* the `DataType` used for the work arrays.
80+
* the `Type` used for the work arrays.
8181
=#
8282

8383
plan = plan_psf( ; nx, nz, px, T)

src/fft_convolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Convolve 2D image `img` with 2D (symmetric!) kernel `ker` using FFT.
5757
function fft_conv(
5858
img::AbstractMatrix{I},
5959
ker::AbstractMatrix{K};
60-
T::DataType = promote_type(I, K, Float32),
60+
T::Type{<:AbstractFloat} = promote_type(I, K, Float32),
6161
) where {I <: Number, K <: Number}
6262

6363
ker reverse(ker, dims=:) || throw("asymmetric kernel")
@@ -132,7 +132,7 @@ Adjoint of `fft_conv`.
132132
function fft_conv_adj(
133133
img::AbstractMatrix{I},
134134
ker::AbstractMatrix{K};
135-
T::DataType = promote_type(I, K, Float32),
135+
T::Type{<:AbstractFloat} = promote_type(I, K, Float32),
136136
) where {I <: Number, K <: Number}
137137

138138
ker reverse(ker, dims=:) || throw("asymmetric kernel")

src/plan-psf.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import AbstractFFTs
55
import FFTW
66

77
"""
8-
PlanPSF{T,Tf,Ti}( ; nx::Int, nz::Int, px::Int, pz::Int, T::DataType)
8+
PlanPSF{T,Tf,Ti}( ; nx::Int, nz::Int, px::Int, pz::Int, T::Type)
99
Struct for storing work arrays and factors for 2D convolution for one thread.
1010
Each PSF is `px × pz`
1111
- `T` datatype of work arrays (subtype of `AbstractFloat`)
@@ -41,7 +41,7 @@ struct PlanPSF{T, Tf, Ti}
4141
nz::Int = nx,
4242
px::Int = 1,
4343
pz::Int = px,
44-
T::DataType = Float32,
44+
T::Type{<:AbstractFloat} = Float32,
4545
)
4646

4747
T <: AbstractFloat || throw("invalid T=$T")
@@ -84,7 +84,7 @@ end
8484

8585

8686
"""
87-
plan_psf( ; nx::Int, nz::Int, px::Int, pz::Int, nthread::Int, T::DataType)
87+
plan_psf( ; nx::Int, nz::Int, px::Int, pz::Int, nthread::Int, T::Type)
8888
Make Vector of structs for storing work arrays and factors
8989
for 2D convolution with SPECT depth-dependent PSF model,
9090
threaded across planes parallel to detector.
@@ -102,7 +102,7 @@ function plan_psf( ;
102102
px::Int = 1,
103103
pz::Int = px,
104104
nthread::Int = Threads.nthreads(),
105-
T::DataType = Float32,
105+
T::Type{<:AbstractFloat} = Float32,
106106
)
107107
return [PlanPSF( ; nx, nz, px, pz, T) for id in 1:nthread]
108108
end

src/plan-rotate.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct PlanRotate{T, R}
4646

4747
function PlanRotate(
4848
nx::Int ;
49-
T::DataType = Float32,
49+
T::Type{<:AbstractFloat} = Float32,
5050
method::Symbol = :two, # :one is for 1d interpolation, :two is for 2d interpolation
5151
)
5252

@@ -78,7 +78,7 @@ end
7878

7979

8080
"""
81-
plan_rotate(nx::Int; T::DataType, method::Symbol)
81+
plan_rotate(nx::Int; T::Type{<:AbstractFloat}, method::Symbol)
8282
Make `Vector` of `PlanRotate` structs
8383
for storing work arrays and factors
8484
for threaded rotation of a stack of 2D square images.
@@ -95,7 +95,7 @@ for threaded rotation of a stack of 2D square images.
9595
"""
9696
function plan_rotate(
9797
nx::Int ;
98-
T::DataType = Float32,
98+
T::Type{<:AbstractFloat} = Float32,
9999
method::Symbol = :two,
100100
nthread::Int = Threads.nthreads(),
101101
)

src/psf-gauss.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ having specified full-width half-maximum (FHWM) values.
1717
- 'fwhm::AbstractVector{<:Real} = range(fwhm_start, fwhm_end, ny)'
1818
- 'fwhm_x::AbstractVector{<:Real} = fwhm,
1919
- 'fwhm_z::AbstractVector{<:Real} = fwhm_x'
20-
- 'T::DataType == Float32'
20+
- 'T::Type == Float32'
2121
2222
Returned `psf` is `[px, pz, ny]` where each PSF sums to 1.
2323
"""
@@ -30,7 +30,7 @@ function psf_gauss( ;
3030
fwhm::AbstractVector{<:Real} = range(fwhm_start, fwhm_end, ny),
3131
fwhm_x::AbstractVector{<:Real} = fwhm,
3232
fwhm_z::AbstractVector{<:Real} = fwhm_x,
33-
T::DataType = Float32,
33+
T::Type{<:AbstractFloat} = Float32,
3434
)
3535
isodd(px) || @warn("even px = $px ?")
3636
isodd(pz) || @warn("even pz = $pz ?")

src/rotatez.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function imrotate(
371371
img::AbstractMatrix{I},
372372
θ::RealU;
373373
method::Symbol=:two,
374-
T::DataType = promote_type(I, Float32),
374+
T::Type{<:AbstractFloat} = promote_type(I, Float32),
375375
) where {I <: Number}
376376
output = similar(Matrix{T}, size(img))
377377
plan = plan_rotate(size(img, 1); T, nthread = 1, method)[1]
@@ -424,7 +424,7 @@ function imrotate_adj(
424424
img::AbstractMatrix{I},
425425
θ::RealU;
426426
method::Symbol=:two,
427-
T::DataType = promote_type(I, Float32),
427+
T::Type{<:AbstractFloat} = promote_type(I, Float32),
428428
) where {I <: Number}
429429
output = similar(Matrix{T}, size(img))
430430
plan = plan_rotate(size(img, 1); T, nthread = 1, method)[1]

src/spectplan.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Currently code assumes the following:
3030
* multiprocessing using # of threads specified by `Threads.nthreads()`
3131
"""
3232
struct SPECTplan{T}
33-
T::DataType # default type for work arrays etc.
33+
T::Type{<:AbstractFloat} # default type for work arrays etc.
3434
imgsize::NTuple{3, Int}
3535
px::Int
3636
pz::Int
@@ -56,7 +56,7 @@ struct SPECTplan{T}
5656
mumap::Array{<:RealU, 3},
5757
psfs::Array{<:RealU, 4},
5858
dy::RealU;
59-
T::DataType = promote_type(eltype(mumap), Float32),
59+
T::Type{<:AbstractFloat} = promote_type(eltype(mumap), Float32),
6060
viewangle::StepRangeLen{<:RealU} = (0:size(psfs, 4) - 1) / size(psfs, 4) * T(2π), # set of view angles
6161
interpmeth::Symbol = :two, # :one is for 1d interpolation, :two is for 2d interpolation
6262
nthread::Int = Threads.nthreads(),

0 commit comments

Comments
 (0)