From 7653be0a5e1ce0fece431711129faad45083c72c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 29 Sep 2017 09:45:42 -0500 Subject: [PATCH 01/13] Use argparse in run_tests.py instead of optparse --- tests/run_tests.py | 78 +++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 50e9313df3..a3320823a8 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -10,35 +10,35 @@ import glob import socket from subprocess import call, check_output from collections import OrderedDict -from optparse import OptionParser +from argparse import ArgumentParser # Command line parsing -parser = OptionParser() -parser.add_option('-j', '--parallel', dest='n_procs', default='1', +parser = ArgumentParser() +parser.add_argument('-j', '--parallel', dest='n_procs', default='1', help="Number of parallel jobs.") -parser.add_option('-R', '--tests-regex', dest='regex_tests', +parser.add_argument('-R', '--tests-regex', dest='regex_tests', help="Run tests matching regular expression. \ Test names are the directories present in tests folder.\ This uses standard regex syntax to select tests.") -parser.add_option('-C', '--build-config', dest='build_config', +parser.add_argument('-C', '--build-config', dest='build_config', help="Build configurations matching regular expression. \ Specific build configurations can be printed out with \ optional argument -p, --print. This uses standard \ regex syntax to select build configurations.") -parser.add_option('-l', '--list', action="store_true", +parser.add_argument('-l', '--list', action="store_true", dest="list_build_configs", default=False, help="List out build configurations.") -parser.add_option("-p", "--project", dest="project", default="", +parser.add_argument("-p", "--project", dest="project", default="", help="project name for build") -parser.add_option("-D", "--dashboard", dest="dash", +parser.add_argument("-D", "--dashboard", dest="dash", help="Dash name -- Experimental, Nightly, Continuous") -parser.add_option("-u", "--update", action="store_true", dest="update", +parser.add_argument("-u", "--update", action="store_true", dest="update", help="Allow CTest to update repo. (WARNING: may overwrite\ changes that were not pushed.") -parser.add_option("-s", "--script", action="store_true", dest="script", +parser.add_argument("-s", "--script", action="store_true", dest="script", help="Activate CTest scripting mode for coverage, valgrind\ and dashboard capability.") -(options, args) = parser.parse_args() +args = parser.parse_args() # Default compiler paths FC='gfortran' @@ -173,7 +173,7 @@ class Test(object): # Sets the build name that will show up on the CDash def get_build_name(self): - self.build_name = options.project + '_' + self.name + self.build_name = args.project + '_' + self.name return self.build_name # Sets up build options for various tests. It is used both @@ -246,9 +246,9 @@ class Test(object): make_list = ['make','-s'] # Check for parallel - if options.n_procs is not None: + if args.n_procs is not None: make_list.append('-j') - make_list.append(options.n_procs) + make_list.append(args.n_procs) # Run make rc = call(make_list) @@ -265,14 +265,14 @@ class Test(object): ctest_list = ['ctest'] # Check for parallel - if options.n_procs is not None: + if args.n_procs is not None: ctest_list.append('-j') - ctest_list.append(options.n_procs) + ctest_list.append(args.n_procs) # Check for subset of tests - if options.regex_tests is not None: + if args.regex_tests is not None: ctest_list.append('-R') - ctest_list.append(options.regex_tests) + ctest_list.append(args.regex_tests) # Run ctests rc = call(ctest_list) @@ -308,7 +308,7 @@ add_test('hdf5-debug_valgrind', debug=True, valgrind=True) add_test('hdf5-debug_coverage', debug=True, coverage=True) # Check to see if we should just print build configuration information to user -if options.list_build_configs: +if args.list_build_configs: for key in tests: print('Configuration Name: {0}'.format(key)) print(' Debug Flags:..........{0}'.format(tests[key].debug)) @@ -320,10 +320,10 @@ if options.list_build_configs: exit() # Delete items of dictionary that don't match regular expression -if options.build_config is not None: +if args.build_config is not None: to_delete = [] for key in tests: - if not re.search(options.build_config, key): + if not re.search(args.build_config, key): to_delete.append(key) for key in to_delete: del tests[key] @@ -333,27 +333,21 @@ if options.build_config is not None: # Experimental, Nightly, Continuous. On the CDash end, these can be # reorganized into groups when a hostname, dashboard and build name # are matched. -if options.dash is None: +if args.dash is None: dash = 'Experimental' submit = '' else: - dash = options.dash + dash = args.dash submit = 'ctest_submit()' # Check for update command, which will run git fetch/merge and will delete # any changes to repo that were not pushed to remote origin -if options.update: - update = 'ctest_update()' -else: - update = '' +update = 'ctest_update()' if args.update else '' # Check for CTest scipts mode # Sets up whether we should use just the basic ctest command or use # CTest scripting to perform tests. -if not options.dash is None or options.script: - script_mode = True -else: - script_mode = False +script_mode = (args.dash is not None or args.script) # Setup CTest script vars. Not used in non-script mode pwd = os.getcwd() @@ -364,17 +358,17 @@ ctest_vars = { 'dashboard': dash, 'submit': submit, 'update': update, - 'n_procs': options.n_procs + 'n_procs': args.n_procs } # Check project name -subprop = """set_property(GLOBAL PROPERTY SubProject {0})""" -if options.project == "" : - ctest_vars.update({'subproject':''}) -elif options.project == 'develop': - ctest_vars.update({'subproject':''}) +subprop = "set_property(GLOBAL PROPERTY SubProject {0})" +if args.project == "" : + ctest_vars.update({'subproject': ''}) +elif args.project == 'develop': + ctest_vars.update({'subproject': ''}) else: - ctest_vars.update({'subproject':subprop.format(options.project)}) + ctest_vars.update({'subproject': subprop.format(args.project)}) # Set up default valgrind tests (subset of all tests) # Currently takes too long to run all the tests with valgrind @@ -396,8 +390,8 @@ if not script_mode: for key in to_delete: del tests[key] -# Check if tests empty -if len(list(tests.keys())) == 0: +# Check if tests is empty +if not tests: print('No tests to run.') exit() @@ -447,7 +441,7 @@ for key in iter(tests): # Check for user custom tests # INCLUDE is a CTest command that allows for a subset # of tests to be executed. Only used in script mode. - if options.regex_tests is None: + if args.regex_tests is None: ctest_vars.update({'tests' : ''}) # No user tests, use default valgrind tests @@ -456,7 +450,7 @@ for key in iter(tests): format(valgrind_default_tests)}) else: ctest_vars.update({'tests' : 'INCLUDE {0}'. - format(options.regex_tests)}) + format(args.regex_tests)}) # Main part of code that does the ctest execution. # It is broken up by two modes, script and non-script From 2673880a9c95f710d531a67598119280be2dbe0e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 29 Sep 2017 11:09:50 -0500 Subject: [PATCH 02/13] Move test_element_wo to unit tests --- tests/{test_element_wo => unit_tests}/test_element_wo.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename tests/{test_element_wo => unit_tests}/test_element_wo.py (92%) diff --git a/tests/test_element_wo/test_element_wo.py b/tests/unit_tests/test_element_wo.py similarity index 92% rename from tests/test_element_wo/test_element_wo.py rename to tests/unit_tests/test_element_wo.py index e2a5726f19..7b9487f73d 100644 --- a/tests/test_element_wo/test_element_wo.py +++ b/tests/unit_tests/test_element_wo.py @@ -5,13 +5,11 @@ import sys import numpy as np -sys.path.insert(0, os.pardir) -sys.path.insert(0, os.path.join(os.pardir, os.pardir)) from openmc import Material from openmc.data import NATURAL_ABUNDANCE, atomic_mass -if __name__ == '__main__': +def test_element_wo(): # This test doesn't require an OpenMC run. We just need to make sure the # element.expand() method expands elements with the proper nuclide # compositions. From 232f40e1193c1e520025e30334f5ad3bc9cf30da Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 29 Sep 2017 11:11:18 -0500 Subject: [PATCH 03/13] Only install via setuptools --- setup.py | 65 +++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/setup.py b/setup.py index 7ca824ab01..8d482b8626 100755 --- a/setup.py +++ b/setup.py @@ -3,13 +3,8 @@ import glob import sys import numpy as np -try: - from setuptools import setup - have_setuptools = True -except ImportError: - from distutils.core import setup - have_setuptools = False +from setuptools import setup try: from Cython.Build import cythonize have_cython = True @@ -28,11 +23,12 @@ else: with open('openmc/__init__.py', 'r') as f: version = f.readlines()[-1].split()[-1].strip("'") -kwargs = {'name': 'openmc', - 'version': version, - 'packages': ['openmc', 'openmc.capi', 'openmc.data', 'openmc.mgxs', - 'openmc.model', 'openmc.stats'], - 'scripts': glob.glob('scripts/openmc-*'), +kwargs = { + 'name': 'openmc', + 'version': version, + 'packages': ['openmc', 'openmc.capi', 'openmc.data', 'openmc.mgxs', + 'openmc.model', 'openmc.stats'], + 'scripts': glob.glob('scripts/openmc-*'), # Data files and librarries 'package_data': { @@ -42,33 +38,30 @@ kwargs = {'name': 'openmc', # Metadata 'author': 'Will Boyd', - 'author_email': 'wbinventor@gmail.com', - 'description': 'OpenMC Python API', - 'url': 'https://github.com/mit-crpg/openmc', - 'classifiers': [ - 'Intended Audience :: Developers', - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Topic :: Scientific/Engineering' - ]} + 'author_email': 'wbinventor@gmail.com', + 'description': 'OpenMC Python API', + 'url': 'https://github.com/mit-crpg/openmc', + 'classifiers': [ + 'Intended Audience :: Developers', + 'Intended Audience :: End Users/Desktop', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python', + 'Topic :: Scientific/Engineering' + ], -if have_setuptools: - kwargs.update({ - # Required dependencies - 'install_requires': ['six', 'numpy>=1.9', 'h5py', 'scipy', 'pandas>=0.17.0'], + # Required dependencies + 'install_requires': ['six', 'numpy>=1.9', 'h5py', 'scipy', + 'pandas>=0.17.0', 'lxml'], - # Optional dependencies - 'extras_require': { - 'decay': ['uncertainties'], - 'plot': ['matplotlib', 'ipython'], - 'vtk': ['vtk', 'silomesh'], - 'validate': ['lxml'] - }, - - }) + # Optional dependencies + 'extras_require': { + 'decay': ['uncertainties'], + 'plot': ['matplotlib', 'ipython'], + 'vtk': ['vtk', 'silomesh'], + }, +} # If Cython is present, add resonance reconstruction capability if have_cython: From 819744bbcba2f53a15d4cdd257be3580f2ad0f12 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 29 Sep 2017 14:30:57 -0500 Subject: [PATCH 04/13] Add a MANIFEST.in and tox.ini file --- .gitignore | 4 ++++ MANIFEST.in | 2 ++ tox.ini | 9 +++++++++ 3 files changed, 15 insertions(+) create mode 100644 MANIFEST.in create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index a0cfd5c7ff..35f45e747b 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,7 @@ examples/jupyter/plots *.c *.html *.so + +.cache/ +.tox/ +.python-version diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000..bd3bec5689 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include readme.rst +include openmc/data/reconstruct.pyx diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000..951bd8cd0c --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py{34,36} +[testenv] +commands = pytest tests/unit_tests +deps = + pytest + numpy + cython +passenv = OPENMC_CROSS_SECTIONS From 12848904cb119e2c7b83eaffefa033b2424a58f8 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 2 Oct 2017 14:01:51 -0500 Subject: [PATCH 05/13] Remove unused files at root --- CTestConfig.cmake | 25 ------------------------- Makefile | 14 -------------- 2 files changed, 39 deletions(-) delete mode 100644 CTestConfig.cmake delete mode 100644 Makefile diff --git a/CTestConfig.cmake b/CTestConfig.cmake deleted file mode 100644 index e127a8ddf2..0000000000 --- a/CTestConfig.cmake +++ /dev/null @@ -1,25 +0,0 @@ -## This file should be placed in the root directory of your project. -## Then modify the CMakeLists.txt file in the root directory of your -## project to incorporate the testing dashboard. -## # The following are required to uses Dart and the Cdash dashboard -## ENABLE_TESTING() -## INCLUDE(CTest) - -# Generic information about CDASH site -set(CTEST_PROJECT_NAME "OpenMC") -set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") -set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "openmc.mit.edu") -set(CTEST_DROP_LOCATION "/cdash/submit.php?project=OpenMC") -set(CTEST_DROP_SITE_CDASH TRUE) - -# Set file size larger to see more output -set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "20000") -set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "20000") - -# User/password to CDASH site -# Please contact Nick Horelik or -# Bryan Herman if you want to push -# test suite information to our CDASH site. -set(CTEST_DROP_SITE_USER "") -set(CTEST_DROP_SITE_PASSWORD "") diff --git a/Makefile b/Makefile deleted file mode 100644 index 990f22d9d3..0000000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -all: - mkdir -p build - cmake -H. -Bbuild - make -s -C build -clean: - make -s -C build clean -distclean: - rm -fr build -test: - make -s -C build test -install: - make -s -C build install - -.PHONY: all clean distclean test install From d21d158a5bf3bd21ed49e37a5240e707b053d559 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 2 Oct 2017 14:06:14 -0500 Subject: [PATCH 06/13] Add MANIFEST.in and update setup.py --- MANIFEST.in | 36 +++++++++++++++++++++++++++++++++++- setup.py | 27 +++++++++++++++++---------- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index bd3bec5689..04436bf1df 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,36 @@ -include readme.rst +include CMakeLists.txt +include LICENSE +include schemas.xml +include tox.ini include openmc/data/reconstruct.pyx +include docs/source/_templates/layout.html +include docs/sphinxext/LICENSE +recursive-include . *.rst +recursive-include cmake *.cmake +recursive-include docs *.css +recursive-include docs *.dia +recursive-include docs *.png +recursive-include docs *.py +recursive-include docs *.svg +recursive-include docs *.tex +recursive-include docs *.txt +recursive-include docs Makefile +recursive-include examples *.h5 +recursive-include examples *.ipynb +recursive-include examples *.png +recursive-include examples *.py +recursive-include examples *.xml +recursive-include man *.1 +recursive-include src *.F90 +recursive-include src *.c +recursive-include src *.cc +recursive-include src *.cpp +recursive-include src *.h +recursive-include src *.hpp +recursive-include src *.rnc +recursive-include src *.rng +recursive-include tests *.dat +recursive-include tests *.h5 +recursive-include tests *.py +recursive-include tests *.xml +prune docs/build diff --git a/setup.py b/setup.py index 8d482b8626..354098ea35 100755 --- a/setup.py +++ b/setup.py @@ -26,29 +26,36 @@ with open('openmc/__init__.py', 'r') as f: kwargs = { 'name': 'openmc', 'version': version, - 'packages': ['openmc', 'openmc.capi', 'openmc.data', 'openmc.mgxs', - 'openmc.model', 'openmc.stats'], + 'packages': find_packages(), 'scripts': glob.glob('scripts/openmc-*'), - # Data files and librarries - 'package_data': { - 'openmc.capi': ['libopenmc.{}'.format(suffix)], - 'openmc.data': ['mass.mas12', 'fission_Q_data_endfb71.h5'] - }, + # Data files and librarries + 'package_data': { + 'openmc.capi': ['libopenmc.{}'.format(suffix)], + 'openmc.data': ['mass.mas12', 'fission_Q_data_endfb71.h5'] + }, - # Metadata - 'author': 'Will Boyd', + # Metadata + 'author': 'Will Boyd', 'author_email': 'wbinventor@gmail.com', 'description': 'OpenMC Python API', 'url': 'https://github.com/mit-crpg/openmc', 'classifiers': [ + 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Intended Audience :: End Users/Desktop', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', - 'Programming Language :: Python', 'Topic :: Scientific/Engineering' + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], # Required dependencies From 00f6bbe26608e78b7de6447084f15abff76e3559 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 13 Oct 2017 16:21:34 -0500 Subject: [PATCH 07/13] Run unit tests on Travis --- .travis.yml | 6 ++++-- CMakeLists.txt | 5 +++++ setup.py | 17 +++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64fbdc9df2..bb2c500c9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_install: - conda update -q conda - conda info -a - if [[ $OPENMC_CONFIG != "check_source" ]]; then - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION six numpy scipy h5py=2.5 pandas; + conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pip numpy cython; source activate test-environment; sudo add-apt-repository ppa:nschloe/hdf5-backports -y; sudo apt-get update -q; @@ -52,7 +52,8 @@ before_install: export HDF5_DIR=/usr; fi -install: true +install: + - pip install -e .[test] before_script: - if [[ $OPENMC_CONFIG != "check_source" ]]; then @@ -73,4 +74,5 @@ script: else ./run_tests.py -C $OPENMC_CONFIG -j 2; fi + - pytest unit_tests/ - cd .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 905555a050..0b0bef14ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -468,6 +468,11 @@ file(GLOB_RECURSE TESTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_*.py) # Loop through all the tests foreach(test ${TESTS}) + # Remove unit tests + if(test MATCHES ".*unit_tests.*") + continue() + endif() + # Get test information get_filename_component(TEST_NAME ${test} NAME) get_filename_component(TEST_PATH ${test} PATH) diff --git a/setup.py b/setup.py index 354098ea35..e064efa68c 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import glob import sys import numpy as np -from setuptools import setup +from setuptools import setup, find_packages try: from Cython.Build import cythonize have_cython = True @@ -36,9 +36,9 @@ kwargs = { }, # Metadata - 'author': 'Will Boyd', - 'author_email': 'wbinventor@gmail.com', - 'description': 'OpenMC Python API', + 'author': 'The OpenMC Development Team', + 'author_email': 'openmc-dev@googlegroups.com', + 'description': 'OpenMC', 'url': 'https://github.com/mit-crpg/openmc', 'classifiers': [ 'Development Status :: 4 - Beta', @@ -59,13 +59,14 @@ kwargs = { ], # Required dependencies - 'install_requires': ['six', 'numpy>=1.9', 'h5py', 'scipy', - 'pandas>=0.17.0', 'lxml'], + 'install_requires': [ + 'six', 'numpy>=1.9', 'h5py', 'scipy', 'ipython', 'matplotlib', + 'pandas>=0.17.0', 'lxml', 'uncertainties' + ], # Optional dependencies 'extras_require': { - 'decay': ['uncertainties'], - 'plot': ['matplotlib', 'ipython'], + 'test': ['pytest'], 'vtk': ['vtk', 'silomesh'], }, } From 215220bb060def96323fc316b5c75749db323e6a Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 14 Oct 2017 13:15:01 -0500 Subject: [PATCH 08/13] Don't pip install or run unit tests for check_source configuration --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb2c500c9a..bb7a7da377 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,9 @@ before_install: fi install: - - pip install -e .[test] + - if [[ $OPENMC_CONFIG != "check_source" ]]; then + pip install -e .[test]; + fi before_script: - if [[ $OPENMC_CONFIG != "check_source" ]]; then @@ -73,6 +75,6 @@ script: ./check_source.py; else ./run_tests.py -C $OPENMC_CONFIG -j 2; + pytest unit_tests/; fi - - pytest unit_tests/ - cd .. From ef7261cd713040780ddafc3b74cdf9c31e5945cd Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 14 Oct 2017 14:06:24 -0500 Subject: [PATCH 09/13] Try using default pip/virtualenv on Travis instead of conda --- .travis.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb7a7da377..0de30b20a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,21 +28,7 @@ matrix: env: OPENMC_CONFIG="check_source" before_install: - # ============== Handle Python third-party packages ============== - - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then - wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; - else - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - fi - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - conda info -a - if [[ $OPENMC_CONFIG != "check_source" ]]; then - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pip numpy cython; - source activate test-environment; sudo add-apt-repository ppa:nschloe/hdf5-backports -y; sudo apt-get update -q; sudo apt-get install libhdf5-serial-dev libhdf5-mpich-dev -y; @@ -54,6 +40,7 @@ before_install: install: - if [[ $OPENMC_CONFIG != "check_source" ]]; then + pip install numpy cython; pip install -e .[test]; fi From 3d32f57c6ff3157143a089de096a5ef7b237a706 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 17 Oct 2017 15:13:30 -0500 Subject: [PATCH 10/13] Add coverage to unit tests --- .travis.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0de30b20a4..b4462ed0e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,6 +62,6 @@ script: ./check_source.py; else ./run_tests.py -C $OPENMC_CONFIG -j 2; - pytest unit_tests/; + pytest --cov=../openmc unit_tests/; fi - cd .. diff --git a/setup.py b/setup.py index e064efa68c..271fac0f00 100755 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ kwargs = { # Optional dependencies 'extras_require': { - 'test': ['pytest'], + 'test': ['pytest', 'pytest-cov'], 'vtk': ['vtk', 'silomesh'], }, } From 3955e901b46781503cffc636eba15c54c1e55b09 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 18 Oct 2017 10:51:45 -0500 Subject: [PATCH 11/13] Remove tox.ini for now, update install instructions --- MANIFEST.in | 1 - docs/source/usersguide/install.rst | 17 ++++++++++------- tox.ini | 9 --------- 3 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 tox.ini diff --git a/MANIFEST.in b/MANIFEST.in index 04436bf1df..04348222fa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include CMakeLists.txt include LICENSE include schemas.xml -include tox.ini include openmc/data/reconstruct.pyx include docs/source/_templates/layout.html include docs/sphinxext/LICENSE diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index 497e09b4d5..09fc4520c0 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -414,16 +414,19 @@ distributions. various HDF5 files, h5py is needed to provide access to data within these files from Python. -.. admonition:: Optional - :class: note - `Matplotlib `_ Matplotlib is used to providing plotting functionality in the API like the :meth:`Universe.plot` method and the :func:`openmc.plot_xs` function. `uncertainties `_ - Uncertainties are optionally used for decay data in the :mod:`openmc.data` - module. + Uncertainties are used for decay data in the :mod:`openmc.data` module. + + `lxml `_ + lxml is used for the :ref:`scripts_validate` script and various other + parts of the Python API. + +.. admonition:: Optional + :class: note `Cython `_ Cython is used for resonance reconstruction for ENDF data converted to @@ -437,8 +440,8 @@ distributions. The silomesh package is needed to convert voxel and track files to SILO format. - `lxml `_ - lxml is used for the :ref:`scripts_validate` script. + `pytest `_ + The pytest framework is used for unit testing the Python API. .. _usersguide_nxml: diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 951bd8cd0c..0000000000 --- a/tox.ini +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py{34,36} -[testenv] -commands = pytest tests/unit_tests -deps = - pytest - numpy - cython -passenv = OPENMC_CROSS_SECTIONS From e510fc799213a226756f21a0760b8d1d486671e6 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 18 Oct 2017 11:23:10 -0500 Subject: [PATCH 12/13] Add license badge on readme.rst --- readme.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/readme.rst b/readme.rst index 34d2a5d099..75e4a1438f 100644 --- a/readme.rst +++ b/readme.rst @@ -2,8 +2,7 @@ OpenMC Monte Carlo Particle Transport Code ========================================== -.. image:: https://travis-ci.org/mit-crpg/openmc.svg?branch=develop - :target: https://travis-ci.org/mit-crpg/openmc +|licensebadge| |travisbadge| The OpenMC project aims to provide a fully-featured Monte Carlo particle transport code based on modern methods. It is a constructive solid geometry, @@ -55,3 +54,11 @@ OpenMC is distributed under the MIT/X license_. .. _Troubleshooting section: http://openmc.readthedocs.io/en/stable/usersguide/troubleshoot.html .. _Issues: https://github.com/mit-crpg/openmc/issues .. _license: http://openmc.readthedocs.io/en/stable/license.html + +.. |licensebadge| image:: https://img.shields.io/github/license/mit-crpg/openmc.svg + :target: http://openmc.readthedocs.io/en/latest/license.html + :alt: License + +.. |travisbadge| image:: https://travis-ci.org/mit-crpg/openmc.svg?branch=develop + :target: https://travis-ci.org/mit-crpg/openmc + :alt: Travis CI build status (Linux) From 1c8fbf536747971af6f6b4a9a50755378fb2e24c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 7 Nov 2017 08:28:29 -0600 Subject: [PATCH 13/13] PEP8 fixes in run_tests.py --- tests/run_tests.py | 61 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index a3320823a8..6e6b886a50 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -15,38 +15,38 @@ from argparse import ArgumentParser # Command line parsing parser = ArgumentParser() parser.add_argument('-j', '--parallel', dest='n_procs', default='1', - help="Number of parallel jobs.") + help="Number of parallel jobs.") parser.add_argument('-R', '--tests-regex', dest='regex_tests', - help="Run tests matching regular expression. \ - Test names are the directories present in tests folder.\ - This uses standard regex syntax to select tests.") + help="Run tests matching regular expression. \ + Test names are the directories present in tests folder.\ + This uses standard regex syntax to select tests.") parser.add_argument('-C', '--build-config', dest='build_config', - help="Build configurations matching regular expression. \ - Specific build configurations can be printed out with \ - optional argument -p, --print. This uses standard \ - regex syntax to select build configurations.") + help="Build configurations matching regular expression. \ + Specific build configurations can be printed out with \ + optional argument -p, --print. This uses standard \ + regex syntax to select build configurations.") parser.add_argument('-l', '--list', action="store_true", - dest="list_build_configs", default=False, - help="List out build configurations.") + dest="list_build_configs", default=False, + help="List out build configurations.") parser.add_argument("-p", "--project", dest="project", default="", - help="project name for build") + help="project name for build") parser.add_argument("-D", "--dashboard", dest="dash", - help="Dash name -- Experimental, Nightly, Continuous") + help="Dash name -- Experimental, Nightly, Continuous") parser.add_argument("-u", "--update", action="store_true", dest="update", - help="Allow CTest to update repo. (WARNING: may overwrite\ - changes that were not pushed.") + help="Allow CTest to update repo. (WARNING: may overwrite\ + changes that were not pushed.") parser.add_argument("-s", "--script", action="store_true", dest="script", - help="Activate CTest scripting mode for coverage, valgrind\ - and dashboard capability.") + help="Activate CTest scripting mode for coverage, valgrind\ + and dashboard capability.") args = parser.parse_args() # Default compiler paths -FC='gfortran' -CC='gcc' -CXX='g++' -MPI_DIR='/opt/mpich/3.2-gnu' -HDF5_DIR='/opt/hdf5/1.8.16-gnu' -PHDF5_DIR='/opt/phdf5/1.8.16-gnu' +FC = 'gfortran' +CC = 'gcc' +CXX = 'g++' +MPI_DIR = '/opt/mpich/3.2-gnu' +HDF5_DIR = '/opt/hdf5/1.8.16-gnu' +PHDF5_DIR = '/opt/phdf5/1.8.16-gnu' # Script mode for extra capability script_mode = False @@ -115,6 +115,7 @@ endif() # Define test data structure tests = OrderedDict() + def cleanup(path): """Remove generated output files.""" for dirpath, dirnames, filenames in os.walk(path): @@ -173,7 +174,7 @@ class Test(object): # Sets the build name that will show up on the CDash def get_build_name(self): - self.build_name = args.project + '_' + self.name + self.build_name = args.project + '_' + self.name return self.build_name # Sets up build options for various tests. It is used both @@ -211,7 +212,7 @@ class Test(object): os.environ['HDF5_ROOT'] = PHDF5_DIR else: os.environ['HDF5_ROOT'] = HDF5_DIR - rc = call(['ctest', '-S', 'ctestscript.run','-V']) + rc = call(['ctest', '-S', 'ctestscript.run', '-V']) if rc != 0: self.success = False self.msg = 'Failed on ctest script.' @@ -243,7 +244,7 @@ class Test(object): return # Default make string - make_list = ['make','-s'] + make_list = ['make', '-s'] # Check for parallel if args.n_procs is not None: @@ -282,7 +283,7 @@ class Test(object): # Simple function to add a test to the global tests dictionary -def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ +def add_test(name, debug=False, optimize=False, mpi=False, openmp=False, phdf5=False, valgrind=False, coverage=False): tests.update({name: Test(name, debug, optimize, mpi, openmp, phdf5, valgrind, coverage)}) @@ -363,7 +364,7 @@ ctest_vars = { # Check project name subprop = "set_property(GLOBAL PROPERTY SubProject {0})" -if args.project == "" : +if args.project == "": ctest_vars.update({'subproject': ''}) elif args.project == 'develop': ctest_vars.update({'subproject': ''}) @@ -442,14 +443,14 @@ for key in iter(tests): # INCLUDE is a CTest command that allows for a subset # of tests to be executed. Only used in script mode. if args.regex_tests is None: - ctest_vars.update({'tests' : ''}) + ctest_vars.update({'tests': ''}) # No user tests, use default valgrind tests if test.valgrind: - ctest_vars.update({'tests' : 'INCLUDE {0}'. + ctest_vars.update({'tests': 'INCLUDE {0}'. format(valgrind_default_tests)}) else: - ctest_vars.update({'tests' : 'INCLUDE {0}'. + ctest_vars.update({'tests': 'INCLUDE {0}'. format(args.regex_tests)}) # Main part of code that does the ctest execution.