Changeset 571bf4b in sasview for test/sasdataloader


Ignore:
Timestamp:
Apr 4, 2017 11:42:02 AM (8 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:
b2b3009d, 7b15990
Parents:
a8d79fd (diff), 05d167e (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 11:42:02)
git-committer:
GitHub <noreply@…> (04/04/17 11:42:02)
Message:

Merge pull request #41 from SasView?/update-mac-build-instructions

Add OSX Build Instructions

File:
1 edited

Legend:

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

    r5f26aa4 r36d69e1  
    44 
    55import unittest 
    6 import numpy, math 
    7 from sas.sascalc.dataloader.loader import  Loader 
     6import math 
     7import numpy as np 
     8from sas.sascalc.dataloader.loader import Loader 
     9from sas.sascalc.dataloader.readers.IgorReader import Reader as IgorReader 
    810from sas.sascalc.dataloader.data_info import Data1D 
    911  
     
    8688     
    8789    def setUp(self): 
    88         self.data = Loader().load("MAR07232_rest.ASC") 
    89          
     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 
    9095    def test_igor_checkdata(self): 
    9196        """ 
     
    108113         
    109114        self.assertEqual(self.data.detector[0].beam_center_unit, 'mm') 
    110         center_x = (68.76-1)*5.0 
    111         center_y = (62.47-1)*5.0 
     115        center_x = (68.76 - 1)*5.0 
     116        center_y = (62.47 - 1)*5.0 
    112117        self.assertEqual(self.data.detector[0].beam_center.x, center_x) 
    113118        self.assertEqual(self.data.detector[0].beam_center.y, center_y) 
    114119         
    115120        self.assertEqual(self.data.I_unit, '1/cm') 
    116         self.assertEqual(self.data.data[0], 0.279783) 
    117         self.assertEqual(self.data.data[1], 0.28951) 
    118         self.assertEqual(self.data.data[2], 0.167634) 
    119          
     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 
    120136class danse_reader(unittest.TestCase): 
    121137     
     
    313329        from sas.sascalc.dataloader.readers.cansas_reader import Reader 
    314330        r = Reader() 
    315         x = numpy.ones(5) 
    316         y = numpy.ones(5) 
    317         dy = numpy.ones(5) 
     331        x = np.ones(5) 
     332        y = np.ones(5) 
     333        dy = np.ones(5) 
    318334         
    319335        filename = "write_test.xml" 
Note: See TracChangeset for help on using the changeset viewer.