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 |
|---|---|---|---|---|---|---|---|---|
vsjha18/nsetools | nse.py | https://github.com/vsjha18/nsetools/blob/c306b568471701c19195d2f17e112cc92022d3e0/nse.py#L434-L448 | def download_bhavcopy(self, d):
"""returns bhavcopy as csv file."""
# ex_url = "https://www.nseindia.com/content/historical/EQUITIES/2011/NOV/cm08NOV2011bhav.csv.zip"
url = self.get_bhavcopy_url(d)
filename = self.get_bhavcopy_filename(d)
# response = requests.get(url, headers=se... | [
"def",
"download_bhavcopy",
"(",
"self",
",",
"d",
")",
":",
"# ex_url = \"https://www.nseindia.com/content/historical/EQUITIES/2011/NOV/cm08NOV2011bhav.csv.zip\"",
"url",
"=",
"self",
".",
"get_bhavcopy_url",
"(",
"d",
")",
"filename",
"=",
"self",
".",
"get_bhavcopy_filen... | returns bhavcopy as csv file. | [
"returns",
"bhavcopy",
"as",
"csv",
"file",
"."
] | python | train |
saltstack/salt | salt/modules/cimc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cimc.py#L55-L83 | def activate_backup_image(reset=False):
'''
Activates the firmware backup image.
CLI Example:
Args:
reset(bool): Reset the CIMC device on activate.
.. code-block:: bash
salt '*' cimc.activate_backup_image
salt '*' cimc.activate_backup_image reset=True
'''
dn = "... | [
"def",
"activate_backup_image",
"(",
"reset",
"=",
"False",
")",
":",
"dn",
"=",
"\"sys/rack-unit-1/mgmt/fw-boot-def/bootunit-combined\"",
"r",
"=",
"\"no\"",
"if",
"reset",
"is",
"True",
":",
"r",
"=",
"\"yes\"",
"inconfig",
"=",
"\"\"\"<firmwareBootUnit dn='sys/rack... | Activates the firmware backup image.
CLI Example:
Args:
reset(bool): Reset the CIMC device on activate.
.. code-block:: bash
salt '*' cimc.activate_backup_image
salt '*' cimc.activate_backup_image reset=True | [
"Activates",
"the",
"firmware",
"backup",
"image",
"."
] | python | train |
tensorlayer/tensorlayer | tensorlayer/cost.py | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L639-L683 | def maxnorm_o_regularizer(scale):
"""Max-norm output regularization removes the neurons of current layer.
Returns a function that can be used to apply max-norm regularization to each column of weight matrix.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master... | [
"def",
"maxnorm_o_regularizer",
"(",
"scale",
")",
":",
"if",
"isinstance",
"(",
"scale",
",",
"numbers",
".",
"Integral",
")",
":",
"raise",
"ValueError",
"(",
"'scale cannot be an integer: %s'",
"%",
"scale",
")",
"if",
"isinstance",
"(",
"scale",
",",
"numb... | Max-norm output regularization removes the neurons of current layer.
Returns a function that can be used to apply max-norm regularization to each column of weight matrix.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/... | [
"Max",
"-",
"norm",
"output",
"regularization",
"removes",
"the",
"neurons",
"of",
"current",
"layer",
".",
"Returns",
"a",
"function",
"that",
"can",
"be",
"used",
"to",
"apply",
"max",
"-",
"norm",
"regularization",
"to",
"each",
"column",
"of",
"weight",
... | python | valid |
panzarino/mlbgame | mlbgame/__init__.py | https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L238-L242 | def important_dates(year=None):
"""Return ImportantDates object that contains MLB important dates"""
year = datetime.now().year if not year else year
data = mlbgame.info.important_dates(year)
return mlbgame.info.ImportantDates(data) | [
"def",
"important_dates",
"(",
"year",
"=",
"None",
")",
":",
"year",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"year",
"if",
"not",
"year",
"else",
"year",
"data",
"=",
"mlbgame",
".",
"info",
".",
"important_dates",
"(",
"year",
")",
"return",
"m... | Return ImportantDates object that contains MLB important dates | [
"Return",
"ImportantDates",
"object",
"that",
"contains",
"MLB",
"important",
"dates"
] | python | train |
sendgrid/sendgrid-python | sendgrid/helpers/mail/mail.py | https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L812-L818 | def add_section(self, section):
"""A block section of code to be used as substitutions
:param section: A block section of code to be used as substitutions
:type section: Section
"""
self._sections = self._ensure_append(section, self._sections) | [
"def",
"add_section",
"(",
"self",
",",
"section",
")",
":",
"self",
".",
"_sections",
"=",
"self",
".",
"_ensure_append",
"(",
"section",
",",
"self",
".",
"_sections",
")"
] | A block section of code to be used as substitutions
:param section: A block section of code to be used as substitutions
:type section: Section | [
"A",
"block",
"section",
"of",
"code",
"to",
"be",
"used",
"as",
"substitutions"
] | python | train |
ewiger/mlab | src/mlab/awmstools.py | https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L907-L914 | def iflatten(seq, isSeq=isSeq):
r"""Like `flatten` but lazy."""
for elt in seq:
if isSeq(elt):
for x in iflatten(elt, isSeq):
yield x
else:
yield elt | [
"def",
"iflatten",
"(",
"seq",
",",
"isSeq",
"=",
"isSeq",
")",
":",
"for",
"elt",
"in",
"seq",
":",
"if",
"isSeq",
"(",
"elt",
")",
":",
"for",
"x",
"in",
"iflatten",
"(",
"elt",
",",
"isSeq",
")",
":",
"yield",
"x",
"else",
":",
"yield",
"elt... | r"""Like `flatten` but lazy. | [
"r",
"Like",
"flatten",
"but",
"lazy",
"."
] | python | train |
numenta/nupic | setup.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/setup.py#L46-L62 | def nupicBindingsPrereleaseInstalled():
"""
Make an attempt to determine if a pre-release version of nupic.bindings is
installed already.
@return: boolean
"""
try:
nupicDistribution = pkg_resources.get_distribution("nupic.bindings")
if pkg_resources.parse_version(nupicDistribution.version).is_prere... | [
"def",
"nupicBindingsPrereleaseInstalled",
"(",
")",
":",
"try",
":",
"nupicDistribution",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"\"nupic.bindings\"",
")",
"if",
"pkg_resources",
".",
"parse_version",
"(",
"nupicDistribution",
".",
"version",
")",
".",
... | Make an attempt to determine if a pre-release version of nupic.bindings is
installed already.
@return: boolean | [
"Make",
"an",
"attempt",
"to",
"determine",
"if",
"a",
"pre",
"-",
"release",
"version",
"of",
"nupic",
".",
"bindings",
"is",
"installed",
"already",
"."
] | python | valid |
mattharrison/rst2odp | odplib/preso.py | https://github.com/mattharrison/rst2odp/blob/4adbf29b28c8207ec882f792ded07e98b1d3e7d0/odplib/preso.py#L930-L939 | def push_pending_node(self, name, attr):
"""
pending nodes are for affecting type, such as wrapping content
with text:a to make a hyperlink. Anything in pending nodes
will be written before the actual text.
User needs to remember to pop out of it.
"""
if self.cur... | [
"def",
"push_pending_node",
"(",
"self",
",",
"name",
",",
"attr",
")",
":",
"if",
"self",
".",
"cur_element",
"is",
"None",
":",
"self",
".",
"add_text_frame",
"(",
")",
"self",
".",
"cur_element",
".",
"pending_nodes",
".",
"append",
"(",
"(",
"name",
... | pending nodes are for affecting type, such as wrapping content
with text:a to make a hyperlink. Anything in pending nodes
will be written before the actual text.
User needs to remember to pop out of it. | [
"pending",
"nodes",
"are",
"for",
"affecting",
"type",
"such",
"as",
"wrapping",
"content",
"with",
"text",
":",
"a",
"to",
"make",
"a",
"hyperlink",
".",
"Anything",
"in",
"pending",
"nodes",
"will",
"be",
"written",
"before",
"the",
"actual",
"text",
"."... | python | train |
google/apitools | apitools/base/py/base_api.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/base_api.py#L511-L522 | def __CombineGlobalParams(self, global_params, default_params):
"""Combine the given params with the defaults."""
util.Typecheck(global_params, (type(None), self.__client.params_type))
result = self.__client.params_type()
global_params = global_params or self.__client.params_type()
... | [
"def",
"__CombineGlobalParams",
"(",
"self",
",",
"global_params",
",",
"default_params",
")",
":",
"util",
".",
"Typecheck",
"(",
"global_params",
",",
"(",
"type",
"(",
"None",
")",
",",
"self",
".",
"__client",
".",
"params_type",
")",
")",
"result",
"=... | Combine the given params with the defaults. | [
"Combine",
"the",
"given",
"params",
"with",
"the",
"defaults",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/bam/__init__.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/__init__.py#L406-L431 | def sort(in_bam, config, order="coordinate", out_dir=None):
"""Sort a BAM file, skipping if already present.
"""
assert is_bam(in_bam), "%s in not a BAM file" % in_bam
if bam_already_sorted(in_bam, config, order):
return in_bam
sort_stem = _get_sort_stem(in_bam, order, out_dir)
sort_fil... | [
"def",
"sort",
"(",
"in_bam",
",",
"config",
",",
"order",
"=",
"\"coordinate\"",
",",
"out_dir",
"=",
"None",
")",
":",
"assert",
"is_bam",
"(",
"in_bam",
")",
",",
"\"%s in not a BAM file\"",
"%",
"in_bam",
"if",
"bam_already_sorted",
"(",
"in_bam",
",",
... | Sort a BAM file, skipping if already present. | [
"Sort",
"a",
"BAM",
"file",
"skipping",
"if",
"already",
"present",
"."
] | python | train |
gissehel/supertools | supertools/__init__.py | https://github.com/gissehel/supertools/blob/566bb6f8869082b247d96cb1fd7ccf948e3ba30f/supertools/__init__.py#L1-L7 | def superable(cls) :
'''Provide .__super in python 2.x classes without having to specify the current
class name each time super is used (DRY principle).'''
name = cls.__name__
super_name = '_%s__super' % (name,)
setattr(cls,super_name,super(cls))
return cls | [
"def",
"superable",
"(",
"cls",
")",
":",
"name",
"=",
"cls",
".",
"__name__",
"super_name",
"=",
"'_%s__super'",
"%",
"(",
"name",
",",
")",
"setattr",
"(",
"cls",
",",
"super_name",
",",
"super",
"(",
"cls",
")",
")",
"return",
"cls"
] | Provide .__super in python 2.x classes without having to specify the current
class name each time super is used (DRY principle). | [
"Provide",
".",
"__super",
"in",
"python",
"2",
".",
"x",
"classes",
"without",
"having",
"to",
"specify",
"the",
"current",
"class",
"name",
"each",
"time",
"super",
"is",
"used",
"(",
"DRY",
"principle",
")",
"."
] | python | valid |
draios/python-sdc-client | sdcclient/_common.py | https://github.com/draios/python-sdc-client/blob/47f83415842048778939b90944f64386a3bcb205/sdcclient/_common.py#L620-L637 | def delete_user(self, user_email):
'''**Description**
Deletes a user from Sysdig Monitor.
**Arguments**
- **user_email**: the email address of the user that will be deleted from Sysdig Monitor
**Example**
`examples/user_team_mgmt.py <https://github.com/draio... | [
"def",
"delete_user",
"(",
"self",
",",
"user_email",
")",
":",
"res",
"=",
"self",
".",
"get_user_ids",
"(",
"[",
"user_email",
"]",
")",
"if",
"res",
"[",
"0",
"]",
"==",
"False",
":",
"return",
"res",
"userid",
"=",
"res",
"[",
"1",
"]",
"[",
... | **Description**
Deletes a user from Sysdig Monitor.
**Arguments**
- **user_email**: the email address of the user that will be deleted from Sysdig Monitor
**Example**
`examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_... | [
"**",
"Description",
"**",
"Deletes",
"a",
"user",
"from",
"Sysdig",
"Monitor",
"."
] | python | test |
sernst/cauldron | cauldron/session/projects/steps.py | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/steps.py#L97-L107 | def elapsed_time(self) -> float:
"""
The number of seconds that has elapsed since the step started running
if the step is still running. Or, if the step has already finished
running, the amount of time that elapsed during the last execution of
the step.
"""
curren... | [
"def",
"elapsed_time",
"(",
"self",
")",
"->",
"float",
":",
"current_time",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"start",
"=",
"self",
".",
"start_time",
"or",
"current_time",
"end",
"=",
"self",
".",
"end_time",
"or",
"current_time",
"return",
"(",
... | The number of seconds that has elapsed since the step started running
if the step is still running. Or, if the step has already finished
running, the amount of time that elapsed during the last execution of
the step. | [
"The",
"number",
"of",
"seconds",
"that",
"has",
"elapsed",
"since",
"the",
"step",
"started",
"running",
"if",
"the",
"step",
"is",
"still",
"running",
".",
"Or",
"if",
"the",
"step",
"has",
"already",
"finished",
"running",
"the",
"amount",
"of",
"time",... | python | train |
nielstron/pysyncthru | pysyncthru/__init__.py | https://github.com/nielstron/pysyncthru/blob/850a85ba0a74cbd5c408102bb02fd005d8b61ffb/pysyncthru/__init__.py#L161-L174 | def drum_status(self, filter_supported: bool = True) -> Dict[str, Any]:
"""Return the state of all drums."""
drum_status = {}
for color in self.COLOR_NAMES:
try:
drum_stat = self.data.get('{}_{}'.format(SyncThru.DRUM, color),
... | [
"def",
"drum_status",
"(",
"self",
",",
"filter_supported",
":",
"bool",
"=",
"True",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"drum_status",
"=",
"{",
"}",
"for",
"color",
"in",
"self",
".",
"COLOR_NAMES",
":",
"try",
":",
"drum_stat",
"... | Return the state of all drums. | [
"Return",
"the",
"state",
"of",
"all",
"drums",
"."
] | python | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L25-L51 | def find_latex_font_serif():
r'''
Find an available font to mimic LaTeX, and return its name.
'''
import os, re
import matplotlib.font_manager
name = lambda font: os.path.splitext(os.path.split(font)[-1])[0].split(' - ')[0]
fonts = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
... | [
"def",
"find_latex_font_serif",
"(",
")",
":",
"import",
"os",
",",
"re",
"import",
"matplotlib",
".",
"font_manager",
"name",
"=",
"lambda",
"font",
":",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"font",
")",
"[",
... | r'''
Find an available font to mimic LaTeX, and return its name. | [
"r",
"Find",
"an",
"available",
"font",
"to",
"mimic",
"LaTeX",
"and",
"return",
"its",
"name",
"."
] | python | train |
stephantul/somber | somber/som.py | https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L73-L92 | def _calculate_influence(self, neighborhood):
"""
Pre-calculate the influence for a given value of sigma.
The neighborhood has size num_neurons * num_neurons, so for a
30 * 30 map, the neighborhood will be size (900, 900).
Parameters
----------
neighborhood : fl... | [
"def",
"_calculate_influence",
"(",
"self",
",",
"neighborhood",
")",
":",
"grid",
"=",
"np",
".",
"exp",
"(",
"-",
"self",
".",
"distance_grid",
"/",
"(",
"neighborhood",
"**",
"2",
")",
")",
"return",
"grid",
".",
"reshape",
"(",
"self",
".",
"num_ne... | Pre-calculate the influence for a given value of sigma.
The neighborhood has size num_neurons * num_neurons, so for a
30 * 30 map, the neighborhood will be size (900, 900).
Parameters
----------
neighborhood : float
The neighborhood value.
Returns
-... | [
"Pre",
"-",
"calculate",
"the",
"influence",
"for",
"a",
"given",
"value",
"of",
"sigma",
"."
] | python | train |
kvesteri/validators | validators/utils.py | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/utils.py#L35-L56 | def func_args_as_dict(func, args, kwargs):
"""
Return given function's positional and key value arguments as an ordered
dictionary.
"""
if six.PY2:
_getargspec = inspect.getargspec
else:
_getargspec = inspect.getfullargspec
arg_names = list(
OrderedDict.fromkeys(
... | [
"def",
"func_args_as_dict",
"(",
"func",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"six",
".",
"PY2",
":",
"_getargspec",
"=",
"inspect",
".",
"getargspec",
"else",
":",
"_getargspec",
"=",
"inspect",
".",
"getfullargspec",
"arg_names",
"=",
"list",
"(",... | Return given function's positional and key value arguments as an ordered
dictionary. | [
"Return",
"given",
"function",
"s",
"positional",
"and",
"key",
"value",
"arguments",
"as",
"an",
"ordered",
"dictionary",
"."
] | python | train |
wal-e/wal-e | wal_e/pep3143daemon/daemon.py | https://github.com/wal-e/wal-e/blob/027263860e72a403bc0e1497bb3e67523138e7a2/wal_e/pep3143daemon/daemon.py#L336-L350 | def default_signal_map():
""" Create the default signal map for this system.
:return: dict
"""
name_map = {
'SIGTSTP': None,
'SIGTTIN': None,
'SIGTTOU': None,
'SIGTERM': 'terminate'}
signal_map = {}
for name, target in list(name_map.items()):
if hasattr(s... | [
"def",
"default_signal_map",
"(",
")",
":",
"name_map",
"=",
"{",
"'SIGTSTP'",
":",
"None",
",",
"'SIGTTIN'",
":",
"None",
",",
"'SIGTTOU'",
":",
"None",
",",
"'SIGTERM'",
":",
"'terminate'",
"}",
"signal_map",
"=",
"{",
"}",
"for",
"name",
",",
"target"... | Create the default signal map for this system.
:return: dict | [
"Create",
"the",
"default",
"signal",
"map",
"for",
"this",
"system",
"."
] | python | train |
ibelie/typy | typy/google/protobuf/json_format.py | https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/json_format.py#L324-L402 | def _ConvertFieldValuePair(js, message):
"""Convert field value pairs into regular message.
Args:
js: A JSON object to convert the field value pairs.
message: A regular protocol message to record the data.
Raises:
ParseError: In case of problems converting.
"""
names = []
message_descriptor = ... | [
"def",
"_ConvertFieldValuePair",
"(",
"js",
",",
"message",
")",
":",
"names",
"=",
"[",
"]",
"message_descriptor",
"=",
"message",
".",
"DESCRIPTOR",
"for",
"name",
"in",
"js",
":",
"try",
":",
"field",
"=",
"message_descriptor",
".",
"fields_by_camelcase_nam... | Convert field value pairs into regular message.
Args:
js: A JSON object to convert the field value pairs.
message: A regular protocol message to record the data.
Raises:
ParseError: In case of problems converting. | [
"Convert",
"field",
"value",
"pairs",
"into",
"regular",
"message",
"."
] | python | valid |
ionelmc/python-cogen | examples/cogen-irc/CogenIrcApp/cogenircapp/controllers/irc.py | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-irc/CogenIrcApp/cogenircapp/controllers/irc.py#L25-L41 | def parsemsg(s): # stolen from twisted.words
"""Breaks a message from an IRC server into its prefix, command, and arguments.
"""
prefix = ''
trailing = []
if not s:
raise Exception("Empty line.")
if s[0] == ':':
prefix, s = s[1:].split(' ', 1)
if s.find(' :') != -1:
... | [
"def",
"parsemsg",
"(",
"s",
")",
":",
"# stolen from twisted.words\r",
"prefix",
"=",
"''",
"trailing",
"=",
"[",
"]",
"if",
"not",
"s",
":",
"raise",
"Exception",
"(",
"\"Empty line.\"",
")",
"if",
"s",
"[",
"0",
"]",
"==",
"':'",
":",
"prefix",
",",... | Breaks a message from an IRC server into its prefix, command, and arguments. | [
"Breaks",
"a",
"message",
"from",
"an",
"IRC",
"server",
"into",
"its",
"prefix",
"command",
"and",
"arguments",
"."
] | python | train |
eng-tools/geofound | geofound/capacity.py | https://github.com/eng-tools/geofound/blob/6b1b097d5db998907bdcb5b4798fb4629674c770/geofound/capacity.py#L1115-L1374 | def capacity_sp_meyerhof_and_hanna_1978(sp, fd, verbose=0):
"""
Calculates the two-layered foundation capacity according Meyerhof and Hanna (1978)
:param sp: Soil profile object
:param fd: Foundation object
:param wtl: water table level
:param verbose: verbosity
:return: ultimate bearing st... | [
"def",
"capacity_sp_meyerhof_and_hanna_1978",
"(",
"sp",
",",
"fd",
",",
"verbose",
"=",
"0",
")",
":",
"assert",
"isinstance",
"(",
"sp",
",",
"sm",
".",
"SoilProfile",
")",
"sl_0",
"=",
"sp",
".",
"layer",
"(",
"1",
")",
"sl_1",
"=",
"sp",
".",
"la... | Calculates the two-layered foundation capacity according Meyerhof and Hanna (1978)
:param sp: Soil profile object
:param fd: Foundation object
:param wtl: water table level
:param verbose: verbosity
:return: ultimate bearing stress | [
"Calculates",
"the",
"two",
"-",
"layered",
"foundation",
"capacity",
"according",
"Meyerhof",
"and",
"Hanna",
"(",
"1978",
")"
] | python | test |
kivy/python-for-android | pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py#L2348-L2358 | def error(self, message):
"""error(message: string)
Prints a usage message incorporating the message to stderr and
exits.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
self.print_usage(_sys.... | [
"def",
"error",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"print_usage",
"(",
"_sys",
".",
"stderr",
")",
"self",
".",
"exit",
"(",
"2",
",",
"_",
"(",
"'%s: error: %s\\n'",
")",
"%",
"(",
"self",
".",
"prog",
",",
"message",
")",
")"
] | error(message: string)
Prints a usage message incorporating the message to stderr and
exits.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception. | [
"error",
"(",
"message",
":",
"string",
")",
"Prints",
"a",
"usage",
"message",
"incorporating",
"the",
"message",
"to",
"stderr",
"and",
"exits",
".",
"If",
"you",
"override",
"this",
"in",
"a",
"subclass",
"it",
"should",
"not",
"return",
"--",
"it",
"... | python | train |
brocade/pynos | pynos/versions/ver_7/ver_7_0_0/bgp.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L733-L781 | def enable_peer_bfd(self, **kwargs):
"""BFD enable for each specified peer.
Args:
rbridge_id (str): Rbridge to configure. (1, 225, etc)
peer_ip (str): Peer IPv4 address for BFD setting.
delete (bool): True if BFD configuration should be deleted.
Defa... | [
"def",
"enable_peer_bfd",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"method_name",
"=",
"'rbridge_id_router_router_bgp_router_bgp_attributes_'",
"'neighbor_neighbor_ips_neighbor_addr_bfd_bfd_enable'",
"bfd_enable",
"=",
"getattr",
"(",
"self",
".",
"_rbridge",
",",
... | BFD enable for each specified peer.
Args:
rbridge_id (str): Rbridge to configure. (1, 225, etc)
peer_ip (str): Peer IPv4 address for BFD setting.
delete (bool): True if BFD configuration should be deleted.
Default value will be False if not specified.
... | [
"BFD",
"enable",
"for",
"each",
"specified",
"peer",
"."
] | python | train |
maas/python-libmaas | maas/client/viscera/pods.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/viscera/pods.py#L150-L233 | async def compose(
self, *, cores: int = None, memory: int = None,
cpu_speed: int = None, architecture: str = None,
storage: typing.Sequence[str] = None, hostname: str = None,
domain: typing.Union[int, str] = None,
zone: typing.Union[int, str, Zone] = None,
... | [
"async",
"def",
"compose",
"(",
"self",
",",
"*",
",",
"cores",
":",
"int",
"=",
"None",
",",
"memory",
":",
"int",
"=",
"None",
",",
"cpu_speed",
":",
"int",
"=",
"None",
",",
"architecture",
":",
"str",
"=",
"None",
",",
"storage",
":",
"typing",... | Compose a machine from `Pod`.
All fields below are optional:
:param cores: Minimum number of CPU cores.
:type cores: `int`
:param memory: Minimum amount of memory (MiB).
:type memory: `int`
:param cpu_speed: Minimum amount of CPU speed (MHz).
:type cpu_speed: `i... | [
"Compose",
"a",
"machine",
"from",
"Pod",
"."
] | python | train |
marcomusy/vtkplotter | vtkplotter/actors.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/actors.py#L324-L331 | def rotateY(self, angle, axis_point=(0, 0, 0), rad=False):
"""Rotate around y-axis. If angle is in radians set ``rad=True``."""
if rad:
angle *= 57.29578
self.RotateY(angle)
if self.trail:
self.updateTrail()
return self | [
"def",
"rotateY",
"(",
"self",
",",
"angle",
",",
"axis_point",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"rad",
"=",
"False",
")",
":",
"if",
"rad",
":",
"angle",
"*=",
"57.29578",
"self",
".",
"RotateY",
"(",
"angle",
")",
"if",
"self",
".... | Rotate around y-axis. If angle is in radians set ``rad=True``. | [
"Rotate",
"around",
"y",
"-",
"axis",
".",
"If",
"angle",
"is",
"in",
"radians",
"set",
"rad",
"=",
"True",
"."
] | python | train |
fastai/fastai | fastai/torch_core.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/torch_core.py#L357-L359 | def uniform_int(low:int, high:int, size:Optional[List[int]]=None)->IntOrTensor:
"Generate int or tensor `size` of ints between `low` and `high` (included)."
return random.randint(low,high) if size is None else torch.randint(low,high+1,size) | [
"def",
"uniform_int",
"(",
"low",
":",
"int",
",",
"high",
":",
"int",
",",
"size",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"IntOrTensor",
":",
"return",
"random",
".",
"randint",
"(",
"low",
",",
"high",
")",
... | Generate int or tensor `size` of ints between `low` and `high` (included). | [
"Generate",
"int",
"or",
"tensor",
"size",
"of",
"ints",
"between",
"low",
"and",
"high",
"(",
"included",
")",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L4056-L4069 | def get_stp_mst_detail_output_cist_port_interface_name(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_stp_mst_detail = ET.Element("get_stp_mst_detail")
config = get_stp_mst_detail
output = ET.SubElement(get_stp_mst_detail, "output")
... | [
"def",
"get_stp_mst_detail_output_cist_port_interface_name",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_stp_mst_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_stp_mst_detail\"",
")",
"config",... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
PyCQA/astroid | astroid/brain/brain_builtin_inference.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/brain/brain_builtin_inference.py#L665-L684 | def infer_len(node, context=None):
"""Infer length calls
:param nodes.Call node: len call to infer
:param context.InferenceContext: node context
:rtype nodes.Const: a Const node with the inferred length, if possible
"""
call = arguments.CallSite.from_call(node)
if call.keyword_arguments:
... | [
"def",
"infer_len",
"(",
"node",
",",
"context",
"=",
"None",
")",
":",
"call",
"=",
"arguments",
".",
"CallSite",
".",
"from_call",
"(",
"node",
")",
"if",
"call",
".",
"keyword_arguments",
":",
"raise",
"UseInferenceDefault",
"(",
"\"TypeError: len() must ta... | Infer length calls
:param nodes.Call node: len call to infer
:param context.InferenceContext: node context
:rtype nodes.Const: a Const node with the inferred length, if possible | [
"Infer",
"length",
"calls"
] | python | train |
Rapptz/discord.py | discord/message.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/message.py#L699-L728 | async def add_reaction(self, emoji):
"""|coro|
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild :class:`Emoji`.
You must have the :attr:`~Permissions.read_message_history` permission
to use this. If nobody else has reacted to the message using ... | [
"async",
"def",
"add_reaction",
"(",
"self",
",",
"emoji",
")",
":",
"emoji",
"=",
"self",
".",
"_emoji_reaction",
"(",
"emoji",
")",
"await",
"self",
".",
"_state",
".",
"http",
".",
"add_reaction",
"(",
"self",
".",
"channel",
".",
"id",
",",
"self",... | |coro|
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild :class:`Emoji`.
You must have the :attr:`~Permissions.read_message_history` permission
to use this. If nobody else has reacted to the message using this
emoji, the :attr:`~Permissions.add_... | [
"|coro|"
] | python | train |
prthkms/alex | alex/support.py | https://github.com/prthkms/alex/blob/79d3167c877e94cc07db0aab55a35857fac67ef7/alex/support.py#L63-L79 | def get_readable_filesize(size):
"""get_readable_filesize(size) -> filesize -- return human readable
filesize from given size in bytes.
"""
if(size < 1024):
return str(size)+' bytes'
temp = size/1024.0
level = 1
while(temp >= 1024 and level< 3):
temp = temp/1024
level += 1
if(level == 1):
return str(ro... | [
"def",
"get_readable_filesize",
"(",
"size",
")",
":",
"if",
"(",
"size",
"<",
"1024",
")",
":",
"return",
"str",
"(",
"size",
")",
"+",
"' bytes'",
"temp",
"=",
"size",
"/",
"1024.0",
"level",
"=",
"1",
"while",
"(",
"temp",
">=",
"1024",
"and",
"... | get_readable_filesize(size) -> filesize -- return human readable
filesize from given size in bytes. | [
"get_readable_filesize",
"(",
"size",
")",
"-",
">",
"filesize",
"--",
"return",
"human",
"readable",
"filesize",
"from",
"given",
"size",
"in",
"bytes",
"."
] | python | train |
tjcsl/ion | intranet/apps/users/models.py | https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/users/models.py#L343-L360 | def permissions(self):
"""Dynamically generate dictionary of privacy options
"""
# TODO: optimize this, it's kind of a bad solution for listing a mostly
# static set of files.
# We could either add a permissions dict as an attribute or cache this
# in some way. Creating a... | [
"def",
"permissions",
"(",
"self",
")",
":",
"# TODO: optimize this, it's kind of a bad solution for listing a mostly",
"# static set of files.",
"# We could either add a permissions dict as an attribute or cache this",
"# in some way. Creating a dict would be another place we have to define",
"... | Dynamically generate dictionary of privacy options | [
"Dynamically",
"generate",
"dictionary",
"of",
"privacy",
"options"
] | python | train |
fermiPy/fermipy | fermipy/spectrum.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/spectrum.py#L308-L312 | def flux(self, emin, emax, params=None):
"""Evaluate the integral flux."""
params = self.params if params is None else params
return np.squeeze(self.eval_flux(emin, emax, params, self.scale,
self.extra_params)) | [
"def",
"flux",
"(",
"self",
",",
"emin",
",",
"emax",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"self",
".",
"params",
"if",
"params",
"is",
"None",
"else",
"params",
"return",
"np",
".",
"squeeze",
"(",
"self",
".",
"eval_flux",
"(",
"e... | Evaluate the integral flux. | [
"Evaluate",
"the",
"integral",
"flux",
"."
] | python | train |
amelchio/pysonos | pysonos/core.py | https://github.com/amelchio/pysonos/blob/23527c445a00e198fbb94d44b92f7f99d139e325/pysonos/core.py#L1089-L1101 | def unjoin(self):
"""Remove this speaker from a group.
Seems to work ok even if you remove what was previously the group
master from it's own group. If the speaker was not in a group also
returns ok.
"""
self.avTransport.BecomeCoordinatorOfStandaloneGroup([
... | [
"def",
"unjoin",
"(",
"self",
")",
":",
"self",
".",
"avTransport",
".",
"BecomeCoordinatorOfStandaloneGroup",
"(",
"[",
"(",
"'InstanceID'",
",",
"0",
")",
"]",
")",
"self",
".",
"_zgs_cache",
".",
"clear",
"(",
")",
"self",
".",
"_parse_zone_group_state",
... | Remove this speaker from a group.
Seems to work ok even if you remove what was previously the group
master from it's own group. If the speaker was not in a group also
returns ok. | [
"Remove",
"this",
"speaker",
"from",
"a",
"group",
"."
] | python | train |
jobovy/galpy | galpy/df/streamdf.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/streamdf.py#L218-L257 | def _progenitor_setup(self,progenitor,leading,useTMHessian):
"""The part of the setup relating to the progenitor's orbit"""
#Progenitor orbit: Calculate actions, frequencies, and angles for the progenitor
self._progenitor= progenitor() #call to get new Orbit
# Make sure we do not use phy... | [
"def",
"_progenitor_setup",
"(",
"self",
",",
"progenitor",
",",
"leading",
",",
"useTMHessian",
")",
":",
"#Progenitor orbit: Calculate actions, frequencies, and angles for the progenitor",
"self",
".",
"_progenitor",
"=",
"progenitor",
"(",
")",
"#call to get new Orbit",
... | The part of the setup relating to the progenitor's orbit | [
"The",
"part",
"of",
"the",
"setup",
"relating",
"to",
"the",
"progenitor",
"s",
"orbit"
] | python | train |
StackStorm/pybind | pybind/slxos/v17s_1_02/protocol/cfm/domain_name/ma_name/cfm_ma_sub_commands/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/protocol/cfm/domain_name/ma_name/cfm_ma_sub_commands/__init__.py#L160-L181 | def _set_mep(self, v, load=False):
"""
Setter method for mep, mapped from YANG variable /protocol/cfm/domain_name/ma_name/cfm_ma_sub_commands/mep (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_mep is considered as a private
method. Backends looking to populat... | [
"def",
"_set_mep",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
"... | Setter method for mep, mapped from YANG variable /protocol/cfm/domain_name/ma_name/cfm_ma_sub_commands/mep (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_mep is considered as a private
method. Backends looking to populate this variable should
do so via calling th... | [
"Setter",
"method",
"for",
"mep",
"mapped",
"from",
"YANG",
"variable",
"/",
"protocol",
"/",
"cfm",
"/",
"domain_name",
"/",
"ma_name",
"/",
"cfm_ma_sub_commands",
"/",
"mep",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"... | python | train |
volfpeter/graphscraper | src/graphscraper/eventdispatcher.py | https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/eventdispatcher.py#L144-L166 | def remove_event_listener(self, event_type: str, event_handler: types.MethodType) -> None:
"""
Removes the given event listener registered on the dispatcher for the given event type.
Args:
event_type (str): The type of the event to remove the event handler from.
... | [
"def",
"remove_event_listener",
"(",
"self",
",",
"event_type",
":",
"str",
",",
"event_handler",
":",
"types",
".",
"MethodType",
")",
"->",
"None",
":",
"# TODO: we should also accept types.FunctionType,\r",
"# don't forget the documentation here and in the interface.\r",
"... | Removes the given event listener registered on the dispatcher for the given event type.
Args:
event_type (str): The type of the event to remove the event handler from.
Must not be `None` or empty string.
event_handler (types.MethodType): The event hand... | [
"Removes",
"the",
"given",
"event",
"listener",
"registered",
"on",
"the",
"dispatcher",
"for",
"the",
"given",
"event",
"type",
".",
"Args",
":",
"event_type",
"(",
"str",
")",
":",
"The",
"type",
"of",
"the",
"event",
"to",
"remove",
"the",
"event",
"h... | python | train |
has2k1/plotnine | plotnine/layer.py | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/layer.py#L411-L426 | def setup_data(self):
"""
Prepare/modify data for plotting
"""
data = self.data
if len(data) == 0:
return type(data)()
data = self.geom.setup_data(data)
check_required_aesthetics(
self.geom.REQUIRED_AES,
set(data.columns) | se... | [
"def",
"setup_data",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"data",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
"return",
"type",
"(",
"data",
")",
"(",
")",
"data",
"=",
"self",
".",
"geom",
".",
"setup_data",
"(",
"data",
")",
"c... | Prepare/modify data for plotting | [
"Prepare",
"/",
"modify",
"data",
"for",
"plotting"
] | python | train |
allenai/allennlp | allennlp/semparse/domain_languages/domain_language.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L488-L493 | def is_nonterminal(self, symbol: str) -> bool:
"""
Determines whether an input symbol is a valid non-terminal in the grammar.
"""
nonterminal_productions = self.get_nonterminal_productions()
return symbol in nonterminal_productions | [
"def",
"is_nonterminal",
"(",
"self",
",",
"symbol",
":",
"str",
")",
"->",
"bool",
":",
"nonterminal_productions",
"=",
"self",
".",
"get_nonterminal_productions",
"(",
")",
"return",
"symbol",
"in",
"nonterminal_productions"
] | Determines whether an input symbol is a valid non-terminal in the grammar. | [
"Determines",
"whether",
"an",
"input",
"symbol",
"is",
"a",
"valid",
"non",
"-",
"terminal",
"in",
"the",
"grammar",
"."
] | python | train |
pydanny/webhooks | webhooks/senders/base.py | https://github.com/pydanny/webhooks/blob/84aa1c0b8f995308f4f5977270c9a0532abc16cc/webhooks/senders/base.py#L94-L99 | def jsonify_payload(self):
""" Dump the payload to JSON """
# Assume already json serialized
if isinstance(self.payload, string_types):
return self.payload
return json.dumps(self.payload, cls=StandardJSONEncoder) | [
"def",
"jsonify_payload",
"(",
"self",
")",
":",
"# Assume already json serialized",
"if",
"isinstance",
"(",
"self",
".",
"payload",
",",
"string_types",
")",
":",
"return",
"self",
".",
"payload",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"payload",
... | Dump the payload to JSON | [
"Dump",
"the",
"payload",
"to",
"JSON"
] | python | train |
SHTOOLS/SHTOOLS | pyshtools/shclasses/shcoeffsgrid.py | https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shcoeffsgrid.py#L2906-L2956 | def _plot(self, xticks=[], yticks=[], minor_xticks=[], minor_yticks=[],
xlabel='Longitude', ylabel='Latitude', ax=None, ax2=None,
colorbar=None, cb_orientation=None, cb_label=None, grid=False,
axes_labelsize=None, tick_labelsize=None, **kwargs):
"""Plot the raw data usi... | [
"def",
"_plot",
"(",
"self",
",",
"xticks",
"=",
"[",
"]",
",",
"yticks",
"=",
"[",
"]",
",",
"minor_xticks",
"=",
"[",
"]",
",",
"minor_yticks",
"=",
"[",
"]",
",",
"xlabel",
"=",
"'Longitude'",
",",
"ylabel",
"=",
"'Latitude'",
",",
"ax",
"=",
... | Plot the raw data using a simply cylindrical projection. | [
"Plot",
"the",
"raw",
"data",
"using",
"a",
"simply",
"cylindrical",
"projection",
"."
] | python | train |
refinery29/chassis | chassis/util/params.py | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/params.py#L43-L75 | def _parse_arguments(self, method, parameters):
"""Parse arguments to method, returning a dictionary."""
# TODO: Consider raising an exception if there are extra arguments.
arguments = _fetch_arguments(self, method)
arg_dict = {}
errors = []
for key, properties in parameters:
if key i... | [
"def",
"_parse_arguments",
"(",
"self",
",",
"method",
",",
"parameters",
")",
":",
"# TODO: Consider raising an exception if there are extra arguments.",
"arguments",
"=",
"_fetch_arguments",
"(",
"self",
",",
"method",
")",
"arg_dict",
"=",
"{",
"}",
"errors",
"=",
... | Parse arguments to method, returning a dictionary. | [
"Parse",
"arguments",
"to",
"method",
"returning",
"a",
"dictionary",
"."
] | python | train |
cuihantao/andes | andes/utils/tab.py | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/tab.py#L72-L88 | def draw(self):
"""generate texttable formatted string"""
self.guess_header()
self.add_left_space(
)
# for Texttable, elem_add a column of whitespace on the left for
# better visual effect
if self._title and self._descr:
pre = self._title + '\n' + self... | [
"def",
"draw",
"(",
"self",
")",
":",
"self",
".",
"guess_header",
"(",
")",
"self",
".",
"add_left_space",
"(",
")",
"# for Texttable, elem_add a column of whitespace on the left for",
"# better visual effect",
"if",
"self",
".",
"_title",
"and",
"self",
".",
"_des... | generate texttable formatted string | [
"generate",
"texttable",
"formatted",
"string"
] | python | train |
SFDO-Tooling/CumulusCI | cumulusci/utils.py | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/utils.py#L38-L47 | def parse_api_datetime(value):
""" parse a datetime returned from the salesforce API.
in python 3 we should just use a strptime %z, but until then we're just going
to assert that its a fixed offset of +0000 since thats the observed behavior. getting
python 2 to support fixed offset parsing is too compl... | [
"def",
"parse_api_datetime",
"(",
"value",
")",
":",
"dt",
"=",
"datetime",
".",
"strptime",
"(",
"value",
"[",
"0",
":",
"DATETIME_LEN",
"]",
",",
"API_DATE_FORMAT",
")",
"offset_str",
"=",
"value",
"[",
"DATETIME_LEN",
":",
"]",
"assert",
"offset_str",
"... | parse a datetime returned from the salesforce API.
in python 3 we should just use a strptime %z, but until then we're just going
to assert that its a fixed offset of +0000 since thats the observed behavior. getting
python 2 to support fixed offset parsing is too complicated for what we need imo. | [
"parse",
"a",
"datetime",
"returned",
"from",
"the",
"salesforce",
"API",
"."
] | python | train |
Cadene/pretrained-models.pytorch | pretrainedmodels/models/nasnet.py | https://github.com/Cadene/pretrained-models.pytorch/blob/021d97897c9aa76ec759deff43d341c4fd45d7ba/pretrainedmodels/models/nasnet.py#L608-L635 | def nasnetalarge(num_classes=1001, pretrained='imagenet'):
r"""NASNetALarge model architecture from the
`"NASNet" <https://arxiv.org/abs/1707.07012>`_ paper.
"""
if pretrained:
settings = pretrained_settings['nasnetalarge'][pretrained]
assert num_classes == settings['num_classes'], \
... | [
"def",
"nasnetalarge",
"(",
"num_classes",
"=",
"1001",
",",
"pretrained",
"=",
"'imagenet'",
")",
":",
"if",
"pretrained",
":",
"settings",
"=",
"pretrained_settings",
"[",
"'nasnetalarge'",
"]",
"[",
"pretrained",
"]",
"assert",
"num_classes",
"==",
"settings"... | r"""NASNetALarge model architecture from the
`"NASNet" <https://arxiv.org/abs/1707.07012>`_ paper. | [
"r",
"NASNetALarge",
"model",
"architecture",
"from",
"the",
"NASNet",
"<https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1707",
".",
"07012",
">",
"_",
"paper",
"."
] | python | train |
i3visio/osrframework | osrframework/api/twitter_api.py | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/api/twitter_api.py#L726-L772 | def search_users(self, query, n=20, maxUsers=60):
"""
Method to perform the searchfy searches.
:param query: Query to be performed.
:param n: Number of results per query.
:param maxUsers: Max. number of users to be recovered.
:return: List ... | [
"def",
"search_users",
"(",
"self",
",",
"query",
",",
"n",
"=",
"20",
",",
"maxUsers",
"=",
"60",
")",
":",
"# Connecting to the API",
"api",
"=",
"self",
".",
"_connectToAPI",
"(",
")",
"# Verifying the limits of the API",
"self",
".",
"_rate_limit_status",
... | Method to perform the searchfy searches.
:param query: Query to be performed.
:param n: Number of results per query.
:param maxUsers: Max. number of users to be recovered.
:return: List of users | [
"Method",
"to",
"perform",
"the",
"searchfy",
"searches",
"."
] | python | train |
prompt-toolkit/pyvim | pyvim/layout.py | https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/layout.py#L566-L610 | def _create_buffer_control(self, editor_buffer):
"""
Create a new BufferControl for a given location.
"""
@Condition
def preview_search():
return self.editor.incsearch
input_processors = [
# Processor for visualising spaces. (should come before th... | [
"def",
"_create_buffer_control",
"(",
"self",
",",
"editor_buffer",
")",
":",
"@",
"Condition",
"def",
"preview_search",
"(",
")",
":",
"return",
"self",
".",
"editor",
".",
"incsearch",
"input_processors",
"=",
"[",
"# Processor for visualising spaces. (should come b... | Create a new BufferControl for a given location. | [
"Create",
"a",
"new",
"BufferControl",
"for",
"a",
"given",
"location",
"."
] | python | train |
Locu/chronology | kronos/kronos/storage/cassandra/client.py | https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/kronos/kronos/storage/cassandra/client.py#L107-L131 | def _retrieve(self, namespace, stream, start_id, end_time, order, limit,
configuration):
"""
Retrieve events for `stream` between `start_id` and `end_time`.
`stream` : The stream to return events for.
`start_id` : Return events with id > `start_id`.
`end_time` : Return events ending ... | [
"def",
"_retrieve",
"(",
"self",
",",
"namespace",
",",
"stream",
",",
"start_id",
",",
"end_time",
",",
"order",
",",
"limit",
",",
"configuration",
")",
":",
"stream",
"=",
"self",
".",
"get_stream",
"(",
"namespace",
",",
"stream",
",",
"configuration",... | Retrieve events for `stream` between `start_id` and `end_time`.
`stream` : The stream to return events for.
`start_id` : Return events with id > `start_id`.
`end_time` : Return events ending <= `end_time`.
`order` : Whether to return the results in ResultOrder.ASCENDING
or ResultOrder.DESC... | [
"Retrieve",
"events",
"for",
"stream",
"between",
"start_id",
"and",
"end_time",
".",
"stream",
":",
"The",
"stream",
"to",
"return",
"events",
"for",
".",
"start_id",
":",
"Return",
"events",
"with",
"id",
">",
"start_id",
".",
"end_time",
":",
"Return",
... | python | train |
rootpy/rootpy | rootpy/tree/treemodel.py | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L84-L92 | def prefix(cls, name):
"""
Create a new TreeModel where class attribute
names are prefixed with ``name``
"""
attrs = dict([(name + attr, value) for attr, value in cls.get_attrs()])
return TreeModelMeta(
'_'.join([name, cls.__name__]),
(TreeModel,),... | [
"def",
"prefix",
"(",
"cls",
",",
"name",
")",
":",
"attrs",
"=",
"dict",
"(",
"[",
"(",
"name",
"+",
"attr",
",",
"value",
")",
"for",
"attr",
",",
"value",
"in",
"cls",
".",
"get_attrs",
"(",
")",
"]",
")",
"return",
"TreeModelMeta",
"(",
"'_'"... | Create a new TreeModel where class attribute
names are prefixed with ``name`` | [
"Create",
"a",
"new",
"TreeModel",
"where",
"class",
"attribute",
"names",
"are",
"prefixed",
"with",
"name"
] | python | train |
ravenac95/lxc4u | lxc4u/overlayutils.py | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/overlayutils.py#L62-L67 | def meta(self):
"""Data for loading later"""
mount_points = []
for overlay in self.overlays:
mount_points.append(overlay.mount_point)
return [self.end_dir, self.start_dir, mount_points] | [
"def",
"meta",
"(",
"self",
")",
":",
"mount_points",
"=",
"[",
"]",
"for",
"overlay",
"in",
"self",
".",
"overlays",
":",
"mount_points",
".",
"append",
"(",
"overlay",
".",
"mount_point",
")",
"return",
"[",
"self",
".",
"end_dir",
",",
"self",
".",
... | Data for loading later | [
"Data",
"for",
"loading",
"later"
] | python | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L120-L173 | def send(self,cmd,*args,arg_formats=None):
"""
Send a command (which may or may not have associated arguments) to an
arduino using the CmdMessage protocol. The command and any parameters
should be passed as direct arguments to send.
arg_formats is an optional string that spe... | [
"def",
"send",
"(",
"self",
",",
"cmd",
",",
"*",
"args",
",",
"arg_formats",
"=",
"None",
")",
":",
"# Turn the command into an integer.",
"try",
":",
"command_as_int",
"=",
"self",
".",
"_cmd_name_to_int",
"[",
"cmd",
"]",
"except",
"KeyError",
":",
"err",... | Send a command (which may or may not have associated arguments) to an
arduino using the CmdMessage protocol. The command and any parameters
should be passed as direct arguments to send.
arg_formats is an optional string that specifies the formats to use for
each argument when passed... | [
"Send",
"a",
"command",
"(",
"which",
"may",
"or",
"may",
"not",
"have",
"associated",
"arguments",
")",
"to",
"an",
"arduino",
"using",
"the",
"CmdMessage",
"protocol",
".",
"The",
"command",
"and",
"any",
"parameters",
"should",
"be",
"passed",
"as",
"di... | python | train |
senaite/senaite.api | src/senaite/api/__init__.py | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L714-L726 | def get_workflow_status_of(brain_or_object, state_var="review_state"):
"""Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of ... | [
"def",
"get_workflow_status_of",
"(",
"brain_or_object",
",",
"state_var",
"=",
"\"review_state\"",
")",
":",
"workflow",
"=",
"get_tool",
"(",
"\"portal_workflow\"",
")",
"obj",
"=",
"get_object",
"(",
"brain_or_object",
")",
"return",
"workflow",
".",
"getInfoFor"... | Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of the state variable
:type state_var: string
:returns: Status
:rtype... | [
"Get",
"the",
"current",
"workflow",
"status",
"of",
"the",
"given",
"brain",
"or",
"context",
"."
] | python | train |
Yubico/python-yubico | yubico/yubikey_config.py | https://github.com/Yubico/python-yubico/blob/a72e8eddb90da6ee96e29f60912ca1f2872c9aea/yubico/yubikey_config.py#L309-L330 | def mode_oath_hotp(self, secret, digits=6, factor_seed=None, omp=0x0, tt=0x0, mui=''):
"""
Set the YubiKey up for OATH-HOTP operation.
Requires YubiKey 2.1.
"""
if not self.capabilities.have_OATH('HOTP'):
raise yubikey_base.YubiKeyVersionError('OATH HOTP not availabl... | [
"def",
"mode_oath_hotp",
"(",
"self",
",",
"secret",
",",
"digits",
"=",
"6",
",",
"factor_seed",
"=",
"None",
",",
"omp",
"=",
"0x0",
",",
"tt",
"=",
"0x0",
",",
"mui",
"=",
"''",
")",
":",
"if",
"not",
"self",
".",
"capabilities",
".",
"have_OATH... | Set the YubiKey up for OATH-HOTP operation.
Requires YubiKey 2.1. | [
"Set",
"the",
"YubiKey",
"up",
"for",
"OATH",
"-",
"HOTP",
"operation",
"."
] | python | train |
gwastro/pycbc-glue | pycbc_glue/segmentsUtils.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/segmentsUtils.py#L274-L307 | def to_range_strings(seglist):
"""
Turn a segment list into a list of range strings as could be parsed
by from_range_strings(). A typical use for this function is in
machine-generating configuration files or command lines for other
programs.
Example:
>>> from pycbc_glue.segments import *
>>> segs = segmentli... | [
"def",
"to_range_strings",
"(",
"seglist",
")",
":",
"# preallocate the string list",
"ranges",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"seglist",
")",
"# iterate over segments",
"for",
"i",
",",
"seg",
"in",
"enumerate",
"(",
"seglist",
")",
":",
"if",
"not... | Turn a segment list into a list of range strings as could be parsed
by from_range_strings(). A typical use for this function is in
machine-generating configuration files or command lines for other
programs.
Example:
>>> from pycbc_glue.segments import *
>>> segs = segmentlist([segment(0, 10), segment(35, 35), ... | [
"Turn",
"a",
"segment",
"list",
"into",
"a",
"list",
"of",
"range",
"strings",
"as",
"could",
"be",
"parsed",
"by",
"from_range_strings",
"()",
".",
"A",
"typical",
"use",
"for",
"this",
"function",
"is",
"in",
"machine",
"-",
"generating",
"configuration",
... | python | train |
google-research/batch-ppo | agents/tools/streaming_mean.py | https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/tools/streaming_mean.py#L60-L67 | def clear(self):
"""Return the mean estimate and reset the streaming statistics."""
value = self._sum / tf.cast(self._count, self._dtype)
with tf.control_dependencies([value]):
reset_value = self._sum.assign(tf.zeros_like(self._sum))
reset_count = self._count.assign(0)
with tf.control_depend... | [
"def",
"clear",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"_sum",
"/",
"tf",
".",
"cast",
"(",
"self",
".",
"_count",
",",
"self",
".",
"_dtype",
")",
"with",
"tf",
".",
"control_dependencies",
"(",
"[",
"value",
"]",
")",
":",
"reset_value... | Return the mean estimate and reset the streaming statistics. | [
"Return",
"the",
"mean",
"estimate",
"and",
"reset",
"the",
"streaming",
"statistics",
"."
] | python | train |
fastavro/fastavro | fastavro/_validation_py.py | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L383-L414 | def validate_many(records, schema, raise_errors=True):
"""
Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
... | [
"def",
"validate_many",
"(",
"records",
",",
"schema",
",",
"raise_errors",
"=",
"True",
")",
":",
"errors",
"=",
"[",
"]",
"results",
"=",
"[",
"]",
"for",
"record",
"in",
"records",
":",
"try",
":",
"results",
".",
"append",
"(",
"validate",
"(",
"... | Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
True (valid) or False (invalid) result is returned
Exam... | [
"Validate",
"a",
"list",
"of",
"data!"
] | python | train |
qiniu/python-sdk | qiniu/services/compute/qcos_api.py | https://github.com/qiniu/python-sdk/blob/a69fbef4e3e6ea1ebe09f4610a5b18bb2c17de59/qiniu/services/compute/qcos_api.py#L555-L570 | def publish_ap(self, apid, args):
"""绑定自定义域名
绑定用户自定义的域名,仅对公网域名模式接入点生效。
Args:
- apid: 接入点ID
- args: 请求参数(json),参考 http://kirk-docs.qiniu.com/apidocs/
Returns:
返回一个tuple对象,其格式为(<result>, <ResponseInfo>)
- result 成功返回空dict{},失败返回{"... | [
"def",
"publish_ap",
"(",
"self",
",",
"apid",
",",
"args",
")",
":",
"url",
"=",
"'{0}/v3/aps/{1}/publish'",
".",
"format",
"(",
"self",
".",
"host",
",",
"apid",
")",
"return",
"self",
".",
"__post",
"(",
"url",
",",
"args",
")"
] | 绑定自定义域名
绑定用户自定义的域名,仅对公网域名模式接入点生效。
Args:
- apid: 接入点ID
- args: 请求参数(json),参考 http://kirk-docs.qiniu.com/apidocs/
Returns:
返回一个tuple对象,其格式为(<result>, <ResponseInfo>)
- result 成功返回空dict{},失败返回{"error": "<errMsg string>"}
- Resp... | [
"绑定自定义域名"
] | python | train |
blockadeio/analyst_toolbench | blockade/cli/config.py | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/config.py#L32-L84 | def main():
"""Run the core."""
parser = ArgumentParser()
subs = parser.add_subparsers(dest='cmd')
setup_parser = subs.add_parser('add-user')
setup_parser.add_argument('--user-email', required=True,
help='Email address of the new user')
setup_parser.add_argument('-... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"subs",
"=",
"parser",
".",
"add_subparsers",
"(",
"dest",
"=",
"'cmd'",
")",
"setup_parser",
"=",
"subs",
".",
"add_parser",
"(",
"'add-user'",
")",
"setup_parser",
".",
"add_argumen... | Run the core. | [
"Run",
"the",
"core",
"."
] | python | train |
ejeschke/ginga | ginga/rv/Control.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/Control.py#L971-L978 | def next_img_ws(self, ws, loop=True):
"""Go to the next image in the focused channel in the workspace.
"""
channel = self.get_active_channel_ws(ws)
if channel is None:
return
channel.next_image()
return True | [
"def",
"next_img_ws",
"(",
"self",
",",
"ws",
",",
"loop",
"=",
"True",
")",
":",
"channel",
"=",
"self",
".",
"get_active_channel_ws",
"(",
"ws",
")",
"if",
"channel",
"is",
"None",
":",
"return",
"channel",
".",
"next_image",
"(",
")",
"return",
"Tru... | Go to the next image in the focused channel in the workspace. | [
"Go",
"to",
"the",
"next",
"image",
"in",
"the",
"focused",
"channel",
"in",
"the",
"workspace",
"."
] | python | train |
xoolive/traffic | traffic/core/flight.py | https://github.com/xoolive/traffic/blob/d1a8878098f16759f6b6e0e8d8b8f32e34a680a8/traffic/core/flight.py#L481-L486 | def coords(self) -> Iterator[Tuple[float, float, float]]:
"""Iterates on longitudes, latitudes and altitudes.
"""
data = self.data[self.data.longitude.notnull()]
yield from zip(data["longitude"], data["latitude"], data["altitude"]) | [
"def",
"coords",
"(",
"self",
")",
"->",
"Iterator",
"[",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
"]",
":",
"data",
"=",
"self",
".",
"data",
"[",
"self",
".",
"data",
".",
"longitude",
".",
"notnull",
"(",
")",
"]",
"yield",
"fro... | Iterates on longitudes, latitudes and altitudes. | [
"Iterates",
"on",
"longitudes",
"latitudes",
"and",
"altitudes",
"."
] | python | train |
csparpa/pyowm | pyowm/stationsapi30/buffer.py | https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/stationsapi30/buffer.py#L35-L43 | def append(self, measurement):
"""
Appends the specified ``Measurement`` object to the buffer
:param measurement: a ``measurement.Measurement`` instance
"""
assert isinstance(measurement, Measurement)
assert measurement.station_id == self.station_id
self.measurem... | [
"def",
"append",
"(",
"self",
",",
"measurement",
")",
":",
"assert",
"isinstance",
"(",
"measurement",
",",
"Measurement",
")",
"assert",
"measurement",
".",
"station_id",
"==",
"self",
".",
"station_id",
"self",
".",
"measurements",
".",
"append",
"(",
"me... | Appends the specified ``Measurement`` object to the buffer
:param measurement: a ``measurement.Measurement`` instance | [
"Appends",
"the",
"specified",
"Measurement",
"object",
"to",
"the",
"buffer",
":",
"param",
"measurement",
":",
"a",
"measurement",
".",
"Measurement",
"instance"
] | python | train |
SoCo/SoCo | soco/services.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L616-L650 | def actions(self):
"""The service's actions with their arguments.
Returns:
list(`Action`): A list of Action namedtuples, consisting of
action_name (str), in_args (list of Argument namedtuples,
consisting of name and argtype), and out_args (ditto).
The return... | [
"def",
"actions",
"(",
"self",
")",
":",
"if",
"self",
".",
"_actions",
"is",
"None",
":",
"self",
".",
"_actions",
"=",
"list",
"(",
"self",
".",
"iter_actions",
"(",
")",
")",
"return",
"self",
".",
"_actions"
] | The service's actions with their arguments.
Returns:
list(`Action`): A list of Action namedtuples, consisting of
action_name (str), in_args (list of Argument namedtuples,
consisting of name and argtype), and out_args (ditto).
The return value looks like this::
... | [
"The",
"service",
"s",
"actions",
"with",
"their",
"arguments",
"."
] | python | train |
BD2KOnFHIR/i2b2model | i2b2model/shared/tablenames.py | https://github.com/BD2KOnFHIR/i2b2model/blob/9d49bb53b0733dd83ab5b716014865e270a3c903/i2b2model/shared/tablenames.py#L37-L44 | def phys_name(self, item: str) -> str:
"""Return the physical (mapped) name of item.
:param item: logical table name
:return: physical name of table
"""
v = self.__dict__[item]
return v if v is not None else item | [
"def",
"phys_name",
"(",
"self",
",",
"item",
":",
"str",
")",
"->",
"str",
":",
"v",
"=",
"self",
".",
"__dict__",
"[",
"item",
"]",
"return",
"v",
"if",
"v",
"is",
"not",
"None",
"else",
"item"
] | Return the physical (mapped) name of item.
:param item: logical table name
:return: physical name of table | [
"Return",
"the",
"physical",
"(",
"mapped",
")",
"name",
"of",
"item",
"."
] | python | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L362-L366 | def cache_set(self, to_cache):
"""
Set content into the cache
"""
self.cache.set(self.cache_key, to_cache, self.expire_time) | [
"def",
"cache_set",
"(",
"self",
",",
"to_cache",
")",
":",
"self",
".",
"cache",
".",
"set",
"(",
"self",
".",
"cache_key",
",",
"to_cache",
",",
"self",
".",
"expire_time",
")"
] | Set content into the cache | [
"Set",
"content",
"into",
"the",
"cache"
] | python | train |
rackerlabs/python-lunrclient | lunrclient/base.py | https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/base.py#L124-L131 | def required(self, method, _dict, require):
"""
Ensure the required items are in the dictionary
"""
for key in require:
if key not in _dict:
raise LunrError("'%s' is required argument for method '%s'"
% (key, method)) | [
"def",
"required",
"(",
"self",
",",
"method",
",",
"_dict",
",",
"require",
")",
":",
"for",
"key",
"in",
"require",
":",
"if",
"key",
"not",
"in",
"_dict",
":",
"raise",
"LunrError",
"(",
"\"'%s' is required argument for method '%s'\"",
"%",
"(",
"key",
... | Ensure the required items are in the dictionary | [
"Ensure",
"the",
"required",
"items",
"are",
"in",
"the",
"dictionary"
] | python | train |
Dallinger/Dallinger | dallinger/heroku/rq_gevent_worker.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/rq_gevent_worker.py#L148-L159 | def work(self, burst=False, logging_level=logging.INFO):
"""
Spawning a greenlet to be able to kill it when it's blocked dequeueing job
:param burst: if it's burst worker don't need to spawn a greenlet
"""
# If the is a burst worker it's not needed to spawn greenlet
if bu... | [
"def",
"work",
"(",
"self",
",",
"burst",
"=",
"False",
",",
"logging_level",
"=",
"logging",
".",
"INFO",
")",
":",
"# If the is a burst worker it's not needed to spawn greenlet",
"if",
"burst",
":",
"return",
"self",
".",
"_work",
"(",
"burst",
",",
"logging_l... | Spawning a greenlet to be able to kill it when it's blocked dequeueing job
:param burst: if it's burst worker don't need to spawn a greenlet | [
"Spawning",
"a",
"greenlet",
"to",
"be",
"able",
"to",
"kill",
"it",
"when",
"it",
"s",
"blocked",
"dequeueing",
"job",
":",
"param",
"burst",
":",
"if",
"it",
"s",
"burst",
"worker",
"don",
"t",
"need",
"to",
"spawn",
"a",
"greenlet"
] | python | train |
petrjasek/eve-elastic | eve_elastic/elastic.py | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L303-L321 | def create_index(self, index=None, settings=None, es=None):
"""Create new index and ignore if it exists already."""
if index is None:
index = self.index
if es is None:
es = self.es
try:
alias = index
index = generate_index_name(alias)
... | [
"def",
"create_index",
"(",
"self",
",",
"index",
"=",
"None",
",",
"settings",
"=",
"None",
",",
"es",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"index",
"if",
"es",
"is",
"None",
":",
"es",
"=",
"self",... | Create new index and ignore if it exists already. | [
"Create",
"new",
"index",
"and",
"ignore",
"if",
"it",
"exists",
"already",
"."
] | python | train |
openid/python-openid | openid/server/trustroot.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L136-L188 | def isSane(self):
"""
This method checks the to see if a trust root represents a
reasonable (sane) set of URLs. 'http://*.com/', for example
is not a reasonable pattern, as it cannot meaningfully specify
the site claiming it. This function attempts to find many
related ... | [
"def",
"isSane",
"(",
"self",
")",
":",
"if",
"self",
".",
"host",
"==",
"'localhost'",
":",
"return",
"True",
"host_parts",
"=",
"self",
".",
"host",
".",
"split",
"(",
"'.'",
")",
"if",
"self",
".",
"wildcard",
":",
"assert",
"host_parts",
"[",
"0"... | This method checks the to see if a trust root represents a
reasonable (sane) set of URLs. 'http://*.com/', for example
is not a reasonable pattern, as it cannot meaningfully specify
the site claiming it. This function attempts to find many
related examples, but it can only work via heu... | [
"This",
"method",
"checks",
"the",
"to",
"see",
"if",
"a",
"trust",
"root",
"represents",
"a",
"reasonable",
"(",
"sane",
")",
"set",
"of",
"URLs",
".",
"http",
":",
"//",
"*",
".",
"com",
"/",
"for",
"example",
"is",
"not",
"a",
"reasonable",
"patte... | python | train |
Dentosal/python-sc2 | sc2/unit.py | https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/unit.py#L432-L437 | def is_carrying_minerals(self) -> bool:
""" Checks if a worker or MULE is carrying (gold-)minerals. """
return any(
buff.value in self._proto.buff_ids
for buff in {BuffId.CARRYMINERALFIELDMINERALS, BuffId.CARRYHIGHYIELDMINERALFIELDMINERALS}
) | [
"def",
"is_carrying_minerals",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"buff",
".",
"value",
"in",
"self",
".",
"_proto",
".",
"buff_ids",
"for",
"buff",
"in",
"{",
"BuffId",
".",
"CARRYMINERALFIELDMINERALS",
",",
"BuffId",
".",
"CARRYHI... | Checks if a worker or MULE is carrying (gold-)minerals. | [
"Checks",
"if",
"a",
"worker",
"or",
"MULE",
"is",
"carrying",
"(",
"gold",
"-",
")",
"minerals",
"."
] | python | train |
mailgun/talon | talon/utils.py | https://github.com/mailgun/talon/blob/cdd84563dd329c4f887591807870d10015e0c7a7/talon/utils.py#L57-L70 | def detect_encoding(string):
"""
Tries to detect the encoding of the passed string.
Defaults to UTF-8.
"""
assert isinstance(string, bytes)
try:
detected = chardet.detect(string)
if detected:
return detected.get('encoding') or 'utf-8'
except Exception as e:
... | [
"def",
"detect_encoding",
"(",
"string",
")",
":",
"assert",
"isinstance",
"(",
"string",
",",
"bytes",
")",
"try",
":",
"detected",
"=",
"chardet",
".",
"detect",
"(",
"string",
")",
"if",
"detected",
":",
"return",
"detected",
".",
"get",
"(",
"'encodi... | Tries to detect the encoding of the passed string.
Defaults to UTF-8. | [
"Tries",
"to",
"detect",
"the",
"encoding",
"of",
"the",
"passed",
"string",
"."
] | python | train |
cstatz/maui | maui/field/field.py | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/field/field.py#L351-L433 | def __array_op(self, f, x, axis):
"""operation for 3D Field with planes or vector (type = numpy.ndarray) or 2D Field with vector (numpy.ndarray)
:param f: operator function
:param x: array(1D, 2D) or field (2D) or View (2D)
:param axis: specifies axis, eg. axis = (1,2) plane lies in yz-p... | [
"def",
"__array_op",
"(",
"self",
",",
"f",
",",
"x",
",",
"axis",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"ndarray",
")",
"==",
"False",
"and",
"isinstance",
"(",
"x",
",",
"Field",
")",
"==",
"False",
"and",
"isinstance",
"(",
"x",
",",
"V... | operation for 3D Field with planes or vector (type = numpy.ndarray) or 2D Field with vector (numpy.ndarray)
:param f: operator function
:param x: array(1D, 2D) or field (2D) or View (2D)
:param axis: specifies axis, eg. axis = (1,2) plane lies in yz-plane, axis=0 vector along x axis
:ret... | [
"operation",
"for",
"3D",
"Field",
"with",
"planes",
"or",
"vector",
"(",
"type",
"=",
"numpy",
".",
"ndarray",
")",
"or",
"2D",
"Field",
"with",
"vector",
"(",
"numpy",
".",
"ndarray",
")",
":",
"param",
"f",
":",
"operator",
"function",
":",
"param",... | python | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/mayapylauncher.py | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/mayapylauncher.py#L28-L45 | def setup_environment():
"""Set up neccessary environment variables
This appends all path of sys.path to the python path
so mayapy will find all installed modules.
We have to make sure, that we use maya libs instead of
libs of the virtual env. So we insert all the libs for mayapy
first.
:r... | [
"def",
"setup_environment",
"(",
")",
":",
"osinter",
"=",
"ostool",
".",
"get_interface",
"(",
")",
"pypath",
"=",
"osinter",
".",
"get_maya_envpath",
"(",
")",
"for",
"p",
"in",
"sys",
".",
"path",
":",
"pypath",
"=",
"os",
".",
"pathsep",
".",
"join... | Set up neccessary environment variables
This appends all path of sys.path to the python path
so mayapy will find all installed modules.
We have to make sure, that we use maya libs instead of
libs of the virtual env. So we insert all the libs for mayapy
first.
:returns: None
:rtype: None
... | [
"Set",
"up",
"neccessary",
"environment",
"variables"
] | python | train |
intake/intake | intake/gui/source/gui.py | https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/source/gui.py#L123-L129 | def on_click_plot_widget(self, event):
""" When the plot control is toggled, set visibility and hand down source"""
self.plot.source = self.sources
self.plot.visible = event.new
if self.plot.visible:
self.plot.watchers.append(
self.select.widget.link(self.plot... | [
"def",
"on_click_plot_widget",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"plot",
".",
"source",
"=",
"self",
".",
"sources",
"self",
".",
"plot",
".",
"visible",
"=",
"event",
".",
"new",
"if",
"self",
".",
"plot",
".",
"visible",
":",
"self"... | When the plot control is toggled, set visibility and hand down source | [
"When",
"the",
"plot",
"control",
"is",
"toggled",
"set",
"visibility",
"and",
"hand",
"down",
"source"
] | python | train |
pauleveritt/kaybee | kaybee/plugins/events.py | https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L134-L141 | def call_doctree_resolved(cls, kb_app, sphinx_app: Sphinx,
doctree: doctree,
fromdocname: str):
""" On doctree-resolved, do callbacks"""
for callback in EventAction.get_callbacks(kb_app,
Sphinx... | [
"def",
"call_doctree_resolved",
"(",
"cls",
",",
"kb_app",
",",
"sphinx_app",
":",
"Sphinx",
",",
"doctree",
":",
"doctree",
",",
"fromdocname",
":",
"str",
")",
":",
"for",
"callback",
"in",
"EventAction",
".",
"get_callbacks",
"(",
"kb_app",
",",
"SphinxEv... | On doctree-resolved, do callbacks | [
"On",
"doctree",
"-",
"resolved",
"do",
"callbacks"
] | python | train |
mitsei/dlkit | dlkit/records/assessment/orthographic_visualization/multi_choice_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/orthographic_visualization/multi_choice_records.py#L212-L218 | def set_ortho_choice(self, small_asset_data, large_asset_data, name='Choice'):
"""stub"""
o3d_asset_id = self.create_o3d_asset(manip=None,
small_ov_set=small_asset_data,
large_ov_set=large_asset_data,
... | [
"def",
"set_ortho_choice",
"(",
"self",
",",
"small_asset_data",
",",
"large_asset_data",
",",
"name",
"=",
"'Choice'",
")",
":",
"o3d_asset_id",
"=",
"self",
".",
"create_o3d_asset",
"(",
"manip",
"=",
"None",
",",
"small_ov_set",
"=",
"small_asset_data",
",",
... | stub | [
"stub"
] | python | train |
Unidata/siphon | siphon/radarserver.py | https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/radarserver.py#L23-L43 | def stations(self, *stns):
"""Specify one or more stations for the query.
This modifies the query in-place, but returns `self` so that multiple
queries can be chained together on one line.
This replaces any existing spatial queries that have been set.
Parameters
------... | [
"def",
"stations",
"(",
"self",
",",
"*",
"stns",
")",
":",
"self",
".",
"_set_query",
"(",
"self",
".",
"spatial_query",
",",
"stn",
"=",
"stns",
")",
"return",
"self"
] | Specify one or more stations for the query.
This modifies the query in-place, but returns `self` so that multiple
queries can be chained together on one line.
This replaces any existing spatial queries that have been set.
Parameters
----------
stns : one or more string... | [
"Specify",
"one",
"or",
"more",
"stations",
"for",
"the",
"query",
"."
] | python | train |
bmcfee/muda | muda/base.py | https://github.com/bmcfee/muda/blob/ff82efdfaeb98da0a9f9124845826eb20536a9ba/muda/base.py#L196-L206 | def get_params(self):
'''Get the parameters for this object. Returns as a dict.'''
out = {}
out['__class__'] = self.__class__
out['params'] = dict(steps=[])
for name, step in self.steps:
out['params']['steps'].append([name, step.get_params(deep=True)])
ret... | [
"def",
"get_params",
"(",
"self",
")",
":",
"out",
"=",
"{",
"}",
"out",
"[",
"'__class__'",
"]",
"=",
"self",
".",
"__class__",
"out",
"[",
"'params'",
"]",
"=",
"dict",
"(",
"steps",
"=",
"[",
"]",
")",
"for",
"name",
",",
"step",
"in",
"self",... | Get the parameters for this object. Returns as a dict. | [
"Get",
"the",
"parameters",
"for",
"this",
"object",
".",
"Returns",
"as",
"a",
"dict",
"."
] | python | valid |
DistrictDataLabs/yellowbrick | yellowbrick/features/radviz.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/features/radviz.py#L34-L86 | def radviz(X, y=None, ax=None, features=None, classes=None,
color=None, colormap=None, alpha=1.0, **kwargs):
"""
Displays each feature as an axis around a circle surrounding a scatter
plot whose points are each individual instance.
This helper function is a quick wrapper to utilize the Radia... | [
"def",
"radviz",
"(",
"X",
",",
"y",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"features",
"=",
"None",
",",
"classes",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colormap",
"=",
"None",
",",
"alpha",
"=",
"1.0",
",",
"*",
"*",
"kwargs",
")"... | Displays each feature as an axis around a circle surrounding a scatter
plot whose points are each individual instance.
This helper function is a quick wrapper to utilize the RadialVisualizer
(Transformer) for one-off analysis.
Parameters
----------
X : ndarray or DataFrame of shape n x m
... | [
"Displays",
"each",
"feature",
"as",
"an",
"axis",
"around",
"a",
"circle",
"surrounding",
"a",
"scatter",
"plot",
"whose",
"points",
"are",
"each",
"individual",
"instance",
"."
] | python | train |
moderngl/moderngl | examples/window/sdl2/window.py | https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/sdl2/window.py#L87-L122 | def process_events(self):
"""
Loop through and handle all the queued events.
"""
for event in sdl2.ext.get_events():
if event.type == sdl2.SDL_MOUSEMOTION:
self.example.mouse_position_event(event.motion.x, event.motion.y)
elif event.type =... | [
"def",
"process_events",
"(",
"self",
")",
":",
"for",
"event",
"in",
"sdl2",
".",
"ext",
".",
"get_events",
"(",
")",
":",
"if",
"event",
".",
"type",
"==",
"sdl2",
".",
"SDL_MOUSEMOTION",
":",
"self",
".",
"example",
".",
"mouse_position_event",
"(",
... | Loop through and handle all the queued events. | [
"Loop",
"through",
"and",
"handle",
"all",
"the",
"queued",
"events",
"."
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/PathList.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/PathList.py#L49-L67 | def node_conv(obj):
"""
This is the "string conversion" routine that we have our substitutions
use to return Nodes, not strings. This relies on the fact that an
EntryProxy object has a get() method that returns the underlying
Node that it wraps, which is a bit of architectural dependence
that w... | [
"def",
"node_conv",
"(",
"obj",
")",
":",
"try",
":",
"get",
"=",
"obj",
".",
"get",
"except",
"AttributeError",
":",
"if",
"isinstance",
"(",
"obj",
",",
"SCons",
".",
"Node",
".",
"Node",
")",
"or",
"SCons",
".",
"Util",
".",
"is_Sequence",
"(",
... | This is the "string conversion" routine that we have our substitutions
use to return Nodes, not strings. This relies on the fact that an
EntryProxy object has a get() method that returns the underlying
Node that it wraps, which is a bit of architectural dependence
that we might need to break or modify ... | [
"This",
"is",
"the",
"string",
"conversion",
"routine",
"that",
"we",
"have",
"our",
"substitutions",
"use",
"to",
"return",
"Nodes",
"not",
"strings",
".",
"This",
"relies",
"on",
"the",
"fact",
"that",
"an",
"EntryProxy",
"object",
"has",
"a",
"get",
"()... | python | train |
adamchainz/django-mysql | django_mysql/utils.py | https://github.com/adamchainz/django-mysql/blob/967daa4245cf55c9bc5dc018e560f417c528916a/django_mysql/utils.py#L30-L51 | def update(self, n, t):
"""
Update weighted average rate. Param n is generic; it's how many of
whatever the caller is doing (rows, checksums, etc.). Param s is how
long this n took, in seconds (hi-res or not).
Parameters:
n - Number of operations (rows, etc.)
... | [
"def",
"update",
"(",
"self",
",",
"n",
",",
"t",
")",
":",
"if",
"self",
".",
"avg_n",
"and",
"self",
".",
"avg_t",
":",
"self",
".",
"avg_n",
"=",
"(",
"self",
".",
"avg_n",
"*",
"self",
".",
"weight",
")",
"+",
"n",
"self",
".",
"avg_t",
"... | Update weighted average rate. Param n is generic; it's how many of
whatever the caller is doing (rows, checksums, etc.). Param s is how
long this n took, in seconds (hi-res or not).
Parameters:
n - Number of operations (rows, etc.)
t - Amount of time in seconds that n ... | [
"Update",
"weighted",
"average",
"rate",
".",
"Param",
"n",
"is",
"generic",
";",
"it",
"s",
"how",
"many",
"of",
"whatever",
"the",
"caller",
"is",
"doing",
"(",
"rows",
"checksums",
"etc",
".",
")",
".",
"Param",
"s",
"is",
"how",
"long",
"this",
"... | python | train |
rdussurget/py-altimetry | altimetry/externals/esutils_stat.py | https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/externals/esutils_stat.py#L21-L86 | def histogram(data, bins=None, binsize=1., min=None, max=None, rev=False, use_weave=True, verbose=0):
"""
Similar to IDL histogram.
For reverse indices, the fast version uses weave from scipy. This is the
default. If scipy is not available a slower version is used.
"""
if not have_s... | [
"def",
"histogram",
"(",
"data",
",",
"bins",
"=",
"None",
",",
"binsize",
"=",
"1.",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
",",
"rev",
"=",
"False",
",",
"use_weave",
"=",
"True",
",",
"verbose",
"=",
"0",
")",
":",
"if",
"not",
"h... | Similar to IDL histogram.
For reverse indices, the fast version uses weave from scipy. This is the
default. If scipy is not available a slower version is used. | [
"Similar",
"to",
"IDL",
"histogram",
".",
"For",
"reverse",
"indices",
"the",
"fast",
"version",
"uses",
"weave",
"from",
"scipy",
".",
"This",
"is",
"the",
"default",
".",
"If",
"scipy",
"is",
"not",
"available",
"a",
"slower",
"version",
"is",
"used",
... | python | train |
fastai/fastai | fastai/metrics.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/metrics.py#L266-L272 | def auc_roc_score(input:Tensor, targ:Tensor):
"Using trapezoid method to calculate the area under roc curve"
fpr, tpr = roc_curve(input, targ)
d = fpr[1:] - fpr[:-1]
sl1, sl2 = [slice(None)], [slice(None)]
sl1[-1], sl2[-1] = slice(1, None), slice(None, -1)
return (d * (tpr[tuple(sl1)] + tpr[tupl... | [
"def",
"auc_roc_score",
"(",
"input",
":",
"Tensor",
",",
"targ",
":",
"Tensor",
")",
":",
"fpr",
",",
"tpr",
"=",
"roc_curve",
"(",
"input",
",",
"targ",
")",
"d",
"=",
"fpr",
"[",
"1",
":",
"]",
"-",
"fpr",
"[",
":",
"-",
"1",
"]",
"sl1",
"... | Using trapezoid method to calculate the area under roc curve | [
"Using",
"trapezoid",
"method",
"to",
"calculate",
"the",
"area",
"under",
"roc",
"curve"
] | python | train |
ultrabug/py3status | py3status/py3.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/py3.py#L337-L425 | def format_units(self, value, unit="B", optimal=5, auto=True, si=False):
"""
Takes a value and formats it for user output, we can choose the unit to
use eg B, MiB, kbits/second. This is mainly for use with bytes/bits it
converts the value into a human readable form. It has various
... | [
"def",
"format_units",
"(",
"self",
",",
"value",
",",
"unit",
"=",
"\"B\"",
",",
"optimal",
"=",
"5",
",",
"auto",
"=",
"True",
",",
"si",
"=",
"False",
")",
":",
"UNITS",
"=",
"\"KMGTPEZY\"",
"DECIMAL_SIZE",
"=",
"1000",
"BINARY_SIZE",
"=",
"1024",
... | Takes a value and formats it for user output, we can choose the unit to
use eg B, MiB, kbits/second. This is mainly for use with bytes/bits it
converts the value into a human readable form. It has various
additional options but they are really only for special cases.
The function retu... | [
"Takes",
"a",
"value",
"and",
"formats",
"it",
"for",
"user",
"output",
"we",
"can",
"choose",
"the",
"unit",
"to",
"use",
"eg",
"B",
"MiB",
"kbits",
"/",
"second",
".",
"This",
"is",
"mainly",
"for",
"use",
"with",
"bytes",
"/",
"bits",
"it",
"conve... | python | train |
saltstack/salt | salt/returners/__init__.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L123-L166 | def _fetch_option(cfg, ret_config, virtualname, attr_name):
"""
Fetch a given option value from the config.
@see :func:`get_returner_options`
"""
# c_cfg is a dictionary returned from config.option for
# any options configured for this returner.
if isinstance(cfg, dict):
c_cfg = cfg... | [
"def",
"_fetch_option",
"(",
"cfg",
",",
"ret_config",
",",
"virtualname",
",",
"attr_name",
")",
":",
"# c_cfg is a dictionary returned from config.option for",
"# any options configured for this returner.",
"if",
"isinstance",
"(",
"cfg",
",",
"dict",
")",
":",
"c_cfg",... | Fetch a given option value from the config.
@see :func:`get_returner_options` | [
"Fetch",
"a",
"given",
"option",
"value",
"from",
"the",
"config",
"."
] | python | train |
jic-dtool/dtoolcore | dtoolcore/storagebroker.py | https://github.com/jic-dtool/dtoolcore/blob/eeb9a924dc8fcf543340653748a7877be1f98e0f/dtoolcore/storagebroker.py#L258-L271 | def update_readme(self, content):
"""Update the readme descriptive metadata."""
logger.debug("Updating readme")
key = self.get_readme_key()
# Back up old README content.
backup_content = self.get_readme_content()
backup_key = key + "-{}".format(
timestamp(dat... | [
"def",
"update_readme",
"(",
"self",
",",
"content",
")",
":",
"logger",
".",
"debug",
"(",
"\"Updating readme\"",
")",
"key",
"=",
"self",
".",
"get_readme_key",
"(",
")",
"# Back up old README content.",
"backup_content",
"=",
"self",
".",
"get_readme_content",
... | Update the readme descriptive metadata. | [
"Update",
"the",
"readme",
"descriptive",
"metadata",
"."
] | python | train |
wiredrive/wtframework | wtframework/wtf/web/webelement.py | https://github.com/wiredrive/wtframework/blob/ef7f86c4d4cf7fb17745fd627b3cc4a41f4c0216/wtframework/wtf/web/webelement.py#L89-L114 | def wait_until_element_not_visible(webdriver, locator_lambda_expression,
timeout=WTF_TIMEOUT_MANAGER.NORMAL, sleep=0.5):
"""
Wait for a WebElement to disappear.
Args:
webdriver (Webdriver) - Selenium Webdriver
locator (lambda) - Loc... | [
"def",
"wait_until_element_not_visible",
"(",
"webdriver",
",",
"locator_lambda_expression",
",",
"timeout",
"=",
"WTF_TIMEOUT_MANAGER",
".",
"NORMAL",
",",
"sleep",
"=",
"0.5",
")",
":",
"# Wait for loading progress indicator to go away.",
"try",
":",
"stoptime",
"=",
... | Wait for a WebElement to disappear.
Args:
webdriver (Webdriver) - Selenium Webdriver
locator (lambda) - Locator lambda expression.
Kwargs:
timeout (number) - timeout period
sleep (number) - sleep period between intervals. | [
"Wait",
"for",
"a",
"WebElement",
"to",
"disappear",
"."
] | python | train |
PySimpleGUI/PySimpleGUI | PySimpleGUIQt/PySimpleGUIQt.py | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L7025-L7070 | def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_fol... | [
"def",
"PopupGetFolder",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_path",
"=",
"''",
",",
"no_window",
"=",
"False",
",",
"size",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
... | Display popup with text entry field and browse button. Browse for folder
:param message:
:param default_path:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon:
:param font:
:param no_titlebar:
:param grab_anywhere:
... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"folder",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"no_window",
":",
":",
"param",
"size",
":",
":",
"param",
"bu... | python | train |
upsight/doctor | doctor/types.py | https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/types.py#L914-L922 | def array(description, **kwargs) -> typing.Type:
"""Create a :class:`~doctor.types.Array` type.
:param description: A description of the type.
:param kwargs: Can include any attribute defined in
:class:`~doctor.types.Array`
"""
kwargs['description'] = description
return type('Array', (A... | [
"def",
"array",
"(",
"description",
",",
"*",
"*",
"kwargs",
")",
"->",
"typing",
".",
"Type",
":",
"kwargs",
"[",
"'description'",
"]",
"=",
"description",
"return",
"type",
"(",
"'Array'",
",",
"(",
"Array",
",",
")",
",",
"kwargs",
")"
] | Create a :class:`~doctor.types.Array` type.
:param description: A description of the type.
:param kwargs: Can include any attribute defined in
:class:`~doctor.types.Array` | [
"Create",
"a",
":",
"class",
":",
"~doctor",
".",
"types",
".",
"Array",
"type",
"."
] | python | train |
Clinical-Genomics/scout | scout/adapter/mongo/panel.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/panel.py#L375-L456 | def apply_pending(self, panel_obj, version):
"""Apply the pending changes to an existing gene panel or create a new version of the same panel.
Args:
panel_obj(dict): panel in database to update
version(double): panel version to update
Returns:
inserted_id(st... | [
"def",
"apply_pending",
"(",
"self",
",",
"panel_obj",
",",
"version",
")",
":",
"updates",
"=",
"{",
"}",
"new_panel",
"=",
"deepcopy",
"(",
"panel_obj",
")",
"new_panel",
"[",
"'pending'",
"]",
"=",
"[",
"]",
"new_panel",
"[",
"'date'",
"]",
"=",
"dt... | Apply the pending changes to an existing gene panel or create a new version of the same panel.
Args:
panel_obj(dict): panel in database to update
version(double): panel version to update
Returns:
inserted_id(str): id of updated panel or the new one | [
"Apply",
"the",
"pending",
"changes",
"to",
"an",
"existing",
"gene",
"panel",
"or",
"create",
"a",
"new",
"version",
"of",
"the",
"same",
"panel",
"."
] | python | test |
rocky/python3-trepan | trepan/processor/subcmd.py | https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/processor/subcmd.py#L38-L55 | def short_help(self, subcmd_cb, subcmd_name, label=False):
"""Show short help for a subcommand."""
entry = self.lookup(subcmd_name)
if entry:
if label:
prefix = entry.name
else:
prefix = ''
pass
if hasattr(entry,... | [
"def",
"short_help",
"(",
"self",
",",
"subcmd_cb",
",",
"subcmd_name",
",",
"label",
"=",
"False",
")",
":",
"entry",
"=",
"self",
".",
"lookup",
"(",
"subcmd_name",
")",
"if",
"entry",
":",
"if",
"label",
":",
"prefix",
"=",
"entry",
".",
"name",
"... | Show short help for a subcommand. | [
"Show",
"short",
"help",
"for",
"a",
"subcommand",
"."
] | python | test |
nwhitehead/pineapple-module | pineapple/require.py | https://github.com/nwhitehead/pineapple-module/blob/d35ac6d9c1d748dbc06ac568829325c36680b0cb/pineapple/require.py#L5-L15 | def freeze():
'''
Show arguments to require() to recreate what has been installed
'''
installations = {}
for dist in get_installed_distributions():
req = pip.FrozenRequirement.from_dist(dist, [], find_tags=False)
installations[req.name] = req
return [str(installation).rstrip() f... | [
"def",
"freeze",
"(",
")",
":",
"installations",
"=",
"{",
"}",
"for",
"dist",
"in",
"get_installed_distributions",
"(",
")",
":",
"req",
"=",
"pip",
".",
"FrozenRequirement",
".",
"from_dist",
"(",
"dist",
",",
"[",
"]",
",",
"find_tags",
"=",
"False",
... | Show arguments to require() to recreate what has been installed | [
"Show",
"arguments",
"to",
"require",
"()",
"to",
"recreate",
"what",
"has",
"been",
"installed"
] | python | train |
Opentrons/opentrons | api/src/opentrons/hardware_control/__init__.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/hardware_control/__init__.py#L383-L395 | async def home_plunger(self, mount: top_types.Mount):
"""
Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount`
"""
instr = self._attac... | [
"async",
"def",
"home_plunger",
"(",
"self",
",",
"mount",
":",
"top_types",
".",
"Mount",
")",
":",
"instr",
"=",
"self",
".",
"_attached_instruments",
"[",
"mount",
"]",
"if",
"instr",
":",
"await",
"self",
".",
"home",
"(",
"[",
"Axis",
".",
"of_plu... | Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount` | [
"Home",
"the",
"plunger",
"motor",
"for",
"a",
"mount",
"and",
"then",
"return",
"it",
"to",
"the",
"bottom",
"position",
"."
] | python | train |
zsethna/OLGA | olga/load_model.py | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/load_model.py#L258-L289 | def load_igor_genomic_data(self, params_file_name, V_anchor_pos_file, J_anchor_pos_file):
"""Set attributes by loading in genomic data from IGoR parameter file.
Sets attributes genV, max_delV_palindrome, cutV_genomic_CDR3_segs,
genD, max_delDl_palindrome, max_delDr_palindrome,
... | [
"def",
"load_igor_genomic_data",
"(",
"self",
",",
"params_file_name",
",",
"V_anchor_pos_file",
",",
"J_anchor_pos_file",
")",
":",
"self",
".",
"genV",
"=",
"read_igor_V_gene_parameters",
"(",
"params_file_name",
")",
"self",
".",
"genD",
"=",
"read_igor_D_gene_para... | Set attributes by loading in genomic data from IGoR parameter file.
Sets attributes genV, max_delV_palindrome, cutV_genomic_CDR3_segs,
genD, max_delDl_palindrome, max_delDr_palindrome,
cutD_genomic_CDR3_segs, genJ, max_delJ_palindrome, and
cutJ_genomic_CDR3_segs.
... | [
"Set",
"attributes",
"by",
"loading",
"in",
"genomic",
"data",
"from",
"IGoR",
"parameter",
"file",
".",
"Sets",
"attributes",
"genV",
"max_delV_palindrome",
"cutV_genomic_CDR3_segs",
"genD",
"max_delDl_palindrome",
"max_delDr_palindrome",
"cutD_genomic_CDR3_segs",
"genJ",
... | python | train |
boriel/zxbasic | zxbparser.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L2532-L2547 | def p_addr_of_id(p):
""" bexpr : ADDRESSOF ID
| ADDRESSOF ARRAY_ID
"""
entry = SYMBOL_TABLE.access_id(p[2], p.lineno(2))
if entry is None:
p[0] = None
return
entry.accessed = True
result = make_unary(p.lineno(1), 'ADDRESS', entry, type_=_TYPE(gl.PTR_TYPE))
if i... | [
"def",
"p_addr_of_id",
"(",
"p",
")",
":",
"entry",
"=",
"SYMBOL_TABLE",
".",
"access_id",
"(",
"p",
"[",
"2",
"]",
",",
"p",
".",
"lineno",
"(",
"2",
")",
")",
"if",
"entry",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"None",
"return",
"entry... | bexpr : ADDRESSOF ID
| ADDRESSOF ARRAY_ID | [
"bexpr",
":",
"ADDRESSOF",
"ID",
"|",
"ADDRESSOF",
"ARRAY_ID"
] | python | train |
bxlab/bx-python | lib/bx/intervals/random_intervals.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/intervals/random_intervals.py#L56-L89 | def throw_random_intervals( lengths, regions, save_interval_func=None, allow_overlap=False ):
"""
Generates a set of non-overlapping random intervals from a length
distribution.
`lengths`: list containing the length of each interval to be generated.
We expect this to be sorted by de... | [
"def",
"throw_random_intervals",
"(",
"lengths",
",",
"regions",
",",
"save_interval_func",
"=",
"None",
",",
"allow_overlap",
"=",
"False",
")",
":",
"# Copy regions",
"regions",
"=",
"[",
"(",
"x",
"[",
"1",
"]",
"-",
"x",
"[",
"0",
"]",
",",
"x",
"[... | Generates a set of non-overlapping random intervals from a length
distribution.
`lengths`: list containing the length of each interval to be generated.
We expect this to be sorted by decreasing length to minimize
the chance of failure (MaxtriesException) and for some
... | [
"Generates",
"a",
"set",
"of",
"non",
"-",
"overlapping",
"random",
"intervals",
"from",
"a",
"length",
"distribution",
".",
"lengths",
":",
"list",
"containing",
"the",
"length",
"of",
"each",
"interval",
"to",
"be",
"generated",
".",
"We",
"expect",
"this"... | python | train |
BlueBrain/hpcbench | hpcbench/driver/base.py | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/driver/base.py#L32-L54 | def write_yaml_report(func):
"""Decorator used in campaign node post-processing
"""
@wraps(func)
def _wrapper(*args, **kwargs):
now = datetime.datetime.now()
with Timer() as timer:
data = func(*args, **kwargs)
if isinstance(data, (SEQUENCES, types.GeneratorType))... | [
"def",
"write_yaml_report",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"with",
"Timer",
"(",
")",
"... | Decorator used in campaign node post-processing | [
"Decorator",
"used",
"in",
"campaign",
"node",
"post",
"-",
"processing"
] | python | train |
google/grr | grr/server/grr_response_server/databases/mem_artifacts.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_artifacts.py#L16-L23 | def WriteArtifact(self, artifact):
"""Writes new artifact to the database."""
name = str(artifact.name)
if name in self.artifacts:
raise db.DuplicatedArtifactError(name)
self.artifacts[name] = artifact.Copy() | [
"def",
"WriteArtifact",
"(",
"self",
",",
"artifact",
")",
":",
"name",
"=",
"str",
"(",
"artifact",
".",
"name",
")",
"if",
"name",
"in",
"self",
".",
"artifacts",
":",
"raise",
"db",
".",
"DuplicatedArtifactError",
"(",
"name",
")",
"self",
".",
"art... | Writes new artifact to the database. | [
"Writes",
"new",
"artifact",
"to",
"the",
"database",
"."
] | python | train |
monarch-initiative/dipper | dipper/sources/UDP.py | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/UDP.py#L324-L439 | def _add_variant_gene_relationship(self, patient_var_map, gene_coordinate_map):
"""
Right now it is unclear the best approach on how to connect
variants to genes. In most cases has_affected_locus/GENO:0000418
is accurate; however, there are cases where a variant is in the intron
... | [
"def",
"_add_variant_gene_relationship",
"(",
"self",
",",
"patient_var_map",
",",
"gene_coordinate_map",
")",
":",
"# genotype = Genotype(self.graph)",
"dipper_util",
"=",
"DipperUtil",
"(",
")",
"model",
"=",
"Model",
"(",
"self",
".",
"graph",
")",
"# Note this cou... | Right now it is unclear the best approach on how to connect
variants to genes. In most cases has_affected_locus/GENO:0000418
is accurate; however, there are cases where a variant is in the intron
on one gene and is purported to causally affect another gene down or
upstream. In these ca... | [
"Right",
"now",
"it",
"is",
"unclear",
"the",
"best",
"approach",
"on",
"how",
"to",
"connect",
"variants",
"to",
"genes",
".",
"In",
"most",
"cases",
"has_affected_locus",
"/",
"GENO",
":",
"0000418",
"is",
"accurate",
";",
"however",
"there",
"are",
"cas... | python | train |
hover2pi/svo_filters | svo_filters/svo.py | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L438-L492 | def load_TopHat(self, wave_min, wave_max, pixels_per_bin=100):
"""
Loads a top hat filter given wavelength min and max values
Parameters
----------
wave_min: astropy.units.quantity (optional)
The minimum wavelength to use
wave_max: astropy.units.quantity (opt... | [
"def",
"load_TopHat",
"(",
"self",
",",
"wave_min",
",",
"wave_max",
",",
"pixels_per_bin",
"=",
"100",
")",
":",
"# Get min, max, effective wavelengths and width",
"self",
".",
"pixels_per_bin",
"=",
"pixels_per_bin",
"self",
".",
"n_bins",
"=",
"1",
"self",
".",... | Loads a top hat filter given wavelength min and max values
Parameters
----------
wave_min: astropy.units.quantity (optional)
The minimum wavelength to use
wave_max: astropy.units.quantity (optional)
The maximum wavelength to use
n_pixels: int
... | [
"Loads",
"a",
"top",
"hat",
"filter",
"given",
"wavelength",
"min",
"and",
"max",
"values"
] | python | train |
istresearch/scrapy-cluster | redis-monitor/plugins/info_monitor.py | https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/redis-monitor/plugins/info_monitor.py#L152-L202 | def _build_crawlid_info(self, master, dict):
'''
Builds the crawlid info object
@param master: the master dict
@param dict: the dict object received
@return: the crawlid info object
'''
master['total_pending'] = 0
master['total_domains'] = 0
maste... | [
"def",
"_build_crawlid_info",
"(",
"self",
",",
"master",
",",
"dict",
")",
":",
"master",
"[",
"'total_pending'",
"]",
"=",
"0",
"master",
"[",
"'total_domains'",
"]",
"=",
"0",
"master",
"[",
"'appid'",
"]",
"=",
"dict",
"[",
"'appid'",
"]",
"master",
... | Builds the crawlid info object
@param master: the master dict
@param dict: the dict object received
@return: the crawlid info object | [
"Builds",
"the",
"crawlid",
"info",
"object"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.