repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
nfcpy/nfcpy
src/nfc/tag/tt2_nxp.py
https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2_nxp.py#L346-L374
def protect(self, password=None, read_protect=False, protect_from=0): """Set password protection or permanent lock bits. If the *password* argument is None, all memory pages will be protected by setting the relevant lock bits (note that lock bits can not be reset). If valid NDEF managem...
[ "def", "protect", "(", "self", ",", "password", "=", "None", ",", "read_protect", "=", "False", ",", "protect_from", "=", "0", ")", ":", "args", "=", "(", "password", ",", "read_protect", ",", "protect_from", ")", "return", "super", "(", "NTAG21x", ",", ...
Set password protection or permanent lock bits. If the *password* argument is None, all memory pages will be protected by setting the relevant lock bits (note that lock bits can not be reset). If valid NDEF management data is found, protect() also sets the NDEF write flag to read-only. ...
[ "Set", "password", "protection", "or", "permanent", "lock", "bits", "." ]
python
train
wdbm/shijian
shijian.py
https://github.com/wdbm/shijian/blob/ad6aea877e1eb99fe148127ea185f39f1413ed4f/shijian.py#L1578-L1611
def add_time_variables(df, reindex = True): """ Return a DataFrame with variables for weekday index, weekday name, timedelta through day, fraction through day, hours through day and days through week added, optionally with the index set to datetime and the variable `datetime` removed. It is assumed ...
[ "def", "add_time_variables", "(", "df", ",", "reindex", "=", "True", ")", ":", "if", "not", "\"datetime\"", "in", "df", ".", "columns", ":", "log", ".", "error", "(", "\"field datetime not found in DataFrame\"", ")", "return", "False", "df", "[", "\"datetime\"...
Return a DataFrame with variables for weekday index, weekday name, timedelta through day, fraction through day, hours through day and days through week added, optionally with the index set to datetime and the variable `datetime` removed. It is assumed that the variable `datetime` exists.
[ "Return", "a", "DataFrame", "with", "variables", "for", "weekday", "index", "weekday", "name", "timedelta", "through", "day", "fraction", "through", "day", "hours", "through", "day", "and", "days", "through", "week", "added", "optionally", "with", "the", "index"...
python
train
twisted/mantissa
xmantissa/cachejs.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/cachejs.py#L45-L57
def wasModified(self): """ Check to see if this module has been modified on disk since the last time it was cached. @return: True if it has been modified, False if not. """ self.filePath.restat() mtime = self.filePath.getmtime() if mtime >= self.lastModif...
[ "def", "wasModified", "(", "self", ")", ":", "self", ".", "filePath", ".", "restat", "(", ")", "mtime", "=", "self", ".", "filePath", ".", "getmtime", "(", ")", "if", "mtime", ">=", "self", ".", "lastModified", ":", "return", "True", "else", ":", "re...
Check to see if this module has been modified on disk since the last time it was cached. @return: True if it has been modified, False if not.
[ "Check", "to", "see", "if", "this", "module", "has", "been", "modified", "on", "disk", "since", "the", "last", "time", "it", "was", "cached", "." ]
python
train
summa-tx/riemann
riemann/simple.py
https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/simple.py#L223-L258
def unsigned_legacy_tx(tx_ins, tx_outs, **kwargs): '''Create an unsigned transaction Use this to generate sighashes for unsigned TxIns Gotcha: it requires you to know the timelock and version it will _not_ guess them becuase it may not have acess to all scripts Hint: set version ...
[ "def", "unsigned_legacy_tx", "(", "tx_ins", ",", "tx_outs", ",", "*", "*", "kwargs", ")", ":", "return", "tb", ".", "make_tx", "(", "version", "=", "kwargs", "[", "'version'", "]", "if", "'version'", "in", "kwargs", "else", "1", ",", "tx_ins", "=", "tx...
Create an unsigned transaction Use this to generate sighashes for unsigned TxIns Gotcha: it requires you to know the timelock and version it will _not_ guess them becuase it may not have acess to all scripts Hint: set version to 2 if using sequence number relative time locks Arg...
[ "Create", "an", "unsigned", "transaction", "Use", "this", "to", "generate", "sighashes", "for", "unsigned", "TxIns", "Gotcha", ":", "it", "requires", "you", "to", "know", "the", "timelock", "and", "version", "it", "will", "_not_", "guess", "them", "becuase", ...
python
train
mrcagney/gtfstk
gtfstk/miscellany.py
https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/miscellany.py#L620-L652
def compute_center( feed: "Feed", num_busiest_stops: Optional[int] = None ) -> Tuple: """ Return the centroid (WGS84 longitude-latitude pair) of the convex hull of the stops of the given Feed. If ``num_busiest_stops`` (integer) is given, then compute the ``num_busiest_stops`` busiest stops in th...
[ "def", "compute_center", "(", "feed", ":", "\"Feed\"", ",", "num_busiest_stops", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "Tuple", ":", "s", "=", "feed", ".", "stops", ".", "copy", "(", ")", "if", "num_busiest_stops", "is", "None", ":"...
Return the centroid (WGS84 longitude-latitude pair) of the convex hull of the stops of the given Feed. If ``num_busiest_stops`` (integer) is given, then compute the ``num_busiest_stops`` busiest stops in the feed on the first Monday of the feed and return the mean of the longitudes and the mean of t...
[ "Return", "the", "centroid", "(", "WGS84", "longitude", "-", "latitude", "pair", ")", "of", "the", "convex", "hull", "of", "the", "stops", "of", "the", "given", "Feed", ".", "If", "num_busiest_stops", "(", "integer", ")", "is", "given", "then", "compute", ...
python
train
rueckstiess/mtools
mtools/mplotqueries/plottypes/histogram_type.py
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mplotqueries/plottypes/histogram_type.py#L80-L151
def plot(self, axis, ith_plot, total_plots, limits): """ Plot the histogram as a whole over all groups. Do not plot as individual groups like other plot types. """ print(self.plot_type_str.upper() + " plot") print("%5s %9s %s" % ("id", " #points", "group")) for...
[ "def", "plot", "(", "self", ",", "axis", ",", "ith_plot", ",", "total_plots", ",", "limits", ")", ":", "print", "(", "self", ".", "plot_type_str", ".", "upper", "(", ")", "+", "\" plot\"", ")", "print", "(", "\"%5s %9s %s\"", "%", "(", "\"id\"", ",", ...
Plot the histogram as a whole over all groups. Do not plot as individual groups like other plot types.
[ "Plot", "the", "histogram", "as", "a", "whole", "over", "all", "groups", "." ]
python
train
Azure/azure-uamqp-python
uamqp/client.py
https://github.com/Azure/azure-uamqp-python/blob/b67e4fcaf2e8a337636947523570239c10a58ae2/uamqp/client.py#L249-L281
def close(self): """Close the client. This includes closing the Session and CBS authentication layer as well as the Connection. If the client was opened using an external Connection, this will be left intact. No further messages can be sent or received and the client can...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "message_handler", ":", "self", ".", "message_handler", ".", "destroy", "(", ")", "self", ".", "message_handler", "=", "None", "self", ".", "_shutdown", "=", "True", "if", "self", ".", "_keep_aliv...
Close the client. This includes closing the Session and CBS authentication layer as well as the Connection. If the client was opened using an external Connection, this will be left intact. No further messages can be sent or received and the client cannot be re-opened. A...
[ "Close", "the", "client", ".", "This", "includes", "closing", "the", "Session", "and", "CBS", "authentication", "layer", "as", "well", "as", "the", "Connection", ".", "If", "the", "client", "was", "opened", "using", "an", "external", "Connection", "this", "w...
python
train
kislyuk/aegea
aegea/packages/github3/pulls.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/pulls.py#L254-L264
def iter_comments(self, number=-1, etag=None): """Iterate over the comments on this pull request. :param int number: (optional), number of comments to return. Default: -1 returns all available comments. :param str etag: (optional), ETag from a previous request to the same ...
[ "def", "iter_comments", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'comments'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_iter", "(", "i...
Iterate over the comments on this pull request. :param int number: (optional), number of comments to return. Default: -1 returns all available comments. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`ReviewCo...
[ "Iterate", "over", "the", "comments", "on", "this", "pull", "request", "." ]
python
train
ioos/compliance-checker
compliance_checker/cf/cf.py
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cf/cf.py#L3129-L3194
def check_compression_gathering(self, ds): """ At the current time the netCDF interface does not provide for packing data. However a simple packing may be achieved through the use of the optional NUG defined attributes scale_factor and add_offset . After the data values of a vari...
[ "def", "check_compression_gathering", "(", "self", ",", "ds", ")", ":", "ret_val", "=", "[", "]", "for", "compress_var", "in", "ds", ".", "get_variables_by_attributes", "(", "compress", "=", "lambda", "s", ":", "s", "is", "not", "None", ")", ":", "valid", ...
At the current time the netCDF interface does not provide for packing data. However a simple packing may be achieved through the use of the optional NUG defined attributes scale_factor and add_offset . After the data values of a variable have been read, they are to be multiplied by the s...
[ "At", "the", "current", "time", "the", "netCDF", "interface", "does", "not", "provide", "for", "packing", "data", ".", "However", "a", "simple", "packing", "may", "be", "achieved", "through", "the", "use", "of", "the", "optional", "NUG", "defined", "attribut...
python
train
crocs-muni/roca
roca/detect.py
https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L237-L276
def try_get_dn_string(subject, shorten=False): """ Returns DN as a string :param subject: :param shorten: :return: """ try: from cryptography.x509.oid import NameOID from cryptography.x509 import ObjectIdentifier oid_names = { getattr(NameOID, 'COMMON_NAME...
[ "def", "try_get_dn_string", "(", "subject", ",", "shorten", "=", "False", ")", ":", "try", ":", "from", "cryptography", ".", "x509", ".", "oid", "import", "NameOID", "from", "cryptography", ".", "x509", "import", "ObjectIdentifier", "oid_names", "=", "{", "g...
Returns DN as a string :param subject: :param shorten: :return:
[ "Returns", "DN", "as", "a", "string", ":", "param", "subject", ":", ":", "param", "shorten", ":", ":", "return", ":" ]
python
train
nakagami/pyfirebirdsql
firebirdsql/decfloat.py
https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/decfloat.py#L47-L100
def dpd_to_int(dpd): """ Convert DPD encodined value to int (0-999) dpd: DPD encoded value. 10bit unsigned int """ b = [None] * 10 b[9] = 1 if dpd & 0b1000000000 else 0 b[8] = 1 if dpd & 0b0100000000 else 0 b[7] = 1 if dpd & 0b0010000000 else 0 b[6] = 1 if dpd & 0b0001000000 else 0 ...
[ "def", "dpd_to_int", "(", "dpd", ")", ":", "b", "=", "[", "None", "]", "*", "10", "b", "[", "9", "]", "=", "1", "if", "dpd", "&", "0b1000000000", "else", "0", "b", "[", "8", "]", "=", "1", "if", "dpd", "&", "0b0100000000", "else", "0", "b", ...
Convert DPD encodined value to int (0-999) dpd: DPD encoded value. 10bit unsigned int
[ "Convert", "DPD", "encodined", "value", "to", "int", "(", "0", "-", "999", ")", "dpd", ":", "DPD", "encoded", "value", ".", "10bit", "unsigned", "int" ]
python
train
line/line-bot-sdk-python
linebot/webhook.py
https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/webhook.py#L165-L185
def add(self, event, message=None): """[Decorator] Add handler method. :param event: Specify a kind of Event which you want to handle :type event: T <= :py:class:`linebot.models.events.Event` class :param message: (optional) If event is MessageEvent, specify kind of Messages...
[ "def", "add", "(", "self", ",", "event", ",", "message", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "isinstance", "(", "message", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "it", "in", "message", ":", "self...
[Decorator] Add handler method. :param event: Specify a kind of Event which you want to handle :type event: T <= :py:class:`linebot.models.events.Event` class :param message: (optional) If event is MessageEvent, specify kind of Messages which you want to handle :type: messag...
[ "[", "Decorator", "]", "Add", "handler", "method", "." ]
python
train
saltstack/salt
salt/states/reg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/reg.py#L461-L539
def absent(name, vname=None, use_32bit_registry=False): r''' Ensure a registry value is removed. To remove a key use key_absent. Args: name (str): A string value representing the full path of the key to include the HIVE, Key, and all Subkeys. For example: ``HKEY...
[ "def", "absent", "(", "name", ",", "vname", "=", "None", ",", "use_32bit_registry", "=", "False", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", "}", "hi...
r''' Ensure a registry value is removed. To remove a key use key_absent. Args: name (str): A string value representing the full path of the key to include the HIVE, Key, and all Subkeys. For example: ``HKEY_LOCAL_MACHINE\\SOFTWARE\\Salt`` Valid hive val...
[ "r", "Ensure", "a", "registry", "value", "is", "removed", ".", "To", "remove", "a", "key", "use", "key_absent", "." ]
python
train
sfischer13/python-prompt
prompt/__init__.py
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L108-L132
def integer(prompt=None, empty=False): """Prompt an integer. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- int or None An int if the user entered a valid integer. N...
[ "def", "integer", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "try", ":", "return", "int", "(", "s", ")", "...
Prompt an integer. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- int or None An int if the user entered a valid integer. None if the user pressed only Enter and ``empty...
[ "Prompt", "an", "integer", "." ]
python
train
taddeus/wspy
extension.py
https://github.com/taddeus/wspy/blob/13f054a72442bb8dcc37b0ac011cab6025830d66/extension.py#L31-L42
def conflicts(self, ext): """ Check if the extension conflicts with an already accepted extension. This may be the case when the two extensions use the same reserved bits, or have the same name (when the same extension is negotiated multiple times with different parameters). ...
[ "def", "conflicts", "(", "self", ",", "ext", ")", ":", "return", "ext", ".", "rsv1", "and", "self", ".", "rsv1", "or", "ext", ".", "rsv2", "and", "self", ".", "rsv2", "or", "ext", ".", "rsv3", "and", "self", ".", "rsv3", "or", "set", "(", "ext", ...
Check if the extension conflicts with an already accepted extension. This may be the case when the two extensions use the same reserved bits, or have the same name (when the same extension is negotiated multiple times with different parameters).
[ "Check", "if", "the", "extension", "conflicts", "with", "an", "already", "accepted", "extension", ".", "This", "may", "be", "the", "case", "when", "the", "two", "extensions", "use", "the", "same", "reserved", "bits", "or", "have", "the", "same", "name", "(...
python
train
iotile/coretools
iotilecore/iotile/core/hw/update/records/reflash_controller.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/update/records/reflash_controller.py#L86-L115
def FromBinary(cls, record_data, record_count=1): """Create an UpdateRecord subclass from binary record data. This should be called with a binary record blob (NOT including the record type header) and it will decode it into a ReflashControllerRecord. Args: record_data (byte...
[ "def", "FromBinary", "(", "cls", ",", "record_data", ",", "record_count", "=", "1", ")", ":", "if", "len", "(", "record_data", ")", "<", "ReflashControllerRecord", ".", "RecordHeaderLength", ":", "raise", "ArgumentError", "(", "\"Record was too short to contain a fu...
Create an UpdateRecord subclass from binary record data. This should be called with a binary record blob (NOT including the record type header) and it will decode it into a ReflashControllerRecord. Args: record_data (bytearray): The raw record data that we wish to parse ...
[ "Create", "an", "UpdateRecord", "subclass", "from", "binary", "record", "data", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_firmware_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_firmware_ext.py#L81-L93
def show_firmware_version_output_show_firmware_version_build_time(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") show_firmware_version = ET.Element("show_firmware_version") config = show_firmware_version output = ET.SubElement(show_firmware_vers...
[ "def", "show_firmware_version_output_show_firmware_version_build_time", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "show_firmware_version", "=", "ET", ".", "Element", "(", "\"show_firmware_version\"", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
allenai/allennlp
allennlp/modules/conditional_random_field.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/conditional_random_field.py#L207-L251
def _input_likelihood(self, logits: torch.Tensor, mask: torch.Tensor) -> torch.Tensor: """ Computes the (batch_size,) denominator term for the log-likelihood, which is the sum of the likelihoods across all possible state sequences. """ batch_size, sequence_length, num_tags = logi...
[ "def", "_input_likelihood", "(", "self", ",", "logits", ":", "torch", ".", "Tensor", ",", "mask", ":", "torch", ".", "Tensor", ")", "->", "torch", ".", "Tensor", ":", "batch_size", ",", "sequence_length", ",", "num_tags", "=", "logits", ".", "size", "(",...
Computes the (batch_size,) denominator term for the log-likelihood, which is the sum of the likelihoods across all possible state sequences.
[ "Computes", "the", "(", "batch_size", ")", "denominator", "term", "for", "the", "log", "-", "likelihood", "which", "is", "the", "sum", "of", "the", "likelihoods", "across", "all", "possible", "state", "sequences", "." ]
python
train
seleniumbase/SeleniumBase
seleniumbase/fixtures/email_manager.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/email_manager.py#L54-L102
def __imap_search(self, ** criteria_dict): """ Searches for query in the given IMAP criteria and returns the message numbers that match as a list of strings. Criteria without values (eg DELETED) should be keyword args with KEY=True, or else not passed. Criteria with values should ...
[ "def", "__imap_search", "(", "self", ",", "*", "*", "criteria_dict", ")", ":", "self", ".", "imap_connect", "(", ")", "criteria", "=", "[", "]", "for", "key", "in", "criteria_dict", ":", "if", "criteria_dict", "[", "key", "]", "is", "True", ":", "crite...
Searches for query in the given IMAP criteria and returns the message numbers that match as a list of strings. Criteria without values (eg DELETED) should be keyword args with KEY=True, or else not passed. Criteria with values should be keyword args of the form KEY="VALUE" where KEY is ...
[ "Searches", "for", "query", "in", "the", "given", "IMAP", "criteria", "and", "returns", "the", "message", "numbers", "that", "match", "as", "a", "list", "of", "strings", "." ]
python
train
oanda/v20-python
src/v20/pricing.py
https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/pricing.py#L196-L216
def from_dict(data, ctx): """ Instantiate a new QuoteHomeConversionFactors from a dict (generally from loading a JSON response). The data used to instantiate the QuoteHomeConversionFactors is a shallow copy of the dict passed in, with any complex child types instantiated appropri...
[ "def", "from_dict", "(", "data", ",", "ctx", ")", ":", "data", "=", "data", ".", "copy", "(", ")", "if", "data", ".", "get", "(", "'positiveUnits'", ")", "is", "not", "None", ":", "data", "[", "'positiveUnits'", "]", "=", "ctx", ".", "convert_decimal...
Instantiate a new QuoteHomeConversionFactors from a dict (generally from loading a JSON response). The data used to instantiate the QuoteHomeConversionFactors is a shallow copy of the dict passed in, with any complex child types instantiated appropriately.
[ "Instantiate", "a", "new", "QuoteHomeConversionFactors", "from", "a", "dict", "(", "generally", "from", "loading", "a", "JSON", "response", ")", ".", "The", "data", "used", "to", "instantiate", "the", "QuoteHomeConversionFactors", "is", "a", "shallow", "copy", "...
python
train
fermiPy/fermipy
fermipy/jobs/link.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L475-L480
def _update_file_args(self, file_mapping): """Adjust the arguments to deal with staging files to the scratch area""" for key, value in self.args.items(): new_value = file_mapping.get(value, value) if new_value != value: self.args[key] = new_value
[ "def", "_update_file_args", "(", "self", ",", "file_mapping", ")", ":", "for", "key", ",", "value", "in", "self", ".", "args", ".", "items", "(", ")", ":", "new_value", "=", "file_mapping", ".", "get", "(", "value", ",", "value", ")", "if", "new_value"...
Adjust the arguments to deal with staging files to the scratch area
[ "Adjust", "the", "arguments", "to", "deal", "with", "staging", "files", "to", "the", "scratch", "area" ]
python
train
sentinel-hub/sentinelhub-py
sentinelhub/aws.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L337-L358
def get_requests(self): """ Creates product structure and returns list of files for download. :return: List of download requests and list of empty folders that need to be created :rtype: (list(download.DownloadRequest), list(str)) """ self.download_list = [DownloadReques...
[ "def", "get_requests", "(", "self", ")", ":", "self", ".", "download_list", "=", "[", "DownloadRequest", "(", "url", "=", "self", ".", "get_url", "(", "metafile", ")", ",", "filename", "=", "self", ".", "get_filepath", "(", "metafile", ")", ",", "data_ty...
Creates product structure and returns list of files for download. :return: List of download requests and list of empty folders that need to be created :rtype: (list(download.DownloadRequest), list(str))
[ "Creates", "product", "structure", "and", "returns", "list", "of", "files", "for", "download", "." ]
python
train
saltstack/salt
salt/thorium/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/__init__.py#L163-L190
def call_runtime(self): ''' Execute the runtime ''' cache = self.gather_cache() chunks = self.get_chunks() interval = self.opts['thorium_interval'] recompile = self.opts.get('thorium_recompile', 300) r_start = time.time() while True: ev...
[ "def", "call_runtime", "(", "self", ")", ":", "cache", "=", "self", ".", "gather_cache", "(", ")", "chunks", "=", "self", ".", "get_chunks", "(", ")", "interval", "=", "self", ".", "opts", "[", "'thorium_interval'", "]", "recompile", "=", "self", ".", ...
Execute the runtime
[ "Execute", "the", "runtime" ]
python
train
l04m33/pyx
pyx/http.py
https://github.com/l04m33/pyx/blob/b70efec605832ba3c7079e991584db3f5d1da8cb/pyx/http.py#L273-L287
def respond(self, code): """Starts a response. ``code`` is an integer standing for standard HTTP status code. This method will automatically adjust the response to adapt to request parameters, such as "Accept-Encoding" and "TE". """ # TODO: respect encodings etc. in th...
[ "def", "respond", "(", "self", ",", "code", ")", ":", "# TODO: respect encodings etc. in the request", "resp", "=", "HttpResponse", "(", "code", ",", "self", ".", "connection", ")", "resp", ".", "request", "=", "self", "if", "hasattr", "(", "self", ",", "'ve...
Starts a response. ``code`` is an integer standing for standard HTTP status code. This method will automatically adjust the response to adapt to request parameters, such as "Accept-Encoding" and "TE".
[ "Starts", "a", "response", "." ]
python
train
adafruit/Adafruit_Python_LED_Backpack
Adafruit_LED_Backpack/SevenSegment.py
https://github.com/adafruit/Adafruit_Python_LED_Backpack/blob/7356b4dd8b4bb162d60987878c2cb752fdd017d5/Adafruit_LED_Backpack/SevenSegment.py#L167-L188
def print_number_str(self, value, justify_right=True): """Print a 4 character long string of numeric values to the display. Characters in the string should be any supported character by set_digit, or a decimal point. Decimal point characters will be associated with the previous characte...
[ "def", "print_number_str", "(", "self", ",", "value", ",", "justify_right", "=", "True", ")", ":", "# Calculate length of value without decimals.", "length", "=", "sum", "(", "map", "(", "lambda", "x", ":", "1", "if", "x", "!=", "'.'", "else", "0", ",", "v...
Print a 4 character long string of numeric values to the display. Characters in the string should be any supported character by set_digit, or a decimal point. Decimal point characters will be associated with the previous character.
[ "Print", "a", "4", "character", "long", "string", "of", "numeric", "values", "to", "the", "display", ".", "Characters", "in", "the", "string", "should", "be", "any", "supported", "character", "by", "set_digit", "or", "a", "decimal", "point", ".", "Decimal", ...
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_port_profile.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_port_profile.py#L698-L711
def port_profile_global_port_profile_static_mac_address(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") port_profile_global = ET.SubElement(config, "port-profile-global", xmlns="urn:brocade.com:mgmt:brocade-port-profile") port_profile = ET.SubElement(por...
[ "def", "port_profile_global_port_profile_static_mac_address", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "port_profile_global", "=", "ET", ".", "SubElement", "(", "config", ",", "\"port-profile-glob...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
yougov/FogBugzPy
fogbugz.py
https://github.com/yougov/FogBugzPy/blob/593aba31dff69b5d42f864e544f8a9c1872e3a16/fogbugz.py#L125-L172
def __encode_multipart_formdata(self, fields, files): """ fields is a sequence of (key, value) elements for regular form fields. files is a sequence of (filename, filehandle) files to be uploaded returns (content_type, body) """ BOUNDARY = _make_boundary() if len...
[ "def", "__encode_multipart_formdata", "(", "self", ",", "fields", ",", "files", ")", ":", "BOUNDARY", "=", "_make_boundary", "(", ")", "if", "len", "(", "files", ")", ">", "0", ":", "fields", "[", "'nFileCount'", "]", "=", "str", "(", "len", "(", "file...
fields is a sequence of (key, value) elements for regular form fields. files is a sequence of (filename, filehandle) files to be uploaded returns (content_type, body)
[ "fields", "is", "a", "sequence", "of", "(", "key", "value", ")", "elements", "for", "regular", "form", "fields", ".", "files", "is", "a", "sequence", "of", "(", "filename", "filehandle", ")", "files", "to", "be", "uploaded", "returns", "(", "content_type",...
python
valid
jart/fabulous
fabulous/gotham.py
https://github.com/jart/fabulous/blob/19903cf0a980b82f5928c3bec1f28b6bdd3785bd/fabulous/gotham.py#L95-L105
def lorem_gotham_title(): """Names your poem """ w = lambda l: l[random.randrange(len(l))] sentence = lambda *l: lambda: " ".join(l) pick = lambda *l: (l[random.randrange(len(l))])() return pick( sentence('why i',w(me_verb)), sentence(w(place)), sentence('a',w(adj),w(adj)...
[ "def", "lorem_gotham_title", "(", ")", ":", "w", "=", "lambda", "l", ":", "l", "[", "random", ".", "randrange", "(", "len", "(", "l", ")", ")", "]", "sentence", "=", "lambda", "*", "l", ":", "lambda", ":", "\" \"", ".", "join", "(", "l", ")", "...
Names your poem
[ "Names", "your", "poem" ]
python
train
jbasko/configmanager
configmanager/managers.py
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/managers.py#L152-L167
def configparser(self): """ Adapter to dump/load INI format strings and files using standard library's ``ConfigParser`` (or the backported configparser module in Python 2). Returns: ConfigPersistenceAdapter """ if self._configparser_adapter is None: ...
[ "def", "configparser", "(", "self", ")", ":", "if", "self", ".", "_configparser_adapter", "is", "None", ":", "self", ".", "_configparser_adapter", "=", "ConfigPersistenceAdapter", "(", "config", "=", "self", ",", "reader_writer", "=", "ConfigParserReaderWriter", "...
Adapter to dump/load INI format strings and files using standard library's ``ConfigParser`` (or the backported configparser module in Python 2). Returns: ConfigPersistenceAdapter
[ "Adapter", "to", "dump", "/", "load", "INI", "format", "strings", "and", "files", "using", "standard", "library", "s", "ConfigParser", "(", "or", "the", "backported", "configparser", "module", "in", "Python", "2", ")", ".", "Returns", ":", "ConfigPersistenceAd...
python
train
tcalmant/ipopo
pelix/ipopo/instance.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L927-L950
def __unset_binding(self, dependency, service, reference): # type: (Any, Any, ServiceReference) -> None """ Removes a service from the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected...
[ "def", "__unset_binding", "(", "self", ",", "dependency", ",", "service", ",", "reference", ")", ":", "# type: (Any, Any, ServiceReference) -> None", "# Call the component back", "self", ".", "__safe_field_callback", "(", "dependency", ".", "get_field", "(", ")", ",", ...
Removes a service from the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected service
[ "Removes", "a", "service", "from", "the", "component" ]
python
train
prezi/django-zipkin
django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py
https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L286-L302
def getTraceIdsBySpanName(self, service_name, span_name, end_ts, limit, order): """ Fetch trace ids by service and span name. Gets "limit" number of entries from before the "end_ts". Span name is optional. Timestamps are in microseconds. Parameters: - service_name - span_name - ...
[ "def", "getTraceIdsBySpanName", "(", "self", ",", "service_name", ",", "span_name", ",", "end_ts", ",", "limit", ",", "order", ")", ":", "self", ".", "send_getTraceIdsBySpanName", "(", "service_name", ",", "span_name", ",", "end_ts", ",", "limit", ",", "order"...
Fetch trace ids by service and span name. Gets "limit" number of entries from before the "end_ts". Span name is optional. Timestamps are in microseconds. Parameters: - service_name - span_name - end_ts - limit - order
[ "Fetch", "trace", "ids", "by", "service", "and", "span", "name", ".", "Gets", "limit", "number", "of", "entries", "from", "before", "the", "end_ts", "." ]
python
train
Metatab/metapack
metapack/terms.py
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L242-L254
def headers(self): """Return the headers for the resource. Returns the AltName, if specified; if not, then the Name, and if that is empty, a name based on the column position. These headers are specifically applicable to the output table, and may not apply to the resource source. FOr those heade...
[ "def", "headers", "(", "self", ")", ":", "t", "=", "self", ".", "schema_term", "if", "t", ":", "return", "[", "self", ".", "_name_for_col_term", "(", "c", ",", "i", ")", "for", "i", ",", "c", "in", "enumerate", "(", "t", ".", "children", ",", "1"...
Return the headers for the resource. Returns the AltName, if specified; if not, then the Name, and if that is empty, a name based on the column position. These headers are specifically applicable to the output table, and may not apply to the resource source. FOr those headers, use source_headers
[ "Return", "the", "headers", "for", "the", "resource", ".", "Returns", "the", "AltName", "if", "specified", ";", "if", "not", "then", "the", "Name", "and", "if", "that", "is", "empty", "a", "name", "based", "on", "the", "column", "position", ".", "These",...
python
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L573-L584
def get_url_endpoint(self): """ Returns the Hypermap endpoint for a layer. This endpoint will be the WMTS MapProxy endpoint, only for WM we use the original endpoint. """ endpoint = self.url if self.type not in ('Hypermap:WorldMap',): endpoint = 'registry/%s/l...
[ "def", "get_url_endpoint", "(", "self", ")", ":", "endpoint", "=", "self", ".", "url", "if", "self", ".", "type", "not", "in", "(", "'Hypermap:WorldMap'", ",", ")", ":", "endpoint", "=", "'registry/%s/layer/%s/map/wmts/1.0.0/WMTSCapabilities.xml'", "%", "(", "se...
Returns the Hypermap endpoint for a layer. This endpoint will be the WMTS MapProxy endpoint, only for WM we use the original endpoint.
[ "Returns", "the", "Hypermap", "endpoint", "for", "a", "layer", ".", "This", "endpoint", "will", "be", "the", "WMTS", "MapProxy", "endpoint", "only", "for", "WM", "we", "use", "the", "original", "endpoint", "." ]
python
train
mesbahamin/chronophore
chronophore/controller.py
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L202-L228
def undo_sign_in(entry, session=None): """Delete a signed in entry. :param entry: `models.Entry` object. The entry to delete. :param session: (optional) SQLAlchemy session through which to access the database. """ # noqa if session is None: session = Session() else: session = se...
[ "def", "undo_sign_in", "(", "entry", ",", "session", "=", "None", ")", ":", "# noqa", "if", "session", "is", "None", ":", "session", "=", "Session", "(", ")", "else", ":", "session", "=", "session", "entry_to_delete", "=", "(", "session", ".", "query", ...
Delete a signed in entry. :param entry: `models.Entry` object. The entry to delete. :param session: (optional) SQLAlchemy session through which to access the database.
[ "Delete", "a", "signed", "in", "entry", "." ]
python
train
Alignak-monitoring/alignak
alignak/objects/satellitelink.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/satellitelink.py#L703-L740
def update_infos(self, forced=False, test=False): """Update satellite info each self.polling_interval seconds so we smooth arbiter actions for just useful actions. Raise a satellite update status Brok If forced is True, then ignore the ping period. This is used when the configuration ...
[ "def", "update_infos", "(", "self", ",", "forced", "=", "False", ",", "test", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Update informations, forced: %s\"", ",", "forced", ")", "# First look if it's not too early to ping", "now", "=", "time", ".", "...
Update satellite info each self.polling_interval seconds so we smooth arbiter actions for just useful actions. Raise a satellite update status Brok If forced is True, then ignore the ping period. This is used when the configuration has not yet been dispatched to the Arbiter satellites....
[ "Update", "satellite", "info", "each", "self", ".", "polling_interval", "seconds", "so", "we", "smooth", "arbiter", "actions", "for", "just", "useful", "actions", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/interactive.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/interactive.py#L1301-L1312
def do_continue(self, arg): """ continue - continue execution g - continue execution go - continue execution """ if self.cmdprefix: raise CmdError("prefix not allowed") if arg: raise CmdError("too many arguments") if self.debug.get_...
[ "def", "do_continue", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "cmdprefix", ":", "raise", "CmdError", "(", "\"prefix not allowed\"", ")", "if", "arg", ":", "raise", "CmdError", "(", "\"too many arguments\"", ")", "if", "self", ".", "debug", "....
continue - continue execution g - continue execution go - continue execution
[ "continue", "-", "continue", "execution", "g", "-", "continue", "execution", "go", "-", "continue", "execution" ]
python
train
gwastro/pycbc
pycbc/workflow/psd.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/psd.py#L31-L37
def chunks(l, n): """ Yield n successive chunks from l. """ newn = int(len(l) / n) for i in xrange(0, n-1): yield l[i*newn:i*newn+newn] yield l[n*newn-newn:]
[ "def", "chunks", "(", "l", ",", "n", ")", ":", "newn", "=", "int", "(", "len", "(", "l", ")", "/", "n", ")", "for", "i", "in", "xrange", "(", "0", ",", "n", "-", "1", ")", ":", "yield", "l", "[", "i", "*", "newn", ":", "i", "*", "newn",...
Yield n successive chunks from l.
[ "Yield", "n", "successive", "chunks", "from", "l", "." ]
python
train
gmr/tredis
tredis/hashes.py
https://github.com/gmr/tredis/blob/2e91c6a58a35460be0525c51ac6a98fde3b506ad/tredis/hashes.py#L139-L160
def hdel(self, key, *fields): """ Remove the specified fields from the hash stored at `key`. Specified fields that do not exist within this hash are ignored. If `key` does not exist, it is treated as an empty hash and this command returns zero. :param key: The key of th...
[ "def", "hdel", "(", "self", ",", "key", ",", "*", "fields", ")", ":", "if", "not", "fields", ":", "future", "=", "concurrent", ".", "TracebackFuture", "(", ")", "future", ".", "set_result", "(", "0", ")", "else", ":", "future", "=", "self", ".", "_...
Remove the specified fields from the hash stored at `key`. Specified fields that do not exist within this hash are ignored. If `key` does not exist, it is treated as an empty hash and this command returns zero. :param key: The key of the hash :type key: :class:`str`, :class:`by...
[ "Remove", "the", "specified", "fields", "from", "the", "hash", "stored", "at", "key", "." ]
python
train
google/apitools
apitools/base/py/batch.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/batch.py#L294-L317
def _ConvertHeaderToId(header): """Convert a Content-ID header value to an id. Presumes the Content-ID header conforms to the format that _ConvertIdToHeader() returns. Args: header: A string indicating the Content-ID header value. Returns: The extracted id ...
[ "def", "_ConvertHeaderToId", "(", "header", ")", ":", "if", "not", "(", "header", ".", "startswith", "(", "'<'", ")", "or", "header", ".", "endswith", "(", "'>'", ")", ")", ":", "raise", "exceptions", ".", "BatchError", "(", "'Invalid value for Content-ID: %...
Convert a Content-ID header value to an id. Presumes the Content-ID header conforms to the format that _ConvertIdToHeader() returns. Args: header: A string indicating the Content-ID header value. Returns: The extracted id value. Raises: BatchErro...
[ "Convert", "a", "Content", "-", "ID", "header", "value", "to", "an", "id", "." ]
python
train
optimizely/python-sdk
optimizely/helpers/condition.py
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L47-L64
def _get_condition_json(self, index): """ Method to generate json for logging audience condition. Args: index: Index of the condition. Returns: String: Audience condition JSON. """ condition = self.condition_data[index] condition_log = { 'name': condition[0], 'value': c...
[ "def", "_get_condition_json", "(", "self", ",", "index", ")", ":", "condition", "=", "self", ".", "condition_data", "[", "index", "]", "condition_log", "=", "{", "'name'", ":", "condition", "[", "0", "]", ",", "'value'", ":", "condition", "[", "1", "]", ...
Method to generate json for logging audience condition. Args: index: Index of the condition. Returns: String: Audience condition JSON.
[ "Method", "to", "generate", "json", "for", "logging", "audience", "condition", "." ]
python
train
numenta/nupic
src/nupic/algorithms/spatial_pooler.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L937-L951
def stripUnlearnedColumns(self, activeArray): """ Removes the set of columns who have never been active from the set of active columns selected in the inhibition round. Such columns cannot represent learned pattern and are therefore meaningless if only inference is required. This should not be done ...
[ "def", "stripUnlearnedColumns", "(", "self", ",", "activeArray", ")", ":", "neverLearned", "=", "numpy", ".", "where", "(", "self", ".", "_activeDutyCycles", "==", "0", ")", "[", "0", "]", "activeArray", "[", "neverLearned", "]", "=", "0" ]
Removes the set of columns who have never been active from the set of active columns selected in the inhibition round. Such columns cannot represent learned pattern and are therefore meaningless if only inference is required. This should not be done when using a random, unlearned SP since you would end ...
[ "Removes", "the", "set", "of", "columns", "who", "have", "never", "been", "active", "from", "the", "set", "of", "active", "columns", "selected", "in", "the", "inhibition", "round", ".", "Such", "columns", "cannot", "represent", "learned", "pattern", "and", "...
python
valid
incuna/django-user-management
user_management/api/views.py
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/views.py#L49-L75
def delete(self, request, *args, **kwargs): """Delete auth token when `delete` request was issued.""" # Logic repeated from DRF because one cannot easily reuse it auth = get_authorization_header(request).split() if not auth or auth[0].lower() != b'token': return response.Res...
[ "def", "delete", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Logic repeated from DRF because one cannot easily reuse it", "auth", "=", "get_authorization_header", "(", "request", ")", ".", "split", "(", ")", "if", "not", ...
Delete auth token when `delete` request was issued.
[ "Delete", "auth", "token", "when", "delete", "request", "was", "issued", "." ]
python
test
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L306-L342
def init(self, fle=None): """ Executes the preprocessing steps at the instantiation stage to read in the tables from hdf5 and hold them in memory. """ if fle is None: fname = self.kwargs.get('gmpe_table', self.GMPE_TABLE) if fname is None: ...
[ "def", "init", "(", "self", ",", "fle", "=", "None", ")", ":", "if", "fle", "is", "None", ":", "fname", "=", "self", ".", "kwargs", ".", "get", "(", "'gmpe_table'", ",", "self", ".", "GMPE_TABLE", ")", "if", "fname", "is", "None", ":", "raise", "...
Executes the preprocessing steps at the instantiation stage to read in the tables from hdf5 and hold them in memory.
[ "Executes", "the", "preprocessing", "steps", "at", "the", "instantiation", "stage", "to", "read", "in", "the", "tables", "from", "hdf5", "and", "hold", "them", "in", "memory", "." ]
python
train
wbond/oscrypto
oscrypto/_win/tls.py
https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_win/tls.py#L327-L387
def wrap(cls, socket, hostname, session=None): """ Takes an existing socket and adds TLS :param socket: A socket.socket object to wrap with TLS :param hostname: A unicode string of the hostname or IP the socket is connected to :param session: ...
[ "def", "wrap", "(", "cls", ",", "socket", ",", "hostname", ",", "session", "=", "None", ")", ":", "if", "not", "isinstance", "(", "socket", ",", "socket_", ".", "socket", ")", ":", "raise", "TypeError", "(", "pretty_message", "(", "'''\n soc...
Takes an existing socket and adds TLS :param socket: A socket.socket object to wrap with TLS :param hostname: A unicode string of the hostname or IP the socket is connected to :param session: An existing TLSSession object to allow for session reuse, specifi...
[ "Takes", "an", "existing", "socket", "and", "adds", "TLS" ]
python
valid
openstack/networking-hyperv
networking_hyperv/neutron/qos/qos_driver.py
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/qos/qos_driver.py#L59-L68
def delete(self, port, qos_policy=None): """Remove QoS rules from port. :param port: port object. :param qos_policy: the QoS policy to be removed from port. """ LOG.info("Deleting QoS policy %(qos_policy)s on port %(port)s", dict(qos_policy=qos_policy, port=port...
[ "def", "delete", "(", "self", ",", "port", ",", "qos_policy", "=", "None", ")", ":", "LOG", ".", "info", "(", "\"Deleting QoS policy %(qos_policy)s on port %(port)s\"", ",", "dict", "(", "qos_policy", "=", "qos_policy", ",", "port", "=", "port", ")", ")", "s...
Remove QoS rules from port. :param port: port object. :param qos_policy: the QoS policy to be removed from port.
[ "Remove", "QoS", "rules", "from", "port", "." ]
python
train
spotify/luigi
luigi/setup_logging.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/setup_logging.py#L52-L93
def setup(cls, opts=type('opts', (), { 'background': None, 'logdir': None, 'logging_conf_file': None, 'log_level': 'DEBUG' })): """Setup logging via CLI params and config.""" logger = logging.getLogger('l...
[ "def", "setup", "(", "cls", ",", "opts", "=", "type", "(", "'opts'", ",", "(", ")", ",", "{", "'background'", ":", "None", ",", "'logdir'", ":", "None", ",", "'logging_conf_file'", ":", "None", ",", "'log_level'", ":", "'DEBUG'", "}", ")", ")", ":", ...
Setup logging via CLI params and config.
[ "Setup", "logging", "via", "CLI", "params", "and", "config", "." ]
python
train
pyvisa/pyvisa
pyvisa/rname.py
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/rname.py#L222-L344
def build_rn_class(interface_type, resource_parts, resource_class, is_rc_optional=True): """Builds a resource name class by mixing a named tuple and ResourceName. It also registers the class. The field names are changed to lower case and the spaces replaced by underscores ('_'). ...
[ "def", "build_rn_class", "(", "interface_type", ",", "resource_parts", ",", "resource_class", ",", "is_rc_optional", "=", "True", ")", ":", "interface_type", "=", "interface_type", ".", "upper", "(", ")", "resource_class", "=", "resource_class", ".", "upper", "(",...
Builds a resource name class by mixing a named tuple and ResourceName. It also registers the class. The field names are changed to lower case and the spaces replaced by underscores ('_'). :param interface_type: the interface type :type: interface_type: str :param resource_parts: each of the p...
[ "Builds", "a", "resource", "name", "class", "by", "mixing", "a", "named", "tuple", "and", "ResourceName", "." ]
python
train
davenquinn/Attitude
attitude/geom/util.py
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/geom/util.py#L55-L64
def angle(v1,v2, cos=False): """ Find the angle between two vectors. :param cos: If True, the cosine of the angle will be returned. False by default. """ n = (norm(v1)*norm(v2)) _ = dot(v1,v2)/n return _ if cos else N.arccos(_)
[ "def", "angle", "(", "v1", ",", "v2", ",", "cos", "=", "False", ")", ":", "n", "=", "(", "norm", "(", "v1", ")", "*", "norm", "(", "v2", ")", ")", "_", "=", "dot", "(", "v1", ",", "v2", ")", "/", "n", "return", "_", "if", "cos", "else", ...
Find the angle between two vectors. :param cos: If True, the cosine of the angle will be returned. False by default.
[ "Find", "the", "angle", "between", "two", "vectors", "." ]
python
train
neurosynth/neurosynth
neurosynth/base/dataset.py
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/dataset.py#L758-L765
def _sdf_to_csr(self): """ Convert FeatureTable to SciPy CSR matrix. """ data = self.data.to_dense() self.data = { 'columns': list(data.columns), 'index': list(data.index), 'values': sparse.csr_matrix(data.values) }
[ "def", "_sdf_to_csr", "(", "self", ")", ":", "data", "=", "self", ".", "data", ".", "to_dense", "(", ")", "self", ".", "data", "=", "{", "'columns'", ":", "list", "(", "data", ".", "columns", ")", ",", "'index'", ":", "list", "(", "data", ".", "i...
Convert FeatureTable to SciPy CSR matrix.
[ "Convert", "FeatureTable", "to", "SciPy", "CSR", "matrix", "." ]
python
test
frascoweb/easywebassets
easywebassets/package.py
https://github.com/frascoweb/easywebassets/blob/02f84376067c827c84fc1773895bb2784e033949/easywebassets/package.py#L194-L198
def urls_for(self, asset_type, *args, **kwargs): """Returns urls needed to include all assets of asset_type """ return self.urls_for_depends(asset_type, *args, **kwargs) + \ self.urls_for_self(asset_type, *args, **kwargs)
[ "def", "urls_for", "(", "self", ",", "asset_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "urls_for_depends", "(", "asset_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", "+", "self", ".", "urls_for_self", "...
Returns urls needed to include all assets of asset_type
[ "Returns", "urls", "needed", "to", "include", "all", "assets", "of", "asset_type" ]
python
test
Falkonry/falkonry-python-client
falkonryclient/service/falkonry.py
https://github.com/Falkonry/falkonry-python-client/blob/0aeb2b00293ee94944f1634e9667401b03da29c1/falkonryclient/service/falkonry.py#L321-L334
def get_historical_output(self, assessment, options): """ To get output of a historical Assessment :param assessment: string :param options: dict """ responseFormat=None if options and 'format' in options and options['format'] is not None: responseForm...
[ "def", "get_historical_output", "(", "self", ",", "assessment", ",", "options", ")", ":", "responseFormat", "=", "None", "if", "options", "and", "'format'", "in", "options", "and", "options", "[", "'format'", "]", "is", "not", "None", ":", "responseFormat", ...
To get output of a historical Assessment :param assessment: string :param options: dict
[ "To", "get", "output", "of", "a", "historical", "Assessment", ":", "param", "assessment", ":", "string", ":", "param", "options", ":", "dict" ]
python
train
google/grr
grr/server/grr_response_server/artifact_registry.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L360-L411
def GetArtifacts(self, os_name=None, name_list=None, source_type=None, exclude_dependents=False, provides=None, reload_datastore_artifacts=False): """Retrieve artifact classes with optional filtering. ...
[ "def", "GetArtifacts", "(", "self", ",", "os_name", "=", "None", ",", "name_list", "=", "None", ",", "source_type", "=", "None", ",", "exclude_dependents", "=", "False", ",", "provides", "=", "None", ",", "reload_datastore_artifacts", "=", "False", ")", ":",...
Retrieve artifact classes with optional filtering. All filters must match for the artifact to be returned. Args: os_name: string to match against supported_os name_list: list of strings to match against artifact names source_type: rdf_artifacts.ArtifactSource.SourceType to match against ...
[ "Retrieve", "artifact", "classes", "with", "optional", "filtering", "." ]
python
train
adamziel/python_translate
python_translate/translations.py
https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/translations.py#L177-L207
def add_fallback_catalogue(self, catalogue): """ Merges translations from the given Catalogue into the current one only when the translation does not exist. This is used to provide default translations when they do not exist for the current locale. @type id: The ...
[ "def", "add_fallback_catalogue", "(", "self", ",", "catalogue", ")", ":", "assert", "isinstance", "(", "catalogue", ",", "MessageCatalogue", ")", "# detect circular references", "c", "=", "self", "while", "True", ":", "if", "c", ".", "locale", "==", "catalogue",...
Merges translations from the given Catalogue into the current one only when the translation does not exist. This is used to provide default translations when they do not exist for the current locale. @type id: The @param id: message id
[ "Merges", "translations", "from", "the", "given", "Catalogue", "into", "the", "current", "one", "only", "when", "the", "translation", "does", "not", "exist", "." ]
python
train
MagicStack/asyncpg
asyncpg/connection.py
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L460-L530
async def copy_from_table(self, table_name, *, output, columns=None, schema_name=None, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quot...
[ "async", "def", "copy_from_table", "(", "self", ",", "table_name", ",", "*", ",", "output", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "delimiter...
Copy table contents to a file or file-like object. :param str table_name: The name of the table to copy data from. :param output: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <python:file-like object>`, or a :term:`c...
[ "Copy", "table", "contents", "to", "a", "file", "or", "file", "-", "like", "object", "." ]
python
train
HazyResearch/metal
metal/contrib/visualization/analysis.py
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/contrib/visualization/analysis.py#L79-L97
def plot_probabilities_histogram(Y_p, title=None): """Plot a histogram from a numpy array of probabilities Args: Y_p: An [n] or [n, 1] np.ndarray of probabilities (floats in [0,1]) """ if Y_p.ndim > 1: msg = ( f"Arg Y_p should be a 1-dimensional np.ndarray, not of shape " ...
[ "def", "plot_probabilities_histogram", "(", "Y_p", ",", "title", "=", "None", ")", ":", "if", "Y_p", ".", "ndim", ">", "1", ":", "msg", "=", "(", "f\"Arg Y_p should be a 1-dimensional np.ndarray, not of shape \"", "f\"{Y_p.shape}.\"", ")", "raise", "ValueError", "("...
Plot a histogram from a numpy array of probabilities Args: Y_p: An [n] or [n, 1] np.ndarray of probabilities (floats in [0,1])
[ "Plot", "a", "histogram", "from", "a", "numpy", "array", "of", "probabilities" ]
python
train
bjmorgan/lattice_mc
lattice_mc/lattice_site.py
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice_site.py#L94-L110
def cn_occupation_energy( self, delta_occupation=None ): """ The coordination-number dependent energy for this site. Args: delta_occupation (:obj:Dict(Str:Int), optional): A dictionary of a change in (site-type specific) coordination number, e.g. { 'A' : 1, 'B' : -1 }. ...
[ "def", "cn_occupation_energy", "(", "self", ",", "delta_occupation", "=", "None", ")", ":", "nn_occupations", "=", "self", ".", "site_specific_nn_occupation", "(", ")", "if", "delta_occupation", ":", "for", "site", "in", "delta_occupation", ":", "assert", "(", "...
The coordination-number dependent energy for this site. Args: delta_occupation (:obj:Dict(Str:Int), optional): A dictionary of a change in (site-type specific) coordination number, e.g. { 'A' : 1, 'B' : -1 }. If this is not None, the coordination-number dependent energy is calculate...
[ "The", "coordination", "-", "number", "dependent", "energy", "for", "this", "site", "." ]
python
train
raiden-network/raiden
raiden/blockchain_events_handler.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain_events_handler.py#L45-L75
def handle_tokennetwork_new(raiden: 'RaidenService', event: Event): """ Handles a `TokenNetworkCreated` event. """ data = event.event_data args = data['args'] block_number = data['block_number'] token_network_address = args['token_network_address'] token_address = typing.TokenAddress(args['token...
[ "def", "handle_tokennetwork_new", "(", "raiden", ":", "'RaidenService'", ",", "event", ":", "Event", ")", ":", "data", "=", "event", ".", "event_data", "args", "=", "data", "[", "'args'", "]", "block_number", "=", "data", "[", "'block_number'", "]", "token_n...
Handles a `TokenNetworkCreated` event.
[ "Handles", "a", "TokenNetworkCreated", "event", "." ]
python
train
openearth/mmi-python
mmi/tracker.py
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/tracker.py#L145-L163
def get(self, key=None, view=None): """Register a new model (models)""" self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Content-Type", "application/json") if key is not None: value = {} value.update(self.database[key]) if view is n...
[ "def", "get", "(", "self", ",", "key", "=", "None", ",", "view", "=", "None", ")", ":", "self", ".", "set_header", "(", "\"Access-Control-Allow-Origin\"", ",", "\"*\"", ")", "self", ".", "set_header", "(", "\"Content-Type\"", ",", "\"application/json\"", ")"...
Register a new model (models)
[ "Register", "a", "new", "model", "(", "models", ")" ]
python
train
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L750-L828
def _validate_resolution_output_length(path, entity_name, results, allow_mult=False, all_mult=False, ask_to_resolve=True): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param entity_n...
[ "def", "_validate_resolution_output_length", "(", "path", ",", "entity_name", ",", "results", ",", "allow_mult", "=", "False", ",", "all_mult", "=", "False", ",", "ask_to_resolve", "=", "True", ")", ":", "if", "len", "(", "results", ")", "==", "0", ":", "r...
:param path: Path to the object that required resolution; propagated from command-line :type path: string :param entity_name: Name of the object :type entity_name: string :param results: Result of resolution; non-empty list of object specifications (each specificatio...
[ ":", "param", "path", ":", "Path", "to", "the", "object", "that", "required", "resolution", ";", "propagated", "from", "command", "-", "line", ":", "type", "path", ":", "string", ":", "param", "entity_name", ":", "Name", "of", "the", "object", ":", "type...
python
train
portfors-lab/sparkle
sparkle/gui/plotting/calibration_explore_display.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/plotting/calibration_explore_display.py#L136-L143
def setXlimits(self, lims): """Sets the X axis limits of the signal plots :param lims: (min, max) of x axis, in same units as data :type lims: (float, float) """ self.responseSignalPlot.setXlim(lims) self.stimSignalPlot.setXlim(lims)
[ "def", "setXlimits", "(", "self", ",", "lims", ")", ":", "self", ".", "responseSignalPlot", ".", "setXlim", "(", "lims", ")", "self", ".", "stimSignalPlot", ".", "setXlim", "(", "lims", ")" ]
Sets the X axis limits of the signal plots :param lims: (min, max) of x axis, in same units as data :type lims: (float, float)
[ "Sets", "the", "X", "axis", "limits", "of", "the", "signal", "plots" ]
python
train
StackStorm/pybind
pybind/slxos/v17s_1_02/qos/cpu/slot/port_group/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/qos/cpu/slot/port_group/__init__.py#L127-L148
def _set_group(self, v, load=False): """ Setter method for group, mapped from YANG variable /qos/cpu/slot/port_group/group (list) If this variable is read-only (config: false) in the source YANG file, then _set_group is considered as a private method. Backends looking to populate this variable shoul...
[ "def", "_set_group", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for group, mapped from YANG variable /qos/cpu/slot/port_group/group (list) If this variable is read-only (config: false) in the source YANG file, then _set_group is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_group() dire...
[ "Setter", "method", "for", "group", "mapped", "from", "YANG", "variable", "/", "qos", "/", "cpu", "/", "slot", "/", "port_group", "/", "group", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "...
python
train
ponty/PyVirtualDisplay
pyvirtualdisplay/abstractdisplay.py
https://github.com/ponty/PyVirtualDisplay/blob/903841f5ef13bf162be6fdd22daa5c349af45d67/pyvirtualdisplay/abstractdisplay.py#L84-L98
def redirect_display(self, on): ''' on: * True -> set $DISPLAY to virtual screen * False -> set $DISPLAY to original screen :param on: bool ''' d = self.new_display_var if on else self.old_display_var if d is None: log.debug('unset DISPLAY')...
[ "def", "redirect_display", "(", "self", ",", "on", ")", ":", "d", "=", "self", ".", "new_display_var", "if", "on", "else", "self", ".", "old_display_var", "if", "d", "is", "None", ":", "log", ".", "debug", "(", "'unset DISPLAY'", ")", "del", "os", ".",...
on: * True -> set $DISPLAY to virtual screen * False -> set $DISPLAY to original screen :param on: bool
[ "on", ":", "*", "True", "-", ">", "set", "$DISPLAY", "to", "virtual", "screen", "*", "False", "-", ">", "set", "$DISPLAY", "to", "original", "screen" ]
python
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L817-L834
def decode_secp256r1(str, unhex=True, check_on_curve=True): """ decode a public key on the secp256r1 curve """ GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)) ec = EllipticCurve(GFp, 1157920892103562487626974469494075735300861434152...
[ "def", "decode_secp256r1", "(", "str", ",", "unhex", "=", "True", ",", "check_on_curve", "=", "True", ")", ":", "GFp", "=", "FiniteField", "(", "int", "(", "\"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF\"", ",", "16", ")", ")", "ec", "=", "E...
decode a public key on the secp256r1 curve
[ "decode", "a", "public", "key", "on", "the", "secp256r1", "curve" ]
python
train
mongodb/mongo-python-driver
pymongo/common.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/common.py#L162-L173
def validate_integer(option, value): """Validates that 'value' is an integer (or basestring representation). """ if isinstance(value, integer_types): return value elif isinstance(value, string_type): try: return int(value) except ValueError: raise ValueErr...
[ "def", "validate_integer", "(", "option", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "integer_types", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "string_type", ")", ":", "try", ":", "return", "int", "(", "va...
Validates that 'value' is an integer (or basestring representation).
[ "Validates", "that", "value", "is", "an", "integer", "(", "or", "basestring", "representation", ")", "." ]
python
train
bristosoft/financial
finance.py
https://github.com/bristosoft/financial/blob/382c4fef610d67777d7109d9d0ae230ab67ca20f/finance.py#L90-L100
def syd(c, s, l): """ This accountancy function computes sum of the years digits depreciation for an asset purchased for cash with a known life span and salvage value. The depreciation is returned as a list in python. c = historcal cost or price paid s = the expected salvage proceeds l =...
[ "def", "syd", "(", "c", ",", "s", ",", "l", ")", ":", "return", "[", "(", "c", "-", "s", ")", "*", "(", "x", "/", "(", "l", "*", "(", "l", "+", "1", ")", "/", "2", ")", ")", "for", "x", "in", "range", "(", "l", ",", "0", ",", "-", ...
This accountancy function computes sum of the years digits depreciation for an asset purchased for cash with a known life span and salvage value. The depreciation is returned as a list in python. c = historcal cost or price paid s = the expected salvage proceeds l = expected useful life of the ...
[ "This", "accountancy", "function", "computes", "sum", "of", "the", "years", "digits", "depreciation", "for", "an", "asset", "purchased", "for", "cash", "with", "a", "known", "life", "span", "and", "salvage", "value", ".", "The", "depreciation", "is", "returned...
python
train
soravux/scoop
scoop/bootstrap/__main__.py
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/bootstrap/__main__.py#L240-L293
def run(self, globs=None): """Import user module and start __main__ passing globals() is required when subclassing in another module """ # Without this, the underneath import clashes with the top-level one global scoop if globs is None: globs = globals() ...
[ "def", "run", "(", "self", ",", "globs", "=", "None", ")", ":", "# Without this, the underneath import clashes with the top-level one", "global", "scoop", "if", "globs", "is", "None", ":", "globs", "=", "globals", "(", ")", "# import the user module", "if", "scoop",...
Import user module and start __main__ passing globals() is required when subclassing in another module
[ "Import", "user", "module", "and", "start", "__main__", "passing", "globals", "()", "is", "required", "when", "subclassing", "in", "another", "module" ]
python
train
saltstack/salt
salt/pillar/nsot.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/nsot.py#L150-L169
def _proxy_info(minion_id, api_url, email, secret_key, fqdn_separator): ''' retrieve a dict of a device that exists in nsot :param minion_id: str :param api_url: str :param email: str :param secret_key: str :param fqdn_separator: str :return: dict ''' device_info = {} if fqd...
[ "def", "_proxy_info", "(", "minion_id", ",", "api_url", ",", "email", ",", "secret_key", ",", "fqdn_separator", ")", ":", "device_info", "=", "{", "}", "if", "fqdn_separator", ":", "minion_id", "=", "minion_id", ".", "replace", "(", "'.'", ",", "fqdn_separat...
retrieve a dict of a device that exists in nsot :param minion_id: str :param api_url: str :param email: str :param secret_key: str :param fqdn_separator: str :return: dict
[ "retrieve", "a", "dict", "of", "a", "device", "that", "exists", "in", "nsot" ]
python
train
Tanganelli/CoAPthon3
coapthon/messages/option.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/messages/option.py#L38-L52
def value(self): """ Return the option value. :return: the option value in the correct format depending on the option """ if type(self._value) is None: self._value = bytearray() opt_type = defines.OptionRegistry.LIST[self._number].value_type if opt_ty...
[ "def", "value", "(", "self", ")", ":", "if", "type", "(", "self", ".", "_value", ")", "is", "None", ":", "self", ".", "_value", "=", "bytearray", "(", ")", "opt_type", "=", "defines", ".", "OptionRegistry", ".", "LIST", "[", "self", ".", "_number", ...
Return the option value. :return: the option value in the correct format depending on the option
[ "Return", "the", "option", "value", "." ]
python
train
lyft/python-kmsauth
kmsauth/services.py
https://github.com/lyft/python-kmsauth/blob/aa2dd957a5d3e58c89fe51a55c6053ff81d9191e/kmsauth/services.py#L80-L92
def get_boto_session( region, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None ): """Get a boto3 session.""" return boto3.session.Session( region_name=region, aws_secret_access_key=aws_secret_access_key, aws_access_key_id=...
[ "def", "get_boto_session", "(", "region", ",", "aws_access_key_id", "=", "None", ",", "aws_secret_access_key", "=", "None", ",", "aws_session_token", "=", "None", ")", ":", "return", "boto3", ".", "session", ".", "Session", "(", "region_name", "=", "region", "...
Get a boto3 session.
[ "Get", "a", "boto3", "session", "." ]
python
train
mikedh/trimesh
trimesh/sample.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/sample.py#L117-L140
def sample_surface_even(mesh, count): """ Sample the surface of a mesh, returning samples which are approximately evenly spaced. Parameters --------- mesh: Trimesh object count: number of points to return Returns --------- samples: (count,3) points in space on the surface of m...
[ "def", "sample_surface_even", "(", "mesh", ",", "count", ")", ":", "from", ".", "points", "import", "remove_close", "radius", "=", "np", ".", "sqrt", "(", "mesh", ".", "area", "/", "(", "2", "*", "count", ")", ")", "samples", ",", "ids", "=", "sample...
Sample the surface of a mesh, returning samples which are approximately evenly spaced. Parameters --------- mesh: Trimesh object count: number of points to return Returns --------- samples: (count,3) points in space on the surface of mesh face_index: (count,) indices of faces for ...
[ "Sample", "the", "surface", "of", "a", "mesh", "returning", "samples", "which", "are", "approximately", "evenly", "spaced", "." ]
python
train
spyder-ide/spyder
spyder/app/mainwindow.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1265-L1349
def post_visible_setup(self): """Actions to be performed only after the main window's `show` method was triggered""" self.restore_scrollbar_position.emit() # [Workaround for Issue 880] # QDockWidget objects are not painted if restored as floating # windows, so we ...
[ "def", "post_visible_setup", "(", "self", ")", ":", "self", ".", "restore_scrollbar_position", ".", "emit", "(", ")", "# [Workaround for Issue 880]\r", "# QDockWidget objects are not painted if restored as floating\r", "# windows, so we must dock them before showing the mainwindow,\r",...
Actions to be performed only after the main window's `show` method was triggered
[ "Actions", "to", "be", "performed", "only", "after", "the", "main", "window", "s", "show", "method", "was", "triggered" ]
python
train
liip/taxi
taxi/plugins.py
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/plugins.py#L116-L121
def register_commands(self): """ Load entry points for custom commands. """ for command in self._entry_points[self.COMMANDS_ENTRY_POINT].values(): command.load()
[ "def", "register_commands", "(", "self", ")", ":", "for", "command", "in", "self", ".", "_entry_points", "[", "self", ".", "COMMANDS_ENTRY_POINT", "]", ".", "values", "(", ")", ":", "command", ".", "load", "(", ")" ]
Load entry points for custom commands.
[ "Load", "entry", "points", "for", "custom", "commands", "." ]
python
train
i3visio/osrframework
osrframework/thirdparties/pipl_com/lib/fields.py
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/fields.py#L233-L237
def is_searchable(self): """A bool value that indicates whether the address is a valid address to search by.""" return self.raw or (self.is_valid_country and (not self.state or self.is_valid_state))
[ "def", "is_searchable", "(", "self", ")", ":", "return", "self", ".", "raw", "or", "(", "self", ".", "is_valid_country", "and", "(", "not", "self", ".", "state", "or", "self", ".", "is_valid_state", ")", ")" ]
A bool value that indicates whether the address is a valid address to search by.
[ "A", "bool", "value", "that", "indicates", "whether", "the", "address", "is", "a", "valid", "address", "to", "search", "by", "." ]
python
train
mkoura/dump2polarion
dump2polarion/configuration.py
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/configuration.py#L163-L192
def get_config(config_file=None, config_values=None, load_project_conf=True): """Loads config file and returns its content.""" config_values = config_values or {} config_settings = {} default_conf = _get_default_conf() user_conf = _get_user_conf(config_file) if config_file else {} # load projec...
[ "def", "get_config", "(", "config_file", "=", "None", ",", "config_values", "=", "None", ",", "load_project_conf", "=", "True", ")", ":", "config_values", "=", "config_values", "or", "{", "}", "config_settings", "=", "{", "}", "default_conf", "=", "_get_defaul...
Loads config file and returns its content.
[ "Loads", "config", "file", "and", "returns", "its", "content", "." ]
python
train
summa-tx/riemann
riemann/tx/sprout.py
https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/tx/sprout.py#L188-L197
def calculate_fee(self, input_values): ''' Tx, list(int) -> int ''' total_in = sum(input_values) total_out = sum([utils.le2i(tx_out.value) for tx_out in self.tx_outs]) for js in self.tx_joinsplits: total_in += utils.le2i(js.vpub_new) total_out += u...
[ "def", "calculate_fee", "(", "self", ",", "input_values", ")", ":", "total_in", "=", "sum", "(", "input_values", ")", "total_out", "=", "sum", "(", "[", "utils", ".", "le2i", "(", "tx_out", ".", "value", ")", "for", "tx_out", "in", "self", ".", "tx_out...
Tx, list(int) -> int
[ "Tx", "list", "(", "int", ")", "-", ">", "int" ]
python
train
jim-easterbrook/pywws
src/pywws/timezone.py
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/timezone.py#L81-L85
def to_utc(self, dt): """Convert any timestamp to UTC (with tzinfo).""" if dt.tzinfo is None: return dt.replace(tzinfo=self.utc) return dt.astimezone(self.utc)
[ "def", "to_utc", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "return", "dt", ".", "replace", "(", "tzinfo", "=", "self", ".", "utc", ")", "return", "dt", ".", "astimezone", "(", "self", ".", "utc", ")" ]
Convert any timestamp to UTC (with tzinfo).
[ "Convert", "any", "timestamp", "to", "UTC", "(", "with", "tzinfo", ")", "." ]
python
train
delfick/harpoon
harpoon/ship/runner.py
https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/ship/runner.py#L226-L328
def create_container(self, conf, detach, tty): """Create a single container""" name = conf.name image_name = conf.image_name if conf.tag is not NotSpecified: image_name = conf.image_name_with_tag container_name = conf.container_name with conf.assumed_role():...
[ "def", "create_container", "(", "self", ",", "conf", ",", "detach", ",", "tty", ")", ":", "name", "=", "conf", ".", "name", "image_name", "=", "conf", ".", "image_name", "if", "conf", ".", "tag", "is", "not", "NotSpecified", ":", "image_name", "=", "co...
Create a single container
[ "Create", "a", "single", "container" ]
python
train
python-diamond/Diamond
src/collectors/memcached/memcached.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memcached/memcached.py#L61-L78
def get_default_config(self): """ Returns the default collector settings """ config = super(MemcachedCollector, self).get_default_config() config.update({ 'path': 'memcached', # Which rows of 'status' you would like to publish. # 'telnet h...
[ "def", "get_default_config", "(", "self", ")", ":", "config", "=", "super", "(", "MemcachedCollector", ",", "self", ")", ".", "get_default_config", "(", ")", "config", ".", "update", "(", "{", "'path'", ":", "'memcached'", ",", "# Which rows of 'status' you woul...
Returns the default collector settings
[ "Returns", "the", "default", "collector", "settings" ]
python
train
googledatalab/pydatalab
google/datalab/kernel/__init__.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/kernel/__init__.py#L44-L122
def load_ipython_extension(shell): """ Called when the extension is loaded. Args: shell - (NotebookWebApplication): handle to the Notebook interactive shell instance. """ # Inject our user agent on all requests by monkey-patching a wrapper around httplib2.Http.request. def _request(self, uri, metho...
[ "def", "load_ipython_extension", "(", "shell", ")", ":", "# Inject our user agent on all requests by monkey-patching a wrapper around httplib2.Http.request.", "def", "_request", "(", "self", ",", "uri", ",", "method", "=", "\"GET\"", ",", "body", "=", "None", ",", "header...
Called when the extension is loaded. Args: shell - (NotebookWebApplication): handle to the Notebook interactive shell instance.
[ "Called", "when", "the", "extension", "is", "loaded", "." ]
python
train
albert12132/templar
templar/markdown.py
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L81-L101
def sub_retab(match): r"""Remove all tabs and convert them into spaces. PARAMETERS: match -- regex match; uses re_retab pattern: \1 is text before tab, \2 is a consecutive string of tabs. A simple substitution of 4 spaces would result in the following: to\tlive # original ...
[ "def", "sub_retab", "(", "match", ")", ":", "before", "=", "match", ".", "group", "(", "1", ")", "tabs", "=", "len", "(", "match", ".", "group", "(", "2", ")", ")", "return", "before", "+", "(", "' '", "*", "(", "TAB_SIZE", "*", "tabs", "-", "l...
r"""Remove all tabs and convert them into spaces. PARAMETERS: match -- regex match; uses re_retab pattern: \1 is text before tab, \2 is a consecutive string of tabs. A simple substitution of 4 spaces would result in the following: to\tlive # original to live # simple s...
[ "r", "Remove", "all", "tabs", "and", "convert", "them", "into", "spaces", "." ]
python
train
Esri/ArcREST
src/arcrest/manageorg/_parameters.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_parameters.py#L1775-L1782
def value(self): """returns the values as a dictionary""" val = {} for k in self.__allowed_keys: value = getattr(self, "_" + k) if value is not None: val[k] = value return val
[ "def", "value", "(", "self", ")", ":", "val", "=", "{", "}", "for", "k", "in", "self", ".", "__allowed_keys", ":", "value", "=", "getattr", "(", "self", ",", "\"_\"", "+", "k", ")", "if", "value", "is", "not", "None", ":", "val", "[", "k", "]",...
returns the values as a dictionary
[ "returns", "the", "values", "as", "a", "dictionary" ]
python
train
reingart/pyafipws
wslpg.py
https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wslpg.py#L1746-L1760
def AgregarCalidad(self, analisis_muestra=None, nro_boletin=None, cod_grado=None, valor_grado=None, valor_contenido_proteico=None, valor_factor=None, **kwargs): "Agrega la información sobre la calidad, al autorizar o poster...
[ "def", "AgregarCalidad", "(", "self", ",", "analisis_muestra", "=", "None", ",", "nro_boletin", "=", "None", ",", "cod_grado", "=", "None", ",", "valor_grado", "=", "None", ",", "valor_contenido_proteico", "=", "None", ",", "valor_factor", "=", "None", ",", ...
Agrega la información sobre la calidad, al autorizar o posteriormente
[ "Agrega", "la", "información", "sobre", "la", "calidad", "al", "autorizar", "o", "posteriormente" ]
python
train
studionow/pybrightcove
pybrightcove/http_core.py
https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/http_core.py#L226-L244
def modify_request(self, http_request=None): """Sets HTTP request components based on the URI.""" if http_request is None: http_request = HttpRequest() if http_request.uri is None: http_request.uri = Uri() # Determine the correct scheme. if self.scheme: http_request.uri.scheme = se...
[ "def", "modify_request", "(", "self", ",", "http_request", "=", "None", ")", ":", "if", "http_request", "is", "None", ":", "http_request", "=", "HttpRequest", "(", ")", "if", "http_request", ".", "uri", "is", "None", ":", "http_request", ".", "uri", "=", ...
Sets HTTP request components based on the URI.
[ "Sets", "HTTP", "request", "components", "based", "on", "the", "URI", "." ]
python
train
log2timeline/plaso
plaso/engine/processing_status.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/engine/processing_status.py#L342-L403
def _UpdateProcessStatus( self, process_status, identifier, status, pid, used_memory, display_name, number_of_consumed_sources, number_of_produced_sources, number_of_consumed_events, number_of_produced_events, number_of_consumed_event_tags, number_of_produced_event_tags, number_of_consumed...
[ "def", "_UpdateProcessStatus", "(", "self", ",", "process_status", ",", "identifier", ",", "status", ",", "pid", ",", "used_memory", ",", "display_name", ",", "number_of_consumed_sources", ",", "number_of_produced_sources", ",", "number_of_consumed_events", ",", "number...
Updates a process status. Args: process_status (ProcessStatus): process status. identifier (str): process identifier. status (str): human readable status of the process e.g. 'Idle'. pid (int): process identifier (PID). used_memory (int): size of used memory in bytes. display_nam...
[ "Updates", "a", "process", "status", "." ]
python
train
inspirehep/inspire-schemas
inspire_schemas/builders/signatures.py
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/signatures.py#L69-L85
def add_affiliation(self, value, curated_relation=None, record=None): """Add an affiliation. Args: value (string): affiliation value curated_relation (bool): is relation curated record (dict): affiliation JSON reference """ if value: affil...
[ "def", "add_affiliation", "(", "self", ",", "value", ",", "curated_relation", "=", "None", ",", "record", "=", "None", ")", ":", "if", "value", ":", "affiliation", "=", "{", "'value'", ":", "value", "}", "if", "record", ":", "affiliation", "[", "'record'...
Add an affiliation. Args: value (string): affiliation value curated_relation (bool): is relation curated record (dict): affiliation JSON reference
[ "Add", "an", "affiliation", "." ]
python
train
HEPData/hepdata-validator
hepdata_validator/__init__.py
https://github.com/HEPData/hepdata-validator/blob/d0b0cab742a009c8f0e8aac9f8c8e434a524d43c/hepdata_validator/__init__.py#L65-L79
def get_messages(self, file_name=None): """ Return messages for a file (if file_name provided). If file_name is none, returns all messages as a dict. :param file_name: :return: array if file_name is provided, dict otherwise. """ if file_name is None: r...
[ "def", "get_messages", "(", "self", ",", "file_name", "=", "None", ")", ":", "if", "file_name", "is", "None", ":", "return", "self", ".", "messages", "elif", "file_name", "in", "self", ".", "messages", ":", "return", "self", ".", "messages", "[", "file_n...
Return messages for a file (if file_name provided). If file_name is none, returns all messages as a dict. :param file_name: :return: array if file_name is provided, dict otherwise.
[ "Return", "messages", "for", "a", "file", "(", "if", "file_name", "provided", ")", ".", "If", "file_name", "is", "none", "returns", "all", "messages", "as", "a", "dict", ".", ":", "param", "file_name", ":", ":", "return", ":", "array", "if", "file_name",...
python
train
City-of-Helsinki/django-helusers
helusers/utils.py
https://github.com/City-of-Helsinki/django-helusers/blob/9064979f6f990987358e2bca3c24a80fad201bdb/helusers/utils.py#L5-L17
def uuid_to_username(uuid): """ Convert UUID to username. >>> uuid_to_username('00fbac99-0bab-5e66-8e84-2e567ea4d1f6') 'u-ad52zgilvnpgnduefzlh5jgr6y' >>> uuid_to_username(UUID('00fbac99-0bab-5e66-8e84-2e567ea4d1f6')) 'u-ad52zgilvnpgnduefzlh5jgr6y' """ uuid_data = getattr(uuid, 'bytes',...
[ "def", "uuid_to_username", "(", "uuid", ")", ":", "uuid_data", "=", "getattr", "(", "uuid", ",", "'bytes'", ",", "None", ")", "or", "UUID", "(", "uuid", ")", ".", "bytes", "b32coded", "=", "base64", ".", "b32encode", "(", "uuid_data", ")", "return", "'...
Convert UUID to username. >>> uuid_to_username('00fbac99-0bab-5e66-8e84-2e567ea4d1f6') 'u-ad52zgilvnpgnduefzlh5jgr6y' >>> uuid_to_username(UUID('00fbac99-0bab-5e66-8e84-2e567ea4d1f6')) 'u-ad52zgilvnpgnduefzlh5jgr6y'
[ "Convert", "UUID", "to", "username", "." ]
python
train
esheldon/fitsio
fitsio/hdu/table.py
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L985-L1002
def _fix_tbit_dtype(self, array, colnums): """ If necessary, patch up the TBIT to convert to bool array parameters ---------- array: record array colnums: column numbers for lookup """ descr = array.dtype.descr for i, colnum in enumerate(colnums):...
[ "def", "_fix_tbit_dtype", "(", "self", ",", "array", ",", "colnums", ")", ":", "descr", "=", "array", ".", "dtype", ".", "descr", "for", "i", ",", "colnum", "in", "enumerate", "(", "colnums", ")", ":", "npy_type", ",", "isvar", ",", "istbit", "=", "s...
If necessary, patch up the TBIT to convert to bool array parameters ---------- array: record array colnums: column numbers for lookup
[ "If", "necessary", "patch", "up", "the", "TBIT", "to", "convert", "to", "bool", "array" ]
python
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L264-L290
def disconnect(self, cback, subscribers=None, instance=None): """Remove a previously added function or method from the set of the signal's handlers. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wrapper ...
[ "def", "disconnect", "(", "self", ",", "cback", ",", "subscribers", "=", "None", ",", "instance", "=", "None", ")", ":", "if", "subscribers", "is", "None", ":", "subscribers", "=", "self", ".", "subscribers", "# wrapper", "if", "self", ".", "_fdisconnect",...
Remove a previously added function or method from the set of the signal's handlers. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wrapper
[ "Remove", "a", "previously", "added", "function", "or", "method", "from", "the", "set", "of", "the", "signal", "s", "handlers", "." ]
python
train
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L1448-L1455
def simxUnpackInts(intsPackedInString): ''' Please have a look at the function description/documentation in the V-REP user manual ''' b=[] for i in range(int(len(intsPackedInString)/4)): b.append(struct.unpack('<i',intsPackedInString[4*i:4*(i+1)])[0]) return b
[ "def", "simxUnpackInts", "(", "intsPackedInString", ")", ":", "b", "=", "[", "]", "for", "i", "in", "range", "(", "int", "(", "len", "(", "intsPackedInString", ")", "/", "4", ")", ")", ":", "b", ".", "append", "(", "struct", ".", "unpack", "(", "'<...
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
python
train
Azure/azure-event-hubs-python
azure/eventhub/async_ops/__init__.py
https://github.com/Azure/azure-event-hubs-python/blob/737c5f966557ada2cf10fa0d8f3c19671ae96348/azure/eventhub/async_ops/__init__.py#L237-L270
def add_async_sender( self, partition=None, operation=None, send_timeout=60, keep_alive=30, auto_reconnect=True, loop=None): """ Add an async sender to the client to send ~azure.eventhub.common.EventData object to an EventHub. :param partition: Optionally specify...
[ "def", "add_async_sender", "(", "self", ",", "partition", "=", "None", ",", "operation", "=", "None", ",", "send_timeout", "=", "60", ",", "keep_alive", "=", "30", ",", "auto_reconnect", "=", "True", ",", "loop", "=", "None", ")", ":", "target", "=", "...
Add an async sender to the client to send ~azure.eventhub.common.EventData object to an EventHub. :param partition: Optionally specify a particular partition to send to. If omitted, the events will be distributed to available partitions via round-robin. :type partition: str ...
[ "Add", "an", "async", "sender", "to", "the", "client", "to", "send", "~azure", ".", "eventhub", ".", "common", ".", "EventData", "object", "to", "an", "EventHub", "." ]
python
train
gwpy/gwpy
gwpy/timeseries/statevector.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/timeseries/statevector.py#L778-L827
def get(cls, channel, start, end, bits=None, **kwargs): """Get data for this channel from frames or NDS Parameters ---------- channel : `str`, `~gwpy.detector.Channel` the name of the channel to read, or a `Channel` object. start : `~gwpy.time.LIGOTimeGPS`, `float`,...
[ "def", "get", "(", "cls", ",", "channel", ",", "start", ",", "end", ",", "bits", "=", "None", ",", "*", "*", "kwargs", ")", ":", "new", "=", "cls", ".", "DictClass", ".", "get", "(", "[", "channel", "]", ",", "start", ",", "end", ",", "*", "*...
Get data for this channel from frames or NDS Parameters ---------- channel : `str`, `~gwpy.detector.Channel` the name of the channel to read, or a `Channel` object. start : `~gwpy.time.LIGOTimeGPS`, `float`, `str` GPS start time of required data, any...
[ "Get", "data", "for", "this", "channel", "from", "frames", "or", "NDS" ]
python
train
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L945-L1117
def block_create( self, type, account, wallet=None, representative=None, key=None, destination=None, amount=None, balance=None, previous=None, source=None, work=None, ): """ Creates a json representations...
[ "def", "block_create", "(", "self", ",", "type", ",", "account", ",", "wallet", "=", "None", ",", "representative", "=", "None", ",", "key", "=", "None", ",", "destination", "=", "None", ",", "amount", "=", "None", ",", "balance", "=", "None", ",", "...
Creates a json representations of new block based on input data & signed with private key or account in **wallet** for offline signing .. enable_control required .. version 8.1 required :param type: Type of block to create one of **open**, **receive**, **change**, ...
[ "Creates", "a", "json", "representations", "of", "new", "block", "based", "on", "input", "data", "&", "signed", "with", "private", "key", "or", "account", "in", "**", "wallet", "**", "for", "offline", "signing" ]
python
train
PMEAL/OpenPNM
openpnm/core/Base.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/core/Base.py#L1329-L1380
def num_throats(self, labels='all', mode='union'): r""" Return the number of throats of the specified labels Parameters ---------- labels : list of strings, optional The throat labels that should be included in the count. If not supplied, all throats are ...
[ "def", "num_throats", "(", "self", ",", "labels", "=", "'all'", ",", "mode", "=", "'union'", ")", ":", "# Count number of pores of specified type", "Ts", "=", "self", ".", "_get_indices", "(", "labels", "=", "labels", ",", "mode", "=", "mode", ",", "element"...
r""" Return the number of throats of the specified labels Parameters ---------- labels : list of strings, optional The throat labels that should be included in the count. If not supplied, all throats are counted. mode : string, optional Speci...
[ "r", "Return", "the", "number", "of", "throats", "of", "the", "specified", "labels" ]
python
train
NarrativeScience/lsi
src/lsi/utils/table.py
https://github.com/NarrativeScience/lsi/blob/7d901b03fdb1a34ef795e5412bfe9685d948e32d/src/lsi/utils/table.py#L128-L144
def prepare_rows(table): """ Prepare the rows so they're all strings, and all the same length. :param table: A 2D grid of anything. :type table: [[``object``]] :return: A table of strings, where every row is the same length. :rtype: [[``str``]] """ num_columns = max(len(row) for row in...
[ "def", "prepare_rows", "(", "table", ")", ":", "num_columns", "=", "max", "(", "len", "(", "row", ")", "for", "row", "in", "table", ")", "for", "row", "in", "table", ":", "while", "len", "(", "row", ")", "<", "num_columns", ":", "row", ".", "append...
Prepare the rows so they're all strings, and all the same length. :param table: A 2D grid of anything. :type table: [[``object``]] :return: A table of strings, where every row is the same length. :rtype: [[``str``]]
[ "Prepare", "the", "rows", "so", "they", "re", "all", "strings", "and", "all", "the", "same", "length", "." ]
python
test
senaite/senaite.core
bika/lims/upgrade/v01_02_008.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/upgrade/v01_02_008.py#L103-L117
def fix_client_permissions(portal): """Fix client permissions """ wfs = get_workflows() start = time.time() clients = portal.clients.objectValues() total = len(clients) for num, client in enumerate(clients): logger.info("Fixing permission for client {}/{} ({})" ....
[ "def", "fix_client_permissions", "(", "portal", ")", ":", "wfs", "=", "get_workflows", "(", ")", "start", "=", "time", ".", "time", "(", ")", "clients", "=", "portal", ".", "clients", ".", "objectValues", "(", ")", "total", "=", "len", "(", "clients", ...
Fix client permissions
[ "Fix", "client", "permissions" ]
python
train
espressif/esptool
ecdsa/numbertheory.py
https://github.com/espressif/esptool/blob/c583756c118039cfcfe256f7a3285618914d16a5/ecdsa/numbertheory.py#L185-L203
def inverse_mod( a, m ): """Inverse of a mod m.""" if a < 0 or m <= a: a = a % m # From Ferguson and Schneier, roughly: c, d = a, m uc, vc, ud, vd = 1, 0, 0, 1 while c != 0: q, c, d = divmod( d, c ) + ( c, ) uc, vc, ud, vd = ud - q*uc, vd - q*vc, uc, vc # At this point, d is the GCD, and ud*a+...
[ "def", "inverse_mod", "(", "a", ",", "m", ")", ":", "if", "a", "<", "0", "or", "m", "<=", "a", ":", "a", "=", "a", "%", "m", "# From Ferguson and Schneier, roughly:", "c", ",", "d", "=", "a", ",", "m", "uc", ",", "vc", ",", "ud", ",", "vd", "...
Inverse of a mod m.
[ "Inverse", "of", "a", "mod", "m", "." ]
python
train
openeventdata/mordecai
mordecai/geoparse.py
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L291-L297
def is_country(self, text): """Check if a piece of text is in the list of countries""" ct_list = self._just_cts.keys() if text in ct_list: return True else: return False
[ "def", "is_country", "(", "self", ",", "text", ")", ":", "ct_list", "=", "self", ".", "_just_cts", ".", "keys", "(", ")", "if", "text", "in", "ct_list", ":", "return", "True", "else", ":", "return", "False" ]
Check if a piece of text is in the list of countries
[ "Check", "if", "a", "piece", "of", "text", "is", "in", "the", "list", "of", "countries" ]
python
train
uogbuji/versa
tools/py/driver/memory.py
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/memory.py#L168-L196
def add_many(self, rels): ''' Add a list of relationships to the extent rels - a list of 0 or more relationship tuples, e.g.: [ (origin, rel, target, {attrname1: attrval1, attrname2: attrval2}), ] origin - origin of the relationship (similar to an RDF subjec...
[ "def", "add_many", "(", "self", ",", "rels", ")", ":", "for", "curr_rel", "in", "rels", ":", "attrs", "=", "self", ".", "_attr_cls", "(", ")", "if", "len", "(", "curr_rel", ")", "==", "2", ":", "# handle __iter__ output for copy()", "origin", ",", "rel",...
Add a list of relationships to the extent rels - a list of 0 or more relationship tuples, e.g.: [ (origin, rel, target, {attrname1: attrval1, attrname2: attrval2}), ] origin - origin of the relationship (similar to an RDF subject) rel - type IRI of the relationship ...
[ "Add", "a", "list", "of", "relationships", "to", "the", "extent" ]
python
train
programa-stic/barf-project
barf/core/reil/builder.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/core/reil/builder.py#L166-L171
def gen_nop(): """Return a NOP instruction. """ empty_reg = ReilEmptyOperand() return ReilBuilder.build(ReilMnemonic.NOP, empty_reg, empty_reg, empty_reg)
[ "def", "gen_nop", "(", ")", ":", "empty_reg", "=", "ReilEmptyOperand", "(", ")", "return", "ReilBuilder", ".", "build", "(", "ReilMnemonic", ".", "NOP", ",", "empty_reg", ",", "empty_reg", ",", "empty_reg", ")" ]
Return a NOP instruction.
[ "Return", "a", "NOP", "instruction", "." ]
python
train