Changeset f926abb in sasview


Ignore:
Timestamp:
Nov 7, 2017 1:21:18 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7e82256
Parents:
54b0650
Message:

add smoke test for generic scattering calculator

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/calculator/sas_gen.py

    r54b0650 rf926abb  
    10571057    reader = SLDReader() 
    10581058    oreader = OMFReader() 
    1059     output = decode(reader.read(tfpath)) 
    1060     ooutput = decode(oreader.read(ofpath)) 
     1059    output = reader.read(tfpath) 
     1060    ooutput = oreader.read(ofpath) 
    10611061    foutput = OMF2SLD() 
    10621062    foutput.set_data(ooutput) 
     
    10871087    plt.show() 
    10881088 
    1089 def test(): 
    1090     """ 
    1091         Test code 
    1092     """ 
     1089def test_save(): 
    10931090    ofpath = _get_data_path("coordinate_data", "A_Raw_Example-1.omf") 
    10941091    if not os.path.isfile(ofpath): 
    10951092        raise ValueError("file(s) not found: %r"%(ofpath,)) 
    10961093    oreader = OMFReader() 
    1097     ooutput = decode(oreader.read(ofpath)) 
    1098     foutput = OMF2SLD() 
    1099     foutput.set_data(ooutput) 
     1094    omfdata = oreader.read(ofpath) 
     1095    omf2sld = OMF2SLD() 
     1096    omf2sld.set_data(omfdata) 
    11001097    writer = SLDReader() 
    1101     writer.write("out.txt", foutput.output) 
     1098    writer.write("out.txt", omf2sld.output) 
     1099 
     1100def test(): 
     1101    """ 
     1102        Test code 
     1103    """ 
     1104    ofpath = _get_data_path("coordinate_data", "A_Raw_Example-1.omf") 
     1105    if not os.path.isfile(ofpath): 
     1106        raise ValueError("file(s) not found: %r"%(ofpath,)) 
     1107    oreader = OMFReader() 
     1108    omfdata = oreader.read(ofpath) 
     1109    omf2sld = OMF2SLD() 
     1110    omf2sld.set_data(omfdata) 
    11021111    model = GenSAS() 
    1103     model.set_sld_data(foutput.output) 
    1104     x = np.arange(1000)/10000. + 1e-5 
    1105     y = np.arange(1000)/10000. + 1e-5 
    1106     i = np.zeros(1000) 
    1107     model.runXY([x, y, i]) 
     1112    model.set_sld_data(omf2sld.output) 
     1113    x = np.linspace(0, 0.1, 11)[1:] 
     1114    model.runXY([x, x]) 
    11081115 
    11091116if __name__ == "__main__": 
    11101117    #test_load() 
     1118    #test_save() 
    11111119    test() 
  • test/sascalculator/test/utest_sas_gen.py

    r1d014cb rf926abb  
    66 
    77import unittest 
     8import numpy as np 
     9 
    810from sas.sascalc.calculator import sas_gen 
    911 
     
    4850        self.assertEqual(output.pos_z[0], 0.0) 
    4951 
     52    def test_calculator(self): 
     53        """ 
     54        Test that the calculator calculates. 
     55        """ 
     56        f = self.omfloader.read("A_Raw_Example-1.omf") 
     57        omf2sld = sas_gen.OMF2SLD() 
     58        omf2sld.set_data(f) 
     59        model = sas_gen.GenSAS() 
     60        model.set_sld_data(omf2sld.output) 
     61        x = np.linspace(0, 0.1, 11)[1:] 
     62        model.runXY([x, x]) 
     63 
    5064 
    5165if __name__ == '__main__': 
Note: See TracChangeset for help on using the changeset viewer.