Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update observables #23

Closed
wants to merge 5 commits into from
Closed

update observables #23

wants to merge 5 commits into from

Conversation

yomichi
Copy link
Owner

@yomichi yomichi commented May 26, 2024

  • Some operations for VectorObservable like var are corrected
  • BinningObservable is deprecated
    • Instead, use obs = SimpleObservable() and binned = binning(obs)
    • binning returns new SimpleObservable with binned
    • binning takes one option, binsize::Int or numbins::Int.
      • binsize is the size of each bin
      • numbins is the number of bins
      • If omitted, binsize = floor(Int, sqrt(count(obs))) is used
    • param in runMC(param::Parameter) takes new optional keys, Binning size and Number of Bins
  • Operations for the mixture of Jackknife and JackknifeVector are added

use_index_as_sitetype = get(param, "Use Indecies as Site Types", false)
use_index_as_bondtype = get(param, "Use Indecies as Bond Types", false)
use_index_as_sitetype = get(param, "Use Indicies as Site Types", false)
use_index_as_bondtype = get(param, "Use Indicies as Bond Types", false)

for icell in 0:(numcell-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
for icell in 0:(numcell-1)
for icell = 0:(numcell-1)

src/observables/binning.jl Outdated Show resolved Hide resolved
Comment on lines +7 to +18
raw_ts :: Vector{Vector{Float64}} ## Time series of raw data
bins :: Vector{Vector{Float64}} ## Time series of bins
sum :: Vector{Vector{Float64}} ## Summation of stored values
sum2 :: Vector{Vector{Float64}} ## Summation of square of bin's mean
entries :: Vector{Int} ## Number of bins
binsize :: Int
lastbin :: Int
minbinnum :: Int
maxlevel :: Int
end

function BinningVectorObservable(minbinnum::Int = 128)
BinningVectorObservable( Vector{Float64}[], Vector{Float64}[], Vector{Float64}[], Vector{Float64}[],
zeros(Int,1), 1, 0, minbinnum, 1)
function BinningVectorObservable(minbinnum::Int = 128)
Base.depwarn("BinningVectorObservable is deprecated. Use obs=SimpleVectorObservable() and binning(obs) instead.", nothing, force=true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
raw_ts :: Vector{Vector{Float64}} ## Time series of raw data
bins :: Vector{Vector{Float64}} ## Time series of bins
sum :: Vector{Vector{Float64}} ## Summation of stored values
sum2 :: Vector{Vector{Float64}} ## Summation of square of bin's mean
entries :: Vector{Int} ## Number of bins
binsize :: Int
lastbin :: Int
minbinnum :: Int
maxlevel :: Int
end
function BinningVectorObservable(minbinnum::Int = 128)
BinningVectorObservable( Vector{Float64}[], Vector{Float64}[], Vector{Float64}[], Vector{Float64}[],
zeros(Int,1), 1, 0, minbinnum, 1)
function BinningVectorObservable(minbinnum::Int = 128)
Base.depwarn("BinningVectorObservable is deprecated. Use obs=SimpleVectorObservable() and binning(obs) instead.", nothing, force=true)
raw_ts::Vector{Vector{Float64}} ## Time series of raw data
bins::Vector{Vector{Float64}} ## Time series of bins
sum::Vector{Vector{Float64}} ## Summation of stored values
sum2::Vector{Vector{Float64}} ## Summation of square of bin's mean
entries::Vector{Int} ## Number of bins
binsize::Int
lastbin::Int
minbinnum::Int
maxlevel::Int
function BinningVectorObservable(minbinnum::Int = 128)
Base.depwarn(
"BinningVectorObservable is deprecated. Use obs=SimpleVectorObservable() and binning(obs) instead.",
nothing,
force = true,
)

bins = Vector{Float64}[]
sum = Vector{Float64}[]
sum2 = Vector{Float64}[]
entries = zeros(Int,1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
entries = zeros(Int,1)
entries = zeros(Int, 1)

@@ -5,9 +5,25 @@ mutable struct Jackknife <: ScalarObservable
xs :: Vector{Float64}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
xs :: Vector{Float64}
xs::Vector{Float64}

end

const JackknifeSet = MCObservableSet{Jackknife}
const JackknifeVectorSet = MCObservableSet{JackknifeVector}

jackknife(obs::VectorObservable) = JackknifeVector(obs)
function jackknife(obsset :: MCObservableSet{Obs}) where (Obs<: VectorObservable)
JK = JackknifeSet()
for (k,v) in obsset
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
for (k,v) in obsset
for (k, v) in obsset

end

if binsize > 0
numbins = floor(Int, nobs/binsize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
numbins = floor(Int, nobs/binsize)
numbins = floor(Int, nobs / binsize)

if binsize > 0
numbins = floor(Int, nobs/binsize)
else
binsize = floor(Int, nobs/numbins)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
binsize = floor(Int, nobs/numbins)
binsize = floor(Int, nobs / numbins)


bins = zeros(numbins)
offset = 1
for i in 1:numbins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
for i in 1:numbins
for i = 1:numbins

newobs = SimpleObservable(bins, numbins, sum(bins), sum(abs2, bins))
return newobs
end

function reset!(obs :: SimpleObservable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function reset!(obs :: SimpleObservable)
function reset!(obs::SimpleObservable)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

JuliaFormatter

test/observable.jl|72|
test/observable.jl|75|
test/observable.jl|102|

function binning(obsset::SimpleObservableSet; binsize::Int = 0, numbins::Int = 0)
newobsset = SimpleObservableSet()
for (name, obs) in obsset
newobsset[name] = binning(obs, binsize=binsize, numbins=numbins)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
newobsset[name] = binning(obs, binsize=binsize, numbins=numbins)
newobsset[name] = binning(obs, binsize = binsize, numbins = numbins)

newobsset[name] = binning(obs, binsize=binsize, numbins=numbins)
end
return newobsset
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
end

@@ -9,6 +9,45 @@ end

SimpleVectorObservable() = SimpleVectorObservable(Vector{Float64}[], 0, Float64[], Float64[])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
SimpleVectorObservable() = SimpleVectorObservable(Vector{Float64}[], 0, Float64[], Float64[])
SimpleVectorObservable() =
SimpleVectorObservable(Vector{Float64}[], 0, Float64[], Float64[])

end

if binsize > 0
numbins = floor(Int, nobs/binsize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
numbins = floor(Int, nobs/binsize)
numbins = floor(Int, nobs / binsize)

if binsize > 0
numbins = floor(Int, nobs/binsize)
else
binsize = floor(Int, nobs/numbins)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
binsize = floor(Int, nobs/numbins)
binsize = floor(Int, nobs / numbins)

binning_scalar = [binning(obs_scalar[i]) for i in 1:nobs]
binning_vector = binning(obs_vector)

mean_scalar = [mean(binning_scalar[i]) for i in 1:nobs]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
mean_scalar = [mean(binning_scalar[i]) for i in 1:nobs]
mean_scalar = [mean(binning_scalar[i]) for i = 1:nobs]


mean_scalar = [mean(binning_scalar[i]) for i in 1:nobs]
mean_vector = mean(binning_vector)
var_scalar = [var(binning_scalar[i]) for i in 1:nobs]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
var_scalar = [var(binning_scalar[i]) for i in 1:nobs]
var_scalar = [var(binning_scalar[i]) for i = 1:nobs]

function test_jackknife(scalartype, vectortype)
nobs = 3
ndata = 100
obs_scalar_x = [scalartype() for i in 1:nobs]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
obs_scalar_x = [scalartype() for i in 1:nobs]
obs_scalar_x = [scalartype() for i = 1:nobs]

ndata = 100
obs_scalar_x = [scalartype() for i in 1:nobs]
obs_vector_x = vectortype()
obs_scalar_y = [scalartype() for i in 1:nobs]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
obs_scalar_y = [scalartype() for i in 1:nobs]
obs_scalar_y = [scalartype() for i = 1:nobs]

Comment on lines +64 to +65
for i in 1:ndata
for j in 1:nobs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
for i in 1:ndata
for j in 1:nobs
for i = 1:ndata
for j = 1:nobs

@yomichi
Copy link
Owner Author

yomichi commented May 26, 2024

I close it until the test passes

@yomichi yomichi closed this May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant