Skip to content

Commit

Permalink
add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Feb 10, 2025
1 parent a1ff6f7 commit e6d2fb1
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 119 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# https://github.com/Alexander-Barth/NCDatasets.jl/blob/master/.github/workflows/ci.yml
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
# - '1.3'
- '1'
# - 'nightly'
os:
- ubuntu-latest
- macOS-latest
# - windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest
- run: |
git config --global user.name Tester
git config --global user.email [email protected]
- uses: julia-actions/julia-runtest@latest
continue-on-error: ${{ matrix.version == 'nightly' }}

- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: lcov.info
18 changes: 18 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://github.com/JuliaRegistries/TagBot
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
ssh: ${{ secrets.DOCUMENTER_KEY }}
# ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Manifest.toml
backup
97 changes: 31 additions & 66 deletions test/inflation.jl
Original file line number Diff line number Diff line change
@@ -1,96 +1,61 @@
using Test

using Distributions, LinearAlgebra, Statistics
using EnKF


@testset "Additive Inflation" begin

T = AdditiveInflation(10)

@test size(T)==(10,)


@test length(T)==10

@test mean(T)== zeros(10)
T = AdditiveInflation(10)

A = MvNormal(zeros(10), 1.05*ones(10))

T.α = A

@test var(T) == var(A)

@test var(T) == 1.05^2*ones(10)
@test size(T) == (10,)
@test length(T) == 10
@test mean(T) == zeros(10)

A = MvNormal(zeros(10), 1.05 * ones(10))
T.α = A
@test var(T) == var(A)
@test var(T) == 1.05^2 * ones(10)
end


@testset "Multiplicative Inflation" begin
T = MultiplicativeInflation(10)
@test length(T) == 10
@test T.β == 1.0

T = MultiplicativeInflation(10)


@test length(T)==10

@test T.β == 1.0


T.β = 1.05

@test T.β == 1.05

T.β = 1.05
@test T.β == 1.05
end


@testset "MultiAdditive Inflation" begin
T = MultiAdditiveInflation(10)
@test size(T) == (10,)
@test length(T) == 10
@test T.β == 1.0

T = MultiAdditiveInflation(10)

@test size(T)== (10,)

@test length(T)==10

@test T.β == 1.0
# @test T.α == MvNormal(zeros(10), I)
@test mean(T) == zeros(10)
@test var(T) == ones(10)

# @test T.α == MvNormal(zeros(10), I)
A = MvNormal(zeros(10), 1.05 * ones(10))

@test mean(T) == zeros(10)
T.β = 1.05
T.α = A

@test var(T) == ones(10)
@test T.β == 1.05
@test mean(T) == zeros(10)
@test var(T) == 1.05^2 * ones(10)

A = MvNormal(zeros(10), 1.05*ones(10))


T.β = 1.05

T.α = A

@test T.β == 1.05

@test mean(T) == zeros(10)

@test var(T) == 1.05^2*ones(10)


A = MvNormal(zeros(10), 1.01*ones(10))
T = MultiAdditiveInflation(10, 1.01, A)

@test T.β == 1.01

@test mean(T) == zeros(10)

@test var(T) == 1.01^2*ones(10)
A = MvNormal(zeros(10), 1.01 * ones(10))
T = MultiAdditiveInflation(10, 1.01, A)

@test T.β == 1.01
@test mean(T) == zeros(10)
@test var(T) == 1.01^2 * ones(10)
end






@testset "State" begin



end
13 changes: 4 additions & 9 deletions test/initial.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using Test

using Distributions, LinearAlgebra, Statistics
using EnKF

using EnKF, Test

@testset "Initialize" begin

A = MvNormal(zeros(4), I)
ENS = initialize(10, A)

@test size(ENS) == (10,(4,))
A = MvNormal(zeros(4), I)
ENS = initialize(10, A)
@test size(ENS) == (10, (4,))

end
5 changes: 1 addition & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Test

using Distributions, LinearAlgebra, Statistics
using EnKF

using EnKF, Test

include("inflation.jl")
include("state.jl")
Expand Down
69 changes: 29 additions & 40 deletions test/state.jl
Original file line number Diff line number Diff line change
@@ -1,55 +1,44 @@
using Test

using Distributions, LinearAlgebra, Statistics
using EnKF
using EnKF, Test


@testset "EnsembleState" begin
# Test size and initialize
States = [randn(10) for i = 1:4]
EnS = EnsembleState(States)

# Test size and initialize
States = [randn(10) for i = 1:4]

EnS = EnsembleState(States)

@test EnS.S == States

@test size(EnS) == (4, (10,))

@test mean(EnS) - (EnS.S[1]+EnS.S[2]+EnS.S[3]+EnS.S[4])/4 ==zeros(10)

EnS = EnsembleState(4, zeros(5))

@test size(EnS) == (4, (5,))

@test EnS.S[1] == zeros(5)


# Test mean and deviation
A = MvNormal(ones(5), I)
out = initialize(10, A)
out̄ = mean(out)
@test EnS.S == States
@test size(EnS) == (4, (10,))
@test mean(EnS) - (EnS.S[1] + EnS.S[2] + EnS.S[3] + EnS.S[4]) / 4 == zeros(10)

out̃1 = out.S[1] .- out̄
out̃2 = out.S[2] .- out̄
EnS = EnsembleState(4, zeros(5))

fluc = EnsembleState(10,zeros(5))
deviation(fluc, out)
@test size(EnS) == (4, (5,))
@test EnS.S[1] == zeros(5)

@test fluc.S[1] == out̃1
@test fluc.S[2] == out̃2
# Test mean and deviation
A = MvNormal(ones(5), I)
out = initialize(10, A)
out̄ = mean(out)

# Test addition and substraction
ENS1 = initialize(10,4)
out̃1 = out.S[1] .- out̄
out̃2 = out.S[2] .- out̄

ENS2 = initialize(10,4)
fluc = EnsembleState(10, zeros(5))
deviation(fluc, out)

ENS3 = EnsembleState(10,zeros(4))
@test fluc.S[1] == out̃1
@test fluc.S[2] == out̃2

ENS3 = ENS1 + ENS2
@test ENS1.S + ENS2.S == ENS3.S
# Test addition and substraction
ENS1 = initialize(10, 4)
ENS2 = initialize(10, 4)
ENS3 = EnsembleState(10, zeros(4))

ENS4 = EnsembleState(10,zeros(4))
ENS3 = ENS1 + ENS2
@test ENS1.S + ENS2.S == ENS3.S

ENS4 = ENS1- ENS2
@test ENS1.S - ENS2.S == ENS4.S
ENS4 = EnsembleState(10, zeros(4))
ENS4 = ENS1 - ENS2
@test ENS1.S - ENS2.S == ENS4.S
end

0 comments on commit e6d2fb1

Please sign in to comment.