Changeset 26e4a24 in sasview


Ignore:
Timestamp:
Aug 7, 2009 11:24:39 AM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ecc58e72
Parents:
58c6ba6
Message:

reverse previous unittest

Location:
sansmodels/src/sans/models
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/BaseComponent.py

    r83a25da r26e4a24  
    7272        q_array = numpy.asarray(qdist) 
    7373        iq_array = numpy.zeros(len(q_array)) 
    74         for i in len(q_array): 
     74        for i in xrange(len(q_array)): 
    7575            iq_array[i] = self.runXY(q_array[i]) 
    7676             
  • sansmodels/src/sans/models/DebyeModel.py

    rd37ba31 r26e4a24  
    6464        # an exception 
    6565        y = (x * self.params['rg'])**2.0 
    66         if y == 0: 
    67             return 1e+16 
     66        if x == 0: 
     67            D=1 
    6868        else: 
    69             D = 2.0*( math.exp(-y) + y -1.0 )/y**2.0 
    70             return self.params['scale']* D + self.params['background'] 
     69           D = 2.0*( math.exp(-y) + y -1.0 )/y**2.0 
     70        return self.params['scale']* D + self.params['background'] 
    7171    
    7272    def run(self, x = 0.0): 
  • sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h

    r1ed3834 r26e4a24  
    77 * [DESCRIPTION] = Please see details... 
    88 * [FIXED]= <text> cyl_phi.width; 
    9  * cyl_theta.width; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text> 
     9 * cyl_theta.width; cyl_psi.width; length.width; r_minor.width; r_ratio.width  
     10 *</text> 
    1011 * [ORIENTATION_PARAMS]= cyl_phi; cyl_theta; cyl_psi;  cyl_phi.width; cyl_theta.width; cyl_psi.width 
    1112 * */ 
  • sansmodels/src/sans/models/c_models/classTemplate.txt

    r8344c50 r26e4a24  
    149149    return PyArray_Return(result);  
    150150 } 
    151 /** 
    152  * Function to call to evaluate model 
    153  * @param args: input numpy array  [q[],phi[]] 
    154  * @return: numpy array object  
    155  */ 
    156 static PyObject * evaluateTwoDim( [CMODEL]* model,  
    157                               PyArrayObject *q, PyArrayObject *phi) 
    158  { 
    159     PyArrayObject *result; 
    160     //check validity of input vectors 
    161     if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 
    162         || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 
    163         || phi->dimensions[0] != q->dimensions[0]){ 
    164       
    165         //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 
    166         PyErr_SetString(PyExc_ValueError ,"wrong input");  
    167         return NULL; 
    168     } 
    169         result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 
    170  
    171         if (result == NULL){ 
    172             const char * message= "Could not create result "; 
    173         PyErr_SetString(PyExc_RuntimeError , message); 
    174             return NULL; 
    175         } 
    176          
    177     for (int i = 0; i < q->dimensions[0]; i++) { 
    178       double q_value = *(double *)(q->data + i*q->strides[0]); 
    179       double phi_value = *(double *)(phi->data + i*phi->strides[0]); 
    180       double *result_value = (double *)(result->data + i*result->strides[0]); 
    181       if (q_value == 0) 
    182           *result_value = 0.0; 
    183       else 
    184           *result_value = model->evaluate_rphi(q_value, phi_value); 
    185     } 
    186     return PyArray_Return(result);  
    187  } 
     151 
    188152 /** 
    189153 * Function to call to evaluate model 
  • sansmodels/src/sans/models/test/utest_dispersity.py

    reba9885 r26e4a24  
    5757         
    5858        new_model = self.model.clone() 
    59         print "gaussian",self.model.run(0.001) 
    6059        self.assertAlmostEqual(new_model.run(0.001), 4723.32213339, 3) 
    6160        self.assertAlmostEqual(new_model.runXY([0.001,0.001]), 4743.56, 2) 
    62          
    63     def test_schulz_zero(self): 
    64         from sans.models.dispersion_models import SchulzDispersion 
    65         disp = SchulzDispersion() 
    66         self.model.set_dispersion('radius', disp) 
    67         self.model.dispersion['radius']['width'] = 5.0 
    68         #self.model.dispersion['radius']['width'] = 0.0 
    69         self.model.dispersion['radius']['npts'] = 100 
    70         #self.model.setParam('scale', 1.0) 
    71         self.model.setParam('scale', 10.0) 
    72         print "schulz",self.model.run(0.001), self.model.dispersion 
    73         self.assertAlmostEqual(self.model.run(0.001), 450.355, 3) 
    74         self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3) 
    75          
    76     def test_lognormal_zero(self): 
    77         from sans.models.dispersion_models import LogNormalDispersion 
    78         disp = LogNormalDispersion() 
    79         self.model.set_dispersion('radius', disp) 
    80         self.model.dispersion['radius']['width'] = 5.0 
    81         #self.model.dispersion['radius']['width'] = 0.0 
    82         self.model.dispersion['radius']['npts'] = 100 
    83         #self.model.setParam('scale', 1.0) 
    84         self.model.setParam('scale', 10.0) 
    85         print "model dispersion",self.model.dispersion 
    86         print "lognormal",self.model.run(0.001) 
    87         self.assertAlmostEqual(self.model.run(0.001), 450.355, 3) 
    88         self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3) 
    8961         
    9062    def test_gaussian_zero(self): 
  • sansmodels/src/sans/models/test/utest_models.py

    reba9885 r26e4a24  
    2424    def test1D(self): 
    2525        """ Test 1D model for a sphere """ 
    26         self.assertAlmostEqual(self.comp.run(1.0), 5.6387e-5, 4) 
     26        self.assertAlmostEqual(self.comp.run(1.0), 56.3878, 4) 
    2727         
    2828    def test1D_2(self): 
    2929        """ Test 2D model for a sphere """ 
    30         self.assertAlmostEqual(self.comp.run([1.0, 1.3]), 5.63878e-5, 4) 
     30        self.assertAlmostEqual(self.comp.run([1.0, 1.3]), 56.3878, 4) 
    3131 
    3232class TestCyl(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.