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


Python ZZ.weight方法代码示例

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


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

示例1: _element_constructor_

# 需要导入模块: from sage.rings.all import ZZ [as 别名]
# 或者: from sage.rings.all.ZZ import weight [as 别名]
    def _element_constructor_(self, x):
        r"""
        Return the element of the algebra ``self`` corresponding to ``x``.

        EXAMPLES::

            sage: S = SiegelModularFormsAlgebra(coeff_ring=QQ)
            sage: B = SiegelModularFormsAlgebra(coeff_ring=ZZ).1
            sage: S(B)
            Igusa_6
            sage: S(1/5)
            1/5
            sage: S(1/5).parent() is S
            True
            sage: S._element_constructor_(2.67)
            Traceback (most recent call last):
            ...
            TypeError: Unable to construct an element of Algebra of Siegel modular forms of degree 2 and even weights on Sp(4,Z) over Rational Field corresponding to 2.67000000000000
            sage: S.base_extend(RR)._element_constructor_(2.67)
            2.67000000000000
        """
        if isinstance(x, (int, long)):
            x = ZZ(x)
        if isinstance(x, float):
            from sage.rings.all import RR
            x = RR(x)
        if isinstance(x, complex):
            from sage.rings.all import CC
            x = CC(x)

        if isinstance(x.parent(), SiegelModularFormsAlgebra_class):
            d = dict((f, self.coeff_ring()(x[f])) for f in x.coeffs())
            return self.element_class(parent=self, weight=x.weight(), coeffs=d, prec=x.prec(), name=x.name())

        R = self.base_ring()
        if R.has_coerce_map_from(x.parent()):
            d = {(0, 0, 0): R(x)}
            from sage.rings.all import infinity
            return self.element_class(parent=self, weight=0, coeffs=d, prec=infinity, name=str(x))
        else:
            raise TypeError, "Unable to construct an element of %s corresponding to %s" %(self, x)
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:43,代码来源:siegel_modular_forms_algebra.py


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