本文整理汇总了Python中pyeq2.outputSourceCodeService函数的典型用法代码示例。如果您正苦于以下问题:Python outputSourceCodeService函数的具体用法?Python outputSourceCodeService怎么用?Python outputSourceCodeService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outputSourceCodeService函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_GenerationOf_CSHARP
def test_GenerationOf_CSHARP(self):
generatedShouldBe = '''// To the best of my knowledge this code is correct.
// If you find any errors or problems please contact
// me directly using [email protected]
//
// James
using System;
// Fitting target: lowest sum of squared absolute error
// Fitting target value = 0.223837322455
class Polynomial_Linear
{
\tdouble Polynomial_Linear_model(double x_in)
\t{
\t\tdouble temp;
\t\ttemp = 0.0;
\t\t// coefficients
\t\tdouble a = -8.01913564075E+00;
\t\tdouble b = 1.52644729419E+00;
\t\ttemp += a + b * x_in;
\t\treturn temp;
\t}
}
'''
equation = pyeq2.Models_2D.Polynomial.Linear('SSQABS')
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)
equation.Solve()
generated = pyeq2.outputSourceCodeService().GetOutputSourceCodeCSHARP(equation, inDigitsOfPrecisionString = '11')
self.assertEqual(generated, generatedShouldBe)
示例2: test_GenerationOf_MATLAB
def test_GenerationOf_MATLAB(self):
generatedShouldBe = '''% To the best of my knowledge this code is correct.
% If you find any errors or problems please contact
% me directly using [email protected]
%
% James
% Fitting target: lowest sum of squared absolute error
% Fitting target value = 0.223837322455
function y = Polynomial_Linear_model(x_in)
\ttemp = 0.0;
\t% coefficients
\ta = -8.01913564075E+00;
\tb = 1.52644729419E+00;
\ttemp = temp + a + b .* x_in;
\ty = temp;
'''
equation = pyeq2.Models_2D.Polynomial.Linear('SSQABS')
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)
equation.Solve()
generated = pyeq2.outputSourceCodeService().GetOutputSourceCodeMATLAB(equation, inDigitsOfPrecisionString = '11')
self.assertEqual(generated, generatedShouldBe)
示例3: test_GenerationOf_VBA
def test_GenerationOf_VBA(self):
generatedShouldBe = """' To the best of my knowledge this code is correct.
' If you find any errors or problems please contact
' me directly using [email protected]
'
' James
' Fitting target: lowest sum of squared absolute error
' Fitting target value = 0.223837322455
Public Function Linear_model(x_in)
\ttemp = 0.0
\t' coefficients
\tConst a = -8.01913564075E+00
\tConst b = 1.52644729419E+00
\ttemp = temp + a + b * x_in
\tLinear_model = temp
End Function
"""
equation = pyeq2.Models_2D.Polynomial.Linear("SSQABS")
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(
DataForUnitTests.asciiDataInColumns_2D, equation, False
)
equation.Solve()
generated = pyeq2.outputSourceCodeService().GetOutputSourceCodeVBA(equation, inDigitsOfPrecisionString="11")
self.assertEqual(generated, generatedShouldBe)
示例4: test_GenerationOf_PYTHON
def test_GenerationOf_PYTHON(self):
generatedShouldBe = '''# To the best of my knowledge this code is correct.
# If you find any errors or problems please contact
# me directly using [email protected]
#
# James
import math
# Fitting target: lowest sum of squared absolute error
# Fitting target value = 0.223837322455
def Polynomial_Linear_model(x_in):
temp = 0.0
# coefficients
a = -8.01913564075E+00
b = 1.52644729419E+00
temp += a + b * x_in
return temp
'''
equation = pyeq2.Models_2D.Polynomial.Linear('SSQABS')
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)
equation.Solve()
generated = pyeq2.outputSourceCodeService().GetOutputSourceCodePYTHON(equation, inDigitsOfPrecisionString = '11')
self.assertEqual(generated, generatedShouldBe)
示例5: test_GenerationOf_CPP
def test_GenerationOf_CPP(self):
generatedShouldBe = """// To the best of my knowledge this code is correct.
// If you find any errors or problems please contact
// me directly using [email protected]
//
// James
#include <math.h>
// Fitting target: lowest sum of squared absolute error
// Fitting target value = 0.223837322455
double Linear_model(double x_in)
{
double temp;
temp = 0.0;
// coefficients
double a = -8.01913564075E+00;
double b = 1.52644729419E+00;
temp += a + b * x_in;
return temp;
}
"""
equation = pyeq2.Models_2D.Polynomial.Linear("SSQABS")
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(
DataForUnitTests.asciiDataInColumns_2D, equation, False
)
equation.Solve()
generated = pyeq2.outputSourceCodeService().GetOutputSourceCodeCPP(equation, inDigitsOfPrecisionString="11")
self.assertEqual(generated, generatedShouldBe)
示例6: test_GenerationOf_CPP_ForAllEquations
def test_GenerationOf_CPP_ForAllEquations(self): # ensure no coding errors in source code generation for any equation
for submodule in inspect.getmembers(pyeq2.Models_2D) + inspect.getmembers(pyeq2.Models_3D):
if inspect.ismodule(submodule[1]):
for equationClass in inspect.getmembers(submodule[1]):
if inspect.isclass(equationClass[1]):
try: # not all equation classes have a fixed number of coefficient designators
equation = equationClass[1]()
coeffCount = len(equation.GetCoefficientDesignators())
equation.solvedCoefficients = [1.0] * len(equation.GetCoefficientDesignators())
except:
continue
generated = pyeq2.outputSourceCodeService().GetOutputSourceCodeCPP(equation)
self.assertIs(type(generated), type('')) # must be a striong
self.assertTrue(len(generated) > 0) # must have a length > 0
示例7: test_ConversionFromCppToVBA
def test_ConversionFromCppToVBA(self):
convertedShouldBe = '''
\t' comment
\tvar doubleVariable
\ttemp = a * Abs(1.1)
\ttemp = a / Abs(1.1)
\ttemp = temp + Application.WorksheetFunction.power(temp)
\ttemp = temp - Application.WorksheetFunction.ln(temp)
\ttemp = Application.WorksheetFunction.log(temp)
\ttemp = Exp(temp)
\ttemp = sin(temp)
\ttemp = cos(temp)
\ttemp = tan(temp)
\ttemp = Application.WorksheetFunction.tanh(temp)
\ttemp = Application.WorksheetFunction.cosh(temp)
'''
converted = pyeq2.outputSourceCodeService().ConvertCppToVBA(self.cppStringForTestingLanguageConversions)
self.assertEqual(converted, convertedShouldBe)
示例8: test_ConversionFromCppToJAVA
def test_ConversionFromCppToJAVA(self):
convertedShouldBe = '''
\t\t// comment
\t\tdouble doubleVariable;
\t\ttemp = a * Math.abs(1.1);
\t\ttemp = a / Math.abs(1.1);
\t\ttemp += Math.pow(temp);
\t\ttemp -= Math.log(temp);
\t\ttemp = Math.log10(temp);
\t\ttemp = Math.exp(temp);
\t\ttemp = Math.sin(temp);
\t\ttemp = Math.cos(temp);
\t\ttemp = Math.tan(temp);
\t\ttemp = Math.tanh(temp);
\t\ttemp = Math.cosh(temp);
'''
converted = pyeq2.outputSourceCodeService().ConvertCppToJAVA(self.cppStringForTestingLanguageConversions)
self.assertEqual(converted, convertedShouldBe)
示例9: test_ConversionFromCppToMATLAB
def test_ConversionFromCppToMATLAB(self):
convertedShouldBe = '''
\t% comment
\tdoubleVariable;
\ttemp = a .* abs(1.1);
\ttemp = a ./ abs(1.1);
\ttemp = temp + power(temp);
\ttemp = temp - log(temp);
\ttemp = log10(temp);
\ttemp = exp(temp);
\ttemp = sin(temp);
\ttemp = cos(temp);
\ttemp = tan(temp);
\ttemp = tanh(temp);
\ttemp = cosh(temp);
'''
converted = pyeq2.outputSourceCodeService().ConvertCppToMATLAB(self.cppStringForTestingLanguageConversions)
self.assertEqual(converted, convertedShouldBe)
示例10: test_ConversionFromCppToPYTHON
def test_ConversionFromCppToPYTHON(self):
convertedShouldBe = '''
# comment
doubleVariable
temp = a * math.fabs(1.1)
temp = a / math.fabs(1.1)
temp += math.pow(temp)
temp -= math.log(temp)
temp = math.log10(temp)
temp = math.exp(temp)
temp = math.sin(temp)
temp = math.cos(temp)
temp = math.tan(temp)
temp = math.tanh(temp)
temp = math.cosh(temp)
'''
converted = pyeq2.outputSourceCodeService().ConvertCppToPYTHON(self.cppStringForTestingLanguageConversions)
self.assertEqual(converted, convertedShouldBe)
示例11: test_ConversionFromCppToCSHARP
def test_ConversionFromCppToCSHARP(self):
convertedShouldBe = """
\t\t// comment
\t\tdouble doubleVariable;
\t\ttemp = a * Math.Abs(1.1);
\t\ttemp = a / Math.Abs(1.1);
\t\ttemp += Math.Pow(temp);
\t\ttemp -= Math.Log(temp);
\t\ttemp = Math.Log10(temp);
\t\ttemp = Math.Exp(temp);
\t\ttemp = Math.Sin(temp);
\t\ttemp = Math.Cos(temp);
\t\ttemp = Math.Tan(temp);
\t\ttemp = Math.Tanh(temp);
\t\ttemp = Math.Cosh(temp);
"""
converted = pyeq2.outputSourceCodeService().ConvertCppToCSHARP(self.cppStringForTestingLanguageConversions)
self.assertEqual(converted, convertedShouldBe)
示例12: SaveSourceCode
def SaveSourceCode(in_sourceCodeFilePath, in_equation):
outputFile = open(in_sourceCodeFilePath, 'w')
outputFile.write('<html><body>\n\n')
try:
outputFile.write('<b>C++</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeCPP(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>CSHARP</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeCSHARP(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>VBA</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeVBA(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>PYTHON</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodePYTHON(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>JAVA</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVA(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>JAVASCRIPT</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVASCRIPT(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>JULIA</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeJULIA(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>FORTRAN90</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeFORTRAN90(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>SCILAB</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeSCILAB(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
try:
outputFile.write('<b>MATLAB</b><br><textarea rows="20" cols="85" wrap="OFF">')
outputFile.write(pyeq2.outputSourceCodeService().GetOutputSourceCodeMATLAB(in_equation))
outputFile.write('</textarea><br><br>\n\n')
except:
pass
outputFile.write('</body></html>\n')
outputFile.close()
示例13: print
equation.solvedCoefficients = solvedCoefficients
equation.dataCache.FindOrCreateAllDataCache(equation)
equation.CalculateModelErrors(equation.solvedCoefficients, equation.dataCache.allDataCacheDictionary)
print()
print('\"Best fit\" was', moduleName + "." + className)
print('Fitting target value', equation.fittingTarget + ":", equation.CalculateAllDataFittingTarget(equation.solvedCoefficients))
print()
print('Polyfunctional flags:', polyfunctional3DFlags)
print()
for i in range(len(equation.solvedCoefficients)):
print("Coefficient " + equation.GetCoefficientDesignators()[i] + ": " + str(equation.solvedCoefficients[i]))
print()
##########################################################
print('Generated source code section commented out')
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeCPP(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeCSHARP(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeVBA(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodePYTHON(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVA(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVASCRIPT(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeSCILAB(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeMATLAB(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeJULIA(equation))
#print(pyeq2.outputSourceCodeService().GetOutputSourceCodeFORTRAN90(equation))
示例14: Exception
if -1 != sys.path[0].find('pyeq2-master'):raise Exception('Please rename git checkout directory from "pyeq2-master" to "pyeq2"')
importDir = os.path.join(os.path.join(sys.path[0][:sys.path[0].rfind(os.sep)], '..'), '..')
if importDir not in sys.path:
sys.path.append(importDir)
import pyeq2
# see IModel.fittingTargetDictionary
equation = pyeq2.Models_2D.Polynomial.Quadratic() # SSQABS by default
data = equation.exampleData
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(data, equation, False)
equation.Solve()
##########################################################
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeCPP(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeCSHARP(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeVBA(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodePYTHON(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVA(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVASCRIPT(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeSCILAB(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeMATLAB(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeJULIA(equation))
print(pyeq2.outputSourceCodeService().GetOutputSourceCodeFORTRAN90(equation))
示例15: str
import pyeq2
pythonFileName = sys.argv[0] # unused
equationInfoFromNodeJS = json.loads(sys.argv[1])
textDataFromNodeJS = json.loads(sys.argv[2])
fittingTargetFromNodeJS = json.loads(sys.argv[3])
moduleName = equationInfoFromNodeJS['pythonModuleName']
className = equationInfoFromNodeJS['pythonClassName']
extendedVersionString = equationInfoFromNodeJS['extendedVersionString']
dimensionality = equationInfoFromNodeJS['dimensionality']
eqStringToEvaluate = 'equation = pyeq2.Models_'
eqStringToEvaluate += str(dimensionality) + 'D.'
eqStringToEvaluate += moduleName + '.'
eqStringToEvaluate += className + '('
eqStringToEvaluate += '"' + fittingTargetFromNodeJS + '",'
eqStringToEvaluate += '"' + extendedVersionString + '")'
exec(eqStringToEvaluate)
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(textDataFromNodeJS, equation, False)
equation.Solve()
# output could include data statistics, error statistics, fit
# and coefficients statistics, etc. from the other Python examples
print json.dumps(equation.solvedCoefficients.tolist())
print(json.dumps(pyeq2.outputSourceCodeService().GetOutputSourceCodeJAVASCRIPT(equation)))