Changeset 4bfd277 in sasmodels for sasmodels/kernelpy.py
- Timestamp:
- Apr 8, 2016 12:11:16 PM (8 years ago)
- 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:
- 2afc26d
- Parents:
- d2fc9a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelpy.py
r6d6508e r4bfd277 10 10 from numpy import pi, cos 11 11 12 from . import details 12 13 from .generate import F64 13 14 … … 145 146 146 147 def __call__(self, call_details, weights, values, cutoff): 147 # type: (.generate.CallDetails, np.ndarray, np.ndarray, float) -> np.ndarray148 assert isinstance(call_details, details.CallDetails) 148 149 res = _loops(self._parameter_vector, self._form, self._volume, 149 150 self.q_input.nq, call_details, weights, values, cutoff) … … 160 161 form_volume, # type: Callable[[], float] 161 162 nq, # type: int 162 call_details,# type: .generate.CallDetails163 call_details,# type: details.CallDetails 163 164 weights, # type: np.ndarray 164 165 values, # type: np.ndarray … … 205 206 this_offset = call_details.par_offset[par] 206 207 block_size = 1 207 for bit in xrange(32):208 for bit in range(len(pd_offset)): 208 209 if coord&1: 209 210 this_offset += block_size * pd_index[bit] … … 245 246 246 247 248 def _create_default_functions(model_info): 249 """ 250 Autogenerate missing functions, such as Iqxy from Iq. 251 252 This only works for Iqxy when Iq is written in python. :func:`make_source` 253 performs a similar role for Iq written in C. This also vectorizes 254 any functions that are not already marked as vectorized. 255 """ 256 _create_vector_Iq(model_info) 257 _create_vector_Iqxy(model_info) # call create_vector_Iq() first 258 247 259 248 260 def _create_vector_Iq(model_info): … … 252 264 Iq = model_info.Iq 253 265 if callable(Iq) and not getattr(Iq, 'vectorized', False): 266 #print("vectorizing Iq") 254 267 def vector_Iq(q, *args): 255 268 """ … … 265 278 """ 266 279 Iq, Iqxy = model_info.Iq, model_info.Iqxy 267 if callable(Iqxy) and not getattr(Iqxy, 'vectorized', False): 268 def vector_Iqxy(qx, qy, *args): 269 """ 270 Vectorized 2D kernel. 271 """ 272 return np.array([Iqxy(qxi, qyi, *args) for qxi, qyi in zip(qx, qy)]) 273 vector_Iqxy.vectorized = True 274 model_info.Iqxy = vector_Iqxy 280 if callable(Iqxy): 281 if not getattr(Iqxy, 'vectorized', False): 282 #print("vectorizing Iqxy") 283 def vector_Iqxy(qx, qy, *args): 284 """ 285 Vectorized 2D kernel. 286 """ 287 return np.array([Iqxy(qxi, qyi, *args) for qxi, qyi in zip(qx, qy)]) 288 vector_Iqxy.vectorized = True 289 model_info.Iqxy = vector_Iqxy 275 290 elif callable(Iq): 291 #print("defaulting Iqxy") 276 292 # Iq is vectorized because create_vector_Iq was already called. 277 293 def default_Iqxy(qx, qy, *args): … … 283 299 model_info.Iqxy = default_Iqxy 284 300 285 def _create_default_functions(model_info):286 """287 Autogenerate missing functions, such as Iqxy from Iq.288 289 This only works for Iqxy when Iq is written in python. :func:`make_source`290 performs a similar role for Iq written in C. This also vectorizes291 any functions that are not already marked as vectorized.292 """293 _create_vector_Iq(model_info)294 _create_vector_Iqxy(model_info) # call create_vector_Iq() first295
Note: See TracChangeset
for help on using the changeset viewer.