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


Python float_info.max方法代码示例

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


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

示例1: get_view_data

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def get_view_data():
    waypoint_ids = app.waypoint.get_waypoint_ids()
    waypoints = {}
    arrows = app.arrow.get_arrows()
    lat_min, lng_min = float_info.max, float_info.max
    lat_max, lng_max = 0.0, 0.0
    for waypoint_id in waypoint_ids:
        lat, lng = app.waypoint.get_latlng(waypoint_id)
        lat_min = min(lat_min, lat)
        lat_max = max(lat_max, lat)
        lng_min = min(lng_min, lng)
        lng_max = max(lng_max, lng)
        waypoints[waypoint_id] = {
            "geohash": app.waypoint.get_geohash(waypoint_id),
            "position": dict(zip(["x", "y", "z"], app.waypoint.get_xyz(waypoint_id)))
        }
    return api_response(code=200, message={
        "viewPoint": {
            "lat": 0.5*(lat_max + lat_min),
            "lng": 0.5*(lng_max + lng_min)},
        "waypoints": waypoints,
        "arrows": arrows,
        "topics": app.topics
    }) 
开发者ID:CPFL,项目名称:AMS,代码行数:26,代码来源:router.py

示例2: as_frame_time

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def as_frame_time(self, _in_time_seconds: float):
        """
        Convert the specified time in seconds to a frame number by rounding
        down to the nearest integer

        Param: _in_time_seconds  The time to convert in seconds

        Returns a frame number that represents the supplied time. Rounded
        down to the nearest integer
        """
        time_as_frame = ((_in_time_seconds * self.numerator)
                         / self.denominator)
        frame_number = math.floor(time_as_frame)
        sub_frame = time_as_frame - math.floor(time_as_frame)
        if sub_frame > 0:
            sub_frame = min(sub_frame, float_info.max)
        return FrameTime(frame_number, sub_frame) 
开发者ID:tscrypter,项目名称:blender-ue4-live-link,代码行数:19,代码来源:FrameRate.py

示例3: from_decimal

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def from_decimal(self, _in_decimal_frame):
        """
        Convert a decimal representation to a frame time
        Note that subframes are always positive, so negative
        decimal representations result in an inverted sub frame
        and floored frame number
        """
        new_frame = math.floor(_in_decimal_frame)

        # Ensure fractional parts above the highest sub frame
        # float precision do not round to 0.0
        fraction = _in_decimal_frame - math.floor(_in_decimal_frame)

        # clamp = max(min(value, max_value), min_value)
        return FrameTime(new_frame,
                         max(min(fraction, float_info.max), float_info.min)) 
开发者ID:tscrypter,项目名称:blender-ue4-live-link,代码行数:18,代码来源:FrameTime.py

示例4: number_of_coins

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def number_of_coins(money,coins):
    number = [0]                           # We will use Dynamic Programming, and solve 
                                           # the problem for each amount up to and including money
    for m in range(1,money+1):             # solve for m
        nn = float_info.max            # Number of coins: assume that we haven't solved
        for coin in coins:                 # Find a coin such that we can make change using it
                                           # plus a previoudly comuted value
            if m>=coin:
                if number[m-coin]+1<nn:
                    nn = number[m-coin]+1
        number.append(nn)
    return number[money]

# BA5B 	Find the Length of a Longest Path in a Manhattan-like Grid 
#
# Input: Integers n and m, followed by an n*(m+1) matrix Down and an
#        (n+1)*m matrix Right. The two matrices are separated by the "-" symbol.
#
# Return: The length of a longest path from source (0, 0) to sink (n, m)
#        in the n*m rectangular grid whose edges are defined by the matrices
#        Down and Right.
#
# http://rosalind.info/problems/ba5a/ 
开发者ID:weka511,项目名称:bioinformatics,代码行数:25,代码来源:align.py

示例5: longest_manhattan_path

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def longest_manhattan_path(n,m,down,right):
    s=[]
    for i in range(n+1):
        s.append(zeroes(m+1))

    for i in range(1,n+1):
        s[i][0]=s[i-1][0]+down[i-1][0]
        
    for j in range(1,m+1):
        s[0][j]=s[0][j-1]+right[0][j-1]
        
    for i in range(1,n+1):    
        for j in range(1,m+1):
            s[i][j]=max(s[i-1][j]+down[i-1][j],s[i][j-1]+right[i][j-1])

    return s[n][m]

# BA5C 	Find a Longest Common Subsequence of Two Strings
#
# Input: Two strings.
#
# Return: A longest common subsequence of these strings.
#
# http://rosalind.info/problems/ba5a/ 
开发者ID:weka511,项目名称:bioinformatics,代码行数:26,代码来源:align.py

示例6: test_large_number

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def test_large_number(self):
        most_max = (
            '{}179769313486231570814527423731704356798070567525844996'
            '598917476803157260780028538760589558632766878171540458953'
            '514382464234321326889464182768467546703537516986049910576'
            '551282076245490090389328944075868508455133942304583236903'
            '222948165808559332123348274797826204144723168738177180919'
            '29988125040402618412485836{}'
        )
        most_max2 = (
            '{}35953862697246314162905484746340871359614113505168999'
            '31978349536063145215600570775211791172655337563430809179'
            '07028764928468642653778928365536935093407075033972099821'
            '15310256415249098018077865788815173701691026788460916647'
            '38064458963316171186642466965495956524082894463374763543'
            '61838599762500808052368249716736'
        )
        int_max = int(float_info.max)
        self.assertEqual(nformat(int_max, '.'), most_max.format('', '8'))
        self.assertEqual(nformat(int_max + 1, '.'), most_max.format('', '9'))
        self.assertEqual(nformat(int_max * 2, '.'), most_max2.format(''))
        self.assertEqual(nformat(0 - int_max, '.'), most_max.format('-', '8'))
        self.assertEqual(nformat(-1 - int_max, '.'), most_max.format('-', '9'))
        self.assertEqual(nformat(-2 * int_max, '.'), most_max2.format('-')) 
开发者ID:nesdis,项目名称:djongo,代码行数:26,代码来源:test_numberformat.py

示例7: __init__

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def __init__(self, bottom=float_info.min,
                 top=float_info.max,
                 decimals=float_info.dig, parent=None):

        super(MyDoubleValidator, self).__init__(bottom, top, decimals, parent) 
开发者ID:iris-edu,项目名称:pyweed,代码行数:7,代码来源:MyDoubleValidator.py

示例8: create_distance_matrix

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def create_distance_matrix(nrows,ncolumns,initial_value=-float_info.max):
    s=[]
    for i in range(nrows):
        row=[]
        for j in range(ncolumns):
            row.append(initial_value)        
        s.append(row)
    s[0][0]=0
    return s 
开发者ID:weka511,项目名称:bioinformatics,代码行数:11,代码来源:align.py

示例9: test_split

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def test_split(sample, y_s, feature, n_classes):
    size = y_s.shape[0]
    if size == 0:
        return float_info.max, np.float64(np.inf)

    f = feature[sample]
    sort_indices = np.argsort(f)
    y_sorted = y_s[sort_indices]
    f_sorted = f[sort_indices]

    not_repeated = np.empty(size, dtype=np.bool_)
    not_repeated[0: size - 1] = (f_sorted[1:] != f_sorted[:-1])
    not_repeated[size - 1] = True

    l_freq = np.zeros((n_classes, size), dtype=np.int64)
    l_freq[y_sorted, np.arange(size)] = 1

    r_freq = np.zeros((n_classes, size), dtype=np.int64)
    r_freq[:, 1:] = l_freq[:, :0:-1]

    l_weight = np.sum(np.square(np.cumsum(l_freq, axis=-1)), axis=0)
    r_weight = np.sum(np.square(np.cumsum(r_freq, axis=-1)), axis=0)[::-1]

    l_length = np.arange(1, size + 1, dtype=np.int32)
    r_length = np.arange(size - 1, -1, -1, dtype=np.int32)
    r_length[size - 1] = 1  # Avoid div by zero, the right score is 0 anyways

    scores = gini_criteria_proxy(l_weight, l_length, r_weight, r_length,
                                 not_repeated)

    min_index = size - np.argmin(scores[::-1]) - 1

    if min_index + 1 == size:
        b_value = np.float64(np.inf)
    else:
        b_value = (f_sorted[min_index] + f_sorted[min_index + 1]) / 2
    return scores[min_index], b_value 
开发者ID:bsc-wdc,项目名称:dislib,代码行数:39,代码来源:test_split.py

示例10: _split_node_wrapper

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def _split_node_wrapper(sample, n_features, y_s, n_classes, m_try,
                        random_state, samples_file=None, features_file=None):
    seed = random_state.randint(np.iinfo(np.int32).max)

    if features_file is not None:
        return _split_node_using_features(sample, n_features, y_s, n_classes,
                                          m_try, features_file, seed)
    elif samples_file is not None:
        return _split_node(sample, n_features, y_s, n_classes, m_try,
                           samples_file, seed)
    else:
        raise ValueError('Invalid combination of arguments. samples_file is '
                         'None and features_file is None.') 
开发者ID:bsc-wdc,项目名称:dislib,代码行数:15,代码来源:decision_tree.py

示例11: _compute_split

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def _compute_split(sample, n_features, y_s, n_classes, m_try, features_mmap,
                   random_state):
    node_info = left_group = y_l = right_group = y_r = None
    split_ended = False
    tried_indices = []
    while not split_ended:
        untried_indices = np.setdiff1d(np.arange(n_features), tried_indices)
        index_selection = _feature_selection(untried_indices, m_try,
                                             random_state)
        b_score = float_info.max
        b_index = None
        b_value = None
        for index in index_selection:
            feature = features_mmap[index]
            score, value = test_split(sample, y_s, feature, n_classes)
            if score < b_score:
                b_score, b_value, b_index = score, value, index
        groups = _get_groups(sample, y_s, features_mmap, b_index, b_value)
        left_group, y_l, right_group, y_r = groups
        if left_group.size and right_group.size:
            split_ended = True
            node_info = _InnerNodeInfo(b_index, b_value)
        else:
            tried_indices.extend(list(index_selection))
            if len(tried_indices) == n_features:
                split_ended = True
                node_info = _compute_leaf_info(y_s, n_classes)
                left_group = sample
                y_l = y_s
                right_group = np.array([], dtype=np.int64)
                y_r = np.array([], dtype=np.int8)

    return node_info, left_group, y_l, right_group, y_r 
开发者ID:bsc-wdc,项目名称:dislib,代码行数:35,代码来源:decision_tree.py

示例12: _build_subtree_wrapper

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def _build_subtree_wrapper(sample, y_s, n_features, max_depth, n_classes,
                           m_try, sklearn_max, random_state, samples_file,
                           features_file):
    seed = random_state.randint(np.iinfo(np.int32).max)
    if features_file is not None:
        return _build_subtree_using_features(sample, y_s, n_features,
                                             max_depth, n_classes, m_try,
                                             sklearn_max, seed, samples_file,
                                             features_file)
    else:
        return _build_subtree(sample, y_s, n_features, max_depth, n_classes,
                              m_try, sklearn_max, seed, samples_file) 
开发者ID:bsc-wdc,项目名称:dislib,代码行数:14,代码来源:decision_tree.py

示例13: __init__

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def __init__(self):
        self._weighted_sum = 0
        self._weighted_sum_squared = 0
        self._sum_of_weights = 0
        self._mean = 0
        self._variance = float_info.max
        self._min_var = 1e-12
        self.CONST = math.log(2 * math.pi) 
开发者ID:vitords,项目名称:HoeffdingTree,代码行数:10,代码来源:univariatenormalestimator.py

示例14: update_mean_and_variance

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def update_mean_and_variance(self):
        self._mean = 0
        if self._sum_of_weights > 0:
            self._mean = self._weighted_sum / self._sum_of_weights

        self._variance = float_info.max
        if self._sum_of_weights > 0:
            self._variance = self._weighted_sum_squared / self._sum_of_weights - self._mean * self._mean

        if self._variance <= self._min_var:
            self._variance = self._min_var 
开发者ID:vitords,项目名称:HoeffdingTree,代码行数:13,代码来源:univariatenormalestimator.py

示例15: gpd_loglikelihood_scale_and_shape

# 需要导入模块: from sys import float_info [as 别名]
# 或者: from sys.float_info import max [as 别名]
def gpd_loglikelihood_scale_and_shape(scale, shape, price_data):
    n = len(price_data)
    result = -1 * float_info.max
    if (scale != 0):
        param_factor = shape / scale
        if (shape != 0 and param_factor >= 0 and scale >= 0):
            result = ((-n * np.log(scale)) -
                      (((1 / shape) + 1) *
                       (np.log((shape / scale * price_data) + 1)).sum()))
    return result 
开发者ID:quantopian,项目名称:empyrical,代码行数:12,代码来源:stats.py


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