def __init__(self, sparse): HAS_SCIPY = checkScipy() if sparse is None: self.__sparse = HAS_SCIPY elif sparse is True and not HAS_SCIPY: raise ImportError( "scipy not installed and required for sparse support") else: self.__sparse = bool(sparse)
self.assertTrue(self.msgInLogs(level, msg, partial), msg=failMsg) def assertMsgNotInLogs(self, level, msg, partial=False): """ Assert that the message was not stored under a given level Combines :meth:`LoggerMixin.msgInLogs` with :meth:`unittest.TestCase.assertFalse` """ matchType = "a partial" if partial else "an exact" failMsg = "Found {} match for {} under {} but should not have" self.assertFalse(self.msgInLogs(level, msg, partial), msg=failMsg.format(matchType, msg, level)) HAS_SCIPY = checkScipy('1.0') class MatlabTesterHelper(TestCase): """Helper class for matlab conversion""" def setUp(self): """Call this from subclasses to skip if scipy is unavailable""" # skip tests if scipy not installed if not HAS_SCIPY: raise SkipTest("scipy needed to test matlab conversion") def plotTest(f): """Decorator that clears up existing plots prior to test.""" from matplotlib.pyplot import close, figure
def checkImports(self): """Ensure that :term:`scipy` >= 1.0 is installed.""" if not checkScipy('1.0'): raise ImportError("scipy >= 1.0 required")
from numpy import array, inf from numpy.testing import assert_allclose, assert_array_equal from serpentTools.data import getFile from serpentTools.parsers.sensitivity import SensitivityReader from serpentTools.utils import checkScipy from serpentTools.tests import compareDictOfArrays from serpentTools.tests.utils import ( plotTest, getLegendTexts, MatlabTesterHelper, ) TEST_FILE = getFile('bwr_sens0.m') HAS_SCIPY = checkScipy() class SensitivityTestHelper(TestCase): @classmethod def setUpClass(cls): cls.reader = SensitivityReader(TEST_FILE) cls.reader.read() class SensitivityTester(SensitivityTestHelper): """Class for testing the sensitivity reader.""" def test_expectedSensitivities(self): """Verify the sensitivity arrays are loaded correctly.""" expected = { 'fis2flx':