Esempio n. 1
0
def test_element_data():
    """
    smoke test of all elements
    """

    data1 = []
    data2 = []

    name_list = []
    for i in range(100):
        e = XrfElement(i+1)
        data1.append(e.cs(10)['Ka1'])
        name_list.append(e.name)

    for item in name_list:
        e = XrfElement(item)
        data2.append(e.cs(10)['Ka1'])

    assert_array_equal(data1, data2)

    return
Esempio n. 2
0
def smoke_test_element_creation():
    prev_element = None
    elements = [elm for abbrev, elm in six.iteritems(basic)
                if isinstance(abbrev, int)]
    elements.sort()
    for element in elements:
        Z = element.Z
        mass = element.mass
        density = element.density
        sym = element.sym
        inits = [Z, sym, sym.upper(), sym.lower(), sym.swapcase()]
        element = None
        for init in inits:
            element = XrfElement(init)
            # obtain the next four attributes to make sure the XrayLibWrap is
            # working
            element.bind_energy
            element.fluor_yield
            element.jump_factor
            element.emission_line.all
            if prev_element is not None:
                # compare prev_element to element
                assert_equal(prev_element.__lt__(element), True)
                assert_equal(prev_element < element, True)
                assert_equal(prev_element.__eq__(element), False)
                assert_equal(prev_element == element, False)
                assert_equal(prev_element >= element, False)
                assert_equal(prev_element > element, False)
                # compare element to prev_element
                assert_equal(element < prev_element, False)
                assert_equal(element.__lt__(prev_element), False)
                assert_equal(element <= prev_element, False)
                assert_equal(element.__eq__(prev_element), False)
                assert_equal(element == prev_element, False)
                assert_equal(element >= prev_element, True)
                assert_equal(element > prev_element, True)
        prev_element = element