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


Python Variable._OperatorVariableClass方法代碼示例

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


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

示例1: _OperatorVariableClass

# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import _OperatorVariableClass [as 別名]
    def _OperatorVariableClass(self, baseClass=None):
        baseClass = Variable._OperatorVariableClass(self, baseClass=baseClass)
                                     
        class _MeshOperatorVariable(baseClass):
            def __init__(self, op, var, opShape=None, canInline=True,
                         *args, **kwargs):
                mesh = reduce(lambda a, b: a or b, 
                              [getattr(v, "mesh", None) for v in var])
                for shape in [opShape] + [getattr(v, "opShape", None) for v in var]:
                    if shape is not None:
                        opShape = shape
                        break
##                 opShape = reduce(lambda a, b: a or b, 
##                                  [opShape] + [getattr(v, "opShape", None) for v in var])
                if opShape is not None:
                    elementshape = opShape[:-1]
                else:
                    elementshape = reduce(lambda a, b: a or b, 
                                          [getattr(v, "elementshape", None) for v in var])

                baseClass.__init__(self, mesh=mesh, op=op, var=var, 
                                   opShape=opShape, canInline=canInline,
                                   elementshape=elementshape,
                                   *args, **kwargs)
                                 
            def getRank(self):
                return len(self.opShape) - 1
                
        return _MeshOperatorVariable
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:31,代碼來源:meshVariable.py

示例2: _axisClass

# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import _OperatorVariableClass [as 別名]
 def _axisClass(self, axis):
     """
     if we operate along the mesh elements, then this is no longer a
     `_MeshVariable`, otherwise we get back a `_MeshVariable` of the same
     class, but lower rank.
     """
     if axis is None or axis == len(self.shape) - 1 or axis == -1:
         return Variable._OperatorVariableClass(self, baseClass=Variable)
     else:
         return self._OperatorVariableClass()
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:12,代碼來源:meshVariable.py

示例3: _getitemClass

# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import _OperatorVariableClass [as 別名]
 def _getitemClass(self, index):
     if not isinstance(index, tuple):
         if isinstance(index, list):
             index = tuple(index)
         else:
             index = (index,)
     indexshape = numerix._indexShape(index=index, arrayShape=self.shape)
     if (len(indexshape) > 0
         and indexshape[-1] == self.shape[-1]
         and numerix.obj2sctype(index[-1]) != numerix.obj2sctype(bool)):
         return self._OperatorVariableClass()
     else:
         return Variable._OperatorVariableClass(self, baseClass=Variable)
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:15,代碼來源:meshVariable.py

示例4: allequal

# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import _OperatorVariableClass [as 別名]
    def allequal(self, other):
         if self.getMesh().communicator.Nproc > 1:
             def allequalParallel(a, b):
                 return self.getMesh().communicator.allequal(a, b)

             operatorClass = Variable._OperatorVariableClass(self, baseClass=Variable)
             return self._BinaryOperatorVariable(allequalParallel,
                                                 other, 
                                                 operatorClass=operatorClass,
                                                 opShape=(),
                                                 canInline=False)            
         else:
             return Variable.allequal(self, other)
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:15,代碼來源:meshVariable.py

示例5: allclose

# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import _OperatorVariableClass [as 別名]
    def allclose(self, other, rtol=1.e-5, atol=1.e-8):
         if self.getMesh().communicator.Nproc > 1:
             def allcloseParallel(a, b):
                 return self.getMesh().communicator.allclose(a, b, rtol=rtol, atol=atol)

             operatorClass = Variable._OperatorVariableClass(self, baseClass=Variable)
             return self._BinaryOperatorVariable(allcloseParallel,
                                                 other, 
                                                 operatorClass=operatorClass,
                                                 opShape=(),
                                                 canInline=False)            
         else:
             return Variable.allclose(self, other, rtol=rtol, atol=atol)
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:15,代碼來源:meshVariable.py

示例6: allequal

# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import _OperatorVariableClass [as 別名]
    def allequal(self, other):
         if parallel.Nproc > 1:
             from mpi4py import MPI
             def allequalParallel(a, b):
                 return MPI.COMM_WORLD.allreduce(numerix.allequal(a, b), op=MPI.LAND)

             operatorClass = Variable._OperatorVariableClass(self, baseClass=Variable)
             return self._BinaryOperatorVariable(allequalParallel,
                                                 other, 
                                                 operatorClass=operatorClass,
                                                 opShape=(),
                                                 canInline=False)            
         else:
             return Variable.allequal(self, other)
開發者ID:regmi,項目名稱:fipy,代碼行數:16,代碼來源:meshVariable.py


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