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

Tests for plot recipes #37

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
name: CI

# Controls when the action will run.
on:
- push
- pull_request
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
env:
PYTHON: ""
strategy:
fail-fast: false
matrix:
version:
- '1.3'
- '1.5'
- '1.6'
- 'nightly'
os:
- ubuntu-latest
Expand All @@ -25,6 +36,10 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- run: |
julia -e '
using Pkg
Pkg.Registry.add(RegistrySpec(url="https://github.com/ctp-fpub/JuliaRegistry"))'
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
Expand All @@ -44,6 +59,8 @@ jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
env:
PYTHON: ""
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand Down
41 changes: 29 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@ using Unitful
using Test
SebastianM-C marked this conversation as resolved.
Show resolved Hide resolved

@testset "SDFResultViewer.jl" begin
λ = 800u"nm"
dir = pwd()
file = "0002.sdf"
times = get_times(dir, λ)
@test length(times) == 1

m_Lx = mean_Lx(dir, λ)
@test length(m_Lx) == 1

Lx, y, z = Lx_slice(joinpath(dir, file), λ, 0)
@test length(Lx) > 0
@test length(Lx) == length(y) == length(z)
dir = "/mnt/storage/epoch/Wang-Arefiev2020mod/12mtt_0.8w0_l0_MDO"
Copy link
Member

Choose a reason for hiding this comment

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

We could use the CI env variable to see what path to use. In case we are on CI, we could use the .sdf in the test folder.

sim = read_simulation(dir)
Copy link
Member

Choose a reason for hiding this comment

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

You need to add using SDFResults for this to work


test_plot1 = SDFResultViewer.photon_energy_spectrum(sim; mark_max = true)

test_plot21 = SDFResultViewer.photon_dens_integrated(sim; direction = :y)
test_plot22 = SDFResultViewer.photon_dens_integrated(sim; direction = :z)

test_plot31 = SDFResultViewer.photon_en_dens_integrated(sim; direction = :y, endens_scale = 10^3)
test_plot32 = SDFResultViewer.photon_en_dens_integrated(sim; direction = :z, endens_scale = 10^3)

test_plot4 = SDFResultViewer.energy_spectrum(sim)

test_plot5 = SDFResultViewer.photon_solid_angle_emission(sim; angle = pi/4)

@test typeof(test_plot1) == Plots.Plot{Plots.GRBackend}
@test typeof(test_plot21) == Plots.Plot{Plots.GRBackend}
@test typeof(test_plot22) == Plots.Plot{Plots.GRBackend}
@test typeof(test_plot32) == Plots.Plot{Plots.GRBackend}
@test typeof(test_plot31) == Plots.Plot{Plots.GRBackend}
@test typeof(test_plot4) == Plots.Plot{Plots.GRBackend}

@test typeof(test_plot5) == PyPlot.Figure

@test SDFResultViewer.powertostring(2, 2^BigInt(1345)) == "2¹³⁴⁵"
@test SDFResultViewer.powertostring(10, 1000) == "10³"

@test SDFResultViewer.cell_length(sim, :x) == 15u"μm"/450

end