Changeset 13ed84c in sasmodels


Ignore:
Timestamp:
Feb 4, 2016 5:31:28 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
199d40d
Parents:
5054e80
Message:

set single=False on all models that fail the single precision tests

Location:
sasmodels
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    r5c962df r13ed84c  
    100100                test_name = "Model: %s, Kernel: OpenCL"%model_name 
    101101                test_method_name = "test_%s_opencl" % model_name 
     102                # Using dtype=None so that the models that are only 
     103                # correct for double precision are not tested using 
     104                # single precision.  The choice is determined by the 
     105                # presence of *single=False* in the model file. 
    102106                test = ModelTestCase(test_name, model_definition, 
    103107                                     test_method_name, 
    104                                      platform="ocl", dtype='single') 
     108                                     platform="ocl", dtype=None) 
    105109                #print("defining", test_name) 
    106110                suite.addTest(test) 
     
    157161                    ## values an error.  Only do so for the "dll" tests 
    158162                    ## to reduce noise from both opencl and dll, and because 
    159                     ## python kernels us 
     163                    ## python kernels use platform="dll". 
    160164                    #raise Exception("No test cases provided") 
    161165                    pass 
     
    198202                                    'invalid f(%s): %s' % (xi, actual_yi)) 
    199203                else: 
    200                     err = abs(yi - actual_yi) 
    201                     nrm = abs(yi) 
    202                     self.assertLess(err * 10**5, nrm, 
     204                    self.assertTrue(is_near(yi, actual_yi, 5), 
    203205                                    'f(%s); expected:%s; actual:%s' 
    204206                                    % (xi, yi, actual_yi)) 
     
    206208    return ModelTestCase 
    207209 
    208  
     210def is_near(target, actual, digits=5): 
     211    """ 
     212    Returns true if *actual* is within *digits* significant digits of *target*. 
     213    """ 
     214    import math 
     215    shift = 10**math.ceil(math.log10(abs(target))) 
     216    return abs(target-actual)/shift < 1.5*10**-digits 
    209217 
    210218def main(): 
     
    217225 
    218226    models = sys.argv[1:] 
     227    if models and models[0] == '-v': 
     228        verbosity = 2 
     229        models = models[1:] 
     230    else: 
     231        verbosity = 1 
    219232    if models and models[0] == 'opencl': 
    220233        if not HAVE_OPENCL: 
     
    235248        print("""\ 
    236249usage: 
    237   python -m sasmodels.model_test [opencl|dll|opencl_and_dll] model1 model2 ... 
     250  python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 
     251 
     252If -v is included on the 
     253If neither opencl nor dll is specified, then models will be tested with 
     254both opencl and dll; the compute target is ignored for pure python models. 
    238255 
    239256If model1 is 'all', then all except the remaining models will be tested. 
    240 If no compute target is specified, then models will be tested with both opencl 
    241 and dll; the compute target is ignored for pure python models.""") 
     257 
     258""") 
    242259 
    243260        return 1 
    244261 
    245262    #runner = unittest.TextTestRunner() 
    246     runner = xmlrunner.XMLTestRunner(output='logs') 
     263    runner = xmlrunner.XMLTestRunner(output='logs', verbosity=verbosity) 
    247264    result = runner.run(make_suite(loaders, models)) 
    248265    return 1 if result.failures or result.errors else 0 
  • sasmodels/models/HayterMSAsq.py

    r7f47777 r13ed84c  
    5656        parameters used in P(Q). 
    5757""" 
     58single = False  # double precision only for now 
    5859#             [ "name", "units", default, [lower, upper], "type", "description" ], 
    5960parameters = [["effect_radius", "Ang", 20.75, [0, inf], "volume", 
  • sasmodels/models/bcc.py

    rdcdf29d r13ed84c  
    116116    """ 
    117117category = "shape:paracrystal" 
     118 
     119single = False 
     120 
    118121# pylint: disable=bad-whitespace, line-too-long 
    119122#             ["name", "units", default, [lower, upper], "type","description" ], 
  • sasmodels/models/core_shell_ellipsoid.py

    r81dd619 r13ed84c  
    9696category = "shape:ellipsoid" 
    9797 
     98single = False  # TODO: maybe using sph_j1c inside gfn would help? 
    9899# pylint: disable=bad-whitespace, line-too-long 
    99100#             ["name", "units", default, [lower, upper], "type", "description"], 
  • sasmodels/models/fcc.py

    reb69cce r13ed84c  
    112112category = "shape:paracrystal" 
    113113 
     114single = False 
     115 
    114116#             ["name", "units", default, [lower, upper], "type","description"], 
    115117parameters = [["dnn", "Ang", 220, [-inf, inf], "", "Nearest neighbour distance"], 
  • sasmodels/models/flexible_cylinder.py

    r168052c r13ed84c  
    7878 
    7979category = "shape:cylinder" 
     80single = False 
    8081 
    8182# pylint: disable=bad-whitespace, line-too-long 
  • sasmodels/models/flexible_cylinder_ex.py

    r504abee r13ed84c  
    9898        during model fitting. 
    9999        """ 
     100single = False 
    100101 
    101102category = "shape:cylinder" 
  • sasmodels/models/gaussian_peak.py

    reb69cce r13ed84c  
    4242category = "shape-independent" 
    4343 
     44single = False 
    4445#             ["name", "units", default, [lower, upper], "type","description"], 
    4546parameters = [["q0", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], 
  • sasmodels/models/hardsphere.py

    r7f47777 r13ed84c  
    5555               "volume fraction of hard spheres"], 
    5656             ] 
     57single = False 
    5758 
    5859# No volume normalization despite having a volume parameter 
  • sasmodels/models/lamellarCaille.py

    r7f47777 r13ed84c  
    8787category = "shape:lamellae" 
    8888 
     89single = False 
     90 
    8991#             ["name", "units", default, [lower, upper], "type","description"], 
    9092parameters = [["thickness", "Ang",  30.0, [0, inf], "volume", "sheet thickness"], 
  • sasmodels/models/lamellarCailleHG.py

    r7f47777 r13ed84c  
    9191category = "shape:lamellae" 
    9292 
     93single = False 
    9394parameters = [ 
    9495    #   [ "name", "units", default, [lower, upper], "type", 
  • sasmodels/models/lamellarPC.py

    r7f47777 r13ed84c  
    111111category = "shape:lamellae" 
    112112 
     113single = False 
     114 
    113115#             ["name", "units", default, [lower, upper], "type","description"], 
    114116parameters = [["thickness", "Ang", 33.0, [0, inf], "volume", 
  • sasmodels/models/lib/gfn.c

    r81dd619 r13ed84c  
    66//       <OBLATE ELLIPSOID> 
    77// function gfn4 for oblate ellipsoids 
    8 double 
     8static double 
    99gfn4(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq) 
    1010{ 
  • sasmodels/models/lib/wrc_cyl.c

    r504abee r13ed84c  
    379379} 
    380380 
     381double Sk_WR(double q, double L, double b); 
    381382double Sk_WR(double q, double L, double b) 
    382383{ 
  • sasmodels/models/rpa.c

    r82c299f r13ed84c  
    205205  const double Kbb = 0.0; 
    206206  const double Kcc = 0.0; 
    207   const double Kdd = 0.0; 
     207  //const double Kdd = 0.0; 
    208208  const double Zaa = Kaa - Kad - Kad; 
    209209  const double Zab = Kab - Kad - Kbd; 
     
    278278  const double Q12 = (-Mab*Mcc + Mac*Mcb)/DenQ; 
    279279  const double Q13 = ( Mab*Mbc - Mac*Mbb)/DenQ; 
    280   const double Q21 = (-Mba*Mcc + Mbc*Mca)/DenQ; 
     280  //const double Q21 = (-Mba*Mcc + Mbc*Mca)/DenQ; 
    281281  const double Q22 = ( Maa*Mcc - Mac*Mca)/DenQ; 
    282282  const double Q23 = (-Maa*Mbc + Mac*Mba)/DenQ; 
    283   const double Q31 = ( Mba*Mcb - Mbb*Mca)/DenQ; 
    284   const double Q32 = (-Maa*Mcb + Mab*Mca)/DenQ; 
     283  //const double Q31 = ( Mba*Mcb - Mbb*Mca)/DenQ; 
     284  //const double Q32 = (-Maa*Mcb + Mab*Mca)/DenQ; 
    285285  const double Q33 = ( Maa*Mbb - Mab*Mba)/DenQ; 
    286286 
  • sasmodels/models/star_polymer.py

    r168052c r13ed84c  
    5555        """ 
    5656category = "shape-independent" 
     57single = False 
    5758# pylint: disable=bad-whitespace, line-too-long 
    5859#             ["name", "units", default, [lower, upper], "type","description"], 
  • sasmodels/models/stickyhardsphere.py

    r7f47777 r13ed84c  
    8585category = "structure-factor" 
    8686 
     87single = False 
    8788#             ["name", "units", default, [lower, upper], "type","description"], 
    8889parameters = [ 
Note: See TracChangeset for help on using the changeset viewer.