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
trp07/messages
messages/_config.py
https://github.com/trp07/messages/blob/7789ebc960335a59ea5d319fceed3dd349023648/messages/_config.py#L236-L251
def configure_profile(msg_type, profile_name, data, auth): """ Create the profile entry. Args: :msg_type: (str) message type to create config entry. :profile_name: (str) name of the profile entry :data: (dict) dict values for the 'settings' :auth: (dict) auth parameters ...
[ "def", "configure_profile", "(", "msg_type", ",", "profile_name", ",", "data", ",", "auth", ")", ":", "with", "jsonconfig", ".", "Config", "(", "\"messages\"", ",", "indent", "=", "4", ")", "as", "cfg", ":", "write_data", "(", "msg_type", ",", "profile_nam...
Create the profile entry. Args: :msg_type: (str) message type to create config entry. :profile_name: (str) name of the profile entry :data: (dict) dict values for the 'settings' :auth: (dict) auth parameters
[ "Create", "the", "profile", "entry", "." ]
python
test
38.0625
venthur/python-debianbts
debianbts/debianbts.py
https://github.com/venthur/python-debianbts/blob/72cf11ae3458a8544142e9f365aaafe25634dd4f/debianbts/debianbts.py#L497-L508
def _convert_soap_method_args(*args): """Convert arguments to be consumed by a SoapClient method Soap client required a list of named arguments: >>> _convert_soap_method_args('a', 1) [('arg0', 'a'), ('arg1', 1)] """ soap_args = [] for arg_n, arg in enumerate(args): soap_args.append...
[ "def", "_convert_soap_method_args", "(", "*", "args", ")", ":", "soap_args", "=", "[", "]", "for", "arg_n", ",", "arg", "in", "enumerate", "(", "args", ")", ":", "soap_args", ".", "append", "(", "(", "'arg'", "+", "str", "(", "arg_n", ")", ",", "arg"...
Convert arguments to be consumed by a SoapClient method Soap client required a list of named arguments: >>> _convert_soap_method_args('a', 1) [('arg0', 'a'), ('arg1', 1)]
[ "Convert", "arguments", "to", "be", "consumed", "by", "a", "SoapClient", "method" ]
python
train
29.75
pkgw/pwkit
pwkit/fk10.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L499-L547
def set_hybrid_parameters(self, s_C, s_WH, do_renorm=True): """Set the hybrid/renormalization control parameters. **Call signature** *s_C* The harmonic number above which the continuous approximation is used (with special behavior; see below). *s_WH* The h...
[ "def", "set_hybrid_parameters", "(", "self", ",", "s_C", ",", "s_WH", ",", "do_renorm", "=", "True", ")", ":", "self", ".", "in_vals", "[", "IN_VAL_FCCR", "]", "=", "s_C", "self", ".", "in_vals", "[", "IN_VAL_FWHCR", "]", "=", "s_WH", "self", ".", "in_...
Set the hybrid/renormalization control parameters. **Call signature** *s_C* The harmonic number above which the continuous approximation is used (with special behavior; see below). *s_WH* The harmonic number above which the Wild-Hill BEssel function appr...
[ "Set", "the", "hybrid", "/", "renormalization", "control", "parameters", "." ]
python
train
46.142857
tomekwojcik/envelopes
envelopes/envelope.py
https://github.com/tomekwojcik/envelopes/blob/8ad190a55d0d8b805b6ae545b896e719467253b7/envelopes/envelope.py#L322-L330
def send(self, *args, **kwargs): """Sends the envelope using a freshly created SMTP connection. *args* and *kwargs* are passed directly to :py:class:`envelopes.conn.SMTP` constructor. Returns a tuple of SMTP object and whatever its send method returns.""" conn = SMTP(*args, **kw...
[ "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "SMTP", "(", "*", "args", ",", "*", "*", "kwargs", ")", "send_result", "=", "conn", ".", "send", "(", "self", ")", "return", "conn", ",", "send_result" ...
Sends the envelope using a freshly created SMTP connection. *args* and *kwargs* are passed directly to :py:class:`envelopes.conn.SMTP` constructor. Returns a tuple of SMTP object and whatever its send method returns.
[ "Sends", "the", "envelope", "using", "a", "freshly", "created", "SMTP", "connection", ".", "*", "args", "*", "and", "*", "kwargs", "*", "are", "passed", "directly", "to", ":", "py", ":", "class", ":", "envelopes", ".", "conn", ".", "SMTP", "constructor",...
python
train
43.111111
Karaage-Cluster/python-tldap
tldap/fields.py
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L213-L219
def value_validate(self, value): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not isinstance(value, six.string_types): raise tldap.exceptions.ValidationError("should be a string")
[ "def", "value_validate", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be a string\"", ")" ]
Validates value and throws ValidationError. Subclasses should override this to provide validation logic.
[ "Validates", "value", "and", "throws", "ValidationError", ".", "Subclasses", "should", "override", "this", "to", "provide", "validation", "logic", "." ]
python
train
42.285714
mitsei/dlkit
dlkit/json_/grading/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/managers.py#L1454-L1477
def get_grade_entry_admin_session_for_gradebook(self, gradebook_id, proxy): """Gets the ``OsidSession`` associated with the grade entry admin service for the given gradebook. arg: gradebook_id (osid.id.Id): the ``Id`` of the gradebook arg: proxy (osid.proxy.Proxy): a proxy return:...
[ "def", "get_grade_entry_admin_session_for_gradebook", "(", "self", ",", "gradebook_id", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_grade_entry_admin", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "##", "# Also include check to s...
Gets the ``OsidSession`` associated with the grade entry admin service for the given gradebook. arg: gradebook_id (osid.id.Id): the ``Id`` of the gradebook arg: proxy (osid.proxy.Proxy): a proxy return: (osid.grading.GradeEntryAdminSession) - ``a GradeEntryAdminSession`` ...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "grade", "entry", "admin", "service", "for", "the", "given", "gradebook", "." ]
python
train
50.625
ajenhl/tacl
tacl/jitc.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/jitc.py#L145-L164
def _create_related_chart(self, data, work, output_dir): """Generates and writes to a file in `output_dir` the data used to display a grouped bar chart. This data gives, for each "maybe" work, the percentage of it that is shared with `work`, and the percentage of `work` that is ...
[ "def", "_create_related_chart", "(", "self", ",", "data", ",", "work", ",", "output_dir", ")", ":", "chart_data", "=", "data", "[", "work", "]", ".", "dropna", "(", ")", ".", "sort_values", "(", "by", "=", "SHARED_RELATED_WORK", ",", "ascending", "=", "F...
Generates and writes to a file in `output_dir` the data used to display a grouped bar chart. This data gives, for each "maybe" work, the percentage of it that is shared with `work`, and the percentage of `work` that is shared with the "maybe" work. :param data: data to derive t...
[ "Generates", "and", "writes", "to", "a", "file", "in", "output_dir", "the", "data", "used", "to", "display", "a", "grouped", "bar", "chart", "." ]
python
train
43.4
push-things/django-th
th_rss/lib/conditionchecker/conditionchecker.py
https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/th_rss/lib/conditionchecker/conditionchecker.py#L53-L61
def filter_that(self, criteria, data): ''' this method just use the module 're' to check if the data contain the string to find ''' import re prog = re.compile(criteria) return True if prog.match(data) else False
[ "def", "filter_that", "(", "self", ",", "criteria", ",", "data", ")", ":", "import", "re", "prog", "=", "re", ".", "compile", "(", "criteria", ")", "return", "True", "if", "prog", ".", "match", "(", "data", ")", "else", "False" ]
this method just use the module 're' to check if the data contain the string to find
[ "this", "method", "just", "use", "the", "module", "re", "to", "check", "if", "the", "data", "contain", "the", "string", "to", "find" ]
python
train
29.888889
push-things/django-th
django_th/views_userservices.py
https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/django_th/views_userservices.py#L168-L176
def get_form_kwargs(self): """ initialize default value that won't be displayed :return: """ kwargs = super(UserServiceUpdateView, self).get_form_kwargs() kwargs['initial']['user'] = self.request.user kwargs['initial']['name'] = self.object.name return kwa...
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "UserServiceUpdateView", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "kwargs", "[", "'initial'", "]", "[", "'user'", "]", "=", "self", ".", "request", ".", "user", "kwa...
initialize default value that won't be displayed :return:
[ "initialize", "default", "value", "that", "won", "t", "be", "displayed", ":", "return", ":" ]
python
train
35
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/billing/models/service_package_quota_history_reservation.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/billing/models/service_package_quota_history_reservation.py#L125-L140
def id(self, id): """ Sets the id of this ServicePackageQuotaHistoryReservation. Reservation ID. :param id: The id of this ServicePackageQuotaHistoryReservation. :type: str """ if id is None: raise ValueError("Invalid value for `id`, must not be `None...
[ "def", "id", "(", "self", ",", "id", ")", ":", "if", "id", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `id`, must not be `None`\"", ")", "if", "id", "is", "not", "None", "and", "len", "(", "id", ")", ">", "250", ":", "raise", "V...
Sets the id of this ServicePackageQuotaHistoryReservation. Reservation ID. :param id: The id of this ServicePackageQuotaHistoryReservation. :type: str
[ "Sets", "the", "id", "of", "this", "ServicePackageQuotaHistoryReservation", ".", "Reservation", "ID", "." ]
python
train
38.625
HazyResearch/pdftotree
pdftotree/utils/pdf/grid.py
https://github.com/HazyResearch/pdftotree/blob/5890d668b475d5d3058d1d886aafbfd83268c440/pdftotree/utils/pdf/grid.py#L118-L144
def get_normalized_grid(self): """ Analyzes subcell structure """ log = logging.getLogger(__name__) # Resolve multirow mentions, TODO: validate against all PDFs # subcol_count = 0 mega_rows = [] for row_id, row in enumerate(self._grid): # maps...
[ "def", "get_normalized_grid", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", "# Resolve multirow mentions, TODO: validate against all PDFs", "# subcol_count = 0", "mega_rows", "=", "[", "]", "for", "row_id", ",", "row", "in", ...
Analyzes subcell structure
[ "Analyzes", "subcell", "structure" ]
python
train
33
briney/abutils
abutils/plots/summary.py
https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/plots/summary.py#L111-L144
def _aggregate(data, norm=True, sort_by='value', keys=None): ''' Counts the number of occurances of each item in 'data'. Inputs data: a list of values. norm: normalize the resulting counts (as percent) sort_by: how to sort the retured data. Options are 'value' and 'count'. Output a non...
[ "def", "_aggregate", "(", "data", ",", "norm", "=", "True", ",", "sort_by", "=", "'value'", ",", "keys", "=", "None", ")", ":", "if", "keys", ":", "vdict", "=", "{", "k", ":", "0", "for", "k", "in", "keys", "}", "for", "d", "in", "data", ":", ...
Counts the number of occurances of each item in 'data'. Inputs data: a list of values. norm: normalize the resulting counts (as percent) sort_by: how to sort the retured data. Options are 'value' and 'count'. Output a non-redundant list of values (from 'data') and a list of counts.
[ "Counts", "the", "number", "of", "occurances", "of", "each", "item", "in", "data", "." ]
python
train
28.617647
gijzelaerr/python-snap7
snap7/util.py
https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/util.py#L179-L205
def set_string(_bytearray, byte_index, value, max_size): """ Set string value :params value: string data :params max_size: max possible string size """ if six.PY2: assert isinstance(value, (str, unicode)) else: assert isinstance(value, str) size = len(value) # FAIL ...
[ "def", "set_string", "(", "_bytearray", ",", "byte_index", ",", "value", ",", "max_size", ")", ":", "if", "six", ".", "PY2", ":", "assert", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", "else", ":", "assert", "isinstance", "(",...
Set string value :params value: string data :params max_size: max possible string size
[ "Set", "string", "value" ]
python
train
29.444444
d0c-s4vage/pfp
pfp/native/compat_tools.py
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_tools.py#L47-L133
def Checksum(params, ctxt, scope, stream, coord): """ Runs a simple checksum on a file and returns the result as a int64. The algorithm can be one of the following constants: CHECKSUM_BYTE - Treats the file as a set of unsigned bytes CHECKSUM_SHORT_LE - Treats the file as a set of unsigned little-e...
[ "def", "Checksum", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "checksum_types", "=", "{", "0", ":", "\"CHECKSUM_BYTE\"", ",", "# Treats the file as a set of unsigned bytes", "1", ":", "\"CHECKSUM_SHORT_LE\"", ",", "# Treats th...
Runs a simple checksum on a file and returns the result as a int64. The algorithm can be one of the following constants: CHECKSUM_BYTE - Treats the file as a set of unsigned bytes CHECKSUM_SHORT_LE - Treats the file as a set of unsigned little-endian shorts CHECKSUM_SHORT_BE - Treats the file as a set ...
[ "Runs", "a", "simple", "checksum", "on", "a", "file", "and", "returns", "the", "result", "as", "a", "int64", ".", "The", "algorithm", "can", "be", "one", "of", "the", "following", "constants", ":" ]
python
train
41.505747
abseil/abseil-py
absl/flags/_flagvalues.py
https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L663-L796
def _parse_args(self, args, known_only): """Helper function to do the main argument parsing. This function goes through args and does the bulk of the flag parsing. It will find the corresponding flag in our flag dictionary, and call its .parse() method on the flag value. Args: args: [str], a...
[ "def", "_parse_args", "(", "self", ",", "args", ",", "known_only", ")", ":", "unparsed_names_and_args", "=", "[", "]", "# A list of (flag name or None, arg).", "undefok", "=", "set", "(", ")", "retired_flag_func", "=", "self", ".", "__dict__", "[", "'__is_retired_...
Helper function to do the main argument parsing. This function goes through args and does the bulk of the flag parsing. It will find the corresponding flag in our flag dictionary, and call its .parse() method on the flag value. Args: args: [str], a list of strings with the arguments to parse. ...
[ "Helper", "function", "to", "do", "the", "main", "argument", "parsing", "." ]
python
train
31.731343
iotile/coretools
iotilesensorgraph/iotile/sg/sim/trace.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/trace.py#L39-L52
def save(self, out_path): """Save an ascii representation of this simulation trace. Args: out_path (str): The output path to save this simulation trace. """ out = { 'selectors': [str(x) for x in self.selectors], 'trace': [{'stream': str(DataStream.Fr...
[ "def", "save", "(", "self", ",", "out_path", ")", ":", "out", "=", "{", "'selectors'", ":", "[", "str", "(", "x", ")", "for", "x", "in", "self", ".", "selectors", "]", ",", "'trace'", ":", "[", "{", "'stream'", ":", "str", "(", "DataStream", ".",...
Save an ascii representation of this simulation trace. Args: out_path (str): The output path to save this simulation trace.
[ "Save", "an", "ascii", "representation", "of", "this", "simulation", "trace", "." ]
python
train
36.571429
auth0/auth0-python
auth0/v3/management/guardian.py
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L48-L58
def update_templates(self, body): """Update enrollment and verification SMS templates. Useful to send custom messages on sms enrollment and verification Args: body (dict): Attributes to modify. See: https://auth0.com/docs/api/management/v2#!/Guardian/put_templates ...
[ "def", "update_templates", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "put", "(", "self", ".", "_url", "(", "'factors/sms/templates'", ")", ",", "data", "=", "body", ")" ]
Update enrollment and verification SMS templates. Useful to send custom messages on sms enrollment and verification Args: body (dict): Attributes to modify. See: https://auth0.com/docs/api/management/v2#!/Guardian/put_templates
[ "Update", "enrollment", "and", "verification", "SMS", "templates", "." ]
python
train
35.909091
freakboy3742/pyxero
xero/auth.py
https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L179-L210
def _process_oauth_response(self, response): "Extracts the fields from an oauth response" if response.status_code == 200: credentials = parse_qs(response.text) # Initialize the oauth credentials self._init_oauth( credentials.get('oauth_token')[0], ...
[ "def", "_process_oauth_response", "(", "self", ",", "response", ")", ":", "if", "response", ".", "status_code", "==", "200", ":", "credentials", "=", "parse_qs", "(", "response", ".", "text", ")", "# Initialize the oauth credentials", "self", ".", "_init_oauth", ...
Extracts the fields from an oauth response
[ "Extracts", "the", "fields", "from", "an", "oauth", "response" ]
python
train
43.46875
theislab/scanpy
scanpy/tools/_dpt.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/tools/_dpt.py#L289-L364
def select_segment(self, segs, segs_tips, segs_undecided) -> Tuple[int, int]: """Out of a list of line segments, choose segment that has the most distant second data point. Assume the distance matrix Ddiff is sorted according to seg_idcs. Compute all the distances. Returns ...
[ "def", "select_segment", "(", "self", ",", "segs", ",", "segs_tips", ",", "segs_undecided", ")", "->", "Tuple", "[", "int", ",", "int", "]", ":", "scores_tips", "=", "np", ".", "zeros", "(", "(", "len", "(", "segs", ")", ",", "4", ")", ")", "allind...
Out of a list of line segments, choose segment that has the most distant second data point. Assume the distance matrix Ddiff is sorted according to seg_idcs. Compute all the distances. Returns ------- iseg : int Index identifying the position within the list...
[ "Out", "of", "a", "list", "of", "line", "segments", "choose", "segment", "that", "has", "the", "most", "distant", "second", "data", "point", "." ]
python
train
52.052632
cjdrake/pyeda
pyeda/boolalg/bfarray.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bfarray.py#L778-L805
def rsh(self, num, cin=None): """Right shift the farray by *num* places. The *num* argument must be a non-negative ``int``. If the *cin* farray is provided, it will be shifted in. Otherwise, the carry-in is zero. Returns a two-tuple (farray fs, farray cout), where *fs*...
[ "def", "rsh", "(", "self", ",", "num", ",", "cin", "=", "None", ")", ":", "if", "num", "<", "0", "or", "num", ">", "self", ".", "size", ":", "raise", "ValueError", "(", "\"expected 0 <= num <= {0.size}\"", ".", "format", "(", "self", ")", ")", "if", ...
Right shift the farray by *num* places. The *num* argument must be a non-negative ``int``. If the *cin* farray is provided, it will be shifted in. Otherwise, the carry-in is zero. Returns a two-tuple (farray fs, farray cout), where *fs* is the shifted vector, and *cout* is the...
[ "Right", "shift", "the", "farray", "by", "*", "num", "*", "places", "." ]
python
train
38.571429
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1534-L1555
def getrepositorytree(self, project_id, **kwargs): """ Get a list of repository files and directories in a project. :param project_id: The ID of a project :param path: The path inside repository. Used to get contend of subdirectories :param ref_name: The name of a repository bra...
[ "def", "getrepositorytree", "(", "self", ",", "project_id", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "}", "if", "kwargs", ":", "data", ".", "update", "(", "kwargs", ")", "request", "=", "requests", ".", "get", "(", "'{0}/{1}/repository/tree'"...
Get a list of repository files and directories in a project. :param project_id: The ID of a project :param path: The path inside repository. Used to get contend of subdirectories :param ref_name: The name of a repository branch or tag or if not given the default branch :return: dict wit...
[ "Get", "a", "list", "of", "repository", "files", "and", "directories", "in", "a", "project", "." ]
python
train
36.090909
Archived-Object/ligament
ligament/buildtarget.py
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildtarget.py#L58-L74
def register_with_context(self, myname, context): """ registers this build target (exclusively) with a given context """ if self.context is not None: raise Exception("attempted to register BuildTarget with multiple " "BuildContexts") context.register_tas...
[ "def", "register_with_context", "(", "self", ",", "myname", ",", "context", ")", ":", "if", "self", ".", "context", "is", "not", "None", ":", "raise", "Exception", "(", "\"attempted to register BuildTarget with multiple \"", "\"BuildContexts\"", ")", "context", ".",...
registers this build target (exclusively) with a given context
[ "registers", "this", "build", "target", "(", "exclusively", ")", "with", "a", "given", "context" ]
python
train
44.294118
gmr/tinman
tinman/handlers/mixins.py
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L287-L310
def post(self, *args, **kwargs): """Handle creation of an item. :param args: :param kwargs: """ self.initialize_post() # Don't allow the post if the poster does not have permission if not self.has_create_permission(): LOGGER.debug('Does not have wri...
[ "def", "post", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "initialize_post", "(", ")", "# Don't allow the post if the poster does not have permission", "if", "not", "self", ".", "has_create_permission", "(", ")", ":", "LOGGER"...
Handle creation of an item. :param args: :param kwargs:
[ "Handle", "creation", "of", "an", "item", "." ]
python
train
31.208333
saltstack/salt
salt/transport/zeromq.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/zeromq.py#L1230-L1253
def timeout_message(self, message): ''' Handle a message timeout by removing it from the sending queue and informing the caller :raises: SaltReqTimeoutError ''' future = self.send_future_map.pop(message, None) # In a race condition the message might have been sen...
[ "def", "timeout_message", "(", "self", ",", "message", ")", ":", "future", "=", "self", ".", "send_future_map", ".", "pop", "(", "message", ",", "None", ")", "# In a race condition the message might have been sent by the time", "# we're timing it out. Make sure the future i...
Handle a message timeout by removing it from the sending queue and informing the caller :raises: SaltReqTimeoutError
[ "Handle", "a", "message", "timeout", "by", "removing", "it", "from", "the", "sending", "queue", "and", "informing", "the", "caller" ]
python
train
38.583333
dpgaspar/Flask-AppBuilder
flask_appbuilder/api/__init__.py
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L144-L160
def expose(url="/", methods=("GET",)): """ Use this decorator to expose API endpoints on your API classes. :param url: Relative URL for the endpoint :param methods: Allowed HTTP methods. By default only GET is allowed. """ def wrap(f): if not hasattr...
[ "def", "expose", "(", "url", "=", "\"/\"", ",", "methods", "=", "(", "\"GET\"", ",", ")", ")", ":", "def", "wrap", "(", "f", ")", ":", "if", "not", "hasattr", "(", "f", ",", "\"_urls\"", ")", ":", "f", ".", "_urls", "=", "[", "]", "f", ".", ...
Use this decorator to expose API endpoints on your API classes. :param url: Relative URL for the endpoint :param methods: Allowed HTTP methods. By default only GET is allowed.
[ "Use", "this", "decorator", "to", "expose", "API", "endpoints", "on", "your", "API", "classes", "." ]
python
train
24.411765
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2598-L2601
def organization_subscription_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/organization_subscriptions#create-organization-subscription" api_path = "/api/v2/organization_subscriptions.json" return self.call(api_path, method="POST", data=data, **kwargs)
[ "def", "organization_subscription_create", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/organization_subscriptions.json\"", "return", "self", ".", "call", "(", "api_path", ",", "method", "=", "\"POST\"", ",", "data", "...
https://developer.zendesk.com/rest_api/docs/core/organization_subscriptions#create-organization-subscription
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "organization_subscriptions#create", "-", "organization", "-", "subscription" ]
python
train
76.75
nvdv/vprof
vprof/memory_profiler.py
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L188-L207
def run(self): """Collects memory stats for specified Python program.""" existing_objects = _get_in_memory_objects() prof, result = self.profile() new_objects = _get_in_memory_objects() new_obj_count = _get_obj_count_difference(new_objects, existing_objects) result_obj_c...
[ "def", "run", "(", "self", ")", ":", "existing_objects", "=", "_get_in_memory_objects", "(", ")", "prof", ",", "result", "=", "self", ".", "profile", "(", ")", "new_objects", "=", "_get_in_memory_objects", "(", ")", "new_obj_count", "=", "_get_obj_count_differen...
Collects memory stats for specified Python program.
[ "Collects", "memory", "stats", "for", "specified", "Python", "program", "." ]
python
test
39.15
inasafe/inasafe
safe_extras/pydispatch/dispatcher.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L170-L223
def disconnect(receiver, signal=Any, sender=Any, weak=True): """Disconnect receiver from sender for signal receiver -- the registered receiver to disconnect signal -- the registered signal to disconnect sender -- the registered sender to disconnect weak -- the weakref state to disconnect disco...
[ "def", "disconnect", "(", "receiver", ",", "signal", "=", "Any", ",", "sender", "=", "Any", ",", "weak", "=", "True", ")", ":", "if", "signal", "is", "None", ":", "raise", "errors", ".", "DispatcherTypeError", "(", "'Signal cannot be None (receiver=%r sender=%...
Disconnect receiver from sender for signal receiver -- the registered receiver to disconnect signal -- the registered signal to disconnect sender -- the registered sender to disconnect weak -- the weakref state to disconnect disconnect reverses the process of connect, the semantics for the ind...
[ "Disconnect", "receiver", "from", "sender", "for", "signal" ]
python
train
34.87037
zaturox/glin
glin/zmq/messages.py
https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L11-L13
def brightness(sequence_number, brightness): """Create a brightness message""" return MessageWriter().string("brightness").uint64(sequence_number).uint8(int(brightness*255)).get()
[ "def", "brightness", "(", "sequence_number", ",", "brightness", ")", ":", "return", "MessageWriter", "(", ")", ".", "string", "(", "\"brightness\"", ")", ".", "uint64", "(", "sequence_number", ")", ".", "uint8", "(", "int", "(", "brightness", "*", "255", "...
Create a brightness message
[ "Create", "a", "brightness", "message" ]
python
train
64.333333
codelv/enaml-native
src/enamlnative/ios/uikit_toolkit_object.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_toolkit_object.py#L82-L92
def destroy(self): """ A reimplemented destructor. This destructor will clear the reference to the toolkit widget and set its parent to None. """ widget = self.widget if widget is not None: del self.widget super(UiKitToolkitObject, self).destroy()
[ "def", "destroy", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "if", "widget", "is", "not", "None", ":", "del", "self", ".", "widget", "super", "(", "UiKitToolkitObject", ",", "self", ")", ".", "destroy", "(", ")" ]
A reimplemented destructor. This destructor will clear the reference to the toolkit widget and set its parent to None.
[ "A", "reimplemented", "destructor", "." ]
python
train
27.909091
thombashi/DataProperty
dataproperty/_dataproperty.py
https://github.com/thombashi/DataProperty/blob/1d1a4c6abee87264c2f870a932c0194895d80a18/dataproperty/_dataproperty.py#L113-L122
def length(self): """ :return: Length of the ``data``. :rtype: int """ if not self.__length: self.__length = self.__get_length() return self.__length
[ "def", "length", "(", "self", ")", ":", "if", "not", "self", ".", "__length", ":", "self", ".", "__length", "=", "self", ".", "__get_length", "(", ")", "return", "self", ".", "__length" ]
:return: Length of the ``data``. :rtype: int
[ ":", "return", ":", "Length", "of", "the", "data", ".", ":", "rtype", ":", "int" ]
python
train
20.2
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L163-L183
def normalize_weight(self, samples): """normalize weight Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} ...
[ "def", "normalize_weight", "(", "self", ",", "samples", ")", ":", "for", "i", "in", "range", "(", "NUM_OF_INSTANCE", ")", ":", "total", "=", "0", "for", "j", "in", "range", "(", "self", ".", "effective_model_num", ")", ":", "total", "+=", "samples", "[...
normalize weight Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} Returns ------- list ...
[ "normalize", "weight", "Parameters", "----------", "samples", ":", "list", "a", "collection", "of", "sample", "it", "s", "a", "(", "NUM_OF_INSTANCE", "*", "NUM_OF_FUNCTIONS", ")", "matrix", "representing", "{{", "w11", "w12", "...", "w1k", "}", "{", "w21", "...
python
train
31.714286
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L360-L390
def add_cats(self, axis, cat_data): ''' Add categories to rows or columns using cat_data array of objects. Each object in cat_data is a dictionary with one key (category title) and value (rows/column names) that have this category. Categories will be added onto the existing categories and will be added in the o...
[ "def", "add_cats", "(", "self", ",", "axis", ",", "cat_data", ")", ":", "for", "inst_data", "in", "cat_data", ":", "categories", ".", "add_cats", "(", "self", ",", "axis", ",", "inst_data", ")" ]
Add categories to rows or columns using cat_data array of objects. Each object in cat_data is a dictionary with one key (category title) and value (rows/column names) that have this category. Categories will be added onto the existing categories and will be added in the order of the objects in the array. Example `...
[ "Add", "categories", "to", "rows", "or", "columns", "using", "cat_data", "array", "of", "objects", ".", "Each", "object", "in", "cat_data", "is", "a", "dictionary", "with", "one", "key", "(", "category", "title", ")", "and", "value", "(", "rows", "/", "c...
python
train
26.387097
genialis/resolwe
resolwe/flow/utils/__init__.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/__init__.py#L109-L143
def rewire_inputs(data_list): """Rewire inputs of provided data objects. Input parameter is a list of original and copied data object model instances: ``[{'original': original, 'copy': copy}]``. This function finds which objects reference other objects (in the list) on the input and replaces origin...
[ "def", "rewire_inputs", "(", "data_list", ")", ":", "if", "len", "(", "data_list", ")", "<", "2", ":", "return", "data_list", "mapped_ids", "=", "{", "bundle", "[", "'original'", "]", ".", "id", ":", "bundle", "[", "'copy'", "]", ".", "id", "for", "b...
Rewire inputs of provided data objects. Input parameter is a list of original and copied data object model instances: ``[{'original': original, 'copy': copy}]``. This function finds which objects reference other objects (in the list) on the input and replaces original objects with the copies (mutates ...
[ "Rewire", "inputs", "of", "provided", "data", "objects", "." ]
python
train
34.4
ResidentMario/pysocrata
pysocrata/pysocrata.py
https://github.com/ResidentMario/pysocrata/blob/78d31ed24f9966284043eee45acebd62aa67e5b1/pysocrata/pysocrata.py#L111-L159
def get_resources(domain, token): """ Returns a list of resources (data endpoints) on a Socrata domain. The catalog API and JSON endpoint both return useful information, but the information that they return is useful in slightly different ways. The JSON endpoint provides less information about the reso...
[ "def", "get_resources", "(", "domain", ",", "token", ")", ":", "json_endpoints", "=", "get_endpoints_using_raw_json_emission", "(", "domain", ")", "catalog_api_output", "=", "get_endpoints_using_catalog_api", "(", "domain", ",", "token", ")", "catalog_endpoints", "=", ...
Returns a list of resources (data endpoints) on a Socrata domain. The catalog API and JSON endpoint both return useful information, but the information that they return is useful in slightly different ways. The JSON endpoint provides less information about the resource in question, including lacking a fiel...
[ "Returns", "a", "list", "of", "resources", "(", "data", "endpoints", ")", "on", "a", "Socrata", "domain", "." ]
python
train
51.265306
zhanglab/psamm
psamm/randomsparse.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/randomsparse.py#L152-L224
def random_sparse(strategy, prob, obj_reaction, flux_threshold): """Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be ...
[ "def", "random_sparse", "(", "strategy", ",", "prob", ",", "obj_reaction", ",", "flux_threshold", ")", ":", "essential", "=", "set", "(", ")", "deleted", "=", "set", "(", ")", "for", "entity", ",", "deleted_reactions", "in", "strategy", ".", "iter_tests", ...
Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be deleted. It works with two strategies: deleting reactions or deletin...
[ "Find", "a", "random", "minimal", "network", "of", "model", "reactions", "." ]
python
train
35.39726
gitenberg-dev/gitberg
gitenberg/book.py
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/book.py#L193-L208
def make(self): """ turn fetched files into a local repo, make auxiliary files """ logger.debug("preparing to add all git files") num_added = self.local_repo.add_all_files() if num_added: self.local_repo.commit("Initial import from Project Gutenberg") file_ha...
[ "def", "make", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"preparing to add all git files\"", ")", "num_added", "=", "self", ".", "local_repo", ".", "add_all_files", "(", ")", "if", "num_added", ":", "self", ".", "local_repo", ".", "commit", "(", ...
turn fetched files into a local repo, make auxiliary files
[ "turn", "fetched", "files", "into", "a", "local", "repo", "make", "auxiliary", "files" ]
python
train
36
matthew-brett/delocate
delocate/delocating.py
https://github.com/matthew-brett/delocate/blob/ed48de15fce31c3f52f1a9f32cae1b02fc55aa60/delocate/delocating.py#L150-L233
def _copy_required(lib_path, copy_filt_func, copied_libs): """ Copy libraries required for files in `lib_path` to `lib_path` Augment `copied_libs` dictionary with any newly copied libraries, modifying `copied_libs` in-place - see Notes. This is one pass of ``copy_recurse`` Parameters --------...
[ "def", "_copy_required", "(", "lib_path", ",", "copy_filt_func", ",", "copied_libs", ")", ":", "# Paths will be prepended with `lib_path`", "lib_dict", "=", "tree_libs", "(", "lib_path", ")", "# Map library paths after copy ('copied') to path before copy ('orig')", "rp_lp", "="...
Copy libraries required for files in `lib_path` to `lib_path` Augment `copied_libs` dictionary with any newly copied libraries, modifying `copied_libs` in-place - see Notes. This is one pass of ``copy_recurse`` Parameters ---------- lib_path : str Directory containing libraries co...
[ "Copy", "libraries", "required", "for", "files", "in", "lib_path", "to", "lib_path" ]
python
train
44.404762
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L550-L556
def var(self): """Returns a symbol representing this parameter.""" if self._var is None: self._var = symbol.var(self.name, shape=self.shape, dtype=self.dtype, lr_mult=self.lr_mult, wd_mult=self.wd_mult, init=self.init, sty...
[ "def", "var", "(", "self", ")", ":", "if", "self", ".", "_var", "is", "None", ":", "self", ".", "_var", "=", "symbol", ".", "var", "(", "self", ".", "name", ",", "shape", "=", "self", ".", "shape", ",", "dtype", "=", "self", ".", "dtype", ",", ...
Returns a symbol representing this parameter.
[ "Returns", "a", "symbol", "representing", "this", "parameter", "." ]
python
train
50.571429
etgalloway/fullqualname
fullqualname.py
https://github.com/etgalloway/fullqualname/blob/c16fa82880219cf91cdcd5466db9bf2099592c59/fullqualname.py#L66-L76
def _fullqualname_function_py3(obj): """Fully qualified name for 'function' objects in Python 3. """ if hasattr(obj, "__wrapped__"): # Required for decorator.__version__ <= 4.0.0. qualname = obj.__wrapped__.__qualname__ else: qualname = obj.__qualname__ return obj.__module_...
[ "def", "_fullqualname_function_py3", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "\"__wrapped__\"", ")", ":", "# Required for decorator.__version__ <= 4.0.0.", "qualname", "=", "obj", ".", "__wrapped__", ".", "__qualname__", "else", ":", "qualname", "=",...
Fully qualified name for 'function' objects in Python 3.
[ "Fully", "qualified", "name", "for", "function", "objects", "in", "Python", "3", "." ]
python
train
29.818182
CI-WATER/gsshapy
gsshapy/orm/cif.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/cif.py#L449-L484
def _write(self, session, openFile, replaceParamFile): """ Channel Input File Write to File Method """ # Write lines openFile.write('GSSHA_CHAN\n') alpha = vwp(self.alpha, replaceParamFile) try: openFile.write('ALPHA%s%.6f\n' % (' ' * 7, alpha)) ...
[ "def", "_write", "(", "self", ",", "session", ",", "openFile", ",", "replaceParamFile", ")", ":", "# Write lines", "openFile", ".", "write", "(", "'GSSHA_CHAN\\n'", ")", "alpha", "=", "vwp", "(", "self", ".", "alpha", ",", "replaceParamFile", ")", "try", "...
Channel Input File Write to File Method
[ "Channel", "Input", "File", "Write", "to", "File", "Method" ]
python
train
33.611111
saltstack/salt
salt/modules/splunk.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/splunk.py#L84-L100
def _send_email(name, email): "send a email to inform user of account creation" config = __salt__['config.option']('splunk') email_object = config.get('email') if email_object: cc = email_object.get('cc') subject = email_object.get('subject') message = email_object.get('message')...
[ "def", "_send_email", "(", "name", ",", "email", ")", ":", "config", "=", "__salt__", "[", "'config.option'", "]", "(", "'splunk'", ")", "email_object", "=", "config", ".", "get", "(", "'email'", ")", "if", "email_object", ":", "cc", "=", "email_object", ...
send a email to inform user of account creation
[ "send", "a", "email", "to", "inform", "user", "of", "account", "creation" ]
python
train
40.058824
phaethon/kamene
kamene/contrib/gsm_um.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1651-L1660
def congestionControl(Cause_presence=0): """CONGESTION CONTROL Section 9.3.4""" a = TpPd(pd=0x3) b = MessageType(mesType=0x39) # 00111001 c = CongestionLevelAndSpareHalfOctets() packet = a / b / c if Cause_presence is 1: e = CauseHdr(ieiC=0x08, eightBitC=0x0) packet = packet / e...
[ "def", "congestionControl", "(", "Cause_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x39", ")", "# 00111001", "c", "=", "CongestionLevelAndSpareHalfOctets", "(", ")", "packet",...
CONGESTION CONTROL Section 9.3.4
[ "CONGESTION", "CONTROL", "Section", "9", ".", "3", ".", "4" ]
python
train
32.9
iotile/coretools
iotilecore/iotile/core/hw/update/script.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/update/script.py#L32-L72
def ParseHeader(cls, script_data): """Parse a script integrity header. This function makes sure any integrity hashes are correctly parsed and returns a ScriptHeader structure containing the information that it was able to parse out. Args: script_data (bytearray): Th...
[ "def", "ParseHeader", "(", "cls", ",", "script_data", ")", ":", "if", "len", "(", "script_data", ")", "<", "UpdateScript", ".", "SCRIPT_HEADER_LENGTH", ":", "raise", "ArgumentError", "(", "\"Script is too short to contain a script header\"", ",", "length", "=", "len...
Parse a script integrity header. This function makes sure any integrity hashes are correctly parsed and returns a ScriptHeader structure containing the information that it was able to parse out. Args: script_data (bytearray): The script that we should parse. Raises...
[ "Parse", "a", "script", "integrity", "header", "." ]
python
train
41.512195
novopl/peltak
src/peltak/extra/docker/client.py
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/docker/client.py#L63-L82
def list_tags(self, image_name): # type: (str) -> Iterator[str] """ List all tags for the given image stored in the registry. Args: image_name (str): The name of the image to query. The image must be present on the registry for this call to return any...
[ "def", "list_tags", "(", "self", ",", "image_name", ")", ":", "# type: (str) -> Iterator[str]", "tags_url", "=", "self", ".", "registry_url", "+", "'/v2/{}/tags/list'", "r", "=", "self", ".", "get", "(", "tags_url", ".", "format", "(", "image_name", ")", ",", ...
List all tags for the given image stored in the registry. Args: image_name (str): The name of the image to query. The image must be present on the registry for this call to return any values. Returns: list[str]: List of tags for that image.
[ "List", "all", "tags", "for", "the", "given", "image", "stored", "in", "the", "registry", "." ]
python
train
31.8
koenedaele/skosprovider
skosprovider/registry.py
https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L57-L74
def remove_provider(self, id): ''' Remove the provider with the given id or :term:`URI`. :param str id: The identifier for the provider. :returns: A :class:`skosprovider.providers.VocabularyProvider` or `False` if the id is unknown. ''' if id in self.provider...
[ "def", "remove_provider", "(", "self", ",", "id", ")", ":", "if", "id", "in", "self", ".", "providers", ":", "p", "=", "self", ".", "providers", ".", "get", "(", "id", ",", "False", ")", "del", "self", ".", "providers", "[", "id", "]", "del", "se...
Remove the provider with the given id or :term:`URI`. :param str id: The identifier for the provider. :returns: A :class:`skosprovider.providers.VocabularyProvider` or `False` if the id is unknown.
[ "Remove", "the", "provider", "with", "the", "given", "id", "or", ":", "term", ":", "URI", "." ]
python
valid
36.277778
PMBio/limix-backup
limix/ensemble/py_splitting_core.py
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/ensemble/py_splitting_core.py#L68-L71
def cpp_best_split_full_model(X, Uy, C, S, U, noderange, delta, save_memory=False): """wrappe calling cpp splitting function""" return CSP.best_split_full_model(X, Uy, C, S, U, noderange, delta)
[ "def", "cpp_best_split_full_model", "(", "X", ",", "Uy", ",", "C", ",", "S", ",", "U", ",", "noderange", ",", "delta", ",", "save_memory", "=", "False", ")", ":", "return", "CSP", ".", "best_split_full_model", "(", "X", ",", "Uy", ",", "C", ",", "S",...
wrappe calling cpp splitting function
[ "wrappe", "calling", "cpp", "splitting", "function" ]
python
train
57.25
kcolford/txt2boil
txt2boil/core/gen.py
https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L30-L36
def collectTriggers(self, rgx, code): """Return a dictionary of triggers and their corresponding matches from the code. """ return {m.group(0): m for m in re.finditer(rgx, code)}
[ "def", "collectTriggers", "(", "self", ",", "rgx", ",", "code", ")", ":", "return", "{", "m", ".", "group", "(", "0", ")", ":", "m", "for", "m", "in", "re", ".", "finditer", "(", "rgx", ",", "code", ")", "}" ]
Return a dictionary of triggers and their corresponding matches from the code.
[ "Return", "a", "dictionary", "of", "triggers", "and", "their", "corresponding", "matches", "from", "the", "code", "." ]
python
train
29.428571
SmokinCaterpillar/pypet
pypet/naturalnaming.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/naturalnaming.py#L2804-L2848
def f_remove_child(self, name, recursive=False, predicate=None): """Removes a child of the group. Note that groups and leaves are only removed from the current trajectory in RAM. If the trajectory is stored to disk, this data is not affected. Thus, removing children can be only be used ...
[ "def", "f_remove_child", "(", "self", ",", "name", ",", "recursive", "=", "False", ",", "predicate", "=", "None", ")", ":", "if", "name", "not", "in", "self", ".", "_children", ":", "raise", "ValueError", "(", "'Your group `%s` does not contain the child `%s`.'"...
Removes a child of the group. Note that groups and leaves are only removed from the current trajectory in RAM. If the trajectory is stored to disk, this data is not affected. Thus, removing children can be only be used to free RAM memory! If you want to free memory on disk via your sto...
[ "Removes", "a", "child", "of", "the", "group", "." ]
python
test
40.933333
emencia/emencia-django-forum
forum/markup.py
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/markup.py#L20-L28
def clean_restructuredtext(form_instance, content): """ RST syntax validation """ if content: errors = SourceReporter(content) if errors: raise ValidationError(map(map_parsing_errors, errors)) return content
[ "def", "clean_restructuredtext", "(", "form_instance", ",", "content", ")", ":", "if", "content", ":", "errors", "=", "SourceReporter", "(", "content", ")", "if", "errors", ":", "raise", "ValidationError", "(", "map", "(", "map_parsing_errors", ",", "errors", ...
RST syntax validation
[ "RST", "syntax", "validation" ]
python
train
27.444444
mlperf/training
translation/tensorflow/transformer/model/beam_search.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/beam_search.py#L305-L333
def _get_new_alive_state(self, new_seq, new_log_probs, new_cache): """Gather the top k sequences that are still alive. Args: new_seq: New sequences generated by growing the current alive sequences int32 tensor with shape [batch_size, 2 * beam_size, cur_index + 1] new_log_probs: Log probabil...
[ "def", "_get_new_alive_state", "(", "self", ",", "new_seq", ",", "new_log_probs", ",", "new_cache", ")", ":", "# To prevent finished sequences from being considered, set log probs to -INF", "new_finished_flags", "=", "tf", ".", "equal", "(", "new_seq", "[", ":", ",", ":...
Gather the top k sequences that are still alive. Args: new_seq: New sequences generated by growing the current alive sequences int32 tensor with shape [batch_size, 2 * beam_size, cur_index + 1] new_log_probs: Log probabilities of new sequences float32 tensor with shape [batch_size, beam...
[ "Gather", "the", "top", "k", "sequences", "that", "are", "still", "alive", "." ]
python
train
43.275862
lambdalisue/maidenhair
src/maidenhair/utils/plugins.py
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/utils/plugins.py#L118-L158
def load_plugins(self, plugin_dirs=None, quiet=True): """ Load plugins in `sys.path` and :attr:`plugin_dirs` Parameters ---------- plugin_dirs : list or tuple of string, optional A list or tuple of plugin directory path quiet : bool, optional If T...
[ "def", "load_plugins", "(", "self", ",", "plugin_dirs", "=", "None", ",", "quiet", "=", "True", ")", ":", "from", "pkg_resources", "import", "working_set", "from", "pkg_resources", "import", "iter_entry_points", "from", "pkg_resources", "import", "Environment", "i...
Load plugins in `sys.path` and :attr:`plugin_dirs` Parameters ---------- plugin_dirs : list or tuple of string, optional A list or tuple of plugin directory path quiet : bool, optional If True, print all error message
[ "Load", "plugins", "in", "sys", ".", "path", "and", ":", "attr", ":", "plugin_dirs" ]
python
train
35.707317
gwastro/pycbc
pycbc/inference/sampler/emcee.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/sampler/emcee.py#L140-L148
def set_state_from_file(self, filename): """Sets the state of the sampler back to the instance saved in a file. """ with self.io(filename, 'r') as fp: rstate = fp.read_random_state() # set the numpy random state numpy.random.set_state(rstate) # set emcee's gen...
[ "def", "set_state_from_file", "(", "self", ",", "filename", ")", ":", "with", "self", ".", "io", "(", "filename", ",", "'r'", ")", "as", "fp", ":", "rstate", "=", "fp", ".", "read_random_state", "(", ")", "# set the numpy random state", "numpy", ".", "rand...
Sets the state of the sampler back to the instance saved in a file.
[ "Sets", "the", "state", "of", "the", "sampler", "back", "to", "the", "instance", "saved", "in", "a", "file", "." ]
python
train
42.222222
nickpandolfi/Cyther
cyther/launcher.py
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/launcher.py#L54-L62
def getOutput(self): """ Returns the combined output of stdout and stderr """ output = self.stdout if self.stdout: output += '\r\n' output += self.stderr return output
[ "def", "getOutput", "(", "self", ")", ":", "output", "=", "self", ".", "stdout", "if", "self", ".", "stdout", ":", "output", "+=", "'\\r\\n'", "output", "+=", "self", ".", "stderr", "return", "output" ]
Returns the combined output of stdout and stderr
[ "Returns", "the", "combined", "output", "of", "stdout", "and", "stderr" ]
python
train
25.222222
nitmir/django-cas-server
cas_server/views.py
https://github.com/nitmir/django-cas-server/blob/d106181b94c444f1946269da5c20f6c904840ad3/cas_server/views.py#L148-L231
def get(self, request, *args, **kwargs): """ method called on GET request on this view :param django.http.HttpRequest request: The current request object """ logger.info("logout requested") # initialize the class attributes self.init_get(request) ...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "\"logout requested\"", ")", "# initialize the class attributes", "self", ".", "init_get", "(", "request", ")", "# if CAS federation mod...
method called on GET request on this view :param django.http.HttpRequest request: The current request object
[ "method", "called", "on", "GET", "request", "on", "this", "view" ]
python
train
47.595238
Opentrons/opentrons
update-server/otupdate/buildroot/__init__.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/update-server/otupdate/buildroot/__init__.py#L34-L88
def get_app(system_version_file: str = None, config_file_override: str = None, name_override: str = None, loop: asyncio.AbstractEventLoop = None) -> web.Application: """ Build and return the aiohttp.web.Application that runs the server The params can be overloaded for testin...
[ "def", "get_app", "(", "system_version_file", ":", "str", "=", "None", ",", "config_file_override", ":", "str", "=", "None", ",", "name_override", ":", "str", "=", "None", ",", "loop", ":", "asyncio", ".", "AbstractEventLoop", "=", "None", ")", "->", "web"...
Build and return the aiohttp.web.Application that runs the server The params can be overloaded for testing.
[ "Build", "and", "return", "the", "aiohttp", ".", "web", ".", "Application", "that", "runs", "the", "server" ]
python
train
42.690909
latchset/jwcrypto
jwcrypto/jws.py
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L147-L154
def sign(self): """Generates a signature""" payload = self._payload() sigin = b'.'.join([self.protected.encode('utf-8'), payload]) signature = self.engine.sign(self.key, sigin) return {'protected': self.protected, 'payload': payload, 'signature': b...
[ "def", "sign", "(", "self", ")", ":", "payload", "=", "self", ".", "_payload", "(", ")", "sigin", "=", "b'.'", ".", "join", "(", "[", "self", ".", "protected", ".", "encode", "(", "'utf-8'", ")", ",", "payload", "]", ")", "signature", "=", "self", ...
Generates a signature
[ "Generates", "a", "signature" ]
python
train
42.5
amsehili/auditok
auditok/cmdline.py
https://github.com/amsehili/auditok/blob/df6eb1d80f8cd9034be47b24869ce59b74f5f4db/auditok/cmdline.py#L535-L775
def main(argv=None): '''Command line options.''' program_name = os.path.basename(sys.argv[0]) program_version = version program_build_date = "%s" % __updated__ program_version_string = '%%prog %s (%s)' % (program_version, program_build_date) #program_usage = '''usage: spam two eggs''' # option...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "program_name", "=", "os", ".", "path", ".", "basename", "(", "sys", ".", "argv", "[", "0", "]", ")", "program_version", "=", "version", "program_build_date", "=", "\"%s\"", "%", "__updated__", "program_...
Command line options.
[ "Command", "line", "options", "." ]
python
train
60.900415
tanghaibao/goatools
goatools/gosubdag/go_edges.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L155-L166
def _init_edges(p2cs, c2ps): """Get the directed edges from GO term to GO term.""" edge_from_to = [] for parent, children in p2cs.items(): for child in children: # if child in goids_present and parent in goids_present: edge_from_to.append((child, paren...
[ "def", "_init_edges", "(", "p2cs", ",", "c2ps", ")", ":", "edge_from_to", "=", "[", "]", "for", "parent", ",", "children", "in", "p2cs", ".", "items", "(", ")", ":", "for", "child", "in", "children", ":", "# if child in goids_present and parent in goids_presen...
Get the directed edges from GO term to GO term.
[ "Get", "the", "directed", "edges", "from", "GO", "term", "to", "GO", "term", "." ]
python
train
45.583333
rkargon/pixelsorter
pixelsorter/paths.py
https://github.com/rkargon/pixelsorter/blob/0775d1e487fbcb023e411e1818ba3290b0e8665e/pixelsorter/paths.py#L240-L259
def bresenham_circle_octant(radius): """ Uses Bresenham's algorithm to draw a single octant of a circle with thickness 1, centered on the origin and with the given radius. :param radius: The radius of the circle to draw :return: A list of integer coordinates representing pixels. Starts at (radiu...
[ "def", "bresenham_circle_octant", "(", "radius", ")", ":", "x", ",", "y", "=", "radius", ",", "0", "r2", "=", "radius", "*", "radius", "coords", "=", "[", "]", "while", "x", ">=", "y", ":", "coords", ".", "append", "(", "(", "x", ",", "y", ")", ...
Uses Bresenham's algorithm to draw a single octant of a circle with thickness 1, centered on the origin and with the given radius. :param radius: The radius of the circle to draw :return: A list of integer coordinates representing pixels. Starts at (radius, 0) and end with a pixel (x, y) where x == y.
[ "Uses", "Bresenham", "s", "algorithm", "to", "draw", "a", "single", "octant", "of", "a", "circle", "with", "thickness", "1", "centered", "on", "the", "origin", "and", "with", "the", "given", "radius", ".", ":", "param", "radius", ":", "The", "radius", "o...
python
train
37.95
sorgerlab/indra
indra/databases/go_client.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/go_client.py#L41-L60
def load_go_graph(go_fname): """Load the GO data from an OWL file and parse into an RDF graph. Parameters ---------- go_fname : str Path to the GO OWL file. Can be downloaded from http://geneontology.org/ontology/go.owl. Returns ------- rdflib.Graph RDF graph contai...
[ "def", "load_go_graph", "(", "go_fname", ")", ":", "global", "_go_graph", "if", "_go_graph", "is", "None", ":", "_go_graph", "=", "rdflib", ".", "Graph", "(", ")", "logger", ".", "info", "(", "\"Parsing GO OWL file\"", ")", "_go_graph", ".", "parse", "(", ...
Load the GO data from an OWL file and parse into an RDF graph. Parameters ---------- go_fname : str Path to the GO OWL file. Can be downloaded from http://geneontology.org/ontology/go.owl. Returns ------- rdflib.Graph RDF graph containing GO data.
[ "Load", "the", "GO", "data", "from", "an", "OWL", "file", "and", "parse", "into", "an", "RDF", "graph", "." ]
python
train
25.95
sendwithus/sendwithus_python
sendwithus/__init__.py
https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L142-L160
def _parse_response(self, response): """Parses the API response and raises appropriate errors if raise_errors was set to True """ if not self._raise_errors: return response is_4xx_error = str(response.status_code)[0] == '4' is_5xx_error = str(response.status_...
[ "def", "_parse_response", "(", "self", ",", "response", ")", ":", "if", "not", "self", ".", "_raise_errors", ":", "return", "response", "is_4xx_error", "=", "str", "(", "response", ".", "status_code", ")", "[", "0", "]", "==", "'4'", "is_5xx_error", "=", ...
Parses the API response and raises appropriate errors if raise_errors was set to True
[ "Parses", "the", "API", "response", "and", "raises", "appropriate", "errors", "if", "raise_errors", "was", "set", "to", "True" ]
python
valid
31.263158
codeinthehole/purl
purl/url.py
https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L47-L57
def dict_to_unicode(raw_dict): """ Ensure all keys and values in a dict are unicode. The passed dict is assumed to have lists for all values. """ decoded = {} for key, value in raw_dict.items(): decoded[to_unicode(key)] = map( to_unicode, value) return decoded
[ "def", "dict_to_unicode", "(", "raw_dict", ")", ":", "decoded", "=", "{", "}", "for", "key", ",", "value", "in", "raw_dict", ".", "items", "(", ")", ":", "decoded", "[", "to_unicode", "(", "key", ")", "]", "=", "map", "(", "to_unicode", ",", "value",...
Ensure all keys and values in a dict are unicode. The passed dict is assumed to have lists for all values.
[ "Ensure", "all", "keys", "and", "values", "in", "a", "dict", "are", "unicode", "." ]
python
train
27.181818
opencobra/cobrapy
cobra/flux_analysis/summary.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/summary.py#L147-L257
def model_summary(model, solution=None, threshold=0.01, fva=None, names=False, floatfmt='.3g'): """ Print a summary of the input and output fluxes of the model. Parameters ---------- solution: cobra.Solution, optional A previously solved model solution to use for generatin...
[ "def", "model_summary", "(", "model", ",", "solution", "=", "None", ",", "threshold", "=", "0.01", ",", "fva", "=", "None", ",", "names", "=", "False", ",", "floatfmt", "=", "'.3g'", ")", ":", "if", "names", ":", "emit", "=", "attrgetter", "(", "'nam...
Print a summary of the input and output fluxes of the model. Parameters ---------- solution: cobra.Solution, optional A previously solved model solution to use for generating the summary. If none provided (default), the summary method will resolve the model. Note that the solution o...
[ "Print", "a", "summary", "of", "the", "input", "and", "output", "fluxes", "of", "the", "model", "." ]
python
valid
43.792793
Autodesk/aomi
aomi/template.py
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L21-L31
def grok_filter_name(element): """Extracts the name, which may be embedded, for a Jinja2 filter node""" e_name = None if element.name == 'default': if isinstance(element.node, jinja2.nodes.Getattr): e_name = element.node.node.name else: e_name = element.node.name ...
[ "def", "grok_filter_name", "(", "element", ")", ":", "e_name", "=", "None", "if", "element", ".", "name", "==", "'default'", ":", "if", "isinstance", "(", "element", ".", "node", ",", "jinja2", ".", "nodes", ".", "Getattr", ")", ":", "e_name", "=", "el...
Extracts the name, which may be embedded, for a Jinja2 filter node
[ "Extracts", "the", "name", "which", "may", "be", "embedded", "for", "a", "Jinja2", "filter", "node" ]
python
train
29.818182
pycontribs/pyrax
pyrax/clouddns.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddns.py#L882-L892
def update_records(self, domain, records): """ Modifies an existing records for a domain. """ if not isinstance(records, list): raise TypeError("Expected records of type list") uri = "/domains/%s/records" % utils.get_id(domain) resp, resp_body = self._async_ca...
[ "def", "update_records", "(", "self", ",", "domain", ",", "records", ")", ":", "if", "not", "isinstance", "(", "records", ",", "list", ")", ":", "raise", "TypeError", "(", "\"Expected records of type list\"", ")", "uri", "=", "\"/domains/%s/records\"", "%", "u...
Modifies an existing records for a domain.
[ "Modifies", "an", "existing", "records", "for", "a", "domain", "." ]
python
train
43.363636
odlgroup/odl
odl/solvers/functional/default_functionals.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/solvers/functional/default_functionals.py#L1984-L1998
def _asarray(self, vec): """Convert ``x`` to an array. Here the indices are changed such that the "outer" indices come last in order to have the access order as `numpy.linalg.svd` needs it. This is the inverse of `_asvector`. """ shape = self.domain[0, 0].shape + self.p...
[ "def", "_asarray", "(", "self", ",", "vec", ")", ":", "shape", "=", "self", ".", "domain", "[", "0", ",", "0", "]", ".", "shape", "+", "self", ".", "pshape", "arr", "=", "np", ".", "empty", "(", "shape", ",", "dtype", "=", "self", ".", "domain"...
Convert ``x`` to an array. Here the indices are changed such that the "outer" indices come last in order to have the access order as `numpy.linalg.svd` needs it. This is the inverse of `_asvector`.
[ "Convert", "x", "to", "an", "array", "." ]
python
train
34.066667
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L153-L194
def cmd_fence(self, args): '''fence commands''' if len(args) < 1: self.print_usage() return if args[0] == "enable": self.set_fence_enabled(1) elif args[0] == "disable": self.set_fence_enabled(0) elif args[0] == "load": ...
[ "def", "cmd_fence", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "self", ".", "print_usage", "(", ")", "return", "if", "args", "[", "0", "]", "==", "\"enable\"", ":", "self", ".", "set_fence_enabled", "(", "1", ...
fence commands
[ "fence", "commands" ]
python
train
34.238095
flyte/xbee-helper
xbee_helper/device.py
https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L105-L120
def next_frame_id(self): """ Gets a byte of the next valid frame ID (1 - 255), increments the internal _frame_id counter and wraps it back to 1 if necessary. """ # Python 2/3 compatible way of converting 1 to "\x01" in py2 or b"\x01" # in py3. fid = bytes(bytearra...
[ "def", "next_frame_id", "(", "self", ")", ":", "# Python 2/3 compatible way of converting 1 to \"\\x01\" in py2 or b\"\\x01\"", "# in py3.", "fid", "=", "bytes", "(", "bytearray", "(", "(", "self", ".", "_frame_id", ",", ")", ")", ")", "self", ".", "_frame_id", "+="...
Gets a byte of the next valid frame ID (1 - 255), increments the internal _frame_id counter and wraps it back to 1 if necessary.
[ "Gets", "a", "byte", "of", "the", "next", "valid", "frame", "ID", "(", "1", "-", "255", ")", "increments", "the", "internal", "_frame_id", "counter", "and", "wraps", "it", "back", "to", "1", "if", "necessary", "." ]
python
train
33.125
jjgomera/iapws
iapws/iapws97.py
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L4341-L4361
def calculable(self): """Check if class is calculable by its kwargs""" self._thermo = "" if self.kwargs["T"] and self.kwargs["P"]: self._thermo = "TP" elif self.kwargs["P"] and self.kwargs["h"] is not None: self._thermo = "Ph" elif self.kwargs["P"] and sel...
[ "def", "calculable", "(", "self", ")", ":", "self", ".", "_thermo", "=", "\"\"", "if", "self", ".", "kwargs", "[", "\"T\"", "]", "and", "self", ".", "kwargs", "[", "\"P\"", "]", ":", "self", ".", "_thermo", "=", "\"TP\"", "elif", "self", ".", "kwar...
Check if class is calculable by its kwargs
[ "Check", "if", "class", "is", "calculable", "by", "its", "kwargs" ]
python
train
44.095238
tanghaibao/jcvi
jcvi/projects/tgbs.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/projects/tgbs.py#L327-L397
def novo(args): """ %prog novo reads.fastq Reference-free tGBS pipeline v1. """ from jcvi.assembly.kmer import jellyfish, histogram from jcvi.assembly.preprocess import diginorm from jcvi.formats.fasta import filter as fasta_filter, format from jcvi.apps.cdhit import filter as cdhit_fil...
[ "def", "novo", "(", "args", ")", ":", "from", "jcvi", ".", "assembly", ".", "kmer", "import", "jellyfish", ",", "histogram", "from", "jcvi", ".", "assembly", ".", "preprocess", "import", "diginorm", "from", "jcvi", ".", "formats", ".", "fasta", "import", ...
%prog novo reads.fastq Reference-free tGBS pipeline v1.
[ "%prog", "novo", "reads", ".", "fastq" ]
python
train
36.915493
CityOfZion/neo-python
neo/Core/State/AccountState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/AccountState.py#L244-L258
def ToByteArray(self): """ Serialize self and get the byte stream. Returns: bytes: serialized object. """ ms = StreamManager.GetStream() writer = BinaryWriter(ms) self.Serialize(writer) retval = ms.ToArray() StreamManager.ReleaseStrea...
[ "def", "ToByteArray", "(", "self", ")", ":", "ms", "=", "StreamManager", ".", "GetStream", "(", ")", "writer", "=", "BinaryWriter", "(", "ms", ")", "self", ".", "Serialize", "(", "writer", ")", "retval", "=", "ms", ".", "ToArray", "(", ")", "StreamMana...
Serialize self and get the byte stream. Returns: bytes: serialized object.
[ "Serialize", "self", "and", "get", "the", "byte", "stream", "." ]
python
train
22.266667
tjguk/winshell
winshell.py
https://github.com/tjguk/winshell/blob/1509d211ab3403dd1cff6113e4e13462d6dec35b/winshell.py#L266-L294
def copy_file( source_path, target_path, allow_undo=True, no_confirm=False, rename_on_collision=True, silent=False, extra_flags=0, hWnd=None ): """Perform a shell-based file copy. Copying in this way allows the possibility of undo, auto-renaming, and showing the "flying file"...
[ "def", "copy_file", "(", "source_path", ",", "target_path", ",", "allow_undo", "=", "True", ",", "no_confirm", "=", "False", ",", "rename_on_collision", "=", "True", ",", "silent", "=", "False", ",", "extra_flags", "=", "0", ",", "hWnd", "=", "None", ")", ...
Perform a shell-based file copy. Copying in this way allows the possibility of undo, auto-renaming, and showing the "flying file" animation during the copy. The default options allow for undo, don't automatically clobber on a name clash, automatically rename on collision and display the animation.
[ "Perform", "a", "shell", "-", "based", "file", "copy", ".", "Copying", "in", "this", "way", "allows", "the", "possibility", "of", "undo", "auto", "-", "renaming", "and", "showing", "the", "flying", "file", "animation", "during", "the", "copy", "." ]
python
train
24.241379
teepark/junction
junction/hub.py
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/hub.py#L182-L195
def publish_receiver_count(self, service, routing_id): '''Get the number of peers that would handle a particular publish :param service: the service name :type service: anything hash-able :param routing_id: the id used for limiting the service handlers :type routing_id: int ...
[ "def", "publish_receiver_count", "(", "self", ",", "service", ",", "routing_id", ")", ":", "peers", "=", "len", "(", "list", "(", "self", ".", "_dispatcher", ".", "find_peer_routes", "(", "const", ".", "MSG_TYPE_PUBLISH", ",", "service", ",", "routing_id", "...
Get the number of peers that would handle a particular publish :param service: the service name :type service: anything hash-able :param routing_id: the id used for limiting the service handlers :type routing_id: int
[ "Get", "the", "number", "of", "peers", "that", "would", "handle", "a", "particular", "publish" ]
python
train
42.071429
andycasey/ads
ads/base.py
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/base.py#L88-L100
def load_http_response(cls, http_response): """ This method should return an instantiated class and set its response to the requests.Response object. """ if not http_response.ok: raise APIResponseError(http_response.text) c = cls(http_response) c.respo...
[ "def", "load_http_response", "(", "cls", ",", "http_response", ")", ":", "if", "not", "http_response", ".", "ok", ":", "raise", "APIResponseError", "(", "http_response", ".", "text", ")", "c", "=", "cls", "(", "http_response", ")", "c", ".", "response", "=...
This method should return an instantiated class and set its response to the requests.Response object.
[ "This", "method", "should", "return", "an", "instantiated", "class", "and", "set", "its", "response", "to", "the", "requests", ".", "Response", "object", "." ]
python
train
32.076923
chrissimpkins/crypto
lib/crypto/library/cryptor.py
https://github.com/chrissimpkins/crypto/blob/6b95fa81b26312e46f02557dca0b5f5c898a76fd/lib/crypto/library/cryptor.py#L86-L89
def encrypt_files(self, file_list, force_nocompress=False, force_compress=False, armored=False, checksum=False): """public method for multiple file encryption with optional compression, ASCII armored formatting, and file hash digest generation""" for the_file in file_list: self.encrypt_file(...
[ "def", "encrypt_files", "(", "self", ",", "file_list", ",", "force_nocompress", "=", "False", ",", "force_compress", "=", "False", ",", "armored", "=", "False", ",", "checksum", "=", "False", ")", ":", "for", "the_file", "in", "file_list", ":", "self", "."...
public method for multiple file encryption with optional compression, ASCII armored formatting, and file hash digest generation
[ "public", "method", "for", "multiple", "file", "encryption", "with", "optional", "compression", "ASCII", "armored", "formatting", "and", "file", "hash", "digest", "generation" ]
python
train
94.75
vinitkumar/pycrawler
crawler.py
https://github.com/vinitkumar/pycrawler/blob/d3fe6d2da1469fc701c4fe04df88cee9cc8cd9c3/crawler.py#L17-L39
def option_parser(): """Option Parser to give various options.""" usage = ''' $ ./crawler -d5 <url> Here in this case it goes till depth of 5 and url is target URL to start crawling. ''' version = "2.0.0" parser = optparse.OptionParser(usage=usag...
[ "def", "option_parser", "(", ")", ":", "usage", "=", "'''\n $ ./crawler -d5 <url>\n Here in this case it goes till depth of 5 and url is target URL to\n start crawling.\n '''", "version", "=", "\"2.0.0\"", "parser", "=", "optparse", "....
Option Parser to give various options.
[ "Option", "Parser", "to", "give", "various", "options", "." ]
python
train
32.347826
gwastro/pycbc
pycbc/workflow/core.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/core.py#L435-L492
def update_current_retention_level(self, value): """Set a new value for the current retention level. This updates the value of self.retain_files for an updated value of the retention level. Parameters ----------- value : int The new value to use for the rete...
[ "def", "update_current_retention_level", "(", "self", ",", "value", ")", ":", "# Determine the level at which output files should be kept", "self", ".", "current_retention_level", "=", "value", "try", ":", "global_retention_level", "=", "self", ".", "cp", ".", "get_opt_ta...
Set a new value for the current retention level. This updates the value of self.retain_files for an updated value of the retention level. Parameters ----------- value : int The new value to use for the retention level.
[ "Set", "a", "new", "value", "for", "the", "current", "retention", "level", "." ]
python
train
46.793103
SpotlightData/preprocessing
preprocessing/spellcheck.py
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L91-L101
def find_word_prob(word_string, word_total=sum(WORD_DISTRIBUTION.values())): ''' Finds the relative probability of the word appearing given context of a base corpus. Returns this probability value as a float instance. ''' if word_string is None: return 0 elif isinstance(word_string, str)...
[ "def", "find_word_prob", "(", "word_string", ",", "word_total", "=", "sum", "(", "WORD_DISTRIBUTION", ".", "values", "(", ")", ")", ")", ":", "if", "word_string", "is", "None", ":", "return", "0", "elif", "isinstance", "(", "word_string", ",", "str", ")", ...
Finds the relative probability of the word appearing given context of a base corpus. Returns this probability value as a float instance.
[ "Finds", "the", "relative", "probability", "of", "the", "word", "appearing", "given", "context", "of", "a", "base", "corpus", ".", "Returns", "this", "probability", "value", "as", "a", "float", "instance", "." ]
python
train
43.454545
bcbio/bcbio-nextgen
bcbio/structural/cnvkit.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/cnvkit.py#L112-L123
def _run_cnvkit_cancer(items, background): """Run CNVkit on a tumor/normal pair. """ paired = vcfutils.get_paired_bams([x["align_bam"] for x in items], items) normal_data = [x for x in items if dd.get_sample_name(x) != paired.tumor_name] tumor_ready, normal_ready = _match_batches(paired.tumor_data, ...
[ "def", "_run_cnvkit_cancer", "(", "items", ",", "background", ")", ":", "paired", "=", "vcfutils", ".", "get_paired_bams", "(", "[", "x", "[", "\"align_bam\"", "]", "for", "x", "in", "items", "]", ",", "items", ")", "normal_data", "=", "[", "x", "for", ...
Run CNVkit on a tumor/normal pair.
[ "Run", "CNVkit", "on", "a", "tumor", "/", "normal", "pair", "." ]
python
train
52.083333
PyCQA/astroid
astroid/scoped_nodes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/scoped_nodes.py#L2615-L2666
def _islots(self): """ Return an iterator with the inferred slots. """ if "__slots__" not in self.locals: return None for slots in self.igetattr("__slots__"): # check if __slots__ is a valid type for meth in ITER_METHODS: try: ...
[ "def", "_islots", "(", "self", ")", ":", "if", "\"__slots__\"", "not", "in", "self", ".", "locals", ":", "return", "None", "for", "slots", "in", "self", ".", "igetattr", "(", "\"__slots__\"", ")", ":", "# check if __slots__ is a valid type", "for", "meth", "...
Return an iterator with the inferred slots.
[ "Return", "an", "iterator", "with", "the", "inferred", "slots", "." ]
python
train
35.807692
skorch-dev/skorch
skorch/net.py
https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/net.py#L1450-L1513
def save_params( self, f=None, f_params=None, f_optimizer=None, f_history=None): """Saves the module's parameters, history, and optimizer, not the whole object. To save the whole object, use pickle. ``f_params`` and ``f_optimizer`` uses PyTorchs' :func:`~torch.save`...
[ "def", "save_params", "(", "self", ",", "f", "=", "None", ",", "f_params", "=", "None", ",", "f_optimizer", "=", "None", ",", "f_history", "=", "None", ")", ":", "# TODO: Remove warning in a future release", "if", "f", "is", "not", "None", ":", "warnings", ...
Saves the module's parameters, history, and optimizer, not the whole object. To save the whole object, use pickle. ``f_params`` and ``f_optimizer`` uses PyTorchs' :func:`~torch.save`. Parameters ---------- f_params : file-like object, str, None (default=None) ...
[ "Saves", "the", "module", "s", "parameters", "history", "and", "optimizer", "not", "the", "whole", "object", "." ]
python
train
39.203125
scidash/sciunit
sciunit/utils.py
https://github.com/scidash/sciunit/blob/41b2e38c45c0776727ab1f281a572b65be19cea1/sciunit/utils.py#L352-L376
def import_all_modules(package, skip=None, verbose=False, prefix="", depth=0): """Recursively imports all subpackages, modules, and submodules of a given package. 'package' should be an imported package, not a string. 'skip' is a list of modules or subpackages not to import. """ skip = [] if sk...
[ "def", "import_all_modules", "(", "package", ",", "skip", "=", "None", ",", "verbose", "=", "False", ",", "prefix", "=", "\"\"", ",", "depth", "=", "0", ")", ":", "skip", "=", "[", "]", "if", "skip", "is", "None", "else", "skip", "for", "ff", ",", ...
Recursively imports all subpackages, modules, and submodules of a given package. 'package' should be an imported package, not a string. 'skip' is a list of modules or subpackages not to import.
[ "Recursively", "imports", "all", "subpackages", "modules", "and", "submodules", "of", "a", "given", "package", ".", "package", "should", "be", "an", "imported", "package", "not", "a", "string", ".", "skip", "is", "a", "list", "of", "modules", "or", "subpacka...
python
train
41.36
vanheeringen-lab/gimmemotifs
gimmemotifs/tools.py
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/tools.py#L33-L58
def get_tool(name): """ Returns an instance of a specific tool. Parameters ---------- name : str Name of the tool (case-insensitive). Returns ------- tool : MotifProgram instance """ tool = name.lower() if tool not in __tools__: raise ValueError("Tool {0} n...
[ "def", "get_tool", "(", "name", ")", ":", "tool", "=", "name", ".", "lower", "(", ")", "if", "tool", "not", "in", "__tools__", ":", "raise", "ValueError", "(", "\"Tool {0} not found!\\n\"", ".", "format", "(", "name", ")", ")", "t", "=", "__tools__", "...
Returns an instance of a specific tool. Parameters ---------- name : str Name of the tool (case-insensitive). Returns ------- tool : MotifProgram instance
[ "Returns", "an", "instance", "of", "a", "specific", "tool", "." ]
python
train
21.461538
ausaki/python-validator
validator/validator.py
https://github.com/ausaki/python-validator/blob/a3e591b1eae6d7a70f894c203dbd7195f929baa8/validator/validator.py#L138-L157
def create_validator(data_struct_dict, name=None): """ create a Validator instance from data_struct_dict :param data_struct_dict: a dict describe validator's fields, like the dict `to_dict()` method returned. :param name: name of Validator class :return: Validator instance """ if name is...
[ "def", "create_validator", "(", "data_struct_dict", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'FromDictValidator'", "attrs", "=", "{", "}", "for", "field_name", ",", "field_info", "in", "six", ".", "iteritems", "(",...
create a Validator instance from data_struct_dict :param data_struct_dict: a dict describe validator's fields, like the dict `to_dict()` method returned. :param name: name of Validator class :return: Validator instance
[ "create", "a", "Validator", "instance", "from", "data_struct_dict" ]
python
test
38.5
dylanaraps/bum
bum/__main__.py
https://github.com/dylanaraps/bum/blob/004d795a67398e79f2c098d7775e9cd97231646b/bum/__main__.py#L19-L48
def get_args(): """Get the script arguments.""" description = "bum - Download and display album art \ for mpd tracks." arg = argparse.ArgumentParser(description=description) arg.add_argument("--size", metavar="\"px\"", help="what size to display the album art in....
[ "def", "get_args", "(", ")", ":", "description", "=", "\"bum - Download and display album art \\\n for mpd tracks.\"", "arg", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "description", ")", "arg", ".", "add_argument", "(", "\"--size\...
Get the script arguments.
[ "Get", "the", "script", "arguments", "." ]
python
train
35.966667
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L9690-L9714
def pltnp(point, v1, v2, v3): """ Find the nearest point on a triangular plate to a given point. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltnp_c.html :param point: A point in 3-dimensional space. :type point: 3-Element Array of floats :param v1: Vertices of a triangu...
[ "def", "pltnp", "(", "point", ",", "v1", ",", "v2", ",", "v3", ")", ":", "point", "=", "stypes", ".", "toDoubleVector", "(", "point", ")", "v1", "=", "stypes", ".", "toDoubleVector", "(", "v1", ")", "v2", "=", "stypes", ".", "toDoubleVector", "(", ...
Find the nearest point on a triangular plate to a given point. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltnp_c.html :param point: A point in 3-dimensional space. :type point: 3-Element Array of floats :param v1: Vertices of a triangular plate. :type v1: 3-Element Array o...
[ "Find", "the", "nearest", "point", "on", "a", "triangular", "plate", "to", "a", "given", "point", ".", "https", ":", "//", "naif", ".", "jpl", ".", "nasa", ".", "gov", "/", "pub", "/", "naif", "/", "toolkit_docs", "/", "C", "/", "cspice", "/", "plt...
python
train
38.64
python-visualization/folium
folium/utilities.py
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L343-L357
def _locations_mirror(x): """ Mirrors the points in a list-of-list-of-...-of-list-of-points. For example: >>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]]) [[[2, 1], [4, 3]], [6, 5], [8, 7]] """ if hasattr(x, '__iter__'): if hasattr(x[0], '__iter__'): return list...
[ "def", "_locations_mirror", "(", "x", ")", ":", "if", "hasattr", "(", "x", ",", "'__iter__'", ")", ":", "if", "hasattr", "(", "x", "[", "0", "]", ",", "'__iter__'", ")", ":", "return", "list", "(", "map", "(", "_locations_mirror", ",", "x", ")", ")...
Mirrors the points in a list-of-list-of-...-of-list-of-points. For example: >>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]]) [[[2, 1], [4, 3]], [6, 5], [8, 7]]
[ "Mirrors", "the", "points", "in", "a", "list", "-", "of", "-", "list", "-", "of", "-", "...", "-", "of", "-", "list", "-", "of", "-", "points", ".", "For", "example", ":", ">>>", "_locations_mirror", "(", "[[[", "1", "2", "]", "[", "3", "4", "]...
python
train
27.133333
jspricke/python-abook
abook.py
https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L270-L280
def _conv_tel_list(tel_list, entry): """Converts to Abook phone types""" for tel in tel_list: if not hasattr(tel, 'TYPE_param'): entry['other'] = tel.value elif tel.TYPE_param.lower() == 'home': entry['phone'] = tel.value elif tel.TYPE_...
[ "def", "_conv_tel_list", "(", "tel_list", ",", "entry", ")", ":", "for", "tel", "in", "tel_list", ":", "if", "not", "hasattr", "(", "tel", ",", "'TYPE_param'", ")", ":", "entry", "[", "'other'", "]", "=", "tel", ".", "value", "elif", "tel", ".", "TYP...
Converts to Abook phone types
[ "Converts", "to", "Abook", "phone", "types" ]
python
train
43.272727
newville/wxmplot
wxmplot/plotframe.py
https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotframe.py#L38-L40
def oplot(self, x, y, **kw): """generic plotting method, overplotting any existing plot """ self.panel.oplot(x, y, **kw)
[ "def", "oplot", "(", "self", ",", "x", ",", "y", ",", "*", "*", "kw", ")", ":", "self", ".", "panel", ".", "oplot", "(", "x", ",", "y", ",", "*", "*", "kw", ")" ]
generic plotting method, overplotting any existing plot
[ "generic", "plotting", "method", "overplotting", "any", "existing", "plot" ]
python
train
44.666667
TheRealLink/pylgtv
pylgtv/webos_client.py
https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L314-L317
def get_volume(self): """Get the current volume.""" self.request(EP_GET_VOLUME) return 0 if self.last_response is None else self.last_response.get('payload').get('volume')
[ "def", "get_volume", "(", "self", ")", ":", "self", ".", "request", "(", "EP_GET_VOLUME", ")", "return", "0", "if", "self", ".", "last_response", "is", "None", "else", "self", ".", "last_response", ".", "get", "(", "'payload'", ")", ".", "get", "(", "'...
Get the current volume.
[ "Get", "the", "current", "volume", "." ]
python
train
48
log2timeline/plaso
plaso/output/rawpy.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/rawpy.py#L16-L59
def GetFormattedEventObject(cls, event): """Retrieves a string representation of the event. Args: event (EventObject): event. Returns: str: string representation of the event. """ time_string = timelib.Timestamp.CopyToIsoFormat(event.timestamp) lines_of_text = [ '+-' * 40,...
[ "def", "GetFormattedEventObject", "(", "cls", ",", "event", ")", ":", "time_string", "=", "timelib", ".", "Timestamp", ".", "CopyToIsoFormat", "(", "event", ".", "timestamp", ")", "lines_of_text", "=", "[", "'+-'", "*", "40", ",", "'[Timestamp]:'", ",", "' ...
Retrieves a string representation of the event. Args: event (EventObject): event. Returns: str: string representation of the event.
[ "Retrieves", "a", "string", "representation", "of", "the", "event", "." ]
python
train
32.181818
AtmaHou/atma
Metrics.py
https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L31-L67
def load_dataset_items(test_file, predict_file_lst, nonfeature_file): """ This function is used to read 3 kinds of data into list, 3 kinds of data are stored in files given by parameter :param test_file: path string, the testing set used for SVm rank :param predict_file_lst: filename lst, all predic...
[ "def", "load_dataset_items", "(", "test_file", ",", "predict_file_lst", ",", "nonfeature_file", ")", ":", "print", "'Reading baseline feature & bleu...'", "with", "open", "(", "test_file", ",", "'r'", ")", "as", "reader", ":", "for", "line", "in", "reader", ":", ...
This function is used to read 3 kinds of data into list, 3 kinds of data are stored in files given by parameter :param test_file: path string, the testing set used for SVm rank :param predict_file_lst: filename lst, all prediction file output by SVM rank :param nonfeature_file: path string, contain all t...
[ "This", "function", "is", "used", "to", "read", "3", "kinds", "of", "data", "into", "list", "3", "kinds", "of", "data", "are", "stored", "in", "files", "given", "by", "parameter", ":", "param", "test_file", ":", "path", "string", "the", "testing", "set",...
python
train
44.621622
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_process_net_command.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_process_net_command.py#L25-L66
def process_net_command(self, py_db, cmd_id, seq, text): '''Processes a command received from the Java side @param cmd_id: the id of the command @param seq: the sequence of the command @param text: the text received in the command ''' meaning = ID_TO_MEANING[str(cmd_id)]...
[ "def", "process_net_command", "(", "self", ",", "py_db", ",", "cmd_id", ",", "seq", ",", "text", ")", ":", "meaning", "=", "ID_TO_MEANING", "[", "str", "(", "cmd_id", ")", "]", "# print('Handling %s (%s)' % (meaning, text))", "method_name", "=", "meaning", ".", ...
Processes a command received from the Java side @param cmd_id: the id of the command @param seq: the sequence of the command @param text: the text received in the command
[ "Processes", "a", "command", "received", "from", "the", "Java", "side" ]
python
train
36.47619
J535D165/recordlinkage
recordlinkage/measures.py
https://github.com/J535D165/recordlinkage/blob/87a5f4af904e0834047cd07ff1c70146b1e6d693/recordlinkage/measures.py#L330-L362
def recall(links_true, links_pred=None): """recall(links_true, links_pred) Compute the recall/sensitivity. The recall is given by TP/(TP+FN). Parameters ---------- links_true: pandas.MultiIndex, pandas.DataFrame, pandas.Series The true (or actual) collection of links. links_pred: ...
[ "def", "recall", "(", "links_true", ",", "links_pred", "=", "None", ")", ":", "if", "_isconfusionmatrix", "(", "links_true", ")", ":", "confusion_matrix", "=", "links_true", "v", "=", "confusion_matrix", "[", "0", ",", "0", "]", "/", "(", "confusion_matrix",...
recall(links_true, links_pred) Compute the recall/sensitivity. The recall is given by TP/(TP+FN). Parameters ---------- links_true: pandas.MultiIndex, pandas.DataFrame, pandas.Series The true (or actual) collection of links. links_pred: pandas.MultiIndex, pandas.DataFrame, pandas.Seri...
[ "recall", "(", "links_true", "links_pred", ")" ]
python
train
23.878788
uw-it-aca/uw-restclients-uwnetid
uw_uwnetid/subscription_60.py
https://github.com/uw-it-aca/uw-restclients-uwnetid/blob/58c78b564f9c920a8f8fd408eec959ddd5605b0b/uw_uwnetid/subscription_60.py#L35-L46
def _has_desired_permit(permits, acategory, astatus): """ return True if permits has one whose category_code and status_code match with the given ones """ if permits is None: return False for permit in permits: if permit.category_code == acategory and\ permit.status_co...
[ "def", "_has_desired_permit", "(", "permits", ",", "acategory", ",", "astatus", ")", ":", "if", "permits", "is", "None", ":", "return", "False", "for", "permit", "in", "permits", ":", "if", "permit", ".", "category_code", "==", "acategory", "and", "permit", ...
return True if permits has one whose category_code and status_code match with the given ones
[ "return", "True", "if", "permits", "has", "one", "whose", "category_code", "and", "status_code", "match", "with", "the", "given", "ones" ]
python
train
30.333333
spyder-ide/conda-manager
conda_manager/api/download_api.py
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L561-L566
def terminate(self): """Terminate all workers and threads.""" for t in self._threads: t.quit() self._thread = [] self._workers = []
[ "def", "terminate", "(", "self", ")", ":", "for", "t", "in", "self", ".", "_threads", ":", "t", ".", "quit", "(", ")", "self", ".", "_thread", "=", "[", "]", "self", ".", "_workers", "=", "[", "]" ]
Terminate all workers and threads.
[ "Terminate", "all", "workers", "and", "threads", "." ]
python
train
28.333333
trailofbits/manticore
manticore/core/workspace.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/workspace.py#L119-L129
def save_stream(self, key, binary=False): """ Return a managed file-like object into which the calling code can write arbitrary data. :param key: :return: A managed stream-like object """ s = io.BytesIO() if binary else io.StringIO() yield s self....
[ "def", "save_stream", "(", "self", ",", "key", ",", "binary", "=", "False", ")", ":", "s", "=", "io", ".", "BytesIO", "(", ")", "if", "binary", "else", "io", ".", "StringIO", "(", ")", "yield", "s", "self", ".", "save_value", "(", "key", ",", "s"...
Return a managed file-like object into which the calling code can write arbitrary data. :param key: :return: A managed stream-like object
[ "Return", "a", "managed", "file", "-", "like", "object", "into", "which", "the", "calling", "code", "can", "write", "arbitrary", "data", "." ]
python
valid
30.818182
tensorflow/mesh
mesh_tensorflow/layers.py
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/layers.py#L963-L989
def attention_bias_local_block(mesh, block_length, memory_length, dtype=tf.int32): """Bias for attention for local blocks where attention to right is disallowed. Create the bias matrix by using two separate masks, one for the memory part which doesn't overlap with the query and sec...
[ "def", "attention_bias_local_block", "(", "mesh", ",", "block_length", ",", "memory_length", ",", "dtype", "=", "tf", ".", "int32", ")", ":", "memory_length", "=", "mtf", ".", "Dimension", "(", "memory_length", ".", "name", ",", "block_length", ".", "size", ...
Bias for attention for local blocks where attention to right is disallowed. Create the bias matrix by using two separate masks, one for the memory part which doesn't overlap with the query and second which interacts with the query and should be disallowed to look to the right of the current query position. Ar...
[ "Bias", "for", "attention", "for", "local", "blocks", "where", "attention", "to", "right", "is", "disallowed", "." ]
python
train
39.37037
bcbio/bcbio-nextgen
bcbio/ngsalign/alignprep.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L133-L154
def _seqtk_fastq_prep_cl(data, in_file=None, read_num=0): """Provide a commandline for prep of fastq inputs with seqtk. Handles fast conversion of fastq quality scores and trimming. """ needs_convert = dd.get_quality_format(data).lower() == "illumina" trim_ends = dd.get_trim_ends(data) seqtk = ...
[ "def", "_seqtk_fastq_prep_cl", "(", "data", ",", "in_file", "=", "None", ",", "read_num", "=", "0", ")", ":", "needs_convert", "=", "dd", ".", "get_quality_format", "(", "data", ")", ".", "lower", "(", ")", "==", "\"illumina\"", "trim_ends", "=", "dd", "...
Provide a commandline for prep of fastq inputs with seqtk. Handles fast conversion of fastq quality scores and trimming.
[ "Provide", "a", "commandline", "for", "prep", "of", "fastq", "inputs", "with", "seqtk", "." ]
python
train
43.363636