Changeset ed2276f in sasview for test/sasdataloader


Ignore:
Timestamp:
Apr 4, 2017 12:00:18 PM (7 years ago)
Author:
GitHub <noreply@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7b15990
Parents:
9a5097c (diff), 571bf4b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Andrew Jackson <andrew.jackson@…> (04/04/17 12:00:18)
git-committer:
GitHub <noreply@…> (04/04/17 12:00:18)
Message:

Merge branch 'master' into numpy_import

Location:
test/sasdataloader
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • test/sasdataloader/test/utest_abs_reader.py

    r9a5097c red2276f  
    44 
    55import unittest 
     6 
     7import math 
    68import numpy as np 
    7 from sas.sascalc.dataloader.loader import  Loader 
     9from sas.sascalc.dataloader.loader import Loader 
     10from sas.sascalc.dataloader.readers.IgorReader import Reader as IgorReader 
    811from sas.sascalc.dataloader.data_info import Data1D 
    912  
     
    8588     
    8689    def setUp(self): 
    87         self.data = Loader().load("MAR07232_rest.ASC") 
    88          
     90        # the IgorReader should be able to read this filetype 
     91        # if it can't, stop here. 
     92        reader = IgorReader() 
     93        self.data = reader.read("MAR07232_rest.ASC") 
     94 
    8995    def test_igor_checkdata(self): 
    9096        """ 
     
    107113         
    108114        self.assertEqual(self.data.detector[0].beam_center_unit, 'mm') 
    109         center_x = (68.76-1)*5.0 
    110         center_y = (62.47-1)*5.0 
     115        center_x = (68.76 - 1)*5.0 
     116        center_y = (62.47 - 1)*5.0 
    111117        self.assertEqual(self.data.detector[0].beam_center.x, center_x) 
    112118        self.assertEqual(self.data.detector[0].beam_center.y, center_y) 
    113119         
    114120        self.assertEqual(self.data.I_unit, '1/cm') 
    115         self.assertEqual(self.data.data[0], 0.279783) 
    116         self.assertEqual(self.data.data[1], 0.28951) 
    117         self.assertEqual(self.data.data[2], 0.167634) 
    118          
     121        # 3 points should be suffcient to check that the data is in column 
     122        # major order. 
     123        np.testing.assert_almost_equal(self.data.data[0:3], 
     124                                       [0.279783, 0.28951, 0.167634]) 
     125        np.testing.assert_almost_equal(self.data.qx_data[0:3], 
     126                                       [-0.01849072, -0.01821785, -0.01794498]) 
     127        np.testing.assert_almost_equal(self.data.qy_data[0:3], 
     128                                       [-0.01677435, -0.01677435, -0.01677435]) 
     129 
     130    def test_generic_loader(self): 
     131        # the generic loader should direct the file to IgorReader as well 
     132        data = Loader().load("MAR07232_rest.ASC") 
     133        self.assertEqual(data.meta_data['loader'], "IGOR 2D") 
     134 
     135 
    119136class danse_reader(unittest.TestCase): 
    120137     
  • test/sasdataloader/plugins/test_reader.py

    rb699768 r9a5097c  
    88copyright 2008, University of Tennessee 
    99""" 
    10 import numpy, os 
     10import os 
     11import numpy as np 
    1112from sas.sascalc.dataloader.data_info import Data1D 
    1213 
     
    4041                buff = input_f.read() 
    4142                lines = buff.split('\n') 
    42                 x  = numpy.zeros(0) 
    43                 y  = numpy.zeros(0) 
    44                 dy = numpy.zeros(0) 
     43                x  = np.zeros(0) 
     44                y  = np.zeros(0) 
     45                dy = np.zeros(0) 
    4546                output = Data1D(x, y, dy=dy) 
    4647                self.filename = output.filename = basename 
    4748            
    4849                for line in lines: 
    49                     x  = numpy.append(x,  float(line))  
     50                    x  = np.append(x,  float(line)) 
    5051                     
    5152                output.x = x 
  • test/sasdataloader/test/utest_averaging.py

    rb699768 r9a5097c  
    11 
    22import unittest 
     3import math 
    34 
    45from sas.sascalc.dataloader.loader import  Loader 
    56from sas.sascalc.dataloader.manipulations import Ring, CircularAverage, SectorPhi, get_q,reader2D_converter 
    6   
    7 import os.path 
    8 import numpy, math 
     7 
     8import numpy as np 
    99import sas.sascalc.dataloader.data_info as data_info 
    1010 
     
    1818            should return the predefined height of the distribution (1.0). 
    1919        """ 
    20         x_0  = numpy.ones([100,100]) 
    21         dx_0 = numpy.ones([100,100]) 
     20        x_0  = np.ones([100,100]) 
     21        dx_0 = np.ones([100,100]) 
    2222         
    2323        self.data = data_info.Data2D(data=x_0, err_data=dx_0) 
     
    4242         
    4343        self.qstep = len(x_0) 
    44         x=  numpy.linspace(start= -1*self.qmax, 
     44        x=  np.linspace(start= -1*self.qmax, 
    4545                               stop= self.qmax, 
    4646                               num= self.qstep, 
    4747                               endpoint=True )   
    48         y = numpy.linspace(start= -1*self.qmax, 
     48        y = np.linspace(start= -1*self.qmax, 
    4949                               stop= self.qmax, 
    5050                               num= self.qstep, 
  • test/sasdataloader/test/utest_cansas.py

    r1686a333 r9a5097c  
    1515import pylint as pylint 
    1616import unittest 
    17 import numpy 
     17import numpy as np 
    1818import logging 
    1919import warnings 
Note: See TracChangeset for help on using the changeset viewer.