当前位置: 首页>>代码示例>>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;未经允许,请勿转载。