<s> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> from __future__ import absolute_import <EOL> import sys , os <EOL> if os . path . join ( sys . path [ <NUM_LIT:0> ] [ : sys . path [ <NUM_LIT:0> ] . rfind ( os . sep ) ] , '<STR_LIT:..>' ) not in sys . path : <EOL> sys . path . append ( os . path . join ( sys . path [ <NUM_LIT:0> ] [ : sys . path [ <NUM_LIT:0> ] . rfind ( os . sep ) ] , '<STR_LIT:..>' ) ) <EOL> import pyeq2 , pyeq2 . PolyFunctions <EOL> import numpy <EOL> numpy . seterr ( all = '<STR_LIT:ignore>' ) <EOL> import pyeq2 . Model_2D_BaseClass , pyeq2 , pyeq2 . PolyFunctions <EOL> class UserSelectablePolyfunctional ( pyeq2 . Model_2D_BaseClass . Model_2D_BaseClass ) : <EOL> userSelectablePolyfunctionalFlag = True <EOL> _baseName = "<STR_LIT>" <EOL> _leftSideHTML = '<STR_LIT:y>' <EOL> _canLinearSolverBeUsedForSSQABS = True <EOL> webReferenceURL = '<STR_LIT>' <EOL> baseEquationHasGlobalMultiplierOrDivisor_UsedInExtendedVersions = False <EOL> autoGenerateOffsetForm = False <EOL> autoGenerateReciprocalForm = False <EOL> autoGenerateInverseForms = False <EOL> autoGenerateGrowthAndDecayForms = False <EOL> def __init__ ( self , inFittingTarget = None , inExtendedVersionName = '<STR_LIT>' , inPolyfunctional2DFlags = [ ] , inPolyfunctionalEquationList_X = [ ] ) : <EOL> if not inPolyfunctionalEquationList_X : <EOL> self . polyfunctionalEquationList = pyeq2 . PolyFunctions . GenerateListForPolyfunctionals_2D ( ) <EOL> else : <EOL> self . polyfunctionalEquationList = inPolyfunctionalEquationList_X <EOL> self . independentData1CannotContainZeroFlag = False <EOL> self . independentData1CannotContainPositiveFlag = False <EOL> self . independentData1CannotContainNegativeFlag = False <EOL> self . independentData2CannotContainZeroFlag = False <EOL> self . independentData2CannotContainPositiveFlag = False <EOL> self . independentData2CannotContainNegativeFlag = False <EOL> pyeq2 . Model_2D_BaseClass . Model_2D_BaseClass . __init__ ( self , inFittingTarget , inExtendedVersionName ) <EOL> self . polyfunctional2DFlags = inPolyfunctional2DFlags <EOL> def GetDisplayHTML ( self ) : <EOL> if not self . polyfunctional2DFlags : <EOL> self . _HTML = "<STR_LIT>" <EOL> else : <EOL> self . _HTML = '<STR_LIT>' <EOL> coefficientDesignatorIndex = <NUM_LIT:0> <EOL> cd = self . GetCoefficientDesignators ( ) <EOL> for index in range ( len ( self . polyfunctional2DFlags ) ) : <EOL> if self . polyfunctional2DFlags [ index ] == <NUM_LIT:0> : <EOL> continue <EOL> self . _HTML += '<STR_LIT>' + cd [ coefficientDesignatorIndex ] + '<STR_LIT>' + self . polyfunctionalEquationList [ self . polyfunctional2DFlags [ index ] ] . HTML + '<STR_LIT>' <EOL> coefficientDesignatorIndex += <NUM_LIT:1> <EOL> if ( self . polyfunctional2DFlags [ index ] != self . polyfunctional2DFlags [ len ( self . polyfunctional2DFlags ) - <NUM_LIT:1> ] ) or ( <NUM_LIT:0> in self . polyfunctional2DFlags ) : <EOL> self . _HTML += "<STR_LIT>" <EOL> if <NUM_LIT:0> in self . polyfunctional2DFlags : <EOL> self . _HTML += "<STR_LIT>" <EOL> return self . extendedVersionHandler . AssembleDisplayHTML ( self ) <EOL> def GetCoefficientDesignators ( self ) : <EOL> if <NUM_LIT:0> in self . polyfunctional2DFlags : <EOL> self . _coefficientDesignators = list ( self . listOfAdditionalCoefficientDesignators [ : len ( self . polyfunctional2DFlags ) - <NUM_LIT:1> ] ) <EOL> self . _coefficientDesignators . append ( '<STR_LIT>' ) <EOL> else : <EOL> self . _coefficientDesignators = list ( self . listOfAdditionalCoefficientDesignators [ : len ( self . polyfunctional2DFlags ) ] ) <EOL> return self . _coefficientDesignators <EOL> def GetDataCacheFunctions ( self ) : <EOL> functionList = [ ] <EOL> for i in self . polyfunctional2DFlags : <EOL> if i == <NUM_LIT:0> : <EOL> continue <EOL> functionList . append ( [ pyeq2 . DataCache . DataCacheFunctions . Polyfunctional2D ( NameOrValueFlag = <NUM_LIT:1> , args = i ) , i ] ) <EOL> if <NUM_LIT:0> in self . polyfunctional2DFlags : <EOL> functionList . append ( [ pyeq2 . DataCache . DataCacheFunctions . Polyfunctional2D ( NameOrValueFlag = <NUM_LIT:1> , args = <NUM_LIT:0> ) , <NUM_LIT:0> ] ) <EOL> return functionList <EOL> def ShouldDataBeRejected ( self , unused ) : <EOL> for i in self . polyfunctional2DFlags : <EOL> self . independentData1CannotContainZeroFlag |= self . polyfunctionalEquationList [ i ] . cannotAcceptDataWith_Zero <EOL> self . independentData1CannotContainPositiveFlag |= self . polyfunctionalEquationList [ i ] . cannotAcceptDataWith_Positive <EOL> self . independentData1CannotContainNegativeFlag |= self . polyfunctionalEquationList [ i ] . cannotAcceptDataWith_Negative <EOL> return pyeq2 . Model_2D_BaseClass . Model_2D_BaseClass . ShouldDataBeRejected ( self , unused ) <EOL> def CalculateModelPredictions ( self , inCoeffs , inDataCacheDictionary ) : <EOL> temp = <NUM_LIT:0.0> <EOL> coeffCount = <NUM_LIT:0> <EOL> try : <EOL> for i in self . polyfunctional2DFlags : <EOL> if i == <NUM_LIT:0> : <EOL> continue <EOL> temp += inCoeffs [ coeffCount ] * eval ( "<STR_LIT>" + str ( i ) + "<STR_LIT>" ) <EOL> coeffCount += <NUM_LIT:1> <EOL> if <NUM_LIT:0> in self . polyfunctional2DFlags : <EOL> temp += inCoeffs [ coeffCount ] * eval ( "<STR_LIT>" ) <EOL> return self . extendedVersionHandler . GetAdditionalModelPredictions ( temp , inCoeffs , inDataCacheDictionary , self ) <EOL> except : <EOL> return numpy . ones ( len ( inDataCacheDictionary [ '<STR_LIT>' ] ) ) * <NUM_LIT> <EOL> def SpecificCodeCPP ( self ) : <EOL> s = "<STR_LIT>" <EOL> count = <NUM_LIT:0> <EOL> cd = self . GetCoefficientDesignators ( ) <EOL> for i in self . polyfunctional2DFlags : <EOL> if i != <NUM_LIT:0> : <EOL> s += "<STR_LIT>" + cd [ count ] + "<STR_LIT>" + self . polyfunctionalEquationList [ i ] . CPP + "<STR_LIT>" <EOL> count += <NUM_LIT:1> <EOL> if <NUM_LIT:0> in self . polyfunctional2DFlags : <EOL> s += "<STR_LIT>" + cd [ count ] + "<STR_LIT>" <EOL> return s </s>
