當前位置: 首頁>>代碼示例>>Python>>正文


Python DataContainer.assertEqual方法代碼示例

本文整理匯總了Python中pyphant.core.DataContainer.assertEqual方法的典型用法代碼示例。如果您正苦於以下問題:Python DataContainer.assertEqual方法的具體用法?Python DataContainer.assertEqual怎麽用?Python DataContainer.assertEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyphant.core.DataContainer的用法示例。


在下文中一共展示了DataContainer.assertEqual方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testParabelArray

# 需要導入模塊: from pyphant.core import DataContainer [as 別名]
# 或者: from pyphant.core.DataContainer import assertEqual [as 別名]
 def testParabelArray(self):
     x = numpy.array([-2,-1,0,1,2],'float')
     field = numpy.array([(x-0.2)**2-0.5,(x+0.1)**2])
     inputField = DC.FieldContainer(field,
                                    error=numpy.resize(numpy.repeat(0.1,len(field)),field.shape),
                                    dimensions=[DC.FieldContainer(numpy.array([1,2]),
                                                                  longname='type',shortname=r'\theta'),
                                                DC.FieldContainer(x,longname='position',shortname='x')],
                                    longname='parabel',
                                    shortname='f')
     def error(y):
         error  = inputField.error[0,0] / (y[1]-2*y[2]+y[3])**2
         error *= numpy.abs(y[2]-y[3]) + numpy.abs(y[1]-y[3]) + numpy.abs(y[1]-y[2])
         return error
     expectedResult = DC.FieldContainer(numpy.array([[0.2,-0.1]]),
                                        longname = 'position of the local minima of parabel',
                                        shortname = 'x_0',
                                        error = numpy.array([[error(field[0]),error(field[1])]]))
     expectedResult.dimensions[-1] = DC.FieldContainer(numpy.array([1,2]),
                                                       longname='type',
                                                       shortname=r'\theta')
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     #Retrieve result from worker
     result = w.locate(inputField)
     DC.assertEqual(result,expectedResult)
開發者ID:GitEdit,項目名稱:pyphant1,代碼行數:28,代碼來源:TestExtremumFinder.py

示例2: testDistanceMappingInvertedStringDyDx

# 需要導入模塊: from pyphant.core import DataContainer [as 別名]
# 或者: from pyphant.core.DataContainer import assertEqual [as 別名]
 def testDistanceMappingInvertedStringDyDx(self):
     """
     Consider two features, which are divided by a vertical line.
     The respective distances increase by dx for each column counted
     from the centre line.
     """
     self.dydx = 0.01
     self.yDim = DataContainer.FieldContainer(
         numpy.linspace(-self.dydx,self.dydx,self.dim),
         unit = '1m',
         longname= 'height',
         shortname='h')
     referenceField = DataContainer.FieldContainer(
         numpy.logical_not(stringFeature(self.dim,distanceToBorder=0)),
         dimensions = [self.xDim, self.yDim],
         unit = '1',
         longname='Inverted String Feature',
         shortname='S')
     referenceField.seal()
     result = self.worker.calculateDistanceMap(referenceField)
     #Compute result afoot
     afoot = numpy.zeros(referenceField.data.shape,'f')
     dx = numpy.diff(referenceField.dimensions[0].data)[0]
     for i in xrange(referenceField.data.shape[1]):
         afoot[:,i]= dx * abs(5-i)
     afootC=DataContainer.FieldContainer(afoot, unit=self.xDim.unit,
                                        dimensions = map(copy.deepcopy,referenceField.dimensions))
     DataContainer.assertEqual(afootC, result)
開發者ID:gclos,項目名稱:pyphant1,代碼行數:30,代碼來源:TestDistanceMapper.py

示例3: testMinima

# 需要導入模塊: from pyphant.core import DataContainer [as 別名]
# 或者: from pyphant.core.DataContainer import assertEqual [as 別名]
 def testMinima(self):
     """Test the correct computation of all local minima for a bistable potential."""
     #Predict result
     x0,curv,mask = fixedPoints(numpy.array([self.LAMBDA]),kappa1=self.kappa1)
     expectedResult = DC.FieldContainer(numpy.extract(curv[0]>0,x0[0]),
                                        unit = self.xField.unit,
                                        longname = 'position of the local minima of electric potential',
                                        shortname = 'x_0')
     #Retrieve result from worker
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     result = w.locate(self.V)
     #Testing
     DC.assertEqual(result,expectedResult)
開發者ID:GitEdit,項目名稱:pyphant1,代碼行數:16,代碼來源:TestExtremumFinder.py

示例4: testParabel

# 需要導入模塊: from pyphant.core import DataContainer [as 別名]
# 或者: from pyphant.core.DataContainer import assertEqual [as 別名]
 def testParabel(self):
     x = numpy.array([-2,-1,0,1,2],'float')+0.1
     y = x**2
     inputField = DC.FieldContainer(y,
                                    error=numpy.repeat(0.1,len(y)),
                                    dimensions=[DC.FieldContainer(x,longname='abscissae',shortname='x')],
                                    longname='parabel',
                                    shortname='f')
     error  = inputField.error[slice(0,1)] / (y[1]-2*y[2]+y[3])**2
     error *= numpy.abs(y[2]-y[3]) + numpy.abs(y[1]-y[3]) + numpy.abs(y[1]-y[2])
     expectedResult = DC.FieldContainer(numpy.array([0.0]),
                                        longname = 'position of the local minimum of parabel',
                                        shortname = 'x_0',
                                        error = error)
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     #Retrieve result from worker
     result = w.locate(inputField)
     DC.assertEqual(result,expectedResult)
開發者ID:GitEdit,項目名稱:pyphant1,代碼行數:21,代碼來源:TestExtremumFinder.py

示例5: testParabelSymmetricallyBoxedMinimum

# 需要導入模塊: from pyphant.core import DataContainer [as 別名]
# 或者: from pyphant.core.DataContainer import assertEqual [as 別名]
 def testParabelSymmetricallyBoxedMinimum(self):
     x = numpy.array([-2,-1,0,1,2],'float')-0.5
     y = x**2
     inputField = DC.FieldContainer(y,
                                    error=numpy.repeat(0.1,len(y)),
                                    dimensions=[DC.FieldContainer(x,longname='abscissae',shortname='x')],
                                    longname='parabel',
                                    shortname='f'
                                    )
     expectedResult = DC.FieldContainer(numpy.array([0.0]),
                                        longname = 'position of the local minimum of parabel',
                                        shortname = 'x_0',
                                        error = numpy.array([0.1])
                                        )
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     #Retrieve result from worker
     result = w.locate(inputField)
     DC.assertEqual(result,expectedResult)
開發者ID:GitEdit,項目名稱:pyphant1,代碼行數:21,代碼來源:TestExtremumFinder.py


注:本文中的pyphant.core.DataContainer.assertEqual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。