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 |
|---|---|---|---|---|---|---|---|---|
cocagne/txdbus | txdbus/objects.py | https://github.com/cocagne/txdbus/blob/eb424918764b7b93eecd2a4e2e5c2d0b2944407b/txdbus/objects.py#L898-L984 | def getRemoteObject(self, busName, objectPath, interfaces=None,
replaceKnownInterfaces=False):
"""
Creates a L{RemoteDBusObject} instance to represent the
specified DBus object. If explicit interfaces are not
supplied, DBus object introspection will be used to ob... | [
"def",
"getRemoteObject",
"(",
"self",
",",
"busName",
",",
"objectPath",
",",
"interfaces",
"=",
"None",
",",
"replaceKnownInterfaces",
"=",
"False",
")",
":",
"weak_id",
"=",
"(",
"busName",
",",
"objectPath",
",",
"interfaces",
")",
"need_introspection",
"=... | Creates a L{RemoteDBusObject} instance to represent the
specified DBus object. If explicit interfaces are not
supplied, DBus object introspection will be used to obtain
them automatically.
@type busName: C{string}
@param busName: Name of the bus exporting the desired object
... | [
"Creates",
"a",
"L",
"{",
"RemoteDBusObject",
"}",
"instance",
"to",
"represent",
"the",
"specified",
"DBus",
"object",
".",
"If",
"explicit",
"interfaces",
"are",
"not",
"supplied",
"DBus",
"object",
"introspection",
"will",
"be",
"used",
"to",
"obtain",
"the... | python | train |
ckan/ckan-service-provider | ckanserviceprovider/db.py | https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L98-L179 | def get_job(job_id):
"""Return the job with the given job_id as a dict.
The dict also includes any metadata or logs associated with the job.
Returns None instead of a dict if there's no job with the given job_id.
The keys of a job dict are:
"job_id": The unique identifier for the job (unicode)
... | [
"def",
"get_job",
"(",
"job_id",
")",
":",
"# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"",
"# warnings.",
"if",
"job_id",
":",
"job_id",
"=",
"unicode",
"(",
"job_id",
")",
"result",
"=",
"ENGINE",
".",
"execute",
"(",
"JOBS_TABLE",
".",
... | Return the job with the given job_id as a dict.
The dict also includes any metadata or logs associated with the job.
Returns None instead of a dict if there's no job with the given job_id.
The keys of a job dict are:
"job_id": The unique identifier for the job (unicode)
"job_type": The name of ... | [
"Return",
"the",
"job",
"with",
"the",
"given",
"job_id",
"as",
"a",
"dict",
"."
] | python | train |
KE-works/pykechain | pykechain/models/customization.py | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L825-L896 | def add_attachment_viewer_widget(self, attachment_property, custom_title=False, height=None):
"""
Add a KE-chain Attachment Viewer (e.g. attachment viewer widget) to the customization.
The widget will be saved to KE-chain.
:param attachment_property: The Attachment Property to which th... | [
"def",
"add_attachment_viewer_widget",
"(",
"self",
",",
"attachment_property",
",",
"custom_title",
"=",
"False",
",",
"height",
"=",
"None",
")",
":",
"# Check whether the attachment property is uuid type or class `Property`",
"if",
"isinstance",
"(",
"attachment_property",... | Add a KE-chain Attachment Viewer (e.g. attachment viewer widget) to the customization.
The widget will be saved to KE-chain.
:param attachment_property: The Attachment Property to which the Viewer will be connected to.
:type attachment_property: :class:`Property` or UUID
:param custom_... | [
"Add",
"a",
"KE",
"-",
"chain",
"Attachment",
"Viewer",
"(",
"e",
".",
"g",
".",
"attachment",
"viewer",
"widget",
")",
"to",
"the",
"customization",
"."
] | python | train |
mobinrg/rpi_spark_drives | JMRPiSpark/Drives/Screen/SSPILScreen.py | https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Screen/SSPILScreen.py#L139-L157 | def clearView(self, fillColor = 0 ):
"""!
\~english
Clear up canvas with view size
@param fillColor: a color value
@note
The fillColor value range depends on the setting of _buffer_color_mode.
* If it is SS_COLOR_MODE_MONO ("1") monochrome mode, it can on... | [
"def",
"clearView",
"(",
"self",
",",
"fillColor",
"=",
"0",
")",
":",
"self",
".",
"Canvas",
".",
"rectangle",
"(",
"self",
".",
"View",
".",
"rectToArray",
"(",
")",
",",
"outline",
"=",
"0",
",",
"fill",
"=",
"fillColor",
")"
] | !
\~english
Clear up canvas with view size
@param fillColor: a color value
@note
The fillColor value range depends on the setting of _buffer_color_mode.
* If it is SS_COLOR_MODE_MONO ("1") monochrome mode, it can only select 0: black and 1: white
* If... | [
"!",
"\\",
"~english",
"Clear",
"up",
"canvas",
"with",
"view",
"size",
"@param",
"fillColor",
":",
"a",
"color",
"value",
"@note",
"The",
"fillColor",
"value",
"range",
"depends",
"on",
"the",
"setting",
"of",
"_buffer_color_mode",
".",
"*",
"If",
"it",
"... | python | train |
scanny/python-pptx | pptx/chart/xmlwriter.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/xmlwriter.py#L1524-L1548 | def _lvl_xml(self, categories):
"""
The unicode XML snippet for the ``<c:lvl>`` elements containing
multi-level category names.
"""
def lvl_pt_xml(level):
xml = ''
for idx, name in level:
xml += (
' <c:p... | [
"def",
"_lvl_xml",
"(",
"self",
",",
"categories",
")",
":",
"def",
"lvl_pt_xml",
"(",
"level",
")",
":",
"xml",
"=",
"''",
"for",
"idx",
",",
"name",
"in",
"level",
":",
"xml",
"+=",
"(",
"' <c:pt idx=\"%d\">\\n'",
"' <c:v>... | The unicode XML snippet for the ``<c:lvl>`` elements containing
multi-level category names. | [
"The",
"unicode",
"XML",
"snippet",
"for",
"the",
"<c",
":",
"lvl",
">",
"elements",
"containing",
"multi",
"-",
"level",
"category",
"names",
"."
] | python | train |
ihgazni2/elist | elist/elist.py | https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2666-L2714 | def pop_range(ol,start_index,end_index,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_range(ol,2,4)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
r... | [
"def",
"pop_range",
"(",
"ol",
",",
"start_index",
",",
"end_index",
",",
"*",
"*",
"kwargs",
")",
":",
"length",
"=",
"ol",
".",
"__len__",
"(",
")",
"start_index",
"=",
"uniform_index",
"(",
"start_index",
",",
"length",
")",
"end_index",
"=",
"uniform... | from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_range(ol,2,4)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_range(ol,2,4,mode="original")
rslt
ol
... | [
"from",
"elist",
".",
"jprint",
"import",
"pobj",
"from",
"elist",
".",
"elist",
"import",
"*",
"ol",
"=",
"[",
"1",
"2",
"3",
"4",
"5",
"6",
"]",
"id",
"(",
"ol",
")",
"rslt",
"=",
"pop_range",
"(",
"ol",
"2",
"4",
")",
"ol",
"id",
"(",
"ol"... | python | valid |
splunk/splunk-sdk-python | splunklib/modularinput/event_writer.py | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/event_writer.py#L74-L81 | def write_xml_document(self, document):
"""Writes a string representation of an
``ElementTree`` object to the output stream.
:param document: An ``ElementTree`` object.
"""
self._out.write(ET.tostring(document))
self._out.flush() | [
"def",
"write_xml_document",
"(",
"self",
",",
"document",
")",
":",
"self",
".",
"_out",
".",
"write",
"(",
"ET",
".",
"tostring",
"(",
"document",
")",
")",
"self",
".",
"_out",
".",
"flush",
"(",
")"
] | Writes a string representation of an
``ElementTree`` object to the output stream.
:param document: An ``ElementTree`` object. | [
"Writes",
"a",
"string",
"representation",
"of",
"an",
"ElementTree",
"object",
"to",
"the",
"output",
"stream",
"."
] | python | train |
theosysbio/means | src/means/util/sympyhelpers.py | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/util/sympyhelpers.py#L63-L87 | def to_sympy_matrix(value):
"""
Converts value to a `sympy.Matrix` object, if possible.
Leaves the value as `sympy.Matrix` if it already was
:param value: value to convert
:return:
:rtype: `sympy.Matrix`
"""
if isinstance(value, sympy.Matrix):
return value
try:
return... | [
"def",
"to_sympy_matrix",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"sympy",
".",
"Matrix",
")",
":",
"return",
"value",
"try",
":",
"return",
"sympy",
".",
"Matrix",
"(",
"value",
")",
"except",
"ValueError",
"as",
"original_exception... | Converts value to a `sympy.Matrix` object, if possible.
Leaves the value as `sympy.Matrix` if it already was
:param value: value to convert
:return:
:rtype: `sympy.Matrix` | [
"Converts",
"value",
"to",
"a",
"sympy",
".",
"Matrix",
"object",
"if",
"possible",
".",
"Leaves",
"the",
"value",
"as",
"sympy",
".",
"Matrix",
"if",
"it",
"already",
"was",
":",
"param",
"value",
":",
"value",
"to",
"convert",
":",
"return",
":",
":"... | python | train |
manns/pyspread | pyspread/src/lib/_grid_cairo_renderer.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/_grid_cairo_renderer.py#L1080-L1094 | def get_above_right_key_rect(self):
"""Returns tuple key rect of above right cell"""
key_above = self.row - 1, self.col, self.tab
key_above_right = self.row - 1, self.col + 1, self.tab
border_width_right = \
float(self.cell_attributes[key_above]["borderwidth_right"]) / 2.0
... | [
"def",
"get_above_right_key_rect",
"(",
"self",
")",
":",
"key_above",
"=",
"self",
".",
"row",
"-",
"1",
",",
"self",
".",
"col",
",",
"self",
".",
"tab",
"key_above_right",
"=",
"self",
".",
"row",
"-",
"1",
",",
"self",
".",
"col",
"+",
"1",
","... | Returns tuple key rect of above right cell | [
"Returns",
"tuple",
"key",
"rect",
"of",
"above",
"right",
"cell"
] | python | train |
Microsoft/knack | knack/cli.py | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L122-L126 | def show_version(self):
""" Print version information to the out file. """
version_info = self.get_cli_version()
version_info += self.get_runtime_version()
print(version_info, file=self.out_file) | [
"def",
"show_version",
"(",
"self",
")",
":",
"version_info",
"=",
"self",
".",
"get_cli_version",
"(",
")",
"version_info",
"+=",
"self",
".",
"get_runtime_version",
"(",
")",
"print",
"(",
"version_info",
",",
"file",
"=",
"self",
".",
"out_file",
")"
] | Print version information to the out file. | [
"Print",
"version",
"information",
"to",
"the",
"out",
"file",
"."
] | python | train |
mardiros/pyshop | pyshop/models.py | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L113-L126 | def by_name(cls, session, name):
"""
Get a package from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the group
:type name: `unicode
:return: package instance
:rtype: :class:`pyshop.mode... | [
"def",
"by_name",
"(",
"cls",
",",
"session",
",",
"name",
")",
":",
"return",
"cls",
".",
"first",
"(",
"session",
",",
"where",
"=",
"(",
"cls",
".",
"name",
"==",
"name",
",",
")",
")"
] | Get a package from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the group
:type name: `unicode
:return: package instance
:rtype: :class:`pyshop.models.Group` | [
"Get",
"a",
"package",
"from",
"a",
"given",
"name",
"."
] | python | train |
spacetelescope/pysynphot | pysynphot/observation.py | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L607-L643 | def efflam(self,binned=True):
"""Calculate :ref:`effective wavelength <pysynphot-formula-efflam>`
of the observation.
Calculation is done in the flux unit of ``flam``.
.. note::
Similar to IRAF STSDAS SYNPHOT ``efflphot`` task.
Parameters
----------
... | [
"def",
"efflam",
"(",
"self",
",",
"binned",
"=",
"True",
")",
":",
"myfluxunits",
"=",
"self",
".",
"fluxunits",
".",
"name",
"self",
".",
"convert",
"(",
"'flam'",
")",
"if",
"binned",
":",
"wave",
"=",
"self",
".",
"binwave",
"flux",
"=",
"self",
... | Calculate :ref:`effective wavelength <pysynphot-formula-efflam>`
of the observation.
Calculation is done in the flux unit of ``flam``.
.. note::
Similar to IRAF STSDAS SYNPHOT ``efflphot`` task.
Parameters
----------
binned : bool
Use binned dat... | [
"Calculate",
":",
"ref",
":",
"effective",
"wavelength",
"<pysynphot",
"-",
"formula",
"-",
"efflam",
">",
"of",
"the",
"observation",
".",
"Calculation",
"is",
"done",
"in",
"the",
"flux",
"unit",
"of",
"flam",
"."
] | python | train |
PMEAL/OpenPNM | openpnm/io/CSV.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/io/CSV.py#L83-L130 | def load(cls, filename, project=None, delim=' | '):
r"""
Opens a 'csv' file, reads in the data, and adds it to the **Network**
Parameters
----------
filename : string (optional)
The name of the file containing the data to import. The formatting
of this f... | [
"def",
"load",
"(",
"cls",
",",
"filename",
",",
"project",
"=",
"None",
",",
"delim",
"=",
"' | '",
")",
":",
"if",
"project",
"is",
"None",
":",
"project",
"=",
"ws",
".",
"new_project",
"(",
")",
"fname",
"=",
"cls",
".",
"_parse_filename",
"(",
... | r"""
Opens a 'csv' file, reads in the data, and adds it to the **Network**
Parameters
----------
filename : string (optional)
The name of the file containing the data to import. The formatting
of this file is outlined below.
project : OpenPNM Project ob... | [
"r",
"Opens",
"a",
"csv",
"file",
"reads",
"in",
"the",
"data",
"and",
"adds",
"it",
"to",
"the",
"**",
"Network",
"**"
] | python | train |
bukun/TorCMS | torcms/model/relation_model.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/relation_model.py#L63-L89 | def get_app_relations(app_id, num=20, kind='1'):
'''
The the related infors.
'''
info_tag = MInfor2Catalog.get_first_category(app_id)
if info_tag:
return TabPost2Tag.select(
TabPost2Tag,
TabPost.title.alias('post_title'),
... | [
"def",
"get_app_relations",
"(",
"app_id",
",",
"num",
"=",
"20",
",",
"kind",
"=",
"'1'",
")",
":",
"info_tag",
"=",
"MInfor2Catalog",
".",
"get_first_category",
"(",
"app_id",
")",
"if",
"info_tag",
":",
"return",
"TabPost2Tag",
".",
"select",
"(",
"TabP... | The the related infors. | [
"The",
"the",
"related",
"infors",
"."
] | python | train |
data-8/datascience | datascience/tables.py | https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/tables.py#L1842-L1869 | def as_html(self, max_rows=0):
"""Format table as HTML."""
if not max_rows or max_rows > self.num_rows:
max_rows = self.num_rows
omitted = max(0, self.num_rows - max_rows)
labels = self.labels
lines = [
(0, '<table border="1" class="dataframe">'),
... | [
"def",
"as_html",
"(",
"self",
",",
"max_rows",
"=",
"0",
")",
":",
"if",
"not",
"max_rows",
"or",
"max_rows",
">",
"self",
".",
"num_rows",
":",
"max_rows",
"=",
"self",
".",
"num_rows",
"omitted",
"=",
"max",
"(",
"0",
",",
"self",
".",
"num_rows",... | Format table as HTML. | [
"Format",
"table",
"as",
"HTML",
"."
] | python | train |
DataBiosphere/toil | src/toil/utils/toilStatus.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/utils/toilStatus.py#L256-L291 | def traverseJobGraph(self, rootJob, jobsToReport=None, foundJobStoreIDs=None):
"""
Find all current jobs in the jobStore and return them as an Array.
:param jobNode rootJob: The root job of the workflow.
:param list jobsToReport: A list of jobNodes to be added to and returned.
:... | [
"def",
"traverseJobGraph",
"(",
"self",
",",
"rootJob",
",",
"jobsToReport",
"=",
"None",
",",
"foundJobStoreIDs",
"=",
"None",
")",
":",
"if",
"jobsToReport",
"is",
"None",
":",
"jobsToReport",
"=",
"[",
"]",
"if",
"foundJobStoreIDs",
"is",
"None",
":",
"... | Find all current jobs in the jobStore and return them as an Array.
:param jobNode rootJob: The root job of the workflow.
:param list jobsToReport: A list of jobNodes to be added to and returned.
:param set foundJobStoreIDs: A set of jobStoreIDs used to keep track of jobStoreIDs encountered in t... | [
"Find",
"all",
"current",
"jobs",
"in",
"the",
"jobStore",
"and",
"return",
"them",
"as",
"an",
"Array",
"."
] | python | train |
libtcod/python-tcod | tcod/event.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/event.py#L48-L52 | def _pixel_to_tile(x: float, y: float) -> Tuple[float, float]:
"""Convert pixel coordinates to tile coordinates."""
xy = tcod.ffi.new("double[2]", (x, y))
tcod.lib.TCOD_sys_pixel_to_tile(xy, xy + 1)
return xy[0], xy[1] | [
"def",
"_pixel_to_tile",
"(",
"x",
":",
"float",
",",
"y",
":",
"float",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
"]",
":",
"xy",
"=",
"tcod",
".",
"ffi",
".",
"new",
"(",
"\"double[2]\"",
",",
"(",
"x",
",",
"y",
")",
")",
"tcod",
".",
... | Convert pixel coordinates to tile coordinates. | [
"Convert",
"pixel",
"coordinates",
"to",
"tile",
"coordinates",
"."
] | python | train |
scopus-api/scopus | scopus/author_search.py | https://github.com/scopus-api/scopus/blob/27ce02dd3095bfdab9d3e8475543d7c17767d1ab/scopus/author_search.py#L9-L40 | def authors(self):
"""A list of namedtuples storing author information,
where each namedtuple corresponds to one author.
The information in each namedtuple is (eid surname initials givenname
documents affiliation affiliation_id city country areas).
All entries are strings or Non... | [
"def",
"authors",
"(",
"self",
")",
":",
"out",
"=",
"[",
"]",
"order",
"=",
"'eid surname initials givenname affiliation documents '",
"'affiliation_id city country areas'",
"auth",
"=",
"namedtuple",
"(",
"'Author'",
",",
"order",
")",
"for",
"item",
"in",
"self",... | A list of namedtuples storing author information,
where each namedtuple corresponds to one author.
The information in each namedtuple is (eid surname initials givenname
documents affiliation affiliation_id city country areas).
All entries are strings or None. Areas combines abbreviated... | [
"A",
"list",
"of",
"namedtuples",
"storing",
"author",
"information",
"where",
"each",
"namedtuple",
"corresponds",
"to",
"one",
"author",
".",
"The",
"information",
"in",
"each",
"namedtuple",
"is",
"(",
"eid",
"surname",
"initials",
"givenname",
"documents",
"... | python | train |
IdentityPython/pysaml2 | src/saml2/assertion.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/assertion.py#L810-L828 | def apply_policy(self, sp_entity_id, policy, metadata=None):
""" Apply policy to the assertion I'm representing
:param sp_entity_id: The SP entity ID
:param policy: The policy
:param metadata: Metadata to use
:return: The resulting AVA after the policy is applied
"""
... | [
"def",
"apply_policy",
"(",
"self",
",",
"sp_entity_id",
",",
"policy",
",",
"metadata",
"=",
"None",
")",
":",
"policy",
".",
"acs",
"=",
"self",
".",
"acs",
"ava",
"=",
"policy",
".",
"restrict",
"(",
"self",
",",
"sp_entity_id",
",",
"metadata",
")"... | Apply policy to the assertion I'm representing
:param sp_entity_id: The SP entity ID
:param policy: The policy
:param metadata: Metadata to use
:return: The resulting AVA after the policy is applied | [
"Apply",
"policy",
"to",
"the",
"assertion",
"I",
"m",
"representing"
] | python | train |
CalebBell/thermo | thermo/safety.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/safety.py#L1179-L1229 | def Crowl_Louvar_UFL(atoms):
r'''Calculates upper flammability limit, using the Crowl-Louvar [1]_
correlation. Uses molecular formula only.
The upper flammability limit of a gas is air is:
.. math::
C_mH_xO_y + zO_2 \to mCO_2 + \frac{x}{2}H_2O
\text{UFL} = \frac{3.5}{4.76m + 1.19x - 2... | [
"def",
"Crowl_Louvar_UFL",
"(",
"atoms",
")",
":",
"nC",
",",
"nH",
",",
"nO",
"=",
"0",
",",
"0",
",",
"0",
"if",
"'C'",
"in",
"atoms",
"and",
"atoms",
"[",
"'C'",
"]",
":",
"nC",
"=",
"atoms",
"[",
"'C'",
"]",
"else",
":",
"return",
"None",
... | r'''Calculates upper flammability limit, using the Crowl-Louvar [1]_
correlation. Uses molecular formula only.
The upper flammability limit of a gas is air is:
.. math::
C_mH_xO_y + zO_2 \to mCO_2 + \frac{x}{2}H_2O
\text{UFL} = \frac{3.5}{4.76m + 1.19x - 2.38y + 1}
Parameters
---... | [
"r",
"Calculates",
"upper",
"flammability",
"limit",
"using",
"the",
"Crowl",
"-",
"Louvar",
"[",
"1",
"]",
"_",
"correlation",
".",
"Uses",
"molecular",
"formula",
"only",
"."
] | python | valid |
The-Politico/politico-civic-election-night | electionnight/serializers/state.py | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/state.py#L52-L67 | def get_elections(self, obj):
"""All elections in division."""
election_day = ElectionDay.objects.get(
date=self.context['election_date'])
elections = list(obj.elections.filter(election_day=election_day))
district = DivisionLevel.objects.get(name=DivisionLevel.DISTRICT)
... | [
"def",
"get_elections",
"(",
"self",
",",
"obj",
")",
":",
"election_day",
"=",
"ElectionDay",
".",
"objects",
".",
"get",
"(",
"date",
"=",
"self",
".",
"context",
"[",
"'election_date'",
"]",
")",
"elections",
"=",
"list",
"(",
"obj",
".",
"elections",... | All elections in division. | [
"All",
"elections",
"in",
"division",
"."
] | python | train |
timothycrosley/simple_ci | simple_ci.py | https://github.com/timothycrosley/simple_ci/blob/3d2a7b0c527d34731f15b752ff200e76d5addd67/simple_ci.py#L43-L56 | def repository(namespace, name, branch='master'):
'''Returns a repository'''
with TemporaryDirectory() as download_path:
old_directory = str(pwd()).strip()
try:
git.clone('https://github.com/{0}/{1}.git'.format(namespace, name), download_path)
cd(download_path)
... | [
"def",
"repository",
"(",
"namespace",
",",
"name",
",",
"branch",
"=",
"'master'",
")",
":",
"with",
"TemporaryDirectory",
"(",
")",
"as",
"download_path",
":",
"old_directory",
"=",
"str",
"(",
"pwd",
"(",
")",
")",
".",
"strip",
"(",
")",
"try",
":"... | Returns a repository | [
"Returns",
"a",
"repository"
] | python | train |
django-crispy-forms/django-crispy-forms | crispy_forms/helper.py | https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/helper.py#L353-L421 | def get_attributes(self, template_pack=TEMPLATE_PACK):
"""
Used by crispy_forms_tags to get helper attributes
"""
items = {
'form_method': self.form_method.strip(),
'form_tag': self.form_tag,
'form_style': self.form_style.strip(),
'form_sho... | [
"def",
"get_attributes",
"(",
"self",
",",
"template_pack",
"=",
"TEMPLATE_PACK",
")",
":",
"items",
"=",
"{",
"'form_method'",
":",
"self",
".",
"form_method",
".",
"strip",
"(",
")",
",",
"'form_tag'",
":",
"self",
".",
"form_tag",
",",
"'form_style'",
"... | Used by crispy_forms_tags to get helper attributes | [
"Used",
"by",
"crispy_forms_tags",
"to",
"get",
"helper",
"attributes"
] | python | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/pyprf_sim_ep.py | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_sim_ep.py#L14-L54 | def get_arg_parse():
"""Parses the Command Line Arguments using argparse."""
# Create parser object:
objParser = argparse.ArgumentParser()
# Add argument to namespace -strCsvPrf results file path:
objParser.add_argument('-strCsvPrf', required=True,
metavar='/path/to/my_pr... | [
"def",
"get_arg_parse",
"(",
")",
":",
"# Create parser object:",
"objParser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"# Add argument to namespace -strCsvPrf results file path:",
"objParser",
".",
"add_argument",
"(",
"'-strCsvPrf'",
",",
"required",
"=",
"True... | Parses the Command Line Arguments using argparse. | [
"Parses",
"the",
"Command",
"Line",
"Arguments",
"using",
"argparse",
"."
] | python | train |
boriel/zxbasic | zxbparser.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L264-L272 | def make_argument(expr, lineno, byref=None):
""" Wrapper: Creates a node containing an ARGUMENT
"""
if expr is None:
return # There were a syntax / semantic error
if byref is None:
byref = OPTIONS.byref.value
return symbols.ARGUMENT(expr, lineno=lineno, byref=byref) | [
"def",
"make_argument",
"(",
"expr",
",",
"lineno",
",",
"byref",
"=",
"None",
")",
":",
"if",
"expr",
"is",
"None",
":",
"return",
"# There were a syntax / semantic error",
"if",
"byref",
"is",
"None",
":",
"byref",
"=",
"OPTIONS",
".",
"byref",
".",
"val... | Wrapper: Creates a node containing an ARGUMENT | [
"Wrapper",
":",
"Creates",
"a",
"node",
"containing",
"an",
"ARGUMENT"
] | python | train |
pivotal-energy-solutions/django-datatable-view | datatableview/datatables.py | https://github.com/pivotal-energy-solutions/django-datatable-view/blob/00b77a9b5051c34e258c51b06c020e92edf15034/datatableview/datatables.py#L962-L998 | def preload_record_data(self, obj):
"""
Modifies the ``obj`` values dict to alias the selected values to the column name that asked
for its selection.
For example, a datatable that declares a column ``'blog'`` which has a related lookup source
``'blog__name'`` will ensure that t... | [
"def",
"preload_record_data",
"(",
"self",
",",
"obj",
")",
":",
"data",
"=",
"{",
"}",
"for",
"orm_path",
",",
"column_name",
"in",
"self",
".",
"value_queries",
".",
"items",
"(",
")",
":",
"value",
"=",
"obj",
"[",
"orm_path",
"]",
"if",
"column_nam... | Modifies the ``obj`` values dict to alias the selected values to the column name that asked
for its selection.
For example, a datatable that declares a column ``'blog'`` which has a related lookup source
``'blog__name'`` will ensure that the selected value exists in ``obj`` at both keys
... | [
"Modifies",
"the",
"obj",
"values",
"dict",
"to",
"alias",
"the",
"selected",
"values",
"to",
"the",
"column",
"name",
"that",
"asked",
"for",
"its",
"selection",
"."
] | python | train |
noobermin/pys | pys/__init__.py | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L54-L59 | def check_vprint(s, vprinter):
'''checked verbose printing'''
if vprinter is True:
print(s);
elif callable(vprinter):
vprinter(s); | [
"def",
"check_vprint",
"(",
"s",
",",
"vprinter",
")",
":",
"if",
"vprinter",
"is",
"True",
":",
"print",
"(",
"s",
")",
"elif",
"callable",
"(",
"vprinter",
")",
":",
"vprinter",
"(",
"s",
")"
] | checked verbose printing | [
"checked",
"verbose",
"printing"
] | python | train |
CivicSpleen/ambry | ambry/library/warehouse.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/warehouse.py#L289-L318 | def geoframe(self, sql, simplify=None, crs=None, epsg=4326):
"""
Return geopandas dataframe
:param simplify: Integer or None. Simplify the geometry to a tolerance, in the units of the geometry.
:param crs: Coordinate reference system information
:param epsg: Specifiy the CRS as ... | [
"def",
"geoframe",
"(",
"self",
",",
"sql",
",",
"simplify",
"=",
"None",
",",
"crs",
"=",
"None",
",",
"epsg",
"=",
"4326",
")",
":",
"import",
"geopandas",
"from",
"shapely",
".",
"wkt",
"import",
"loads",
"from",
"fiona",
".",
"crs",
"import",
"fr... | Return geopandas dataframe
:param simplify: Integer or None. Simplify the geometry to a tolerance, in the units of the geometry.
:param crs: Coordinate reference system information
:param epsg: Specifiy the CRS as an EPGS number.
:return: A Geopandas GeoDataFrame | [
"Return",
"geopandas",
"dataframe"
] | python | train |
fbngrm/babelpy | babelpy/babelfy.py | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L211-L231 | def _wraps(self, tokens):
"""determine if a token is wrapped by another token
"""
def _differ(tokens):
inner, outer = tokens
not_same_start = inner.get('start') != outer.get('start')
not_same_end = inner.get('end') != outer.get('end')
return not_sa... | [
"def",
"_wraps",
"(",
"self",
",",
"tokens",
")",
":",
"def",
"_differ",
"(",
"tokens",
")",
":",
"inner",
",",
"outer",
"=",
"tokens",
"not_same_start",
"=",
"inner",
".",
"get",
"(",
"'start'",
")",
"!=",
"outer",
".",
"get",
"(",
"'start'",
")",
... | determine if a token is wrapped by another token | [
"determine",
"if",
"a",
"token",
"is",
"wrapped",
"by",
"another",
"token"
] | python | train |
kragniz/python-etcd3 | etcd3/client.py | https://github.com/kragniz/python-etcd3/blob/0adb14840d4a6011a2023a13f07e247e4c336a80/etcd3/client.py#L1091-L1103 | def client(host='localhost', port=2379,
ca_cert=None, cert_key=None, cert_cert=None, timeout=None,
user=None, password=None, grpc_options=None):
"""Return an instance of an Etcd3Client."""
return Etcd3Client(host=host,
port=port,
ca_cert=ca_cer... | [
"def",
"client",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"2379",
",",
"ca_cert",
"=",
"None",
",",
"cert_key",
"=",
"None",
",",
"cert_cert",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",... | Return an instance of an Etcd3Client. | [
"Return",
"an",
"instance",
"of",
"an",
"Etcd3Client",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L3472-L3487 | def schedule_forced_host_svc_checks(self, host, check_time):
"""Schedule a forced check on all services of a host
Format of the line that triggers function call::
SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>
:param host: host to check
:type host: alignak.object.host... | [
"def",
"schedule_forced_host_svc_checks",
"(",
"self",
",",
"host",
",",
"check_time",
")",
":",
"for",
"service_id",
"in",
"host",
".",
"services",
":",
"service",
"=",
"self",
".",
"daemon",
".",
"services",
"[",
"service_id",
"]",
"self",
".",
"schedule_f... | Schedule a forced check on all services of a host
Format of the line that triggers function call::
SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>
:param host: host to check
:type host: alignak.object.host.Host
:param check_time: time to check
:type check_time:... | [
"Schedule",
"a",
"forced",
"check",
"on",
"all",
"services",
"of",
"a",
"host",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train |
odlgroup/odl | odl/discr/grid.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/discr/grid.py#L564-L640 | def is_subgrid(self, other, atol=0.0):
"""Return ``True`` if this grid is a subgrid of ``other``.
Parameters
----------
other : `RectGrid`
The other grid which is supposed to contain this grid
atol : float, optional
Allow deviations up to this number in ... | [
"def",
"is_subgrid",
"(",
"self",
",",
"other",
",",
"atol",
"=",
"0.0",
")",
":",
"# Optimization for some common cases",
"if",
"other",
"is",
"self",
":",
"return",
"True",
"if",
"not",
"isinstance",
"(",
"other",
",",
"RectGrid",
")",
":",
"return",
"Fa... | Return ``True`` if this grid is a subgrid of ``other``.
Parameters
----------
other : `RectGrid`
The other grid which is supposed to contain this grid
atol : float, optional
Allow deviations up to this number in absolute value
per coordinate vector e... | [
"Return",
"True",
"if",
"this",
"grid",
"is",
"a",
"subgrid",
"of",
"other",
"."
] | python | train |
ejeschke/ginga | ginga/rv/plugins/TVMask.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/TVMask.py#L207-L228 | def redo(self):
"""Image or masks have changed. Clear and redraw."""
if not self.gui_up:
return
self.clear_mask()
image = self.fitsimage.get_image()
if image is None:
return
n_obj = len(self._maskobjs)
self.logger.debug('Displaying {0} m... | [
"def",
"redo",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"gui_up",
":",
"return",
"self",
".",
"clear_mask",
"(",
")",
"image",
"=",
"self",
".",
"fitsimage",
".",
"get_image",
"(",
")",
"if",
"image",
"is",
"None",
":",
"return",
"n_obj",
"... | Image or masks have changed. Clear and redraw. | [
"Image",
"or",
"masks",
"have",
"changed",
".",
"Clear",
"and",
"redraw",
"."
] | python | train |
paypal/baler | baler/baler.py | https://github.com/paypal/baler/blob/db4f09dd2c7729b2df5268c87ad3b4cb43396abf/baler/baler.py#L22-L41 | def paths_in_directory(input_directory):
"""
Generate a list of all files in input_directory, each as a list containing path components.
"""
paths = []
for base_path, directories, filenames in os.walk(input_directory):
relative_path = os.path.relpath(base_path, input_directory)
path_... | [
"def",
"paths_in_directory",
"(",
"input_directory",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"base_path",
",",
"directories",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"input_directory",
")",
":",
"relative_path",
"=",
"os",
".",
"path",
".",
"relpa... | Generate a list of all files in input_directory, each as a list containing path components. | [
"Generate",
"a",
"list",
"of",
"all",
"files",
"in",
"input_directory",
"each",
"as",
"a",
"list",
"containing",
"path",
"components",
"."
] | python | train |
PedalPi/Raspberry-Physical | physical/liquidcristal/liquid_crystal.py | https://github.com/PedalPi/Raspberry-Physical/blob/3dc71b6997ef36d0de256c5db7a1b38178937fd5/physical/liquidcristal/liquid_crystal.py#L206-L209 | def left_to_right(self):
"""This is for text that flows Left to Right"""
self._entry_mode |= Command.MODE_INCREMENT
self.command(self._entry_mode) | [
"def",
"left_to_right",
"(",
"self",
")",
":",
"self",
".",
"_entry_mode",
"|=",
"Command",
".",
"MODE_INCREMENT",
"self",
".",
"command",
"(",
"self",
".",
"_entry_mode",
")"
] | This is for text that flows Left to Right | [
"This",
"is",
"for",
"text",
"that",
"flows",
"Left",
"to",
"Right"
] | python | train |
ionelmc/python-cogen | cogen/core/schedulers.py | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/schedulers.py#L89-L98 | def add(self, coro, args=(), kwargs={}, first=True):
"""Add a coroutine in the scheduler. You can add arguments
(_args_, _kwargs_) to init the coroutine with."""
assert callable(coro), "'%s' not a callable object" % coro
coro = coro(*args, **kwargs)
if first:
se... | [
"def",
"add",
"(",
"self",
",",
"coro",
",",
"args",
"=",
"(",
")",
",",
"kwargs",
"=",
"{",
"}",
",",
"first",
"=",
"True",
")",
":",
"assert",
"callable",
"(",
"coro",
")",
",",
"\"'%s' not a callable object\"",
"%",
"coro",
"coro",
"=",
"coro",
... | Add a coroutine in the scheduler. You can add arguments
(_args_, _kwargs_) to init the coroutine with. | [
"Add",
"a",
"coroutine",
"in",
"the",
"scheduler",
".",
"You",
"can",
"add",
"arguments",
"(",
"_args_",
"_kwargs_",
")",
"to",
"init",
"the",
"coroutine",
"with",
"."
] | python | train |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L567-L576 | def extra_funcs(*funcs):
"""Decorator which adds extra functions to be downloaded to the pyboard."""
def extra_funcs_decorator(real_func):
def wrapper(*args, **kwargs):
return real_func(*args, **kwargs)
wrapper.extra_funcs = list(funcs)
wrapper.source = inspect.getsource(real_func)
wrapper.nam... | [
"def",
"extra_funcs",
"(",
"*",
"funcs",
")",
":",
"def",
"extra_funcs_decorator",
"(",
"real_func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"real_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Decorator which adds extra functions to be downloaded to the pyboard. | [
"Decorator",
"which",
"adds",
"extra",
"functions",
"to",
"be",
"downloaded",
"to",
"the",
"pyboard",
"."
] | python | train |
collectiveacuity/labPack | labpack/databases/couchbase.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L605-L639 | def create_session(self, uid, duration=0):
'''
a method to create a session token for the user
:param uid: string with id of user in bucket
:param duration: integer with number of seconds to last (default: 24hrs)
:return: dictionary with account fields for user... | [
"def",
"create_session",
"(",
"self",
",",
"uid",
",",
"duration",
"=",
"0",
")",
":",
"title",
"=",
"'%s.create_session'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs",
"input_fields",
"=",
"{",
"'uid'",
":",
"uid",
",",
"'duration'",... | a method to create a session token for the user
:param uid: string with id of user in bucket
:param duration: integer with number of seconds to last (default: 24hrs)
:return: dictionary with account fields for user | [
"a",
"method",
"to",
"create",
"a",
"session",
"token",
"for",
"the",
"user",
":",
"param",
"uid",
":",
"string",
"with",
"id",
"of",
"user",
"in",
"bucket",
":",
"param",
"duration",
":",
"integer",
"with",
"number",
"of",
"seconds",
"to",
"last",
"("... | python | train |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/iam/apis/account_admin_api.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/account_admin_api.py#L242-L263 | def add_subjects_to_group(self, group_id, body, **kwargs): # noqa: E501
"""Add members to a group. # noqa: E501
An endpoint for adding users and API keys to a group. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/policy-groups/{group-id} -d '{\"users\": [0162056a9a1586f3024... | [
"def",
"add_subjects_to_group",
"(",
"self",
",",
"group_id",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'asynchronous'",
")",
":",
"return",
... | Add members to a group. # noqa: E501
An endpoint for adding users and API keys to a group. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/policy-groups/{group-id} -d '{\"users\": [0162056a9a1586f30242590700000000,0117056a9a1586f30242590700000000]\"}' -H 'content-type: application/js... | [
"Add",
"members",
"to",
"a",
"group",
".",
"#",
"noqa",
":",
"E501"
] | python | train |
molmod/molmod | molmod/io/fchk.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L214-L226 | def get_hessian(self):
"""Return the hessian"""
force_const = self.fields.get("Cartesian Force Constants")
if force_const is None:
return None
N = len(self.molecule.numbers)
result = np.zeros((3*N, 3*N), float)
counter = 0
for row in range(3*N):
... | [
"def",
"get_hessian",
"(",
"self",
")",
":",
"force_const",
"=",
"self",
".",
"fields",
".",
"get",
"(",
"\"Cartesian Force Constants\"",
")",
"if",
"force_const",
"is",
"None",
":",
"return",
"None",
"N",
"=",
"len",
"(",
"self",
".",
"molecule",
".",
"... | Return the hessian | [
"Return",
"the",
"hessian"
] | python | train |
pydata/xarray | xarray/core/variable.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1667-L1681 | def coarsen(self, windows, func, boundary='exact', side='left'):
"""
Apply
"""
windows = {k: v for k, v in windows.items() if k in self.dims}
if not windows:
return self.copy()
reshaped, axes = self._coarsen_reshape(windows, boundary, side)
if isinsta... | [
"def",
"coarsen",
"(",
"self",
",",
"windows",
",",
"func",
",",
"boundary",
"=",
"'exact'",
",",
"side",
"=",
"'left'",
")",
":",
"windows",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"windows",
".",
"items",
"(",
")",
"if",
"k",
"in... | Apply | [
"Apply"
] | python | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L472-L485 | def dmail_create(self, to_name, title, body):
"""Create a dmail (Requires login)
Parameters:
to_name (str): The recipient's name.
title (str): The title of the message.
body (str): The body of the message.
"""
params = {
'dmail[to_name]': ... | [
"def",
"dmail_create",
"(",
"self",
",",
"to_name",
",",
"title",
",",
"body",
")",
":",
"params",
"=",
"{",
"'dmail[to_name]'",
":",
"to_name",
",",
"'dmail[title]'",
":",
"title",
",",
"'dmail[body]'",
":",
"body",
"}",
"return",
"self",
".",
"_get",
"... | Create a dmail (Requires login)
Parameters:
to_name (str): The recipient's name.
title (str): The title of the message.
body (str): The body of the message. | [
"Create",
"a",
"dmail",
"(",
"Requires",
"login",
")"
] | python | train |
saltstack/salt | salt/modules/win_system.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_system.py#L70-L76 | def _convert_date_time_string(dt_string):
'''
convert string to date time object
'''
dt_string = dt_string.split('.')[0]
dt_obj = datetime.strptime(dt_string, '%Y%m%d%H%M%S')
return dt_obj.strftime('%Y-%m-%d %H:%M:%S') | [
"def",
"_convert_date_time_string",
"(",
"dt_string",
")",
":",
"dt_string",
"=",
"dt_string",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"dt_obj",
"=",
"datetime",
".",
"strptime",
"(",
"dt_string",
",",
"'%Y%m%d%H%M%S'",
")",
"return",
"dt_obj",
".",
... | convert string to date time object | [
"convert",
"string",
"to",
"date",
"time",
"object"
] | python | train |
materialsproject/pymatgen | pymatgen/analysis/diffusion_analyzer.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/diffusion_analyzer.py#L868-L908 | def get_arrhenius_plot(temps, diffusivities, diffusivity_errors=None,
**kwargs):
"""
Returns an Arrhenius plot.
Args:
temps ([float]): A sequence of temperatures.
diffusivities ([float]): A sequence of diffusivities (e.g.,
from DiffusionAnalyzer.diffusivit... | [
"def",
"get_arrhenius_plot",
"(",
"temps",
",",
"diffusivities",
",",
"diffusivity_errors",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"Ea",
",",
"c",
",",
"_",
"=",
"fit_arrhenius",
"(",
"temps",
",",
"diffusivities",
")",
"from",
"pymatgen",
".",
... | Returns an Arrhenius plot.
Args:
temps ([float]): A sequence of temperatures.
diffusivities ([float]): A sequence of diffusivities (e.g.,
from DiffusionAnalyzer.diffusivity).
diffusivity_errors ([float]): A sequence of errors for the
diffusivities. If None, no error ... | [
"Returns",
"an",
"Arrhenius",
"plot",
"."
] | python | train |
estnltk/estnltk | estnltk/syntax/utils.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L746-L838 | def as_dependencygraph( self, keep_dummy_root=False, add_morph=True ):
''' Returns this tree as NLTK's DependencyGraph object.
Note that this method constructs 'zero_based' graph,
where counting of the words starts from 0 and the
root index is -1 (not 0, as in M... | [
"def",
"as_dependencygraph",
"(",
"self",
",",
"keep_dummy_root",
"=",
"False",
",",
"add_morph",
"=",
"True",
")",
":",
"from",
"nltk",
".",
"parse",
".",
"dependencygraph",
"import",
"DependencyGraph",
"graph",
"=",
"DependencyGraph",
"(",
"zero_based",
"=",
... | Returns this tree as NLTK's DependencyGraph object.
Note that this method constructs 'zero_based' graph,
where counting of the words starts from 0 and the
root index is -1 (not 0, as in Malt-TAB format);
Parameters
-----------
... | [
"Returns",
"this",
"tree",
"as",
"NLTK",
"s",
"DependencyGraph",
"object",
".",
"Note",
"that",
"this",
"method",
"constructs",
"zero_based",
"graph",
"where",
"counting",
"of",
"the",
"words",
"starts",
"from",
"0",
"and",
"the",
"root",
"index",
"is",
"-",... | python | train |
raiden-network/raiden | raiden/transfer/balance_proof.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/balance_proof.py#L7-L35 | def pack_balance_proof(
nonce: Nonce,
balance_hash: BalanceHash,
additional_hash: AdditionalHash,
canonical_identifier: CanonicalIdentifier,
msg_type: MessageTypeId = MessageTypeId.BALANCE_PROOF,
) -> bytes:
"""Packs balance proof data to be signed
Packs the given argume... | [
"def",
"pack_balance_proof",
"(",
"nonce",
":",
"Nonce",
",",
"balance_hash",
":",
"BalanceHash",
",",
"additional_hash",
":",
"AdditionalHash",
",",
"canonical_identifier",
":",
"CanonicalIdentifier",
",",
"msg_type",
":",
"MessageTypeId",
"=",
"MessageTypeId",
".",
... | Packs balance proof data to be signed
Packs the given arguments in a byte array in the same configuration the
contracts expect the signed data to have. | [
"Packs",
"balance",
"proof",
"data",
"to",
"be",
"signed"
] | python | train |
openid/python-openid | examples/djopenid/server/views.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/examples/djopenid/server/views.py#L63-L72 | def server(request):
"""
Respond to requests for the server's primary web page.
"""
return direct_to_template(
request,
'server/index.html',
{'user_url': getViewURL(request, idPage),
'server_xrds_url': getViewURL(request, idpXrds),
}) | [
"def",
"server",
"(",
"request",
")",
":",
"return",
"direct_to_template",
"(",
"request",
",",
"'server/index.html'",
",",
"{",
"'user_url'",
":",
"getViewURL",
"(",
"request",
",",
"idPage",
")",
",",
"'server_xrds_url'",
":",
"getViewURL",
"(",
"request",
"... | Respond to requests for the server's primary web page. | [
"Respond",
"to",
"requests",
"for",
"the",
"server",
"s",
"primary",
"web",
"page",
"."
] | python | train |
log2timeline/dfdatetime | dfdatetime/posix_time.py | https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/posix_time.py#L236-L251 | def _GetNormalizedTimestamp(self):
"""Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cann... | [
"def",
"_GetNormalizedTimestamp",
"(",
"self",
")",
":",
"if",
"self",
".",
"_normalized_timestamp",
"is",
"None",
":",
"if",
"self",
".",
"_timestamp",
"is",
"not",
"None",
":",
"self",
".",
"_normalized_timestamp",
"=",
"(",
"decimal",
".",
"Decimal",
"(",... | Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined. | [
"Retrieves",
"the",
"normalized",
"timestamp",
"."
] | python | train |
happyleavesaoc/python-snapcast | snapcast/control/group.py | https://github.com/happyleavesaoc/python-snapcast/blob/9b3c483358677327c7fd6d0666bf474c19d87f19/snapcast/control/group.py#L128-L132 | def update_stream(self, data):
"""Update stream."""
self._group['stream_id'] = data['stream_id']
self.callback()
_LOGGER.info('updated stream to %s on %s', self.stream, self.friendly_name) | [
"def",
"update_stream",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_group",
"[",
"'stream_id'",
"]",
"=",
"data",
"[",
"'stream_id'",
"]",
"self",
".",
"callback",
"(",
")",
"_LOGGER",
".",
"info",
"(",
"'updated stream to %s on %s'",
",",
"self",
... | Update stream. | [
"Update",
"stream",
"."
] | python | train |
robotools/fontMath | Lib/fontMath/mathTransform.py | https://github.com/robotools/fontMath/blob/6abcb9d5a1ca19788fbde4418d7b5630c60990d8/Lib/fontMath/mathTransform.py#L338-L340 | def _linearInterpolationTransformMatrix(matrix1, matrix2, value):
""" Linear, 'oldstyle' interpolation of the transform matrix."""
return tuple(_interpolateValue(matrix1[i], matrix2[i], value) for i in range(len(matrix1))) | [
"def",
"_linearInterpolationTransformMatrix",
"(",
"matrix1",
",",
"matrix2",
",",
"value",
")",
":",
"return",
"tuple",
"(",
"_interpolateValue",
"(",
"matrix1",
"[",
"i",
"]",
",",
"matrix2",
"[",
"i",
"]",
",",
"value",
")",
"for",
"i",
"in",
"range",
... | Linear, 'oldstyle' interpolation of the transform matrix. | [
"Linear",
"oldstyle",
"interpolation",
"of",
"the",
"transform",
"matrix",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/core/states/library_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/library_state.py#L567-L580 | def library_hierarchy_depth(self):
""" Calculates the library hierarchy depth
Counting starts at the current library state. So if the there is no upper library state the depth is one.
:return: library hierarchy depth
:rtype: int
"""
current_library_hierarchy_dep... | [
"def",
"library_hierarchy_depth",
"(",
"self",
")",
":",
"current_library_hierarchy_depth",
"=",
"1",
"library_root_state",
"=",
"self",
".",
"get_next_upper_library_root_state",
"(",
")",
"while",
"library_root_state",
"is",
"not",
"None",
":",
"current_library_hierarchy... | Calculates the library hierarchy depth
Counting starts at the current library state. So if the there is no upper library state the depth is one.
:return: library hierarchy depth
:rtype: int | [
"Calculates",
"the",
"library",
"hierarchy",
"depth"
] | python | train |
google/grumpy | third_party/stdlib/rfc822.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/rfc822.py#L492-L498 | def parseaddr(address):
"""Parse an address into a (realname, mailaddr) tuple."""
a = AddressList(address)
lst = a.addresslist
if not lst:
return (None, None)
return lst[0] | [
"def",
"parseaddr",
"(",
"address",
")",
":",
"a",
"=",
"AddressList",
"(",
"address",
")",
"lst",
"=",
"a",
".",
"addresslist",
"if",
"not",
"lst",
":",
"return",
"(",
"None",
",",
"None",
")",
"return",
"lst",
"[",
"0",
"]"
] | Parse an address into a (realname, mailaddr) tuple. | [
"Parse",
"an",
"address",
"into",
"a",
"(",
"realname",
"mailaddr",
")",
"tuple",
"."
] | python | valid |
mattrobenolt/ec2 | ec2/helpers.py | https://github.com/mattrobenolt/ec2/blob/fc1f8bce6cf76899165d9ac006371181d52439f8/ec2/helpers.py#L12-L22 | def make_compare(key, value, obj):
"Map a key name to a specific comparison function"
if '__' not in key:
# If no __ exists, default to doing an "exact" comparison
key, comp = key, 'exact'
else:
key, comp = key.rsplit('__', 1)
# Check if comp is valid
if hasattr(Compare, comp... | [
"def",
"make_compare",
"(",
"key",
",",
"value",
",",
"obj",
")",
":",
"if",
"'__'",
"not",
"in",
"key",
":",
"# If no __ exists, default to doing an \"exact\" comparison",
"key",
",",
"comp",
"=",
"key",
",",
"'exact'",
"else",
":",
"key",
",",
"comp",
"=",... | Map a key name to a specific comparison function | [
"Map",
"a",
"key",
"name",
"to",
"a",
"specific",
"comparison",
"function"
] | python | train |
LordDarkula/chess_py | chess_py/core/board.py | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L73-L108 | def init_default(cls):
"""
Creates a ``Board`` with the standard chess starting position.
:rtype: Board
"""
return cls([
# First rank
[Rook(white, Location(0, 0)), Knight(white, Location(0, 1)), Bishop(white, Location(0, 2)),
Queen(white, Lo... | [
"def",
"init_default",
"(",
"cls",
")",
":",
"return",
"cls",
"(",
"[",
"# First rank",
"[",
"Rook",
"(",
"white",
",",
"Location",
"(",
"0",
",",
"0",
")",
")",
",",
"Knight",
"(",
"white",
",",
"Location",
"(",
"0",
",",
"1",
")",
")",
",",
"... | Creates a ``Board`` with the standard chess starting position.
:rtype: Board | [
"Creates",
"a",
"Board",
"with",
"the",
"standard",
"chess",
"starting",
"position",
"."
] | python | train |
saltstack/salt | salt/modules/ssh.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ssh.py#L123-L134 | def _get_config_file(user, config):
'''
Get absolute path to a user's ssh_config.
'''
uinfo = __salt__['user.info'](user)
if not uinfo:
raise CommandExecutionError('User \'{0}\' does not exist'.format(user))
home = uinfo['home']
config = _expand_authorized_keys_path(config, user, hom... | [
"def",
"_get_config_file",
"(",
"user",
",",
"config",
")",
":",
"uinfo",
"=",
"__salt__",
"[",
"'user.info'",
"]",
"(",
"user",
")",
"if",
"not",
"uinfo",
":",
"raise",
"CommandExecutionError",
"(",
"'User \\'{0}\\' does not exist'",
".",
"format",
"(",
"user... | Get absolute path to a user's ssh_config. | [
"Get",
"absolute",
"path",
"to",
"a",
"user",
"s",
"ssh_config",
"."
] | python | train |
ntoll/uflash | uflash.py | https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L358-L376 | def watch_file(path, func, *args, **kwargs):
"""
Watch a file for changes by polling its last modification time. Call the
provided function with *args and **kwargs upon modification.
"""
if not path:
raise ValueError('Please specify a file to watch')
print('Watching "{}" for changes'.for... | [
"def",
"watch_file",
"(",
"path",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"'Please specify a file to watch'",
")",
"print",
"(",
"'Watching \"{}\" for changes'",
".",
"format",
"... | Watch a file for changes by polling its last modification time. Call the
provided function with *args and **kwargs upon modification. | [
"Watch",
"a",
"file",
"for",
"changes",
"by",
"polling",
"its",
"last",
"modification",
"time",
".",
"Call",
"the",
"provided",
"function",
"with",
"*",
"args",
"and",
"**",
"kwargs",
"upon",
"modification",
"."
] | python | train |
wdbm/abstraction | abstraction.py | https://github.com/wdbm/abstraction/blob/58c81e73954cc6b4cd2f79b2216467528a96376b/abstraction.py#L1930-L1956 | def sentiment(
text = None,
confidence = False
):
"""
This function accepts a string text input. It calculates the sentiment of
the text, "pos" or "neg". By default, it returns this calculated sentiment.
If selected, it returns a tuple of the calculated sentiment and the
classifica... | [
"def",
"sentiment",
"(",
"text",
"=",
"None",
",",
"confidence",
"=",
"False",
")",
":",
"try",
":",
"words",
"=",
"text",
".",
"split",
"(",
"\" \"",
")",
"# Remove empty strings.",
"words",
"=",
"[",
"word",
"for",
"word",
"in",
"words",
"if",
"word"... | This function accepts a string text input. It calculates the sentiment of
the text, "pos" or "neg". By default, it returns this calculated sentiment.
If selected, it returns a tuple of the calculated sentiment and the
classificaton confidence. | [
"This",
"function",
"accepts",
"a",
"string",
"text",
"input",
".",
"It",
"calculates",
"the",
"sentiment",
"of",
"the",
"text",
"pos",
"or",
"neg",
".",
"By",
"default",
"it",
"returns",
"this",
"calculated",
"sentiment",
".",
"If",
"selected",
"it",
"ret... | python | train |
iotile/coretools | iotilecore/iotile/core/utilities/schema_verify/literal_verify.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/schema_verify/literal_verify.py#L35-L49 | def format(self, indent_level, indent_size=4):
"""Format this verifier
Returns:
string: A formatted string
"""
name = self.format_name('Literal', indent_size)
if self.long_desc is not None:
name += '\n'
name += self.wrap_lines('value: %s\n' % s... | [
"def",
"format",
"(",
"self",
",",
"indent_level",
",",
"indent_size",
"=",
"4",
")",
":",
"name",
"=",
"self",
".",
"format_name",
"(",
"'Literal'",
",",
"indent_size",
")",
"if",
"self",
".",
"long_desc",
"is",
"not",
"None",
":",
"name",
"+=",
"'\\n... | Format this verifier
Returns:
string: A formatted string | [
"Format",
"this",
"verifier"
] | python | train |
klen/muffin-session | example.py | https://github.com/klen/muffin-session/blob/f1d14d12b7d09d8cc40be14b0dfa0b1e2f4ae8e9/example.py#L23-L27 | def update(request):
"""Update a current user's session."""
session = yield from app.ps.session.load(request)
session['random'] = random.random()
return session | [
"def",
"update",
"(",
"request",
")",
":",
"session",
"=",
"yield",
"from",
"app",
".",
"ps",
".",
"session",
".",
"load",
"(",
"request",
")",
"session",
"[",
"'random'",
"]",
"=",
"random",
".",
"random",
"(",
")",
"return",
"session"
] | Update a current user's session. | [
"Update",
"a",
"current",
"user",
"s",
"session",
"."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L21823-L21845 | def wait_for_completion(self, timeout):
"""Waits until the task is done (including all sub-operations)
with a given timeout in milliseconds; specify -1 for an indefinite wait.
Note that the VirtualBox/XPCOM/COM/native event queues of the calling
thread are not processed while wa... | [
"def",
"wait_for_completion",
"(",
"self",
",",
"timeout",
")",
":",
"if",
"not",
"isinstance",
"(",
"timeout",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"timeout can only be an instance of type baseinteger\"",
")",
"self",
".",
"_call",
"(",
"\"w... | Waits until the task is done (including all sub-operations)
with a given timeout in milliseconds; specify -1 for an indefinite wait.
Note that the VirtualBox/XPCOM/COM/native event queues of the calling
thread are not processed while waiting. Neglecting event queues may
have dir... | [
"Waits",
"until",
"the",
"task",
"is",
"done",
"(",
"including",
"all",
"sub",
"-",
"operations",
")",
"with",
"a",
"given",
"timeout",
"in",
"milliseconds",
";",
"specify",
"-",
"1",
"for",
"an",
"indefinite",
"wait",
".",
"Note",
"that",
"the",
"Virtua... | python | train |
persephone-tools/persephone | persephone/utils.py | https://github.com/persephone-tools/persephone/blob/f94c63e4d5fe719fb1deba449b177bb299d225fb/persephone/utils.py#L117-L130 | def get_prefixes(dirname: str, extension: str) -> List[str]:
""" Returns a list of prefixes to files in the directory (which might be a whole
corpus, or a train/valid/test subset. The prefixes include the path leading
up to it, but only the filename up until the first observed period '.'
"""
prefix... | [
"def",
"get_prefixes",
"(",
"dirname",
":",
"str",
",",
"extension",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"prefixes",
"=",
"[",
"]",
"for",
"root",
",",
"_",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"dirname",
")",
":",
"fo... | Returns a list of prefixes to files in the directory (which might be a whole
corpus, or a train/valid/test subset. The prefixes include the path leading
up to it, but only the filename up until the first observed period '.' | [
"Returns",
"a",
"list",
"of",
"prefixes",
"to",
"files",
"in",
"the",
"directory",
"(",
"which",
"might",
"be",
"a",
"whole",
"corpus",
"or",
"a",
"train",
"/",
"valid",
"/",
"test",
"subset",
".",
"The",
"prefixes",
"include",
"the",
"path",
"leading",
... | python | train |
quantmind/pulsar | pulsar/utils/config.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/config.py#L613-L641 | def add_argument(self, parser, set_default=False):
"""Add this :class:`Setting` to the ``parser``.
The operation is carried out only if :attr:`flags` or
:attr:`nargs` and :attr:`name` are defined.
"""
default = self.default if set_default else None
kwargs = dict(
... | [
"def",
"add_argument",
"(",
"self",
",",
"parser",
",",
"set_default",
"=",
"False",
")",
":",
"default",
"=",
"self",
".",
"default",
"if",
"set_default",
"else",
"None",
"kwargs",
"=",
"dict",
"(",
"nargs",
"=",
"self",
".",
"nargs",
",",
"default",
... | Add this :class:`Setting` to the ``parser``.
The operation is carried out only if :attr:`flags` or
:attr:`nargs` and :attr:`name` are defined. | [
"Add",
"this",
":",
"class",
":",
"Setting",
"to",
"the",
"parser",
"."
] | python | train |
google/python-gflags | gflags2man.py | https://github.com/google/python-gflags/blob/4f06c3d0d6cbe9b1fb90ee9fb1c082b3bf9285f6/gflags2man.py#L274-L321 | def ParsePythonFlags(self, start_line=0):
"""Parse python/swig style flags."""
modname = None # name of current module
modlist = []
flag = None
for line_num in range(start_line, len(self.output)): # collect flags
line = self.output[line_num].rstrip()
if not line: ... | [
"def",
"ParsePythonFlags",
"(",
"self",
",",
"start_line",
"=",
"0",
")",
":",
"modname",
"=",
"None",
"# name of current module",
"modlist",
"=",
"[",
"]",
"flag",
"=",
"None",
"for",
"line_num",
"in",
"range",
"(",
"start_line",
",",
"len",
"(",
"self",
... | Parse python/swig style flags. | [
"Parse",
"python",
"/",
"swig",
"style",
"flags",
"."
] | python | train |
quodlibet/mutagen | mutagen/easymp4.py | https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/easymp4.py#L152-L180 | def RegisterFreeformKey(cls, key, name, mean="com.apple.iTunes"):
"""Register a text key.
If the key you need to register is a simple one-to-one mapping
of MP4 freeform atom (----) and name to EasyMP4Tags key, then
you can use this function::
EasyMP4Tags.RegisterFreeformKey... | [
"def",
"RegisterFreeformKey",
"(",
"cls",
",",
"key",
",",
"name",
",",
"mean",
"=",
"\"com.apple.iTunes\"",
")",
":",
"atomid",
"=",
"\"----:\"",
"+",
"mean",
"+",
"\":\"",
"+",
"name",
"def",
"getter",
"(",
"tags",
",",
"key",
")",
":",
"return",
"["... | Register a text key.
If the key you need to register is a simple one-to-one mapping
of MP4 freeform atom (----) and name to EasyMP4Tags key, then
you can use this function::
EasyMP4Tags.RegisterFreeformKey(
"musicbrainz_artistid", "MusicBrainz Artist Id") | [
"Register",
"a",
"text",
"key",
"."
] | python | train |
SmokinCaterpillar/pypet | pypet/utils/explore.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/utils/explore.py#L66-L108 | def find_unique_points(explored_parameters):
"""Takes a list of explored parameters and finds unique parameter combinations.
If parameter ranges are hashable operates in O(N), otherwise O(N**2).
:param explored_parameters:
List of **explored** parameters
:return:
List of tuples, fir... | [
"def",
"find_unique_points",
"(",
"explored_parameters",
")",
":",
"ranges",
"=",
"[",
"param",
".",
"f_get_range",
"(",
"copy",
"=",
"False",
")",
"for",
"param",
"in",
"explored_parameters",
"]",
"zipped_tuples",
"=",
"list",
"(",
"zip",
"(",
"*",
"ranges"... | Takes a list of explored parameters and finds unique parameter combinations.
If parameter ranges are hashable operates in O(N), otherwise O(N**2).
:param explored_parameters:
List of **explored** parameters
:return:
List of tuples, first entry being the parameter values, second entry a ... | [
"Takes",
"a",
"list",
"of",
"explored",
"parameters",
"and",
"finds",
"unique",
"parameter",
"combinations",
"."
] | python | test |
nerdvegas/rez | src/support/package_utils/set_authors.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/support/package_utils/set_authors.py#L5-L21 | def set_authors(data):
"""Add 'authors' attribute based on repo contributions
"""
if "authors" in data:
return
shfile = os.path.join(os.path.dirname(__file__), "get_committers.sh")
p = subprocess.Popen(["bash", shfile], stdout=subprocess.PIPE)
out, _ = p.communicate()
if p.returnco... | [
"def",
"set_authors",
"(",
"data",
")",
":",
"if",
"\"authors\"",
"in",
"data",
":",
"return",
"shfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"get_committers.sh\"",
")",
"p",
"=",
"... | Add 'authors' attribute based on repo contributions | [
"Add",
"authors",
"attribute",
"based",
"on",
"repo",
"contributions"
] | python | train |
aiortc/aiortc | aiortc/rtcrtpreceiver.py | https://github.com/aiortc/aiortc/blob/60ed036abf4575bd63985724b4493d569e6da29b/aiortc/rtcrtpreceiver.py#L493-L499 | async def _send_rtcp_pli(self, media_ssrc):
"""
Send an RTCP packet to report picture loss.
"""
if self.__rtcp_ssrc is not None:
packet = RtcpPsfbPacket(fmt=RTCP_PSFB_PLI, ssrc=self.__rtcp_ssrc, media_ssrc=media_ssrc)
await self._send_rtcp(packet) | [
"async",
"def",
"_send_rtcp_pli",
"(",
"self",
",",
"media_ssrc",
")",
":",
"if",
"self",
".",
"__rtcp_ssrc",
"is",
"not",
"None",
":",
"packet",
"=",
"RtcpPsfbPacket",
"(",
"fmt",
"=",
"RTCP_PSFB_PLI",
",",
"ssrc",
"=",
"self",
".",
"__rtcp_ssrc",
",",
... | Send an RTCP packet to report picture loss. | [
"Send",
"an",
"RTCP",
"packet",
"to",
"report",
"picture",
"loss",
"."
] | python | train |
AtteqCom/zsl | src/zsl/utils/cache_helper.py | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/cache_helper.py#L181-L194 | def create_key_for_data(prefix, data, key_params):
"""
From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator)
"""
d = data.get_data()
values = []
for k in key_params:
if k in d and type(d[k]) is list:
values.append("{0}:{1}".f... | [
"def",
"create_key_for_data",
"(",
"prefix",
",",
"data",
",",
"key_params",
")",
":",
"d",
"=",
"data",
".",
"get_data",
"(",
")",
"values",
"=",
"[",
"]",
"for",
"k",
"in",
"key_params",
":",
"if",
"k",
"in",
"d",
"and",
"type",
"(",
"d",
"[",
... | From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator) | [
"From",
"data",
"params",
"in",
"task",
"create",
"corresponding",
"key",
"with",
"help",
"of",
"key_params",
"(",
"defined",
"in",
"decorator",
")"
] | python | train |
CityOfZion/neo-python | neo/SmartContract/ContractParameter.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/SmartContract/ContractParameter.py#L27-L53 | def ToParameter(item: StackItem):
"""
Convert a StackItem to a ContractParameter object
Args:
item (neo.VM.InteropService.StackItem) The item to convert to a ContractParameter object
Returns:
ContractParameter
"""
if isinstance(item, Array) or i... | [
"def",
"ToParameter",
"(",
"item",
":",
"StackItem",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"Array",
")",
"or",
"isinstance",
"(",
"item",
",",
"Struct",
")",
":",
"items",
"=",
"item",
".",
"GetArray",
"(",
")",
"output",
"=",
"[",
"Contrac... | Convert a StackItem to a ContractParameter object
Args:
item (neo.VM.InteropService.StackItem) The item to convert to a ContractParameter object
Returns:
ContractParameter | [
"Convert",
"a",
"StackItem",
"to",
"a",
"ContractParameter",
"object"
] | python | train |
mitodl/PyLmod | pylmod/gradebook.py | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L723-L838 | def get_students(
self,
gradebook_id='',
simple=False,
section_name='',
include_photo=False,
include_grade_info=False,
include_grade_history=False,
include_makeup_grades=False
):
"""Get students for a gradebook.
... | [
"def",
"get_students",
"(",
"self",
",",
"gradebook_id",
"=",
"''",
",",
"simple",
"=",
"False",
",",
"section_name",
"=",
"''",
",",
"include_photo",
"=",
"False",
",",
"include_grade_info",
"=",
"False",
",",
"include_grade_history",
"=",
"False",
",",
"in... | Get students for a gradebook.
Get a list of students for a given gradebook,
specified by a gradebook id. Does not include grade data.
Args:
gradebook_id (str): unique identifier for gradebook, i.e. ``2314``
simple (bool):
if ``True``, just return diction... | [
"Get",
"students",
"for",
"a",
"gradebook",
"."
] | python | train |
bububa/pyTOP | pyTOP/category.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/category.py#L63-L75 | def get(self, parent_cid=None, cids=[], fields=[]):
'''taobao.itemcats.get 获取后台供卖家发布商品的标准商品类目'''
request = TOPRequest('taobao.itemcats.get')
if not fields:
itemCat = ItemCat()
fields = itemCat.fields
request['fields'] = fields
if parent_cid!=None:
... | [
"def",
"get",
"(",
"self",
",",
"parent_cid",
"=",
"None",
",",
"cids",
"=",
"[",
"]",
",",
"fields",
"=",
"[",
"]",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'taobao.itemcats.get'",
")",
"if",
"not",
"fields",
":",
"itemCat",
"=",
"ItemCat",
"("... | taobao.itemcats.get 获取后台供卖家发布商品的标准商品类目 | [
"taobao",
".",
"itemcats",
".",
"get",
"获取后台供卖家发布商品的标准商品类目"
] | python | train |
Scoppio/RagnarokEngine3 | RagnarokEngine3/RE3.py | https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L2526-L2531 | def is_any_down(self):
"""Is any button depressed?"""
for key in range(len(self.current_state.key_states)):
if self.is_down(key):
return True
return False | [
"def",
"is_any_down",
"(",
"self",
")",
":",
"for",
"key",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"current_state",
".",
"key_states",
")",
")",
":",
"if",
"self",
".",
"is_down",
"(",
"key",
")",
":",
"return",
"True",
"return",
"False"
] | Is any button depressed? | [
"Is",
"any",
"button",
"depressed?"
] | python | train |
saltstack/salt | salt/modules/swift.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/swift.py#L179-L202 | def put(cont, path=None, local_file=None, profile=None):
'''
Create a new container, or upload an object to a container.
CLI Example to create a container:
.. code-block:: bash
salt myminion swift.put mycontainer
CLI Example to upload an object to a container:
.. code-block:: bash
... | [
"def",
"put",
"(",
"cont",
",",
"path",
"=",
"None",
",",
"local_file",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"swift_conn",
"=",
"_auth",
"(",
"profile",
")",
"if",
"path",
"is",
"None",
":",
"return",
"swift_conn",
".",
"put_container",
... | Create a new container, or upload an object to a container.
CLI Example to create a container:
.. code-block:: bash
salt myminion swift.put mycontainer
CLI Example to upload an object to a container:
.. code-block:: bash
salt myminion swift.put mycontainer remotepath local_file=/pa... | [
"Create",
"a",
"new",
"container",
"or",
"upload",
"an",
"object",
"to",
"a",
"container",
"."
] | python | train |
google/transitfeed | kmlwriter.py | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L213-L242 | def _CreateLineString(self, parent, coordinate_list):
"""Create a KML LineString element.
The points of the string are given in coordinate_list. Every element of
coordinate_list should be one of a tuple (longitude, latitude) or a tuple
(longitude, latitude, altitude).
Args:
parent: The paren... | [
"def",
"_CreateLineString",
"(",
"self",
",",
"parent",
",",
"coordinate_list",
")",
":",
"if",
"not",
"coordinate_list",
":",
"return",
"None",
"linestring",
"=",
"ET",
".",
"SubElement",
"(",
"parent",
",",
"'LineString'",
")",
"tessellate",
"=",
"ET",
"."... | Create a KML LineString element.
The points of the string are given in coordinate_list. Every element of
coordinate_list should be one of a tuple (longitude, latitude) or a tuple
(longitude, latitude, altitude).
Args:
parent: The parent ElementTree.Element instance.
coordinate_list: The li... | [
"Create",
"a",
"KML",
"LineString",
"element",
"."
] | python | train |
jacebrowning/comparable | comparable/base.py | https://github.com/jacebrowning/comparable/blob/48455e613650e22412d31109681368fcc479298d/comparable/base.py#L127-L132 | def equal(obj1, obj2):
"""Calculate equality between two (Comparable) objects."""
Comparable.log(obj1, obj2, '==')
equality = obj1.equality(obj2)
Comparable.log(obj1, obj2, '==', result=equality)
return equality | [
"def",
"equal",
"(",
"obj1",
",",
"obj2",
")",
":",
"Comparable",
".",
"log",
"(",
"obj1",
",",
"obj2",
",",
"'=='",
")",
"equality",
"=",
"obj1",
".",
"equality",
"(",
"obj2",
")",
"Comparable",
".",
"log",
"(",
"obj1",
",",
"obj2",
",",
"'=='",
... | Calculate equality between two (Comparable) objects. | [
"Calculate",
"equality",
"between",
"two",
"(",
"Comparable",
")",
"objects",
"."
] | python | train |
nerdvegas/rez | src/rez/utils/backcompat.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/backcompat.py#L40-L48 | def convert_old_command_expansions(command):
"""Convert expansions from !OLD! style to {new}."""
command = command.replace("!VERSION!", "{version}")
command = command.replace("!MAJOR_VERSION!", "{version.major}")
command = command.replace("!MINOR_VERSION!", "{version.minor}")
command = command... | [
"def",
"convert_old_command_expansions",
"(",
"command",
")",
":",
"command",
"=",
"command",
".",
"replace",
"(",
"\"!VERSION!\"",
",",
"\"{version}\"",
")",
"command",
"=",
"command",
".",
"replace",
"(",
"\"!MAJOR_VERSION!\"",
",",
"\"{version.major}\"",
")",
"... | Convert expansions from !OLD! style to {new}. | [
"Convert",
"expansions",
"from",
"!OLD!",
"style",
"to",
"{",
"new",
"}",
"."
] | python | train |
pkgw/pwkit | pwkit/kwargv.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/kwargv.py#L381-L461 | def parse(self, args=None):
"""Parse textual keywords as described by this class’s attributes, and update
this instance’s attributes with the parsed values. *args* is a list of
strings; if ``None``, it defaults to ``sys.argv[1:]``. Returns *self*
for convenience. Raises :exc:`KwargvError... | [
"def",
"parse",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"import",
"sys",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"seen",
"=",
"set",
"(",
")",
"for",
"arg",
"in",
"args",
":",
"t",
"=",
... | Parse textual keywords as described by this class’s attributes, and update
this instance’s attributes with the parsed values. *args* is a list of
strings; if ``None``, it defaults to ``sys.argv[1:]``. Returns *self*
for convenience. Raises :exc:`KwargvError` if invalid keywords are
encou... | [
"Parse",
"textual",
"keywords",
"as",
"described",
"by",
"this",
"class’s",
"attributes",
"and",
"update",
"this",
"instance’s",
"attributes",
"with",
"the",
"parsed",
"values",
".",
"*",
"args",
"*",
"is",
"a",
"list",
"of",
"strings",
";",
"if",
"None",
... | python | train |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/tools.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/tools.py#L178-L248 | def on_button_release(self, event):
"""Write back changes
If one or more items have been moved, the new position are stored in the corresponding meta data and a signal
notifying the change is emitted.
:param event: The button event
"""
affected_models = {}
for ... | [
"def",
"on_button_release",
"(",
"self",
",",
"event",
")",
":",
"affected_models",
"=",
"{",
"}",
"for",
"inmotion",
"in",
"self",
".",
"_movable_items",
":",
"inmotion",
".",
"move",
"(",
"(",
"event",
".",
"x",
",",
"event",
".",
"y",
")",
")",
"r... | Write back changes
If one or more items have been moved, the new position are stored in the corresponding meta data and a signal
notifying the change is emitted.
:param event: The button event | [
"Write",
"back",
"changes"
] | python | train |
awslabs/serverless-application-model | samtranslator/plugins/globals/globals_plugin.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals_plugin.py#L20-L40 | def on_before_transform_template(self, template_dict):
"""
Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
from the template (if present).
:param dict template_dict: SAM template as a dictionary
"""
try:
... | [
"def",
"on_before_transform_template",
"(",
"self",
",",
"template_dict",
")",
":",
"try",
":",
"global_section",
"=",
"Globals",
"(",
"template_dict",
")",
"except",
"InvalidGlobalsSectionException",
"as",
"ex",
":",
"raise",
"InvalidDocumentException",
"(",
"[",
"... | Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
from the template (if present).
:param dict template_dict: SAM template as a dictionary | [
"Hook",
"method",
"that",
"runs",
"before",
"a",
"template",
"gets",
"transformed",
".",
"In",
"this",
"method",
"we",
"parse",
"and",
"process",
"Globals",
"section",
"from",
"the",
"template",
"(",
"if",
"present",
")",
"."
] | python | train |
inasafe/inasafe | safe/gui/tools/minimum_needs/needs_manager_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L234-L240 | def populate_resource_list(self):
"""Populate the list resource list.
"""
minimum_needs = self.minimum_needs.get_full_needs()
for full_resource in minimum_needs["resources"]:
self.add_resource(full_resource)
self.provenance.setText(minimum_needs["provenance"]) | [
"def",
"populate_resource_list",
"(",
"self",
")",
":",
"minimum_needs",
"=",
"self",
".",
"minimum_needs",
".",
"get_full_needs",
"(",
")",
"for",
"full_resource",
"in",
"minimum_needs",
"[",
"\"resources\"",
"]",
":",
"self",
".",
"add_resource",
"(",
"full_re... | Populate the list resource list. | [
"Populate",
"the",
"list",
"resource",
"list",
"."
] | python | train |
knipknap/exscript | Exscript/account.py | https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/account.py#L123-L138 | def release(self, signal=True):
"""
Unlocks the account.
Method has no effect if the constructor argument `needs_lock`
wsa set to False.
:type signal: bool
:param signal: Whether to emit the released_event signal.
"""
if not self.needs_lock:
r... | [
"def",
"release",
"(",
"self",
",",
"signal",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"needs_lock",
":",
"return",
"with",
"self",
".",
"synclock",
":",
"self",
".",
"lock",
".",
"release",
"(",
")",
"if",
"signal",
":",
"self",
".",
"rele... | Unlocks the account.
Method has no effect if the constructor argument `needs_lock`
wsa set to False.
:type signal: bool
:param signal: Whether to emit the released_event signal. | [
"Unlocks",
"the",
"account",
".",
"Method",
"has",
"no",
"effect",
"if",
"the",
"constructor",
"argument",
"needs_lock",
"wsa",
"set",
"to",
"False",
"."
] | python | train |
ludeeus/pytautulli | pytautulli/__init__.py | https://github.com/ludeeus/pytautulli/blob/0cf602f6720a105abb2311c8fbc8c6b2f9581276/pytautulli/__init__.py#L72-L87 | async def get_session_data(self):
"""Get Tautulli sessions."""
cmd = 'get_activity'
url = self.base_url + cmd
try:
async with async_timeout.timeout(8, loop=self._loop):
response = await self._session.get(url)
logger("Status from Tautulli: " + str(... | [
"async",
"def",
"get_session_data",
"(",
"self",
")",
":",
"cmd",
"=",
"'get_activity'",
"url",
"=",
"self",
".",
"base_url",
"+",
"cmd",
"try",
":",
"async",
"with",
"async_timeout",
".",
"timeout",
"(",
"8",
",",
"loop",
"=",
"self",
".",
"_loop",
")... | Get Tautulli sessions. | [
"Get",
"Tautulli",
"sessions",
"."
] | python | train |
wbond/oscrypto | oscrypto/_win/asymmetric.py | https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_win/asymmetric.py#L2945-L2994 | def _encrypt(certificate_or_public_key, data, rsa_oaep_padding=False):
"""
Encrypts a value using an RSA public key
:param certificate_or_public_key:
A Certificate or PublicKey instance to encrypt with
:param data:
A byte string of the data to encrypt
:param rsa_oaep_padding:
... | [
"def",
"_encrypt",
"(",
"certificate_or_public_key",
",",
"data",
",",
"rsa_oaep_padding",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"certificate_or_public_key",
",",
"(",
"Certificate",
",",
"PublicKey",
")",
")",
":",
"raise",
"TypeError",
"(",
... | Encrypts a value using an RSA public key
:param certificate_or_public_key:
A Certificate or PublicKey instance to encrypt with
:param data:
A byte string of the data to encrypt
:param rsa_oaep_padding:
If OAEP padding should be used instead of PKCS#1 v1.5
:raises:
Val... | [
"Encrypts",
"a",
"value",
"using",
"an",
"RSA",
"public",
"key"
] | python | valid |
google/grr | api_client/python/grr_api_client/client.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L179-L203 | def CreateApproval(self,
reason=None,
notified_users=None,
email_cc_addresses=None,
keep_client_alive=False):
"""Create a new approval for the current user to access this client."""
if not reason:
raise ValueError("reason... | [
"def",
"CreateApproval",
"(",
"self",
",",
"reason",
"=",
"None",
",",
"notified_users",
"=",
"None",
",",
"email_cc_addresses",
"=",
"None",
",",
"keep_client_alive",
"=",
"False",
")",
":",
"if",
"not",
"reason",
":",
"raise",
"ValueError",
"(",
"\"reason ... | Create a new approval for the current user to access this client. | [
"Create",
"a",
"new",
"approval",
"for",
"the",
"current",
"user",
"to",
"access",
"this",
"client",
"."
] | python | train |
MartinThoma/hwrt | hwrt/utils.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L64-L70 | def is_valid_folder(parser, arg):
"""Check if arg is a valid file that already exists on the file system."""
arg = os.path.abspath(arg)
if not os.path.isdir(arg):
parser.error("The folder %s does not exist!" % arg)
else:
return arg | [
"def",
"is_valid_folder",
"(",
"parser",
",",
"arg",
")",
":",
"arg",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"arg",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"arg",
")",
":",
"parser",
".",
"error",
"(",
"\"The folder %s does not ... | Check if arg is a valid file that already exists on the file system. | [
"Check",
"if",
"arg",
"is",
"a",
"valid",
"file",
"that",
"already",
"exists",
"on",
"the",
"file",
"system",
"."
] | python | train |
radjkarl/imgProcessor | imgProcessor/transformations.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L138-L146 | def rgChromaticity(img):
'''
returns the normalized RGB space (RGB/intensity)
see https://en.wikipedia.org/wiki/Rg_chromaticity
'''
out = _calc(img)
if img.dtype == np.uint8:
out = (255 * out).astype(np.uint8)
return out | [
"def",
"rgChromaticity",
"(",
"img",
")",
":",
"out",
"=",
"_calc",
"(",
"img",
")",
"if",
"img",
".",
"dtype",
"==",
"np",
".",
"uint8",
":",
"out",
"=",
"(",
"255",
"*",
"out",
")",
".",
"astype",
"(",
"np",
".",
"uint8",
")",
"return",
"out"... | returns the normalized RGB space (RGB/intensity)
see https://en.wikipedia.org/wiki/Rg_chromaticity | [
"returns",
"the",
"normalized",
"RGB",
"space",
"(",
"RGB",
"/",
"intensity",
")",
"see",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rg_chromaticity"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Scanner/Dir.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Scanner/Dir.py#L39-L44 | def DirEntryScanner(**kw):
"""Return a prototype Scanner instance for "scanning"
directory Nodes for their in-memory entries"""
kw['node_factory'] = SCons.Node.FS.Entry
kw['recursive'] = None
return SCons.Scanner.Base(scan_in_memory, "DirEntryScanner", **kw) | [
"def",
"DirEntryScanner",
"(",
"*",
"*",
"kw",
")",
":",
"kw",
"[",
"'node_factory'",
"]",
"=",
"SCons",
".",
"Node",
".",
"FS",
".",
"Entry",
"kw",
"[",
"'recursive'",
"]",
"=",
"None",
"return",
"SCons",
".",
"Scanner",
".",
"Base",
"(",
"scan_in_m... | Return a prototype Scanner instance for "scanning"
directory Nodes for their in-memory entries | [
"Return",
"a",
"prototype",
"Scanner",
"instance",
"for",
"scanning",
"directory",
"Nodes",
"for",
"their",
"in",
"-",
"memory",
"entries"
] | python | train |
materialsproject/pymatgen | pymatgen/io/vasp/inputs.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/inputs.py#L1141-L1175 | def automatic_linemode(divisions, ibz):
"""
Convenient static constructor for a KPOINTS in mode line_mode.
gamma centered Monkhorst-Pack grids and the number of subdivisions
along each reciprocal lattice vector determined by the scheme in the
VASP manual.
Args:
... | [
"def",
"automatic_linemode",
"(",
"divisions",
",",
"ibz",
")",
":",
"kpoints",
"=",
"list",
"(",
")",
"labels",
"=",
"list",
"(",
")",
"for",
"path",
"in",
"ibz",
".",
"kpath",
"[",
"\"path\"",
"]",
":",
"kpoints",
".",
"append",
"(",
"ibz",
".",
... | Convenient static constructor for a KPOINTS in mode line_mode.
gamma centered Monkhorst-Pack grids and the number of subdivisions
along each reciprocal lattice vector determined by the scheme in the
VASP manual.
Args:
divisions: Parameter determining the number of k-points a... | [
"Convenient",
"static",
"constructor",
"for",
"a",
"KPOINTS",
"in",
"mode",
"line_mode",
".",
"gamma",
"centered",
"Monkhorst",
"-",
"Pack",
"grids",
"and",
"the",
"number",
"of",
"subdivisions",
"along",
"each",
"reciprocal",
"lattice",
"vector",
"determined",
... | python | train |
Yelp/py_zipkin | py_zipkin/logging_helper.py | https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/logging_helper.py#L71-L96 | def emit_spans(self):
"""Main function to log all the annotations stored during the entire
request. This is done if the request is sampled and the response was
a success. It also logs the service (`ss` and `sr`) or the client
('cs' and 'cr') annotations.
"""
# FIXME: Sho... | [
"def",
"emit_spans",
"(",
"self",
")",
":",
"# FIXME: Should have a single aggregate handler",
"if",
"self",
".",
"firehose_handler",
":",
"# FIXME: We need to allow different batching settings per handler",
"self",
".",
"_emit_spans_with_span_sender",
"(",
"ZipkinBatchSender",
"... | Main function to log all the annotations stored during the entire
request. This is done if the request is sampled and the response was
a success. It also logs the service (`ss` and `sr`) or the client
('cs' and 'cr') annotations. | [
"Main",
"function",
"to",
"log",
"all",
"the",
"annotations",
"stored",
"during",
"the",
"entire",
"request",
".",
"This",
"is",
"done",
"if",
"the",
"request",
"is",
"sampled",
"and",
"the",
"response",
"was",
"a",
"success",
".",
"It",
"also",
"logs",
... | python | test |
klahnakoski/pyLibrary | jx_python/meta.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/meta.py#L537-L543 | def get_schema_from_list(table_name, frum):
"""
SCAN THE LIST FOR COLUMN TYPES
"""
columns = UniqueIndex(keys=("name",))
_get_schema_from_list(frum, ".", parent=".", nested_path=ROOT_PATH, columns=columns)
return Schema(table_name=table_name, columns=list(columns)) | [
"def",
"get_schema_from_list",
"(",
"table_name",
",",
"frum",
")",
":",
"columns",
"=",
"UniqueIndex",
"(",
"keys",
"=",
"(",
"\"name\"",
",",
")",
")",
"_get_schema_from_list",
"(",
"frum",
",",
"\".\"",
",",
"parent",
"=",
"\".\"",
",",
"nested_path",
"... | SCAN THE LIST FOR COLUMN TYPES | [
"SCAN",
"THE",
"LIST",
"FOR",
"COLUMN",
"TYPES"
] | python | train |
makinacorpus/landez | landez/tiles.py | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L188-L193 | def grid(self, z_x_y):
""" Return the UTFGrid content """
# sources.py -> MapnikRenderer -> grid
(z, x, y) = z_x_y
content = self.reader.grid(z, x, y, self.grid_fields, self.grid_layer)
return content | [
"def",
"grid",
"(",
"self",
",",
"z_x_y",
")",
":",
"# sources.py -> MapnikRenderer -> grid",
"(",
"z",
",",
"x",
",",
"y",
")",
"=",
"z_x_y",
"content",
"=",
"self",
".",
"reader",
".",
"grid",
"(",
"z",
",",
"x",
",",
"y",
",",
"self",
".",
"grid... | Return the UTFGrid content | [
"Return",
"the",
"UTFGrid",
"content"
] | python | train |
pgjones/quart | quart/logging.py | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/logging.py#L15-L27 | def create_logger(app: 'Quart') -> Logger:
"""Create a logger for the app based on the app settings.
This creates a logger named quart.app that has a log level based
on the app configuration.
"""
logger = getLogger('quart.app')
if app.debug and logger.level == NOTSET:
logger.setLevel(D... | [
"def",
"create_logger",
"(",
"app",
":",
"'Quart'",
")",
"->",
"Logger",
":",
"logger",
"=",
"getLogger",
"(",
"'quart.app'",
")",
"if",
"app",
".",
"debug",
"and",
"logger",
".",
"level",
"==",
"NOTSET",
":",
"logger",
".",
"setLevel",
"(",
"DEBUG",
"... | Create a logger for the app based on the app settings.
This creates a logger named quart.app that has a log level based
on the app configuration. | [
"Create",
"a",
"logger",
"for",
"the",
"app",
"based",
"on",
"the",
"app",
"settings",
"."
] | python | train |
HDI-Project/RDT | rdt/hyper_transformer.py | https://github.com/HDI-Project/RDT/blob/b28fdd671a1d7fbd14983eefe0cfbd8d87ded92a/rdt/hyper_transformer.py#L306-L336 | def reverse_transform_table(self, table, table_meta, missing=None):
"""Transform a `table` back to its original format.
Args:
table(pandas.DataFrame): Contents of the table to be transformed.
table_meta(dict): Metadata for the given table.
missing(bool): ... | [
"def",
"reverse_transform_table",
"(",
"self",
",",
"table",
",",
"table_meta",
",",
"missing",
"=",
"None",
")",
":",
"if",
"missing",
"is",
"None",
":",
"missing",
"=",
"self",
".",
"missing",
"else",
":",
"self",
".",
"missing",
"=",
"missing",
"warni... | Transform a `table` back to its original format.
Args:
table(pandas.DataFrame): Contents of the table to be transformed.
table_meta(dict): Metadata for the given table.
missing(bool): Wheter or not use NullTransformer to handle missing values.
Returns:
... | [
"Transform",
"a",
"table",
"back",
"to",
"its",
"original",
"format",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/alchemy/materials.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/alchemy/materials.py#L300-L318 | def from_poscar_string(poscar_string, transformations=None):
"""
Generates TransformedStructure from a poscar string.
Args:
poscar_string (str): Input POSCAR string.
transformations ([Transformations]): Sequence of transformations
to be applied to the inp... | [
"def",
"from_poscar_string",
"(",
"poscar_string",
",",
"transformations",
"=",
"None",
")",
":",
"p",
"=",
"Poscar",
".",
"from_string",
"(",
"poscar_string",
")",
"if",
"not",
"p",
".",
"true_names",
":",
"raise",
"ValueError",
"(",
"\"Transformation can be cr... | Generates TransformedStructure from a poscar string.
Args:
poscar_string (str): Input POSCAR string.
transformations ([Transformations]): Sequence of transformations
to be applied to the input structure. | [
"Generates",
"TransformedStructure",
"from",
"a",
"poscar",
"string",
"."
] | python | train |
ralphje/imagemounter | imagemounter/parser.py | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L130-L139 | def init_volumes(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True):
"""Detects volumes (as volume system or as single volume) in all disks and yields the volumes. This calls
:func:`Disk.init_volumes` on all disks and should be called after :func:`mount_disks`.
:rtype... | [
"def",
"init_volumes",
"(",
"self",
",",
"single",
"=",
"None",
",",
"only_mount",
"=",
"None",
",",
"skip_mount",
"=",
"None",
",",
"swallow_exceptions",
"=",
"True",
")",
":",
"for",
"disk",
"in",
"self",
".",
"disks",
":",
"logger",
".",
"info",
"("... | Detects volumes (as volume system or as single volume) in all disks and yields the volumes. This calls
:func:`Disk.init_volumes` on all disks and should be called after :func:`mount_disks`.
:rtype: generator | [
"Detects",
"volumes",
"(",
"as",
"volume",
"system",
"or",
"as",
"single",
"volume",
")",
"in",
"all",
"disks",
"and",
"yields",
"the",
"volumes",
".",
"This",
"calls",
":",
"func",
":",
"Disk",
".",
"init_volumes",
"on",
"all",
"disks",
"and",
"should",... | python | train |
mozilla-releng/scriptworker | scriptworker/artifacts.py | https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L80-L108 | def compress_artifact_if_supported(artifact_path):
"""Compress artifacts with GZip if they're known to be supported.
This replaces the artifact given by a gzip binary.
Args:
artifact_path (str): the path to compress
Returns:
content_type, content_encoding (tuple): Type and encoding o... | [
"def",
"compress_artifact_if_supported",
"(",
"artifact_path",
")",
":",
"content_type",
",",
"encoding",
"=",
"guess_content_type_and_encoding",
"(",
"artifact_path",
")",
"log",
".",
"debug",
"(",
"'\"{}\" is encoded with \"{}\" and has mime/type \"{}\"'",
".",
"format",
... | Compress artifacts with GZip if they're known to be supported.
This replaces the artifact given by a gzip binary.
Args:
artifact_path (str): the path to compress
Returns:
content_type, content_encoding (tuple): Type and encoding of the file. Encoding equals 'gzip' if compressed. | [
"Compress",
"artifacts",
"with",
"GZip",
"if",
"they",
"re",
"known",
"to",
"be",
"supported",
"."
] | python | train |
haikuginger/beekeeper | beekeeper/exceptions.py | https://github.com/haikuginger/beekeeper/blob/b647d3add0b407ec5dc3a2a39c4f6dac31243b18/beekeeper/exceptions.py#L71-L93 | def top_level(self):
"""
Print just the top level of an object, being sure to show where
it goes deeper
"""
output = {}
if isinstance(self.obj, dict):
for name, item in self.obj.items():
if isinstance(item, dict):
if item:
... | [
"def",
"top_level",
"(",
"self",
")",
":",
"output",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"self",
".",
"obj",
",",
"dict",
")",
":",
"for",
"name",
",",
"item",
"in",
"self",
".",
"obj",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
... | Print just the top level of an object, being sure to show where
it goes deeper | [
"Print",
"just",
"the",
"top",
"level",
"of",
"an",
"object",
"being",
"sure",
"to",
"show",
"where",
"it",
"goes",
"deeper"
] | python | train |
bitesofcode/projexui | projexui/widgets/xtablewidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtablewidget.py#L188-L198 | def mimeData( self, items ):
"""
Returns the mime data for dragging for this instance.
:param items | [<QTableWidgetItem>, ..]
"""
func = self.dataCollector()
if ( func ):
return func(self, items)
return super(XTableWidget, s... | [
"def",
"mimeData",
"(",
"self",
",",
"items",
")",
":",
"func",
"=",
"self",
".",
"dataCollector",
"(",
")",
"if",
"(",
"func",
")",
":",
"return",
"func",
"(",
"self",
",",
"items",
")",
"return",
"super",
"(",
"XTableWidget",
",",
"self",
")",
".... | Returns the mime data for dragging for this instance.
:param items | [<QTableWidgetItem>, ..] | [
"Returns",
"the",
"mime",
"data",
"for",
"dragging",
"for",
"this",
"instance",
".",
":",
"param",
"items",
"|",
"[",
"<QTableWidgetItem",
">",
"..",
"]"
] | python | train |
google/grr | grr/server/grr_response_server/console_utils.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/console_utils.py#L177-L194 | def ApprovalGrant(token=None):
"""Iterate through requested access approving or not."""
user = getpass.getuser()
notifications = GetNotifications(user=user, token=token)
requests = [n for n in notifications if n.type == "GrantAccess"]
for request in requests:
_, client_id, user, reason = rdfvalue.RDFURN(r... | [
"def",
"ApprovalGrant",
"(",
"token",
"=",
"None",
")",
":",
"user",
"=",
"getpass",
".",
"getuser",
"(",
")",
"notifications",
"=",
"GetNotifications",
"(",
"user",
"=",
"user",
",",
"token",
"=",
"token",
")",
"requests",
"=",
"[",
"n",
"for",
"n",
... | Iterate through requested access approving or not. | [
"Iterate",
"through",
"requested",
"access",
"approving",
"or",
"not",
"."
] | python | train |
robinandeer/puzzle | puzzle/cli/base.py | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/cli/base.py#L25-L35 | def base(ctx, verbose, config):
"""Puzzle: manage DNA variant resources."""
# configure root logger to print to STDERR
loglevel = LEVELS.get(min(verbose, 3))
configure_stream(level=loglevel)
ctx.obj = {}
if config and os.path.exists(config):
ctx.obj = yaml.load(open(config, 'r')) or {}
... | [
"def",
"base",
"(",
"ctx",
",",
"verbose",
",",
"config",
")",
":",
"# configure root logger to print to STDERR",
"loglevel",
"=",
"LEVELS",
".",
"get",
"(",
"min",
"(",
"verbose",
",",
"3",
")",
")",
"configure_stream",
"(",
"level",
"=",
"loglevel",
")",
... | Puzzle: manage DNA variant resources. | [
"Puzzle",
":",
"manage",
"DNA",
"variant",
"resources",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.