本文整理汇总了Python中sys.maxsize方法的典型用法代码示例。如果您正苦于以下问题:Python sys.maxsize方法的具体用法?Python sys.maxsize怎么用?Python sys.maxsize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sys
的用法示例。
在下文中一共展示了sys.maxsize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: map_onto_unit_simplex
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def map_onto_unit_simplex(rnd, method):
n_points, n_dim = rnd.shape
if method == "sum":
ret = rnd / rnd.sum(axis=1)[:, None]
elif method == "kraemer":
M = sys.maxsize
rnd *= M
rnd = rnd[:, :n_dim - 1]
rnd = np.column_stack([np.zeros(n_points), rnd, np.full(n_points, M)])
rnd = np.sort(rnd, axis=1)
ret = np.full((n_points, n_dim), np.nan)
for i in range(1, n_dim + 1):
ret[:, i - 1] = rnd[:, i] - rnd[:, i - 1]
ret /= M
else:
raise Exception("Invalid unit simplex mapping!")
return ret
示例2: findall
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def findall(self, string, pos=0, endpos=sys.maxsize):
"""Return a list of all non-overlapping matches of pattern in string."""
matchlist = []
state = _State(string, pos, endpos, self.flags)
while state.start <= state.end:
state.reset()
state.string_position = state.start
if not state.search(self._code):
break
match = SRE_Match(self, state)
if self.groups == 0 or self.groups == 1:
item = match.group(self.groups)
else:
item = match.groups("")
matchlist.append(item)
if state.string_position == state.start:
state.start += 1
else:
state.start = state.string_position
return matchlist
示例3: parse_tags_argument
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def parse_tags_argument(tags_arg, exclude):
pattern = re.compile(r"^(?P<tag>[^:]*)(?::(?P<from>\d+):(?P<to>\d+)?)?$")
tags = tags_arg.split(',')
Task.tags = []
for tag_spec in tags:
m = pattern.match(tag_spec)
if not m:
mx.abort('--tags option requires the format `name[:from:[to]]`: {0}'.format(tag_spec))
(tag, t_from, t_to) = m.groups()
if t_from:
if exclude:
mx.abort('-x option cannot be used tag ranges: {0}'.format(tag_spec))
frm = int(t_from)
to = int(t_to) if t_to else sys.maxsize
# insert range tuple
Task.tags_range[tag] = (frm, to)
# sanity check
if to <= frm:
mx.abort('`from` must be less than `to` for tag ranges: {0}'.format(tag_spec))
# init counter
Task.tags_count[tag] = 0
Task.tags.append(tag)
示例4: _render_trades
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def _render_trades(self, step_range, trades):
trades = [trade for sublist in trades.values() for trade in sublist]
for trade in trades:
if trade.step in range(sys.maxsize)[step_range]:
date = self.df.index.values[trade.step]
close = self.df['close'].values[trade.step]
color = 'green'
if trade.side is TradeSide.SELL:
color = 'red'
self.price_ax.annotate(' ', (date, close),
xytext=(date, close),
size="large",
arrowprops=dict(arrowstyle='simple', facecolor=color))
示例5: dijkstra
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def dijkstra(self, src):
dist = [sys.maxsize] * self.vert
dist[src] = 0
self.pathlist[0].append(src)
sptSet = [False] * self.vert
for cout in range(self.vert):
u = self.findmindist(dist, sptSet)
#if u == 225 :
# break
sptSet[u] = True
for v in range(self.vert):
if self.graph[u][v] > 0 and sptSet[v] == False and dist[v] > dist[u] + self.graph[u][v]:
dist[v] = dist[u] + self.graph[u][v]
self.pathlist[v] = self.pathlist[u] + [v]
#print(dist,"Changing")
#print("bhavin")
self.printshortestgraph(dist)
示例6: printshortestgraph
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def printshortestgraph(self, dist,src):
f = open('somefile.txt', 'a')
#print("Vertex tDistance from Source")
for node in range(self.vert):
if(node == src):
continue
if(node == self.vert - 1):
if(dist[node] != sys.maxsize):
print(dist[node],file = f)
else:
print(-1,file = f)
elif(dist[node] != sys.maxsize):
#print("From 0 to ", node ," - >",dist[node],end = " ")
#print(self.pathlist[node])
print(dist[node],end = ' ',file = f)
#f.write(dist[node] + " ")
elif(dist[node] == sys.maxsize):
#print("From 0 to ", node ," - >",-1,end = " ")
print(-1,end = ' ',file = f)
#f.write(-1 + " ")
#print('\n')
#f.write("\n")
示例7: dijkstra
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def dijkstra(self, src):
dist = [sys.maxsize] * self.vert
src = src - 1
dist[src] = 0
self.pathlist[0].append(src)
sptSet = [False] * self.vert
for cout in range(self.vert):
u = self.findmindist(dist, sptSet)
#if u == 225 :
# break
sptSet[u] = True
for v in range(self.vert):
if self.graph[u][v] > 0 and sptSet[v] == False and dist[v] > dist[u] + self.graph[u][v]:
dist[v] = dist[u] + self.graph[u][v]
self.pathlist[v] = self.pathlist[u] + [v]
#print(dist,"Changing")
#print("bhavin")
self.printshortestgraph(dist,src)
示例8: generate
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def generate(grammar, start=None, depth=None, n=None):
"""
Generates an iterator of all sentences from a CFG.
:param grammar: The Grammar used to generate sentences.
:param start: The Nonterminal from which to start generate sentences.
:param depth: The maximal depth of the generated tree.
:param n: The maximum number of sentences to return.
:return: An iterator of lists of terminal tokens.
"""
if not start:
start = grammar.start()
if depth is None:
depth = sys.maxsize
iter = _generate_all(grammar, [start], depth)
if n:
iter = itertools.islice(iter, n)
return iter
示例9: _make_boundary
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def _make_boundary(cls, text=None):
# Craft a random boundary. If text is given, ensure that the chosen
# boundary doesn't appear in the text.
token = random.randrange(sys.maxsize)
boundary = ('=' * 15) + (_fmt % token) + '=='
if text is None:
return boundary
b = boundary
counter = 0
while True:
cre = cls._compile_re('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
if not cre.search(text):
break
b = boundary + '.' + str(counter)
counter += 1
return b
示例10: bbox_corner_dist_measure
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def bbox_corner_dist_measure(crnr1, crnr2):
""" compute distance between box corners to replace iou
Args:
crnr1, crnr2: Nx3 points of box corners in camera axis (y points down)
output is a scalar between 0 and 1
"""
dist = sys.maxsize
for y in range(4):
rows = ([(x+y)%4 for x in range(4)] + [4+(x+y)%4 for x in range(4)])
d_ = np.linalg.norm(crnr2[rows, :] - crnr1, axis=1).sum() / 8.0
if d_ < dist:
dist = d_
u = sum([np.linalg.norm(x[0,:] - x[6,:]) for x in [crnr1, crnr2]])/2.0
measure = max(1.0 - dist/u, 0)
print(measure)
return measure
示例11: __init__
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def __init__(
self,
calls=15,
period=900,
raise_on_limit=False,
group_by=BY_HOST_AND_PORT,
clock=now,
):
self._max_calls = max(1, min(sys.maxsize, math.floor(calls)))
self._period = period
self._clock = clock
self._limiter_cache = {}
self._group_by = utils.no_op if group_by is None else group_by
if utils.is_subclass(raise_on_limit, Exception) or isinstance(
raise_on_limit, Exception
):
self._create_limit_reached_exception = raise_on_limit
elif raise_on_limit:
self._create_limit_reached_exception = (
self._create_rate_limit_exceeded
)
else:
self._create_limit_reached_exception = None
示例12: platform
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def platform():
ret = {
"arch": sys.maxsize > 2**32 and "x64" or "x86",
}
if xbmc.getCondVisibility("system.platform.android"):
ret["os"] = "android"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.linux"):
ret["os"] = "linux"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.xbox"):
system_platform = "xbox"
ret["arch"] = ""
elif xbmc.getCondVisibility("system.platform.windows"):
ret["os"] = "windows"
elif xbmc.getCondVisibility("system.platform.osx"):
ret["os"] = "darwin"
elif xbmc.getCondVisibility("system.platform.ios"):
ret["os"] = "ios"
ret["arch"] = "arm"
return ret
示例13: __init__
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def __init__(self, calls=15, period=900, clock=now(), raise_on_limit=True):
'''
Instantiate a RateLimitDecorator with some sensible defaults. By
default the Twitter rate limiting window is respected (15 calls every
15 minutes).
:param int calls: Maximum function invocations allowed within a time period.
:param float period: An upper bound time period (in seconds) before the rate limit resets.
:param function clock: An optional function retuning the current time.
:param bool raise_on_limit: A boolean allowing the caller to avoiding rasing an exception.
'''
self.clamped_calls = max(1, min(sys.maxsize, floor(calls)))
self.period = period
self.clock = clock
self.raise_on_limit = raise_on_limit
# Initialise the decorator state.
self.last_reset = clock()
self.num_calls = 0
# Add thread safety.
self.lock = threading.RLock()
示例14: leave_module
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def leave_module(self, node): # pylint: disable=unused-argument
for all_groups in six.itervalues(self._bad_names):
if len(all_groups) < 2:
continue
groups = collections.defaultdict(list)
min_warnings = sys.maxsize
for group in six.itervalues(all_groups):
groups[len(group)].append(group)
min_warnings = min(len(group), min_warnings)
if len(groups[min_warnings]) > 1:
by_line = sorted(groups[min_warnings],
key=lambda group: min(warning[0].lineno for warning in group))
warnings = itertools.chain(*by_line[1:])
else:
warnings = groups[min_warnings][0]
for args in warnings:
self._raise_name_warning(*args)
示例15: __getitem__
# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxsize [as 别名]
def __getitem__(self, item):
if self._cache_complete:
return self._cache[item]
elif isinstance(item, slice):
if item.step and item.step < 0:
return list(iter(self))[item]
else:
return list(itertools.islice(self,
item.start or 0,
item.stop or sys.maxsize,
item.step or 1))
elif item >= 0:
gen = iter(self)
try:
for i in range(item+1):
res = advance_iterator(gen)
except StopIteration:
raise IndexError
return res
else:
return list(iter(self))[item]