Changeset e499ca0 in sasview for calculatorview/src/sans/perspectives
- Timestamp:
- Jan 22, 2012 4:07:55 PM (13 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f9feff3
- Parents:
- d2c4c06
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/model_editor.py
r2b4c8ca re499ca0 287 287 Do the layout for parameter related widgets 288 288 """ 289 param_txt = wx.StaticText(self, -1, ' Parameters: ')289 param_txt = wx.StaticText(self, -1, 'Fit Parameters (if any): ') 290 290 param_tip = "#Set the parameters and initial values.\n" 291 291 param_tip += "#Example:\n" … … 307 307 function_txt = wx.StaticText(self, -1, 'Function(x) : ') 308 308 hint_function = "#Example:\n" 309 hint_function += "new_x = x * math.pi\n" 310 hint_function += "if new_x <= 0:\n" 309 hint_function += "if x <= 0:\n" 311 310 hint_function += " y = A + B\n" 312 311 hint_function += "else:\n" 313 hint_function += " y = A + B * numpy.cos(new_x)\n"312 hint_function += " y = A + B * cos(2 * pi * x)\n" 314 313 hint_function += "return y\n" 315 314 id = wx.NewId() … … 423 422 # Sort out the errors if occur 424 423 if self.check_name(): 424 name = self.name_tcl.GetValue().lstrip().rstrip() 425 425 description = self.desc_tcl.GetValue() 426 426 param_str = self.param_tcl.GetText() … … 471 471 except : 472 472 raise 473 # Prepare the content of the function 473 474 lines = CUSTOM_TEMPLATE.split('\n') 475 im_np = 'import numpy' 476 im_sp = 'import scipy' 477 if func_str.count(im_np): 478 func_str = func_str.replace(im_np, '') 479 if func_str.count(im_sp): 480 func_str = func_str.replace(im_sp, '') 474 481 has_scipy = func_str.count("scipy.") 475 482 self.is_2d = func_str.count("#self.ndim = 2") … … 495 502 out_f.write(local_params) 496 503 elif line.count("self.description = "): 504 des0 = self.name + "\\n" 497 505 desc = str(desc_str.lstrip().rstrip().replace('\"', '')) 498 if not desc: 499 desc= self.name 500 out_f.write(line% desc + "\n") 506 out_f.write(line% (des0 + desc) + "\n") 501 507 elif line.count("def function(self, x=0.0%s):"): 502 508 if self.is_2d: … … 544 550 for item in items: 545 551 name = item.split("=")[0].lstrip().rstrip() 546 value = item.split("=")[1].lstrip().rstrip()547 552 try: 553 value = item.split("=")[1].lstrip().rstrip() 548 554 float(value) 549 555 except: 550 raise556 value = 1.0 # default 551 557 params_str += spaces + "self.params['%s'] = %s\n"% (name, value) 552 558 … … 604 610 CUSTOM_TEMPLATE = """ 605 611 from sans.models.pluginmodel import Model1DPlugin 606 import math 612 from math import * 607 613 import numpy 608 614 #import scipy?
Note: See TracChangeset
for help on using the changeset viewer.