- Timestamp:
- Sep 29, 2008 9:47:47 AM (16 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:
- 65b788b2
- Parents:
- fa9674b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/plugins/testmodel.py
rb30f001 rfa38d83 2 2 Test plug-in model 3 3 """ 4 #try: 5 # from DataPlugin import * 6 #except: 7 # import sys, os 8 # print os.path.abspath('..') 9 # sys.path.insert(1,os.path.abspath('..')) 10 # from DataPlugin import * 11 # print "Running independently" 12 # 4 from sans.models.pluginmodel import Model1DPlugin 13 5 import math 14 from sans.models.BaseComponent import BaseComponent15 import math16 class Model1DPlugin(BaseComponent):17 ## Name of the model18 name = "Plugin Model"19 6 20 def __init__(self):21 """ Initialization """22 self.details = {}23 self.params = {}24 25 def function(self, x):26 """27 Function to be implemented by the plug-in writer28 """29 return x30 31 def run(self, x = 0.0):32 """ Evaluate the model33 @param x: input x, or [x, phi] [radian]34 @return: function value35 """36 if x.__class__.__name__ == 'list':37 x_val = x[0]*math.cos(x[1])38 y_val = x[0]*math.sin(x[1])39 return self.function(x_val)*self.function(y_val)40 elif x.__class__.__name__ == 'tuple':41 raise ValueError, "Tuples are not allowed as input to BaseComponent models"42 else:43 return self.function(x)44 45 def runXY(self, x = 0.0):46 """ Evaluate the model47 @param x: input x, or [x, y]48 @return: function value49 """50 if x.__class__.__name__ == 'list':51 return self.function(x[0])*self.function(x[1])52 elif x.__class__.__name__ == 'tuple':53 raise ValueError, "Tuples are not allowed as input to BaseComponent models"54 else:55 return self.function(x)56 7 57 8 # Your model HAS to be called Model
Note: See TracChangeset
for help on using the changeset viewer.