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


Python special.cbrt方法代码示例

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


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

示例1: get_scipy_special_helpers

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import cbrt [as 别名]
def get_scipy_special_helpers():
    import scipy.special as sps
    SCIPY_HELPERS = {}
    for name in dimensionless_to_dimensionless_sps_ufuncs:
        # TODO: Revert https://github.com/astropy/astropy/pull/7219 when
        #       astropy requires scipy>=0.18, and loggamma is guaranteed
        #       to exist.
        # See https://github.com/astropy/astropy/issues/7159
        ufunc = getattr(sps, name, None)
        if ufunc:
            SCIPY_HELPERS[ufunc] = helper_dimensionless_to_dimensionless

    for ufunc in degree_to_dimensionless_sps_ufuncs:
        SCIPY_HELPERS[getattr(sps, ufunc)] = helper_degree_to_dimensionless

    for ufunc in two_arg_dimensionless_sps_ufuncs:
        SCIPY_HELPERS[getattr(sps, ufunc)] = helper_two_arg_dimensionless

    # ufuncs handled as special cases
    SCIPY_HELPERS[sps.cbrt] = helper_cbrt
    SCIPY_HELPERS[sps.radian] = helper_degree_minute_second_to_radian
    return SCIPY_HELPERS 
开发者ID:holzschu,项目名称:Carnets,代码行数:24,代码来源:scipy_special.py

示例2: test_cbrt

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import cbrt [as 别名]
def test_cbrt(self):
        assert_approx_equal(cephes.cbrt(1),1.0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:test_basic.py

示例3: test_cbrtmore

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import cbrt [as 别名]
def test_cbrtmore(self):
        cb1 = special.cbrt(27.9)
        cbrl1 = 27.9**(1.0/3.0)
        assert_almost_equal(cb1,cbrl1,8) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:test_basic.py

示例4: scott

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import cbrt [as 别名]
def scott(data, ddof=0):
        """
        Scott's rule for the number of bins in a histogram.

        """
        if np.std(data, ddof=ddof) == 0:
            return sturges_rule(data)

        h = 3.5*np.std(data, ddof=ddof)/cbrt(len(data))
        return int((np.max(data) - np.min(data))/h) 
开发者ID:frsong,项目名称:pycog,代码行数:12,代码来源:figtools.py

示例5: test_cbrt_array

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import cbrt [as 别名]
def test_cbrt_array(self, function):
        # Calculate cbrt on both sides since on Windows the cube root of 64
        # does not exactly equal 4.  See 4388.
        values = np.array([1., 8., 64.])
        assert np.all(function(values * u.m**3) ==
                      function(values) * u.m) 
开发者ID:holzschu,项目名称:Carnets,代码行数:8,代码来源:test_quantity_ufuncs.py

示例6: _distort_tsai

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import cbrt [as 别名]
def _distort_tsai(self, metric_image_coord):
        """
        Distort centered metric image coordinates following Tsai model.

        See: Devernay, Frederic, and Olivier Faugeras. "Straight lines have to be straight."
        Machine vision and applications 13.1 (2001): 14-24. Section 2.1.
        (only for illustration, the formulas didn't work for me)

        http://www.cvg.rdg.ac.uk/PETS2009/sample.zip :CameraModel.cpp:CameraModel::undistortedToDistortedSensorCoord

        Analytical inverse of the undistort_tsai() function.

        :param metric_image_coord: centered metric image coordinates
            (metric image coordinate = image_xy * f / z)
        :type metric_image_coord: numpy.ndarray, shape=(2, n)
        :return: distorted centered metric image coordinates
        :rtype: numpy.ndarray, shape=(2, n)
        """
        assert metric_image_coord.shape[0] == 2
        x = metric_image_coord[0, :]  # vector
        y = metric_image_coord[1, :]  # vector
        r_u = np.sqrt(x ** 2 + y ** 2)  # vector
        c = 1.0 / self.tsai_kappa  # scalar
        d = -c * r_u  # vector

        # solve polynomial of 3rd degree for r_distorted using Cardan method:
        # https://proofwiki.org/wiki/Cardano%27s_Formula
        # r_distorted ** 3 + c * r_distorted + d = 0
        q = c / 3.  # scalar
        r = -d / 2.  # vector
        delta = q ** 3 + r ** 2  # polynomial discriminant, vector

        positive_mask = delta >= 0
        r_distorted = np.zeros((metric_image_coord.shape[1]))

        # discriminant > 0
        s = cbrt(r[positive_mask] + np.sqrt(delta[positive_mask]))
        t = cbrt(r[positive_mask] - np.sqrt(delta[positive_mask]))
        r_distorted[positive_mask] = s + t

        # discriminant < 0
        delta_sqrt = np.sqrt(-delta[~positive_mask])
        s = cbrt(np.sqrt(r[~positive_mask] ** 2 + delta_sqrt ** 2))
        # s = cbrt(np.sqrt(r[~positive_mask] ** 2 + (-delta[~positive_mask]) ** 2))
        t = 1. / 3 * np.arctan2(delta_sqrt, r[~positive_mask])
        r_distorted[~positive_mask] = -s * np.cos(t) + s * np.sqrt(3) * np.sin(t)

        return metric_image_coord * r_distorted / r_u 
开发者ID:smidm,项目名称:camera.py,代码行数:50,代码来源:camera.py


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