text stringlengths 0 828 |
|---|
""""""Parse plowup's output. |
For now, we just return the last line. |
:param hostname: Name of host you are working with. |
:type hostname: str |
:param output: Dictionary containing information about a plowshare |
action. |
:type output: dict |
:returns: Parsed and decoded output list. |
:rtype: list |
"""""" |
if isinstance(output, bytes): |
output = output.decode('utf-8') |
return output.split()[-1]" |
1027,"def set(self, keyword, default, from_env=True): |
"""""" |
Set value on self if not already set. If unset, attempt to |
retrieve from environment variable of same name (unless disabled |
via 'from_env'). If 'default' value is not a string, evaluate |
environment variable as a Python type. If no env variables are |
found, fallback to 'default' value. |
"""""" |
env_key = '{}{}'.format(self.ENV_PREFIX, keyword.upper()) |
if hasattr(self, keyword): |
return getattr(self, keyword) |
value = default |
if from_env and (env_key in env): |
env_val = env.get(env_key) |
should_eval = not isinstance(default, str) |
try: |
value = literal_eval(env_val) if should_eval else env_val |
except (ValueError, SyntaxError): |
raise ValueError(""Unable to cast %r to %r"" % ( |
env_val, type.__name__)) |
setattr(self, keyword, value) |
return getattr(self, keyword)" |
1028,"def _generate_queues(queues, exchange, platform_queue): |
"""""" Queues known by this worker """""" |
return set([ |
Queue('celery', exchange, routing_key='celery'), |
Queue(platform_queue, exchange, routing_key='#'), |
] + [ |
Queue(q_name, exchange, routing_key=q_name) |
for q_name in queues |
])" |
1029,"def _erf(x): |
"""""" |
Port of cephes ``ndtr.c`` ``erf`` function. |
See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c |
"""""" |
T = [ |
9.60497373987051638749E0, |
9.00260197203842689217E1, |
2.23200534594684319226E3, |
7.00332514112805075473E3, |
5.55923013010394962768E4, |
] |
U = [ |
3.35617141647503099647E1, |
5.21357949780152679795E2, |
4.59432382970980127987E3, |
2.26290000613890934246E4, |
4.92673942608635921086E4, |
] |
# Shorcut special cases |
if x == 0: |
return 0 |
if x >= MAXVAL: |
return 1 |
if x <= -MAXVAL: |
return -1 |
if abs(x) > 1: |
return 1 - erfc(x) |
z = x * x |
return x * _polevl(z, T, 4) / _p1evl(z, U, 5)" |
1030,"def _erfc(a): |
"""""" |
Port of cephes ``ndtr.c`` ``erfc`` function. |
See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c |
"""""" |
# approximation for abs(a) < 8 and abs(a) >= 1 |
P = [ |
2.46196981473530512524E-10, |
5.64189564831068821977E-1, |
7.46321056442269912687E0, |
4.86371970985681366614E1, |
1.96520832956077098242E2, |
5.26445194995477358631E2, |
9.34528527171957607540E2, |
1.02755188689515710272E3, |
5.57535335369399327526E2, |
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.