repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
evhub/coconut
coconut/exceptions.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/exceptions.py#L87-L93
def message(self, message, item, extra): """Uses arguments to create the message.""" if item is not None: message += ": " + ascii(item) if extra is not None: message += " (" + str(extra) + ")" return message
[ "def", "message", "(", "self", ",", "message", ",", "item", ",", "extra", ")", ":", "if", "item", "is", "not", "None", ":", "message", "+=", "\": \"", "+", "ascii", "(", "item", ")", "if", "extra", "is", "not", "None", ":", "message", "+=", "\" (\"...
Uses arguments to create the message.
[ "Uses", "arguments", "to", "create", "the", "message", "." ]
python
train
36.714286
usc-isi-i2/etk
etk/extractors/spacy_rule_extractor.py
https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/extractors/spacy_rule_extractor.py#L638-L665
def _construct_punctuation_token(self, d: Dict, nlp) -> List[Dict]: """ Construct a shape token Args: d: Dict nlp Returns: List[Dict] """ result = [] if not d["token"]: this_token = {attrs.IS_PUNCT: True} elif len(d["t...
[ "def", "_construct_punctuation_token", "(", "self", ",", "d", ":", "Dict", ",", "nlp", ")", "->", "List", "[", "Dict", "]", ":", "result", "=", "[", "]", "if", "not", "d", "[", "\"token\"", "]", ":", "this_token", "=", "{", "attrs", ".", "IS_PUNCT", ...
Construct a shape token Args: d: Dict nlp Returns: List[Dict]
[ "Construct", "a", "shape", "token", "Args", ":", "d", ":", "Dict", "nlp" ]
python
train
27.75
geertj/gruvi
vendor/txdbus/marshal.py
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/marshal.py#L307-L354
def genCompleteTypes( compoundSig ): """ Generator function used to iterate over each complete, top-level type contained in in a signature. Ex:: "iii" => [ 'i', 'i', 'i' ] "i(ii)i" => [ 'i', '(ii)', 'i' ] "i(i(ii))i" => [ 'i', '(i(ii))', 'i' ] """ i = 0 s...
[ "def", "genCompleteTypes", "(", "compoundSig", ")", ":", "i", "=", "0", "start", "=", "0", "end", "=", "len", "(", "compoundSig", ")", "def", "find_end", "(", "idx", ",", "b", ",", "e", ")", ":", "depth", "=", "1", "while", "idx", "<", "end", ":"...
Generator function used to iterate over each complete, top-level type contained in in a signature. Ex:: "iii" => [ 'i', 'i', 'i' ] "i(ii)i" => [ 'i', '(ii)', 'i' ] "i(i(ii))i" => [ 'i', '(i(ii))', 'i' ]
[ "Generator", "function", "used", "to", "iterate", "over", "each", "complete", "top", "-", "level", "type", "contained", "in", "in", "a", "signature", ".", "Ex", "::", "iii", "=", ">", "[", "i", "i", "i", "]", "i", "(", "ii", ")", "i", "=", ">", "...
python
train
23.958333
google/pybadges
pybadges/precalculated_text_measurer.py
https://github.com/google/pybadges/blob/d42c8080adb21b81123ac9540c53127ed2fa1edc/pybadges/precalculated_text_measurer.py#L62-L70
def from_json(f: TextIO) -> 'PrecalculatedTextMeasurer': """Return a PrecalculatedTextMeasurer given a JSON stream. See precalculate_text.py for details on the required format. """ o = json.load(f) return PrecalculatedTextMeasurer(o['mean-character-length'], ...
[ "def", "from_json", "(", "f", ":", "TextIO", ")", "->", "'PrecalculatedTextMeasurer'", ":", "o", "=", "json", ".", "load", "(", "f", ")", "return", "PrecalculatedTextMeasurer", "(", "o", "[", "'mean-character-length'", "]", ",", "o", "[", "'character-lengths'"...
Return a PrecalculatedTextMeasurer given a JSON stream. See precalculate_text.py for details on the required format.
[ "Return", "a", "PrecalculatedTextMeasurer", "given", "a", "JSON", "stream", "." ]
python
test
46.333333
pyrogram/pyrogram
pyrogram/client/methods/messages/edit_message_media.py
https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/methods/messages/edit_message_media.py#L36-L366
def edit_message_media( self, chat_id: Union[int, str], message_id: int, media: InputMedia, reply_markup: "pyrogram.InlineKeyboardMarkup" = None ) -> "pyrogram.Message": """Use this method to edit audio, document, photo, or video messages. If a message is a p...
[ "def", "edit_message_media", "(", "self", ",", "chat_id", ":", "Union", "[", "int", ",", "str", "]", ",", "message_id", ":", "int", ",", "media", ":", "InputMedia", ",", "reply_markup", ":", "\"pyrogram.InlineKeyboardMarkup\"", "=", "None", ")", "->", "\"pyr...
Use this method to edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded ...
[ "Use", "this", "method", "to", "edit", "audio", "document", "photo", "or", "video", "messages", "." ]
python
train
43.522659
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L77-L86
def on(self, state): """ Turn on or off. :param state: True (on) or False (off). """ self._on = state cmd = self.command_set.off() if state: cmd = self.command_set.on() self.send(cmd)
[ "def", "on", "(", "self", ",", "state", ")", ":", "self", ".", "_on", "=", "state", "cmd", "=", "self", ".", "command_set", ".", "off", "(", ")", "if", "state", ":", "cmd", "=", "self", ".", "command_set", ".", "on", "(", ")", "self", ".", "sen...
Turn on or off. :param state: True (on) or False (off).
[ "Turn", "on", "or", "off", "." ]
python
train
24.3
kytos/python-openflow
pyof/foundation/base.py
https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/base.py#L387-L411
def replace_pyof_version(module_fullname, version): """Replace the OF Version of a module fullname. Get's a module name (eg. 'pyof.v0x01.common.header') and returns it on a new 'version' (eg. 'pyof.v0x02.common.header'). Args: module_fullname (str): The fullname of the modu...
[ "def", "replace_pyof_version", "(", "module_fullname", ",", "version", ")", ":", "module_version", "=", "MetaStruct", ".", "get_pyof_version", "(", "module_fullname", ")", "if", "not", "module_version", "or", "module_version", "==", "version", ":", "return", "None",...
Replace the OF Version of a module fullname. Get's a module name (eg. 'pyof.v0x01.common.header') and returns it on a new 'version' (eg. 'pyof.v0x02.common.header'). Args: module_fullname (str): The fullname of the module (e.g.: pyof.v0x01.common....
[ "Replace", "the", "OF", "Version", "of", "a", "module", "fullname", "." ]
python
train
42.32
rmed/pyemtmad
pyemtmad/api/parking.py
https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L230-L254
def list_features(self, **kwargs): """Obtain a list of parkings. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Parking]), or message string in case of error. """ # Endpoint parameters ...
[ "def", "list_features", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Endpoint parameters", "params", "=", "{", "'language'", ":", "util", ".", "language_code", "(", "kwargs", ".", "get", "(", "'lang'", ")", ")", ",", "'publicData'", ":", "True", "}...
Obtain a list of parkings. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Parking]), or message string in case of error.
[ "Obtain", "a", "list", "of", "parkings", "." ]
python
train
29.68
SoftwareDefinedBuildings/XBOS
apps/Data_quality_analysis/Wrapper.py
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/Data_quality_analysis/Wrapper.py#L439-L543
def clean_data(self, data, rename_col=None, drop_col=None, resample=True, freq='h', resampler='mean', interpolate=True, limit=1, method='linear', remove_na=True, remove_na_how='any', remove_outliers=True, sd_val=3, remov...
[ "def", "clean_data", "(", "self", ",", "data", ",", "rename_col", "=", "None", ",", "drop_col", "=", "None", ",", "resample", "=", "True", ",", "freq", "=", "'h'", ",", "resampler", "=", "'mean'", ",", "interpolate", "=", "True", ",", "limit", "=", "...
Cleans dataframe according to user specifications and stores result in self.cleaned_data. Parameters ---------- data : pd.DataFrame() Dataframe to be cleaned. rename_col : list(str) List of new column names. drop_col ...
[ "Cleans", "dataframe", "according", "to", "user", "specifications", "and", "stores", "result", "in", "self", ".", "cleaned_data", "." ]
python
train
41.628571
saltstack/salt
salt/cli/daemons.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L377-L389
def shutdown(self, exitcode=0, exitmsg=None): ''' If sub-classed, run any shutdown operations on this method. :param exitcode :param exitmsg ''' self.action_log_info('Shutting down') if hasattr(self, 'minion') and hasattr(self.minion, 'destroy'): self...
[ "def", "shutdown", "(", "self", ",", "exitcode", "=", "0", ",", "exitmsg", "=", "None", ")", ":", "self", ".", "action_log_info", "(", "'Shutting down'", ")", "if", "hasattr", "(", "self", ",", "'minion'", ")", "and", "hasattr", "(", "self", ".", "mini...
If sub-classed, run any shutdown operations on this method. :param exitcode :param exitmsg
[ "If", "sub", "-", "classed", "run", "any", "shutdown", "operations", "on", "this", "method", "." ]
python
train
38
yougov/mongo-connector
mongo_connector/connector.py
https://github.com/yougov/mongo-connector/blob/557cafd4b54c848cd54ef28a258391a154650cb4/mongo_connector/connector.py#L348-L473
def run(self): """Discovers the mongo cluster and creates a thread for each primary. """ # Reset the global minimum MongoDB version update_mininum_mongodb_version(None) self.main_conn = self.create_authed_client() LOG.always( "Source MongoDB version: %s", ...
[ "def", "run", "(", "self", ")", ":", "# Reset the global minimum MongoDB version", "update_mininum_mongodb_version", "(", "None", ")", "self", ".", "main_conn", "=", "self", ".", "create_authed_client", "(", ")", "LOG", ".", "always", "(", "\"Source MongoDB version: %...
Discovers the mongo cluster and creates a thread for each primary.
[ "Discovers", "the", "mongo", "cluster", "and", "creates", "a", "thread", "for", "each", "primary", "." ]
python
train
40.222222
saltstack/salt
salt/modules/selinux.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/selinux.py#L331-L376
def list_semod(): ''' Return a structure listing all of the selinux modules on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_semod .. versionadded:: 2016.3.0 ''' helptext = __salt__['cmd.run']('semodule -h').splitlines() sem...
[ "def", "list_semod", "(", ")", ":", "helptext", "=", "__salt__", "[", "'cmd.run'", "]", "(", "'semodule -h'", ")", ".", "splitlines", "(", ")", "semodule_version", "=", "''", "for", "line", "in", "helptext", ":", "if", "line", ".", "strip", "(", ")", "...
Return a structure listing all of the selinux modules on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_semod .. versionadded:: 2016.3.0
[ "Return", "a", "structure", "listing", "all", "of", "the", "selinux", "modules", "on", "the", "system", "and", "what", "state", "they", "are", "in" ]
python
train
29.826087
sanger-pathogens/Fastaq
pyfastaq/intervals.py
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L34-L39
def distance_to_point(self, p): '''Returns the distance from the point to the interval. Zero if the point lies inside the interval.''' if self.start <= p <= self.end: return 0 else: return min(abs(self.start - p), abs(self.end - p))
[ "def", "distance_to_point", "(", "self", ",", "p", ")", ":", "if", "self", ".", "start", "<=", "p", "<=", "self", ".", "end", ":", "return", "0", "else", ":", "return", "min", "(", "abs", "(", "self", ".", "start", "-", "p", ")", ",", "abs", "(...
Returns the distance from the point to the interval. Zero if the point lies inside the interval.
[ "Returns", "the", "distance", "from", "the", "point", "to", "the", "interval", ".", "Zero", "if", "the", "point", "lies", "inside", "the", "interval", "." ]
python
valid
45.833333
samirelanduk/quickplots
quickplots/charts.py
https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L516-L534
def y_ticks(self, *ticks): """The points on the y-axis for which there are markers and grid lines. There are default ticks, but you can pass values to this method to override the defaults. Otherwise the method will return the ticks. :param \*ticks: if given, these will be chart's x-tic...
[ "def", "y_ticks", "(", "self", ",", "*", "ticks", ")", ":", "if", "ticks", ":", "for", "tick", "in", "ticks", ":", "if", "not", "is_numeric", "(", "tick", ")", ":", "raise", "TypeError", "(", "\"'%s' is not a numeric tick\"", "%", "str", "(", "tick", "...
The points on the y-axis for which there are markers and grid lines. There are default ticks, but you can pass values to this method to override the defaults. Otherwise the method will return the ticks. :param \*ticks: if given, these will be chart's x-ticks. :rtype: ``tuple``
[ "The", "points", "on", "the", "y", "-", "axis", "for", "which", "there", "are", "markers", "and", "grid", "lines", "." ]
python
train
38.631579
DataDog/integrations-core
kube_dns/datadog_checks/kube_dns/kube_dns.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kube_dns/datadog_checks/kube_dns/kube_dns.py#L56-L86
def _create_kube_dns_instance(self, instance): """ Set up kube_dns instance so it can be used in OpenMetricsBaseCheck """ kube_dns_instance = deepcopy(instance) # kube_dns uses 'prometheus_endpoint' and not 'prometheus_url', so we have to rename the key kube_dns_instance...
[ "def", "_create_kube_dns_instance", "(", "self", ",", "instance", ")", ":", "kube_dns_instance", "=", "deepcopy", "(", "instance", ")", "# kube_dns uses 'prometheus_endpoint' and not 'prometheus_url', so we have to rename the key", "kube_dns_instance", "[", "'prometheus_url'", "]...
Set up kube_dns instance so it can be used in OpenMetricsBaseCheck
[ "Set", "up", "kube_dns", "instance", "so", "it", "can", "be", "used", "in", "OpenMetricsBaseCheck" ]
python
train
49.258065
seomoz/qless-py
qless/util.py
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/util.py#L4-L9
def import_class(klass): '''Import the named class and return that class''' mod = __import__(klass.rpartition('.')[0]) for segment in klass.split('.')[1:-1]: mod = getattr(mod, segment) return getattr(mod, klass.rpartition('.')[2])
[ "def", "import_class", "(", "klass", ")", ":", "mod", "=", "__import__", "(", "klass", ".", "rpartition", "(", "'.'", ")", "[", "0", "]", ")", "for", "segment", "in", "klass", ".", "split", "(", "'.'", ")", "[", "1", ":", "-", "1", "]", ":", "m...
Import the named class and return that class
[ "Import", "the", "named", "class", "and", "return", "that", "class" ]
python
train
41.666667
LonamiWebs/Telethon
telethon/utils.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L457-L469
def get_input_message(message): """Similar to :meth:`get_input_peer`, but for input messages.""" try: if isinstance(message, int): # This case is really common too return types.InputMessageID(message) elif message.SUBCLASS_OF_ID == 0x54b6bcc5: # crc32(b'InputMessage'): ...
[ "def", "get_input_message", "(", "message", ")", ":", "try", ":", "if", "isinstance", "(", "message", ",", "int", ")", ":", "# This case is really common too", "return", "types", ".", "InputMessageID", "(", "message", ")", "elif", "message", ".", "SUBCLASS_OF_ID...
Similar to :meth:`get_input_peer`, but for input messages.
[ "Similar", "to", ":", "meth", ":", "get_input_peer", "but", "for", "input", "messages", "." ]
python
train
40.923077
benley/butcher
butcher/targets/pkgfilegroup.py
https://github.com/benley/butcher/blob/8b18828ea040af56b7835beab5fd03eab23cc9ee/butcher/targets/pkgfilegroup.py#L62-L73
def output_files(self): """Returns the list of output files from this rule. Paths are generated from the outputs of this rule's dependencies, with their paths translated based on prefix and strip_prefix. Returned paths are relative to buildroot. """ for dep in self.subg...
[ "def", "output_files", "(", "self", ")", ":", "for", "dep", "in", "self", ".", "subgraph", ".", "successors", "(", "self", ".", "address", ")", ":", "dep_rule", "=", "self", ".", "subgraph", ".", "node", "[", "dep", "]", "[", "'target_obj'", "]", "fo...
Returns the list of output files from this rule. Paths are generated from the outputs of this rule's dependencies, with their paths translated based on prefix and strip_prefix. Returned paths are relative to buildroot.
[ "Returns", "the", "list", "of", "output", "files", "from", "this", "rule", "." ]
python
train
43.75
buriburisuri/sugartensor
sugartensor/sg_transform.py
https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_transform.py#L338-L353
def sg_mean(tensor, opt): r"""Computes the mean of elements across axis of a tensor. See `tf.reduce_mean()` in tensorflow. Args: tensor: A `Tensor` (automatically given by chain). opt: axis : A tuple/list of integers or an integer. The axis to reduce. keep_dims: If true, re...
[ "def", "sg_mean", "(", "tensor", ",", "opt", ")", ":", "return", "tf", ".", "reduce_mean", "(", "tensor", ",", "axis", "=", "opt", ".", "axis", ",", "keep_dims", "=", "opt", ".", "keep_dims", ",", "name", "=", "opt", ".", "name", ")" ]
r"""Computes the mean of elements across axis of a tensor. See `tf.reduce_mean()` in tensorflow. Args: tensor: A `Tensor` (automatically given by chain). opt: axis : A tuple/list of integers or an integer. The axis to reduce. keep_dims: If true, retains reduced dimensions with ...
[ "r", "Computes", "the", "mean", "of", "elements", "across", "axis", "of", "a", "tensor", ".", "See", "tf", ".", "reduce_mean", "()", "in", "tensorflow", "." ]
python
train
33.1875
prompt-toolkit/pymux
pymux/commands/commands.py
https://github.com/prompt-toolkit/pymux/blob/3f66e62b9de4b2251c7f9afad6c516dc5a30ec67/pymux/commands/commands.py#L603-L610
def clear_history(pymux, variables): " Clear scrollback buffer. " pane = pymux.arrangement.get_active_pane() if pane.display_scroll_buffer: raise CommandException('Not available in copy mode') else: pane.process.screen.clear_history()
[ "def", "clear_history", "(", "pymux", ",", "variables", ")", ":", "pane", "=", "pymux", ".", "arrangement", ".", "get_active_pane", "(", ")", "if", "pane", ".", "display_scroll_buffer", ":", "raise", "CommandException", "(", "'Not available in copy mode'", ")", ...
Clear scrollback buffer.
[ "Clear", "scrollback", "buffer", "." ]
python
train
32.5
edx/edx-enterprise
integrated_channels/xapi/management/commands/send_course_completions.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/management/commands/send_course_completions.py#L168-L183
def prefetch_users(persistent_course_grades): """ Prefetch Users from the list of user_ids present in the persistent_course_grades. Arguments: persistent_course_grades (list): A list of PersistentCourseGrade. Returns: (dict): A dictionary containing user_id to u...
[ "def", "prefetch_users", "(", "persistent_course_grades", ")", ":", "users", "=", "User", ".", "objects", ".", "filter", "(", "id__in", "=", "[", "grade", ".", "user_id", "for", "grade", "in", "persistent_course_grades", "]", ")", "return", "{", "user", ".",...
Prefetch Users from the list of user_ids present in the persistent_course_grades. Arguments: persistent_course_grades (list): A list of PersistentCourseGrade. Returns: (dict): A dictionary containing user_id to user mapping.
[ "Prefetch", "Users", "from", "the", "list", "of", "user_ids", "present", "in", "the", "persistent_course_grades", "." ]
python
valid
32.5
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L487-L511
def simxAuxiliaryConsoleOpen(clientID, title, maxLines, mode, position, size, textColor, backgroundColor, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' consoleHandle = ct.c_int() if (sys.version_info[0] == 3) and (type(title) is str): ...
[ "def", "simxAuxiliaryConsoleOpen", "(", "clientID", ",", "title", ",", "maxLines", ",", "mode", ",", "position", ",", "size", ",", "textColor", ",", "backgroundColor", ",", "operationMode", ")", ":", "consoleHandle", "=", "ct", ".", "c_int", "(", ")", "if", ...
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
38.2
dwavesystems/dimod
dimod/binary_quadratic_model.py
https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/binary_quadratic_model.py#L1905-L1958
def from_networkx_graph(cls, G, vartype=None, node_attribute_name='bias', edge_attribute_name='bias'): """Create a binary quadratic model from a NetworkX graph. Args: G (:obj:`networkx.Graph`): A NetworkX graph with biases stored as node/edge attr...
[ "def", "from_networkx_graph", "(", "cls", ",", "G", ",", "vartype", "=", "None", ",", "node_attribute_name", "=", "'bias'", ",", "edge_attribute_name", "=", "'bias'", ")", ":", "if", "vartype", "is", "None", ":", "if", "not", "hasattr", "(", "G", ",", "'...
Create a binary quadratic model from a NetworkX graph. Args: G (:obj:`networkx.Graph`): A NetworkX graph with biases stored as node/edge attributes. vartype (:class:`.Vartype`/str/set, optional): Variable type for the binary quadratic model. Accepted inp...
[ "Create", "a", "binary", "quadratic", "model", "from", "a", "NetworkX", "graph", "." ]
python
train
38.925926
pyparsing/pyparsing
examples/pymicko.py
https://github.com/pyparsing/pyparsing/blob/f0264bd8d1a548a50b3e5f7d99cfefd577942d14/examples/pymicko.py#L409-L422
def insert_id(self, sname, skind, skinds, stype): """Inserts a new identifier at the end of the symbol table, if possible. Returns symbol index, or raises an exception if the symbol alredy exists sname - symbol name skind - symbol kind skinds - symbol kinds ...
[ "def", "insert_id", "(", "self", ",", "sname", ",", "skind", ",", "skinds", ",", "stype", ")", ":", "index", "=", "self", ".", "lookup_symbol", "(", "sname", ",", "skinds", ")", "if", "index", "==", "None", ":", "index", "=", "self", ".", "insert_sym...
Inserts a new identifier at the end of the symbol table, if possible. Returns symbol index, or raises an exception if the symbol alredy exists sname - symbol name skind - symbol kind skinds - symbol kinds to check for stype - symbol type
[ "Inserts", "a", "new", "identifier", "at", "the", "end", "of", "the", "symbol", "table", "if", "possible", ".", "Returns", "symbol", "index", "or", "raises", "an", "exception", "if", "the", "symbol", "alredy", "exists", "sname", "-", "symbol", "name", "ski...
python
train
43.928571
tanghaibao/jcvi
jcvi/formats/fasta.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/fasta.py#L2038-L2093
def trim(args): """ %prog trim fasta.screen newfasta take the screen output from `cross_match` (against a vector db, for example), then trim the sequences to remove X's. Will also perform quality trim if fasta.screen.qual is found. The trimming algorithm is based on finding the subarray that ma...
[ "def", "trim", "(", "args", ")", ":", "from", "jcvi", ".", "algorithms", ".", "maxsum", "import", "max_sum", "p", "=", "OptionParser", "(", "trim", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"-c\"", ",", "dest", "=", "\"min_length\"", ",", "ty...
%prog trim fasta.screen newfasta take the screen output from `cross_match` (against a vector db, for example), then trim the sequences to remove X's. Will also perform quality trim if fasta.screen.qual is found. The trimming algorithm is based on finding the subarray that maximize the sum
[ "%prog", "trim", "fasta", ".", "screen", "newfasta" ]
python
train
31.321429
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/external/ssh/tunnel.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/external/ssh/tunnel.py#L108-L128
def _try_passwordless_paramiko(server, keyfile): """Try passwordless login with paramiko.""" if paramiko is None: msg = "Paramiko unavaliable, " if sys.platform == 'win32': msg += "Paramiko is required for ssh tunneled connections on Windows." else: msg += "use Op...
[ "def", "_try_passwordless_paramiko", "(", "server", ",", "keyfile", ")", ":", "if", "paramiko", "is", "None", ":", "msg", "=", "\"Paramiko unavaliable, \"", "if", "sys", ".", "platform", "==", "'win32'", ":", "msg", "+=", "\"Paramiko is required for ssh tunneled con...
Try passwordless login with paramiko.
[ "Try", "passwordless", "login", "with", "paramiko", "." ]
python
test
36.380952
DMSC-Instrument-Data/lewis
src/lewis/core/statemachine.py
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/statemachine.py#L56-L61
def set_context(self, new_context): """Assigns the new context to the member variable ``_context``.""" self._context = new_context if hasattr(self, '_set_logging_context'): self._set_logging_context(self._context)
[ "def", "set_context", "(", "self", ",", "new_context", ")", ":", "self", ".", "_context", "=", "new_context", "if", "hasattr", "(", "self", ",", "'_set_logging_context'", ")", ":", "self", ".", "_set_logging_context", "(", "self", ".", "_context", ")" ]
Assigns the new context to the member variable ``_context``.
[ "Assigns", "the", "new", "context", "to", "the", "member", "variable", "_context", "." ]
python
train
40.833333
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L5044-L5056
def get_stp_mst_detail_output_last_instance_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_stp_mst_detail = ET.Element("get_stp_mst_detail") config = get_stp_mst_detail output = ET.SubElement(get_stp_mst_detail, "output") ...
[ "def", "get_stp_mst_detail_output_last_instance_instance_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_stp_mst_detail", "=", "ET", ".", "Element", "(", "\"get_stp_mst_detail\"", ")", "config"...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
44.076923
reingart/gui2py
gui/controls/gridview.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/controls/gridview.py#L560-L570
def EndEdit(self, row, col, grid, val=None): "Complete the editing of the current cell. Returns True if changed" changed = False val = self._tc.GetStringSelection() print "val", val, row, col, self.startValue if val != self.startValue: changed = True ...
[ "def", "EndEdit", "(", "self", ",", "row", ",", "col", ",", "grid", ",", "val", "=", "None", ")", ":", "changed", "=", "False", "val", "=", "self", ".", "_tc", ".", "GetStringSelection", "(", ")", "print", "\"val\"", ",", "val", ",", "row", ",", ...
Complete the editing of the current cell. Returns True if changed
[ "Complete", "the", "editing", "of", "the", "current", "cell", ".", "Returns", "True", "if", "changed" ]
python
test
42.272727
ralphbean/bugwarrior
bugwarrior/services/trello.py
https://github.com/ralphbean/bugwarrior/blob/b2a5108f7b40cb0c437509b64eaa28f941f7ac8b/bugwarrior/services/trello.py#L125-L139
def get_boards(self): """ Get the list of boards to pull cards from. If the user gave a value to trello.include_boards use that, otherwise ask the Trello API for the user's boards. """ if 'include_boards' in self.config: for boardid in self.config.get('includ...
[ "def", "get_boards", "(", "self", ")", ":", "if", "'include_boards'", "in", "self", ".", "config", ":", "for", "boardid", "in", "self", ".", "config", ".", "get", "(", "'include_boards'", ",", "to_type", "=", "aslist", ")", ":", "# Get the board name", "yi...
Get the list of boards to pull cards from. If the user gave a value to trello.include_boards use that, otherwise ask the Trello API for the user's boards.
[ "Get", "the", "list", "of", "boards", "to", "pull", "cards", "from", ".", "If", "the", "user", "gave", "a", "value", "to", "trello", ".", "include_boards", "use", "that", "otherwise", "ask", "the", "Trello", "API", "for", "the", "user", "s", "boards", ...
python
test
42.266667
Alignak-monitoring/alignak
alignak/modules/inner_metrics.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modules/inner_metrics.py#L690-L740
def manage_host_check_result_brok(self, b): # pylint: disable=too-many-branches """An host check result brok has just arrived...""" host_name = b.data.get('host_name', None) if not host_name: return logger.debug("host check result: %s", host_name) # If host initial ...
[ "def", "manage_host_check_result_brok", "(", "self", ",", "b", ")", ":", "# pylint: disable=too-many-branches", "host_name", "=", "b", ".", "data", ".", "get", "(", "'host_name'", ",", "None", ")", "if", "not", "host_name", ":", "return", "logger", ".", "debug...
An host check result brok has just arrived...
[ "An", "host", "check", "result", "brok", "has", "just", "arrived", "..." ]
python
train
42.705882
open511/open511
open511/converter/o5json.py
https://github.com/open511/open511/blob/3d573f59d7efa06ff1b5419ea5ff4d90a90b3cf8/open511/converter/o5json.py#L9-L63
def xml_to_json(root): """Convert an Open511 XML document or document fragment to JSON. Takes an lxml Element object. Returns a dict ready to be JSON-serialized.""" j = {} if len(root) == 0: # Tag with no children, return str/int return _maybe_intify(root.text) if len(root) == 1 and root...
[ "def", "xml_to_json", "(", "root", ")", ":", "j", "=", "{", "}", "if", "len", "(", "root", ")", "==", "0", ":", "# Tag with no children, return str/int", "return", "_maybe_intify", "(", "root", ".", "text", ")", "if", "len", "(", "root", ")", "==", "1"...
Convert an Open511 XML document or document fragment to JSON. Takes an lxml Element object. Returns a dict ready to be JSON-serialized.
[ "Convert", "an", "Open511", "XML", "document", "or", "document", "fragment", "to", "JSON", "." ]
python
valid
37.872727
PMBio/limix-backup
limix/deprecated/archive/varianceDecompositionOld.py
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/varianceDecompositionOld.py#L75-L101
def setY(self,Y,standardize=False): """ Set phenotype matrix Args: Y: phenotype matrix [N, P] standardize: if True, phenotype is standardized (zero mean, unit variance) """ assert Y.shape[0]==self.N, 'CVarianceDecomposition:: Incompat...
[ "def", "setY", "(", "self", ",", "Y", ",", "standardize", "=", "False", ")", ":", "assert", "Y", ".", "shape", "[", "0", "]", "==", "self", ".", "N", ",", "'CVarianceDecomposition:: Incompatible shape'", "assert", "Y", ".", "shape", "[", "1", "]", "=="...
Set phenotype matrix Args: Y: phenotype matrix [N, P] standardize: if True, phenotype is standardized (zero mean, unit variance)
[ "Set", "phenotype", "matrix", "Args", ":", "Y", ":", "phenotype", "matrix", "[", "N", "P", "]", "standardize", ":", "if", "True", "phenotype", "is", "standardized", "(", "zero", "mean", "unit", "variance", ")" ]
python
train
33.666667
mongodb/mongo-python-driver
pymongo/uri_parser.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/uri_parser.py#L211-L234
def _parse_options(opts, delim): """Helper method for split_options which creates the options dict. Also handles the creation of a list for the URI tag_sets/ readpreferencetags portion and the use of the tlsInsecure option.""" options = _CaseInsensitiveDictionary() for uriopt in opts.split(delim): ...
[ "def", "_parse_options", "(", "opts", ",", "delim", ")", ":", "options", "=", "_CaseInsensitiveDictionary", "(", ")", "for", "uriopt", "in", "opts", ".", "split", "(", "delim", ")", ":", "key", ",", "value", "=", "uriopt", ".", "split", "(", "\"=\"", "...
Helper method for split_options which creates the options dict. Also handles the creation of a list for the URI tag_sets/ readpreferencetags portion and the use of the tlsInsecure option.
[ "Helper", "method", "for", "split_options", "which", "creates", "the", "options", "dict", ".", "Also", "handles", "the", "creation", "of", "a", "list", "for", "the", "URI", "tag_sets", "/", "readpreferencetags", "portion", "and", "the", "use", "of", "the", "...
python
train
44.708333
luqasz/librouteros
librouteros/connections.py
https://github.com/luqasz/librouteros/blob/59293eb49c07a339af87b0416e4619e78ca5176d/librouteros/connections.py#L88-L114
def decodeLength(length): """ Decode length based on given bytes. :param length: Bytes string to decode. :return: Decoded length. """ bytes_length = len(length) if bytes_length < 2: offset = b'\x00\x00\x00' XOR = 0 elif bytes_leng...
[ "def", "decodeLength", "(", "length", ")", ":", "bytes_length", "=", "len", "(", "length", ")", "if", "bytes_length", "<", "2", ":", "offset", "=", "b'\\x00\\x00\\x00'", "XOR", "=", "0", "elif", "bytes_length", "<", "3", ":", "offset", "=", "b'\\x00\\x00'"...
Decode length based on given bytes. :param length: Bytes string to decode. :return: Decoded length.
[ "Decode", "length", "based", "on", "given", "bytes", "." ]
python
train
26.925926
sirfoga/pyhal
hal/charts/correlation.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/charts/correlation.py#L11-L31
def create_correlation_matrix_plot(correlation_matrix, title, feature_list): """Creates plot for correlation matrix :param correlation_matrix: Correlation matrix of features :param title: Title of plot :param feature_list: List of names of features :return: Shows the given correlation matrix as ima...
[ "def", "create_correlation_matrix_plot", "(", "correlation_matrix", ",", "title", ",", "feature_list", ")", ":", "chart", "=", "SimpleChart", "(", "title", ")", "ax1", "=", "chart", ".", "get_ax", "(", ")", "ax1", ".", "set_xticks", "(", "list", "(", "range"...
Creates plot for correlation matrix :param correlation_matrix: Correlation matrix of features :param title: Title of plot :param feature_list: List of names of features :return: Shows the given correlation matrix as image
[ "Creates", "plot", "for", "correlation", "matrix" ]
python
train
42.095238
marcomusy/vtkplotter
vtkplotter/vtkio.py
https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/vtkio.py#L313-L354
def loadOFF(filename, c="gold", alpha=1, wire=False, bc=None): """Read OFF file format.""" if not os.path.exists(filename): colors.printc("~noentry Error in loadOFF: Cannot find", filename, c=1) return None f = open(filename, "r") lines = f.readlines() f.close() vertices = [] ...
[ "def", "loadOFF", "(", "filename", ",", "c", "=", "\"gold\"", ",", "alpha", "=", "1", ",", "wire", "=", "False", ",", "bc", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "colors", ".", "printc", ...
Read OFF file format.
[ "Read", "OFF", "file", "format", "." ]
python
train
26.904762
TUT-ARG/sed_eval
sed_eval/sound_event.py
https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/sound_event.py#L1633-L1668
def validate_offset(reference_event, estimated_event, t_collar=0.200, percentage_of_length=0.5): """Validate estimated event based on event offset Parameters ---------- reference_event : dict Reference event. estimated_event : dict Estimated event. ...
[ "def", "validate_offset", "(", "reference_event", ",", "estimated_event", ",", "t_collar", "=", "0.200", ",", "percentage_of_length", "=", "0.5", ")", ":", "# Detect field naming style used and validate onset", "if", "'event_offset'", "in", "reference_event", "and", "'eve...
Validate estimated event based on event offset Parameters ---------- reference_event : dict Reference event. estimated_event : dict Estimated event. t_collar : float > 0, seconds First condition, Time collar with which the estimated offset h...
[ "Validate", "estimated", "event", "based", "on", "event", "offset" ]
python
train
40.583333
eqcorrscan/EQcorrscan
eqcorrscan/utils/clustering.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/clustering.py#L574-L793
def extract_detections(detections, templates, archive, arc_type, extract_len=90.0, outdir=None, extract_Z=True, additional_stations=[]): """ Extract waveforms associated with detections Takes a list of detections for the template, template. Waveforms will be ...
[ "def", "extract_detections", "(", "detections", ",", "templates", ",", "archive", ",", "arc_type", ",", "extract_len", "=", "90.0", ",", "outdir", "=", "None", ",", "extract_Z", "=", "True", ",", "additional_stations", "=", "[", "]", ")", ":", "# Sort the te...
Extract waveforms associated with detections Takes a list of detections for the template, template. Waveforms will be returned as a list of :class:`obspy.core.stream.Stream` containing segments of extract_len. They will also be saved if outdir is set. The default is unset. The default extract_len i...
[ "Extract", "waveforms", "associated", "with", "detections" ]
python
train
45.736364
nicolargo/glances
glances/plugins/glances_irq.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L165-L179
def __sum(self, line): """Return the IRQ sum number. IRQ line samples: 1: 44487 341 44 72 IO-APIC 1-edge i8042 LOC: 33549868 22394684 32474570 21855077 Local timer interrupts FIQ: usb_fiq """ splitted_line = line.sp...
[ "def", "__sum", "(", "self", ",", "line", ")", ":", "splitted_line", "=", "line", ".", "split", "(", ")", "try", ":", "ret", "=", "sum", "(", "map", "(", "int", ",", "splitted_line", "[", "1", ":", "(", "self", ".", "cpu_number", "+", "1", ")", ...
Return the IRQ sum number. IRQ line samples: 1: 44487 341 44 72 IO-APIC 1-edge i8042 LOC: 33549868 22394684 32474570 21855077 Local timer interrupts FIQ: usb_fiq
[ "Return", "the", "IRQ", "sum", "number", "." ]
python
train
35.866667
noxdafox/clipspy
clips/classes.py
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L294-L296
def watch_instances(self, flag): """Whether or not the Class Instances are being watched.""" lib.EnvSetDefclassWatchInstances(self._env, int(flag), self._cls)
[ "def", "watch_instances", "(", "self", ",", "flag", ")", ":", "lib", ".", "EnvSetDefclassWatchInstances", "(", "self", ".", "_env", ",", "int", "(", "flag", ")", ",", "self", ".", "_cls", ")" ]
Whether or not the Class Instances are being watched.
[ "Whether", "or", "not", "the", "Class", "Instances", "are", "being", "watched", "." ]
python
train
57.333333
lpantano/seqcluster
seqcluster/libs/thinkbayes.py
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/thinkbayes.py#L949-L967
def Value(self, p): """Returns InverseCDF(p), the value that corresponds to probability p. Args: p: number in the range [0, 1] Returns: number value """ if p < 0 or p > 1: raise ValueError('Probability p must be in range [0, 1]') if ...
[ "def", "Value", "(", "self", ",", "p", ")", ":", "if", "p", "<", "0", "or", "p", ">", "1", ":", "raise", "ValueError", "(", "'Probability p must be in range [0, 1]'", ")", "if", "p", "==", "0", ":", "return", "self", ".", "xs", "[", "0", "]", "if",...
Returns InverseCDF(p), the value that corresponds to probability p. Args: p: number in the range [0, 1] Returns: number value
[ "Returns", "InverseCDF", "(", "p", ")", "the", "value", "that", "corresponds", "to", "probability", "p", "." ]
python
train
27.842105
heikomuller/sco-datastore
scodata/subject.py
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/subject.py#L193-L213
def upload_file(self, filename, file_type=FILE_TYPE_FREESURFER_DIRECTORY): """Create an anatomy object on local disk from the given file. Currently, only Freesurfer anatomy directories are supported. Expects a tar file. Parameters ---------- filename : string ...
[ "def", "upload_file", "(", "self", ",", "filename", ",", "file_type", "=", "FILE_TYPE_FREESURFER_DIRECTORY", ")", ":", "# We currently only support one file type (i.e., FREESURFER_DIRECTORY).", "if", "file_type", "!=", "FILE_TYPE_FREESURFER_DIRECTORY", ":", "raise", "ValueError...
Create an anatomy object on local disk from the given file. Currently, only Freesurfer anatomy directories are supported. Expects a tar file. Parameters ---------- filename : string Name of the (uploaded) file file_type : string File type (current...
[ "Create", "an", "anatomy", "object", "on", "local", "disk", "from", "the", "given", "file", ".", "Currently", "only", "Freesurfer", "anatomy", "directories", "are", "supported", ".", "Expects", "a", "tar", "file", "." ]
python
train
38.380952
mcs07/CIRpy
cirpy.py
https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L441-L448
def download(self, filename, representation, overwrite=False): """Download the resolved structure as a file. :param string filename: File path to save to :param string representation: Desired output representation :param bool overwrite: (Optional) Whether to allow overwriting of an exis...
[ "def", "download", "(", "self", ",", "filename", ",", "representation", ",", "overwrite", "=", "False", ")", ":", "download", "(", "self", ".", "input", ",", "filename", ",", "representation", ",", "overwrite", ",", "self", ".", "resolvers", ",", "self", ...
Download the resolved structure as a file. :param string filename: File path to save to :param string representation: Desired output representation :param bool overwrite: (Optional) Whether to allow overwriting of an existing file
[ "Download", "the", "resolved", "structure", "as", "a", "file", "." ]
python
train
55.375
genepattern/genepattern-python
gp/core.py
https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/core.py#L212-L228
def open(self): """ Opens the URL associated with the GPFile and returns a file-like object with three extra methods: * geturl() - return the ultimate URL (can be used to determine if a redirect was followed) * info() - return the meta-information of the...
[ "def", "open", "(", "self", ")", ":", "request", "=", "urllib", ".", "request", ".", "Request", "(", "self", ".", "uri", ")", "if", "self", ".", "server_data", ".", "authorization_header", "(", ")", "is", "not", "None", ":", "request", ".", "add_header...
Opens the URL associated with the GPFile and returns a file-like object with three extra methods: * geturl() - return the ultimate URL (can be used to determine if a redirect was followed) * info() - return the meta-information of the page, such as headers ...
[ "Opens", "the", "URL", "associated", "with", "the", "GPFile", "and", "returns", "a", "file", "-", "like", "object", "with", "three", "extra", "methods", ":" ]
python
train
42.352941
saltstack/salt
salt/modules/boto_s3_bucket.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3_bucket.py#L348-L373
def list(region=None, key=None, keyid=None, profile=None): ''' List all buckets owned by the authenticated sender of the request. Returns list of buckets CLI Example: .. code-block:: yaml Owner: {...} Buckets: - {...} - {...} ''' try: conn = _...
[ "def", "list", "(", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "try", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid", "=", ...
List all buckets owned by the authenticated sender of the request. Returns list of buckets CLI Example: .. code-block:: yaml Owner: {...} Buckets: - {...} - {...}
[ "List", "all", "buckets", "owned", "by", "the", "authenticated", "sender", "of", "the", "request", "." ]
python
train
26.153846
zyga/python-glibc
tempfile_ext.py
https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/tempfile_ext.py#L279-L315
def _get_default_tempdir(): """Calculate the default directory to use for temporary files. This routine should be called exactly once. We determine whether or not a candidate temp dir is usable by trying to create and write to a file in that directory. If this is successful, the test file is delet...
[ "def", "_get_default_tempdir", "(", ")", ":", "namer", "=", "_RandomNameSequence", "(", ")", "dirlist", "=", "_candidate_tempdir_list", "(", ")", "for", "dir", "in", "dirlist", ":", "if", "dir", "!=", "_os", ".", "curdir", ":", "dir", "=", "_os", ".", "p...
Calculate the default directory to use for temporary files. This routine should be called exactly once. We determine whether or not a candidate temp dir is usable by trying to create and write to a file in that directory. If this is successful, the test file is deleted. To prevent denial of servi...
[ "Calculate", "the", "default", "directory", "to", "use", "for", "temporary", "files", ".", "This", "routine", "should", "be", "called", "exactly", "once", "." ]
python
train
38.081081
timothycrosley/isort
isort/isort.py
https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/isort.py#L139-L143
def _get_line(self) -> str: """Returns the current line from the file while incrementing the index.""" line = self.in_lines[self.index] self.index += 1 return line
[ "def", "_get_line", "(", "self", ")", "->", "str", ":", "line", "=", "self", ".", "in_lines", "[", "self", ".", "index", "]", "self", ".", "index", "+=", "1", "return", "line" ]
Returns the current line from the file while incrementing the index.
[ "Returns", "the", "current", "line", "from", "the", "file", "while", "incrementing", "the", "index", "." ]
python
train
38.2
Kortemme-Lab/klab
klab/biblio/doi.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/biblio/doi.py#L398-L441
def to_dict(self): '''A representation of that publication data that matches the schema we use in our databases.''' if not self.record_type == 'journal': # todo: it may be worthwhile creating subclasses for each entry type (journal, conference, etc.) with a common # API e.g. to_j...
[ "def", "to_dict", "(", "self", ")", ":", "if", "not", "self", ".", "record_type", "==", "'journal'", ":", "# todo: it may be worthwhile creating subclasses for each entry type (journal, conference, etc.) with a common", "# API e.g. to_json which creates output appropriately", "raise"...
A representation of that publication data that matches the schema we use in our databases.
[ "A", "representation", "of", "that", "publication", "data", "that", "matches", "the", "schema", "we", "use", "in", "our", "databases", "." ]
python
train
41.727273
nephics/mat4py
mat4py/loadmat.py
https://github.com/nephics/mat4py/blob/6c1a2ad903937437cc5f24f3c3f5aa2c5a77a1c1/mat4py/loadmat.py#L94-L100
def diff(iterable): """Diff elements of a sequence: s -> s0 - s1, s1 - s2, s2 - s3, ... """ a, b = tee(iterable) next(b, None) return (i - j for i, j in izip(a, b))
[ "def", "diff", "(", "iterable", ")", ":", "a", ",", "b", "=", "tee", "(", "iterable", ")", "next", "(", "b", ",", "None", ")", "return", "(", "i", "-", "j", "for", "i", ",", "j", "in", "izip", "(", "a", ",", "b", ")", ")" ]
Diff elements of a sequence: s -> s0 - s1, s1 - s2, s2 - s3, ...
[ "Diff", "elements", "of", "a", "sequence", ":", "s", "-", ">", "s0", "-", "s1", "s1", "-", "s2", "s2", "-", "s3", "..." ]
python
valid
26
Microsoft/ApplicationInsights-Python
applicationinsights/channel/contracts/Device.py
https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/contracts/Device.py#L105-L114
def oem_name(self, value): """The oem_name property. Args: value (string). the property value. """ if value == self._defaults['ai.device.oemName'] and 'ai.device.oemName' in self._values: del self._values['ai.device.oemName'] else: sel...
[ "def", "oem_name", "(", "self", ",", "value", ")", ":", "if", "value", "==", "self", ".", "_defaults", "[", "'ai.device.oemName'", "]", "and", "'ai.device.oemName'", "in", "self", ".", "_values", ":", "del", "self", ".", "_values", "[", "'ai.device.oemName'"...
The oem_name property. Args: value (string). the property value.
[ "The", "oem_name", "property", ".", "Args", ":", "value", "(", "string", ")", ".", "the", "property", "value", "." ]
python
train
34.9
peri-source/peri
peri/opt/optimize.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L735-L777
def _run1(self): """workhorse for do_run_1""" if self.check_update_J(): self.update_J() else: if self.check_Broyden_J(): self.update_Broyden_J() if self.check_update_eig_J(): self.update_eig_J() #1. Assuming that J star...
[ "def", "_run1", "(", "self", ")", ":", "if", "self", ".", "check_update_J", "(", ")", ":", "self", ".", "update_J", "(", ")", "else", ":", "if", "self", ".", "check_Broyden_J", "(", ")", ":", "self", ".", "update_Broyden_J", "(", ")", "if", "self", ...
workhorse for do_run_1
[ "workhorse", "for", "do_run_1" ]
python
valid
41.465116
Azure/azure-storage-python
azure-storage-common/azure/storage/common/_http/httpclient.py
https://github.com/Azure/azure-storage-python/blob/52327354b192cbcf6b7905118ec6b5d57fa46275/azure-storage-common/azure/storage/common/_http/httpclient.py#L42-L66
def set_proxy(self, host, port, user, password): ''' Sets the proxy server host and port for the HTTP CONNECT Tunnelling. Note that we set the proxies directly on the request later on rather than using the session object as requests has a bug where session proxy is ignored in fa...
[ "def", "set_proxy", "(", "self", ",", "host", ",", "port", ",", "user", ",", "password", ")", ":", "if", "user", "and", "password", ":", "proxy_string", "=", "'{}:{}@{}:{}'", ".", "format", "(", "user", ",", "password", ",", "host", ",", "port", ")", ...
Sets the proxy server host and port for the HTTP CONNECT Tunnelling. Note that we set the proxies directly on the request later on rather than using the session object as requests has a bug where session proxy is ignored in favor of environment proxy. So, auth will not work unless it is passed ...
[ "Sets", "the", "proxy", "server", "host", "and", "port", "for", "the", "HTTP", "CONNECT", "Tunnelling", "." ]
python
train
41.48
projectatomic/osbs-client
osbs/build/plugins_configuration.py
https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L175-L187
def adjust_for_isolated(self): """ Remove certain plugins in order to handle the "isolated build" scenario. """ if self.user_params.isolated.value: remove_plugins = [ ("prebuild_plugins", "check_and_set_rebuild"), ("prebuild_plugins", "...
[ "def", "adjust_for_isolated", "(", "self", ")", ":", "if", "self", ".", "user_params", ".", "isolated", ".", "value", ":", "remove_plugins", "=", "[", "(", "\"prebuild_plugins\"", ",", "\"check_and_set_rebuild\"", ")", ",", "(", "\"prebuild_plugins\"", ",", "\"s...
Remove certain plugins in order to handle the "isolated build" scenario.
[ "Remove", "certain", "plugins", "in", "order", "to", "handle", "the", "isolated", "build", "scenario", "." ]
python
train
37.692308
django-fluent/django-fluent-comments
fluent_comments/moderation.py
https://github.com/django-fluent/django-fluent-comments/blob/bfe98d55b56fedd8ca2e2659eed53a6390e53adf/fluent_comments/moderation.py#L66-L104
def moderate(self, comment, content_object, request): """ Determine whether a given comment on a given object should be allowed to show up immediately, or should be marked non-public and await approval. Returns ``True`` if the comment should be moderated (marked non-public), ``False`` o...
[ "def", "moderate", "(", "self", ",", "comment", ",", "content_object", ",", "request", ")", ":", "# Soft delete checks are done first, so these comments are not mistakenly \"just moderated\"", "# for expiring the `close_after` date, but correctly get marked as spam instead.", "# This hel...
Determine whether a given comment on a given object should be allowed to show up immediately, or should be marked non-public and await approval. Returns ``True`` if the comment should be moderated (marked non-public), ``False`` otherwise.
[ "Determine", "whether", "a", "given", "comment", "on", "a", "given", "object", "should", "be", "allowed", "to", "show", "up", "immediately", "or", "should", "be", "marked", "non", "-", "public", "and", "await", "approval", "." ]
python
train
47.666667
gwastro/pycbc-glue
pycbc_glue/ligolw/dbtables.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/dbtables.py#L164-L183
def uninstall_signal_trap(signums = None): """ Undo the effects of install_signal_trap(). Restores the original signal handlers. If signums is a sequence of signal numbers only the signal handlers for those signals will be restored (KeyError will be raised if one of them is not one that install_signal_trap() in...
[ "def", "uninstall_signal_trap", "(", "signums", "=", "None", ")", ":", "# NOTE: this must be called with the temporary_files_lock held.", "if", "signums", "is", "None", ":", "signums", "=", "origactions", ".", "keys", "(", ")", "for", "signum", "in", "signums", ":"...
Undo the effects of install_signal_trap(). Restores the original signal handlers. If signums is a sequence of signal numbers only the signal handlers for those signals will be restored (KeyError will be raised if one of them is not one that install_signal_trap() installed a handler for, in which case some undefin...
[ "Undo", "the", "effects", "of", "install_signal_trap", "()", ".", "Restores", "the", "original", "signal", "handlers", ".", "If", "signums", "is", "a", "sequence", "of", "signal", "numbers", "only", "the", "signal", "handlers", "for", "those", "signals", "will...
python
train
45.5
cakebread/yolk
yolk/cli.py
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L236-L279
def show_updates(self): """ Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None """ di...
[ "def", "show_updates", "(", "self", ")", ":", "dists", "=", "Distributions", "(", ")", "if", "self", ".", "project_name", ":", "#Check for a single package", "pkg_list", "=", "[", "self", ".", "project_name", "]", "else", ":", "#Check for every installed package",...
Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None
[ "Check", "installed", "packages", "for", "available", "updates", "on", "PyPI" ]
python
train
39.386364
guillermo-carrasco/bcbio-nextgen-monitor
bcbio_monitor/analysis/__init__.py
https://github.com/guillermo-carrasco/bcbio-nextgen-monitor/blob/6d059154d774140e1fd03a0e3625f607cef06f5a/bcbio_monitor/analysis/__init__.py#L155-L163
def update_frontend(self, info): """Updates frontend with info from the log :param info: dict - Information from a line in the log. i.e regular line, new step. """ headers = {'Content-Type': 'text/event-stream'} if info.get('when'): info['when'] = info['when'].isofor...
[ "def", "update_frontend", "(", "self", ",", "info", ")", ":", "headers", "=", "{", "'Content-Type'", ":", "'text/event-stream'", "}", "if", "info", ".", "get", "(", "'when'", ")", ":", "info", "[", "'when'", "]", "=", "info", "[", "'when'", "]", ".", ...
Updates frontend with info from the log :param info: dict - Information from a line in the log. i.e regular line, new step.
[ "Updates", "frontend", "with", "info", "from", "the", "log" ]
python
train
45.222222
apache/incubator-superset
superset/models/core.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/core.py#L933-L938
def all_table_names_in_database(self, cache=False, cache_timeout=None, force=False): """Parameters need to be passed as keyword arguments.""" if not self.allow_multi_schema_metadata_fetch: return [] return self.db_engine_spec.fetch_result_sets(self...
[ "def", "all_table_names_in_database", "(", "self", ",", "cache", "=", "False", ",", "cache_timeout", "=", "None", ",", "force", "=", "False", ")", ":", "if", "not", "self", ".", "allow_multi_schema_metadata_fetch", ":", "return", "[", "]", "return", "self", ...
Parameters need to be passed as keyword arguments.
[ "Parameters", "need", "to", "be", "passed", "as", "keyword", "arguments", "." ]
python
train
54.166667
twilio/twilio-python
twilio/rest/preview/bulk_exports/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/bulk_exports/__init__.py#L38-L44
def export_configuration(self): """ :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationList """ if self._export_configuration is None: self._export_configuration = ExportConfigurationList(self) return self._export_configuration
[ "def", "export_configuration", "(", "self", ")", ":", "if", "self", ".", "_export_configuration", "is", "None", ":", "self", ".", "_export_configuration", "=", "ExportConfigurationList", "(", "self", ")", "return", "self", ".", "_export_configuration" ]
:rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationList
[ ":", "rtype", ":", "twilio", ".", "rest", ".", "preview", ".", "bulk_exports", ".", "export_configuration", ".", "ExportConfigurationList" ]
python
train
43.285714
OCA/odoorpc
odoorpc/fields.py
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L612-L625
def _check_relation(self, relation): """Raise a `ValueError` if `relation` is not allowed among the possible values. """ selection = [val[0] for val in self.selection] if relation not in selection: raise ValueError( ("The value '{value}' supplied doesn...
[ "def", "_check_relation", "(", "self", ",", "relation", ")", ":", "selection", "=", "[", "val", "[", "0", "]", "for", "val", "in", "self", ".", "selection", "]", "if", "relation", "not", "in", "selection", ":", "raise", "ValueError", "(", "(", "\"The v...
Raise a `ValueError` if `relation` is not allowed among the possible values.
[ "Raise", "a", "ValueError", "if", "relation", "is", "not", "allowed", "among", "the", "possible", "values", "." ]
python
train
41.357143
welbornprod/colr
colr/controls.py
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L244-L271
def print_inplace(*args, **kwargs): """ Save cursor position, write some text, and then restore the position. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in s...
[ "def", "print_inplace", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'file'", ",", "sys", ".", "stdout", ")", "kwargs", ".", "setdefault", "(", "'end'", ",", "''", ")", "pos_save", "(", "file", "=", "kwargs"...
Save cursor position, write some text, and then restore the position. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in seconds between character writes.
[ "Save", "cursor", "position", "write", "some", "text", "and", "then", "restore", "the", "position", ".", "Arguments", ":", "Same", "as", "print", "()", "." ]
python
train
32.928571
blackecho/Deep-Learning-TensorFlow
yadlt/models/recurrent/lstm.py
https://github.com/blackecho/Deep-Learning-TensorFlow/blob/ddeb1f2848da7b7bee166ad2152b4afc46bb2086/yadlt/models/recurrent/lstm.py#L105-L113
def build_model(self): """Build the model's computational graph.""" with tf.variable_scope( "model", reuse=None, initializer=self.initializer): self._create_placeholders() self._create_rnn_cells() self._create_initstate_and_embeddings() sel...
[ "def", "build_model", "(", "self", ")", ":", "with", "tf", ".", "variable_scope", "(", "\"model\"", ",", "reuse", "=", "None", ",", "initializer", "=", "self", ".", "initializer", ")", ":", "self", ".", "_create_placeholders", "(", ")", "self", ".", "_cr...
Build the model's computational graph.
[ "Build", "the", "model", "s", "computational", "graph", "." ]
python
train
42.444444
mickybart/python-atlasbroker
atlasbroker/service.py
https://github.com/mickybart/python-atlasbroker/blob/5b741c1348a6d33b342e0852a8a8900fa9ebf00a/atlasbroker/service.py#L95-L114
def unbind(self, instance_id: str, binding_id: str, details: UnbindDetails): """Unbinding the instance see openbrokerapi documentation Raises: ErrBindingDoesNotExist: Binding does not exist. """ # Find the instance instance = self._b...
[ "def", "unbind", "(", "self", ",", "instance_id", ":", "str", ",", "binding_id", ":", "str", ",", "details", ":", "UnbindDetails", ")", ":", "# Find the instance", "instance", "=", "self", ".", "_backend", ".", "find", "(", "instance_id", ")", "# Find the bi...
Unbinding the instance see openbrokerapi documentation Raises: ErrBindingDoesNotExist: Binding does not exist.
[ "Unbinding", "the", "instance", "see", "openbrokerapi", "documentation", "Raises", ":", "ErrBindingDoesNotExist", ":", "Binding", "does", "not", "exist", "." ]
python
train
31
radujica/baloo
baloo/io/csv.py
https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/io/csv.py#L56-L86
def to_csv(df, filepath, sep=',', header=True, index=True): """Save DataFrame as csv. Note data is expected to be evaluated. Currently delegates to Pandas. Parameters ---------- df : DataFrame filepath : str sep : str, optional Separator used between values. header : bool,...
[ "def", "to_csv", "(", "df", ",", "filepath", ",", "sep", "=", "','", ",", "header", "=", "True", ",", "index", "=", "True", ")", ":", "df", ".", "to_pandas", "(", ")", ".", "to_csv", "(", "filepath", ",", "sep", "=", "sep", ",", "header", "=", ...
Save DataFrame as csv. Note data is expected to be evaluated. Currently delegates to Pandas. Parameters ---------- df : DataFrame filepath : str sep : str, optional Separator used between values. header : bool, optional Whether to save the header. index : bool, opt...
[ "Save", "DataFrame", "as", "csv", "." ]
python
train
23.870968
hardbyte/python-can
can/interfaces/usb2can/serial_selector.py
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/usb2can/serial_selector.py#L32-L45
def find_serial_devices(serial_matcher="ED"): """ Finds a list of USB devices where the serial number (partially) matches the given string. :param str serial_matcher (optional): only device IDs starting with this string are returned :rtype: List[str] """ objWMIService = win32com.client...
[ "def", "find_serial_devices", "(", "serial_matcher", "=", "\"ED\"", ")", ":", "objWMIService", "=", "win32com", ".", "client", ".", "Dispatch", "(", "\"WbemScripting.SWbemLocator\"", ")", "objSWbemServices", "=", "objWMIService", ".", "ConnectServer", "(", "\".\"", ...
Finds a list of USB devices where the serial number (partially) matches the given string. :param str serial_matcher (optional): only device IDs starting with this string are returned :rtype: List[str]
[ "Finds", "a", "list", "of", "USB", "devices", "where", "the", "serial", "number", "(", "partially", ")", "matches", "the", "given", "string", "." ]
python
train
44.214286
tdryer/hangups
hangups/conversation_event.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/conversation_event.py#L123-L141
def serialize(self): """Serialize this segment to a ``Segment`` message. Returns: ``Segment`` message. """ segment = hangouts_pb2.Segment( type=self.type_, text=self.text, formatting=hangouts_pb2.Formatting( bold=self.is_bo...
[ "def", "serialize", "(", "self", ")", ":", "segment", "=", "hangouts_pb2", ".", "Segment", "(", "type", "=", "self", ".", "type_", ",", "text", "=", "self", ".", "text", ",", "formatting", "=", "hangouts_pb2", ".", "Formatting", "(", "bold", "=", "self...
Serialize this segment to a ``Segment`` message. Returns: ``Segment`` message.
[ "Serialize", "this", "segment", "to", "a", "Segment", "message", "." ]
python
valid
31.157895
Dentosal/python-sc2
sc2/units.py
https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/units.py#L117-L124
def closest_distance_to(self, position: Union[Unit, Point2, Point3]) -> Union[int, float]: """ Returns the distance between the closest unit from this group to the target unit """ assert self.exists if isinstance(position, Unit): position = position.position return position.d...
[ "def", "closest_distance_to", "(", "self", ",", "position", ":", "Union", "[", "Unit", ",", "Point2", ",", "Point3", "]", ")", "->", "Union", "[", "int", ",", "float", "]", ":", "assert", "self", ".", "exists", "if", "isinstance", "(", "position", ",",...
Returns the distance between the closest unit from this group to the target unit
[ "Returns", "the", "distance", "between", "the", "closest", "unit", "from", "this", "group", "to", "the", "target", "unit" ]
python
train
47.625
pydata/xarray
xarray/core/groupby.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L448-L451
def first(self, skipna=None, keep_attrs=None): """Return the first element of each group along the group dimension """ return self._first_or_last(duck_array_ops.first, skipna, keep_attrs)
[ "def", "first", "(", "self", ",", "skipna", "=", "None", ",", "keep_attrs", "=", "None", ")", ":", "return", "self", ".", "_first_or_last", "(", "duck_array_ops", ".", "first", ",", "skipna", ",", "keep_attrs", ")" ]
Return the first element of each group along the group dimension
[ "Return", "the", "first", "element", "of", "each", "group", "along", "the", "group", "dimension" ]
python
train
52
Yelp/kafka-utils
kafka_utils/util/validation.py
https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/validation.py#L36-L47
def assignment_to_plan(assignment): """Convert an assignment to the format used by Kafka to describe a reassignment plan. """ return { 'version': 1, 'partitions': [{'topic': t_p[0], 'partition': t_p[1], 'replicas': replica } for t_p, replica in six.i...
[ "def", "assignment_to_plan", "(", "assignment", ")", ":", "return", "{", "'version'", ":", "1", ",", "'partitions'", ":", "[", "{", "'topic'", ":", "t_p", "[", "0", "]", ",", "'partition'", ":", "t_p", "[", "1", "]", ",", "'replicas'", ":", "replica", ...
Convert an assignment to the format used by Kafka to describe a reassignment plan.
[ "Convert", "an", "assignment", "to", "the", "format", "used", "by", "Kafka", "to", "describe", "a", "reassignment", "plan", "." ]
python
train
28
chaoss/grimoirelab-elk
grimoire_elk/raw/elastic.py
https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/elastic.py#L147-L153
def add_update_date(self, item): """ All item['updated_on'] from perceval is epoch """ updated = unixtime_to_datetime(item['updated_on']) timestamp = unixtime_to_datetime(item['timestamp']) item['metadata__updated_on'] = updated.isoformat() # Also add timestamp used in incrementa...
[ "def", "add_update_date", "(", "self", ",", "item", ")", ":", "updated", "=", "unixtime_to_datetime", "(", "item", "[", "'updated_on'", "]", ")", "timestamp", "=", "unixtime_to_datetime", "(", "item", "[", "'timestamp'", "]", ")", "item", "[", "'metadata__upda...
All item['updated_on'] from perceval is epoch
[ "All", "item", "[", "updated_on", "]", "from", "perceval", "is", "epoch" ]
python
train
55.142857
DLR-RM/RAFCON
source/rafcon/gui/utils/shell_execution.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/utils/shell_execution.py#L8-L29
def execute_command_with_path_in_process(command, path, shell=False, cwd=None, logger=None): """Executes a specific command in a separate process with a path as argument. :param command: the command to be executed :param path: the path as first argument to the shell command :param bool shell: Whether t...
[ "def", "execute_command_with_path_in_process", "(", "command", ",", "path", ",", "shell", "=", "False", ",", "cwd", "=", "None", ",", "logger", "=", "None", ")", ":", "if", "logger", "is", "None", ":", "logger", "=", "_logger", "logger", ".", "debug", "(...
Executes a specific command in a separate process with a path as argument. :param command: the command to be executed :param path: the path as first argument to the shell command :param bool shell: Whether to use a shell :param str cwd: The working directory of the command :param logger: optional l...
[ "Executes", "a", "specific", "command", "in", "a", "separate", "process", "with", "a", "path", "as", "argument", "." ]
python
train
45.181818
geronimp/graftM
graftm/orfm.py
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/orfm.py#L11-L33
def command_line(self, input_path=None): '''Return a string to run OrfM with, assuming sequences are incoming on stdin and printed to stdout Parameters ---------- input_path: str path to the input path, or None for STDIN being the input ''' ...
[ "def", "command_line", "(", "self", ",", "input_path", "=", "None", ")", ":", "if", "self", ".", "min_orf_length", ":", "orfm_arg_l", "=", "\" -m %d\"", "%", "self", ".", "min_orf_length", "else", ":", "orfm_arg_l", "=", "''", "if", "self", ".", "restrict_...
Return a string to run OrfM with, assuming sequences are incoming on stdin and printed to stdout Parameters ---------- input_path: str path to the input path, or None for STDIN being the input
[ "Return", "a", "string", "to", "run", "OrfM", "with", "assuming", "sequences", "are", "incoming", "on", "stdin", "and", "printed", "to", "stdout", "Parameters", "----------", "input_path", ":", "str", "path", "to", "the", "input", "path", "or", "None", "for"...
python
train
30.956522
angr/angr
angr/analyses/cfg/cfb.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/cfg/cfb.py#L181-L212
def dbg_repr(self): """ The debugging representation of this CFBlanket. :return: The debugging representation of this CFBlanket. :rtype: str """ output = [ ] for obj in self.project.loader.all_objects: for section in obj.sections: ...
[ "def", "dbg_repr", "(", "self", ")", ":", "output", "=", "[", "]", "for", "obj", "in", "self", ".", "project", ".", "loader", ".", "all_objects", ":", "for", "section", "in", "obj", ".", "sections", ":", "if", "section", ".", "memsize", "==", "0", ...
The debugging representation of this CFBlanket. :return: The debugging representation of this CFBlanket. :rtype: str
[ "The", "debugging", "representation", "of", "this", "CFBlanket", "." ]
python
train
31.9375
limpyd/redis-limpyd-jobs
limpyd_jobs/workers.py
https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L751-L800
def manage_options(self): """ Create a parser given the command-line arguments, creates a parser Return True if the programme must exit. """ self.parser = self.create_parser() self.options, self.args = self.parser.parse_args(self.argv) self.do_imports() ...
[ "def", "manage_options", "(", "self", ")", ":", "self", ".", "parser", "=", "self", ".", "create_parser", "(", ")", "self", ".", "options", ",", "self", ".", "args", "=", "self", ".", "parser", ".", "parse_args", "(", "self", ".", "argv", ")", "self"...
Create a parser given the command-line arguments, creates a parser Return True if the programme must exit.
[ "Create", "a", "parser", "given", "the", "command", "-", "line", "arguments", "creates", "a", "parser", "Return", "True", "if", "the", "programme", "must", "exit", "." ]
python
train
53.48
NoneGG/aredis
aredis/commands/lists.py
https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/lists.py#L139-L147
async def ltrim(self, name, start, end): """ Trim the list ``name``, removing all values not within the slice between ``start`` and ``end`` ``start`` and ``end`` can be negative numbers just like Python slicing notation """ return await self.execute_command('LTRI...
[ "async", "def", "ltrim", "(", "self", ",", "name", ",", "start", ",", "end", ")", ":", "return", "await", "self", ".", "execute_command", "(", "'LTRIM'", ",", "name", ",", "start", ",", "end", ")" ]
Trim the list ``name``, removing all values not within the slice between ``start`` and ``end`` ``start`` and ``end`` can be negative numbers just like Python slicing notation
[ "Trim", "the", "list", "name", "removing", "all", "values", "not", "within", "the", "slice", "between", "start", "and", "end" ]
python
train
37
jamescooke/flake8-aaa
src/flake8_aaa/helpers.py
https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/helpers.py#L188-L197
def find_stringy_lines(tree: ast.AST, first_line_no: int) -> Set[int]: """ Finds all lines that contain a string in a tree, usually a function. These lines will be ignored when searching for blank lines. """ str_footprints = set() for node in ast.walk(tree): if isinstance(node, ast.Str):...
[ "def", "find_stringy_lines", "(", "tree", ":", "ast", ".", "AST", ",", "first_line_no", ":", "int", ")", "->", "Set", "[", "int", "]", ":", "str_footprints", "=", "set", "(", ")", "for", "node", "in", "ast", ".", "walk", "(", "tree", ")", ":", "if"...
Finds all lines that contain a string in a tree, usually a function. These lines will be ignored when searching for blank lines.
[ "Finds", "all", "lines", "that", "contain", "a", "string", "in", "a", "tree", "usually", "a", "function", ".", "These", "lines", "will", "be", "ignored", "when", "searching", "for", "blank", "lines", "." ]
python
train
40.9
OSSOS/MOP
src/ossos/core/ossos/util.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/util.py#L87-L98
def stream(self): """ the stream to write the log content too. @return: """ if self._stream is None: self._stream = tempfile.NamedTemporaryFile(delete=False) try: self._stream.write(self.client.open(self.filename, view='data').read()) ...
[ "def", "stream", "(", "self", ")", ":", "if", "self", ".", "_stream", "is", "None", ":", "self", ".", "_stream", "=", "tempfile", ".", "NamedTemporaryFile", "(", "delete", "=", "False", ")", "try", ":", "self", ".", "_stream", ".", "write", "(", "sel...
the stream to write the log content too. @return:
[ "the", "stream", "to", "write", "the", "log", "content", "too", "." ]
python
train
30.833333
Crunch-io/crunch-cube
src/cr/cube/crunch_cube.py
https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/crunch_cube.py#L189-L198
def index(self, weighted=True, prune=False): """Return cube index measurement. This function is deprecated. Use index_table from CubeSlice. """ warnings.warn( "CrunchCube.index() is deprecated. Use CubeSlice.index_table().", DeprecationWarning, ) ...
[ "def", "index", "(", "self", ",", "weighted", "=", "True", ",", "prune", "=", "False", ")", ":", "warnings", ".", "warn", "(", "\"CrunchCube.index() is deprecated. Use CubeSlice.index_table().\"", ",", "DeprecationWarning", ",", ")", "return", "Index", ".", "data"...
Return cube index measurement. This function is deprecated. Use index_table from CubeSlice.
[ "Return", "cube", "index", "measurement", "." ]
python
train
35.1
pywavefront/PyWavefront
pywavefront/parser.py
https://github.com/pywavefront/PyWavefront/blob/39ee5186cb37750d4654d19ebe43f723ecd01e2f/pywavefront/parser.py#L104-L107
def next_line(self): """Read the next line from the line generator and split it""" self.line = next(self.lines) # Will raise StopIteration when there are no more lines self.values = self.line.split()
[ "def", "next_line", "(", "self", ")", ":", "self", ".", "line", "=", "next", "(", "self", ".", "lines", ")", "# Will raise StopIteration when there are no more lines", "self", ".", "values", "=", "self", ".", "line", ".", "split", "(", ")" ]
Read the next line from the line generator and split it
[ "Read", "the", "next", "line", "from", "the", "line", "generator", "and", "split", "it" ]
python
train
55.25
senaite/senaite.core
bika/lims/browser/publish/emailview.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/publish/emailview.py#L468-L506
def get_responsibles_data(self, reports): """Responsibles data to be used in the template """ if not reports: return [] recipients = [] recipient_names = [] for num, report in enumerate(reports): # get the linked AR of this ARReport a...
[ "def", "get_responsibles_data", "(", "self", ",", "reports", ")", ":", "if", "not", "reports", ":", "return", "[", "]", "recipients", "=", "[", "]", "recipient_names", "=", "[", "]", "for", "num", ",", "report", "in", "enumerate", "(", "reports", ")", ...
Responsibles data to be used in the template
[ "Responsibles", "data", "to", "be", "used", "in", "the", "template" ]
python
train
36.820513
singnet/snet-cli
snet_cli/utils_config.py
https://github.com/singnet/snet-cli/blob/1b5ac98cb9a64211c861ead9fcfe6208f2749032/snet_cli/utils_config.py#L48-L62
def get_field_from_args_or_session(config, args, field_name): """ We try to get field_name from diffent sources: The order of priorioty is following: - command line argument (--<field_name>) - current session configuration (default_<filed_name>) """ rez = getattr(args, field_name, None) ...
[ "def", "get_field_from_args_or_session", "(", "config", ",", "args", ",", "field_name", ")", ":", "rez", "=", "getattr", "(", "args", ",", "field_name", ",", "None", ")", "#type(rez) can be int in case of wallet-index, so we cannot make simply if(rez)", "if", "(", "rez"...
We try to get field_name from diffent sources: The order of priorioty is following: - command line argument (--<field_name>) - current session configuration (default_<filed_name>)
[ "We", "try", "to", "get", "field_name", "from", "diffent", "sources", ":", "The", "order", "of", "priorioty", "is", "following", ":", "-", "command", "line", "argument", "(", "--", "<field_name", ">", ")", "-", "current", "session", "configuration", "(", "...
python
train
46.6
secynic/ipwhois
ipwhois/utils.py
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/utils.py#L609-L631
def ipv6_generate_random(total=100): """ The generator to produce random, unique IPv6 addresses that are not defined (can be looked up using ipwhois). Args: total (:obj:`int`): The total number of IPv6 addresses to generate. Yields: str: The next IPv6 address. """ count = ...
[ "def", "ipv6_generate_random", "(", "total", "=", "100", ")", ":", "count", "=", "0", "yielded", "=", "set", "(", ")", "while", "count", "<", "total", ":", "address", "=", "str", "(", "IPv6Address", "(", "random", ".", "randint", "(", "0", ",", "2", ...
The generator to produce random, unique IPv6 addresses that are not defined (can be looked up using ipwhois). Args: total (:obj:`int`): The total number of IPv6 addresses to generate. Yields: str: The next IPv6 address.
[ "The", "generator", "to", "produce", "random", "unique", "IPv6", "addresses", "that", "are", "not", "defined", "(", "can", "be", "looked", "up", "using", "ipwhois", ")", "." ]
python
train
24.521739
mitsei/dlkit
dlkit/json_/commenting/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/commenting/managers.py#L405-L420
def get_comment_book_assignment_session(self): """Gets the session for assigning comment to book mappings. return: (osid.commenting.CommentBookAssignmentSession) - a ``CommentBookAssignmentSession`` raise: OperationFailed - unable to complete request raise: Unimplement...
[ "def", "get_comment_book_assignment_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_comment_book_assignment", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "CommentBookA...
Gets the session for assigning comment to book mappings. return: (osid.commenting.CommentBookAssignmentSession) - a ``CommentBookAssignmentSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_comment_book_assignment()`` ...
[ "Gets", "the", "session", "for", "assigning", "comment", "to", "book", "mappings", "." ]
python
train
45.5
brechtm/rinohtype
src/rinoh/text.py
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/text.py#L329-L340
def font(self, container): """The :class:`Font` described by this single-styled text's style. If the exact font style as described by the `font_weight`, `font_slant` and `font_width` style attributes is not present in the `typeface`, the closest font available is returned instead, and a...
[ "def", "font", "(", "self", ",", "container", ")", ":", "typeface", "=", "self", ".", "get_style", "(", "'typeface'", ",", "container", ")", "weight", "=", "self", ".", "get_style", "(", "'font_weight'", ",", "container", ")", "slant", "=", "self", ".", ...
The :class:`Font` described by this single-styled text's style. If the exact font style as described by the `font_weight`, `font_slant` and `font_width` style attributes is not present in the `typeface`, the closest font available is returned instead, and a warning is printed.
[ "The", ":", "class", ":", "Font", "described", "by", "this", "single", "-", "styled", "text", "s", "style", "." ]
python
train
53.416667
cgrok/cr-async
crasync/models.py
https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L344-L351
def clan_badge_url(self): '''Returns clan badge url''' if self.clan_tag is None: return None url = self.raw_data.get('clan').get('badge').get('url') if not url: return None return "http://api.cr-api.com" + url
[ "def", "clan_badge_url", "(", "self", ")", ":", "if", "self", ".", "clan_tag", "is", "None", ":", "return", "None", "url", "=", "self", ".", "raw_data", ".", "get", "(", "'clan'", ")", ".", "get", "(", "'badge'", ")", ".", "get", "(", "'url'", ")",...
Returns clan badge url
[ "Returns", "clan", "badge", "url" ]
python
train
33.25
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L190-L210
def str_to_v1_str(xml_str): """Convert a API v2 XML doc to v1 XML doc. Removes elements that are only valid for v2 and changes namespace to v1. If doc is already v1, it is returned unchanged. Args: xml_str : str API v2 XML doc. E.g.: ``SystemMetadata v2``. Returns: str : API ...
[ "def", "str_to_v1_str", "(", "xml_str", ")", ":", "if", "str_is_v1", "(", "xml_str", ")", ":", "return", "xml_str", "etree_obj", "=", "str_to_etree", "(", "xml_str", ")", "strip_v2_elements", "(", "etree_obj", ")", "etree_replace_namespace", "(", "etree_obj", ",...
Convert a API v2 XML doc to v1 XML doc. Removes elements that are only valid for v2 and changes namespace to v1. If doc is already v1, it is returned unchanged. Args: xml_str : str API v2 XML doc. E.g.: ``SystemMetadata v2``. Returns: str : API v1 XML doc. E.g.: ``SystemMetadata ...
[ "Convert", "a", "API", "v2", "XML", "doc", "to", "v1", "XML", "doc", "." ]
python
train
27.952381
meejah/txtorcon
txtorcon/circuit.py
https://github.com/meejah/txtorcon/blob/14053b95adf0b4bd9dd9c317bece912a26578a93/txtorcon/circuit.py#L346-L383
def close(self, **kw): """ This asks Tor to close the underlying circuit object. See :meth:`txtorcon.torstate.TorState.close_circuit` for details. You may pass keyword arguments to take care of any Flags Tor accepts for the CLOSECIRCUIT command. Currently, this is only ...
[ "def", "close", "(", "self", ",", "*", "*", "kw", ")", ":", "# we're already closed; nothing to do", "if", "self", ".", "state", "==", "'CLOSED'", ":", "return", "defer", ".", "succeed", "(", "None", ")", "# someone already called close() but we're not closed yet", ...
This asks Tor to close the underlying circuit object. See :meth:`txtorcon.torstate.TorState.close_circuit` for details. You may pass keyword arguments to take care of any Flags Tor accepts for the CLOSECIRCUIT command. Currently, this is only "IfUnused". So for example: circ.clo...
[ "This", "asks", "Tor", "to", "close", "the", "underlying", "circuit", "object", ".", "See", ":", "meth", ":", "txtorcon", ".", "torstate", ".", "TorState", ".", "close_circuit", "for", "details", "." ]
python
train
34.763158
QInfer/python-qinfer
src/qinfer/abstract_model.py
https://github.com/QInfer/python-qinfer/blob/8170c84a0be1723f8c6b09e0d3c7a40a886f1fe3/src/qinfer/abstract_model.py#L218-L239
def are_expparam_dtypes_consistent(self, expparams): """ Returns ``True`` iff all of the given expparams correspond to outcome domains with the same dtype. For efficiency, concrete subclasses should override this method if the result is always ``True``. :param np.ndarr...
[ "def", "are_expparam_dtypes_consistent", "(", "self", ",", "expparams", ")", ":", "if", "self", ".", "is_n_outcomes_constant", ":", "# This implies that all domains are equal, so this must be true", "return", "True", "# otherwise we have to actually check all the dtypes", "if", "...
Returns ``True`` iff all of the given expparams correspond to outcome domains with the same dtype. For efficiency, concrete subclasses should override this method if the result is always ``True``. :param np.ndarray expparams: Array of expparamms of type ``expparams_dtype...
[ "Returns", "True", "iff", "all", "of", "the", "given", "expparams", "correspond", "to", "outcome", "domains", "with", "the", "same", "dtype", ".", "For", "efficiency", "concrete", "subclasses", "should", "override", "this", "method", "if", "the", "result", "is...
python
train
38.545455
soasme/rio-client
rio_client/contrib/flask.py
https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/contrib/flask.py#L111-L123
def current(self): """A namedtuple contains `uuid`, `project`, `action`. Example:: @app.route('/webhook/broadcast-news') def broadcast_news(): if rio.current.action.startswith('news-'): broadcast(request.get_json()) """ event ...
[ "def", "current", "(", "self", ")", ":", "event", "=", "request", ".", "headers", ".", "get", "(", "'X-RIO-EVENT'", ")", "data", "=", "dict", "(", "[", "elem", ".", "split", "(", "'='", ")", "for", "elem", "in", "event", ".", "split", "(", "','", ...
A namedtuple contains `uuid`, `project`, `action`. Example:: @app.route('/webhook/broadcast-news') def broadcast_news(): if rio.current.action.startswith('news-'): broadcast(request.get_json())
[ "A", "namedtuple", "contains", "uuid", "project", "action", "." ]
python
train
34.076923
3DLIRIOUS/MeshLabXML
meshlabxml/mlx.py
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/mlx.py#L270-L316
def handle_error(program_name, cmd, log=None): """Subprocess program error handling Args: program_name (str): name of the subprocess program Returns: break_now (bool): indicate whether calling program should break out of loop """ print('\nHouston, we have a problem.', '\...
[ "def", "handle_error", "(", "program_name", ",", "cmd", ",", "log", "=", "None", ")", ":", "print", "(", "'\\nHouston, we have a problem.'", ",", "'\\n%s did not finish successfully. Review the log'", "%", "program_name", ",", "'file and the input file(s) to see what went wro...
Subprocess program error handling Args: program_name (str): name of the subprocess program Returns: break_now (bool): indicate whether calling program should break out of loop
[ "Subprocess", "program", "error", "handling" ]
python
test
35.234043
pushyzheng/flask-rabbitmq
example/consumer/flask_rabbitmq/RabbitMQ.py
https://github.com/pushyzheng/flask-rabbitmq/blob/beecefdf7bb6ff0892388e2bc303aa96931588bd/example/consumer/flask_rabbitmq/RabbitMQ.py#L147-L180
def send_sync(self, body, exchange, key): """ 发送并同步接受回复消息 :return: """ callback_queue = self.declare_queue(exclusive=True, auto_delete=True) # 得到随机回调队列名 self._channel.basic_consume(self.on_response, # 客户端消费回调队列 ...
[ "def", "send_sync", "(", "self", ",", "body", ",", "exchange", ",", "key", ")", ":", "callback_queue", "=", "self", ".", "declare_queue", "(", "exclusive", "=", "True", ",", "auto_delete", "=", "True", ")", "# 得到随机回调队列名", "self", ".", "_channel", ".", "b...
发送并同步接受回复消息 :return:
[ "发送并同步接受回复消息", ":", "return", ":" ]
python
train
34.205882
rbarrois/xworkflows
src/xworkflows/base.py
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L988-L990
def _add_workflow(mcs, field_name, state_field, attrs): """Attach a workflow to the attribute list (create a StateProperty).""" attrs[field_name] = StateProperty(state_field.workflow, field_name)
[ "def", "_add_workflow", "(", "mcs", ",", "field_name", ",", "state_field", ",", "attrs", ")", ":", "attrs", "[", "field_name", "]", "=", "StateProperty", "(", "state_field", ".", "workflow", ",", "field_name", ")" ]
Attach a workflow to the attribute list (create a StateProperty).
[ "Attach", "a", "workflow", "to", "the", "attribute", "list", "(", "create", "a", "StateProperty", ")", "." ]
python
train
69.666667
blockstack/blockstack-core
blockstack/lib/operations/transfer.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/transfer.py#L87-L146
def find_transfer_consensus_hash( name_rec, block_id, vtxindex, nameop_consensus_hash ): """ Given a name record, find the last consensus hash set by a non-NAME_TRANSFER operation. @name_rec is the current name record, before this NAME_TRANSFER. @block_id is the current block height. @vtxindex is t...
[ "def", "find_transfer_consensus_hash", "(", "name_rec", ",", "block_id", ",", "vtxindex", ",", "nameop_consensus_hash", ")", ":", "# work backwards from the last block", "for", "historic_block_number", "in", "reversed", "(", "sorted", "(", "name_rec", "[", "'history'", ...
Given a name record, find the last consensus hash set by a non-NAME_TRANSFER operation. @name_rec is the current name record, before this NAME_TRANSFER. @block_id is the current block height. @vtxindex is the relative index of this transaction in this block. @nameop_consensus_hash is the consensus hash...
[ "Given", "a", "name", "record", "find", "the", "last", "consensus", "hash", "set", "by", "a", "non", "-", "NAME_TRANSFER", "operation", "." ]
python
train
76.4
NaPs/Kolekto
kolekto/printer.py
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/printer.py#L263-L274
def ask(self, question, default=False): """ Ask a y/n question to the user. """ choices = '[%s/%s]' % ('Y' if default else 'y', 'n' if default else 'N') while True: response = raw_input('%s %s' % (question, choices)).strip() if not response: return...
[ "def", "ask", "(", "self", ",", "question", ",", "default", "=", "False", ")", ":", "choices", "=", "'[%s/%s]'", "%", "(", "'Y'", "if", "default", "else", "'y'", ",", "'n'", "if", "default", "else", "'N'", ")", "while", "True", ":", "response", "=", ...
Ask a y/n question to the user.
[ "Ask", "a", "y", "/", "n", "question", "to", "the", "user", "." ]
python
train
37.166667
JustinLovinger/optimal
optimal/algorithms/genalg.py
https://github.com/JustinLovinger/optimal/blob/ab48a4961697338cc32d50e3a6b06ac989e39c3f/optimal/algorithms/genalg.py#L109-L144
def _new_population_genalg(population, fitnesses, mutation_chance=0.02, crossover_chance=0.7, selection_function=gaoperators.tournament_selection, crossover_function=gaoperators.one_poi...
[ "def", "_new_population_genalg", "(", "population", ",", "fitnesses", ",", "mutation_chance", "=", "0.02", ",", "crossover_chance", "=", "0.7", ",", "selection_function", "=", "gaoperators", ".", "tournament_selection", ",", "crossover_function", "=", "gaoperators", "...
Perform all genetic algorithm operations on a population, and return a new population. population must have an even number of chromosomes. Args: population: A list of binary lists, ex. [[0,1,1,0], [1,0,1,0]] fitness: A list of fitnesses that correspond with chromosomes in the population, ...
[ "Perform", "all", "genetic", "algorithm", "operations", "on", "a", "population", "and", "return", "a", "new", "population", "." ]
python
train
43.083333
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L283-L299
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.htm...
[ "def", "set_meta_rdf", "(", "self", ",", "rdf", ",", "fmt", "=", "'n3'", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_entity_meta_set", "(", "self", ".", "__lid", ",", "rdf", ",", "fmt", "=", "fmt", ")", "self", ".", "_client", ".", ...
Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) ...
[ "Set", "the", "metadata", "for", "this", "Thing", "in", "RDF", "fmt" ]
python
train
50
Calysto/calysto
calysto/ai/conx.py
https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L860-L883
def path(self, startLayer, endLayer): """ Used in error checking with verifyArchitecture() and in prop_from(). """ next = {startLayer.name : startLayer} visited = {} while next != {}: for item in list(next.items()): # item[0] : name, item[1] : ...
[ "def", "path", "(", "self", ",", "startLayer", ",", "endLayer", ")", ":", "next", "=", "{", "startLayer", ".", "name", ":", "startLayer", "}", "visited", "=", "{", "}", "while", "next", "!=", "{", "}", ":", "for", "item", "in", "list", "(", "next",...
Used in error checking with verifyArchitecture() and in prop_from().
[ "Used", "in", "error", "checking", "with", "verifyArchitecture", "()", "and", "in", "prop_from", "()", "." ]
python
train
47.75
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/gallery/gallery_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/gallery/gallery_client.py#L1529-L1548
def create_review(self, review, pub_name, ext_name): """CreateReview. [Preview API] Creates a new review for an extension :param :class:`<Review> <azure.devops.v5_0.gallery.models.Review>` review: Review to be created for the extension :param str pub_name: Name of the publisher who publi...
[ "def", "create_review", "(", "self", ",", "review", ",", "pub_name", ",", "ext_name", ")", ":", "route_values", "=", "{", "}", "if", "pub_name", "is", "not", "None", ":", "route_values", "[", "'pubName'", "]", "=", "self", ".", "_serialize", ".", "url", ...
CreateReview. [Preview API] Creates a new review for an extension :param :class:`<Review> <azure.devops.v5_0.gallery.models.Review>` review: Review to be created for the extension :param str pub_name: Name of the publisher who published the extension :param str ext_name: Name of the exte...
[ "CreateReview", ".", "[", "Preview", "API", "]", "Creates", "a", "new", "review", "for", "an", "extension", ":", "param", ":", "class", ":", "<Review", ">", "<azure", ".", "devops", ".", "v5_0", ".", "gallery", ".", "models", ".", "Review", ">", "revie...
python
train
56.25
yakupadakli/python-unsplash
unsplash/models.py
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/models.py#L18-L25
def parse_list(cls, data): """Parse a list of JSON objects into a result set of model instances.""" results = ResultSet() data = data or [] for obj in data: if obj: results.append(cls.parse(obj)) return results
[ "def", "parse_list", "(", "cls", ",", "data", ")", ":", "results", "=", "ResultSet", "(", ")", "data", "=", "data", "or", "[", "]", "for", "obj", "in", "data", ":", "if", "obj", ":", "results", ".", "append", "(", "cls", ".", "parse", "(", "obj",...
Parse a list of JSON objects into a result set of model instances.
[ "Parse", "a", "list", "of", "JSON", "objects", "into", "a", "result", "set", "of", "model", "instances", "." ]
python
train
33.875