Changeset e65c3ba in sasmodels for sasmodels/special.py


Ignore:
Timestamp:
Nov 28, 2017 6:09:34 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
32398dc
Parents:
110f69c
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/special.py

    r110f69c re65c3ba  
    192192 
    193193""" 
     194# pylint: disable=unused-import 
     195 
    194196import numpy as np 
    195 import scipy.special 
    196197 
    197198# Functions to add to our standard set 
     
    199200 
    200201# C99 standard math library functions 
    201 M_PI, M_PI_2, M_PI_4, M_SQRT1_2, M_E = np.pi, np.pi/2, np.pi/4, np.sqrt(0.5), np.e 
    202202from numpy import exp, log, power as pow, expm1, sqrt 
    203203from numpy import sin, cos, tan, arcsin as asin, arccos as acos, arctan as atan 
     
    207207from numpy import NAN, inf as INFINITY 
    208208 
    209 # erf, erfc, tgamma, lgamma  **do not use** 
    210  
    211 # non-standard constants and functions 
    212 M_PI_180, M_4PI_3 = M_PI/180, 4*M_PI/3 
    213  
    214 # can't do SINCOS in python; use "s, c = SINCOS(x)" instead 
    215 def SINCOS(x): return sin(x), cos(x) 
    216  
    217 def square(x): return x*x 
    218  
    219 def cube(x): return x*x*x 
    220  
    221 from numpy import sinc as _sinc 
    222 def sas_sinx_x(x): return _sinc(x/M_PI) 
    223 def powr(x, y): return x**y 
    224 def pown(x, n): return x**n 
    225  
    226 FLOAT_SIZE = 8 
    227  
    228 def polevl(x, c, n): return np.polyval(c[:n], x) 
    229 def p1evl(x, c, n): return np.polyval(np.hstack(([1.], c))[:n], x) 
    230  
    231209from scipy.special import gamma as sas_gamma 
    232210from scipy.special import erf as sas_erf 
     
    236214from scipy.special import jn as sas_JN 
    237215 
     216# erf, erfc, tgamma, lgamma  **do not use** 
     217 
     218# C99 standard math constants 
     219M_PI, M_PI_2, M_PI_4, M_SQRT1_2, M_E = np.pi, np.pi/2, np.pi/4, np.sqrt(0.5), np.e 
     220 
     221# non-standard constants 
     222M_PI_180, M_4PI_3 = M_PI/180, 4*M_PI/3 
     223 
     224# can't do SINCOS in python; use "s, c = SINCOS(x)" instead 
     225def SINCOS(x): 
     226    """return sin(x), cos(x)""" 
     227    return sin(x), cos(x) 
     228 
     229def square(x): 
     230    """return x^2""" 
     231    return x*x 
     232 
     233def cube(x): 
     234    """return x^3""" 
     235    return x*x*x 
     236 
     237def sas_sinx_x(x): 
     238    """return sin(x)/x""" 
     239    from numpy import sinc as _sinc 
     240    return _sinc(x/M_PI) 
     241 
     242def powr(x, y): 
     243    """return x^y for x>0""" 
     244    return x**y 
     245def pown(x, n): 
     246    """return x^n for n integer""" 
     247    return x**n 
     248 
     249FLOAT_SIZE = 8 
     250 
     251def polevl(x, c, n): 
     252    """return p(x) for polynomial p of degree n-1 with coefficients c""" 
     253    return np.polyval(c[:n], x) 
     254 
     255def p1evl(x, c, n): 
     256    """return x^n + p(x) for polynomial p of degree n-1 with coefficients c""" 
     257    return np.polyval(np.hstack(([1.], c))[:n], x) 
     258 
    238259def sas_Si(x): 
    239     return scipy.special.sici(x)[0] 
     260    """return Si(x)""" 
     261    from scipy.special import sici 
     262    return sici(x)[0] 
    240263 
    241264def sas_j1(x): 
     265    """return j1(x)""" 
    242266    if np.isscalar(x): 
    243267        retvalue = (sin(x) - x*cos(x))/x**2 if x != 0. else 0. 
     
    246270            retvalue = (sin(x) - x*cos(x))/x**2 
    247271        retvalue[x == 0.] = 0. 
     272    return retvalue 
    248273 
    249274def sas_3j1x_x(x): 
     275    """return 3*j1(x)/x""" 
    250276    if np.isscalar(x): 
    251277        retvalue = 3*(sin(x) - x*cos(x))/x**3 if x != 0. else 1. 
     
    257283 
    258284def sas_2J1x_x(x): 
     285    """return 2*J1(x)/x""" 
    259286    if np.isscalar(x): 
    260287        retvalue = 2*sas_J1(x)/x if x != 0 else 1. 
Note: See TracChangeset for help on using the changeset viewer.