当前位置: 首页>>代码示例>>Python>>正文


Python Symbol.__new__方法代码示例

本文整理汇总了Python中sympy.Symbol.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python Symbol.__new__方法的具体用法?Python Symbol.__new__怎么用?Python Symbol.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.Symbol的用法示例。


在下文中一共展示了Symbol.__new__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, i, label="sigma"):
     if not i in [1, 2, 3]:
         raise IndexError("Invalid Pauli index")
     obj = Symbol.__new__(cls, "%s%d" %(label,i), commutative=False, hermitian=True)
     obj.i = i
     obj.label = label
     return obj
开发者ID:asmeurer,项目名称:sympy,代码行数:9,代码来源:paulialgebra.py

示例2: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, name, dim=None):
     obj = Symbol.__new__(cls, name)
     obj.dim = dim
     obj._fields = None
     obj._field_names = None
     obj._constant_fields = None
     return obj
开发者ID:IgnitionProject,项目名称:ignition,代码行数:9,代码来源:language.py

示例3: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
    def __new__ (cls, ten, rank=None, shape=None, has_inv=None, transposed=None,
                 **kws):

        # Handle either str or change the behavior
        if isinstance(ten, str):
            name = ten
            if rank is None:
                raise ValueError("Must give rank with string arg.")
            if name in ['0', '1']:
                name = "%s_%d" % (name, rank)

            if name.startswith('0'):
                has_inv = False
            elif name.startswith('1') and rank in [0, 2]:
                has_inv = True
            elif rank == 0:
                has_inv = True
            elif has_inv is None:
                has_inv = False

        elif isinstance(ten, Tensor):
            name = ten.name
            if has_inv is None:
                has_inv = ten.has_inverse
            if not rank is None and rank != ten.rank:
                raise ValueError("Given rank and rank of ten don't match")
            if shape is None and transposed is None:
                shape = ten.shape
            if transposed is None:
                transposed = ten.transposed
            rank = ten.rank
        else:
            raise ValueError("Unable to create Tensor from a %s" \
                             % type(ten))

        if rank > 0 and not kws.has_key("commutative"):
            kws['commutative'] = False

        if transposed is None:
            transposed = False
        if transposed:
            name += "'"

        obj = Symbol.__new__(cls, name, **kws)
        obj.rank = rank
        obj.has_inverse = has_inv
        obj.transposed = transposed
        obj._set_default_shape(shape)
        return obj
开发者ID:mfarthin,项目名称:ignition,代码行数:51,代码来源:tensor.py

示例4: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
    def __new__(cls, name=None, longname=None):

        if name is None or name == "":
            name = "NoName_"+str(Quantity.dummy_count)
            Quantity.dummy_count += 1
            self = Dummy.__new__(cls, name)
        else:
            self = Symbol.__new__(cls, name)

        self.count = Quantity.quantity_count
        Quantity.quantity_count += 1

        self.abbrev = name
        self.name = name
        self.longname = longname
        self.value = None
        self.value_formula = None
        self.error = None
        self.error_formula = None
        self.prefer_unit = None
        self.dim = None
        return self
开发者ID:benti,项目名称:Error-Pypagation,代码行数:24,代码来源:quantities.py

示例5: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, i):
     if not i in [1, 2, 3]:
         raise IndexError("Invalid Pauli index")
     obj = Symbol.__new__(cls, "sigma%d" % i, commutative=False)
     obj.i = i
     return obj
开发者ID:abhishekkumawat23,项目名称:sympy,代码行数:8,代码来源:paulialgebra.py

示例6: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, data, step_size=1.0):
     return Symbol.__new__(cls, "lits%s_%s" % (hashlib.sha1(np.array(data)).hexdigest(), step_size))
开发者ID:marcinofulus,项目名称:sailfish,代码行数:4,代码来源:node_type.py

示例7: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, name, constant=None, fundamental=None, substitution=None, substitution_atoms=None, datatype=None, **assumptions) :
     from sympy import Symbol
     return Symbol.__new__(cls, name, **assumptions)
开发者ID:moble,项目名称:PostNewtonian,代码行数:5,代码来源:PNObjects.py

示例8: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, name, comment=None):
     return Symbol.__new__(cls, name)
开发者ID:vikeu,项目名称:sailfish,代码行数:4,代码来源:sym.py

示例9: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, name, *args):
     return Symbol.__new__(cls, name)
开发者ID:navjotk,项目名称:opesci-fd,代码行数:4,代码来源:derivative.py

示例10: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, name):
     return Symbol.__new__(cls, name.upper(), nonnegative=True, real=True)
开发者ID:broshe,项目名称:pycalphad,代码行数:4,代码来源:variables.py

示例11: __new__

# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
 def __new__(cls, name, rank=None, dim=None):
     obj = Symbol.__new__(cls, name)
     obj.rank = rank
     return obj
开发者ID:IgnitionProject,项目名称:ignition,代码行数:6,代码来源:language.py


注:本文中的sympy.Symbol.__new__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。