def importEntirePackage(module): """Load every module in a package""" # TODO: this method may only work for a flat directory? modules = glob.glob( pathTools.armiAbsDirFromName(module.__name__) + "/*.py") names = [os.path.basename(f)[:-3] for f in modules] for name in names: import_module(module.__package__ + "." + name)
from six.moves import cPickle from armi import settings from armi.tests import mockRunLogs from armi.localization import exceptions from armi.nucDirectory import nuclideBases from armi.nuclearDataIO import isotxs from armi.nuclearDataIO import pmatrx from armi.nuclearDataIO import gamiso from armi.nuclearDataIO import xsLibraries from armi.utils import pathTools from armi.utils import directoryChangers from armi.utils import properties from armi.utils import outputCache THIS_DIR = pathTools.armiAbsDirFromName(__name__) RUN_DIR = os.path.join(THIS_DIR, "library-file-generation") FIXTURE_DIR = os.path.join(THIS_DIR, "fixtures") ISOTXS_AA = os.path.join(FIXTURE_DIR, "mc2v3-AA.isotxs") ISOTXS_AB = os.path.join(FIXTURE_DIR, "mc2v3-AB.isotxs") ISOTXS_AA_AB = os.path.join(FIXTURE_DIR, "combined-AA-AB.isotxs") ISOTXS_LUMPED = os.path.join(FIXTURE_DIR, "combined-and-lumped-AA-AB.isotxs") PMATRX_AA = os.path.join(FIXTURE_DIR, "mc2v3-AA.pmatrx") PMATRX_AB = os.path.join(FIXTURE_DIR, "mc2v3-AB.pmatrx") PMATRX_AA_AB = os.path.join(FIXTURE_DIR, "combined-AA-AB.pmatrx") PMATRX_LUMPED = os.path.join(FIXTURE_DIR, "combined-and-lumped-AA-AB.pmatrx") GAMISO_AA = os.path.join(FIXTURE_DIR, "mc2v3-AA.gamiso") GAMISO_AB = os.path.join(FIXTURE_DIR, "mc2v3-AB.gamiso")
def test_armiAbsDir(self): result = pathTools.armiAbsDirFromName("armi.utils.tests.test1") self.assertEqual(result, path.join(ROOT, "utils", "tests"))
def test_armiAbsDir_name(self): result = pathTools.armiAbsDirFromName(__name__) self.assertEqual(result, path.join(ROOT, "utils", "tests"))
import os import shutil import armi from armi import utils from armi.bookkeeping import historyTracker from armi.reactor import blocks from armi.reactor.flags import Flags from armi.utils import pathTools from armi import settings from armi.utils import directoryChangers from armi.reactor import grids from armi.cases import case from armi.tests import ArmiTestHelper THIS_DIR = pathTools.armiAbsDirFromName( __name__) # b/c tests don't run in this folder TUTORIAL_DIR = os.path.join(armi.context.ROOT, "tests", "tutorials") CASE_TITLE = "anl-afci-177" def runTutorialNotebook(): import nbformat from nbconvert.preprocessors import ExecutePreprocessor with directoryChangers.DirectoryChanger(TUTORIAL_DIR): with open("data_model.ipynb") as f: nb = nbformat.read(f, as_version=4) ep = ExecutePreprocessor(timeout=600, kernel_name="python") ep.preprocess(nb, {})