當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.heaviside方法代碼示例

本文整理匯總了Python中numpy.heaviside方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.heaviside方法的具體用法?Python numpy.heaviside怎麽用?Python numpy.heaviside使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy的用法示例。


在下文中一共展示了numpy.heaviside方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: heaviside

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def heaviside(x1, x2):
  def f(x1, x2):
    return tf.where(x1 < 0, tf.constant(0, dtype=x2.dtype),
                    tf.where(x1 > 0, tf.constant(1, dtype=x2.dtype), x2))
  y = _bin_op(f, x1, x2)
  if not np.issubdtype(y.dtype, np.inexact):
    y = y.astype(dtypes.default_float_type())
  return y 
開發者ID:google,項目名稱:trax,代碼行數:10,代碼來源:math_ops.py

示例2: _f_step

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def _f_step(a_x, a_date, params, is_mult=False, **kwargs):
    (A, B) = params
    if is_mult:
        y = 1 + (B - 1) * np.heaviside(a_x - A, 1)
    else:
        y = B * np.heaviside(a_x - A, 1)
    return y


# TODO: Implement initialisation for multiplicative composition 
開發者ID:sky-uk,項目名稱:anticipy,代碼行數:12,代碼來源:forecast_models.py

示例3: _f_ramp

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def _f_ramp(a_x, a_date, params, is_mult=False, **kwargs):
    (A, B) = params
    if is_mult:
        y = 1 + (a_x - A) * (B) * np.heaviside(a_x - A, 1)
    else:
        y = (a_x - A) * B * np.heaviside(a_x - A, 1)
    return y 
開發者ID:sky-uk,項目名稱:anticipy,代碼行數:9,代碼來源:forecast_models.py

示例4: get_IVC_JJ

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def get_IVC_JJ(x, Ic, Rn, SNR):
    sign = np.sign(x[-1] - x[0])
    return Rn * x * np.heaviside(np.abs(x) - Ic, int(sign > 0)) \
           + (np.heaviside(x, int(sign > 0)) - np.heaviside(x + sign * Ic, 0)) * Ic * Rn \
           + Ic * Rn / SNR * np.random.rand(x.size) 
開發者ID:qkitgroup,項目名稱:qkit,代碼行數:7,代碼來源:IVD_dummy.py

示例5: __call__

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def __call__(self, X):
        sign = np.heaviside(-1 * X[:, :-1] * X[:, 1:], 0)
        abs_diff = np.abs(np.diff(X, axis=1))
        return np.sum(sign * abs_diff >= self.threshold, axis=1, dtype=X.dtype) 
開發者ID:dmbee,項目名稱:seglearn,代碼行數:6,代碼來源:feature_functions.py

示例6: helper_heaviside

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def helper_heaviside(f, unit1, unit2):
    try:
        converter2 = (get_converter(unit2, dimensionless_unscaled)
                      if unit2 is not None else None)
    except UnitsError:
        raise UnitTypeError("Can only apply 'heaviside' function with a "
                            "dimensionless second argument.")
    return ([None, converter2], dimensionless_unscaled) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:10,代碼來源:helpers.py

示例7: test_heaviside_scalar

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def test_heaviside_scalar(self):
        assert np.heaviside(0. * u.m, 0.5) == 0.5 * u.dimensionless_unscaled
        assert np.heaviside(0. * u.s,
                            25 * u.percent) == 0.25 * u.dimensionless_unscaled
        assert np.heaviside(2. * u.J, 0.25) == 1. * u.dimensionless_unscaled 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:7,代碼來源:test_quantity_ufuncs.py

示例8: test_heaviside_array

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import heaviside [as 別名]
def test_heaviside_array(self):
        values = np.array([-1., 0., 0., +1.])
        halfway = np.array([0.75, 0.25, 0.75, 0.25]) * u.dimensionless_unscaled
        assert np.all(np.heaviside(values * u.m,
                                   halfway * u.dimensionless_unscaled) ==
                      [0, 0.25, 0.75, +1.] * u.dimensionless_unscaled) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:8,代碼來源:test_quantity_ufuncs.py


注:本文中的numpy.heaviside方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。