repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
ixc/python-edtf
edtf/convert.py
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/convert.py#L52-L63
def trim_struct_time(st, strip_time=False): """ Return a `struct_time` based on the one provided but with the extra fields `tm_wday`, `tm_yday`, and `tm_isdst` reset to default values. If `strip_time` is set to true the time value are also set to zero: `tm_hour`, `tm_min`, and `tm_sec`. """ ...
[ "def", "trim_struct_time", "(", "st", ",", "strip_time", "=", "False", ")", ":", "if", "strip_time", ":", "return", "struct_time", "(", "list", "(", "st", "[", ":", "3", "]", ")", "+", "TIME_EMPTY_TIME", "+", "TIME_EMPTY_EXTRAS", ")", "else", ":", "retur...
Return a `struct_time` based on the one provided but with the extra fields `tm_wday`, `tm_yday`, and `tm_isdst` reset to default values. If `strip_time` is set to true the time value are also set to zero: `tm_hour`, `tm_min`, and `tm_sec`.
[ "Return", "a", "struct_time", "based", "on", "the", "one", "provided", "but", "with", "the", "extra", "fields", "tm_wday", "tm_yday", "and", "tm_isdst", "reset", "to", "default", "values", "." ]
python
train
39.5
hhatto/autopep8
autopep8.py
https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L666-L679
def fix_e131(self, result): """Fix indentation undistinguish from the next logical line.""" num_indent_spaces = int(result['info'].split()[1]) line_index = result['line'] - 1 target = self.source[line_index] spaces_to_add = num_indent_spaces - len(_get_indentation(target)) ...
[ "def", "fix_e131", "(", "self", ",", "result", ")", ":", "num_indent_spaces", "=", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "1", "]", ")", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self...
Fix indentation undistinguish from the next logical line.
[ "Fix", "indentation", "undistinguish", "from", "the", "next", "logical", "line", "." ]
python
train
41.642857
bunq/sdk_python
bunq/sdk/model/generated/object_.py
https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/object_.py#L5214-L5286
def get_referenced_object(self): """ :rtype: core.BunqModel :raise: BunqException """ if self._BunqMeFundraiserResult is not None: return self._BunqMeFundraiserResult if self._BunqMeTab is not None: return self._BunqMeTab if self._BunqMe...
[ "def", "get_referenced_object", "(", "self", ")", ":", "if", "self", ".", "_BunqMeFundraiserResult", "is", "not", "None", ":", "return", "self", ".", "_BunqMeFundraiserResult", "if", "self", ".", "_BunqMeTab", "is", "not", "None", ":", "return", "self", ".", ...
:rtype: core.BunqModel :raise: BunqException
[ ":", "rtype", ":", "core", ".", "BunqModel", ":", "raise", ":", "BunqException" ]
python
train
28.369863
google/grr
grr/server/grr_response_server/flow_runner.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L930-L961
def _SendTerminationMessage(self, status=None): """This notifies the parent flow of our termination.""" if not self.runner_args.request_state.session_id: # No parent flow, nothing to do here. return if status is None: status = rdf_flows.GrrStatus() client_resources = self.context.cli...
[ "def", "_SendTerminationMessage", "(", "self", ",", "status", "=", "None", ")", ":", "if", "not", "self", ".", "runner_args", ".", "request_state", ".", "session_id", ":", "# No parent flow, nothing to do here.", "return", "if", "status", "is", "None", ":", "sta...
This notifies the parent flow of our termination.
[ "This", "notifies", "the", "parent", "flow", "of", "our", "termination", "." ]
python
train
37.25
NASA-AMMOS/AIT-Core
ait/core/gds.py
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/gds.py#L32-L76
def compress (input_filename, output_filename=None, verbose=False): """compress(input_filename, output_filename=None, verbose=False) -> integer Uses zlib to compress input_filename and store the result in output_filename. The size of output_filename is returned on success; zero is returned on failure. The ...
[ "def", "compress", "(", "input_filename", ",", "output_filename", "=", "None", ",", "verbose", "=", "False", ")", ":", "input_size", "=", "0", "output_size", "=", "0", "if", "output_filename", "is", "None", ":", "output_filename", "=", "input_fillename", "+", ...
compress(input_filename, output_filename=None, verbose=False) -> integer Uses zlib to compress input_filename and store the result in output_filename. The size of output_filename is returned on success; zero is returned on failure. The input file is compressed in one fell swoop. The output_filename defaul...
[ "compress", "(", "input_filename", "output_filename", "=", "None", "verbose", "=", "False", ")", "-", ">", "integer" ]
python
train
28.555556
apple/turicreate
deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/benchmark.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/benchmark.py#L48-L73
def benchmark_file( filename, compiler, include_dirs, (progress_from, progress_to), iter_count, extra_flags = ''): """Benchmark one file""" time_sum = 0 mem_sum = 0 for nth_run in xrange(0, iter_count): (time_spent, mem_used) = benchmark_command( '{0} -std=c++11 {1} -...
[ "def", "benchmark_file", "(", "filename", ",", "compiler", ",", "include_dirs", ",", "(", "progress_from", ",", "progress_to", ")", ",", "iter_count", ",", "extra_flags", "=", "''", ")", ":", "time_sum", "=", "0", "mem_sum", "=", "0", "for", "nth_run", "in...
Benchmark one file
[ "Benchmark", "one", "file" ]
python
train
33.230769
rigetti/quantumflow
quantumflow/states.py
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L322-L326
def mixed_density(qubits: Union[int, Qubits]) -> Density: """Returns the completely mixed density matrix""" N, qubits = qubits_count_tuple(qubits) matrix = np.eye(2**N) / 2**N return Density(matrix, qubits)
[ "def", "mixed_density", "(", "qubits", ":", "Union", "[", "int", ",", "Qubits", "]", ")", "->", "Density", ":", "N", ",", "qubits", "=", "qubits_count_tuple", "(", "qubits", ")", "matrix", "=", "np", ".", "eye", "(", "2", "**", "N", ")", "/", "2", ...
Returns the completely mixed density matrix
[ "Returns", "the", "completely", "mixed", "density", "matrix" ]
python
train
43.6
nicolargo/glances
glances/stats.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L144-L178
def load_exports(self, args=None): """Load all export modules in the 'exports' folder.""" if args is None: return False header = "glances_" # Build the export module available list args_var = vars(locals()['args']) for item in os.listdir(exports_path): ...
[ "def", "load_exports", "(", "self", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "return", "False", "header", "=", "\"glances_\"", "# Build the export module available list", "args_var", "=", "vars", "(", "locals", "(", ")", "[", "'ar...
Load all export modules in the 'exports' folder.
[ "Load", "all", "export", "modules", "in", "the", "exports", "folder", "." ]
python
train
49.314286
rauenzi/discordbot.py
discordbot/cogs/botadmin.py
https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L151-L171
async def disable(self, ctx, *, command: str): """Disables a command for this server. You must have Manage Server permissions or the Bot Admin role to use this command. """ command = command.lower() if command in ('enable', 'disable'): return await self.bot....
[ "async", "def", "disable", "(", "self", ",", "ctx", ",", "*", ",", "command", ":", "str", ")", ":", "command", "=", "command", ".", "lower", "(", ")", "if", "command", "in", "(", "'enable'", ",", "'disable'", ")", ":", "return", "await", "self", "....
Disables a command for this server. You must have Manage Server permissions or the Bot Admin role to use this command.
[ "Disables", "a", "command", "for", "this", "server", "." ]
python
train
40.619048
MaxStrange/AudioSegment
audiosegment.py
https://github.com/MaxStrange/AudioSegment/blob/1daefb8de626ddff3ff7016697c3ad31d262ecd6/audiosegment.py#L829-L876
def normalize_spl_by_average(self, db): """ Normalize the values in the AudioSegment so that its `spl` property gives `db`. .. note:: This method is currently broken - it returns an AudioSegment whose values are much smaller than reasonable, yet which yield an SPL valu...
[ "def", "normalize_spl_by_average", "(", "self", ",", "db", ")", ":", "arr", "=", "self", ".", "to_numpy_array", "(", ")", ".", "copy", "(", ")", "if", "len", "(", "arr", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Cannot normalize the SPL of an emp...
Normalize the values in the AudioSegment so that its `spl` property gives `db`. .. note:: This method is currently broken - it returns an AudioSegment whose values are much smaller than reasonable, yet which yield an SPL value that equals the given `db`. Such an Audi...
[ "Normalize", "the", "values", "in", "the", "AudioSegment", "so", "that", "its", "spl", "property", "gives", "db", "." ]
python
test
41.8125
Chilipp/psyplot
psyplot/data.py
https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1842-L1854
def get_nodes(self, coord, coords): """Get the variables containing the definition of the nodes Parameters ---------- coord: xarray.Coordinate The mesh variable coords: dict The coordinates to use to get node coordinates""" def get_coord(coord): ...
[ "def", "get_nodes", "(", "self", ",", "coord", ",", "coords", ")", ":", "def", "get_coord", "(", "coord", ")", ":", "return", "coords", ".", "get", "(", "coord", ",", "self", ".", "ds", ".", "coords", ".", "get", "(", "coord", ")", ")", "return", ...
Get the variables containing the definition of the nodes Parameters ---------- coord: xarray.Coordinate The mesh variable coords: dict The coordinates to use to get node coordinates
[ "Get", "the", "variables", "containing", "the", "definition", "of", "the", "nodes" ]
python
train
37.153846
docker/docker-py
docker/api/container.py
https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/container.py#L926-L948
def put_archive(self, container, path, data): """ Insert a file or folder in an existing container using a tar archive as source. Args: container (str): The container where the file(s) will be extracted path (str): Path inside the container where the file(s) will...
[ "def", "put_archive", "(", "self", ",", "container", ",", "path", ",", "data", ")", ":", "params", "=", "{", "'path'", ":", "path", "}", "url", "=", "self", ".", "_url", "(", "'/containers/{0}/archive'", ",", "container", ")", "res", "=", "self", ".", ...
Insert a file or folder in an existing container using a tar archive as source. Args: container (str): The container where the file(s) will be extracted path (str): Path inside the container where the file(s) will be extracted. Must exist. data (bytes...
[ "Insert", "a", "file", "or", "folder", "in", "an", "existing", "container", "using", "a", "tar", "archive", "as", "source", "." ]
python
train
34.913043
instaloader/instaloader
instaloader/structures.py
https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L276-L282
def viewer_has_liked(self) -> Optional[bool]: """Whether the viewer has liked the post, or None if not logged in.""" if not self._context.is_logged_in: return None if 'likes' in self._node and 'viewer_has_liked' in self._node['likes']: return self._node['likes']['viewer_h...
[ "def", "viewer_has_liked", "(", "self", ")", "->", "Optional", "[", "bool", "]", ":", "if", "not", "self", ".", "_context", ".", "is_logged_in", ":", "return", "None", "if", "'likes'", "in", "self", ".", "_node", "and", "'viewer_has_liked'", "in", "self", ...
Whether the viewer has liked the post, or None if not logged in.
[ "Whether", "the", "viewer", "has", "liked", "the", "post", "or", "None", "if", "not", "logged", "in", "." ]
python
train
53
gwpy/gwpy
gwpy/io/gwf.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/io/gwf.py#L236-L259
def channel_in_frame(channel, framefile): """Determine whether a channel is stored in this framefile **Requires:** |LDAStools.frameCPP|_ Parameters ---------- channel : `str` name of channel to find framefile : `str` path of GWF file to test Returns ------- infram...
[ "def", "channel_in_frame", "(", "channel", ",", "framefile", ")", ":", "channel", "=", "str", "(", "channel", ")", "for", "name", "in", "iter_channel_names", "(", "framefile", ")", ":", "if", "channel", "==", "name", ":", "return", "True", "return", "False...
Determine whether a channel is stored in this framefile **Requires:** |LDAStools.frameCPP|_ Parameters ---------- channel : `str` name of channel to find framefile : `str` path of GWF file to test Returns ------- inframe : `bool` whether this channel is includ...
[ "Determine", "whether", "a", "channel", "is", "stored", "in", "this", "framefile" ]
python
train
23.166667
openergy/oplus
oplus/epm/epm.py
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L299-L317
def to_json(self, buffer_or_path=None, indent=2): """ Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. indent: int, default 2 Defines the indentation of the json Returns ...
[ "def", "to_json", "(", "self", ",", "buffer_or_path", "=", "None", ",", "indent", "=", "2", ")", ":", "# return json", "return", "json_data_to_json", "(", "self", ".", "to_json_data", "(", ")", ",", "buffer_or_path", "=", "buffer_or_path", ",", "indent", "="...
Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. indent: int, default 2 Defines the indentation of the json Returns ------- None, or a json string (if buffer_or_path is No...
[ "Parameters", "----------", "buffer_or_path", ":", "buffer", "or", "path", "default", "None", "output", "to", "write", "into", ".", "If", "None", "will", "return", "a", "json", "string", ".", "indent", ":", "int", "default", "2", "Defines", "the", "indentati...
python
test
29.263158
shapiromatron/bmds
bmds/datasets.py
https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/datasets.py#L136-L142
def to_dict(self): """ Returns a dictionary representation of the dataset. """ d = dict(doses=self.doses, ns=self.ns, incidences=self.incidences) d.update(self.kwargs) return d
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "dict", "(", "doses", "=", "self", ".", "doses", ",", "ns", "=", "self", ".", "ns", ",", "incidences", "=", "self", ".", "incidences", ")", "d", ".", "update", "(", "self", ".", "kwargs", ")", ...
Returns a dictionary representation of the dataset.
[ "Returns", "a", "dictionary", "representation", "of", "the", "dataset", "." ]
python
train
31.142857
jmoiron/johnny-cache
johnny/cache.py
https://github.com/jmoiron/johnny-cache/blob/d96ea94c5dfcde517ff8f65d6ba4e435d8a0168c/johnny/cache.py#L255-L264
def sql_key(self, generation, sql, params, order, result_type, using='default'): """ Return the specific cache key for the sql query described by the pieces of the query and the generation key. """ # these keys will always look pretty opaque suffix = self....
[ "def", "sql_key", "(", "self", ",", "generation", ",", "sql", ",", "params", ",", "order", ",", "result_type", ",", "using", "=", "'default'", ")", ":", "# these keys will always look pretty opaque", "suffix", "=", "self", ".", "keygen", ".", "gen_key", "(", ...
Return the specific cache key for the sql query described by the pieces of the query and the generation key.
[ "Return", "the", "specific", "cache", "key", "for", "the", "sql", "query", "described", "by", "the", "pieces", "of", "the", "query", "and", "the", "generation", "key", "." ]
python
train
48.2
LogicalDash/LiSE
allegedb/allegedb/cache.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L233-L254
def load(self, data): """Add a bunch of data. Must be in chronological order. But it doesn't need to all be from the same branch, as long as each branch is chronological of itself. """ branches = defaultdict(list) for row in data: branches[row[-4]].append(ro...
[ "def", "load", "(", "self", ",", "data", ")", ":", "branches", "=", "defaultdict", "(", "list", ")", "for", "row", "in", "data", ":", "branches", "[", "row", "[", "-", "4", "]", "]", ".", "append", "(", "row", ")", "# Make keycaches and valcaches. Must...
Add a bunch of data. Must be in chronological order. But it doesn't need to all be from the same branch, as long as each branch is chronological of itself.
[ "Add", "a", "bunch", "of", "data", ".", "Must", "be", "in", "chronological", "order", "." ]
python
train
35.045455
toastdriven/alligator
alligator/backends/beanstalk_backend.py
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L34-L53
def len(self, queue_name): """ Returns the length of the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :returns: The length of the queue :rtype: integer """ try: ...
[ "def", "len", "(", "self", ",", "queue_name", ")", ":", "try", ":", "stats", "=", "self", ".", "conn", ".", "stats_tube", "(", "queue_name", ")", "except", "beanstalkc", ".", "CommandFailed", "as", "err", ":", "if", "err", "[", "1", "]", "==", "'NOT_...
Returns the length of the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :returns: The length of the queue :rtype: integer
[ "Returns", "the", "length", "of", "the", "queue", "." ]
python
train
26.25
wdbm/propyte
propyte.py
https://github.com/wdbm/propyte/blob/0375a267c49e80223627331c8edbe13dfe9fd116/propyte.py#L398-L481
def say( text = None, preference_program = "festival", background = False, silent = True, filepath = None ): """ Say specified text to speakers or to file, as specified. Determine the program to use based on the specified program preference...
[ "def", "say", "(", "text", "=", "None", ",", "preference_program", "=", "\"festival\"", ",", "background", "=", "False", ",", "silent", "=", "True", ",", "filepath", "=", "None", ")", ":", "if", "not", "text", ":", "if", "not", "silent", ":", "print", ...
Say specified text to speakers or to file, as specified. Determine the program to use based on the specified program preference and availability, then say the text to speakers or synthesize speech of the text and save it to file, as specified.
[ "Say", "specified", "text", "to", "speakers", "or", "to", "file", "as", "specified", ".", "Determine", "the", "program", "to", "use", "based", "on", "the", "specified", "program", "preference", "and", "availability", "then", "say", "the", "text", "to", "spea...
python
train
36.928571
leancloud/python-sdk
leancloud/cloud.py
https://github.com/leancloud/python-sdk/blob/fea3240257ce65e6a32c7312a5cee1f94a51a587/leancloud/cloud.py#L42-L59
def rpc(_cloud_rpc_name, **params): """ 调用 LeanEngine 上的远程代码 与 cloud.run 类似,但是允许传入 leancloud.Object 作为参数,也允许传入 leancloud.Object 作为结果 :param name: 需要调用的远程 Cloud Code 的名称 :type name: basestring :param params: 调用参数 :return: 调用结果 """ encoded_params = {} for key, value in params.items...
[ "def", "rpc", "(", "_cloud_rpc_name", ",", "*", "*", "params", ")", ":", "encoded_params", "=", "{", "}", "for", "key", ",", "value", "in", "params", ".", "items", "(", ")", ":", "if", "isinstance", "(", "params", ",", "leancloud", ".", "Object", ")"...
调用 LeanEngine 上的远程代码 与 cloud.run 类似,但是允许传入 leancloud.Object 作为参数,也允许传入 leancloud.Object 作为结果 :param name: 需要调用的远程 Cloud Code 的名称 :type name: basestring :param params: 调用参数 :return: 调用结果
[ "调用", "LeanEngine", "上的远程代码", "与", "cloud", ".", "run", "类似,但是允许传入", "leancloud", ".", "Object", "作为参数,也允许传入", "leancloud", ".", "Object", "作为结果", ":", "param", "name", ":", "需要调用的远程", "Cloud", "Code", "的名称", ":", "type", "name", ":", "basestring", ":", "p...
python
train
36.666667
ecell/ecell4
ecell4/extra/ensemble.py
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L597-L775
def ensemble_simulations( t, y0=None, volume=1.0, model=None, solver='ode', is_netfree=False, species_list=None, without_reset=False, return_type='matplotlib', opt_args=(), opt_kwargs=None, structures=None, rndseed=None, n=1, nproc=None, method=None, errorbar=True, **kwargs): """ Run sim...
[ "def", "ensemble_simulations", "(", "t", ",", "y0", "=", "None", ",", "volume", "=", "1.0", ",", "model", "=", "None", ",", "solver", "=", "'ode'", ",", "is_netfree", "=", "False", ",", "species_list", "=", "None", ",", "without_reset", "=", "False", "...
Run simulations multiple times and return its ensemble. Arguments are almost same with ``ecell4.util.simulation.run_simulation``. `observers` and `progressbar` is not available here. Parameters ---------- n : int, optional A number of runs. Default is 1. nproc : int, optional A ...
[ "Run", "simulations", "multiple", "times", "and", "return", "its", "ensemble", ".", "Arguments", "are", "almost", "same", "with", "ecell4", ".", "util", ".", "simulation", ".", "run_simulation", ".", "observers", "and", "progressbar", "is", "not", "available", ...
python
train
37.586592
klavinslab/coral
coral/reaction/_oligo_assembly.py
https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/reaction/_oligo_assembly.py#L95-L134
def bind_unique(reference, query_list, min_overlap=12, right=True): '''(5' or 3' region on reference sequence that uniquely matches the reverse complement of the associated (5' or 3') region of one sequence in a list of query sequences. :param reference: Reference sequence. :type reference: coral.D...
[ "def", "bind_unique", "(", "reference", ",", "query_list", ",", "min_overlap", "=", "12", ",", "right", "=", "True", ")", ":", "size", "=", "min_overlap", "found", "=", "[", "]", "# Reverse complementing here provides massive speedup?", "rev_query", "=", "[", "s...
(5' or 3' region on reference sequence that uniquely matches the reverse complement of the associated (5' or 3') region of one sequence in a list of query sequences. :param reference: Reference sequence. :type reference: coral.DNA :param query_list: List of query sequences. :type query_list: co...
[ "(", "5", "or", "3", "region", "on", "reference", "sequence", "that", "uniquely", "matches", "the", "reverse", "complement", "of", "the", "associated", "(", "5", "or", "3", ")", "region", "of", "one", "sequence", "in", "a", "list", "of", "query", "sequen...
python
train
37.65
erikrose/blessings
blessings/__init__.py
https://github.com/erikrose/blessings/blob/b1d4daf948d1db8455af64836906785204d09055/blessings/__init__.py#L347-L368
def _resolve_formatter(self, attr): """Resolve a sugary or plain capability name, color, or compound formatting function name into a callable capability. Return a ``ParametrizingString`` or a ``FormattingString``. """ if attr in COLORS: return self._resolve_color(at...
[ "def", "_resolve_formatter", "(", "self", ",", "attr", ")", ":", "if", "attr", "in", "COLORS", ":", "return", "self", ".", "_resolve_color", "(", "attr", ")", "elif", "attr", "in", "COMPOUNDABLES", ":", "# Bold, underline, or something that takes no parameters", "...
Resolve a sugary or plain capability name, color, or compound formatting function name into a callable capability. Return a ``ParametrizingString`` or a ``FormattingString``.
[ "Resolve", "a", "sugary", "or", "plain", "capability", "name", "color", "or", "compound", "formatting", "function", "name", "into", "a", "callable", "capability", "." ]
python
train
45.909091
cltk/cltk
cltk/corpus/arabic/utils/pyarabic/araby.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/arabic/utils/pyarabic/araby.py#L678-L693
def strip_lastharaka(text): """Strip the last Haraka from arabic word except Shadda. The striped marks are : - FATHA, DAMMA, KASRA - SUKUN - FATHATAN, DAMMATAN, KASRATAN @param text: arabic text. @type text: unicode. @return: return a striped text. @rtype: unicode. ...
[ "def", "strip_lastharaka", "(", "text", ")", ":", "if", "text", ":", "if", "is_vocalized", "(", "text", ")", ":", "return", "re", ".", "sub", "(", "LASTHARAKA_PATTERN", ",", "u''", ",", "text", ")", "return", "text" ]
Strip the last Haraka from arabic word except Shadda. The striped marks are : - FATHA, DAMMA, KASRA - SUKUN - FATHATAN, DAMMATAN, KASRATAN @param text: arabic text. @type text: unicode. @return: return a striped text. @rtype: unicode.
[ "Strip", "the", "last", "Haraka", "from", "arabic", "word", "except", "Shadda", ".", "The", "striped", "marks", "are", ":", "-", "FATHA", "DAMMA", "KASRA", "-", "SUKUN", "-", "FATHATAN", "DAMMATAN", "KASRATAN" ]
python
train
26.75
pypa/pipenv
pipenv/vendor/shellingham/posix/__init__.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/shellingham/posix/__init__.py#L22-L36
def _iter_process_command(mapping, pid, max_depth): """Iterator to traverse up the tree, yielding `argv[0]` of each process. """ for _ in range(max_depth): try: proc = mapping[pid] except KeyError: # We've reached the root process. Give up. break try: ...
[ "def", "_iter_process_command", "(", "mapping", ",", "pid", ",", "max_depth", ")", ":", "for", "_", "in", "range", "(", "max_depth", ")", ":", "try", ":", "proc", "=", "mapping", "[", "pid", "]", "except", "KeyError", ":", "# We've reached the root process. ...
Iterator to traverse up the tree, yielding `argv[0]` of each process.
[ "Iterator", "to", "traverse", "up", "the", "tree", "yielding", "argv", "[", "0", "]", "of", "each", "process", "." ]
python
train
32
santoshphilip/eppy
eppy/geometry/area_zone.py
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/area_zone.py#L19-L26
def area(poly): """Calculation of zone area""" poly_xy = [] num = len(poly) for i in range(num): poly[i] = poly[i][0:2] + (0,) poly_xy.append(poly[i]) return surface.area(poly)
[ "def", "area", "(", "poly", ")", ":", "poly_xy", "=", "[", "]", "num", "=", "len", "(", "poly", ")", "for", "i", "in", "range", "(", "num", ")", ":", "poly", "[", "i", "]", "=", "poly", "[", "i", "]", "[", "0", ":", "2", "]", "+", "(", ...
Calculation of zone area
[ "Calculation", "of", "zone", "area" ]
python
train
25.625
heikomuller/sco-client
scocli/__init__.py
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/__init__.py#L634-L661
def models_list(self, api_url=None, offset=0, limit=-1, properties=None): """Get list of model resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional ...
[ "def", "models_list", "(", "self", ",", "api_url", "=", "None", ",", "offset", "=", "0", ",", "limit", "=", "-", "1", ",", "properties", "=", "None", ")", ":", "# Get subject listing Url for given SCO-API and return the retrieved", "# resource listing", "return", ...
Get list of model resources from a SCO-API. Parameters ---------- api_url : string, optional Base Url of the SCO-API. Uses default API if argument not present. offset : int, optional Starting offset for returned list items limit : int, optional ...
[ "Get", "list", "of", "model", "resources", "from", "a", "SCO", "-", "API", "." ]
python
train
35.25
jalanb/pysyte
pysyte/paths.py
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L542-L554
def make_file_exist(self, filename=None): """Make the directory exist, then touch the file If the filename is None, then use self.name as filename """ if filename is None: path_to_file = FilePath(self) path_to_file.make_file_exist() return path_to_fil...
[ "def", "make_file_exist", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "path_to_file", "=", "FilePath", "(", "self", ")", "path_to_file", ".", "make_file_exist", "(", ")", "return", "path_to_file", "else", ":", ...
Make the directory exist, then touch the file If the filename is None, then use self.name as filename
[ "Make", "the", "directory", "exist", "then", "touch", "the", "file" ]
python
train
35.230769
django-admin-tools/django-admin-tools
admin_tools/template_loaders.py
https://github.com/django-admin-tools/django-admin-tools/blob/ba6f46f51ebd84fcf84f2f79ec9487f45452d79b/admin_tools/template_loaders.py#L44-L67
def get_template_sources(self, template_name, template_dirs=None): """ Returns the absolute paths to "template_name" in the specified app. If the name does not contain an app name (no colon), an empty list is returned. The parent FilesystemLoader.load_template_source() will take ...
[ "def", "get_template_sources", "(", "self", ",", "template_name", ",", "template_dirs", "=", "None", ")", ":", "if", "':'", "not", "in", "template_name", ":", "return", "[", "]", "app_name", ",", "template_name", "=", "template_name", ".", "split", "(", "\":...
Returns the absolute paths to "template_name" in the specified app. If the name does not contain an app name (no colon), an empty list is returned. The parent FilesystemLoader.load_template_source() will take care of the actual loading for us.
[ "Returns", "the", "absolute", "paths", "to", "template_name", "in", "the", "specified", "app", ".", "If", "the", "name", "does", "not", "contain", "an", "app", "name", "(", "no", "colon", ")", "an", "empty", "list", "is", "returned", ".", "The", "parent"...
python
train
40.083333
caesar0301/relogger
relogger/syslog.py
https://github.com/caesar0301/relogger/blob/40b722ad2115ac6a179e2cc4eb0c88333f5114de/relogger/syslog.py#L153-L164
def hostname(self, value): """ The hostname where the log message was created. Should be the first part of the hostname, or an IP address. Should NOT be set to a fully qualified domain name. """ if value is None: value = socket.gethostname() ...
[ "def", "hostname", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "value", "=", "socket", ".", "gethostname", "(", ")", "self", ".", "_hostname", "=", "value" ]
The hostname where the log message was created. Should be the first part of the hostname, or an IP address. Should NOT be set to a fully qualified domain name.
[ "The", "hostname", "where", "the", "log", "message", "was", "created", "." ]
python
train
27.583333
MinchinWeb/minchin.releaser
minchin/releaser/make_release.py
https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/make_release.py#L171-L182
def build_distribution(): """Build distributions of the code.""" result = invoke.run('python setup.py sdist bdist_egg bdist_wheel', warn=True, hide=True) if result.ok: print("[{}GOOD{}] Distribution built without errors." .format(GOOD_COLOR, RESET_COLOR)) el...
[ "def", "build_distribution", "(", ")", ":", "result", "=", "invoke", ".", "run", "(", "'python setup.py sdist bdist_egg bdist_wheel'", ",", "warn", "=", "True", ",", "hide", "=", "True", ")", "if", "result", ".", "ok", ":", "print", "(", "\"[{}GOOD{}] Distribu...
Build distributions of the code.
[ "Build", "distributions", "of", "the", "code", "." ]
python
train
40.583333
msfrank/cifparser
cifparser/grammar.py
https://github.com/msfrank/cifparser/blob/ecd899ba2e7b990e2cec62b115742d830e7e4384/cifparser/grammar.py#L58-L71
def calculate_indent(text): """ :param text: :type text: str :return: """ indent = 0 for c in text: if c is '\t': raise ValueError() if c is not ' ': return indent,text[indent:] indent += 1 return indent,''
[ "def", "calculate_indent", "(", "text", ")", ":", "indent", "=", "0", "for", "c", "in", "text", ":", "if", "c", "is", "'\\t'", ":", "raise", "ValueError", "(", ")", "if", "c", "is", "not", "' '", ":", "return", "indent", ",", "text", "[", "indent",...
:param text: :type text: str :return:
[ ":", "param", "text", ":", ":", "type", "text", ":", "str", ":", "return", ":" ]
python
train
19.5
dereneaton/ipyrad
ipyrad/assemble/refmap.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/refmap.py#L977-L1234
def bam_region_to_fasta(data, sample, proc1, chrom, region_start, region_end): """ Take the chromosome position, and start and end bases and return sequences of all reads that overlap these sites. This is the command we're building: samtools view -b 1A_sorted.bam 1:116202035-116202060 | \ ...
[ "def", "bam_region_to_fasta", "(", "data", ",", "sample", ",", "proc1", ",", "chrom", ",", "region_start", ",", "region_end", ")", ":", "## output bam file handle for storing genome regions", "bamf", "=", "sample", ".", "files", ".", "mapped_reads", "if", "not", "...
Take the chromosome position, and start and end bases and return sequences of all reads that overlap these sites. This is the command we're building: samtools view -b 1A_sorted.bam 1:116202035-116202060 | \ samtools bam2fq <options> - -b : output bam format -0 : ...
[ "Take", "the", "chromosome", "position", "and", "start", "and", "end", "bases", "and", "return", "sequences", "of", "all", "reads", "that", "overlap", "these", "sites", ".", "This", "is", "the", "command", "we", "re", "building", ":" ]
python
valid
44.821705
Riffstation/flask-philo
flask_philo/views.py
https://github.com/Riffstation/flask-philo/blob/76c9d562edb4a77010c8da6dfdb6489fa29cbc9e/flask_philo/views.py#L49-L59
def template_response(self, template_name, headers={}, **values): """ Constructs a response, allowing custom template name and content_type """ response = make_response( self.render_template(template_name, **values)) for field, value in headers.items(): r...
[ "def", "template_response", "(", "self", ",", "template_name", ",", "headers", "=", "{", "}", ",", "*", "*", "values", ")", ":", "response", "=", "make_response", "(", "self", ".", "render_template", "(", "template_name", ",", "*", "*", "values", ")", ")...
Constructs a response, allowing custom template name and content_type
[ "Constructs", "a", "response", "allowing", "custom", "template", "name", "and", "content_type" ]
python
train
33.454545
cokelaer/spectrum
src/spectrum/lpc.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/lpc.py#L10-L72
def lpc(x, N=None): """Linear Predictor Coefficients. :param x: :param int N: default is length(X) - 1 :Details: Finds the coefficients :math:`A=(1, a(2), \dots a(N+1))`, of an Nth order forward linear predictor that predicts the current value value of the real-valued time series x based ...
[ "def", "lpc", "(", "x", ",", "N", "=", "None", ")", ":", "m", "=", "len", "(", "x", ")", "if", "N", "is", "None", ":", "N", "=", "m", "-", "1", "#default value if N is not provided", "elif", "N", ">", "m", "-", "1", ":", "#disp('Warning: zero-paddi...
Linear Predictor Coefficients. :param x: :param int N: default is length(X) - 1 :Details: Finds the coefficients :math:`A=(1, a(2), \dots a(N+1))`, of an Nth order forward linear predictor that predicts the current value value of the real-valued time series x based on past samples: .. ma...
[ "Linear", "Predictor", "Coefficients", "." ]
python
valid
28.809524
awslabs/sockeye
sockeye/training.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/training.py#L223-L272
def _generate_fixed_param_names(self, param_names: List[str], strategy: str) -> List[str]: """ Generate a fixed parameter list given a list of all parameter names and a strategy. """ # Number of encoder/decoder layers in model. if isinstance(self.config.config_encoder, Em...
[ "def", "_generate_fixed_param_names", "(", "self", ",", "param_names", ":", "List", "[", "str", "]", ",", "strategy", ":", "str", ")", "->", "List", "[", "str", "]", ":", "# Number of encoder/decoder layers in model.", "if", "isinstance", "(", "self", ".", "co...
Generate a fixed parameter list given a list of all parameter names and a strategy.
[ "Generate", "a", "fixed", "parameter", "list", "given", "a", "list", "of", "all", "parameter", "names", "and", "a", "strategy", "." ]
python
train
68.02
Kuniwak/vint
vint/ast/parsing.py
https://github.com/Kuniwak/vint/blob/db29337d859d88239c282c2e9d84c858f23a4a09/vint/ast/parsing.py#L45-L84
def parse_redir(self, redir_cmd): """ Parse a command :redir content. """ redir_cmd_str = redir_cmd['str'] matched = re.match(r'redir?!?\s*(=>>?\s*)(\S+)', redir_cmd_str) if matched: redir_cmd_op = matched.group(1) redir_cmd_body = matched.group(2) a...
[ "def", "parse_redir", "(", "self", ",", "redir_cmd", ")", ":", "redir_cmd_str", "=", "redir_cmd", "[", "'str'", "]", "matched", "=", "re", ".", "match", "(", "r'redir?!?\\s*(=>>?\\s*)(\\S+)'", ",", "redir_cmd_str", ")", "if", "matched", ":", "redir_cmd_op", "=...
Parse a command :redir content.
[ "Parse", "a", "command", ":", "redir", "content", "." ]
python
train
32.2
saltstack/salt
salt/cloud/clouds/clc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/clc.py#L213-L224
def get_server_alerts(call=None, for_output=True, **kwargs): ''' Return a list of alerts from CLC as reported by their infra ''' for key, value in kwargs.items(): servername = "" if key == "servername": servername = value creds = get_creds() clc.v2.SetCredentials(cred...
[ "def", "get_server_alerts", "(", "call", "=", "None", ",", "for_output", "=", "True", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "servername", "=", "\"\"", "if", "key", "==", "\"servern...
Return a list of alerts from CLC as reported by their infra
[ "Return", "a", "list", "of", "alerts", "from", "CLC", "as", "reported", "by", "their", "infra" ]
python
train
33.666667
Jajcus/pyxmpp2
pyxmpp2/ext/muc/muc.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/muc/muc.py#L251-L262
def error(self,stanza): """ Called when an error stanza is received. :Parameters: - `stanza`: the stanza received. :Types: - `stanza`: `pyxmpp.stanza.Stanza` """ err=stanza.get_error() self.__logger.debug("Error from: %r Condition: %r" ...
[ "def", "error", "(", "self", ",", "stanza", ")", ":", "err", "=", "stanza", ".", "get_error", "(", ")", "self", ".", "__logger", ".", "debug", "(", "\"Error from: %r Condition: %r\"", "%", "(", "stanza", ".", "get_from", "(", ")", ",", "err", ".", "get...
Called when an error stanza is received. :Parameters: - `stanza`: the stanza received. :Types: - `stanza`: `pyxmpp.stanza.Stanza`
[ "Called", "when", "an", "error", "stanza", "is", "received", "." ]
python
valid
30.166667
6809/MC6809
MC6809/components/mc6809_ops_branches.py
https://github.com/6809/MC6809/blob/6ba2f5106df46689017b5d0b6d84d43b7ee6a240/MC6809/components/mc6809_ops_branches.py#L329-L344
def instruction_BNE(self, opcode, ea): """ Tests the state of the Z (zero) bit and causes a branch if it is clear. When used after a subtract or compare operation on any binary values, this instruction will branch if the register is, or would be, not equal to the memory register....
[ "def", "instruction_BNE", "(", "self", ",", "opcode", ",", "ea", ")", ":", "if", "self", ".", "Z", "==", "0", ":", "# log.info(\"$%x BNE branch to $%x, because Z==0 \\t| %s\" % (", "# self.program_counter, ea, self.cfg.mem_info.get_shortest(ea)", "# ...
Tests the state of the Z (zero) bit and causes a branch if it is clear. When used after a subtract or compare operation on any binary values, this instruction will branch if the register is, or would be, not equal to the memory register. source code forms: BNE dd; LBNE DDDD CC ...
[ "Tests", "the", "state", "of", "the", "Z", "(", "zero", ")", "bit", "and", "causes", "a", "branch", "if", "it", "is", "clear", ".", "When", "used", "after", "a", "subtract", "or", "compare", "operation", "on", "any", "binary", "values", "this", "instru...
python
train
39.0625
push-things/django-th
th_trello/my_trello.py
https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/th_trello/my_trello.py#L194-L201
def callback(self, request, **kwargs): """ Called from the Service when the user accept to activate it :param request: request object :return: callback url :rtype: string , path to the template """ return super(ServiceTrello, self).callback(request...
[ "def", "callback", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ServiceTrello", ",", "self", ")", ".", "callback", "(", "request", ",", "*", "*", "kwargs", ")" ]
Called from the Service when the user accept to activate it :param request: request object :return: callback url :rtype: string , path to the template
[ "Called", "from", "the", "Service", "when", "the", "user", "accept", "to", "activate", "it", ":", "param", "request", ":", "request", "object", ":", "return", ":", "callback", "url", ":", "rtype", ":", "string", "path", "to", "the", "template" ]
python
train
40.5
pantsbuild/pants
src/python/pants/backend/jvm/tasks/jvm_platform_analysis.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/jvm_platform_analysis.py#L174-L217
def validate_platform_dependencies(self): """Check all jvm targets in the context, throwing an error or warning if there are bad targets. If there are errors, this method fails slow rather than fails fast -- that is, it continues checking the rest of the targets before spitting error messages. This is usef...
[ "def", "validate_platform_dependencies", "(", "self", ")", ":", "conflicts", "=", "[", "]", "def", "is_conflicting", "(", "target", ",", "dependency", ")", ":", "return", "self", ".", "jvm_version", "(", "dependency", ")", ">", "self", ".", "jvm_version", "(...
Check all jvm targets in the context, throwing an error or warning if there are bad targets. If there are errors, this method fails slow rather than fails fast -- that is, it continues checking the rest of the targets before spitting error messages. This is useful, because it's nice to have a comprehensive...
[ "Check", "all", "jvm", "targets", "in", "the", "context", "throwing", "an", "error", "or", "warning", "if", "there", "are", "bad", "targets", "." ]
python
train
45.522727
Scout24/succubus
src/main/python/succubus/daemonize.py
https://github.com/Scout24/succubus/blob/465d6ef978be165b1b652736935b7cf0ee5ebe9e/src/main/python/succubus/daemonize.py#L46-L56
def set_gid(self): """Change the group of the running process""" if self.group: gid = getgrnam(self.group).gr_gid try: os.setgid(gid) except Exception: message = ("Unable to switch ownership to {0}:{1}. " + "D...
[ "def", "set_gid", "(", "self", ")", ":", "if", "self", ".", "group", ":", "gid", "=", "getgrnam", "(", "self", ".", "group", ")", ".", "gr_gid", "try", ":", "os", ".", "setgid", "(", "gid", ")", "except", "Exception", ":", "message", "=", "(", "\...
Change the group of the running process
[ "Change", "the", "group", "of", "the", "running", "process" ]
python
train
39.363636
peeringdb/peeringdb-py
peeringdb/client.py
https://github.com/peeringdb/peeringdb-py/blob/cf2060a1d5ef879a01cf849e54b7756909ab2661/peeringdb/client.py#L81-L84
def all(self, res): "Get resources using a filter condition" B = get_backend() return B.get_objects(B.get_concrete(res))
[ "def", "all", "(", "self", ",", "res", ")", ":", "B", "=", "get_backend", "(", ")", "return", "B", ".", "get_objects", "(", "B", ".", "get_concrete", "(", "res", ")", ")" ]
Get resources using a filter condition
[ "Get", "resources", "using", "a", "filter", "condition" ]
python
train
35.25
saltstack/salt
salt/modules/rh_service.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_service.py#L161-L166
def _service_is_chkconfig(name): ''' Return True if the service is managed by chkconfig. ''' cmdline = '/sbin/chkconfig --list {0}'.format(name) return __salt__['cmd.retcode'](cmdline, python_shell=False, ignore_retcode=True) == 0
[ "def", "_service_is_chkconfig", "(", "name", ")", ":", "cmdline", "=", "'/sbin/chkconfig --list {0}'", ".", "format", "(", "name", ")", "return", "__salt__", "[", "'cmd.retcode'", "]", "(", "cmdline", ",", "python_shell", "=", "False", ",", "ignore_retcode", "="...
Return True if the service is managed by chkconfig.
[ "Return", "True", "if", "the", "service", "is", "managed", "by", "chkconfig", "." ]
python
train
40.833333
pygobject/pgi
pgi/overrides/GObject.py
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GObject.py#L392-L402
def signal_list_names(type_): """Returns a list of signal names for the given type :param type\\_: :type type\\_: :obj:`GObject.GType` :returns: A list of signal names :rtype: :obj:`list` """ ids = signal_list_ids(type_) return tuple(GObjectModule.signal_name(i) for i in ids)
[ "def", "signal_list_names", "(", "type_", ")", ":", "ids", "=", "signal_list_ids", "(", "type_", ")", "return", "tuple", "(", "GObjectModule", ".", "signal_name", "(", "i", ")", "for", "i", "in", "ids", ")" ]
Returns a list of signal names for the given type :param type\\_: :type type\\_: :obj:`GObject.GType` :returns: A list of signal names :rtype: :obj:`list`
[ "Returns", "a", "list", "of", "signal", "names", "for", "the", "given", "type" ]
python
train
27.272727
cloudnull/cloudlib
cloudlib/arguments.py
https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/arguments.py#L270-L326
def arg_parser(self, passed_args=None): """Setup argument Parsing. If preset args are to be specified use the ``passed_args`` tuple. :param passed_args: ``list`` :return: ``dict`` """ parser, subpar, remaining_argv = self._setup_parser() if not isinstance(passed...
[ "def", "arg_parser", "(", "self", ",", "passed_args", "=", "None", ")", ":", "parser", ",", "subpar", ",", "remaining_argv", "=", "self", ".", "_setup_parser", "(", ")", "if", "not", "isinstance", "(", "passed_args", ",", "list", ")", ":", "passed_args", ...
Setup argument Parsing. If preset args are to be specified use the ``passed_args`` tuple. :param passed_args: ``list`` :return: ``dict``
[ "Setup", "argument", "Parsing", "." ]
python
train
35.333333
fishtown-analytics/dbt
core/dbt/parser/schemas.py
https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/schemas.py#L183-L198
def _filter_validate(filepath, location, values, validate): """Generator for validate() results called against all given values. On errors, fields are warned about and ignored, unless strict mode is set in which case a compiler error is raised. """ for value in values: if not isinstance(valu...
[ "def", "_filter_validate", "(", "filepath", ",", "location", ",", "values", ",", "validate", ")", ":", "for", "value", "in", "values", ":", "if", "not", "isinstance", "(", "value", ",", "dict", ")", ":", "warn_invalid", "(", "filepath", ",", "location", ...
Generator for validate() results called against all given values. On errors, fields are warned about and ignored, unless strict mode is set in which case a compiler error is raised.
[ "Generator", "for", "validate", "()", "results", "called", "against", "all", "given", "values", ".", "On", "errors", "fields", "are", "warned", "about", "and", "ignored", "unless", "strict", "mode", "is", "set", "in", "which", "case", "a", "compiler", "error...
python
train
44.5625
dereneaton/ipyrad
ipyrad/assemble/cluster_across.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/cluster_across.py#L1376-L1447
def build_clustbits(data, ipyclient, force): """ Reconstitutes clusters from .utemp and htemp files and writes them to chunked files for aligning in muscle. """ ## If you run this step then we clear all tmp .fa and .indel.h5 files if os.path.exists(data.tmpdir): shutil.rmtree(data.tmpdi...
[ "def", "build_clustbits", "(", "data", ",", "ipyclient", ",", "force", ")", ":", "## If you run this step then we clear all tmp .fa and .indel.h5 files", "if", "os", ".", "path", ".", "exists", "(", "data", ".", "tmpdir", ")", ":", "shutil", ".", "rmtree", "(", ...
Reconstitutes clusters from .utemp and htemp files and writes them to chunked files for aligning in muscle.
[ "Reconstitutes", "clusters", "from", ".", "utemp", "and", "htemp", "files", "and", "writes", "them", "to", "chunked", "files", "for", "aligning", "in", "muscle", "." ]
python
valid
36.930556
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L511-L544
def _lower_non_existent_context_field_filters(match_traversals, visitor_fn): """Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a Tr...
[ "def", "_lower_non_existent_context_field_filters", "(", "match_traversals", ",", "visitor_fn", ")", ":", "new_match_traversals", "=", "[", "]", "for", "match_traversal", "in", "match_traversals", ":", "new_match_traversal", "=", "[", "]", "for", "step", "in", "match_...
Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a TrueLiteral, are lowered appropriately based on the present operator (u'||' and u'...
[ "Return", "new", "match", "traversals", "lowering", "filters", "involving", "non", "-", "existent", "ContextFields", "." ]
python
train
44.176471
MacHu-GWU/uszipcode-project
uszipcode/pkg/sqlalchemy_mate/pkg/prettytable/prettytable.py
https://github.com/MacHu-GWU/uszipcode-project/blob/96282b779a3efb422802de83c48ca284598ba952/uszipcode/pkg/sqlalchemy_mate/pkg/prettytable/prettytable.py#L1080-L1106
def _get_rows(self, options): """Return only those data rows that should be printed, based on slicing and sorting. Arguments: options - dictionary of option settings.""" if options["oldsortslice"]: rows = copy.deepcopy(self._rows[options["start"]:options["end"]]) e...
[ "def", "_get_rows", "(", "self", ",", "options", ")", ":", "if", "options", "[", "\"oldsortslice\"", "]", ":", "rows", "=", "copy", ".", "deepcopy", "(", "self", ".", "_rows", "[", "options", "[", "\"start\"", "]", ":", "options", "[", "\"end\"", "]", ...
Return only those data rows that should be printed, based on slicing and sorting. Arguments: options - dictionary of option settings.
[ "Return", "only", "those", "data", "rows", "that", "should", "be", "printed", "based", "on", "slicing", "and", "sorting", "." ]
python
train
31.666667
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L1172-L1182
def save_indexed_audio(self, indexed_audio_file_abs_path): """ Writes the corrected timestamps to a file. Timestamps are a python dictionary. Parameters ---------- indexed_audio_file_abs_path : str """ with open(indexed_audio_file_abs_path, "wb") as f: ...
[ "def", "save_indexed_audio", "(", "self", ",", "indexed_audio_file_abs_path", ")", ":", "with", "open", "(", "indexed_audio_file_abs_path", ",", "\"wb\"", ")", "as", "f", ":", "pickle", ".", "dump", "(", "self", ".", "get_timestamps", "(", ")", ",", "f", ","...
Writes the corrected timestamps to a file. Timestamps are a python dictionary. Parameters ---------- indexed_audio_file_abs_path : str
[ "Writes", "the", "corrected", "timestamps", "to", "a", "file", ".", "Timestamps", "are", "a", "python", "dictionary", "." ]
python
train
34.727273
splunk/splunk-sdk-python
examples/analytics/bottle.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1576-L1604
def path_shift(script_name, path_info, shift=1): ''' Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. :return: The modified paths. :param script_name: The SCRIPT_NAME path. :param script_name: The PATH_INFO path. :param shift: The number of path fragments to shift....
[ "def", "path_shift", "(", "script_name", ",", "path_info", ",", "shift", "=", "1", ")", ":", "if", "shift", "==", "0", ":", "return", "script_name", ",", "path_info", "pathlist", "=", "path_info", ".", "strip", "(", "'/'", ")", ".", "split", "(", "'/'"...
Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. :return: The modified paths. :param script_name: The SCRIPT_NAME path. :param script_name: The PATH_INFO path. :param shift: The number of path fragments to shift. May be negative to change the shift direction....
[ "Shift", "path", "fragments", "from", "PATH_INFO", "to", "SCRIPT_NAME", "and", "vice", "versa", "." ]
python
train
44.517241
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2534-L2553
def dropEvent(self, event): """Reimplement Qt method Unpack dropped data and handle it""" source = event.mimeData() # The second check is necessary when mimedata2url(source) # returns None. # Fixes issue 7742 if source.hasUrls() and mimedata2url(source): ...
[ "def", "dropEvent", "(", "self", ",", "event", ")", ":", "source", "=", "event", ".", "mimeData", "(", ")", "# The second check is necessary when mimedata2url(source)\r", "# returns None.\r", "# Fixes issue 7742\r", "if", "source", ".", "hasUrls", "(", ")", "and", "...
Reimplement Qt method Unpack dropped data and handle it
[ "Reimplement", "Qt", "method", "Unpack", "dropped", "data", "and", "handle", "it" ]
python
train
38.65
modlinltd/django-advanced-filters
advanced_filters/forms.py
https://github.com/modlinltd/django-advanced-filters/blob/ba51e6946d1652796a82b2b95cceffbe1190a227/advanced_filters/forms.py#L322-L338
def generate_query(self): """ Reduces multiple queries into a single usable query """ query = Q() ORed = [] for form in self._non_deleted_forms: if not hasattr(form, 'cleaned_data'): continue if form.cleaned_data['field'] == "_OR": ...
[ "def", "generate_query", "(", "self", ")", ":", "query", "=", "Q", "(", ")", "ORed", "=", "[", "]", "for", "form", "in", "self", ".", "_non_deleted_forms", ":", "if", "not", "hasattr", "(", "form", ",", "'cleaned_data'", ")", ":", "continue", "if", "...
Reduces multiple queries into a single usable query
[ "Reduces", "multiple", "queries", "into", "a", "single", "usable", "query" ]
python
train
34.823529
inspirehep/harvesting-kit
harvestingkit/configparser.py
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/configparser.py#L35-L83
def load_config(filename=None, section_option_dict={}): """ This function returns a Bunch object from the stated config file. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The values are not evaluated by default. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!...
[ "def", "load_config", "(", "filename", "=", "None", ",", "section_option_dict", "=", "{", "}", ")", ":", "config", "=", "ConfigParser", "(", ")", "config", ".", "read", "(", "filename", ")", "working_dict", "=", "_prepare_working_dict", "(", "config", ",", ...
This function returns a Bunch object from the stated config file. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The values are not evaluated by default. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! filename: The desired...
[ "This", "function", "returns", "a", "Bunch", "object", "from", "the", "stated", "config", "file", "." ]
python
valid
30.408163
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/factory.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/factory.py#L68-L77
def _propagate_url(self): """Ensure self.url contains full transport://interface:port""" if self.url: iface = self.url.split('://',1) if len(iface) == 2: self.transport,iface = iface iface = iface.split(':') self.ip = iface[0] i...
[ "def", "_propagate_url", "(", "self", ")", ":", "if", "self", ".", "url", ":", "iface", "=", "self", ".", "url", ".", "split", "(", "'://'", ",", "1", ")", "if", "len", "(", "iface", ")", "==", "2", ":", "self", ".", "transport", ",", "iface", ...
Ensure self.url contains full transport://interface:port
[ "Ensure", "self", ".", "url", "contains", "full", "transport", ":", "//", "interface", ":", "port" ]
python
test
36.7
apache/spark
python/pyspark/sql/session.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/session.py#L363-L380
def _inferSchemaFromList(self, data, names=None): """ Infer schema from list of Row or tuple. :param data: list of Row or tuple :param names: list of column names :return: :class:`pyspark.sql.types.StructType` """ if not data: raise ValueError("can no...
[ "def", "_inferSchemaFromList", "(", "self", ",", "data", ",", "names", "=", "None", ")", ":", "if", "not", "data", ":", "raise", "ValueError", "(", "\"can not infer schema from empty dataset\"", ")", "first", "=", "data", "[", "0", "]", "if", "type", "(", ...
Infer schema from list of Row or tuple. :param data: list of Row or tuple :param names: list of column names :return: :class:`pyspark.sql.types.StructType`
[ "Infer", "schema", "from", "list", "of", "Row", "or", "tuple", "." ]
python
train
41.611111
openfisca/openfisca-core
openfisca_core/taxscales.py
https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/taxscales.py#L275-L279
def scale_tax_scales(self, factor): """Scale all the MarginalRateTaxScales in the node.""" assert isinstance(factor, (float, int)) scaled_tax_scale = self.copy() return scaled_tax_scale.multiply_thresholds(factor)
[ "def", "scale_tax_scales", "(", "self", ",", "factor", ")", ":", "assert", "isinstance", "(", "factor", ",", "(", "float", ",", "int", ")", ")", "scaled_tax_scale", "=", "self", ".", "copy", "(", ")", "return", "scaled_tax_scale", ".", "multiply_thresholds",...
Scale all the MarginalRateTaxScales in the node.
[ "Scale", "all", "the", "MarginalRateTaxScales", "in", "the", "node", "." ]
python
train
48.2
mlaprise/genSpline
genSpline/genSpline.py
https://github.com/mlaprise/genSpline/blob/cedfb45bd6afde47042dd71292549493f27cd136/genSpline/genSpline.py#L420-L428
def sortedbyAge(self): ''' Sorting the pop. base of the age ''' ageAll = numpy.zeros(self.length) for i in range(self.length): ageAll[i] = self.Ind[i].age ageSorted = ageAll.argsort() return ageSorted[::-1]
[ "def", "sortedbyAge", "(", "self", ")", ":", "ageAll", "=", "numpy", ".", "zeros", "(", "self", ".", "length", ")", "for", "i", "in", "range", "(", "self", ".", "length", ")", ":", "ageAll", "[", "i", "]", "=", "self", ".", "Ind", "[", "i", "]"...
Sorting the pop. base of the age
[ "Sorting", "the", "pop", ".", "base", "of", "the", "age" ]
python
train
23.888889
EnigmaBridge/client.py
ebclient/eb_utils.py
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_utils.py#L123-L150
def update(dest, variation, path=None): """ Deep merges dictionary object variation into dest, dest keys in variation will be assigned new values from variation :param dest: :param variation: :param path: :return: """ if dest is None: r...
[ "def", "update", "(", "dest", ",", "variation", ",", "path", "=", "None", ")", ":", "if", "dest", "is", "None", ":", "return", "None", "if", "variation", "is", "None", ":", "return", "dest", "if", "path", "is", "None", ":", "path", "=", "[", "]", ...
Deep merges dictionary object variation into dest, dest keys in variation will be assigned new values from variation :param dest: :param variation: :param path: :return:
[ "Deep", "merges", "dictionary", "object", "variation", "into", "dest", "dest", "keys", "in", "variation", "will", "be", "assigned", "new", "values", "from", "variation", ":", "param", "dest", ":", ":", "param", "variation", ":", ":", "param", "path", ":", ...
python
train
31.214286
esheldon/fitsio
fitsio/hdu/table.py
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1102-L1188
def _read_rec_with_var( self, colnums, rows, dtype, offsets, isvar, vstorage): """ Read columns from a table into a rec array, including variable length columns. This is special because, for efficiency, it involves reading from the main table as normal but skipping the colum...
[ "def", "_read_rec_with_var", "(", "self", ",", "colnums", ",", "rows", ",", "dtype", ",", "offsets", ",", "isvar", ",", "vstorage", ")", ":", "colnumsp", "=", "colnums", "+", "1", "if", "rows", "is", "None", ":", "nrows", "=", "self", ".", "_info", "...
Read columns from a table into a rec array, including variable length columns. This is special because, for efficiency, it involves reading from the main table as normal but skipping the columns in the array that are variable. Then reading the variable length columns, with accounting f...
[ "Read", "columns", "from", "a", "table", "into", "a", "rec", "array", "including", "variable", "length", "columns", ".", "This", "is", "special", "because", "for", "efficiency", "it", "involves", "reading", "from", "the", "main", "table", "as", "normal", "bu...
python
train
42.103448
hyperledger/indy-plenum
plenum/common/batched.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/batched.py#L90-L147
def flushOutBoxes(self) -> None: """ Clear the outBoxes and transmit batched messages to remotes. """ removedRemotes = [] for rid, msgs in self.outBoxes.items(): try: dest = self.remotes[rid].name except KeyError: removedRem...
[ "def", "flushOutBoxes", "(", "self", ")", "->", "None", ":", "removedRemotes", "=", "[", "]", "for", "rid", ",", "msgs", "in", "self", ".", "outBoxes", ".", "items", "(", ")", ":", "try", ":", "dest", "=", "self", ".", "remotes", "[", "rid", "]", ...
Clear the outBoxes and transmit batched messages to remotes.
[ "Clear", "the", "outBoxes", "and", "transmit", "batched", "messages", "to", "remotes", "." ]
python
train
47.155172
dslackw/slpkg
slpkg/new_config.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/new_config.py#L183-L210
def diff(self, n): """Print the differences between the two files """ if os.path.isfile(n[:-4]): diff1 = Utils().read_file(n[:-4]).splitlines() if os.path.isfile(n): diff2 = Utils().read_file(n).splitlines() lines, l, c = [], 0, 0 for a, b in itert...
[ "def", "diff", "(", "self", ",", "n", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "n", "[", ":", "-", "4", "]", ")", ":", "diff1", "=", "Utils", "(", ")", ".", "read_file", "(", "n", "[", ":", "-", "4", "]", ")", ".", "splitlin...
Print the differences between the two files
[ "Print", "the", "differences", "between", "the", "two", "files" ]
python
train
37.357143
openstack/networking-cisco
networking_cisco/ml2_drivers/ucsm/deprecated_network_driver.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/ml2_drivers/ucsm/deprecated_network_driver.py#L179-L194
def _get_server_name(self, handle, service_profile_mo, ucsm_ip): """Get the contents of the 'Name' field associated with UCS Server. When a valid connection hande to UCS Manager is handed in, the Name field associated with a UCS Server is returned. """ try: resolved_...
[ "def", "_get_server_name", "(", "self", ",", "handle", ",", "service_profile_mo", ",", "ucsm_ip", ")", ":", "try", ":", "resolved_dest", "=", "handle", ".", "ConfigResolveDn", "(", "service_profile_mo", ".", "PnDn", ")", "server_list", "=", "resolved_dest", ".",...
Get the contents of the 'Name' field associated with UCS Server. When a valid connection hande to UCS Manager is handed in, the Name field associated with a UCS Server is returned.
[ "Get", "the", "contents", "of", "the", "Name", "field", "associated", "with", "UCS", "Server", "." ]
python
train
45.0625
SolutionsCloud/apidoc
setup_cmd/__init__.py
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/setup_cmd/__init__.py#L118-L123
def _merge_files(self, input_files, output_file): """Combine the input files to a big output file""" # we assume that all the input files have the same charset with open(output_file, mode='wb') as out: for input_file in input_files: out.write(open(input_file, mode='rb...
[ "def", "_merge_files", "(", "self", ",", "input_files", ",", "output_file", ")", ":", "# we assume that all the input files have the same charset", "with", "open", "(", "output_file", ",", "mode", "=", "'wb'", ")", "as", "out", ":", "for", "input_file", "in", "inp...
Combine the input files to a big output file
[ "Combine", "the", "input", "files", "to", "a", "big", "output", "file" ]
python
train
54.166667
quiltdata/quilt
compiler/quilt/tools/util.py
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/util.py#L36-L48
def parse_package_extended(identifier): """ Parses the extended package syntax and returns a tuple of (package, hash, version, tag). """ match = EXTENDED_PACKAGE_RE.match(identifier) if match is None: raise ValueError full_name, pkg_hash, version, tag = match.groups() team, user, na...
[ "def", "parse_package_extended", "(", "identifier", ")", ":", "match", "=", "EXTENDED_PACKAGE_RE", ".", "match", "(", "identifier", ")", "if", "match", "is", "None", ":", "raise", "ValueError", "full_name", ",", "pkg_hash", ",", "version", ",", "tag", "=", "...
Parses the extended package syntax and returns a tuple of (package, hash, version, tag).
[ "Parses", "the", "extended", "package", "syntax", "and", "returns", "a", "tuple", "of", "(", "package", "hash", "version", "tag", ")", "." ]
python
train
37.076923
mlperf/training
rnn_translator/pytorch/scripts/filter_dataset.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/scripts/filter_dataset.py#L17-L75
def main(): """ Discards all pairs of sentences which can't be decoded by latin-1 encoder. It aims to filter out sentences with rare unicode glyphs and pairs which are most likely not valid English-German sentences. Examples of discarded sentences: ✿★★★Hommage au king de la pop ★★★✿ ✿★★★Q...
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "c", "=", "Counter", "(", ")", "skipped", "=", "0", "valid", "=", "0", "data1", "=", "[", "]", "data2", "=", "[", "]", "with", "open", "(", "args", ".", "file1", ")", "as", "f...
Discards all pairs of sentences which can't be decoded by latin-1 encoder. It aims to filter out sentences with rare unicode glyphs and pairs which are most likely not valid English-German sentences. Examples of discarded sentences: ✿★★★Hommage au king de la pop ★★★✿ ✿★★★Que son âme repos... ...
[ "Discards", "all", "pairs", "of", "sentences", "which", "can", "t", "be", "decoded", "by", "latin", "-", "1", "encoder", "." ]
python
train
32.898305
dmbee/seglearn
seglearn/transform.py
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L329-L385
def transform(self, X, y=None, sample_weight=None): ''' Transforms the time series data into segments Note this transformation changes the number of samples in the data If y is provided, it is segmented and transformed to align to the new samples as per ``y_func`` Current...
[ "def", "transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "check_ts_data", "(", "X", ",", "y", ")", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "yt", "=", "y", "N", "=", "len", ...
Transforms the time series data into segments Note this transformation changes the number of samples in the data If y is provided, it is segmented and transformed to align to the new samples as per ``y_func`` Currently sample weights always returned as None Parameters --...
[ "Transforms", "the", "time", "series", "data", "into", "segments", "Note", "this", "transformation", "changes", "the", "number", "of", "samples", "in", "the", "data", "If", "y", "is", "provided", "it", "is", "segmented", "and", "transformed", "to", "align", ...
python
train
33.45614
explosion/spaCy
spacy/language.py
https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/language.py#L526-L567
def begin_training(self, get_gold_tuples=None, sgd=None, component_cfg=None, **cfg): """Allocate models, pre-process training data and acquire a trainer and optimizer. Used as a contextmanager. get_gold_tuples (function): Function returning gold data component_cfg (dict): Config paramet...
[ "def", "begin_training", "(", "self", ",", "get_gold_tuples", "=", "None", ",", "sgd", "=", "None", ",", "component_cfg", "=", "None", ",", "*", "*", "cfg", ")", ":", "if", "get_gold_tuples", "is", "None", ":", "get_gold_tuples", "=", "lambda", ":", "[",...
Allocate models, pre-process training data and acquire a trainer and optimizer. Used as a contextmanager. get_gold_tuples (function): Function returning gold data component_cfg (dict): Config parameters for specific components. **cfg: Config parameters. RETURNS: An optimizer. ...
[ "Allocate", "models", "pre", "-", "process", "training", "data", "and", "acquire", "a", "trainer", "and", "optimizer", ".", "Used", "as", "a", "contextmanager", "." ]
python
train
41.095238
sentinel-hub/sentinelhub-py
sentinelhub/geo_utils.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geo_utils.py#L178-L197
def wgs84_to_pixel(lng, lat, transform, utm_epsg=None, truncate=True): """ Convert WGS84 coordinates to pixel image coordinates given transform and UTM CRS. If no CRS is given it will be calculated it automatically. :param lng: longitude of point :type lng: float :param lat: latitude of point :...
[ "def", "wgs84_to_pixel", "(", "lng", ",", "lat", ",", "transform", ",", "utm_epsg", "=", "None", ",", "truncate", "=", "True", ")", ":", "east", ",", "north", "=", "wgs84_to_utm", "(", "lng", ",", "lat", ",", "utm_epsg", ")", "row", ",", "column", "=...
Convert WGS84 coordinates to pixel image coordinates given transform and UTM CRS. If no CRS is given it will be calculated it automatically. :param lng: longitude of point :type lng: float :param lat: latitude of point :type lat: float :param transform: georeferencing transform of the image, e....
[ "Convert", "WGS84", "coordinates", "to", "pixel", "image", "coordinates", "given", "transform", "and", "UTM", "CRS", ".", "If", "no", "CRS", "is", "given", "it", "will", "be", "calculated", "it", "automatically", "." ]
python
train
46.45
timgabets/bpc8583
bpc8583/transaction.py
https://github.com/timgabets/bpc8583/blob/1b8e95d73ad273ad9d11bff40d1af3f06f0f3503/bpc8583/transaction.py#L196-L208
def get_description(self): """ Get transaction description (for logging purposes) """ if self.card: card_description = self.card.get_description() else: card_description = 'Cardless' if card_description: card_description += ' | ' ...
[ "def", "get_description", "(", "self", ")", ":", "if", "self", ".", "card", ":", "card_description", "=", "self", ".", "card", ".", "get_description", "(", ")", "else", ":", "card_description", "=", "'Cardless'", "if", "card_description", ":", "card_descriptio...
Get transaction description (for logging purposes)
[ "Get", "transaction", "description", "(", "for", "logging", "purposes", ")" ]
python
train
34.692308
madisona/apysigner
apysigner.py
https://github.com/madisona/apysigner/blob/3666b478d228a38aca66a1b73d0aaf4aa67e765d/apysigner.py#L66-L85
def create_signature(self, base_url, payload=None): """ Creates unique signature for request. Make sure ALL 'GET' and 'POST' data is already included before creating the signature or receiver won't be able to re-create it. :param base_url: The url you'll using for yo...
[ "def", "create_signature", "(", "self", ",", "base_url", ",", "payload", "=", "None", ")", ":", "url", "=", "urlparse", "(", "base_url", ")", "url_to_sign", "=", "\"{path}?{query}\"", ".", "format", "(", "path", "=", "url", ".", "path", ",", "query", "="...
Creates unique signature for request. Make sure ALL 'GET' and 'POST' data is already included before creating the signature or receiver won't be able to re-create it. :param base_url: The url you'll using for your request. :param payload: The POST data that you'l...
[ "Creates", "unique", "signature", "for", "request", ".", "Make", "sure", "ALL", "GET", "and", "POST", "data", "is", "already", "included", "before", "creating", "the", "signature", "or", "receiver", "won", "t", "be", "able", "to", "re", "-", "create", "it"...
python
train
41.05
nyergler/hieroglyph
src/hieroglyph/writer.py
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/writer.py#L127-L133
def _add_slide_number(self, slide_no): """Add the slide number to the output if enabled.""" if self.builder.config.slide_numbers: self.body.append( '\n<div class="slide-no">%s</div>\n' % (slide_no,), )
[ "def", "_add_slide_number", "(", "self", ",", "slide_no", ")", ":", "if", "self", ".", "builder", ".", "config", ".", "slide_numbers", ":", "self", ".", "body", ".", "append", "(", "'\\n<div class=\"slide-no\">%s</div>\\n'", "%", "(", "slide_no", ",", ")", "...
Add the slide number to the output if enabled.
[ "Add", "the", "slide", "number", "to", "the", "output", "if", "enabled", "." ]
python
train
36
noxdafox/clipspy
clips/classes.py
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L554-L567
def allowed_classes(self): """Iterate over the allowed classes for this slot. The Python equivalent of the CLIPS slot-allowed-classes function. """ data = clips.data.DataObject(self._env) lib.EnvSlotAllowedClasses( self._env, self._cls, self._name, data.byref) ...
[ "def", "allowed_classes", "(", "self", ")", ":", "data", "=", "clips", ".", "data", ".", "DataObject", "(", "self", ".", "_env", ")", "lib", ".", "EnvSlotAllowedClasses", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "self", ".", "_name", ...
Iterate over the allowed classes for this slot. The Python equivalent of the CLIPS slot-allowed-classes function.
[ "Iterate", "over", "the", "allowed", "classes", "for", "this", "slot", "." ]
python
train
30.642857
sci-bots/pygtkhelpers
pygtkhelpers/debug/console.py
https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/debug/console.py#L56-L68
def _commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' prefix = m[0] for item in m: for i in range(len(prefix)): if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: ...
[ "def", "_commonprefix", "(", "m", ")", ":", "if", "not", "m", ":", "return", "''", "prefix", "=", "m", "[", "0", "]", "for", "item", "in", "m", ":", "for", "i", "in", "range", "(", "len", "(", "prefix", ")", ")", ":", "if", "prefix", "[", ":"...
Given a list of pathnames, returns the longest common leading component
[ "Given", "a", "list", "of", "pathnames", "returns", "the", "longest", "common", "leading", "component" ]
python
train
28.384615
pip-services3-python/pip-services3-commons-python
pip_services3_commons/reflect/PropertyReflector.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L43-L69
def has_property(obj, name): """ Checks if object has a property with specified name. :param obj: an object to introspect. :param name: a name of the property to check. :return: true if the object has the property and false if it doesn't. """ if obj == None: ...
[ "def", "has_property", "(", "obj", ",", "name", ")", ":", "if", "obj", "==", "None", ":", "raise", "Exception", "(", "\"Object cannot be null\"", ")", "if", "name", "==", "None", ":", "raise", "Exception", "(", "\"Property name cannot be null\"", ")", "name", ...
Checks if object has a property with specified name. :param obj: an object to introspect. :param name: a name of the property to check. :return: true if the object has the property and false if it doesn't.
[ "Checks", "if", "object", "has", "a", "property", "with", "specified", "name", "." ]
python
train
27.888889
gwastro/pycbc
pycbc/tmpltbank/brute_force_methods.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/brute_force_methods.py#L124-L347
def get_mass_distribution(bestMasses, scaleFactor, massRangeParams, metricParams, fUpper, numJumpPoints=100, chirpMassJumpFac=0.0001, etaJumpFac=0.01, spin1zJumpFac=0.01, spin2zJumpFac=0.01): """ Given a set ...
[ "def", "get_mass_distribution", "(", "bestMasses", ",", "scaleFactor", ",", "massRangeParams", ",", "metricParams", ",", "fUpper", ",", "numJumpPoints", "=", "100", ",", "chirpMassJumpFac", "=", "0.0001", ",", "etaJumpFac", "=", "0.01", ",", "spin1zJumpFac", "=", ...
Given a set of masses, this function will create a set of points nearby in the mass space and map these to the xi space. Parameters ----------- bestMasses : list Contains [ChirpMass, eta, spin1z, spin2z]. Points will be placed around tjos scaleFactor : float This parameter d...
[ "Given", "a", "set", "of", "masses", "this", "function", "will", "create", "a", "set", "of", "points", "nearby", "in", "the", "mass", "space", "and", "map", "these", "to", "the", "xi", "space", "." ]
python
train
45.580357
wummel/linkchecker
linkcheck/url.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/url.py#L483-L506
def splitport (host, port=0): """Split optional port number from host. If host has no port number, the given default port is returned. @param host: host name @ptype host: string @param port: the port number (default 0) @ptype port: int @return: tuple of (host, port) @rtype: tuple of (s...
[ "def", "splitport", "(", "host", ",", "port", "=", "0", ")", ":", "if", "\":\"", "in", "host", ":", "shost", ",", "sport", "=", "host", ".", "split", "(", "\":\"", ",", "1", ")", "iport", "=", "is_numeric_port", "(", "sport", ")", "if", "iport", ...
Split optional port number from host. If host has no port number, the given default port is returned. @param host: host name @ptype host: string @param port: the port number (default 0) @ptype port: int @return: tuple of (host, port) @rtype: tuple of (string, int)
[ "Split", "optional", "port", "number", "from", "host", ".", "If", "host", "has", "no", "port", "number", "the", "given", "default", "port", "is", "returned", "." ]
python
train
29.166667
bcbio/bcbio-nextgen
bcbio/ngsalign/tophat.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/tophat.py#L189-L193
def _add_rg(unmapped_file, config, names): """Add the missing RG header.""" picard = broad.runner_from_path("picard", config) rg_fixed = picard.run_fn("picard_fix_rgs", unmapped_file, names) return rg_fixed
[ "def", "_add_rg", "(", "unmapped_file", ",", "config", ",", "names", ")", ":", "picard", "=", "broad", ".", "runner_from_path", "(", "\"picard\"", ",", "config", ")", "rg_fixed", "=", "picard", ".", "run_fn", "(", "\"picard_fix_rgs\"", ",", "unmapped_file", ...
Add the missing RG header.
[ "Add", "the", "missing", "RG", "header", "." ]
python
train
43.6
quantmind/pulsar
pulsar/utils/tools/pidfile.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/tools/pidfile.py#L54-L65
def read(self): """ Validate pidfile and make it stale if needed""" if not self.fname: return try: with open(self.fname, "r") as f: wpid = int(f.read() or 0) if wpid <= 0: return return wpid excep...
[ "def", "read", "(", "self", ")", ":", "if", "not", "self", ".", "fname", ":", "return", "try", ":", "with", "open", "(", "self", ".", "fname", ",", "\"r\"", ")", "as", "f", ":", "wpid", "=", "int", "(", "f", ".", "read", "(", ")", "or", "0", ...
Validate pidfile and make it stale if needed
[ "Validate", "pidfile", "and", "make", "it", "stale", "if", "needed" ]
python
train
28.166667
markchil/gptools
gptools/kernel/warping.py
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L507-L531
def w_func(self, X, d, n): """Evaluate the (possibly recursive) warping function and its derivatives. Parameters ---------- X : array, (`M`,) The points (from dimension `d`) to evaluate the warping function at. d : int The dimension to warp. ...
[ "def", "w_func", "(", "self", ",", "X", ",", "d", ",", "n", ")", ":", "if", "n", "==", "0", ":", "wX", "=", "self", ".", "w", "(", "X", ",", "d", ",", "0", ")", "if", "isinstance", "(", "self", ".", "k", ",", "WarpedKernel", ")", ":", "wX...
Evaluate the (possibly recursive) warping function and its derivatives. Parameters ---------- X : array, (`M`,) The points (from dimension `d`) to evaluate the warping function at. d : int The dimension to warp. n : int The derivative ...
[ "Evaluate", "the", "(", "possibly", "recursive", ")", "warping", "function", "and", "its", "derivatives", ".", "Parameters", "----------", "X", ":", "array", "(", "M", ")", "The", "points", "(", "from", "dimension", "d", ")", "to", "evaluate", "the", "warp...
python
train
35.28
ucbvislab/radiotool
radiotool/algorithms/retarget.py
https://github.com/ucbvislab/radiotool/blob/01c9d878a811cf400b1482896d641d9c95e83ded/radiotool/algorithms/retarget.py#L170-L492
def retarget(songs, duration, music_labels=None, out_labels=None, out_penalty=None, volume=None, volume_breakpoints=None, springs=None, constraints=None, min_beats=None, max_beats=None, fade_in_len=3.0, fade_out_len=5.0, **kwargs): """Retarget a song ...
[ "def", "retarget", "(", "songs", ",", "duration", ",", "music_labels", "=", "None", ",", "out_labels", "=", "None", ",", "out_penalty", "=", "None", ",", "volume", "=", "None", ",", "volume_breakpoints", "=", "None", ",", "springs", "=", "None", ",", "co...
Retarget a song to a duration given input and output labels on the music. Suppose you like one section of a song, say, the guitar solo, and you want to create a three minute long version of the solo. Suppose the guitar solo occurs from the 150 second mark to the 200 second mark in the original song...
[ "Retarget", "a", "song", "to", "a", "duration", "given", "input", "and", "output", "labels", "on", "the", "music", "." ]
python
train
36.20743
brentp/cruzdb
cruzdb/__init__.py
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L94-L110
def mirror(self, tables, dest_url): """ miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db' """ ...
[ "def", "mirror", "(", "self", ",", "tables", ",", "dest_url", ")", ":", "from", "mirror", "import", "mirror", "return", "mirror", "(", "self", ",", "tables", ",", "dest_url", ")" ]
miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db'
[ "miror", "a", "set", "of", "tables", "from", "dest_url" ]
python
train
22.411765
estnltk/estnltk
estnltk/text.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L937-L941
def timex_spans(self): """The list of spans of ``timexes`` layer elements.""" if not self.is_tagged(TIMEXES): self.tag_timexes() return self.spans(TIMEXES)
[ "def", "timex_spans", "(", "self", ")", ":", "if", "not", "self", ".", "is_tagged", "(", "TIMEXES", ")", ":", "self", ".", "tag_timexes", "(", ")", "return", "self", ".", "spans", "(", "TIMEXES", ")" ]
The list of spans of ``timexes`` layer elements.
[ "The", "list", "of", "spans", "of", "timexes", "layer", "elements", "." ]
python
train
37.4
tensorflow/tensorboard
tensorboard/plugins/debugger/tensor_helper.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/debugger/tensor_helper.py#L43-L62
def parse_time_indices(s): """Parse a string as time indices. Args: s: A valid slicing string for time indices. E.g., '-1', '[:]', ':', '2:10' Returns: A slice object. Raises: ValueError: If `s` does not represent valid time indices. """ if not s.startswith('['): s = '[' + s + ']' parse...
[ "def", "parse_time_indices", "(", "s", ")", ":", "if", "not", "s", ".", "startswith", "(", "'['", ")", ":", "s", "=", "'['", "+", "s", "+", "']'", "parsed", "=", "command_parser", ".", "_parse_slices", "(", "s", ")", "if", "len", "(", "parsed", ")"...
Parse a string as time indices. Args: s: A valid slicing string for time indices. E.g., '-1', '[:]', ':', '2:10' Returns: A slice object. Raises: ValueError: If `s` does not represent valid time indices.
[ "Parse", "a", "string", "as", "time", "indices", "." ]
python
train
24.5
ucsb-cs/submit
submit/models.py
https://github.com/ucsb-cs/submit/blob/92810c81255a4fc6bbebac1ac8aae856fd576ffe/submit/models.py#L1084-L1096
def create_schema(alembic_config_ini=None): """Create the database schema. :param alembic_config_ini: When provided, stamp with the current revision version. """ Base.metadata.create_all() if alembic_config_ini: from alembic.config import Config from alembic import command ...
[ "def", "create_schema", "(", "alembic_config_ini", "=", "None", ")", ":", "Base", ".", "metadata", ".", "create_all", "(", ")", "if", "alembic_config_ini", ":", "from", "alembic", ".", "config", "import", "Config", "from", "alembic", "import", "command", "alem...
Create the database schema. :param alembic_config_ini: When provided, stamp with the current revision version.
[ "Create", "the", "database", "schema", "." ]
python
train
30.384615
openstack/quark
quark/drivers/nvp_driver.py
https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/nvp_driver.py#L587-L600
def _lswitch_select_open(self, context, switches=None, **kwargs): """Selects an open lswitch for a network. Note that it does not select the most full switch, but merely one with ports available. """ if switches is not None: for res in switches["results"]: ...
[ "def", "_lswitch_select_open", "(", "self", ",", "context", ",", "switches", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "switches", "is", "not", "None", ":", "for", "res", "in", "switches", "[", "\"results\"", "]", ":", "count", "=", "res", ...
Selects an open lswitch for a network. Note that it does not select the most full switch, but merely one with ports available.
[ "Selects", "an", "open", "lswitch", "for", "a", "network", "." ]
python
valid
40.714286
davesque/django-rest-framework-simplejwt
rest_framework_simplejwt/authentication.py
https://github.com/davesque/django-rest-framework-simplejwt/blob/d6084c595aefbf97865d15254b56017e710e8e47/rest_framework_simplejwt/authentication.py#L59-L80
def get_raw_token(self, header): """ Extracts an unvalidated JSON web token from the given "Authorization" header value. """ parts = header.split() if len(parts) == 0: # Empty AUTHORIZATION header sent return None if parts[0] not in AUTH_...
[ "def", "get_raw_token", "(", "self", ",", "header", ")", ":", "parts", "=", "header", ".", "split", "(", ")", "if", "len", "(", "parts", ")", "==", "0", ":", "# Empty AUTHORIZATION header sent", "return", "None", "if", "parts", "[", "0", "]", "not", "i...
Extracts an unvalidated JSON web token from the given "Authorization" header value.
[ "Extracts", "an", "unvalidated", "JSON", "web", "token", "from", "the", "given", "Authorization", "header", "value", "." ]
python
train
29.409091
nyaruka/smartmin
smartmin/views.py
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L659-L679
def order_queryset(self, queryset): """ Orders the passed in queryset, returning a new queryset in response. By default uses the _order query parameter. """ order = self.derive_ordering() # if we get our order from the request # make sure it is a valid field in ...
[ "def", "order_queryset", "(", "self", ",", "queryset", ")", ":", "order", "=", "self", ".", "derive_ordering", "(", ")", "# if we get our order from the request", "# make sure it is a valid field in the list", "if", "'_order'", "in", "self", ".", "request", ".", "GET"...
Orders the passed in queryset, returning a new queryset in response. By default uses the _order query parameter.
[ "Orders", "the", "passed", "in", "queryset", "returning", "a", "new", "queryset", "in", "response", ".", "By", "default", "uses", "the", "_order", "query", "parameter", "." ]
python
train
32.285714
codenerix/django-codenerix
codenerix/multiforms.py
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L329-L334
def form_invalid(self, form, forms, open_tabs, position_form_default): """ Called if a form is invalid. Re-renders the context data with the data-filled forms and errors. """ # return self.render_to_response( self.get_context_data( form = form, forms = forms ) ) return self.rende...
[ "def", "form_invalid", "(", "self", ",", "form", ",", "forms", ",", "open_tabs", ",", "position_form_default", ")", ":", "# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )", "return", "self", ".", "render_to_response", "(", "self", ".",...
Called if a form is invalid. Re-renders the context data with the data-filled forms and errors.
[ "Called", "if", "a", "form", "is", "invalid", ".", "Re", "-", "renders", "the", "context", "data", "with", "the", "data", "-", "filled", "forms", "and", "errors", "." ]
python
train
73.5
merll/docker-map
dockermap/map/yaml.py
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/yaml.py#L56-L78
def load_map(stream, name=None, check_integrity=True, check_duplicates=True): """ Loads a ContainerMap configuration from a YAML document stream. :param stream: YAML stream. :type stream: file :param name: Name of the ContainerMap. If not provided, will be attempted to read from a ``name`` attribut...
[ "def", "load_map", "(", "stream", ",", "name", "=", "None", ",", "check_integrity", "=", "True", ",", "check_duplicates", "=", "True", ")", ":", "map_dict", "=", "yaml", ".", "safe_load", "(", "stream", ")", "if", "isinstance", "(", "map_dict", ",", "dic...
Loads a ContainerMap configuration from a YAML document stream. :param stream: YAML stream. :type stream: file :param name: Name of the ContainerMap. If not provided, will be attempted to read from a ``name`` attribute on the document root level. :type name: unicode | str :param check_integri...
[ "Loads", "a", "ContainerMap", "configuration", "from", "a", "YAML", "document", "stream", "." ]
python
train
46.913043
Robpol86/libnl
libnl/socket_.py
https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/socket_.py#L51-L61
def generate_local_port(): """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L63.""" global _PREVIOUS_LOCAL_PORT if _PREVIOUS_LOCAL_PORT is None: try: with contextlib.closing(socket.socket(getattr(socket, 'AF_NETLINK', -1), socket.SOCK_RAW)) as s: s.bind((...
[ "def", "generate_local_port", "(", ")", ":", "global", "_PREVIOUS_LOCAL_PORT", "if", "_PREVIOUS_LOCAL_PORT", "is", "None", ":", "try", ":", "with", "contextlib", ".", "closing", "(", "socket", ".", "socket", "(", "getattr", "(", "socket", ",", "'AF_NETLINK'", ...
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L63.
[ "https", ":", "//", "github", ".", "com", "/", "thom311", "/", "libnl", "/", "blob", "/", "libnl3_2_25", "/", "lib", "/", "socket", ".", "c#L63", "." ]
python
train
45.454545
tensorflow/probability
tensorflow_probability/python/distributions/mixture.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/mixture.py#L497-L502
def _cat_probs(self, log_probs): """Get a list of num_components batchwise probabilities.""" which_softmax = tf.nn.log_softmax if log_probs else tf.nn.softmax cat_probs = which_softmax(self.cat.logits) cat_probs = tf.unstack(cat_probs, num=self.num_components, axis=-1) return cat_probs
[ "def", "_cat_probs", "(", "self", ",", "log_probs", ")", ":", "which_softmax", "=", "tf", ".", "nn", ".", "log_softmax", "if", "log_probs", "else", "tf", ".", "nn", ".", "softmax", "cat_probs", "=", "which_softmax", "(", "self", ".", "cat", ".", "logits"...
Get a list of num_components batchwise probabilities.
[ "Get", "a", "list", "of", "num_components", "batchwise", "probabilities", "." ]
python
test
50.166667
XuShaohua/bcloud
bcloud/Shutdown.py
https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/Shutdown.py#L127-L149
def _prepair(self): '''Try to connect to the given dbus services. If successful it will return a callable dbus proxy and those arguments. ''' try: sessionbus = dbus.SessionBus() systembus = dbus.SystemBus() except: return (None, None) ...
[ "def", "_prepair", "(", "self", ")", ":", "try", ":", "sessionbus", "=", "dbus", ".", "SessionBus", "(", ")", "systembus", "=", "dbus", ".", "SystemBus", "(", ")", "except", ":", "return", "(", "None", ",", "None", ")", "for", "dbus_props", "in", "se...
Try to connect to the given dbus services. If successful it will return a callable dbus proxy and those arguments.
[ "Try", "to", "connect", "to", "the", "given", "dbus", "services", ".", "If", "successful", "it", "will", "return", "a", "callable", "dbus", "proxy", "and", "those", "arguments", "." ]
python
train
41.304348
tensorflow/tensor2tensor
tensor2tensor/envs/rendered_env_problem.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/envs/rendered_env_problem.py#L87-L108
def _generate_time_steps(self, trajectory_list): """Transforms time step observations to frames of a video.""" for time_step in env_problem.EnvProblem._generate_time_steps( self, trajectory_list): # Convert the rendered observations from numpy to png format. frame_np = np.array(time_step.pop...
[ "def", "_generate_time_steps", "(", "self", ",", "trajectory_list", ")", ":", "for", "time_step", "in", "env_problem", ".", "EnvProblem", ".", "_generate_time_steps", "(", "self", ",", "trajectory_list", ")", ":", "# Convert the rendered observations from numpy to png for...
Transforms time step observations to frames of a video.
[ "Transforms", "time", "step", "observations", "to", "frames", "of", "a", "video", "." ]
python
train
46.954545
hozn/coilmq
coilmq/store/dbm.py
https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L146-L172
def enqueue(self, destination, frame): """ Store message (frame) for specified destinationination. @param destination: The destinationination queue name for this message (frame). @type destination: C{str} @param frame: The message (frame) to send to specified destinationination...
[ "def", "enqueue", "(", "self", ",", "destination", ",", "frame", ")", ":", "message_id", "=", "frame", ".", "headers", ".", "get", "(", "'message-id'", ")", "if", "not", "message_id", ":", "raise", "ValueError", "(", "\"Cannot queue a frame without message-id se...
Store message (frame) for specified destinationination. @param destination: The destinationination queue name for this message (frame). @type destination: C{str} @param frame: The message (frame) to send to specified destinationination. @type frame: C{stompclient.frame.Frame}
[ "Store", "message", "(", "frame", ")", "for", "specified", "destinationination", "." ]
python
train
38.814815
urinieto/msaf
msaf/run.py
https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/run.py#L220-L262
def process_track(file_struct, boundaries_id, labels_id, config, annotator_id=0): """Prepares the parameters, runs the algorithms, and saves results. Parameters ---------- file_struct: `msaf.io.FileStruct` FileStruct containing the paths of the input files (audio file, ...
[ "def", "process_track", "(", "file_struct", ",", "boundaries_id", ",", "labels_id", ",", "config", ",", "annotator_id", "=", "0", ")", ":", "logging", ".", "info", "(", "\"Segmenting %s\"", "%", "file_struct", ".", "audio_file", ")", "# Get features", "config", ...
Prepares the parameters, runs the algorithms, and saves results. Parameters ---------- file_struct: `msaf.io.FileStruct` FileStruct containing the paths of the input files (audio file, features file, reference file, output estimation file). boundaries_id: str Identifier of the b...
[ "Prepares", "the", "parameters", "runs", "the", "algorithms", "and", "saves", "results", "." ]
python
test
36.604651
openvax/varcode
varcode/effects/effect_prediction_coding_in_frame.py
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_prediction_coding_in_frame.py#L36-L107
def get_codons( variant, trimmed_cdna_ref, trimmed_cdna_alt, sequence_from_start_codon, cds_offset): """ Returns indices of first and last reference codons affected by the variant, as well as the actual sequence of the mutated codons which replace those reference ...
[ "def", "get_codons", "(", "variant", ",", "trimmed_cdna_ref", ",", "trimmed_cdna_alt", ",", "sequence_from_start_codon", ",", "cds_offset", ")", ":", "# index (starting from 0) of first affected reference codon", "ref_codon_start_offset", "=", "cds_offset", "//", "3", "# whic...
Returns indices of first and last reference codons affected by the variant, as well as the actual sequence of the mutated codons which replace those reference codons. Parameters ---------- variant : Variant trimmed_cdna_ref : str Trimmed reference cDNA nucleotides affected by the varia...
[ "Returns", "indices", "of", "first", "and", "last", "reference", "codons", "affected", "by", "the", "variant", "as", "well", "as", "the", "actual", "sequence", "of", "the", "mutated", "codons", "which", "replace", "those", "reference", "codons", "." ]
python
train
39.708333