repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
rgmining/ria | ria/bipartite_sum.py | Reviewer.update_anomalous_score | def update_anomalous_score(self):
"""Update anomalous score.
New anomalous score is the summation of weighted differences
between current summary and reviews. The weights come from credibilities.
Therefore, the new anomalous score is defined as
.. math::
{\\rm ano... | python | def update_anomalous_score(self):
"""Update anomalous score.
New anomalous score is the summation of weighted differences
between current summary and reviews. The weights come from credibilities.
Therefore, the new anomalous score is defined as
.. math::
{\\rm ano... | [
"def",
"update_anomalous_score",
"(",
"self",
")",
":",
"old",
"=",
"self",
".",
"anomalous_score",
"products",
"=",
"self",
".",
"_graph",
".",
"retrieve_products",
"(",
"self",
")",
"self",
".",
"anomalous_score",
"=",
"sum",
"(",
"p",
".",
"summary",
".... | Update anomalous score.
New anomalous score is the summation of weighted differences
between current summary and reviews. The weights come from credibilities.
Therefore, the new anomalous score is defined as
.. math::
{\\rm anomalous}(r)
= \\sum_{p \\in P} \\m... | [
"Update",
"anomalous",
"score",
"."
] | train | https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite_sum.py#L38-L67 |
rgmining/ria | ria/bipartite_sum.py | BipartiteGraph.update | def update(self):
""" Update reviewers' anomalous scores and products' summaries.
The update consists of 2 steps;
Step1 (updating summaries):
Update summaries of products with anomalous scores of reviewers
and weight function. The weight is calculated by the manner in
... | python | def update(self):
""" Update reviewers' anomalous scores and products' summaries.
The update consists of 2 steps;
Step1 (updating summaries):
Update summaries of products with anomalous scores of reviewers
and weight function. The weight is calculated by the manner in
... | [
"def",
"update",
"(",
"self",
")",
":",
"res",
"=",
"super",
"(",
"BipartiteGraph",
",",
"self",
")",
".",
"update",
"(",
")",
"max_v",
"=",
"None",
"min_v",
"=",
"float",
"(",
"\"inf\"",
")",
"for",
"r",
"in",
"self",
".",
"reviewers",
":",
"max_v... | Update reviewers' anomalous scores and products' summaries.
The update consists of 2 steps;
Step1 (updating summaries):
Update summaries of products with anomalous scores of reviewers
and weight function. The weight is calculated by the manner in
:class:`ria.biparti... | [
"Update",
"reviewers",
"anomalous",
"scores",
"and",
"products",
"summaries",
"."
] | train | https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite_sum.py#L85-L120 |
kodexlab/reliure | reliure/utils/__init__.py | parse_bool | def parse_bool(value):
""" Convert a string to a boolean
>>> parse_bool(None)
False
>>> parse_bool("true")
True
>>> parse_bool("TRUE")
True
>>> parse_bool("yes")
True
>>> parse_bool("1")
True
>>> parse_bool("false")
False
>>> parse_bool("sqdf")
False
... | python | def parse_bool(value):
""" Convert a string to a boolean
>>> parse_bool(None)
False
>>> parse_bool("true")
True
>>> parse_bool("TRUE")
True
>>> parse_bool("yes")
True
>>> parse_bool("1")
True
>>> parse_bool("false")
False
>>> parse_bool("sqdf")
False
... | [
"def",
"parse_bool",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"False",
"if",
"value",
"is",
"True",
"or",
"value",
"is",
"False",
":",
"return",
"value",
"boolean",
"=",
"str",
"(",
"value",
")",
".",
"strip",
"(",
")",
"... | Convert a string to a boolean
>>> parse_bool(None)
False
>>> parse_bool("true")
True
>>> parse_bool("TRUE")
True
>>> parse_bool("yes")
True
>>> parse_bool("1")
True
>>> parse_bool("false")
False
>>> parse_bool("sqdf")
False
>>> parse_bool(False)
False... | [
"Convert",
"a",
"string",
"to",
"a",
"boolean",
">>>",
"parse_bool",
"(",
"None",
")",
"False",
">>>",
"parse_bool",
"(",
"true",
")",
"True",
">>>",
"parse_bool",
"(",
"TRUE",
")",
"True",
">>>",
"parse_bool",
"(",
"yes",
")",
"True",
">>>",
"parse_bool... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/utils/__init__.py#L17-L44 |
kodexlab/reliure | reliure/utils/__init__.py | deprecated | def deprecated(new_fct_name, logger=None):
""" Decorator to notify that a fct is deprecated
"""
if logger is None:
logger = logging.getLogger("kodex")
nfct_name = new_fct_name
def aux_deprecated(func):
"""This is a decorator which can be used to mark functions
as deprecated. ... | python | def deprecated(new_fct_name, logger=None):
""" Decorator to notify that a fct is deprecated
"""
if logger is None:
logger = logging.getLogger("kodex")
nfct_name = new_fct_name
def aux_deprecated(func):
"""This is a decorator which can be used to mark functions
as deprecated. ... | [
"def",
"deprecated",
"(",
"new_fct_name",
",",
"logger",
"=",
"None",
")",
":",
"if",
"logger",
"is",
"None",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"kodex\"",
")",
"nfct_name",
"=",
"new_fct_name",
"def",
"aux_deprecated",
"(",
"func",
")... | Decorator to notify that a fct is deprecated | [
"Decorator",
"to",
"notify",
"that",
"a",
"fct",
"is",
"deprecated"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/utils/__init__.py#L52-L71 |
kodexlab/reliure | reliure/utils/__init__.py | engine_schema | def engine_schema(engine, out_names=None, filename=None, format="pdf"):
""" Build a graphviz schema of a reliure :class:`.Engine`.
It depends on `graphviz <https://pypi.python.org/pypi/graphviz>`_.
:param engine: reliure engine to graph
:type engine: :class:`.Engine`
:param out_names: list of ... | python | def engine_schema(engine, out_names=None, filename=None, format="pdf"):
""" Build a graphviz schema of a reliure :class:`.Engine`.
It depends on `graphviz <https://pypi.python.org/pypi/graphviz>`_.
:param engine: reliure engine to graph
:type engine: :class:`.Engine`
:param out_names: list of ... | [
"def",
"engine_schema",
"(",
"engine",
",",
"out_names",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"format",
"=",
"\"pdf\"",
")",
":",
"import",
"graphviz",
"as",
"pgv",
"#engine.validate()",
"dg",
"=",
"pgv",
".",
"Digraph",
"(",
"format",
"=",
"f... | Build a graphviz schema of a reliure :class:`.Engine`.
It depends on `graphviz <https://pypi.python.org/pypi/graphviz>`_.
:param engine: reliure engine to graph
:type engine: :class:`.Engine`
:param out_names: list of block output to consider as engine output (all by default)
:param filename: ... | [
"Build",
"a",
"graphviz",
"schema",
"of",
"a",
"reliure",
":",
"class",
":",
".",
"Engine",
".",
"It",
"depends",
"on",
"graphviz",
"<https",
":",
"//",
"pypi",
".",
"python",
".",
"org",
"/",
"pypi",
"/",
"graphviz",
">",
"_",
"."
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/utils/__init__.py#L74-L142 |
gfranxman/utinypass | utinypass/crypto.py | blockgen | def blockgen(bytes, block_size=16):
''' a block generator for pprp '''
for i in range(0, len(bytes), block_size):
block = bytes[i:i + block_size]
block_len = len(block)
if block_len > 0:
yield block
if block_len < block_size:
break | python | def blockgen(bytes, block_size=16):
''' a block generator for pprp '''
for i in range(0, len(bytes), block_size):
block = bytes[i:i + block_size]
block_len = len(block)
if block_len > 0:
yield block
if block_len < block_size:
break | [
"def",
"blockgen",
"(",
"bytes",
",",
"block_size",
"=",
"16",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"bytes",
")",
",",
"block_size",
")",
":",
"block",
"=",
"bytes",
"[",
"i",
":",
"i",
"+",
"block_size",
"]",
"block_le... | a block generator for pprp | [
"a",
"block",
"generator",
"for",
"pprp"
] | train | https://github.com/gfranxman/utinypass/blob/c49cff25ae408dbbb58ec98d1c87894474011cdf/utinypass/crypto.py#L78-L86 |
lehins/python-wepay | wepay/calls/user.py | User.__register | def __register(self, client_id, client_secret, email, scope, first_name,
last_name, original_ip, original_device, **kwargs):
"""Call documentation: `/user/register
<https://www.wepay.com/developer/reference/user#register>`_, plus
extra keyword parameter:
:keyw... | python | def __register(self, client_id, client_secret, email, scope, first_name,
last_name, original_ip, original_device, **kwargs):
"""Call documentation: `/user/register
<https://www.wepay.com/developer/reference/user#register>`_, plus
extra keyword parameter:
:keyw... | [
"def",
"__register",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"email",
",",
"scope",
",",
"first_name",
",",
"last_name",
",",
"original_ip",
",",
"original_device",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'client_id'",
":"... | Call documentation: `/user/register
<https://www.wepay.com/developer/reference/user#register>`_, plus
extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `reference_id` param fo... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"register",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user#register",
">",
"_",
"plus",
"extra",
"keyword",
"parameter",
":",
":",
"keyword",
"bool",
"b... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L59-L89 |
lehins/python-wepay | wepay/calls/user.py | MFA.__create | def __create(self, type, **kwargs):
"""Call documentation: `/user/mfa/create
<https://www.wepay.com/developer/reference/user-mfa#create>`_, plus
extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyw... | python | def __create(self, type, **kwargs):
"""Call documentation: `/user/mfa/create
<https://www.wepay.com/developer/reference/user-mfa#create>`_, plus
extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyw... | [
"def",
"__create",
"(",
"self",
",",
"type",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'type'",
":",
"type",
"}",
"return",
"self",
".",
"make_call",
"(",
"self",
".",
"__create",
",",
"params",
",",
"kwargs",
")"
] | Call documentation: `/user/mfa/create
<https://www.wepay.com/developer/reference/user-mfa#create>`_, plus
extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `reference_id` para... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"mfa",
"/",
"create",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user",
"-",
"mfa#create",
">",
"_",
"plus",
"extra",
"keyword",
"parameter",
":",
":",... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L128-L146 |
lehins/python-wepay | wepay/calls/user.py | MFA.__validate_cookie | def __validate_cookie(self, mfa_id, cookie, **kwargs):
"""Call documentation: `/user/mfa/validate_cookie
<https://www.wepay.com/developer/reference/user-mfa#validate_cookie>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:c... | python | def __validate_cookie(self, mfa_id, cookie, **kwargs):
"""Call documentation: `/user/mfa/validate_cookie
<https://www.wepay.com/developer/reference/user-mfa#validate_cookie>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:c... | [
"def",
"__validate_cookie",
"(",
"self",
",",
"mfa_id",
",",
"cookie",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'mfa_id'",
":",
"mfa_id",
",",
"'cookie'",
":",
"cookie",
"}",
"return",
"self",
".",
"make_call",
"(",
"self",
".",
"__valid... | Call documentation: `/user/mfa/validate_cookie
<https://www.wepay.com/developer/reference/user-mfa#validate_cookie>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"mfa",
"/",
"validate_cookie",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user",
"-",
"mfa#validate_cookie",
">",
"_",
"plus",
"extra",
"keyword",
"paramet... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L152-L171 |
lehins/python-wepay | wepay/calls/user.py | MFA.__send_challenge | def __send_challenge(self, mfa_id, **kwargs):
"""Call documentation: `/user/mfa/send_challenge
<https://www.wepay.com/developer/reference/user-mfa#send_challenge>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay... | python | def __send_challenge(self, mfa_id, **kwargs):
"""Call documentation: `/user/mfa/send_challenge
<https://www.wepay.com/developer/reference/user-mfa#send_challenge>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay... | [
"def",
"__send_challenge",
"(",
"self",
",",
"mfa_id",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'mfa_id'",
":",
"mfa_id",
"}",
"return",
"self",
".",
"make_call",
"(",
"self",
".",
"__send_challenge",
",",
"params",
",",
"kwargs",
")"
] | Call documentation: `/user/mfa/send_challenge
<https://www.wepay.com/developer/reference/user-mfa#send_challenge>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `re... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"mfa",
"/",
"send_challenge",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user",
"-",
"mfa#send_challenge",
">",
"_",
"plus",
"extra",
"keyword",
"parameter... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L177-L195 |
lehins/python-wepay | wepay/calls/user.py | MFA.__send_default_challenge | def __send_default_challenge(self, **kwargs):
"""Call documentation: `/user/mfa/send_default_challenge
<https://www.wepay.com/developer/reference/user-mfa#send_default_challenge>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
... | python | def __send_default_challenge(self, **kwargs):
"""Call documentation: `/user/mfa/send_default_challenge
<https://www.wepay.com/developer/reference/user-mfa#send_default_challenge>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
... | [
"def",
"__send_default_challenge",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"return",
"self",
".",
"make_call",
"(",
"self",
".",
"__send_default_challenge",
",",
"params",
",",
"kwargs",
")"
] | Call documentation: `/user/mfa/send_default_challenge
<https://www.wepay.com/developer/reference/user-mfa#send_default_challenge>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_r... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"mfa",
"/",
"send_default_challenge",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user",
"-",
"mfa#send_default_challenge",
">",
"_",
"plus",
"extra",
"keywor... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L201-L217 |
lehins/python-wepay | wepay/calls/user.py | MFA.__confirm | def __confirm(self, mfa_id, challenge, **kwargs):
"""Call documentation: `/user/mfa/confirm
<https://www.wepay.com/developer/reference/user-mfa#confirm>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay... | python | def __confirm(self, mfa_id, challenge, **kwargs):
"""Call documentation: `/user/mfa/confirm
<https://www.wepay.com/developer/reference/user-mfa#confirm>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay... | [
"def",
"__confirm",
"(",
"self",
",",
"mfa_id",
",",
"challenge",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'mfa_id'",
":",
"mfa_id",
",",
"'challenge'",
":",
"challenge",
"}",
"return",
"self",
".",
"make_call",
"(",
"self",
".",
"__conf... | Call documentation: `/user/mfa/confirm
<https://www.wepay.com/developer/reference/user-mfa#confirm>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `reference_id` pa... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"mfa",
"/",
"confirm",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user",
"-",
"mfa#confirm",
">",
"_",
"plus",
"extra",
"keyword",
"parameter",
":",
":... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L221-L240 |
lehins/python-wepay | wepay/calls/user.py | MFA.__modify | def __modify(self, mfa_id, **kwargs):
"""Call documentation: `/user/mfa/modify
<https://www.wepay.com/developer/reference/user-mfa#modify>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:ke... | python | def __modify(self, mfa_id, **kwargs):
"""Call documentation: `/user/mfa/modify
<https://www.wepay.com/developer/reference/user-mfa#modify>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:ke... | [
"def",
"__modify",
"(",
"self",
",",
"mfa_id",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'mfa_id'",
":",
"mfa_id",
"}",
"return",
"self",
".",
"make_call",
"(",
"self",
".",
"__modify",
",",
"params",
",",
"kwargs",
")"
] | Call documentation: `/user/mfa/modify
<https://www.wepay.com/developer/reference/user-mfa#modify>`_,
plus extra keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `reference_id` para... | [
"Call",
"documentation",
":",
"/",
"user",
"/",
"mfa",
"/",
"modify",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"user",
"-",
"mfa#modify",
">",
"_",
"plus",
"extra",
"keyword",
"parameter",
":",
":",... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/user.py#L268-L286 |
kodexlab/reliure | reliure/utils/log.py | get_basic_logger | def get_basic_logger(level=logging.WARN, scope='reliure'):
""" return a basic logger that print on stdout msg from reliure lib
"""
logger = logging.getLogger(scope)
logger.setLevel(level)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(level)
# c... | python | def get_basic_logger(level=logging.WARN, scope='reliure'):
""" return a basic logger that print on stdout msg from reliure lib
"""
logger = logging.getLogger(scope)
logger.setLevel(level)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(level)
# c... | [
"def",
"get_basic_logger",
"(",
"level",
"=",
"logging",
".",
"WARN",
",",
"scope",
"=",
"'reliure'",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"scope",
")",
"logger",
".",
"setLevel",
"(",
"level",
")",
"# create console handler with a higher... | return a basic logger that print on stdout msg from reliure lib | [
"return",
"a",
"basic",
"logger",
"that",
"print",
"on",
"stdout",
"msg",
"from",
"reliure",
"lib"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/utils/log.py#L20-L33 |
kodexlab/reliure | reliure/utils/log.py | get_app_logger_color | def get_app_logger_color(appname, app_log_level=logging.INFO, log_level=logging.WARN, logfile=None):
""" Configure the logging for an app using reliure (it log's both the app and reliure lib)
:param appname: the name of the application to log
:parap app_log_level: log level for the app
:param log_level... | python | def get_app_logger_color(appname, app_log_level=logging.INFO, log_level=logging.WARN, logfile=None):
""" Configure the logging for an app using reliure (it log's both the app and reliure lib)
:param appname: the name of the application to log
:parap app_log_level: log level for the app
:param log_level... | [
"def",
"get_app_logger_color",
"(",
"appname",
",",
"app_log_level",
"=",
"logging",
".",
"INFO",
",",
"log_level",
"=",
"logging",
".",
"WARN",
",",
"logfile",
"=",
"None",
")",
":",
"# create lib handler",
"stderr_handler",
"=",
"logging",
".",
"StreamHandler"... | Configure the logging for an app using reliure (it log's both the app and reliure lib)
:param appname: the name of the application to log
:parap app_log_level: log level for the app
:param log_level: log level for the reliure
:param logfile: file that store the log, time rotating file (by day), no if N... | [
"Configure",
"the",
"logging",
"for",
"an",
"app",
"using",
"reliure",
"(",
"it",
"log",
"s",
"both",
"the",
"app",
"and",
"reliure",
"lib",
")"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/utils/log.py#L76-L119 |
af/turrentine | turrentine/admin.py | ChangeableContentForm.save | def save(self, *args, **kwargs):
"""
Save the created_by and last_modified_by fields based on the current admin user.
"""
if not self.instance.id:
self.instance.created_by = self.user
self.instance.last_modified_by = self.user
return super(ChangeableContentFor... | python | def save(self, *args, **kwargs):
"""
Save the created_by and last_modified_by fields based on the current admin user.
"""
if not self.instance.id:
self.instance.created_by = self.user
self.instance.last_modified_by = self.user
return super(ChangeableContentFor... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"instance",
".",
"id",
":",
"self",
".",
"instance",
".",
"created_by",
"=",
"self",
".",
"user",
"self",
".",
"instance",
".",
"last_modifie... | Save the created_by and last_modified_by fields based on the current admin user. | [
"Save",
"the",
"created_by",
"and",
"last_modified_by",
"fields",
"based",
"on",
"the",
"current",
"admin",
"user",
"."
] | train | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/admin.py#L19-L26 |
af/turrentine | turrentine/admin.py | PageAdmin.get_urls | def get_urls(self):
"""
Add our preview view to our urls.
"""
urls = super(PageAdmin, self).get_urls()
my_urls = patterns('',
(r'^add/preview$', self.admin_site.admin_view(PagePreviewView.as_view())),
(r'^(?P<id>\d+)/preview$', self.admin_site.admin_view(P... | python | def get_urls(self):
"""
Add our preview view to our urls.
"""
urls = super(PageAdmin, self).get_urls()
my_urls = patterns('',
(r'^add/preview$', self.admin_site.admin_view(PagePreviewView.as_view())),
(r'^(?P<id>\d+)/preview$', self.admin_site.admin_view(P... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"urls",
"=",
"super",
"(",
"PageAdmin",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"my_urls",
"=",
"patterns",
"(",
"''",
",",
"(",
"r'^add/preview$'",
",",
"self",
".",
"admin_site",
".",
"admin_view",
"(",
... | Add our preview view to our urls. | [
"Add",
"our",
"preview",
"view",
"to",
"our",
"urls",
"."
] | train | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/admin.py#L101-L111 |
af/turrentine | turrentine/admin.py | PagePreviewView.get_template_names | def get_template_names(self):
"""
Return the page's specified template name, or a fallback if one hasn't been chosen.
"""
posted_name = self.request.POST.get('template_name')
if posted_name:
return [posted_name,]
else:
return super(PagePreviewView,... | python | def get_template_names(self):
"""
Return the page's specified template name, or a fallback if one hasn't been chosen.
"""
posted_name = self.request.POST.get('template_name')
if posted_name:
return [posted_name,]
else:
return super(PagePreviewView,... | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"posted_name",
"=",
"self",
".",
"request",
".",
"POST",
".",
"get",
"(",
"'template_name'",
")",
"if",
"posted_name",
":",
"return",
"[",
"posted_name",
",",
"]",
"else",
":",
"return",
"super",
"(",
"... | Return the page's specified template name, or a fallback if one hasn't been chosen. | [
"Return",
"the",
"page",
"s",
"specified",
"template",
"name",
"or",
"a",
"fallback",
"if",
"one",
"hasn",
"t",
"been",
"chosen",
"."
] | train | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/admin.py#L135-L143 |
af/turrentine | turrentine/admin.py | PagePreviewView.post | def post(self, request, *args, **kwargs):
"""
Accepts POST requests, and substitute the data in for the page's attributes.
"""
self.object = self.get_object()
self.object.content = request.POST['content']
self.object.title = request.POST['title']
self.object = se... | python | def post(self, request, *args, **kwargs):
"""
Accepts POST requests, and substitute the data in for the page's attributes.
"""
self.object = self.get_object()
self.object.content = request.POST['content']
self.object.title = request.POST['title']
self.object = se... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"self",
".",
"object",
".",
"content",
"=",
"request",
".",
"POST",
"[",
"'content'",
... | Accepts POST requests, and substitute the data in for the page's attributes. | [
"Accepts",
"POST",
"requests",
"and",
"substitute",
"the",
"data",
"in",
"for",
"the",
"page",
"s",
"attributes",
"."
] | train | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/admin.py#L145-L155 |
hitchtest/hitchserve | hitchserve/service_bundle.py | ServiceBundle.redirect_stdout | def redirect_stdout(self):
"""Redirect stdout to file so that it can be tailed and aggregated with the other logs."""
self.hijacked_stdout = sys.stdout
self.hijacked_stderr = sys.stderr
# 0 must be set as the buffer, otherwise lines won't get logged in time.
sys.stdout = open(sel... | python | def redirect_stdout(self):
"""Redirect stdout to file so that it can be tailed and aggregated with the other logs."""
self.hijacked_stdout = sys.stdout
self.hijacked_stderr = sys.stderr
# 0 must be set as the buffer, otherwise lines won't get logged in time.
sys.stdout = open(sel... | [
"def",
"redirect_stdout",
"(",
"self",
")",
":",
"self",
".",
"hijacked_stdout",
"=",
"sys",
".",
"stdout",
"self",
".",
"hijacked_stderr",
"=",
"sys",
".",
"stderr",
"# 0 must be set as the buffer, otherwise lines won't get logged in time.",
"sys",
".",
"stdout",
"="... | Redirect stdout to file so that it can be tailed and aggregated with the other logs. | [
"Redirect",
"stdout",
"to",
"file",
"so",
"that",
"it",
"can",
"be",
"tailed",
"and",
"aggregated",
"with",
"the",
"other",
"logs",
"."
] | train | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_bundle.py#L202-L208 |
hitchtest/hitchserve | hitchserve/service_bundle.py | ServiceBundle.unredirect_stdout | def unredirect_stdout(self):
"""Redirect stdout and stderr back to screen."""
if hasattr(self, 'hijacked_stdout') and hasattr(self, 'hijacked_stderr'):
sys.stdout = self.hijacked_stdout
sys.stderr = self.hijacked_stderr | python | def unredirect_stdout(self):
"""Redirect stdout and stderr back to screen."""
if hasattr(self, 'hijacked_stdout') and hasattr(self, 'hijacked_stderr'):
sys.stdout = self.hijacked_stdout
sys.stderr = self.hijacked_stderr | [
"def",
"unredirect_stdout",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'hijacked_stdout'",
")",
"and",
"hasattr",
"(",
"self",
",",
"'hijacked_stderr'",
")",
":",
"sys",
".",
"stdout",
"=",
"self",
".",
"hijacked_stdout",
"sys",
".",
"stder... | Redirect stdout and stderr back to screen. | [
"Redirect",
"stdout",
"and",
"stderr",
"back",
"to",
"screen",
"."
] | train | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_bundle.py#L210-L214 |
hitchtest/hitchserve | hitchserve/service_bundle.py | ServiceBundle.time_travel | def time_travel(self, datetime=None, timedelta=None, seconds=0, minutes=0, hours=0, days=0):
"""Mock moving forward or backward in time by shifting the system clock fed to the services tested.
Note that all of these arguments can be used together, individually or not at all. The time
traveled t... | python | def time_travel(self, datetime=None, timedelta=None, seconds=0, minutes=0, hours=0, days=0):
"""Mock moving forward or backward in time by shifting the system clock fed to the services tested.
Note that all of these arguments can be used together, individually or not at all. The time
traveled t... | [
"def",
"time_travel",
"(",
"self",
",",
"datetime",
"=",
"None",
",",
"timedelta",
"=",
"None",
",",
"seconds",
"=",
"0",
",",
"minutes",
"=",
"0",
",",
"hours",
"=",
"0",
",",
"days",
"=",
"0",
")",
":",
"if",
"datetime",
"is",
"not",
"None",
":... | Mock moving forward or backward in time by shifting the system clock fed to the services tested.
Note that all of these arguments can be used together, individually or not at all. The time
traveled to will be the sum of all specified time deltas from datetime. If no datetime is specified,
the d... | [
"Mock",
"moving",
"forward",
"or",
"backward",
"in",
"time",
"by",
"shifting",
"the",
"system",
"clock",
"fed",
"to",
"the",
"services",
"tested",
"."
] | train | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_bundle.py#L261-L285 |
hitchtest/hitchserve | hitchserve/service_bundle.py | ServiceBundle.wait_for_ipykernel | def wait_for_ipykernel(self, service_name, timeout=10):
"""Wait for an IPython kernel-nnnn.json filename message to appear in log."""
kernel_line = self._services[service_name].logs.tail.until(
lambda line: "--existing" in line[1], timeout=10, lines_back=5
)
return kernel_lin... | python | def wait_for_ipykernel(self, service_name, timeout=10):
"""Wait for an IPython kernel-nnnn.json filename message to appear in log."""
kernel_line = self._services[service_name].logs.tail.until(
lambda line: "--existing" in line[1], timeout=10, lines_back=5
)
return kernel_lin... | [
"def",
"wait_for_ipykernel",
"(",
"self",
",",
"service_name",
",",
"timeout",
"=",
"10",
")",
":",
"kernel_line",
"=",
"self",
".",
"_services",
"[",
"service_name",
"]",
".",
"logs",
".",
"tail",
".",
"until",
"(",
"lambda",
"line",
":",
"\"--existing\""... | Wait for an IPython kernel-nnnn.json filename message to appear in log. | [
"Wait",
"for",
"an",
"IPython",
"kernel",
"-",
"nnnn",
".",
"json",
"filename",
"message",
"to",
"appear",
"in",
"log",
"."
] | train | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_bundle.py#L294-L299 |
hitchtest/hitchserve | hitchserve/service_bundle.py | ServiceBundle.connect_to_ipykernel | def connect_to_ipykernel(self, service_name, timeout=10):
"""Connect to an IPython kernel as soon as its message is logged."""
kernel_json_file = self.wait_for_ipykernel(service_name, timeout=10)
self.start_interactive_mode()
subprocess.check_call([
sys.executable, "-m", "IPy... | python | def connect_to_ipykernel(self, service_name, timeout=10):
"""Connect to an IPython kernel as soon as its message is logged."""
kernel_json_file = self.wait_for_ipykernel(service_name, timeout=10)
self.start_interactive_mode()
subprocess.check_call([
sys.executable, "-m", "IPy... | [
"def",
"connect_to_ipykernel",
"(",
"self",
",",
"service_name",
",",
"timeout",
"=",
"10",
")",
":",
"kernel_json_file",
"=",
"self",
".",
"wait_for_ipykernel",
"(",
"service_name",
",",
"timeout",
"=",
"10",
")",
"self",
".",
"start_interactive_mode",
"(",
"... | Connect to an IPython kernel as soon as its message is logged. | [
"Connect",
"to",
"an",
"IPython",
"kernel",
"as",
"soon",
"as",
"its",
"message",
"is",
"logged",
"."
] | train | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_bundle.py#L301-L308 |
EventTeam/beliefs | src/beliefs/referent.py | TaxonomyCell.build_class_graph | def build_class_graph(modules, klass=None, graph=None):
""" Builds up a graph of the DictCell subclass structure """
if klass is None:
class_graph = nx.DiGraph()
for name, classmember in inspect.getmembers(modules, inspect.isclass):
if issubclass(classmember, Refe... | python | def build_class_graph(modules, klass=None, graph=None):
""" Builds up a graph of the DictCell subclass structure """
if klass is None:
class_graph = nx.DiGraph()
for name, classmember in inspect.getmembers(modules, inspect.isclass):
if issubclass(classmember, Refe... | [
"def",
"build_class_graph",
"(",
"modules",
",",
"klass",
"=",
"None",
",",
"graph",
"=",
"None",
")",
":",
"if",
"klass",
"is",
"None",
":",
"class_graph",
"=",
"nx",
".",
"DiGraph",
"(",
")",
"for",
"name",
",",
"classmember",
"in",
"inspect",
".",
... | Builds up a graph of the DictCell subclass structure | [
"Builds",
"up",
"a",
"graph",
"of",
"the",
"DictCell",
"subclass",
"structure"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/referent.py#L45-L62 |
EventTeam/beliefs | src/beliefs/referent.py | Referent.cells_from_defaults | def cells_from_defaults(clz, jsonobj):
""" Creates a referent instance of type `json.kind` and
initializes it to default values.
"""
# convert strings to dicts
if isinstance(jsonobj, (str, unicode)):
jsonobj = json.loads(jsonobj)
assert 'cells' in js... | python | def cells_from_defaults(clz, jsonobj):
""" Creates a referent instance of type `json.kind` and
initializes it to default values.
"""
# convert strings to dicts
if isinstance(jsonobj, (str, unicode)):
jsonobj = json.loads(jsonobj)
assert 'cells' in js... | [
"def",
"cells_from_defaults",
"(",
"clz",
",",
"jsonobj",
")",
":",
"# convert strings to dicts",
"if",
"isinstance",
"(",
"jsonobj",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"jsonobj",
"=",
"json",
".",
"loads",
"(",
"jsonobj",
")",
"assert",
"'cel... | Creates a referent instance of type `json.kind` and
initializes it to default values. | [
"Creates",
"a",
"referent",
"instance",
"of",
"type",
"json",
".",
"kind",
"and",
"initializes",
"it",
"to",
"default",
"values",
"."
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/referent.py#L75-L96 |
EventTeam/beliefs | src/beliefs/referent.py | Referent.from_defaults | def from_defaults(clz, defaults):
""" Given a dictionary of defaults, ie {attribute: value},
this classmethod constructs a new instance of the class and
merges the defaults"""
if isinstance(defaults, (str, unicode)):
defaults = json.loads(defaults)
c = clz()
... | python | def from_defaults(clz, defaults):
""" Given a dictionary of defaults, ie {attribute: value},
this classmethod constructs a new instance of the class and
merges the defaults"""
if isinstance(defaults, (str, unicode)):
defaults = json.loads(defaults)
c = clz()
... | [
"def",
"from_defaults",
"(",
"clz",
",",
"defaults",
")",
":",
"if",
"isinstance",
"(",
"defaults",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"defaults",
"=",
"json",
".",
"loads",
"(",
"defaults",
")",
"c",
"=",
"clz",
"(",
")",
"for",
"attr... | Given a dictionary of defaults, ie {attribute: value},
this classmethod constructs a new instance of the class and
merges the defaults | [
"Given",
"a",
"dictionary",
"of",
"defaults",
"ie",
"{",
"attribute",
":",
"value",
"}",
"this",
"classmethod",
"constructs",
"a",
"new",
"instance",
"of",
"the",
"class",
"and",
"merges",
"the",
"defaults"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/referent.py#L100-L120 |
Ffisegydd/whatis | whatis/_iterable.py | get_element_types | def get_element_types(obj, **kwargs):
"""Get element types as a set."""
max_iterable_length = kwargs.get('max_iterable_length', 10000)
consume_generator = kwargs.get('consume_generator', False)
if not isiterable(obj):
return None
if isgenerator(obj) and not consume_generator:
retu... | python | def get_element_types(obj, **kwargs):
"""Get element types as a set."""
max_iterable_length = kwargs.get('max_iterable_length', 10000)
consume_generator = kwargs.get('consume_generator', False)
if not isiterable(obj):
return None
if isgenerator(obj) and not consume_generator:
retu... | [
"def",
"get_element_types",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"max_iterable_length",
"=",
"kwargs",
".",
"get",
"(",
"'max_iterable_length'",
",",
"10000",
")",
"consume_generator",
"=",
"kwargs",
".",
"get",
"(",
"'consume_generator'",
",",
"Fals... | Get element types as a set. | [
"Get",
"element",
"types",
"as",
"a",
"set",
"."
] | train | https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_iterable.py#L37-L57 |
ouroboroscoding/reconsider | reconsider.py | parseArgs | def parseArgs(args):
"""Parse Arguments
Used to parse the arguments passed to the script
Args:
args (list): A list of strings representing arguments to a script
Returns:
dict: Returns a dictionary with args as keys and the values sent with
them or True for valueless arguments
Raises:
ValueError: If ar... | python | def parseArgs(args):
"""Parse Arguments
Used to parse the arguments passed to the script
Args:
args (list): A list of strings representing arguments to a script
Returns:
dict: Returns a dictionary with args as keys and the values sent with
them or True for valueless arguments
Raises:
ValueError: If ar... | [
"def",
"parseArgs",
"(",
"args",
")",
":",
"# If args is not a list",
"if",
"not",
"isinstance",
"(",
"args",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"ValueError",
"(",
"'args is not a list or tuple'",
")",
"# Init the return value",
"dRet",
"=",... | Parse Arguments
Used to parse the arguments passed to the script
Args:
args (list): A list of strings representing arguments to a script
Returns:
dict: Returns a dictionary with args as keys and the values sent with
them or True for valueless arguments
Raises:
ValueError: If args is not a list or tuple | [
"Parse",
"Arguments"
] | train | https://github.com/ouroboroscoding/reconsider/blob/155061d72e757665f9d3fee5a8a9d6f31f6872ed/reconsider.py#L11-L53 |
ouroboroscoding/reconsider | reconsider.py | printHelp | def printHelp(script):
"""Print Help
Prints out the arguments needs to run the script
Returns:
None
"""
print 'Reconsider cli script copyright 2016 OuroborosCoding'
print ''
print script + ' --source=localhost:28015 --destination=somedomain.com:28015'
print script + ' --destination=somedomain.com:28015 --d... | python | def printHelp(script):
"""Print Help
Prints out the arguments needs to run the script
Returns:
None
"""
print 'Reconsider cli script copyright 2016 OuroborosCoding'
print ''
print script + ' --source=localhost:28015 --destination=somedomain.com:28015'
print script + ' --destination=somedomain.com:28015 --d... | [
"def",
"printHelp",
"(",
"script",
")",
":",
"print",
"'Reconsider cli script copyright 2016 OuroborosCoding'",
"print",
"''",
"print",
"script",
"+",
"' --source=localhost:28015 --destination=somedomain.com:28015'",
"print",
"script",
"+",
"' --destination=somedomain.com:28015 --d... | Print Help
Prints out the arguments needs to run the script
Returns:
None | [
"Print",
"Help"
] | train | https://github.com/ouroboroscoding/reconsider/blob/155061d72e757665f9d3fee5a8a9d6f31f6872ed/reconsider.py#L56-L84 |
xtrementl/focus | focus/plugin/modules/stats.py | Stats._setup_dir | def _setup_dir(self, base_dir):
""" Creates stats directory for storing stat files.
`base_dir`
Base directory.
"""
stats_dir = self._sdir(base_dir)
if not os.path.isdir(stats_dir):
try:
os.mkdir(stats_dir)
except O... | python | def _setup_dir(self, base_dir):
""" Creates stats directory for storing stat files.
`base_dir`
Base directory.
"""
stats_dir = self._sdir(base_dir)
if not os.path.isdir(stats_dir):
try:
os.mkdir(stats_dir)
except O... | [
"def",
"_setup_dir",
"(",
"self",
",",
"base_dir",
")",
":",
"stats_dir",
"=",
"self",
".",
"_sdir",
"(",
"base_dir",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"stats_dir",
")",
":",
"try",
":",
"os",
".",
"mkdir",
"(",
"stats_dir",
"... | Creates stats directory for storing stat files.
`base_dir`
Base directory. | [
"Creates",
"stats",
"directory",
"for",
"storing",
"stat",
"files",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L40-L52 |
xtrementl/focus | focus/plugin/modules/stats.py | Stats._log_task | def _log_task(self, task):
""" Logs task record to file.
`task`
``Task`` instance.
"""
if not task.duration:
return
self._setup_dir(task.base_dir)
stats_dir = self._sdir(task.base_dir)
duration = task.duration
while d... | python | def _log_task(self, task):
""" Logs task record to file.
`task`
``Task`` instance.
"""
if not task.duration:
return
self._setup_dir(task.base_dir)
stats_dir = self._sdir(task.base_dir)
duration = task.duration
while d... | [
"def",
"_log_task",
"(",
"self",
",",
"task",
")",
":",
"if",
"not",
"task",
".",
"duration",
":",
"return",
"self",
".",
"_setup_dir",
"(",
"task",
".",
"base_dir",
")",
"stats_dir",
"=",
"self",
".",
"_sdir",
"(",
"task",
".",
"base_dir",
")",
"dur... | Logs task record to file.
`task`
``Task`` instance. | [
"Logs",
"task",
"record",
"to",
"file",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L54-L112 |
xtrementl/focus | focus/plugin/modules/stats.py | Stats._fuzzy_time_parse | def _fuzzy_time_parse(self, value):
""" Parses a fuzzy time value into a meaningful interpretation.
`value`
String value to parse.
"""
value = value.lower().strip()
today = datetime.date.today()
if value in ('today', 't'):
return tod... | python | def _fuzzy_time_parse(self, value):
""" Parses a fuzzy time value into a meaningful interpretation.
`value`
String value to parse.
"""
value = value.lower().strip()
today = datetime.date.today()
if value in ('today', 't'):
return tod... | [
"def",
"_fuzzy_time_parse",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"today",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"if",
"value",
"in",
"(",
"'today'",
",",
"'t'",
... | Parses a fuzzy time value into a meaningful interpretation.
`value`
String value to parse. | [
"Parses",
"a",
"fuzzy",
"time",
"value",
"into",
"a",
"meaningful",
"interpretation",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L114-L152 |
xtrementl/focus | focus/plugin/modules/stats.py | Stats._get_stats | def _get_stats(self, task, start_date):
""" Fetches statistic information for given task and start range.
"""
stats = []
stats_dir = self._sdir(task.base_dir)
date = start_date
end_date = datetime.date.today()
delta = datetime.timedelta(days=1)
while... | python | def _get_stats(self, task, start_date):
""" Fetches statistic information for given task and start range.
"""
stats = []
stats_dir = self._sdir(task.base_dir)
date = start_date
end_date = datetime.date.today()
delta = datetime.timedelta(days=1)
while... | [
"def",
"_get_stats",
"(",
"self",
",",
"task",
",",
"start_date",
")",
":",
"stats",
"=",
"[",
"]",
"stats_dir",
"=",
"self",
".",
"_sdir",
"(",
"task",
".",
"base_dir",
")",
"date",
"=",
"start_date",
"end_date",
"=",
"datetime",
".",
"date",
".",
"... | Fetches statistic information for given task and start range. | [
"Fetches",
"statistic",
"information",
"for",
"given",
"task",
"and",
"start",
"range",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L154-L184 |
xtrementl/focus | focus/plugin/modules/stats.py | Stats._print_stats | def _print_stats(self, env, stats):
""" Prints statistic information using io stream.
`env`
``Environment`` object.
`stats`
Tuple of task stats for each date.
"""
def _format_time(mins):
""" Generates formatted time string... | python | def _print_stats(self, env, stats):
""" Prints statistic information using io stream.
`env`
``Environment`` object.
`stats`
Tuple of task stats for each date.
"""
def _format_time(mins):
""" Generates formatted time string... | [
"def",
"_print_stats",
"(",
"self",
",",
"env",
",",
"stats",
")",
":",
"def",
"_format_time",
"(",
"mins",
")",
":",
"\"\"\" Generates formatted time string.\n \"\"\"",
"mins",
"=",
"int",
"(",
"mins",
")",
"if",
"mins",
"<",
"MINS_IN_HOUR",
":",... | Prints statistic information using io stream.
`env`
``Environment`` object.
`stats`
Tuple of task stats for each date. | [
"Prints",
"statistic",
"information",
"using",
"io",
"stream",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L186-L239 |
xtrementl/focus | focus/plugin/modules/stats.py | Stats.execute | def execute(self, env, args):
""" Prints task information.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
start = self._fuzzy_time_parse(args.start)
if not start:
raise errors.... | python | def execute(self, env, args):
""" Prints task information.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
start = self._fuzzy_time_parse(args.start)
if not start:
raise errors.... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"start",
"=",
"self",
".",
"_fuzzy_time_parse",
"(",
"args",
".",
"start",
")",
"if",
"not",
"start",
":",
"raise",
"errors",
".",
"FocusError",
"(",
"u'Invalid start period provided'",
")",... | Prints task information.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Prints",
"task",
"information",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L252-L266 |
etcher-be/elib_run | elib_run/_find_exe.py | find_executable | def find_executable(executable: str, *paths: str) -> typing.Optional[Path]:
"""
Based on: https://gist.github.com/4368898
Public domain code by anatoly techtonik <techtonik@gmail.com>
Programmatic equivalent to Linux `which` and Windows `where`
Find if ´executable´ can be run. Looks for it in 'pa... | python | def find_executable(executable: str, *paths: str) -> typing.Optional[Path]:
"""
Based on: https://gist.github.com/4368898
Public domain code by anatoly techtonik <techtonik@gmail.com>
Programmatic equivalent to Linux `which` and Windows `where`
Find if ´executable´ can be run. Looks for it in 'pa... | [
"def",
"find_executable",
"(",
"executable",
":",
"str",
",",
"*",
"paths",
":",
"str",
")",
"->",
"typing",
".",
"Optional",
"[",
"Path",
"]",
":",
"if",
"not",
"executable",
".",
"endswith",
"(",
"'.exe'",
")",
":",
"executable",
"=",
"f'{executable}.e... | Based on: https://gist.github.com/4368898
Public domain code by anatoly techtonik <techtonik@gmail.com>
Programmatic equivalent to Linux `which` and Windows `where`
Find if ´executable´ can be run. Looks for it in 'path'
(string that lists directories separated by 'os.pathsep';
defaults to os.env... | [
"Based",
"on",
":",
"https",
":",
"//",
"gist",
".",
"github",
".",
"com",
"/",
"4368898"
] | train | https://github.com/etcher-be/elib_run/blob/c9d8ba9f067ab90c5baa27375a92b23f1b97cdde/elib_run/_find_exe.py#L18-L62 |
rich-pixley/rain | rain/__init__.py | WorkSpace.create | def create(self):
"""called to create the work space"""
self.logger.log(logging.DEBUG, 'os.mkdir %s', self.name)
os.mkdir(self.name) | python | def create(self):
"""called to create the work space"""
self.logger.log(logging.DEBUG, 'os.mkdir %s', self.name)
os.mkdir(self.name) | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"log",
"(",
"logging",
".",
"DEBUG",
",",
"'os.mkdir %s'",
",",
"self",
".",
"name",
")",
"os",
".",
"mkdir",
"(",
"self",
".",
"name",
")"
] | called to create the work space | [
"called",
"to",
"create",
"the",
"work",
"space"
] | train | https://github.com/rich-pixley/rain/blob/ed95aafc73002fbf0466be9a5eaa1e6ed3990a6d/rain/__init__.py#L40-L43 |
fordhurley/s3url | s3url/s3.py | parse_obj | def parse_obj(obj):
"""
>>> parse_obj('bucket/key')
('bucket', 'key')
>>> parse_obj('my-bucket/path/to/file.txt')
('my-bucket', 'path/to/file.txt')
>>> parse_obj('s3://this_bucket/some/path.txt')
('this_bucket', 'some/path.txt')
>>> parse_obj('https://s3.amazonaws.com/bucket/file.txt')
... | python | def parse_obj(obj):
"""
>>> parse_obj('bucket/key')
('bucket', 'key')
>>> parse_obj('my-bucket/path/to/file.txt')
('my-bucket', 'path/to/file.txt')
>>> parse_obj('s3://this_bucket/some/path.txt')
('this_bucket', 'some/path.txt')
>>> parse_obj('https://s3.amazonaws.com/bucket/file.txt')
... | [
"def",
"parse_obj",
"(",
"obj",
")",
":",
"obj",
"=",
"obj",
".",
"lstrip",
"(",
"'s3://'",
")",
"if",
"obj",
".",
"startswith",
"(",
"'http'",
")",
":",
"url",
"=",
"urlparse",
".",
"urlparse",
"(",
"obj",
")",
"if",
"url",
".",
"netloc",
"==",
... | >>> parse_obj('bucket/key')
('bucket', 'key')
>>> parse_obj('my-bucket/path/to/file.txt')
('my-bucket', 'path/to/file.txt')
>>> parse_obj('s3://this_bucket/some/path.txt')
('this_bucket', 'some/path.txt')
>>> parse_obj('https://s3.amazonaws.com/bucket/file.txt')
('bucket', 'file.txt')
>>... | [
">>>",
"parse_obj",
"(",
"bucket",
"/",
"key",
")",
"(",
"bucket",
"key",
")",
">>>",
"parse_obj",
"(",
"my",
"-",
"bucket",
"/",
"path",
"/",
"to",
"/",
"file",
".",
"txt",
")",
"(",
"my",
"-",
"bucket",
"path",
"/",
"to",
"/",
"file",
".",
"t... | train | https://github.com/fordhurley/s3url/blob/a9e932308ee1bc70a4626ff0a28575cd6927ea33/s3url/s3.py#L32-L57 |
pjuren/pyokit | src/pyokit/scripts/remDupsBED.py | ambigFilter | def ambigFilter(in_fh1, in_fh2, out_fh1, out_fh2, verbose=False, best=False):
"""
@summary: take reads from in_fh1 and output to out_fh1 if they don't
appear also in in_fh2 (ditto for in_fh2)
@param in_fh1: BED formated stream of reads
@param in_fh2: BED formated stream of reads
@param ... | python | def ambigFilter(in_fh1, in_fh2, out_fh1, out_fh2, verbose=False, best=False):
"""
@summary: take reads from in_fh1 and output to out_fh1 if they don't
appear also in in_fh2 (ditto for in_fh2)
@param in_fh1: BED formated stream of reads
@param in_fh2: BED formated stream of reads
@param ... | [
"def",
"ambigFilter",
"(",
"in_fh1",
",",
"in_fh2",
",",
"out_fh1",
",",
"out_fh2",
",",
"verbose",
"=",
"False",
",",
"best",
"=",
"False",
")",
":",
"for",
"r1",
",",
"r2",
"in",
"BEDUniqueIterator",
"(",
"in_fh1",
",",
"in_fh2",
",",
"verbose",
",",... | @summary: take reads from in_fh1 and output to out_fh1 if they don't
appear also in in_fh2 (ditto for in_fh2)
@param in_fh1: BED formated stream of reads
@param in_fh2: BED formated stream of reads
@param out_fh1: Output reads that pass from in_fh1 to this stream
@param out_fh2: Output re... | [
"@summary",
":",
"take",
"reads",
"from",
"in_fh1",
"and",
"output",
"to",
"out_fh1",
"if",
"they",
"don",
"t",
"appear",
"also",
"in",
"in_fh2",
"(",
"ditto",
"for",
"in_fh2",
")"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/remDupsBED.py#L133-L152 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | bodycomp | def bodycomp(mass, tbw, method='reilly', simulate=False, n_rand=1000):
'''Create dataframe with derived body composition values
Args
----
mass: ndarray
Mass of the seal (kg)
tbw: ndarray
Total body water (kg)
method: str
name of method used to derive composition values
... | python | def bodycomp(mass, tbw, method='reilly', simulate=False, n_rand=1000):
'''Create dataframe with derived body composition values
Args
----
mass: ndarray
Mass of the seal (kg)
tbw: ndarray
Total body water (kg)
method: str
name of method used to derive composition values
... | [
"def",
"bodycomp",
"(",
"mass",
",",
"tbw",
",",
"method",
"=",
"'reilly'",
",",
"simulate",
"=",
"False",
",",
"n_rand",
"=",
"1000",
")",
":",
"import",
"numpy",
"import",
"pandas",
"if",
"len",
"(",
"mass",
")",
"!=",
"len",
"(",
"tbw",
")",
":"... | Create dataframe with derived body composition values
Args
----
mass: ndarray
Mass of the seal (kg)
tbw: ndarray
Total body water (kg)
method: str
name of method used to derive composition values
simulate: bool
switch for generating values with random noise
n... | [
"Create",
"dataframe",
"with",
"derived",
"body",
"composition",
"values"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L49-L124 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | perc_bc_from_lipid | def perc_bc_from_lipid(perc_lipid, perc_water=None):
'''Calculate body composition component percentages based on % lipid
Calculation of percent protein and percent ash are based on those presented
in Reilly and Fedak (1990).
Args
----
perc_lipid: float or ndarray
1D array of percent l... | python | def perc_bc_from_lipid(perc_lipid, perc_water=None):
'''Calculate body composition component percentages based on % lipid
Calculation of percent protein and percent ash are based on those presented
in Reilly and Fedak (1990).
Args
----
perc_lipid: float or ndarray
1D array of percent l... | [
"def",
"perc_bc_from_lipid",
"(",
"perc_lipid",
",",
"perc_water",
"=",
"None",
")",
":",
"import",
"numpy",
"# Cast iterables to numpy arrays",
"if",
"numpy",
".",
"iterable",
"(",
"perc_lipid",
")",
":",
"perc_lipid",
"=",
"numpy",
".",
"asarray",
"(",
"perc_l... | Calculate body composition component percentages based on % lipid
Calculation of percent protein and percent ash are based on those presented
in Reilly and Fedak (1990).
Args
----
perc_lipid: float or ndarray
1D array of percent lipid values from which to calculate body composition
per... | [
"Calculate",
"body",
"composition",
"component",
"percentages",
"based",
"on",
"%",
"lipid"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L127-L176 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | lip2dens | def lip2dens(perc_lipid, dens_lipid=0.9007, dens_prot=1.34, dens_water=0.994,
dens_ash=2.3):
'''Derive tissue density from lipids
The equation calculating animal density is from Biuw et al. (2003), and
default values for component densities are from human studies collected in
the book by Moore ... | python | def lip2dens(perc_lipid, dens_lipid=0.9007, dens_prot=1.34, dens_water=0.994,
dens_ash=2.3):
'''Derive tissue density from lipids
The equation calculating animal density is from Biuw et al. (2003), and
default values for component densities are from human studies collected in
the book by Moore ... | [
"def",
"lip2dens",
"(",
"perc_lipid",
",",
"dens_lipid",
"=",
"0.9007",
",",
"dens_prot",
"=",
"1.34",
",",
"dens_water",
"=",
"0.994",
",",
"dens_ash",
"=",
"2.3",
")",
":",
"import",
"numpy",
"# Cast iterables to numpy array",
"if",
"numpy",
".",
"iterable",... | Derive tissue density from lipids
The equation calculating animal density is from Biuw et al. (2003), and
default values for component densities are from human studies collected in
the book by Moore et al. (1963).
Args
----
perc_lipid: float or ndarray
Percent lipid of body composition... | [
"Derive",
"tissue",
"density",
"from",
"lipids"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L203-L254 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | dens2lip | def dens2lip(dens_gcm3, dens_lipid=0.9007, dens_prot=1.34, dens_water=0.994,
dens_ash=2.3):
'''Get percent composition of animal from body density
The equation calculating animal density is from Biuw et al. (2003), and
default values for component densities are from human studies collected in
t... | python | def dens2lip(dens_gcm3, dens_lipid=0.9007, dens_prot=1.34, dens_water=0.994,
dens_ash=2.3):
'''Get percent composition of animal from body density
The equation calculating animal density is from Biuw et al. (2003), and
default values for component densities are from human studies collected in
t... | [
"def",
"dens2lip",
"(",
"dens_gcm3",
",",
"dens_lipid",
"=",
"0.9007",
",",
"dens_prot",
"=",
"1.34",
",",
"dens_water",
"=",
"0.994",
",",
"dens_ash",
"=",
"2.3",
")",
":",
"import",
"numpy",
"# Cast iterables to numpy array",
"if",
"numpy",
".",
"iterable",
... | Get percent composition of animal from body density
The equation calculating animal density is from Biuw et al. (2003), and
default values for component densities are from human studies collected in
the book by Moore et al. (1963).
Args
----
dens_gcm3: float or ndarray
An array of seal... | [
"Get",
"percent",
"composition",
"of",
"animal",
"from",
"body",
"density"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L257-L315 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | diff_speed | def diff_speed(sw_dens=1.028, dens_gcm3=1.053, seal_length=300, seal_girth=200,
Cd=0.09):
'''Calculate terminal velocity of animal with a body size
Args
----
sw_dens: float
Density of seawater (g/cm^3)
dens_gcm3: float
Density of animal (g/cm^3)
seal_length: float
... | python | def diff_speed(sw_dens=1.028, dens_gcm3=1.053, seal_length=300, seal_girth=200,
Cd=0.09):
'''Calculate terminal velocity of animal with a body size
Args
----
sw_dens: float
Density of seawater (g/cm^3)
dens_gcm3: float
Density of animal (g/cm^3)
seal_length: float
... | [
"def",
"diff_speed",
"(",
"sw_dens",
"=",
"1.028",
",",
"dens_gcm3",
"=",
"1.053",
",",
"seal_length",
"=",
"300",
",",
"seal_girth",
"=",
"200",
",",
"Cd",
"=",
"0.09",
")",
":",
"import",
"numpy",
"surf",
",",
"vol",
"=",
"surf_vol",
"(",
"seal_lengt... | Calculate terminal velocity of animal with a body size
Args
----
sw_dens: float
Density of seawater (g/cm^3)
dens_gcm3: float
Density of animal (g/cm^3)
seal_length: float
Length of animal (cm)
seal_girth: float
Girth of animal (cm)
Cd: float
Drag coe... | [
"Calculate",
"terminal",
"velocity",
"of",
"animal",
"with",
"a",
"body",
"size"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L344-L388 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | surf_vol | def surf_vol(length, girth):
'''Calculate the surface volume of an animal from its length and girth
Args
----
length: float or ndarray
Length of animal (m)
girth: float or ndarray
Girth of animal (m)
Returns
-------
surf:
Surface area of animal (m^2)
vol: fl... | python | def surf_vol(length, girth):
'''Calculate the surface volume of an animal from its length and girth
Args
----
length: float or ndarray
Length of animal (m)
girth: float or ndarray
Girth of animal (m)
Returns
-------
surf:
Surface area of animal (m^2)
vol: fl... | [
"def",
"surf_vol",
"(",
"length",
",",
"girth",
")",
":",
"import",
"numpy",
"a_r",
"=",
"0.01",
"*",
"girth",
"/",
"(",
"2",
"*",
"numpy",
".",
"pi",
")",
"stl_l",
"=",
"0.01",
"*",
"length",
"c_r",
"=",
"stl_l",
"/",
"2",
"e",
"=",
"numpy",
"... | Calculate the surface volume of an animal from its length and girth
Args
----
length: float or ndarray
Length of animal (m)
girth: float or ndarray
Girth of animal (m)
Returns
-------
surf:
Surface area of animal (m^2)
vol: float or ndarray
Volume of ani... | [
"Calculate",
"the",
"surface",
"volume",
"of",
"an",
"animal",
"from",
"its",
"length",
"and",
"girth"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L411-L440 |
ryanjdillon/pyotelem | pyotelem/physio_seal.py | calc_seal_volume | def calc_seal_volume(mass_kg, dens_kgm3, length=None, girth=None):
'''Calculate an animal's volume from mass and density or length and girth
Args
----
mass_kg: float or ndarray
Mass of animal (kg)
dens_kgm3: float or ndarray
Density of animal (kg/m^3)
length: float or None
... | python | def calc_seal_volume(mass_kg, dens_kgm3, length=None, girth=None):
'''Calculate an animal's volume from mass and density or length and girth
Args
----
mass_kg: float or ndarray
Mass of animal (kg)
dens_kgm3: float or ndarray
Density of animal (kg/m^3)
length: float or None
... | [
"def",
"calc_seal_volume",
"(",
"mass_kg",
",",
"dens_kgm3",
",",
"length",
"=",
"None",
",",
"girth",
"=",
"None",
")",
":",
"if",
"(",
"length",
"is",
"not",
"None",
")",
"and",
"(",
"girth",
"is",
"not",
"None",
")",
":",
"_",
",",
"seal_vol",
"... | Calculate an animal's volume from mass and density or length and girth
Args
----
mass_kg: float or ndarray
Mass of animal (kg)
dens_kgm3: float or ndarray
Density of animal (kg/m^3)
length: float or None
Length of animal. Default `None` (m)
girth: float or None
G... | [
"Calculate",
"an",
"animal",
"s",
"volume",
"from",
"mass",
"and",
"density",
"or",
"length",
"and",
"girth"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/physio_seal.py#L443-L467 |
pschmitt/zhue | zhue/model/bridge.py | Bridge.__find_new | def __find_new(self, hueobjecttype):
'''
Starts a search for new Hue objects
'''
assert hueobjecttype in ['lights', 'sensors'], \
'Unsupported object type {}'.format(hueobjecttype)
url = '{}/{}'.format(self.API, hueobjecttype)
return self._request(
... | python | def __find_new(self, hueobjecttype):
'''
Starts a search for new Hue objects
'''
assert hueobjecttype in ['lights', 'sensors'], \
'Unsupported object type {}'.format(hueobjecttype)
url = '{}/{}'.format(self.API, hueobjecttype)
return self._request(
... | [
"def",
"__find_new",
"(",
"self",
",",
"hueobjecttype",
")",
":",
"assert",
"hueobjecttype",
"in",
"[",
"'lights'",
",",
"'sensors'",
"]",
",",
"'Unsupported object type {}'",
".",
"format",
"(",
"hueobjecttype",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",... | Starts a search for new Hue objects | [
"Starts",
"a",
"search",
"for",
"new",
"Hue",
"objects"
] | train | https://github.com/pschmitt/zhue/blob/4a3f4ddf12ceeedcb2157f92d93ff1c6438a7d59/zhue/model/bridge.py#L311-L321 |
pschmitt/zhue | zhue/model/bridge.py | Bridge.__get_new | def __get_new(self, hueobjecttype):
'''
Get a list of newly found Hue object
'''
assert hueobjecttype in ['lights', 'sensors'], \
'Unsupported object type {}'.format(hueobjecttype)
url = '{}/{}/new'.format(self.API, hueobjecttype)
return self._request(url=url) | python | def __get_new(self, hueobjecttype):
'''
Get a list of newly found Hue object
'''
assert hueobjecttype in ['lights', 'sensors'], \
'Unsupported object type {}'.format(hueobjecttype)
url = '{}/{}/new'.format(self.API, hueobjecttype)
return self._request(url=url) | [
"def",
"__get_new",
"(",
"self",
",",
"hueobjecttype",
")",
":",
"assert",
"hueobjecttype",
"in",
"[",
"'lights'",
",",
"'sensors'",
"]",
",",
"'Unsupported object type {}'",
".",
"format",
"(",
"hueobjecttype",
")",
"url",
"=",
"'{}/{}/new'",
".",
"format",
"... | Get a list of newly found Hue object | [
"Get",
"a",
"list",
"of",
"newly",
"found",
"Hue",
"object"
] | train | https://github.com/pschmitt/zhue/blob/4a3f4ddf12ceeedcb2157f92d93ff1c6438a7d59/zhue/model/bridge.py#L323-L330 |
bogdan-kulynych/defaultcontext | defaultcontext/stack.py | DefaultStack.get_context_manager | def get_context_manager(self, default):
"""A context manager for manipulating a default stack."""
try:
self.stack.append(default)
yield default
finally:
if self.enforce_nesting:
if self.stack[-1] is not default:
raise Assert... | python | def get_context_manager(self, default):
"""A context manager for manipulating a default stack."""
try:
self.stack.append(default)
yield default
finally:
if self.enforce_nesting:
if self.stack[-1] is not default:
raise Assert... | [
"def",
"get_context_manager",
"(",
"self",
",",
"default",
")",
":",
"try",
":",
"self",
".",
"stack",
".",
"append",
"(",
"default",
")",
"yield",
"default",
"finally",
":",
"if",
"self",
".",
"enforce_nesting",
":",
"if",
"self",
".",
"stack",
"[",
"... | A context manager for manipulating a default stack. | [
"A",
"context",
"manager",
"for",
"manipulating",
"a",
"default",
"stack",
"."
] | train | https://github.com/bogdan-kulynych/defaultcontext/blob/ec9bb96552dfb3d42a1103da1772b024414dd801/defaultcontext/stack.py#L229-L242 |
dharif23/pyrainbowterm | pyrainbowterm/pyrainbowterm.py | print | def print(*args, **kwargs):
"""
Normally print function in python prints values to a stream / stdout
>> print(value1, value2, sep='', end='\n', file=sys.stdout)
Current package usage:
======================
print(value1, value2, sep='', end='\n', file=sys.stdout, color=None,
bg_color=None, ... | python | def print(*args, **kwargs):
"""
Normally print function in python prints values to a stream / stdout
>> print(value1, value2, sep='', end='\n', file=sys.stdout)
Current package usage:
======================
print(value1, value2, sep='', end='\n', file=sys.stdout, color=None,
bg_color=None, ... | [
"def",
"print",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Pop out color and background values from kwargs",
"color_name",
"=",
"kwargs",
".",
"pop",
"(",
"'color'",
",",
"None",
")",
"bg_color",
"=",
"kwargs",
".",
"pop",
"(",
"'bg_color'",
","... | Normally print function in python prints values to a stream / stdout
>> print(value1, value2, sep='', end='\n', file=sys.stdout)
Current package usage:
======================
print(value1, value2, sep='', end='\n', file=sys.stdout, color=None,
bg_color=None, text_format=None, log_type=None)
:p... | [
"Normally",
"print",
"function",
"in",
"python",
"prints",
"values",
"to",
"a",
"stream",
"/",
"stdout",
">>",
"print",
"(",
"value1",
"value2",
"sep",
"=",
"end",
"=",
"\\",
"n",
"file",
"=",
"sys",
".",
"stdout",
")"
] | train | https://github.com/dharif23/pyrainbowterm/blob/fb35b9b7a04fbf7a0ea236bb94275240c6322b1a/pyrainbowterm/pyrainbowterm.py#L96-L179 |
rackerlabs/rackspace-python-neutronclient | neutronclient/neutron/v2_0/vpn/ipsec_site_connection.py | IPsecSiteConnectionMixin.args2body | def args2body(self, parsed_args, body=None):
"""Add in conditional args and then return all conn info."""
if body is None:
body = {}
if parsed_args.dpd:
vpn_utils.validate_dpd_dict(parsed_args.dpd)
body['dpd'] = parsed_args.dpd
if parsed_args.local_ep... | python | def args2body(self, parsed_args, body=None):
"""Add in conditional args and then return all conn info."""
if body is None:
body = {}
if parsed_args.dpd:
vpn_utils.validate_dpd_dict(parsed_args.dpd)
body['dpd'] = parsed_args.dpd
if parsed_args.local_ep... | [
"def",
"args2body",
"(",
"self",
",",
"parsed_args",
",",
"body",
"=",
"None",
")",
":",
"if",
"body",
"is",
"None",
":",
"body",
"=",
"{",
"}",
"if",
"parsed_args",
".",
"dpd",
":",
"vpn_utils",
".",
"validate_dpd_dict",
"(",
"parsed_args",
".",
"dpd"... | Add in conditional args and then return all conn info. | [
"Add",
"in",
"conditional",
"args",
"and",
"then",
"return",
"all",
"conn",
"info",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/v2_0/vpn/ipsec_site_connection.py#L70-L88 |
neoinsanity/cognate | cognate/component_core.py | copy_attribute_values | def copy_attribute_values(source, target, property_names):
"""Function to copy attributes from a source to a target object.
This method copies the property values in a given list from a given
source object to a target source object.
:param source: The source object that is to be inspected for property
values.... | python | def copy_attribute_values(source, target, property_names):
"""Function to copy attributes from a source to a target object.
This method copies the property values in a given list from a given
source object to a target source object.
:param source: The source object that is to be inspected for property
values.... | [
"def",
"copy_attribute_values",
"(",
"source",
",",
"target",
",",
"property_names",
")",
":",
"if",
"source",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'\"source\" must be provided.'",
")",
"if",
"target",
"is",
"None",
":",
"raise",
"ValueError",
"(",
... | Function to copy attributes from a source to a target object.
This method copies the property values in a given list from a given
source object to a target source object.
:param source: The source object that is to be inspected for property
values.
:type source: type
:param target: The target object that will be ... | [
"Function",
"to",
"copy",
"attributes",
"from",
"a",
"source",
"to",
"a",
"target",
"object",
"."
] | train | https://github.com/neoinsanity/cognate/blob/ea7ac74d756872a34bd2fb6f8518fd5d7c6ba6f8/cognate/component_core.py#L414-L466 |
neoinsanity/cognate | cognate/component_core.py | ComponentCore.cognate_options | def cognate_options(self, arg_parser):
"""This method will be called to get the *ComponentCore* configuration
options.
:param arg_parser: An *ArgumentParser* instance to add configuration
options.
:type arg_parser: argparse.ArgumentParser
:return: None
"""
... | python | def cognate_options(self, arg_parser):
"""This method will be called to get the *ComponentCore* configuration
options.
:param arg_parser: An *ArgumentParser* instance to add configuration
options.
:type arg_parser: argparse.ArgumentParser
:return: None
"""
... | [
"def",
"cognate_options",
"(",
"self",
",",
"arg_parser",
")",
":",
"arg_parser",
".",
"add_argument",
"(",
"'--service_name'",
",",
"default",
"=",
"self",
".",
"service_name",
",",
"help",
"=",
"'This will set the name for the current '",
"'instance. This will be refl... | This method will be called to get the *ComponentCore* configuration
options.
:param arg_parser: An *ArgumentParser* instance to add configuration
options.
:type arg_parser: argparse.ArgumentParser
:return: None | [
"This",
"method",
"will",
"be",
"called",
"to",
"get",
"the",
"*",
"ComponentCore",
"*",
"configuration",
"options",
"."
] | train | https://github.com/neoinsanity/cognate/blob/ea7ac74d756872a34bd2fb6f8518fd5d7c6ba6f8/cognate/component_core.py#L171-L200 |
neoinsanity/cognate | cognate/component_core.py | ComponentCore._configure_logging | def _configure_logging(self):
"""This method configures the self.log entity for log handling.
:return: None
The method will cognate_configure the logging facilities for the
derive service instance. This includes setting up logging to files
and console. The configured log will b... | python | def _configure_logging(self):
"""This method configures the self.log entity for log handling.
:return: None
The method will cognate_configure the logging facilities for the
derive service instance. This includes setting up logging to files
and console. The configured log will b... | [
"def",
"_configure_logging",
"(",
"self",
")",
":",
"self",
".",
"log_level",
"=",
"ComponentCore",
".",
"LOG_LEVEL_MAP",
".",
"get",
"(",
"self",
".",
"log_level",
",",
"logging",
".",
"ERROR",
")",
"# assign the windmill instance logger",
"self",
".",
"log",
... | This method configures the self.log entity for log handling.
:return: None
The method will cognate_configure the logging facilities for the
derive service instance. This includes setting up logging to files
and console. The configured log will be available to the service
instan... | [
"This",
"method",
"configures",
"the",
"self",
".",
"log",
"entity",
"for",
"log",
"handling",
"."
] | train | https://github.com/neoinsanity/cognate/blob/ea7ac74d756872a34bd2fb6f8518fd5d7c6ba6f8/cognate/component_core.py#L221-L258 |
neoinsanity/cognate | cognate/component_core.py | ComponentCore._execute_configuration | def _execute_configuration(self, argv):
"""This method assigns an argument list to attributes assigned to self.
:param argv: A list of arguments.
:type argv: list<str>
:return: None
This is the work horse method that does the work of invoking
*configuration_option* and ... | python | def _execute_configuration(self, argv):
"""This method assigns an argument list to attributes assigned to self.
:param argv: A list of arguments.
:type argv: list<str>
:return: None
This is the work horse method that does the work of invoking
*configuration_option* and ... | [
"def",
"_execute_configuration",
"(",
"self",
",",
"argv",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"[",
"]",
"# just create an empty arg list",
"# ensure that sys.argv is not modified in case it was passed.",
"if",
"argv",
"is",
"sys",
".",
"argv",
"... | This method assigns an argument list to attributes assigned to self.
:param argv: A list of arguments.
:type argv: list<str>
:return: None
This is the work horse method that does the work of invoking
*configuration_option* and *cognate_configure* methods on progenitor
c... | [
"This",
"method",
"assigns",
"an",
"argument",
"list",
"to",
"attributes",
"assigned",
"to",
"self",
"."
] | train | https://github.com/neoinsanity/cognate/blob/ea7ac74d756872a34bd2fb6f8518fd5d7c6ba6f8/cognate/component_core.py#L260-L315 |
neoinsanity/cognate | cognate/component_core.py | ComponentCore.invoke_method_on_children | def invoke_method_on_children(self, func_name=None, *args, **kwargs):
"""This helper method will walk the primary base class hierarchy to
invoke a method if it exists for a given child base class.
:param func_name: The name of a function to search for invocation.
:type func_name: str
... | python | def invoke_method_on_children(self, func_name=None, *args, **kwargs):
"""This helper method will walk the primary base class hierarchy to
invoke a method if it exists for a given child base class.
:param func_name: The name of a function to search for invocation.
:type func_name: str
... | [
"def",
"invoke_method_on_children",
"(",
"self",
",",
"func_name",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"func_name",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'invoke_method_on_children:func_name parameter required'",
")",
... | This helper method will walk the primary base class hierarchy to
invoke a method if it exists for a given child base class.
:param func_name: The name of a function to search for invocation.
:type func_name: str
:param args: An argument list to pass to the target function.
:type... | [
"This",
"helper",
"method",
"will",
"walk",
"the",
"primary",
"base",
"class",
"hierarchy",
"to",
"invoke",
"a",
"method",
"if",
"it",
"exists",
"for",
"a",
"given",
"child",
"base",
"class",
"."
] | train | https://github.com/neoinsanity/cognate/blob/ea7ac74d756872a34bd2fb6f8518fd5d7c6ba6f8/cognate/component_core.py#L317-L405 |
thespacedoctor/neddy | neddy/namesearch.py | namesearch.get | def get(self):
"""
*get the namesearch object*
**Return:**
- ``results``
"""
self.log.info('starting the ``get`` method')
# SPLIT THE LIST OF NAMES INTO BATCHES
self.theseBatches, self.theseBatchParams = self._split_incoming_queries_into_batches(
... | python | def get(self):
"""
*get the namesearch object*
**Return:**
- ``results``
"""
self.log.info('starting the ``get`` method')
# SPLIT THE LIST OF NAMES INTO BATCHES
self.theseBatches, self.theseBatchParams = self._split_incoming_queries_into_batches(
... | [
"def",
"get",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``get`` method'",
")",
"# SPLIT THE LIST OF NAMES INTO BATCHES",
"self",
".",
"theseBatches",
",",
"self",
".",
"theseBatchParams",
"=",
"self",
".",
"_split_incoming_queries_i... | *get the namesearch object*
**Return:**
- ``results`` | [
"*",
"get",
"the",
"namesearch",
"object",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/namesearch.py#L76-L97 |
thespacedoctor/neddy | neddy/namesearch.py | namesearch._build_api_url_and_download_results | def _build_api_url_and_download_results(
self):
"""
*build api url for NED to perform batch name queries*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _build_api_url_and_download_results me... | python | def _build_api_url_and_download_results(
self):
"""
*build api url for NED to perform batch name queries*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _build_api_url_and_download_results me... | [
"def",
"_build_api_url_and_download_results",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_build_api_url_and_download_results`` method'",
")",
"baseUrl",
"=",
"\"https://ned.ipac.caltech.edu/cgi-bin/\"",
"command",
"=",
"\"gmd\"",
"urlParamet... | *build api url for NED to perform batch name queries*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _build_api_url_and_download_results method
- @review: when complete add logging | [
"*",
"build",
"api",
"url",
"for",
"NED",
"to",
"perform",
"batch",
"name",
"queries",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/namesearch.py#L99-L180 |
thespacedoctor/neddy | neddy/namesearch.py | namesearch._output_results | def _output_results(
self):
"""
*output results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _output_results method
- @review: when complete add logging
"""
sel... | python | def _output_results(
self):
"""
*output results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _output_results method
- @review: when complete add logging
"""
sel... | [
"def",
"_output_results",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_output_results`` method'",
")",
"content",
"=",
"\"\"",
"maxNameLen",
"=",
"0",
"for",
"r",
"in",
"self",
".",
"results",
":",
"if",
"maxNameLen",
"<",
... | *output results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _output_results method
- @review: when complete add logging | [
"*",
"output",
"results",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/namesearch.py#L182-L244 |
abhinav/reversible | reversible/core.py | execute | def execute(action):
"""
Execute the given action.
An action is any object with a ``forwards()`` and ``backwards()`` method.
.. code-block:: python
class CreateUser(object):
def __init__(self, userinfo):
self.userinfo = userinfo
self.user_id = Non... | python | def execute(action):
"""
Execute the given action.
An action is any object with a ``forwards()`` and ``backwards()`` method.
.. code-block:: python
class CreateUser(object):
def __init__(self, userinfo):
self.userinfo = userinfo
self.user_id = Non... | [
"def",
"execute",
"(",
"action",
")",
":",
"# TODO this should probably be a class to configure logging, etc. The",
"# global execute can refer to the \"default\" instance of the executor.",
"try",
":",
"return",
"action",
".",
"forwards",
"(",
")",
"except",
"Exception",
":",
... | Execute the given action.
An action is any object with a ``forwards()`` and ``backwards()`` method.
.. code-block:: python
class CreateUser(object):
def __init__(self, userinfo):
self.userinfo = userinfo
self.user_id = None
def forwards(self)... | [
"Execute",
"the",
"given",
"action",
"."
] | train | https://github.com/abhinav/reversible/blob/7e28aaf0390f7d4b889c6ac14d7b340f8f314e89/reversible/core.py#L9-L61 |
abhinav/reversible | reversible/core.py | action | def action(forwards=None, context_class=None):
"""
Decorator to build functions.
This decorator can be applied to a function to build actions. The
decorated function becomes the ``forwards`` implementation of the action.
The first argument of the ``forwards`` implementation is a context object
... | python | def action(forwards=None, context_class=None):
"""
Decorator to build functions.
This decorator can be applied to a function to build actions. The
decorated function becomes the ``forwards`` implementation of the action.
The first argument of the ``forwards`` implementation is a context object
... | [
"def",
"action",
"(",
"forwards",
"=",
"None",
",",
"context_class",
"=",
"None",
")",
":",
"context_class",
"=",
"context_class",
"or",
"dict",
"def",
"decorator",
"(",
"_forwards",
")",
":",
"return",
"ActionBuilder",
"(",
"_forwards",
",",
"context_class",
... | Decorator to build functions.
This decorator can be applied to a function to build actions. The
decorated function becomes the ``forwards`` implementation of the action.
The first argument of the ``forwards`` implementation is a context object
that can be used to share state between the forwards and ba... | [
"Decorator",
"to",
"build",
"functions",
"."
] | train | https://github.com/abhinav/reversible/blob/7e28aaf0390f7d4b889c6ac14d7b340f8f314e89/reversible/core.py#L125-L199 |
abhinav/reversible | reversible/core.py | ActionBuilder.backwards | def backwards(self, backwards):
"""Decorator to specify the ``backwards`` action."""
if self._backwards is not None:
raise ValueError('Backwards action already specified.')
self._backwards = backwards
return backwards | python | def backwards(self, backwards):
"""Decorator to specify the ``backwards`` action."""
if self._backwards is not None:
raise ValueError('Backwards action already specified.')
self._backwards = backwards
return backwards | [
"def",
"backwards",
"(",
"self",
",",
"backwards",
")",
":",
"if",
"self",
".",
"_backwards",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'Backwards action already specified.'",
")",
"self",
".",
"_backwards",
"=",
"backwards",
"return",
"backwards"
] | Decorator to specify the ``backwards`` action. | [
"Decorator",
"to",
"specify",
"the",
"backwards",
"action",
"."
] | train | https://github.com/abhinav/reversible/blob/7e28aaf0390f7d4b889c6ac14d7b340f8f314e89/reversible/core.py#L110-L117 |
eddiejessup/spatious | spatious/geom.py | sphere_volume | def sphere_volume(R, n):
"""Return the volume of a sphere in an arbitrary number of dimensions.
Parameters
----------
R: array-like
Radius.
n: array-like
The number of dimensions of the space in which the sphere lives.
Returns
-------
V: array-like
Volume.
"... | python | def sphere_volume(R, n):
"""Return the volume of a sphere in an arbitrary number of dimensions.
Parameters
----------
R: array-like
Radius.
n: array-like
The number of dimensions of the space in which the sphere lives.
Returns
-------
V: array-like
Volume.
"... | [
"def",
"sphere_volume",
"(",
"R",
",",
"n",
")",
":",
"return",
"(",
"(",
"np",
".",
"pi",
"**",
"(",
"n",
"/",
"2.0",
")",
")",
"/",
"scipy",
".",
"special",
".",
"gamma",
"(",
"n",
"/",
"2.0",
"+",
"1",
")",
")",
"*",
"R",
"**",
"n"
] | Return the volume of a sphere in an arbitrary number of dimensions.
Parameters
----------
R: array-like
Radius.
n: array-like
The number of dimensions of the space in which the sphere lives.
Returns
-------
V: array-like
Volume. | [
"Return",
"the",
"volume",
"of",
"a",
"sphere",
"in",
"an",
"arbitrary",
"number",
"of",
"dimensions",
"."
] | train | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L12-L27 |
eddiejessup/spatious | spatious/geom.py | sphere_radius | def sphere_radius(V, n):
"""Return the radius of a sphere in an arbitrary number of dimensions.
Parameters
----------
V: array-like
Volume.
n: array-like
The number of dimensions of the space in which the sphere lives.
Returns
-------
R: array-like
Radius.
"... | python | def sphere_radius(V, n):
"""Return the radius of a sphere in an arbitrary number of dimensions.
Parameters
----------
V: array-like
Volume.
n: array-like
The number of dimensions of the space in which the sphere lives.
Returns
-------
R: array-like
Radius.
"... | [
"def",
"sphere_radius",
"(",
"V",
",",
"n",
")",
":",
"return",
"(",
"(",
"(",
"scipy",
".",
"special",
".",
"gamma",
"(",
"n",
"/",
"2.0",
"+",
"1.0",
")",
"*",
"V",
")",
"**",
"(",
"1.0",
"/",
"n",
")",
")",
"/",
"np",
".",
"sqrt",
"(",
... | Return the radius of a sphere in an arbitrary number of dimensions.
Parameters
----------
V: array-like
Volume.
n: array-like
The number of dimensions of the space in which the sphere lives.
Returns
-------
R: array-like
Radius. | [
"Return",
"the",
"radius",
"of",
"a",
"sphere",
"in",
"an",
"arbitrary",
"number",
"of",
"dimensions",
"."
] | train | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L30-L46 |
eddiejessup/spatious | spatious/geom.py | spherocylinder_radius | def spherocylinder_radius(V, l):
"""Return the radius of a
[spherocylinder](http://en.wikipedia.org/wiki/Capsule_(geometry)).
Parameters
----------
V: float
Volume.
l: float
Length of the cylinder section.
Returns
-------
R: float
Radius.
"""
return ... | python | def spherocylinder_radius(V, l):
"""Return the radius of a
[spherocylinder](http://en.wikipedia.org/wiki/Capsule_(geometry)).
Parameters
----------
V: float
Volume.
l: float
Length of the cylinder section.
Returns
-------
R: float
Radius.
"""
return ... | [
"def",
"spherocylinder_radius",
"(",
"V",
",",
"l",
")",
":",
"return",
"np",
".",
"roots",
"(",
"[",
"4.0",
"/",
"3.0",
",",
"l",
",",
"0",
",",
"-",
"V",
"/",
"np",
".",
"pi",
"]",
")",
"[",
"-",
"1",
"]",
".",
"real"
] | Return the radius of a
[spherocylinder](http://en.wikipedia.org/wiki/Capsule_(geometry)).
Parameters
----------
V: float
Volume.
l: float
Length of the cylinder section.
Returns
-------
R: float
Radius. | [
"Return",
"the",
"radius",
"of",
"a",
"[",
"spherocylinder",
"]",
"(",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Capsule_",
"(",
"geometry",
"))",
"."
] | train | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L163-L179 |
eddiejessup/spatious | spatious/geom.py | spheres_sep | def spheres_sep(ar, aR, br, bR):
"""Return the separation distance between two spheres.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Returns
---... | python | def spheres_sep(ar, aR, br, bR):
"""Return the separation distance between two spheres.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Returns
---... | [
"def",
"spheres_sep",
"(",
"ar",
",",
"aR",
",",
"br",
",",
"bR",
")",
":",
"return",
"vector",
".",
"vector_mag",
"(",
"ar",
"-",
"br",
")",
"-",
"(",
"aR",
"+",
"bR",
")"
] | Return the separation distance between two spheres.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Returns
-------
d: float
Separation dis... | [
"Return",
"the",
"separation",
"distance",
"between",
"two",
"spheres",
"."
] | train | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L223-L239 |
eddiejessup/spatious | spatious/geom.py | spheres_intersect | def spheres_intersect(ar, aR, br, bR):
"""Return whether or not two spheres intersect each other.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Retur... | python | def spheres_intersect(ar, aR, br, bR):
"""Return whether or not two spheres intersect each other.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Retur... | [
"def",
"spheres_intersect",
"(",
"ar",
",",
"aR",
",",
"br",
",",
"bR",
")",
":",
"return",
"vector",
".",
"vector_mag_sq",
"(",
"ar",
"-",
"br",
")",
"<",
"(",
"aR",
"+",
"bR",
")",
"**",
"2"
] | Return whether or not two spheres intersect each other.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Returns
-------
intersecting: boolean
... | [
"Return",
"whether",
"or",
"not",
"two",
"spheres",
"intersect",
"each",
"other",
"."
] | train | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L242-L257 |
eddiejessup/spatious | spatious/geom.py | point_seg_sep | def point_seg_sep(ar, br1, br2):
"""Return the minimum separation vector between a point and a line segment,
in 3 dimensions.
Parameters
----------
ar: array-like, shape (3,)
Coordinates of a point.
br1, br2: array-like, shape (3,)
Coordinates for the points of a line segment
... | python | def point_seg_sep(ar, br1, br2):
"""Return the minimum separation vector between a point and a line segment,
in 3 dimensions.
Parameters
----------
ar: array-like, shape (3,)
Coordinates of a point.
br1, br2: array-like, shape (3,)
Coordinates for the points of a line segment
... | [
"def",
"point_seg_sep",
"(",
"ar",
",",
"br1",
",",
"br2",
")",
":",
"v",
"=",
"br2",
"-",
"br1",
"w",
"=",
"ar",
"-",
"br1",
"c1",
"=",
"np",
".",
"dot",
"(",
"w",
",",
"v",
")",
"if",
"c1",
"<=",
"0.0",
":",
"return",
"ar",
"-",
"br1",
... | Return the minimum separation vector between a point and a line segment,
in 3 dimensions.
Parameters
----------
ar: array-like, shape (3,)
Coordinates of a point.
br1, br2: array-like, shape (3,)
Coordinates for the points of a line segment
Returns
-------
sep: float ar... | [
"Return",
"the",
"minimum",
"separation",
"vector",
"between",
"a",
"point",
"and",
"a",
"line",
"segment",
"in",
"3",
"dimensions",
"."
] | train | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L260-L289 |
xtrementl/focus | focus/common.py | readfile | def readfile(filename, binary=False):
""" Reads the contents of the specified file.
`filename`
Filename to read.
`binary`
Set to ``True`` to indicate a binary file.
Returns string or ``None``.
"""
if not os.path.isfile(filename):
return None
... | python | def readfile(filename, binary=False):
""" Reads the contents of the specified file.
`filename`
Filename to read.
`binary`
Set to ``True`` to indicate a binary file.
Returns string or ``None``.
"""
if not os.path.isfile(filename):
return None
... | [
"def",
"readfile",
"(",
"filename",
",",
"binary",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"return",
"None",
"try",
":",
"flags",
"=",
"'r'",
"if",
"not",
"binary",
"else",
"'rb'",
"with",
"... | Reads the contents of the specified file.
`filename`
Filename to read.
`binary`
Set to ``True`` to indicate a binary file.
Returns string or ``None``. | [
"Reads",
"the",
"contents",
"of",
"the",
"specified",
"file",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L18-L38 |
xtrementl/focus | focus/common.py | writefile | def writefile(filename, data, binary=False):
""" Write the provided data to the file.
`filename`
Filename to write.
`data`
Data buffer to write.
`binary`
Set to ``True`` to indicate a binary file.
Returns boolean.
"""
try:
fla... | python | def writefile(filename, data, binary=False):
""" Write the provided data to the file.
`filename`
Filename to write.
`data`
Data buffer to write.
`binary`
Set to ``True`` to indicate a binary file.
Returns boolean.
"""
try:
fla... | [
"def",
"writefile",
"(",
"filename",
",",
"data",
",",
"binary",
"=",
"False",
")",
":",
"try",
":",
"flags",
"=",
"'w'",
"if",
"not",
"binary",
"else",
"'wb'",
"with",
"open",
"(",
"filename",
",",
"flags",
")",
"as",
"_file",
":",
"_file",
".",
"... | Write the provided data to the file.
`filename`
Filename to write.
`data`
Data buffer to write.
`binary`
Set to ``True`` to indicate a binary file.
Returns boolean. | [
"Write",
"the",
"provided",
"data",
"to",
"the",
"file",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L41-L61 |
xtrementl/focus | focus/common.py | which | def which(name):
""" Returns the full path to executable in path matching provided name.
`name`
String value.
Returns string or ``None``.
"""
# we were given a filename, return it if it's executable
if os.path.dirname(name) != '':
if not os.path.isdir(name) and... | python | def which(name):
""" Returns the full path to executable in path matching provided name.
`name`
String value.
Returns string or ``None``.
"""
# we were given a filename, return it if it's executable
if os.path.dirname(name) != '':
if not os.path.isdir(name) and... | [
"def",
"which",
"(",
"name",
")",
":",
"# we were given a filename, return it if it's executable",
"if",
"os",
".",
"path",
".",
"dirname",
"(",
"name",
")",
"!=",
"''",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"name",
")",
"and",
"os",
".... | Returns the full path to executable in path matching provided name.
`name`
String value.
Returns string or ``None``. | [
"Returns",
"the",
"full",
"path",
"to",
"executable",
"in",
"path",
"matching",
"provided",
"name",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L75-L101 |
xtrementl/focus | focus/common.py | extract_app_paths | def extract_app_paths(values, app_should_exist=True):
""" Extracts application paths from the values provided.
`values`
List of strings to extract paths from.
`app_should_exist`
Set to ``True`` to check that application file exists.
Returns list of strings.
... | python | def extract_app_paths(values, app_should_exist=True):
""" Extracts application paths from the values provided.
`values`
List of strings to extract paths from.
`app_should_exist`
Set to ``True`` to check that application file exists.
Returns list of strings.
... | [
"def",
"extract_app_paths",
"(",
"values",
",",
"app_should_exist",
"=",
"True",
")",
":",
"def",
"_osx_app_path",
"(",
"name",
")",
":",
"\"\"\" Attempts to find the full application path for the name specified.\n\n `name`\n Application name.\n\n ... | Extracts application paths from the values provided.
`values`
List of strings to extract paths from.
`app_should_exist`
Set to ``True`` to check that application file exists.
Returns list of strings.
* Raises ``ValueError`` exception if value extraction fails. | [
"Extracts",
"application",
"paths",
"from",
"the",
"values",
"provided",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L104-L189 |
xtrementl/focus | focus/common.py | shell_process | def shell_process(command, input_data=None, background=False, exitcode=False):
""" Shells a process with the given shell command.
`command`
Shell command to spawn.
`input_data`
String to pipe to process as input.
`background`
Set to ``True`` to fork proce... | python | def shell_process(command, input_data=None, background=False, exitcode=False):
""" Shells a process with the given shell command.
`command`
Shell command to spawn.
`input_data`
String to pipe to process as input.
`background`
Set to ``True`` to fork proce... | [
"def",
"shell_process",
"(",
"command",
",",
"input_data",
"=",
"None",
",",
"background",
"=",
"False",
",",
"exitcode",
"=",
"False",
")",
":",
"data",
"=",
"None",
"try",
":",
"# kick off the process",
"kwargs",
"=",
"{",
"'shell'",
":",
"isinstance",
"... | Shells a process with the given shell command.
`command`
Shell command to spawn.
`input_data`
String to pipe to process as input.
`background`
Set to ``True`` to fork process into background.
NOTE: This exits immediately with no result returned.
... | [
"Shells",
"a",
"process",
"with",
"the",
"given",
"shell",
"command",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L192-L249 |
xtrementl/focus | focus/common.py | to_utf8 | def to_utf8(buf, errors='replace'):
""" Encodes a string into a UTF-8 compatible, ASCII string.
`buf`
string or unicode to convert.
Returns string.
* Raises a ``UnicodeEncodeError`` exception if encoding failed and
`errors` isn't set to 'replace'.
"""
if... | python | def to_utf8(buf, errors='replace'):
""" Encodes a string into a UTF-8 compatible, ASCII string.
`buf`
string or unicode to convert.
Returns string.
* Raises a ``UnicodeEncodeError`` exception if encoding failed and
`errors` isn't set to 'replace'.
"""
if... | [
"def",
"to_utf8",
"(",
"buf",
",",
"errors",
"=",
"'replace'",
")",
":",
"if",
"isinstance",
"(",
"buf",
",",
"unicode",
")",
":",
"return",
"buf",
".",
"encode",
"(",
"'utf-8'",
",",
"errors",
")",
"else",
":",
"return",
"buf"
] | Encodes a string into a UTF-8 compatible, ASCII string.
`buf`
string or unicode to convert.
Returns string.
* Raises a ``UnicodeEncodeError`` exception if encoding failed and
`errors` isn't set to 'replace'. | [
"Encodes",
"a",
"string",
"into",
"a",
"UTF",
"-",
"8",
"compatible",
"ASCII",
"string",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L252-L268 |
xtrementl/focus | focus/common.py | from_utf8 | def from_utf8(buf, errors='replace'):
""" Decodes a UTF-8 compatible, ASCII string into a unicode object.
`buf`
string or unicode string to convert.
Returns unicode` string.
* Raises a ``UnicodeDecodeError`` exception if encoding failed and
`errors` isn't set to 'rep... | python | def from_utf8(buf, errors='replace'):
""" Decodes a UTF-8 compatible, ASCII string into a unicode object.
`buf`
string or unicode string to convert.
Returns unicode` string.
* Raises a ``UnicodeDecodeError`` exception if encoding failed and
`errors` isn't set to 'rep... | [
"def",
"from_utf8",
"(",
"buf",
",",
"errors",
"=",
"'replace'",
")",
":",
"if",
"isinstance",
"(",
"buf",
",",
"unicode",
")",
":",
"return",
"buf",
"else",
":",
"return",
"unicode",
"(",
"buf",
",",
"'utf-8'",
",",
"errors",
")"
] | Decodes a UTF-8 compatible, ASCII string into a unicode object.
`buf`
string or unicode string to convert.
Returns unicode` string.
* Raises a ``UnicodeDecodeError`` exception if encoding failed and
`errors` isn't set to 'replace'. | [
"Decodes",
"a",
"UTF",
"-",
"8",
"compatible",
"ASCII",
"string",
"into",
"a",
"unicode",
"object",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L271-L287 |
dugan/coverage-reporter | coverage_reporter/options.py | Option.get | def get(self, value, cfg=None):
"""
Returns value for this option from either cfg object or optparse option list, preferring the option list.
"""
if value is None and cfg:
if self.option_type == 'list':
value = cfg.get_list(self.name, None)
else:
... | python | def get(self, value, cfg=None):
"""
Returns value for this option from either cfg object or optparse option list, preferring the option list.
"""
if value is None and cfg:
if self.option_type == 'list':
value = cfg.get_list(self.name, None)
else:
... | [
"def",
"get",
"(",
"self",
",",
"value",
",",
"cfg",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
"and",
"cfg",
":",
"if",
"self",
".",
"option_type",
"==",
"'list'",
":",
"value",
"=",
"cfg",
".",
"get_list",
"(",
"self",
".",
"name",
","... | Returns value for this option from either cfg object or optparse option list, preferring the option list. | [
"Returns",
"value",
"for",
"this",
"option",
"from",
"either",
"cfg",
"object",
"or",
"optparse",
"option",
"list",
"preferring",
"the",
"option",
"list",
"."
] | train | https://github.com/dugan/coverage-reporter/blob/18ecc9189de4f62b15366901b2451b8047f1ccfb/coverage_reporter/options.py#L68-L84 |
dhain/potpy | potpy/wsgi.py | PathRouter.add | def add(self, *args):
"""Add a path template and handler.
:param name: Optional. If specified, allows reverse path lookup with
:meth:`reverse`.
:param template: A string or :class:`~potpy.template.Template`
instance used to match paths against. Strings will be wrapped in... | python | def add(self, *args):
"""Add a path template and handler.
:param name: Optional. If specified, allows reverse path lookup with
:meth:`reverse`.
:param template: A string or :class:`~potpy.template.Template`
instance used to match paths against. Strings will be wrapped in... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"2",
":",
"name",
",",
"template",
"=",
"args",
"[",
":",
"2",
"]",
"args",
"=",
"args",
"[",
"2",
":",
"]",
"else",
":",
"name",
"=",
"None",
"templ... | Add a path template and handler.
:param name: Optional. If specified, allows reverse path lookup with
:meth:`reverse`.
:param template: A string or :class:`~potpy.template.Template`
instance used to match paths against. Strings will be wrapped in a
Template instance.... | [
"Add",
"a",
"path",
"template",
"and",
"handler",
"."
] | train | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/wsgi.py#L39-L65 |
dhain/potpy | potpy/wsgi.py | PathRouter.reverse | def reverse(self, *args, **kwargs):
"""Look up a path by name and fill in the provided parameters.
Example:
>>> handler = lambda: None # just a bogus handler
>>> router = PathRouter(('post', '/posts/{slug}', handler))
>>> router.reverse('post', slug='my-post')
... | python | def reverse(self, *args, **kwargs):
"""Look up a path by name and fill in the provided parameters.
Example:
>>> handler = lambda: None # just a bogus handler
>>> router = PathRouter(('post', '/posts/{slug}', handler))
>>> router.reverse('post', slug='my-post')
... | [
"def",
"reverse",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"(",
"name",
",",
")",
"=",
"args",
"return",
"self",
".",
"_templates",
"[",
"name",
"]",
".",
"fill",
"(",
"*",
"*",
"kwargs",
")"
] | Look up a path by name and fill in the provided parameters.
Example:
>>> handler = lambda: None # just a bogus handler
>>> router = PathRouter(('post', '/posts/{slug}', handler))
>>> router.reverse('post', slug='my-post')
'/posts/my-post' | [
"Look",
"up",
"a",
"path",
"by",
"name",
"and",
"fill",
"in",
"the",
"provided",
"parameters",
"."
] | train | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/wsgi.py#L88-L99 |
dhain/potpy | potpy/wsgi.py | MethodRouter.match | def match(self, methods, request_method):
"""Check for a method match.
:param methods: A method or tuple of methods to match against.
:param request_method: The method to check for a match.
:returns: An empty :class:`dict` in the case of a match, or ``None``
if there is no m... | python | def match(self, methods, request_method):
"""Check for a method match.
:param methods: A method or tuple of methods to match against.
:param request_method: The method to check for a match.
:returns: An empty :class:`dict` in the case of a match, or ``None``
if there is no m... | [
"def",
"match",
"(",
"self",
",",
"methods",
",",
"request_method",
")",
":",
"if",
"isinstance",
"(",
"methods",
",",
"basestring",
")",
":",
"return",
"{",
"}",
"if",
"request_method",
"==",
"methods",
"else",
"None",
"return",
"{",
"}",
"if",
"request... | Check for a method match.
:param methods: A method or tuple of methods to match against.
:param request_method: The method to check for a match.
:returns: An empty :class:`dict` in the case of a match, or ``None``
if there is no matching handler for the given method.
Exampl... | [
"Check",
"for",
"a",
"method",
"match",
"."
] | train | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/wsgi.py#L136-L152 |
axil/redissentry-core | redissentrycore/utils.py | humanize | def humanize(t):
"""
>>> print humanize(0)
now
>>> print humanize(1)
in a minute
>>> print humanize(60)
in a minute
>>> print humanize(61)
in 2 minutes
>>> print humanize(3600)
in an hour
>>> print humanize(3601)
in 2 hours
"""
m, s = divmod(t, 60)
if s:
... | python | def humanize(t):
"""
>>> print humanize(0)
now
>>> print humanize(1)
in a minute
>>> print humanize(60)
in a minute
>>> print humanize(61)
in 2 minutes
>>> print humanize(3600)
in an hour
>>> print humanize(3601)
in 2 hours
"""
m, s = divmod(t, 60)
if s:
... | [
"def",
"humanize",
"(",
"t",
")",
":",
"m",
",",
"s",
"=",
"divmod",
"(",
"t",
",",
"60",
")",
"if",
"s",
":",
"m",
"+=",
"1",
"# ceil minutes ",
"h",
",",
"m",
"=",
"divmod",
"(",
"m",
",",
"60",
")",
"if",
"m",
"and",
"h",
":",
"h",
"+=... | >>> print humanize(0)
now
>>> print humanize(1)
in a minute
>>> print humanize(60)
in a minute
>>> print humanize(61)
in 2 minutes
>>> print humanize(3600)
in an hour
>>> print humanize(3601)
in 2 hours | [
">>>",
"print",
"humanize",
"(",
"0",
")",
"now",
">>>",
"print",
"humanize",
"(",
"1",
")",
"in",
"a",
"minute",
">>>",
"print",
"humanize",
"(",
"60",
")",
"in",
"a",
"minute",
">>>",
"print",
"humanize",
"(",
"61",
")",
"in",
"2",
"minutes",
">>... | train | https://github.com/axil/redissentry-core/blob/210c30226d9f4e35b8be47f7c3ce52b975d26e8c/redissentrycore/utils.py#L6-L40 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetIntersectionCell.coerce | def coerce(self, value):
"""
Ensures that a value is a SetCell
"""
if hasattr(value, 'values') and hasattr(value, 'domain'):
return value
elif hasattr(value, '__iter__'):
# if the values are consistent with the comparison's domains, then
# copy... | python | def coerce(self, value):
"""
Ensures that a value is a SetCell
"""
if hasattr(value, 'values') and hasattr(value, 'domain'):
return value
elif hasattr(value, '__iter__'):
# if the values are consistent with the comparison's domains, then
# copy... | [
"def",
"coerce",
"(",
"self",
",",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'values'",
")",
"and",
"hasattr",
"(",
"value",
",",
"'domain'",
")",
":",
"return",
"value",
"elif",
"hasattr",
"(",
"value",
",",
"'__iter__'",
")",
":",
"# ... | Ensures that a value is a SetCell | [
"Ensures",
"that",
"a",
"value",
"is",
"a",
"SetCell"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L35-L51 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetIntersectionCell.same_domain | def same_domain(self, other):
"""
Cheap pointer comparison or symmetric difference operation
to ensure domains are the same
"""
return self.domain == other.domain or \
len(self.domain.symmetric_difference(set(other.domain))) == 0 | python | def same_domain(self, other):
"""
Cheap pointer comparison or symmetric difference operation
to ensure domains are the same
"""
return self.domain == other.domain or \
len(self.domain.symmetric_difference(set(other.domain))) == 0 | [
"def",
"same_domain",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"domain",
"==",
"other",
".",
"domain",
"or",
"len",
"(",
"self",
".",
"domain",
".",
"symmetric_difference",
"(",
"set",
"(",
"other",
".",
"domain",
")",
")",
")",
"=... | Cheap pointer comparison or symmetric difference operation
to ensure domains are the same | [
"Cheap",
"pointer",
"comparison",
"or",
"symmetric",
"difference",
"operation",
"to",
"ensure",
"domains",
"are",
"the",
"same"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L53-L59 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetIntersectionCell.is_equal | def is_equal(self, other):
"""
True iff all members are the same
"""
other = self.coerce(other)
return len(self.get_values().symmetric_difference(other.get_values())) == 0 | python | def is_equal(self, other):
"""
True iff all members are the same
"""
other = self.coerce(other)
return len(self.get_values().symmetric_difference(other.get_values())) == 0 | [
"def",
"is_equal",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"coerce",
"(",
"other",
")",
"return",
"len",
"(",
"self",
".",
"get_values",
"(",
")",
".",
"symmetric_difference",
"(",
"other",
".",
"get_values",
"(",
")",
")",
")... | True iff all members are the same | [
"True",
"iff",
"all",
"members",
"are",
"the",
"same"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L60-L65 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetIntersectionCell.is_contradictory | def is_contradictory(self, other):
"""
What does it mean for a set to contradict another? If a merge results
in the empty set -- when both sets are disjoint.
CONTRADICTION: self = {4} other = {3}
NOT CONTRADICTION: self = {4} other = {3,4}
NOT CONTRADICTION: self = {3,4}... | python | def is_contradictory(self, other):
"""
What does it mean for a set to contradict another? If a merge results
in the empty set -- when both sets are disjoint.
CONTRADICTION: self = {4} other = {3}
NOT CONTRADICTION: self = {4} other = {3,4}
NOT CONTRADICTION: self = {3,4}... | [
"def",
"is_contradictory",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"coerce",
"(",
"other",
")",
"# contradictory if both values are disjoint",
"return",
"self",
".",
"get_values",
"(",
")",
".",
"isdisjoint",
"(",
"other",
".",
"get_val... | What does it mean for a set to contradict another? If a merge results
in the empty set -- when both sets are disjoint.
CONTRADICTION: self = {4} other = {3}
NOT CONTRADICTION: self = {4} other = {3,4}
NOT CONTRADICTION: self = {3,4} other = {3} | [
"What",
"does",
"it",
"mean",
"for",
"a",
"set",
"to",
"contradict",
"another?",
"If",
"a",
"merge",
"results",
"in",
"the",
"empty",
"set",
"--",
"when",
"both",
"sets",
"are",
"disjoint",
"."
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L67-L78 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetIntersectionCell.is_entailed_by | def is_entailed_by(self, other):
"""
Fewer members = more information (exception is empty set, which means
all members of the domain)
(1) when self is empty and others is not (equal to containing the
entire domain)
(2) when other contains more members than self
... | python | def is_entailed_by(self, other):
"""
Fewer members = more information (exception is empty set, which means
all members of the domain)
(1) when self is empty and others is not (equal to containing the
entire domain)
(2) when other contains more members than self
... | [
"def",
"is_entailed_by",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"same_domain",
"(",
"other",
")",
":",
"return",
"False",
"if",
"not",
"other",
".",
"values",
":",
"if",
"self",
".",
"values",
":",
"# None can never entail -None",
... | Fewer members = more information (exception is empty set, which means
all members of the domain)
(1) when self is empty and others is not (equal to containing the
entire domain)
(2) when other contains more members than self | [
"Fewer",
"members",
"=",
"more",
"information",
"(",
"exception",
"is",
"empty",
"set",
"which",
"means",
"all",
"members",
"of",
"the",
"domain",
")"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L86-L107 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetIntersectionCell.merge | def merge(self, other):
"""
We can merge unless the merge results in an empty set -- a
contradiction
"""
other = self.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif other.is_entailed_by(self):
... | python | def merge(self, other):
"""
We can merge unless the merge results in an empty set -- a
contradiction
"""
other = self.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif other.is_entailed_by(self):
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"coerce",
"(",
"other",
")",
"if",
"self",
".",
"is_equal",
"(",
"other",
")",
":",
"# pick among dependencies",
"return",
"self",
"elif",
"other",
".",
"is_entailed_by",
"("... | We can merge unless the merge results in an empty set -- a
contradiction | [
"We",
"can",
"merge",
"unless",
"the",
"merge",
"results",
"in",
"an",
"empty",
"set",
"--",
"a",
"contradiction"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L122-L145 |
EventTeam/beliefs | src/beliefs/cells/sets.py | SetUnionCell.merge | def merge(self, other):
"""
We can merge unless the merge results in an empty set -- a
contradiction
"""
other = self.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif self.is_contradictory(other):
... | python | def merge(self, other):
"""
We can merge unless the merge results in an empty set -- a
contradiction
"""
other = self.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif self.is_contradictory(other):
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"coerce",
"(",
"other",
")",
"if",
"self",
".",
"is_equal",
"(",
"other",
")",
":",
"# pick among dependencies",
"return",
"self",
"elif",
"self",
".",
"is_contradictory",
"(... | We can merge unless the merge results in an empty set -- a
contradiction | [
"We",
"can",
"merge",
"unless",
"the",
"merge",
"results",
"in",
"an",
"empty",
"set",
"--",
"a",
"contradiction"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L175-L194 |
bfontaine/firapria | firapria/pollution.py | get_indices | def get_indices():
"""
Return a list of 3 integers representing EU indices for yesterday, today
and tomorrow.
"""
doc = BeautifulSoup(urlopen(BASEURL))
divs = doc.select('.indices_txt')
if not divs:
return None
sibling = divs[1].nextSibling
if not sibling:
return No... | python | def get_indices():
"""
Return a list of 3 integers representing EU indices for yesterday, today
and tomorrow.
"""
doc = BeautifulSoup(urlopen(BASEURL))
divs = doc.select('.indices_txt')
if not divs:
return None
sibling = divs[1].nextSibling
if not sibling:
return No... | [
"def",
"get_indices",
"(",
")",
":",
"doc",
"=",
"BeautifulSoup",
"(",
"urlopen",
"(",
"BASEURL",
")",
")",
"divs",
"=",
"doc",
".",
"select",
"(",
"'.indices_txt'",
")",
"if",
"not",
"divs",
":",
"return",
"None",
"sibling",
"=",
"divs",
"[",
"1",
"... | Return a list of 3 integers representing EU indices for yesterday, today
and tomorrow. | [
"Return",
"a",
"list",
"of",
"3",
"integers",
"representing",
"EU",
"indices",
"for",
"yesterday",
"today",
"and",
"tomorrow",
"."
] | train | https://github.com/bfontaine/firapria/blob/a2eeeab6f6d1db50337950cfbd6f835272306ff0/firapria/pollution.py#L17-L40 |
heikomuller/sco-datastore | scodata/__init__.py | create_dir | def create_dir(directory):
"""Create given directory, if doesn't exist.
Parameters
----------
directory : string
Directory path (can be relative or absolute)
Returns
-------
string
Absolute directory path
"""
if not os.access(directory, os.F_OK):
os.makedirs... | python | def create_dir(directory):
"""Create given directory, if doesn't exist.
Parameters
----------
directory : string
Directory path (can be relative or absolute)
Returns
-------
string
Absolute directory path
"""
if not os.access(directory, os.F_OK):
os.makedirs... | [
"def",
"create_dir",
"(",
"directory",
")",
":",
"if",
"not",
"os",
".",
"access",
"(",
"directory",
",",
"os",
".",
"F_OK",
")",
":",
"os",
".",
"makedirs",
"(",
"directory",
")",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"directory",
")"
] | Create given directory, if doesn't exist.
Parameters
----------
directory : string
Directory path (can be relative or absolute)
Returns
-------
string
Absolute directory path | [
"Create",
"given",
"directory",
"if",
"doesn",
"t",
"exist",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L1212-L1227 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_create | def experiments_create(self, subject_id, image_group_id, properties):
"""Create an experiment object with subject, and image group. Objects
are referenced by their unique identifiers. The API ensure that at time
of creation all referenced objects exist. Referential consistency,
however, ... | python | def experiments_create(self, subject_id, image_group_id, properties):
"""Create an experiment object with subject, and image group. Objects
are referenced by their unique identifiers. The API ensure that at time
of creation all referenced objects exist. Referential consistency,
however, ... | [
"def",
"experiments_create",
"(",
"self",
",",
"subject_id",
",",
"image_group_id",
",",
"properties",
")",
":",
"# Ensure that reference subject exists",
"if",
"self",
".",
"subjects_get",
"(",
"subject_id",
")",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'u... | Create an experiment object with subject, and image group. Objects
are referenced by their unique identifiers. The API ensure that at time
of creation all referenced objects exist. Referential consistency,
however, is currently not enforced when objects are deleted.
Expects experiment n... | [
"Create",
"an",
"experiment",
"object",
"with",
"subject",
"and",
"image",
"group",
".",
"Objects",
"are",
"referenced",
"by",
"their",
"unique",
"identifiers",
".",
"The",
"API",
"ensure",
"that",
"at",
"time",
"of",
"creation",
"all",
"referenced",
"objects"... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L110-L142 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_fmri_create | def experiments_fmri_create(self, experiment_id, filename):
"""Create functional data object from given file and associate the
object with the specified experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
filename : File-type... | python | def experiments_fmri_create(self, experiment_id, filename):
"""Create functional data object from given file and associate the
object with the specified experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
filename : File-type... | [
"def",
"experiments_fmri_create",
"(",
"self",
",",
"experiment_id",
",",
"filename",
")",
":",
"# Get the experiment to ensure that it exist before we even create the",
"# functional data object",
"experiment",
"=",
"self",
".",
"experiments_get",
"(",
"experiment_id",
")",
... | Create functional data object from given file and associate the
object with the specified experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
filename : File-type object
Functional data file
Returns
-----... | [
"Create",
"functional",
"data",
"object",
"from",
"given",
"file",
"and",
"associate",
"the",
"object",
"with",
"the",
"specified",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L163-L198 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_fmri_delete | def experiments_fmri_delete(self, experiment_id):
"""Delete fMRI data object associated with given experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier
... | python | def experiments_fmri_delete(self, experiment_id):
"""Delete fMRI data object associated with given experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier
... | [
"def",
"experiments_fmri_delete",
"(",
"self",
",",
"experiment_id",
")",
":",
"# Get experiment fMRI to ensure that it exists",
"fmri",
"=",
"self",
".",
"experiments_fmri_get",
"(",
"experiment_id",
")",
"if",
"fmri",
"is",
"None",
":",
"return",
"None",
"# Delete r... | Delete fMRI data object associated with given experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier
Returns
-------
FMRIDataHandle
Ha... | [
"Delete",
"fMRI",
"data",
"object",
"associated",
"with",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L200-L226 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_fmri_download | def experiments_fmri_download(self, experiment_id):
"""Download the fMRI data file associated with given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
Returns
-------
FileInfo
Information about fMRI... | python | def experiments_fmri_download(self, experiment_id):
"""Download the fMRI data file associated with given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
Returns
-------
FileInfo
Information about fMRI... | [
"def",
"experiments_fmri_download",
"(",
"self",
",",
"experiment_id",
")",
":",
"# Get experiment fMRI to ensure that it exists",
"fmri",
"=",
"self",
".",
"experiments_fmri_get",
"(",
"experiment_id",
")",
"if",
"fmri",
"is",
"None",
":",
"return",
"None",
"# Return... | Download the fMRI data file associated with given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
Returns
-------
FileInfo
Information about fMRI file on disk or None if experiment is
unknown or h... | [
"Download",
"the",
"fMRI",
"data",
"file",
"associated",
"with",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L228-L251 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_fmri_get | def experiments_fmri_get(self, experiment_id):
"""Get fMRI data object that is associated with the given experiment.
Parameters
----------
experiment_id : string
unique experiment identifier
Returns
-------
FMRIDataHandle
Handle for fMRI ... | python | def experiments_fmri_get(self, experiment_id):
"""Get fMRI data object that is associated with the given experiment.
Parameters
----------
experiment_id : string
unique experiment identifier
Returns
-------
FMRIDataHandle
Handle for fMRI ... | [
"def",
"experiments_fmri_get",
"(",
"self",
",",
"experiment_id",
")",
":",
"# Get experiment to ensure that it exists",
"experiment",
"=",
"self",
".",
"experiments_get",
"(",
"experiment_id",
")",
"if",
"experiment",
"is",
"None",
":",
"return",
"None",
"# Check if ... | Get fMRI data object that is associated with the given experiment.
Parameters
----------
experiment_id : string
unique experiment identifier
Returns
-------
FMRIDataHandle
Handle for fMRI data object of None if (a) the experiment is unknown
... | [
"Get",
"fMRI",
"data",
"object",
"that",
"is",
"associated",
"with",
"the",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L253-L277 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_fmri_upsert_property | def experiments_fmri_upsert_property(self, experiment_id, properties):
"""Upsert property of fMRI data object associated with given experiment.
Raises ValueError if given property dictionary results in an illegal
operation.
Parameters
----------
experiment_id : string
... | python | def experiments_fmri_upsert_property(self, experiment_id, properties):
"""Upsert property of fMRI data object associated with given experiment.
Raises ValueError if given property dictionary results in an illegal
operation.
Parameters
----------
experiment_id : string
... | [
"def",
"experiments_fmri_upsert_property",
"(",
"self",
",",
"experiment_id",
",",
"properties",
")",
":",
"# Get experiment fMRI to ensure that it exists. Needed to get fMRI",
"# data object identifier for given experiment identifier",
"fmri",
"=",
"self",
".",
"experiments_fmri_get... | Upsert property of fMRI data object associated with given experiment.
Raises ValueError if given property dictionary results in an illegal
operation.
Parameters
----------
experiment_id : string
Unique experiment identifier
properties : Dictionary()
... | [
"Upsert",
"property",
"of",
"fMRI",
"data",
"object",
"associated",
"with",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L279-L303 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_list | def experiments_list(self, limit=-1, offset=-1):
"""Retrieve list of all experiments in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)... | python | def experiments_list(self, limit=-1, offset=-1):
"""Retrieve list of all experiments in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)... | [
"def",
"experiments_list",
"(",
"self",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"experiments",
".",
"list_objects",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
")"
] | Retrieve list of all experiments in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
Returns
-------
ObjectListing
... | [
"Retrieve",
"list",
"of",
"all",
"experiments",
"in",
"the",
"data",
"store",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L320-L335 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_attachments_create | def experiments_predictions_attachments_create(self, experiment_id, run_id, resource_id, filename, mime_type=None):
"""Attach a given data file with a model run. The attached file is
identified by the resource identifier. If a resource with the given
identifier already exists it will be overwrit... | python | def experiments_predictions_attachments_create(self, experiment_id, run_id, resource_id, filename, mime_type=None):
"""Attach a given data file with a model run. The attached file is
identified by the resource identifier. If a resource with the given
identifier already exists it will be overwrit... | [
"def",
"experiments_predictions_attachments_create",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"resource_id",
",",
"filename",
",",
"mime_type",
"=",
"None",
")",
":",
"# Get experiment to ensure that it exists",
"if",
"self",
".",
"experiments_get",
"(",
... | Attach a given data file with a model run. The attached file is
identified by the resource identifier. If a resource with the given
identifier already exists it will be overwritten.
Parameters
----------
experiment_id : string
Unique experiment identifier
mod... | [
"Attach",
"a",
"given",
"data",
"file",
"with",
"a",
"model",
"run",
".",
"The",
"attached",
"file",
"is",
"identified",
"by",
"the",
"resource",
"identifier",
".",
"If",
"a",
"resource",
"with",
"the",
"given",
"identifier",
"already",
"exists",
"it",
"wi... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L337-L369 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_attachments_delete | def experiments_predictions_attachments_delete(self, experiment_id, run_id, resource_id):
"""Delete attached file with given resource identifier from a mode run.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
... | python | def experiments_predictions_attachments_delete(self, experiment_id, run_id, resource_id):
"""Delete attached file with given resource identifier from a mode run.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
... | [
"def",
"experiments_predictions_attachments_delete",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"resource_id",
")",
":",
"# Get experiment to ensure that it exists",
"if",
"self",
".",
"experiments_get",
"(",
"experiment_id",
")",
"is",
"None",
":",
"return"... | Delete attached file with given resource identifier from a mode run.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
Parameters
----------
experiment_id : string
Unique experiment identifi... | [
"Delete",
"attached",
"file",
"with",
"given",
"resource",
"identifier",
"from",
"a",
"mode",
"run",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L371-L396 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_attachments_download | def experiments_predictions_attachments_download(self, experiment_id, run_id, resource_id):
"""Download a data file that has been attached with a successful model
run.
Parameters
----------
experiment_id : string
Unique experiment identifier
model_id : string... | python | def experiments_predictions_attachments_download(self, experiment_id, run_id, resource_id):
"""Download a data file that has been attached with a successful model
run.
Parameters
----------
experiment_id : string
Unique experiment identifier
model_id : string... | [
"def",
"experiments_predictions_attachments_download",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"resource_id",
")",
":",
"# Get experiment to ensure that it exists",
"if",
"self",
".",
"experiments_get",
"(",
"experiment_id",
")",
"is",
"None",
":",
"retur... | Download a data file that has been attached with a successful model
run.
Parameters
----------
experiment_id : string
Unique experiment identifier
model_id : string
Unique identifier of model to run
resource_id : string
Unique attachme... | [
"Download",
"a",
"data",
"file",
"that",
"has",
"been",
"attached",
"with",
"a",
"successful",
"model",
"run",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L398-L427 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.