nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
XX-net/XX-Net | a9898cfcf0084195fb7e69b6bc834e59aecdf14f | python3.8.2/Lib/site-packages/cerealizer/__init__.py | python | Handler.undump_data | (self, obj, dumper, s) | Handler.undump_data(obj, dumper, s)
Reads the data for OBJ, from DUMPER and file S.
If you override undump_data, you should use DUMPER.undump_ref(S) to
read a reference or a basic type (=a string, an int,...). | Handler.undump_data(obj, dumper, s) | [
"Handler",
".",
"undump_data",
"(",
"obj",
"dumper",
"s",
")"
] | def undump_data(self, obj, dumper, s):
"""Handler.undump_data(obj, dumper, s)
Reads the data for OBJ, from DUMPER and file S.
If you override undump_data, you should use DUMPER.undump_ref(S) to
read a reference or a basic type (=a string, an int,...).""" | [
"def",
"undump_data",
"(",
"self",
",",
"obj",
",",
"dumper",
",",
"s",
")",
":"
] | https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/python3.8.2/Lib/site-packages/cerealizer/__init__.py#L268-L273 | ||
tuckerbalch/QSTK | 4981506c37227a72404229d5e1e0887f797a5d57 | epydoc-3.0.1/epydoc/gui.py | python | _version | () | Display the version information, and exit.
@rtype: C{None} | Display the version information, and exit. | [
"Display",
"the",
"version",
"information",
"and",
"exit",
"."
] | def _version():
"""
Display the version information, and exit.
@rtype: C{None}
"""
import epydoc
print "Epydoc version %s" % epydoc.__version__
sys.exit(0) | [
"def",
"_version",
"(",
")",
":",
"import",
"epydoc",
"print",
"\"Epydoc version %s\"",
"%",
"epydoc",
".",
"__version__",
"sys",
".",
"exit",
"(",
"0",
")"
] | https://github.com/tuckerbalch/QSTK/blob/4981506c37227a72404229d5e1e0887f797a5d57/epydoc-3.0.1/epydoc/gui.py#L1084-L1091 | ||
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/django-extensions-1.8.0/django_extensions/management/commands/sqldiff.py | python | PostgresqlSQLDiff.get_constraints | (self, cursor, table_name, introspection) | return constraints | backport of django's introspection.get_constraints(...) | backport of django's introspection.get_constraints(...) | [
"backport",
"of",
"django",
"s",
"introspection",
".",
"get_constraints",
"(",
"...",
")"
] | def get_constraints(self, cursor, table_name, introspection):
""" backport of django's introspection.get_constraints(...) """
constraints = {}
# Loop over the key table, collecting things as constraints
# This will get PKs, FKs, and uniques, but not CHECK
cursor.execute("""
... | [
"def",
"get_constraints",
"(",
"self",
",",
"cursor",
",",
"table_name",
",",
"introspection",
")",
":",
"constraints",
"=",
"{",
"}",
"# Loop over the key table, collecting things as constraints",
"# This will get PKs, FKs, and uniques, but not CHECK",
"cursor",
".",
"execut... | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/django-extensions-1.8.0/django_extensions/management/commands/sqldiff.py#L753-L838 | |
log2timeline/plaso | fe2e316b8c76a0141760c0f2f181d84acb83abc2 | plaso/multi_process/analysis_engine.py | python | AnalysisMultiProcessEngine.AnalyzeEvents | (
self, session, knowledge_base_object, storage_writer, data_location,
analysis_plugins, processing_configuration, event_filter=None,
event_filter_expression=None, status_update_callback=None,
storage_file_path=None) | return self._processing_status | Analyzes events in a Plaso storage.
Args:
session (Session): session in which the events are analyzed.
knowledge_base_object (KnowledgeBase): contains information from
the source data needed for processing.
storage_writer (StorageWriter): storage writer.
data_location (str): path ... | Analyzes events in a Plaso storage. | [
"Analyzes",
"events",
"in",
"a",
"Plaso",
"storage",
"."
] | def AnalyzeEvents(
self, session, knowledge_base_object, storage_writer, data_location,
analysis_plugins, processing_configuration, event_filter=None,
event_filter_expression=None, status_update_callback=None,
storage_file_path=None):
"""Analyzes events in a Plaso storage.
Args:
s... | [
"def",
"AnalyzeEvents",
"(",
"self",
",",
"session",
",",
"knowledge_base_object",
",",
"storage_writer",
",",
"data_location",
",",
"analysis_plugins",
",",
"processing_configuration",
",",
"event_filter",
"=",
"None",
",",
"event_filter_expression",
"=",
"None",
","... | https://github.com/log2timeline/plaso/blob/fe2e316b8c76a0141760c0f2f181d84acb83abc2/plaso/multi_process/analysis_engine.py#L531-L699 | |
plotly/plotly.py | cfad7862594b35965c0e000813bd7805e8494a5b | packages/python/plotly/plotly/graph_objs/layout/geo/_center.py | python | Center.lat | (self) | return self["lat"] | Sets the latitude of the map's center. For all projection
types, the map's latitude center lies at the middle of the
latitude range by default.
The 'lat' property is a number and may be specified as:
- An int or float
Returns
-------
int|float | Sets the latitude of the map's center. For all projection
types, the map's latitude center lies at the middle of the
latitude range by default.
The 'lat' property is a number and may be specified as:
- An int or float | [
"Sets",
"the",
"latitude",
"of",
"the",
"map",
"s",
"center",
".",
"For",
"all",
"projection",
"types",
"the",
"map",
"s",
"latitude",
"center",
"lies",
"at",
"the",
"middle",
"of",
"the",
"latitude",
"range",
"by",
"default",
".",
"The",
"lat",
"propert... | def lat(self):
"""
Sets the latitude of the map's center. For all projection
types, the map's latitude center lies at the middle of the
latitude range by default.
The 'lat' property is a number and may be specified as:
- An int or float
Returns
---... | [
"def",
"lat",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"lat\"",
"]"
] | https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/layout/geo/_center.py#L16-L29 | |
Calysto/calysto_scheme | 15bf81987870bcae1264e5a0a06feb9a8ee12b8b | calysto_scheme/src/Scheme.py | python | caaddr | (lyst) | return lyst.cdr.cdr.car.car | [] | def caaddr(lyst):
return lyst.cdr.cdr.car.car | [
"def",
"caaddr",
"(",
"lyst",
")",
":",
"return",
"lyst",
".",
"cdr",
".",
"cdr",
".",
"car",
".",
"car"
] | https://github.com/Calysto/calysto_scheme/blob/15bf81987870bcae1264e5a0a06feb9a8ee12b8b/calysto_scheme/src/Scheme.py#L412-L413 | |||
Tautulli/Tautulli | 2410eb33805aaac4bd1c5dad0f71e4f15afaf742 | lib/musicbrainzngs/musicbrainz.py | python | browse_works | (artist=None, includes=[], limit=None, offset=None) | return _browse_impl("work", includes, limit, offset, params) | Get all works linked to an artist
*Available includes*: {includes} | Get all works linked to an artist | [
"Get",
"all",
"works",
"linked",
"to",
"an",
"artist"
] | def browse_works(artist=None, includes=[], limit=None, offset=None):
"""Get all works linked to an artist
*Available includes*: {includes}"""
params = {"artist": artist}
return _browse_impl("work", includes, limit, offset, params) | [
"def",
"browse_works",
"(",
"artist",
"=",
"None",
",",
"includes",
"=",
"[",
"]",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"artist\"",
":",
"artist",
"}",
"return",
"_browse_impl",
"(",
"\"work\"",
",",
... | https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/musicbrainzngs/musicbrainz.py#L1180-L1185 | |
nopernik/mpDNS | b17dc39e7068406df82cb3431b3042e74e520cf9 | circuits/core/pollers.py | python | Poll._process | (self, fileno, event) | [] | def _process(self, fileno, event):
if fileno not in self._map:
return
fd = self._map[fileno]
if fd == self._ctrl_recv:
self._read_ctrl()
return
if event & self._disconnected_flag and not (event & select.POLLIN):
self.fire(_disconnect(fd),... | [
"def",
"_process",
"(",
"self",
",",
"fileno",
",",
"event",
")",
":",
"if",
"fileno",
"not",
"in",
"self",
".",
"_map",
":",
"return",
"fd",
"=",
"self",
".",
"_map",
"[",
"fileno",
"]",
"if",
"fd",
"==",
"self",
".",
"_ctrl_recv",
":",
"self",
... | https://github.com/nopernik/mpDNS/blob/b17dc39e7068406df82cb3431b3042e74e520cf9/circuits/core/pollers.py#L298-L323 | ||||
taoyds/spider | 7036cf422b1da08a907acbdc062e598bb0761bf7 | baselines/seq2seq_attention_copy/seq2seq/data/sequence_example_decoder.py | python | TFSEquenceExampleDecoder.decode | (self, serialized_example, items=None) | return outputs | Decodes the given serialized TF-example.
Args:
serialized_example: a serialized TF-example tensor.
items: the list of items to decode. These must be a subset of the item
keys in self._items_to_handlers. If `items` is left as None, then all
of the items in self._items_to_handlers are deco... | Decodes the given serialized TF-example.
Args:
serialized_example: a serialized TF-example tensor.
items: the list of items to decode. These must be a subset of the item
keys in self._items_to_handlers. If `items` is left as None, then all
of the items in self._items_to_handlers are deco... | [
"Decodes",
"the",
"given",
"serialized",
"TF",
"-",
"example",
".",
"Args",
":",
"serialized_example",
":",
"a",
"serialized",
"TF",
"-",
"example",
"tensor",
".",
"items",
":",
"the",
"list",
"of",
"items",
"to",
"decode",
".",
"These",
"must",
"be",
"a... | def decode(self, serialized_example, items=None):
"""Decodes the given serialized TF-example.
Args:
serialized_example: a serialized TF-example tensor.
items: the list of items to decode. These must be a subset of the item
keys in self._items_to_handlers. If `items` is left as None, then all... | [
"def",
"decode",
"(",
"self",
",",
"serialized_example",
",",
"items",
"=",
"None",
")",
":",
"context",
",",
"sequence",
"=",
"tf",
".",
"parse_single_sequence_example",
"(",
"serialized_example",
",",
"self",
".",
"_context_keys_to_features",
",",
"self",
".",... | https://github.com/taoyds/spider/blob/7036cf422b1da08a907acbdc062e598bb0761bf7/baselines/seq2seq_attention_copy/seq2seq/data/sequence_example_decoder.py#L53-L89 | |
google/ml-fairness-gym | 5b1cd336b844059aa4e4426b54d1f0e6b8c4c7e9 | agents/recommenders/utils.py | python | accumulate_rewards | (rewards, gamma) | return np.array(acc[::-1]) | Computes the discounted reward for the entire episode. | Computes the discounted reward for the entire episode. | [
"Computes",
"the",
"discounted",
"reward",
"for",
"the",
"entire",
"episode",
"."
] | def accumulate_rewards(rewards, gamma):
"""Computes the discounted reward for the entire episode."""
reversed_rewards = rewards[::-1] # list reversal
acc = list(itertools.accumulate(reversed_rewards, lambda x, y: x*gamma + y))
return np.array(acc[::-1]) | [
"def",
"accumulate_rewards",
"(",
"rewards",
",",
"gamma",
")",
":",
"reversed_rewards",
"=",
"rewards",
"[",
":",
":",
"-",
"1",
"]",
"# list reversal",
"acc",
"=",
"list",
"(",
"itertools",
".",
"accumulate",
"(",
"reversed_rewards",
",",
"lambda",
"x",
... | https://github.com/google/ml-fairness-gym/blob/5b1cd336b844059aa4e4426b54d1f0e6b8c4c7e9/agents/recommenders/utils.py#L35-L39 | |
adewes/blitzdb | 36191579be14fbc2d7a47ede099bcdf31297a9fa | blitzdb/backends/mongo/queryset.py | python | QuerySet.limit | (self, *args, **kwargs) | return self | [] | def limit(self, *args, **kwargs):
self._cursor.limit(*args, **kwargs)
return self | [
"def",
"limit",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_cursor",
".",
"limit",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self"
] | https://github.com/adewes/blitzdb/blob/36191579be14fbc2d7a47ede099bcdf31297a9fa/blitzdb/backends/mongo/queryset.py#L81-L83 | |||
log2timeline/plaso | fe2e316b8c76a0141760c0f2f181d84acb83abc2 | plaso/parsers/fseventsd.py | python | FseventsdParser._GetParentModificationTime | (self, gzip_file_entry) | return parent_file_entry.modification_time | Retrieves the modification time of the file entry's parent file.
Note that this retrieves the time from the file entry of the parent of the
gzip file entry's path spec, which is different from trying to retrieve it
from the gzip file entry's parent file entry.
It would be preferable to retrieve the mo... | Retrieves the modification time of the file entry's parent file. | [
"Retrieves",
"the",
"modification",
"time",
"of",
"the",
"file",
"entry",
"s",
"parent",
"file",
"."
] | def _GetParentModificationTime(self, gzip_file_entry):
"""Retrieves the modification time of the file entry's parent file.
Note that this retrieves the time from the file entry of the parent of the
gzip file entry's path spec, which is different from trying to retrieve it
from the gzip file entry's par... | [
"def",
"_GetParentModificationTime",
"(",
"self",
",",
"gzip_file_entry",
")",
":",
"parent_file_entry",
"=",
"path_spec_resolver",
".",
"Resolver",
".",
"OpenFileEntry",
"(",
"gzip_file_entry",
".",
"path_spec",
".",
"parent",
")",
"if",
"not",
"parent_file_entry",
... | https://github.com/log2timeline/plaso/blob/fe2e316b8c76a0141760c0f2f181d84acb83abc2/plaso/parsers/fseventsd.py#L122-L146 | |
kuri65536/python-for-android | 26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891 | python3-alpha/python-libs/gdata/analytics/data.py | python | AnalyticsLink.parent | (cls) | return '%s#parent' % GA_NS[1:-3] | Parent target_kind | Parent target_kind | [
"Parent",
"target_kind"
] | def parent(cls):
"""Parent target_kind"""
return '%s#parent' % GA_NS[1:-3] | [
"def",
"parent",
"(",
"cls",
")",
":",
"return",
"'%s#parent'",
"%",
"GA_NS",
"[",
"1",
":",
"-",
"3",
"]"
] | https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python3-alpha/python-libs/gdata/analytics/data.py#L278-L280 | |
mbusb/multibootusb | fa89b28f27891a9ce8d6e2a5737baa2e6ee83dfd | scripts/imager.py | python | Imager.__init__ | (self) | [] | def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self) | [
"def",
"__init__",
"(",
"self",
")",
":",
"QtWidgets",
".",
"QMainWindow",
".",
"__init__",
"(",
"self",
")",
"self",
".",
"ui",
"=",
"Ui_MainWindow",
"(",
")",
"self",
".",
"ui",
".",
"setupUi",
"(",
"self",
")"
] | https://github.com/mbusb/multibootusb/blob/fa89b28f27891a9ce8d6e2a5737baa2e6ee83dfd/scripts/imager.py#L90-L93 | ||||
OpenRCE/paimei | d78f574129f9aade35af03ced08765ea2a15288c | console/modules/_PAIMEIpstalker/PIDAModulesListCtrl.py | python | PIDAModulesListCtrl.on_right_down | (self, event) | Grab the x/y coordinates when the right mouse button is clicked. | Grab the x/y coordinates when the right mouse button is clicked. | [
"Grab",
"the",
"x",
"/",
"y",
"coordinates",
"when",
"the",
"right",
"mouse",
"button",
"is",
"clicked",
"."
] | def on_right_down (self, event):
'''
Grab the x/y coordinates when the right mouse button is clicked.
'''
self.x = event.GetX()
self.y = event.GetY()
item, flags = self.HitTest((self.x, self.y))
if flags & wx.LIST_HITTEST_ONITEM:
self.Select(item)
... | [
"def",
"on_right_down",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"x",
"=",
"event",
".",
"GetX",
"(",
")",
"self",
".",
"y",
"=",
"event",
".",
"GetY",
"(",
")",
"item",
",",
"flags",
"=",
"self",
".",
"HitTest",
"(",
"(",
"self",
".",... | https://github.com/OpenRCE/paimei/blob/d78f574129f9aade35af03ced08765ea2a15288c/console/modules/_PAIMEIpstalker/PIDAModulesListCtrl.py#L166-L180 | ||
sqlmapproject/sqlmap | 3b07b70864624dff4c29dcaa8a61c78e7f9189f7 | lib/core/session.py | python | setOs | () | Example of kb.bannerFp dictionary:
{
'sp': set(['Service Pack 4']),
'dbmsVersion': '8.00.194',
'dbmsServicePack': '0',
'distrib': set(['2000']),
'dbmsRelease': '2000',
'type': set(['Windows'])
} | Example of kb.bannerFp dictionary: | [
"Example",
"of",
"kb",
".",
"bannerFp",
"dictionary",
":"
] | def setOs():
"""
Example of kb.bannerFp dictionary:
{
'sp': set(['Service Pack 4']),
'dbmsVersion': '8.00.194',
'dbmsServicePack': '0',
'distrib': set(['2000']),
'dbmsRelease': '2000',
'type': set(['Windows'])
}
"""
infoMsg = ""
if not kb.bannerFp:
... | [
"def",
"setOs",
"(",
")",
":",
"infoMsg",
"=",
"\"\"",
"if",
"not",
"kb",
".",
"bannerFp",
":",
"return",
"if",
"\"type\"",
"in",
"kb",
".",
"bannerFp",
":",
"Backend",
".",
"setOs",
"(",
"Format",
".",
"humanize",
"(",
"kb",
".",
"bannerFp",
"[",
... | https://github.com/sqlmapproject/sqlmap/blob/3b07b70864624dff4c29dcaa8a61c78e7f9189f7/lib/core/session.py#L40-L79 | ||
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/com.oracle.graal.python.cext/setup.py | python | Bzip2Depedency.build | (self, extracted_dir=None) | return lib_src_folder | [] | def build(self, extracted_dir=None):
if not extracted_dir:
extracted_dir = self.download()
lib_src_folder = os.path.join(extracted_dir, self.package_name + "-" + self.version)
logger.info("Building dependency %s in %s using Makefile %s" % (self.package_name, lib_src_folder, self.make... | [
"def",
"build",
"(",
"self",
",",
"extracted_dir",
"=",
"None",
")",
":",
"if",
"not",
"extracted_dir",
":",
"extracted_dir",
"=",
"self",
".",
"download",
"(",
")",
"lib_src_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"extracted_dir",
",",
"self"... | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/com.oracle.graal.python.cext/setup.py#L258-L275 | |||
tflearn/tflearn | db5176773299b67a2a75c5889fb2aba7fd0fea8a | tflearn/initializations.py | python | truncated_normal | (shape=None, mean=0.0, stddev=0.02, dtype=tf.float32,
seed=None) | Truncated Normal.
Initialization with random values from a normal truncated distribution.
The generated values follow a normal distribution with specified mean and
standard deviation, except that values whose magnitude is more than 2 standard
deviations from the mean are dropped and re-picked.
Ar... | Truncated Normal. | [
"Truncated",
"Normal",
"."
] | def truncated_normal(shape=None, mean=0.0, stddev=0.02, dtype=tf.float32,
seed=None):
""" Truncated Normal.
Initialization with random values from a normal truncated distribution.
The generated values follow a normal distribution with specified mean and
standard deviation, except ... | [
"def",
"truncated_normal",
"(",
"shape",
"=",
"None",
",",
"mean",
"=",
"0.0",
",",
"stddev",
"=",
"0.02",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"seed",
"=",
"None",
")",
":",
"if",
"shape",
":",
"return",
"tf",
".",
"truncated_normal",
"(",
... | https://github.com/tflearn/tflearn/blob/db5176773299b67a2a75c5889fb2aba7fd0fea8a/tflearn/initializations.py#L138-L165 | ||
AstroPrint/AstroBox | e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75 | src/ext/makerbot_driver/FileReader/FileReader.py | python | FileReader.GetNextCommand | (self) | return cmd | Assuming the file pointer is at a command, gets the next command number
If ReadBytes raises an InsufficientDataError (indicating no more information
if available in the file), we throw an EndOfFileError
@return int The command number | Assuming the file pointer is at a command, gets the next command number
If ReadBytes raises an InsufficientDataError (indicating no more information
if available in the file), we throw an EndOfFileError | [
"Assuming",
"the",
"file",
"pointer",
"is",
"at",
"a",
"command",
"gets",
"the",
"next",
"command",
"number",
"If",
"ReadBytes",
"raises",
"an",
"InsufficientDataError",
"(",
"indicating",
"no",
"more",
"information",
"if",
"available",
"in",
"the",
"file",
")... | def GetNextCommand(self):
"""Assuming the file pointer is at a command, gets the next command number
If ReadBytes raises an InsufficientDataError (indicating no more information
if available in the file), we throw an EndOfFileError
@return int The command number
"""
try:... | [
"def",
"GetNextCommand",
"(",
"self",
")",
":",
"try",
":",
"cmd",
"=",
"ord",
"(",
"self",
".",
"ReadBytes",
"(",
"1",
")",
")",
"except",
"makerbot_driver",
".",
"FileReader",
".",
"InsufficientDataError",
":",
"raise",
"makerbot_driver",
".",
"FileReader"... | https://github.com/AstroPrint/AstroBox/blob/e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75/src/ext/makerbot_driver/FileReader/FileReader.py#L55-L73 | |
ninja-ide/ninja-ide | 87d91131bd19fdc3dcfd91eb97ad1e41c49c60c0 | ninja_ide/dependencies/notimportchecker.py | python | Checker.get_not_imports_on_file | (self, stmt, path=None) | Get imports that dont exist on the file
Parameters
----------
stmt: dict -> dict of not imports in the file
{'sys':{'lineno': 1, 'mod_name': 'sys'}}
if stmt == -1 (see parse_file) return None
path: string -> default None. path is the basename
of the file. | Get imports that dont exist on the file | [
"Get",
"imports",
"that",
"dont",
"exist",
"on",
"the",
"file"
] | def get_not_imports_on_file(self, stmt, path=None):
"""Get imports that dont exist on the file
Parameters
----------
stmt: dict -> dict of not imports in the file
{'sys':{'lineno': 1, 'mod_name': 'sys'}}
if stmt == -1 (see parse_file) return None
path: stri... | [
"def",
"get_not_imports_on_file",
"(",
"self",
",",
"stmt",
",",
"path",
"=",
"None",
")",
":",
"if",
"(",
"stmt",
"==",
"-",
"1",
")",
":",
"self",
".",
"_import_error_list",
"=",
"{",
"}",
"return",
"None",
"if",
"path",
"is",
"None",
":",
"path",
... | https://github.com/ninja-ide/ninja-ide/blob/87d91131bd19fdc3dcfd91eb97ad1e41c49c60c0/ninja_ide/dependencies/notimportchecker.py#L130-L173 | ||
wakatime/komodo-wakatime | 8923c04ded9fa64d7374fadd8cde3a6fadfe053d | components/wakatime/packages/urllib3/packages/ordered_dict.py | python | OrderedDict.update | (*args, **kwds) | od.update(E, **F) -> None. Update od from dict/iterable E and F.
If E is a dict instance, does: for k in E: od[k] = E[k]
If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
Or if E is an iterable of items, does: for k, v in E: od[k] = v
In either case, ... | od.update(E, **F) -> None. Update od from dict/iterable E and F. | [
"od",
".",
"update",
"(",
"E",
"**",
"F",
")",
"-",
">",
"None",
".",
"Update",
"od",
"from",
"dict",
"/",
"iterable",
"E",
"and",
"F",
"."
] | def update(*args, **kwds):
'''od.update(E, **F) -> None. Update od from dict/iterable E and F.
If E is a dict instance, does: for k in E: od[k] = E[k]
If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
Or if E is an iterable of items, does: for k, v in... | [
"def",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"2",
":",
"raise",
"TypeError",
"(",
"'update() takes at most 2 positional '",
"'arguments (%d given)'",
"%",
"(",
"len",
"(",
"args",
")",
",",
")",
... | https://github.com/wakatime/komodo-wakatime/blob/8923c04ded9fa64d7374fadd8cde3a6fadfe053d/components/wakatime/packages/urllib3/packages/ordered_dict.py#L142-L171 | ||
VirtueSecurity/aws-extender | d123b7e1a845847709ba3a481f11996bddc68a1c | BappModules/docutils/parsers/rst/states.py | python | Body.directive | (self, match, **option_presets) | Returns a 2-tuple: list of nodes, and a "blank finish" boolean. | Returns a 2-tuple: list of nodes, and a "blank finish" boolean. | [
"Returns",
"a",
"2",
"-",
"tuple",
":",
"list",
"of",
"nodes",
"and",
"a",
"blank",
"finish",
"boolean",
"."
] | def directive(self, match, **option_presets):
"""Returns a 2-tuple: list of nodes, and a "blank finish" boolean."""
type_name = match.group(1)
directive_class, messages = directives.directive(
type_name, self.memo.language, self.document)
self.parent += messages
if di... | [
"def",
"directive",
"(",
"self",
",",
"match",
",",
"*",
"*",
"option_presets",
")",
":",
"type_name",
"=",
"match",
".",
"group",
"(",
"1",
")",
"directive_class",
",",
"messages",
"=",
"directives",
".",
"directive",
"(",
"type_name",
",",
"self",
".",... | https://github.com/VirtueSecurity/aws-extender/blob/d123b7e1a845847709ba3a481f11996bddc68a1c/BappModules/docutils/parsers/rst/states.py#L2073-L2083 | ||
Dvlv/Tkinter-By-Example | 30721f15f7bea41489a7c46819beb5282781e563 | Code/Chapter6-1.py | python | Editor.destroy_autocomplete_menu | (self, event=None) | [] | def destroy_autocomplete_menu(self, event=None):
try:
self.complete_menu.destroy()
self.main_text.unbind("<Down>")
self.main_text.focus_force()
except AttributeError:
pass | [
"def",
"destroy_autocomplete_menu",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"complete_menu",
".",
"destroy",
"(",
")",
"self",
".",
"main_text",
".",
"unbind",
"(",
"\"<Down>\"",
")",
"self",
".",
"main_text",
".",
"foc... | https://github.com/Dvlv/Tkinter-By-Example/blob/30721f15f7bea41489a7c46819beb5282781e563/Code/Chapter6-1.py#L117-L123 | ||||
gramps-project/gramps | 04d4651a43eb210192f40a9f8c2bad8ee8fa3753 | gramps/gen/proxy/proxybase.py | python | ProxyDbBase.get_note_from_handle | (self, handle) | return self.gfilter(self.include_note,
self.db.get_note_from_handle(handle)) | Finds a Note in the database from the passed gramps handle.
If no such Note exists, None is returned. | Finds a Note in the database from the passed gramps handle.
If no such Note exists, None is returned. | [
"Finds",
"a",
"Note",
"in",
"the",
"database",
"from",
"the",
"passed",
"gramps",
"handle",
".",
"If",
"no",
"such",
"Note",
"exists",
"None",
"is",
"returned",
"."
] | def get_note_from_handle(self, handle):
"""
Finds a Note in the database from the passed gramps handle.
If no such Note exists, None is returned.
"""
return self.gfilter(self.include_note,
self.db.get_note_from_handle(handle)) | [
"def",
"get_note_from_handle",
"(",
"self",
",",
"handle",
")",
":",
"return",
"self",
".",
"gfilter",
"(",
"self",
".",
"include_note",
",",
"self",
".",
"db",
".",
"get_note_from_handle",
"(",
"handle",
")",
")"
] | https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/gen/proxy/proxybase.py#L562-L568 | |
ThaWeatherman/scrapers | d82e2b707bbb2b450176dbf85842aeccb6e812f9 | craigslist/free_stuff_requests.py | python | get_args | () | return parser.parse_args() | [] | def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('-w', type=str, default='http://baltimore.craigslist.org', help='your local craigslist website, including HTTP schema')
return parser.parse_args() | [
"def",
"get_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-w'",
",",
"type",
"=",
"str",
",",
"default",
"=",
"'http://baltimore.craigslist.org'",
",",
"help",
"=",
"'your local craigsli... | https://github.com/ThaWeatherman/scrapers/blob/d82e2b707bbb2b450176dbf85842aeccb6e812f9/craigslist/free_stuff_requests.py#L15-L18 | |||
GoogleChrome/chromium-dashboard | 7ef9184080fc4cdf11efbe29dba27f95f07a20d9 | internals/search.py | python | _get_referenced_features | (approvals, reverse=False) | return features | Retrieve the features being approved, withuot duplicates. | Retrieve the features being approved, withuot duplicates. | [
"Retrieve",
"the",
"features",
"being",
"approved",
"withuot",
"duplicates",
"."
] | def _get_referenced_features(approvals, reverse=False):
"""Retrieve the features being approved, withuot duplicates."""
logging.info('approvals is %r', [(a.feature_id, a.state) for a in approvals])
feature_ids = []
seen = set()
for appr in approvals:
if appr.feature_id not in seen:
seen.add(appr.fea... | [
"def",
"_get_referenced_features",
"(",
"approvals",
",",
"reverse",
"=",
"False",
")",
":",
"logging",
".",
"info",
"(",
"'approvals is %r'",
",",
"[",
"(",
"a",
".",
"feature_id",
",",
"a",
".",
"state",
")",
"for",
"a",
"in",
"approvals",
"]",
")",
... | https://github.com/GoogleChrome/chromium-dashboard/blob/7ef9184080fc4cdf11efbe29dba27f95f07a20d9/internals/search.py#L31-L42 | |
polakowo/vectorbt | 6638735c131655760474d72b9f045d1dbdbd8fe9 | vectorbt/generic/nb.py | python | pct_change_nb | (a: tp.Array2d, n: int = 1) | return out | 2-dim version of `pct_change_1d_nb`. | 2-dim version of `pct_change_1d_nb`. | [
"2",
"-",
"dim",
"version",
"of",
"pct_change_1d_nb",
"."
] | def pct_change_nb(a: tp.Array2d, n: int = 1) -> tp.Array2d:
"""2-dim version of `pct_change_1d_nb`."""
out = np.empty_like(a, dtype=np.float_)
for col in range(a.shape[1]):
out[:, col] = pct_change_1d_nb(a[:, col], n=n)
return out | [
"def",
"pct_change_nb",
"(",
"a",
":",
"tp",
".",
"Array2d",
",",
"n",
":",
"int",
"=",
"1",
")",
"->",
"tp",
".",
"Array2d",
":",
"out",
"=",
"np",
".",
"empty_like",
"(",
"a",
",",
"dtype",
"=",
"np",
".",
"float_",
")",
"for",
"col",
"in",
... | https://github.com/polakowo/vectorbt/blob/6638735c131655760474d72b9f045d1dbdbd8fe9/vectorbt/generic/nb.py#L319-L324 | |
titu1994/keras-non-local-nets | 334b0331d230383bf36328a1cd8cd409246bcafd | non_local.py | python | non_local_block | (ip, intermediate_dim=None, compression=2,
mode='embedded', add_residual=True) | return y | Adds a Non-Local block for self attention to the input tensor.
Input tensor can be or rank 3 (temporal), 4 (spatial) or 5 (spatio-temporal).
Arguments:
ip: input tensor
intermediate_dim: The dimension of the intermediate representation. Can be
`None` or a positive integer greater th... | Adds a Non-Local block for self attention to the input tensor.
Input tensor can be or rank 3 (temporal), 4 (spatial) or 5 (spatio-temporal). | [
"Adds",
"a",
"Non",
"-",
"Local",
"block",
"for",
"self",
"attention",
"to",
"the",
"input",
"tensor",
".",
"Input",
"tensor",
"can",
"be",
"or",
"rank",
"3",
"(",
"temporal",
")",
"4",
"(",
"spatial",
")",
"or",
"5",
"(",
"spatio",
"-",
"temporal",
... | def non_local_block(ip, intermediate_dim=None, compression=2,
mode='embedded', add_residual=True):
"""
Adds a Non-Local block for self attention to the input tensor.
Input tensor can be or rank 3 (temporal), 4 (spatial) or 5 (spatio-temporal).
Arguments:
ip: input tensor
... | [
"def",
"non_local_block",
"(",
"ip",
",",
"intermediate_dim",
"=",
"None",
",",
"compression",
"=",
"2",
",",
"mode",
"=",
"'embedded'",
",",
"add_residual",
"=",
"True",
")",
":",
"channel_dim",
"=",
"1",
"if",
"K",
".",
"image_data_format",
"(",
")",
"... | https://github.com/titu1994/keras-non-local-nets/blob/334b0331d230383bf36328a1cd8cd409246bcafd/non_local.py#L7-L152 | |
Scalsol/mega.pytorch | a6aa6e0537b82d70da94228100a51e6a53d98f82 | mega_core/modeling/roi_heads/mask_head/inference.py | python | expand_boxes | (boxes, scale) | return boxes_exp | [] | def expand_boxes(boxes, scale):
w_half = (boxes[:, 2] - boxes[:, 0]) * .5
h_half = (boxes[:, 3] - boxes[:, 1]) * .5
x_c = (boxes[:, 2] + boxes[:, 0]) * .5
y_c = (boxes[:, 3] + boxes[:, 1]) * .5
w_half *= scale
h_half *= scale
boxes_exp = torch.zeros_like(boxes)
boxes_exp[:, 0] = x_c - ... | [
"def",
"expand_boxes",
"(",
"boxes",
",",
"scale",
")",
":",
"w_half",
"=",
"(",
"boxes",
"[",
":",
",",
"2",
"]",
"-",
"boxes",
"[",
":",
",",
"0",
"]",
")",
"*",
".5",
"h_half",
"=",
"(",
"boxes",
"[",
":",
",",
"3",
"]",
"-",
"boxes",
"[... | https://github.com/Scalsol/mega.pytorch/blob/a6aa6e0537b82d70da94228100a51e6a53d98f82/mega_core/modeling/roi_heads/mask_head/inference.py#L91-L105 | |||
jython/jython3 | def4f8ec47cb7a9c799ea4c745f12badf92c5769 | lib-python/3.5.1/imp.py | python | get_magic | () | return util.MAGIC_NUMBER | **DEPRECATED**
Return the magic number for .pyc files. | **DEPRECATED** | [
"**",
"DEPRECATED",
"**"
] | def get_magic():
"""**DEPRECATED**
Return the magic number for .pyc files.
"""
return util.MAGIC_NUMBER | [
"def",
"get_magic",
"(",
")",
":",
"return",
"util",
".",
"MAGIC_NUMBER"
] | https://github.com/jython/jython3/blob/def4f8ec47cb7a9c799ea4c745f12badf92c5769/lib-python/3.5.1/imp.py#L59-L64 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/requests/cookies.py | python | MockRequest.get_new_headers | (self) | return self._new_headers | [] | def get_new_headers(self):
return self._new_headers | [
"def",
"get_new_headers",
"(",
"self",
")",
":",
"return",
"self",
".",
"_new_headers"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/requests/cookies.py#L82-L83 | |||
Yubico/yubikey-manager | 32914673d1d0004aba820e614ac9a9a640b4d196 | ykman/pcsc/__init__.py | python | ScardYubiKeyDevice.__init__ | (self, reader) | [] | def __init__(self, reader):
# Base transport on reader name: NFC readers will have a different name
if YK_READER_NAME in reader.name.lower():
transport = TRANSPORT.USB
else:
transport = TRANSPORT.NFC
super(ScardYubiKeyDevice, self).__init__(
transport,... | [
"def",
"__init__",
"(",
"self",
",",
"reader",
")",
":",
"# Base transport on reader name: NFC readers will have a different name",
"if",
"YK_READER_NAME",
"in",
"reader",
".",
"name",
".",
"lower",
"(",
")",
":",
"transport",
"=",
"TRANSPORT",
".",
"USB",
"else",
... | https://github.com/Yubico/yubikey-manager/blob/32914673d1d0004aba820e614ac9a9a640b4d196/ykman/pcsc/__init__.py#L69-L78 | ||||
tuckerbalch/QSTK | 4981506c37227a72404229d5e1e0887f797a5d57 | epydoc-3.0.1/epydoc/docwriter/dotgraph.py | python | DotGraphEdge.to_dotfile | (self) | return 'node%d -> node%d%s' % (self.start.id, self.end.id, attribs) | Return the dot commands that should be used to render this edge. | Return the dot commands that should be used to render this edge. | [
"Return",
"the",
"dot",
"commands",
"that",
"should",
"be",
"used",
"to",
"render",
"this",
"edge",
"."
] | def to_dotfile(self):
"""
Return the dot commands that should be used to render this edge.
"""
# Set head & tail ports, if the nodes have preferred ports.
attribs = self._attribs.copy()
if (self.start.port is not None and 'headport' not in attribs):
attribs['h... | [
"def",
"to_dotfile",
"(",
"self",
")",
":",
"# Set head & tail ports, if the nodes have preferred ports.",
"attribs",
"=",
"self",
".",
"_attribs",
".",
"copy",
"(",
")",
"if",
"(",
"self",
".",
"start",
".",
"port",
"is",
"not",
"None",
"and",
"'headport'",
"... | https://github.com/tuckerbalch/QSTK/blob/4981506c37227a72404229d5e1e0887f797a5d57/epydoc-3.0.1/epydoc/docwriter/dotgraph.py#L333-L348 | |
conda/conda-build | 2a19925f2b2ca188f80ffa625cd783e7d403793f | conda_build/environ.py | python | Environment.package_specs | (self) | return specs | List all package specs in the environment. | List all package specs in the environment. | [
"List",
"all",
"package",
"specs",
"in",
"the",
"environment",
"."
] | def package_specs(self):
"""
List all package specs in the environment.
"""
self._read_package_json()
json_objs = self._packages.values()
specs = []
for i in json_objs:
p, v, b = i['name'], i['version'], i['build']
specs.append(f'{p} {v} {b... | [
"def",
"package_specs",
"(",
"self",
")",
":",
"self",
".",
"_read_package_json",
"(",
")",
"json_objs",
"=",
"self",
".",
"_packages",
".",
"values",
"(",
")",
"specs",
"=",
"[",
"]",
"for",
"i",
"in",
"json_objs",
":",
"p",
",",
"v",
",",
"b",
"=... | https://github.com/conda/conda-build/blob/2a19925f2b2ca188f80ffa625cd783e7d403793f/conda_build/environ.py#L741-L751 | |
JetBrains/python-skeletons | 95ad24b666e475998e5d1cc02ed53a2188036167 | os/path.py | python | expanduser | (path) | return path | On Unix and Windows, return the argument with an initial component of ~
or ~user replaced by that user's home directory.
:type path: bytes | unicode | os.PathLike
:rtype: bytes | unicode | On Unix and Windows, return the argument with an initial component of ~
or ~user replaced by that user's home directory. | [
"On",
"Unix",
"and",
"Windows",
"return",
"the",
"argument",
"with",
"an",
"initial",
"component",
"of",
"~",
"or",
"~user",
"replaced",
"by",
"that",
"user",
"s",
"home",
"directory",
"."
] | def expanduser(path):
"""On Unix and Windows, return the argument with an initial component of ~
or ~user replaced by that user's home directory.
:type path: bytes | unicode | os.PathLike
:rtype: bytes | unicode
"""
return path | [
"def",
"expanduser",
"(",
"path",
")",
":",
"return",
"path"
] | https://github.com/JetBrains/python-skeletons/blob/95ad24b666e475998e5d1cc02ed53a2188036167/os/path.py#L65-L72 | |
mnot/thor | 8a6f14e15bd4e59e2348e6308e935a401e39d4a6 | thor/http/common.py | python | header_dict | (
hdr_tuples: RawHeaderListType, omit: List[bytes] = None
) | return out | Given a list of header tuples, return a dictionary keyed upon the
lower-cased header names.
If omit is defined, each header listed (by lower-cased name) will not be
returned in the dictionary. | Given a list of header tuples, return a dictionary keyed upon the
lower-cased header names. | [
"Given",
"a",
"list",
"of",
"header",
"tuples",
"return",
"a",
"dictionary",
"keyed",
"upon",
"the",
"lower",
"-",
"cased",
"header",
"names",
"."
] | def header_dict(
hdr_tuples: RawHeaderListType, omit: List[bytes] = None
) -> Dict[bytes, List[bytes]]:
"""
Given a list of header tuples, return a dictionary keyed upon the
lower-cased header names.
If omit is defined, each header listed (by lower-cased name) will not be
returned in the dictio... | [
"def",
"header_dict",
"(",
"hdr_tuples",
":",
"RawHeaderListType",
",",
"omit",
":",
"List",
"[",
"bytes",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"bytes",
",",
"List",
"[",
"bytes",
"]",
"]",
":",
"out",
"=",
"defaultdict",
"(",
"list",
")",
"# ty... | https://github.com/mnot/thor/blob/8a6f14e15bd4e59e2348e6308e935a401e39d4a6/thor/http/common.py#L68-L84 | |
saltstack/salt | fae5bc757ad0f1716483ce7ae180b451545c2058 | salt/modules/pkg_resource.py | python | pack_sources | (sources, normalize=True) | return ret | Accepts list of dicts (or a string representing a list of dicts) and packs
the key/value pairs into a single dict.
``'[{"foo": "salt://foo.rpm"}, {"bar": "salt://bar.rpm"}]'`` would become
``{"foo": "salt://foo.rpm", "bar": "salt://bar.rpm"}``
normalize : True
Normalize the package name by rem... | Accepts list of dicts (or a string representing a list of dicts) and packs
the key/value pairs into a single dict. | [
"Accepts",
"list",
"of",
"dicts",
"(",
"or",
"a",
"string",
"representing",
"a",
"list",
"of",
"dicts",
")",
"and",
"packs",
"the",
"key",
"/",
"value",
"pairs",
"into",
"a",
"single",
"dict",
"."
] | def pack_sources(sources, normalize=True):
"""
Accepts list of dicts (or a string representing a list of dicts) and packs
the key/value pairs into a single dict.
``'[{"foo": "salt://foo.rpm"}, {"bar": "salt://bar.rpm"}]'`` would become
``{"foo": "salt://foo.rpm", "bar": "salt://bar.rpm"}``
nor... | [
"def",
"pack_sources",
"(",
"sources",
",",
"normalize",
"=",
"True",
")",
":",
"if",
"normalize",
"and",
"\"pkg.normalize_name\"",
"in",
"__salt__",
":",
"_normalize_name",
"=",
"__salt__",
"[",
"\"pkg.normalize_name\"",
"]",
"else",
":",
"_normalize_name",
"=",
... | https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/pkg_resource.py#L36-L80 | |
TengXiaoDai/DistributedCrawling | f5c2439e6ce68dd9b49bde084d76473ff9ed4963 | Lib/site-packages/pip/wheel.py | python | check_compatibility | (version, name) | Raises errors or warns if called with an incompatible Wheel-Version.
Pip should refuse to install a Wheel-Version that's a major series
ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
installing a version only minor version ahead (e.g 1.2 > 1.1).
version: a 2-tuple representing a Whe... | Raises errors or warns if called with an incompatible Wheel-Version. | [
"Raises",
"errors",
"or",
"warns",
"if",
"called",
"with",
"an",
"incompatible",
"Wheel",
"-",
"Version",
"."
] | def check_compatibility(version, name):
"""
Raises errors or warns if called with an incompatible Wheel-Version.
Pip should refuse to install a Wheel-Version that's a major series
ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
installing a version only minor version ahead (e.g 1.... | [
"def",
"check_compatibility",
"(",
"version",
",",
"name",
")",
":",
"if",
"not",
"version",
":",
"raise",
"UnsupportedWheel",
"(",
"\"%s is in an unsupported or invalid wheel\"",
"%",
"name",
")",
"if",
"version",
"[",
"0",
"]",
">",
"VERSION_COMPATIBLE",
"[",
... | https://github.com/TengXiaoDai/DistributedCrawling/blob/f5c2439e6ce68dd9b49bde084d76473ff9ed4963/Lib/site-packages/pip/wheel.py#L583-L609 | ||
pdfminer/pdfminer.six | 10f6fb40c258c86fd04d86bade20f69fb07faabd | pdfminer/_saslprep.py | python | saslprep | (data: str, prohibit_unassigned_code_points: bool = True) | return data | An implementation of RFC4013 SASLprep.
:param data:
The string to SASLprep.
:param prohibit_unassigned_code_points:
RFC 3454 and RFCs for various SASL mechanisms distinguish between
`queries` (unassigned code points allowed) and
`stored strings` (unassigned code points prohibited... | An implementation of RFC4013 SASLprep.
:param data:
The string to SASLprep.
:param prohibit_unassigned_code_points:
RFC 3454 and RFCs for various SASL mechanisms distinguish between
`queries` (unassigned code points allowed) and
`stored strings` (unassigned code points prohibited... | [
"An",
"implementation",
"of",
"RFC4013",
"SASLprep",
".",
":",
"param",
"data",
":",
"The",
"string",
"to",
"SASLprep",
".",
":",
"param",
"prohibit_unassigned_code_points",
":",
"RFC",
"3454",
"and",
"RFCs",
"for",
"various",
"SASL",
"mechanisms",
"distinguish"... | def saslprep(data: str, prohibit_unassigned_code_points: bool = True) -> str:
"""An implementation of RFC4013 SASLprep.
:param data:
The string to SASLprep.
:param prohibit_unassigned_code_points:
RFC 3454 and RFCs for various SASL mechanisms distinguish between
`queries` (unassigned... | [
"def",
"saslprep",
"(",
"data",
":",
"str",
",",
"prohibit_unassigned_code_points",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"prohibit_unassigned_code_points",
":",
"prohibited",
"=",
"_PROHIBITED",
"+",
"(",
"stringprep",
".",
"in_table_a1",
",",
... | https://github.com/pdfminer/pdfminer.six/blob/10f6fb40c258c86fd04d86bade20f69fb07faabd/pdfminer/_saslprep.py#L43-L95 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/dateutil/tz/_common.py | python | _tzinfo.fromutc | (self, dt) | return enfold(dt_wall, fold=_fold) | Given a timezone-aware datetime in a given timezone, calculates a
timezone-aware datetime in a new timezone.
Since this is the one time that we *know* we have an unambiguous
datetime object, we take this opportunity to determine whether the
datetime is ambiguous and in a "fold" state (e... | Given a timezone-aware datetime in a given timezone, calculates a
timezone-aware datetime in a new timezone. | [
"Given",
"a",
"timezone",
"-",
"aware",
"datetime",
"in",
"a",
"given",
"timezone",
"calculates",
"a",
"timezone",
"-",
"aware",
"datetime",
"in",
"a",
"new",
"timezone",
"."
] | def fromutc(self, dt):
"""
Given a timezone-aware datetime in a given timezone, calculates a
timezone-aware datetime in a new timezone.
Since this is the one time that we *know* we have an unambiguous
datetime object, we take this opportunity to determine whether the
dat... | [
"def",
"fromutc",
"(",
"self",
",",
"dt",
")",
":",
"dt_wall",
"=",
"self",
".",
"_fromutc",
"(",
"dt",
")",
"# Calculate the fold status given the two datetimes.",
"_fold",
"=",
"self",
".",
"_fold_status",
"(",
"dt",
",",
"dt_wall",
")",
"# Set the default fol... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/dateutil/tz/_common.py#L241-L260 | |
LiuRoy/zhihu_spider | 8eb925d294689ad9ab13c1532fb7ba8c556b5ea7 | zhihu/zhihu/pipelines.py | python | ZhihuPipeline._process_relation | (self, item) | 存储人际拓扑关系 | 存储人际拓扑关系 | [
"存储人际拓扑关系"
] | def _process_relation(self, item):
"""
存储人际拓扑关系
"""
collection = self.db['relation']
data = collection.find_one({
'zhihu_id': item['zhihu_id'],
'user_type': item['user_type']})
if not data:
self.db['relation'].insert(dict(item))
... | [
"def",
"_process_relation",
"(",
"self",
",",
"item",
")",
":",
"collection",
"=",
"self",
".",
"db",
"[",
"'relation'",
"]",
"data",
"=",
"collection",
".",
"find_one",
"(",
"{",
"'zhihu_id'",
":",
"item",
"[",
"'zhihu_id'",
"]",
",",
"'user_type'",
":"... | https://github.com/LiuRoy/zhihu_spider/blob/8eb925d294689ad9ab13c1532fb7ba8c556b5ea7/zhihu/zhihu/pipelines.py#L57-L73 | ||
Tencent/bk-bcs-saas | 2b437bf2f5fd5ce2078f7787c3a12df609f7679d | bcs-app/backend/utils/local.py | python | Local.get_http_request_id | (self) | return new_request_id() | 从接入层获取request_id,或者生成一个新的request_id | 从接入层获取request_id,或者生成一个新的request_id | [
"从接入层获取request_id,或者生成一个新的request_id"
] | def get_http_request_id(self):
"""从接入层获取request_id,或者生成一个新的request_id"""
# 在从header中获取
request_id = self.request.META.get(settings.REQUEST_ID_HEADER, '')
if request_id:
return request_id
# 最后主动生成一个
return new_request_id() | [
"def",
"get_http_request_id",
"(",
"self",
")",
":",
"# 在从header中获取",
"request_id",
"=",
"self",
".",
"request",
".",
"META",
".",
"get",
"(",
"settings",
".",
"REQUEST_ID_HEADER",
",",
"''",
")",
"if",
"request_id",
":",
"return",
"request_id",
"# 最后主动生成一个",
... | https://github.com/Tencent/bk-bcs-saas/blob/2b437bf2f5fd5ce2078f7787c3a12df609f7679d/bcs-app/backend/utils/local.py#L65-L73 | |
log2timeline/plaso | fe2e316b8c76a0141760c0f2f181d84acb83abc2 | plaso/analysis/chrome_extension.py | python | ChromeExtensionPlugin._GetPathSegmentSeparator | (self, path) | return '/' | Given a path give back the path separator as a best guess.
Args:
path (str): path.
Returns:
str: path segment separator. | Given a path give back the path separator as a best guess. | [
"Given",
"a",
"path",
"give",
"back",
"the",
"path",
"separator",
"as",
"a",
"best",
"guess",
"."
] | def _GetPathSegmentSeparator(self, path):
"""Given a path give back the path separator as a best guess.
Args:
path (str): path.
Returns:
str: path segment separator.
"""
if path[0] in ('\\', '/'):
return path[0]
if path[1:].startswith(':\\'):
return '\\'
backward_... | [
"def",
"_GetPathSegmentSeparator",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"[",
"0",
"]",
"in",
"(",
"'\\\\'",
",",
"'/'",
")",
":",
"return",
"path",
"[",
"0",
"]",
"if",
"path",
"[",
"1",
":",
"]",
".",
"startswith",
"(",
"':\\\\'",
"... | https://github.com/log2timeline/plaso/blob/fe2e316b8c76a0141760c0f2f181d84acb83abc2/plaso/analysis/chrome_extension.py#L54-L74 | |
h5py/h5py | aa31f03bef99e5807d1d6381e36233325d944279 | h5py/_hl/files.py | python | register_driver | (name, set_fapl) | Register a custom driver.
Parameters
----------
name : str
The name of the driver.
set_fapl : callable[PropFAID, **kwargs] -> NoneType
The function to set the fapl to use your custom driver. | Register a custom driver. | [
"Register",
"a",
"custom",
"driver",
"."
] | def register_driver(name, set_fapl):
"""Register a custom driver.
Parameters
----------
name : str
The name of the driver.
set_fapl : callable[PropFAID, **kwargs] -> NoneType
The function to set the fapl to use your custom driver.
"""
_drivers[name] = set_fapl | [
"def",
"register_driver",
"(",
"name",
",",
"set_fapl",
")",
":",
"_drivers",
"[",
"name",
"]",
"=",
"set_fapl"
] | https://github.com/h5py/h5py/blob/aa31f03bef99e5807d1d6381e36233325d944279/h5py/_hl/files.py#L81-L91 | ||
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/encodings/cp720.py | python | IncrementalEncoder.encode | (self, input, final=False) | return codecs.charmap_encode(input,self.errors,encoding_table)[0] | [] | def encode(self, input, final=False):
return codecs.charmap_encode(input,self.errors,encoding_table)[0] | [
"def",
"encode",
"(",
"self",
",",
"input",
",",
"final",
"=",
"False",
")",
":",
"return",
"codecs",
".",
"charmap_encode",
"(",
"input",
",",
"self",
".",
"errors",
",",
"encoding_table",
")",
"[",
"0",
"]"
] | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/encodings/cp720.py#L20-L21 | |||
mjwestcott/Goodrich | dc2516591bd28488516c0337a62e64248debe47c | ch08/linked_binary_tree.py | python | LinkedBinaryTree._delete | (self, p) | return node._element | Delete the node at Position p, and replace it with its child, if any.
Return the element that had been stored at Position p.
Raise ValueError if Position p is invalid or p has two children. | Delete the node at Position p, and replace it with its child, if any. | [
"Delete",
"the",
"node",
"at",
"Position",
"p",
"and",
"replace",
"it",
"with",
"its",
"child",
"if",
"any",
"."
] | def _delete(self, p):
"""Delete the node at Position p, and replace it with its child, if any.
Return the element that had been stored at Position p.
Raise ValueError if Position p is invalid or p has two children.
"""
node = self._validate(p)
if self.num_children(p) == 2:
raise ValueErro... | [
"def",
"_delete",
"(",
"self",
",",
"p",
")",
":",
"node",
"=",
"self",
".",
"_validate",
"(",
"p",
")",
"if",
"self",
".",
"num_children",
"(",
"p",
")",
"==",
"2",
":",
"raise",
"ValueError",
"(",
"'Position has two children'",
")",
"child",
"=",
"... | https://github.com/mjwestcott/Goodrich/blob/dc2516591bd28488516c0337a62e64248debe47c/ch08/linked_binary_tree.py#L155-L177 | |
researchmm/tasn | 5dba8ccc096cedc63913730eeea14a9647911129 | tasn-mxnet/3rdparty/tvm/python/tvm/autotvm/database.py | python | Database.load | (self, inp, get_all=False) | Load a result based on an input's string key
Parameters
----------
inp: MeasureInput
to be translated into key for RedisDB
get_all: bool, optional
Whether the latest result (or all matching results) should be returned
Returns
-------
rec:... | Load a result based on an input's string key | [
"Load",
"a",
"result",
"based",
"on",
"an",
"input",
"s",
"string",
"key"
] | def load(self, inp, get_all=False):
"""
Load a result based on an input's string key
Parameters
----------
inp: MeasureInput
to be translated into key for RedisDB
get_all: bool, optional
Whether the latest result (or all matching results) should b... | [
"def",
"load",
"(",
"self",
",",
"inp",
",",
"get_all",
"=",
"False",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | https://github.com/researchmm/tasn/blob/5dba8ccc096cedc63913730eeea14a9647911129/tasn-mxnet/3rdparty/tvm/python/tvm/autotvm/database.py#L15-L30 | ||
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/shutil.py | python | _unpack_zipfile | (filename, extract_dir) | Unpack zip `filename` to `extract_dir` | Unpack zip `filename` to `extract_dir` | [
"Unpack",
"zip",
"filename",
"to",
"extract_dir"
] | def _unpack_zipfile(filename, extract_dir):
"""Unpack zip `filename` to `extract_dir`
"""
try:
import zipfile
except ImportError:
raise ReadError('zlib not supported, cannot unpack this archive.')
if not zipfile.is_zipfile(filename):
raise ReadError("%s is not a zip file" % ... | [
"def",
"_unpack_zipfile",
"(",
"filename",
",",
"extract_dir",
")",
":",
"try",
":",
"import",
"zipfile",
"except",
"ImportError",
":",
"raise",
"ReadError",
"(",
"'zlib not supported, cannot unpack this archive.'",
")",
"if",
"not",
"zipfile",
".",
"is_zipfile",
"(... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/shutil.py#L869-L904 | ||
simonw/sqlite-utils | e0c476bc380744680c8b7675c24fb0e9f5ec6dcd | sqlite_utils/db.py | python | Database.vacuum | (self) | Run a SQLite ``VACUUM`` against the database. | Run a SQLite ``VACUUM`` against the database. | [
"Run",
"a",
"SQLite",
"VACUUM",
"against",
"the",
"database",
"."
] | def vacuum(self):
"Run a SQLite ``VACUUM`` against the database."
self.execute("VACUUM;") | [
"def",
"vacuum",
"(",
"self",
")",
":",
"self",
".",
"execute",
"(",
"\"VACUUM;\"",
")"
] | https://github.com/simonw/sqlite-utils/blob/e0c476bc380744680c8b7675c24fb0e9f5ec6dcd/sqlite_utils/db.py#L922-L924 | ||
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/twisted/twisted/spread/pb.py | python | RemoteReference.callRemote | (self, _name, *args, **kw) | return self.broker._sendMessage('',self.perspective, self.luid,
_name, args, kw) | Asynchronously invoke a remote method.
@type _name: C{string}
@param _name: the name of the remote method to invoke
@param args: arguments to serialize for the remote function
@param kw: keyword arguments to serialize for the remote function.
@rtype: L{twisted.internet.def... | Asynchronously invoke a remote method. | [
"Asynchronously",
"invoke",
"a",
"remote",
"method",
"."
] | def callRemote(self, _name, *args, **kw):
"""Asynchronously invoke a remote method.
@type _name: C{string}
@param _name: the name of the remote method to invoke
@param args: arguments to serialize for the remote function
@param kw: keyword arguments to serialize for the remo... | [
"def",
"callRemote",
"(",
"self",
",",
"_name",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# note that we use '_name' instead of 'name' so the user can call",
"# remote methods with 'name' as a keyword parameter, like this:",
"# ref.callRemote(\"getPeopleNamed\", count=12, ... | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/twisted/twisted/spread/pb.py#L312-L328 | |
pypa/pip | 7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4 | src/pip/_internal/metadata/pkg_resources.py | python | Distribution.metadata | (self) | return feed_parser.close() | :raises NoneMetadataError: if the distribution reports `has_metadata()`
True but `get_metadata()` returns None. | :raises NoneMetadataError: if the distribution reports `has_metadata()`
True but `get_metadata()` returns None. | [
":",
"raises",
"NoneMetadataError",
":",
"if",
"the",
"distribution",
"reports",
"has_metadata",
"()",
"True",
"but",
"get_metadata",
"()",
"returns",
"None",
"."
] | def metadata(self) -> email.message.Message:
"""
:raises NoneMetadataError: if the distribution reports `has_metadata()`
True but `get_metadata()` returns None.
"""
if isinstance(self._dist, pkg_resources.DistInfoDistribution):
metadata_name = "METADATA"
e... | [
"def",
"metadata",
"(",
"self",
")",
"->",
"email",
".",
"message",
".",
"Message",
":",
"if",
"isinstance",
"(",
"self",
".",
"_dist",
",",
"pkg_resources",
".",
"DistInfoDistribution",
")",
":",
"metadata_name",
"=",
"\"METADATA\"",
"else",
":",
"metadata_... | https://github.com/pypa/pip/blob/7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4/src/pip/_internal/metadata/pkg_resources.py#L177-L197 | |
andresriancho/w3af | cd22e5252243a87aaa6d0ddea47cf58dacfe00a9 | w3af/plugins/attack/db/sqlmap/thirdparty/odict/odict.py | python | Keys.__call__ | (self) | return self._main._keys() | Pretend to be the keys method. | Pretend to be the keys method. | [
"Pretend",
"to",
"be",
"the",
"keys",
"method",
"."
] | def __call__(self):
"""Pretend to be the keys method."""
return self._main._keys() | [
"def",
"__call__",
"(",
"self",
")",
":",
"return",
"self",
".",
"_main",
".",
"_keys",
"(",
")"
] | https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/plugins/attack/db/sqlmap/thirdparty/odict/odict.py#L889-L891 | |
kennethreitz-archive/requests3 | 69eb662703b40db58fdc6c095d0fe130c56649bb | requests3/__init__.py | python | _check_cryptography | (cryptography_version: str) | [] | def _check_cryptography(cryptography_version: str) -> None:
# cryptography < 1.3.4
try:
cryptography_version = list(
map(int, cryptography_version.split("."))
) # type: ignore
except ValueError:
return
if cryptography_version < [1, 3, 4]:
warning = "Old vers... | [
"def",
"_check_cryptography",
"(",
"cryptography_version",
":",
"str",
")",
"->",
"None",
":",
"# cryptography < 1.3.4",
"try",
":",
"cryptography_version",
"=",
"list",
"(",
"map",
"(",
"int",
",",
"cryptography_version",
".",
"split",
"(",
"\".\"",
")",
")",
... | https://github.com/kennethreitz-archive/requests3/blob/69eb662703b40db58fdc6c095d0fe130c56649bb/requests3/__init__.py#L70-L83 | ||||
yahoo/lopq | 0f17655b901e6dfabe5c2aa62b4c8e492f34b05a | scripts/query_runtime.py | python | subquantizer_flops | (D, M, clusters=256) | return (M / 2) * (D / M) * clusters * 2 | Given the dimension of the data, the number of subquantizers and the
subquantizer vocabulary size, compute the number of flops to compute
a projected query's LOPQ distance for a single half of the query. | Given the dimension of the data, the number of subquantizers and the
subquantizer vocabulary size, compute the number of flops to compute
a projected query's LOPQ distance for a single half of the query. | [
"Given",
"the",
"dimension",
"of",
"the",
"data",
"the",
"number",
"of",
"subquantizers",
"and",
"the",
"subquantizer",
"vocabulary",
"size",
"compute",
"the",
"number",
"of",
"flops",
"to",
"compute",
"a",
"projected",
"query",
"s",
"LOPQ",
"distance",
"for",... | def subquantizer_flops(D, M, clusters=256):
"""
Given the dimension of the data, the number of subquantizers and the
subquantizer vocabulary size, compute the number of flops to compute
a projected query's LOPQ distance for a single half of the query.
"""
# (subquants per half) * (dims per subqu... | [
"def",
"subquantizer_flops",
"(",
"D",
",",
"M",
",",
"clusters",
"=",
"256",
")",
":",
"# (subquants per half) * (dims per subquant) * (cluster per subquant) * (flops per squared distance)",
"return",
"(",
"M",
"/",
"2",
")",
"*",
"(",
"D",
"/",
"M",
")",
"*",
"c... | https://github.com/yahoo/lopq/blob/0f17655b901e6dfabe5c2aa62b4c8e492f34b05a/scripts/query_runtime.py#L25-L32 | |
HCIILAB/DeRPN | 21e6738ee1f7d3f159ee48d435c543e773f8ce99 | tools/train_svms.py | python | SVMTrainer.train | (self) | [] | def train(self):
# Initialize SVMs using
# a. w_i = fc8_w_i - fc8_w_0
# b. b_i = fc8_b_i - fc8_b_0
# c. Install SVMs into net
self.initialize_net()
# Pass over roidb to count num positives for each class
# a. Pre-allocate arrays for positive feature vecto... | [
"def",
"train",
"(",
"self",
")",
":",
"# Initialize SVMs using",
"# a. w_i = fc8_w_i - fc8_w_0",
"# b. b_i = fc8_b_i - fc8_b_0",
"# c. Install SVMs into net",
"self",
".",
"initialize_net",
"(",
")",
"# Pass over roidb to count num positives for each class",
"# a. Pre-alloca... | https://github.com/HCIILAB/DeRPN/blob/21e6738ee1f7d3f159ee48d435c543e773f8ce99/tools/train_svms.py#L164-L190 | ||||
qiucheng025/zao- | 3a5edf3607b3a523f95746bc69b688090c76d89a | lib/face_filter.py | python | FaceFilter.get_filter_encodings | (self) | Return filter face encodings from Keras VGG Face | Return filter face encodings from Keras VGG Face | [
"Return",
"filter",
"face",
"encodings",
"from",
"Keras",
"VGG",
"Face"
] | def get_filter_encodings(self):
""" Return filter face encodings from Keras VGG Face """
for filename, face in self.filters.items():
logger.debug("Getting encodings for: '%s'", filename)
encodings = self.vgg_face.predict(face["face"])
logger.debug("Filter Filename: %s... | [
"def",
"get_filter_encodings",
"(",
"self",
")",
":",
"for",
"filename",
",",
"face",
"in",
"self",
".",
"filters",
".",
"items",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"Getting encodings for: '%s'\"",
",",
"filename",
")",
"encodings",
"=",
"self",
... | https://github.com/qiucheng025/zao-/blob/3a5edf3607b3a523f95746bc69b688090c76d89a/lib/face_filter.py#L116-L123 | ||
flennerhag/mlens | 6cbc11354b5f9500a33d9cefb700a1bba9d3199a | mlens/index/subsemble.py | python | SubsetIndex._gen_indices | (self) | Create generator for subsample.
Generate indices of training set and test set for
- each partition
- each fold in the partition
Note that the test index return is *global*, i.e. it contains the
test indices of that fold across partitions. See Examples for
furthe... | Create generator for subsample. | [
"Create",
"generator",
"for",
"subsample",
"."
] | def _gen_indices(self):
"""Create generator for subsample.
Generate indices of training set and test set for
- each partition
- each fold in the partition
Note that the test index return is *global*, i.e. it contains the
test indices of that fold across partitio... | [
"def",
"_gen_indices",
"(",
"self",
")",
":",
"partitions",
"=",
"self",
".",
"partitions",
"n_samples",
"=",
"self",
".",
"n_samples",
"folds",
"=",
"self",
".",
"folds",
"T",
"=",
"self",
".",
"_build_test_sets",
"(",
")",
"# For each partition, for each fol... | https://github.com/flennerhag/mlens/blob/6cbc11354b5f9500a33d9cefb700a1bba9d3199a/mlens/index/subsemble.py#L231-L274 | ||
dipy/dipy | be956a529465b28085f8fc435a756947ddee1c89 | dipy/io/stateful_tractogram.py | python | StatefulTractogram._vox_to_rasmm | (self) | Unsafe function to transform streamlines | Unsafe function to transform streamlines | [
"Unsafe",
"function",
"to",
"transform",
"streamlines"
] | def _vox_to_rasmm(self):
""" Unsafe function to transform streamlines """
if self._space == Space.VOX:
if self._tractogram.streamlines._data.size > 0:
self._tractogram.apply_affine(self._affine)
self._space = Space.RASMM
logger.debug('Moved str... | [
"def",
"_vox_to_rasmm",
"(",
"self",
")",
":",
"if",
"self",
".",
"_space",
"==",
"Space",
".",
"VOX",
":",
"if",
"self",
".",
"_tractogram",
".",
"streamlines",
".",
"_data",
".",
"size",
">",
"0",
":",
"self",
".",
"_tractogram",
".",
"apply_affine",... | https://github.com/dipy/dipy/blob/be956a529465b28085f8fc435a756947ddee1c89/dipy/io/stateful_tractogram.py#L603-L612 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/uptimerobot/__init__.py | python | UptimeRobotDataUpdateCoordinator.__init__ | (
self,
hass: HomeAssistant,
config_entry_id: str,
dev_reg: DeviceRegistry,
api: UptimeRobot,
) | Initialize coordinator. | Initialize coordinator. | [
"Initialize",
"coordinator",
"."
] | def __init__(
self,
hass: HomeAssistant,
config_entry_id: str,
dev_reg: DeviceRegistry,
api: UptimeRobot,
) -> None:
"""Initialize coordinator."""
super().__init__(
hass,
LOGGER,
name=DOMAIN,
update_method=self._... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"config_entry_id",
":",
"str",
",",
"dev_reg",
":",
"DeviceRegistry",
",",
"api",
":",
"UptimeRobot",
",",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/uptimerobot/__init__.py#L60-L77 | ||
graphcore/examples | 46d2b7687b829778369fc6328170a7b14761e5c6 | applications/tensorflow/cnns/inference/models/tf_layers.py | python | crop | (input_tensor: tf.Tensor, cropping: Tuple[Tuple[int, int], Tuple[int, int]]) | return input_tensor[:, cropping[0][0]:rows - cropping[0][1], cropping[1][0]:cols - cropping[1][1], :] | Crop input along width and height dimensions, assumes channels_last.
Args:
input_tensor: Input to be cropped.
cropping: Start and stop index along height and width.
Returns: Cropped tensor. | Crop input along width and height dimensions, assumes channels_last. | [
"Crop",
"input",
"along",
"width",
"and",
"height",
"dimensions",
"assumes",
"channels_last",
"."
] | def crop(input_tensor: tf.Tensor, cropping: Tuple[Tuple[int, int], Tuple[int, int]]):
"""Crop input along width and height dimensions, assumes channels_last.
Args:
input_tensor: Input to be cropped.
cropping: Start and stop index along height and width.
Returns: Cropped tensor.
"""
... | [
"def",
"crop",
"(",
"input_tensor",
":",
"tf",
".",
"Tensor",
",",
"cropping",
":",
"Tuple",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
",",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
")",
":",
"_",
",",
"rows",
",",
"cols",
",",
"_",
"=",
"i... | https://github.com/graphcore/examples/blob/46d2b7687b829778369fc6328170a7b14761e5c6/applications/tensorflow/cnns/inference/models/tf_layers.py#L478-L488 | |
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/distutils/command/sdist.py | python | sdist.add_defaults | (self) | Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as... | Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as... | [
"Add",
"all",
"the",
"default",
"files",
"to",
"self",
".",
"filelist",
":",
"-",
"README",
"or",
"README",
".",
"txt",
"-",
"setup",
".",
"py",
"-",
"test",
"/",
"test",
"*",
".",
"py",
"-",
"all",
"pure",
"Python",
"modules",
"mentioned",
"in",
"... | def add_defaults(self):
"""Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_file... | [
"def",
"add_defaults",
"(",
"self",
")",
":",
"standards",
"=",
"[",
"(",
"'README'",
",",
"'README.txt'",
")",
",",
"self",
".",
"distribution",
".",
"script_name",
"]",
"for",
"fn",
"in",
"standards",
":",
"if",
"isinstance",
"(",
"fn",
",",
"tuple",
... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/distutils/command/sdist.py#L218-L298 | ||
IlyaSkriblovsky/txredisapi | c89a49829d1c48baa10d03c41d39c261c02ad6e1 | txredisapi.py | python | BaseRedisProtocol.lindex | (self, key, index) | return self.execute_command("LINDEX", key, index) | Return the element at index position from the List at key | Return the element at index position from the List at key | [
"Return",
"the",
"element",
"at",
"index",
"position",
"from",
"the",
"List",
"at",
"key"
] | def lindex(self, key, index):
"""
Return the element at index position from the List at key
"""
return self.execute_command("LINDEX", key, index) | [
"def",
"lindex",
"(",
"self",
",",
"key",
",",
"index",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"\"LINDEX\"",
",",
"key",
",",
"index",
")"
] | https://github.com/IlyaSkriblovsky/txredisapi/blob/c89a49829d1c48baa10d03c41d39c261c02ad6e1/txredisapi.py#L988-L992 | |
Abjad/abjad | d0646dfbe83db3dc5ab268f76a0950712b87b7fd | abjad/indicators/StartPianoPedal.py | python | StartPianoPedal.tweaks | (self) | return self._tweaks | r"""
Gets tweaks
.. container:: example
REGRESSION. Tweaks survive copy:
>>> import copy
>>> start_piano_pedal = abjad.StartPianoPedal()
>>> abjad.tweak(start_piano_pedal).color = "#blue"
>>> string = abjad.storage(start_piano_pedal)
... | r"""
Gets tweaks | [
"r",
"Gets",
"tweaks"
] | def tweaks(self) -> typing.Optional[_overrides.TweakInterface]:
r"""
Gets tweaks
.. container:: example
REGRESSION. Tweaks survive copy:
>>> import copy
>>> start_piano_pedal = abjad.StartPianoPedal()
>>> abjad.tweak(start_piano_pedal).color = ... | [
"def",
"tweaks",
"(",
"self",
")",
"->",
"typing",
".",
"Optional",
"[",
"_overrides",
".",
"TweakInterface",
"]",
":",
"return",
"self",
".",
"_tweaks"
] | https://github.com/Abjad/abjad/blob/d0646dfbe83db3dc5ab268f76a0950712b87b7fd/abjad/indicators/StartPianoPedal.py#L135-L160 | |
barseghyanartur/django-fobi | a998feae007d7fe3637429a80e42952ec7cda79f | src/fobi/contrib/plugins/form_elements/content/content_text/base.py | python | ContentTextPlugin.get_rendered_text | (self) | return rendered_text | Get rendered text. | Get rendered text. | [
"Get",
"rendered",
"text",
"."
] | def get_rendered_text(self):
"""Get rendered text."""
rendered_text = "<p>{0}</p>".format(smart_str(self.data.text))
return rendered_text | [
"def",
"get_rendered_text",
"(",
"self",
")",
":",
"rendered_text",
"=",
"\"<p>{0}</p>\"",
".",
"format",
"(",
"smart_str",
"(",
"self",
".",
"data",
".",
"text",
")",
")",
"return",
"rendered_text"
] | https://github.com/barseghyanartur/django-fobi/blob/a998feae007d7fe3637429a80e42952ec7cda79f/src/fobi/contrib/plugins/form_elements/content/content_text/base.py#L49-L52 | |
luispedro/jug | e967c6388ca69c78698e1522b9535d647a2c5b22 | jug/hooks/exit_checks.py | python | exit_after_n_tasks | (n) | Exit after a specific number of tasks have been executed
Parameters
----------
n : int
Number of tasks to execute | Exit after a specific number of tasks have been executed | [
"Exit",
"after",
"a",
"specific",
"number",
"of",
"tasks",
"have",
"been",
"executed"
] | def exit_after_n_tasks(n):
'''Exit after a specific number of tasks have been executed
Parameters
----------
n : int
Number of tasks to execute
'''
from jug import hooks
# In newer Python, we could use nonlocal, but this is a work around
# (http://stackoverflow.com/questions/960... | [
"def",
"exit_after_n_tasks",
"(",
"n",
")",
":",
"from",
"jug",
"import",
"hooks",
"# In newer Python, we could use nonlocal, but this is a work around",
"# (http://stackoverflow.com/questions/9603278/is-there-something-like-nonlocal-in-python-3/9603491#9603491)",
"executed",
"=",
"[",
... | https://github.com/luispedro/jug/blob/e967c6388ca69c78698e1522b9535d647a2c5b22/jug/hooks/exit_checks.py#L42-L59 | ||
lsbardel/python-stdnet | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | stdnet/odm/fields.py | python | JSONField.set_get_value | (self, instance, value) | [] | def set_get_value(self, instance, value):
# Optimisation, avoid to call serialise since it is the same
# as to_python
value = self.to_python(value)
setattr(instance, self.attname, value)
if self.as_string:
# dump as a string
return self.serialise(value)
... | [
"def",
"set_get_value",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"# Optimisation, avoid to call serialise since it is the same",
"# as to_python",
"value",
"=",
"self",
".",
"to_python",
"(",
"value",
")",
"setattr",
"(",
"instance",
",",
"self",
".",
... | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/fields.py#L770-L793 | ||||
nerdvegas/rez | d392c65bf63b4bca8106f938cec49144ba54e770 | src/rez/rex.py | python | RexExecutor.compile_code | (cls, code, filename=None, exec_namespace=None) | return pyc | Compile and possibly execute rex code.
Args:
code (str or SourceCode): The python code to compile.
filename (str): File to associate with the code, will default to
'<string>'.
exec_namespace (dict): Namespace to execute the code in. If None,
t... | Compile and possibly execute rex code. | [
"Compile",
"and",
"possibly",
"execute",
"rex",
"code",
"."
] | def compile_code(cls, code, filename=None, exec_namespace=None):
"""Compile and possibly execute rex code.
Args:
code (str or SourceCode): The python code to compile.
filename (str): File to associate with the code, will default to
'<string>'.
exec_na... | [
"def",
"compile_code",
"(",
"cls",
",",
"code",
",",
"filename",
"=",
"None",
",",
"exec_namespace",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"if",
"isinstance",
"(",
"code",
",",
"SourceCode",
")",
":",
"filename",
"=",
"code",
".",... | https://github.com/nerdvegas/rez/blob/d392c65bf63b4bca8106f938cec49144ba54e770/src/rez/rex.py#L1316-L1364 | |
seopbo/nlp_classification | 21ea6e3f5737e7074bdd8dd190e5f5172f86f6bf | Efficient_Character-level_Document_Classification_by_Combining_Convolution_and_Recurrent_Layers/model/data.py | python | batchify | (data: List[Tuple[torch.Tensor, torch.Tensor]]) | return indices, labels | custom collate_fn for DataLoader
Args:
data (list): list of torch.Tensors
Returns:
data (tuple): tuple of torch.Tensors | custom collate_fn for DataLoader | [
"custom",
"collate_fn",
"for",
"DataLoader"
] | def batchify(data: List[Tuple[torch.Tensor, torch.Tensor]]) -> Tuple[torch.Tensor, torch.Tensor]:
"""custom collate_fn for DataLoader
Args:
data (list): list of torch.Tensors
Returns:
data (tuple): tuple of torch.Tensors
"""
indices, labels = zip(*data)
indices = pad_sequence(i... | [
"def",
"batchify",
"(",
"data",
":",
"List",
"[",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
"]",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"indices",
",",
"labels",
"=",
... | https://github.com/seopbo/nlp_classification/blob/21ea6e3f5737e7074bdd8dd190e5f5172f86f6bf/Efficient_Character-level_Document_Classification_by_Combining_Convolution_and_Recurrent_Layers/model/data.py#L38-L50 | |
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.4/django/views/csrf.py | python | csrf_failure | (request, reason="") | return HttpResponseForbidden(t.render(c), mimetype='text/html') | Default view used when request fails CSRF protection | Default view used when request fails CSRF protection | [
"Default",
"view",
"used",
"when",
"request",
"fails",
"CSRF",
"protection"
] | def csrf_failure(request, reason=""):
"""
Default view used when request fails CSRF protection
"""
from django.middleware.csrf import REASON_NO_REFERER
t = Template(CSRF_FAILURE_TEMPLATE)
c = Context({'DEBUG': settings.DEBUG,
'reason': reason,
'no_referer': reas... | [
"def",
"csrf_failure",
"(",
"request",
",",
"reason",
"=",
"\"\"",
")",
":",
"from",
"django",
".",
"middleware",
".",
"csrf",
"import",
"REASON_NO_REFERER",
"t",
"=",
"Template",
"(",
"CSRF_FAILURE_TEMPLATE",
")",
"c",
"=",
"Context",
"(",
"{",
"'DEBUG'",
... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.4/django/views/csrf.py#L94-L104 | |
cjdrake/pyeda | 554ee53aa678f4b61bcd7e07ba2c74ddc749d665 | pyeda/parsing/dimacs.py | python | parse_cnf | (s, varname='x') | return ast | Parse an input string in DIMACS CNF format,
and return an expression abstract syntax tree.
Parameters
----------
s : str
String containing a DIMACS CNF.
varname : str, optional
The variable name used for creating literals.
Defaults to 'x'.
Returns
-------
An as... | Parse an input string in DIMACS CNF format,
and return an expression abstract syntax tree. | [
"Parse",
"an",
"input",
"string",
"in",
"DIMACS",
"CNF",
"format",
"and",
"return",
"an",
"expression",
"abstract",
"syntax",
"tree",
"."
] | def parse_cnf(s, varname='x'):
"""
Parse an input string in DIMACS CNF format,
and return an expression abstract syntax tree.
Parameters
----------
s : str
String containing a DIMACS CNF.
varname : str, optional
The variable name used for creating literals.
Defaults... | [
"def",
"parse_cnf",
"(",
"s",
",",
"varname",
"=",
"'x'",
")",
":",
"lexer",
"=",
"iter",
"(",
"CNFLexer",
"(",
"s",
")",
")",
"try",
":",
"ast",
"=",
"_cnf",
"(",
"lexer",
",",
"varname",
")",
"except",
"lex",
".",
"RunError",
"as",
"exc",
":",
... | https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/parsing/dimacs.py#L143-L181 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/urllib/request.py | python | HTTPPasswordMgr.reduce_uri | (self, uri, default_port=True) | return authority, path | Accept authority or URI and extract only the authority and path. | Accept authority or URI and extract only the authority and path. | [
"Accept",
"authority",
"or",
"URI",
"and",
"extract",
"only",
"the",
"authority",
"and",
"path",
"."
] | def reduce_uri(self, uri, default_port=True):
"""Accept authority or URI and extract only the authority and path."""
# note HTTP URLs do not have a userinfo component
parts = urlsplit(uri)
if parts[1]:
# URI
scheme = parts[0]
authority = parts[1]
... | [
"def",
"reduce_uri",
"(",
"self",
",",
"uri",
",",
"default_port",
"=",
"True",
")",
":",
"# note HTTP URLs do not have a userinfo component",
"parts",
"=",
"urlsplit",
"(",
"uri",
")",
"if",
"parts",
"[",
"1",
"]",
":",
"# URI",
"scheme",
"=",
"parts",
"[",... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/urllib/request.py#L861-L882 | |
NVlabs/noise2noise | 7355519e7bfc49e0606cca8867748e736431244b | dnnlib/tflib/autosummary.py | python | autosummary | (name: str, value: TfExpressionEx) | Create a new autosummary. | Create a new autosummary. | [
"Create",
"a",
"new",
"autosummary",
"."
] | def autosummary(name: str, value: TfExpressionEx) -> TfExpressionEx:
"""Create a new autosummary."""
tfutil.assert_tf_initialized()
name_id = name.replace("/", "_")
if tfutil.is_tf_expression(value):
with tf.name_scope("summary_" + name_id), tf.device(value.device):
update_op = _cre... | [
"def",
"autosummary",
"(",
"name",
":",
"str",
",",
"value",
":",
"TfExpressionEx",
")",
"->",
"TfExpressionEx",
":",
"tfutil",
".",
"assert_tf_initialized",
"(",
")",
"name_id",
"=",
"name",
".",
"replace",
"(",
"\"/\"",
",",
"\"_\"",
")",
"if",
"tfutil",... | https://github.com/NVlabs/noise2noise/blob/7355519e7bfc49e0606cca8867748e736431244b/dnnlib/tflib/autosummary.py#L74-L94 | ||
awesto/django-shop | 13d9a77aff7eede74a5f363c1d540e005d88dbcd | shop/templatetags/shop_tags.py | python | from_iso8601 | (value) | [] | def from_iso8601(value):
try:
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ")
except ValueError:
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ") | [
"def",
"from_iso8601",
"(",
"value",
")",
":",
"try",
":",
"return",
"datetime",
".",
"strptime",
"(",
"value",
",",
"\"%Y-%m-%dT%H:%M:%S.%fZ\"",
")",
"except",
"ValueError",
":",
"return",
"datetime",
".",
"strptime",
"(",
"value",
",",
"\"%Y-%m-%dT%H:%M:%SZ\""... | https://github.com/awesto/django-shop/blob/13d9a77aff7eede74a5f363c1d540e005d88dbcd/shop/templatetags/shop_tags.py#L65-L69 | ||||
uqfoundation/mystic | 154e6302d1f2f94e8f13e88ecc5f24241cc28ac7 | mystic/math/legacydata.py | python | lipschitzcone.contains | (self, point) | return abs(y - G) <= self.distance(point) | return True if a given point is within the cone | return True if a given point is within the cone | [
"return",
"True",
"if",
"a",
"given",
"point",
"is",
"within",
"the",
"cone"
] | def contains(self, point):
""" return True if a given point is within the cone """
L = self.slopes
if any([i == NULLSLOPE for i in L]): return True
x = point.position
Z = self.vertex.position
if all([x[i] == Z[i] for i in range(len(x))]): return True
y = point.value
G = self.vertex.value... | [
"def",
"contains",
"(",
"self",
",",
"point",
")",
":",
"L",
"=",
"self",
".",
"slopes",
"if",
"any",
"(",
"[",
"i",
"==",
"NULLSLOPE",
"for",
"i",
"in",
"L",
"]",
")",
":",
"return",
"True",
"x",
"=",
"point",
".",
"position",
"Z",
"=",
"self"... | https://github.com/uqfoundation/mystic/blob/154e6302d1f2f94e8f13e88ecc5f24241cc28ac7/mystic/math/legacydata.py#L60-L69 | |
wistbean/learn_python3_spider | 73c873f4845f4385f097e5057407d03dd37a117b | stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/distlib/database.py | python | _Cache.add | (self, dist) | Add a distribution to the cache.
:param dist: The distribution to add. | Add a distribution to the cache.
:param dist: The distribution to add. | [
"Add",
"a",
"distribution",
"to",
"the",
"cache",
".",
":",
"param",
"dist",
":",
"The",
"distribution",
"to",
"add",
"."
] | def add(self, dist):
"""
Add a distribution to the cache.
:param dist: The distribution to add.
"""
if dist.path not in self.path:
self.path[dist.path] = dist
self.name.setdefault(dist.key, []).append(dist) | [
"def",
"add",
"(",
"self",
",",
"dist",
")",
":",
"if",
"dist",
".",
"path",
"not",
"in",
"self",
".",
"path",
":",
"self",
".",
"path",
"[",
"dist",
".",
"path",
"]",
"=",
"dist",
"self",
".",
"name",
".",
"setdefault",
"(",
"dist",
".",
"key"... | https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/distlib/database.py#L65-L72 | ||
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/tbm/v20180129/tbm_client.py | python | TbmClient.DescribeBrandMediaReport | (self, request) | 监测品牌关键词出现在媒体网站(新闻媒体、网络门户、政府网站、微信公众号、天天快报等)发布资讯标题和正文中的报道数。按天输出结果。
:param request: Request instance for DescribeBrandMediaReport.
:type request: :class:`tencentcloud.tbm.v20180129.models.DescribeBrandMediaReportRequest`
:rtype: :class:`tencentcloud.tbm.v20180129.models.DescribeBrandMediaReportRes... | 监测品牌关键词出现在媒体网站(新闻媒体、网络门户、政府网站、微信公众号、天天快报等)发布资讯标题和正文中的报道数。按天输出结果。 | [
"监测品牌关键词出现在媒体网站(新闻媒体、网络门户、政府网站、微信公众号、天天快报等)发布资讯标题和正文中的报道数。按天输出结果。"
] | def DescribeBrandMediaReport(self, request):
"""监测品牌关键词出现在媒体网站(新闻媒体、网络门户、政府网站、微信公众号、天天快报等)发布资讯标题和正文中的报道数。按天输出结果。
:param request: Request instance for DescribeBrandMediaReport.
:type request: :class:`tencentcloud.tbm.v20180129.models.DescribeBrandMediaReportRequest`
:rtype: :class:`tence... | [
"def",
"DescribeBrandMediaReport",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"params",
"=",
"request",
".",
"_serialize",
"(",
")",
"body",
"=",
"self",
".",
"call",
"(",
"\"DescribeBrandMediaReport\"",
",",
"params",
")",
"response",
"=",
"json",
... | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tbm/v20180129/tbm_client.py#L85-L110 | ||
stevearc/flywheel | ac6eea314f6d88b593cf809336d8723df0b78f6f | flywheel/models.py | python | Model.cached_ | (self, name, default=None) | return field.get_cached_value(self) | Get the cached (server) value of a field | Get the cached (server) value of a field | [
"Get",
"the",
"cached",
"(",
"server",
")",
"value",
"of",
"a",
"field"
] | def cached_(self, name, default=None):
""" Get the cached (server) value of a field """
if not self.persisted_:
return default
if name in self.__cache__:
return self.__cache__[name]
field = self.meta_.fields.get(name)
# Need this redirection for Composite ... | [
"def",
"cached_",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"persisted_",
":",
"return",
"default",
"if",
"name",
"in",
"self",
".",
"__cache__",
":",
"return",
"self",
".",
"__cache__",
"[",
"name",
"... | https://github.com/stevearc/flywheel/blob/ac6eea314f6d88b593cf809336d8723df0b78f6f/flywheel/models.py#L304-L312 | |
pyparallel/pyparallel | 11e8c6072d48c8f13641925d17b147bf36ee0ba3 | Lib/site-packages/pip-7.1.2-py3.3.egg/pip/download.py | python | get_file_content | (url, comes_from=None, session=None) | return url, content | Gets the content of a file; it may be a filename, file: URL, or
http: URL. Returns (location, content). Content is unicode. | Gets the content of a file; it may be a filename, file: URL, or
http: URL. Returns (location, content). Content is unicode. | [
"Gets",
"the",
"content",
"of",
"a",
"file",
";",
"it",
"may",
"be",
"a",
"filename",
"file",
":",
"URL",
"or",
"http",
":",
"URL",
".",
"Returns",
"(",
"location",
"content",
")",
".",
"Content",
"is",
"unicode",
"."
] | def get_file_content(url, comes_from=None, session=None):
"""Gets the content of a file; it may be a filename, file: URL, or
http: URL. Returns (location, content). Content is unicode."""
if session is None:
raise TypeError(
"get_file_content() missing 1 required keyword argument: 'ses... | [
"def",
"get_file_content",
"(",
"url",
",",
"comes_from",
"=",
"None",
",",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"get_file_content() missing 1 required keyword argument: 'session'\"",
")",
"match",
"=",
... | https://github.com/pyparallel/pyparallel/blob/11e8c6072d48c8f13641925d17b147bf36ee0ba3/Lib/site-packages/pip-7.1.2-py3.3.egg/pip/download.py#L376-L418 | |
exaile/exaile | a7b58996c5c15b3aa7b9975ac13ee8f784ef4689 | xlgui/widgets/dialogs.py | python | error | (parent, message=None, markup=None) | Shows an error dialog | Shows an error dialog | [
"Shows",
"an",
"error",
"dialog"
] | def error(parent, message=None, markup=None):
"""
Shows an error dialog
"""
if message is markup is None:
raise ValueError("message or markup must be specified")
dialog = Gtk.MessageDialog(
buttons=Gtk.ButtonsType.CLOSE,
message_type=Gtk.MessageType.ERROR,
modal=True,... | [
"def",
"error",
"(",
"parent",
",",
"message",
"=",
"None",
",",
"markup",
"=",
"None",
")",
":",
"if",
"message",
"is",
"markup",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"message or markup must be specified\"",
")",
"dialog",
"=",
"Gtk",
".",
"Me... | https://github.com/exaile/exaile/blob/a7b58996c5c15b3aa7b9975ac13ee8f784ef4689/xlgui/widgets/dialogs.py#L54-L71 | ||
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/video/v1/composition_hook.py | python | CompositionHookInstance.trim | (self) | return self._properties['trim'] | :returns: Whether intervals with no media are clipped
:rtype: bool | :returns: Whether intervals with no media are clipped
:rtype: bool | [
":",
"returns",
":",
"Whether",
"intervals",
"with",
"no",
"media",
"are",
"clipped",
":",
"rtype",
":",
"bool"
] | def trim(self):
"""
:returns: Whether intervals with no media are clipped
:rtype: bool
"""
return self._properties['trim'] | [
"def",
"trim",
"(",
"self",
")",
":",
"return",
"self",
".",
"_properties",
"[",
"'trim'",
"]"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/video/v1/composition_hook.py#L479-L484 | |
plasma-umass/scalene | e5d1c4d8cac49d0caa43e1a2c3898a3720071913 | scalene/leak_analysis.py | python | zlog | (x: float) | Redefine log so that if x is <= 0, log x is 0. | Redefine log so that if x is <= 0, log x is 0. | [
"Redefine",
"log",
"so",
"that",
"if",
"x",
"is",
"<",
"=",
"0",
"log",
"x",
"is",
"0",
"."
] | def zlog(x: float) -> float:
"""Redefine log so that if x is <= 0, log x is 0."""
if x <= 0:
return 0
else:
return math.log(x) | [
"def",
"zlog",
"(",
"x",
":",
"float",
")",
"->",
"float",
":",
"if",
"x",
"<=",
"0",
":",
"return",
"0",
"else",
":",
"return",
"math",
".",
"log",
"(",
"x",
")"
] | https://github.com/plasma-umass/scalene/blob/e5d1c4d8cac49d0caa43e1a2c3898a3720071913/scalene/leak_analysis.py#L10-L15 | ||
vispy/vispy | 26256fdc2574259dd227022fbce0767cae4e244b | vispy/gloo/glir.py | python | GlirProgram._get_active_attributes_and_uniforms | (self) | return set([v[0] for v in attributes] + [v[0] for v in uniforms]) | Retrieve active attributes and uniforms to be able to check that
all uniforms/attributes are set by the user.
Other GLIR implementations may omit this. | Retrieve active attributes and uniforms to be able to check that
all uniforms/attributes are set by the user.
Other GLIR implementations may omit this. | [
"Retrieve",
"active",
"attributes",
"and",
"uniforms",
"to",
"be",
"able",
"to",
"check",
"that",
"all",
"uniforms",
"/",
"attributes",
"are",
"set",
"by",
"the",
"user",
".",
"Other",
"GLIR",
"implementations",
"may",
"omit",
"this",
"."
] | def _get_active_attributes_and_uniforms(self):
"""Retrieve active attributes and uniforms to be able to check that
all uniforms/attributes are set by the user.
Other GLIR implementations may omit this.
"""
# This match a name of the form "name[size]" (= array)
regex = re.... | [
"def",
"_get_active_attributes_and_uniforms",
"(",
"self",
")",
":",
"# This match a name of the form \"name[size]\" (= array)",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"\"\"(?P<name>\\w+)\\s*(\\[(?P<size>\\d+)\\])\\s*\"\"\"",
")",
"# Get how many active attributes and uniforms the... | https://github.com/vispy/vispy/blob/26256fdc2574259dd227022fbce0767cae4e244b/vispy/gloo/glir.py#L1124-L1149 | |
fonttools/fonttools | 892322aaff6a89bea5927379ec06bc0da3dfb7df | Lib/fontTools/varLib/instancer/names.py | python | _updateNameTableStyleRecords | (
varfont,
familyNameSuffix,
subFamilyName,
typoSubFamilyName,
platformID=3,
platEncID=1,
langID=0x409,
) | [] | def _updateNameTableStyleRecords(
varfont,
familyNameSuffix,
subFamilyName,
typoSubFamilyName,
platformID=3,
platEncID=1,
langID=0x409,
):
# TODO (Marc F) It may be nice to make this part a standalone
# font renamer in the future.
nametable = varfont["name"]
platform = (platf... | [
"def",
"_updateNameTableStyleRecords",
"(",
"varfont",
",",
"familyNameSuffix",
",",
"subFamilyName",
",",
"typoSubFamilyName",
",",
"platformID",
"=",
"3",
",",
"platEncID",
"=",
"1",
",",
"langID",
"=",
"0x409",
",",
")",
":",
"# TODO (Marc F) It may be nice to ma... | https://github.com/fonttools/fonttools/blob/892322aaff6a89bea5927379ec06bc0da3dfb7df/Lib/fontTools/varLib/instancer/names.py#L252-L318 | ||||
FederatedAI/FATE | 32540492623568ecd1afcb367360133616e02fa3 | python/fate_arch/storage/_table.py | python | StorageTableMeta.get_engine | (self) | return self.engine | [] | def get_engine(self):
return self.engine | [
"def",
"get_engine",
"(",
"self",
")",
":",
"return",
"self",
".",
"engine"
] | https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/fate_arch/storage/_table.py#L352-L353 | |||
DataDog/integrations-core | 934674b29d94b70ccc008f76ea172d0cdae05e1e | mesos_master/datadog_checks/mesos_master/config_models/defaults.py | python | instance_kerberos_hostname | (field, value) | return get_default_field_value(field, value) | [] | def instance_kerberos_hostname(field, value):
return get_default_field_value(field, value) | [
"def",
"instance_kerberos_hostname",
"(",
"field",
",",
"value",
")",
":",
"return",
"get_default_field_value",
"(",
"field",
",",
"value",
")"
] | https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/mesos_master/datadog_checks/mesos_master/config_models/defaults.py#L89-L90 | |||
ldx/python-iptables | 542efdb739b4e3ef6f28274d23b506bf0027eec2 | iptc/xtables.py | python | xtables._fcheck_match_old | (self, match) | [] | def _fcheck_match_old(self, match):
# old API
if not match.final_check:
return
rv = _wrap_uintfn(match.final_check, match.mflags)
if rv:
raise XTablesError("%s.final_check() has failed" %
(match.name)) | [
"def",
"_fcheck_match_old",
"(",
"self",
",",
"match",
")",
":",
"# old API",
"if",
"not",
"match",
".",
"final_check",
":",
"return",
"rv",
"=",
"_wrap_uintfn",
"(",
"match",
".",
"final_check",
",",
"match",
".",
"mflags",
")",
"if",
"rv",
":",
"raise"... | https://github.com/ldx/python-iptables/blob/542efdb739b4e3ef6f28274d23b506bf0027eec2/iptc/xtables.py#L1222-L1229 | ||||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/requests/utils.py | python | urldefragauth | (url) | return urlunparse((scheme, netloc, path, params, query, '')) | Given a url remove the fragment and the authentication part.
:rtype: str | Given a url remove the fragment and the authentication part. | [
"Given",
"a",
"url",
"remove",
"the",
"fragment",
"and",
"the",
"authentication",
"part",
"."
] | def urldefragauth(url):
"""
Given a url remove the fragment and the authentication part.
:rtype: str
"""
scheme, netloc, path, params, query, fragment = urlparse(url)
# see func:`prepend_scheme_if_needed`
if not netloc:
netloc, path = path, netloc
netloc = netloc.rsplit('@', 1... | [
"def",
"urldefragauth",
"(",
"url",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"urlparse",
"(",
"url",
")",
"# see func:`prepend_scheme_if_needed`",
"if",
"not",
"netloc",
":",
"netloc",
",",
"path",
... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/requests/utils.py#L948-L962 | |
dingjiansw101/AerialDetection | fbb7726bc0c6898fc00e50a418a3f5e0838b30d4 | DOTA_devkit/ImgSplit_multi_process.py | python | splitbase.__init__ | (self,
basepath,
outpath,
code = 'utf-8',
gap=512,
subsize=1024,
thresh=0.7,
choosebestpoint=True,
ext = '.png',
padding=True,
num_process=8
... | :param basepath: base path for dota data
:param outpath: output base path for dota data,
the basepath and outputpath have the similar subdirectory, 'images' and 'labelTxt'
:param code: encodeing format of txt file
:param gap: overlap between two patches
:param subsize: subsize of... | :param basepath: base path for dota data
:param outpath: output base path for dota data,
the basepath and outputpath have the similar subdirectory, 'images' and 'labelTxt'
:param code: encodeing format of txt file
:param gap: overlap between two patches
:param subsize: subsize of... | [
":",
"param",
"basepath",
":",
"base",
"path",
"for",
"dota",
"data",
":",
"param",
"outpath",
":",
"output",
"base",
"path",
"for",
"dota",
"data",
"the",
"basepath",
"and",
"outputpath",
"have",
"the",
"similar",
"subdirectory",
"images",
"and",
"labelTxt"... | def __init__(self,
basepath,
outpath,
code = 'utf-8',
gap=512,
subsize=1024,
thresh=0.7,
choosebestpoint=True,
ext = '.png',
padding=True,
num_process... | [
"def",
"__init__",
"(",
"self",
",",
"basepath",
",",
"outpath",
",",
"code",
"=",
"'utf-8'",
",",
"gap",
"=",
"512",
",",
"subsize",
"=",
"1024",
",",
"thresh",
"=",
"0.7",
",",
"choosebestpoint",
"=",
"True",
",",
"ext",
"=",
"'.png'",
",",
"paddin... | https://github.com/dingjiansw101/AerialDetection/blob/fbb7726bc0c6898fc00e50a418a3f5e0838b30d4/DOTA_devkit/ImgSplit_multi_process.py#L43-L91 | ||
asyml/texar | a23f021dae289a3d768dc099b220952111da04fd | texar/tf/core/layers.py | python | gelu | (input_tensor) | return input_tensor * cdf | Gaussian Error Linear Unit.
This is a smoother version of the RELU.
Original paper: https://arxiv.org/abs/1606.08415
Args:
input_tensor: float Tensor to perform activation.
Returns:
`input_tensor` with the GELU activation applied. | Gaussian Error Linear Unit. | [
"Gaussian",
"Error",
"Linear",
"Unit",
"."
] | def gelu(input_tensor):
"""Gaussian Error Linear Unit.
This is a smoother version of the RELU.
Original paper: https://arxiv.org/abs/1606.08415
Args:
input_tensor: float Tensor to perform activation.
Returns:
`input_tensor` with the GELU activation applied.
"""
cdf = 0.5 * (1.... | [
"def",
"gelu",
"(",
"input_tensor",
")",
":",
"cdf",
"=",
"0.5",
"*",
"(",
"1.0",
"+",
"tf",
".",
"erf",
"(",
"input_tensor",
"/",
"tf",
".",
"sqrt",
"(",
"2.0",
")",
")",
")",
"return",
"input_tensor",
"*",
"cdf"
] | https://github.com/asyml/texar/blob/a23f021dae289a3d768dc099b220952111da04fd/texar/tf/core/layers.py#L1250-L1263 | |
mozilla-services/socorro | 8bff4a90e9e3320eabe7e067adbe0e89f6a39ba7 | bin/permadelete_crash_data.py | python | cmd_permadelete | (ctx, crashidsfile) | Permanently deletes crash report data from crash storage.
The crashidsfile should be a complete path to the file with
crashids in it--one per line. This will skip lines prefixed
with a # treating them like comments. | Permanently deletes crash report data from crash storage. | [
"Permanently",
"deletes",
"crash",
"report",
"data",
"from",
"crash",
"storage",
"."
] | def cmd_permadelete(ctx, crashidsfile):
"""
Permanently deletes crash report data from crash storage.
The crashidsfile should be a complete path to the file with
crashids in it--one per line. This will skip lines prefixed
with a # treating them like comments.
"""
if not os.path.exists(cras... | [
"def",
"cmd_permadelete",
"(",
"ctx",
",",
"crashidsfile",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"crashidsfile",
")",
":",
"click",
".",
"echo",
"(",
"\"File %s does not exist.\"",
"%",
"crashidsfile",
")",
"return",
"1",
"crashids",
... | https://github.com/mozilla-services/socorro/blob/8bff4a90e9e3320eabe7e067adbe0e89f6a39ba7/bin/permadelete_crash_data.py#L216-L236 | ||
hbrobotics/ros_arduino_bridge | a960c8a88a6255d0104c92838045c06257c509d0 | ros_arduino_python/src/ros_arduino_python/arduino_driver.py | python | Arduino.reset_encoders | (self) | return self.execute_ack('r') | Reset the encoder counts to 0 | Reset the encoder counts to 0 | [
"Reset",
"the",
"encoder",
"counts",
"to",
"0"
] | def reset_encoders(self):
''' Reset the encoder counts to 0
'''
return self.execute_ack('r') | [
"def",
"reset_encoders",
"(",
"self",
")",
":",
"return",
"self",
".",
"execute_ack",
"(",
"'r'",
")"
] | https://github.com/hbrobotics/ros_arduino_bridge/blob/a960c8a88a6255d0104c92838045c06257c509d0/ros_arduino_python/src/ros_arduino_python/arduino_driver.py#L277-L280 | |
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/iotexplorer/v20190423/models.py | python | GetFamilyDeviceUserListResponse.__init__ | (self) | r"""
:param UserList: 设备的用户列表
注意:此字段可能返回 null,表示取不到有效值。
:type UserList: list of DeviceUser
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | r"""
:param UserList: 设备的用户列表
注意:此字段可能返回 null,表示取不到有效值。
:type UserList: list of DeviceUser
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | [
"r",
":",
"param",
"UserList",
":",
"设备的用户列表",
"注意:此字段可能返回",
"null,表示取不到有效值。",
":",
"type",
"UserList",
":",
"list",
"of",
"DeviceUser",
":",
"param",
"RequestId",
":",
"唯一请求",
"ID,每次请求都会返回。定位问题时需要提供该次请求的",
"RequestId。",
":",
"type",
"RequestId",
":",
"str"
] | def __init__(self):
r"""
:param UserList: 设备的用户列表
注意:此字段可能返回 null,表示取不到有效值。
:type UserList: list of DeviceUser
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str
"""
self.UserList = None
self.RequestId = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"UserList",
"=",
"None",
"self",
".",
"RequestId",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/iotexplorer/v20190423/models.py#L3571-L3580 | ||
DamnWidget/anaconda | a9998fb362320f907d5ccbc6fcf5b62baca677c0 | anaconda_lib/linting/pycodestyle.py | python | normalize_paths | (value, parent=os.curdir) | return paths | Parse a comma-separated list of paths.
Return a list of absolute paths. | Parse a comma-separated list of paths. | [
"Parse",
"a",
"comma",
"-",
"separated",
"list",
"of",
"paths",
"."
] | def normalize_paths(value, parent=os.curdir):
"""Parse a comma-separated list of paths.
Return a list of absolute paths.
"""
if not value:
return []
if isinstance(value, list):
return value
paths = []
for path in value.split(','):
path = path.strip()
if '/' i... | [
"def",
"normalize_paths",
"(",
"value",
",",
"parent",
"=",
"os",
".",
"curdir",
")",
":",
"if",
"not",
"value",
":",
"return",
"[",
"]",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"return",
"value",
"paths",
"=",
"[",
"]",
"for",
"pa... | https://github.com/DamnWidget/anaconda/blob/a9998fb362320f907d5ccbc6fcf5b62baca677c0/anaconda_lib/linting/pycodestyle.py#L1872-L1887 | |
HunterMcGushion/hyperparameter_hunter | 28b1d48e01a993818510811b82a677e0a7a232b2 | hyperparameter_hunter/experiments.py | python | BaseExperiment._empty_output_like | (self, like: pd.DataFrame, index=None, target_column=None) | return pd.DataFrame(0, index=index, columns=target_column) | Make an empty DataFrame of the same shape and with the same index as `like`, intended for
use with output :mod:`~hyperparameter_hunter.data.data_chunks`, like descendants of
:class:`~hyperparameter_hunter.data.data_chunks.prediction_chunks.BasePredictionChunk` and
:class:`~hyperparameter_hunter.... | Make an empty DataFrame of the same shape and with the same index as `like`, intended for
use with output :mod:`~hyperparameter_hunter.data.data_chunks`, like descendants of
:class:`~hyperparameter_hunter.data.data_chunks.prediction_chunks.BasePredictionChunk` and
:class:`~hyperparameter_hunter.... | [
"Make",
"an",
"empty",
"DataFrame",
"of",
"the",
"same",
"shape",
"and",
"with",
"the",
"same",
"index",
"as",
"like",
"intended",
"for",
"use",
"with",
"output",
":",
"mod",
":",
"~hyperparameter_hunter",
".",
"data",
".",
"data_chunks",
"like",
"descendant... | def _empty_output_like(self, like: pd.DataFrame, index=None, target_column=None):
"""Make an empty DataFrame of the same shape and with the same index as `like`, intended for
use with output :mod:`~hyperparameter_hunter.data.data_chunks`, like descendants of
:class:`~hyperparameter_hunter.data.d... | [
"def",
"_empty_output_like",
"(",
"self",
",",
"like",
":",
"pd",
".",
"DataFrame",
",",
"index",
"=",
"None",
",",
"target_column",
"=",
"None",
")",
":",
"index",
"=",
"like",
".",
"index",
".",
"copy",
"(",
")",
"if",
"index",
"is",
"None",
"else"... | https://github.com/HunterMcGushion/hyperparameter_hunter/blob/28b1d48e01a993818510811b82a677e0a7a232b2/hyperparameter_hunter/experiments.py#L532-L556 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/geometry/line.py | python | Ray.contains | (self, o) | return False | Is other GeometryEntity contained in this Ray? | Is other GeometryEntity contained in this Ray? | [
"Is",
"other",
"GeometryEntity",
"contained",
"in",
"this",
"Ray?"
] | def contains(self, o):
"""Is other GeometryEntity contained in this Ray?"""
if isinstance(o, Ray):
return (Point.is_collinear(self.p1, self.p2, o.p1, o.p2) and
self.xdirection == o.xdirection and
self.ydirection == o.ydirection)
elif isinstance... | [
"def",
"contains",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"Ray",
")",
":",
"return",
"(",
"Point",
".",
"is_collinear",
"(",
"self",
".",
"p1",
",",
"self",
".",
"p2",
",",
"o",
".",
"p1",
",",
"o",
".",
"p2",
")"... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/geometry/line.py#L1419-L1447 | |
MartinThoma/algorithms | 6199cfa3446e1056c7b4d75ca6e306e9e56fd95b | ML/nlp/reuters_mlp.py | python | main | (data_module) | Load data, train model and evaluate it. | Load data, train model and evaluate it. | [
"Load",
"data",
"train",
"model",
"and",
"evaluate",
"it",
"."
] | def main(data_module):
"""Load data, train model and evaluate it."""
data = data_module.load_data()
model = create_model(data_module.n_classes, (data['x_train'].shape[1], ))
print(model.summary())
optimizer = get_optimizer({'optimizer': {'initial_lr': 0.001}})
model.compile(loss='binary_crossent... | [
"def",
"main",
"(",
"data_module",
")",
":",
"data",
"=",
"data_module",
".",
"load_data",
"(",
")",
"model",
"=",
"create_model",
"(",
"data_module",
".",
"n_classes",
",",
"(",
"data",
"[",
"'x_train'",
"]",
".",
"shape",
"[",
"1",
"]",
",",
")",
"... | https://github.com/MartinThoma/algorithms/blob/6199cfa3446e1056c7b4d75ca6e306e9e56fd95b/ML/nlp/reuters_mlp.py#L82-L111 | ||
theislab/scvelo | 1805ab4a72d3f34496f0ef246500a159f619d3a2 | scvelo/tools/rank_velocity_genes.py | python | velocity_clusters | (
data,
vkey="velocity",
match_with="clusters",
sort_by="velocity_pseudotime",
resolution=None,
min_likelihood=None,
copy=False,
) | return adata if copy else None | Computes velocity clusters via louvain on velocities.
.. code:: python
scv.tl.velocity_clusters(adata)
scv.pl.scatter(adata, color='velocity_clusters')
.. image:: https://user-images.githubusercontent.com/31883718/69625627-484dc480-1047-11ea-847f-6607a3430427.png
:width: 600px
Ar... | Computes velocity clusters via louvain on velocities. | [
"Computes",
"velocity",
"clusters",
"via",
"louvain",
"on",
"velocities",
"."
] | def velocity_clusters(
data,
vkey="velocity",
match_with="clusters",
sort_by="velocity_pseudotime",
resolution=None,
min_likelihood=None,
copy=False,
):
"""Computes velocity clusters via louvain on velocities.
.. code:: python
scv.tl.velocity_clusters(adata)
scv.pl.... | [
"def",
"velocity_clusters",
"(",
"data",
",",
"vkey",
"=",
"\"velocity\"",
",",
"match_with",
"=",
"\"clusters\"",
",",
"sort_by",
"=",
"\"velocity_pseudotime\"",
",",
"resolution",
"=",
"None",
",",
"min_likelihood",
"=",
"None",
",",
"copy",
"=",
"False",
",... | https://github.com/theislab/scvelo/blob/1805ab4a72d3f34496f0ef246500a159f619d3a2/scvelo/tools/rank_velocity_genes.py#L64-L191 | |
intel/virtual-storage-manager | 00706ab9701acbd0d5e04b19cc80c6b66a2973b8 | source/vsm/vsm/image/glance.py | python | GlanceImageService._is_image_available | (context, image) | return str(user_id) == str(context.user_id) | Check image availability.
This check is needed in case Nova and Glance are deployed
without authentication turned on. | Check image availability. | [
"Check",
"image",
"availability",
"."
] | def _is_image_available(context, image):
"""Check image availability.
This check is needed in case Nova and Glance are deployed
without authentication turned on.
"""
# The presence of an auth token implies this is an authenticated
# request and we need not handle the noa... | [
"def",
"_is_image_available",
"(",
"context",
",",
"image",
")",
":",
"# The presence of an auth token implies this is an authenticated",
"# request and we need not handle the noauth use-case.",
"if",
"hasattr",
"(",
"context",
",",
"'auth_token'",
")",
"and",
"context",
".",
... | https://github.com/intel/virtual-storage-manager/blob/00706ab9701acbd0d5e04b19cc80c6b66a2973b8/source/vsm/vsm/image/glance.py#L288-L315 | |
google/pytype | fa43edc95dd42ade6e3147d6580d63e778c9d506 | pytype/tools/analyze_project/parse_args.py | python | parse_jobs | (s) | Parse the --jobs option. | Parse the --jobs option. | [
"Parse",
"the",
"--",
"jobs",
"option",
"."
] | def parse_jobs(s):
"""Parse the --jobs option."""
if s == 'auto':
n = _auto_detect_cpus()
return n if n else 1
elif s is not None:
return int(s)
else:
return None | [
"def",
"parse_jobs",
"(",
"s",
")",
":",
"if",
"s",
"==",
"'auto'",
":",
"n",
"=",
"_auto_detect_cpus",
"(",
")",
"return",
"n",
"if",
"n",
"else",
"1",
"elif",
"s",
"is",
"not",
"None",
":",
"return",
"int",
"(",
"s",
")",
"else",
":",
"return",... | https://github.com/google/pytype/blob/fa43edc95dd42ade6e3147d6580d63e778c9d506/pytype/tools/analyze_project/parse_args.py#L22-L30 | ||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/utils/dummy_pt_objects.py | python | GPTJForCausalLM.__init__ | (self, *args, **kwargs) | [] | def __init__(self, *args, **kwargs):
requires_backends(self, ["torch"]) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"requires_backends",
"(",
"self",
",",
"[",
"\"torch\"",
"]",
")"
] | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/utils/dummy_pt_objects.py#L2522-L2523 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.