Changeset 823e620 in sasmodels for sasmodels/kerneldll.py
- Timestamp:
- Jan 29, 2016 10:46:54 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:
- eafc9fa
- Parents:
- 803f835
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r74667d3 r823e620 122 122 models are allowed as DLLs. 123 123 """ 124 if callable(info.get('Iq', None)):124 if callable(info.get('Iq', None)): 125 125 return PyModel(info) 126 126 … … 140 140 source = generate.convert_type(source, dtype) 141 141 source_files = generate.sources(info) + [info['filename']] 142 dll = dll_path(info, dtype)142 dll = dll_path(info, dtype) 143 143 newest = max(os.path.getmtime(f) for f in source_files) 144 if not os.path.exists(dll) or os.path.getmtime(dll) <newest:144 if not os.path.exists(dll) or os.path.getmtime(dll) < newest: 145 145 # Replace with a proper temp file 146 fid, filename = tempfile.mkstemp(suffix=".c", prefix=tempfile_prefix)147 os.fdopen(fid, "w").write(source)146 fid, filename = tempfile.mkstemp(suffix=".c", prefix=tempfile_prefix) 147 os.fdopen(fid, "w").write(source) 148 148 command = COMPILE%{"source":filename, "output":dll} 149 149 print("Compile command: "+command) … … 160 160 def load_dll(source, info, dtype="double"): 161 161 """ 162 Create and load a dll corresponding to the source, info pair returned162 Create and load a dll corresponding to the source, info pair returned 163 163 from :func:`sasmodels.generate.make` compiled for the target precision. 164 164 … … 199 199 Npd2d = len(self.info['partype']['pd-2d']) 200 200 201 #print("dll", self.dllpath)201 #print("dll", self.dllpath) 202 202 try: 203 203 self.dll = ct.CDLL(self.dllpath) … … 210 210 else c_longdouble) 211 211 pd_args_1d = [c_void_p, fp] + [c_int]*Npd1d if Npd1d else [] 212 pd_args_2d = [c_void_p, fp] + [c_int]*Npd2d if Npd2d else []212 pd_args_2d = [c_void_p, fp] + [c_int]*Npd2d if Npd2d else [] 213 213 self.Iq = self.dll[generate.kernel_name(self.info, False)] 214 214 self.Iq.argtypes = IQ_ARGS + pd_args_1d + [fp]*Nfixed1d … … 257 257 258 258 The resulting call method takes the *pars*, a list of values for 259 the fixed parameters to the kernel, and *pd_pars*, a list of (value, weight)259 the fixed parameters to the kernel, and *pd_pars*, a list of (value, weight) 260 260 vectors for the polydisperse parameters. *cutoff* determines the 261 261 integration limits: any points with combined weight less than *cutoff*
Note: See TracChangeset
for help on using the changeset viewer.