本文整理汇总了Python中pyeq2.dataConvertorService函数的典型用法代码示例。如果您正苦于以下问题:Python dataConvertorService函数的具体用法?Python dataConvertorService怎么用?Python dataConvertorService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dataConvertorService函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_SolveUsingSimplex_SSQREL_2D
def test_SolveUsingSimplex_SSQREL_2D(self):
coefficientsShouldBe = numpy.array([-6.74510573, 1.32459622])
model = pyeq2.Models_2D.Polynomial.Linear("SSQREL")
model.estimatedCoefficients = numpy.array([1.0, 1.0]) # starting values for the simplex solver
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, model, False)
coefficients = pyeq2.solverService().SolveUsingSimplex(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0e-06, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:7,代码来源:Test_SolverService.py
示例2: 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)
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:33,代码来源:Test_OutputSourceCodeService.py
示例3: test_SolveUsingLevenbergMarquardt_2D
def test_SolveUsingLevenbergMarquardt_2D(self):
coefficientsShouldBe = numpy.array([-8.01913565, 1.5264473])
model = pyeq2.Models_2D.Polynomial.Linear("SSQABS")
model.estimatedCoefficients = numpy.array([-4.0, 2.0]) # starting values for the simplex solver
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, model, False)
coefficients = pyeq2.solverService().SolveUsingLevenbergMarquardt(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0e-06, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:7,代码来源:Test_SolverService.py
示例4: 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)
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:28,代码来源:Test_OutputSourceCodeService.py
示例5: test_SolveUsingODR_3D
def test_SolveUsingODR_3D(self):
coefficientsShouldBe = numpy.array([-0.04925, -0.90509, 1.28076])
model = pyeq2.Models_3D.Polynomial.Linear("ODR")
model.estimatedCoefficients = numpy.array([0.2, -1.0, 1.0]) # starting values for the ODR solver
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D, model, False)
coefficients = pyeq2.solverService().SolveUsingODR(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0e-03, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:7,代码来源:Test_SolverService.py
示例6: 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)
开发者ID:HerobrinesArmy,项目名称:pyeq2,代码行数:34,代码来源:Test_OutputSourceCodeService.py
示例7: 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)
开发者ID:HerobrinesArmy,项目名称:pyeq2,代码行数:27,代码来源:Test_OutputSourceCodeService.py
示例8: test_SolveUsingDE_3D
def test_SolveUsingDE_3D(self):
coefficientsShouldBe = numpy.array([-2.05105972, -0.49194959, 1.77817475])
model = pyeq2.Models_3D.UserDefinedFunction.UserDefinedFunction('SSQABS', 'Default', 'a + b*X + c*Y')
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D_small, model, False)
coefficients = pyeq2.solverService().SolveUsingDE(model)
fittingTarget = model.CalculateAllDataFittingTarget(coefficients)
self.assertTrue(fittingTarget <= 0.1)
开发者ID:JMoravec,项目名称:RadNetWeb,代码行数:7,代码来源:Test_SolverService.py
示例9: 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)
开发者ID:HerobrinesArmy,项目名称:pyeq2,代码行数:28,代码来源:Test_OutputSourceCodeService.py
示例10: test_SolveUsingSpline_3D
def test_SolveUsingSpline_3D(self):
xKnotPointsShouldBe = numpy.array([0.607, 0.607, 0.607, 3.017, 3.017, 3.017])
yKnotPointsShouldBe = numpy.array([1.984, 1.984, 1.984, 3.153, 3.153, 3.153])
coefficientsShouldBe = numpy.array(
[2.33418963, 1.80079612, 5.07902936, 0.54445029, 1.04110843, 2.14180324, 0.26992805, 0.39148852, 0.8177307]
)
testEvaluationShouldBe = numpy.array([0.76020577997])
model = pyeq2.Models_3D.Spline.Spline(inSmoothingFactor=1.0, inXOrder=2, inYOrder=2)
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D, model, False)
fittedParameters = pyeq2.solverService().SolveUsingSpline(model)
# example of later using the saved spline knot points and coefficients
unFittedSpline = scipy.interpolate.fitpack2.SmoothBivariateSpline(
model.dataCache.allDataCacheDictionary["X"],
model.dataCache.allDataCacheDictionary["Y"],
model.dataCache.allDataCacheDictionary["DependentData"],
s=model.smoothingFactor,
kx=model.xOrder,
ky=model.yOrder,
)
unFittedSpline.tck = fittedParameters
testEvaluation = unFittedSpline.ev(2.5, 2.5)
self.assertTrue(numpy.allclose(testEvaluation, testEvaluationShouldBe, rtol=1.0e-10, atol=1.0e-300))
self.assertTrue(numpy.equal(fittedParameters[0], xKnotPointsShouldBe).all())
self.assertTrue(numpy.equal(fittedParameters[1], yKnotPointsShouldBe).all())
self.assertTrue(numpy.allclose(fittedParameters[2], coefficientsShouldBe, rtol=1.0e-06, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:27,代码来源:Test_SolverService.py
示例11: fp_fit
def fp_fit(x, y):
"""Given a list of x and y values, function fits a four parameter logistic
distribution to the data. The distribution being fit has bounds set on several of
the parameters to keep the distribution in the proper orientation. These are:
a -0.25 0.25
b -inf -0.1
c 0 inf
d 0.75 1.25
The function returns a tuple of the parameters and the covariance of the fit:
((a, b, c, d), cov)
"""
equation = pyeq2.Models_2D.Sigmoidal.FourParameterLogistic()
data = "\n".join("{} {}".format(x1, y1) for x1, y1 in zip(x, y))
equation.upperCoefficientBounds = [0.25, -0.1, None, 1.25]
equation.lowerCoefficientBounds = [-0.25, None, 0, 0.75]
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(data, equation, False)
equation.Solve()
return equation.solvedCoefficients, equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)
开发者ID:kenjsc,项目名称:CAMpping,代码行数:26,代码来源:biomap.py
示例12: SetParametersAndFit
def SetParametersAndFit(equationString, inFittingTargetString, inExtendedVersionString, inTextData):
# individual cluster nodes must be able to import pyeq2
import pyeq2
exec('equation = ' + equationString +'("' + inFittingTargetString + '", "' + inExtendedVersionString + '")')
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(inTextData, equation, False)
try:
# check for number of coefficients > number of data points to be fitted
if len(equation.GetCoefficientDesignators()) > len(equation.dataCache.allDataCacheDictionary['DependentData']):
return None
# check for functions requiring non-zero nor non-negative data such as 1/x, etc.
if equation.ShouldDataBeRejected(equation):
return None
equation.Solve()
fittedTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)
if fittedTarget > 1.0E290: # error too large
return None
except:
return None
return [fittedTarget, equation.GetDisplayName(), equation.solvedCoefficients, equationString, inExtendedVersionString]
开发者ID:HerobrinesArmy,项目名称:pyeq2,代码行数:26,代码来源:FitAllEquations_2D.py
示例13: test_SolveUsingSimplex_3D
def test_SolveUsingSimplex_3D(self):
coefficientsShouldBe = numpy.array([0.28658383, -0.90215775, 1.15483864])
model = pyeq2.Models_3D.Polynomial.Linear("SSQABS")
model.estimatedCoefficients = numpy.array([1.0, 1.0, 1.0]) # starting values for the simplex solver
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D, model, False)
coefficients = pyeq2.solverService().SolveUsingSimplex(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0e-06, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:7,代码来源:Test_SolverService.py
示例14: test_SolveUsingDE_3D
def test_SolveUsingDE_3D(self):
coefficientsShouldBe = numpy.array([-0.206068766376, -0.644872592849, 1.13361007134])
model = pyeq2.Models_3D.UserDefinedFunction.UserDefinedFunction("SSQABS", "Default", "a + b*X + c*Y")
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(
DataForUnitTests.asciiDataInColumns_3D_small, model, False
)
coefficients = pyeq2.solverService().SolveUsingDE(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0e-06, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:8,代码来源:Test_SolverService.py
示例15: test_SolveUsingDE_2D
def test_SolveUsingDE_2D(self):
coefficientsShouldBe = numpy.array([-6.15515504031, 1.21618173729])
model = pyeq2.Models_2D.UserDefinedFunction.UserDefinedFunction("SSQABS", "Default", "m*X + b")
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(
DataForUnitTests.asciiDataInColumns_2D_small, model, False
)
coefficients = pyeq2.solverService().SolveUsingDE(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0e-06, atol=1.0e-300))
开发者ID:JMoravec,项目名称:unkRadnet,代码行数:8,代码来源:Test_SolverService.py
示例16: CalculateAndPrintResults
def CalculateAndPrintResults(equation, nistDataObject, inStartValues, inStartValuesString, inPrintFlag):
if nistDataObject.RawDataIn_XY_Format != "": # 2D data
rawData = nistDataObject.RawDataIn_XY_Format
else: # 3D data
rawData = nistDataObject.RawDataIn_XYZ_Format
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(rawData, equation, False)
equation.estimatedCoefficients = inStartValues
equation.Solve()
ssq = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)
#
# See the NIST note at the top of this file regarding dignificant digits.
# NIST files truncate SSQ to 10 decimal places. First check if 8 decimal
# places (to allow for machine precision, rounding, etc) in Python
# gives the same result as NIST, then compare actual values if that fails
# as it is possible though very, very unlikely that pyeq2 fits better than NIST.
ssqString = "%-.11E" % (ssq)
if (ssqString[:10] + ssqString[-4:]) == (nistDataObject.ResidualSumOfSquaresString[:10] + nistDataObject.ResidualSumOfSquaresString[-4:]):
compareString = '- equal to NIST'
betterThanOrEqualToNIST = True
else:
deltaSSQ = nistDataObject.ResidualSumOfSquaresValue - ssq
if deltaSSQ > 0.0: # NIST gives values to 10 decimal places
compareString = '- better than NIST'
betterThanOrEqualToNIST = True
elif deltaSSQ < 0.0:
compareString = '- worse than NIST'
betterThanOrEqualToNIST = False
else:
compareString = '- equal to NIST'
betterThanOrEqualToNIST = True
if inPrintFlag:
print(equation.GetDisplayName(), str(equation.GetDimensionality()) + "D", '- using "' + inStartValuesString + '" values')
print(equation.fittingTargetDictionary[equation.fittingTarget], '=',)
print(ssqString + ', should be',)
print(nistDataObject.ResidualSumOfSquaresValue, compareString)
print("Parameters:")
for i in range(len(equation.solvedCoefficients)):
spacer = ' '
if equation.solvedCoefficients[i] < 0.0:
spacer = ''
print(" %s = %s%-.10E" % (equation.GetCoefficientDesignators()[i], spacer, equation.solvedCoefficients[i]),)
print('(NIST Cert. %s%-.10E, NIST est. %s%-.5E' % (spacer, nistDataObject.CertifiedValues[i], spacer, inStartValues[i]))
print()
return betterThanOrEqualToNIST
开发者ID:HerobrinesArmy,项目名称:pyeq2,代码行数:55,代码来源:NIST_TestingUtilities.py
示例17: test_SplineSolve_2D
def test_SplineSolve_2D(self):
resultShouldBe = (numpy.array([5.357, 5.357, 5.357, 5.357, 9.861, 9.861, 9.861, 9.861]),
numpy.array([0.38297001, 1.95535226, 4.59605664, 7.16162379, 0.0, 0.0, 0.0, 0.0]),
3
)
model = pyeq2.Models_2D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 3)
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(model.exampleData, model, False)
result = model.Solve()
self.assertTrue(numpy.allclose(result[0], resultShouldBe[0], rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(result[1], resultShouldBe[1], rtol=1.0E-06, atol=1.0E-300))
self.assertEqual(result[2], resultShouldBe[2])
开发者ID:JMoravec,项目名称:RadNetWeb,代码行数:11,代码来源:Test_ModelSolveMethods.py
示例18: test_SplineSolve_3D
def test_SplineSolve_3D(self):
resultShouldBe = (numpy.array([0.607, 0.607, 0.607, 3.017, 3.017, 3.017]),
numpy.array([1.984, 1.984, 1.984, 3.153, 3.153, 3.153]),
numpy.array([2.33418963, 1.80079612, 5.07902936, 0.54445029, 1.04110843, 2.14180324, 0.26992805, 0.39148852, 0.8177307])
)
model = pyeq2.Models_3D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 2, inYOrder = 2)
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(model.exampleData, model, False)
result = model.Solve()
self.assertTrue(numpy.allclose(result[0], resultShouldBe[0], rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(result[1], resultShouldBe[1], rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(result[2], resultShouldBe[2], rtol=1.0E-06, atol=1.0E-300))
开发者ID:JMoravec,项目名称:RadNetWeb,代码行数:11,代码来源:Test_ModelSolveMethods.py
示例19: fitEquationUsingDispyCluster
def fitEquationUsingDispyCluster(inEquationString, inFittingTargetString, inExtendedVersionString, inTextData):
# individual cluster nodes must be able to import pyeq2
import pyeq2
exec('equation = ' + inEquationString +'("' + inFittingTargetString + '", "' + inExtendedVersionString + '")')
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(inTextData, equation, False)
equation.Solve()
fittedTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)
# this result list allows easy sorting of multiple results later
return [fittedTarget, inEquationString, equation.solvedCoefficients]
开发者ID:HerobrinesArmy,项目名称:pyeq2,代码行数:12,代码来源:Test_Parallel_Fit.py
示例20: OnFit3D
def OnFit3D(self, evt):
textData = str(self.text_3D.GetValue())
equationSelection = self.rbEqChoice_3D.GetStringSelection()
fittingTargetSelection = self.rbFittingTargetChoice_3D.GetStringSelection()
# the GUI's fitting target string contains what we need - extract it
fittingTarget = fittingTargetSelection.split("(")[1].split(")")[0]
if equationSelection == "Linear Polynomial":
self.equation = pyeq2.Models_3D.Polynomial.Linear(fittingTarget)
if equationSelection == "Full Quadratic Polynomial":
self.equation = pyeq2.Models_3D.Polynomial.FullQuadratic(fittingTarget)
if equationSelection == "Full Cubic Polynomial":
self.equation = pyeq2.Models_3D.Polynomial.FullCubic(fittingTarget)
if equationSelection == "Monkey Saddle A":
self.equation = pyeq2.Models_3D.Miscellaneous.MonkeySaddleA(fittingTarget)
if equationSelection == "Gaussian Curvature Of Whitneys Umbrella A":
self.equation = pyeq2.Models_3D.Miscellaneous.GaussianCurvatureOfWhitneysUmbrellaA(fittingTarget)
if equationSelection == "NIST Nelson Autolog":
self.equation = pyeq2.Models_3D.NIST.NIST_NelsonAutolog(fittingTarget)
if equationSelection == "Custom Polynomial One":
self.equation = pyeq2.Models_3D.Polynomial.UserSelectablePolynomial(fittingTarget, "Default", 3, 1)
# convert text to numeric data checking for log of negative numbers, etc.
try:
pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(textData, self.equation, False)
except:
wx.MessageBox(self.equation.reasonWhyDataRejected, "Error")
return
# check for number of coefficients > number of data points to be fitted
coeffCount = len(self.equation.GetCoefficientDesignators())
dataCount = len(self.equation.dataCache.allDataCacheDictionary["DependentData"])
if coeffCount > dataCount:
wx.MessageBox(
"This equation requires a minimum of "
+ str(coeffCount)
+ " data points, you have supplied "
+ repr(dataCount)
+ ".",
"Error",
)
return
# Now the status dialog is used. Disable fitting buttons until thread completes
self.btnFit2D.Disable()
self.btnFit3D.Disable()
self.statusBox.text.SetValue("")
self.statusBox.Show() # hidden by OnThreadStatus() when thread completes
# thread will automatically start to run
self.fittingWorkerThread = CustomThreads.FittingThread(self, self.equation)
开发者ID:agulbronson,项目名称:pyeq2,代码行数:52,代码来源:wxPythonFit.py
注:本文中的pyeq2.dataConvertorService函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论