Skip to content

Commit

Permalink
Int64 -> Int
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbauer authored Jul 25, 2024
1 parent 7496607 commit 86659e4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions src/ErrorPropagation/binning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct ErrorPropagator{T, N} <: AbstractBinner{T}
# ∑xy
sums2D::NTuple{N, Matrix{T}}

count::Vector{Int64}
count::Vector{Int}
end


Expand All @@ -32,7 +32,7 @@ Base.isempty(ep::ErrorPropagator) = length(ep) == 0
Base.:(!=)(a::ErrorPropagator, b::ErrorPropagator) = !(a == b)
function Base.:(==)(a::ErrorPropagator, b::ErrorPropagator)
length(a.count) > length(b.count) && return b == a

for i in eachindex(a.count)
a.compressors[i] == b.compressors[i] || return false
a.sums1D[i] == b.sums1D[i] || return false
Expand All @@ -45,7 +45,7 @@ end

function Base.isapprox(a::ErrorPropagator, b::ErrorPropagator; kwargs...)
length(a.count) > length(b.count) && return b == a

for i in eachindex(a.count)
isapprox(a.compressors[i], b.compressors[i]; kwargs...) || return false
isapprox(a.sums1D[i], b.sums1D[i]; kwargs...) || return false
Expand Down Expand Up @@ -154,7 +154,7 @@ for each of `N_args` inputs of type `T`.
The default is `T = Float64`, `N_args = 2` and `capacity = 2^32-1 ≈ 4e9`.
"""
function ErrorPropagator(::Type{T} = Float64; N_args::Int64 = 2, kw...) where T
function ErrorPropagator(::Type{T} = Float64; N_args::Int = 2, kw...) where T
ErrorPropagator([zero(T) for _ in 1:N_args]...; kw...)
end

Expand All @@ -176,7 +176,7 @@ Creates a new `ErrorPropagator` and adds all elements from each given timeseries
"""
function ErrorPropagator(
xs::T...;
capacity::Int64 = _nlvls2capacity(32)
capacity::Int = _nlvls2capacity(32)
) where {T <: Union{Number, AbstractArray}}

# check keyword args
Expand Down Expand Up @@ -211,7 +211,7 @@ function ErrorPropagator(
[copy(el) for _ in 1:length(xs), __ in 1:length(xs)]
for __ in 1:N
]...),
zeros(Int64, N)
zeros(Int, N)
)

got_timeseries && append!(ep, xs...)
Expand Down Expand Up @@ -262,7 +262,7 @@ end
@inline _mult(x::AbstractArray, y::AbstractArray) = _mult.(x, y)

# recursion, back-end function
@inline function _push!(ep::ErrorPropagator{T, N}, lvl::Int64, args) where {T, N}
@inline function _push!(ep::ErrorPropagator{T, N}, lvl::Int, args) where {T, N}
@boundscheck begin
(length(args) == length(ep.sums1D[1])) || throw(DimensionMismatch(
"Number of arguments $(length(args)) does not match the number " *
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorPropagation/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# standard error estimate:
# Take the highest lvl with at least 32 bins.
# (Chose 32 based on https://doi.org/10.1119/1.3247985)
function _reliable_level(B::ErrorPropagator{T,N})::Int64 where {T,N}
function _reliable_level(B::ErrorPropagator{T,N})::Int where {T,N}
isempty(B) && (return 1) # results in NaN in std_error
i = findlast(x -> x >= 32, B.count)
return something(i, 1)
Expand Down
18 changes: 9 additions & 9 deletions src/incrementing/IncrementBinner.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mutable struct IncrementBinner{T}
keep::Int64 # number of values per block
compression::Int64 # current N-mean
stage::Int64 # stage * keep == current max length
keep::Int # number of values per block
compression::Int # current N-mean
stage::Int # stage * keep == current max length

# for local averages
sum::T
count::Int64
count::Int

output::Vector{T}
end
Expand All @@ -24,9 +24,9 @@ Base.show(io::IO, B::IncrementBinner{T}) where {T} = print(io, "IncrementBinner{
Creates an `IncrementBinner` from a `zero_element` numeric type `T`.
Values pushed to an `IncrementBinner` are averaged in stages. For the first
Values pushed to an `IncrementBinner` are averaged in stages. For the first
`blocksize` values pushed no averaging happens. After that `2blocksize` elements
are averaged 2 at a time, then `4blocksize` element 4 at a time, etc. This means
are averaged 2 at a time, then `4blocksize` element 4 at a time, etc. This means
values pushed become progressively more compressed and smoothed.
"""
IncrementBinner(::Type{T} = Float64; kw...) where {T} = IncrementBinner(zero(T); kw...)
Expand Down Expand Up @@ -105,11 +105,11 @@ function indices(B::IncrementBinner)
out[1] = 1
for i in 2:length(B.output)
if i % B.keep == 1
out[i] = out[i-1] + 1.5step
out[i] = out[i-1] + 1.5step
step *= 2
else
out[i] = out[i-1] + step
end
end
out
end
end
8 changes: 4 additions & 4 deletions src/log/binning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Values can be added using `push!` and `append!`.
Creates a new `LogBinner` and adds all elements from the given timeseries.
"""
function LogBinner(x::T;
capacity::Int64 = _nlvls2capacity(32),
capacity::Int = _nlvls2capacity(32),
accumulator::Type{<:AbstractVarianceAccumulator} = Variance
) where {T <: Union{Number, AbstractArray}}

Expand Down Expand Up @@ -233,7 +233,7 @@ end
Creates a new `LogBinner` from an existing LogBinner, copying the data inside.
The new LogBinner may be larger or smaller than the given one.
"""
function LogBinner(B::LogBinner{S, M}; capacity::Int64 = _nlvls2capacity(32)) where {S, M}
function LogBinner(B::LogBinner{S, M}; capacity::Int = _nlvls2capacity(32)) where {S, M}
N = _capacity2nlvls(capacity)
B.accumulators[min(M, N)].count > 1 && throw(OverflowError(
"The new LogBinner is too small to reconstruct the given LogBinner. " *
Expand Down Expand Up @@ -277,7 +277,7 @@ function Base.push!(B::LogBinner{T,N}, value::S) where {N, T, S}
end

# recursion, back-end function
@inline function _push!(B::LogBinner{T,N}, lvl::Int64, value::S) where {N, T <: Number, S}
@inline function _push!(B::LogBinner{T,N}, lvl::Int, value::S) where {N, T <: Number, S}
C = B.compressors[lvl]

# any value propagating through this function is new to lvl. Therefore we
Expand Down Expand Up @@ -308,7 +308,7 @@ end

function _push!(
B::LogBinner{T,N},
lvl::Int64,
lvl::Int,
value::S
) where {N, T <: AbstractArray, S}

Expand Down
2 changes: 1 addition & 1 deletion src/log/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# standard error estimate:
# Take the highest lvl with at least 32 bins.
# (Chose 32 based on https://doi.org/10.1119/1.3247985)
function _reliable_level(B::LogBinner{T,N})::Int64 where {T,N}
function _reliable_level(B::LogBinner{T,N})::Int where {T,N}
isempty(B) && (return 1) # results in NaN in std_error
i = findlast(x -> x.count >= 32, B.accumulators)
return something(i, 1)
Expand Down
4 changes: 2 additions & 2 deletions test/errorpropagator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ end

@testset "Sum-type heuristic" begin
# numbers
@test typeof(ErrorPropagator(zero(Int64))) == ErrorPropagator{Float64, 32}
@test typeof(ErrorPropagator(zero(Int))) == ErrorPropagator{Float64, 32}
@test typeof(ErrorPropagator(zero(ComplexF16))) == ErrorPropagator{ComplexF64, 32}

# arrays
@test typeof(ErrorPropagator(zeros(Int64, 2,2))) == ErrorPropagator{Matrix{Float64}, 32}
@test typeof(ErrorPropagator(zeros(Int, 2,2))) == ErrorPropagator{Matrix{Float64}, 32}
@test typeof(ErrorPropagator(zeros(ComplexF16, 2,2))) == ErrorPropagator{Matrix{ComplexF64}, 32}
end

Expand Down
4 changes: 2 additions & 2 deletions test/logbinning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ end

@testset "Sum-type heuristic" begin
# numbers
@test typeof(LogBinner(zero(Int64))) == LogBinner{Float64, 32, BinningAnalysis.Variance{Float64}}
@test typeof(LogBinner(zero(Int))) == LogBinner{Float64, 32, BinningAnalysis.Variance{Float64}}
@test typeof(LogBinner(zero(ComplexF16))) == LogBinner{ComplexF64, 32, BinningAnalysis.Variance{ComplexF64}}

# arrays
@test typeof(LogBinner(zeros(Int64, 2,2))) == LogBinner{Matrix{Float64}, 32, BinningAnalysis.Variance{Matrix{Float64}}}
@test typeof(LogBinner(zeros(Int, 2,2))) == LogBinner{Matrix{Float64}, 32, BinningAnalysis.Variance{Matrix{Float64}}}
@test typeof(LogBinner(zeros(ComplexF16, 2,2))) == LogBinner{Matrix{ComplexF64}, 32, BinningAnalysis.Variance{Matrix{ComplexF64}}}
end

Expand Down

0 comments on commit 86659e4

Please sign in to comment.