Skip to content

Commit

Permalink
enable and test general array or number type observables
Browse files Browse the repository at this point in the history
You can measure complex matrices now!
  • Loading branch information
lukas-weber committed Apr 9, 2024
1 parent 18244dc commit 4ea2300
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/accumulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Statistics

const binning_output_chunk_size = 1000

mutable struct Accumulator{T<:AbstractFloat,N,M}
mutable struct Accumulator{T<:Number,N,M}
const bin_length::Int64
bins::ElasticArray{T,N,M,Vector{T}}

Expand Down
6 changes: 3 additions & 3 deletions src/results.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import JSON

"""Result of a Carlo Monte Carlo calculation containing the mean, statistical error and autocorrelation time."""
mutable struct ResultObservable{T<:AbstractFloat,N,M}
mutable struct ResultObservable{T<:Number,R<:Real,N,M}
internal_bin_length::Int64
rebin_length::Int64

mean::Array{T,N}
error::Array{T,N}
autocorrelation_time::Array{T,N}
error::Array{R,N}
autocorrelation_time::Array{R,N}

rebin_means::Array{T,M}
end
Expand Down
6 changes: 3 additions & 3 deletions test/test_merge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function create_mock_data(
idx = 1
for run = 1:runs
nsamples = samples_per_run + extra_samples * (run == 1)
samples = zeros(0)
samples = []
h5open(filenames[run], "w") do file
meas = Carlo.Measurements(internal_binsize)
for i = 1:nsamples
Expand Down Expand Up @@ -65,7 +65,7 @@ end
end

filenames2, _ = create_mock_data(
idx -> [idx, 1.0];
idx -> [idx+1.0im 1.0; 1.0im 0];
runs = runs,
obsname = :vec_test,
internal_binsize = internal_binsize,
Expand Down Expand Up @@ -101,7 +101,7 @@ end
vec_obs = results2[:vec_test]
@test iszero(vec_obs.error[2])
@test vec_obs.error[1] count_obs.error[1]
@test vec_obs.mean [count_obs.mean[1], 1.0]
@test vec_obs.mean [count_obs.mean[1]+1.0im 1.0; 1.0im 0]
end
end
end
Expand Down

0 comments on commit 4ea2300

Please sign in to comment.