当前位置: 首页>>代码示例>>Python>>正文


Python testhelpers.assertRaisesNothing函数代码示例

本文整理汇总了Python中testhelpers.assertRaisesNothing函数的典型用法代码示例。如果您正苦于以下问题:Python assertRaisesNothing函数的具体用法?Python assertRaisesNothing怎么用?Python assertRaisesNothing使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assertRaisesNothing函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_MDFrameValidator_construction

 def test_MDFrameValidator_construction(self):
     """
         Test that the MDFrameValidator can be constructed
         with a single string
     """
     testhelpers.assertRaisesNothing(self, MDFrameValidator, "HKL")
     self.assertRaises(Exception, MDFrameValidator)
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:WorkspaceValidatorsTest.py

示例2: test_plotconstE_nonListArgsExecutes

 def test_plotconstE_nonListArgsExecutes(self):
     kwargs = {
         'workspaces': self._sqw,
         'E' : -1.,
         'dE' : 1.5
     }
     testhelpers.assertRaisesNothing(self, directtools.plotconstE, **kwargs)
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:DirectToolsTest.py

示例3: testSumInQModeProducesDX

 def testSumInQModeProducesDX(self):
     dirWS = illhelpers.create_poor_mans_d17_workspace()
     mtd.add('dirWS', dirWS)
     illhelpers.add_slit_configuration_D17(dirWS, 0.03, 0.02)
     illhelpers.add_chopper_configuration_D17(dirWS)
     illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128)
     dirWS = illhelpers.refl_preprocess('dirWS', dirWS, 'dirBeamPosWS')
     dirFgdWS = illhelpers.refl_sum_foreground('dirFgdWS', 'SumInLambda', dirWS)
     reflWS = illhelpers.create_poor_mans_d17_workspace()
     illhelpers.add_chopper_configuration_D17(reflWS)
     illhelpers.add_slit_configuration_D17(reflWS, 0.03, 0.02)
     illhelpers.refl_rotate_detector(reflWS, 1.5)
     mtd.add('reflWS', reflWS)
     illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.5, 128)
     reflWS = illhelpers.refl_preprocess('reflWS', reflWS, 'reflBeamPosWS')
     fgdWS = illhelpers.refl_sum_foreground('fgdWS', 'SumInQ', reflWS, dirFgdWS, dirWS)
     args = {
         'InputWorkspace': fgdWS,
         'OutputWorkspace': 'inQ',
         'DirectForegroundWorkspace': dirFgdWS,
         'GroupingQFraction': 0.2,
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLConvertToQ', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEqual(outWS.getNumberHistograms(), 1)
     self.assertTrue(outWS.hasDx(0))
开发者ID:samueljackson92,项目名称:mantid,代码行数:29,代码来源:ReflectometryILLConvertToQTest.py

示例4: test_clear_functions_do_not_throw

 def test_clear_functions_do_not_throw(self):
     # Test they don't throw for now
     testhelpers.assertRaisesNothing(self, FrameworkManager.clear)
     testhelpers.assertRaisesNothing(self, FrameworkManager.clearData)
     testhelpers.assertRaisesNothing(self, FrameworkManager.clearAlgorithms)
     testhelpers.assertRaisesNothing(self, FrameworkManager.clearInstruments)
     testhelpers.assertRaisesNothing(self, FrameworkManager.clearPropertyManagers)
开发者ID:BigShows,项目名称:mantid,代码行数:7,代码来源:FrameworkManagerTest.py

示例5: testWaterWorkspace

 def testWaterWorkspace(self):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     # Add a peak to the sample workspace.
     ws = mtd[inWSName]
     for i in range(ws.getNumberHistograms()):
         ys = ws.dataY(i)
         ys.fill(10.27)
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'WaterWorkspace': inWSName,
         'FluxNormalisation': 'Normalisation OFF',
         'FlatBackground': 'Background OFF',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     ysSize = outWS.blocksize()
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         numpy.testing.assert_equal(ys, [1.0] * ysSize)
     self.assertEquals(mtd.getObjectNames(), ['ReflectometryILLPreprocess_test_ws'])
开发者ID:mantidproject,项目名称:mantid,代码行数:26,代码来源:ReflectometryILLPreprocessTest.py

示例6: test_RawCountValidator_construction

 def test_RawCountValidator_construction(self):
     """
         Test that the HistogramValidator can be constructed
         with no args or a single bool
     """
     testhelpers.assertRaisesNothing(self, RawCountValidator)
     testhelpers.assertRaisesNothing(self, RawCountValidator, False)
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:WorkspaceValidatorsTest.py

示例7: testForegroundBackgroundRanges

 def testForegroundBackgroundRanges(self):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     ws = mtd[inWSName]
     # Add special background fitting zones around the exclude zones.
     lowerBkgIndices = [26]
     for i in lowerBkgIndices:
         ys = ws.dataY(i)
         ys += 5.0
     # Add negative 'exclude zone' around the peak.
     lowerExclusionIndices = [27, 28]
     for i in lowerExclusionIndices:
         ys = ws.dataY(i)
         ys -= 1000.0
     # Add a peak to the sample workspace.
     foregroundIndices = [29, 30, 31]
     for i in foregroundIndices:
         ys = ws.dataY(i)
         ys += 1000.0
     # The second exclusion zone is wider.
     upperExclusionIndices = [32, 33, 34]
     for i in upperExclusionIndices:
         ys = ws.dataY(i)
         ys -= 1000.0
     # The second fitting zone is wider.
     upperBkgIndices = [35, 36]
     for i in upperBkgIndices:
         ys = ws.dataY(i)
         ys += 5.0
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'BeamCentre': 30,
         'ForegroundHalfWidth': [1],
         'LowAngleBkgOffset': len(lowerExclusionIndices),
         'LowAngleBkgWidth': len(lowerBkgIndices),
         'HighAngleBkgOffset': len(upperExclusionIndices),
         'HighAngleBkgWidth': len(upperBkgIndices),
         'FluxNormalisation': 'Normalisation OFF',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         if i in lowerBkgIndices:
             numpy.testing.assert_equal(ys, 0)
         elif i in lowerExclusionIndices:
             numpy.testing.assert_equal(ys, -1005)
         elif i in foregroundIndices:
             numpy.testing.assert_equal(ys, 995)
         elif i in upperExclusionIndices:
             numpy.testing.assert_equal(ys, -1005)
         elif i in upperBkgIndices:
             numpy.testing.assert_equal(ys, 0)
         else:
             numpy.testing.assert_equal(ys, -5)
开发者ID:samueljackson92,项目名称:mantid,代码行数:60,代码来源:ReflectometryILLPreprocessTest.py

示例8: _backgroundSubtraction

 def _backgroundSubtraction(self, subtractionType):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     # Add a peak to the sample workspace.
     ws = mtd[inWSName]
     ys = ws.dataY(49)
     ys += 10.0
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'LinePosition': 49,
         'FluxNormalisation': 'Normalisation OFF',
         'FlatBackground': subtractionType,
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     ysSize = outWS.blocksize()
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         if i != 49:
             numpy.testing.assert_almost_equal(ys, [0.0] * ysSize)
         else:
             numpy.testing.assert_almost_equal(ys, [10.0] * ysSize)
     self.assertEquals(mtd.getObjectNames(), ['ReflectometryILLPreprocess_test_ws'])
开发者ID:mantidproject,项目名称:mantid,代码行数:28,代码来源:ReflectometryILLPreprocessTest.py

示例9: test_WorkspaceUnitValidator_construction

 def test_WorkspaceUnitValidator_construction(self):
     """
         Test that the WorkspaceUnitValidator can be constructed
         with a single string
     """
     testhelpers.assertRaisesNothing(self, WorkspaceUnitValidator,"DeltaE")
     self.assertRaises(Exception, WorkspaceUnitValidator)
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:WorkspaceValidatorsTest.py

示例10: testAsymmetricForegroundRanges

 def testAsymmetricForegroundRanges(self):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     ws = mtd[inWSName]
     # Add special background fitting zones around the exclude zones.
     foregroundIndices = [21, 22, 23, 24]
     for i in range(ws.getNumberHistograms()):
         ys = ws.dataY(i)
         es = ws.dataE(i)
         if i in foregroundIndices:
             ys.fill(1000.0)
             es.fill(numpy.sqrt(1000.0))
         else:
             ys.fill(-100)
             es.fill(numpy.sqrt(100))
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'BeamCentre': 23,
         'ForegroundHalfWidth': [2, 1],
         'FlatBackground': 'Background OFF',
         'FluxNormalisation': 'Normalisation OFF',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     logs = outWS.run()
     properties = ['foreground.first_workspace_index', 'foreground.centre_workspace_index', 'foreground.last_workspace_index']
     values = [21, 23, 24]
     for p, val in zip(properties, values):
         self.assertTrue(logs.hasProperty(p))
         self.assertEqual(logs.getProperty(p).value, val)
开发者ID:samueljackson92,项目名称:mantid,代码行数:35,代码来源:ReflectometryILLPreprocessTest.py

示例11: test_attributes

 def test_attributes(self):
     testhelpers.assertRaisesNothing(self, FunctionWrapper, "Polynomial", attributes={'n': 3}, A0=4, A1=3, A2=2, A3=1)
     testhelpers.assertRaisesNothing(self, FunctionWrapper, "Polynomial", n=3, A0=4, A1=3, A2=2, A3=1)
     p = Polynomial(n=3, A0=1, A1=2, A2=4, A3=3)
     self.assertEqual(p['n'],3)
     p['n'] = 4
     self.assertEqual(p['n'],4)
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:FitFunctionsTest.py

示例12: test_NumericAxisValidator_construction

 def test_NumericAxisValidator_construction(self):
     """
         Test that the NumericAxis can be constructed
         with no args or a single integer
     """
     testhelpers.assertRaisesNothing(self, NumericAxisValidator)
     testhelpers.assertRaisesNothing(self, NumericAxisValidator, 0)
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:WorkspaceValidatorsTest.py

示例13: test_plotconstQ_nonListArgsExecutes

 def test_plotconstQ_nonListArgsExecutes(self):
     kwargs = {
         'workspaces': self._sqw,
         'Q' : 2.3,
         'dQ' : 0.3
     }
     testhelpers.assertRaisesNothing(self, directtools.plotconstQ, **kwargs)
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:DirectToolsTest.py

示例14: test_that_script_is_executable_in_mantid

    def test_that_script_is_executable_in_mantid(self):
        # data files are here
        self.scriptElement.dataDir  = ''

        # vanadium runs & comment
        self.scriptElement.vanRuns  = 'TOFTOFTestdata.nxs'

        # empty can runs, comment, and factor
        self.scriptElement.ecRuns   = 'TOFTOFTestdata.nxs'
        self.scriptElement.ecTemp   = OptionalFloat(21.0)
        self.scriptElement.ecFactor = 0.9

        # data runs: [(runs,comment, temperature), ...]
        self.scriptElement.dataRuns = [
            [unicode('TOFTOFTestdata.nxs'), unicode('H2O 21C'), OptionalFloat(None)],
            [unicode('TOFTOFTestdata.nxs'), unicode('H2O 34C'), OptionalFloat(34.0)]
        ]

        self.scriptElement.maskDetectors = '1,2'

        # options
        self.scriptElement.subtractECVan = True
        self.scriptElement.normalise     = TOFTOFScriptElement.NORM_MONITOR
        self.scriptElement.correctTof    = TOFTOFScriptElement.CORR_TOF_VAN
        self.scriptElement.replaceNaNs   = True
        self.scriptElement.createDiff    = True
        self.scriptElement.keepSteps     = True

        testhelpers.assertRaisesNothing(self, self.execScript, 
                                        self.scriptElement.to_script().replace('import matplotlib.pyplot as plt', ''))
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:TOFTOFScriptElementTest.py

示例15: test_properties_obey_attached_validators

 def test_properties_obey_attached_validators(self):
     """
         Test property declarations with validator.
         The validators each have their own test.
     """
     class PropertiesWithValidation(PythonAlgorithm):
         
         def PyInit(self):
             only_positive = IntBoundedValidator()
             only_positive.setLower(0)
             self.declareProperty('NumPropWithDefaultDir', -1, only_positive)
             self.declareProperty('NumPropWithInOutDir', -1, only_positive,"doc string", Direction.InOut)
         
         def PyExec(self):
             pass
     ###################################################
     alg = PropertiesWithValidation()
     alg.initialize()
     props = alg.getProperties()
     self.assertEquals(2, len(props))
     
     def_dir = alg.getProperty("NumPropWithDefaultDir")
     self.assertEquals(def_dir.direction, Direction.Input)
     self.assertNotEquals("", def_dir.isValid)
     self.assertRaises(ValueError, alg.setProperty, "NumPropWithDefaultDir", -10)
     testhelpers.assertRaisesNothing(self, alg.setProperty, "NumPropWithDefaultDir", 11)
开发者ID:AlistairMills,项目名称:mantid,代码行数:26,代码来源:PythonAlgorithmPropertiesTest.py


注:本文中的testhelpers.assertRaisesNothing函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。