Changeset 44a698c in sasview for src/sas/sascalc/fit/expression.py
- Timestamp:
- Mar 12, 2019 7:15:06 AM (5 years ago)
- Branches:
- ESS_GUI_sync_sascalc
- Parents:
- 390494d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/fit/expression.py
re4c475b7 r44a698c 188 188 189 189 # Initialize dictionary with available functions 190 global s= {}191 global s.update(math.__dict__)192 global s.update(dict(arcsin=math.asin,arccos=math.acos,190 global_context = {} 191 global_context.update(math.__dict__) 192 global_context.update(dict(arcsin=math.asin,arccos=math.acos, 193 193 arctan=math.atan,arctan2=math.atan2)) 194 global s.update(context)195 global s.update(parameters)196 global s['id'] = id197 local s= {}194 global_context.update(context) 195 global_context.update(parameters) 196 global_context['id'] = id 197 local_context = {} 198 198 199 199 # Define the constraints function … … 210 210 211 211 #print("Function: "+functiondef) 212 # Python 2.7 213 #exec (functiondef in globals,locals) 214 # Python 3.5 215 exec (functiondef, globals, locals) 216 217 retfn = locals['eval_expressions'] 212 # CRUFT: python < 3.0; doc builder isn't allowing the following exec 213 # https://stackoverflow.com/questions/4484872/why-doesnt-exec-work-in-a-function-with-a-subfunction/41368813#comment73790496_41368813 214 #exec(functiondef, global_context, local_context) 215 eval(compile(functiondef, '<string>', 'exec'), global_context, local_context) 216 retfn = local_context['eval_expressions'] 218 217 219 218 # Remove garbage added to globals by exec 220 global s.pop('__doc__',None)221 global s.pop('__name__',None)222 global s.pop('__file__',None)223 global s.pop('__builtins__')219 global_context.pop('__doc__', None) 220 global_context.pop('__name__', None) 221 global_context.pop('__file__', None) 222 global_context.pop('__builtins__') 224 223 #print globals.keys() 225 224 … … 236 235 237 236 # Break pairs into left set and right set 238 left,right = [set(s) for s in zip(*pairs)] if pairs != [] else ([],[]) 239 while pairs != []: 237 # Note: pairs is array or list, so use "len(pairs) > 0" to check for empty. 238 left,right = [set(s) for s in zip(*pairs)] if len(pairs) > 0 else ([],[]) 239 while len(pairs) > 0: 240 240 #print "within",pairs 241 241 # Find which items only occur on the right … … 265 265 satisfies the partial ordering given by the pairs in partial order. 266 266 """ 267 left,right = zip(*pairs) if pairs != [] else ([],[]) 267 # Note: pairs is array or list, so use "len(pairs) > 0" to check for empty. 268 left,right = zip(*pairs) if len(pairs) > 0 else ([],[]) 268 269 items = set(left) 269 270 n = order_dependencies(pairs)
Note: See TracChangeset
for help on using the changeset viewer.