Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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'
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 def testNonexistentAtomicSymbol(self):
     with pytest.raises(BadElementInputError):
         Transition(500 * u.nm, 'X', 1)
Exemplo n.º 6
0
 def testWrongAtomicSymbolTooLong(self):
     with pytest.raises(BadElementInputError):
         Transition(500 * u.nm, 'Ah!', 1)  # Element of surprise
Exemplo n.º 7
0
 def testAtomicNumberInt(self):
     a = Transition(500 * u.nm, 54, 1)
     assert a.atomicSymbol == 'Xe'
Exemplo n.º 8
0
 def transition_2(self):
     return Transition(600 * u.nm, 26, 1)
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 def testStringRomanNumeralIonizationState(self):
     a = Transition(500 * u.nm, 26, 'I')
     assert a.ionizationState == 1
     assert a.atomicSpecies == 'Fe I'
     assert a.atomicSymbol == 'Fe'
Exemplo n.º 11
0
 def testZeroIonizationState(self):
     with pytest.raises(IonizationStateError):
         Transition(500 * u.nm, 26, 0)
Exemplo n.º 12
0
 def testNegativeAtomicNumber(self):
     with pytest.raises(AtomicNumberError):
         Transition(500 * u.nm, -1, 1)
Exemplo n.º 13
0
 def testZeroAtomicNumber(self):
     with pytest.raises(AtomicNumberError):
         Transition(500 * u.nm, 0, 1)
Exemplo n.º 14
0
 def testNoUnits(self):
     with pytest.raises(AttributeError):
         Transition(500, 26, 1)
Exemplo n.º 15
0
    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
Exemplo n.º 16
0
 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'
Exemplo n.º 17
0
 def testNegativeIonizationState(self):
     with pytest.raises(IonizationStateError):
         Transition(500 * u.nm, 26, -1)
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
 def testUnsupportedRomanNumeral(self):
     with pytest.raises(IonizationStateError):
         Transition(500 * u.nm, 26, 'XL')
Exemplo n.º 20
0
 def transition_1(self):
     return Transition(500 * u.nm, 26, 1)
Exemplo n.º 21
0
 def testAtomicSymbolString(self):
     a = Transition(500 * u.nm, 'fe', 1)
     assert a.atomicNumber == 26
Exemplo n.º 22
0
 def transition_3(self):
     return Transition(650 * u.nm, 26, 1)
Exemplo n.º 23
0
 def testAtomicNumberString(self):
     a = Transition(500 * u.nm, '77', 1)
     assert a.atomicSymbol == 'Ir'