repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
LuqueDaniel/pybooru | pybooru/api_moebooru.py | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_moebooru.py#L516-L526 | def pool_create(self, name, description, is_public):
"""Function to create a pool (Require login) (UNTESTED).
Parameters:
name (str): The name.
description (str): A description of the pool.
is_public (int): 1 or 0, whether or not the pool is public.
"""
... | [
"def",
"pool_create",
"(",
"self",
",",
"name",
",",
"description",
",",
"is_public",
")",
":",
"params",
"=",
"{",
"'pool[name]'",
":",
"name",
",",
"'pool[description]'",
":",
"description",
",",
"'pool[is_public]'",
":",
"is_public",
"}",
"return",
"self",
... | Function to create a pool (Require login) (UNTESTED).
Parameters:
name (str): The name.
description (str): A description of the pool.
is_public (int): 1 or 0, whether or not the pool is public. | [
"Function",
"to",
"create",
"a",
"pool",
"(",
"Require",
"login",
")",
"(",
"UNTESTED",
")",
"."
] | python | train |
tensorflow/datasets | tensorflow_datasets/translate/wmt.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L838-L858 | def _parse_tmx(path):
"""Generates examples from TMX file."""
def _get_tuv_lang(tuv):
for k, v in tuv.items():
if k.endswith("}lang"):
return v
raise AssertionError("Language not found in `tuv` attributes.")
def _get_tuv_seg(tuv):
segs = tuv.findall("seg")
assert len(segs) == 1, "In... | [
"def",
"_parse_tmx",
"(",
"path",
")",
":",
"def",
"_get_tuv_lang",
"(",
"tuv",
")",
":",
"for",
"k",
",",
"v",
"in",
"tuv",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"endswith",
"(",
"\"}lang\"",
")",
":",
"return",
"v",
"raise",
"AssertionErro... | Generates examples from TMX file. | [
"Generates",
"examples",
"from",
"TMX",
"file",
"."
] | python | train |
dpkp/kafka-python | kafka/producer/kafka.py | https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L612-L637 | def flush(self, timeout=None):
"""
Invoking this method makes all buffered records immediately available
to send (even if linger_ms is greater than 0) and blocks on the
completion of the requests associated with these records. The
post-condition of :meth:`~kafka.KafkaProducer.flu... | [
"def",
"flush",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\"Flushing accumulated records in producer.\"",
")",
"# trace",
"self",
".",
"_accumulator",
".",
"begin_flush",
"(",
")",
"self",
".",
"_sender",
".",
"wakeup",
"... | Invoking this method makes all buffered records immediately available
to send (even if linger_ms is greater than 0) and blocks on the
completion of the requests associated with these records. The
post-condition of :meth:`~kafka.KafkaProducer.flush` is that any
previously sent record will... | [
"Invoking",
"this",
"method",
"makes",
"all",
"buffered",
"records",
"immediately",
"available",
"to",
"send",
"(",
"even",
"if",
"linger_ms",
"is",
"greater",
"than",
"0",
")",
"and",
"blocks",
"on",
"the",
"completion",
"of",
"the",
"requests",
"associated",... | python | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv1/queue.py | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/queue.py#L18-L26 | def List(type='All'):
"""List of Queued requests and their current status details.
https://t3n.zendesk.com/entries/20350251-List-Queue-Requests
:param type: list items in the queue filtered by status (All, Pending, Complete, Error)
"""
r = clc.v1.API.Call('post','Queue/ListQueueRequests',{'ItemStatusType': ... | [
"def",
"List",
"(",
"type",
"=",
"'All'",
")",
":",
"r",
"=",
"clc",
".",
"v1",
".",
"API",
".",
"Call",
"(",
"'post'",
",",
"'Queue/ListQueueRequests'",
",",
"{",
"'ItemStatusType'",
":",
"Queue",
".",
"item_status_type_map",
"[",
"type",
"]",
"}",
")... | List of Queued requests and their current status details.
https://t3n.zendesk.com/entries/20350251-List-Queue-Requests
:param type: list items in the queue filtered by status (All, Pending, Complete, Error) | [
"List",
"of",
"Queued",
"requests",
"and",
"their",
"current",
"status",
"details",
"."
] | python | train |
project-ncl/pnc-cli | pnc_cli/buildconfigurations.py | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/buildconfigurations.py#L367-L373 | def add_dependency(id=None, name=None, dependency_id=None, dependency_name=None):
"""
Add an existing BuildConfiguration as a dependency to another BuildConfiguration.
"""
data = add_dependency_raw(id, name, dependency_id, dependency_name)
if data:
return utils.format_json_list(data) | [
"def",
"add_dependency",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"dependency_id",
"=",
"None",
",",
"dependency_name",
"=",
"None",
")",
":",
"data",
"=",
"add_dependency_raw",
"(",
"id",
",",
"name",
",",
"dependency_id",
",",
"dependency_n... | Add an existing BuildConfiguration as a dependency to another BuildConfiguration. | [
"Add",
"an",
"existing",
"BuildConfiguration",
"as",
"a",
"dependency",
"to",
"another",
"BuildConfiguration",
"."
] | python | train |
arista-eosplus/pyeapi | pyeapi/api/vrrp.py | https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/vrrp.py#L354-L379 | def create(self, interface, vrid, **kwargs):
"""Creates a vrrp instance from an interface
Note:
This method will attempt to create a vrrp in the node's
operational config. If the vrrp already exists on the
interface, then this method will set the properties of
... | [
"def",
"create",
"(",
"self",
",",
"interface",
",",
"vrid",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'enable'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'enable'",
"]",
"=",
"False",
"return",
"self",
".",
"_vrrp_set",
"(",
"interface",
",",
"vr... | Creates a vrrp instance from an interface
Note:
This method will attempt to create a vrrp in the node's
operational config. If the vrrp already exists on the
interface, then this method will set the properties of
the existing vrrp to those that have been passed i... | [
"Creates",
"a",
"vrrp",
"instance",
"from",
"an",
"interface"
] | python | train |
Brazelton-Lab/bio_utils | bio_utils/iterators/b6.py | https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/iterators/b6.py#L97-L125 | def write(self, default: bool=False):
"""Restore B6/M8 entry to original format
Args:
default (bool): output entry in default BLAST+ B6 format
Returns:
str: properly formatted string containing the B6/M8 entry
"""
none_type = type(None)
if def... | [
"def",
"write",
"(",
"self",
",",
"default",
":",
"bool",
"=",
"False",
")",
":",
"none_type",
"=",
"type",
"(",
"None",
")",
"if",
"default",
":",
"# Default order of format specifiers",
"ordered_vals",
"=",
"[",
"'query'",
",",
"'subject'",
",",
"'identity... | Restore B6/M8 entry to original format
Args:
default (bool): output entry in default BLAST+ B6 format
Returns:
str: properly formatted string containing the B6/M8 entry | [
"Restore",
"B6",
"/",
"M8",
"entry",
"to",
"original",
"format"
] | python | train |
housecanary/hc-api-python | housecanary/apiclient.py | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L218-L250 | def _convert_to_identifier_json(self, address_data):
"""Convert input address data into json format"""
if isinstance(address_data, str):
# allow just passing a slug string.
return {"slug": address_data}
if isinstance(address_data, tuple) and len(address_data) > 0:
... | [
"def",
"_convert_to_identifier_json",
"(",
"self",
",",
"address_data",
")",
":",
"if",
"isinstance",
"(",
"address_data",
",",
"str",
")",
":",
"# allow just passing a slug string.",
"return",
"{",
"\"slug\"",
":",
"address_data",
"}",
"if",
"isinstance",
"(",
"a... | Convert input address data into json format | [
"Convert",
"input",
"address",
"data",
"into",
"json",
"format"
] | python | train |
pvlib/pvlib-python | pvlib/solarposition.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/solarposition.py#L1313-L1355 | def hour_angle(times, longitude, equation_of_time):
"""
Hour angle in local solar time. Zero at local solar noon.
Parameters
----------
times : :class:`pandas.DatetimeIndex`
Corresponding timestamps, must be localized to the timezone for the
``longitude``.
longitude : numeric
... | [
"def",
"hour_angle",
"(",
"times",
",",
"longitude",
",",
"equation_of_time",
")",
":",
"naive_times",
"=",
"times",
".",
"tz_localize",
"(",
"None",
")",
"# naive but still localized",
"# hours - timezone = (times - normalized_times) - (naive_times - times)",
"hrs_minus_tzs"... | Hour angle in local solar time. Zero at local solar noon.
Parameters
----------
times : :class:`pandas.DatetimeIndex`
Corresponding timestamps, must be localized to the timezone for the
``longitude``.
longitude : numeric
Longitude in degrees
equation_of_time : numeric
... | [
"Hour",
"angle",
"in",
"local",
"solar",
"time",
".",
"Zero",
"at",
"local",
"solar",
"noon",
"."
] | python | train |
shaunduncan/nosqlite | nosqlite.py | https://github.com/shaunduncan/nosqlite/blob/3033c029b7c8290c66a8b36dc512e560505d4c85/nosqlite.py#L133-L149 | def update(self, document):
"""
Updates a document stored in this collection. If the document does not
already have an '_id' value, it will be created
"""
if '_id' not in document:
return self.insert(document)
# Update the stored document, removing the id
... | [
"def",
"update",
"(",
"self",
",",
"document",
")",
":",
"if",
"'_id'",
"not",
"in",
"document",
":",
"return",
"self",
".",
"insert",
"(",
"document",
")",
"# Update the stored document, removing the id",
"copy",
"=",
"document",
".",
"copy",
"(",
")",
"del... | Updates a document stored in this collection. If the document does not
already have an '_id' value, it will be created | [
"Updates",
"a",
"document",
"stored",
"in",
"this",
"collection",
".",
"If",
"the",
"document",
"does",
"not",
"already",
"have",
"an",
"_id",
"value",
"it",
"will",
"be",
"created"
] | python | train |
Kane610/axis | axis/rtsp.py | https://github.com/Kane610/axis/blob/b2b44ce595c7b722b5e13eabcab7b91f048e1808/axis/rtsp.py#L231-L239 | def SETUP(self):
"""Set up stream transport."""
message = "SETUP " + self.session.control_url + " RTSP/1.0\r\n"
message += self.sequence
message += self.authentication
message += self.user_agent
message += self.transport
message += '\r\n'
return message | [
"def",
"SETUP",
"(",
"self",
")",
":",
"message",
"=",
"\"SETUP \"",
"+",
"self",
".",
"session",
".",
"control_url",
"+",
"\" RTSP/1.0\\r\\n\"",
"message",
"+=",
"self",
".",
"sequence",
"message",
"+=",
"self",
".",
"authentication",
"message",
"+=",
"self... | Set up stream transport. | [
"Set",
"up",
"stream",
"transport",
"."
] | python | train |
csparpa/pyowm | pyowm/weatherapi25/parsers/observationlistparser.py | https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/parsers/observationlistparser.py#L20-L64 | def parse_JSON(self, JSON_string):
"""
Parses a list of *Observation* instances out of raw JSON data. Only
certain properties of the data are used: if these properties are not
found or cannot be parsed, an error is issued.
:param JSON_string: a raw JSON string
:type JSON... | [
"def",
"parse_JSON",
"(",
"self",
",",
"JSON_string",
")",
":",
"if",
"JSON_string",
"is",
"None",
":",
"raise",
"ParseResponseError",
"(",
"'JSON data is None'",
")",
"d",
"=",
"json",
".",
"loads",
"(",
"JSON_string",
")",
"observation_parser",
"=",
"Observa... | Parses a list of *Observation* instances out of raw JSON data. Only
certain properties of the data are used: if these properties are not
found or cannot be parsed, an error is issued.
:param JSON_string: a raw JSON string
:type JSON_string: str
:returns: a list of *Observation* ... | [
"Parses",
"a",
"list",
"of",
"*",
"Observation",
"*",
"instances",
"out",
"of",
"raw",
"JSON",
"data",
".",
"Only",
"certain",
"properties",
"of",
"the",
"data",
"are",
"used",
":",
"if",
"these",
"properties",
"are",
"not",
"found",
"or",
"cannot",
"be"... | python | train |
spoqa/tsukkomi | tsukkomi/typed.py | https://github.com/spoqa/tsukkomi/blob/c67bd28a5211cdd11f8ac81f109c915f3b780445/tsukkomi/typed.py#L109-L142 | def check_tuple(data: typing.Tuple,
hint: typing.Union[type, typing.TypingMeta]) -> bool:
"""Check argument type & return type of :class:`typing.Tuple`. since it
raises check :class:`typing.Tuple` using `isinstance`, so compare in
diffrent way
:param data: tuple given as a argument
... | [
"def",
"check_tuple",
"(",
"data",
":",
"typing",
".",
"Tuple",
",",
"hint",
":",
"typing",
".",
"Union",
"[",
"type",
",",
"typing",
".",
"TypingMeta",
"]",
")",
"->",
"bool",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"tuple",
")",
":",
"r... | Check argument type & return type of :class:`typing.Tuple`. since it
raises check :class:`typing.Tuple` using `isinstance`, so compare in
diffrent way
:param data: tuple given as a argument
:param hint: assumed type of given ``data`` | [
"Check",
"argument",
"type",
"&",
"return",
"type",
"of",
":",
"class",
":",
"typing",
".",
"Tuple",
".",
"since",
"it",
"raises",
"check",
":",
"class",
":",
"typing",
".",
"Tuple",
"using",
"isinstance",
"so",
"compare",
"in",
"diffrent",
"way"
] | python | train |
etcher-be/epab | epab/cmd/_chglog.py | https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/cmd/_chglog.py#L53-L63 | def temporary_tag(tag):
"""
Temporarily tags the repo
"""
if tag:
CTX.repo.tag(tag)
try:
yield
finally:
if tag:
CTX.repo.remove_tag(tag) | [
"def",
"temporary_tag",
"(",
"tag",
")",
":",
"if",
"tag",
":",
"CTX",
".",
"repo",
".",
"tag",
"(",
"tag",
")",
"try",
":",
"yield",
"finally",
":",
"if",
"tag",
":",
"CTX",
".",
"repo",
".",
"remove_tag",
"(",
"tag",
")"
] | Temporarily tags the repo | [
"Temporarily",
"tags",
"the",
"repo"
] | python | train |
elliterate/capybara.py | capybara/session.py | https://github.com/elliterate/capybara.py/blob/0c6ae449cc37e4445ec3cd6af95674533beedc6c/capybara/session.py#L532-L546 | def dismiss_confirm(self, text=None, wait=None):
"""
Execute the wrapped code, dismissing a confirm.
Args:
text (str | RegexObject, optional): Text to match against the text in the modal.
wait (int | float, optional): Maximum time to wait for the modal to appear after
... | [
"def",
"dismiss_confirm",
"(",
"self",
",",
"text",
"=",
"None",
",",
"wait",
"=",
"None",
")",
":",
"with",
"self",
".",
"driver",
".",
"dismiss_modal",
"(",
"\"confirm\"",
",",
"text",
"=",
"text",
",",
"wait",
"=",
"wait",
")",
":",
"yield"
] | Execute the wrapped code, dismissing a confirm.
Args:
text (str | RegexObject, optional): Text to match against the text in the modal.
wait (int | float, optional): Maximum time to wait for the modal to appear after
executing the wrapped code.
Raises:
... | [
"Execute",
"the",
"wrapped",
"code",
"dismissing",
"a",
"confirm",
"."
] | python | test |
thespacedoctor/fundamentals | fundamentals/mysql/readquery.py | https://github.com/thespacedoctor/fundamentals/blob/1d2c007ac74442ec2eabde771cfcacdb9c1ab382/fundamentals/mysql/readquery.py#L19-L79 | def readquery(
sqlQuery,
dbConn,
log,
quiet=False):
"""Given a mysql query, read the data from the database and return the results as a list of dictionaries (database rows)
**Key Arguments:**
- ``log`` -- the logger.
- ``sqlQuery`` -- the MySQL command to execute... | [
"def",
"readquery",
"(",
"sqlQuery",
",",
"dbConn",
",",
"log",
",",
"quiet",
"=",
"False",
")",
":",
"log",
".",
"debug",
"(",
"'starting the ``readquery`` function'",
")",
"import",
"pymysql",
"import",
"warnings",
"warnings",
".",
"filterwarnings",
"(",
"'e... | Given a mysql query, read the data from the database and return the results as a list of dictionaries (database rows)
**Key Arguments:**
- ``log`` -- the logger.
- ``sqlQuery`` -- the MySQL command to execute
- ``dbConn`` -- the db connection
- ``quiet`` -- ignore mysql warnings and... | [
"Given",
"a",
"mysql",
"query",
"read",
"the",
"data",
"from",
"the",
"database",
"and",
"return",
"the",
"results",
"as",
"a",
"list",
"of",
"dictionaries",
"(",
"database",
"rows",
")"
] | python | train |
apple/turicreate | src/unity/python/turicreate/toolkits/_tree_model_mixin.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_tree_model_mixin.py#L122-L189 | def _extract_features_with_missing(self, dataset, tree_id = 0,
missing_value_action = 'auto'):
"""
Extract features along with all the missing features associated with
a dataset.
Parameters
----------
dataset: bool
Dataset on which to make predict... | [
"def",
"_extract_features_with_missing",
"(",
"self",
",",
"dataset",
",",
"tree_id",
"=",
"0",
",",
"missing_value_action",
"=",
"'auto'",
")",
":",
"# Extract the features from only one tree.",
"sf",
"=",
"dataset",
"sf",
"[",
"'leaf_id'",
"]",
"=",
"self",
".",... | Extract features along with all the missing features associated with
a dataset.
Parameters
----------
dataset: bool
Dataset on which to make predictions.
missing_value_action: str, optional
Action to perform when missing values are encountered. This can ... | [
"Extract",
"features",
"along",
"with",
"all",
"the",
"missing",
"features",
"associated",
"with",
"a",
"dataset",
"."
] | python | train |
eddiejessup/agaro | agaro/runner.py | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/runner.py#L105-L111 | def is_snapshot_time(self, output_every=None, t_output_every=None):
"""Determine whether or not the model's iteration number is one
where the runner is expected to make an output snapshot.
"""
if t_output_every is not None:
output_every = int(round(t_output_every // self.mode... | [
"def",
"is_snapshot_time",
"(",
"self",
",",
"output_every",
"=",
"None",
",",
"t_output_every",
"=",
"None",
")",
":",
"if",
"t_output_every",
"is",
"not",
"None",
":",
"output_every",
"=",
"int",
"(",
"round",
"(",
"t_output_every",
"//",
"self",
".",
"m... | Determine whether or not the model's iteration number is one
where the runner is expected to make an output snapshot. | [
"Determine",
"whether",
"or",
"not",
"the",
"model",
"s",
"iteration",
"number",
"is",
"one",
"where",
"the",
"runner",
"is",
"expected",
"to",
"make",
"an",
"output",
"snapshot",
"."
] | python | train |
Esri/ArcREST | src/arcrest/common/symbology.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/symbology.py#L157-L182 | def value(self):
"""returns the object as dictionary"""
if self._outline is None:
return {
"type" : "esriSMS",
"style" : self._style,
"color" : self._color.value,
"size" : self._size,
"angle" : self._angle,
... | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_outline",
"is",
"None",
":",
"return",
"{",
"\"type\"",
":",
"\"esriSMS\"",
",",
"\"style\"",
":",
"self",
".",
"_style",
",",
"\"color\"",
":",
"self",
".",
"_color",
".",
"value",
",",
"\"... | returns the object as dictionary | [
"returns",
"the",
"object",
"as",
"dictionary"
] | python | train |
Cue/scales | src/greplin/scales/util.py | https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L85-L93 | def disconnect(self):
"""Disconnect from the Graphite server if connected."""
if self.sock is not None:
try:
self.sock.close()
except socket.error:
pass
finally:
self.sock = None | [
"def",
"disconnect",
"(",
"self",
")",
":",
"if",
"self",
".",
"sock",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"sock",
".",
"close",
"(",
")",
"except",
"socket",
".",
"error",
":",
"pass",
"finally",
":",
"self",
".",
"sock",
"=",
"No... | Disconnect from the Graphite server if connected. | [
"Disconnect",
"from",
"the",
"Graphite",
"server",
"if",
"connected",
"."
] | python | train |
dcos/shakedown | shakedown/dcos/task.py | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L118-L120 | def wait_for_task(service, task, timeout_sec=120):
"""Waits for a task which was launched to be launched"""
return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec) | [
"def",
"wait_for_task",
"(",
"service",
",",
"task",
",",
"timeout_sec",
"=",
"120",
")",
":",
"return",
"time_wait",
"(",
"lambda",
":",
"task_predicate",
"(",
"service",
",",
"task",
")",
",",
"timeout_seconds",
"=",
"timeout_sec",
")"
] | Waits for a task which was launched to be launched | [
"Waits",
"for",
"a",
"task",
"which",
"was",
"launched",
"to",
"be",
"launched"
] | python | train |
Robpol86/libnl | libnl/linux_private/genetlink.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/linux_private/genetlink.py#L71-L73 | def reserved(self, value):
"""Reserved setter."""
self.bytearray[self._get_slicers(2)] = bytearray(c_uint16(value or 0)) | [
"def",
"reserved",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"bytearray",
"[",
"self",
".",
"_get_slicers",
"(",
"2",
")",
"]",
"=",
"bytearray",
"(",
"c_uint16",
"(",
"value",
"or",
"0",
")",
")"
] | Reserved setter. | [
"Reserved",
"setter",
"."
] | python | train |
KelSolaar/Umbra | umbra/ui/widgets/basic_QPlainTextEdit.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/basic_QPlainTextEdit.py#L612-L637 | def duplicate_lines(self):
"""
Duplicates the document lines under cursor.
:return: Method success.
:rtype: bool
"""
cursor = self.textCursor()
self.__select_text_under_cursor_blocks(cursor)
text = cursor.selectedText()
cursor.setPosition(cursor... | [
"def",
"duplicate_lines",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"self",
".",
"__select_text_under_cursor_blocks",
"(",
"cursor",
")",
"text",
"=",
"cursor",
".",
"selectedText",
"(",
")",
"cursor",
".",
"setPosition",
"("... | Duplicates the document lines under cursor.
:return: Method success.
:rtype: bool | [
"Duplicates",
"the",
"document",
"lines",
"under",
"cursor",
"."
] | python | train |
mitsei/dlkit | dlkit/records/assessment/qti/numeric_response_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/qti/numeric_response_records.py#L905-L931 | def _init_metadata(self):
"""stub"""
DecimalValuesFormRecord._init_metadata(self)
IntegerValuesFormRecord._init_metadata(self)
TextAnswerFormRecord._init_metadata(self)
super(MultiLanguageCalculationInteractionFeedbackAndFilesAnswerFormRecord, self)._init_metadata()
self.... | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"DecimalValuesFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"IntegerValuesFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"TextAnswerFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"super",
"(",
"... | stub | [
"stub"
] | python | train |
UCBerkeleySETI/blimpy | blimpy/waterfall.py | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/waterfall.py#L509-L539 | def grab_data(self, f_start=None, f_stop=None,t_start=None, t_stop=None, if_id=0):
""" Extract a portion of data by frequency range.
Args:
f_start (float): start frequency in MHz
f_stop (float): stop frequency in MHz
if_id (int): IF input identification (req. when mu... | [
"def",
"grab_data",
"(",
"self",
",",
"f_start",
"=",
"None",
",",
"f_stop",
"=",
"None",
",",
"t_start",
"=",
"None",
",",
"t_stop",
"=",
"None",
",",
"if_id",
"=",
"0",
")",
":",
"self",
".",
"freqs",
"=",
"self",
".",
"populate_freqs",
"(",
")",... | Extract a portion of data by frequency range.
Args:
f_start (float): start frequency in MHz
f_stop (float): stop frequency in MHz
if_id (int): IF input identification (req. when multiple IFs in file)
Returns:
(freqs, data) (np.arrays): frequency axis in ... | [
"Extract",
"a",
"portion",
"of",
"data",
"by",
"frequency",
"range",
"."
] | python | test |
kontron/python-ipmi | pyipmi/interfaces/rmcp.py | https://github.com/kontron/python-ipmi/blob/ce46da47a37dd683615f32d04a10eda069aa569a/pyipmi/interfaces/rmcp.py#L541-L555 | def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
"""Interface function to send and receive raw message.
target: IPMI target
lun: logical unit number
netfn: network function
raw_bytes: RAW bytes as bytestring
Returns the IPMI message response bytestring.
... | [
"def",
"send_and_receive_raw",
"(",
"self",
",",
"target",
",",
"lun",
",",
"netfn",
",",
"raw_bytes",
")",
":",
"return",
"self",
".",
"_send_and_receive",
"(",
"target",
"=",
"target",
",",
"lun",
"=",
"lun",
",",
"netfn",
"=",
"netfn",
",",
"cmdid",
... | Interface function to send and receive raw message.
target: IPMI target
lun: logical unit number
netfn: network function
raw_bytes: RAW bytes as bytestring
Returns the IPMI message response bytestring. | [
"Interface",
"function",
"to",
"send",
"and",
"receive",
"raw",
"message",
"."
] | python | train |
elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L454-L461 | def get_settings(self, using=None, **kwargs):
"""
Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged.
"""
return self._get_connection(using).indices.get_settings(index=self._name, **kwargs) | [
"def",
"get_settings",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get_settings",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*"... | Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged. | [
"Retrieve",
"settings",
"for",
"the",
"index",
"."
] | python | train |
openstack/horizon | openstack_dashboard/api/keystone.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L671-L696 | def get_project_groups_roles(request, project):
"""Gets the groups roles in a given project.
:param request: the request entity containing the login user information
:param project: the project to filter the groups roles. It accepts both
project object resource or project ID
:retur... | [
"def",
"get_project_groups_roles",
"(",
"request",
",",
"project",
")",
":",
"groups_roles",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"project_role_assignments",
"=",
"role_assignments_list",
"(",
"request",
",",
"project",
"=",
"project",
")",
"f... | Gets the groups roles in a given project.
:param request: the request entity containing the login user information
:param project: the project to filter the groups roles. It accepts both
project object resource or project ID
:returns group_roles: a dictionary mapping the groups and the... | [
"Gets",
"the",
"groups",
"roles",
"in",
"a",
"given",
"project",
"."
] | python | train |
google/grr | grr/core/grr_response_core/lib/communicator.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L242-L263 | def VerifyCipherSignature(self, remote_public_key):
"""Verifies the signature on the encrypted cipher block.
This method returns True if the signature verifies correctly with
the key given.
Args:
remote_public_key: The remote public key.
Returns:
None
Raises:
rdf_crypto.Veri... | [
"def",
"VerifyCipherSignature",
"(",
"self",
",",
"remote_public_key",
")",
":",
"if",
"self",
".",
"cipher_metadata",
".",
"signature",
"and",
"remote_public_key",
":",
"stats_collector_instance",
".",
"Get",
"(",
")",
".",
"IncrementCounter",
"(",
"\"grr_rsa_opera... | Verifies the signature on the encrypted cipher block.
This method returns True if the signature verifies correctly with
the key given.
Args:
remote_public_key: The remote public key.
Returns:
None
Raises:
rdf_crypto.VerificationError: A signature and a key were both given but
... | [
"Verifies",
"the",
"signature",
"on",
"the",
"encrypted",
"cipher",
"block",
"."
] | python | train |
PSPC-SPAC-buyandsell/von_agent | von_agent/agent/holder_prover.py | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/holder_prover.py#L690-L738 | async def get_box_ids_json(self) -> str:
"""
Return json object on lists of all unique box identifiers for credentials in wallet:
schema identifiers, credential definition identifiers, and revocation registry identifiers; e.g.,
::
{
"schema_id": [
"R... | [
"async",
"def",
"get_box_ids_json",
"(",
"self",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'HolderProver.get_box_ids_json >>>'",
")",
"s_ids",
"=",
"set",
"(",
")",
"cd_ids",
"=",
"set",
"(",
")",
"rr_ids",
"=",
"set",
"(",
")",
"for",
"cred",... | Return json object on lists of all unique box identifiers for credentials in wallet:
schema identifiers, credential definition identifiers, and revocation registry identifiers; e.g.,
::
{
"schema_id": [
"R17v42T4pk...:2:tombstone:1.2",
"9cHbp54C8n...... | [
"Return",
"json",
"object",
"on",
"lists",
"of",
"all",
"unique",
"box",
"identifiers",
"for",
"credentials",
"in",
"wallet",
":",
"schema",
"identifiers",
"credential",
"definition",
"identifiers",
"and",
"revocation",
"registry",
"identifiers",
";",
"e",
".",
... | python | train |
dgomes/pymediaroom | pymediaroom/notify.py | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L80-L85 | def timeshift(self):
"""Return if the stream is a timeshift."""
if self.tune and self.tune.get('@src'):
return True if self.tune.get('@src').startswith('timeshift') else False
else:
raise PyMediaroomError("No information in <node> about @src") | [
"def",
"timeshift",
"(",
"self",
")",
":",
"if",
"self",
".",
"tune",
"and",
"self",
".",
"tune",
".",
"get",
"(",
"'@src'",
")",
":",
"return",
"True",
"if",
"self",
".",
"tune",
".",
"get",
"(",
"'@src'",
")",
".",
"startswith",
"(",
"'timeshift'... | Return if the stream is a timeshift. | [
"Return",
"if",
"the",
"stream",
"is",
"a",
"timeshift",
"."
] | python | train |
dslackw/slpkg | slpkg/downloader.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/downloader.py#L85-L89 | def _make_tarfile(self, output_filename, source_dir):
"""Create .tar.gz file
"""
with tarfile.open(output_filename, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir)) | [
"def",
"_make_tarfile",
"(",
"self",
",",
"output_filename",
",",
"source_dir",
")",
":",
"with",
"tarfile",
".",
"open",
"(",
"output_filename",
",",
"\"w:gz\"",
")",
"as",
"tar",
":",
"tar",
".",
"add",
"(",
"source_dir",
",",
"arcname",
"=",
"os",
"."... | Create .tar.gz file | [
"Create",
".",
"tar",
".",
"gz",
"file"
] | python | train |
pymoca/pymoca | src/pymoca/backends/xml/model.py | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L102-L108 | def create_function_f_J(self):
"""Jacobian for state integration"""
return ca.Function(
'J',
[self.t, self.x, self.y, self.m, self.p, self.c, self.ng, self.nu],
[ca.jacobian(self.f_x_rhs, self.x)],
['t', 'x', 'y', 'm', 'p', 'c', 'ng', 'nu'], ['J'], self.fu... | [
"def",
"create_function_f_J",
"(",
"self",
")",
":",
"return",
"ca",
".",
"Function",
"(",
"'J'",
",",
"[",
"self",
".",
"t",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"m",
",",
"self",
".",
"p",
",",
"self",
".",
"c",
"... | Jacobian for state integration | [
"Jacobian",
"for",
"state",
"integration"
] | python | train |
boris-savic/python-mbills | python_mbills/api.py | https://github.com/boris-savic/python-mbills/blob/a2147810c8c54b9242d9bcc2218622f1e19f9ac3/python_mbills/api.py#L101-L121 | def fetch_transaction_status(self, transaction_id):
"""
Get the transaction current status.
:param transaction_id:
:return:
"""
url = "%s%s%s/status" % (self.api_endpoint, constants.TRANSACTION_STATUS_ENDPOINT, transaction_id)
username = self.base.get_usernam... | [
"def",
"fetch_transaction_status",
"(",
"self",
",",
"transaction_id",
")",
":",
"url",
"=",
"\"%s%s%s/status\"",
"%",
"(",
"self",
".",
"api_endpoint",
",",
"constants",
".",
"TRANSACTION_STATUS_ENDPOINT",
",",
"transaction_id",
")",
"username",
"=",
"self",
".",... | Get the transaction current status.
:param transaction_id:
:return: | [
"Get",
"the",
"transaction",
"current",
"status",
"."
] | python | train |
jpscaletti/solution | solution/_compat.py | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/_compat.py#L47-L51 | def itervalues(d, **kw):
"""Return an iterator over the values of a dictionary."""
if not PY2:
return iter(d.values(**kw))
return d.itervalues(**kw) | [
"def",
"itervalues",
"(",
"d",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"PY2",
":",
"return",
"iter",
"(",
"d",
".",
"values",
"(",
"*",
"*",
"kw",
")",
")",
"return",
"d",
".",
"itervalues",
"(",
"*",
"*",
"kw",
")"
] | Return an iterator over the values of a dictionary. | [
"Return",
"an",
"iterator",
"over",
"the",
"values",
"of",
"a",
"dictionary",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/video/basic_deterministic_params.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/basic_deterministic_params.py#L110-L117 | def next_frame_ae_tiny():
"""Conv autoencoder, tiny set for testing."""
hparams = next_frame_tiny()
hparams.bottom["inputs"] = modalities.video_bitwise_bottom
hparams.top["inputs"] = modalities.video_top
hparams.batch_size = 8
hparams.dropout = 0.4
return hparams | [
"def",
"next_frame_ae_tiny",
"(",
")",
":",
"hparams",
"=",
"next_frame_tiny",
"(",
")",
"hparams",
".",
"bottom",
"[",
"\"inputs\"",
"]",
"=",
"modalities",
".",
"video_bitwise_bottom",
"hparams",
".",
"top",
"[",
"\"inputs\"",
"]",
"=",
"modalities",
".",
... | Conv autoencoder, tiny set for testing. | [
"Conv",
"autoencoder",
"tiny",
"set",
"for",
"testing",
"."
] | python | train |
kata198/indexedredis | IndexedRedis/__init__.py | https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/__init__.py#L515-L536 | def hasUnsavedChanges(self, cascadeObjects=False):
'''
hasUnsavedChanges - Check if any unsaved changes are present in this model, or if it has never been saved.
@param cascadeObjects <bool> default False, if True will check if any foreign linked objects themselves have unsaved changes (recursively).
Other... | [
"def",
"hasUnsavedChanges",
"(",
"self",
",",
"cascadeObjects",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_id",
"or",
"not",
"self",
".",
"_origData",
":",
"return",
"True",
"for",
"thisField",
"in",
"self",
".",
"FIELDS",
":",
"thisVal",
"=",
... | hasUnsavedChanges - Check if any unsaved changes are present in this model, or if it has never been saved.
@param cascadeObjects <bool> default False, if True will check if any foreign linked objects themselves have unsaved changes (recursively).
Otherwise, will just check if the pk has changed.
@return <bo... | [
"hasUnsavedChanges",
"-",
"Check",
"if",
"any",
"unsaved",
"changes",
"are",
"present",
"in",
"this",
"model",
"or",
"if",
"it",
"has",
"never",
"been",
"saved",
"."
] | python | valid |
saltstack/salt | salt/states/boto3_elasticache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto3_elasticache.py#L106-L161 | def _diff_cache_cluster(current, desired):
'''
If you need to enhance what modify_cache_cluster() considers when deciding what is to be
(or can be) updated, add it to 'modifiable' below. It's a dict mapping the param as used
in modify_cache_cluster() to that in describe_cache_clusters(). Any data fidd... | [
"def",
"_diff_cache_cluster",
"(",
"current",
",",
"desired",
")",
":",
"### The data formats are annoyingly (and as far as I can can tell, unnecessarily)",
"### different - we have to munge to a common format to compare...",
"if",
"current",
".",
"get",
"(",
"'SecurityGroups'",
")",... | If you need to enhance what modify_cache_cluster() considers when deciding what is to be
(or can be) updated, add it to 'modifiable' below. It's a dict mapping the param as used
in modify_cache_cluster() to that in describe_cache_clusters(). Any data fiddlery that
needs to be done to make the mappings mea... | [
"If",
"you",
"need",
"to",
"enhance",
"what",
"modify_cache_cluster",
"()",
"considers",
"when",
"deciding",
"what",
"is",
"to",
"be",
"(",
"or",
"can",
"be",
")",
"updated",
"add",
"it",
"to",
"modifiable",
"below",
".",
"It",
"s",
"a",
"dict",
"mapping... | python | train |
napalm-automation/napalm-ios | napalm_ios/ios.py | https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L436-L443 | def discard_config(self):
"""Set candidate_cfg to current running-config. Erase the merge_cfg file."""
discard_candidate = 'copy running-config {}'.format(self._gen_full_path(self.candidate_cfg))
discard_merge = 'copy null: {}'.format(self._gen_full_path(self.merge_cfg))
self._disable_co... | [
"def",
"discard_config",
"(",
"self",
")",
":",
"discard_candidate",
"=",
"'copy running-config {}'",
".",
"format",
"(",
"self",
".",
"_gen_full_path",
"(",
"self",
".",
"candidate_cfg",
")",
")",
"discard_merge",
"=",
"'copy null: {}'",
".",
"format",
"(",
"se... | Set candidate_cfg to current running-config. Erase the merge_cfg file. | [
"Set",
"candidate_cfg",
"to",
"current",
"running",
"-",
"config",
".",
"Erase",
"the",
"merge_cfg",
"file",
"."
] | python | train |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L282-L327 | def create_folder(self, uri, recursive=False):
"""Create folder.
uri -- MediaFire URI
Keyword arguments:
recursive -- set to True to create intermediate folders.
"""
logger.info("Creating %s", uri)
# check that folder exists already
try:
res... | [
"def",
"create_folder",
"(",
"self",
",",
"uri",
",",
"recursive",
"=",
"False",
")",
":",
"logger",
".",
"info",
"(",
"\"Creating %s\"",
",",
"uri",
")",
"# check that folder exists already",
"try",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(... | Create folder.
uri -- MediaFire URI
Keyword arguments:
recursive -- set to True to create intermediate folders. | [
"Create",
"folder",
"."
] | python | train |
csparpa/pyowm | pyowm/pollutionapi30/ozone.py | https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/pollutionapi30/ozone.py#L144-L162 | def _to_DOM(self):
"""
Dumps object data to a fully traversable DOM representation of the
object.
:returns: a ``xml.etree.Element`` object
"""
root_node = ET.Element("ozone")
reference_time_node = ET.SubElement(root_node, "reference_time")
reference_time... | [
"def",
"_to_DOM",
"(",
"self",
")",
":",
"root_node",
"=",
"ET",
".",
"Element",
"(",
"\"ozone\"",
")",
"reference_time_node",
"=",
"ET",
".",
"SubElement",
"(",
"root_node",
",",
"\"reference_time\"",
")",
"reference_time_node",
".",
"text",
"=",
"str",
"("... | Dumps object data to a fully traversable DOM representation of the
object.
:returns: a ``xml.etree.Element`` object | [
"Dumps",
"object",
"data",
"to",
"a",
"fully",
"traversable",
"DOM",
"representation",
"of",
"the",
"object",
"."
] | python | train |
edeposit/marcxml_parser | src/marcxml_parser/query.py | https://github.com/edeposit/marcxml_parser/blob/6d1c77c61fc2827b71f1b3d5aa3332d7f5807820/src/marcxml_parser/query.py#L385-L403 | def get_corporations(self, roles=["dst"]):
"""
Args:
roles (list, optional): Specify which types of corporations you
need. Set to ``["any"]`` for any role, ``["dst"]`` for
distributors, etc..
Note:
See http://www.loc.gov/marc/relators/... | [
"def",
"get_corporations",
"(",
"self",
",",
"roles",
"=",
"[",
"\"dst\"",
"]",
")",
":",
"corporations",
"=",
"self",
".",
"_parse_corporations",
"(",
"\"110\"",
",",
"\"a\"",
",",
"roles",
")",
"corporations",
"+=",
"self",
".",
"_parse_corporations",
"(",... | Args:
roles (list, optional): Specify which types of corporations you
need. Set to ``["any"]`` for any role, ``["dst"]`` for
distributors, etc..
Note:
See http://www.loc.gov/marc/relators/relaterm.html for details.
Returns:
list: ... | [
"Args",
":",
"roles",
"(",
"list",
"optional",
")",
":",
"Specify",
"which",
"types",
"of",
"corporations",
"you",
"need",
".",
"Set",
"to",
"[",
"any",
"]",
"for",
"any",
"role",
"[",
"dst",
"]",
"for",
"distributors",
"etc",
".."
] | python | valid |
dhermes/bezier | src/bezier/curve.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L276-L315 | def subdivide(self):
r"""Split the curve :math:`B(s)` into a left and right half.
Takes the interval :math:`\left[0, 1\right]` and splits the curve into
:math:`B_1 = B\left(\left[0, \frac{1}{2}\right]\right)` and
:math:`B_2 = B\left(\left[\frac{1}{2}, 1\right]\right)`. In
order ... | [
"def",
"subdivide",
"(",
"self",
")",
":",
"left_nodes",
",",
"right_nodes",
"=",
"_curve_helpers",
".",
"subdivide_nodes",
"(",
"self",
".",
"_nodes",
")",
"left",
"=",
"Curve",
"(",
"left_nodes",
",",
"self",
".",
"_degree",
",",
"_copy",
"=",
"False",
... | r"""Split the curve :math:`B(s)` into a left and right half.
Takes the interval :math:`\left[0, 1\right]` and splits the curve into
:math:`B_1 = B\left(\left[0, \frac{1}{2}\right]\right)` and
:math:`B_2 = B\left(\left[\frac{1}{2}, 1\right]\right)`. In
order to do this, also reparameteri... | [
"r",
"Split",
"the",
"curve",
":",
"math",
":",
"B",
"(",
"s",
")",
"into",
"a",
"left",
"and",
"right",
"half",
"."
] | python | train |
geophysics-ubonn/reda | lib/reda/utils/geometric_factors.py | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/geometric_factors.py#L29-L74 | def compute_K_numerical(dataframe, settings=None, keep_dir=None):
"""Use a finite-element modeling code to infer geometric factors for meshes
with topography or irregular electrode spacings.
Parameters
----------
dataframe : pandas.DataFrame
the data frame that contains the data
setting... | [
"def",
"compute_K_numerical",
"(",
"dataframe",
",",
"settings",
"=",
"None",
",",
"keep_dir",
"=",
"None",
")",
":",
"inversion_code",
"=",
"reda",
".",
"rcParams",
".",
"get",
"(",
"'geom_factor.inversion_code'",
",",
"'crtomo'",
")",
"if",
"inversion_code",
... | Use a finite-element modeling code to infer geometric factors for meshes
with topography or irregular electrode spacings.
Parameters
----------
dataframe : pandas.DataFrame
the data frame that contains the data
settings : dict
The settings required to compute the geometric factors. ... | [
"Use",
"a",
"finite",
"-",
"element",
"modeling",
"code",
"to",
"infer",
"geometric",
"factors",
"for",
"meshes",
"with",
"topography",
"or",
"irregular",
"electrode",
"spacings",
"."
] | python | train |
koenedaele/skosprovider | skosprovider/registry.py | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L37-L55 | def register_provider(self, provider):
'''
Register a :class:`skosprovider.providers.VocabularyProvider`.
:param skosprovider.providers.VocabularyProvider provider: The provider
to register.
:raises RegistryException: A provider with this id or uri has already
b... | [
"def",
"register_provider",
"(",
"self",
",",
"provider",
")",
":",
"if",
"provider",
".",
"get_vocabulary_id",
"(",
")",
"in",
"self",
".",
"providers",
":",
"raise",
"RegistryException",
"(",
"'A provider with this id has already been registered.'",
")",
"self",
"... | Register a :class:`skosprovider.providers.VocabularyProvider`.
:param skosprovider.providers.VocabularyProvider provider: The provider
to register.
:raises RegistryException: A provider with this id or uri has already
been registered. | [
"Register",
"a",
":",
"class",
":",
"skosprovider",
".",
"providers",
".",
"VocabularyProvider",
"."
] | python | valid |
h2non/paco | paco/curry.py | https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/curry.py#L8-L143 | def curry(arity_or_fn=None, ignore_kwargs=False, evaluator=None, *args, **kw):
"""
Creates a function that accepts one or more arguments of a function and
either invokes func returning its result if at least arity number of
arguments have been provided, or returns a function that accepts the
remaini... | [
"def",
"curry",
"(",
"arity_or_fn",
"=",
"None",
",",
"ignore_kwargs",
"=",
"False",
",",
"evaluator",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"def",
"isvalidarg",
"(",
"x",
")",
":",
"return",
"all",
"(",
"[",
"x",
".",
"ki... | Creates a function that accepts one or more arguments of a function and
either invokes func returning its result if at least arity number of
arguments have been provided, or returns a function that accepts the
remaining function arguments until the function arity is satisfied.
This function is overload... | [
"Creates",
"a",
"function",
"that",
"accepts",
"one",
"or",
"more",
"arguments",
"of",
"a",
"function",
"and",
"either",
"invokes",
"func",
"returning",
"its",
"result",
"if",
"at",
"least",
"arity",
"number",
"of",
"arguments",
"have",
"been",
"provided",
"... | python | train |
jbloomlab/phydms | phydmslib/models.py | https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/models.py#L1281-L1295 | def _update_phi(self):
"""Compute `phi`, `dphi_dbeta`, and `eta` from `g` and `frxy`."""
self.phi = self._compute_empirical_phi(self.beta)
_checkParam('phi', self.phi, self.PARAMLIMITS, self.PARAMTYPES)
self._eta_from_phi()
dbeta = 1.0e-3
self.dphi_dbeta = scipy.misc.deri... | [
"def",
"_update_phi",
"(",
"self",
")",
":",
"self",
".",
"phi",
"=",
"self",
".",
"_compute_empirical_phi",
"(",
"self",
".",
"beta",
")",
"_checkParam",
"(",
"'phi'",
",",
"self",
".",
"phi",
",",
"self",
".",
"PARAMLIMITS",
",",
"self",
".",
"PARAMT... | Compute `phi`, `dphi_dbeta`, and `eta` from `g` and `frxy`. | [
"Compute",
"phi",
"dphi_dbeta",
"and",
"eta",
"from",
"g",
"and",
"frxy",
"."
] | python | train |
IdentityPython/pysaml2 | src/saml2/attribute_converter.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/attribute_converter.py#L335-L358 | def fro(self, statement):
""" Get the attributes and the attribute values.
:param statement: The AttributeStatement.
:return: A dictionary containing attributes and values
"""
if not self.name_format:
return self.fail_safe_fro(statement)
result = {}
... | [
"def",
"fro",
"(",
"self",
",",
"statement",
")",
":",
"if",
"not",
"self",
".",
"name_format",
":",
"return",
"self",
".",
"fail_safe_fro",
"(",
"statement",
")",
"result",
"=",
"{",
"}",
"for",
"attribute",
"in",
"statement",
".",
"attribute",
":",
"... | Get the attributes and the attribute values.
:param statement: The AttributeStatement.
:return: A dictionary containing attributes and values | [
"Get",
"the",
"attributes",
"and",
"the",
"attribute",
"values",
"."
] | python | train |
MAVENSDC/cdflib | cdflib/cdfwrite.py | https://github.com/MAVENSDC/cdflib/blob/d237c60e5db67db0f92d96054209c25c4042465c/cdflib/cdfwrite.py#L2304-L2312 | def _update_offset_value(self, f, offset, size, value):
'''
Writes "value" into location "offset" in file "f".
'''
f.seek(offset, 0)
if (size == 8):
f.write(struct.pack('>q', value))
else:
f.write(struct.pack('>i', value)) | [
"def",
"_update_offset_value",
"(",
"self",
",",
"f",
",",
"offset",
",",
"size",
",",
"value",
")",
":",
"f",
".",
"seek",
"(",
"offset",
",",
"0",
")",
"if",
"(",
"size",
"==",
"8",
")",
":",
"f",
".",
"write",
"(",
"struct",
".",
"pack",
"("... | Writes "value" into location "offset" in file "f". | [
"Writes",
"value",
"into",
"location",
"offset",
"in",
"file",
"f",
"."
] | python | train |
belbio/bel | bel/lang/ast.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/lang/ast.py#L358-L380 | def subcomponents(self, subcomponents):
"""Generate subcomponents of the BEL subject or object
These subcomponents are used for matching parts of a BEL
subject or Object in the Edgestore.
Args:
AST
subcomponents: Pass an empty list to start a new subcomponents ... | [
"def",
"subcomponents",
"(",
"self",
",",
"subcomponents",
")",
":",
"for",
"arg",
"in",
"self",
".",
"args",
":",
"if",
"arg",
".",
"__class__",
".",
"__name__",
"==",
"\"Function\"",
":",
"subcomponents",
".",
"append",
"(",
"arg",
".",
"to_string",
"(... | Generate subcomponents of the BEL subject or object
These subcomponents are used for matching parts of a BEL
subject or Object in the Edgestore.
Args:
AST
subcomponents: Pass an empty list to start a new subcomponents request
Returns:
List[str]: su... | [
"Generate",
"subcomponents",
"of",
"the",
"BEL",
"subject",
"or",
"object"
] | python | train |
tensorflow/datasets | tensorflow_datasets/core/tf_compat.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/tf_compat.py#L135-L152 | def _patch_for_tf1_13(tf):
"""Monkey patch tf 1.13 so tfds can use it."""
if not hasattr(tf.io.gfile, "GFile"):
tf.io.gfile.GFile = tf.gfile.GFile
if not hasattr(tf, "nest"):
tf.nest = tf.contrib.framework.nest
if not hasattr(tf.compat, "v2"):
tf.compat.v2 = types.ModuleType("tf.compat.v2")
tf.c... | [
"def",
"_patch_for_tf1_13",
"(",
"tf",
")",
":",
"if",
"not",
"hasattr",
"(",
"tf",
".",
"io",
".",
"gfile",
",",
"\"GFile\"",
")",
":",
"tf",
".",
"io",
".",
"gfile",
".",
"GFile",
"=",
"tf",
".",
"gfile",
".",
"GFile",
"if",
"not",
"hasattr",
"... | Monkey patch tf 1.13 so tfds can use it. | [
"Monkey",
"patch",
"tf",
"1",
".",
"13",
"so",
"tfds",
"can",
"use",
"it",
"."
] | python | train |
ynop/audiomate | audiomate/corpus/io/mailabs.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/mailabs.py#L132-L151 | def load_speaker(corpus, path):
"""
Create a speaker instance for the given path.
"""
base_path, speaker_name = os.path.split(path)
base_path, gender_desc = os.path.split(base_path)
base_path, __ = os.path.split(base_path)
base_path, tag = os.path.split(base_path)... | [
"def",
"load_speaker",
"(",
"corpus",
",",
"path",
")",
":",
"base_path",
",",
"speaker_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"base_path",
",",
"gender_desc",
"=",
"os",
".",
"path",
".",
"split",
"(",
"base_path",
")",
"base_p... | Create a speaker instance for the given path. | [
"Create",
"a",
"speaker",
"instance",
"for",
"the",
"given",
"path",
"."
] | python | train |
mvn23/pyotgw | pyotgw/pyotgw.py | https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L458-L500 | async def set_gpio_mode(self, gpio_id, mode, timeout=OTGW_DEFAULT_TIMEOUT):
"""
Configure the functions of the two GPIO pins of the gateway.
The following functions are available:
0 No function, default for both ports on a freshly flashed chip
1 Ground - A permanently low output... | [
"async",
"def",
"set_gpio_mode",
"(",
"self",
",",
"gpio_id",
",",
"mode",
",",
"timeout",
"=",
"OTGW_DEFAULT_TIMEOUT",
")",
":",
"if",
"gpio_id",
"in",
"\"AB\"",
"and",
"mode",
"in",
"range",
"(",
"8",
")",
":",
"if",
"mode",
"==",
"7",
"and",
"gpio_i... | Configure the functions of the two GPIO pins of the gateway.
The following functions are available:
0 No function, default for both ports on a freshly flashed chip
1 Ground - A permanently low output (0V). Could be used for a
power LED
2 Vcc - A permanently high output (5V).... | [
"Configure",
"the",
"functions",
"of",
"the",
"two",
"GPIO",
"pins",
"of",
"the",
"gateway",
".",
"The",
"following",
"functions",
"are",
"available",
":"
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/psychiatry/drugs.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/psychiatry/drugs.py#L1324-L1334 | def drug_name_to_generic(drug_name: str,
unknown_to_default: bool = False,
default: str = None,
include_categories: bool = False) -> str:
"""
Converts a drug name to the name of its generic equivalent.
"""
drug = get_drug(drug_na... | [
"def",
"drug_name_to_generic",
"(",
"drug_name",
":",
"str",
",",
"unknown_to_default",
":",
"bool",
"=",
"False",
",",
"default",
":",
"str",
"=",
"None",
",",
"include_categories",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"drug",
"=",
"get_drug"... | Converts a drug name to the name of its generic equivalent. | [
"Converts",
"a",
"drug",
"name",
"to",
"the",
"name",
"of",
"its",
"generic",
"equivalent",
"."
] | python | train |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/docker_api/sip_docker_swarm/docker_swarm_client.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/docker_api/sip_docker_swarm/docker_swarm_client.py#L178-L191 | def delete_all_services(self):
"""Removes/stops a service.
Only the manager nodes can delete a service
"""
# Raise an exception if we are not a manager
if not self._manager:
raise RuntimeError('Services can only be deleted '
'on swarm m... | [
"def",
"delete_all_services",
"(",
"self",
")",
":",
"# Raise an exception if we are not a manager",
"if",
"not",
"self",
".",
"_manager",
":",
"raise",
"RuntimeError",
"(",
"'Services can only be deleted '",
"'on swarm manager nodes'",
")",
"service_list",
"=",
"self",
"... | Removes/stops a service.
Only the manager nodes can delete a service | [
"Removes",
"/",
"stops",
"a",
"service",
"."
] | python | train |
aiidateam/aiida-nwchem | aiida_nwchem/tools/dbexporters/tcod_plugins/nwcpymatgen.py | https://github.com/aiidateam/aiida-nwchem/blob/21034e7f8ea8249948065c28030f4b572a6ecf05/aiida_nwchem/tools/dbexporters/tcod_plugins/nwcpymatgen.py#L46-L55 | def get_atom_type_symbol(cls,calc,**kwargs):
"""
Returns a list of atom types. Each atom site MUST occur only
once in this list. List MUST be sorted.
"""
parameters = calc.out.output
dictionary = parameters.get_dict()
if 'basis_set' not in dictionary.keys():
... | [
"def",
"get_atom_type_symbol",
"(",
"cls",
",",
"calc",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"calc",
".",
"out",
".",
"output",
"dictionary",
"=",
"parameters",
".",
"get_dict",
"(",
")",
"if",
"'basis_set'",
"not",
"in",
"dictionary",
"... | Returns a list of atom types. Each atom site MUST occur only
once in this list. List MUST be sorted. | [
"Returns",
"a",
"list",
"of",
"atom",
"types",
".",
"Each",
"atom",
"site",
"MUST",
"occur",
"only",
"once",
"in",
"this",
"list",
".",
"List",
"MUST",
"be",
"sorted",
"."
] | python | train |
pydata/xarray | xarray/core/indexing.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L716-L740 | def _combine_indexers(old_key, shape, new_key):
""" Combine two indexers.
Parameters
----------
old_key: ExplicitIndexer
The first indexer for the original array
shape: tuple of ints
Shape of the original array to be indexed by old_key
new_key:
The second indexer for ind... | [
"def",
"_combine_indexers",
"(",
"old_key",
",",
"shape",
",",
"new_key",
")",
":",
"if",
"not",
"isinstance",
"(",
"old_key",
",",
"VectorizedIndexer",
")",
":",
"old_key",
"=",
"_outer_to_vectorized_indexer",
"(",
"old_key",
",",
"shape",
")",
"if",
"len",
... | Combine two indexers.
Parameters
----------
old_key: ExplicitIndexer
The first indexer for the original array
shape: tuple of ints
Shape of the original array to be indexed by old_key
new_key:
The second indexer for indexing original[old_key] | [
"Combine",
"two",
"indexers",
"."
] | python | train |
saltstack/salt | salt/modules/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/state.py#L411-L422 | def _check_queue(queue, kwargs):
'''
Utility function to queue the state run if requested
and to check for conflicts in currently running states
'''
if queue:
_wait(kwargs.get('__pub_jid'))
else:
conflict = running(concurrent=kwargs.get('concurrent', False))
if conflict:
... | [
"def",
"_check_queue",
"(",
"queue",
",",
"kwargs",
")",
":",
"if",
"queue",
":",
"_wait",
"(",
"kwargs",
".",
"get",
"(",
"'__pub_jid'",
")",
")",
"else",
":",
"conflict",
"=",
"running",
"(",
"concurrent",
"=",
"kwargs",
".",
"get",
"(",
"'concurrent... | Utility function to queue the state run if requested
and to check for conflicts in currently running states | [
"Utility",
"function",
"to",
"queue",
"the",
"state",
"run",
"if",
"requested",
"and",
"to",
"check",
"for",
"conflicts",
"in",
"currently",
"running",
"states"
] | python | train |
pickleshare/pickleshare | pickleshare.py | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L137-L154 | def hget(self, hashroot, key, default = _sentinel, fast_only = True):
""" hashed get """
hroot = self.root / hashroot
hfile = hroot / gethashfile(key)
d = self.get(hfile, _sentinel )
#print "got dict",d,"from",hfile
if d is _sentinel:
if fast_only:
... | [
"def",
"hget",
"(",
"self",
",",
"hashroot",
",",
"key",
",",
"default",
"=",
"_sentinel",
",",
"fast_only",
"=",
"True",
")",
":",
"hroot",
"=",
"self",
".",
"root",
"/",
"hashroot",
"hfile",
"=",
"hroot",
"/",
"gethashfile",
"(",
"key",
")",
"d",
... | hashed get | [
"hashed",
"get"
] | python | train |
arne-cl/discoursegraphs | src/discoursegraphs/discoursegraph.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/discoursegraph.py#L1257-L1295 | def select_edges_by(docgraph, layer=None, edge_type=None, data=False):
"""
get all edges with the given edge type and layer.
Parameters
----------
docgraph : DiscourseDocumentGraph
document graph from which the nodes will be extracted
layer : str
name of the layer
edge_type ... | [
"def",
"select_edges_by",
"(",
"docgraph",
",",
"layer",
"=",
"None",
",",
"edge_type",
"=",
"None",
",",
"data",
"=",
"False",
")",
":",
"edge_type_eval",
"=",
"\"edge_attribs['edge_type'] == '{}'\"",
".",
"format",
"(",
"edge_type",
")",
"layer_eval",
"=",
"... | get all edges with the given edge type and layer.
Parameters
----------
docgraph : DiscourseDocumentGraph
document graph from which the nodes will be extracted
layer : str
name of the layer
edge_type : str
Type of the edges to be extracted (Edge types are defined in the
... | [
"get",
"all",
"edges",
"with",
"the",
"given",
"edge",
"type",
"and",
"layer",
"."
] | python | train |
vtkiorg/vtki | vtki/common.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L403-L413 | def rotate_z(self, angle):
"""
Rotates mesh about the z-axis.
Parameters
----------
angle : float
Angle in degrees to rotate about the z-axis.
"""
axis_rotation(self.points, angle, inplace=True, axis='z') | [
"def",
"rotate_z",
"(",
"self",
",",
"angle",
")",
":",
"axis_rotation",
"(",
"self",
".",
"points",
",",
"angle",
",",
"inplace",
"=",
"True",
",",
"axis",
"=",
"'z'",
")"
] | Rotates mesh about the z-axis.
Parameters
----------
angle : float
Angle in degrees to rotate about the z-axis. | [
"Rotates",
"mesh",
"about",
"the",
"z",
"-",
"axis",
"."
] | python | train |
spyder-ide/spyder | spyder/widgets/mixins.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L375-L392 | def get_position(self, subject):
"""Get offset in character for the given subject from the start of
text edit area"""
cursor = self.textCursor()
if subject == 'cursor':
pass
elif subject == 'sol':
cursor.movePosition(QTextCursor.StartOfBlock)
... | [
"def",
"get_position",
"(",
"self",
",",
"subject",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"if",
"subject",
"==",
"'cursor'",
":",
"pass",
"elif",
"subject",
"==",
"'sol'",
":",
"cursor",
".",
"movePosition",
"(",
"QTextCursor",
".... | Get offset in character for the given subject from the start of
text edit area | [
"Get",
"offset",
"in",
"character",
"for",
"the",
"given",
"subject",
"from",
"the",
"start",
"of",
"text",
"edit",
"area"
] | python | train |
Pytwitcher/pytwitcherapi | src/pytwitcherapi/models.py | https://github.com/Pytwitcher/pytwitcherapi/blob/d53ac5ad5ca113ecb7da542e8cdcbbf8c762b336/src/pytwitcherapi/models.py#L375-L390 | def wrap_json(cls, json):
"""Create a User instance for the given json
:param json: the dict with the information of the user
:type json: :class:`dict` | None
:returns: the new user instance
:rtype: :class:`User`
:raises: None
"""
u = User(usertype=json['... | [
"def",
"wrap_json",
"(",
"cls",
",",
"json",
")",
":",
"u",
"=",
"User",
"(",
"usertype",
"=",
"json",
"[",
"'type'",
"]",
",",
"name",
"=",
"json",
"[",
"'name'",
"]",
",",
"logo",
"=",
"json",
"[",
"'logo'",
"]",
",",
"twitchid",
"=",
"json",
... | Create a User instance for the given json
:param json: the dict with the information of the user
:type json: :class:`dict` | None
:returns: the new user instance
:rtype: :class:`User`
:raises: None | [
"Create",
"a",
"User",
"instance",
"for",
"the",
"given",
"json"
] | python | train |
boriel/zxbasic | zxbparser.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L2226-L2229 | def p_expr_mod_expr(p):
""" expr : expr MOD expr
"""
p[0] = make_binary(p.lineno(2), 'MOD', p[1], p[3], lambda x, y: x % y) | [
"def",
"p_expr_mod_expr",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"make_binary",
"(",
"p",
".",
"lineno",
"(",
"2",
")",
",",
"'MOD'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
",",
"lambda",
"x",
",",
"y",
":",
"x",
"%",
"y"... | expr : expr MOD expr | [
"expr",
":",
"expr",
"MOD",
"expr"
] | python | train |
CitrineInformatics/python-citrination-client | citrination_client/models/client.py | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/models/client.py#L117-L126 | def _data_analysis(self, data_view_id):
"""
Data analysis endpoint.
:param data_view_id: The model identifier (id number for data views)
:type data_view_id: str
:return: dictionary containing information about the data, e.g. dCorr and tsne
"""
failure_message = "... | [
"def",
"_data_analysis",
"(",
"self",
",",
"data_view_id",
")",
":",
"failure_message",
"=",
"\"Error while retrieving data analysis for data view {}\"",
".",
"format",
"(",
"data_view_id",
")",
"return",
"self",
".",
"_get_success_json",
"(",
"self",
".",
"_get",
"("... | Data analysis endpoint.
:param data_view_id: The model identifier (id number for data views)
:type data_view_id: str
:return: dictionary containing information about the data, e.g. dCorr and tsne | [
"Data",
"analysis",
"endpoint",
"."
] | python | valid |
swimlane/swimlane-python | swimlane/core/fields/base/field.py | https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/fields/base/field.py#L57-L68 | def get_report(self, value):
"""Return provided field Python value formatted for use in report filter"""
if self.multiselect:
value = value or []
children = []
for child in value:
children.append(self.cast_to_report(child))
return childre... | [
"def",
"get_report",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"multiselect",
":",
"value",
"=",
"value",
"or",
"[",
"]",
"children",
"=",
"[",
"]",
"for",
"child",
"in",
"value",
":",
"children",
".",
"append",
"(",
"self",
".",
"cas... | Return provided field Python value formatted for use in report filter | [
"Return",
"provided",
"field",
"Python",
"value",
"formatted",
"for",
"use",
"in",
"report",
"filter"
] | python | train |
pywbem/pywbem | pywbem/mof_compiler.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/mof_compiler.py#L1128-L1136 | def p_parameter_3(p):
"""parameter_3 : objectRef parameterName
| objectRef parameterName array
"""
args = {}
if len(p) == 4:
args['is_array'] = True
args['array_size'] = p[3]
p[0] = CIMParameter(p[2], 'reference', reference_class=p[1], **args) | [
"def",
"p_parameter_3",
"(",
"p",
")",
":",
"args",
"=",
"{",
"}",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"args",
"[",
"'is_array'",
"]",
"=",
"True",
"args",
"[",
"'array_size'",
"]",
"=",
"p",
"[",
"3",
"]",
"p",
"[",
"0",
"]",
"=",
... | parameter_3 : objectRef parameterName
| objectRef parameterName array | [
"parameter_3",
":",
"objectRef",
"parameterName",
"|",
"objectRef",
"parameterName",
"array"
] | python | train |
tkf/rash | rash/record.py | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/record.py#L86-L99 | def generate_session_id(data):
"""
Generate session ID based on HOST, TTY, PID [#]_ and start time.
:type data: dict
:rtype: str
.. [#] PID of the shell, i.e., PPID of this Python process.
"""
host = data['environ']['HOST']
tty = data['environ'].get('TTY') or 'NO_TTY'
return ':'.j... | [
"def",
"generate_session_id",
"(",
"data",
")",
":",
"host",
"=",
"data",
"[",
"'environ'",
"]",
"[",
"'HOST'",
"]",
"tty",
"=",
"data",
"[",
"'environ'",
"]",
".",
"get",
"(",
"'TTY'",
")",
"or",
"'NO_TTY'",
"return",
"':'",
".",
"join",
"(",
"map",... | Generate session ID based on HOST, TTY, PID [#]_ and start time.
:type data: dict
:rtype: str
.. [#] PID of the shell, i.e., PPID of this Python process. | [
"Generate",
"session",
"ID",
"based",
"on",
"HOST",
"TTY",
"PID",
"[",
"#",
"]",
"_",
"and",
"start",
"time",
"."
] | python | train |
gabfl/dbschema | src/schema_change.py | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L221-L242 | def get_migrations_applied(engine, connection):
""" Get list of migrations already applied """
try:
# Get cursor based on engine
if engine == 'postgresql':
cursor = connection.cursor(
cursor_factory=psycopg2.extras.RealDictCursor)
else:
cursor = c... | [
"def",
"get_migrations_applied",
"(",
"engine",
",",
"connection",
")",
":",
"try",
":",
"# Get cursor based on engine",
"if",
"engine",
"==",
"'postgresql'",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
"cursor_factory",
"=",
"psycopg2",
".",
"extras",
... | Get list of migrations already applied | [
"Get",
"list",
"of",
"migrations",
"already",
"applied"
] | python | train |
quantopian/zipline | zipline/utils/argcheck.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/argcheck.py#L131-L140 | def _expect_extra(expected, present, exc_unexpected, exc_missing, exc_args):
"""
Checks for the presence of an extra to the argument list. Raises expections
if this is unexpected or if it is missing and expected.
"""
if present:
if not expected:
raise exc_unexpected(*exc_args)
... | [
"def",
"_expect_extra",
"(",
"expected",
",",
"present",
",",
"exc_unexpected",
",",
"exc_missing",
",",
"exc_args",
")",
":",
"if",
"present",
":",
"if",
"not",
"expected",
":",
"raise",
"exc_unexpected",
"(",
"*",
"exc_args",
")",
"elif",
"expected",
"and"... | Checks for the presence of an extra to the argument list. Raises expections
if this is unexpected or if it is missing and expected. | [
"Checks",
"for",
"the",
"presence",
"of",
"an",
"extra",
"to",
"the",
"argument",
"list",
".",
"Raises",
"expections",
"if",
"this",
"is",
"unexpected",
"or",
"if",
"it",
"is",
"missing",
"and",
"expected",
"."
] | python | train |
sernst/cauldron | cauldron/runner/markdown_file.py | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/markdown_file.py#L6-L32 | def run(
project: 'projects.Project',
step: 'projects.ProjectStep'
) -> dict:
"""
Runs the markdown file and renders the contents to the notebook display
:param project:
:param step:
:return:
A run response dictionary containing
"""
with open(step.source_path, 'r') ... | [
"def",
"run",
"(",
"project",
":",
"'projects.Project'",
",",
"step",
":",
"'projects.ProjectStep'",
")",
"->",
"dict",
":",
"with",
"open",
"(",
"step",
".",
"source_path",
",",
"'r'",
")",
"as",
"f",
":",
"code",
"=",
"f",
".",
"read",
"(",
")",
"t... | Runs the markdown file and renders the contents to the notebook display
:param project:
:param step:
:return:
A run response dictionary containing | [
"Runs",
"the",
"markdown",
"file",
"and",
"renders",
"the",
"contents",
"to",
"the",
"notebook",
"display"
] | python | train |
SoftwareDefinedBuildings/XBOS | apps/Data_quality_analysis/Clean_Data.py | https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/Data_quality_analysis/Clean_Data.py#L907-L946 | def count_if(self, data, condition, val, output="number"):
""" Count the number of values that match the condition.
Parameters
----------
data : pd.DataFrame()
Input dataframe.
condition : str
Condition to match.
val : flo... | [
"def",
"count_if",
"(",
"self",
",",
"data",
",",
"condition",
",",
"val",
",",
"output",
"=",
"\"number\"",
")",
":",
"if",
"condition",
"==",
"\"=\"",
":",
"count",
"=",
"self",
".",
"_find_equal_to_values",
"(",
"data",
",",
"val",
")",
".",
"sum",
... | Count the number of values that match the condition.
Parameters
----------
data : pd.DataFrame()
Input dataframe.
condition : str
Condition to match.
val : float
Value to compare against.
output : str
... | [
"Count",
"the",
"number",
"of",
"values",
"that",
"match",
"the",
"condition",
".",
"Parameters",
"----------",
"data",
":",
"pd",
".",
"DataFrame",
"()",
"Input",
"dataframe",
".",
"condition",
":",
"str",
"Condition",
"to",
"match",
".",
"val",
":",
"flo... | python | train |
flowersteam/explauto | explauto/sensorimotor_model/inverse/cma.py | https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8411-L8423 | def fun_as_arg(self, x, *args):
"""``fun_as_arg(x, fun, *more_args)`` calls ``fun(x, *more_args)``.
Use case::
fmin(cma.fun_as_arg, args=(fun,), gradf=grad_numerical)
calls fun_as_args(x, args) and grad_numerical(x, fun, args=args)
"""
fun = args[0]
more_a... | [
"def",
"fun_as_arg",
"(",
"self",
",",
"x",
",",
"*",
"args",
")",
":",
"fun",
"=",
"args",
"[",
"0",
"]",
"more_args",
"=",
"args",
"[",
"1",
":",
"]",
"if",
"len",
"(",
"args",
")",
">",
"1",
"else",
"(",
")",
"return",
"fun",
"(",
"x",
"... | ``fun_as_arg(x, fun, *more_args)`` calls ``fun(x, *more_args)``.
Use case::
fmin(cma.fun_as_arg, args=(fun,), gradf=grad_numerical)
calls fun_as_args(x, args) and grad_numerical(x, fun, args=args) | [
"fun_as_arg",
"(",
"x",
"fun",
"*",
"more_args",
")",
"calls",
"fun",
"(",
"x",
"*",
"more_args",
")",
"."
] | python | train |
CalebBell/thermo | thermo/chemical.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/chemical.py#L1314-L1330 | def legal_status(self):
r'''Dictionary of legal status indicators for the chemical.
Examples
--------
>>> pprint(Chemical('benzene').legal_status)
{'DSL': 'LISTED',
'EINECS': 'LISTED',
'NLP': 'UNLISTED',
'SPIN': 'LISTED',
'TSCA': 'LISTED'}
... | [
"def",
"legal_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"__legal_status",
":",
"return",
"self",
".",
"__legal_status",
"else",
":",
"self",
".",
"__legal_status",
"=",
"legal_status",
"(",
"self",
".",
"CAS",
",",
"Method",
"=",
"'COMBINED'",
")"... | r'''Dictionary of legal status indicators for the chemical.
Examples
--------
>>> pprint(Chemical('benzene').legal_status)
{'DSL': 'LISTED',
'EINECS': 'LISTED',
'NLP': 'UNLISTED',
'SPIN': 'LISTED',
'TSCA': 'LISTED'} | [
"r",
"Dictionary",
"of",
"legal",
"status",
"indicators",
"for",
"the",
"chemical",
"."
] | python | valid |
senaite/senaite.core | bika/lims/api/__init__.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/api/__init__.py#L968-L981 | def get_group(group_or_groupname):
"""Return Plone Group
:param group_or_groupname: Plone group or the name of the group
:type groupname: GroupData/str
:returns: Plone GroupData
"""
if not group_or_groupname:
return None
if hasattr(group_or_groupname, "_getGroup"):
return ... | [
"def",
"get_group",
"(",
"group_or_groupname",
")",
":",
"if",
"not",
"group_or_groupname",
":",
"return",
"None",
"if",
"hasattr",
"(",
"group_or_groupname",
",",
"\"_getGroup\"",
")",
":",
"return",
"group_or_groupname",
"gtool",
"=",
"get_tool",
"(",
"\"portal_... | Return Plone Group
:param group_or_groupname: Plone group or the name of the group
:type groupname: GroupData/str
:returns: Plone GroupData | [
"Return",
"Plone",
"Group"
] | python | train |
cmcqueen/simplerandom | python/python2/simplerandom/random/_random_py.py | https://github.com/cmcqueen/simplerandom/blob/3f19ffdfeaa8256986adf7173f08c1c719164d01/python/python2/simplerandom/random/_random_py.py#L65-L68 | def setbpf(self, bpf):
"""Set number of bits per float output"""
self._bpf = min(bpf, self.BPF)
self._rng_n = int((self._bpf + self.RNG_RANGE_BITS - 1) / self.RNG_RANGE_BITS) | [
"def",
"setbpf",
"(",
"self",
",",
"bpf",
")",
":",
"self",
".",
"_bpf",
"=",
"min",
"(",
"bpf",
",",
"self",
".",
"BPF",
")",
"self",
".",
"_rng_n",
"=",
"int",
"(",
"(",
"self",
".",
"_bpf",
"+",
"self",
".",
"RNG_RANGE_BITS",
"-",
"1",
")",
... | Set number of bits per float output | [
"Set",
"number",
"of",
"bits",
"per",
"float",
"output"
] | python | train |
StanfordBioinformatics/loom | client/loomengine/playbooks/gce.py | https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L198-L254 | def get_config(self):
"""
Reads the settings from the gce.ini file.
Populates a SafeConfigParser object with defaults and
attempts to read an .ini-style configuration from the filename
specified in GCE_INI_PATH. If the environment variable is
not present, the filename de... | [
"def",
"get_config",
"(",
"self",
")",
":",
"gce_ini_default_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
",",
"\"gce.ini\"",
")",
"gce_ini_path"... | Reads the settings from the gce.ini file.
Populates a SafeConfigParser object with defaults and
attempts to read an .ini-style configuration from the filename
specified in GCE_INI_PATH. If the environment variable is
not present, the filename defaults to gce.ini in the current
w... | [
"Reads",
"the",
"settings",
"from",
"the",
"gce",
".",
"ini",
"file",
"."
] | python | train |
pypa/pipenv | pipenv/patched/notpip/_internal/req/req_install.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_install.py#L255-L275 | def hashes(self, trust_internet=True):
# type: (bool) -> Hashes
"""Return a hash-comparer that considers my option- and URL-based
hashes to be known-good.
Hashes in URLs--ones embedded in the requirements file, not ones
downloaded from an index server--are almost peers with ones... | [
"def",
"hashes",
"(",
"self",
",",
"trust_internet",
"=",
"True",
")",
":",
"# type: (bool) -> Hashes",
"good_hashes",
"=",
"self",
".",
"options",
".",
"get",
"(",
"'hashes'",
",",
"{",
"}",
")",
".",
"copy",
"(",
")",
"link",
"=",
"self",
".",
"link"... | Return a hash-comparer that considers my option- and URL-based
hashes to be known-good.
Hashes in URLs--ones embedded in the requirements file, not ones
downloaded from an index server--are almost peers with ones from
flags. They satisfy --require-hashes (whether it was implicitly or
... | [
"Return",
"a",
"hash",
"-",
"comparer",
"that",
"considers",
"my",
"option",
"-",
"and",
"URL",
"-",
"based",
"hashes",
"to",
"be",
"known",
"-",
"good",
"."
] | python | train |
yyuu/botornado | boto/s3/bucket.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/s3/bucket.py#L1155-L1186 | def configure_website(self, suffix, error_key='', headers=None):
"""
Configure this bucket to act as a website
:type suffix: str
:param suffix: Suffix that is appended to a request that is for a
"directory" on the website endpoint (e.g. if the suffix
... | [
"def",
"configure_website",
"(",
"self",
",",
"suffix",
",",
"error_key",
"=",
"''",
",",
"headers",
"=",
"None",
")",
":",
"if",
"error_key",
":",
"error_frag",
"=",
"self",
".",
"WebsiteErrorFragment",
"%",
"error_key",
"else",
":",
"error_frag",
"=",
"'... | Configure this bucket to act as a website
:type suffix: str
:param suffix: Suffix that is appended to a request that is for a
"directory" on the website endpoint (e.g. if the suffix
is index.html and you make a request to
samplebucket... | [
"Configure",
"this",
"bucket",
"to",
"act",
"as",
"a",
"website"
] | python | train |
fredRos/pypmc | pypmc/sampler/markov_chain.py | https://github.com/fredRos/pypmc/blob/9138b67c976f0d58edd080353d16769a47794d09/pypmc/sampler/markov_chain.py#L98-L163 | def run(self, N=1):
'''Run the chain and store the history of visited points into
the member variable ``self.samples``. Returns the number of
accepted points during the run.
.. seealso::
:py:class:`pypmc.tools.History`
:param N:
An int which defines the... | [
"def",
"run",
"(",
"self",
",",
"N",
"=",
"1",
")",
":",
"if",
"N",
"==",
"0",
":",
"return",
"0",
"# set the accept function",
"if",
"self",
".",
"proposal",
".",
"symmetric",
":",
"get_log_rho",
"=",
"self",
".",
"_get_log_rho_metropolis",
"else",
":",... | Run the chain and store the history of visited points into
the member variable ``self.samples``. Returns the number of
accepted points during the run.
.. seealso::
:py:class:`pypmc.tools.History`
:param N:
An int which defines the number of steps to run the cha... | [
"Run",
"the",
"chain",
"and",
"store",
"the",
"history",
"of",
"visited",
"points",
"into",
"the",
"member",
"variable",
"self",
".",
"samples",
".",
"Returns",
"the",
"number",
"of",
"accepted",
"points",
"during",
"the",
"run",
"."
] | python | train |
jxtech/wechatpy | wechatpy/client/api/shakearound.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/shakearound.py#L234-L254 | def add_material(self, media_file, media_type='icon'):
"""
上传图片素材
详情请参考
http://mp.weixin.qq.com/wiki/5/e997428269ff189d8f9a4b9e177be2d9.html
:param media_file: 要上传的文件,一个 File-object
:param media_type: 摇一摇素材类型, 取值为 icon或者 license, 默认 icon.
:return: 上传的素材信息
... | [
"def",
"add_material",
"(",
"self",
",",
"media_file",
",",
"media_type",
"=",
"'icon'",
")",
":",
"res",
"=",
"self",
".",
"_post",
"(",
"'shakearound/material/add'",
",",
"files",
"=",
"{",
"'media'",
":",
"media_file",
"}",
",",
"params",
"=",
"{",
"'... | 上传图片素材
详情请参考
http://mp.weixin.qq.com/wiki/5/e997428269ff189d8f9a4b9e177be2d9.html
:param media_file: 要上传的文件,一个 File-object
:param media_type: 摇一摇素材类型, 取值为 icon或者 license, 默认 icon.
:return: 上传的素材信息 | [
"上传图片素材",
"详情请参考",
"http",
":",
"//",
"mp",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"wiki",
"/",
"5",
"/",
"e997428269ff189d8f9a4b9e177be2d9",
".",
"html"
] | python | train |
neherlab/treetime | treetime/treeanc.py | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1324-L1461 | def _ml_anc_marginal(self, store_compressed=False, final=True, sample_from_profile=False,
debug=False, **kwargs):
"""
Perform marginal ML reconstruction of the ancestral states. In contrast to
joint reconstructions, this needs to access the probabilities rather than only... | [
"def",
"_ml_anc_marginal",
"(",
"self",
",",
"store_compressed",
"=",
"False",
",",
"final",
"=",
"True",
",",
"sample_from_profile",
"=",
"False",
",",
"debug",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"tree",
"=",
"self",
".",
"tree",
"# number... | Perform marginal ML reconstruction of the ancestral states. In contrast to
joint reconstructions, this needs to access the probabilities rather than only
log probabilities and is hence handled by a separate function.
Parameters
----------
store_compressed : bool, default True
... | [
"Perform",
"marginal",
"ML",
"reconstruction",
"of",
"the",
"ancestral",
"states",
".",
"In",
"contrast",
"to",
"joint",
"reconstructions",
"this",
"needs",
"to",
"access",
"the",
"probabilities",
"rather",
"than",
"only",
"log",
"probabilities",
"and",
"is",
"h... | python | test |
rbit/pydtls | dtls/sslconnection.py | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L206-L217 | def set_curves(self, curves):
u''' Set supported curves by name, nid or nist.
:param str | tuple(int) curves: Example "secp384r1:secp256k1", (715, 714), "P-384", "K-409:B-409:K-571", ...
:return: 1 for success and 0 for failure
'''
retVal = None
if isinstance(curves, str... | [
"def",
"set_curves",
"(",
"self",
",",
"curves",
")",
":",
"retVal",
"=",
"None",
"if",
"isinstance",
"(",
"curves",
",",
"str",
")",
":",
"retVal",
"=",
"SSL_CTX_set1_curves_list",
"(",
"self",
".",
"_ctx",
",",
"curves",
")",
"elif",
"isinstance",
"(",... | u''' Set supported curves by name, nid or nist.
:param str | tuple(int) curves: Example "secp384r1:secp256k1", (715, 714), "P-384", "K-409:B-409:K-571", ...
:return: 1 for success and 0 for failure | [
"u",
"Set",
"supported",
"curves",
"by",
"name",
"nid",
"or",
"nist",
"."
] | python | train |
SoCo/SoCo | dev_tools/analyse_ws.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/dev_tools/analyse_ws.py#L86-L125 | def set_file(self, filename):
""" Analyse the file with the captured content """
# Use the file name as prefix if none is given
if self.output_prefix is None:
_, self.output_prefix = os.path.split(filename)
# Check if the file is present, since rdpcap will not do that
... | [
"def",
"set_file",
"(",
"self",
",",
"filename",
")",
":",
"# Use the file name as prefix if none is given",
"if",
"self",
".",
"output_prefix",
"is",
"None",
":",
"_",
",",
"self",
".",
"output_prefix",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filename",
... | Analyse the file with the captured content | [
"Analyse",
"the",
"file",
"with",
"the",
"captured",
"content"
] | python | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1054-L1077 | def subset(self, used_indices, params=None):
"""Get subset of current Dataset.
Parameters
----------
used_indices : list of int
Indices used to create the subset.
params : dict or None, optional (default=None)
These parameters will be passed to Dataset co... | [
"def",
"subset",
"(",
"self",
",",
"used_indices",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"self",
".",
"params",
"ret",
"=",
"Dataset",
"(",
"None",
",",
"reference",
"=",
"self",
",",
"feature_name",
... | Get subset of current Dataset.
Parameters
----------
used_indices : list of int
Indices used to create the subset.
params : dict or None, optional (default=None)
These parameters will be passed to Dataset constructor.
Returns
-------
subs... | [
"Get",
"subset",
"of",
"current",
"Dataset",
"."
] | python | train |
StackStorm/pybind | pybind/slxos/v17r_1_01a/ipv6_acl/ipv6/access_list/extended/seq/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/ipv6_acl/ipv6/access_list/extended/seq/__init__.py#L206-L227 | def _set_protocol_type(self, v, load=False):
"""
Setter method for protocol_type, mapped from YANG variable /ipv6_acl/ipv6/access_list/extended/seq/protocol_type (union)
If this variable is read-only (config: false) in the
source YANG file, then _set_protocol_type is considered as a private
method. ... | [
"def",
"_set_protocol_type",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"... | Setter method for protocol_type, mapped from YANG variable /ipv6_acl/ipv6/access_list/extended/seq/protocol_type (union)
If this variable is read-only (config: false) in the
source YANG file, then _set_protocol_type is considered as a private
method. Backends looking to populate this variable should
do ... | [
"Setter",
"method",
"for",
"protocol_type",
"mapped",
"from",
"YANG",
"variable",
"/",
"ipv6_acl",
"/",
"ipv6",
"/",
"access_list",
"/",
"extended",
"/",
"seq",
"/",
"protocol_type",
"(",
"union",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"... | python | train |
dereneaton/ipyrad | ipyrad/analysis/tetrad.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/tetrad.py#L707-L740 | def _dump_qmc(self):
"""
Makes a reduced array that excludes quartets with no information and
prints the quartets and weights to a file formatted for wQMC
"""
## open the h5 database
io5 = h5py.File(self.database.output, 'r')
## create an output file for writi... | [
"def",
"_dump_qmc",
"(",
"self",
")",
":",
"## open the h5 database",
"io5",
"=",
"h5py",
".",
"File",
"(",
"self",
".",
"database",
".",
"output",
",",
"'r'",
")",
"## create an output file for writing",
"self",
".",
"files",
".",
"qdump",
"=",
"os",
".",
... | Makes a reduced array that excludes quartets with no information and
prints the quartets and weights to a file formatted for wQMC | [
"Makes",
"a",
"reduced",
"array",
"that",
"excludes",
"quartets",
"with",
"no",
"information",
"and",
"prints",
"the",
"quartets",
"and",
"weights",
"to",
"a",
"file",
"formatted",
"for",
"wQMC"
] | python | valid |
abilian/abilian-core | abilian/services/security/service.py | https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L210-L247 | def get_roles(self, principal, object=None, no_group_roles=False):
"""Get all the roles attached to given `principal`, on a given
`object`.
:param principal: a :class:`User` or :class:`Group`
:param object: an :class:`Entity`
:param no_group_roles: If `True`, return only direc... | [
"def",
"get_roles",
"(",
"self",
",",
"principal",
",",
"object",
"=",
"None",
",",
"no_group_roles",
"=",
"False",
")",
":",
"assert",
"principal",
"if",
"hasattr",
"(",
"principal",
",",
"\"is_anonymous\"",
")",
"and",
"principal",
".",
"is_anonymous",
":"... | Get all the roles attached to given `principal`, on a given
`object`.
:param principal: a :class:`User` or :class:`Group`
:param object: an :class:`Entity`
:param no_group_roles: If `True`, return only direct roles, not roles
acquired through group membership. | [
"Get",
"all",
"the",
"roles",
"attached",
"to",
"given",
"principal",
"on",
"a",
"given",
"object",
"."
] | python | train |
ellmetha/django-machina | machina/apps/forum_conversation/forum_attachments/cache.py | https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/forum_attachments/cache.py#L82-L120 | def get(self, key):
""" Regenerates a MultiValueDict instance containing the files related to all file states
stored for the given key.
"""
upload = None
files_states = self.backend.get(key)
files = MultiValueDict()
if files_states:
for name, state... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"upload",
"=",
"None",
"files_states",
"=",
"self",
".",
"backend",
".",
"get",
"(",
"key",
")",
"files",
"=",
"MultiValueDict",
"(",
")",
"if",
"files_states",
":",
"for",
"name",
",",
"state",
"in",
... | Regenerates a MultiValueDict instance containing the files related to all file states
stored for the given key. | [
"Regenerates",
"a",
"MultiValueDict",
"instance",
"containing",
"the",
"files",
"related",
"to",
"all",
"file",
"states",
"stored",
"for",
"the",
"given",
"key",
"."
] | python | train |
markovmodel/msmtools | msmtools/flux/api.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/flux/api.py#L233-L267 | def to_netflux(flux):
r"""Compute the netflux from the gross flux.
Parameters
----------
flux : (M, M) ndarray
Matrix of flux values between pairs of states.
Returns
-------
netflux : (M, M) ndarray
Matrix of netflux values between pairs of states.
Notes
-----
... | [
"def",
"to_netflux",
"(",
"flux",
")",
":",
"if",
"issparse",
"(",
"flux",
")",
":",
"return",
"sparse",
".",
"tpt",
".",
"to_netflux",
"(",
"flux",
")",
"elif",
"isdense",
"(",
"flux",
")",
":",
"return",
"dense",
".",
"tpt",
".",
"to_netflux",
"(",... | r"""Compute the netflux from the gross flux.
Parameters
----------
flux : (M, M) ndarray
Matrix of flux values between pairs of states.
Returns
-------
netflux : (M, M) ndarray
Matrix of netflux values between pairs of states.
Notes
-----
The netflux or effective c... | [
"r",
"Compute",
"the",
"netflux",
"from",
"the",
"gross",
"flux",
"."
] | python | train |
tensorflow/hub | examples/image_retraining/retrain.py | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L270-L291 | def get_bottleneck_path(image_lists, label_name, index, bottleneck_dir,
category, module_name):
"""Returns a path to a bottleneck file for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image f... | [
"def",
"get_bottleneck_path",
"(",
"image_lists",
",",
"label_name",
",",
"index",
",",
"bottleneck_dir",
",",
"category",
",",
"module_name",
")",
":",
"module_name",
"=",
"(",
"module_name",
".",
"replace",
"(",
"'://'",
",",
"'~'",
")",
"# URL scheme.",
"."... | Returns a path to a bottleneck file for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image for.
index: Integer offset of the image we want. This will be moduloed by the
available number of images for the label... | [
"Returns",
"a",
"path",
"to",
"a",
"bottleneck",
"file",
"for",
"a",
"label",
"at",
"the",
"given",
"index",
"."
] | python | train |
bmcfee/muda | muda/deformers/util.py | https://github.com/bmcfee/muda/blob/ff82efdfaeb98da0a9f9124845826eb20536a9ba/muda/deformers/util.py#L40-L59 | def transform(self, jam):
'''Bypass transformations.
Parameters
----------
jam : pyjams.JAMS
A muda-enabled JAMS object
Yields
------
jam_out : pyjams.JAMS iterator
The first result is `jam` (unmodified), by reference
All subs... | [
"def",
"transform",
"(",
"self",
",",
"jam",
")",
":",
"# Step 1: yield the unmodified jam",
"yield",
"jam",
"# Step 2: yield from the transformer",
"for",
"jam_out",
"in",
"self",
".",
"transformer",
".",
"transform",
"(",
"jam",
")",
":",
"yield",
"jam_out"
] | Bypass transformations.
Parameters
----------
jam : pyjams.JAMS
A muda-enabled JAMS object
Yields
------
jam_out : pyjams.JAMS iterator
The first result is `jam` (unmodified), by reference
All subsequent results are generated by `tran... | [
"Bypass",
"transformations",
"."
] | python | valid |
bokeh/bokeh | bokeh/models/sources.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/models/sources.py#L519-L674 | def patch(self, patches, setter=None):
''' Efficiently update data source columns at specific locations
If it is only necessary to update a small subset of data in a
``ColumnDataSource``, this method can be used to efficiently update only
the subset, instead of requiring the entire data... | [
"def",
"patch",
"(",
"self",
",",
"patches",
",",
"setter",
"=",
"None",
")",
":",
"import",
"numpy",
"as",
"np",
"extra",
"=",
"set",
"(",
"patches",
".",
"keys",
"(",
")",
")",
"-",
"set",
"(",
"self",
".",
"data",
".",
"keys",
"(",
")",
")",... | Efficiently update data source columns at specific locations
If it is only necessary to update a small subset of data in a
``ColumnDataSource``, this method can be used to efficiently update only
the subset, instead of requiring the entire data set to be sent.
This method should be pas... | [
"Efficiently",
"update",
"data",
"source",
"columns",
"at",
"specific",
"locations"
] | python | train |
lablup/backend.ai-client-py | src/ai/backend/client/resource_policy.py | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/resource_policy.py#L23-L66 | async def create(cls, name: str,
default_for_unspecified: int,
total_resource_slots: int,
max_concurrent_sessions: int,
max_containers_per_session: int,
max_vfolder_count: int,
max_vfolder_size:... | [
"async",
"def",
"create",
"(",
"cls",
",",
"name",
":",
"str",
",",
"default_for_unspecified",
":",
"int",
",",
"total_resource_slots",
":",
"int",
",",
"max_concurrent_sessions",
":",
"int",
",",
"max_containers_per_session",
":",
"int",
",",
"max_vfolder_count",... | Creates a new keypair resource policy with the given options.
You need an admin privilege for this operation. | [
"Creates",
"a",
"new",
"keypair",
"resource",
"policy",
"with",
"the",
"given",
"options",
".",
"You",
"need",
"an",
"admin",
"privilege",
"for",
"this",
"operation",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/visualization/text.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L483-L549 | def lines(self, line_length=None):
"""
Generates a list with lines. These lines form the text drawing.
Args:
line_length (int): Optional. Breaks the circuit drawing to this length. This
useful when the drawing does not fit in the console. If
... | [
"def",
"lines",
"(",
"self",
",",
"line_length",
"=",
"None",
")",
":",
"if",
"line_length",
"is",
"None",
":",
"line_length",
"=",
"self",
".",
"line_length",
"if",
"line_length",
"is",
"None",
":",
"if",
"(",
"'ipykernel'",
"in",
"sys",
".",
"modules",... | Generates a list with lines. These lines form the text drawing.
Args:
line_length (int): Optional. Breaks the circuit drawing to this length. This
useful when the drawing does not fit in the console. If
None (default), it will try to gues... | [
"Generates",
"a",
"list",
"with",
"lines",
".",
"These",
"lines",
"form",
"the",
"text",
"drawing",
".",
"Args",
":",
"line_length",
"(",
"int",
")",
":",
"Optional",
".",
"Breaks",
"the",
"circuit",
"drawing",
"to",
"this",
"length",
".",
"This",
"usefu... | python | test |
simpleai-team/simpleai | samples/search/missioners.py | https://github.com/simpleai-team/simpleai/blob/2836befa7e970013f62e0ee75562652aacac6f65/samples/search/missioners.py#L27-L34 | def _is_valid(self, s):
'''Check if a state is valid.'''
# valid states: no more cannibals than missioners on each side,
# and numbers between 0 and 3
return ((s[0] >= s[1] or s[0] == 0)) and \
((3 - s[0]) >= (3 - s[1]) or s[0] == 3) and \
(0 <= s[0] <= 3)... | [
"def",
"_is_valid",
"(",
"self",
",",
"s",
")",
":",
"# valid states: no more cannibals than missioners on each side,",
"# and numbers between 0 and 3",
"return",
"(",
"(",
"s",
"[",
"0",
"]",
">=",
"s",
"[",
"1",
"]",
"or",
"s",
"[",
"0",
"]",
"==",
"0",
")... | Check if a state is valid. | [
"Check",
"if",
"a",
"state",
"is",
"valid",
"."
] | python | train |
rosenbrockc/fortpy | fortpy/isense/builtin.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/isense/builtin.py#L11-L33 | def load(parser, serializer):
"""Returns a dictionary of builtin functions for Fortran. Checks the
cache first to see if we have a serialized version. If we don't, it
loads it from the XML file.
:arg parser: the DocParser instance for parsing the XML tags.
:arg serializer: a Serializer instance fro... | [
"def",
"load",
"(",
"parser",
",",
"serializer",
")",
":",
"fortdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"fortpy",
".",
"__file__",
")",
"xmlpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"fortdir",
",",
"\"isense\"",
",",
"\"builtin.xml\""... | Returns a dictionary of builtin functions for Fortran. Checks the
cache first to see if we have a serialized version. If we don't, it
loads it from the XML file.
:arg parser: the DocParser instance for parsing the XML tags.
:arg serializer: a Serializer instance from the CodeParser to cache
the l... | [
"Returns",
"a",
"dictionary",
"of",
"builtin",
"functions",
"for",
"Fortran",
".",
"Checks",
"the",
"cache",
"first",
"to",
"see",
"if",
"we",
"have",
"a",
"serialized",
"version",
".",
"If",
"we",
"don",
"t",
"it",
"loads",
"it",
"from",
"the",
"XML",
... | python | train |
ktbyers/netmiko | netmiko/citrix/netscaler_ssh.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/citrix/netscaler_ssh.py#L53-L60 | def strip_prompt(self, a_string):
""" Strip 'Done' from command output """
output = super(NetscalerSSH, self).strip_prompt(a_string)
lines = output.split(self.RESPONSE_RETURN)
if "Done" in lines[-1]:
return self.RESPONSE_RETURN.join(lines[:-1])
else:
retur... | [
"def",
"strip_prompt",
"(",
"self",
",",
"a_string",
")",
":",
"output",
"=",
"super",
"(",
"NetscalerSSH",
",",
"self",
")",
".",
"strip_prompt",
"(",
"a_string",
")",
"lines",
"=",
"output",
".",
"split",
"(",
"self",
".",
"RESPONSE_RETURN",
")",
"if",... | Strip 'Done' from command output | [
"Strip",
"Done",
"from",
"command",
"output"
] | python | train |
mfcloud/python-zvm-sdk | zvmsdk/database.py | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/database.py#L670-L683 | def get_comments_by_userid(self, userid):
""" Get comments record.
output should be like: {'k1': 'v1', 'k2': 'v2'}'
"""
userid = userid
with get_guest_conn() as conn:
res = conn.execute("SELECT comments FROM guests "
"WHERE userid=?", (u... | [
"def",
"get_comments_by_userid",
"(",
"self",
",",
"userid",
")",
":",
"userid",
"=",
"userid",
"with",
"get_guest_conn",
"(",
")",
"as",
"conn",
":",
"res",
"=",
"conn",
".",
"execute",
"(",
"\"SELECT comments FROM guests \"",
"\"WHERE userid=?\"",
",",
"(",
... | Get comments record.
output should be like: {'k1': 'v1', 'k2': 'v2'}' | [
"Get",
"comments",
"record",
".",
"output",
"should",
"be",
"like",
":",
"{",
"k1",
":",
"v1",
"k2",
":",
"v2",
"}"
] | python | train |
cloudmesh/cloudmesh-common | cloudmesh/common/StopWatch.py | https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/StopWatch.py#L57-L70 | def get(cls, name):
"""
returns the time of the timer.
:param name: the name of the timer
:type name: string
:rtype: the elapsed time
"""
if name in cls.timer_end:
cls.timer_elapsed[name] = cls.timer_end[name] - \
... | [
"def",
"get",
"(",
"cls",
",",
"name",
")",
":",
"if",
"name",
"in",
"cls",
".",
"timer_end",
":",
"cls",
".",
"timer_elapsed",
"[",
"name",
"]",
"=",
"cls",
".",
"timer_end",
"[",
"name",
"]",
"-",
"cls",
".",
"timer_start",
"[",
"name",
"]",
"r... | returns the time of the timer.
:param name: the name of the timer
:type name: string
:rtype: the elapsed time | [
"returns",
"the",
"time",
"of",
"the",
"timer",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.