本文整理汇总了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
示例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
示例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
示例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
示例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
示例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))
示例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)
示例8: __new__
# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
def __new__(cls, name, comment=None):
return Symbol.__new__(cls, name)
示例9: __new__
# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __new__ [as 别名]
def __new__(cls, name, *args):
return Symbol.__new__(cls, name)
示例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)
示例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