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


Python numpy.fmin方法代码示例

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


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

示例1: compute_corr_significance

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def compute_corr_significance(r, N):
    """ Compute statistical significance for a pearson correlation between
        two xarray objects.

    Parameters
    ----------
    r : `xarray.DataArray` object
        correlation coefficient between two time series.

    N : int
        length of time series being correlated.

    Returns
    -------
    pval : float
        p value for pearson correlation.

    """
    df = N - 2
    t_squared = r ** 2 * (df / ((1.0 - r) * (1.0 + r)))
    # method used in scipy, where `np.fmin` constrains values to be
    # below 1 due to errors in floating point arithmetic.
    pval = special.betainc(0.5 * df, 0.5, np.fmin(df / (df + t_squared), 1.0))
    return xr.DataArray(pval, coords=t_squared.coords, dims=t_squared.dims) 
开发者ID:NCAR,项目名称:esmlab,代码行数:26,代码来源:statistics.py

示例2: test_NotImplemented_not_returned

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_NotImplemented_not_returned(self):
        # See gh-5964 and gh-2091. Some of these functions are not operator
        # related and were fixed for other reasons in the past.
        binary_funcs = [
            np.power, np.add, np.subtract, np.multiply, np.divide,
            np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or,
            np.bitwise_xor, np.left_shift, np.right_shift, np.fmax,
            np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2,
            np.logical_and, np.logical_or, np.logical_xor, np.maximum,
            np.minimum, np.mod,
            np.greater, np.greater_equal, np.less, np.less_equal,
            np.equal, np.not_equal]

        a = np.array('1')
        b = 1
        c = np.array([1., 2.])
        for f in binary_funcs:
            assert_raises(TypeError, f, a, b)
            assert_raises(TypeError, f, c, a) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_ufunc.py

示例3: test_reduce

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_reduce(self):
        dflt = np.typecodes['AllFloat']
        dint = np.typecodes['AllInteger']
        seq1 = np.arange(11)
        seq2 = seq1[::-1]
        func = np.fmin.reduce
        for dt in dint:
            tmp1 = seq1.astype(dt)
            tmp2 = seq2.astype(dt)
            assert_equal(func(tmp1), 0)
            assert_equal(func(tmp2), 0)
        for dt in dflt:
            tmp1 = seq1.astype(dt)
            tmp2 = seq2.astype(dt)
            assert_equal(func(tmp1), 0)
            assert_equal(func(tmp2), 0)
            tmp1[::2] = np.nan
            tmp2[::2] = np.nan
            assert_equal(func(tmp1), 1)
            assert_equal(func(tmp2), 1) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:test_umath.py

示例4: test_NotImplemented_not_returned

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_NotImplemented_not_returned(self):
        # See gh-5964 and gh-2091. Some of these functions are not operator
        # related and were fixed for other reasons in the past.
        binary_funcs = [
            np.power, np.add, np.subtract, np.multiply, np.divide,
            np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or,
            np.bitwise_xor, np.left_shift, np.right_shift, np.fmax,
            np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2,
            np.logical_and, np.logical_or, np.logical_xor, np.maximum,
            np.minimum, np.mod
            ]

        # These functions still return NotImplemented. Will be fixed in
        # future.
        # bad = [np.greater, np.greater_equal, np.less, np.less_equal, np.not_equal]

        a = np.array('1')
        b = 1
        for f in binary_funcs:
            assert_raises(TypeError, f, a, b) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:22,代码来源:test_ufunc.py

示例5: optimize_transformation

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def optimize_transformation(self):
        """
        returns optimal transformation
        """
        x0 = [1.0, 0, 0, 0, 1.0, 0, 0, 0, 1.0]
        self._add_params_trafo_stack_(x0)
        print("starts optimizing...")
        np.fmin(self._calc_min_func_, x0, full_output=1, maxiter=2000)
        # self.alpha1=self.multiplier_x*self.alpha1
        # self.beta1=self.multiplier_x*self.beta1
        # self.gamma1=self.multiplier_x*self.gamma1
        # self.alpha2=self.multiplier_y*self.alpha2
        # self.beta2=self.multiplier_y*self.beta2
        # self.gamma2=self.multiplier_y*self.gamma2
        self._set_transformation_to_all_axis_()
        # self._calc_bounding_box_()
        # self._trafo_to_paper_() 
开发者ID:lefakkomies,项目名称:pynomo,代码行数:19,代码来源:nomo_axis_func.py

示例6: predict_movement

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def predict_movement(self, data, epsilon):
        rand_val = np.random.random(data.shape[0])
        # q_actions = self.model.predict(data)
        p_actions = self.model_policy.predict(data)
        opt_policy_orig = np.argmax(np.abs(p_actions), axis=-1)
        opt_policy = 1.0 * opt_policy_orig
        opt_policy[rand_val < epsilon] = np.random.randint(0, self.action_size, size=(np.sum(rand_val < epsilon)))

        # store the qvalue_evolution (lots of computation time maybe here)
        tmp = np.zeros((data.shape[0], self.action_size))
        tmp[np.arange(data.shape[0]), opt_policy_orig] = 1.0
        q_actions0 = self.model_Q.predict([data, tmp])
        q_actions2 = self.model_Q2.predict([data, tmp])
        q_actions = np.fmin(q_actions0, q_actions2).reshape(-1)
        self.qvalue_evolution = np.concatenate((self.qvalue_evolution, q_actions))
        # above is not mandatory for predicting a movement so, might need to be moved somewhere else...

        opt_policy = opt_policy.astype(np.int)
        return opt_policy, p_actions[:, opt_policy] 
开发者ID:rte-france,项目名称:Grid2Op,代码行数:21,代码来源:ml_agent.py

示例7: _fof_local

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def _fof_local(layout, pos, boxsize, ll, comm):
    from kdcount import cluster

    N = len(pos)

    pos = layout.exchange(pos)
    if boxsize is not None:
        pos %= boxsize
    data = cluster.dataset(pos, boxsize=boxsize)
    fof = cluster.fof(data, linking_length=ll, np=0)
    labels = fof.labels
    del fof

    PID = numpy.arange(N, dtype='intp')
    PID += numpy.sum(comm.allgather(N)[:comm.rank], dtype='intp')

    PID = layout.exchange(PID)
    # initialize global labels
    minid = equiv_class(labels, PID, op=numpy.fmin)[labels]

    return minid 
开发者ID:bccp,项目名称:nbodykit,代码行数:23,代码来源:fof.py

示例8: test_reduce_complex

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_reduce_complex(self):
        assert_equal(np.fmin.reduce([1, 2j]), 2j)
        assert_equal(np.fmin.reduce([1+3j, 2j]), 2j) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:5,代码来源:test_umath.py

示例9: test_float_nans

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_float_nans(self):
        nan = np.nan
        arg1 = np.array([0,   nan, nan])
        arg2 = np.array([nan, 0,   nan])
        out = np.array([0,   0,   nan])
        assert_equal(np.fmin(arg1, arg2), out) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_umath.py

示例10: MTS_LS3v1

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def MTS_LS3v1(Xk, Xk_fit, Xb, Xb_fit, improve, SR, task, phi=3, BONUS1=10, BONUS2=1, rnd=rand, **ukwargs):
	r"""Multiple trajectory local search three version one.

	Args:
		Xk (numpy.ndarray): Current solution.
		Xk_fit (float): Current solutions fitness/function value.
		Xb (numpy.ndarray): Global best solution.
		Xb_fit (float): Global best solutions fitness/function value.
		improve (bool): Has the solution been improved.
		SR (numpy.ndarray): Search range.
		task (Task): Optimization task.
		phi (int): Number of new generated positions.
		BONUS1 (int): Bonus reward for improving global best solution.
		BONUS2 (int): Bonus reward for improving solution.
		rnd (mtrand.RandomState): Random number generator.
		**ukwargs (Dict[str, Any]): Additional arguments.

	Returns:
		Tuple[numpy.ndarray, float, numpy.ndarray, float, bool, numpy.ndarray]:
			1. New solution.
			2. New solutions fitness/function value.
			3. Global best if found else old global best.
			4. Global bests function/fitness value.
			5. If solution has improved.
			6. Search range.
	"""
	grade, Disp = 0.0, task.bRange / 10
	while True in (Disp > 1e-3):
		Xn = apply_along_axis(task.repair, 1, asarray([rnd.permutation(Xk) + Disp * rnd.uniform(-1, 1, len(Xk)) for _ in range(phi)]), rnd)
		Xn_f = apply_along_axis(task.eval, 1, Xn)
		iBetter, iBetterBest = argwhere(Xn_f < Xk_fit), argwhere(Xn_f < Xb_fit)
		grade += len(iBetterBest) * BONUS1 + (len(iBetter) - len(iBetterBest)) * BONUS2
		if len(Xn_f[iBetterBest]) > 0:
			ib, improve = argmin(Xn_f[iBetterBest]), True
			Xb, Xb_fit, Xk, Xk_fit = Xn[iBetterBest][ib][0].copy(), Xn_f[iBetterBest][ib][0], Xn[iBetterBest][ib][0].copy(), Xn_f[iBetterBest][ib][0]
		elif len(Xn_f[iBetter]) > 0:
			ib, improve = argmin(Xn_f[iBetter]), True
			Xk, Xk_fit = Xn[iBetter][ib][0].copy(), Xn_f[iBetter][ib][0]
		Su, Sl = fmin(task.Upper, Xk + 2 * Disp), fmax(task.Lower, Xk - 2 * Disp)
		Disp = (Su - Sl) / 10
	return Xk, Xk_fit, Xb, Xb_fit, improve, grade, SR 
开发者ID:NiaOrg,项目名称:NiaPy,代码行数:43,代码来源:mts.py

示例11: MutationUros

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def MutationUros(pop, ic, mr, task, rnd=rand):
	r"""Mutation method made by Uros Mlakar.

	Args:
		pop (numpy.ndarray[Individual]): Current population.
		ic (int): Index of individual.
		mr (float): Mutation rate.
		task (Task): Optimization task.
		rnd (mtrand.RandomState): Random generator.

	Returns:
		numpy.ndarray: New genotype.
	"""
	return fmin(fmax(rnd.normal(pop[ic], mr * task.bRange), task.Lower), task.Upper) 
开发者ID:NiaOrg,项目名称:NiaPy,代码行数:16,代码来源:ga.py

示例12: test_complex_nans

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_complex_nans(self):
        nan = np.nan
        for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
            arg1 = np.array([0, cnan, cnan], dtype=np.complex)
            arg2 = np.array([cnan, 0, cnan], dtype=np.complex)
            out = np.array([0,    0, nan], dtype=np.complex)
            assert_equal(np.fmin(arg1, arg2), out) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:test_umath.py

示例13: test_complex_nans

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import fmin [as 别名]
def test_complex_nans(self):
        nan = np.nan
        for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
            arg1 = np.array([0, cnan, cnan], dtype=complex)
            arg2 = np.array([cnan, 0, cnan], dtype=complex)
            out = np.array([0,    0, nan], dtype=complex)
            assert_equal(np.fmin(arg1, arg2), out) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:test_umath.py


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