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


Python sympy.nan方法代码示例

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


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

示例1: test_constants

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def test_constants():
    assert sympify(sympy.E) == E
    assert sympy.E == E._sympy_()

    assert sympify(sympy.pi) == pi
    assert sympy.pi == pi._sympy_()

    assert sympify(sympy.GoldenRatio) == GoldenRatio
    assert sympy.GoldenRatio == GoldenRatio._sympy_()

    assert sympify(sympy.Catalan) == Catalan
    assert sympy.Catalan == Catalan._sympy_()

    assert sympify(sympy.EulerGamma) == EulerGamma
    assert sympy.EulerGamma == EulerGamma._sympy_()

    assert sympify(sympy.oo) == oo
    assert sympy.oo == oo._sympy_()

    assert sympify(sympy.zoo) == zoo
    assert sympy.zoo == zoo._sympy_()

    assert sympify(sympy.nan) == nan
    assert sympy.nan == nan._sympy_() 
开发者ID:symengine,项目名称:symengine.py,代码行数:26,代码来源:test_sympy_conv.py

示例2: __init__

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def __init__ (self, decl, exists_ok, cache):
        '''
        :decl: declaration string of variable ('Batch(b):20')
        :exists_ok: if declared earlier, nop
        :cache: store in `decls` cache
        '''
        assert isinstance(decl, str)
        decl = decl.strip()

        m = re.search(DimVar.parse_regexp, decl)
        name, sname, val = m.groups()
        #print (m.groups())

        self._name = name
        self._sname = sname if sname is not None else name
        self._val = int(val) if val is not None else nan
        
        self._e = Symbol(self._sname)
        if self._e in DimVar.decls:
            prevd = DimVar.decls[self._e]
            if not exists_ok:
                raise ValueError(f'DimVar {self._sname} already declared as {prevd._name}({self._e}). Use exists_ok=True to skip check.')

        else:
            if cache: DimVar.decls[self._e] = self 
开发者ID:ofnote,项目名称:tsalib,代码行数:27,代码来源:ts.py

示例3: len

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def len(self): 
        return self._val if (self._val != nan) else None 
开发者ID:ofnote,项目名称:tsalib,代码行数:4,代码来源:ts.py

示例4: __int__

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def __int__(self): 
        #print(f'called int {self._val}')
        if self._val != nan:
            return int(self._val)
        else: 
            #return DimExpr.DEFAULT_VALUE
            raise ValueError(f'Cannot cast to integer: Default value of {self._e} not provided') 
开发者ID:ofnote,项目名称:tsalib,代码行数:9,代码来源:ts.py

示例5: __eq__

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def __eq__(self, d):
        #print (f'eq: {self}, {d}')
        if isinstance(d, int):
            #semantics: any integer matches nan
            if self._val == nan: return True 
            else: return self._val == d
        elif isinstance(d, DimExpr):
            res = self._e == d._e 
            #print (res)
            return res
        else:
            return False 
开发者ID:ofnote,项目名称:tsalib,代码行数:14,代码来源:ts.py

示例6: _atan2_0

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def _atan2_0(X):
    """Like sympy.atan2, but return 0 for x=y=0. Mathematically, the value is
    undefined, so sympy returns NaN, but for the sake of the coordinate
    conversion, its value doesn't matter. NaNs, however, produce NaNs down the
    line.
    """
    out = numpy.array([sympy.atan2(X[k, 1], X[k, 0]) for k in range(len(X))])
    out[out == sympy.nan] = 0
    return out 
开发者ID:nschloe,项目名称:quadpy,代码行数:11,代码来源:_helpers.py

示例7: q_affine

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import nan [as 别名]
def q_affine(expr, vars):
    """
    Return True if ``expr`` is (separately) affine in the variables ``vars``,
    False otherwise.

    Notes
    -----
    Exploits:

        https://stackoverflow.com/questions/36283548\
        /check-if-an-equation-is-linear-for-a-specific-set-of-variables/
    """
    vars = as_tuple(vars)
    free_symbols = expr.free_symbols

    # At this point, `expr` is (separately) affine in the `vars` variables
    # if all non-mixed second order derivatives are identically zero.
    for x in vars:
        if expr is x:
            continue

        if x not in free_symbols:
            # At this point the only hope is that `expr` is constant
            return q_constant(expr)

        # The vast majority of calls here are incredibly simple tests
        # like q_affine(x+1, [x]).  Catch these quickly and
        # explicitly, instead of calling the very slow function `diff`.
        if expr.is_Add and len(expr.args) == 2:
            if expr.args[1] is x and expr.args[0].is_Number:
                continue
            if expr.args[0] is x and expr.args[1].is_Number:
                continue

        try:
            if diff(expr, x) is nan or not Eq(diff(expr, x, x), 0):
                return False
        except TypeError:
            return False

    return True 
开发者ID:devitocodes,项目名称:devito,代码行数:43,代码来源:queries.py


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