Python sys.float_info.max() Examples
The following are 24
code examples of sys.float_info.max().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sys.float_info
, or try the search function
.
Example #1
Source File: router.py From AMS with Apache License 2.0 | 6 votes |
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 })
Example #2
Source File: test_numberformat.py From djongo with GNU Affero General Public License v3.0 | 6 votes |
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('-'))
Example #3
Source File: test_numberformat.py From djongo with GNU Affero General Public License v3.0 | 6 votes |
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('-'))
Example #4
Source File: align.py From bioinformatics with GNU General Public License v3.0 | 6 votes |
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/
Example #5
Source File: align.py From bioinformatics with GNU General Public License v3.0 | 6 votes |
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/
Example #6
Source File: FrameTime.py From blender-ue4-live-link with GNU General Public License v3.0 | 6 votes |
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))
Example #7
Source File: router.py From AMS with Apache License 2.0 | 6 votes |
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 })
Example #8
Source File: router.py From AMS with Apache License 2.0 | 6 votes |
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 })
Example #9
Source File: router.py From AMS with Apache License 2.0 | 6 votes |
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 })
Example #10
Source File: FrameRate.py From blender-ue4-live-link with GNU General Public License v3.0 | 6 votes |
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)
Example #11
Source File: router.py From AMS with Apache License 2.0 | 6 votes |
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 })
Example #12
Source File: MyDoubleValidator.py From pyweed with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #13
Source File: stats.py From empyrical with Apache License 2.0 | 5 votes |
def gpd_loglikelihood_scale_only(scale, price_data): n = len(price_data) data_sum = price_data.sum() result = -1 * float_info.max if (scale >= 0): result = ((-n*np.log(scale)) - (data_sum/scale)) return result
Example #14
Source File: stats.py From empyrical with Apache License 2.0 | 5 votes |
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
Example #15
Source File: univariatenormalestimator.py From HoeffdingTree with GNU General Public License v3.0 | 5 votes |
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
Example #16
Source File: univariatenormalestimator.py From HoeffdingTree with GNU General Public License v3.0 | 5 votes |
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)
Example #17
Source File: decision_tree.py From dislib with Apache License 2.0 | 5 votes |
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)
Example #18
Source File: decision_tree.py From dislib with Apache License 2.0 | 5 votes |
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
Example #19
Source File: decision_tree.py From dislib with Apache License 2.0 | 5 votes |
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.')
Example #20
Source File: test_split.py From dislib with Apache License 2.0 | 5 votes |
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
Example #21
Source File: align.py From bioinformatics with GNU General Public License v3.0 | 5 votes |
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
Example #22
Source File: decision_tree.py From dislib with Apache License 2.0 | 4 votes |
def fit(self, dataset): """Fits the DecisionTreeClassifier. Parameters ---------- dataset : dislib.classification.rf._data.RfDataset """ self.n_features = dataset.get_n_features() self.n_classes = dataset.get_n_classes() samples_path = dataset.samples_path features_path = dataset.features_path n_samples = dataset.get_n_samples() y_codes = dataset.get_y_codes() seed = self.random_state.randint(np.iinfo(np.int32).max) sample, y_s = _sample_selection(n_samples, y_codes, self.bootstrap, seed) self.tree = _Node() self.nodes_info = [] self.subtrees = [] tree_traversal = [(self.tree, sample, y_s, 0)] while tree_traversal: node, sample, y_s, depth = tree_traversal.pop() if depth < self.distr_depth: split = _split_node_wrapper(sample, self.n_features, y_s, self.n_classes, self.try_features, self.random_state, samples_file=samples_path, features_file=features_path) node_info, left_group, y_l, right_group, y_r = split compss_delete_object(sample) compss_delete_object(y_s) node.content = len(self.nodes_info) self.nodes_info.append(node_info) node.left = _Node() node.right = _Node() depth = depth + 1 tree_traversal.append((node.right, right_group, y_r, depth)) tree_traversal.append((node.left, left_group, y_l, depth)) else: subtree = _build_subtree_wrapper(sample, y_s, self.n_features, self.max_depth - depth, self.n_classes, self.try_features, self.sklearn_max, self.random_state, samples_path, features_path) node.content = len(self.subtrees) self.subtrees.append(subtree) compss_delete_object(sample) compss_delete_object(y_s) self.nodes_info = _merge(*self.nodes_info)
Example #23
Source File: align.py From bioinformatics with GNU General Public License v3.0 | 4 votes |
def san_kai(s,t, replace_score=blosum62,sigma=11,epsilon=1,backtrack=unwind_moves): def match(pair,replace_score=replace_score): def reverse(pair): a,b=pair return (b,a) return replace_score[pair] if pair in replace_score else replace_score[reverse(pair)] lower = create_distance_matrix(len(s)+1,len(t)+1) middle = create_distance_matrix(len(s)+1,len(t)+1) upper = create_distance_matrix(len(s)+1,len(t)+1) moves = {} lower[0][0] = -float('inf') middle[0][0] = 0 upper[0][0] = -float('inf') for i in range(1,len(s)+1): lower[i][0] = - (sigma + epsilon *(i-1)) middle[i][0] = - (sigma + epsilon *(i-1)) #-float('inf') upper[i][0] = - (sigma + epsilon *(i-1))# -float('inf') for j in range(1,len(t)+1): lower[0][j] = - (sigma + epsilon *(j-1))#-float('inf') middle[0][j] = - (sigma + epsilon *(j-1)) #-float('inf') upper[0][j] = - (sigma + epsilon *(j-1)) for i in range(1,len(s)+1): for j in range(1,len(t)+1): lower[i][j] = max(lower[i-1][j] - epsilon, middle[i-1][j] - sigma) upper[i][j] = max(upper[i][j-1] - epsilon, middle[i][j-1] - sigma) choices = [lower[i][j], middle[i-1][j-1] + match((s[i-1],t[j-1])), upper[i][j]] index = argmax(choices) middle[i][j] = choices[index] moves[(i,j)] = [(i-1, j, s[i-1], '-'), # Comes from lower (i-1, j-1, s[i-1], t[j-1]), # Comes from middle (i, j-1, '-', t[j-1] # Comes from upper )][index] return backtrack(moves,middle[len(s)][len(t)],len(s),len(t))
Example #24
Source File: align.py From bioinformatics with GNU General Public License v3.0 | 4 votes |
def longest_path(source,sink,graph): def initialize_s(): s={} for a,b,_ in graph: s[a]=-float_info.max s[b]=-float_info.max s[source]=0 return s def create_adjacency_list(): adjacency_list={} for a,b,w in graph: if not a in adjacency_list: adjacency_list[a]=[] adjacency_list[a].append(b) return adjacency_list def create_weights(): weights={} for a,b,w in graph: weights[(a,b)]=w return weights def calculate_distances(ordering): s=initialize_s() weights=create_weights() predecessors={} for b in ordering: for a in ordering: if a==b: break new_s=max(s[b],s[a]+(weights[(a,b)] if (a,b) in weights else 0)) if new_s>s[b]: s[b]=new_s predecessors[b]=a return (s,predecessors) def create_path(predecessors): path=[sink] node=sink while node in predecessors: node=predecessors[node] path.append(node) return path s,predecessors=calculate_distances(topological_order(create_adjacency_list())) return (s[sink],create_path(predecessors)[::-1]) # BA5F Find a Highest-Scoring Local Alignment of Two Strings # # common code # BA5E Find a Highest-Scoring Alignment of Two Strings # create_distance_matrix