From 12d6356f50aa0dc6d4f9ac7627b829fc1518b648 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Tue, 1 Oct 2024 19:28:34 -0400 Subject: [PATCH] compare --- .github/workflows/build-pull-request.yaml | 17 +++++++++++------ tests/compare_ab.py | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 tests/compare_ab.py diff --git a/.github/workflows/build-pull-request.yaml b/.github/workflows/build-pull-request.yaml index a52758c..45c1ec7 100644 --- a/.github/workflows/build-pull-request.yaml +++ b/.github/workflows/build-pull-request.yaml @@ -9,7 +9,7 @@ concurrency: cancel-in-progress: true jobs: - build: + build-n-test: runs-on: [gpu] container: @@ -24,14 +24,19 @@ jobs: - name: Build shell: bash - env: - GEOM: testgeom - OPTICKS_EVENT_MODE: DebugLite run: | cmake -S . -B build cmake --build build + + - name: Test + shell: bash + env: + GEOM: fakegeom + OPTICKS_EVENT_MODE: DebugLite + run: | QCurandState_SPEC=3:0:0 /usr/local/opticks/lib/QCurandStateTest build/src/simtox build/src/simg4ox -g geom/raindrop.gdml -m run.mac - ls -la /tmp/GEOM/testgeom/simg4ox/ALL0/A000 - ls -la /tmp/GEOM/testgeom/simg4ox/ALL0/B000 + ls -la /tmp/GEOM/fakegeom/simg4ox/ALL0/A000 + ls -la /tmp/GEOM/fakegeom/simg4ox/ALL0/B000 + python tests/compare_ab.py diff --git a/tests/compare_ab.py b/tests/compare_ab.py new file mode 100644 index 0000000..daf97d7 --- /dev/null +++ b/tests/compare_ab.py @@ -0,0 +1,15 @@ +import numpy as np +import opticks.sysrap.sevt as s + +a = s.SEvt.Load("/tmp/GEOM/fakegeom/simg4ox/ALL0/A000/") +b = s.SEvt.Load("/tmp/GEOM/fakegeom/simg4ox/ALL0/B000/") + +#np.allclose(a.f.record[:,1:], b.f.record[:,0:-1], rtol=0, atol=1e-5) + +assert len(a.f.record) == len(b.f.record) + +diff = [i for i, (a, b) in enumerate(zip(a.f.record[:, 1:], b.f.record[:, 0:-1])) if not np.allclose(a, b, rtol=0, atol=1e-5)] +print(diff) + +assert diff == [14, 21, 22, 36, 40, 54, 64, 81] +