Changeset eafc9fa in sasmodels for sasmodels/kerneldll.py
- Timestamp:
- Jan 30, 2016 7:39:59 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:
- 5925e90
- Parents:
- 823e620
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r823e620 reafc9fa 1 1 r""" 2 C types wrapper for sasview models. 2 DLL driver for C kernels 3 3 4 4 The global attribute *ALLOW_SINGLE_PRECISION_DLLS* should be set to *True* if … … 44 44 directory for this application, then OpenMP should be supported. 45 45 """ 46 from __future__ import print_function 46 47 47 48 import sys … … 139 140 140 141 source = generate.convert_type(source, dtype) 141 source_files = generate. sources(info) + [info['filename']]142 source_files = generate.model_sources(info) + [info['filename']] 142 143 dll = dll_path(info, dtype) 143 144 newest = max(os.path.getmtime(f) for f in source_files) … … 218 219 219 220 def __getstate__(self): 220 return {'info': self.info, 'dllpath': self.dllpath, 'dll': None}221 return self.info, self.dllpath 221 222 222 223 def __setstate__(self, state): 223 self. __dict__= state224 225 def __call__(self, q_input): 226 if self.dtype != q_input.dtype:227 raise TypeError("data is %s kernel is %s" % (q_input.dtype, self.dtype))224 self.info, self.dllpath = state 225 self.dll = None 226 227 def __call__(self, q_vectors): 228 q_input = PyInput(q_vectors, self.dtype) 228 229 if self.dll is None: self._load_dll() 229 kernel = self.Iqxy if q_input.is_2 Delse self.Iq230 kernel = self.Iqxy if q_input.is_2d else self.Iq 230 231 return DllKernel(kernel, self.info, q_input) 231 232 232 # pylint: disable=no-self-use233 def make_input(self, q_vectors):234 """235 Make q input vectors available to the model.236 237 Note that each model needs its own q vector even if the case of238 mixture models because some models may be OpenCL, some may be239 ctypes and some may be pure python.240 """241 return PyInput(q_vectors, dtype=self.dtype)242 243 233 def release(self): 234 """ 235 Release any resources associated with the model. 236 """ 244 237 pass # TODO: should release the dll 245 238 … … 269 262 self.kernel = kernel 270 263 self.res = np.empty(q_input.nq, q_input.dtype) 271 dim = '2d' if q_input.is_2 Delse '1d'264 dim = '2d' if q_input.is_2d else '1d' 272 265 self.fixed_pars = info['partype']['fixed-'+dim] 273 266 self.pd_pars = info['partype']['pd-'+dim] … … 299 292 300 293 def release(self): 294 """ 295 Release any resources associated with the kernel. 296 """ 301 297 pass
Note: See TracChangeset
for help on using the changeset viewer.