<s> from __future__ import absolute_import , division , print_function <EOL> import six <EOL> from numpy . testing import ( assert_array_equal , assert_raises ) <EOL> from nose . tools import assert_equal , assert_not_equal <EOL> from skbeam . core . constants . xrf import ( XrfElement , emission_line_search , <EOL> XrayLibWrap , XrayLibWrap_Energy ) <EOL> from skbeam . core . utils import NotInstalledError <EOL> from skbeam . core . constants . basic import basic <EOL> def test_element_data ( ) : <EOL> """<STR_LIT>""" <EOL> data1 = [ ] <EOL> data2 = [ ] <EOL> name_list = [ ] <EOL> for i in range ( <NUM_LIT:100> ) : <EOL> e = XrfElement ( i + <NUM_LIT:1> ) <EOL> data1 . append ( e . cs ( <NUM_LIT:10> ) [ '<STR_LIT>' ] ) <EOL> name_list . append ( e . name ) <EOL> for item in name_list : <EOL> e = XrfElement ( item ) <EOL> data2 . append ( e . cs ( <NUM_LIT:10> ) [ '<STR_LIT>' ] ) <EOL> assert_array_equal ( data1 , data2 ) <EOL> return <EOL> def test_element_finder ( ) : <EOL> true_name = sorted ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> out = emission_line_search ( <NUM_LIT:8> , <NUM_LIT> , <NUM_LIT:10> ) <EOL> found_name = sorted ( list ( six . iterkeys ( out ) ) ) <EOL> assert_equal ( true_name , found_name ) <EOL> return <EOL> def test_XrayLibWrap_notpresent ( ) : <EOL> from skbeam . core . constants import xrf <EOL> xraylib = xrf . xraylib <EOL> xrf . xraylib = None <EOL> assert_raises ( NotInstalledError , xrf . XrfElement , None ) <EOL> assert_raises ( NotInstalledError , xrf . emission_line_search , <EOL> None , None , None ) <EOL> assert_raises ( NotInstalledError , xrf . XrayLibWrap , None , None ) <EOL> assert_raises ( NotInstalledError , xrf . XrayLibWrap_Energy , <EOL> None , None , None ) <EOL> xrf . xraylib = xraylib <EOL> def test_XrayLibWrap ( ) : <EOL> for Z in range ( <NUM_LIT:1> , <NUM_LIT> ) : <EOL> for infotype in XrayLibWrap . opts_info_type : <EOL> xlw = XrayLibWrap ( Z , infotype ) <EOL> assert_not_equal ( xlw . all , None ) <EOL> for key in xlw : <EOL> assert_not_equal ( xlw [ key ] , None ) <EOL> assert_equal ( xlw . info_type , infotype ) <EOL> len ( xlw ) <EOL> def test_XrayLibWrap_Energy ( ) : <EOL> for Z in range ( <NUM_LIT:1> , <NUM_LIT> ) : <EOL> for infotype in XrayLibWrap_Energy . opts_info_type : <EOL> incident_energy = <NUM_LIT:10> <EOL> xlwe = XrayLibWrap_Energy ( element = Z , <EOL> info_type = infotype , <EOL> incident_energy = incident_energy ) <EOL> incident_energy *= <NUM_LIT:2> <EOL> xlwe . incident_energy = incident_energy <EOL> assert_equal ( xlwe . incident_energy , incident_energy ) <EOL> assert_equal ( xlwe . info_type , infotype ) <EOL> def smoke_test_element_creation ( ) : <EOL> prev_element = None <EOL> elements = [ elm for abbrev , elm in six . iteritems ( basic ) <EOL> if isinstance ( abbrev , int ) ] <EOL> elements . sort ( ) <EOL> for element in elements : <EOL> Z = element . Z <EOL> element . mass <EOL> element . density <EOL> sym = element . sym <EOL> inits = [ Z , sym , sym . upper ( ) , sym . lower ( ) , sym . swapcase ( ) ] <EOL> element = None <EOL> for init in inits : <EOL> element = XrfElement ( init ) <EOL> element . bind_energy <EOL> element . fluor_yield <EOL> element . jump_factor <EOL> element . emission_line . all <EOL> if prev_element is not None : <EOL> assert_equal ( prev_element . __lt__ ( element ) , True ) <EOL> assert_equal ( prev_element < element , True ) <EOL> assert_equal ( prev_element . __eq__ ( element ) , False ) <EOL> assert_equal ( prev_element == element , False ) <EOL> assert_equal ( prev_element >= element , False ) <EOL> assert_equal ( prev_element > element , False ) <EOL> assert_equal ( element < prev_element , False ) <EOL> assert_equal ( element . __lt__ ( prev_element ) , False ) <EOL> assert_equal ( element <= prev_element , False ) <EOL> assert_equal ( element . __eq__ ( prev_element ) , False ) <EOL> assert_equal ( element == prev_element , False ) <EOL> assert_equal ( element >= prev_element , True ) <EOL> assert_equal ( element > prev_element , True ) <EOL> prev_element = element <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import nose <EOL> nose . runmodule ( argv = [ '<STR_LIT>' , '<STR_LIT>' ] , exit = False ) </s>
