本文整理汇总了Python中pyLibrary.maths.Math.max方法的典型用法代码示例。如果您正苦于以下问题:Python Math.max方法的具体用法?Python Math.max怎么用?Python Math.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyLibrary.maths.Math
的用法示例。
在下文中一共展示了Math.max方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyLibrary.maths import Math [as 别名]
# 或者: from pyLibrary.maths.Math import max [as 别名]
def __init__(self, **desc):
Domain.__init__(self, **desc)
self.type = "range"
self.NULL = Null
if self.partitions:
# IGNORE THE min, max, interval
if not self.key:
Log.error("Must have a key value")
parts = listwrap(self.partitions)
for i, p in enumerate(parts):
self.min = Math.min(self.min, p.min)
self.max = Math.max(self.max, p.max)
if p.dataIndex != None and p.dataIndex != i:
Log.error("Expecting `dataIndex` to agree with the order of the parts")
if p[self.key] == None:
Log.error("Expecting all parts to have {{key}} as a property", key=self.key)
p.dataIndex = i
# VERIFY PARTITIONS DO NOT OVERLAP, HOLES ARE FINE
for p, q in itertools.product(parts, parts):
if p.min <= q.min and q.min < p.max:
Log.error("partitions overlap!")
self.partitions = parts
return
elif any([self.min == None, self.max == None, self.interval == None]):
Log.error("Can not handle missing parameter")
self.key = "min"
self.partitions = wrap([{"min": v, "max": v + self.interval, "dataIndex": i} for i, v in enumerate(frange(self.min, self.max, self.interval))])
示例2: full_etl
# 需要导入模块: from pyLibrary.maths import Math [as 别名]
# 或者: from pyLibrary.maths.Math import max [as 别名]
def full_etl(settings, sink, bugs):
with Timer("process block {{start}}", {"start": min(bugs)}):
es = elasticsearch.Index(settings.source)
with FromES(es) as esq:
versions = esq.query({
"from": "bugs",
"select": "*",
"where": {"terms": {"bug_id": bugs}}
})
starts = qb.run({
"select": [
"bug_id",
"bug_status",
{"name": "attach_id", "value": "attachments.attach_id"},
{"name": "request_time", "value": "modified_ts"},
{"name": "request_type", "value": "attachments.flags.request_type"},
{"name": "reviewer", "value": "attachments.flags.requestee"},
{"name": "created_by", "value": "attachments.created_by"},
"product",
"component"
],
"from":
versions,
"where":
{"and": [
{"terms": {"attachments.flags.request_status": ["?"]}},
{"terms": {"attachments.flags.request_type": TYPES}},
{"equal": ["attachments.flags.modified_ts", "modified_ts"]},
{"term": {"attachments.isobsolete": 0}}
]},
"sort": ["bug_id", "attach_id", "created_by"]
})
ends = qb.run({
"select": [
{"name": "bug_id", "value": "bug_id"},
"bug_status",
{"name": "attach_id", "value": "attachments.attach_id"},
{"name": "modified_ts", "value": lambda r: Math.max(r.modified_ts, r.attachments.modified_ts, r.attachments.flags.modified_ts)},
{"name": "reviewer", "value": "attachments.flags.requestee"},
{"name": "request_type", "value": "attachments.flags.request_type"},
{"name": "modified_by", "value": "attachments.flags.modified_by"},
{"name": "product", "value": "product"},
{"name": "component", "value": "component"},
{"name": "review_end_reason", "value": lambda r: 'done' if r.attachments.flags.request_status != '?' else ('obsolete' if r.attachments.isobsolete == 1 else 'closed')},
{"name": "review_result", "value": lambda r: '+' if r.attachments.flags.request_status == '+' else ('-' if r.attachments.flags.request_status == '-' else '?')}
],
"from":
versions,
"where":
{"and": [
{"terms": {"attachments.flags.request_type": TYPES}},
{"or": [
{"and": [# IF THE REQUESTEE SWITCHED THE ? FLAG, THEN IT IS DONE
{"term": {"attachments.flags.previous_status": "?"}},
{"not": {"term": {"attachments.flags.request_status": "?"}}},
{"equal": ["attachments.flags.modified_ts", "modified_ts"]}
]},
{"and": [# IF OBSOLETED THE ATTACHMENT, IT IS DONE
{"term": {"attachments.isobsolete": 1}},
{"term": {"previous_values.isobsolete_value": 0}}
]},
{"and": [# SOME BUGS ARE CLOSED WITHOUT REMOVING REVIEW
{"terms": {"bug_status": ["resolved", "verified", "closed"]}},
{"not": {"terms": {"previous_values.bug_status_value": ["resolved", "verified", "closed"]}}}
]}
]}
]}
})
# SOME ATTACHMENTS GO MISSING, CLOSE THEM TOO
closed_bugs = {b.bug_id: b for b in qb.filter(versions, {"and": [# SOME BUGS ARE CLOSED WITHOUT REMOVING REVIEW
{"terms": {"bug_status": ["resolved", "verified", "closed"]}},
{"range": {"expires_on": {"gte": Date.now().milli}}}
]})}
for s in starts:
if s.bug_id in closed_bugs:
e = closed_bugs[s.bug_id]
ends.append({
"bug_id": e.bug_id,
"bug_status": e.bug_status,
"attach_id": s.attach_id,
"modified_ts": e.modified_ts,
"reviewer": s.reviewer,
"request_type": s.request_type,
"modified_by": e.modified_by,
"product": e.product,
"component": e.component,
"review_end_reason": 'closed',
"review_result": '?'
})
# REVIEWS END WHEN REASSIGNED TO SOMEONE ELSE
changes = qb.run({
"select": [
"bug_id",
{"name": "attach_id", "value": "changes.attach_id"},
"modified_ts",
#.........这里部分代码省略.........