Skip to content

Commit

Permalink
Merge pull request #190 from jwise77/fix-test-suite
Browse files Browse the repository at this point in the history
Updating test suite to yt-4.x and concurrent testing
  • Loading branch information
gregbryan authored Jul 14, 2022
2 parents aceb1cf + 9d21810 commit a01a390
Show file tree
Hide file tree
Showing 49 changed files with 372 additions and 276 deletions.
47 changes: 30 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ commands:
echo 'export ENZOTEST_DIR=$HOME/enzo_test' >> $BASH_ENV
echo 'export ANSWER_NAME="push_suite"' >> $BASH_ENV
echo 'export HYPRE=2.20.0' >> $BASH_ENV
# get tags from the main repository (for the current gold standard)
source $BASH_ENV
# get tags from the main and PR repository (for the current gold standard)
git fetch --tags https://github.com/enzo-project/enzo-dev
if [ -n "$CIRCLE_PR_REPONAME" ]; then
git fetch --tags https://github.com/$CIRCLE_PR_USERNAME/$CIRCLE_PR_REPONAME
fi
# tag the tip so we can go back to it
git tag tip
Expand All @@ -24,14 +28,21 @@ commands:
command: |
source $BASH_ENV
sudo apt-get update
sudo apt-get install -y csh libhdf5-serial-dev libopenmpi-dev openmpi-bin gfortran libtool-bin
sudo apt-get install -y csh libhdf5-serial-dev libopenmpi-dev openmpi-bin gfortran libtool-bin xutils-dev
python3 -m venv $HOME/venv
source $HOME/venv/bin/activate
pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade setuptools
pip install 'matplotlib<3.3.0'
pip install Cython numpy h5py fastcache flake8 nose yt==3.6.1 girder-client
pip install Cython numpy h5py fastcache flake8 nose girder-client matplotlib pytest gitpython # yt
# Temporary workaround to use updated answer testing from the yt dev repository
# instead of pip until next yt point release
git clone https://github.com/yt-project/yt
cd yt
git checkout main
pip install -e .
cd ..
pip install yt_astro_analysis
# Install hypre
mkdir -p $HOME/local
if [ ! -f $HOME/local/lib/libHYPRE.a ]; then
Expand Down Expand Up @@ -108,9 +119,9 @@ commands:
make machine-ubuntu
make load-config-test-suite
make clean
make -j 4
make -j 6
cd ../../run
python ./test_runner.py --suite=push -o $ENZOTEST_DIR --answer-name=$ANSWER_NAME --local --strict=high --verbose << parameters.flags >>
python ./test_runner.py --suite=push -o $ENZOTEST_DIR --answer-name=$ANSWER_NAME --local --machine=local_nompi --strict=high --verbose --jrun=4 << parameters.flags >>
fi
compile-test:
Expand All @@ -135,7 +146,7 @@ commands:
make precision-$prec
make particles-$part
make clean
make -j 4 || (make show-config ; exit 1)
make -j 6 || (make show-config ; exit 1)
done ; done
# return this to default
make precision-64
Expand All @@ -151,19 +162,19 @@ commands:
make integers-$inte
make particle-id-$pids
make clean
make -j 4 || (make show-config ; exit 1)
make -j 6 || (make show-config ; exit 1)
done ; done
make integers-64
make particle-id-64
# test without mpi
make use-mpi-no
make clean
make -j 4 || (make show-config ; exit 1)
make -j 6 || (make show-config ; exit 1)
make use-mpi-yes
# test ray-tracing
make photon-no
make clean
make -j 4 || (make show-config ; exit 1)
make -j 6 || (make show-config ; exit 1)
build-docs:
description: "Test the docs build."
Expand All @@ -180,6 +191,7 @@ jobs:
docker:
- image: cimg/python:3.8.5

resource_class: large
working_directory: ~/enzo-dev

steps:
Expand All @@ -188,13 +200,13 @@ jobs:

- restore_cache:
name: "Restore dependencies cache."
key: dependencies-v2
key: dependencies-v3

- install-dependencies

- save_cache:
name: "Save dependencies cache"
key: dependencies-v2
key: dependencies-v3
paths:
- ~/.cache/pip
- ~/venv
Expand All @@ -205,16 +217,16 @@ jobs:

- restore_cache:
name: "Restore test answers."
key: test-answers-v14
key: test-answers-v15a

- build-and-test:
tag: gold-standard-v14
tag: gold-standard-v15
skipfile: ~/enzo_test/push_suite
flags: --answer-store

- save_cache:
name: "Save test answers cache."
key: test-answers-v14
key: test-answers-v15a
paths:
- ~/enzo_test/push_suite

Expand All @@ -227,6 +239,7 @@ jobs:
docker:
- image: cimg/python:3.8.5

resource_class: large
working_directory: ~/enzo-dev

steps:
Expand All @@ -235,13 +248,13 @@ jobs:

- restore_cache:
name: "Restore dependencies cache."
key: dependencies-v1
key: dependencies-v3

- install-dependencies

- save_cache:
name: "Save dependencies cache"
key: dependencies-v1
key: dependencies-v3
paths:
- ~/.cache/pip
- ~/venv
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from yt.mods import *
import os
from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
Expand All @@ -15,7 +15,7 @@ def test_cooling_time():
sim = sim_dir_load(_pf_name, path=_dir_name,
find_outputs=True)
sim.get_time_series()
tolerance = ytcfg.getint("yt", "answer_testing_tolerance")
tolerance = ytcfg.get("yt", "answer_testing_tolerance")
pf = sim[-1]
for field in _fields:
yield FieldValuesTest(pf, field, decimals=tolerance)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from yt.mods import *
import os
from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
Expand All @@ -15,7 +15,7 @@ def test_cooling_time():
sim = sim_dir_load(_pf_name, path=_dir_name,
find_outputs=True)
sim.get_time_series()
tolerance = ytcfg.getint("yt", "answer_testing_tolerance")
tolerance = ytcfg.get("yt", "answer_testing_tolerance")
pf = sim[-1]
for field in _fields:
yield FieldValuesTest(pf, field, decimals=tolerance)
Expand Down
4 changes: 2 additions & 2 deletions run/Cooling/CoolingTest_JHW/CoolingTest_JHW__test_cooling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from yt.mods import *
import os
from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
Expand All @@ -15,7 +15,7 @@ def test_cooling_time():
sim = sim_dir_load(_pf_name, path=_dir_name,
find_outputs=True)
sim.get_time_series()
tolerance = ytcfg.getint("yt", "answer_testing_tolerance")
tolerance = ytcfg.get("yt", "answer_testing_tolerance")
pf = sim[-1]
for field in _fields:
yield FieldValuesTest(pf, field, decimals=tolerance)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from yt.mods import *
import os
from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
Expand All @@ -16,7 +16,7 @@ def test_freefall():
sim = sim_dir_load(_pf_name, path=_dir_name,
find_outputs=True)
sim.get_time_series()
tolerance = ytcfg.getint("yt", "answer_testing_tolerance")
tolerance = ytcfg.get("yt", "answer_testing_tolerance")
pf = sim[-1]
for field in _fields:
yield FieldValuesTest(pf, field, decimals=tolerance)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
###

import os
from yt.mods import *
from yt.testing import *
from yt.utilities.answer_testing.framework import \
VerifySimulationSameTest, \
Expand All @@ -29,7 +28,7 @@ def test_standard():
sim.get_time_series()
yield VerifySimulationSameTest(sim)
base_pf = sim[0]
fields = [f for f in _base_fields if f in base_pf.h.field_list]
fields = [f for f in _base_fields if f in base_pf.field_list]
# Only test the last output.
pf = sim[-1]
for test in standard_small_simulation(pf, fields): yield test
Expand Down
2 changes: 1 addition & 1 deletion run/Cosmology/MHDZeldovichPancake/MHDZeldovichPancake.enzo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
ProblemType = 20 // Zeldovich pancake
TopGridRank = 1
TopGridDimensions = 500 64 2
TopGridDimensions = 500
SelfGravity = 1 // gravity on
TopGridGravityBoundary = 0 // Periodic BC for gravity
LeftFaceBoundaryCondition = 3 // same for fluid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
###

import os
from yt.mods import *
from yt.testing import *
from yt.utilities.answer_testing.framework import \
VerifySimulationSameTest, \
Expand All @@ -29,7 +28,7 @@ def test_almost_standard():
sim.get_time_series()
yield VerifySimulationSameTest(sim)
base_pf = sim[0]
fields = [f for f in _base_fields if f in base_pf.h.field_list]
fields = [f for f in _base_fields if f in base_pf.field_list]
# Only test the last output.
pf = sim[-1]
for test in standard_small_simulation(pf, fields): yield test
Expand Down
53 changes: 26 additions & 27 deletions run/CosmologySimulation/amr_cosmology/test_amr_cosmology.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import matplotlib.pyplot as plt
import numpy as np
import os
from yt.analysis_modules.halo_mass_function.api import *
from yt.analysis_modules.halo_analysis.api import HaloCatalog
from yt_astro_analysis.halo_analysis import HaloCatalog
from yt.testing import assert_rel_equal
from numpy.testing import assert_equal

Expand All @@ -30,7 +29,7 @@ def test_hmf():
data_ds=ds, finder_method='fof',
output_dir=os.path.join(_dir_name, "halo_catalogs/catalog"))
hc.create()
masses = hc.data_source['particle_mass'].in_units('Msun')
masses = hc.data_ds.r[('all', 'particle_mass')].in_units('Msun')
h = ds.hubble_constant
mtot = np.log10(masses*1.2) - np.log10(h)
masses_sim = np.sort(mtot)
Expand Down Expand Up @@ -69,12 +68,12 @@ def test_max_density_halo_quantities():

# Find the point of maximum density, center a sphere of radius
# 1 Mpc around it, and sum the masses inside
val,pos = ds.find_max('Density')
val,pos = ds.find_max(('enzo', 'Density'))
sp = ds.sphere(pos,(1000.,'kpc'))
ct = sp['creation_time']
ct = sp[('nbody', 'creation_time')]
dm = (ct < 0)
dm_mass = np.sum(sp['particle_mass'][dm]).in_units('Msun')
gas_mass = np.sum(sp['cell_mass'].in_units('Msun'))
dm_mass = np.sum(sp[('all', 'particle_mass')][dm]).in_units('Msun')
gas_mass = np.sum(sp[('gas', 'cell_mass')].in_units('Msun'))

# Also look at the radial profiles of density and temperature
# within these spheres. The bin size is chosen to make the profiles
Expand Down Expand Up @@ -115,9 +114,9 @@ def test_dark_matter_mass():
data = ds.all_data()

# sum masses
MDM = np.sum(data['particle_mass'][ data['particle_type'] == 1 ].to('Msun'))
MDM = np.sum(data[('all', 'particle_mass')][ data[('all', 'particle_type')] == 1 ].to('Msun'))

output_data = {'mass' : MDM}
output_data = {(('data', 'mass') : MDM}

# save
filename = "DM_mass_results.h5"
Expand All @@ -130,7 +129,7 @@ def test_dark_matter_mass():
return

ds_comp = yt.load(compare_filename)
assert_rel_equal(output_data['mass'], ds_comp.data['mass'], tolerance)
assert_rel_equal(output_data[('data', 'mass')], ds_comp.data[('data', 'mass')], tolerance)

def test_individual_baryon_mass():
# gather most recent data set
Expand All @@ -145,8 +144,8 @@ def test_individual_baryon_mass():
data = ds.all_data()

# sum masses
Mstar = np.sum(data['particle_mass'][ data['particle_type'] == 2 ].to('Msun'))
Mgas = np.sum(data['cell_mass'].to('Msun'))
Mstar = np.sum(data[('all', 'particle_mass')][ data[('all', 'particle_type')] == 2 ].to('Msun'))
Mgas = np.sum(data[('gas', 'cell_mass')].to('Msun'))

output_data = {'masses' : np.array([Mstar, Mgas])}

Expand Down Expand Up @@ -176,8 +175,8 @@ def test_total_baryon_mass():
data = ds.all_data()

# sum masses
Mstar = np.sum(data['particle_mass'][ data['particle_type'] == 2 ].to('Msun'))
Mgas = np.sum(data['cell_mass'].to('Msun'))
Mstar = np.sum(data[('all', 'particle_mass')][ data[('all', 'particle_type')] == 2 ].to('Msun'))
Mgas = np.sum(data[('gas', 'cell_mass')].to('Msun'))

output_data = {'masses' : Mstar + Mgas}

Expand Down Expand Up @@ -228,21 +227,21 @@ def test_phase():
("gas", "cooling_time")],
weight_field=('gas', 'cell_mass'))
density = profile.x
temperature = profile['gas', 'temperature']
cooling_time = profile1['gas', 'cooling_time']
cell_mass = profile['gas', 'cell_mass']
temperature = profile[('gas', 'temperature')]
cooling_time = profile1[('gas', 'cooling_time')]
cell_mass = profile[('gas', 'cell_mass')]

filename = 'phase_data.h5'
save_filename = os.path.join(_dir_name, filename)
data = {'density': density, 'temperature': temperature,
'cooling_time': cooling_time, 'cell_mass': cell_mass}
data = {('data', 'density'): density, ('data', 'temperature'): temperature,
('data', 'cooling_time'): cooling_time, ('data', 'cell_mass'): cell_mass}
yt.save_as_dataset(ds, save_filename, data)

pp = yt.PhasePlot(ad, 'density', 'temperature', 'cell_mass')
pp.set_unit('cell_mass', 'Msun')
pp = yt.PhasePlot(ad, ('gas', 'density'), ('gas', 'temperature'), ('gas', 'cell_mass'))
pp.set_unit(('gas', 'cell_mass'), 'Msun')
pp.save(_dir_name)
pp1 = yt.PhasePlot(ad, 'density', 'temperature', 'cooling_time',
weight_field='cell_mass')
pp1 = yt.PhasePlot(ad, ('gas', 'density'), ('gas', 'temperature'), ('gas', 'cooling_time'),
weight_field=('gas', 'cell_mass'))
pp1.save(_dir_name)

compare_filename = os.path.join(test_data_dir, filename)
Expand All @@ -254,7 +253,7 @@ def test_phase():
ds_comp = yt.load(compare_filename)

# assert quality to 8 decimals
assert_rel_equal(data['density'], ds_comp.data['density'], 8)
assert_rel_equal(data['temperature'], ds_comp.data['temperature'], 8)
assert_rel_equal(data['cooling_time'], ds_comp.data['cooling_time'], 8)
assert_rel_equal(data['cell_mass'], ds_comp.data['cell_mass'], 8)
assert_rel_equal(data[('data', 'density')], ds_comp.data[('data', 'density')], 8)
assert_rel_equal(data[('data', 'temperature')], ds_comp.data[('data', 'temperature')], 8)
assert_rel_equal(data[('data', 'cooling_time')], ds_comp.data[('data', 'cooling_time')], 8)
assert_rel_equal(data[('data', 'cell_mass')], ds_comp.data[('data', 'cell_mass')], 8)
Loading

0 comments on commit a01a390

Please sign in to comment.