Changeset f734e7d in sasmodels for sasmodels/kernelpy.py


Ignore:
Timestamp:
Feb 21, 2015 11:44:54 PM (9 years ago)
Author:
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:
6137124
Parents:
711d8e2
Message:

restructure c code generation for maintainability; extend test harness to allow opencl and ctypes tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelpy.py

    r6edb74a rf734e7d  
    33 
    44from .generate import F32, F64 
     5 
     6class PyModel(object): 
     7    def __init__(self, info): 
     8        self.info = info 
     9    def __call__(self, input): 
     10        kernel = self.info['Iqxy'] if input.is_2D else self.info['Iq'] 
     11        return PyKernel(kernel, self.info, input) 
     12    def make_input(self, q_vectors): 
     13        return PyInput(q_vectors, dtype=F64) 
     14    def release(self): 
     15        pass 
    516 
    617class PyInput(object): 
     
    134145    """ 
    135146 
    136     ########################################################## 
    137     #                                                        # 
    138     #   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   # 
    139     #   !!                                              !!   # 
    140     #   !!  KEEP THIS CODE CONSISTENT WITH GENERATE.PY  !!   # 
    141     #   !!                                              !!   # 
    142     #   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   # 
    143     #                                                        # 
    144     ########################################################## 
     147    ################################################################ 
     148    #                                                              # 
     149    #   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   # 
     150    #   !!                                                    !!   # 
     151    #   !!  KEEP THIS CODE CONSISTENT WITH KERNEL_TEMPLATE.C  !!   # 
     152    #   !!                                                    !!   # 
     153    #   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   # 
     154    #                                                              # 
     155    ################################################################ 
    145156 
    146157    weight = np.empty(len(pd), 'd') 
     
    164175        stride = np.array([1]) 
    165176        vol_weight_index = slice(None, None) 
     177        # keep lint happy 
     178        fast_value = [None] 
     179        fast_weight = [None] 
    166180 
    167181    ret = np.zeros_like(args[0]) 
     
    193207            # Correction factor for spherical integration p(theta) I(q) sin(theta) dtheta 
    194208            #spherical_correction = abs(sin(pi*args[theta_index])) if theta_index>=0 else 1.0 
    195             #spherical_correction = abs(cos(pi*args[theta_index]))*pi/2 if theta_index>=0 else 1.0 
    196             spherical_correction = 1.0 
     209            spherical_correction = abs(cos(pi*args[theta_index]))*pi/2 if theta_index>=0 else 1.0 
     210            #spherical_correction = 1.0 
    197211            ret += w*I*spherical_correction*positive 
    198212            norm += w*positive 
Note: See TracChangeset for help on using the changeset viewer.