當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。