scikit-beam / scikit-beam

@@ -0,0 +1,30 @@
Loading
1 +
import pytest
2 +
import numpy.testing as npt
3 +
4 +
from skbeam.core.fitting.xrf_model import get_line_energy
5 +
6 +
7 +
@pytest.mark.parametrize("elemental_line, energy_expected", [
8 +
    ("Ca_K", 3.6917),
9 +
    ("Ca_Ka", 3.6917),
10 +
    ("Ca_Ka1", 3.6917),
11 +
    ("Ca_Kb", 4.0127),
12 +
    ("Ca_Kb1", 4.0127),
13 +
    ("Ca_Ka3", 3.6003),
14 +
    ("Ca_ka3", 3.6003),
15 +
    ("Ca_kA3", 3.6003),
16 +
    ("Eu_L", 5.8460),
17 +
    ("Eu_La", 5.8460),
18 +
    ("Eu_La1", 5.8460),
19 +
    ("Eu_Lb", 6.4565),
20 +
    ("Eu_Lb1", 6.4565),
21 +
    ("Eu_Lb3", 6.5714),
22 +
    ("U_M", 3.1710),
23 +
    ("U_Ma", 3.1710),
24 +
    ("U_Ma1", 3.1710),
25 +
    ("U_Ma2", 3.1610),
26 +
])
27 +
def test_get_line_energy(elemental_line, energy_expected):
28 +
    energy = get_line_energy(elemental_line)
29 +
    npt.assert_almost_equal(energy, energy_expected,
30 +
                            err_msg="Energy doesn't match expected")

@@ -1087,15 +1087,18 @@
Loading
1087 1087
1088 1088
1089 1089
def get_line_energy(elemental_line):
1090 -
    """Return the energy of the first line in K, L or M series.
1090 +
    """Return the energy of the emission line.
1091 1091
1092 1092
    Parameters
1093 1093
    ----------
1094 1094
    elemental_line : str
1095 -
        For instance, Eu_L is the format for L lines and Pt_M for M lines.
1096 -
        And for K lines, user needs to define lines like ka1, kb1,
1097 -
        because for K lines, we consider contributions from either ka1
1098 -
        or kb1, while for L or M lines, we only consider the primary peak.
1095 +
        For instance, Ca_K will return energy of the peak for Ca_ka1 line,
1096 +
        Ca_Kb will return energy for Ca_Kb1 line and Ca_Kb2 line will return
1097 +
        energy for Ca_Kb2 line. The letters in the element name (e.g. Ca) should
1098 +
        be capitalized properly. Letters in the line name may be arbitrarily
1099 +
        capitalized, e.g. Ca_kb1 is equivalent to Ca_Kb1 or Ca_KB1.
1100 +
        The function is primarily used for finding center of a pileup peak,
1101 +
        so typical format for the emission line is Ca_Ka1.
1099 1102
1100 1103
    Returns
1101 1104
    -------
@@ -1104,15 +1107,15 @@
Loading
1104 1107
    """
1105 1108
    name, line = elemental_line.split('_')
1106 1109
    line = line.lower()
1110 +
1111 +
    # Complete the emission line name
1112 +
    if len(line) == 1:  # elemental line format 'Ca_K'
1113 +
        line += 'a1'
1114 +
    elif len(line) == 2:  # elemental line format 'Ca_Ka'
1115 +
        line += "1"
1116 +
1107 1117
    e = Element(name)
1108 -
    if 'k' in line:
1109 -
        e_cen = e.emission_line[line]
1110 -
    elif 'l' in line:
1111 -
        # only the first line for L
1112 -
        e_cen = e.emission_line['la1']
1113 -
    else:
1114 -
        # only the first line for M
1115 -
        e_cen = e.emission_line['ma1']
1118 +
    e_cen = e.emission_line[line]
1116 1119
    return e_cen
1117 1120
1118 1121
Files Coverage
skbeam 90.95%
Project Totals (69 files) 90.95%
2143.7
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading