def test__ne__(self): d = PhotonDetector('det2', math.radians(35), math.radians(90)) self.assertNotEqual(d, self.d) d = PhotonDetector(math.radians(36), math.radians(90)) self.assertNotEqual(d, self.d) d = PhotonDetector(math.radians(35), math.radians(91)) self.assertNotEqual(d, self.d)
def testvalidate_limit_uncertainty(self): xrayline = XrayLine(13, 'Ka1') detector = PhotonDetector('det', 1.1, 2.2) limit = UncertaintyLimit(xrayline, detector, 0.02) limit2 = self.v.validate_limit(limit, self.options) self.assertEqual(limit2, limit) self.assertIsNot(limit2, limit)
def testvalidate_analysis_kratio(self): detector = PhotonDetector('det', 1.1, 2.2) analysis = KRatioAnalysis(detector) analysis.add_standard_material(13, Material.pure(13)) analysis2 = self.v.validate_analysis(analysis, self.options) self.assertEqual(analysis2, analysis) self.assertIsNot(analysis2, analysis)
def testvalidate_analysis_photonintensity_exception(self): detector = PhotonDetector('', 2.0, -1.0) analysis = PhotonIntensityAnalysis(detector) self.assertRaises(ValidationError, self.v.validate_analysis, analysis, self.options) errors = set() self.v._validate_analysis(analysis, self.options, errors) self.assertEqual(3, len(errors))
def testvalidate_limit_uncertainty_exception(self): xrayline = XrayLine(13, 'Ka1') detector = PhotonDetector('', float('nan'), -1) limit = UncertaintyLimit(xrayline, detector, 0.0) self.assertRaises(ValidationError, self.v.validate_limit, limit, self.options) errors = set() self.v._validate_limit(limit, self.options, errors) self.assertEqual(3, len(errors))
def testvalidate_analysis_kratio_exception(self): detector = PhotonDetector('', 2.0, -1.0) analysis = KRatioAnalysis(detector) analysis.add_standard_material(14, Material.pure(13)) self.assertRaises(ValidationError, self.v.validate_analysis, analysis, self.options) errors = set() self.v._validate_analysis(analysis, self.options, errors) self.assertEqual(4, len(errors))
def setUp(self): super().setUp() detector = PhotonDetector(1.1, 2.2) analysis = PhotonIntensityAnalysis(detector) b = EmittedPhotonIntensityResultBuilder(analysis) b.add_intensity((13, 'Ka1'), 1.0, 0.1) b.add_intensity((13, 'Ka2'), 2.0, 0.2) b.add_intensity((13, 'Kb1'), 4.0, 0.5) b.add_intensity((13, 'Kb3'), 5.0, 0.7) b.add_intensity((13, 'Ll'), 3.0, 0.1) self.r = b.build()
def testconvert(self): handler = OptionsHtmlHandler() options = self.create_basic_options() sample = HorizontalLayerSample(COPPER, tilt_rad=0.1, azimuth_rad=0.2) sample.add_layer(ZINC, 20e-9) sample.add_layer(VACUUM, 20e-9) sample.add_layer(GALLIUM, 50e-9) options.sample = sample detector = PhotonDetector('xray2', 2.2, 3.3) analysis = KRatioAnalysis(detector) analysis.add_standard_material(29, COPPER) analysis.add_standard_material(30, ZINC) options.analyses.append(analysis) doc = handler.convert(options) self.assertEqual(12, len(doc.getElementsByTagName('dt')))
def detector(): return PhotonDetector("det", math.radians(35), math.radians(90))
def create_analysis(): detector = PhotonDetector(name='detector_1', elevation_rad=math.radians(40)) photon_analysis = PhotonIntensityAnalysis(detector) return photon_analysis
def setUp(self): super().setUp() detector = PhotonDetector(1.1, 2.2) analysis = PhotonIntensityAnalysis(detector) self.b = EmittedPhotonIntensityResultBuilder(analysis)
def setUp(self): super().setUp() self.d = PhotonDetector('det', math.radians(35), math.radians(90))
def testconvert_parse(self): handler = PhotonDetectorHDF5Handler() detector = PhotonDetector('det', math.radians(35), math.radians(45)) detector2 = self.convert_parse_hdf5handler(handler, detector) self.assertEqual(detector2, detector)
def test_photondetector_eq(detector): assert detector == PhotonDetector("det", math.radians(35), math.radians(90))
def test__eq__(self): d = PhotonDetector('det', math.radians(35), math.radians(90)) self.assertEqual(d, self.d)
def test_photondetector_ne(detector): assert not detector == PhotonDetector("det2", math.radians(35), math.radians(90)) assert not detector == PhotonDetector(math.radians(36), math.radians(90)) assert not detector == PhotonDetector(math.radians(35), math.radians(91))
def testvalidate_analysis_photonintensity(self): detector = PhotonDetector('det', 1.1, 2.2) analysis = PhotonIntensityAnalysis(detector) analysis2 = self.v.validate_analysis(analysis, self.options) self.assertEqual(analysis2, analysis) self.assertIsNot(analysis2, analysis)