Changeset 416609b in sasmodels


Ignore:
Timestamp:
Apr 8, 2016 12:14:58 PM (9 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:
3a45c2c, a936688, 1ca1fd9
Parents:
65279d8
Message:

use np.sqrt rather than math.sqrt for vector functions

Location:
sasmodels/models
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/elliptical_cylinder.py

    rec45c4f r416609b  
    8181""" 
    8282 
    83 import math 
    84 from numpy import pi, inf 
     83from numpy import pi, inf, sqrt 
    8584 
    8685name = "elliptical_cylinder" 
     
    117116        @param length: Length of the cylinder 
    118117    """ 
    119     radius = math.sqrt(r_minor * r_minor * axis_ratio) 
     118    radius = sqrt(r_minor * r_minor * axis_ratio) 
    120119    ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) 
    121120    return 0.5 * (ddd) ** (1. / 3.) 
  • sasmodels/models/line.py

    rec45c4f r416609b  
    99.. math:: 
    1010 
    11     I(q) = A + B \cdot q 
     11    I(q) = \text{scale} (A + B \cdot q) + \text{background} 
    1212 
    1313.. note:: 
     
    1515 
    1616.. math:: 
    17     I(q) = I(qx) \cdot I(qy) 
     17    I(q) = \text{scale} (I(qx) \cdot I(qy)) + \text{background} 
    1818 
    1919References 
     
    5151    """ 
    5252    inten = intercept + slope*q 
    53     # TODO: In SasView code additional formula for list has been specified. 
    54     # if inten(x) = intercept + slope*x: 
    55     # then if q is a list, Iq=inten(x[0]*math.cos(x[1]))*inten(x[0]*math.sin(x[1])) 
    5653    return inten 
    5754 
     
    6562    :return:     2D-Intensity 
    6663    """ 
    67     # TODO: SasView documention lists 2D intensity as Iq(qx)*Iq(qy) but code says: 
    68     # return self._line(x[1]) 
     64    # TODO: SasView documents 2D intensity as Iq(qx)*Iq(qy), but returns Iq(qy) 
     65    # Note: SasView.run([r, theta]) does return Iq(qx)*Iq(qy) 
    6966    return Iq(qx, *args)*Iq(qy, *args) 
    7067 
    7168Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values 
    7269 
    73 demo = dict(scale=1.0, background=0, intercept=1.0, slope=1.0) 
    74  
    7570tests = [ 
    76  
    77     [{'intercept':   1.0, 
    78       'slope': 1.0, 
    79      }, 1.0, 2.001], 
    80  
    81     [{'intercept':   1.0, 
    82       'slope': 1.0, 
    83      }, 0.0, 1.001], 
    84  
    85     [{'intercept':   1.0, 
    86       'slope': 1.0, 
    87      }, 0.4, 1.401], 
    88  
    89     [{'intercept':   1.0, 
    90       'slope': 1.0, 
    91      }, 1.3, 2.301], 
    92  
    93     [{'intercept':   1.0, 
    94       'slope': 1.0, 
    95      }, 0.5, 1.501], 
    96  
    97     [{'intercept':   1.0, 
    98       'slope': 1.0, 
    99      }, [0.4, 0.5], [1.401, 1.501]], 
    100  
    101     [{'intercept':   1.0, 
    102       'slope': 1.0, 
    103       'background': 0.0, 
    104      }, (1.3, 1.57), 5.911], 
     71    [{'intercept': 1.0, 'slope': 1.0, }, 1.0, 2.001], 
     72    [{'intercept': 1.0, 'slope': 1.0, }, 0.0, 1.001], 
     73    [{'intercept': 1.0, 'slope': 1.0, }, 0.4, 1.401], 
     74    [{'intercept': 1.0, 'slope': 1.0, }, 1.3, 2.301], 
     75    [{'intercept': 1.0, 'slope': 1.0, }, 0.5, 1.501], 
     76    [{'intercept': 1.0, 'slope': 1.0, }, [0.4, 0.5], [1.401, 1.501]], 
     77    [{'intercept': 1.0, 'slope': 1.0, 'background': 0.0, }, (1.3, 1.57), 5.911], 
    10578] 
  • sasmodels/models/onion.py

    rec45c4f r416609b  
    385385    # "A[1]": 0, "A[2]": -1, "A[3]": 1e-4, "A[4]": 1, 
    386386    } 
     387 
  • sasmodels/models/polymer_excl_volume.py

    rec45c4f r416609b  
    9393""" 
    9494 
    95 from math import sqrt 
    96 from numpy import inf, power 
     95from numpy import inf, power, sqrt 
    9796from scipy.special import gammainc, gamma 
    9897 
     
    114113 
    115114 
    116 def Iq(q, 
    117        rg=60.0, 
    118        porod_exp=3.0): 
     115def Iq(q, rg=60.0, porod_exp=3.0): 
    119116    """ 
    120117    :param q:         Input q-value (float or [float, float]) 
     
    144141    :return:     2D-Intensity 
    145142    """ 
    146  
    147143    return Iq(sqrt(qx**2 + qy**2), *args) 
    148144 
    149145Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values 
    150146 
    151  
    152 demo = dict(scale=1, background=0.0, 
    153             rg=60.0, 
    154             porod_exp=3.0) 
    155147 
    156148tests = [ 
  • sasmodels/models/two_lorentzian.py

    rec45c4f r416609b  
    3434""" 
    3535 
    36 from math import sqrt 
    37 from numpy import inf, power 
     36from numpy import inf, power, sqrt 
    3837 
    3938name = "two_lorentzian" 
Note: See TracChangeset for help on using the changeset viewer.