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 |
|---|---|---|---|---|---|---|---|---|
python-cmd2/cmd2 | examples/scripts/save_help_text.py | https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/examples/scripts/save_help_text.py#L39-L55 | def add_help_to_file(item: str, outfile: TextIO, is_command: bool) -> None:
"""
Write help text for commands and topics to the output file
:param item: what is having its help text saved
:param outfile: file being written to
:param is_command: tells if the item is a command and not just a help topic... | [
"def",
"add_help_to_file",
"(",
"item",
":",
"str",
",",
"outfile",
":",
"TextIO",
",",
"is_command",
":",
"bool",
")",
"->",
"None",
":",
"if",
"is_command",
":",
"label",
"=",
"\"COMMAND\"",
"else",
":",
"label",
"=",
"\"TOPIC\"",
"header",
"=",
"'{}\\... | Write help text for commands and topics to the output file
:param item: what is having its help text saved
:param outfile: file being written to
:param is_command: tells if the item is a command and not just a help topic | [
"Write",
"help",
"text",
"for",
"commands",
"and",
"topics",
"to",
"the",
"output",
"file",
":",
"param",
"item",
":",
"what",
"is",
"having",
"its",
"help",
"text",
"saved",
":",
"param",
"outfile",
":",
"file",
"being",
"written",
"to",
":",
"param",
... | python | train |
Parquery/sphinx-icontract | sphinx_icontract/__init__.py | https://github.com/Parquery/sphinx-icontract/blob/92918f23a8ea1873112e9b7446c64cd6f12ee04b/sphinx_icontract/__init__.py#L303-L343 | def _capture_as_text(capture: Callable[..., Any]) -> str:
"""Convert the capture function into its text representation by parsing the source code of the decorator."""
if not icontract._represent._is_lambda(a_function=capture):
signature = inspect.signature(capture)
param_names = list(signature.p... | [
"def",
"_capture_as_text",
"(",
"capture",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"str",
":",
"if",
"not",
"icontract",
".",
"_represent",
".",
"_is_lambda",
"(",
"a_function",
"=",
"capture",
")",
":",
"signature",
"=",
"inspect",
".",... | Convert the capture function into its text representation by parsing the source code of the decorator. | [
"Convert",
"the",
"capture",
"function",
"into",
"its",
"text",
"representation",
"by",
"parsing",
"the",
"source",
"code",
"of",
"the",
"decorator",
"."
] | python | train |
google/tangent | tangent/grad_util.py | https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/grad_util.py#L116-L172 | def autodiff_tree(func, wrt, motion, mode, preserve_result, check_dims,
verbose):
"""Perform AD on all functions in a call tree.
This function walks the call tree and differentiates each function in it. It
also ensures that the global namespaces that each function in the call tree
was in are ... | [
"def",
"autodiff_tree",
"(",
"func",
",",
"wrt",
",",
"motion",
",",
"mode",
",",
"preserve_result",
",",
"check_dims",
",",
"verbose",
")",
":",
"# Imported here to avoid circular imports",
"import",
"tangent",
"namespace",
"=",
"{",
"'tangent'",
":",
"tangent",
... | Perform AD on all functions in a call tree.
This function walks the call tree and differentiates each function in it. It
also ensures that the global namespaces that each function in the call tree
was in are merged.
The `tangent` and `numpy` packages are added to the namespace here, so that
the gradient tem... | [
"Perform",
"AD",
"on",
"all",
"functions",
"in",
"a",
"call",
"tree",
"."
] | python | train |
saltstack/salt | salt/states/pkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pkg.py#L840-L884 | def _verify_install(desired, new_pkgs, ignore_epoch=False, new_caps=None):
'''
Determine whether or not the installed packages match what was requested in
the SLS file.
'''
ok = []
failed = []
if not new_caps:
new_caps = dict()
for pkgname, pkgver in desired.items():
# Fr... | [
"def",
"_verify_install",
"(",
"desired",
",",
"new_pkgs",
",",
"ignore_epoch",
"=",
"False",
",",
"new_caps",
"=",
"None",
")",
":",
"ok",
"=",
"[",
"]",
"failed",
"=",
"[",
"]",
"if",
"not",
"new_caps",
":",
"new_caps",
"=",
"dict",
"(",
")",
"for"... | Determine whether or not the installed packages match what was requested in
the SLS file. | [
"Determine",
"whether",
"or",
"not",
"the",
"installed",
"packages",
"match",
"what",
"was",
"requested",
"in",
"the",
"SLS",
"file",
"."
] | python | train |
eqcorrscan/EQcorrscan | eqcorrscan/utils/archive_read.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/archive_read.py#L31-L140 | def read_data(archive, arc_type, day, stachans, length=86400):
"""
Function to read the appropriate data from an archive for a day.
:type archive: str
:param archive:
The archive source - if arc_type is seishub, this should be a url,
if the arc_type is FDSN then this can be either a url... | [
"def",
"read_data",
"(",
"archive",
",",
"arc_type",
",",
"day",
",",
"stachans",
",",
"length",
"=",
"86400",
")",
":",
"st",
"=",
"[",
"]",
"available_stations",
"=",
"_check_available_data",
"(",
"archive",
",",
"arc_type",
",",
"day",
")",
"for",
"st... | Function to read the appropriate data from an archive for a day.
:type archive: str
:param archive:
The archive source - if arc_type is seishub, this should be a url,
if the arc_type is FDSN then this can be either a url or a known obspy
client. If arc_type is day_vols, then this is th... | [
"Function",
"to",
"read",
"the",
"appropriate",
"data",
"from",
"an",
"archive",
"for",
"a",
"day",
"."
] | python | train |
CulturePlex/django-zotero | django_zotero/templatetags/zotero_inline_extras.py | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/templatetags/zotero_inline_extras.py#L10-L32 | def zotero_inline_tags(parser, token):
"""
Render an inline formset of tags.
Usage:
{% zotero_inline_tags formset[ option] %}
option = "all" | "media" | "formset"
"""
args = token.split_contents()
length = len(args)
if length == 2:
rendered_node = RenderedAl... | [
"def",
"zotero_inline_tags",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"length",
"=",
"len",
"(",
"args",
")",
"if",
"length",
"==",
"2",
":",
"rendered_node",
"=",
"RenderedAllNode",
"(",
"args",
"[",
... | Render an inline formset of tags.
Usage:
{% zotero_inline_tags formset[ option] %}
option = "all" | "media" | "formset" | [
"Render",
"an",
"inline",
"formset",
"of",
"tags",
".",
"Usage",
":",
"{",
"%",
"zotero_inline_tags",
"formset",
"[",
"option",
"]",
"%",
"}",
"option",
"=",
"all",
"|",
"media",
"|",
"formset"
] | python | train |
michael-lazar/rtv | rtv/packages/praw/__init__.py | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1146-L1162 | def get_subreddit_recommendations(self, subreddits, omit=None):
"""Return a list of recommended subreddits as Subreddit objects.
Subreddits with activity less than a certain threshold, will not have
any recommendations due to lack of data.
:param subreddits: A list of subreddits (eithe... | [
"def",
"get_subreddit_recommendations",
"(",
"self",
",",
"subreddits",
",",
"omit",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'omit'",
":",
"_to_reddit_list",
"(",
"omit",
"or",
"[",
"]",
")",
"}",
"url",
"=",
"self",
".",
"config",
"[",
"'sub_recomme... | Return a list of recommended subreddits as Subreddit objects.
Subreddits with activity less than a certain threshold, will not have
any recommendations due to lack of data.
:param subreddits: A list of subreddits (either names or Subreddit
objects) to base the recommendations on.
... | [
"Return",
"a",
"list",
"of",
"recommended",
"subreddits",
"as",
"Subreddit",
"objects",
"."
] | python | train |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L596-L603 | def _norm_perm_list_from_perm_dict(self, perm_dict):
"""Return a minimal, ordered, hashable list of subjects and permissions."""
high_perm_dict = self._highest_perm_dict_from_perm_dict(perm_dict)
return [
[k, list(sorted(high_perm_dict[k]))]
for k in ORDERED_PERM_LIST
... | [
"def",
"_norm_perm_list_from_perm_dict",
"(",
"self",
",",
"perm_dict",
")",
":",
"high_perm_dict",
"=",
"self",
".",
"_highest_perm_dict_from_perm_dict",
"(",
"perm_dict",
")",
"return",
"[",
"[",
"k",
",",
"list",
"(",
"sorted",
"(",
"high_perm_dict",
"[",
"k"... | Return a minimal, ordered, hashable list of subjects and permissions. | [
"Return",
"a",
"minimal",
"ordered",
"hashable",
"list",
"of",
"subjects",
"and",
"permissions",
"."
] | python | train |
cisco-sas/kitty | kitty/data/data_manager.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/data/data_manager.py#L75-L86 | def get_results(self):
'''
:return: result from running the task
'''
self._event.wait()
if self._exception is not None:
#
# Well... rethrownig the exception caught in execute
# but on the caller thread
#
raise self._exce... | [
"def",
"get_results",
"(",
"self",
")",
":",
"self",
".",
"_event",
".",
"wait",
"(",
")",
"if",
"self",
".",
"_exception",
"is",
"not",
"None",
":",
"#",
"# Well... rethrownig the exception caught in execute",
"# but on the caller thread",
"#",
"raise",
"self",
... | :return: result from running the task | [
":",
"return",
":",
"result",
"from",
"running",
"the",
"task"
] | python | train |
census-instrumentation/opencensus-python | contrib/opencensus-ext-prometheus/opencensus/ext/prometheus/stats_exporter/__init__.py | https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-prometheus/opencensus/ext/prometheus/stats_exporter/__init__.py#L121-L132 | def register_view(self, view):
""" register_view will create the needed structure
in order to be able to sent all data to Prometheus
"""
v_name = get_view_name(self.options.namespace, view)
if v_name not in self.registered_views:
desc = {'name': v_name,
... | [
"def",
"register_view",
"(",
"self",
",",
"view",
")",
":",
"v_name",
"=",
"get_view_name",
"(",
"self",
".",
"options",
".",
"namespace",
",",
"view",
")",
"if",
"v_name",
"not",
"in",
"self",
".",
"registered_views",
":",
"desc",
"=",
"{",
"'name'",
... | register_view will create the needed structure
in order to be able to sent all data to Prometheus | [
"register_view",
"will",
"create",
"the",
"needed",
"structure",
"in",
"order",
"to",
"be",
"able",
"to",
"sent",
"all",
"data",
"to",
"Prometheus"
] | python | train |
Clinical-Genomics/scout | scout/server/blueprints/variants/controllers.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/variants/controllers.py#L677-L697 | def transcript_str(transcript_obj, gene_name=None):
"""Generate amino acid change as a string."""
if transcript_obj.get('exon'):
gene_part, part_count_raw = 'exon', transcript_obj['exon']
elif transcript_obj.get('intron'):
gene_part, part_count_raw = 'intron', transcript_obj['intron']
el... | [
"def",
"transcript_str",
"(",
"transcript_obj",
",",
"gene_name",
"=",
"None",
")",
":",
"if",
"transcript_obj",
".",
"get",
"(",
"'exon'",
")",
":",
"gene_part",
",",
"part_count_raw",
"=",
"'exon'",
",",
"transcript_obj",
"[",
"'exon'",
"]",
"elif",
"trans... | Generate amino acid change as a string. | [
"Generate",
"amino",
"acid",
"change",
"as",
"a",
"string",
"."
] | python | test |
quodlibet/mutagen | mutagen/mp3/__init__.py | https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/mp3/__init__.py#L229-L244 | def skip_id3(fileobj):
"""Might raise IOError"""
# WMP writes multiple id3s, so skip as many as we find
while True:
idata = fileobj.read(10)
try:
id3, insize = struct.unpack('>3sxxx4s', idata)
except struct.error:
id3, insize = b'', 0
insize = BitPadd... | [
"def",
"skip_id3",
"(",
"fileobj",
")",
":",
"# WMP writes multiple id3s, so skip as many as we find",
"while",
"True",
":",
"idata",
"=",
"fileobj",
".",
"read",
"(",
"10",
")",
"try",
":",
"id3",
",",
"insize",
"=",
"struct",
".",
"unpack",
"(",
"'>3sxxx4s'"... | Might raise IOError | [
"Might",
"raise",
"IOError"
] | python | train |
rytilahti/python-songpal | songpal/service.py | https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L283-L292 | def asdict(self):
"""Return dict presentation of this service.
Useful for dumping the device information into JSON.
"""
return {
"methods": {m.name: m.asdict() for m in self.methods},
"protocols": self.protocols,
"notifications": {n.name: n.asdict() f... | [
"def",
"asdict",
"(",
"self",
")",
":",
"return",
"{",
"\"methods\"",
":",
"{",
"m",
".",
"name",
":",
"m",
".",
"asdict",
"(",
")",
"for",
"m",
"in",
"self",
".",
"methods",
"}",
",",
"\"protocols\"",
":",
"self",
".",
"protocols",
",",
"\"notific... | Return dict presentation of this service.
Useful for dumping the device information into JSON. | [
"Return",
"dict",
"presentation",
"of",
"this",
"service",
"."
] | python | train |
UCL-INGI/INGInious | inginious/frontend/pages/queue.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/queue.py#L16-L18 | def GET_AUTH(self):
""" GET request """
return self.template_helper.get_renderer().queue(*self.submission_manager.get_job_queue_snapshot(), datetime.fromtimestamp) | [
"def",
"GET_AUTH",
"(",
"self",
")",
":",
"return",
"self",
".",
"template_helper",
".",
"get_renderer",
"(",
")",
".",
"queue",
"(",
"*",
"self",
".",
"submission_manager",
".",
"get_job_queue_snapshot",
"(",
")",
",",
"datetime",
".",
"fromtimestamp",
")"
... | GET request | [
"GET",
"request"
] | python | train |
edx/XBlock | xblock/runtime.py | https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/runtime.py#L638-L651 | def get_block(self, usage_id, for_parent=None):
"""
Create an XBlock instance in this runtime.
The `usage_id` is used to find the XBlock class and data.
"""
def_id = self.id_reader.get_definition_id(usage_id)
try:
block_type = self.id_reader.get_block_type(de... | [
"def",
"get_block",
"(",
"self",
",",
"usage_id",
",",
"for_parent",
"=",
"None",
")",
":",
"def_id",
"=",
"self",
".",
"id_reader",
".",
"get_definition_id",
"(",
"usage_id",
")",
"try",
":",
"block_type",
"=",
"self",
".",
"id_reader",
".",
"get_block_ty... | Create an XBlock instance in this runtime.
The `usage_id` is used to find the XBlock class and data. | [
"Create",
"an",
"XBlock",
"instance",
"in",
"this",
"runtime",
"."
] | python | train |
denisenkom/pytds | src/pytds/tds.py | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds.py#L555-L575 | def process_param(self):
""" Reads and processes RETURNVALUE stream.
This stream is used to send OUTPUT parameters from RPC to client.
Stream format url: http://msdn.microsoft.com/en-us/library/dd303881.aspx
"""
self.log_response_message('got RETURNVALUE message')
r = se... | [
"def",
"process_param",
"(",
"self",
")",
":",
"self",
".",
"log_response_message",
"(",
"'got RETURNVALUE message'",
")",
"r",
"=",
"self",
".",
"_reader",
"if",
"tds_base",
".",
"IS_TDS72_PLUS",
"(",
"self",
")",
":",
"ordinal",
"=",
"r",
".",
"get_usmalli... | Reads and processes RETURNVALUE stream.
This stream is used to send OUTPUT parameters from RPC to client.
Stream format url: http://msdn.microsoft.com/en-us/library/dd303881.aspx | [
"Reads",
"and",
"processes",
"RETURNVALUE",
"stream",
"."
] | python | train |
djgagne/hagelslag | hagelslag/data/HREFv2ModelGrid.py | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/data/HREFv2ModelGrid.py#L103-L187 | def load_data(self):
"""
Loads data from grib2 file objects or list of grib2 file objects. Handles specific grib2 variable names
and grib2 message numbers.
Returns:
Array of data loaded from files in (time, y, x) dimensions, Units
"""
file_... | [
"def",
"load_data",
"(",
"self",
")",
":",
"file_objects",
"=",
"self",
".",
"file_objects",
"var",
"=",
"self",
".",
"variable",
"valid_date",
"=",
"self",
".",
"valid_dates",
"data",
"=",
"self",
".",
"data",
"unknown_names",
"=",
"self",
".",
"unknown_n... | Loads data from grib2 file objects or list of grib2 file objects. Handles specific grib2 variable names
and grib2 message numbers.
Returns:
Array of data loaded from files in (time, y, x) dimensions, Units | [
"Loads",
"data",
"from",
"grib2",
"file",
"objects",
"or",
"list",
"of",
"grib2",
"file",
"objects",
".",
"Handles",
"specific",
"grib2",
"variable",
"names",
"and",
"grib2",
"message",
"numbers",
".",
"Returns",
":",
"Array",
"of",
"data",
"loaded",
"from",... | python | train |
ThreatConnect-Inc/tcex | tcex/tcex_ti/mappings/tcex_ti_mappings.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/tcex_ti_mappings.py#L726-L764 | def attribute_label(self, attribute_id, label, action='GET', params=None):
"""
Gets a security labels from a attribute
Args:
attribute_id:
label:
action:
params:
Returns: Security label json
"""
if params is None:
... | [
"def",
"attribute_label",
"(",
"self",
",",
"attribute_id",
",",
"label",
",",
"action",
"=",
"'GET'",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"can_update",
"(",
")",... | Gets a security labels from a attribute
Args:
attribute_id:
label:
action:
params:
Returns: Security label json | [
"Gets",
"a",
"security",
"labels",
"from",
"a",
"attribute"
] | python | train |
edx/edx-val | edxval/api.py | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L79-L115 | def create_video(video_data):
"""
Called on to create Video objects in the database
create_video is used to create Video objects whose children are EncodedVideo
objects which are linked to Profile objects. This is an alternative to the HTTP
requests so it can be used internally. The VideoSerializer... | [
"def",
"create_video",
"(",
"video_data",
")",
":",
"serializer",
"=",
"VideoSerializer",
"(",
"data",
"=",
"video_data",
")",
"if",
"serializer",
".",
"is_valid",
"(",
")",
":",
"serializer",
".",
"save",
"(",
")",
"return",
"video_data",
".",
"get",
"(",... | Called on to create Video objects in the database
create_video is used to create Video objects whose children are EncodedVideo
objects which are linked to Profile objects. This is an alternative to the HTTP
requests so it can be used internally. The VideoSerializer is used to
deserialize this object. I... | [
"Called",
"on",
"to",
"create",
"Video",
"objects",
"in",
"the",
"database"
] | python | train |
PyPSA/PyPSA | pypsa/opf.py | https://github.com/PyPSA/PyPSA/blob/46954b1b3c21460550f7104681517065279a53b7/pypsa/opf.py#L1400-L1425 | def network_lopf_prepare_solver(network, solver_name="glpk", solver_io=None):
"""
Prepare solver for linear optimal power flow.
Parameters
----------
solver_name : string
Must be a solver name that pyomo recognises and that is
installed, e.g. "glpk", "gurobi"
solver_io : string,... | [
"def",
"network_lopf_prepare_solver",
"(",
"network",
",",
"solver_name",
"=",
"\"glpk\"",
",",
"solver_io",
"=",
"None",
")",
":",
"network",
".",
"opt",
"=",
"SolverFactory",
"(",
"solver_name",
",",
"solver_io",
"=",
"solver_io",
")",
"patch_optsolver_record_me... | Prepare solver for linear optimal power flow.
Parameters
----------
solver_name : string
Must be a solver name that pyomo recognises and that is
installed, e.g. "glpk", "gurobi"
solver_io : string, default None
Solver Input-Output option, e.g. "python" to use "gurobipy" for
... | [
"Prepare",
"solver",
"for",
"linear",
"optimal",
"power",
"flow",
"."
] | python | train |
joeyespo/path-and-address | path_and_address/validation.py | https://github.com/joeyespo/path-and-address/blob/f8193a09f4b785574d920e8a2aeeb55ea6ff4e20/path_and_address/validation.py#L7-L21 | def valid_address(address):
"""
Determines whether the specified address string is valid.
"""
if not address:
return False
components = str(address).split(':')
if len(components) > 2 or not valid_hostname(components[0]):
return False
if len(components) == 2 and not valid_po... | [
"def",
"valid_address",
"(",
"address",
")",
":",
"if",
"not",
"address",
":",
"return",
"False",
"components",
"=",
"str",
"(",
"address",
")",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"components",
")",
">",
"2",
"or",
"not",
"valid_hostname"... | Determines whether the specified address string is valid. | [
"Determines",
"whether",
"the",
"specified",
"address",
"string",
"is",
"valid",
"."
] | python | train |
reingart/pyafipws | wsltv.py | https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wsltv.py#L565-L578 | def ConsultarCondicionesVenta(self, sep="||"):
"Retorna un listado de códigos y descripciones de las condiciones de ventas"
ret = self.client.consultarCondicionesVenta(
auth={
'token': self.Token, 'sign': self.Sign,
'cuit': ... | [
"def",
"ConsultarCondicionesVenta",
"(",
"self",
",",
"sep",
"=",
"\"||\"",
")",
":",
"ret",
"=",
"self",
".",
"client",
".",
"consultarCondicionesVenta",
"(",
"auth",
"=",
"{",
"'token'",
":",
"self",
".",
"Token",
",",
"'sign'",
":",
"self",
".",
"Sign... | Retorna un listado de códigos y descripciones de las condiciones de ventas | [
"Retorna",
"un",
"listado",
"de",
"códigos",
"y",
"descripciones",
"de",
"las",
"condiciones",
"de",
"ventas"
] | python | train |
cobrateam/flask-mongoalchemy | examples/library/library.py | https://github.com/cobrateam/flask-mongoalchemy/blob/66ab6f857cae69e35d37035880c1dfaf1dc9bd15/examples/library/library.py#L37-L45 | def list_authors():
"""List all authors.
e.g.: GET /authors"""
authors = Author.query.all()
content = '<p>Authors:</p>'
for author in authors:
content += '<p>%s</p>' % author.name
return content | [
"def",
"list_authors",
"(",
")",
":",
"authors",
"=",
"Author",
".",
"query",
".",
"all",
"(",
")",
"content",
"=",
"'<p>Authors:</p>'",
"for",
"author",
"in",
"authors",
":",
"content",
"+=",
"'<p>%s</p>'",
"%",
"author",
".",
"name",
"return",
"content"
... | List all authors.
e.g.: GET /authors | [
"List",
"all",
"authors",
"."
] | python | train |
alfred82santa/dirty-loader | dirty_loader/__init__.py | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L289-L301 | def unregister_module(self, module):
"""
Unregister a module.
:param module: must be a string or a module object to unregistered
:type module: str
"""
if module not in self._namespaces.values():
raise NoRegisteredError("Module '{0}' is not registered on loade... | [
"def",
"unregister_module",
"(",
"self",
",",
"module",
")",
":",
"if",
"module",
"not",
"in",
"self",
".",
"_namespaces",
".",
"values",
"(",
")",
":",
"raise",
"NoRegisteredError",
"(",
"\"Module '{0}' is not registered on loader.\"",
".",
"format",
"(",
"modu... | Unregister a module.
:param module: must be a string or a module object to unregistered
:type module: str | [
"Unregister",
"a",
"module",
"."
] | python | train |
manns/pyspread | pyspread/src/gui/_chart_dialog.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L654-L659 | def OnLabelSizeIntCtrl(self, event):
"""Label size IntCtrl event handler"""
self.attrs["labelsize"] = event.GetValue()
post_command_event(self, self.DrawChartMsg) | [
"def",
"OnLabelSizeIntCtrl",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"attrs",
"[",
"\"labelsize\"",
"]",
"=",
"event",
".",
"GetValue",
"(",
")",
"post_command_event",
"(",
"self",
",",
"self",
".",
"DrawChartMsg",
")"
] | Label size IntCtrl event handler | [
"Label",
"size",
"IntCtrl",
"event",
"handler"
] | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/features/importances.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/features/importances.py#L239-L256 | def finalize(self, **kwargs):
"""
Finalize the drawing setting labels and title.
"""
# Set the title
self.set_title('Feature Importances of {} Features using {}'.format(
len(self.features_), self.name))
# Set the xlabel
self.ax.set_xlabel(self._ge... | [
"def",
"finalize",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set the title",
"self",
".",
"set_title",
"(",
"'Feature Importances of {} Features using {}'",
".",
"format",
"(",
"len",
"(",
"self",
".",
"features_",
")",
",",
"self",
".",
"name",
")"... | Finalize the drawing setting labels and title. | [
"Finalize",
"the",
"drawing",
"setting",
"labels",
"and",
"title",
"."
] | python | train |
pantsbuild/pants | src/python/pants/backend/jvm/tasks/coursier_resolve.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/coursier_resolve.py#L209-L284 | def _get_result_from_coursier(self, jars_to_resolve, global_excludes, pinned_coords,
coursier_cache_path, sources, javadoc, executor):
"""
Calling coursier and return the result per invocation.
If coursier was called once for classifier '' and once for classifier 'tests', th... | [
"def",
"_get_result_from_coursier",
"(",
"self",
",",
"jars_to_resolve",
",",
"global_excludes",
",",
"pinned_coords",
",",
"coursier_cache_path",
",",
"sources",
",",
"javadoc",
",",
"executor",
")",
":",
"# Prepare coursier args",
"coursier_subsystem_instance",
"=",
"... | Calling coursier and return the result per invocation.
If coursier was called once for classifier '' and once for classifier 'tests', then the return value
would be: {'default': [<first coursier output>, <second coursier output>]}
:param jars_to_resolve: List of `JarDependency`s to resolve
:param glob... | [
"Calling",
"coursier",
"and",
"return",
"the",
"result",
"per",
"invocation",
"."
] | python | train |
UCL-INGI/INGInious | inginious/frontend/user_manager.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L723-L752 | def course_is_open_to_user(self, course, username=None, lti=None):
"""
Checks if a user is can access a course
:param course: a Course object
:param username: The username of the user that we want to check. If None, uses self.session_username()
:param lti: indicates if the user i... | [
"def",
"course_is_open_to_user",
"(",
"self",
",",
"course",
",",
"username",
"=",
"None",
",",
"lti",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
":",
"username",
"=",
"self",
".",
"session_username",
"(",
")",
"if",
"lti",
"==",
"\"auto\"",
... | Checks if a user is can access a course
:param course: a Course object
:param username: The username of the user that we want to check. If None, uses self.session_username()
:param lti: indicates if the user is currently in a LTI session or not.
- None to ignore the check
... | [
"Checks",
"if",
"a",
"user",
"is",
"can",
"access",
"a",
"course",
":",
"param",
"course",
":",
"a",
"Course",
"object",
":",
"param",
"username",
":",
"The",
"username",
"of",
"the",
"user",
"that",
"we",
"want",
"to",
"check",
".",
"If",
"None",
"u... | python | train |
duniter/duniter-python-api | duniterpy/api/client.py | https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/duniterpy/api/client.py#L37-L51 | def parse_text(text: str, schema: dict) -> Any:
"""
Validate and parse the BMA answer from websocket
:param text: the bma answer
:param schema: dict for jsonschema
:return: the json data
"""
try:
data = json.loads(text)
jsonschema.validate(data, schema)
except (TypeError... | [
"def",
"parse_text",
"(",
"text",
":",
"str",
",",
"schema",
":",
"dict",
")",
"->",
"Any",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"text",
")",
"jsonschema",
".",
"validate",
"(",
"data",
",",
"schema",
")",
"except",
"(",
"TypeEr... | Validate and parse the BMA answer from websocket
:param text: the bma answer
:param schema: dict for jsonschema
:return: the json data | [
"Validate",
"and",
"parse",
"the",
"BMA",
"answer",
"from",
"websocket"
] | python | train |
qwilka/vn-tree | vntree/node.py | https://github.com/qwilka/vn-tree/blob/f08106e9c7232d8748d78d1d39b019699a7407dd/vntree/node.py#L435-L507 | def to_texttree(self, indent=3, func=True, symbol='ascii'):
"""Method returning a text representation of the (sub-)tree
rooted at the current node instance (`self`).
:param indent: the indentation width for each tree level.
:type indent: int
:param func: function returning a s... | [
"def",
"to_texttree",
"(",
"self",
",",
"indent",
"=",
"3",
",",
"func",
"=",
"True",
",",
"symbol",
"=",
"'ascii'",
")",
":",
"if",
"indent",
"<",
"2",
":",
"indent",
"=",
"2",
"if",
"func",
"is",
"True",
":",
"# default func prints node.name",
"func"... | Method returning a text representation of the (sub-)tree
rooted at the current node instance (`self`).
:param indent: the indentation width for each tree level.
:type indent: int
:param func: function returning a string representation for
each node. e.g. `func=lambda n: s... | [
"Method",
"returning",
"a",
"text",
"representation",
"of",
"the",
"(",
"sub",
"-",
")",
"tree",
"rooted",
"at",
"the",
"current",
"node",
"instance",
"(",
"self",
")",
"."
] | python | train |
PyCQA/pylint | pylint/reporters/reports_handler_mix_in.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/reporters/reports_handler_mix_in.py#L70-L79 | def add_stats(self, **kwargs):
"""add some stats entries to the statistic dictionary
raise an AssertionError if there is a key conflict
"""
for key, value in kwargs.items():
if key[-1] == "_":
key = key[:-1]
assert key not in self.stats
... | [
"def",
"add_stats",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"key",
"[",
"-",
"1",
"]",
"==",
"\"_\"",
":",
"key",
"=",
"key",
"[",
":",
"-",
"1",
"]",
"a... | add some stats entries to the statistic dictionary
raise an AssertionError if there is a key conflict | [
"add",
"some",
"stats",
"entries",
"to",
"the",
"statistic",
"dictionary",
"raise",
"an",
"AssertionError",
"if",
"there",
"is",
"a",
"key",
"conflict"
] | python | test |
codeghar/brokerlso | brokerlso/qmfv2.py | https://github.com/codeghar/brokerlso/blob/e110e12502b090e12b06c7615dd0a96a14a92585/brokerlso/qmfv2.py#L109-L124 | def delete_queue(self, name):
"""Create message content and properties to delete queue with QMFv2
:param name: Name of queue to delete
:type name: str
:returns: Tuple containing content and method properties
"""
content = {"_object_id": {"_object_name": self.object_name... | [
"def",
"delete_queue",
"(",
"self",
",",
"name",
")",
":",
"content",
"=",
"{",
"\"_object_id\"",
":",
"{",
"\"_object_name\"",
":",
"self",
".",
"object_name",
"}",
",",
"\"_method_name\"",
":",
"\"delete\"",
",",
"\"_arguments\"",
":",
"{",
"\"type\"",
":"... | Create message content and properties to delete queue with QMFv2
:param name: Name of queue to delete
:type name: str
:returns: Tuple containing content and method properties | [
"Create",
"message",
"content",
"and",
"properties",
"to",
"delete",
"queue",
"with",
"QMFv2"
] | python | test |
twilio/twilio-python | twilio/rest/ip_messaging/v2/service/channel/invite.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/ip_messaging/v2/service/channel/invite.py#L214-L228 | def get_instance(self, payload):
"""
Build an instance of InviteInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.chat.v2.service.channel.invite.InviteInstance
:rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance
"""
... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"InviteInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
"channel_sid",
"=",
"self",
".",
"_so... | Build an instance of InviteInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.chat.v2.service.channel.invite.InviteInstance
:rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance | [
"Build",
"an",
"instance",
"of",
"InviteInstance"
] | python | train |
ionelmc/python-redis-lock | src/redis_lock/__init__.py | https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L222-L261 | def acquire(self, blocking=True, timeout=None):
"""
:param blocking:
Boolean value specifying whether lock should be blocking or not.
:param timeout:
An integer value specifying the maximum number of seconds to block.
"""
logger.debug("Getting %r ...", sel... | [
"def",
"acquire",
"(",
"self",
",",
"blocking",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Getting %r ...\"",
",",
"self",
".",
"_name",
")",
"if",
"self",
".",
"_held",
":",
"raise",
"AlreadyAcquired",
"(",
"\"... | :param blocking:
Boolean value specifying whether lock should be blocking or not.
:param timeout:
An integer value specifying the maximum number of seconds to block. | [
":",
"param",
"blocking",
":",
"Boolean",
"value",
"specifying",
"whether",
"lock",
"should",
"be",
"blocking",
"or",
"not",
".",
":",
"param",
"timeout",
":",
"An",
"integer",
"value",
"specifying",
"the",
"maximum",
"number",
"of",
"seconds",
"to",
"block"... | python | train |
yyuu/botornado | boto/dynamodb/table.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/table.py#L104-L129 | def refresh(self, wait_for_active=False, retry_seconds=5):
"""
Refresh all of the fields of the Table object by calling
the underlying DescribeTable request.
:type wait_for_active: bool
:param wait_for_active: If True, this command will not return
until the table sta... | [
"def",
"refresh",
"(",
"self",
",",
"wait_for_active",
"=",
"False",
",",
"retry_seconds",
"=",
"5",
")",
":",
"done",
"=",
"False",
"while",
"not",
"done",
":",
"response",
"=",
"self",
".",
"layer2",
".",
"describe_table",
"(",
"self",
".",
"name",
"... | Refresh all of the fields of the Table object by calling
the underlying DescribeTable request.
:type wait_for_active: bool
:param wait_for_active: If True, this command will not return
until the table status, as returned from Amazon DynamoDB, is
'ACTIVE'.
:type ... | [
"Refresh",
"all",
"of",
"the",
"fields",
"of",
"the",
"Table",
"object",
"by",
"calling",
"the",
"underlying",
"DescribeTable",
"request",
"."
] | python | train |
yyuu/botornado | botornado/s3/bucket.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/botornado/s3/bucket.py#L53-L63 | def lookup(self, key_name, headers=None, callback=None):
"""
Deprecated: Please use get_key method.
:type key_name: string
:param key_name: The name of the key to retrieve
:rtype: :class:`boto.s3.key.Key`
:returns: A Key object from this bucket.
... | [
"def",
"lookup",
"(",
"self",
",",
"key_name",
",",
"headers",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_key",
"(",
"key_name",
",",
"headers",
"=",
"headers",
",",
"callback",
"=",
"callback",
")"
] | Deprecated: Please use get_key method.
:type key_name: string
:param key_name: The name of the key to retrieve
:rtype: :class:`boto.s3.key.Key`
:returns: A Key object from this bucket. | [
"Deprecated",
":",
"Please",
"use",
"get_key",
"method",
".",
":",
"type",
"key_name",
":",
"string",
":",
"param",
"key_name",
":",
"The",
"name",
"of",
"the",
"key",
"to",
"retrieve",
":",
"rtype",
":",
":",
"class",
":",
"boto",
".",
"s3",
".",
"k... | python | train |
GaretJax/django-click | djclick/adapter.py | https://github.com/GaretJax/django-click/blob/3584bff81cb7891a1aa2d7fe49c1db501f5b0e84/djclick/adapter.py#L90-L110 | def execute(self, *args, **kwargs):
"""
Called when run through `call_command`. `args` are passed through,
while `kwargs` is the __dict__ of the return value of
`self.create_parser('', name)` updated with the kwargs passed to
`call_command`.
"""
# Remove internal ... | [
"def",
"execute",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Remove internal Django command handling machinery",
"kwargs",
".",
"pop",
"(",
"'skip_checks'",
",",
"None",
")",
"parent_ctx",
"=",
"click",
".",
"get_current_context",
"(",
... | Called when run through `call_command`. `args` are passed through,
while `kwargs` is the __dict__ of the return value of
`self.create_parser('', name)` updated with the kwargs passed to
`call_command`. | [
"Called",
"when",
"run",
"through",
"call_command",
".",
"args",
"are",
"passed",
"through",
"while",
"kwargs",
"is",
"the",
"__dict__",
"of",
"the",
"return",
"value",
"of",
"self",
".",
"create_parser",
"(",
"name",
")",
"updated",
"with",
"the",
"kwargs",... | python | train |
mitsei/dlkit | dlkit/services/hierarchy.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/hierarchy.py#L458-L466 | def get_hierarchy_form(self, *args, **kwargs):
"""Pass through to provider HierarchyAdminSession.get_hierarchy_form_for_update"""
# Implemented from kitosid template for -
# osid.resource.BinAdminSession.get_bin_form_for_update_template
# This method might be a bit sketchy. Time will tel... | [
"def",
"get_hierarchy_form",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Implemented from kitosid template for -",
"# osid.resource.BinAdminSession.get_bin_form_for_update_template",
"# This method might be a bit sketchy. Time will tell.",
"if",
"isinstance... | Pass through to provider HierarchyAdminSession.get_hierarchy_form_for_update | [
"Pass",
"through",
"to",
"provider",
"HierarchyAdminSession",
".",
"get_hierarchy_form_for_update"
] | python | train |
senaite/senaite.jsonapi | src/senaite/jsonapi/catalog.py | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/catalog.py#L113-L131 | def make_query(self, **kw):
"""create a query suitable for the catalog
"""
query = kw.pop("query", {})
query.update(self.get_request_query())
query.update(self.get_custom_query())
query.update(self.get_keyword_query(**kw))
sort_on, sort_order = self.get_sort_spe... | [
"def",
"make_query",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"query",
"=",
"kw",
".",
"pop",
"(",
"\"query\"",
",",
"{",
"}",
")",
"query",
".",
"update",
"(",
"self",
".",
"get_request_query",
"(",
")",
")",
"query",
".",
"update",
"(",
"sel... | create a query suitable for the catalog | [
"create",
"a",
"query",
"suitable",
"for",
"the",
"catalog"
] | python | train |
ska-sa/montblanc | install/tensorflow_ops_ext.py | https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/tensorflow_ops_ext.py#L82-L152 | def create_tensorflow_extension(nvcc_settings, device_info):
""" Create an extension that builds the custom tensorflow ops """
import tensorflow as tf
import glob
use_cuda = (bool(nvcc_settings['cuda_available'])
and tf.test.is_built_with_cuda())
# Source and includes
source_path = os.... | [
"def",
"create_tensorflow_extension",
"(",
"nvcc_settings",
",",
"device_info",
")",
":",
"import",
"tensorflow",
"as",
"tf",
"import",
"glob",
"use_cuda",
"=",
"(",
"bool",
"(",
"nvcc_settings",
"[",
"'cuda_available'",
"]",
")",
"and",
"tf",
".",
"test",
"."... | Create an extension that builds the custom tensorflow ops | [
"Create",
"an",
"extension",
"that",
"builds",
"the",
"custom",
"tensorflow",
"ops"
] | python | train |
mongodb/motor | motor/core.py | https://github.com/mongodb/motor/blob/6af22720723bde7c78eb8cb126962cfbfc034b2c/motor/core.py#L1440-L1451 | def close(self):
"""Close this change stream.
Stops any "async for" loops using this change stream.
"""
if self.delegate:
return self._close()
# Never started.
future = self._framework.get_future(self.get_io_loop())
future.set_result(None)
re... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"delegate",
":",
"return",
"self",
".",
"_close",
"(",
")",
"# Never started.",
"future",
"=",
"self",
".",
"_framework",
".",
"get_future",
"(",
"self",
".",
"get_io_loop",
"(",
")",
")",
"futu... | Close this change stream.
Stops any "async for" loops using this change stream. | [
"Close",
"this",
"change",
"stream",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/daemon.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L830-L872 | def do_stop(self):
"""Execute the stop of this daemon:
- request the daemon to stop
- request the http thread to stop, else force stop the thread
- Close the http socket
- Shutdown the manager
- Stop and join all started "modules"
:return: None
"""
... | [
"def",
"do_stop",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Stopping %s...\"",
",",
"self",
".",
"name",
")",
"if",
"self",
".",
"sync_manager",
":",
"logger",
".",
"info",
"(",
"\"Shutting down synchronization manager...\"",
")",
"self",
".",
"s... | Execute the stop of this daemon:
- request the daemon to stop
- request the http thread to stop, else force stop the thread
- Close the http socket
- Shutdown the manager
- Stop and join all started "modules"
:return: None | [
"Execute",
"the",
"stop",
"of",
"this",
"daemon",
":",
"-",
"request",
"the",
"daemon",
"to",
"stop",
"-",
"request",
"the",
"http",
"thread",
"to",
"stop",
"else",
"force",
"stop",
"the",
"thread",
"-",
"Close",
"the",
"http",
"socket",
"-",
"Shutdown",... | python | train |
gem/oq-engine | openquake/hazardlib/geo/geodetic.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L489-L525 | def distance_to_arc(alon, alat, aazimuth, plons, plats):
"""
Calculate a closest distance between a great circle arc and a point
(or a collection of points).
:param float alon, alat:
Arc reference point longitude and latitude, in decimal degrees.
:param azimuth:
Arc azimuth (an angl... | [
"def",
"distance_to_arc",
"(",
"alon",
",",
"alat",
",",
"aazimuth",
",",
"plons",
",",
"plats",
")",
":",
"azimuth_to_target",
"=",
"azimuth",
"(",
"alon",
",",
"alat",
",",
"plons",
",",
"plats",
")",
"distance_to_target",
"=",
"geodetic_distance",
"(",
... | Calculate a closest distance between a great circle arc and a point
(or a collection of points).
:param float alon, alat:
Arc reference point longitude and latitude, in decimal degrees.
:param azimuth:
Arc azimuth (an angle between direction to a north and arc in clockwise
direction... | [
"Calculate",
"a",
"closest",
"distance",
"between",
"a",
"great",
"circle",
"arc",
"and",
"a",
"point",
"(",
"or",
"a",
"collection",
"of",
"points",
")",
"."
] | python | train |
albertyw/pyziptax | pyziptax/ziptax.py | https://github.com/albertyw/pyziptax/blob/c56dd440e4cadff7f2dd4b72e5dcced06a44969d/pyziptax/ziptax.py#L36-L44 | def make_request_data(self, zipcode, city, state):
""" Make the request params given location data """
data = {'key': self.api_key,
'postalcode': str(zipcode),
'city': city,
'state': state
}
data = ZipTaxClient._clean_request_data(data)
... | [
"def",
"make_request_data",
"(",
"self",
",",
"zipcode",
",",
"city",
",",
"state",
")",
":",
"data",
"=",
"{",
"'key'",
":",
"self",
".",
"api_key",
",",
"'postalcode'",
":",
"str",
"(",
"zipcode",
")",
",",
"'city'",
":",
"city",
",",
"'state'",
":... | Make the request params given location data | [
"Make",
"the",
"request",
"params",
"given",
"location",
"data"
] | python | valid |
ThreatConnect-Inc/tcex | tcex/tcex_bin_run.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L661-L682 | def profile(self, profile):
"""Set the current profile.
Args:
profile (dict): The profile data.
"""
# clear staging data
self._staging_data = None
# retrieve language from install.json or assume Python
lang = profile.get('install_json', {}).get('progr... | [
"def",
"profile",
"(",
"self",
",",
"profile",
")",
":",
"# clear staging data",
"self",
".",
"_staging_data",
"=",
"None",
"# retrieve language from install.json or assume Python",
"lang",
"=",
"profile",
".",
"get",
"(",
"'install_json'",
",",
"{",
"}",
")",
"."... | Set the current profile.
Args:
profile (dict): The profile data. | [
"Set",
"the",
"current",
"profile",
"."
] | python | train |
google/textfsm | textfsm/parser.py | https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L814-L859 | def _ValidateFSM(self):
"""Checks state names and destinations for validity.
Each destination state must exist, be a valid name and
not be a reserved name.
There must be a 'Start' state and if 'EOF' or 'End' states are specified,
they must be empty.
Returns:
True if FSM is valid.
Ra... | [
"def",
"_ValidateFSM",
"(",
"self",
")",
":",
"# Must have 'Start' state.",
"if",
"'Start'",
"not",
"in",
"self",
".",
"states",
":",
"raise",
"TextFSMTemplateError",
"(",
"\"Missing state 'Start'.\"",
")",
"# 'End/EOF' state (if specified) must be empty.",
"if",
"self",
... | Checks state names and destinations for validity.
Each destination state must exist, be a valid name and
not be a reserved name.
There must be a 'Start' state and if 'EOF' or 'End' states are specified,
they must be empty.
Returns:
True if FSM is valid.
Raises:
TextFSMTemplateErro... | [
"Checks",
"state",
"names",
"and",
"destinations",
"for",
"validity",
"."
] | python | train |
trailofbits/manticore | manticore/native/cpu/arm.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L270-L280 | def _write_APSR(self, apsr):
"""Auxiliary function - Writes flags from a full APSR (only 4 msb used)"""
V = Operators.EXTRACT(apsr, 28, 1)
C = Operators.EXTRACT(apsr, 29, 1)
Z = Operators.EXTRACT(apsr, 30, 1)
N = Operators.EXTRACT(apsr, 31, 1)
self.write('APSR_V', V)
... | [
"def",
"_write_APSR",
"(",
"self",
",",
"apsr",
")",
":",
"V",
"=",
"Operators",
".",
"EXTRACT",
"(",
"apsr",
",",
"28",
",",
"1",
")",
"C",
"=",
"Operators",
".",
"EXTRACT",
"(",
"apsr",
",",
"29",
",",
"1",
")",
"Z",
"=",
"Operators",
".",
"E... | Auxiliary function - Writes flags from a full APSR (only 4 msb used) | [
"Auxiliary",
"function",
"-",
"Writes",
"flags",
"from",
"a",
"full",
"APSR",
"(",
"only",
"4",
"msb",
"used",
")"
] | python | valid |
openego/eDisGo | edisgo/grid/network.py | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/network.py#L142-L182 | def plot_mv_grid_expansion_costs(self, **kwargs):
"""
Plots costs per MV line.
For more information see :func:`edisgo.tools.plots.mv_grid_topology`.
"""
if self.network.pypsa is not None and \
self.network.results.grid_expansion_costs is not None:
if... | [
"def",
"plot_mv_grid_expansion_costs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"network",
".",
"pypsa",
"is",
"not",
"None",
"and",
"self",
".",
"network",
".",
"results",
".",
"grid_expansion_costs",
"is",
"not",
"None",
":",
... | Plots costs per MV line.
For more information see :func:`edisgo.tools.plots.mv_grid_topology`. | [
"Plots",
"costs",
"per",
"MV",
"line",
"."
] | python | train |
alfred82santa/dirty-models | dirty_models/base.py | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/base.py#L61-L70 | def is_locked(self):
"""
Returns whether model is locked
"""
if not self.__locked__:
return False
elif self.get_parent():
return self.get_parent().is_locked()
return True | [
"def",
"is_locked",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__locked__",
":",
"return",
"False",
"elif",
"self",
".",
"get_parent",
"(",
")",
":",
"return",
"self",
".",
"get_parent",
"(",
")",
".",
"is_locked",
"(",
")",
"return",
"True"
] | Returns whether model is locked | [
"Returns",
"whether",
"model",
"is",
"locked"
] | python | train |
pantsbuild/pants | src/python/pants/build_graph/target.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/target.py#L174-L183 | def target_base(self):
"""
:API: public
:returns: the source root path for this target.
"""
source_root = self._sources_field.source_root
if not source_root:
raise TargetDefinitionException(self, 'Not under any configured source root.')
return source_root.path | [
"def",
"target_base",
"(",
"self",
")",
":",
"source_root",
"=",
"self",
".",
"_sources_field",
".",
"source_root",
"if",
"not",
"source_root",
":",
"raise",
"TargetDefinitionException",
"(",
"self",
",",
"'Not under any configured source root.'",
")",
"return",
"so... | :API: public
:returns: the source root path for this target. | [
":",
"API",
":",
"public"
] | python | train |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L91-L120 | def echo_results(data, no_color, verbose=False):
"""Print test results in nagios style format."""
try:
summary = data['summary']
except KeyError as error:
click.secho(
'The results json is missing key: %s' % error,
fg='red'
)
sys.exit(1)
if 'faile... | [
"def",
"echo_results",
"(",
"data",
",",
"no_color",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"summary",
"=",
"data",
"[",
"'summary'",
"]",
"except",
"KeyError",
"as",
"error",
":",
"click",
".",
"secho",
"(",
"'The results json is missing key: %... | Print test results in nagios style format. | [
"Print",
"test",
"results",
"in",
"nagios",
"style",
"format",
"."
] | python | train |
madmaze/pytesseract | src/pytesseract.py | https://github.com/madmaze/pytesseract/blob/dd7dffc227480e9de024e99a5e10e7664f42b2de/src/pytesseract.py#L281-L292 | def get_tesseract_version():
'''
Returns LooseVersion object of the Tesseract version
'''
try:
return LooseVersion(
subprocess.check_output(
[tesseract_cmd, '--version'], stderr=subprocess.STDOUT
).decode('utf-8').split()[1].lstrip(string.printable[10:])
... | [
"def",
"get_tesseract_version",
"(",
")",
":",
"try",
":",
"return",
"LooseVersion",
"(",
"subprocess",
".",
"check_output",
"(",
"[",
"tesseract_cmd",
",",
"'--version'",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
".",
"decode",
"(",
"'utf-8... | Returns LooseVersion object of the Tesseract version | [
"Returns",
"LooseVersion",
"object",
"of",
"the",
"Tesseract",
"version"
] | python | train |
BerkeleyAutomation/autolab_core | autolab_core/utils.py | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L64-L102 | def histogram(values, num_bins, bounds, normalized=True, plot=False, color='b'):
"""Generate a histogram plot.
Parameters
----------
values : :obj:`numpy.ndarray`
An array of values to put in the histogram.
num_bins : int
The number equal-width bins in the histogram.
bounds : ... | [
"def",
"histogram",
"(",
"values",
",",
"num_bins",
",",
"bounds",
",",
"normalized",
"=",
"True",
",",
"plot",
"=",
"False",
",",
"color",
"=",
"'b'",
")",
":",
"hist",
",",
"bins",
"=",
"np",
".",
"histogram",
"(",
"values",
",",
"bins",
"=",
"nu... | Generate a histogram plot.
Parameters
----------
values : :obj:`numpy.ndarray`
An array of values to put in the histogram.
num_bins : int
The number equal-width bins in the histogram.
bounds : :obj:`tuple` of float
Two floats - a min and a max - that define the lower and u... | [
"Generate",
"a",
"histogram",
"plot",
"."
] | python | train |
mabuchilab/QNET | src/qnet/algebra/core/abstract_algebra.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_algebra.py#L298-L320 | def del_rules(cls, *names, attr=None):
"""Delete algebraic rules used by :meth:`create`
Remove the rules with the given `names`, or all rules if no names are
given
Args:
names (str): Names of rules to delete
attr (None or str): Name of the class attribute from w... | [
"def",
"del_rules",
"(",
"cls",
",",
"*",
"names",
",",
"attr",
"=",
"None",
")",
":",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"cls",
".",
"_rules_attr",
"(",
")",
"if",
"len",
"(",
"names",
")",
"==",
"0",
":",
"getattr",
"(",
"cls",
","... | Delete algebraic rules used by :meth:`create`
Remove the rules with the given `names`, or all rules if no names are
given
Args:
names (str): Names of rules to delete
attr (None or str): Name of the class attribute from which to
delete the rules. Cf. :met... | [
"Delete",
"algebraic",
"rules",
"used",
"by",
":",
"meth",
":",
"create"
] | python | train |
andrewsnowden/dota2py | dota2py/parser.py | https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L262-L280 | def parse_game_event(self, event):
"""
So CSVCMsg_GameEventList is a list of all events that can happen.
A game event has an eventid which maps to a type of event that happened
"""
if event.eventid in self.event_lookup:
#Bash this into a nicer data format to work wit... | [
"def",
"parse_game_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"eventid",
"in",
"self",
".",
"event_lookup",
":",
"#Bash this into a nicer data format to work with",
"event_type",
"=",
"self",
".",
"event_lookup",
"[",
"event",
".",
"eventid",... | So CSVCMsg_GameEventList is a list of all events that can happen.
A game event has an eventid which maps to a type of event that happened | [
"So",
"CSVCMsg_GameEventList",
"is",
"a",
"list",
"of",
"all",
"events",
"that",
"can",
"happen",
".",
"A",
"game",
"event",
"has",
"an",
"eventid",
"which",
"maps",
"to",
"a",
"type",
"of",
"event",
"that",
"happened"
] | python | train |
senaite/senaite.core | bika/lims/content/worksheet.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/worksheet.py#L1166-L1174 | def getQCAnalyses(self):
"""
Return the Quality Control analyses.
:returns: a list of QC analyses
:rtype: List of ReferenceAnalysis/DuplicateAnalysis
"""
qc_types = ['ReferenceAnalysis', 'DuplicateAnalysis']
analyses = self.getAnalyses()
return [a for a in... | [
"def",
"getQCAnalyses",
"(",
"self",
")",
":",
"qc_types",
"=",
"[",
"'ReferenceAnalysis'",
",",
"'DuplicateAnalysis'",
"]",
"analyses",
"=",
"self",
".",
"getAnalyses",
"(",
")",
"return",
"[",
"a",
"for",
"a",
"in",
"analyses",
"if",
"a",
".",
"portal_ty... | Return the Quality Control analyses.
:returns: a list of QC analyses
:rtype: List of ReferenceAnalysis/DuplicateAnalysis | [
"Return",
"the",
"Quality",
"Control",
"analyses",
".",
":",
"returns",
":",
"a",
"list",
"of",
"QC",
"analyses",
":",
"rtype",
":",
"List",
"of",
"ReferenceAnalysis",
"/",
"DuplicateAnalysis"
] | python | train |
HydrelioxGitHub/pybbox | pybbox/__init__.py | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L245-L254 | def get_down_used_bandwith(self):
"""
Return a percentage of the current used xdsl download bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int
"""
ip_stats_up = self.ge... | [
"def",
"get_down_used_bandwith",
"(",
"self",
")",
":",
"ip_stats_up",
"=",
"self",
".",
"get_ip_stats",
"(",
")",
"[",
"'rx'",
"]",
"percent",
"=",
"ip_stats_up",
"[",
"'bandwidth'",
"]",
"*",
"100",
"/",
"ip_stats_up",
"[",
"'maxBandwidth'",
"]",
"return",... | Return a percentage of the current used xdsl download bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int | [
"Return",
"a",
"percentage",
"of",
"the",
"current",
"used",
"xdsl",
"download",
"bandwith",
"Instant",
"measure",
"can",
"be",
"very",
"different",
"from",
"one",
"call",
"to",
"another",
":",
"return",
":",
"0",
"no",
"bandwith",
"is",
"used",
"100",
"al... | python | train |
apache/incubator-superset | superset/utils/core.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/core.py#L403-L423 | def error_msg_from_exception(e):
"""Translate exception into error message
Database have different ways to handle exception. This function attempts
to make sense of the exception object and construct a human readable
sentence.
TODO(bkyryliuk): parse the Presto error message from the connection
... | [
"def",
"error_msg_from_exception",
"(",
"e",
")",
":",
"msg",
"=",
"''",
"if",
"hasattr",
"(",
"e",
",",
"'message'",
")",
":",
"if",
"isinstance",
"(",
"e",
".",
"message",
",",
"dict",
")",
":",
"msg",
"=",
"e",
".",
"message",
".",
"get",
"(",
... | Translate exception into error message
Database have different ways to handle exception. This function attempts
to make sense of the exception object and construct a human readable
sentence.
TODO(bkyryliuk): parse the Presto error message from the connection
created via create_eng... | [
"Translate",
"exception",
"into",
"error",
"message"
] | python | train |
SheffieldML/GPy | GPy/core/symbolic.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/core/symbolic.py#L371-L377 | def _print_code(self, code):
"""Prepare code for string writing."""
# This needs a rewrite --- it doesn't check for match clashes! So sub11 would be replaced by sub1 before being replaced with sub11!!
for key in self.variables.keys():
for arg in self.variables[key]:
c... | [
"def",
"_print_code",
"(",
"self",
",",
"code",
")",
":",
"# This needs a rewrite --- it doesn't check for match clashes! So sub11 would be replaced by sub1 before being replaced with sub11!!",
"for",
"key",
"in",
"self",
".",
"variables",
".",
"keys",
"(",
")",
":",
"for",
... | Prepare code for string writing. | [
"Prepare",
"code",
"for",
"string",
"writing",
"."
] | python | train |
tethysplatform/condorpy | condorpy/job.py | https://github.com/tethysplatform/condorpy/blob/a5aaaef0d73198f7d9756dda7abe98b4e209f1f4/condorpy/job.py#L173-L180 | def job_file(self):
"""The path to the submit description file representing this job.
"""
job_file_name = '%s.job' % (self.name)
job_file_path = os.path.join(self.initial_dir, job_file_name)
self._job_file = job_file_path
return self._job_file | [
"def",
"job_file",
"(",
"self",
")",
":",
"job_file_name",
"=",
"'%s.job'",
"%",
"(",
"self",
".",
"name",
")",
"job_file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"initial_dir",
",",
"job_file_name",
")",
"self",
".",
"_job_file",
... | The path to the submit description file representing this job. | [
"The",
"path",
"to",
"the",
"submit",
"description",
"file",
"representing",
"this",
"job",
"."
] | python | train |
pgmpy/pgmpy | pgmpy/models/MarkovChain.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovChain.py#L236-L294 | def sample(self, start_state=None, size=1):
"""
Sample from the Markov Chain.
Parameters:
-----------
start_state: dict or array-like iterable
Representing the starting states of the variables. If None is passed, a random start_state is chosen.
size: int
... | [
"def",
"sample",
"(",
"self",
",",
"start_state",
"=",
"None",
",",
"size",
"=",
"1",
")",
":",
"if",
"start_state",
"is",
"None",
":",
"if",
"self",
".",
"state",
"is",
"None",
":",
"self",
".",
"state",
"=",
"self",
".",
"random_state",
"(",
")",... | Sample from the Markov Chain.
Parameters:
-----------
start_state: dict or array-like iterable
Representing the starting states of the variables. If None is passed, a random start_state is chosen.
size: int
Number of samples to be generated.
Return Type:... | [
"Sample",
"from",
"the",
"Markov",
"Chain",
"."
] | python | train |
pypa/setuptools | setuptools/command/build_py.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L220-L235 | def _get_platform_patterns(spec, package, src_dir):
"""
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
"""
raw_patterns = itertools.... | [
"def",
"_get_platform_patterns",
"(",
"spec",
",",
"package",
",",
"src_dir",
")",
":",
"raw_patterns",
"=",
"itertools",
".",
"chain",
"(",
"spec",
".",
"get",
"(",
"''",
",",
"[",
"]",
")",
",",
"spec",
".",
"get",
"(",
"package",
",",
"[",
"]",
... | yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir. | [
"yield",
"platform",
"-",
"specific",
"path",
"patterns",
"(",
"suitable",
"for",
"glob",
"or",
"fn_match",
")",
"from",
"a",
"glob",
"-",
"based",
"spec",
"(",
"such",
"as",
"self",
".",
"package_data",
"or",
"self",
".",
"exclude_package_data",
")",
"mat... | python | train |
molmod/molmod | molmod/transformations.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/transformations.py#L379-L383 | def inv(self):
"""The inverse transformation"""
result = Complete(self.r.transpose(), np.dot(self.r.transpose(), -self.t))
result._cache_inv = self
return result | [
"def",
"inv",
"(",
"self",
")",
":",
"result",
"=",
"Complete",
"(",
"self",
".",
"r",
".",
"transpose",
"(",
")",
",",
"np",
".",
"dot",
"(",
"self",
".",
"r",
".",
"transpose",
"(",
")",
",",
"-",
"self",
".",
"t",
")",
")",
"result",
".",
... | The inverse transformation | [
"The",
"inverse",
"transformation"
] | python | train |
OCA/openupgradelib | openupgradelib/openupgrade_70.py | https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade_70.py#L29-L53 | def set_partner_id_from_partner_address_id(
cr, pool, model_name, partner_field, address_field, table=None):
"""
Set the new partner_id on any table with migrated contact ids
:param model_name: the model name of the target table
:param partner_field: the column in the target model's table \
... | [
"def",
"set_partner_id_from_partner_address_id",
"(",
"cr",
",",
"pool",
",",
"model_name",
",",
"partner_field",
",",
"address_field",
",",
"table",
"=",
"None",
")",
":",
"model",
"=",
"pool",
".",
"get",
"(",
"model_name",
")",
"table",
"=",
"table",
"or"... | Set the new partner_id on any table with migrated contact ids
:param model_name: the model name of the target table
:param partner_field: the column in the target model's table \
that will store the new partner when found
:param address_field: the legacy field in the model's table... | [
"Set",
"the",
"new",
"partner_id",
"on",
"any",
"table",
"with",
"migrated",
"contact",
"ids"
] | python | train |
chrisspen/burlap | burlap/dj.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/dj.py#L430-L444 | def manage_all(self, *args, **kwargs):
"""
Runs manage() across all unique site default databases.
"""
for site, site_data in self.iter_unique_databases(site='all'):
if self.verbose:
print('-'*80, file=sys.stderr)
print('site:', site, file=sys.... | [
"def",
"manage_all",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"site",
",",
"site_data",
"in",
"self",
".",
"iter_unique_databases",
"(",
"site",
"=",
"'all'",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
... | Runs manage() across all unique site default databases. | [
"Runs",
"manage",
"()",
"across",
"all",
"unique",
"site",
"default",
"databases",
"."
] | python | valid |
nerdvegas/rez | src/rez/resolved_context.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolved_context.py#L558-L563 | def load(cls, path):
"""Load a resolved context from file."""
with open(path) as f:
context = cls.read_from_buffer(f, path)
context.set_load_path(path)
return context | [
"def",
"load",
"(",
"cls",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"context",
"=",
"cls",
".",
"read_from_buffer",
"(",
"f",
",",
"path",
")",
"context",
".",
"set_load_path",
"(",
"path",
")",
"return",
"context"
] | Load a resolved context from file. | [
"Load",
"a",
"resolved",
"context",
"from",
"file",
"."
] | python | train |
lmcinnes/umap | umap/rp_tree.py | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L596-L605 | def max_sparse_hyperplane_size(tree):
"""Determine the most number on non zeros in a hyperplane entry"""
if tree.is_leaf:
return 0
else:
return max(
tree.hyperplane.shape[1],
max_sparse_hyperplane_size(tree.left_child),
max_sparse_hyperplane_size(tree.righ... | [
"def",
"max_sparse_hyperplane_size",
"(",
"tree",
")",
":",
"if",
"tree",
".",
"is_leaf",
":",
"return",
"0",
"else",
":",
"return",
"max",
"(",
"tree",
".",
"hyperplane",
".",
"shape",
"[",
"1",
"]",
",",
"max_sparse_hyperplane_size",
"(",
"tree",
".",
... | Determine the most number on non zeros in a hyperplane entry | [
"Determine",
"the",
"most",
"number",
"on",
"non",
"zeros",
"in",
"a",
"hyperplane",
"entry"
] | python | train |
senaite/senaite.lims | src/senaite/lims/browser/bootstrap/views.py | https://github.com/senaite/senaite.lims/blob/3c7fc7b462321fb354c478c19b5c20f3014fa398/src/senaite/lims/browser/bootstrap/views.py#L83-L91 | def getViewportValues(self, view=None):
"""Determine the value of the viewport meta-tag
"""
values = {
'width': 'device-width',
'initial-scale': '1.0',
}
return ','.join('%s=%s' % (k, v) for k, v in values.items()) | [
"def",
"getViewportValues",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"values",
"=",
"{",
"'width'",
":",
"'device-width'",
",",
"'initial-scale'",
":",
"'1.0'",
",",
"}",
"return",
"','",
".",
"join",
"(",
"'%s=%s'",
"%",
"(",
"k",
",",
"v",
... | Determine the value of the viewport meta-tag | [
"Determine",
"the",
"value",
"of",
"the",
"viewport",
"meta",
"-",
"tag"
] | python | train |
ff0000/scarlet | scarlet/cms/item.py | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/item.py#L442-L455 | def render(self, request, **kwargs):
"""
Renders this view. Adds cancel_url to the context.
If the request get parameters contains 'popup' then
the `render_type` is set to 'popup'.
"""
if request.GET.get('popup'):
self.render_type = 'popup'
kwargs[... | [
"def",
"render",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"request",
".",
"GET",
".",
"get",
"(",
"'popup'",
")",
":",
"self",
".",
"render_type",
"=",
"'popup'",
"kwargs",
"[",
"'popup'",
"]",
"=",
"1",
"kwargs",
"[",
... | Renders this view. Adds cancel_url to the context.
If the request get parameters contains 'popup' then
the `render_type` is set to 'popup'. | [
"Renders",
"this",
"view",
".",
"Adds",
"cancel_url",
"to",
"the",
"context",
".",
"If",
"the",
"request",
"get",
"parameters",
"contains",
"popup",
"then",
"the",
"render_type",
"is",
"set",
"to",
"popup",
"."
] | python | train |
nickmckay/LiPD-utilities | Python/lipd/misc.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/misc.py#L522-L532 | def print_filename(path):
"""
Print out lipd filename that is being read or written
:param str path: all file metadata
:return str: filename
"""
if os.path.basename(path):
return os.path.basename(path)
return path | [
"def",
"print_filename",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"return",
"path"
] | Print out lipd filename that is being read or written
:param str path: all file metadata
:return str: filename | [
"Print",
"out",
"lipd",
"filename",
"that",
"is",
"being",
"read",
"or",
"written"
] | python | train |
nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L281-L323 | def search_service_code(self, service_index):
"""Search for a service code that corresponds to an index.
The Search Service Code command provides access to the
iterable list of services and areas within the activated
system. The *service_index* argument may be any value from 0
t... | [
"def",
"search_service_code",
"(",
"self",
",",
"service_index",
")",
":",
"log",
".",
"debug",
"(",
"\"search service code index {0}\"",
".",
"format",
"(",
"service_index",
")",
")",
"# The maximum response time is given by the value of PMM[3].",
"# Some cards (like RC-S860... | Search for a service code that corresponds to an index.
The Search Service Code command provides access to the
iterable list of services and areas within the activated
system. The *service_index* argument may be any value from 0
to 0xffff. As long as there is a service or area found for... | [
"Search",
"for",
"a",
"service",
"code",
"that",
"corresponds",
"to",
"an",
"index",
"."
] | python | train |
tanghaibao/jcvi | jcvi/assembly/postprocess.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/postprocess.py#L149-L174 | def dust(args):
"""
%prog dust assembly.fasta
Remove low-complexity contigs within assembly.
"""
p = OptionParser(dust.__doc__)
opts, args = p.parse_args(args)
if len(args) != 1:
sys.exit(not p.print_help())
fastafile, = args
dustfastafile = fastafile.rsplit(".", 1)[0] + "... | [
"def",
"dust",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"dust",
".",
"__doc__",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"sys",
".",
"exit",
"(",
"not",... | %prog dust assembly.fasta
Remove low-complexity contigs within assembly. | [
"%prog",
"dust",
"assembly",
".",
"fasta"
] | python | train |
SHTOOLS/SHTOOLS | pyshtools/shclasses/shcoeffsgrid.py | https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shcoeffsgrid.py#L3038-L3113 | def _plot(self, xticks=[], yticks=[], minor_xticks=[], minor_yticks=[],
xlabel='Longitude', ylabel='Latitude', ax=None, ax2=None,
colorbar=None, cb_label=None, cb_orientation=None, grid=False,
axes_labelsize=None, tick_labelsize=None, **kwargs):
"""Plot the raw data usi... | [
"def",
"_plot",
"(",
"self",
",",
"xticks",
"=",
"[",
"]",
",",
"yticks",
"=",
"[",
"]",
",",
"minor_xticks",
"=",
"[",
"]",
",",
"minor_yticks",
"=",
"[",
"]",
",",
"xlabel",
"=",
"'Longitude'",
",",
"ylabel",
"=",
"'Latitude'",
",",
"ax",
"=",
... | Plot the raw data using a simply cylindrical projection. | [
"Plot",
"the",
"raw",
"data",
"using",
"a",
"simply",
"cylindrical",
"projection",
"."
] | python | train |
RedHatInsights/insights-core | insights/client/__init__.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/__init__.py#L134-L193 | def _fetch(self, path, etag_file, target_path, force):
"""
returns (str): path to new egg. None if no update.
"""
url = self.connection.base_url + path
# Searched for cached etag information
current_etag = None
if os.path.isfile(etag_file):
with op... | [
"def",
"_fetch",
"(",
"self",
",",
"path",
",",
"etag_file",
",",
"target_path",
",",
"force",
")",
":",
"url",
"=",
"self",
".",
"connection",
".",
"base_url",
"+",
"path",
"# Searched for cached etag information",
"current_etag",
"=",
"None",
"if",
"os",
"... | returns (str): path to new egg. None if no update. | [
"returns",
"(",
"str",
")",
":",
"path",
"to",
"new",
"egg",
".",
"None",
"if",
"no",
"update",
"."
] | python | train |
rgs1/zk_shell | zk_shell/xclient.py | https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/xclient.py#L463-L479 | def dump_by_server(self, hosts):
"""Returns the output of dump for each server.
:param hosts: comma separated lists of members of the ZK ensemble.
:returns: A dictionary of ((server_ip, port), ClientInfo).
"""
dump_by_endpoint = {}
for endpoint in self._to_endpoints(ho... | [
"def",
"dump_by_server",
"(",
"self",
",",
"hosts",
")",
":",
"dump_by_endpoint",
"=",
"{",
"}",
"for",
"endpoint",
"in",
"self",
".",
"_to_endpoints",
"(",
"hosts",
")",
":",
"try",
":",
"out",
"=",
"self",
".",
"cmd",
"(",
"[",
"endpoint",
"]",
","... | Returns the output of dump for each server.
:param hosts: comma separated lists of members of the ZK ensemble.
:returns: A dictionary of ((server_ip, port), ClientInfo). | [
"Returns",
"the",
"output",
"of",
"dump",
"for",
"each",
"server",
"."
] | python | train |
tweepy/tweepy | tweepy/cache.py | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L326-L340 | def store(self, key, value):
"""Store the key, value pair in our redis server"""
# Prepend tweepy to our key,
# this makes it easier to identify tweepy keys in our redis server
key = self.pre_identifier + key
# Get a pipe (to execute several redis commands in one step)
pi... | [
"def",
"store",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# Prepend tweepy to our key,",
"# this makes it easier to identify tweepy keys in our redis server",
"key",
"=",
"self",
".",
"pre_identifier",
"+",
"key",
"# Get a pipe (to execute several redis commands in one ... | Store the key, value pair in our redis server | [
"Store",
"the",
"key",
"value",
"pair",
"in",
"our",
"redis",
"server"
] | python | train |
by46/simplekit | simplekit/docker/utils.py | https://github.com/by46/simplekit/blob/33f3ce6de33accc185e1057f096af41859db5976/simplekit/docker/utils.py#L48-L66 | def parse_image_name(name):
"""
parse the image name into three element tuple, like below:
(repository, name, version)
:param name: `class`:`str`, name
:return: (repository, name, version)
"""
name = name or ""
if '/' in name:
repository, other = name.split('/')
els... | [
"def",
"parse_image_name",
"(",
"name",
")",
":",
"name",
"=",
"name",
"or",
"\"\"",
"if",
"'/'",
"in",
"name",
":",
"repository",
",",
"other",
"=",
"name",
".",
"split",
"(",
"'/'",
")",
"else",
":",
"repository",
",",
"other",
"=",
"None",
",",
... | parse the image name into three element tuple, like below:
(repository, name, version)
:param name: `class`:`str`, name
:return: (repository, name, version) | [
"parse",
"the",
"image",
"name",
"into",
"three",
"element",
"tuple",
"like",
"below",
":",
"(",
"repository",
"name",
"version",
")",
":",
"param",
"name",
":",
"class",
":",
"str",
"name",
":",
"return",
":",
"(",
"repository",
"name",
"version",
")"
] | python | train |
vijayvarma392/surfinBH | surfinBH/_lal_spin_evolution.py | https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_lal_spin_evolution.py#L158-L211 | def evolve_pn_spins(q, chiA0, chiB0, omega0, omegaTimesM_final,
approximant='SpinTaylorT4', dt=0.1, spinO=7, phaseO=7):
""" Evolves PN spins from a starting orbital frequency and spins to a final
frequency.
Inputs:
q: Mass ratio (q>=1)
chiA0: Dimless sp... | [
"def",
"evolve_pn_spins",
"(",
"q",
",",
"chiA0",
",",
"chiB0",
",",
"omega0",
",",
"omegaTimesM_final",
",",
"approximant",
"=",
"'SpinTaylorT4'",
",",
"dt",
"=",
"0.1",
",",
"spinO",
"=",
"7",
",",
"phaseO",
"=",
"7",
")",
":",
"omega",
",",
"phi",
... | Evolves PN spins from a starting orbital frequency and spins to a final
frequency.
Inputs:
q: Mass ratio (q>=1)
chiA0: Dimless spin of BhA at initial freq.
chiB0: Dimless spin of BhB at initial freq.
omega0: Initial orbital freque... | [
"Evolves",
"PN",
"spins",
"from",
"a",
"starting",
"orbital",
"frequency",
"and",
"spins",
"to",
"a",
"final",
"frequency",
"."
] | python | train |
kodexlab/reliure | reliure/utils/log.py | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/utils/log.py#L20-L33 | def get_basic_logger(level=logging.WARN, scope='reliure'):
""" return a basic logger that print on stdout msg from reliure lib
"""
logger = logging.getLogger(scope)
logger.setLevel(level)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(level)
# c... | [
"def",
"get_basic_logger",
"(",
"level",
"=",
"logging",
".",
"WARN",
",",
"scope",
"=",
"'reliure'",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"scope",
")",
"logger",
".",
"setLevel",
"(",
"level",
")",
"# create console handler with a higher... | return a basic logger that print on stdout msg from reliure lib | [
"return",
"a",
"basic",
"logger",
"that",
"print",
"on",
"stdout",
"msg",
"from",
"reliure",
"lib"
] | python | train |
inasafe/inasafe | safe/metadata/base_metadata.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/base_metadata.py#L531-L565 | def set(self, name, value, xml_path):
"""
Create a new metadata property.
The accepted type depends on the property type which is determined
by the xml_path
:param name: the name of the property
:type name: str
:param value: the value of the property
:ty... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
",",
"xml_path",
")",
":",
"xml_type",
"=",
"xml_path",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"# check if the desired type is supported",
"try",
":",
"property_class",
"=",
"TYPE_CONVERSIONS"... | Create a new metadata property.
The accepted type depends on the property type which is determined
by the xml_path
:param name: the name of the property
:type name: str
:param value: the value of the property
:type value:
:param xml_path: the xml path where the ... | [
"Create",
"a",
"new",
"metadata",
"property",
"."
] | python | train |
SuperCowPowers/bat | bat/utils/cache.py | https://github.com/SuperCowPowers/bat/blob/069e6bc52843dc07760969c531cc442ca7da8e0c/bat/utils/cache.py#L66-L75 | def _check_limit(self):
"""Intenal method: check if current cache size exceeds maximum cache
size and pop the oldest item in this case"""
# First compress
self._compress()
# Then check the max size
if len(self._store) >= self._max_size:
self._store.popite... | [
"def",
"_check_limit",
"(",
"self",
")",
":",
"# First compress",
"self",
".",
"_compress",
"(",
")",
"# Then check the max size",
"if",
"len",
"(",
"self",
".",
"_store",
")",
">=",
"self",
".",
"_max_size",
":",
"self",
".",
"_store",
".",
"popitem",
"("... | Intenal method: check if current cache size exceeds maximum cache
size and pop the oldest item in this case | [
"Intenal",
"method",
":",
"check",
"if",
"current",
"cache",
"size",
"exceeds",
"maximum",
"cache",
"size",
"and",
"pop",
"the",
"oldest",
"item",
"in",
"this",
"case"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/docbook/__init__.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/docbook/__init__.py#L221-L272 | def __xml_scan(node, env, path, arg):
""" Simple XML file scanner, detecting local images and XIncludes as implicit dependencies. """
# Does the node exist yet?
if not os.path.isfile(str(node)):
return []
if env.get('DOCBOOK_SCANENT',''):
# Use simple pattern matching for system ent... | [
"def",
"__xml_scan",
"(",
"node",
",",
"env",
",",
"path",
",",
"arg",
")",
":",
"# Does the node exist yet?",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"str",
"(",
"node",
")",
")",
":",
"return",
"[",
"]",
"if",
"env",
".",
"get",
"(",
... | Simple XML file scanner, detecting local images and XIncludes as implicit dependencies. | [
"Simple",
"XML",
"file",
"scanner",
"detecting",
"local",
"images",
"and",
"XIncludes",
"as",
"implicit",
"dependencies",
"."
] | python | train |
fredericklussier/TinyPeriodicTask | tinyPeriodicTask/TinyPeriodicTask.py | https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L172-L179 | def useThis(self, *args, **kwargs):
"""
Change parameter of the callback function.
:param *args, **kwargs: parameter(s) to use when executing the
callback function.
"""
self._callback = functools.partial(self._callback, *args, **kwargs) | [
"def",
"useThis",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_callback",
"=",
"functools",
".",
"partial",
"(",
"self",
".",
"_callback",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Change parameter of the callback function.
:param *args, **kwargs: parameter(s) to use when executing the
callback function. | [
"Change",
"parameter",
"of",
"the",
"callback",
"function",
"."
] | python | train |
tensorflow/mesh | mesh_tensorflow/layers.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/layers.py#L963-L989 | def attention_bias_local_block(mesh, block_length, memory_length,
dtype=tf.int32):
"""Bias for attention for local blocks where attention to right is disallowed.
Create the bias matrix by using two separate masks, one for the memory part
which doesn't overlap with the query and sec... | [
"def",
"attention_bias_local_block",
"(",
"mesh",
",",
"block_length",
",",
"memory_length",
",",
"dtype",
"=",
"tf",
".",
"int32",
")",
":",
"memory_length",
"=",
"mtf",
".",
"Dimension",
"(",
"memory_length",
".",
"name",
",",
"block_length",
".",
"size",
... | Bias for attention for local blocks where attention to right is disallowed.
Create the bias matrix by using two separate masks, one for the memory part
which doesn't overlap with the query and second which interacts with the query
and should be disallowed to look to the right of the current query position.
Ar... | [
"Bias",
"for",
"attention",
"for",
"local",
"blocks",
"where",
"attention",
"to",
"right",
"is",
"disallowed",
"."
] | python | train |
kstaniek/condoor | condoor/device.py | https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L476-L480 | def reload(self, reload_timeout, save_config, no_reload_cmd):
"""Reload device."""
if not no_reload_cmd:
self.ctrl.send_command(self.driver.reload_cmd)
return self.driver.reload(reload_timeout, save_config) | [
"def",
"reload",
"(",
"self",
",",
"reload_timeout",
",",
"save_config",
",",
"no_reload_cmd",
")",
":",
"if",
"not",
"no_reload_cmd",
":",
"self",
".",
"ctrl",
".",
"send_command",
"(",
"self",
".",
"driver",
".",
"reload_cmd",
")",
"return",
"self",
".",... | Reload device. | [
"Reload",
"device",
"."
] | python | train |
aiogram/aiogram | aiogram/bot/bot.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L809-L848 | async def send_contact(self, chat_id: typing.Union[base.Integer, base.String],
phone_number: base.String, first_name: base.String,
last_name: typing.Union[base.String, None] = None,
vcard: typing.Union[base.String, None] = None,
... | [
"async",
"def",
"send_contact",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
",",
"phone_number",
":",
"base",
".",
"String",
",",
"first_name",
":",
"base",
".",
"String",
",",... | Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
:param chat_id: Unique identifier for the target chat or username of the target channel
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:param phone_number: Contact's phone numb... | [
"Use",
"this",
"method",
"to",
"send",
"phone",
"contacts",
"."
] | python | train |
StanfordBioinformatics/loom | utils/loomengine_utils/connection.py | https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/connection.py#L108-L134 | def _make_request_to_server(self, query_function, raise_for_status=True,
time_limit_seconds=2, retry_delay_seconds=0.2):
"""Retry sending request until timeout or until receiving a response.
"""
start_time = datetime.datetime.now()
while datetime.datetime.... | [
"def",
"_make_request_to_server",
"(",
"self",
",",
"query_function",
",",
"raise_for_status",
"=",
"True",
",",
"time_limit_seconds",
"=",
"2",
",",
"retry_delay_seconds",
"=",
"0.2",
")",
":",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
... | Retry sending request until timeout or until receiving a response. | [
"Retry",
"sending",
"request",
"until",
"timeout",
"or",
"until",
"receiving",
"a",
"response",
"."
] | python | train |
nrcharles/caelum | caelum/forecast.py | https://github.com/nrcharles/caelum/blob/9a8e65806385978556d7bb2e6870f003ff82023e/caelum/forecast.py#L44-L55 | def hourly(place):
"""return data as list of dicts with all data filled in."""
# time in utc?
lat, lon = place
url = "https://api.forecast.io/forecast/%s/%s,%s?solar" % (APIKEY, lat,
lon)
w_data = json.loads(urllib2.urlopen(url).read())
... | [
"def",
"hourly",
"(",
"place",
")",
":",
"# time in utc?",
"lat",
",",
"lon",
"=",
"place",
"url",
"=",
"\"https://api.forecast.io/forecast/%s/%s,%s?solar\"",
"%",
"(",
"APIKEY",
",",
"lat",
",",
"lon",
")",
"w_data",
"=",
"json",
".",
"loads",
"(",
"urllib2... | return data as list of dicts with all data filled in. | [
"return",
"data",
"as",
"list",
"of",
"dicts",
"with",
"all",
"data",
"filled",
"in",
"."
] | python | train |
myint/rstcheck | rstcheck.py | https://github.com/myint/rstcheck/blob/2f975906b75f3b88d501ef3b13d213815cf7079a/rstcheck.py#L107-L117 | def run(self):
"""Run directive."""
try:
language = self.arguments[0]
except IndexError:
language = ''
code = '\n'.join(self.content)
literal = docutils.nodes.literal_block(code, code)
literal['classes'].append('code-block')
literal['langua... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"language",
"=",
"self",
".",
"arguments",
"[",
"0",
"]",
"except",
"IndexError",
":",
"language",
"=",
"''",
"code",
"=",
"'\\n'",
".",
"join",
"(",
"self",
".",
"content",
")",
"literal",
"=",
"doc... | Run directive. | [
"Run",
"directive",
"."
] | python | train |
rambleraptor/amusement | amusement/parks/universal/UniversalPark.py | https://github.com/rambleraptor/amusement/blob/ec850035747a5b0549f9ea2ee4399bff035460be/amusement/parks/universal/UniversalPark.py#L34-L46 | def _buildPark(self):
token = self._get_token()
ride_page = self._get_request(token, self.getUrl())
show_page = self._get_request(token, SHOW_URL)
for ride in ride_page['Results']:
if ride['VenueId'] == self.getId():
self._make_attraction(ride)
"""
... | [
"def",
"_buildPark",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"_get_token",
"(",
")",
"ride_page",
"=",
"self",
".",
"_get_request",
"(",
"token",
",",
"self",
".",
"getUrl",
"(",
")",
")",
"show_page",
"=",
"self",
".",
"_get_request",
"(",
... | for show in page['Shows']:
if show['VenueId'] == self.getId():
self._make_show(show) | [
"for",
"show",
"in",
"page",
"[",
"Shows",
"]",
":",
"if",
"show",
"[",
"VenueId",
"]",
"==",
"self",
".",
"getId",
"()",
":",
"self",
".",
"_make_show",
"(",
"show",
")"
] | python | train |
DarkEnergySurvey/ugali | ugali/utils/stats.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L286-L292 | def mean_interval(self, name, alpha=_alpha, **kwargs):
"""
Interval assuming gaussian posterior.
"""
data = self.get(name,**kwargs)
#return ugali.utils.stats.mean_interval(data,alpha)
return mean_interval(data,alpha) | [
"def",
"mean_interval",
"(",
"self",
",",
"name",
",",
"alpha",
"=",
"_alpha",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"#return ugali.utils.stats.mean_interval(data,alpha)",
"return",
"... | Interval assuming gaussian posterior. | [
"Interval",
"assuming",
"gaussian",
"posterior",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v7_2_0/event_handler/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v7_2_0/event_handler/__init__.py#L94-L115 | def _set_event_handler_list(self, v, load=False):
"""
Setter method for event_handler_list, mapped from YANG variable /event_handler/event_handler_list (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_event_handler_list is considered as a private
method. Backen... | [
"def",
"_set_event_handler_list",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
","... | Setter method for event_handler_list, mapped from YANG variable /event_handler/event_handler_list (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_event_handler_list is considered as a private
method. Backends looking to populate this variable should
do so via call... | [
"Setter",
"method",
"for",
"event_handler_list",
"mapped",
"from",
"YANG",
"variable",
"/",
"event_handler",
"/",
"event_handler_list",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"sou... | python | train |
ActivisionGameScience/assertpy | assertpy/assertpy.py | https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L231-L244 | def is_instance_of(self, some_class):
"""Asserts that val is an instance of the given class."""
try:
if not isinstance(self.val, some_class):
if hasattr(self.val, '__name__'):
t = self.val.__name__
elif hasattr(self.val, '__class__'):
... | [
"def",
"is_instance_of",
"(",
"self",
",",
"some_class",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"val",
",",
"some_class",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"val",
",",
"'__name__'",
")",
":",
"t",
"=",
"self",
... | Asserts that val is an instance of the given class. | [
"Asserts",
"that",
"val",
"is",
"an",
"instance",
"of",
"the",
"given",
"class",
"."
] | python | valid |
reingart/pyafipws | wslum.py | https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wslum.py#L544-L574 | def ConsultarBonificacionesPenalizaciones(self, sep="||"):
"Retorna un listado de bonificaciones/penalizaciones con código y descripción"
ret = self.client.consultarBonificacionesPenalizaciones(
auth={
'token': self.Token, 'sign': self.Sign,
... | [
"def",
"ConsultarBonificacionesPenalizaciones",
"(",
"self",
",",
"sep",
"=",
"\"||\"",
")",
":",
"ret",
"=",
"self",
".",
"client",
".",
"consultarBonificacionesPenalizaciones",
"(",
"auth",
"=",
"{",
"'token'",
":",
"self",
".",
"Token",
",",
"'sign'",
":",
... | Retorna un listado de bonificaciones/penalizaciones con código y descripción | [
"Retorna",
"un",
"listado",
"de",
"bonificaciones",
"/",
"penalizaciones",
"con",
"código",
"y",
"descripción"
] | python | train |
goose3/goose3 | goose3/extractors/videos.py | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/videos.py#L67-L78 | def get_video(self, node):
"""
Create a video object from a video embed
"""
video = Video()
video._embed_code = self.get_embed_code(node)
video._embed_type = self.get_embed_type(node)
video._width = self.get_width(node)
video._height = self.get_height(node... | [
"def",
"get_video",
"(",
"self",
",",
"node",
")",
":",
"video",
"=",
"Video",
"(",
")",
"video",
".",
"_embed_code",
"=",
"self",
".",
"get_embed_code",
"(",
"node",
")",
"video",
".",
"_embed_type",
"=",
"self",
".",
"get_embed_type",
"(",
"node",
")... | Create a video object from a video embed | [
"Create",
"a",
"video",
"object",
"from",
"a",
"video",
"embed"
] | python | valid |
pandas-dev/pandas | pandas/core/sorting.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L406-L507 | def safe_sort(values, labels=None, na_sentinel=-1, assume_unique=False):
"""
Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
-... | [
"def",
"safe_sort",
"(",
"values",
",",
"labels",
"=",
"None",
",",
"na_sentinel",
"=",
"-",
"1",
",",
"assume_unique",
"=",
"False",
")",
":",
"if",
"not",
"is_list_like",
"(",
"values",
")",
":",
"raise",
"TypeError",
"(",
"\"Only list-like objects are all... | Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
----------
values : list-like
Sequence; must be unique if ``labels`` is no... | [
"Sort",
"values",
"and",
"reorder",
"corresponding",
"labels",
".",
"values",
"should",
"be",
"unique",
"if",
"labels",
"is",
"not",
"None",
".",
"Safe",
"for",
"use",
"with",
"mixed",
"types",
"(",
"int",
"str",
")",
"orders",
"ints",
"before",
"strs",
... | python | train |
rackerlabs/rackspace-python-neutronclient | neutronclient/v2_0/client.py | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L1598-L1601 | def update_bandwidth_limit_rule(self, rule, policy, body=None):
"""Updates a bandwidth limit rule."""
return self.put(self.qos_bandwidth_limit_rule_path %
(policy, rule), body=body) | [
"def",
"update_bandwidth_limit_rule",
"(",
"self",
",",
"rule",
",",
"policy",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"put",
"(",
"self",
".",
"qos_bandwidth_limit_rule_path",
"%",
"(",
"policy",
",",
"rule",
")",
",",
"body",
"=",
"b... | Updates a bandwidth limit rule. | [
"Updates",
"a",
"bandwidth",
"limit",
"rule",
"."
] | python | train |
ray-project/ray | python/ray/tune/ray_trial_executor.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L188-L221 | def start_trial(self, trial, checkpoint=None):
"""Starts the trial.
Will not return resources if trial repeatedly fails on start.
Args:
trial (Trial): Trial to be started.
checkpoint (Checkpoint): A Python object or path storing the state
of trial.
... | [
"def",
"start_trial",
"(",
"self",
",",
"trial",
",",
"checkpoint",
"=",
"None",
")",
":",
"self",
".",
"_commit_resources",
"(",
"trial",
".",
"resources",
")",
"try",
":",
"self",
".",
"_start_trial",
"(",
"trial",
",",
"checkpoint",
")",
"except",
"Ex... | Starts the trial.
Will not return resources if trial repeatedly fails on start.
Args:
trial (Trial): Trial to be started.
checkpoint (Checkpoint): A Python object or path storing the state
of trial. | [
"Starts",
"the",
"trial",
"."
] | python | train |
gagneurlab/concise | concise/layers.py | https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L73-L78 | def InputSplines(seq_length, n_bases=10, name=None, **kwargs):
"""Input placeholder for array returned by `encodeSplines`
Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)`
"""
return Input((seq_length, n_bases), name=name, **kwargs) | [
"def",
"InputSplines",
"(",
"seq_length",
",",
"n_bases",
"=",
"10",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Input",
"(",
"(",
"seq_length",
",",
"n_bases",
")",
",",
"name",
"=",
"name",
",",
"*",
"*",
"kwargs",
")"... | Input placeholder for array returned by `encodeSplines`
Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)` | [
"Input",
"placeholder",
"for",
"array",
"returned",
"by",
"encodeSplines"
] | python | train |
atlassian-api/atlassian-python-api | atlassian/confluence.py | https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/confluence.py#L330-L372 | def attach_file(self, filename, page_id=None, title=None, space=None, comment=None):
"""
Attach (upload) a file to a page, if it exists it will update the
automatically version the new file and keep the old one.
:param title: The page name
:type title: ``str``
:param spa... | [
"def",
"attach_file",
"(",
"self",
",",
"filename",
",",
"page_id",
"=",
"None",
",",
"title",
"=",
"None",
",",
"space",
"=",
"None",
",",
"comment",
"=",
"None",
")",
":",
"page_id",
"=",
"self",
".",
"get_page_id",
"(",
"space",
"=",
"space",
",",... | Attach (upload) a file to a page, if it exists it will update the
automatically version the new file and keep the old one.
:param title: The page name
:type title: ``str``
:param space: The space name
:type space: ``str``
:param page_id: The page id to which we would li... | [
"Attach",
"(",
"upload",
")",
"a",
"file",
"to",
"a",
"page",
"if",
"it",
"exists",
"it",
"will",
"update",
"the",
"automatically",
"version",
"the",
"new",
"file",
"and",
"keep",
"the",
"old",
"one",
".",
":",
"param",
"title",
":",
"The",
"page",
"... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.