Changeset 879a0d8 in sasview


Ignore:
Timestamp:
Dec 6, 2017 9:11:06 AM (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:
b6b81a3
Parents:
df59f92 (diff), 5bb05a4 (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.
Message:

Merge branch 'master' into ticket-873

Files:
8 added
13 deleted
75 edited
2 moved

Legend:

Unmodified
Added
Removed
  • docs/sphinx-docs/source/_extensions/dollarmath.py

    reddf6af5 r2a2fb09  
    1111 
    1212import re 
    13 _dollar = re.compile(r"(?:^|(?<=\s))[$]([^\n]*?)(?<![\\])[$](?:$|(?=\s|[.,;:?\\()]))") 
     13_dollar = re.compile(r"(?:^|(?<=\s|[-(]))[$]([^\n]*?)(?<![\\])[$](?:$|(?=\s|[-.,;:?\\)]))") 
    1414_notdollar = re.compile(r"\\[$]") 
    1515 
  • docs/sphinx-docs/source/conf.py

    rf80b416e r3ca67dcf  
    7878# 
    7979# The short X.Y version. 
    80 version = '4.1' 
     80version = '4.2' 
    8181# The full version, including alpha/beta/rc tags. 
    82 release = '4.1.2' 
     82release = '4.2.0' 
    8383 
    8484# The language for content autogenerated by Sphinx. Refer to documentation 
  • run.py

    r0225a3f rbc8b8a1  
    112112 
    113113    # Build project if the build directory does not already exist. 
    114     if not os.path.exists(build_path): 
     114    # PAK: with "update" we can always build since it is fast 
     115    if True or not os.path.exists(build_path): 
    115116        import subprocess 
     117        build_cmd = [sys.executable, "setup.py", "build", "update"] 
     118        if os.name == 'nt': 
     119            build_cmd.append('--compiler=tinycc') 
     120        # need shell=True on windows to keep console box from popping up 
     121        shell = (os.name == 'nt') 
    116122        with cd(root): 
    117             subprocess.call((sys.executable, "setup.py", "build"), shell=False) 
     123            subprocess.call(build_cmd, shell=shell) 
    118124 
    119125    # Put the source trees on the path 
  • setup.py

    r36ca21e r1a3602d  
    1717import numpy as np 
    1818from setuptools import Extension, setup 
     19 
     20try: 
     21    import tinycc.distutils 
     22except ImportError: 
     23    pass 
    1924 
    2025# Manage version number ###################################### 
     
    138143        c = self.compiler.compiler_type 
    139144        print("Compiling with %s (64bit=%s)" % (c, str(is_64bits))) 
     145        #print("=== compiler attributes ===") 
     146        #print("\n".join("%s: %s"%(k, v) for k, v in sorted(self.compiler.__dict__.items()))) 
     147        #print("=== build_ext attributes ===") 
     148        #print("\n".join("%s: %s"%(k, v) for k, v in self.__dict__.items())) 
     149        #sys.exit(1) 
    140150 
    141151        # OpenMP build options 
     
    242252ext_modules.append(Extension("sas.sascalc.calculator.core.sld2i", 
    243253                             sources=[ 
    244                                  os.path.join(gen_dir, "sld2i_module.cpp"), 
    245                                  os.path.join(gen_dir, "sld2i.cpp"), 
     254                                 os.path.join(gen_dir, "sld2i_module.c"), 
     255                                 os.path.join(gen_dir, "sld2i.c"), 
    246256                                 os.path.join(gen_dir, "libfunc.c"), 
    247257                                 os.path.join(gen_dir, "librefl.c"), 
     
    428438    entry_points={ 
    429439        'console_scripts': [ 
    430             "sasview = sas.sasview.sasview:run", 
     440            "sasview = sas.sasview.sasview:run_gui", 
    431441        ] 
    432442    }, 
  • src/examples/test_panel2D.py

    r9a5097c r20fa5fe  
    205205            L=Loader() 
    206206             
    207             #Recieves data  
     207            #Receives data 
    208208            try: 
    209209                output=L.load(path) 
  • src/sas/sascalc/calculator/c_extensions/libfunc.c

    rb6c8abe r144e032a  
    9595// spintheta: angle (anti-clock-wise) between neutron spin(up) and x axis 
    9696// Note: all angles are in degrees. 
    97 polar_sld cal_msld(int isangle, double qx, double qy, double bn, 
     97void cal_msld(polar_sld *p_sld, int isangle, double qx, double qy, double bn, 
    9898                                double m01, double mtheta1, double mphi1, 
    9999                                double spinfraci, double spinfracf, double spintheta) 
     
    124124        double my = 0.0; 
    125125        double mz = 0.0; 
    126         polar_sld p_sld; 
    127         p_sld.uu = sld; 
    128         p_sld.dd = sld; 
    129         p_sld.re_ud = 0.0; 
    130         p_sld.im_ud = 0.0; 
    131         p_sld.re_du = 0.0; 
    132         p_sld.im_du = 0.0; 
     126        double uu = sld; 
     127        double dd = sld; 
     128        double re_ud = 0.0; 
     129        double im_ud = 0.0; 
     130        double re_du = 0.0; 
     131        double im_du = 0.0; 
    133132 
    134133        //No mag means no further calculation 
    135         if (isangle>0){ 
     134        if (isangle>0) { 
    136135                if (m_max < 1.0e-32){ 
    137                         p_sld.uu = sqrt(sqrt(in_spin * out_spin)) * p_sld.uu; 
    138                         p_sld.dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * p_sld.dd; 
    139                         return p_sld; 
    140                 } 
    141         } 
    142         else{ 
    143                 if (fabs(m_max)< 1.0e-32 && fabs(m_phi)< 1.0e-32 && fabs(m_theta)< 1.0e-32){ 
    144                         p_sld.uu = sqrt(sqrt(in_spin * out_spin)) * p_sld.uu; 
    145                         p_sld.dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * p_sld.dd; 
    146                         return p_sld; 
    147                 } 
    148         } 
    149  
    150         //These are needed because of the precision of inputs 
    151         if (in_spin < 0.0) in_spin = 0.0; 
    152         if (in_spin > 1.0) in_spin = 1.0; 
    153         if (out_spin < 0.0) out_spin = 0.0; 
    154         if (out_spin > 1.0) out_spin = 1.0; 
    155  
    156         if (q_x == 0.0) q_angle = pi / 2.0; 
    157         else q_angle = atan(q_y/q_x); 
    158         if (q_y < 0.0 && q_x < 0.0) q_angle -= pi; 
    159         else if (q_y > 0.0 && q_x < 0.0) q_angle += pi; 
    160  
    161         q_angle = pi/2.0 - q_angle; 
    162         if (q_angle > pi) q_angle -= 2.0 * pi; 
    163         else if (q_angle < -pi) q_angle += 2.0 * pi; 
    164  
    165         if (fabs(q_x) < 1.0e-16 && fabs(q_y) < 1.0e-16){ 
    166                 m_perp = 0.0; 
    167                 } 
    168         else { 
    169                 m_perp = m_max; 
    170                 } 
    171         if (is_angle > 0){ 
    172                 m_phi *= pi/180.0; 
    173                 m_theta *= pi/180.0; 
    174                 mx = m_perp * cos(m_theta) * cos(m_phi); 
    175                 my = m_perp * sin(m_theta); 
    176                 mz = -(m_perp * cos(m_theta) * sin(m_phi)); 
    177         } 
    178         else{ 
    179                 mx = m_perp; 
    180                 my = m_phi; 
    181                 mz = m_theta; 
    182         } 
    183         //ToDo: simplify these steps 
    184         // m_perp1 -m_perp2 
    185         m_perp_x = (mx) *  cos(q_angle); 
    186         m_perp_x -= (my) * sin(q_angle); 
    187         m_perp_y = m_perp_x; 
    188         m_perp_x *= cos(-q_angle); 
    189         m_perp_y *= sin(-q_angle); 
    190         m_perp_z = mz; 
    191  
    192         m_sigma_x = (m_perp_x * cos(-s_theta) - m_perp_y * sin(-s_theta)); 
    193         m_sigma_y = (m_perp_x * sin(-s_theta) + m_perp_y * cos(-s_theta)); 
    194         m_sigma_z = (m_perp_z); 
    195  
    196         //Find b 
    197         p_sld.uu -= m_sigma_x; 
    198         p_sld.dd += m_sigma_x; 
    199         p_sld.re_ud = m_sigma_y; 
    200         p_sld.re_du = m_sigma_y; 
    201         p_sld.im_ud = m_sigma_z; 
    202         p_sld.im_du = -m_sigma_z; 
    203  
    204         p_sld.uu = sqrt(sqrt(in_spin * out_spin)) * p_sld.uu; 
    205         p_sld.dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * p_sld.dd; 
    206  
    207         p_sld.re_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * p_sld.re_ud; 
    208         p_sld.im_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * p_sld.im_ud; 
    209         p_sld.re_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * p_sld.re_du; 
    210         p_sld.im_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * p_sld.im_du; 
    211  
    212         return p_sld; 
     136                        uu = sqrt(sqrt(in_spin * out_spin)) * uu; 
     137                        dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * dd; 
     138                } 
     139        } 
     140        else if (fabs(m_max)< 1.0e-32 && fabs(m_phi)< 1.0e-32 && fabs(m_theta)< 1.0e-32){ 
     141                        uu = sqrt(sqrt(in_spin * out_spin)) * uu; 
     142                        dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * dd; 
     143        } else { 
     144 
     145                //These are needed because of the precision of inputs 
     146                if (in_spin < 0.0) in_spin = 0.0; 
     147                if (in_spin > 1.0) in_spin = 1.0; 
     148                if (out_spin < 0.0) out_spin = 0.0; 
     149                if (out_spin > 1.0) out_spin = 1.0; 
     150 
     151                if (q_x == 0.0) q_angle = pi / 2.0; 
     152                else q_angle = atan(q_y/q_x); 
     153                if (q_y < 0.0 && q_x < 0.0) q_angle -= pi; 
     154                else if (q_y > 0.0 && q_x < 0.0) q_angle += pi; 
     155 
     156                q_angle = pi/2.0 - q_angle; 
     157                if (q_angle > pi) q_angle -= 2.0 * pi; 
     158                else if (q_angle < -pi) q_angle += 2.0 * pi; 
     159 
     160                if (fabs(q_x) < 1.0e-16 && fabs(q_y) < 1.0e-16){ 
     161                        m_perp = 0.0; 
     162                        } 
     163                else { 
     164                        m_perp = m_max; 
     165                        } 
     166                if (is_angle > 0){ 
     167                        m_phi *= pi/180.0; 
     168                        m_theta *= pi/180.0; 
     169                        mx = m_perp * cos(m_theta) * cos(m_phi); 
     170                        my = m_perp * sin(m_theta); 
     171                        mz = -(m_perp * cos(m_theta) * sin(m_phi)); 
     172                } 
     173                else{ 
     174                        mx = m_perp; 
     175                        my = m_phi; 
     176                        mz = m_theta; 
     177                } 
     178                //ToDo: simplify these steps 
     179                // m_perp1 -m_perp2 
     180                m_perp_x = (mx) *  cos(q_angle); 
     181                m_perp_x -= (my) * sin(q_angle); 
     182                m_perp_y = m_perp_x; 
     183                m_perp_x *= cos(-q_angle); 
     184                m_perp_y *= sin(-q_angle); 
     185                m_perp_z = mz; 
     186 
     187                m_sigma_x = (m_perp_x * cos(-s_theta) - m_perp_y * sin(-s_theta)); 
     188                m_sigma_y = (m_perp_x * sin(-s_theta) + m_perp_y * cos(-s_theta)); 
     189                m_sigma_z = (m_perp_z); 
     190 
     191                //Find b 
     192                uu -= m_sigma_x; 
     193                dd += m_sigma_x; 
     194                re_ud = m_sigma_y; 
     195                re_du = m_sigma_y; 
     196                im_ud = m_sigma_z; 
     197                im_du = -m_sigma_z; 
     198 
     199                uu = sqrt(sqrt(in_spin * out_spin)) * uu; 
     200                dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * dd; 
     201 
     202                re_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * re_ud; 
     203                im_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * im_ud; 
     204                re_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * re_du; 
     205                im_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * im_du; 
     206        } 
     207        p_sld->uu = uu; 
     208        p_sld->dd = dd; 
     209        p_sld->re_ud = re_ud; 
     210        p_sld->im_ud = im_ud; 
     211        p_sld->re_du = re_du; 
     212        p_sld->im_du = im_du; 
    213213} 
    214214 
  • src/sas/sascalc/calculator/c_extensions/libfunc.h

    rb6c8abe r144e032a  
    1818//double gamln(double x); 
    1919 
    20 polar_sld cal_msld(int isangle, double qx, double qy, double bn, double m01, double mtheta1,  
     20void cal_msld(polar_sld*, int isangle, double qx, double qy, double bn, double m01, double mtheta1,  
    2121                        double mphi1, double spinfraci, double spinfracf, double spintheta); 
    2222 
  • src/sas/sascalc/calculator/c_extensions/librefl.c

    r4c29e4d r144e032a  
    77#include <stdio.h> 
    88#include <stdlib.h> 
    9 #if defined(_MSC_VER) 
     9#if defined _MSC_VER  || defined __TINYCC__ 
    1010#define NEED_ERF 
    1111#endif 
     
    2121 
    2222 
    23 #ifdef _WIN32 
     23#ifdef __TINYCC__ 
     24# ifdef isnan 
     25#   undef isnan 
     26# endif 
     27# ifdef isfinite 
     28#   undef isfinite 
     29# endif 
     30# define isnan(x) (x != x) 
     31# define isfinite(x) (x != INFINITY && x != -INFINITY) 
     32#elif defined _WIN32 
    2433# include <float.h> 
    2534# if !defined __MINGW32__ || defined __NO_ISOCEXT 
     
    3039#   define isinf(x) (!_finite(x) && !_isnan(x)) 
    3140#  endif 
    32 #  ifndef finite 
    33 #   define finite(x) _finite(x) 
     41#  ifndef isfinite 
     42#   define isfinite(x) _finite(x) 
    3443#  endif 
    3544# endif 
     
    8493double erf(double x) 
    8594{ 
    86     if (!finite(x)) { 
     95    if (!isfinite(x)) { 
    8796        if (isnan(x)) return x;      /* erf(NaN)   = NaN   */ 
    8897        return (x>0 ? 1.0 : -1.0);   /* erf(+-inf) = +-1.0 */ 
     
    94103double erfc(double x) 
    95104{ 
    96     if (!finite(x)) { 
     105    if (!isfinite(x)) { 
    97106        if (isnan(x)) return x;      /* erfc(NaN)   = NaN      */ 
    98107        return (x>0 ? 0.0 : 2.0);    /* erfc(+-inf) = 0.0, 2.0 */ 
     
    103112#endif // NEED_ERF 
    104113 
    105 complex cassign(real, imag) 
    106         double real, imag; 
    107 { 
    108         complex x; 
    109         x.re = real; 
    110         x.im = imag; 
    111         return x; 
    112 } 
    113  
    114  
    115 complex cplx_add(x,y) 
    116         complex x,y; 
    117 { 
    118         complex z; 
    119         z.re = x.re + y.re; 
    120         z.im = x.im + y.im; 
    121         return z; 
    122 } 
    123  
    124 complex rcmult(x,y) 
    125         double x; 
    126     complex y; 
    127 { 
    128         complex z; 
    129         z.re = x*y.re; 
    130         z.im = x*y.im; 
    131         return z; 
    132 } 
    133  
    134 complex cplx_sub(x,y) 
    135         complex x,y; 
    136 { 
    137         complex z; 
    138         z.re = x.re - y.re; 
    139         z.im = x.im - y.im; 
    140         return z; 
    141 } 
    142  
    143  
    144 complex cplx_mult(x,y) 
    145         complex x,y; 
    146 { 
    147         complex z; 
    148         z.re = x.re*y.re - x.im*y.im; 
    149         z.im = x.re*y.im + x.im*y.re; 
    150         return z; 
    151 } 
    152  
    153 complex cplx_div(x,y) 
    154         complex x,y; 
    155 { 
    156         complex z; 
    157         z.re = (x.re*y.re + x.im*y.im)/(y.re*y.re + y.im*y.im); 
    158         z.im = (x.im*y.re - x.re*y.im)/(y.re*y.re + y.im*y.im); 
    159         return z; 
    160 } 
    161  
    162 complex cplx_exp(b) 
    163         complex b; 
    164 { 
    165         complex z; 
     114void cassign(Cplx *x, double real, double imag) 
     115{ 
     116        x->re = real; 
     117        x->im = imag; 
     118} 
     119 
     120 
     121void cplx_add(Cplx *z, Cplx x, Cplx y) 
     122{ 
     123        z->re = x.re + y.re; 
     124        z->im = x.im + y.im; 
     125} 
     126 
     127void rcmult(Cplx *z, double x, Cplx y) 
     128{ 
     129        z->re = x*y.re; 
     130        z->im = x*y.im; 
     131} 
     132 
     133void cplx_sub(Cplx *z, Cplx x, Cplx y) 
     134{ 
     135        z->re = x.re - y.re; 
     136        z->im = x.im - y.im; 
     137} 
     138 
     139 
     140void cplx_mult(Cplx *z, Cplx x, Cplx y) 
     141{ 
     142        z->re = x.re*y.re - x.im*y.im; 
     143        z->im = x.re*y.im + x.im*y.re; 
     144} 
     145 
     146void cplx_div(Cplx *z, Cplx x, Cplx y) 
     147{ 
     148        z->re = (x.re*y.re + x.im*y.im)/(y.re*y.re + y.im*y.im); 
     149        z->im = (x.im*y.re - x.re*y.im)/(y.re*y.re + y.im*y.im); 
     150} 
     151 
     152void cplx_exp(Cplx *z, Cplx b) 
     153{ 
    166154        double br,bi; 
    167155        br=b.re; 
    168156        bi=b.im; 
    169         z.re = exp(br)*cos(bi); 
    170         z.im = exp(br)*sin(bi); 
    171         return z; 
    172 } 
    173  
    174  
    175 complex cplx_sqrt(z)    //see Schaum`s Math Handbook p. 22, 6.6 and 6.10 
    176         complex z; 
    177 { 
    178         complex c; 
     157        z->re = exp(br)*cos(bi); 
     158        z->im = exp(br)*sin(bi); 
     159} 
     160 
     161 
     162void cplx_sqrt(Cplx *c, Cplx z)    //see Schaum`s Math Handbook p. 22, 6.6 and 6.10 
     163{ 
    179164        double zr,zi,x,y,r,w; 
    180165 
     
    184169        if (zr==0.0 && zi==0.0) 
    185170        { 
    186     c.re=0.0; 
    187         c.im=0.0; 
    188     return c; 
    189         } 
    190         else 
    191         { 
     171                c->re=0.0; 
     172                c->im=0.0; 
     173        } else { 
    192174                x=fabs(zr); 
    193175                y=fabs(zi); 
     
    196178                        r=y/x; 
    197179                        w=sqrt(x)*sqrt(0.5*(1.0+sqrt(1.0+r*r))); 
    198                 } 
    199                 else 
    200                 { 
     180                } else { 
    201181                        r=x/y; 
    202182                        w=sqrt(y)*sqrt(0.5*(r+sqrt(1.0+r*r))); 
     
    204184                if (zr >=0.0) 
    205185                { 
    206                         c.re=w; 
    207                         c.im=zi/(2.0*w); 
     186                        c->re=w; 
     187                        c->im=zi/(2.0*w); 
     188                } else { 
     189                        c->im=(zi >= 0) ? w : -w; 
     190                        c->re=zi/(2.0*c->im); 
    208191                } 
    209                 else 
    210                 { 
    211                         c.im=(zi >= 0) ? w : -w; 
    212                         c.re=zi/(2.0*c.im); 
    213                 } 
    214                 return c; 
    215         } 
    216 } 
    217  
    218 complex cplx_cos(b) 
    219         complex b; 
    220 { 
    221         complex zero,two,z,i,bi,negbi; 
    222         zero = cassign(0.0,0.0); 
    223         two = cassign(2.0,0.0); 
    224         i = cassign(0.0,1.0); 
    225         bi = cplx_mult(b,i); 
    226         negbi = cplx_sub(zero,bi); 
    227         z = cplx_div(cplx_add(cplx_exp(bi),cplx_exp(negbi)),two); 
    228         return z; 
     192        } 
     193} 
     194 
     195void cplx_cos(Cplx *z, Cplx b) 
     196{ 
     197        // cos(b) = (e^bi + e^-bi)/2 
     198        //        = (e^b.im e^-i bi.re) + e^-b.im e^i b.re)/2 
     199        //        = (e^b.im cos(-b.re) + e^b.im sin(-b.re) i)/2 + (e^-b.im cos(b.re) + e^-b.im sin(b.re) i)/2 
     200        //        = e^b.im cos(b.re)/2 - e^b.im sin(b.re)/2 i + 1/e^b.im cos(b.re)/2 + 1/e^b.im sin(b.re)/2 i 
     201        //        = (e^b.im + 1/e^b.im)/2 cos(b.re) + (-e^b.im + 1/e^b.im)/2 sin(b.re) i 
     202        //        = cosh(b.im) cos(b.re) - sinh(b.im) sin(b.re) i 
     203        double exp_b_im = exp(b.im); 
     204        z->re = 0.5*(+exp_b_im + 1.0/exp_b_im) * cos(b.re); 
     205        z->im = -0.5*(exp_b_im - 1.0/exp_b_im) * sin(b.re); 
    229206} 
    230207 
  • src/sas/sascalc/calculator/c_extensions/librefl.h

    r9e531f2 r144e032a  
    55        double re; 
    66        double im; 
    7 } complex; 
     7} Cplx; 
    88 
    99typedef struct { 
    10         complex a; 
    11         complex b; 
    12         complex c; 
    13         complex d; 
     10        Cplx a; 
     11        Cplx b; 
     12        Cplx c; 
     13        Cplx d; 
    1414} matrix; 
    1515 
    16 complex cassign(double real, double imag); 
     16void cassign(Cplx*, double real, double imag); 
    1717 
    18 complex cplx_add(complex x,complex y); 
     18void cplx_add(Cplx*, Cplx x,Cplx y); 
    1919 
    20 complex rcmult(double x,complex y); 
     20void rcmult(Cplx*, double x,Cplx y); 
    2121 
    22 complex cplx_sub(complex x,complex y); 
     22void cplx_sub(Cplx*, Cplx x,Cplx y); 
    2323 
    24 complex cplx_mult(complex x,complex y); 
     24void cplx_mult(Cplx*, Cplx x,Cplx y); 
    2525 
    26 complex cplx_div(complex x,complex y); 
     26void cplx_div(Cplx*, Cplx x,Cplx y); 
    2727 
    28 complex cplx_exp(complex b); 
     28void cplx_exp(Cplx*, Cplx b); 
    2929 
    30 complex cplx_sqrt(complex z); 
     30void cplx_sqrt(Cplx*, Cplx z); 
    3131 
    32 complex cplx_cos(complex b); 
     32void cplx_cos(Cplx*, Cplx b); 
    3333 
    3434double intersldfunc(int fun_type, double n_sub, double i, double nu, double sld_l, double sld_r); 
  • src/sas/sascalc/calculator/c_extensions/sld2i.c

    rb523c0e r144e032a  
    22Computes the (magnetic) scattering form sld (n and m) profile 
    33 */ 
    4 #include "sld2i.hh" 
    54#include <stdio.h> 
    65#include <math.h> 
    7 using namespace std; 
    8 extern "C" { 
    9         #include "libfunc.h" 
    10         #include "librefl.h" 
    11 } 
     6#include "sld2i.h" 
     7#include "libfunc.h" 
     8#include "librefl.h" 
    129/** 
    1310 * Constructor for GenI 
     
    2825 * @param s_theta: angle (from x-axis) of the up spin in degree 
    2926 */ 
    30 GenI :: GenI(int npix, double* x, double* y, double* z, double* sldn, 
     27void initGenI(GenI* this, int is_avg, int npix, double* x, double* y, double* z, double* sldn, 
    3128                        double* mx, double* my, double* mz, double* voli, 
    3229                        double in_spin, double out_spin, 
    3330                        double s_theta) { 
    34         //this->qx_val = qx; 
    35         //this->qy_val = qy; 
    36         //this->qz_val = qz; 
     31        this->is_avg = is_avg; 
    3732        this->n_pix = npix; 
    3833        this->x_val = x; 
     
    4742        this->outspin = out_spin; 
    4843        this->stheta = s_theta; 
    49 }; 
     44} 
    5045 
    5146/** 
    5247 * Compute 2D anisotropic 
    5348 */ 
    54 void GenI :: genicomXY(int npoints, double *qx, double *qy, double *I_out){ 
    55         //npoints is given negative for angular averaging  
     49void genicomXY(GenI* this, int npoints, double *qx, double *qy, double *I_out){ 
     50        //npoints is given negative for angular averaging 
    5651        // Assumes that q doesn't have qz component and sld_n is all real 
    5752        //double q = 0.0; 
     
    5954        polar_sld b_sld; 
    6055        double qr = 0.0; 
    61         complex iqr = cassign(0.0, 0.0); 
    62         complex ephase = cassign(0.0, 0.0); 
    63         complex comp_sld = cassign(0.0, 0.0); 
    64  
    65         complex sumj_uu; 
    66         complex sumj_ud; 
    67         complex sumj_du; 
    68         complex sumj_dd; 
    69         complex temp_fi; 
     56        Cplx iqr; 
     57        Cplx ephase; 
     58        Cplx comp_sld; 
     59 
     60        Cplx sumj_uu; 
     61        Cplx sumj_ud; 
     62        Cplx sumj_du; 
     63        Cplx sumj_dd; 
     64        Cplx temp_fi; 
    7065 
    7166        double count = 0.0; 
    72         //check if this computation is for averaging 
     67        int i, j; 
     68 
     69        cassign(&iqr, 0.0, 0.0); 
     70        cassign(&ephase, 0.0, 0.0); 
     71        cassign(&comp_sld, 0.0, 0.0); 
    7372 
    7473        //Assume that pixel volumes are given in vol_pix in A^3 unit 
     
    7675        //int y_size = 0; //in Ang 
    7776        //int z_size = 0; //in Ang 
    78          
     77 
    7978        // Loop over q-values and multiply apply matrix 
    80          
    81         for(int i=0; i<npoints; i++){ 
     79 
     80        //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 
     81        for(i=0; i<npoints; i++){ 
    8282                //I_out[i] = 0.0; 
    83                 sumj_uu = cassign(0.0, 0.0); 
    84                 sumj_ud = cassign(0.0, 0.0); 
    85                 sumj_du = cassign(0.0, 0.0); 
    86                 sumj_dd = cassign(0.0, 0.0);             
    87                 //printf ("%d ", i); 
     83                cassign(&sumj_uu, 0.0, 0.0); 
     84                cassign(&sumj_ud, 0.0, 0.0); 
     85                cassign(&sumj_du, 0.0, 0.0); 
     86                cassign(&sumj_dd, 0.0, 0.0); 
     87                //printf("i: %d\n", i); 
    8888                //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 
    8989 
    90                 for(int j=0; j<n_pix; j++){ 
    91                         if (sldn_val[j]!=0.0||mx_val[j]!=0.0||my_val[j]!=0.0||mz_val[j]!=0.0) 
    92                         {        
     90                for(j=0; j<this->n_pix; j++){ 
     91                        if (this->sldn_val[j]!=0.0 
     92                                ||this->mx_val[j]!=0.0 
     93                                ||this->my_val[j]!=0.0 
     94                                ||this->mz_val[j]!=0.0) 
     95                        { 
     96                            // printf("i,j: %d,%d\n", i,j); 
    9397                                //anisotropic 
    94                                 temp_fi = cassign(0.0, 0.0); 
    95                                 b_sld = cal_msld(0, qx[i], qy[i], sldn_val[j], 
    96                                                          mx_val[j], my_val[j], mz_val[j], 
    97                                                          inspin, outspin, stheta); 
    98                                 qr = (qx[i]*x_val[j] + qy[i]*y_val[j]); 
    99                                 iqr = cassign(0.0, qr); 
    100                                 ephase = cplx_exp(iqr); 
    101                                  
     98                                cassign(&temp_fi, 0.0, 0.0); 
     99                                cal_msld(&b_sld, 0, qx[i], qy[i], this->sldn_val[j], 
     100                                                         this->mx_val[j], this->my_val[j], this->mz_val[j], 
     101                                                         this->inspin, this->outspin, this->stheta); 
     102                                qr = (qx[i]*this->x_val[j] + qy[i]*this->y_val[j]); 
     103                                cassign(&iqr, 0.0, qr); 
     104                                cplx_exp(&ephase, iqr); 
     105 
    102106                                //Let's multiply pixel(atomic) volume here 
    103                                 ephase = rcmult(vol_pix[j], ephase); 
     107                                rcmult(&ephase, this->vol_pix[j], ephase); 
    104108                                //up_up 
    105                                 if (inspin > 0.0 && outspin > 0.0){ 
    106                                         comp_sld = cassign(b_sld.uu, 0.0); 
    107                                         temp_fi = cplx_mult(comp_sld, ephase); 
    108                                         sumj_uu = cplx_add(sumj_uu, temp_fi); 
     109                                if (this->inspin > 0.0 && this->outspin > 0.0){ 
     110                                        cassign(&comp_sld, b_sld.uu, 0.0); 
     111                                        cplx_mult(&temp_fi, comp_sld, ephase); 
     112                                        cplx_add(&sumj_uu, sumj_uu, temp_fi); 
    109113                                } 
    110114                                //down_down 
    111                                 if (inspin < 1.0 && outspin < 1.0){ 
    112                                         comp_sld = cassign(b_sld.dd, 0.0); 
    113                                         temp_fi = cplx_mult(comp_sld, ephase); 
    114                                         sumj_dd = cplx_add(sumj_dd, temp_fi); 
     115                                if (this->inspin < 1.0 && this->outspin < 1.0){ 
     116                                        cassign(&comp_sld, b_sld.dd, 0.0); 
     117                                        cplx_mult(&temp_fi, comp_sld, ephase); 
     118                                        cplx_add(&sumj_dd, sumj_dd, temp_fi); 
    115119                                } 
    116120                                //up_down 
    117                                 if (inspin > 0.0 && outspin < 1.0){ 
    118                                         comp_sld = cassign(b_sld.re_ud, b_sld.im_ud); 
    119                                         temp_fi = cplx_mult(comp_sld, ephase); 
    120                                         sumj_ud = cplx_add(sumj_ud, temp_fi); 
     121                                if (this->inspin > 0.0 && this->outspin < 1.0){ 
     122                                        cassign(&comp_sld, b_sld.re_ud, b_sld.im_ud); 
     123                                        cplx_mult(&temp_fi, comp_sld, ephase); 
     124                                        cplx_add(&sumj_ud, sumj_ud, temp_fi); 
    121125                                } 
    122126                                //down_up 
    123                                 if (inspin < 1.0 && outspin > 0.0){ 
    124                                         comp_sld = cassign(b_sld.re_du, b_sld.im_du); 
    125                                         temp_fi = cplx_mult(comp_sld, ephase); 
    126                                         sumj_du = cplx_add(sumj_du, temp_fi); 
    127                                 } 
    128  
     127                                if (this->inspin < 1.0 && this->outspin > 0.0){ 
     128                                        cassign(&comp_sld, b_sld.re_du, b_sld.im_du); 
     129                                        cplx_mult(&temp_fi, comp_sld, ephase); 
     130                                        cplx_add(&sumj_du, sumj_du, temp_fi); 
     131                                } 
    129132 
    130133                                if (i == 0){ 
    131                                         count += vol_pix[j]; 
     134                                        count += this->vol_pix[j]; 
    132135                                } 
    133136                        } 
     
    142145                I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 
    143146        } 
    144         //printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]); 
     147        //printf("count = %d %g %g %g %g\n", count, this->sldn_val[0],this->mx_val[0], this->my_val[0], this->mz_val[0]); 
    145148} 
    146149/** 
     
    149152 * Also assumes there is no polarization: No dependency on spin 
    150153 */ 
    151 void GenI :: genicom(int npoints, double *q, double *I_out){ 
    152         //npoints is given negative for angular averaging  
     154void genicom(GenI* this, int npoints, double *q, double *I_out){ 
     155        //npoints is given negative for angular averaging 
    153156        // Assumes that q doesn't have qz component and sld_n is all real 
    154157        //double Pi = 4.0*atan(1.0); 
    155         int is_sym = 0; 
    156158        double qr = 0.0; 
    157159        double sumj; 
    158160        double sld_j = 0.0; 
    159161        double count = 0.0; 
    160         if (n_pix < 0 ){ 
    161                 is_sym = 1; 
    162                 n_pix = n_pix * -1; 
    163         } 
     162        int i, j, k; 
     163 
    164164        //Assume that pixel volumes are given in vol_pix in A^3 unit 
    165165        // Loop over q-values and multiply apply matrix 
    166         for(int i=0; i<npoints; i++){ 
    167                 sumj =0.0;               
    168                 for(int j=0; j<n_pix; j++){ 
     166        for(i=0; i<npoints; i++){ 
     167                sumj =0.0; 
     168                for(j=0; j<this->n_pix; j++){ 
    169169                        //Isotropic: Assumes all slds are real (no magnetic) 
    170170                        //Also assumes there is no polarization: No dependency on spin 
    171                         if (is_sym == 1){ 
     171                        if (this->is_avg == 1){ 
    172172                                // approximation for a spherical symmetric particle 
    173                                 qr = sqrt(x_val[j]*x_val[j]+y_val[j]*y_val[j]+z_val[j]*z_val[j])*q[i]; 
     173                                qr = sqrt(this->x_val[j]*this->x_val[j]+this->y_val[j]*this->y_val[j]+this->z_val[j]*this->z_val[j])*q[i]; 
    174174                                if (qr > 0.0){ 
    175175                                        qr = sin(qr) / qr; 
    176                                         sumj += sldn_val[j] * vol_pix[j] * qr; 
     176                                        sumj += this->sldn_val[j] * this->vol_pix[j] * qr; 
    177177                                } 
    178178                                else{ 
    179                                         sumj += sldn_val[j] * vol_pix[j]; 
     179                                        sumj += this->sldn_val[j] * this->vol_pix[j]; 
    180180                                } 
    181181                        } 
     
    183183                                //full calculation 
    184184                                //pragma omp parallel for 
    185                                 for(int k=0; k<n_pix; k++){ 
    186                                         sld_j =  sldn_val[j] * sldn_val[k] * vol_pix[j] * vol_pix[k]; 
    187                                         qr = (x_val[j]-x_val[k])*(x_val[j]-x_val[k])+ 
    188                                                       (y_val[j]-y_val[k])*(y_val[j]-y_val[k])+  
    189                                                       (z_val[j]-z_val[k])*(z_val[j]-z_val[k]); 
     185                                for(k=0; k<this->n_pix; k++){ 
     186                                        sld_j =  this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 
     187                                        qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+ 
     188                                                      (this->y_val[j]-this->y_val[k])*(this->y_val[j]-this->y_val[k])+ 
     189                                                      (this->z_val[j]-this->z_val[k])*(this->z_val[j]-this->z_val[k]); 
    190190                                        qr = sqrt(qr) * q[i]; 
    191191                                        if (qr > 0.0){ 
     
    198198                        } 
    199199                        if (i == 0){ 
    200                                 count += vol_pix[j]; 
     200                                count += this->vol_pix[j]; 
    201201                        } 
    202202                } 
    203203                I_out[i] = sumj; 
    204                 if (is_sym == 1){ 
     204                if (this->is_avg == 1) { 
    205205                        I_out[i] *= sumj; 
    206206                } 
    207207                I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 
    208208        } 
    209         //printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]); 
     209        //printf("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]); 
    210210} 
  • src/sas/sascalc/calculator/c_extensions/sld2i_module.c

    r1d014cb ra1daf86  
    44#include <Python.h> 
    55#include <stdio.h> 
    6 #include <sld2i.hh> 
     6#include "sld2i.h" 
    77 
    88#if PY_MAJOR_VERSION < 3 
     
    3535void 
    3636del_sld2i(PyObject *obj){ 
    37         GenI* sld2i = static_cast<GenI *>(PyCapsule_GetPointer(obj, "GenI")); 
    38         delete sld2i; 
    39         return; 
     37#if PY_MAJOR_VERSION < 3 
     38        GenI* sld2i = (GenI *)obj; 
     39#else 
     40        GenI* sld2i = (GenI *)(PyCapsule_GetPointer(obj, "GenI")); 
     41#endif 
     42        PyMem_Free((void *)sld2i); 
    4043} 
    4144 
     
    4346 * Create a GenI as a python object by supplying arrays 
    4447 */ 
    45 PyObject * new_GenI(PyObject *, PyObject *args) { 
     48PyObject * new_GenI(PyObject *self, PyObject *args) { 
    4649        PyObject *x_val_obj; 
    4750        PyObject *y_val_obj; 
     
    5255        PyObject *mz_val_obj; 
    5356        PyObject *vol_pix_obj; 
    54         Py_ssize_t n_x; 
    55         //PyObject rlimit_obj; 
    56         //PyObject npoints_obj; 
    57         //PyObject nrbins_obj; 
    58         //PyObject nphibins_obj; 
    59         int n_pix; 
     57        Py_ssize_t n_x, n_y, n_z, n_sld, n_mx, n_my, n_mz, n_vol_pix; 
     58        int is_avg; 
    6059        double* x_val; 
    6160        double* y_val; 
     
    6968        double outspin; 
    7069        double stheta; 
    71  
    72         if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &n_pix, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL; 
    73         OUTVECTOR(x_val_obj, x_val, n_x); 
    74         OUTVECTOR(y_val_obj, y_val, n_x); 
    75         OUTVECTOR(z_val_obj, z_val, n_x); 
    76         OUTVECTOR(sldn_val_obj, sldn_val, n_x); 
    77         OUTVECTOR(mx_val_obj, mx_val, n_x); 
    78         OUTVECTOR(my_val_obj, my_val, n_x); 
    79         OUTVECTOR(mz_val_obj, mz_val, n_x); 
    80         OUTVECTOR(vol_pix_obj, vol_pix, n_x); 
    81         GenI* sld2i = new GenI(n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta); 
    82         return PyCapsule_New(sld2i, "GenI", del_sld2i); 
     70        PyObject *obj; 
     71        GenI* sld2i; 
     72 
     73        //printf("new GenI\n"); 
     74        if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &is_avg, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL; 
     75        INVECTOR(x_val_obj, x_val, n_x); 
     76        INVECTOR(y_val_obj, y_val, n_y); 
     77        INVECTOR(z_val_obj, z_val, n_z); 
     78        INVECTOR(sldn_val_obj, sldn_val, n_sld); 
     79        INVECTOR(mx_val_obj, mx_val, n_mx); 
     80        INVECTOR(my_val_obj, my_val, n_my); 
     81        INVECTOR(mz_val_obj, mz_val, n_mz); 
     82        INVECTOR(vol_pix_obj, vol_pix, n_vol_pix); 
     83        sld2i = PyMem_Malloc(sizeof(GenI)); 
     84        //printf("sldi:%p\n", sld2i); 
     85        if (sld2i != NULL) { 
     86                initGenI(sld2i,is_avg,(int)n_x,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta); 
     87        } 
     88        obj = PyCapsule_New(sld2i, "GenI", del_sld2i); 
     89        //printf("constructed %p\n", obj); 
     90        return obj; 
    8391} 
    8492 
     
    8694 * GenI the given input (2D) according to a given object 
    8795 */ 
    88 PyObject * genicom_inputXY(PyObject *, PyObject *args) { 
    89         int npoints; 
     96PyObject * genicom_inputXY(PyObject *self, PyObject *args) { 
     97        PyObject *gen_obj; 
    9098        PyObject *qx_obj; 
     99        PyObject *qy_obj; 
     100        PyObject *I_out_obj; 
     101        Py_ssize_t n_qx, n_qy, n_out; 
    91102        double *qx; 
    92         PyObject *qy_obj; 
    93103        double *qy; 
    94         PyObject *I_out_obj; 
    95         Py_ssize_t n_out; 
    96104        double *I_out; 
    97         PyObject *gen_obj; 
    98  
    99         if (!PyArg_ParseTuple(args, "OiOOO",  &gen_obj, &npoints, &qx_obj, &qy_obj, &I_out_obj)) return NULL; 
    100         OUTVECTOR(qx_obj, qx, n_out); 
    101         OUTVECTOR(qy_obj, qy, n_out); 
     105        GenI* sld2i; 
     106 
     107        //printf("in genicom_inputXY\n"); 
     108        if (!PyArg_ParseTuple(args, "OOOO",  &gen_obj, &qx_obj, &qy_obj, &I_out_obj)) return NULL; 
     109        sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 
     110        INVECTOR(qx_obj, qx, n_qx); 
     111        INVECTOR(qy_obj, qy, n_qy); 
    102112        OUTVECTOR(I_out_obj, I_out, n_out); 
     113        //printf("qx, qy, I_out: %d %d %d, %d %d %d\n", qx, qy, I_out, n_qx, n_qy, n_out); 
    103114 
    104115        // Sanity check 
    105         //if(n_in!=n_out) return Py_BuildValue("i",-1); 
    106  
    107         // Set the array pointers 
    108         void *temp = PyCapsule_GetPointer(gen_obj, "GenI"); 
    109         GenI* s = static_cast<GenI *>(temp); 
    110  
    111         s->genicomXY(npoints, qx, qy, I_out); 
     116        //if(n_q!=n_out) return Py_BuildValue("i",-1); 
     117 
     118        genicomXY(sld2i, (int)n_qx, qx, qy, I_out); 
     119        //printf("done calc\n"); 
    112120        //return PyCObject_FromVoidPtr(s, del_genicom); 
    113121        return Py_BuildValue("i",1); 
     
    117125 * GenI the given 1D input according to a given object 
    118126 */ 
    119 PyObject * genicom_input(PyObject *, PyObject *args) { 
    120         int npoints; 
     127PyObject * genicom_input(PyObject *self, PyObject *args) { 
     128        PyObject *gen_obj; 
    121129        PyObject *q_obj; 
     130        PyObject *I_out_obj; 
     131        Py_ssize_t n_q, n_out; 
    122132        double *q; 
    123         PyObject *I_out_obj; 
    124         Py_ssize_t n_out; 
    125133        double *I_out; 
    126         PyObject *gen_obj; 
    127  
    128         if (!PyArg_ParseTuple(args, "OiOO",  &gen_obj, &npoints, &q_obj, &I_out_obj)) return NULL; 
    129         OUTVECTOR(q_obj, q, n_out); 
     134        GenI *sld2i; 
     135 
     136        if (!PyArg_ParseTuple(args, "OOO",  &gen_obj, &q_obj, &I_out_obj)) return NULL; 
     137        sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 
     138        INVECTOR(q_obj, q, n_q); 
    130139        OUTVECTOR(I_out_obj, I_out, n_out); 
    131140 
    132141        // Sanity check 
    133         //if(n_in!=n_out) return Py_BuildValue("i",-1); 
    134  
    135         // Set the array pointers 
    136         void *temp = PyCapsule_GetPointer(gen_obj, "GenI"); 
    137         GenI* s = static_cast<GenI *>(temp); 
    138  
    139         s->genicom(npoints, q, I_out); 
    140         //return PyCObject_FromVoidPtr(s, del_genicom); 
     142        //if (n_q!=n_out) return Py_BuildValue("i",-1); 
     143 
     144        genicom(sld2i, (int)n_q, q, I_out); 
    141145        return Py_BuildValue("i",1); 
    142146} 
  • src/sas/sascalc/calculator/instrument.py

    r574adc7 rf4775563  
    314314        """ 
    315315        To plot the wavelength spactrum 
    316         : requirment: matplotlib.pyplot 
     316        : requirement: matplotlib.pyplot 
    317317        """ 
    318318        try: 
  • src/sas/sascalc/calculator/sas_gen.py

    rb58265c3 r144e032a  
    118118        self.is_avg = is_avg 
    119119 
    120     def _gen(self, x, y, i): 
     120    def _gen(self, qx, qy): 
    121121        """ 
    122122        Evaluate the function 
     
    129129        pos_y = self.data_y 
    130130        pos_z = self.data_z 
    131         len_x = len(pos_x) 
    132131        if self.is_avg is None: 
    133             len_x *= -1 
    134132            pos_x, pos_y, pos_z = transform_center(pos_x, pos_y, pos_z) 
    135         len_q = len(x) 
    136133        sldn = copy.deepcopy(self.data_sldn) 
    137134        sldn -= self.params['solvent_SLD'] 
    138         model = mod.new_GenI(len_x, pos_x, pos_y, pos_z, 
    139                              sldn, self.data_mx, self.data_my, 
    140                              self.data_mz, self.data_vol, 
    141                              self.params['Up_frac_in'], 
    142                              self.params['Up_frac_out'], 
    143                              self.params['Up_theta']) 
    144         if y == []: 
    145             mod.genicom(model, len_q, x, i) 
    146         else: 
    147             mod.genicomXY(model, len_q, x, y, i) 
     135        # **** WARNING **** new_GenI holds pointers to numpy vectors 
     136        # be sure that they are contiguous double precision arrays and make  
     137        # sure the GC doesn't eat them before genicom is called. 
     138        # TODO: rewrite so that the parameters are passed directly to genicom 
     139        args = ( 
     140            (1 if self.is_avg else 0), 
     141            pos_x, pos_y, pos_z, 
     142            sldn, self.data_mx, self.data_my, 
     143            self.data_mz, self.data_vol, 
     144            self.params['Up_frac_in'], 
     145            self.params['Up_frac_out'], 
     146            self.params['Up_theta']) 
     147        model = mod.new_GenI(*args) 
     148        if len(qy): 
     149            qx, qy = _vec(qx), _vec(qy) 
     150            I_out = np.empty_like(qx) 
     151            #print("npoints", qx.shape, "npixels", pos_x.shape) 
     152            mod.genicomXY(model, qx, qy, I_out) 
     153            #print("I_out after", I_out) 
     154        else: 
     155            qx = _vec(qx) 
     156            I_out = np.empty_like(qx) 
     157            mod.genicom(model, qx, I_out) 
    148158        vol_correction = self.data_total_volume / self.params['total_volume'] 
    149         return  self.params['scale'] * vol_correction * i + \ 
    150                         self.params['background'] 
     159        result = (self.params['scale'] * vol_correction * I_out 
     160                  + self.params['background']) 
     161        return result 
    151162 
    152163    def set_sld_data(self, sld_data=None): 
     
    156167        self.sld_data = sld_data 
    157168        self.data_pos_unit = sld_data.pos_unit 
    158         self.data_x = sld_data.pos_x 
    159         self.data_y = sld_data.pos_y 
    160         self.data_z = sld_data.pos_z 
    161         self.data_sldn = sld_data.sld_n 
    162         self.data_mx = sld_data.sld_mx 
    163         self.data_my = sld_data.sld_my 
    164         self.data_mz = sld_data.sld_mz 
    165         self.data_vol = sld_data.vol_pix 
     169        self.data_x = _vec(sld_data.pos_x) 
     170        self.data_y = _vec(sld_data.pos_y) 
     171        self.data_z = _vec(sld_data.pos_z) 
     172        self.data_sldn = _vec(sld_data.sld_n) 
     173        self.data_mx = _vec(sld_data.sld_mx) 
     174        self.data_my = _vec(sld_data.sld_my) 
     175        self.data_mz = _vec(sld_data.sld_mz) 
     176        self.data_vol = _vec(sld_data.vol_pix) 
    166177        self.data_total_volume = sum(sld_data.vol_pix) 
    167178        self.params['total_volume'] = sum(sld_data.vol_pix) 
     
    180191        :return: (I value) 
    181192        """ 
    182         if x.__class__.__name__ == 'list': 
     193        if isinstance(x, list): 
    183194            if len(x[1]) > 0: 
    184195                msg = "Not a 1D." 
    185196                raise ValueError(msg) 
    186             i_out = np.zeros_like(x[0]) 
    187197            # 1D I is found at y =0 in the 2D pattern 
    188             out = self._gen(x[0], [], i_out) 
     198            out = self._gen(x[0], []) 
    189199            return out 
    190200        else: 
     
    199209        :Use this runXY() for the computation 
    200210        """ 
    201         if x.__class__.__name__ == 'list': 
    202             i_out = np.zeros_like(x[0]) 
    203             out = self._gen(x[0], x[1], i_out) 
    204             return out 
     211        if isinstance(x, list): 
     212            return self._gen(x[0], x[1]) 
    205213        else: 
    206214            msg = "Q must be given as list of qx's and qy's" 
     
    214222                      where qx,qy are 1D ndarrays (for 2D). 
    215223        """ 
    216         if qdist.__class__.__name__ == 'list': 
    217             if len(qdist[1]) < 1: 
    218                 out = self.run(qdist) 
    219             else: 
    220                 out = self.runXY(qdist) 
    221             return out 
     224        if isinstance(qdist, list): 
     225            return self.run(qdist) if len(qdist[1]) < 1 else self.runXY(qdist) 
    222226        else: 
    223227            mesg = "evalDistribution is expecting an ndarray of " 
    224228            mesg += "a list [qx,qy] where qx,qy are arrays." 
    225229            raise RuntimeError(mesg) 
     230 
     231def _vec(v): 
     232    return np.ascontiguousarray(v, 'd') 
    226233 
    227234class OMF2SLD(object): 
     
    10411048        self.line_z = line_z 
    10421049 
     1050def _get_data_path(*path_parts): 
     1051    from os.path import realpath, join as joinpath, dirname, abspath 
     1052    # in sas/sascalc/calculator;  want sas/sasview/test 
     1053    return joinpath(dirname(realpath(__file__)), 
     1054                    '..', '..', 'sasview', 'test', *path_parts) 
     1055 
    10431056def test_load(): 
    10441057    """ 
     
    10461059    """ 
    10471060    from mpl_toolkits.mplot3d import Axes3D 
    1048     current_dir = os.path.abspath(os.path.curdir) 
    1049     print(current_dir) 
    1050     for i in range(6): 
    1051         current_dir, _ = os.path.split(current_dir) 
    1052         tfile = os.path.join(current_dir, "test", "CoreXY_ShellZ.txt") 
    1053         ofile = os.path.join(current_dir, "test", "A_Raw_Example-1.omf") 
    1054         if os.path.isfile(tfile): 
    1055             tfpath = tfile 
    1056             ofpath = ofile 
    1057             break 
     1061    tfpath = _get_data_path("1d_data", "CoreXY_ShellZ.txt") 
     1062    ofpath = _get_data_path("coordinate_data", "A_Raw_Example-1.omf") 
     1063    if not os.path.isfile(tfpath) or not os.path.isfile(ofpath): 
     1064        raise ValueError("file(s) not found: %r, %r"%(tfpath, ofpath)) 
    10581065    reader = SLDReader() 
    10591066    oreader = OMFReader() 
    1060     output = decode(reader.read(tfpath)) 
    1061     ooutput = decode(oreader.read(ofpath)) 
     1067    output = reader.read(tfpath) 
     1068    ooutput = oreader.read(ofpath) 
    10621069    foutput = OMF2SLD() 
    10631070    foutput.set_data(ooutput) 
     
    10881095    plt.show() 
    10891096 
     1097def test_save(): 
     1098    ofpath = _get_data_path("coordinate_data", "A_Raw_Example-1.omf") 
     1099    if not os.path.isfile(ofpath): 
     1100        raise ValueError("file(s) not found: %r"%(ofpath,)) 
     1101    oreader = OMFReader() 
     1102    omfdata = oreader.read(ofpath) 
     1103    omf2sld = OMF2SLD() 
     1104    omf2sld.set_data(omfdata) 
     1105    writer = SLDReader() 
     1106    writer.write("out.txt", omf2sld.output) 
     1107 
    10901108def test(): 
    10911109    """ 
    10921110        Test code 
    10931111    """ 
    1094     current_dir = os.path.abspath(os.path.curdir) 
    1095     for i in range(3): 
    1096         current_dir, _ = os.path.split(current_dir) 
    1097         ofile = os.path.join(current_dir, "test", "A_Raw_Example-1.omf") 
    1098         if os.path.isfile(ofile): 
    1099             ofpath = ofile 
    1100             break 
     1112    ofpath = _get_data_path("coordinate_data", "A_Raw_Example-1.omf") 
     1113    if not os.path.isfile(ofpath): 
     1114        raise ValueError("file(s) not found: %r"%(ofpath,)) 
    11011115    oreader = OMFReader() 
    1102     ooutput = decode(oreader.read(ofpath)) 
    1103     foutput = OMF2SLD() 
    1104     foutput.set_data(ooutput) 
    1105     writer = SLDReader() 
    1106     writer.write(os.path.join(os.path.dirname(ofpath), "out.txt"), 
    1107                  foutput.output) 
     1116    omfdata = oreader.read(ofpath) 
     1117    omf2sld = OMF2SLD() 
     1118    omf2sld.set_data(omfdata) 
    11081119    model = GenSAS() 
    1109     model.set_sld_data(foutput.output) 
    1110     x = np.arange(1000)/10000. + 1e-5 
    1111     y = np.arange(1000)/10000. + 1e-5 
    1112     i = np.zeros(1000) 
    1113     model.runXY([x, y, i]) 
     1120    model.set_sld_data(omf2sld.output) 
     1121    x = np.linspace(0, 0.1, 11)[1:] 
     1122    return model.runXY([x, x]) 
    11141123 
    11151124if __name__ == "__main__": 
     1125    #test_load() 
     1126    #test_save() 
     1127    #print(test()) 
    11161128    test() 
    1117     test_load() 
  • src/sas/sascalc/dataloader/file_reader_base_class.py

    r1576693 r3053a4a  
    2727 
    2828class FileReader(object): 
    29     # List of Data1D and Data2D objects to be sent back to data_loader 
    30     output = [] 
    31     # Current plottable_(1D/2D) object being loaded in 
    32     current_dataset = None 
    33     # Current DataInfo object being loaded in 
    34     current_datainfo = None 
    3529    # String to describe the type of data this reader can load 
    3630    type_name = "ASCII" 
     
    4337    # Able to import the unit converter 
    4438    has_converter = True 
    45     # Open file handle 
    46     f_open = None 
    4739    # Default value of zero 
    4840    _ZERO = 1e-16 
    4941 
     42    def __init__(self): 
     43        # List of Data1D and Data2D objects to be sent back to data_loader 
     44        self.output = [] 
     45        # Current plottable_(1D/2D) object being loaded in 
     46        self.current_dataset = None 
     47        # Current DataInfo object being loaded in 
     48        self.current_datainfo = None 
     49        # File path sent to reader 
     50        self.filepath = None 
     51        # Open file handle 
     52        self.f_open = None 
     53 
    5054    def read(self, filepath): 
    5155        """ 
     
    5458        :param filepath: The full or relative path to a file to be loaded 
    5559        """ 
     60        self.filepath = filepath 
    5661        if os.path.isfile(filepath): 
    5762            basename, extension = os.path.splitext(os.path.basename(filepath)) 
     
    96101        self.current_datainfo = None 
    97102        self.current_dataset = None 
     103        self.filepath = None 
    98104        self.output = [] 
    99105 
     
    123129        """ 
    124130        Generic error handler to add an error to the current datainfo to 
    125         propogate the error up the error chain. 
     131        propagate the error up the error chain. 
    126132        :param msg: Error message 
    127133        """ 
     
    325331    def splitline(line): 
    326332        """ 
    327         Splits a line into pieces based on common delimeters 
     333        Splits a line into pieces based on common delimiters 
    328334        :param line: A single line of text 
    329335        :return: list of values 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r61f329f0 r2469df7  
    8282 
    8383    def read(self, xml_file, schema_path="", invalid=True): 
    84         if schema_path != "" or invalid != True: 
     84        if schema_path != "" or not invalid: 
    8585            # read has been called from self.get_file_contents because xml file doens't conform to schema 
    8686            _, self.extension = os.path.splitext(os.path.basename(xml_file)) 
     
    942942            pos, "z", datainfo.sample.position.z, 
    943943            {"unit": datainfo.sample.position_unit}) 
    944         if written == True: 
     944        if written: 
    945945            self.append(pos, sample) 
    946946 
     
    955955            ori, "yaw", datainfo.sample.orientation.z, 
    956956            {"unit": datainfo.sample.orientation_unit}) 
    957         if written == True: 
     957        if written: 
    958958            self.append(ori, sample) 
    959959 
     
    10021002            size, "z", datainfo.source.beam_size.z, 
    10031003            {"unit": datainfo.source.beam_size_unit}) 
    1004         if written == True: 
     1004        if written: 
    10051005            self.append(size, source) 
    10061006 
     
    10581058                    size, "z", aperture.size.z, 
    10591059                    {"unit": aperture.size_unit}) 
    1060                 if written == True: 
     1060                if written: 
    10611061                    self.append(size, apert) 
    10621062 
     
    10811081            written = written | self.write_node(det, "SDD", item.distance, 
    10821082                                                {"unit": item.distance_unit}) 
    1083             if written == True: 
     1083            if written: 
    10841084                self.append(det, instr) 
    10851085 
     
    10911091            written = written | self.write_node(off, "z", item.offset.z, 
    10921092                                                {"unit": item.offset_unit}) 
    1093             if written == True: 
     1093            if written: 
    10941094                self.append(off, det) 
    10951095 
     
    11031103                                                item.orientation.z, 
    11041104                                                {"unit": item.orientation_unit}) 
    1105             if written == True: 
     1105            if written: 
    11061106                self.append(ori, det) 
    11071107 
     
    11151115                                                item.beam_center.z, 
    11161116                                                {"unit": item.beam_center_unit}) 
    1117             if written == True: 
     1117            if written: 
    11181118                self.append(center, det) 
    11191119 
     
    11251125            written = written | self.write_node(pix, "z", item.pixel_size.z, 
    11261126                                                {"unit": item.pixel_size_unit}) 
    1127             if written == True: 
     1127            if written: 
    11281128                self.append(pix, det) 
    11291129            self.write_node(det, "slit_length", item.slit_length, 
  • src/sas/sascalc/dataloader/readers/danse_reader.py

    raf3e9f5 r2469df7  
    157157        # Store all data 
    158158        # Store wavelength 
    159         if has_converter == True and self.current_datainfo.source.wavelength_unit != 'A': 
     159        if has_converter and self.current_datainfo.source.wavelength_unit != 'A': 
    160160            conv = Converter('A') 
    161161            wavelength = conv(wavelength, 
     
    164164 
    165165        # Store distance 
    166         if has_converter == True and detector.distance_unit != 'm': 
     166        if has_converter and detector.distance_unit != 'm': 
    167167            conv = Converter('m') 
    168168            distance = conv(distance, units=detector.distance_unit) 
     
    170170 
    171171        # Store pixel size 
    172         if has_converter == True and detector.pixel_size_unit != 'mm': 
     172        if has_converter and detector.pixel_size_unit != 'mm': 
    173173            conv = Converter('mm') 
    174174            pixel = conv(pixel, units=detector.pixel_size_unit) 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r849094a r3053a4a  
    1212from ..file_reader_base_class import FileReader 
    1313from ..data_info import plottable_1D, DataInfo 
    14 from ..loader_exceptions import FileContentsException, DataReaderException 
     14from ..loader_exceptions import FileContentsException 
    1515 
    1616# Check whether we have a converter available 
     
    1818try: 
    1919    from sas.sascalc.data_util.nxsunit import Converter 
    20 except: 
     20except ImportError: 
    2121    has_converter = False 
    2222_ZERO = 1e-16 
     
    4646        line = self.nextline() 
    4747        params = {} 
    48         while not line.startswith("BEGIN_DATA"): 
     48        while line and not line.startswith("BEGIN_DATA"): 
    4949            terms = line.split() 
    5050            if len(terms) >= 2: 
     
    6363            raise FileContentsException("Wavelength has no units") 
    6464        if params["SpinEchoLength_unit"] != params["Wavelength_unit"]: 
    65             raise FileContentsException("The spin echo data has rudely used " 
    66                                "different units for the spin echo length " 
    67                                "and the wavelength.  While sasview could " 
    68                                "handle this instance, it is a violation " 
    69                                "of the file format and will not be " 
    70                                "handled by other software.") 
     65            raise FileContentsException( 
     66                "The spin echo data has rudely used " 
     67                "different units for the spin echo length " 
     68                "and the wavelength.  While sasview could " 
     69                "handle this instance, it is a violation " 
     70                "of the file format and will not be " 
     71                "handled by other software.") 
    7172 
    7273        headers = self.nextline().split() 
     
    8687 
    8788        if not data.size: 
    88             raise FileContentsException("{} is empty".format(path)) 
     89            raise FileContentsException("{} is empty".format(self.filepath)) 
    8990        x = data[:, headers.index("SpinEchoLength")] 
    9091        if "SpinEchoLength_error" in headers: 
  • src/sas/sascalc/file_converter/otoko_loader.py

    r0b1a677 r20fa5fe  
    3636 
    3737        Given the paths of two header files, this function will load each axis in 
    38         turn.  If loading is successfull then an instance of the OTOKOData class 
     38        turn.  If loading is successful then an instance of the OTOKOData class 
    3939        will be returned, else an exception will be raised. 
    4040 
  • src/sas/sascalc/fit/AbstractFitEngine.py

    r574adc7 r20fa5fe  
    7878    def get_params(self, fitparams): 
    7979        """ 
    80         return a list of value of paramter to fit 
    81  
    82         :param fitparams: list of paramaters name to fit 
     80        return a list of value of parameter to fit 
     81 
     82        :param fitparams: list of parameters name to fit 
    8383 
    8484        """ 
  • src/sas/sascalc/fit/MultiplicationModel.py

    r574adc7 r0a9cbc3  
    6868        try: 
    6969            multiplicity = p_model.multiplicity 
    70         except: 
     70        except AttributeError: 
    7171            multiplicity = 1 
    7272        ## functional multiplicity of the model 
     
    7676        self.non_fittable = p_model.non_fittable 
    7777        self.multiplicity_info = [] 
    78         self.fun_list = {} 
     78        self.fun_list = [] 
    7979        if self.non_fittable > 1: 
    8080            try: 
     
    8282                self.fun_list = p_model.fun_list 
    8383                self.is_multiplicity_model = True 
    84             except: 
     84            except AttributeError: 
    8585                pass 
    8686        else: 
  • src/sas/sascalc/fit/qsmearing.py

    r50fcb09 r2469df7  
    9090            #print "data1D.dx[0]",data1D.dx[0],data1D.dxl[0] 
    9191    # If we found resolution smearing data, return a QSmearer 
    92     if _found_resolution == True: 
     92    if _found_resolution: 
    9393         return pinhole_smear(data, model) 
    9494 
     
    113113                break 
    114114    # If we found slit smearing data, return a slit smearer 
    115     if _found_slit == True: 
     115    if _found_slit: 
    116116        return slit_smear(data, model) 
    117117    return None 
  • src/sas/sascalc/pr/c_extensions/Cinvertor.c

    rd04ac05 ra52f32f  
    735735 
    736736const char get_peaks_doc[] = 
    737         "Returns the number of peaks in the output P(r) distrubution\n" 
     737        "Returns the number of peaks in the output P(r) distribution\n" 
    738738        "for the given set of coefficients.\n" 
    739739        " @param args: c-parameters\n" 
  • src/sas/sascalc/pr/fit/AbstractFitEngine.py

    r574adc7 r20fa5fe  
    7878    def get_params(self, fitparams): 
    7979        """ 
    80         return a list of value of paramter to fit 
    81  
    82         :param fitparams: list of paramaters name to fit 
     80        return a list of value of parameter to fit 
     81 
     82        :param fitparams: list of parameters name to fit 
    8383 
    8484        """ 
  • src/sas/sascalc/pr/invertor.py

    rd04ac05 r2469df7  
    222222        elif name == 'est_bck': 
    223223            value = self.get_est_bck() 
    224             if value == 1: 
    225                 return True 
    226             else: 
    227                 return False 
     224            return value == 1 
    228225        elif name in self.__dict__: 
    229226            return self.__dict__[name] 
     
    460457 
    461458        # If we need to fit the background, add a term 
    462         if self.est_bck == True: 
     459        if self.est_bck: 
    463460            nfunc_0 = nfunc 
    464461            nfunc += 1 
     
    506503 
    507504        # Keep a copy of the last output 
    508         if self.est_bck == False: 
     505        if not self.est_bck: 
    509506            self.out = c 
    510507            self.cov = err 
     
    658655        file.write("#slit_width=%g\n" % self.slit_width) 
    659656        file.write("#background=%g\n" % self.background) 
    660         if self.est_bck == True: 
     657        if self.est_bck: 
    661658            file.write("#has_bck=1\n") 
    662659        else: 
     
    738735                    elif line.startswith('#has_bck='): 
    739736                        toks = line.split('=') 
    740                         if int(toks[1]) == 1: 
    741                             self.est_bck = True 
    742                         else: 
    743                             self.est_bck = False 
     737                        self.est_bck = int(toks[1]) == 1 
    744738 
    745739                    # Now read in the parameters 
  • src/sas/sascalc/pr/num_term.py

    ra1b8fee r2469df7  
    5555        medi = 0 
    5656        for i in range(dv): 
    57             if odd == True: 
     57            if odd: 
    5858                medi = osc[int(med)] 
    5959            else: 
     
    9898                new_osc3.append(self.osc_list[i]) 
    9999 
    100         if flag9 == True: 
     100        if flag9: 
    101101            self.dataset = new_osc1 
    102         elif flag8 == True: 
     102        elif flag8: 
    103103            self.dataset = new_osc2 
    104104        else: 
     
    141141            div = len(nts) 
    142142            tem = float(div) / 2.0 
    143             odd = self.is_odd(div) 
    144             if odd == True: 
     143            if self.is_odd(div): 
    145144                nt = nts[int(tem)] 
    146145            else: 
     
    148147            return nt, self.alpha_list[nt - 10], self.mess_list[nt - 10] 
    149148        except: 
    150             #TODO: check the logic above and make sure it doesn't  
     149            #TODO: check the logic above and make sure it doesn't 
    151150            # rely on the try-except. 
    152151            return self.nterm_min, self.invertor.alpha, '' 
  • src/sas/sasgui/guiframe/data_processor.py

    ra1b8fee r20fa5fe  
    758758        cell pop up context by right clicking on a cell and gives the 
    759759        option to cut, paste, and clear. This will probably be removed in 
    760         future versions and is being superceded by more traditional cut and 
     760        future versions and is being superseded by more traditional cut and 
    761761        paste options. 
    762762        """ 
     
    800800        THIS METHOD IS NOT CURRENTLY USED.  it is part of right click cell 
    801801        context menu which is being removed. This will probably be removed in 
    802         future versions and is being superceded by more traditional cut and 
     802        future versions and is being superseded by more traditional cut and 
    803803        paste options 
    804804        """ 
     
    812812        THIS METHOD IS NOT CURRENTLY USED.  it is part of right click cell 
    813813        context menu which is being removed. This will probably be removed in 
    814         future versions and is being superceded by more traditional cut and 
     814        future versions and is being superseded by more traditional cut and 
    815815        paste options 
    816816        """ 
     
    828828        THIS METHOD IS NOT CURRENTLY USED.  it is part of right click cell 
    829829        context menu which is being removed. This will probably be removed in 
    830         future versions and is being superceded by more traditional cut and 
     830        future versions and is being superseded by more traditional cut and 
    831831        paste options 
    832832        """ 
     
    12331233        """ 
    12341234        Get object represented by the given cells and plot them.  Basically 
    1235         plot the colum in y vs the column in x. 
     1235        plot the column in y vs the column in x. 
    12361236        """ 
    12371237 
     
    19611961        selection_sizer.Add(self.save_to_file, (iy, ix), 
    19621962                            (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    1963         #contruction the sizer contaning button 
     1963        #contruction the sizer containing button 
    19641964        button_sizer.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    19651965 
  • src/sas/sasgui/guiframe/events.py

    r959eb01 r20fa5fe  
    1414#create a panel slicer 
    1515(SlicerPanelEvent, EVT_SLICER_PANEL)   = wx.lib.newevent.NewEvent() 
    16 #print update paramaters for panel slicer 
     16#print update parameers for panel slicer 
    1717(SlicerParamUpdateEvent, EVT_SLICER_PARS_UPDATE)   = wx.lib.newevent.NewEvent() 
    1818#update the slicer from the panel 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    rb963b20 r20fa5fe  
    9090    def can_load_data(self): 
    9191        """ 
    92         if return True, then call handler to laod data 
     92        if return True, then call handler to load data 
    9393        """ 
    9494        return True 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r7432acb r2469df7  
    827827        on_Modify Plot Property_close 
    828828        """ 
    829         if self.appD.okay_clicked == True: 
     829        if self.appD.okay_clicked: 
    830830            info = self.appD.get_current_values() 
    831831            self.appearance_selected_plot.custom_color = \ 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py

    r463e7ffc r20fa5fe  
    359359        # TODO: Do we need an explicit focus command for keyboard? 
    360360        # TODO: Can we tab between items? 
    361         # TODO: How do unhandled events get propogated to axes, figure and 
     361        # TODO: How do unhandled events get propagated to axes, figure and 
    362362        # TODO: finally to application?  Do we need to implement a full tags 
    363363        # TODO: architecture a la Tk? 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py

    r7432acb r20fa5fe  
    216216        """ 
    217217        self.base.thaw_axes() 
    218         # Post paramters 
     218        # Post parameters 
    219219        event = SlicerParameterEvent() 
    220220        event.type = self.__class__.__name__ 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/masking.py

    r45dffa69 r20fa5fe  
    7777    def compute(self): 
    7878        """ 
    79         excuting computation 
     79        executing computation 
    8080        """ 
    8181        elapsed = time.time() - self.starttime 
  • src/sas/sasgui/guiframe/plugin_base.py

    r7432acb r20fa5fe  
    8282    def can_load_data(self): 
    8383        """ 
    84         if return True, then call handler to laod data 
     84        if return True, then call handler to load data 
    8585        """ 
    8686        return False 
  • src/sas/sasgui/guiframe/proxy.py

    ra1b8fee r20fa5fe  
    1717connect() function: 
    1818    - auto detects proxy in windows, osx 
    19     - in ux systems, the http_proxy enviroment variable must be set 
     19    - in ux systems, the http_proxy environment variable must be set 
    2020    - if it fails, try to find the proxy.pac address. 
    2121      - parses the file, and looks up for all possible proxies 
  • src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py

    ra1b8fee r20fa5fe  
    113113    def compute(self): 
    114114        """ 
    115         excuting computation 
     115        executing computation 
    116116        """ 
    117117        #elapsed = time.time() - self.starttime 
  • src/sas/sasgui/perspectives/calculator/media/sas_calculator_help.rst

    r5ed76f8 r1b67f3e  
    2626intensity from the particle is 
    2727 
    28 .. image:: gen_i.png 
     28.. math:: 
     29 
     30    I(\vec Q) = \frac{1}{V}\left| 
     31        \sum_j^N v_j \beta_j \exp(i\vec Q \cdot \vec r_j)\right|^2 
    2932 
    3033Equation 1. 
     
    4649atomic structure (such as taken from a PDB file) to get the right normalization. 
    4750 
    48 *NOTE! $\beta_j$ displayed in the GUI may be incorrect but this will not 
     51*NOTE!* $\beta_j$ *displayed in the GUI may be incorrect but this will not 
    4952affect the scattering computation if the correction of the total volume V is made.* 
    5053 
     
    5659^^^^^^^^^^^^^^^^^^^ 
    5760 
    58 For magnetic scattering, only the magnetization component, $M_\perp$, 
    59 perpendicular to the scattering vector $Q$ contributes to the magnetic 
     61For magnetic scattering, only the magnetization component, $\mathbf{M}_\perp$, 
     62perpendicular to the scattering vector $\vec Q$ contributes to the magnetic 
    6063scattering length. 
    6164 
     
    6467The magnetic scattering length density is then 
    6568 
    66 .. image:: dm_eq.png 
     69.. math:: 
     70 
     71    \beta_M = \frac{\gamma r_0}{2 \mu_B}\sigma \cdot \mathbf{M}_\perp 
     72        = D_M\sigma \cdot \mathbf{M}_\perp 
    6773 
    6874where the gyromagnetic ratio is $\gamma = -1.913$, $\mu_B$ is the Bohr 
     
    8187.. image:: gen_mag_pic.png 
    8288 
    83 Now let us assume that the angles of the *Q* vector and the spin-axis (x') 
    84 to the x-axis are $\phi$ and $\theta_\text{up}$ respectively (see above). Then, 
     89Now let us assume that the angles of the $\vec Q$ vector and the spin-axis ($x'$) 
     90to the $x$-axis are $\phi$ and $\theta_\text{up}$ respectively (see above). Then, 
    8591depending upon the polarization (spin) state of neutrons, the scattering 
    8692length densities, including the nuclear scattering length density ($\beta_N$) 
     
    8995*  for non-spin-flips 
    9096 
    91    .. image:: sld1.png 
     97.. math:: 
     98    \beta_{\pm\pm} = \beta_N \mp D_M M_{\perp x'} 
    9299 
    93100*  for spin-flips 
    94101 
    95    .. image:: sld2.png 
     102.. math:: 
     103    \beta_{\pm\mp} = - D_M(M_{\perp y'} \pm i M_{\perp z'}) 
    96104 
    97105where 
    98106 
    99 .. image:: mxp.png 
     107.. math:: 
    100108 
    101 .. image:: myp.png 
     109    M_{\perp x'} &= M_{0q_x}\cos\theta_\text{up} + M_{0q_y}\sin\theta_\text{up} \\ 
     110    M_{\perp y'} &= M_{0q_y}\cos\theta_\text{up} - M_{0q_x}\sin\theta_\text{up} \\ 
     111    M_{\perp z'} &= M_{0z} \\ 
     112    M_{0q_x} &= (M_{0x}\cos\phi - M_{0y}\sin\phi)\cos\phi \\ 
     113    M_{0q_y} &= (M_{0y}\sin\phi - M_{0y}\cos\phi)\sin\phi 
    102114 
    103 .. image:: mzp.png 
    104  
    105 .. image:: mqx.png 
    106  
    107 .. image:: mqy.png 
    108  
    109 Here the $M0_x$, $M0_y$ and $M0_z$ are the $x$, $y$ and $z$ 
    110 components of the magnetisation vector in the laboratory $xyz$ frame. 
     115Here the $M_{0x}$, $M_{0y}$ and $M_{0z}$ are 
     116the $x$, $y$ and $z$ components of the magnetisation vector in the 
     117laboratory $x$-$y$-$z$ frame. 
    111118 
    112119.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    148155uses the Debye equation below providing a 1D output 
    149156 
    150 .. image:: gen_debye_eq.png 
     157.. math:: 
     158 
     159    I(|\vec Q|) = \frac{1}{V}\sum_j^N v_j\beta_j \sum_k^N v_k \beta_k 
     160        \frac{\sin(|\vec Q||\vec r_j - \vec r_k|)}{|\vec Q||\vec r_j - \vec r_k|} 
    151161 
    152162where $v_j \beta_j \equiv b_j$ is the scattering 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    r69363c7 r2469df7  
    338338            list_fnames = os.listdir(self.plugin_dir) 
    339339            # fake existing regular model name list 
    340             m_list = [model.name + ".py" for model in self.model_list] 
     340            m_list = [model + ".py" for model in self.model_list] 
    341341            list_fnames.append(m_list) 
    342342            if t_fname in list_fnames and title != mname: 
     
    344344                msg = "Name exists already." 
    345345 
    346         if self.good_name == False: 
     346        if not self.good_name: 
    347347            self.name_tcl.SetBackgroundColour('pink') 
    348348            info = 'Error' 
  • src/sas/sasgui/perspectives/calculator/resolcal_thread.py

    r959eb01 r20fa5fe  
    4444    def compute(self): 
    4545        """ 
    46         excuting computation 
     46        executing computation 
    4747        """ 
    4848        self.image = map(self.func, self.qx, self.qy, 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r3bd677b reee94bf  
    16431643                        if item_page[2].__class__.__name__ == "ComboBox": 
    16441644                            if item_page_info[2] in self.model.fun_list: 
    1645                                 fun_val = self.model.fun_list[item_page_info[2]] 
     1645                                fun_val = self.model.fun_list.index(item_page_info[2]) 
    16461646                                self.model.setParam(item_page_info[1], fun_val) 
    16471647                    if item_page[3] is not None: 
     
    16871687                selection = value 
    16881688                if value in self.model.fun_list: 
    1689                     selection = self.model.fun_list[value] 
     1689                    selection = self.model.fun_list.index(value) 
    16901690                item_page[2].SetValue(selection) 
    16911691                self.model.setParam(param_name, selection) 
     
    33653365                    if item[2].__class__.__name__ == "ComboBox": 
    33663366                        if content[name][1] in self.model.fun_list: 
    3367                             fun_val = self.model.fun_list[content[name][1]] 
     3367                            fun_val = self.model.fun_list.index(content[name][1]) 
    33683368                            self.model.setParam(name, fun_val) 
    33693369                    try: 
     
    34153415                        if item[2].__class__.__name__ == "ComboBox": 
    34163416                            if value[0] in self.model.fun_list: 
    3417                                 fun_val = self.model.fun_list[value[0]] 
     3417                                fun_val = self.model.fun_list.index(value[0]) 
    34183418                                self.model.setParam(name, fun_val) 
    34193419                                # save state 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r3bd677b rbfeb823  
    17261726                and not self.temp_multi_functional: 
    17271727            return None 
    1728         # Get the func name list 
    1729         list = self.model.fun_list 
    1730         if len(list) == 0: 
    1731             return None 
    1732         # build function (combo)box 
    1733         ind = 0 
    1734         while(ind < len(list)): 
    1735             for key, val in list.items(): 
    1736                 if val == ind: 
    1737                     fun_box.Append(key, val) 
    1738                     break 
    1739             ind += 1 
     1728        for index, choice in enumerate(self.model.fun_list): 
     1729            fun_box.Append(choice, index) 
    17401730 
    17411731    def _on_select_accuracy(self, event): 
     
    17651755        value = fun_box.GetValue() 
    17661756        if value in self.model.fun_list: 
    1767             fun_val = self.model.fun_list[value] 
     1757            fun_val = self.model.fun_list.index(value) 
    17681758 
    17691759        self.model.setParam(name, fun_val) 
  • src/sas/sasgui/perspectives/fitting/fitproblem.py

    r251ef684 r20fa5fe  
    11""" 
    22Inferface containing information to store data, model, range of data, etc... 
    3 and retreive this information. This is an inferface 
     3and retrieve this information. This is an inferface 
    44for a fitProblem i.e relationship between data and model. 
    55""" 
     
    5656        """ 
    5757        :param flag: bool.When flag is 1 get the computer smear value. When 
    58             flag is 0 ingore smear value. 
     58            flag is 0 ignore smear value. 
    5959        """ 
    6060        self.smearer_enable = flag 
     
    305305        """ 
    306306        :param flag: bool.When flag is 1 get the computer smear value. When 
    307             flag is 0 ingore smear value. 
     307            flag is 0 ignore smear value. 
    308308        """ 
    309309        self._smear_on = flag 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r9706d88 r20fa5fe  
    763763        the current page and set value. 
    764764        :param value: integer 0 or 1 
    765         :param uid: the id related to a page contaning fitting information 
     765        :param uid: the id related to a page containing fitting information 
    766766        """ 
    767767        if uid in self.page_finder.keys(): 
     
    778778        Used by simfitpage.py to reset a parameter given the string constrainst. 
    779779 
    780         :param modelname: the name ot the model for with the parameter 
     780        :param modelname: the name of the model for with the parameter 
    781781                            has to reset 
    782782        :param value: can be a string in this case. 
    783         :param names: the paramter name 
     783        :param names: the parameter name 
    784784        """ 
    785785        sim_page_id = self.sim_page.uid 
     
    797797        name into model name and parameter name example: :: 
    798798 
    799             paramaterset (item) = M1.A 
     799            parameterset (item) = M1.A 
    800800            Will return model_name = M1 , parameter name = A 
    801801 
     
    11171117    def store_data(self, uid, data_list=None, caption=None): 
    11181118        """ 
    1119         Recieve a list of data and store them ans well as a caption of 
     1119        Receive a list of data and store them ans well as a caption of 
    11201120        the fit page where they come from. 
    11211121        :param uid: if related to a fit page 
     
    11961196        for a given interactor. 
    11971197 
    1198         :param event: contains type of slicer , paramaters for updating 
     1198        :param event: contains type of slicer , parameters for updating 
    11991199            the panel and panel_name to find the slicer 's panel concerned. 
    12001200        """ 
  • src/sas/sasgui/perspectives/fitting/fitting_widgets.py

    r959eb01 r20fa5fe  
    6464        selection_sizer.Add(self.data_2d_selected, (iy, ix), 
    6565                           (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    66         #contruction the sizer contaning button 
     66        #contruction the sizer containing button 
    6767        button_sizer.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    6868        button_sizer.Add(button_cancel, 0, 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r3bd677b r20fa5fe  
    8888        self.option_button = {} 
    8989        self.buttons = [] 
    90         #Check if SAS_OPENCL is already set as enviromental variable 
     90        #Check if SAS_OPENCL is already set as environment variable 
    9191        self.sas_opencl = os.environ.get("SAS_OPENCL", "") 
    9292 
  • src/sas/sasgui/perspectives/fitting/media/fitting.rst

    r3bd677b rc926a97  
    1818 
    1919   Polarisation/Magnetic Scattering <magnetism/magnetism> 
     20    
     21   Oriented Particles <orientation/orientation> 
    2022 
    2123   Information on the SasView Optimisers <optimizer> 
  • src/sas/sasgui/perspectives/fitting/simfitpage.py

    r0a3c740 r20fa5fe  
    976976        param_cbox = self.constraints_list[-1].param_cbox 
    977977        param_cbox.Clear() 
    978         # insert only fittable paramaters 
     978        # insert only fittable parameters 
    979979        for param in param_list: 
    980980            param_cbox.Append(str(param), model) 
  • src/sas/sasgui/perspectives/invariant/invariant_details.py

    r959eb01 r20fa5fe  
    422422        except: 
    423423            scale = RECTANGLE_SCALE 
    424             self.warning_msg += "Recieve an invalid scale for %s\n" 
     424            self.warning_msg += "Receive an invalid scale for %s\n" 
    425425            self.warning_msg += "check this value : %s\n" % str(percentage) 
    426426        return  scale 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    r7432acb r2469df7  
    707707 
    708708        # reset power_out to default to get ready for another '_on_text' 
    709         if self.is_power_out == True: 
     709        if self.is_power_out: 
    710710            self.state.container = copy.deepcopy(self.inv_container) 
    711711            self.state.timestamp = self._get_time_stamp() 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    r1fa4f736 r2469df7  
    655655        : return: None 
    656656        """ 
    657         if self.cansas == True: 
     657        if self.cansas: 
    658658            return self._read_cansas(path) 
    659659        else: 
     
    763763        """ 
    764764        # Sanity check 
    765         if self.cansas == True: 
     765        if self.cansas: 
    766766            doc = self.write_toXML(datainfo, invstate) 
    767767            # Write the XML document 
  • src/sas/sasgui/perspectives/pr/explore_dialog.py

    r959eb01 r20fa5fe  
    9393 
    9494        :TODO: Would be nice to add printing and log/linear scales. 
    95             The current verison of plottools no longer plays well with 
     95            The current version of plottools no longer plays well with 
    9696            plots outside of guiframe. Guiframe team needs to fix this. 
    9797        """ 
  • src/sas/sasgui/perspectives/pr/inversion_state.py

    r1fa4f736 r2469df7  
    389389 
    390390        """ 
    391         if self.cansas == True: 
     391        if self.cansas: 
    392392            return self._read_cansas(path) 
    393393        else: 
     
    505505        """ 
    506506        # Sanity check 
    507         if self.cansas == True: 
     507        if self.cansas: 
    508508            doc = self.write_toXML(datainfo, prstate) 
    509509            # Write the XML document 
  • src/sas/sasgui/perspectives/pr/pr.py

    rcb62bd5 r2469df7  
    407407            y[i] = value 
    408408 
    409         if self._normalize_output == True: 
     409        if self._normalize_output: 
    410410            y = y / total 
    411411            dy = dy / total 
    412         elif self._scale_output_unity == True: 
     412        elif self._scale_output_unity: 
    413413            y = y / pmax 
    414414            dy = dy / pmax 
     
    544544            lines = buff.split('\n') 
    545545            for line in lines: 
    546                 if data_started == True: 
     546                if data_started: 
    547547                    try: 
    548548                        toks = line.split() 
  • src/sas/sasgui/plottools/PlotPanel.py

    ra1b8fee r2469df7  
    476476            return 
    477477        self.mousemotion = True 
    478         if self.leftdown == True and self.mousemotion == True: 
     478        if self.leftdown and self.mousemotion: 
    479479            ax = event.inaxes 
    480480            if ax is not None:  # the dragging is perform inside the figure 
  • src/sas/sasgui/plottools/binder.py

    ra1b8fee r20fa5fe  
    366366        # TODO: Do we need an explicit focus command for keyboard? 
    367367        # TODO: Can we tab between items? 
    368         # TODO: How do unhandled events get propogated to axes, figure and 
     368        # TODO: How do unhandled events get propagated to axes, figure and 
    369369        # TODO: finally to application?  Do we need to implement a full tags 
    370370        # TODO: architecture a la Tk? 
  • src/sas/sasgui/plottools/fitDialog.py

    r7432acb r2469df7  
    4444        fitting and derives and displays specialized output parameters based 
    4545        on the scale choice of the plot calling it. 
    46          
     46 
    4747        :note1: The fitting is currently a bit convoluted as besides using 
    4848        plottools.transform.py to handle all the conversions, it uses 
     
    5555        This would considerably simplify the code and remove the need I think 
    5656        for LineModel.py and possibly fittins.py altogether.   -PDB 7/10/16 
    57          
     57 
    5858        :note2: The linearized fits do not take resolution into account. This 
    5959        means that for poor resolution such as slit smearing the answers will 
     
    142142        """ 
    143143 
    144         # set up sizers first.  
     144        # set up sizers first. 
    145145        # vbox is the panel sizer and is a vertical sizer 
    146146        # The first element of the panel is sizer which is a gridbagsizer 
     
    151151        sizer = wx.GridBagSizer(5, 5) 
    152152        sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    153          
     153 
    154154        #size of string boxes in pixels 
    155155        _BOX_WIDTH = 100 
     
    395395        sizer_button.Add(self.btClose, 0, 
    396396                         wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) 
    397          
     397 
    398398        vbox.Add(sizer) 
    399         self.static_line_1 = wx.StaticLine(self, -1)         
     399        self.static_line_1 = wx.StaticLine(self, -1) 
    400400        vbox.Add(self.static_line_1, 0, wx.EXPAND, 0) 
    401401        vbox.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10) 
     
    439439        # makes transformation for y as a line to fit 
    440440        if self.x != []: 
    441             if self.checkFitValues(self.xminFit) == True: 
     441            if self.checkFitValues(self.xminFit): 
    442442                # Check if the field of Fit Dialog contain values 
    443443                # and use the x max and min of the user 
  • src/sas/sasgui/plottools/plottable_interactor.py

    ra1b8fee r2469df7  
    166166        from within the boundaries of an artist. 
    167167        """ 
    168         if self._context_menu == True: 
     168        if self._context_menu: 
    169169            self._context_menu = False 
    170170            evt.artist = self.marker 
     
    216216        """ 
    217217        if not evt.artist.__class__.__name__ == "AxesSubplot": 
    218             if self._context_menu == False: 
     218            if not self._context_menu: 
    219219                self.base.plottable_selected(None) 
    220220                try: 
  • src/sas/sasgui/plottools/plottables.py

    r2d9526d r2469df7  
    227227        max_value = None 
    228228        for p in self.plottables: 
    229             if p.hidden == True: 
     229            if p.hidden: 
    230230                continue 
    231231            if p.x is not None: 
     
    10621062        Renders the plottable on the graph 
    10631063        """ 
    1064         if self.interactive == True: 
     1064        if self.interactive: 
    10651065            kw['symbol'] = self.symbol 
    10661066            kw['id'] = self.id 
  • src/sas/sasgui/plottools/toolbar.py

    r959eb01 r20fa5fe  
    145145    def OnPrintPage(self, page): 
    146146        """ 
    147         Most rudimentry OnPrintPage overide.  instatiates a dc object, gets 
     147        Most rudimentry OnPrintPage override.  instatiates a dc object, gets 
    148148        its size, gets the size of the figure object, scales it to the dc 
    149149        canvas size keeping the aspect ratio intact, then prints as bitmap 
  • src/sas/sasview/__init__.py

    r6a88ad9 r3ca67dcf  
    1 __version__ = "4.1" 
     1__version__ = "4.2.0" 
    22__build__ = "GIT_COMMIT" 
  • src/sas/sasview/sasview.py

    r0225a3f r20fa5fe  
    203203    plugin_dir = os.path.join(sas.get_user_dir(), PLUGIN_MODEL_DIR) 
    204204    os.environ['SAS_MODELPATH'] = plugin_dir 
    205     #Initiliaze enviromental variable with custom setting but only if variable not set 
     205    #Initialize environment variable with custom setting but only if variable not set 
    206206    SAS_OPENCL = sas.get_custom_config().SAS_OPENCL 
    207207    if SAS_OPENCL and "SAS_OPENCL" not in os.environ: 
  • test/corfunc/test/utest_corfunc.py

    r86ba9d6 rf53d684  
    44from __future__ import division, print_function 
    55 
     6import os.path 
    67import unittest 
    78import time 
     
    1112from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 
    1213from sas.sascalc.dataloader.data_info import Data1D 
     14 
     15 
     16def find(filename): 
     17    return os.path.join(os.path.dirname(__file__), filename) 
    1318 
    1419 
     
    3136        self.extrapolation = None 
    3237        self.transformation = None 
    33         self.results = [np.loadtxt(filename+"_out.txt").T[2] 
     38        self.results = [np.loadtxt(find(filename+"_out.txt")).T[2] 
    3439                        for filename in ("gamma1", "gamma3", "idf")] 
    3540 
     
    110115 
    111116def load_data(filename="98929.txt"): 
    112     data = np.loadtxt(filename, dtype=np.float64) 
     117    data = np.loadtxt(find(filename), dtype=np.float64) 
    113118    q = data[:,0] 
    114119    iq = data[:,1] 
  • test/fileconverter/test/utest_nxcansas_writer.py

    r5a8cdbb rf53d684  
    33 
    44import os 
    5 import pylint 
     5import os.path 
    66import unittest 
    77import warnings 
    88 
    99warnings.simplefilter("ignore") 
     10 
     11 
     12def find(filename): 
     13    return os.path.join(os.path.dirname(__file__), filename) 
     14 
    1015 
    1116class nxcansas_writer(unittest.TestCase): 
     
    1419        self.loader = Loader() 
    1520        self.writer = NXcanSASWriter() 
    16         self.read_file_1d = "cansas1d.xml" 
    17         self.write_file_1d = "export1d.h5" 
    18         self.read_file_2d = "exp18_14_igor_2dqxqy.dat" 
    19         self.write_file_2d = "export2d.h5" 
     21        self.read_file_1d = find("cansas1d.xml") 
     22        self.write_file_1d = find("export1d.h5") 
     23        self.read_file_2d = find("exp18_14_igor_2dqxqy.dat") 
     24        self.write_file_2d = find("export2d.h5") 
    2025 
    2126        self.data_1d = self.loader.load(self.read_file_1d)[0] 
  • test/pr_inversion/test/utest_explorer.py

    r959eb01 rf53d684  
    33""" 
    44 
     5import os.path 
    56import unittest, math, numpy 
    67from utest_invertor import load 
    78from sas.sascalc.pr.invertor import Invertor 
    89from sas.sascalc.pr.distance_explorer import DistExplorer 
    9          
     10 
     11 
     12def find(filename): 
     13    return os.path.join(os.path.dirname(__file__), filename) 
     14 
     15 
    1016class TestExplorer(unittest.TestCase): 
    1117             
    1218    def setUp(self): 
    1319        self.invertor = Invertor() 
    14         x, y, err = load('sphere_80.txt') 
     20        x, y, err = load(find('sphere_80.txt')) 
    1521         
    1622        # Choose the right d_max... 
  • test/pr_inversion/test/utest_invertor.py

    rcb62bd5 rf53d684  
    1010 
    1111import os 
     12import os.path 
    1213import unittest 
    1314import math 
    1415import numpy 
    1516from sas.sascalc.pr.invertor import Invertor 
     17 
     18 
     19def find(filename): 
     20    return os.path.join(os.path.dirname(__file__), filename) 
    1621 
    1722 
     
    2833            self.x_in[i] = 1.0*(i+1) 
    2934        
    30         x, y, err = load("sphere_80.txt") 
     35        x, y, err = load(find("sphere_80.txt")) 
    3136 
    3237        # Choose the right d_max... 
     
    192197            Test an inversion for which we know the answer 
    193198        """ 
    194         x, y, err = load("sphere_80.txt") 
     199        x, y, err = load(find("sphere_80.txt")) 
    195200 
    196201        # Choose the right d_max... 
     
    247252            Test an inversion for which we know the answer 
    248253        """ 
    249         x, y, err = load("sphere_80.txt") 
     254        x, y, err = load(find("sphere_80.txt")) 
    250255 
    251256        # Choose the right d_max... 
     
    312317            Test error condition where a point has q=0 
    313318        """ 
    314         x, y, err = load("sphere_80.txt") 
     319        x, y, err = load(find("sphere_80.txt")) 
    315320        x[0] = 0.0 
    316321         
     
    329334            Test error condition where a point has q<0 
    330335        """ 
    331         x, y, err = load("sphere_80.txt") 
     336        x, y, err = load(find("sphere_80.txt")) 
    332337        x[0] = -0.2 
    333338         
     
    353358            Test error condition where a point has q<0 
    354359        """ 
    355         x, y, err = load("sphere_80.txt") 
     360        x, y, err = load(find("sphere_80.txt")) 
    356361        y[0] = 0.0 
    357362         
     
    374379         
    375380    def no_test_time(self): 
    376         x, y, err = load("sphere_80.txt") 
     381        x, y, err = load(find("sphere_80.txt")) 
    377382 
    378383        # Choose the right d_max... 
     
    406411         
    407412    def test_save(self): 
    408         x, y, err = load("sphere_80.txt") 
     413        x, y, err = load(find("sphere_80.txt")) 
    409414 
    410415        # Choose the right d_max... 
     
    464469            Test an inversion for which we know the answer 
    465470        """ 
    466         x, y, err = load("data_error_1.txt") 
     471        x, y, err = load(find("data_error_1.txt")) 
    467472 
    468473        # Choose the right d_max... 
     
    482487            Have zero as an error should raise an exception 
    483488        """ 
    484         x, y, err = load("data_error_2.txt") 
     489        x, y, err = load(find("data_error_2.txt")) 
    485490 
    486491        # Set data 
     
    495500            Test an inversion for which we know the answer 
    496501        """ 
    497         x, y, err = load("data_error_1.txt") 
     502        x, y, err = load(find("data_error_1.txt")) 
    498503 
    499504        # Set data 
     
    511516            An exception should be raised. 
    512517        """ 
    513         x, y, err = load("data_error_3.txt") 
     518        x, y, err = load(find("data_error_3.txt")) 
    514519 
    515520        # Set data 
     
    521526            Should not complain or crash. 
    522527        """ 
    523         x, y, err = load("data_error_4.txt") 
     528        x, y, err = load(find("data_error_4.txt")) 
    524529 
    525530        # Set data 
     
    535540            Makes not sense, but should not complain or crash. 
    536541        """ 
    537         x, y, err = load("data_error_5.txt") 
     542        x, y, err = load(find("data_error_5.txt")) 
    538543 
    539544        # Set data 
     
    549554            Makes not sense, but should not complain or crash. 
    550555        """ 
    551         x, y, err = load("data_error_6.txt") 
     556        x, y, err = load(find("data_error_6.txt")) 
    552557 
    553558        # Set data 
  • test/sascalculator/test/utest_sas_gen.py

    r1d014cb r5bb05a4  
    22Unit tests for the sas_gen 
    33""" 
     4 
     5import os.path 
    46import warnings 
    57warnings.simplefilter("ignore") 
    68 
    79import unittest 
     10import numpy as np 
     11 
    812from sas.sascalc.calculator import sas_gen 
     13 
     14 
     15def find(filename): 
     16    return os.path.join(os.path.dirname(__file__), filename) 
    917 
    1018 
     
    2028        Test .sld file loaded 
    2129        """ 
    22         f = self.sldloader.read("sld_file.sld") 
     30        f = self.sldloader.read(find("sld_file.sld")) 
    2331        self.assertEqual(f.pos_x[0], -40.5) 
    2432        self.assertEqual(f.pos_y[0], -13.5) 
     
    2937        Test .pdb file loaded 
    3038        """ 
    31         f = self.pdbloader.read("c60.pdb") 
     39        f = self.pdbloader.read(find("c60.pdb")) 
    3240        self.assertEqual(f.pos_x[0], -0.733) 
    3341        self.assertEqual(f.pos_y[0], -1.008) 
     
    3846        Test .omf file loaded 
    3947        """ 
    40         f = self.omfloader.read("A_Raw_Example-1.omf") 
     48        f = self.omfloader.read(find("A_Raw_Example-1.omf")) 
    4149        output = sas_gen.OMF2SLD() 
    4250        output.set_data(f) 
     
    4856        self.assertEqual(output.pos_z[0], 0.0) 
    4957 
     58    def test_calculator(self): 
     59        """ 
     60        Test that the calculator calculates. 
     61        """ 
     62        f = self.omfloader.read("A_Raw_Example-1.omf") 
     63        omf2sld = sas_gen.OMF2SLD() 
     64        omf2sld.set_data(f) 
     65        model = sas_gen.GenSAS() 
     66        model.set_sld_data(omf2sld.output) 
     67        x = np.linspace(0, 0.1, 11)[1:] 
     68        model.runXY([x, x]) 
     69 
    5070 
    5171if __name__ == '__main__': 
  • test/sascalculator/test/utest_slit_length_calculator.py

    rb09095a rf53d684  
    33""" 
    44 
     5import os.path 
    56import unittest 
    67from sas.sascalc.dataloader.readers.ascii_reader import Reader 
    78from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator \ 
    89    as calculator 
     10 
     11 
     12def find(filename): 
     13    return os.path.join(os.path.dirname(__file__), filename) 
    914 
    1015 
     
    1924            Test slit_length_calculator" 
    2025        """ 
    21         list = self.reader.read("beam profile.DAT") 
     26        list = self.reader.read(find("beam profile.DAT")) 
    2227        self.assertTrue(len(list) == 1) 
    2328        f = list[0] 
  • test/sasdataloader/test/utest_abs_reader.py

    rfe15198 rf53d684  
    1616 
    1717 
     18def find(filename): 
     19    return os.path.join(os.path.dirname(__file__), filename) 
     20 
     21 
    1822class abs_reader(unittest.TestCase): 
    1923 
    2024    def setUp(self): 
    2125        reader = AbsReader() 
    22         self.data_list = reader.read("jan08002.ABS") 
     26        self.data_list = reader.read(find("jan08002.ABS")) 
    2327        self.data = self.data_list[0] 
    2428 
     
    3135            tests won't pass 
    3236        """ 
    33         self.assertEqual(self.data.filename, "jan08002.ABS") 
     37        self.assertEqual(os.path.basename(self.data.filename), "jan08002.ABS") 
    3438        self.assertEqual(self.data.meta_data['loader'], "IGOR 1D") 
    3539 
     
    6973    def test_generic_loader(self): 
    7074        # the generic loader should work as well 
    71         data = Loader().load("jan08002.ABS") 
     75        data = Loader().load(find("jan08002.ABS")) 
    7276        self.assertEqual(data[0].meta_data['loader'], "IGOR 1D") 
    7377 
     
    7680    def setUp(self): 
    7781        reader = DANSEReader() 
    78         self.data_list = reader.read("MP_New.sans") 
     82        self.data_list = reader.read(find("MP_New.sans")) 
    7983        self.data = self.data_list[0] 
    8084 
     
    8892        """ 
    8993        self.assertEqual(len(self.data_list), 1) 
    90         self.assertEqual(self.data.filename, "MP_New.sans") 
     94        self.assertEqual(os.path.basename(self.data.filename), "MP_New.sans") 
    9195        self.assertEqual(self.data.meta_data['loader'], "DANSE") 
    9296 
     
    114118    def test_generic_loader(self): 
    115119        # the generic loader should work as well 
    116         data = Loader().load("MP_New.sans") 
     120        data = Loader().load(find("MP_New.sans")) 
    117121        self.assertEqual(len(data), 1) 
    118122        self.assertEqual(data[0].meta_data['loader'], "DANSE") 
     
    123127    def setUp(self): 
    124128        reader = CANSASReader() 
    125         self.data_list = reader.read("cansas1d.xml") 
     129        self.data_list = reader.read(find("cansas1d.xml")) 
    126130        self.data = self.data_list[0] 
    127131 
    128132    def test_generic_loader(self): 
    129133        # the generic loader should work as well 
    130         data = Loader().load("cansas1d.xml") 
     134        data = Loader().load(find("cansas1d.xml")) 
    131135        self.assertEqual(len(data), 1) 
    132136        self.assertEqual(data[0].meta_data['loader'], "CanSAS XML 1D") 
    133137 
    134138    def test_cansas_checkdata(self): 
    135         self.assertEqual(self.data.filename, "cansas1d.xml") 
     139        self.assertEqual(os.path.basename(self.data.filename), "cansas1d.xml") 
    136140        self._checkdata() 
    137141 
     
    282286 
    283287        filename = "write_test.xml" 
    284         r.write(filename, self.data) 
    285         data = Loader().load(filename) 
     288        r.write(find(filename), self.data) 
     289        data = Loader().load(find(filename)) 
    286290        self.data = data[0] 
    287291        self.assertEqual(len(data), 1) 
     
    297301        """ 
    298302        filename = "cansas1d_units.xml" 
    299         data = CANSASReader().read(filename) 
     303        data = CANSASReader().read(find(filename)) 
    300304        self.data = data[0] 
    301305        self.assertEqual(len(data), 1) 
     
    309313        """ 
    310314        filename = "cansas1d_badunits.xml" 
    311         data = CANSASReader().read(filename) 
     315        data = CANSASReader().read(find(filename)) 
    312316        self.data = data[0] 
    313317        self.assertEqual(len(data), 1) 
     
    326330        """ 
    327331        filename = "cansas1d_slit.xml" 
    328         data = CANSASReader().read(filename) 
     332        data = CANSASReader().read(find(filename)) 
    329333        self.data = data[0] 
    330334        self.assertEqual(len(data), 1) 
  • test/sasdataloader/test/utest_ascii.py

    rfe15198 rf53d684  
    22    Unit tests for the ascii (n-column) reader 
    33""" 
     4 
     5import os.path 
    46import warnings 
    57warnings.simplefilter("ignore") 
     
    911 
    1012 
     13def find(filename): 
     14    return os.path.join(os.path.dirname(__file__), filename) 
     15 
     16 
    1117class ABSReaderTests(unittest.TestCase): 
    1218     
    1319    def setUp(self): 
    1420        self.loader = Loader() 
    15         self.f1_list = self.loader.load("ascii_test_1.txt") 
     21        self.f1_list = self.loader.load(find("ascii_test_1.txt")) 
    1622        self.f1 = self.f1_list[0] 
    17         self.f2_list = self.loader.load("ascii_test_2.txt") 
     23        self.f2_list = self.loader.load(find("ascii_test_2.txt")) 
    1824        self.f2 = self.f2_list[0] 
    19         self.f3_list = self.loader.load("ascii_test_3.txt") 
     25        self.f3_list = self.loader.load(find("ascii_test_3.txt")) 
    2026        self.f3 = self.f3_list[0] 
    21         self.f4_list = self.loader.load("ascii_test_4.abs") 
     27        self.f4_list = self.loader.load(find("ascii_test_4.abs")) 
    2228        self.f4 = self.f4_list[0] 
    23         self.f5_list = self.loader.load("ascii_test_5.txt") 
     29        self.f5_list = self.loader.load(find("ascii_test_5.txt")) 
    2430        self.f5 = self.f5_list[0] 
    2531 
     
    99105        f = None 
    100106        try: 
    101             f = self.loader.load("ascii_test_6.txt") 
     107            f = self.loader.load(find("ascii_test_6.txt")) 
    102108        # The length of the data is 5 
    103109        except: 
  • test/sasdataloader/test/utest_averaging.py

    rfe15198 rf53d684  
    1313                                                  SlabY, get_q, 
    1414                                                  reader2D_converter) 
     15 
     16 
     17def find(filename): 
     18    return os.path.join(os.path.dirname(__file__), filename) 
    1519 
    1620 
     
    102106 
    103107    def setUp(self): 
    104         filepath = os.path.join(os.path.dirname( 
    105             os.path.realpath(__file__)), 'MAR07232_rest.h5') 
     108        filepath = find('MAR07232_rest.h5') 
    106109        self.data_list = Loader().load(filepath) 
    107110        self.data = self.data_list[0] 
     
    118121 
    119122        o = r(self.data) 
    120         filepath = os.path.join(os.path.dirname( 
    121             os.path.realpath(__file__)), 'ring_testdata.txt') 
     123        filepath = find('ring_testdata.txt') 
    122124        answer_list = Loader().load(filepath) 
    123125        answer = answer_list[0] 
     
    140142        o = r(self.data) 
    141143 
    142         filepath = os.path.join(os.path.dirname( 
    143             os.path.realpath(__file__)), 'avg_testdata.txt') 
     144        filepath = find('avg_testdata.txt') 
    144145        answer = Loader().load(filepath)[0] 
    145146        for i in range(r.nbins_phi): 
     
    176177        o = r(self.data) 
    177178 
    178         filepath = os.path.join(os.path.dirname( 
    179             os.path.realpath(__file__)), 'slabx_testdata.txt') 
     179        filepath = find('slabx_testdata.txt') 
    180180        answer = Loader().load(filepath)[0] 
    181181        for i in range(len(o.x)): 
     
    195195        o = r(self.data) 
    196196 
    197         filepath = os.path.join(os.path.dirname( 
    198             os.path.realpath(__file__)), 'slaby_testdata.txt') 
     197        filepath = find('slaby_testdata.txt') 
    199198        answer = Loader().load(filepath)[0] 
    200199        for i in range(len(o.x)): 
     
    222221        o = r(self.data) 
    223222 
    224         filepath = os.path.join(os.path.dirname( 
    225             os.path.realpath(__file__)), 'ring_testdata.txt') 
     223        filepath = find('ring_testdata.txt') 
    226224        answer = Loader().load(filepath)[0] 
    227225        for i in range(len(o.x)): 
     
    240238        o = r(self.data) 
    241239 
    242         filepath = os.path.join(os.path.dirname( 
    243             os.path.realpath(__file__)), 'sectorphi_testdata.txt') 
     240        filepath = find('sectorphi_testdata.txt') 
    244241        answer = Loader().load(filepath)[0] 
    245242        for i in range(len(o.x)): 
     
    258255        o = r(self.data) 
    259256 
    260         filepath = os.path.join(os.path.dirname( 
    261             os.path.realpath(__file__)), 'sectorq_testdata.txt') 
     257        filepath = find('sectorq_testdata.txt') 
    262258        answer = Loader().load(filepath)[0] 
    263259        for i in range(len(o.x)): 
  • test/sasdataloader/test/utest_cansas.py

    rf00072f rf53d684  
    3131CANSAS_NS = CansasConstants.CANSAS_NS 
    3232 
     33 
     34def find(filename): 
     35    return os.path.join(os.path.dirname(__file__), filename) 
     36 
     37 
    3338class cansas_reader_xml(unittest.TestCase): 
    3439 
    3540    def setUp(self): 
    3641        self.loader = Loader() 
    37         self.xml_valid = "cansas_test_modified.xml" 
    38         self.xml_invalid = "cansas_test.xml" 
    39         self.cansas1d_badunits = "cansas1d_badunits.xml" 
    40         self.cansas1d = "cansas1d.xml" 
    41         self.cansas1d_slit = "cansas1d_slit.xml" 
    42         self.cansas1d_units = "cansas1d_units.xml" 
    43         self.cansas1d_notitle = "cansas1d_notitle.xml" 
    44         self.isis_1_0 = "ISIS_1_0.xml" 
    45         self.isis_1_1 = "ISIS_1_1.xml" 
    46         self.isis_1_1_notrans = "ISIS_1_1_notrans.xml" 
    47         self.isis_1_1_doubletrans = "ISIS_1_1_doubletrans.xml" 
    48         self.schema_1_0 = "cansas1d_v1_0.xsd" 
    49         self.schema_1_1 = "cansas1d_v1_1.xsd" 
    50         self.write_1_0_filename = "isis_1_0_write_test.xml" 
    51         self.write_1_1_filename = "isis_1_1_write_test.xml" 
     42        self.xml_valid = find("cansas_test_modified.xml") 
     43        self.xml_invalid = find("cansas_test.xml") 
     44        self.cansas1d_badunits = find("cansas1d_badunits.xml") 
     45        self.cansas1d = find("cansas1d.xml") 
     46        self.cansas1d_slit = find("cansas1d_slit.xml") 
     47        self.cansas1d_units = find("cansas1d_units.xml") 
     48        self.cansas1d_notitle = find("cansas1d_notitle.xml") 
     49        self.isis_1_0 = find("ISIS_1_0.xml") 
     50        self.isis_1_1 = find("ISIS_1_1.xml") 
     51        self.isis_1_1_notrans = find("ISIS_1_1_notrans.xml") 
     52        self.isis_1_1_doubletrans = find("ISIS_1_1_doubletrans.xml") 
     53        self.schema_1_0 = find("cansas1d_v1_0.xsd") 
     54        self.schema_1_1 = find("cansas1d_v1_1.xsd") 
     55        self.write_1_0_filename = find("isis_1_0_write_test.xml") 
     56        self.write_1_1_filename = find("isis_1_1_write_test.xml") 
    5257 
    5358    def get_number_of_entries(self, dictionary, name, i): 
     
    254259    def setUp(self): 
    255260        self.loader = Loader() 
    256         self.datafile_basic = "simpleexamplefile.h5" 
    257         self.datafile_multiplesasentry = "cansas_1Dand2D_samedatafile.h5" 
    258         self.datafile_multiplesasdata = "cansas_1Dand2D_samesasentry.h5" 
    259         self.datafile_multiplesasdata_multiplesasentry = "cansas_1Dand2D_multiplesasentry_multiplesasdata.h5" 
     261        self.datafile_basic = find("simpleexamplefile.h5") 
     262        self.datafile_multiplesasentry = find("cansas_1Dand2D_samedatafile.h5") 
     263        self.datafile_multiplesasdata = find("cansas_1Dand2D_samesasentry.h5") 
     264        self.datafile_multiplesasdata_multiplesasentry = find("cansas_1Dand2D_multiplesasentry_multiplesasdata.h5") 
    260265 
    261266    def test_real_data(self): 
  • test/sasdataloader/test/utest_extension_registry.py

    rdcb91cf rf53d684  
    1313logger = logging.getLogger(__name__) 
    1414 
     15 
     16def find(filename): 
     17    return os.path.join(os.path.dirname(__file__), filename) 
     18 
     19 
    1520class ExtensionRegistryTests(unittest.TestCase): 
    1621 
    1722    def setUp(self): 
    18         self.valid_file = "valid_cansas_xml.xml" 
    19         self.valid_file_wrong_known_ext = "valid_cansas_xml.txt" 
    20         self.valid_file_wrong_unknown_ext = "valid_cansas_xml.xyz" 
     23        self.valid_file = find("valid_cansas_xml.xml") 
     24        self.valid_file_wrong_known_ext = find("valid_cansas_xml.txt") 
     25        self.valid_file_wrong_unknown_ext = find("valid_cansas_xml.xyz") 
    2126        shutil.copyfile(self.valid_file, self.valid_file_wrong_known_ext) 
    2227        shutil.copyfile(self.valid_file, self.valid_file_wrong_unknown_ext) 
    23         self.invalid_file = "cansas1d_notitle.xml" 
     28        self.invalid_file = find("cansas1d_notitle.xml") 
    2429 
    2530        self.loader = Loader() 
  • test/sasdataloader/test/utest_generic_file_reader_class.py

    r3648cbf rf53d684  
    1414 
    1515 
     16def find(filename): 
     17    return os.path.join(os.path.dirname(__file__), filename) 
     18 
     19 
    1620class GenericFileReaderTests(unittest.TestCase): 
    1721 
    1822    def setUp(self): 
    1923        self.reader = TestFileReader() 
    20         self.bad_file = "ACB123.txt" 
    21         self.good_file = "123ABC.txt" 
     24        self.bad_file = find("ACB123.txt") 
     25        self.good_file = find("123ABC.txt") 
    2226 
    2327    def test_bad_file_path(self): 
  • test/sasdataloader/test/utest_red2d_reader.py

    rfe15198 rf53d684  
    1010import os.path 
    1111 
     12 
     13def find(filename): 
     14    return os.path.join(os.path.dirname(__file__), filename) 
     15 
     16 
    1217class abs_reader(unittest.TestCase): 
    1318 
    1419    def setUp(self): 
    1520        self.loader = Loader() 
    16         self.data_list = self.loader.load("exp18_14_igor_2dqxqy.dat") 
     21        self.data_list = self.loader.load(find("exp18_14_igor_2dqxqy.dat")) 
    1722 
    1823    def test_checkdata(self): 
  • test/sasdataloader/test/utest_sesans.py

    rfe15198 rf53d684  
    33""" 
    44 
     5import os.path 
    56import unittest 
    67from sas.sascalc.dataloader.loader_exceptions import FileContentsException,\ 
     
    89from sas.sascalc.dataloader.readers.sesans_reader import Reader 
    910from sas.sascalc.dataloader.loader import  Loader 
     11 
     12 
     13def find(filename): 
     14    return os.path.join(os.path.dirname(__file__), filename) 
     15 
    1016 
    1117class sesans_reader(unittest.TestCase): 
     
    1925            Test .SES in the full loader to make sure that the file type is correctly accepted 
    2026        """ 
    21         file = Loader().load("sesans_examples/sphere2micron.ses") 
     27        file = Loader().load(find("sesans_examples/sphere2micron.ses")) 
    2228        f = file[0] 
    2329        # self.assertEqual(f, 5) 
     
    3844            Test .SES loading on a TOF dataset 
    3945        """ 
    40         file = self.loader("sesans_examples/sphere_isis.ses") 
     46        file = self.loader(find("sesans_examples/sphere_isis.ses")) 
    4147        f = file[0] 
    4248        self.assertEqual(len(file), 1) 
     
    5662            FileContentsException, 
    5763            self.loader, 
    58             "sesans_examples/sesans_no_data.ses") 
     64            find("sesans_examples/sesans_no_data.ses")) 
    5965 
    6066    def test_sesans_no_spin_echo_unit(self): 
     
    6571            FileContentsException, 
    6672            self.loader, 
    67             "sesans_examples/no_spin_echo_unit.ses") 
     73            find("sesans_examples/no_spin_echo_unit.ses")) 
    6874 
    6975    def test_sesans_future_version(self): 
     
    7480            FileContentsException, 
    7581            self.loader, 
    76             "sesans_examples/next_gen.ses") 
     82            find("sesans_examples/next_gen.ses")) 
    7783 
    7884    def test_sesans_mandatory_headers(self): 
     
    8389            FileContentsException, 
    8490            self.loader, 
    85             "sesans_examples/no_wavelength.ses") 
     91            find("sesans_examples/no_wavelength.ses")) 
    8692 
    8793    def test_sesans_columns_match_headers(self): 
     
    9298            FileContentsException, 
    9399            self.loader, 
    94             "sesans_examples/too_many_headers.ses") 
     100            find("sesans_examples/too_many_headers.ses")) 
    95101 
    96102if __name__ == "__main__": 
  • test/sasguiframe/test/utest_manipulations.py

    rc0ca2e3d rf53d684  
    1515 
    1616 
     17def find(filename): 
     18    return os.path.join(os.path.dirname(__file__), filename) 
     19 
     20 
    1721class DataInfoTests(unittest.TestCase): 
    1822 
    1923    def setUp(self): 
    20         data = Loader().load("cansas1d.xml") 
     24        data = Loader().load(find("cansas1d.xml")) 
    2125        self.data = data[0] 
    2226 
     
    3539 
    3640    def setUp(self): 
    37         data = Loader().load("cansas1d.xml") 
     41        data = Loader().load(find("cansas1d.xml")) 
    3842        self.data = data[0] 
    3943 
  • test/sasinvariant/test/utest_data_handling.py

    r9a5097c rf53d684  
    88copyright 2010, University of Tennessee 
    99""" 
     10 
     11import os.path 
    1012import unittest 
    1113import math 
     
    1517 
    1618from sas.sascalc.invariant import invariant 
    17      
     19 
     20 
     21def find(filename): 
     22    return os.path.join(os.path.dirname(__file__), filename) 
     23 
     24 
    1825class TestLinearFit(unittest.TestCase): 
    1926    """ 
     
    94101    """ 
    95102    def setUp(self): 
    96         data = Loader().load("latex_smeared_slit.xml") 
     103        data = Loader().load(find("latex_smeared_slit.xml")) 
    97104        self.data = data[0] 
    98105        self.data.dxl = None 
     
    676683            value  = math.fabs(test_y[i]- temp[i])/temp[i] 
    677684            self.assert_(value < 0.001)                 
    678                        
  • test/sasinvariant/test/utest_use_cases.py

    rb09095a rf53d684  
    44""" 
    55#TODO: there's no test for smeared extrapolation 
     6 
     7import os.path 
    68import unittest 
    79from sas.sascalc.dataloader.loader import  Loader 
     
    911 
    1012 
     13def find(filename): 
     14    return os.path.join(os.path.dirname(__file__), filename) 
     15 
     16 
    1117class Data1D: 
    1218    pass 
     
    1824    """ 
    1925    def setUp(self): 
    20         self.data_list = Loader().load("linefittest.txt") 
     26        self.data_list = Loader().load(find("linefittest.txt")) 
    2127        self.data = self.data_list[0] 
    2228 
     
    5763    """ 
    5864    def setUp(self): 
    59         self.data_list = Loader().load("linefittest_no_weight.txt") 
     65        self.data_list = Loader().load(find("linefittest_no_weight.txt")) 
    6066        self.data = self.data_list[0] 
    6167 
     
    96102    """ 
    97103    def setUp(self): 
    98         self.data_list = Loader().load("PolySpheres.txt") 
     104        self.data_list = Loader().load(find("PolySpheres.txt")) 
    99105        self.data = self.data_list[0] 
    100106 
     
    278284    def setUp(self): 
    279285        # data with smear info 
    280         list = Loader().load("latex_smeared.xml") 
     286        list = Loader().load(find("latex_smeared.xml")) 
    281287        self.data_q_smear = list[0] 
    282288 
Note: See TracChangeset for help on using the changeset viewer.