def testNonsensicalAtomicSymbol(self): with pytest.raises(BadElementInputError): Transition(500 * u.nm, True, 1) with pytest.raises(BadElementInputError): Transition(500 * u.nm, (True, ), 1) with pytest.raises(BadElementInputError): Transition(500 * u.nm, False, 1) with pytest.raises(BadElementInputError): Transition(500 * u.nm, [False], 1)
def testWavelengthSorting(self): a = Transition(500 * u.nm, 26, 1) b = Transition(501 * u.nm, 26, 1) assert a < b assert not a > b assert b > a assert not b < a with pytest.raises(ValueError): assert a < 'A non-transition' with pytest.raises(ValueError): assert b > 'A non-transition'
def mock_transition(self): a = Transition(558.0345 * u.nm, 54, 1) a.lowerEnergy = 17.012 * u.cm**-1 a.lowerOrbital = '(4F)4s a5F' a.lowerJ = 1.5 a.higherEnergy = 12051.823 * u.cm**-1 a.higherOrbital = '3Gsp3P x3H' a.higherJ = 0 a.normalizedDepth = 0.234 return a
def testFractionalJConversion(self): a = Transition(500 * u.nm, 26, 1) a.lowerJ = 1.5 assert a.lowerJ == Fraction(3, 2) a.lowerJ = None assert a.lowerJ is None a.higherJ = 2 assert a.higherJ == Fraction(2, 1) a.higherJ = None assert a.higherJ is None
def testNonexistentAtomicSymbol(self): with pytest.raises(BadElementInputError): Transition(500 * u.nm, 'X', 1)
def testWrongAtomicSymbolTooLong(self): with pytest.raises(BadElementInputError): Transition(500 * u.nm, 'Ah!', 1) # Element of surprise
def testAtomicNumberInt(self): a = Transition(500 * u.nm, 54, 1) assert a.atomicSymbol == 'Xe'
def transition_2(self): return Transition(600 * u.nm, 26, 1)
def testWavenumberConversion(self): a = Transition(500 * u.nm, 26, 1) a.wavenumber = 2500000 * 1 / u.m assert a.wavelength.value == pytest.approx(4e-5) assert a.wavelength.units == u.cm assert a.wavenumber.units == u.cm**-1
def testStringRomanNumeralIonizationState(self): a = Transition(500 * u.nm, 26, 'I') assert a.ionizationState == 1 assert a.atomicSpecies == 'Fe I' assert a.atomicSymbol == 'Fe'
def testZeroIonizationState(self): with pytest.raises(IonizationStateError): Transition(500 * u.nm, 26, 0)
def testNegativeAtomicNumber(self): with pytest.raises(AtomicNumberError): Transition(500 * u.nm, -1, 1)
def testZeroAtomicNumber(self): with pytest.raises(AtomicNumberError): Transition(500 * u.nm, 0, 1)
def testNoUnits(self): with pytest.raises(AttributeError): Transition(500, 26, 1)
def testEquality(self): a = Transition(500.0 * u.nm, 26, 1) b = Transition(500.0 * u.nm, 26, 1) with pytest.raises(ValueError): assert a == 'A non-transition' assert a == b a.lowerEnergy = b.lowerEnergy = 1.3 * u.eV assert a == b a.higherEnergy = b.higherEnergy = 5.6 * u.eV assert a == b a.lowerJ = b.lowerJ = 1.5 assert a == b a.higherJ = b.higherJ = 0.5 assert a == b a.lowerOrbital = b.lowerOrbital = '3d8.(3F).4s.4p.(3P*)' assert a == b a.higherOrbital = b.higherOrbital = '3d8.4s.(2F).5s ' assert a == b # Now test for inequality. b.higherOrbital = 'non-existent' assert a != b b.lowerOrbital = "it's gone too" assert a != b b.higherJ = 3 assert a != b b.lowerJ = 0 assert a != b b.higherEnergy = 4 * u.eV assert a != b b.lowerEnergy = 3 * u.eV assert a != b b.ionizationState = 2 assert a != b b.ionizationState = 1 b.atomicNumber = 27 assert a != b b.atomicNumber = 26 b.wavelength = 501 * u.nm assert a != b
def testAtomicSpecies(self): a = Transition(500 * u.nm, 26, 1) assert a.atomicSpecies == 'Fe I' b = Transition(500 * u.nm, 31, 2) assert b.atomicSpecies == 'Ga II'
def testNegativeIonizationState(self): with pytest.raises(IonizationStateError): Transition(500 * u.nm, 26, -1)
def testWavenumberAssigment(self): a = Transition(500 * u.nm, 26, 1) assert a.wavenumber.value == pytest.approx(20000) a.wavenumber = 20000 * u.cm**-1 assert a.wavelength.value == pytest.approx(5e-5)
def testUnsupportedRomanNumeral(self): with pytest.raises(IonizationStateError): Transition(500 * u.nm, 26, 'XL')
def transition_1(self): return Transition(500 * u.nm, 26, 1)
def testAtomicSymbolString(self): a = Transition(500 * u.nm, 'fe', 1) assert a.atomicNumber == 26
def transition_3(self): return Transition(650 * u.nm, 26, 1)
def testAtomicNumberString(self): a = Transition(500 * u.nm, '77', 1) assert a.atomicSymbol == 'Ir'