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 |
|---|---|---|---|---|---|---|---|---|
gwastro/pycbc | pycbc/results/metadata.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/results/metadata.py#L57-L67 | def load_html_metadata(filename):
""" Get metadata from html file """
parser = MetaParser()
data = open(filename, 'r').read()
if 'pycbc-meta' in data:
print("LOADING HTML FILE %s" % filename)
parser.feed(data)
cp = ConfigParser.ConfigParser(parser.metadata)
cp.add_section(os.path.ba... | [
"def",
"load_html_metadata",
"(",
"filename",
")",
":",
"parser",
"=",
"MetaParser",
"(",
")",
"data",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
".",
"read",
"(",
")",
"if",
"'pycbc-meta'",
"in",
"data",
":",
"print",
"(",
"\"LOADING HTML FILE %s\"",
... | Get metadata from html file | [
"Get",
"metadata",
"from",
"html",
"file"
] | python | train |
vint21h/nagios-notification-google-calendar | notification_google_calendar.py | https://github.com/vint21h/nagios-notification-google-calendar/blob/ef2b58c939d9d55a69a54b4e6a3fd9b61bde50d4/notification_google_calendar.py#L192-L220 | def create_event(options, config, credentials):
"""
Create event in calendar with sms reminder.
"""
try:
http = credentials.authorize(httplib2.Http())
service = build("calendar", "v3", http=http)
event = {
"summary": options.message,
"location": "",
... | [
"def",
"create_event",
"(",
"options",
",",
"config",
",",
"credentials",
")",
":",
"try",
":",
"http",
"=",
"credentials",
".",
"authorize",
"(",
"httplib2",
".",
"Http",
"(",
")",
")",
"service",
"=",
"build",
"(",
"\"calendar\"",
",",
"\"v3\"",
",",
... | Create event in calendar with sms reminder. | [
"Create",
"event",
"in",
"calendar",
"with",
"sms",
"reminder",
"."
] | python | test |
python-wink/python-wink | src/pywink/devices/binary_switch.py | https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/binary_switch.py#L15-L23 | def set_state(self, state):
"""
:param state: a boolean of true (on) or false ('off')
:return: nothing
"""
_field = self.binary_state_name()
values = {"desired_state": {_field: state}}
response = self.api_interface.local_set_state(self, values, type_overr... | [
"def",
"set_state",
"(",
"self",
",",
"state",
")",
":",
"_field",
"=",
"self",
".",
"binary_state_name",
"(",
")",
"values",
"=",
"{",
"\"desired_state\"",
":",
"{",
"_field",
":",
"state",
"}",
"}",
"response",
"=",
"self",
".",
"api_interface",
".",
... | :param state: a boolean of true (on) or false ('off')
:return: nothing | [
":",
"param",
"state",
":",
"a",
"boolean",
"of",
"true",
"(",
"on",
")",
"or",
"false",
"(",
"off",
")",
":",
"return",
":",
"nothing"
] | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/html5lib/html5parser.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/html5lib/html5parser.py#L404-L419 | def parseRCDataRawtext(self, token, contentType):
"""Generic RCDATA/RAWTEXT Parsing algorithm
contentType - RCDATA or RAWTEXT
"""
assert contentType in ("RAWTEXT", "RCDATA")
self.tree.insertElement(token)
if contentType == "RAWTEXT":
self.tokenizer.state = s... | [
"def",
"parseRCDataRawtext",
"(",
"self",
",",
"token",
",",
"contentType",
")",
":",
"assert",
"contentType",
"in",
"(",
"\"RAWTEXT\"",
",",
"\"RCDATA\"",
")",
"self",
".",
"tree",
".",
"insertElement",
"(",
"token",
")",
"if",
"contentType",
"==",
"\"RAWTE... | Generic RCDATA/RAWTEXT Parsing algorithm
contentType - RCDATA or RAWTEXT | [
"Generic",
"RCDATA",
"/",
"RAWTEXT",
"Parsing",
"algorithm",
"contentType",
"-",
"RCDATA",
"or",
"RAWTEXT"
] | python | test |
sonyxperiadev/pygerrit | pygerrit/ssh.py | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L84-L111 | def _configure(self):
""" Configure the ssh parameters from the config file. """
configfile = expanduser("~/.ssh/config")
if not isfile(configfile):
raise GerritError("ssh config file '%s' does not exist" %
configfile)
config = SSHConfig()
... | [
"def",
"_configure",
"(",
"self",
")",
":",
"configfile",
"=",
"expanduser",
"(",
"\"~/.ssh/config\"",
")",
"if",
"not",
"isfile",
"(",
"configfile",
")",
":",
"raise",
"GerritError",
"(",
"\"ssh config file '%s' does not exist\"",
"%",
"configfile",
")",
"config"... | Configure the ssh parameters from the config file. | [
"Configure",
"the",
"ssh",
"parameters",
"from",
"the",
"config",
"file",
"."
] | python | train |
DsixTools/python-smeftrunner | smeftrunner/classes.py | https://github.com/DsixTools/python-smeftrunner/blob/4c9130e53ad4f7bbb526657a82150ca9d57c4b37/smeftrunner/classes.py#L134-L156 | def get_wcxf(self, C_out, scale_out):
"""Return the Wilson coefficients `C_out` as a wcxf.WC instance.
Note that the Wilson coefficients are rotated into the Warsaw basis
as defined in WCxf, i.e. to the basis where the down-type and charged
lepton mass matrices are diagonal."""
... | [
"def",
"get_wcxf",
"(",
"self",
",",
"C_out",
",",
"scale_out",
")",
":",
"import",
"wcxf",
"C",
"=",
"self",
".",
"rotate_defaultbasis",
"(",
"C_out",
")",
"d",
"=",
"wcxf",
".",
"translators",
".",
"smeft",
".",
"arrays2wcxf",
"(",
"C",
")",
"basis",... | Return the Wilson coefficients `C_out` as a wcxf.WC instance.
Note that the Wilson coefficients are rotated into the Warsaw basis
as defined in WCxf, i.e. to the basis where the down-type and charged
lepton mass matrices are diagonal. | [
"Return",
"the",
"Wilson",
"coefficients",
"C_out",
"as",
"a",
"wcxf",
".",
"WC",
"instance",
"."
] | python | train |
basho/riak-python-client | riak/transports/http/transport.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/transport.py#L379-L413 | def get_index(self, bucket, index, startkey, endkey=None,
return_terms=None, max_results=None, continuation=None,
timeout=None, term_regex=None):
"""
Performs a secondary index query.
"""
if term_regex and not self.index_term_regex():
raise... | [
"def",
"get_index",
"(",
"self",
",",
"bucket",
",",
"index",
",",
"startkey",
",",
"endkey",
"=",
"None",
",",
"return_terms",
"=",
"None",
",",
"max_results",
"=",
"None",
",",
"continuation",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"term_regex"... | Performs a secondary index query. | [
"Performs",
"a",
"secondary",
"index",
"query",
"."
] | python | train |
tensorflow/hub | tensorflow_hub/feature_column.py | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L83-L124 | def _check_module_is_text_embedding(module_spec):
"""Raises ValueError if `module_spec` is not a text-embedding module.
Args:
module_spec: A `ModuleSpec` to test.
Raises:
ValueError: if `module_spec` default signature is not compatible with
Tensor(string, shape=(?,)) -> Tensor(float32, shape=(?,K)).... | [
"def",
"_check_module_is_text_embedding",
"(",
"module_spec",
")",
":",
"issues",
"=",
"[",
"]",
"# Find issues with signature inputs.",
"input_info_dict",
"=",
"module_spec",
".",
"get_input_info_dict",
"(",
")",
"if",
"len",
"(",
"input_info_dict",
")",
"!=",
"1",
... | Raises ValueError if `module_spec` is not a text-embedding module.
Args:
module_spec: A `ModuleSpec` to test.
Raises:
ValueError: if `module_spec` default signature is not compatible with
Tensor(string, shape=(?,)) -> Tensor(float32, shape=(?,K)). | [
"Raises",
"ValueError",
"if",
"module_spec",
"is",
"not",
"a",
"text",
"-",
"embedding",
"module",
"."
] | python | train |
adamalton/django-csp-reports | cspreports/summary.py | https://github.com/adamalton/django-csp-reports/blob/867992c6f535cf6afbf911f92af7eea4c61e4b73/cspreports/summary.py#L35-L40 | def append(self, report):
"""Append a new CSP report."""
assert report not in self.examples
self.count += 1
if len(self.examples) < self.top:
self.examples.append(report) | [
"def",
"append",
"(",
"self",
",",
"report",
")",
":",
"assert",
"report",
"not",
"in",
"self",
".",
"examples",
"self",
".",
"count",
"+=",
"1",
"if",
"len",
"(",
"self",
".",
"examples",
")",
"<",
"self",
".",
"top",
":",
"self",
".",
"examples",... | Append a new CSP report. | [
"Append",
"a",
"new",
"CSP",
"report",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/shortcut_manager.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/shortcut_manager.py#L72-L106 | def add_callback_for_action(self, action, callback):
"""Adds a callback function to an action
The method checks whether both action and callback are valid. If so, the callback is added to the list of
functions called when the action is triggered.
:param str action: An action like 'add'... | [
"def",
"add_callback_for_action",
"(",
"self",
",",
"action",
",",
"callback",
")",
":",
"if",
"hasattr",
"(",
"callback",
",",
"'__call__'",
")",
":",
"# Is the callback really a function?",
"if",
"action",
"not",
"in",
"self",
".",
"__action_to_callbacks",
":",
... | Adds a callback function to an action
The method checks whether both action and callback are valid. If so, the callback is added to the list of
functions called when the action is triggered.
:param str action: An action like 'add', 'copy', 'info'
:param callback: A callback function, w... | [
"Adds",
"a",
"callback",
"function",
"to",
"an",
"action"
] | python | train |
jotacor/ComunioPy | ComunioPy/__init__.py | https://github.com/jotacor/ComunioPy/blob/2dd71e3e197b497980ea7b9cfbec1da64dca3ed0/ComunioPy/__init__.py#L100-L108 | def standings(self):
'''Get standings from the community's account'''
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain","User-Agent": user_agent}
req = self.session.get('http://'+self.domain+'/standings.phtml',headers=headers).content
soup = BeautifulS... | [
"def",
"standings",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"Accept\"",
":",
"\"text/plain\"",
",",
"\"User-Agent\"",
":",
"user_agent",
"}",
"req",
"=",
"self",
".",
"session",
".",
"g... | Get standings from the community's account | [
"Get",
"standings",
"from",
"the",
"community",
"s",
"account"
] | python | train |
exosite-labs/pyonep | pyonep/portals/__init__.py | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L506-L516 | def add_dplist_permission_for_user_on_portal(self, user_email, portal_id):
""" Adds the 'd_p_list' permission to a user object when provided
a user_email and portal_id."""
_id = self.get_user_id_from_email(user_email)
print(self.get_user_permission_from_email(user_email))
ret... | [
"def",
"add_dplist_permission_for_user_on_portal",
"(",
"self",
",",
"user_email",
",",
"portal_id",
")",
":",
"_id",
"=",
"self",
".",
"get_user_id_from_email",
"(",
"user_email",
")",
"print",
"(",
"self",
".",
"get_user_permission_from_email",
"(",
"user_email",
... | Adds the 'd_p_list' permission to a user object when provided
a user_email and portal_id. | [
"Adds",
"the",
"d_p_list",
"permission",
"to",
"a",
"user",
"object",
"when",
"provided",
"a",
"user_email",
"and",
"portal_id",
"."
] | python | train |
MycroftAI/adapt | adapt/tools/text/trie.py | https://github.com/MycroftAI/adapt/blob/334f23248b8e09fb9d84a88398424ec5bd3bae4c/adapt/tools/text/trie.py#L86-L104 | def insert(self, iterable, index=0, data=None, weight=1.0):
"""Insert new node into tree
Args:
iterable(hashable): key used to find in the future.
data(object): data associated with the key
index(int): an index used for insertion.
weight(float): the wait ... | [
"def",
"insert",
"(",
"self",
",",
"iterable",
",",
"index",
"=",
"0",
",",
"data",
"=",
"None",
",",
"weight",
"=",
"1.0",
")",
":",
"if",
"index",
"==",
"len",
"(",
"iterable",
")",
":",
"self",
".",
"is_terminal",
"=",
"True",
"self",
".",
"ke... | Insert new node into tree
Args:
iterable(hashable): key used to find in the future.
data(object): data associated with the key
index(int): an index used for insertion.
weight(float): the wait given for the item added. | [
"Insert",
"new",
"node",
"into",
"tree"
] | python | train |
refenv/cijoe | deprecated/modules/cij/liblight.py | https://github.com/refenv/cijoe/blob/21d7b2ed4ff68e0a1457e7df2db27f6334f1a379/deprecated/modules/cij/liblight.py#L177-L184 | def scalar_write(self, address, block_count, data_file, meta_file):
"""nvme write"""
cmd = ["nvme", "write", self.envs["DEV_PATH"], "-s 0x{:x}".format(address),
"-c {}".format(block_count-1), "-d {}".format(data_file), "-M {}".format(meta_file),
"-z 0x{:x}".format(block_cou... | [
"def",
"scalar_write",
"(",
"self",
",",
"address",
",",
"block_count",
",",
"data_file",
",",
"meta_file",
")",
":",
"cmd",
"=",
"[",
"\"nvme\"",
",",
"\"write\"",
",",
"self",
".",
"envs",
"[",
"\"DEV_PATH\"",
"]",
",",
"\"-s 0x{:x}\"",
".",
"format",
... | nvme write | [
"nvme",
"write"
] | python | valid |
codelv/enaml-native | src/enamlnative/core/app.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L375-L411 | def handle_event(self, event):
""" When we get an 'event' type from the bridge
handle it by invoking the handler and if needed
sending back the result.
"""
result_id, ptr, method, args = event[1]
obj = None
result = None
try:
obj, hand... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"result_id",
",",
"ptr",
",",
"method",
",",
"args",
"=",
"event",
"[",
"1",
"]",
"obj",
"=",
"None",
"result",
"=",
"None",
"try",
":",
"obj",
",",
"handler",
"=",
"bridge",
".",
"get_han... | When we get an 'event' type from the bridge
handle it by invoking the handler and if needed
sending back the result. | [
"When",
"we",
"get",
"an",
"event",
"type",
"from",
"the",
"bridge",
"handle",
"it",
"by",
"invoking",
"the",
"handler",
"and",
"if",
"needed",
"sending",
"back",
"the",
"result",
"."
] | python | train |
Kortemme-Lab/pull_into_place | pull_into_place/pipeline.py | https://github.com/Kortemme-Lab/pull_into_place/blob/247f303100a612cc90cf31c86e4fe5052eb28c8d/pull_into_place/pipeline.py#L164-L179 | def largest_loop(self):
"""
Return the boundaries for the largest loop segment.
This is just meant to be a reasonable default for various selectors and
filters to work with, in the case that more than one loop is being
modeled. If you want to be more precise, you'll h... | [
"def",
"largest_loop",
"(",
"self",
")",
":",
"from",
"collections",
"import",
"namedtuple",
"Loop",
"=",
"namedtuple",
"(",
"'Loop'",
",",
"'start end'",
")",
"largest_segment",
"=",
"sorted",
"(",
"self",
".",
"loop_segments",
",",
"key",
"=",
"lambda",
"x... | Return the boundaries for the largest loop segment.
This is just meant to be a reasonable default for various selectors and
filters to work with, in the case that more than one loop is being
modeled. If you want to be more precise, you'll have to override the
selectors and f... | [
"Return",
"the",
"boundaries",
"for",
"the",
"largest",
"loop",
"segment",
".",
"This",
"is",
"just",
"meant",
"to",
"be",
"a",
"reasonable",
"default",
"for",
"various",
"selectors",
"and",
"filters",
"to",
"work",
"with",
"in",
"the",
"case",
"that",
"mo... | python | train |
mdgart/sentrylogs | sentrylogs/daemonize.py | https://github.com/mdgart/sentrylogs/blob/1bff3f2c8e37265430269cdf1ed8f860ce2dd72a/sentrylogs/daemonize.py#L44-L179 | def create_daemon():
"""Detach a process from the controlling terminal and run it in the
background as a daemon.
"""
try:
# Fork a child process so the parent can exit. This returns control to
# the command-line or shell. It also guarantees that the child will not
# be a proce... | [
"def",
"create_daemon",
"(",
")",
":",
"try",
":",
"# Fork a child process so the parent can exit. This returns control to",
"# the command-line or shell. It also guarantees that the child will not",
"# be a process group leader, since the child receives a new process ID",
"# and inherits the ... | Detach a process from the controlling terminal and run it in the
background as a daemon. | [
"Detach",
"a",
"process",
"from",
"the",
"controlling",
"terminal",
"and",
"run",
"it",
"in",
"the",
"background",
"as",
"a",
"daemon",
"."
] | python | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/rollup.py | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/rollup.py#L31-L40 | def get_rollup_caps(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the index to check rollup capabilities on, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "data", id), params=params
... | [
"def",
"get_rollup_caps",
"(",
"self",
",",
"id",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_rollup\"",
",",
"\"data\"",
",",
"id",
")",
",",
... | `<>`_
:arg id: The ID of the index to check rollup capabilities on, or left
blank for all jobs | [
"<",
">",
"_"
] | python | train |
BerkeleyAutomation/perception | perception/image.py | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L685-L723 | def focus(self, height, width, center_i=None, center_j=None):
"""Zero out all of the image outside of a crop box.
Parameters
----------
height : int
The height of the desired crop box.
width : int
The width of the desired crop box.
center_i : in... | [
"def",
"focus",
"(",
"self",
",",
"height",
",",
"width",
",",
"center_i",
"=",
"None",
",",
"center_j",
"=",
"None",
")",
":",
"if",
"center_i",
"is",
"None",
":",
"center_i",
"=",
"self",
".",
"height",
"/",
"2",
"if",
"center_j",
"is",
"None",
"... | Zero out all of the image outside of a crop box.
Parameters
----------
height : int
The height of the desired crop box.
width : int
The width of the desired crop box.
center_i : int
The center height point of the crop box. If not specified, ... | [
"Zero",
"out",
"all",
"of",
"the",
"image",
"outside",
"of",
"a",
"crop",
"box",
"."
] | python | train |
ibelie/typy | typy/google/protobuf/descriptor.py | https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/descriptor.py#L174-L179 | def GetTopLevelContainingType(self):
"""Returns the root if this is a nested type, or itself if its the root."""
desc = self
while desc.containing_type is not None:
desc = desc.containing_type
return desc | [
"def",
"GetTopLevelContainingType",
"(",
"self",
")",
":",
"desc",
"=",
"self",
"while",
"desc",
".",
"containing_type",
"is",
"not",
"None",
":",
"desc",
"=",
"desc",
".",
"containing_type",
"return",
"desc"
] | Returns the root if this is a nested type, or itself if its the root. | [
"Returns",
"the",
"root",
"if",
"this",
"is",
"a",
"nested",
"type",
"or",
"itself",
"if",
"its",
"the",
"root",
"."
] | python | valid |
docker/docker-py | docker/models/images.py | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/models/images.py#L300-L316 | def get(self, name):
"""
Gets an image.
Args:
name (str): The name of the image.
Returns:
(:py:class:`Image`): The image.
Raises:
:py:class:`docker.errors.ImageNotFound`
If the image does not exist.
:py:class:`doc... | [
"def",
"get",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"prepare_model",
"(",
"self",
".",
"client",
".",
"api",
".",
"inspect_image",
"(",
"name",
")",
")"
] | Gets an image.
Args:
name (str): The name of the image.
Returns:
(:py:class:`Image`): The image.
Raises:
:py:class:`docker.errors.ImageNotFound`
If the image does not exist.
:py:class:`docker.errors.APIError`
If t... | [
"Gets",
"an",
"image",
"."
] | python | train |
opendatateam/udata | udata/harvest/actions.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/harvest/actions.py#L45-L49 | def paginate_sources(owner=None, page=1, page_size=DEFAULT_PAGE_SIZE):
'''Paginate harvest sources'''
sources = _sources_queryset(owner=owner)
page = max(page or 1, 1)
return sources.paginate(page, page_size) | [
"def",
"paginate_sources",
"(",
"owner",
"=",
"None",
",",
"page",
"=",
"1",
",",
"page_size",
"=",
"DEFAULT_PAGE_SIZE",
")",
":",
"sources",
"=",
"_sources_queryset",
"(",
"owner",
"=",
"owner",
")",
"page",
"=",
"max",
"(",
"page",
"or",
"1",
",",
"1... | Paginate harvest sources | [
"Paginate",
"harvest",
"sources"
] | python | train |
mikedh/trimesh | trimesh/base.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/base.py#L1423-L1440 | def is_volume(self):
"""
Check if a mesh has all the properties required to represent
a valid volume, rather than just a surface.
These properties include being watertight, having consistent
winding and outward facing normals.
Returns
---------
valid : b... | [
"def",
"is_volume",
"(",
"self",
")",
":",
"valid",
"=",
"bool",
"(",
"self",
".",
"is_watertight",
"and",
"self",
".",
"is_winding_consistent",
"and",
"np",
".",
"isfinite",
"(",
"self",
".",
"center_mass",
")",
".",
"all",
"(",
")",
"and",
"self",
".... | Check if a mesh has all the properties required to represent
a valid volume, rather than just a surface.
These properties include being watertight, having consistent
winding and outward facing normals.
Returns
---------
valid : bool
Does the mesh represent a v... | [
"Check",
"if",
"a",
"mesh",
"has",
"all",
"the",
"properties",
"required",
"to",
"represent",
"a",
"valid",
"volume",
"rather",
"than",
"just",
"a",
"surface",
"."
] | python | train |
QunarOPS/qg.core | qg/core/importutils.py | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/importutils.py#L41-L52 | def import_object_ns(name_space, import_str, *args, **kwargs):
"""Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace.
"""
im... | [
"def",
"import_object_ns",
"(",
"name_space",
",",
"import_str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import_value",
"=",
"\"%s.%s\"",
"%",
"(",
"name_space",
",",
"import_str",
")",
"try",
":",
"return",
"import_class",
"(",
"import_value",... | Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace. | [
"Tries",
"to",
"import",
"object",
"from",
"default",
"namespace",
"."
] | python | train |
opendatateam/udata | udata/frontend/helpers.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/frontend/helpers.py#L254-L264 | def tooltip_ellipsis(source, length=0):
''' return the plain text representation of markdown encoded text. That
is the texted without any html tags. If ``length`` is 0 then it
will not be truncated.'''
try:
length = int(length)
except ValueError: # invalid literal for int()
return... | [
"def",
"tooltip_ellipsis",
"(",
"source",
",",
"length",
"=",
"0",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"length",
")",
"except",
"ValueError",
":",
"# invalid literal for int()",
"return",
"source",
"# Fail silently.",
"ellipsis",
"=",
"'<a href v-to... | return the plain text representation of markdown encoded text. That
is the texted without any html tags. If ``length`` is 0 then it
will not be truncated. | [
"return",
"the",
"plain",
"text",
"representation",
"of",
"markdown",
"encoded",
"text",
".",
"That",
"is",
"the",
"texted",
"without",
"any",
"html",
"tags",
".",
"If",
"length",
"is",
"0",
"then",
"it",
"will",
"not",
"be",
"truncated",
"."
] | python | train |
cloudtools/stacker | stacker/lookups/handlers/dynamodb.py | https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/lookups/handlers/dynamodb.py#L146-L177 | def _get_val_from_ddb_data(data, keylist):
"""Given a dictionary of dynamodb data (including the datatypes) and a
properly structured keylist, it will return the value of the lookup
Args:
data (dict): the raw dynamodb data
keylist(list): a list of keys to lookup. This must include the
... | [
"def",
"_get_val_from_ddb_data",
"(",
"data",
",",
"keylist",
")",
":",
"next_type",
"=",
"None",
"# iterate through the keylist to find the matching key/datatype",
"for",
"k",
"in",
"keylist",
":",
"for",
"k1",
"in",
"k",
":",
"if",
"next_type",
"is",
"None",
":"... | Given a dictionary of dynamodb data (including the datatypes) and a
properly structured keylist, it will return the value of the lookup
Args:
data (dict): the raw dynamodb data
keylist(list): a list of keys to lookup. This must include the
datatype
Returns:
vari... | [
"Given",
"a",
"dictionary",
"of",
"dynamodb",
"data",
"(",
"including",
"the",
"datatypes",
")",
"and",
"a",
"properly",
"structured",
"keylist",
"it",
"will",
"return",
"the",
"value",
"of",
"the",
"lookup"
] | python | train |
Nukesor/pueue | pueue/client/displaying.py | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/displaying.py#L159-L228 | def execute_show(args, root_dir):
"""Print stderr and stdout of the current running process.
Args:
args['watch'] (bool): If True, we open a curses session and tail
the output live in the console.
root_dir (string): The path to the root directory the daemon is runni... | [
"def",
"execute_show",
"(",
"args",
",",
"root_dir",
")",
":",
"key",
"=",
"None",
"if",
"args",
".",
"get",
"(",
"'key'",
")",
":",
"key",
"=",
"args",
"[",
"'key'",
"]",
"status",
"=",
"command_factory",
"(",
"'status'",
")",
"(",
"{",
"}",
",",
... | Print stderr and stdout of the current running process.
Args:
args['watch'] (bool): If True, we open a curses session and tail
the output live in the console.
root_dir (string): The path to the root directory the daemon is running in. | [
"Print",
"stderr",
"and",
"stdout",
"of",
"the",
"current",
"running",
"process",
"."
] | python | train |
gmr/queries | queries/session.py | https://github.com/gmr/queries/blob/a68855013dc6aaf9ed7b6909a4701f8da8796a0a/queries/session.py#L368-L382 | def _status(self):
"""Return the current connection status as an integer value.
The status should match one of the following constants:
- queries.Session.INTRANS: Connection established, in transaction
- queries.Session.PREPARED: Prepared for second phase of transaction
- queri... | [
"def",
"_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"_conn",
".",
"status",
"==",
"psycopg2",
".",
"extensions",
".",
"STATUS_BEGIN",
":",
"return",
"self",
".",
"READY",
"return",
"self",
".",
"_conn",
".",
"status"
] | Return the current connection status as an integer value.
The status should match one of the following constants:
- queries.Session.INTRANS: Connection established, in transaction
- queries.Session.PREPARED: Prepared for second phase of transaction
- queries.Session.READY: Connected, n... | [
"Return",
"the",
"current",
"connection",
"status",
"as",
"an",
"integer",
"value",
"."
] | python | train |
StackStorm/pybind | pybind/slxos/v17s_1_02/acl_mirror/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/acl_mirror/__init__.py#L92-L113 | def _set_source(self, v, load=False):
"""
Setter method for source, mapped from YANG variable /acl_mirror/source (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_source is considered as a private
method. Backends looking to populate this variable should
do ... | [
"def",
"_set_source",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
... | Setter method for source, mapped from YANG variable /acl_mirror/source (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_source is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_source() directly. | [
"Setter",
"method",
"for",
"source",
"mapped",
"from",
"YANG",
"variable",
"/",
"acl_mirror",
"/",
"source",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"YANG",
"file",
... | python | train |
numenta/htmresearch | htmresearch/frameworks/poirazi_neuron_model/neuron_model.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/poirazi_neuron_model/neuron_model.py#L95-L102 | def calculate_activation(self, datapoint):
"""
Only for a single datapoint
"""
activations = datapoint * self.dendrites
activations = self.nonlinearity(activations)
return activations.sum() | [
"def",
"calculate_activation",
"(",
"self",
",",
"datapoint",
")",
":",
"activations",
"=",
"datapoint",
"*",
"self",
".",
"dendrites",
"activations",
"=",
"self",
".",
"nonlinearity",
"(",
"activations",
")",
"return",
"activations",
".",
"sum",
"(",
")"
] | Only for a single datapoint | [
"Only",
"for",
"a",
"single",
"datapoint"
] | python | train |
wummel/patool | patoolib/programs/xdms.py | https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/programs/xdms.py#L30-L33 | def list_dms (archive, compression, cmd, verbosity, interactive):
"""List a DMS archive."""
check_archive_ext(archive)
return [cmd, 'v', archive] | [
"def",
"list_dms",
"(",
"archive",
",",
"compression",
",",
"cmd",
",",
"verbosity",
",",
"interactive",
")",
":",
"check_archive_ext",
"(",
"archive",
")",
"return",
"[",
"cmd",
",",
"'v'",
",",
"archive",
"]"
] | List a DMS archive. | [
"List",
"a",
"DMS",
"archive",
"."
] | python | train |
pycontribs/jira | jira/client.py | https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L3782-L3826 | def create_board(self, name, project_ids, preset="scrum",
location_type='user', location_id=None):
"""Create a new board for the ``project_ids``.
:param name: name of the board
:type name: str
:param project_ids: the projects to create the board in
:type pro... | [
"def",
"create_board",
"(",
"self",
",",
"name",
",",
"project_ids",
",",
"preset",
"=",
"\"scrum\"",
",",
"location_type",
"=",
"'user'",
",",
"location_id",
"=",
"None",
")",
":",
"if",
"self",
".",
"_options",
"[",
"'agile_rest_path'",
"]",
"!=",
"Green... | Create a new board for the ``project_ids``.
:param name: name of the board
:type name: str
:param project_ids: the projects to create the board in
:type project_ids: str
:param preset: What preset to use for this board. (Default: "scrum")
:type preset: 'kanban', 'scrum',... | [
"Create",
"a",
"new",
"board",
"for",
"the",
"project_ids",
"."
] | python | train |
blockstack/blockstack-core | blockstack/blockstackd.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1552-L1568 | def rpc_get_all_names_cumulative( self, offset, count, **con_info ):
"""
Get all names that have ever existed, paginated
Return {'status': true, 'names': [...]} on success
Return {'error': ...} on error
"""
if not check_offset(offset):
return {'error': 'invali... | [
"def",
"rpc_get_all_names_cumulative",
"(",
"self",
",",
"offset",
",",
"count",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_offset",
"(",
"offset",
")",
":",
"return",
"{",
"'error'",
":",
"'invalid offset'",
",",
"'http_status'",
":",
"400",
... | Get all names that have ever existed, paginated
Return {'status': true, 'names': [...]} on success
Return {'error': ...} on error | [
"Get",
"all",
"names",
"that",
"have",
"ever",
"existed",
"paginated",
"Return",
"{",
"status",
":",
"true",
"names",
":",
"[",
"...",
"]",
"}",
"on",
"success",
"Return",
"{",
"error",
":",
"...",
"}",
"on",
"error"
] | python | train |
daler/trackhub | trackhub/helpers.py | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L134-L150 | def print_rendered_results(results_dict):
"""
Pretty-prints the rendered results dictionary.
Rendered results can be multiply-nested dictionaries; this uses JSON
serialization to print a nice representation.
"""
class _HubComponentEncoder(json.JSONEncoder):
def default(self, o):
... | [
"def",
"print_rendered_results",
"(",
"results_dict",
")",
":",
"class",
"_HubComponentEncoder",
"(",
"json",
".",
"JSONEncoder",
")",
":",
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"base",
".",
"HubComponent",
"... | Pretty-prints the rendered results dictionary.
Rendered results can be multiply-nested dictionaries; this uses JSON
serialization to print a nice representation. | [
"Pretty",
"-",
"prints",
"the",
"rendered",
"results",
"dictionary",
"."
] | python | train |
linuxsoftware/ls.joyous | ls/joyous/models/events.py | https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/events.py#L951-L958 | def next_date(self):
"""
Date when this event is next scheduled to occur in the local time zone
(Does not include postponements, but does exclude cancellations)
"""
nextDt = self.__localAfter(timezone.localtime(), dt.time.min)
if nextDt is not None:
return nex... | [
"def",
"next_date",
"(",
"self",
")",
":",
"nextDt",
"=",
"self",
".",
"__localAfter",
"(",
"timezone",
".",
"localtime",
"(",
")",
",",
"dt",
".",
"time",
".",
"min",
")",
"if",
"nextDt",
"is",
"not",
"None",
":",
"return",
"nextDt",
".",
"date",
... | Date when this event is next scheduled to occur in the local time zone
(Does not include postponements, but does exclude cancellations) | [
"Date",
"when",
"this",
"event",
"is",
"next",
"scheduled",
"to",
"occur",
"in",
"the",
"local",
"time",
"zone",
"(",
"Does",
"not",
"include",
"postponements",
"but",
"does",
"exclude",
"cancellations",
")"
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L12053-L12087 | def spkltc(targ, et, ref, abcorr, stobs):
"""
Return the state (position and velocity) of a target body
relative to an observer, optionally corrected for light time,
expressed relative to an inertial reference frame.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkltc_c.html
:param ... | [
"def",
"spkltc",
"(",
"targ",
",",
"et",
",",
"ref",
",",
"abcorr",
",",
"stobs",
")",
":",
"assert",
"len",
"(",
"stobs",
")",
"==",
"6",
"targ",
"=",
"stypes",
".",
"c_int",
"(",
"targ",
")",
"et",
"=",
"ctypes",
".",
"c_double",
"(",
"et",
"... | Return the state (position and velocity) of a target body
relative to an observer, optionally corrected for light time,
expressed relative to an inertial reference frame.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkltc_c.html
:param targ: Target body.
:type targ: int
:param et: ... | [
"Return",
"the",
"state",
"(",
"position",
"and",
"velocity",
")",
"of",
"a",
"target",
"body",
"relative",
"to",
"an",
"observer",
"optionally",
"corrected",
"for",
"light",
"time",
"expressed",
"relative",
"to",
"an",
"inertial",
"reference",
"frame",
"."
] | python | train |
alevinval/scheduling | scheduling/graph.py | https://github.com/alevinval/scheduling/blob/127239712c0b73b929ca19b4b5c2855eebb7fcf0/scheduling/graph.py#L88-L110 | def dfs(node, expand=expansion_all, callback=None, silent=True):
""" Perform a depth-first search on the node graph
:param node: GraphNode
:param expand: Returns the list of Nodes to explore from a Node
:param callback: Callback to run in each node
:param silent: Don't throw exception on circular de... | [
"def",
"dfs",
"(",
"node",
",",
"expand",
"=",
"expansion_all",
",",
"callback",
"=",
"None",
",",
"silent",
"=",
"True",
")",
":",
"nodes",
"=",
"deque",
"(",
")",
"for",
"n",
"in",
"expand",
"(",
"node",
")",
":",
"nodes",
".",
"append",
"(",
"... | Perform a depth-first search on the node graph
:param node: GraphNode
:param expand: Returns the list of Nodes to explore from a Node
:param callback: Callback to run in each node
:param silent: Don't throw exception on circular dependency
:return: | [
"Perform",
"a",
"depth",
"-",
"first",
"search",
"on",
"the",
"node",
"graph",
":",
"param",
"node",
":",
"GraphNode",
":",
"param",
"expand",
":",
"Returns",
"the",
"list",
"of",
"Nodes",
"to",
"explore",
"from",
"a",
"Node",
":",
"param",
"callback",
... | python | train |
numenta/nupic | src/nupic/data/stream_reader.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/stream_reader.py#L375-L388 | def getDataRowCount(self):
"""
Iterates through stream to calculate total records after aggregation.
This will alter the bookmark state.
"""
inputRowCountAfterAggregation = 0
while True:
record = self.getNextRecord()
if record is None:
return inputRowCountAfterAggregation
... | [
"def",
"getDataRowCount",
"(",
"self",
")",
":",
"inputRowCountAfterAggregation",
"=",
"0",
"while",
"True",
":",
"record",
"=",
"self",
".",
"getNextRecord",
"(",
")",
"if",
"record",
"is",
"None",
":",
"return",
"inputRowCountAfterAggregation",
"inputRowCountAft... | Iterates through stream to calculate total records after aggregation.
This will alter the bookmark state. | [
"Iterates",
"through",
"stream",
"to",
"calculate",
"total",
"records",
"after",
"aggregation",
".",
"This",
"will",
"alter",
"the",
"bookmark",
"state",
"."
] | python | valid |
CalebBell/fluids | fluids/particle_size_distribution.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1913-L1952 | def di_power(self, i, power=1):
r'''Method to calculate a power of a particle class/bin in a generic
way so as to support when there are as many `ds` as `fractions`,
or one more diameter spec than `fractions`.
When each bin has a lower and upper bound, the formula is as follows
... | [
"def",
"di_power",
"(",
"self",
",",
"i",
",",
"power",
"=",
"1",
")",
":",
"if",
"self",
".",
"size_classes",
":",
"rt",
"=",
"power",
"+",
"1",
"return",
"(",
"(",
"self",
".",
"ds",
"[",
"i",
"+",
"1",
"]",
"**",
"rt",
"-",
"self",
".",
... | r'''Method to calculate a power of a particle class/bin in a generic
way so as to support when there are as many `ds` as `fractions`,
or one more diameter spec than `fractions`.
When each bin has a lower and upper bound, the formula is as follows
[1]_.
.. math::... | [
"r",
"Method",
"to",
"calculate",
"a",
"power",
"of",
"a",
"particle",
"class",
"/",
"bin",
"in",
"a",
"generic",
"way",
"so",
"as",
"to",
"support",
"when",
"there",
"are",
"as",
"many",
"ds",
"as",
"fractions",
"or",
"one",
"more",
"diameter",
"spec"... | python | train |
uber/tchannel-python | tchannel/tornado/peer.py | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L352-L442 | def send(
self, arg1, arg2, arg3,
headers=None,
retry_limit=None,
ttl=None,
):
"""Make a request to the Peer.
:param arg1:
String or Stream containing the contents of arg1. If None, an empty
stream is used.
:param arg2:
Str... | [
"def",
"send",
"(",
"self",
",",
"arg1",
",",
"arg2",
",",
"arg3",
",",
"headers",
"=",
"None",
",",
"retry_limit",
"=",
"None",
",",
"ttl",
"=",
"None",
",",
")",
":",
"# find a peer connection",
"# If we can't find available peer at the first time, we throw",
... | Make a request to the Peer.
:param arg1:
String or Stream containing the contents of arg1. If None, an empty
stream is used.
:param arg2:
String or Stream containing the contents of arg2. If None, an empty
stream is used.
:param arg3:
... | [
"Make",
"a",
"request",
"to",
"the",
"Peer",
"."
] | python | train |
nephila/djangocms-apphook-setup | djangocms_apphook_setup/base.py | https://github.com/nephila/djangocms-apphook-setup/blob/e82c0afdf966f859fe13dc80fcd417b44080f460/djangocms_apphook_setup/base.py#L60-L71 | def _create_config(cls):
"""
Creates an ApphookConfig instance
``AutoCMSAppMixin.auto_setup['config_fields']`` is used to fill in the data
of the instance.
:return: ApphookConfig instance
"""
return cls.app_config.objects.create(
namespace=cls.auto_s... | [
"def",
"_create_config",
"(",
"cls",
")",
":",
"return",
"cls",
".",
"app_config",
".",
"objects",
".",
"create",
"(",
"namespace",
"=",
"cls",
".",
"auto_setup",
"[",
"'namespace'",
"]",
",",
"*",
"*",
"cls",
".",
"auto_setup",
"[",
"'config_fields'",
"... | Creates an ApphookConfig instance
``AutoCMSAppMixin.auto_setup['config_fields']`` is used to fill in the data
of the instance.
:return: ApphookConfig instance | [
"Creates",
"an",
"ApphookConfig",
"instance"
] | python | train |
DLR-RM/RAFCON | source/rafcon/core/id_generator.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/id_generator.py#L143-L156 | def global_variable_id_generator(size=10, chars=string.ascii_uppercase):
""" Create a new and unique global variable id
Generates an id for a global variable. It randomly samples from random ascii uppercase letters size times
and concatenates them. If the id already exists it draws a new one.
:param s... | [
"def",
"global_variable_id_generator",
"(",
"size",
"=",
"10",
",",
"chars",
"=",
"string",
".",
"ascii_uppercase",
")",
":",
"new_global_variable_id",
"=",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"chars",
")",
"for",
"x",
"in",
"range",
"(",... | Create a new and unique global variable id
Generates an id for a global variable. It randomly samples from random ascii uppercase letters size times
and concatenates them. If the id already exists it draws a new one.
:param size: the length of the generated keys
:param chars: the set of characters a s... | [
"Create",
"a",
"new",
"and",
"unique",
"global",
"variable",
"id"
] | python | train |
lbusoni/pysilico | pysilico/gui/image_show_widget/image_show_basic_widget.py | https://github.com/lbusoni/pysilico/blob/44872c8c202bedc8af5d7ac0cd2971912a59a365/pysilico/gui/image_show_widget/image_show_basic_widget.py#L504-L513 | def _getProcessedImage(self):
"""Returns the image data after it has been processed by any normalization options in use.
This method also sets the attributes self.levelMin and self.levelMax
to indicate the range of data in the image."""
if self.imageDisp is None:
self.imageD... | [
"def",
"_getProcessedImage",
"(",
"self",
")",
":",
"if",
"self",
".",
"imageDisp",
"is",
"None",
":",
"self",
".",
"imageDisp",
"=",
"self",
".",
"image",
"self",
".",
"levelMin",
",",
"self",
".",
"levelMax",
"=",
"self",
".",
"_quickLevels",
"(",
"s... | Returns the image data after it has been processed by any normalization options in use.
This method also sets the attributes self.levelMin and self.levelMax
to indicate the range of data in the image. | [
"Returns",
"the",
"image",
"data",
"after",
"it",
"has",
"been",
"processed",
"by",
"any",
"normalization",
"options",
"in",
"use",
".",
"This",
"method",
"also",
"sets",
"the",
"attributes",
"self",
".",
"levelMin",
"and",
"self",
".",
"levelMax",
"to",
"... | python | train |
django-danceschool/django-danceschool | danceschool/guestlist/models.py | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L33-L45 | def recentEvents(self):
'''
Get the set of recent and upcoming events to which this list applies.
'''
return Event.objects.filter(
Q(pk__in=self.individualEvents.values_list('pk',flat=True)) |
Q(session__in=self.eventSessions.all()) |
Q(publicevent__ca... | [
"def",
"recentEvents",
"(",
"self",
")",
":",
"return",
"Event",
".",
"objects",
".",
"filter",
"(",
"Q",
"(",
"pk__in",
"=",
"self",
".",
"individualEvents",
".",
"values_list",
"(",
"'pk'",
",",
"flat",
"=",
"True",
")",
")",
"|",
"Q",
"(",
"sessio... | Get the set of recent and upcoming events to which this list applies. | [
"Get",
"the",
"set",
"of",
"recent",
"and",
"upcoming",
"events",
"to",
"which",
"this",
"list",
"applies",
"."
] | python | train |
GuiltyTargets/ppi-network-annotation | src/ppi_network_annotation/parsers.py | https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L89-L129 | def handle_dataframe(
df: pd.DataFrame,
entrez_id_name,
log2_fold_change_name,
adjusted_p_value_name,
entrez_delimiter,
base_mean=None,
) -> List[Gene]:
"""Convert data frame on differential expression values as Gene objects.
:param df: Data frame with columns sh... | [
"def",
"handle_dataframe",
"(",
"df",
":",
"pd",
".",
"DataFrame",
",",
"entrez_id_name",
",",
"log2_fold_change_name",
",",
"adjusted_p_value_name",
",",
"entrez_delimiter",
",",
"base_mean",
"=",
"None",
",",
")",
"->",
"List",
"[",
"Gene",
"]",
":",
"logger... | Convert data frame on differential expression values as Gene objects.
:param df: Data frame with columns showing values on differential
expression.
:param cfp: An object that includes paths, cutoffs and other information.
:return list: A list of Gene objects. | [
"Convert",
"data",
"frame",
"on",
"differential",
"expression",
"values",
"as",
"Gene",
"objects",
"."
] | python | train |
hcpl/xkbgroup | xkbgroup/core.py | https://github.com/hcpl/xkbgroup/blob/fcf4709a3c8221e0cdf62c09e5cccda232b0104c/xkbgroup/core.py#L261-L267 | def groups_names(self):
"""Names of all groups (get-only).
:getter: Returns names of all groups
:type: list of str
"""
return _ListProxy(self._get_group_name_by_num(i) for i in range(self.groups_count)) | [
"def",
"groups_names",
"(",
"self",
")",
":",
"return",
"_ListProxy",
"(",
"self",
".",
"_get_group_name_by_num",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"groups_count",
")",
")"
] | Names of all groups (get-only).
:getter: Returns names of all groups
:type: list of str | [
"Names",
"of",
"all",
"groups",
"(",
"get",
"-",
"only",
")",
"."
] | python | train |
Tinche/django-bower-cache | registry/models.py | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/models.py#L40-L43 | def pull(self):
"""Pull from the origin."""
repo_root = settings.REPO_ROOT
pull_from_origin(join(repo_root, self.name)) | [
"def",
"pull",
"(",
"self",
")",
":",
"repo_root",
"=",
"settings",
".",
"REPO_ROOT",
"pull_from_origin",
"(",
"join",
"(",
"repo_root",
",",
"self",
".",
"name",
")",
")"
] | Pull from the origin. | [
"Pull",
"from",
"the",
"origin",
"."
] | python | train |
genialis/resolwe | resolwe/flow/migration_ops.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migration_ops.py#L396-L406 | def deconstruct(self):
"""Deconstruct operation."""
return (
self.__class__.__name__,
[],
{
'process': self.process,
'field': self._raw_field,
'new_field': self.new_field,
}
) | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"[",
"]",
",",
"{",
"'process'",
":",
"self",
".",
"process",
",",
"'field'",
":",
"self",
".",
"_raw_field",
",",
"'new_field'",
":",
"self",
... | Deconstruct operation. | [
"Deconstruct",
"operation",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L1159-L1178 | def get_update(self, id, update_number, project=None):
"""GetUpdate.
[Preview API] Returns a single update for a work item
:param int id:
:param int update_number:
:param str project: Project ID or project name
:rtype: :class:`<WorkItemUpdate> <azure.devops.v5_1.work-item... | [
"def",
"get_update",
"(",
"self",
",",
"id",
",",
"update_number",
",",
"project",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"=",
"self",
".",
"_serialize",
"... | GetUpdate.
[Preview API] Returns a single update for a work item
:param int id:
:param int update_number:
:param str project: Project ID or project name
:rtype: :class:`<WorkItemUpdate> <azure.devops.v5_1.work-item-tracking.models.WorkItemUpdate>` | [
"GetUpdate",
".",
"[",
"Preview",
"API",
"]",
"Returns",
"a",
"single",
"update",
"for",
"a",
"work",
"item",
":",
"param",
"int",
"id",
":",
":",
"param",
"int",
"update_number",
":",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"projec... | python | train |
redhat-cip/python-dciclient | dciclient/v1/shell_commands/remoteci.py | https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L264-L275 | def refresh_keys(context, id, etag):
"""refresh_keys(context, id, etag)
Refresh a remoteci key pair.
>>> dcictl remoteci-refresh-keys [OPTIONS]
:param string id: ID of the remote CI [required]
:param string etag: Entity tag of the remote CI resource [required]
"""
result = remoteci.refres... | [
"def",
"refresh_keys",
"(",
"context",
",",
"id",
",",
"etag",
")",
":",
"result",
"=",
"remoteci",
".",
"refresh_keys",
"(",
"context",
",",
"id",
"=",
"id",
",",
"etag",
"=",
"etag",
")",
"utils",
".",
"format_output",
"(",
"result",
",",
"context",
... | refresh_keys(context, id, etag)
Refresh a remoteci key pair.
>>> dcictl remoteci-refresh-keys [OPTIONS]
:param string id: ID of the remote CI [required]
:param string etag: Entity tag of the remote CI resource [required] | [
"refresh_keys",
"(",
"context",
"id",
"etag",
")"
] | python | train |
miguelgrinberg/python-engineio | engineio/client.py | https://github.com/miguelgrinberg/python-engineio/blob/261fd67103cb5d9a44369415748e66fdf62de6fb/engineio/client.py#L446-L456 | def _trigger_event(self, event, *args, **kwargs):
"""Invoke an event handler."""
run_async = kwargs.pop('run_async', False)
if event in self.handlers:
if run_async:
return self.start_background_task(self.handlers[event], *args)
else:
try:
... | [
"def",
"_trigger_event",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"run_async",
"=",
"kwargs",
".",
"pop",
"(",
"'run_async'",
",",
"False",
")",
"if",
"event",
"in",
"self",
".",
"handlers",
":",
"if",
"run_asyn... | Invoke an event handler. | [
"Invoke",
"an",
"event",
"handler",
"."
] | python | train |
boriel/zxbasic | asmparse.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L624-L629 | def p_line_label_asm(p):
""" line : LABEL asms NEWLINE
"""
p[0] = p[2]
__DEBUG__("Declaring '%s%s' (value %04Xh) in %i" % (NAMESPACE, p[1], MEMORY.org, p.lineno(1)))
MEMORY.declare_label(p[1], p.lineno(1)) | [
"def",
"p_line_label_asm",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"2",
"]",
"__DEBUG__",
"(",
"\"Declaring '%s%s' (value %04Xh) in %i\"",
"%",
"(",
"NAMESPACE",
",",
"p",
"[",
"1",
"]",
",",
"MEMORY",
".",
"org",
",",
"p",
".",
"linen... | line : LABEL asms NEWLINE | [
"line",
":",
"LABEL",
"asms",
"NEWLINE"
] | python | train |
mkorpela/pabot | pabot/pabotlib.py | https://github.com/mkorpela/pabot/blob/b7d85546a58e398d579bb14fd9135858ec08a031/pabot/pabotlib.py#L231-L242 | def acquire_value_set(self, *tags):
"""
Reserve a set of values for this execution.
No other process can reserve the same set of values while the set is
reserved. Acquired value set needs to be released after use to allow
other processes to access it.
Add tags to limit th... | [
"def",
"acquire_value_set",
"(",
"self",
",",
"*",
"tags",
")",
":",
"setname",
"=",
"self",
".",
"_acquire_value_set",
"(",
"*",
"tags",
")",
"if",
"setname",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Could not aquire a value set\"",
")",
"return",
... | Reserve a set of values for this execution.
No other process can reserve the same set of values while the set is
reserved. Acquired value set needs to be released after use to allow
other processes to access it.
Add tags to limit the possible value sets that this returns. | [
"Reserve",
"a",
"set",
"of",
"values",
"for",
"this",
"execution",
".",
"No",
"other",
"process",
"can",
"reserve",
"the",
"same",
"set",
"of",
"values",
"while",
"the",
"set",
"is",
"reserved",
".",
"Acquired",
"value",
"set",
"needs",
"to",
"be",
"rele... | python | train |
metric-learn/metric-learn | metric_learn/base_metric.py | https://github.com/metric-learn/metric-learn/blob/d945df1342c69012608bb70b92520392a0853de6/metric_learn/base_metric.py#L573-L596 | def predict(self, quadruplets):
"""Predicts the ordering between sample distances in input quadruplets.
For each quadruplet, returns 1 if the quadruplet is in the right order (
first pair is more similar than second pair), and -1 if not.
Parameters
----------
quadruplets : array-like, shape=(n... | [
"def",
"predict",
"(",
"self",
",",
"quadruplets",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"'transformer_'",
")",
"quadruplets",
"=",
"check_input",
"(",
"quadruplets",
",",
"type_of_inputs",
"=",
"'tuples'",
",",
"preprocessor",
"=",
"self",
".",
"prep... | Predicts the ordering between sample distances in input quadruplets.
For each quadruplet, returns 1 if the quadruplet is in the right order (
first pair is more similar than second pair), and -1 if not.
Parameters
----------
quadruplets : array-like, shape=(n_quadruplets, 4, n_features) or
... | [
"Predicts",
"the",
"ordering",
"between",
"sample",
"distances",
"in",
"input",
"quadruplets",
"."
] | python | train |
wilson-eft/wilson | wilson/translate/wet.py | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L269-L415 | def _Fierz_to_JMS_III_IV_V(Fqqqq, qqqq):
"""From 4-quark Fierz to JMS basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
F = Fqqqq.copy()
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc'... | [
"def",
"_Fierz_to_JMS_III_IV_V",
"(",
"Fqqqq",
",",
"qqqq",
")",
":",
"F",
"=",
"Fqqqq",
".",
"copy",
"(",
")",
"#case dduu",
"classIII",
"=",
"[",
"'sbuc'",
",",
"'sbcu'",
",",
"'dbuc'",
",",
"'dbcu'",
",",
"'dsuc'",
",",
"'dscu'",
"]",
"classVdduu",
... | From 4-quark Fierz to JMS basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc. | [
"From",
"4",
"-",
"quark",
"Fierz",
"to",
"JMS",
"basis",
"for",
"Classes",
"III",
"IV",
"and",
"V",
".",
"qqqq",
"should",
"be",
"of",
"the",
"form",
"sbuc",
"sdcc",
"ucuu",
"etc",
"."
] | python | train |
smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L239-L302 | def add_parser_to_cascade(self, parser: AnyParser, typ: Type = None):
"""
Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to ... | [
"def",
"add_parser_to_cascade",
"(",
"self",
",",
"parser",
":",
"AnyParser",
",",
"typ",
":",
"Type",
"=",
"None",
")",
":",
"# the first parser added will configure the cascade",
"if",
"not",
"self",
".",
"configured",
":",
"self",
".",
"supported_exts",
"=",
... | Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to support the same capabilities at least, to be added.
:param parser:
:para... | [
"Adds",
"the",
"provided",
"parser",
"to",
"this",
"cascade",
".",
"If",
"this",
"is",
"the",
"first",
"parser",
"it",
"will",
"configure",
"the",
"cascade",
"according",
"to",
"the",
"parser",
"capabilities",
"(",
"single",
"and",
"multifile",
"support",
"e... | python | train |
toumorokoshi/sprinter | sprinter/environment.py | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L335-L349 | def write_debug_log(self, file_path):
""" Write the debug log to a file """
with open(file_path, "wb+") as fh:
fh.write(system.get_system_info().encode('utf-8'))
# writing to debug stream
self._debug_stream.seek(0)
fh.write(self._debug_stream.read().encode... | [
"def",
"write_debug_log",
"(",
"self",
",",
"file_path",
")",
":",
"with",
"open",
"(",
"file_path",
",",
"\"wb+\"",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"system",
".",
"get_system_info",
"(",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"... | Write the debug log to a file | [
"Write",
"the",
"debug",
"log",
"to",
"a",
"file"
] | python | train |
joferkington/mpldatacursor | mpldatacursor/datacursor.py | https://github.com/joferkington/mpldatacursor/blob/7dabc589ed02c35ac5d89de5931f91e0323aa795/mpldatacursor/datacursor.py#L277-L310 | def event_info(self, event):
"""Get a dict of info for the artist selected by "event"."""
def default_func(event):
return {}
registry = {
AxesImage : [pick_info.image_props],
PathCollection : [pick_info.scatter_props, self._contour_info,
... | [
"def",
"event_info",
"(",
"self",
",",
"event",
")",
":",
"def",
"default_func",
"(",
"event",
")",
":",
"return",
"{",
"}",
"registry",
"=",
"{",
"AxesImage",
":",
"[",
"pick_info",
".",
"image_props",
"]",
",",
"PathCollection",
":",
"[",
"pick_info",
... | Get a dict of info for the artist selected by "event". | [
"Get",
"a",
"dict",
"of",
"info",
"for",
"the",
"artist",
"selected",
"by",
"event",
"."
] | python | train |
ReFirmLabs/binwalk | src/binwalk/core/magic.py | https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L473-L546 | def _do_math(self, offset, expression):
'''
Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc.
@offset - The offset inside self.data that the current signature starts at.
@expressions - The expression to evaluate.
Returns an integer value that is th... | [
"def",
"_do_math",
"(",
"self",
",",
"offset",
",",
"expression",
")",
":",
"# Does the expression contain an offset (e.g., \"(4.l+12)\")?",
"if",
"'.'",
"in",
"expression",
"and",
"'('",
"in",
"expression",
":",
"replacements",
"=",
"{",
"}",
"for",
"period",
"in... | Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc.
@offset - The offset inside self.data that the current signature starts at.
@expressions - The expression to evaluate.
Returns an integer value that is the result of the evaluated expression. | [
"Parses",
"and",
"evaluates",
"complex",
"expressions",
"e",
".",
"g",
".",
"(",
"4",
".",
"l",
"+",
"12",
")",
"(",
"6",
"*",
"32",
")",
"etc",
"."
] | python | train |
odlgroup/odl | odl/util/utility.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/util/utility.py#L1309-L1430 | def method_repr_string(inst_str, meth_str, arg_strs=None,
allow_mixed_seps=True):
r"""Return a repr string for a method that respects line width.
This function is useful to generate a ``repr`` string for a derived
class that is created through a method, for instance ::
funct... | [
"def",
"method_repr_string",
"(",
"inst_str",
",",
"meth_str",
",",
"arg_strs",
"=",
"None",
",",
"allow_mixed_seps",
"=",
"True",
")",
":",
"linewidth",
"=",
"np",
".",
"get_printoptions",
"(",
")",
"[",
"'linewidth'",
"]",
"# Part up to the method name",
"if",... | r"""Return a repr string for a method that respects line width.
This function is useful to generate a ``repr`` string for a derived
class that is created through a method, for instance ::
functional.translated(x)
as a better way of representing ::
FunctionalTranslation(functional, x)
... | [
"r",
"Return",
"a",
"repr",
"string",
"for",
"a",
"method",
"that",
"respects",
"line",
"width",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/handlers.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/handlers.py#L170-L180 | def ws_url(self):
"""websocket url matching the current request
turns http[s]://host[:port] into
ws[s]://host[:port]
"""
proto = self.request.protocol.replace('http', 'ws')
host = self.application.ipython_app.websocket_host # default to config value
if ho... | [
"def",
"ws_url",
"(",
"self",
")",
":",
"proto",
"=",
"self",
".",
"request",
".",
"protocol",
".",
"replace",
"(",
"'http'",
",",
"'ws'",
")",
"host",
"=",
"self",
".",
"application",
".",
"ipython_app",
".",
"websocket_host",
"# default to config value",
... | websocket url matching the current request
turns http[s]://host[:port] into
ws[s]://host[:port] | [
"websocket",
"url",
"matching",
"the",
"current",
"request"
] | python | test |
ska-sa/katcp-python | katcp/server.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/server.py#L810-L833 | def on_message(self, client_conn, msg):
"""Handle message.
Returns
-------
ready : Future
A future that will resolve once we're ready, else None.
Notes
-----
*on_message* should not be called again until *ready* has resolved.
"""
MAX... | [
"def",
"on_message",
"(",
"self",
",",
"client_conn",
",",
"msg",
")",
":",
"MAX_QUEUE_SIZE",
"=",
"30",
"if",
"len",
"(",
"self",
".",
"_msg_queue",
")",
">=",
"MAX_QUEUE_SIZE",
":",
"# This should never happen if callers to handle_message wait",
"# for its futures t... | Handle message.
Returns
-------
ready : Future
A future that will resolve once we're ready, else None.
Notes
-----
*on_message* should not be called again until *ready* has resolved. | [
"Handle",
"message",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/commenting/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/commenting/sessions.py#L2572-L2593 | def get_child_books(self, book_id):
"""Gets the child books of the given ``id``.
arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` to
query
return: (osid.commenting.BookList) - the child books of the
``id``
raise: NotFound - a ``Book`` identified ... | [
"def",
"get_child_books",
"(",
"self",
",",
"book_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_child_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".",
"ge... | Gets the child books of the given ``id``.
arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` to
query
return: (osid.commenting.BookList) - the child books of the
``id``
raise: NotFound - a ``Book`` identified by ``Id is`` not found
raise: NullArgu... | [
"Gets",
"the",
"child",
"books",
"of",
"the",
"given",
"id",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/distlib/manifest.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/manifest.py#L297-L315 | def _exclude_pattern(self, pattern, anchor=True, prefix=None,
is_regex=False):
"""Remove strings (presumably filenames) from 'files' that match
'pattern'.
Other parameters are the same as for 'include_pattern()', above.
The list 'self.files' is modified in place... | [
"def",
"_exclude_pattern",
"(",
"self",
",",
"pattern",
",",
"anchor",
"=",
"True",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"False",
")",
":",
"found",
"=",
"False",
"pattern_re",
"=",
"self",
".",
"_translate_pattern",
"(",
"pattern",
",",
"an... | Remove strings (presumably filenames) from 'files' that match
'pattern'.
Other parameters are the same as for 'include_pattern()', above.
The list 'self.files' is modified in place. Return True if files are
found.
This API is public to allow e.g. exclusion of SCM subdirs, e.g. ... | [
"Remove",
"strings",
"(",
"presumably",
"filenames",
")",
"from",
"files",
"that",
"match",
"pattern",
"."
] | python | train |
ofek/depq | run_performance_check.py | https://github.com/ofek/depq/blob/370e3ad503d3e9cedc3c49dc64add393ba945764/run_performance_check.py#L63-L114 | def binary_insert(self, item, priority):
"""Traditional binary search. Performance: O(n log n)"""
with self.lock:
self_data = self.data
rotate = self_data.rotate
maxlen = self._maxlen
length = len(self_data)
index = 0
min = 0
max = length - 1
wh... | [
"def",
"binary_insert",
"(",
"self",
",",
"item",
",",
"priority",
")",
":",
"with",
"self",
".",
"lock",
":",
"self_data",
"=",
"self",
".",
"data",
"rotate",
"=",
"self_data",
".",
"rotate",
"maxlen",
"=",
"self",
".",
"_maxlen",
"length",
"=",
"len"... | Traditional binary search. Performance: O(n log n) | [
"Traditional",
"binary",
"search",
".",
"Performance",
":",
"O",
"(",
"n",
"log",
"n",
")"
] | python | train |
raymontag/kppy | kppy/database.py | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L861-L871 | def _cbc_encrypt(self, content, final_key):
"""This method encrypts the content."""
aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv)
padding = (16 - len(content) % AES.block_size)
for _ in range(padding):
content += chr(padding).encode()
temp = bytes(content)
... | [
"def",
"_cbc_encrypt",
"(",
"self",
",",
"content",
",",
"final_key",
")",
":",
"aes",
"=",
"AES",
".",
"new",
"(",
"final_key",
",",
"AES",
".",
"MODE_CBC",
",",
"self",
".",
"_enc_iv",
")",
"padding",
"=",
"(",
"16",
"-",
"len",
"(",
"content",
"... | This method encrypts the content. | [
"This",
"method",
"encrypts",
"the",
"content",
"."
] | python | train |
pgmpy/pgmpy | pgmpy/readwrite/ProbModelXML.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/ProbModelXML.py#L768-L787 | def add_probnet_additionalconstraints(self, constraint):
"""
Adds Additional Constraints to the probnet dict.
Parameters
----------
criterion: <Element Constraint at AdditionalConstraints Node in XML>
etree Element consisting Constraint tag.
Examples
... | [
"def",
"add_probnet_additionalconstraints",
"(",
"self",
",",
"constraint",
")",
":",
"constraint_name",
"=",
"constraint",
".",
"attrib",
"[",
"'name'",
"]",
"self",
".",
"probnet",
"[",
"'AdditionalConstraints'",
"]",
"[",
"constraint_name",
"]",
"=",
"{",
"}"... | Adds Additional Constraints to the probnet dict.
Parameters
----------
criterion: <Element Constraint at AdditionalConstraints Node in XML>
etree Element consisting Constraint tag.
Examples
-------
>>> reader = ProbModelXMLReader()
>>> reader.add_add... | [
"Adds",
"Additional",
"Constraints",
"to",
"the",
"probnet",
"dict",
"."
] | python | train |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/__init__.py | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/__init__.py#L181-L213 | def conditional_http_tween_factory(handler, registry):
"""
Tween that adds ETag headers and tells Pyramid to enable
conditional responses where appropriate.
"""
settings = registry.settings if hasattr(registry, 'settings') else {}
if 'generate_etag_for.list' in settings:
route_names = s... | [
"def",
"conditional_http_tween_factory",
"(",
"handler",
",",
"registry",
")",
":",
"settings",
"=",
"registry",
".",
"settings",
"if",
"hasattr",
"(",
"registry",
",",
"'settings'",
")",
"else",
"{",
"}",
"if",
"'generate_etag_for.list'",
"in",
"settings",
":",... | Tween that adds ETag headers and tells Pyramid to enable
conditional responses where appropriate. | [
"Tween",
"that",
"adds",
"ETag",
"headers",
"and",
"tells",
"Pyramid",
"to",
"enable",
"conditional",
"responses",
"where",
"appropriate",
"."
] | python | train |
matousc89/padasip | padasip/ann/mlp.py | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L172-L198 | def update(self, w, e):
"""
This function make update according provided target
and the last used input vector.
**Args:**
* `d` : target (float or 1-dimensional array).
Size depends on number of MLP outputs.
**Returns:**
* `w` : weights of the laye... | [
"def",
"update",
"(",
"self",
",",
"w",
",",
"e",
")",
":",
"if",
"len",
"(",
"w",
".",
"shape",
")",
"==",
"1",
":",
"e",
"=",
"self",
".",
"activation",
"(",
"self",
".",
"y",
",",
"f",
"=",
"self",
".",
"f",
",",
"der",
"=",
"True",
")... | This function make update according provided target
and the last used input vector.
**Args:**
* `d` : target (float or 1-dimensional array).
Size depends on number of MLP outputs.
**Returns:**
* `w` : weights of the layers (2-dimensional layer).
Every ... | [
"This",
"function",
"make",
"update",
"according",
"provided",
"target",
"and",
"the",
"last",
"used",
"input",
"vector",
"."
] | python | train |
ericpruitt/cronex | cronex/__init__.py | https://github.com/ericpruitt/cronex/blob/ff48a3a71bbcdf01cff46c0bf9376e69492c9224/cronex/__init__.py#L302-L362 | def parse_atom(parse, minmax):
"""
Returns a set containing valid values for a given cron-style range of
numbers. The 'minmax' arguments is a two element iterable containing the
inclusive upper and lower limits of the expression.
Examples:
>>> parse_atom("1-5",(0,6))
set([1, 2, 3, 4, 5])
... | [
"def",
"parse_atom",
"(",
"parse",
",",
"minmax",
")",
":",
"parse",
"=",
"parse",
".",
"strip",
"(",
")",
"increment",
"=",
"1",
"if",
"parse",
"==",
"'*'",
":",
"return",
"set",
"(",
"xrange",
"(",
"minmax",
"[",
"0",
"]",
",",
"minmax",
"[",
"... | Returns a set containing valid values for a given cron-style range of
numbers. The 'minmax' arguments is a two element iterable containing the
inclusive upper and lower limits of the expression.
Examples:
>>> parse_atom("1-5",(0,6))
set([1, 2, 3, 4, 5])
>>> parse_atom("*/6",(0,23))
set([0,... | [
"Returns",
"a",
"set",
"containing",
"valid",
"values",
"for",
"a",
"given",
"cron",
"-",
"style",
"range",
"of",
"numbers",
".",
"The",
"minmax",
"arguments",
"is",
"a",
"two",
"element",
"iterable",
"containing",
"the",
"inclusive",
"upper",
"and",
"lower"... | python | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/utils/winresource.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/utils/winresource.py#L243-L264 | def UpdateResourcesFromDict(dstpath, res, types=None, names=None,
languages=None):
"""
Update or add resources from resource dict in dll/exe file dstpath.
types = a list of resource types to update (None = all)
names = a list of resource names to update (None = all)
... | [
"def",
"UpdateResourcesFromDict",
"(",
"dstpath",
",",
"res",
",",
"types",
"=",
"None",
",",
"names",
"=",
"None",
",",
"languages",
"=",
"None",
")",
":",
"if",
"types",
":",
"types",
"=",
"set",
"(",
"types",
")",
"if",
"names",
":",
"names",
"=",... | Update or add resources from resource dict in dll/exe file dstpath.
types = a list of resource types to update (None = all)
names = a list of resource names to update (None = all)
languages = a list of resource languages to update (None = all) | [
"Update",
"or",
"add",
"resources",
"from",
"resource",
"dict",
"in",
"dll",
"/",
"exe",
"file",
"dstpath",
".",
"types",
"=",
"a",
"list",
"of",
"resource",
"types",
"to",
"update",
"(",
"None",
"=",
"all",
")",
"names",
"=",
"a",
"list",
"of",
"res... | python | train |
digidotcom/python-wvalib | wva/core.py | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/core.py#L102-L112 | def get_event_stream(self):
"""Get the event stream associated with this WVA
Note that this event stream is shared across all users of this WVA device
as the WVA only supports a single event stream.
:return: a new :class:`WVAEventStream` instance
"""
if self._event_stre... | [
"def",
"get_event_stream",
"(",
"self",
")",
":",
"if",
"self",
".",
"_event_stream",
"is",
"None",
":",
"self",
".",
"_event_stream",
"=",
"WVAEventStream",
"(",
"self",
".",
"_http_client",
")",
"return",
"self",
".",
"_event_stream"
] | Get the event stream associated with this WVA
Note that this event stream is shared across all users of this WVA device
as the WVA only supports a single event stream.
:return: a new :class:`WVAEventStream` instance | [
"Get",
"the",
"event",
"stream",
"associated",
"with",
"this",
"WVA"
] | python | train |
vertexproject/synapse | synapse/lib/syntax.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/syntax.py#L614-L630 | def formpivotin(self):
'''
<- * / <- prop
'''
self.ignore(whitespace)
self.nextmust('<-')
self.ignore(whitespace)
if self.nextchar() == '*':
self.offs += 1
return s_ast.PivotIn()
prop = self.absprop()
return s_ast.Pivot... | [
"def",
"formpivotin",
"(",
"self",
")",
":",
"self",
".",
"ignore",
"(",
"whitespace",
")",
"self",
".",
"nextmust",
"(",
"'<-'",
")",
"self",
".",
"ignore",
"(",
"whitespace",
")",
"if",
"self",
".",
"nextchar",
"(",
")",
"==",
"'*'",
":",
"self",
... | <- * / <- prop | [
"<",
"-",
"*",
"/",
"<",
"-",
"prop"
] | python | train |
brainiak/brainiak | brainiak/funcalign/sssrm.py | https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/funcalign/sssrm.py#L299-L383 | def _sssrm(self, data_align, data_sup, labels):
"""Block-Coordinate Descent algorithm for fitting SS-SRM.
Parameters
----------
data_align : list of 2D arrays, element i has shape=[voxels_i, n_align]
Each element in the list contains the fMRI data for alignment of
... | [
"def",
"_sssrm",
"(",
"self",
",",
"data_align",
",",
"data_sup",
",",
"labels",
")",
":",
"classes",
"=",
"self",
".",
"classes_",
".",
"size",
"# Initialization:",
"self",
".",
"random_state_",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"self",
... | Block-Coordinate Descent algorithm for fitting SS-SRM.
Parameters
----------
data_align : list of 2D arrays, element i has shape=[voxels_i, n_align]
Each element in the list contains the fMRI data for alignment of
one subject. There are n_align samples for each subject.... | [
"Block",
"-",
"Coordinate",
"Descent",
"algorithm",
"for",
"fitting",
"SS",
"-",
"SRM",
"."
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10725-L10749 | def position_target_global_int_encode(self, time_boot_ms, coordinate_frame, type_mask, lat_int, lon_int, alt, vx, vy, vz, afx, afy, afz, yaw, yaw_rate):
'''
Reports the current commanded vehicle position, velocity, and
acceleration as specified by the autopilot. This
... | [
"def",
"position_target_global_int_encode",
"(",
"self",
",",
"time_boot_ms",
",",
"coordinate_frame",
",",
"type_mask",
",",
"lat_int",
",",
"lon_int",
",",
"alt",
",",
"vx",
",",
"vy",
",",
"vz",
",",
"afx",
",",
"afy",
",",
"afz",
",",
"yaw",
",",
"ya... | Reports the current commanded vehicle position, velocity, and
acceleration as specified by the autopilot. This
should match the commands sent in
SET_POSITION_TARGET_GLOBAL_INT if the vehicle is being
controlled this way.
time_boot_ms ... | [
"Reports",
"the",
"current",
"commanded",
"vehicle",
"position",
"velocity",
"and",
"acceleration",
"as",
"specified",
"by",
"the",
"autopilot",
".",
"This",
"should",
"match",
"the",
"commands",
"sent",
"in",
"SET_POSITION_TARGET_GLOBAL_INT",
"if",
"the",
"vehicle"... | python | train |
donovan-duplessis/pwnurl | pwnurl/models/base.py | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L60-L66 | def save(self, commit=True):
""" Save model to database """
db.session.add(self)
if commit:
db.session.commit()
return self | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"db",
".",
"session",
".",
"add",
"(",
"self",
")",
"if",
"commit",
":",
"db",
".",
"session",
".",
"commit",
"(",
")",
"return",
"self"
] | Save model to database | [
"Save",
"model",
"to",
"database"
] | python | train |
bwhite/hadoopy | hadoopy/_reporter.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_reporter.py#L27-L40 | def counter(group, counter, amount=1, err=None):
"""Output a counter update that is displayed in the Hadoop web interface
Counters are useful for quickly identifying the number of times an error
occurred, current progress, or coarse statistics.
:param group: Counter group
:param counter: Counter n... | [
"def",
"counter",
"(",
"group",
",",
"counter",
",",
"amount",
"=",
"1",
",",
"err",
"=",
"None",
")",
":",
"if",
"not",
"err",
":",
"err",
"=",
"_err",
"err",
"(",
"\"reporter:counter:%s,%s,%s\\n\"",
"%",
"(",
"group",
",",
"counter",
",",
"str",
"(... | Output a counter update that is displayed in the Hadoop web interface
Counters are useful for quickly identifying the number of times an error
occurred, current progress, or coarse statistics.
:param group: Counter group
:param counter: Counter name
:param amount: Value to add (default 1)
:par... | [
"Output",
"a",
"counter",
"update",
"that",
"is",
"displayed",
"in",
"the",
"Hadoop",
"web",
"interface"
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/block.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L343-L369 | def order_block_volume(self, storage_type, location, size, os_type,
iops=None, tier_level=None, snapshot_size=None,
service_offering='storage_as_a_service',
hourly_billing_flag=False):
"""Places an order for a block volume.
... | [
"def",
"order_block_volume",
"(",
"self",
",",
"storage_type",
",",
"location",
",",
"size",
",",
"os_type",
",",
"iops",
"=",
"None",
",",
"tier_level",
"=",
"None",
",",
"snapshot_size",
"=",
"None",
",",
"service_offering",
"=",
"'storage_as_a_service'",
",... | Places an order for a block volume.
:param storage_type: 'performance' or 'endurance'
:param location: Datacenter in which to order iSCSI volume
:param size: Size of the desired volume, in GB
:param os_type: OS Type to use for volume alignment, see help for list
:param iops: Num... | [
"Places",
"an",
"order",
"for",
"a",
"block",
"volume",
"."
] | python | train |
aconrad/pycobertura | pycobertura/cobertura.py | https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L420-L429 | def file_source_hunks(self, filename):
"""
Like `CoberturaDiff.file_source`, but returns a list of line hunks of
the lines that have changed for the given file `filename`. An empty
list means that the file has no lines that have a change in coverage
status.
"""
li... | [
"def",
"file_source_hunks",
"(",
"self",
",",
"filename",
")",
":",
"lines",
"=",
"self",
".",
"file_source",
"(",
"filename",
")",
"hunks",
"=",
"hunkify_lines",
"(",
"lines",
")",
"return",
"hunks"
] | Like `CoberturaDiff.file_source`, but returns a list of line hunks of
the lines that have changed for the given file `filename`. An empty
list means that the file has no lines that have a change in coverage
status. | [
"Like",
"CoberturaDiff",
".",
"file_source",
"but",
"returns",
"a",
"list",
"of",
"line",
"hunks",
"of",
"the",
"lines",
"that",
"have",
"changed",
"for",
"the",
"given",
"file",
"filename",
".",
"An",
"empty",
"list",
"means",
"that",
"the",
"file",
"has"... | python | train |
google/grr | grr/server/grr_response_server/flows/general/filetypes.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filetypes.py#L59-L64 | def Start(self):
"""Issue a request to list the directory."""
self.CallClient(
server_stubs.PlistQuery,
request=self.args.request,
next_state="Receive") | [
"def",
"Start",
"(",
"self",
")",
":",
"self",
".",
"CallClient",
"(",
"server_stubs",
".",
"PlistQuery",
",",
"request",
"=",
"self",
".",
"args",
".",
"request",
",",
"next_state",
"=",
"\"Receive\"",
")"
] | Issue a request to list the directory. | [
"Issue",
"a",
"request",
"to",
"list",
"the",
"directory",
"."
] | python | train |
Fantomas42/django-blog-zinnia | zinnia/admin/widgets.py | https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/admin/widgets.py#L105-L115 | def media(self):
"""
TagAutoComplete's Media.
"""
def static(path):
return staticfiles_storage.url(
'zinnia/admin/select2/%s' % path)
return Media(
css={'all': (static('css/select2.css'),)},
js=(static('js/select2.js'),)
... | [
"def",
"media",
"(",
"self",
")",
":",
"def",
"static",
"(",
"path",
")",
":",
"return",
"staticfiles_storage",
".",
"url",
"(",
"'zinnia/admin/select2/%s'",
"%",
"path",
")",
"return",
"Media",
"(",
"css",
"=",
"{",
"'all'",
":",
"(",
"static",
"(",
"... | TagAutoComplete's Media. | [
"TagAutoComplete",
"s",
"Media",
"."
] | python | train |
earwig/mwparserfromhell | mwparserfromhell/nodes/template.py | https://github.com/earwig/mwparserfromhell/blob/98dc30902d35c714a70aca8e6616f49d71cb24cc/mwparserfromhell/nodes/template.py#L80-L90 | def _surface_escape(code, char):
"""Return *code* with *char* escaped as an HTML entity.
The main use of this is to escape pipes (``|``) or equal signs (``=``)
in parameter names or values so they are not mistaken for new
parameters.
"""
replacement = str(HTMLEntity(valu... | [
"def",
"_surface_escape",
"(",
"code",
",",
"char",
")",
":",
"replacement",
"=",
"str",
"(",
"HTMLEntity",
"(",
"value",
"=",
"ord",
"(",
"char",
")",
")",
")",
"for",
"node",
"in",
"code",
".",
"filter_text",
"(",
"recursive",
"=",
"False",
")",
":... | Return *code* with *char* escaped as an HTML entity.
The main use of this is to escape pipes (``|``) or equal signs (``=``)
in parameter names or values so they are not mistaken for new
parameters. | [
"Return",
"*",
"code",
"*",
"with",
"*",
"char",
"*",
"escaped",
"as",
"an",
"HTML",
"entity",
"."
] | python | train |
saltstack/salt | salt/modules/solaris_system.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solaris_system.py#L111-L131 | def reboot(delay=0, message=None):
'''
Reboot the system
delay : int
Optional wait time in seconds before the system will be rebooted.
message : string
Optional message to broadcast before rebooting.
CLI Example:
.. code-block:: bash
salt '*' system.reboot
sal... | [
"def",
"reboot",
"(",
"delay",
"=",
"0",
",",
"message",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'shutdown'",
",",
"'-i'",
",",
"'6'",
",",
"'-g'",
",",
"delay",
",",
"'-y'",
"]",
"if",
"message",
":",
"cmd",
".",
"append",
"(",
"message",
")",
... | Reboot the system
delay : int
Optional wait time in seconds before the system will be rebooted.
message : string
Optional message to broadcast before rebooting.
CLI Example:
.. code-block:: bash
salt '*' system.reboot
salt '*' system.reboot 60 "=== system upgraded ===... | [
"Reboot",
"the",
"system"
] | python | train |
vilmibm/done | parsedatetime/parsedatetime.py | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime.py#L1479-L1540 | def inc(self, source, month=None, year=None):
"""
Takes the given C{source} date, or current date if none is
passed, and increments it according to the values passed in
by month and/or year.
This routine is needed because Python's C{timedelta()} function
does not ... | [
"def",
"inc",
"(",
"self",
",",
"source",
",",
"month",
"=",
"None",
",",
"year",
"=",
"None",
")",
":",
"yr",
"=",
"source",
".",
"year",
"mth",
"=",
"source",
".",
"month",
"dy",
"=",
"source",
".",
"day",
"if",
"year",
":",
"try",
":",
"yi",... | Takes the given C{source} date, or current date if none is
passed, and increments it according to the values passed in
by month and/or year.
This routine is needed because Python's C{timedelta()} function
does not allow for month or year increments.
@type source: struct... | [
"Takes",
"the",
"given",
"C",
"{",
"source",
"}",
"date",
"or",
"current",
"date",
"if",
"none",
"is",
"passed",
"and",
"increments",
"it",
"according",
"to",
"the",
"values",
"passed",
"in",
"by",
"month",
"and",
"/",
"or",
"year",
".",
"This",
"routi... | python | train |
cloudboss/friend | friend/strings.py | https://github.com/cloudboss/friend/blob/3357e6ec849552e3ae9ed28017ff0926e4006e4e/friend/strings.py#L394-L434 | def format_obj_keys(obj, formatter):
"""
Take a dictionary with string keys and recursively convert
all keys from one form to another using the formatting function.
The dictionary may contain lists as values, and any nested
dictionaries within those lists will also be converted.
:param object ... | [
"def",
"format_obj_keys",
"(",
"obj",
",",
"formatter",
")",
":",
"if",
"type",
"(",
"obj",
")",
"==",
"list",
":",
"return",
"[",
"format_obj_keys",
"(",
"o",
",",
"formatter",
")",
"for",
"o",
"in",
"obj",
"]",
"elif",
"type",
"(",
"obj",
")",
"=... | Take a dictionary with string keys and recursively convert
all keys from one form to another using the formatting function.
The dictionary may contain lists as values, and any nested
dictionaries within those lists will also be converted.
:param object obj: The object to convert
:param function fo... | [
"Take",
"a",
"dictionary",
"with",
"string",
"keys",
"and",
"recursively",
"convert",
"all",
"keys",
"from",
"one",
"form",
"to",
"another",
"using",
"the",
"formatting",
"function",
"."
] | python | train |
Microsoft/nni | src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py#L356-L365 | def handle_update_search_space(self, data):
"""data: JSON object, which is search space
Parameters
----------
data: int
number of trial jobs
"""
self.searchspace_json = data
self.random_state = np.random.RandomState() | [
"def",
"handle_update_search_space",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"searchspace_json",
"=",
"data",
"self",
".",
"random_state",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
")"
] | data: JSON object, which is search space
Parameters
----------
data: int
number of trial jobs | [
"data",
":",
"JSON",
"object",
"which",
"is",
"search",
"space",
"Parameters",
"----------",
"data",
":",
"int",
"number",
"of",
"trial",
"jobs"
] | python | train |
openfisca/openfisca-core | openfisca_core/indexed_enums.py | https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/indexed_enums.py#L118-L128 | def decode_to_str(self):
"""
Return the array of string identifiers corresponding to self
>>> enum_array = household('housing_occupancy_status', period)
>>> enum_array[0]
>>> 2 # Encoded value
>>> enum_array.decode_to_str()[0]
>>> 'free_l... | [
"def",
"decode_to_str",
"(",
"self",
")",
":",
"return",
"np",
".",
"select",
"(",
"[",
"self",
"==",
"item",
".",
"index",
"for",
"item",
"in",
"self",
".",
"possible_values",
"]",
",",
"[",
"item",
".",
"name",
"for",
"item",
"in",
"self",
".",
"... | Return the array of string identifiers corresponding to self
>>> enum_array = household('housing_occupancy_status', period)
>>> enum_array[0]
>>> 2 # Encoded value
>>> enum_array.decode_to_str()[0]
>>> 'free_lodger' # String identifier | [
"Return",
"the",
"array",
"of",
"string",
"identifiers",
"corresponding",
"to",
"self"
] | python | train |
dw/mitogen | ansible_mitogen/connection.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/connection.py#L240-L256 | def _connect_setns(spec, kind=None):
"""
Return ContextService arguments for a mitogen_setns connection.
"""
return {
'method': 'setns',
'kwargs': {
'container': spec.remote_addr(),
'username': spec.remote_user(),
'python_path': spec.python_path(),
... | [
"def",
"_connect_setns",
"(",
"spec",
",",
"kind",
"=",
"None",
")",
":",
"return",
"{",
"'method'",
":",
"'setns'",
",",
"'kwargs'",
":",
"{",
"'container'",
":",
"spec",
".",
"remote_addr",
"(",
")",
",",
"'username'",
":",
"spec",
".",
"remote_user",
... | Return ContextService arguments for a mitogen_setns connection. | [
"Return",
"ContextService",
"arguments",
"for",
"a",
"mitogen_setns",
"connection",
"."
] | python | train |
RJT1990/pyflux | pyflux/gpnarx/kernels.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/kernels.py#L79-L91 | def K(self, parm):
""" Returns the Gram Matrix
Parameters
----------
parm : np.ndarray
Parameters for the Gram Matrix
Returns
----------
- Gram Matrix (np.ndarray)
"""
return OU_K_matrix(self.X, parm) + np.identity(self.X.shape[0])*(1... | [
"def",
"K",
"(",
"self",
",",
"parm",
")",
":",
"return",
"OU_K_matrix",
"(",
"self",
".",
"X",
",",
"parm",
")",
"+",
"np",
".",
"identity",
"(",
"self",
".",
"X",
".",
"shape",
"[",
"0",
"]",
")",
"*",
"(",
"10",
"**",
"-",
"10",
")"
] | Returns the Gram Matrix
Parameters
----------
parm : np.ndarray
Parameters for the Gram Matrix
Returns
----------
- Gram Matrix (np.ndarray) | [
"Returns",
"the",
"Gram",
"Matrix"
] | python | train |
pypa/setuptools | setuptools/msvc.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/msvc.py#L204-L237 | def _augment_exception(exc, version, arch=''):
"""
Add details to the exception message to help guide the user
as to what action will resolve it.
"""
# Error if MSVC++ directory not found or environment not set
message = exc.args[0]
if "vcvarsall" in message.lower() or "visual c" in message... | [
"def",
"_augment_exception",
"(",
"exc",
",",
"version",
",",
"arch",
"=",
"''",
")",
":",
"# Error if MSVC++ directory not found or environment not set",
"message",
"=",
"exc",
".",
"args",
"[",
"0",
"]",
"if",
"\"vcvarsall\"",
"in",
"message",
".",
"lower",
"(... | Add details to the exception message to help guide the user
as to what action will resolve it. | [
"Add",
"details",
"to",
"the",
"exception",
"message",
"to",
"help",
"guide",
"the",
"user",
"as",
"to",
"what",
"action",
"will",
"resolve",
"it",
"."
] | python | train |
datastax/python-driver | cassandra/cqlengine/columns.py | https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cqlengine/columns.py#L44-L63 | def changed(self):
"""
Indicates whether or not this value has changed.
:rtype: boolean
"""
if self.explicit:
return self.value != self.previous_value
if isinstance(self.column, BaseContainerColumn):
default_value = self.column.get_default()
... | [
"def",
"changed",
"(",
"self",
")",
":",
"if",
"self",
".",
"explicit",
":",
"return",
"self",
".",
"value",
"!=",
"self",
".",
"previous_value",
"if",
"isinstance",
"(",
"self",
".",
"column",
",",
"BaseContainerColumn",
")",
":",
"default_value",
"=",
... | Indicates whether or not this value has changed.
:rtype: boolean | [
"Indicates",
"whether",
"or",
"not",
"this",
"value",
"has",
"changed",
"."
] | python | train |
lcgong/redbean | redbean/secure/secure.py | https://github.com/lcgong/redbean/blob/45df9ff1e807e742771c752808d7fdac4007c919/redbean/secure/secure.py#L54-L71 | async def identify(self, request):
""" 从request中得到登录身份identity """
if hasattr(request, '_session_identity'):
return request._session_identity
token = request.cookies.get(self._cookie_name)
if token is None:
token = getAuthorizationTokenFromHeader(request)
... | [
"async",
"def",
"identify",
"(",
"self",
",",
"request",
")",
":",
"if",
"hasattr",
"(",
"request",
",",
"'_session_identity'",
")",
":",
"return",
"request",
".",
"_session_identity",
"token",
"=",
"request",
".",
"cookies",
".",
"get",
"(",
"self",
".",
... | 从request中得到登录身份identity | [
"从request中得到登录身份identity"
] | python | train |
mwouts/jupytext | jupytext/jupytext.py | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L181-L209 | def reads(text, fmt, as_version=4, **kwargs):
"""Read a notebook from a string"""
fmt = copy(fmt)
fmt = long_form_one_format(fmt)
ext = fmt['extension']
if ext == '.ipynb':
return nbformat.reads(text, as_version, **kwargs)
format_name = read_format_from_metadata(text, ext) or fmt.get('... | [
"def",
"reads",
"(",
"text",
",",
"fmt",
",",
"as_version",
"=",
"4",
",",
"*",
"*",
"kwargs",
")",
":",
"fmt",
"=",
"copy",
"(",
"fmt",
")",
"fmt",
"=",
"long_form_one_format",
"(",
"fmt",
")",
"ext",
"=",
"fmt",
"[",
"'extension'",
"]",
"if",
"... | Read a notebook from a string | [
"Read",
"a",
"notebook",
"from",
"a",
"string"
] | python | train |
polyaxon/polyaxon | polyaxon/docker_images/image_info.py | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/docker_images/image_info.py#L22-L32 | def get_job_image_info(project: 'Project', job: Any) -> Tuple[str, str]:
"""Return the image name and image tag for a job"""
project_name = project.name
repo_name = project_name
image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
try:
last_commit = project.repo.last_commit
... | [
"def",
"get_job_image_info",
"(",
"project",
":",
"'Project'",
",",
"job",
":",
"Any",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"project_name",
"=",
"project",
".",
"name",
"repo_name",
"=",
"project_name",
"image_name",
"=",
"'{}/{}'",
".",
... | Return the image name and image tag for a job | [
"Return",
"the",
"image",
"name",
"and",
"image",
"tag",
"for",
"a",
"job"
] | python | train |
Metatab/metatab | metatab/terms.py | https://github.com/Metatab/metatab/blob/8336ec3e4bd8da84a9a5cb86de1c1086e14b8b22/metatab/terms.py#L921-L937 | def rows(self):
"""Yield rows for the section"""
for t in self.terms:
for row in t.rows:
term, value = row # Value can either be a string, or a dict
if isinstance(value, dict): # Dict is for properties, which might be arg-children
term,... | [
"def",
"rows",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"terms",
":",
"for",
"row",
"in",
"t",
".",
"rows",
":",
"term",
",",
"value",
"=",
"row",
"# Value can either be a string, or a dict",
"if",
"isinstance",
"(",
"value",
",",
"dict",
... | Yield rows for the section | [
"Yield",
"rows",
"for",
"the",
"section"
] | python | train |
chrisrink10/basilisp | src/basilisp/lang/compiler/generator.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1823-L1878 | def _var_sym_to_py_ast(
ctx: GeneratorContext, node: VarRef, is_assigning: bool = False
) -> GeneratedPyAST:
"""Generate a Python AST node for accessing a Var.
If the Var is marked as :dynamic or :redef or the compiler option
USE_VAR_INDIRECTION is active, do not compile to a direct access.
If the ... | [
"def",
"_var_sym_to_py_ast",
"(",
"ctx",
":",
"GeneratorContext",
",",
"node",
":",
"VarRef",
",",
"is_assigning",
":",
"bool",
"=",
"False",
")",
"->",
"GeneratedPyAST",
":",
"assert",
"node",
".",
"op",
"==",
"NodeOp",
".",
"VAR",
"var",
"=",
"node",
"... | Generate a Python AST node for accessing a Var.
If the Var is marked as :dynamic or :redef or the compiler option
USE_VAR_INDIRECTION is active, do not compile to a direct access.
If the corresponding function name is not defined in a Python module,
no direct variable access is possible and Var.find in... | [
"Generate",
"a",
"Python",
"AST",
"node",
"for",
"accessing",
"a",
"Var",
"."
] | python | test |
hardbyte/python-can | can/notifier.py | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/notifier.py#L70-L90 | def stop(self, timeout=5):
"""Stop notifying Listeners when new :class:`~can.Message` objects arrive
and call :meth:`~can.Listener.stop` on each Listener.
:param float timeout:
Max time in seconds to wait for receive threads to finish.
Should be longer than timeout given... | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"5",
")",
":",
"self",
".",
"_running",
"=",
"False",
"end_time",
"=",
"time",
".",
"time",
"(",
")",
"+",
"timeout",
"for",
"reader",
"in",
"self",
".",
"_readers",
":",
"if",
"isinstance",
"(",
"re... | Stop notifying Listeners when new :class:`~can.Message` objects arrive
and call :meth:`~can.Listener.stop` on each Listener.
:param float timeout:
Max time in seconds to wait for receive threads to finish.
Should be longer than timeout given at instantiation. | [
"Stop",
"notifying",
"Listeners",
"when",
"new",
":",
"class",
":",
"~can",
".",
"Message",
"objects",
"arrive",
"and",
"call",
":",
"meth",
":",
"~can",
".",
"Listener",
".",
"stop",
"on",
"each",
"Listener",
"."
] | python | train |
calmjs/calmjs | src/calmjs/base.py | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L508-L518 | def which(self):
"""
Figure out which binary this will execute.
Returns None if the binary is not found.
"""
if self.binary is None:
return None
return which(self.binary, path=self.env_path) | [
"def",
"which",
"(",
"self",
")",
":",
"if",
"self",
".",
"binary",
"is",
"None",
":",
"return",
"None",
"return",
"which",
"(",
"self",
".",
"binary",
",",
"path",
"=",
"self",
".",
"env_path",
")"
] | Figure out which binary this will execute.
Returns None if the binary is not found. | [
"Figure",
"out",
"which",
"binary",
"this",
"will",
"execute",
"."
] | python | train |
edoburu/sphinxcontrib-django | sphinxcontrib_django/docstrings.py | https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L43-L59 | def setup(app):
"""Allow this package to be used as Sphinx extension.
This is also called from the top-level ``__init__.py``.
:type app: sphinx.application.Sphinx
"""
from .patches import patch_django_for_autodoc
# When running, make sure Django doesn't execute querysets
patch_django_for_a... | [
"def",
"setup",
"(",
"app",
")",
":",
"from",
".",
"patches",
"import",
"patch_django_for_autodoc",
"# When running, make sure Django doesn't execute querysets",
"patch_django_for_autodoc",
"(",
")",
"# Generate docstrings for Django model fields",
"# Register the docstring processor... | Allow this package to be used as Sphinx extension.
This is also called from the top-level ``__init__.py``.
:type app: sphinx.application.Sphinx | [
"Allow",
"this",
"package",
"to",
"be",
"used",
"as",
"Sphinx",
"extension",
".",
"This",
"is",
"also",
"called",
"from",
"the",
"top",
"-",
"level",
"__init__",
".",
"py",
"."
] | python | train |
neptune-ml/steppy-toolkit | toolkit/preprocessing/misc.py | https://github.com/neptune-ml/steppy-toolkit/blob/bf3f48cfcc65dffc46e65ddd5d6cfec6bb9f9132/toolkit/preprocessing/misc.py#L287-L309 | def transform(self, numerical_feature_list, categorical_feature_list):
"""
Args:
numerical_feature_list: list of numerical features
categorical_feature_list: list of categorical features
Returns:
Dictionary with following keys:
features: DataF... | [
"def",
"transform",
"(",
"self",
",",
"numerical_feature_list",
",",
"categorical_feature_list",
")",
":",
"features",
"=",
"numerical_feature_list",
"+",
"categorical_feature_list",
"for",
"feature",
"in",
"features",
":",
"feature",
"=",
"self",
".",
"_format_target... | Args:
numerical_feature_list: list of numerical features
categorical_feature_list: list of categorical features
Returns:
Dictionary with following keys:
features: DataFrame with concatenated features
feature_names: list of features names
... | [
"Args",
":",
"numerical_feature_list",
":",
"list",
"of",
"numerical",
"features",
"categorical_feature_list",
":",
"list",
"of",
"categorical",
"features"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.