repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
materialsproject/pymatgen
pymatgen/analysis/reaction_calculator.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/reaction_calculator.py#L440-L451
def all_entries(self): """ Equivalent of all_comp but returns entries, in the same order as the coefficients. """ entries = [] for c in self._all_comp: for e in self._all_entries: if e.composition.reduced_formula == c.reduced_formula: ...
[ "def", "all_entries", "(", "self", ")", ":", "entries", "=", "[", "]", "for", "c", "in", "self", ".", "_all_comp", ":", "for", "e", "in", "self", ".", "_all_entries", ":", "if", "e", ".", "composition", ".", "reduced_formula", "==", "c", ".", "reduce...
Equivalent of all_comp but returns entries, in the same order as the coefficients.
[ "Equivalent", "of", "all_comp", "but", "returns", "entries", "in", "the", "same", "order", "as", "the", "coefficients", "." ]
python
train
kstaniek/condoor
condoor/device.py
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L461-L466
def update_console(self): """Update is_console whether connected via console.""" self.chain.connection.log("Detecting console connection") is_console = self.driver.is_console(self.users_text) if is_console is not None: self.is_console = is_console
[ "def", "update_console", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Detecting console connection\"", ")", "is_console", "=", "self", ".", "driver", ".", "is_console", "(", "self", ".", "users_text", ")", "if", "is_con...
Update is_console whether connected via console.
[ "Update", "is_console", "whether", "connected", "via", "console", "." ]
python
train
deepmind/sonnet
sonnet/python/modules/relational_memory.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/relational_memory.py#L212-L234
def _attend_over_memory(self, memory): """Perform multiheaded attention over `memory`. Args: memory: Current relational memory. Returns: The attended-over memory. """ attention_mlp = basic.BatchApply( mlp.MLP([self._mem_size] * self._attention_mlp_layers)) for _ in range(se...
[ "def", "_attend_over_memory", "(", "self", ",", "memory", ")", ":", "attention_mlp", "=", "basic", ".", "BatchApply", "(", "mlp", ".", "MLP", "(", "[", "self", ".", "_mem_size", "]", "*", "self", ".", "_attention_mlp_layers", ")", ")", "for", "_", "in", ...
Perform multiheaded attention over `memory`. Args: memory: Current relational memory. Returns: The attended-over memory.
[ "Perform", "multiheaded", "attention", "over", "memory", "." ]
python
train
rdussurget/py-altimetry
altimetry/externals/esutils_stat.py
https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/externals/esutils_stat.py#L89-L144
def _weave_dohist(data, s, binsize, hist, rev, dorev=False, verbose=0): if dorev: dorev=1 else: dorev=0 """ Weave version of histogram with reverse_indices s is an index into data, sorted and possibly a subset """ code = """ int64_t nbin = hist.size(); ...
[ "def", "_weave_dohist", "(", "data", ",", "s", ",", "binsize", ",", "hist", ",", "rev", ",", "dorev", "=", "False", ",", "verbose", "=", "0", ")", ":", "if", "dorev", ":", "dorev", "=", "1", "else", ":", "dorev", "=", "0", "code", "=", "\"\"\"\r\...
Weave version of histogram with reverse_indices s is an index into data, sorted and possibly a subset
[ "Weave", "version", "of", "histogram", "with", "reverse_indices", "s", "is", "an", "index", "into", "data", "sorted", "and", "possibly", "a", "subset" ]
python
train
praekeltfoundation/marathon-acme
marathon_acme/acme_util.py
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/acme_util.py#L58-L85
def maybe_key_vault(client, mount_path): """ Set up a client key in Vault if one does not exist already. :param client: The Vault API client to use. :param mount_path: The Vault key/value mount path to use. :rtype: twisted.internet.defer.Deferred """ d = client.read_kv2('cli...
[ "def", "maybe_key_vault", "(", "client", ",", "mount_path", ")", ":", "d", "=", "client", ".", "read_kv2", "(", "'client_key'", ",", "mount_path", "=", "mount_path", ")", "def", "get_or_create_key", "(", "client_key", ")", ":", "if", "client_key", "is", "not...
Set up a client key in Vault if one does not exist already. :param client: The Vault API client to use. :param mount_path: The Vault key/value mount path to use. :rtype: twisted.internet.defer.Deferred
[ "Set", "up", "a", "client", "key", "in", "Vault", "if", "one", "does", "not", "exist", "already", "." ]
python
valid
vfilimonov/pydatastream
pydatastream/pydatastream.py
https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L465-L525
def fetch(self, tickers, fields=None, date=None, date_from=None, date_to=None, freq='D', only_data=True, static=False): """Fetch data from TR DWE. tickers - ticker or list of tickers fields - list of fields. date - date for a single-date query date_...
[ "def", "fetch", "(", "self", ",", "tickers", ",", "fields", "=", "None", ",", "date", "=", "None", ",", "date_from", "=", "None", ",", "date_to", "=", "None", ",", "freq", "=", "'D'", ",", "only_data", "=", "True", ",", "static", "=", "False", ")",...
Fetch data from TR DWE. tickers - ticker or list of tickers fields - list of fields. date - date for a single-date query date_from, date_to - date range (used only if "date" is not specified) freq - frequency of data: daily('D'), weekly('W') or monthly('M')...
[ "Fetch", "data", "from", "TR", "DWE", "." ]
python
train
wandb/client
wandb/run_manager.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/run_manager.py#L792-L851
def init_run(self, env=None): """Ensure we create a Run (Bucket) object We either create it now or, if the API call fails for some reason (eg. the network is down), we do it from a thread that we start. We hold off file syncing and streaming until it succeeds. Returns the initi...
[ "def", "init_run", "(", "self", ",", "env", "=", "None", ")", ":", "io_wrap", ".", "init_sigwinch_handler", "(", ")", "self", ".", "_check_update_available", "(", "__version__", ")", "if", "self", ".", "_output", ":", "wandb", ".", "termlog", "(", "\"Local...
Ensure we create a Run (Bucket) object We either create it now or, if the API call fails for some reason (eg. the network is down), we do it from a thread that we start. We hold off file syncing and streaming until it succeeds. Returns the initial step of the run, or None if we didn't ...
[ "Ensure", "we", "create", "a", "Run", "(", "Bucket", ")", "object" ]
python
train
lthibault/expmpp
expmpp/client.py
https://github.com/lthibault/expmpp/blob/635fb3187fe4021410e0f06ca6896098b5e1d3b4/expmpp/client.py#L96-L135
def monitor(self, msg, transformer=lambda _: _, unpack=False): """Decorator that sends a notification to all listeners when the wrapped function returns, optionally reporting said function's return value(s). msg : str Message to send to all listeners. If the message is a ...
[ "def", "monitor", "(", "self", ",", "msg", ",", "transformer", "=", "lambda", "_", ":", "_", ",", "unpack", "=", "False", ")", ":", "def", "decorator", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapper", "(", "*", "args", ",", ...
Decorator that sends a notification to all listeners when the wrapped function returns, optionally reporting said function's return value(s). msg : str Message to send to all listeners. If the message is a Python-formatted string, the wrapped function's return value wil...
[ "Decorator", "that", "sends", "a", "notification", "to", "all", "listeners", "when", "the", "wrapped", "function", "returns", "optionally", "reporting", "said", "function", "s", "return", "value", "(", "s", ")", "." ]
python
train
iotile/coretools
iotilesensorgraph/iotile/sg/processors.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/processors.py#L13-L31
def copy_all_a(input_a, *other_inputs, **kwargs): """Copy all readings in input a into the output. All other inputs are skipped so that after this function runs there are no readings left in any of the input walkers when the function finishes, even if it generated no output readings. Returns: ...
[ "def", "copy_all_a", "(", "input_a", ",", "*", "other_inputs", ",", "*", "*", "kwargs", ")", ":", "output", "=", "[", "]", "while", "input_a", ".", "count", "(", ")", ">", "0", ":", "output", ".", "append", "(", "input_a", ".", "pop", "(", ")", "...
Copy all readings in input a into the output. All other inputs are skipped so that after this function runs there are no readings left in any of the input walkers when the function finishes, even if it generated no output readings. Returns: list(IOTileReading)
[ "Copy", "all", "readings", "in", "input", "a", "into", "the", "output", "." ]
python
train
ThreatConnect-Inc/tcex
tcex/tcex_data_filter.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_data_filter.py#L60-L72
def _in(field, filter_value): """Validate field **IN** string or list. Args: filter_value (string | list): A string or list of values. Returns: (boolean): Results of check """ valid = False if field in filter_value: valid = True ...
[ "def", "_in", "(", "field", ",", "filter_value", ")", ":", "valid", "=", "False", "if", "field", "in", "filter_value", ":", "valid", "=", "True", "return", "valid" ]
Validate field **IN** string or list. Args: filter_value (string | list): A string or list of values. Returns: (boolean): Results of check
[ "Validate", "field", "**", "IN", "**", "string", "or", "list", "." ]
python
train
aws/aws-xray-sdk-python
aws_xray_sdk/core/models/segment.py
https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/core/models/segment.py#L126-L131
def remove_subsegment(self, subsegment): """ Remove the reference of input subsegment. """ super(Segment, self).remove_subsegment(subsegment) self.decrement_subsegments_size()
[ "def", "remove_subsegment", "(", "self", ",", "subsegment", ")", ":", "super", "(", "Segment", ",", "self", ")", ".", "remove_subsegment", "(", "subsegment", ")", "self", ".", "decrement_subsegments_size", "(", ")" ]
Remove the reference of input subsegment.
[ "Remove", "the", "reference", "of", "input", "subsegment", "." ]
python
train
PierreRust/apigpio
apigpio/apigpio.py
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L559-L573
def connect(self, address): """ Connect to a remote or local gpiod daemon. :param address: a pair (address, port), the address must be already resolved (for example an ip address) :return: """ self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self...
[ "def", "connect", "(", "self", ",", "address", ")", ":", "self", ".", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "self", ".", "s", ".", "setblocking", "(", "False", ")", "# Disable the Nagl...
Connect to a remote or local gpiod daemon. :param address: a pair (address, port), the address must be already resolved (for example an ip address) :return:
[ "Connect", "to", "a", "remote", "or", "local", "gpiod", "daemon", ".", ":", "param", "address", ":", "a", "pair", "(", "address", "port", ")", "the", "address", "must", "be", "already", "resolved", "(", "for", "example", "an", "ip", "address", ")", ":"...
python
train
twilio/twilio-python
twilio/rest/video/v1/recording_settings.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/video/v1/recording_settings.py#L216-L226
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RecordingSettingsContext for this RecordingSettingsInstance :rtype: twilio.rest.video.v1.recordin...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "RecordingSettingsContext", "(", "self", ".", "_version", ",", ")", "return", "self", ".", "_context" ]
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RecordingSettingsContext for this RecordingSettingsInstance :rtype: twilio.rest.video.v1.recording_settings.RecordingSettingsContext
[ "Generate", "an", "instance", "context", "for", "the", "instance", "the", "context", "is", "capable", "of", "performing", "various", "actions", ".", "All", "instance", "actions", "are", "proxied", "to", "the", "context" ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10733-L10748
def mag_cal_progress_send(self, compass_id, cal_mask, cal_status, attempt, completion_pct, completion_mask, direction_x, direction_y, direction_z, force_mavlink1=False): ''' Reports progress of compass calibration. compass_id : Compass being calibrated (ui...
[ "def", "mag_cal_progress_send", "(", "self", ",", "compass_id", ",", "cal_mask", ",", "cal_status", ",", "attempt", ",", "completion_pct", ",", "completion_mask", ",", "direction_x", ",", "direction_y", ",", "direction_z", ",", "force_mavlink1", "=", "False", ")",...
Reports progress of compass calibration. compass_id : Compass being calibrated (uint8_t) cal_mask : Bitmask of compasses being calibrated (uint8_t) cal_status : Status (see MAG_CAL_STATUS enum) (uint8_t) atte...
[ "Reports", "progress", "of", "compass", "calibration", "." ]
python
train
juju/charm-helpers
charmhelpers/fetch/ubuntu.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/ubuntu.py#L690-L708
def _run_apt_command(cmd, fatal=False): """Run an apt command with optional retries. :param: cmd: str: The apt command to run. :param: fatal: bool: Whether the command's output should be checked and retried. """ # Provide DEBIAN_FRONTEND=noninteractive if not present in the environment. ...
[ "def", "_run_apt_command", "(", "cmd", ",", "fatal", "=", "False", ")", ":", "# Provide DEBIAN_FRONTEND=noninteractive if not present in the environment.", "cmd_env", "=", "{", "'DEBIAN_FRONTEND'", ":", "os", ".", "environ", ".", "get", "(", "'DEBIAN_FRONTEND'", ",", ...
Run an apt command with optional retries. :param: cmd: str: The apt command to run. :param: fatal: bool: Whether the command's output should be checked and retried.
[ "Run", "an", "apt", "command", "with", "optional", "retries", "." ]
python
train
CellProfiler/centrosome
centrosome/haralick.py
https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/haralick.py#L196-L199
def H7(self): "Sum variance (error in Haralick's original paper here)." h6 = np.tile(self.H6(), (self.rlevels2.shape[1], 1)).transpose() return (((self.rlevels2 + 2) - h6) ** 2 * self.p_xplusy).sum(1)
[ "def", "H7", "(", "self", ")", ":", "h6", "=", "np", ".", "tile", "(", "self", ".", "H6", "(", ")", ",", "(", "self", ".", "rlevels2", ".", "shape", "[", "1", "]", ",", "1", ")", ")", ".", "transpose", "(", ")", "return", "(", "(", "(", "...
Sum variance (error in Haralick's original paper here).
[ "Sum", "variance", "(", "error", "in", "Haralick", "s", "original", "paper", "here", ")", "." ]
python
train
casebeer/audiogen
audiogen/sampler.py
https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L211-L245
def play(channels, blocking=True, raw_samples=False): ''' Play the contents of the generator using PyAudio Play to the system soundcard using PyAudio. PyAudio, an otherwise optional depenency, must be installed for this feature to work. ''' if not pyaudio_loaded: raise Exception("Soundcard playback requires P...
[ "def", "play", "(", "channels", ",", "blocking", "=", "True", ",", "raw_samples", "=", "False", ")", ":", "if", "not", "pyaudio_loaded", ":", "raise", "Exception", "(", "\"Soundcard playback requires PyAudio. Install with `pip install pyaudio`.\"", ")", "channel_count",...
Play the contents of the generator using PyAudio Play to the system soundcard using PyAudio. PyAudio, an otherwise optional depenency, must be installed for this feature to work.
[ "Play", "the", "contents", "of", "the", "generator", "using", "PyAudio" ]
python
train
vtemian/buffpy
buffpy/managers/updates.py
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/managers/updates.py#L102-L135
def new(self, text, shorten=None, now=None, top=None, media=None, when=None): ''' Create one or more new status updates. ''' url = PATHS['CREATE'] post_data = "text=%s&" % text post_data += "profile_ids[]=%s&" % self.profile_id if shorten: post_data += "shorten=%s&" % shorten ...
[ "def", "new", "(", "self", ",", "text", ",", "shorten", "=", "None", ",", "now", "=", "None", ",", "top", "=", "None", ",", "media", "=", "None", ",", "when", "=", "None", ")", ":", "url", "=", "PATHS", "[", "'CREATE'", "]", "post_data", "=", "...
Create one or more new status updates.
[ "Create", "one", "or", "more", "new", "status", "updates", "." ]
python
valid
thefab/tornadis
tornadis/connection.py
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L208-L230
def disconnect(self): """Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors). """ if not self.is_connected() and not self.is_connecting(): return LOG.debug("disconnecting from %s...", se...
[ "def", "disconnect", "(", "self", ")", ":", "if", "not", "self", ".", "is_connected", "(", ")", "and", "not", "self", ".", "is_connecting", "(", ")", ":", "return", "LOG", ".", "debug", "(", "\"disconnecting from %s...\"", ",", "self", ".", "_redis_server"...
Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors).
[ "Disconnects", "the", "object", "." ]
python
train
pypa/pipenv
pipenv/vendor/attr/_make.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/attr/_make.py#L1934-L1946
def validator(self, meth): """ Decorator that adds *meth* to the list of validators. Returns *meth* unchanged. .. versionadded:: 17.1.0 """ if self._validator is None: self._validator = meth else: self._validator = and_(self._validator, m...
[ "def", "validator", "(", "self", ",", "meth", ")", ":", "if", "self", ".", "_validator", "is", "None", ":", "self", ".", "_validator", "=", "meth", "else", ":", "self", ".", "_validator", "=", "and_", "(", "self", ".", "_validator", ",", "meth", ")",...
Decorator that adds *meth* to the list of validators. Returns *meth* unchanged. .. versionadded:: 17.1.0
[ "Decorator", "that", "adds", "*", "meth", "*", "to", "the", "list", "of", "validators", "." ]
python
train
KrishnaswamyLab/graphtools
graphtools/base.py
https://github.com/KrishnaswamyLab/graphtools/blob/44685352be7df2005d44722903092207967457f2/graphtools/base.py#L825-L852
def extend_to_data(self, Y): """Build transition matrix from new data to the graph Creates a transition matrix such that `Y` can be approximated by a linear combination of samples in `self.data`. Any transformation of `self.data` can be trivially applied to `Y` by performing ...
[ "def", "extend_to_data", "(", "self", ",", "Y", ")", ":", "Y", "=", "self", ".", "_check_extension_shape", "(", "Y", ")", "kernel", "=", "self", ".", "build_kernel_to_data", "(", "Y", ")", "transitions", "=", "normalize", "(", "kernel", ",", "norm", "=",...
Build transition matrix from new data to the graph Creates a transition matrix such that `Y` can be approximated by a linear combination of samples in `self.data`. Any transformation of `self.data` can be trivially applied to `Y` by performing `transform_Y = self.interpolate(tr...
[ "Build", "transition", "matrix", "from", "new", "data", "to", "the", "graph" ]
python
train
rosshamish/catan-py
catan/game.py
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/game.py#L171-L209
def start(self, players): """ Start the game. The value of option 'pregame' determines whether the pregame will occur or not. - Resets the board - Sets the players - Sets the game state to the appropriate first turn of the game - Finds the robber on the board, s...
[ "def", "start", "(", "self", ",", "players", ")", ":", "from", ".", "boardbuilder", "import", "Opt", "self", ".", "reset", "(", ")", "if", "self", ".", "board", ".", "opts", ".", "get", "(", "'players'", ")", "==", "Opt", ".", "debug", ":", "player...
Start the game. The value of option 'pregame' determines whether the pregame will occur or not. - Resets the board - Sets the players - Sets the game state to the appropriate first turn of the game - Finds the robber on the board, sets the robber_tile appropriately - Lo...
[ "Start", "the", "game", "." ]
python
train
wadda/gps3
gps3/agps3.py
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/agps3.py#L87-L97
def send(self, commands): """Ship commands to the daemon Arguments: commands: e.g., '?WATCH={{'enable':true,'json':true}}'|'?VERSION;'|'?DEVICES;'|'?DEVICE;'|'?POLL;' """ try: self.streamSock.send(bytes(commands, encoding='utf-8')) except TypeError: ...
[ "def", "send", "(", "self", ",", "commands", ")", ":", "try", ":", "self", ".", "streamSock", ".", "send", "(", "bytes", "(", "commands", ",", "encoding", "=", "'utf-8'", ")", ")", "except", "TypeError", ":", "self", ".", "streamSock", ".", "send", "...
Ship commands to the daemon Arguments: commands: e.g., '?WATCH={{'enable':true,'json':true}}'|'?VERSION;'|'?DEVICES;'|'?DEVICE;'|'?POLL;'
[ "Ship", "commands", "to", "the", "daemon", "Arguments", ":", "commands", ":", "e", ".", "g", ".", "?WATCH", "=", "{{", "enable", ":", "true", "json", ":", "true", "}}", "|", "?VERSION", ";", "|", "?DEVICES", ";", "|", "?DEVICE", ";", "|", "?POLL", ...
python
train
zomux/deepy
deepy/dataset/bunch_seq.py
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/bunch_seq.py#L58-L64
def _cut_to_pieces(self, bunch_stack): """ :type bunch_stack: list of list of int """ stack_len = len(bunch_stack[0]) for i in xrange(0, stack_len, self.fragment_length): yield np.array(map(lambda stack: stack[i: i + self.fragment_length], bunch_stack))
[ "def", "_cut_to_pieces", "(", "self", ",", "bunch_stack", ")", ":", "stack_len", "=", "len", "(", "bunch_stack", "[", "0", "]", ")", "for", "i", "in", "xrange", "(", "0", ",", "stack_len", ",", "self", ".", "fragment_length", ")", ":", "yield", "np", ...
:type bunch_stack: list of list of int
[ ":", "type", "bunch_stack", ":", "list", "of", "list", "of", "int" ]
python
test
user-cont/colin
colin/core/ruleset/loader.py
https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/loader.py#L118-L121
def other_attributes(self): """ return dict with all other data except for the described above""" return {k: v for k, v in self.c.items() if k not in ["name", "names", "tags", "additional_tags", "usable_targets"]}
[ "def", "other_attributes", "(", "self", ")", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "c", ".", "items", "(", ")", "if", "k", "not", "in", "[", "\"name\"", ",", "\"names\"", ",", "\"tags\"", ",", "\"additional_tag...
return dict with all other data except for the described above
[ "return", "dict", "with", "all", "other", "data", "except", "for", "the", "described", "above" ]
python
train
google/grr
grr/server/grr_response_server/rdfvalues/objects.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L460-L485
def UpdateFrom(self, src): """Merge path info records. Merges src into self. Args: src: An rdfvalues.objects.PathInfo record, will be merged into self. Raises: ValueError: If src does not represent the same path. """ if not isinstance(src, PathInfo): raise TypeError("expected...
[ "def", "UpdateFrom", "(", "self", ",", "src", ")", ":", "if", "not", "isinstance", "(", "src", ",", "PathInfo", ")", ":", "raise", "TypeError", "(", "\"expected `%s` but got `%s`\"", "%", "(", "PathInfo", ",", "type", "(", "src", ")", ")", ")", "if", "...
Merge path info records. Merges src into self. Args: src: An rdfvalues.objects.PathInfo record, will be merged into self. Raises: ValueError: If src does not represent the same path.
[ "Merge", "path", "info", "records", "." ]
python
train
intake/intake
intake/source/cache.py
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/source/cache.py#L238-L256
def clear_all(self): """ Clears all cache and metadata. """ for urlpath in self._metadata.keys(): self.clear_cache(urlpath) # Safely clean up anything else. if not os.path.isdir(self._cache_dir): return for subdir in os.listdir(self._cache...
[ "def", "clear_all", "(", "self", ")", ":", "for", "urlpath", "in", "self", ".", "_metadata", ".", "keys", "(", ")", ":", "self", ".", "clear_cache", "(", "urlpath", ")", "# Safely clean up anything else.", "if", "not", "os", ".", "path", ".", "isdir", "(...
Clears all cache and metadata.
[ "Clears", "all", "cache", "and", "metadata", "." ]
python
train
wummel/dosage
dosagelib/events.py
https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/events.py#L273-L276
def comicDownloaded(self, comic, filename, text=None): """Add URL-to-filename mapping into JSON.""" pageInfo = self.getPageInfo(comic.name, comic.referrer) pageInfo['images'][comic.url] = os.path.basename(filename)
[ "def", "comicDownloaded", "(", "self", ",", "comic", ",", "filename", ",", "text", "=", "None", ")", ":", "pageInfo", "=", "self", ".", "getPageInfo", "(", "comic", ".", "name", ",", "comic", ".", "referrer", ")", "pageInfo", "[", "'images'", "]", "[",...
Add URL-to-filename mapping into JSON.
[ "Add", "URL", "-", "to", "-", "filename", "mapping", "into", "JSON", "." ]
python
train
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L140-L186
def document_type(self, key, value): """Populate the ``document_type`` key. Also populates the ``_collections``, ``citeable``, ``core``, ``deleted``, ``refereed``, ``publication_type``, and ``withdrawn`` keys through side effects. """ schema = load_schema('hep') publication_type_schema = sc...
[ "def", "document_type", "(", "self", ",", "key", ",", "value", ")", ":", "schema", "=", "load_schema", "(", "'hep'", ")", "publication_type_schema", "=", "schema", "[", "'properties'", "]", "[", "'publication_type'", "]", "valid_publication_types", "=", "publica...
Populate the ``document_type`` key. Also populates the ``_collections``, ``citeable``, ``core``, ``deleted``, ``refereed``, ``publication_type``, and ``withdrawn`` keys through side effects.
[ "Populate", "the", "document_type", "key", "." ]
python
train
raphaelvallat/pingouin
pingouin/pairwise.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/pairwise.py#L725-L1032
def pairwise_corr(data, columns=None, covar=None, tail='two-sided', method='pearson', padjust='none', export_filename=None): '''Pairwise (partial) correlations between columns of a pandas dataframe. Parameters ---------- data : pandas DataFrame DataFrame. Note that this functi...
[ "def", "pairwise_corr", "(", "data", ",", "columns", "=", "None", ",", "covar", "=", "None", ",", "tail", "=", "'two-sided'", ",", "method", "=", "'pearson'", ",", "padjust", "=", "'none'", ",", "export_filename", "=", "None", ")", ":", "from", "pingouin...
Pairwise (partial) correlations between columns of a pandas dataframe. Parameters ---------- data : pandas DataFrame DataFrame. Note that this function can also directly be used as a Pandas method, in which case this argument is no longer needed. columns : list or str Column nam...
[ "Pairwise", "(", "partial", ")", "correlations", "between", "columns", "of", "a", "pandas", "dataframe", "." ]
python
train
jrxFive/python-nomad
nomad/api/client.py
https://github.com/jrxFive/python-nomad/blob/37df37e4de21e6f8ac41c6154e7f1f44f1800020/nomad/api/client.py#L43-L59
def list_files(self, id=None, path="/"): """ List files in an allocation directory. https://www.nomadproject.io/docs/http/client-fs-ls.html arguments: - id - path returns: list raises: - nomad.api.exceptions.Bas...
[ "def", "list_files", "(", "self", ",", "id", "=", "None", ",", "path", "=", "\"/\"", ")", ":", "if", "id", ":", "return", "self", ".", "request", "(", "id", ",", "params", "=", "{", "\"path\"", ":", "path", "}", ",", "method", "=", "\"get\"", ")"...
List files in an allocation directory. https://www.nomadproject.io/docs/http/client-fs-ls.html arguments: - id - path returns: list raises: - nomad.api.exceptions.BaseNomadException - nomad.api.exceptions....
[ "List", "files", "in", "an", "allocation", "directory", "." ]
python
test
LonamiWebs/Telethon
telethon/sessions/sqlite.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L221-L230
def _execute(self, stmt, *values): """ Gets a cursor, executes `stmt` and closes the cursor, fetching one row afterwards and returning its result. """ c = self._cursor() try: return c.execute(stmt, values).fetchone() finally: c.close()
[ "def", "_execute", "(", "self", ",", "stmt", ",", "*", "values", ")", ":", "c", "=", "self", ".", "_cursor", "(", ")", "try", ":", "return", "c", ".", "execute", "(", "stmt", ",", "values", ")", ".", "fetchone", "(", ")", "finally", ":", "c", "...
Gets a cursor, executes `stmt` and closes the cursor, fetching one row afterwards and returning its result.
[ "Gets", "a", "cursor", "executes", "stmt", "and", "closes", "the", "cursor", "fetching", "one", "row", "afterwards", "and", "returning", "its", "result", "." ]
python
train
SheffieldML/GPyOpt
GPyOpt/interface/driver.py
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L100-L119
def run(self): """ Runs the optimization using the previously loaded elements. """ space = self._get_space() obj_func = self._get_obj(space) model = self._get_model() acq = self._get_acquisition(model, space) acq_eval = self._get_acq_evaluator(acq) ...
[ "def", "run", "(", "self", ")", ":", "space", "=", "self", ".", "_get_space", "(", ")", "obj_func", "=", "self", ".", "_get_obj", "(", "space", ")", "model", "=", "self", ".", "_get_model", "(", ")", "acq", "=", "self", ".", "_get_acquisition", "(", ...
Runs the optimization using the previously loaded elements.
[ "Runs", "the", "optimization", "using", "the", "previously", "loaded", "elements", "." ]
python
train
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L265-L278
def prt_error_summary(self, fout_err): """Print a summary about the GAF file that was read.""" # Get summary of error types and their counts errcnts = [] if self.ignored: errcnts.append(" {N:9,} IGNORED associations\n".format(N=len(self.ignored))) if self.illegal_lin...
[ "def", "prt_error_summary", "(", "self", ",", "fout_err", ")", ":", "# Get summary of error types and their counts", "errcnts", "=", "[", "]", "if", "self", ".", "ignored", ":", "errcnts", ".", "append", "(", "\" {N:9,} IGNORED associations\\n\"", ".", "format", "(...
Print a summary about the GAF file that was read.
[ "Print", "a", "summary", "about", "the", "GAF", "file", "that", "was", "read", "." ]
python
train
mlperf/training
rnn_translator/pytorch/seq2seq/data/sampler.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/data/sampler.py#L69-L81
def reshuffle_batches(self, indices, rng): """ Permutes global batches :param indices: torch.tensor with batch indices :param rng: instance of torch.Generator """ indices = indices.view(-1, self.global_batch_size) num_batches = indices.shape[0] order = to...
[ "def", "reshuffle_batches", "(", "self", ",", "indices", ",", "rng", ")", ":", "indices", "=", "indices", ".", "view", "(", "-", "1", ",", "self", ".", "global_batch_size", ")", "num_batches", "=", "indices", ".", "shape", "[", "0", "]", "order", "=", ...
Permutes global batches :param indices: torch.tensor with batch indices :param rng: instance of torch.Generator
[ "Permutes", "global", "batches" ]
python
train
facebook/watchman
getdeps.py
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/getdeps.py#L285-L294
def vcpkg_dir(): """ Figure out where vcpkg is installed. vcpkg-exported is populated in some flavors of FB internal builds. C:/tools/vcpkg is the appveyor location. C:/open/vcpkg is my local location. """ for p in ["vcpkg-exported", "C:/tools/vcpkg", "C:/open/vcpkg"]: if os.path.isdir(p...
[ "def", "vcpkg_dir", "(", ")", ":", "for", "p", "in", "[", "\"vcpkg-exported\"", ",", "\"C:/tools/vcpkg\"", ",", "\"C:/open/vcpkg\"", "]", ":", "if", "os", ".", "path", ".", "isdir", "(", "p", ")", ":", "return", "os", ".", "path", ".", "realpath", "(",...
Figure out where vcpkg is installed. vcpkg-exported is populated in some flavors of FB internal builds. C:/tools/vcpkg is the appveyor location. C:/open/vcpkg is my local location.
[ "Figure", "out", "where", "vcpkg", "is", "installed", ".", "vcpkg", "-", "exported", "is", "populated", "in", "some", "flavors", "of", "FB", "internal", "builds", ".", "C", ":", "/", "tools", "/", "vcpkg", "is", "the", "appveyor", "location", ".", "C", ...
python
train
hyperledger/sawtooth-core
cli/sawtooth_cli/network_command/compare.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L187-L237
def print_summary(graph, tails, node_id_map): """Print out summary and per-node comparison data.""" # Get comparison data heads = get_heads(tails) heights = get_heights(tails) max_height = max(heights) common_height, block_ids_at_common_height = get_common_height(tails) lags = get_lags(heigh...
[ "def", "print_summary", "(", "graph", ",", "tails", ",", "node_id_map", ")", ":", "# Get comparison data", "heads", "=", "get_heads", "(", "tails", ")", "heights", "=", "get_heights", "(", "tails", ")", "max_height", "=", "max", "(", "heights", ")", "common_...
Print out summary and per-node comparison data.
[ "Print", "out", "summary", "and", "per", "-", "node", "comparison", "data", "." ]
python
train
raiden-network/raiden
raiden/blockchain/events.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L50-L78
def get_contract_events( chain: BlockChainService, abi: Dict, contract_address: Address, topics: Optional[List[str]], from_block: BlockSpecification, to_block: BlockSpecification, ) -> List[Dict]: """ Query the blockchain for all events of the smart contract at `c...
[ "def", "get_contract_events", "(", "chain", ":", "BlockChainService", ",", "abi", ":", "Dict", ",", "contract_address", ":", "Address", ",", "topics", ":", "Optional", "[", "List", "[", "str", "]", "]", ",", "from_block", ":", "BlockSpecification", ",", "to_...
Query the blockchain for all events of the smart contract at `contract_address` that match the filters `topics`, `from_block`, and `to_block`.
[ "Query", "the", "blockchain", "for", "all", "events", "of", "the", "smart", "contract", "at", "contract_address", "that", "match", "the", "filters", "topics", "from_block", "and", "to_block", "." ]
python
train
Scoppio/RagnarokEngine3
RagnarokEngine3/RE3.py
https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L1306-L1308
def center_origin(self): """Sets the origin to the center of the image.""" self.set_origin(Vector2(self.image.get_width() / 2.0, self.image.get_height() / 2.0))
[ "def", "center_origin", "(", "self", ")", ":", "self", ".", "set_origin", "(", "Vector2", "(", "self", ".", "image", ".", "get_width", "(", ")", "/", "2.0", ",", "self", ".", "image", ".", "get_height", "(", ")", "/", "2.0", ")", ")" ]
Sets the origin to the center of the image.
[ "Sets", "the", "origin", "to", "the", "center", "of", "the", "image", "." ]
python
train
jic-dtool/dtoolcore
dtoolcore/storagebroker.py
https://github.com/jic-dtool/dtoolcore/blob/eeb9a924dc8fcf543340653748a7877be1f98e0f/dtoolcore/storagebroker.py#L296-L304
def _document_structure(self): """Document the structure of the dataset.""" logger.debug("Documenting dataset structure") key = self.get_structure_key() text = json.dumps(self._structure_parameters, indent=2, sort_keys=True) self.put_text(key, text) key = self.get_dtool_...
[ "def", "_document_structure", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Documenting dataset structure\"", ")", "key", "=", "self", ".", "get_structure_key", "(", ")", "text", "=", "json", ".", "dumps", "(", "self", ".", "_structure_parameters", ",...
Document the structure of the dataset.
[ "Document", "the", "structure", "of", "the", "dataset", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/pkg_resources.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/pkg_resources.py#L614-L690
def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True ): """Find all activatable distributions in `plugin_env` Example usage:: distributions, errors = working_set.find_plugins( Environment(plugin_dirlist) ) map(w...
[ "def", "find_plugins", "(", "self", ",", "plugin_env", ",", "full_env", "=", "None", ",", "installer", "=", "None", ",", "fallback", "=", "True", ")", ":", "plugin_projects", "=", "list", "(", "plugin_env", ")", "plugin_projects", ".", "sort", "(", ")", ...
Find all activatable distributions in `plugin_env` Example usage:: distributions, errors = working_set.find_plugins( Environment(plugin_dirlist) ) map(working_set.add, distributions) # add plugins+libs to sys.path print 'Could not load', errors ...
[ "Find", "all", "activatable", "distributions", "in", "plugin_env" ]
python
test
user-cont/conu
conu/utils/__init__.py
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L310-L332
def graceful_get(d, *args): """ Obtain values from dicts and lists gracefully. Example: :: print(graceful_get({"a": [{1: 2}, {"b": "c"}]}, "a", "b")) c :param d: collection (usually a dict or list) :param args: list of keys which are used as a lookup :return: the value from yo...
[ "def", "graceful_get", "(", "d", ",", "*", "args", ")", ":", "if", "not", "d", ":", "return", "d", "value", "=", "d", "for", "arg", "in", "args", ":", "try", ":", "value", "=", "value", "[", "arg", "]", "except", "(", "IndexError", ",", "KeyError...
Obtain values from dicts and lists gracefully. Example: :: print(graceful_get({"a": [{1: 2}, {"b": "c"}]}, "a", "b")) c :param d: collection (usually a dict or list) :param args: list of keys which are used as a lookup :return: the value from your collection
[ "Obtain", "values", "from", "dicts", "and", "lists", "gracefully", ".", "Example", ":" ]
python
train
libtcod/python-tcod
tcod/bsp.py
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L260-L272
def find_node(self, x: int, y: int) -> Optional["BSP"]: """Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None. """ if not self.contains(x, y): return None for child in self.children: found = ch...
[ "def", "find_node", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Optional", "[", "\"BSP\"", "]", ":", "if", "not", "self", ".", "contains", "(", "x", ",", "y", ")", ":", "return", "None", "for", "child", "in", "self", "....
Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None.
[ "Return", "the", "deepest", "node", "which", "contains", "these", "coordinates", "." ]
python
train
PmagPy/PmagPy
dialogs/pmag_gui_menu3.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/pmag_gui_menu3.py#L171-L183
def on_clear(self, event): """ initialize window to allow user to empty the working directory """ dia = pmag_menu_dialogs.ClearWD(self.parent, self.parent.WD) clear = dia.do_clear() if clear: # clear directory, but use previously acquired data_model ...
[ "def", "on_clear", "(", "self", ",", "event", ")", ":", "dia", "=", "pmag_menu_dialogs", ".", "ClearWD", "(", "self", ".", "parent", ",", "self", ".", "parent", ".", "WD", ")", "clear", "=", "dia", ".", "do_clear", "(", ")", "if", "clear", ":", "# ...
initialize window to allow user to empty the working directory
[ "initialize", "window", "to", "allow", "user", "to", "empty", "the", "working", "directory" ]
python
train
dropseed/configyaml
configyaml/config/base.py
https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L173-L179
def _validate_type(self): # type: () -> None """Validation to ensure value is the correct type""" if not isinstance(self._value, self._type): title = '{} has an invalid type'.format(self._key_name()) description = '{} must be a {}'.format(self._key_name(), self._type.__name__) ...
[ "def", "_validate_type", "(", "self", ")", ":", "# type: () -> None", "if", "not", "isinstance", "(", "self", ".", "_value", ",", "self", ".", "_type", ")", ":", "title", "=", "'{} has an invalid type'", ".", "format", "(", "self", ".", "_key_name", "(", "...
Validation to ensure value is the correct type
[ "Validation", "to", "ensure", "value", "is", "the", "correct", "type" ]
python
train
pyQode/pyqode.core
pyqode/core/widgets/output_window.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/output_window.py#L978-L985
def _insert_command(self, command): """ Insert command by replacing the current input buffer and display it on the text edit. """ self._clear_user_buffer() tc = self.edit.textCursor() tc.insertText(command) self.edit.setTextCursor(tc)
[ "def", "_insert_command", "(", "self", ",", "command", ")", ":", "self", ".", "_clear_user_buffer", "(", ")", "tc", "=", "self", ".", "edit", ".", "textCursor", "(", ")", "tc", ".", "insertText", "(", "command", ")", "self", ".", "edit", ".", "setTextC...
Insert command by replacing the current input buffer and display it on the text edit.
[ "Insert", "command", "by", "replacing", "the", "current", "input", "buffer", "and", "display", "it", "on", "the", "text", "edit", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/zmq/ipkernel.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/zmq/ipkernel.py#L647-L654
def _topic(self, topic): """prefixed topic for IOPub messages""" if self.int_id >= 0: base = "engine.%i" % self.int_id else: base = "kernel.%s" % self.ident return py3compat.cast_bytes("%s.%s" % (base, topic))
[ "def", "_topic", "(", "self", ",", "topic", ")", ":", "if", "self", ".", "int_id", ">=", "0", ":", "base", "=", "\"engine.%i\"", "%", "self", ".", "int_id", "else", ":", "base", "=", "\"kernel.%s\"", "%", "self", ".", "ident", "return", "py3compat", ...
prefixed topic for IOPub messages
[ "prefixed", "topic", "for", "IOPub", "messages" ]
python
test
akatrevorjay/uninhibited
uninhibited/dispatch.py
https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L189-L202
def add_event(self, name, send_event=True, event_factory=None): """ Add event by name. This is called for you as needed if you allow auto creation of events (see __init__). Upon an event being added, all handlers are searched for if they have this event, and if they do, they ar...
[ "def", "add_event", "(", "self", ",", "name", ",", "send_event", "=", "True", ",", "event_factory", "=", "None", ")", ":", "return", "self", ".", "add_events", "(", "(", "name", ",", ")", ",", "send_event", "=", "send_event", ",", "event_factory", "=", ...
Add event by name. This is called for you as needed if you allow auto creation of events (see __init__). Upon an event being added, all handlers are searched for if they have this event, and if they do, they are added to the Event's list of callables. This is only here to ensure my co...
[ "Add", "event", "by", "name", "." ]
python
train
apache/incubator-mxnet
example/gluon/sn_gan/model.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/model.py#L120-L139
def get_descriptor(ctx): """ construct and return descriptor """ d_net = gluon.nn.Sequential() with d_net.name_scope(): d_net.add(SNConv2D(num_filter=64, kernel_size=4, strides=2, padding=1, in_channels=3, ctx=ctx)) d_net.add(gluon.nn.LeakyReLU(0.2)) d_net.add(SNConv2D(num_filter=1...
[ "def", "get_descriptor", "(", "ctx", ")", ":", "d_net", "=", "gluon", ".", "nn", ".", "Sequential", "(", ")", "with", "d_net", ".", "name_scope", "(", ")", ":", "d_net", ".", "add", "(", "SNConv2D", "(", "num_filter", "=", "64", ",", "kernel_size", "...
construct and return descriptor
[ "construct", "and", "return", "descriptor" ]
python
train
mar10/pyftpsync
ftpsync/ftp_target.py
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/ftp_target.py#L658-L675
def _ftp_pwd(self): """Variant of `self.ftp.pwd()` that supports encoding-fallback. Returns: Current working directory as native string. """ try: return self.ftp.pwd() except UnicodeEncodeError: if compat.PY2 or self.ftp.encoding != "...
[ "def", "_ftp_pwd", "(", "self", ")", ":", "try", ":", "return", "self", ".", "ftp", ".", "pwd", "(", ")", "except", "UnicodeEncodeError", ":", "if", "compat", ".", "PY2", "or", "self", ".", "ftp", ".", "encoding", "!=", "\"utf-8\"", ":", "raise", "# ...
Variant of `self.ftp.pwd()` that supports encoding-fallback. Returns: Current working directory as native string.
[ "Variant", "of", "self", ".", "ftp", ".", "pwd", "()", "that", "supports", "encoding", "-", "fallback", ".", "Returns", ":", "Current", "working", "directory", "as", "native", "string", "." ]
python
train
PmagPy/PmagPy
SPD/lib/lib_arai_plot_statistics.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_arai_plot_statistics.py#L244-L255
def get_R_det2(y_segment, y_avg, y_prime): """ takes in an array of y values, the mean of those values, and the array of y prime values. returns R_det2 """ numerator = sum((numpy.array(y_segment) - numpy.array(y_prime))**2) denominator = sum((numpy.array(y_segment) - y_avg)**2) if denominato...
[ "def", "get_R_det2", "(", "y_segment", ",", "y_avg", ",", "y_prime", ")", ":", "numerator", "=", "sum", "(", "(", "numpy", ".", "array", "(", "y_segment", ")", "-", "numpy", ".", "array", "(", "y_prime", ")", ")", "**", "2", ")", "denominator", "=", ...
takes in an array of y values, the mean of those values, and the array of y prime values. returns R_det2
[ "takes", "in", "an", "array", "of", "y", "values", "the", "mean", "of", "those", "values", "and", "the", "array", "of", "y", "prime", "values", ".", "returns", "R_det2" ]
python
train
openego/ding0
ding0/core/network/__init__.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/core/network/__init__.py#L833-L837
def close(self): """ Close a Circuit Breaker #TODO Check """ self.grid._graph.add_edge(self.branch_nodes[0], self.branch_nodes[1], branch=self.branch) self.status = 'closed'
[ "def", "close", "(", "self", ")", ":", "self", ".", "grid", ".", "_graph", ".", "add_edge", "(", "self", ".", "branch_nodes", "[", "0", "]", ",", "self", ".", "branch_nodes", "[", "1", "]", ",", "branch", "=", "self", ".", "branch", ")", "self", ...
Close a Circuit Breaker #TODO Check
[ "Close", "a", "Circuit", "Breaker", "#TODO", "Check" ]
python
train
trailofbits/manticore
manticore/native/cpu/x86.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/x86.py#L5353-L5357
def CDQ(cpu): """ EDX:EAX = sign-extend of EAX """ cpu.EDX = Operators.EXTRACT(Operators.SEXTEND(cpu.EAX, 32, 64), 32, 32)
[ "def", "CDQ", "(", "cpu", ")", ":", "cpu", ".", "EDX", "=", "Operators", ".", "EXTRACT", "(", "Operators", ".", "SEXTEND", "(", "cpu", ".", "EAX", ",", "32", ",", "64", ")", ",", "32", ",", "32", ")" ]
EDX:EAX = sign-extend of EAX
[ "EDX", ":", "EAX", "=", "sign", "-", "extend", "of", "EAX" ]
python
valid
dmlc/xgboost
python-package/xgboost/core.py
https://github.com/dmlc/xgboost/blob/253fdd8a42d5ec6b819788199584d27bf9ea6253/python-package/xgboost/core.py#L197-L205
def ctypes2buffer(cptr, length): """Convert ctypes pointer to buffer type.""" if not isinstance(cptr, ctypes.POINTER(ctypes.c_char)): raise RuntimeError('expected char pointer') res = bytearray(length) rptr = (ctypes.c_char * length).from_buffer(res) if not ctypes.memmove(rptr, cptr, length)...
[ "def", "ctypes2buffer", "(", "cptr", ",", "length", ")", ":", "if", "not", "isinstance", "(", "cptr", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_char", ")", ")", ":", "raise", "RuntimeError", "(", "'expected char pointer'", ")", "res", "=", "b...
Convert ctypes pointer to buffer type.
[ "Convert", "ctypes", "pointer", "to", "buffer", "type", "." ]
python
train
delph-in/pydelphin
delphin/tdl.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L360-L393
def terminate(self, end): """ Set the value of the tail of the list. Adding values via :meth:`append` places them on the `FIRST` feature of some level of the feature structure (e.g., `REST.FIRST`), while :meth:`terminate` places them on the final `REST` feature (e.g., `R...
[ "def", "terminate", "(", "self", ",", "end", ")", ":", "if", "self", ".", "terminated", ":", "raise", "TdlError", "(", "'Cannot terminate a closed list.'", ")", "if", "end", "==", "LIST_TYPE", ":", "self", ".", "terminated", "=", "False", "elif", "end", "=...
Set the value of the tail of the list. Adding values via :meth:`append` places them on the `FIRST` feature of some level of the feature structure (e.g., `REST.FIRST`), while :meth:`terminate` places them on the final `REST` feature (e.g., `REST.REST`). If *end* is a :class:`Conj...
[ "Set", "the", "value", "of", "the", "tail", "of", "the", "list", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/models/abstract_state.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/abstract_state.py#L524-L548
def store_meta_data(self, copy_path=None): """Save meta data of state model to the file system This method generates a dictionary of the meta data of the state together with the meta data of all state elements (data ports, outcomes, etc.) and stores it on the filesystem. Secure that the...
[ "def", "store_meta_data", "(", "self", ",", "copy_path", "=", "None", ")", ":", "if", "copy_path", ":", "meta_file_path_json", "=", "os", ".", "path", ".", "join", "(", "copy_path", ",", "self", ".", "state", ".", "get_storage_path", "(", ")", ",", "stor...
Save meta data of state model to the file system This method generates a dictionary of the meta data of the state together with the meta data of all state elements (data ports, outcomes, etc.) and stores it on the filesystem. Secure that the store meta data method is called after storing the co...
[ "Save", "meta", "data", "of", "state", "model", "to", "the", "file", "system" ]
python
train
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L416-L447
def add_all(cls, models, commit=True, check_type=False): """Batch method for adding a list of model instances to the db in one get_or_404. Args: models (list): A list of the instances to add. commit (bool, optional): Defaults to True. If False, the trans...
[ "def", "add_all", "(", "cls", ",", "models", ",", "commit", "=", "True", ",", "check_type", "=", "False", ")", ":", "if", "check_type", ":", "for", "model", "in", "models", ":", "if", "not", "isinstance", "(", "model", ",", "cls", ")", ":", "raise", ...
Batch method for adding a list of model instances to the db in one get_or_404. Args: models (list): A list of the instances to add. commit (bool, optional): Defaults to True. If False, the transaction won't get committed. check_type (bool, optional) ...
[ "Batch", "method", "for", "adding", "a", "list", "of", "model", "instances", "to", "the", "db", "in", "one", "get_or_404", "." ]
python
train
apache/incubator-heron
heron/tools/tracker/src/python/handlers/basehandler.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/tracker/src/python/handlers/basehandler.py#L141-L150
def get_argument_environ(self): """ Helper function to get request argument. Raises exception if argument is missing. Returns the environ argument. """ try: return self.get_argument(constants.PARAM_ENVIRON) except tornado.web.MissingArgumentError as e: raise Exception(e.log_messa...
[ "def", "get_argument_environ", "(", "self", ")", ":", "try", ":", "return", "self", ".", "get_argument", "(", "constants", ".", "PARAM_ENVIRON", ")", "except", "tornado", ".", "web", ".", "MissingArgumentError", "as", "e", ":", "raise", "Exception", "(", "e"...
Helper function to get request argument. Raises exception if argument is missing. Returns the environ argument.
[ "Helper", "function", "to", "get", "request", "argument", ".", "Raises", "exception", "if", "argument", "is", "missing", ".", "Returns", "the", "environ", "argument", "." ]
python
valid
pyviz/holoviews
holoviews/plotting/mpl/util.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/mpl/util.py#L101-L134
def filter_styles(style, group, other_groups, blacklist=[]): """ Filters styles which are specific to a particular artist, e.g. for a GraphPlot this will filter options specific to the nodes and edges. Arguments --------- style: dict Dictionary of styles and values group: str ...
[ "def", "filter_styles", "(", "style", ",", "group", ",", "other_groups", ",", "blacklist", "=", "[", "]", ")", ":", "group", "=", "group", "+", "'_'", "filtered", "=", "{", "}", "for", "k", ",", "v", "in", "style", ".", "items", "(", ")", ":", "i...
Filters styles which are specific to a particular artist, e.g. for a GraphPlot this will filter options specific to the nodes and edges. Arguments --------- style: dict Dictionary of styles and values group: str Group within the styles to filter for other_groups: list ...
[ "Filters", "styles", "which", "are", "specific", "to", "a", "particular", "artist", "e", ".", "g", ".", "for", "a", "GraphPlot", "this", "will", "filter", "options", "specific", "to", "the", "nodes", "and", "edges", "." ]
python
train
ethereum/py-evm
eth/tools/_utils/normalization.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/tools/_utils/normalization.py#L72-L90
def normalize_int(value: IntConvertible) -> int: """ Robust to integer conversion, handling hex values, string representations, and special cases like `0x`. """ if is_integer(value): return cast(int, value) elif is_bytes(value): return big_endian_to_int(value) elif is_hex(val...
[ "def", "normalize_int", "(", "value", ":", "IntConvertible", ")", "->", "int", ":", "if", "is_integer", "(", "value", ")", ":", "return", "cast", "(", "int", ",", "value", ")", "elif", "is_bytes", "(", "value", ")", ":", "return", "big_endian_to_int", "(...
Robust to integer conversion, handling hex values, string representations, and special cases like `0x`.
[ "Robust", "to", "integer", "conversion", "handling", "hex", "values", "string", "representations", "and", "special", "cases", "like", "0x", "." ]
python
train
jupyter-widgets/ipywidgets
ipywidgets/widgets/widget_selection.py
https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/ipywidgets/widgets/widget_selection.py#L355-L360
def _validate_value(self, proposal): "Replace all values with the actual objects in the options list" try: return tuple(findvalue(self._options_values, i, self.equals) for i in proposal.value) except ValueError: raise TraitError('Invalid selection: value not found')
[ "def", "_validate_value", "(", "self", ",", "proposal", ")", ":", "try", ":", "return", "tuple", "(", "findvalue", "(", "self", ".", "_options_values", ",", "i", ",", "self", ".", "equals", ")", "for", "i", "in", "proposal", ".", "value", ")", "except"...
Replace all values with the actual objects in the options list
[ "Replace", "all", "values", "with", "the", "actual", "objects", "in", "the", "options", "list" ]
python
train
PmagPy/PmagPy
programs/s_hext.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/s_hext.py#L8-L76
def main(): """ NAME s_hext.py DESCRIPTION calculates Hext statistics for tensor data SYNTAX s_hext.py [-h][-i][-f file] [<filename] OPTIONS -h prints help message and quits -f file specifies filename on command line -l NMEAS do line by line instead of...
[ "def", "main", "(", ")", ":", "ave", "=", "1", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "if", "'-l'", "in", "sys", ".", "argv", ":", "ind", "=", "sys", ".", "argv", ...
NAME s_hext.py DESCRIPTION calculates Hext statistics for tensor data SYNTAX s_hext.py [-h][-i][-f file] [<filename] OPTIONS -h prints help message and quits -f file specifies filename on command line -l NMEAS do line by line instead of whole file, use number ...
[ "NAME", "s_hext", ".", "py" ]
python
train
saltstack/salt
salt/modules/chef.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/chef.py#L145-L206
def solo(whyrun=False, logfile=None, **kwargs): ''' Execute a chef solo run and return a dict with the stderr, stdout, return code, and pid. CLI Example: .. code-block:: bash salt '*' chef.solo override-runlist=test config The configuration file to use ...
[ "def", "solo", "(", "whyrun", "=", "False", ",", "logfile", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "logfile", "is", "None", ":", "logfile", "=", "_default_logfile", "(", "'chef-solo'", ")", "args", "=", "[", "'chef-solo'", ",", "'--no-co...
Execute a chef solo run and return a dict with the stderr, stdout, return code, and pid. CLI Example: .. code-block:: bash salt '*' chef.solo override-runlist=test config The configuration file to use environment Set the Chef Environment on the node group Gr...
[ "Execute", "a", "chef", "solo", "run", "and", "return", "a", "dict", "with", "the", "stderr", "stdout", "return", "code", "and", "pid", "." ]
python
train
refindlyllc/rets
rets/session.py
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/session.py#L253-L286
def get_object(self, resource, object_type, content_ids, object_ids='*', location=0): """ Get a list of Objects from a resource :param resource: The resource to get objects from :param object_type: The type of object to fetch :param content_ids: The unique id of the item to get o...
[ "def", "get_object", "(", "self", ",", "resource", ",", "object_type", ",", "content_ids", ",", "object_ids", "=", "'*'", ",", "location", "=", "0", ")", ":", "object_helper", "=", "GetObject", "(", ")", "request_ids", "=", "object_helper", ".", "ids", "("...
Get a list of Objects from a resource :param resource: The resource to get objects from :param object_type: The type of object to fetch :param content_ids: The unique id of the item to get objects for :param object_ids: ids of the objects to download :param location: The path to ...
[ "Get", "a", "list", "of", "Objects", "from", "a", "resource", ":", "param", "resource", ":", "The", "resource", "to", "get", "objects", "from", ":", "param", "object_type", ":", "The", "type", "of", "object", "to", "fetch", ":", "param", "content_ids", "...
python
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L17-L29
def _safe_match_string(value): """Sanitize and represent a string argument in MATCH.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attempting...
[ "def", "_safe_match_string", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "# should only happen in py3", "value", "=", "value", ".", "d...
Sanitize and represent a string argument in MATCH.
[ "Sanitize", "and", "represent", "a", "string", "argument", "in", "MATCH", "." ]
python
train
croach/django-simple-rest
simple_rest/utils/decorators.py
https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/utils/decorators.py#L7-L32
def wrap_object(obj, decorator): """ Decorates the given object with the decorator function. If obj is a method, the method is decorated with the decorator function and returned. If obj is a class (i.e., a class based view), the methods in the class corresponding to HTTP methods will be decorated a...
[ "def", "wrap_object", "(", "obj", ",", "decorator", ")", ":", "actual_decorator", "=", "method_decorator", "(", "decorator", ")", "if", "inspect", ".", "isfunction", "(", "obj", ")", ":", "wrapped_obj", "=", "actual_decorator", "(", "obj", ")", "update_wrapper...
Decorates the given object with the decorator function. If obj is a method, the method is decorated with the decorator function and returned. If obj is a class (i.e., a class based view), the methods in the class corresponding to HTTP methods will be decorated and the resultant class object will be ret...
[ "Decorates", "the", "given", "object", "with", "the", "decorator", "function", "." ]
python
train
pycontribs/pyrax
pyrax/cloudloadbalancers.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudloadbalancers.py#L522-L529
def add_nodes(self, lb, nodes): """Adds the list of nodes to the specified load balancer.""" if not isinstance(nodes, (list, tuple)): nodes = [nodes] node_dicts = [nd.to_dict() for nd in nodes] resp, body = self.api.method_post("/loadbalancers/%s/nodes" % lb.id, ...
[ "def", "add_nodes", "(", "self", ",", "lb", ",", "nodes", ")", ":", "if", "not", "isinstance", "(", "nodes", ",", "(", "list", ",", "tuple", ")", ")", ":", "nodes", "=", "[", "nodes", "]", "node_dicts", "=", "[", "nd", ".", "to_dict", "(", ")", ...
Adds the list of nodes to the specified load balancer.
[ "Adds", "the", "list", "of", "nodes", "to", "the", "specified", "load", "balancer", "." ]
python
train
limist/py-moneyed
moneyed/classes.py
https://github.com/limist/py-moneyed/blob/1822e9f77edc6608b429e54c8831b873af9a4de6/moneyed/classes.py#L158-L166
def round(self, ndigits=0): """ Rounds the amount using the current ``Decimal`` rounding algorithm. """ if ndigits is None: ndigits = 0 return self.__class__( amount=self.amount.quantize(Decimal('1e' + str(-ndigits))), currency=self.currency)
[ "def", "round", "(", "self", ",", "ndigits", "=", "0", ")", ":", "if", "ndigits", "is", "None", ":", "ndigits", "=", "0", "return", "self", ".", "__class__", "(", "amount", "=", "self", ".", "amount", ".", "quantize", "(", "Decimal", "(", "'1e'", "...
Rounds the amount using the current ``Decimal`` rounding algorithm.
[ "Rounds", "the", "amount", "using", "the", "current", "Decimal", "rounding", "algorithm", "." ]
python
train
SuperCowPowers/bat
bat/bro_log_reader.py
https://github.com/SuperCowPowers/bat/blob/069e6bc52843dc07760969c531cc442ca7da8e0c/bat/bro_log_reader.py#L115-L152
def _parse_bro_header(self, bro_log): """Parse the Bro log header section. Format example: #separator \x09 #set_separator , #empty_field (empty) #unset_field - #path httpheader_recon #fields ts origin us...
[ "def", "_parse_bro_header", "(", "self", ",", "bro_log", ")", ":", "# Open the Bro logfile", "with", "open", "(", "bro_log", ",", "'r'", ")", "as", "bro_file", ":", "# Skip until you find the #fields line", "_line", "=", "bro_file", ".", "readline", "(", ")", "w...
Parse the Bro log header section. Format example: #separator \x09 #set_separator , #empty_field (empty) #unset_field - #path httpheader_recon #fields ts origin useragent header_events_json #types...
[ "Parse", "the", "Bro", "log", "header", "section", "." ]
python
train
log2timeline/plaso
plaso/cli/extraction_tool.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/extraction_tool.py#L195-L212
def _ReadParserPresetsFromFile(self): """Reads the parser presets from the presets.yaml file. Raises: BadConfigOption: if the parser presets file cannot be read. """ self._presets_file = os.path.join( self._data_location, self._PRESETS_FILE_NAME) if not os.path.isfile(self._presets_fi...
[ "def", "_ReadParserPresetsFromFile", "(", "self", ")", ":", "self", ".", "_presets_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_data_location", ",", "self", ".", "_PRESETS_FILE_NAME", ")", "if", "not", "os", ".", "path", ".", "isfile", ...
Reads the parser presets from the presets.yaml file. Raises: BadConfigOption: if the parser presets file cannot be read.
[ "Reads", "the", "parser", "presets", "from", "the", "presets", ".", "yaml", "file", "." ]
python
train
MatiasSM/fcb
fcb/processing/transformations/ToImage.py
https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/transformations/ToImage.py#L15-L23
def _determine_dimensions(num_of_pixels): """ Given a number of pixels, determines the largest width and height that define a rectangle with such an area """ for x in xrange(int(math.sqrt(num_of_pixels)) + 1, 1, -1): if num_of_pixels % x == 0: return num_of_pixels // x, x r...
[ "def", "_determine_dimensions", "(", "num_of_pixels", ")", ":", "for", "x", "in", "xrange", "(", "int", "(", "math", ".", "sqrt", "(", "num_of_pixels", ")", ")", "+", "1", ",", "1", ",", "-", "1", ")", ":", "if", "num_of_pixels", "%", "x", "==", "0...
Given a number of pixels, determines the largest width and height that define a rectangle with such an area
[ "Given", "a", "number", "of", "pixels", "determines", "the", "largest", "width", "and", "height", "that", "define", "a", "rectangle", "with", "such", "an", "area" ]
python
train
leosartaj/sub
sub/main.py
https://github.com/leosartaj/sub/blob/9a8e55a5326c3b41357eedd235e7c36f253db2e0/sub/main.py#L95-L115
def download(name, options): """ download a file or all files in a directory """ dire = os.path.dirname(name) # returns the directory name fName = os.path.basename(name) # returns the filename fNameOnly, fExt = os.path.splitext(fName) dwn = 0 if fileExists(fName, dire) and not fileExis...
[ "def", "download", "(", "name", ",", "options", ")", ":", "dire", "=", "os", ".", "path", ".", "dirname", "(", "name", ")", "# returns the directory name", "fName", "=", "os", ".", "path", ".", "basename", "(", "name", ")", "# returns the filename", "fName...
download a file or all files in a directory
[ "download", "a", "file", "or", "all", "files", "in", "a", "directory" ]
python
train
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/mf.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/mf.py#L1070-L1139
def _resolveCtypesImports(cbinaries): """Completes ctypes BINARY entries for modules with their full path. """ if is_unix: envvar = "LD_LIBRARY_PATH" elif is_darwin: envvar = "DYLD_LIBRARY_PATH" else: envvar = "PATH" def _setPaths(): path = os.pathsep.join(PyInst...
[ "def", "_resolveCtypesImports", "(", "cbinaries", ")", ":", "if", "is_unix", ":", "envvar", "=", "\"LD_LIBRARY_PATH\"", "elif", "is_darwin", ":", "envvar", "=", "\"DYLD_LIBRARY_PATH\"", "else", ":", "envvar", "=", "\"PATH\"", "def", "_setPaths", "(", ")", ":", ...
Completes ctypes BINARY entries for modules with their full path.
[ "Completes", "ctypes", "BINARY", "entries", "for", "modules", "with", "their", "full", "path", "." ]
python
train
klahnakoski/pyLibrary
mo_threads/threads.py
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L68-L73
def add(self, target, *args, **kwargs): """ target IS THE FUNCTION TO EXECUTE IN THE THREAD """ t = Thread.run(target.__name__, target, *args, **kwargs) self.threads.append(t)
[ "def", "add", "(", "self", ",", "target", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "t", "=", "Thread", ".", "run", "(", "target", ".", "__name__", ",", "target", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "threads"...
target IS THE FUNCTION TO EXECUTE IN THE THREAD
[ "target", "IS", "THE", "FUNCTION", "TO", "EXECUTE", "IN", "THE", "THREAD" ]
python
train
sveetch/crispy-forms-foundation
crispy_forms_foundation/__init__.py
https://github.com/sveetch/crispy-forms-foundation/blob/835a4152ef9b2a096b9a27748341ef751823b9f0/crispy_forms_foundation/__init__.py#L13-L22
def _extract_version(package_name): """ Get package version from installed distribution or configuration file if not installed """ try: return pkg_resources.get_distribution(package_name).version except pkg_resources.DistributionNotFound: _conf = read_configuration(os.path.join(P...
[ "def", "_extract_version", "(", "package_name", ")", ":", "try", ":", "return", "pkg_resources", ".", "get_distribution", "(", "package_name", ")", ".", "version", "except", "pkg_resources", ".", "DistributionNotFound", ":", "_conf", "=", "read_configuration", "(", ...
Get package version from installed distribution or configuration file if not installed
[ "Get", "package", "version", "from", "installed", "distribution", "or", "configuration", "file", "if", "not", "installed" ]
python
test
osrg/ryu
ryu/lib/lacplib.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/lacplib.py#L112-L135
def flow_removed_handler(self, evt): """FlowRemoved event handler. when the removed flow entry was for LACP, set the status of the slave i/f to disabled, and send a event.""" msg = evt.msg datapath = msg.datapath ofproto = datapath.ofproto dpid = datapath.id ...
[ "def", "flow_removed_handler", "(", "self", ",", "evt", ")", ":", "msg", "=", "evt", ".", "msg", "datapath", "=", "msg", ".", "datapath", "ofproto", "=", "datapath", ".", "ofproto", "dpid", "=", "datapath", ".", "id", "match", "=", "msg", ".", "match",...
FlowRemoved event handler. when the removed flow entry was for LACP, set the status of the slave i/f to disabled, and send a event.
[ "FlowRemoved", "event", "handler", ".", "when", "the", "removed", "flow", "entry", "was", "for", "LACP", "set", "the", "status", "of", "the", "slave", "i", "/", "f", "to", "disabled", "and", "send", "a", "event", "." ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/preprovision/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/preprovision/__init__.py#L94-L115
def _set_rbridge_id(self, v, load=False): """ Setter method for rbridge_id, mapped from YANG variable /preprovision/rbridge_id (list) If this variable is read-only (config: false) in the source YANG file, then _set_rbridge_id is considered as a private method. Backends looking to populate this varia...
[ "def", "_set_rbridge_id", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "bas...
Setter method for rbridge_id, mapped from YANG variable /preprovision/rbridge_id (list) If this variable is read-only (config: false) in the source YANG file, then _set_rbridge_id is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_rbridge_...
[ "Setter", "method", "for", "rbridge_id", "mapped", "from", "YANG", "variable", "/", "preprovision", "/", "rbridge_id", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", ...
python
train
RJT1990/pyflux
pyflux/ssm/nllm.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L278-L298
def _animate_bbvi(self,stored_latent_variables,stored_predictive_likelihood): """ Produces animated plot of BBVI optimization Returns ---------- None (changes model attributes) """ from matplotlib.animation import FuncAnimation, writers import matplotlib.pyplot ...
[ "def", "_animate_bbvi", "(", "self", ",", "stored_latent_variables", ",", "stored_predictive_likelihood", ")", ":", "from", "matplotlib", ".", "animation", "import", "FuncAnimation", ",", "writers", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "seab...
Produces animated plot of BBVI optimization Returns ---------- None (changes model attributes)
[ "Produces", "animated", "plot", "of", "BBVI", "optimization" ]
python
train
pytest-dev/pytest-xdist
xdist/dsession.py
https://github.com/pytest-dev/pytest-xdist/blob/9fcf8fa636bc69ee6cac9348a6ec20c87f2bb5e4/xdist/dsession.py#L238-L240
def worker_logstart(self, node, nodeid, location): """Emitted when a node calls the pytest_runtest_logstart hook.""" self.config.hook.pytest_runtest_logstart(nodeid=nodeid, location=location)
[ "def", "worker_logstart", "(", "self", ",", "node", ",", "nodeid", ",", "location", ")", ":", "self", ".", "config", ".", "hook", ".", "pytest_runtest_logstart", "(", "nodeid", "=", "nodeid", ",", "location", "=", "location", ")" ]
Emitted when a node calls the pytest_runtest_logstart hook.
[ "Emitted", "when", "a", "node", "calls", "the", "pytest_runtest_logstart", "hook", "." ]
python
train
pypa/pipenv
pipenv/vendor/orderedmultidict/orderedmultidict.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/orderedmultidict/orderedmultidict.py#L274-L282
def getlist(self, key, default=[]): """ Returns: The list of values for <key> if <key> is in the dictionary, else <default>. If <default> is not provided, an empty list is returned. """ if key in self: return [node.value for node in self._map[key]] ret...
[ "def", "getlist", "(", "self", ",", "key", ",", "default", "=", "[", "]", ")", ":", "if", "key", "in", "self", ":", "return", "[", "node", ".", "value", "for", "node", "in", "self", ".", "_map", "[", "key", "]", "]", "return", "default" ]
Returns: The list of values for <key> if <key> is in the dictionary, else <default>. If <default> is not provided, an empty list is returned.
[ "Returns", ":", "The", "list", "of", "values", "for", "<key", ">", "if", "<key", ">", "is", "in", "the", "dictionary", "else", "<default", ">", ".", "If", "<default", ">", "is", "not", "provided", "an", "empty", "list", "is", "returned", "." ]
python
train
gwastro/pycbc-glue
pycbc_glue/segments.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/segments.py#L1207-L1232
def is_coincident(self, other, keys = None): """ Return True if any segment in any list in self intersects any segment in any list in other. If the optional keys argument is not None, then it should be an iterable of keys and only segment lists for those keys will be considered in the test (instead of rais...
[ "def", "is_coincident", "(", "self", ",", "other", ",", "keys", "=", "None", ")", ":", "if", "keys", "is", "not", "None", ":", "keys", "=", "set", "(", "keys", ")", "self", "=", "tuple", "(", "self", "[", "key", "]", "for", "key", "in", "set", ...
Return True if any segment in any list in self intersects any segment in any list in other. If the optional keys argument is not None, then it should be an iterable of keys and only segment lists for those keys will be considered in the test (instead of raising KeyError, keys not present in both segment list...
[ "Return", "True", "if", "any", "segment", "in", "any", "list", "in", "self", "intersects", "any", "segment", "in", "any", "list", "in", "other", ".", "If", "the", "optional", "keys", "argument", "is", "not", "None", "then", "it", "should", "be", "an", ...
python
train
materialsproject/pymatgen-db
matgendb/builders/util.py
https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/builders/util.py#L36-L45
def get_schema_dir(db_version=1): """Get path to directory with schemata. :param db_version: Version of the database :type db_version: int :return: Path :rtype: str """ v = str(db_version) return os.path.join(_top_dir, '..', 'schemata', 'versions', v)
[ "def", "get_schema_dir", "(", "db_version", "=", "1", ")", ":", "v", "=", "str", "(", "db_version", ")", "return", "os", ".", "path", ".", "join", "(", "_top_dir", ",", "'..'", ",", "'schemata'", ",", "'versions'", ",", "v", ")" ]
Get path to directory with schemata. :param db_version: Version of the database :type db_version: int :return: Path :rtype: str
[ "Get", "path", "to", "directory", "with", "schemata", "." ]
python
train
svinota/mdns
mdns/zeroconf.py
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1712-L1719
def get_service_info(self, type, name, timeout=3000): """Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.""" info = ServiceInfo(type, name) if info.request(self, timeout): ...
[ "def", "get_service_info", "(", "self", ",", "type", ",", "name", ",", "timeout", "=", "3000", ")", ":", "info", "=", "ServiceInfo", "(", "type", ",", "name", ")", "if", "info", ".", "request", "(", "self", ",", "timeout", ")", ":", "return", "info",...
Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.
[ "Returns", "network", "s", "service", "information", "for", "a", "particular", "name", "and", "type", "or", "None", "if", "no", "service", "matches", "by", "the", "timeout", "which", "defaults", "to", "3", "seconds", "." ]
python
train
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L56-L68
def load_args(self, args, clargs): """Parse arguments and return configuration settings. """ # Parse All Arguments args = self.parser.parse_args(args=clargs, namespace=args) # Print the help information if no subcommand is given # subcommand is required for operation ...
[ "def", "load_args", "(", "self", ",", "args", ",", "clargs", ")", ":", "# Parse All Arguments", "args", "=", "self", ".", "parser", ".", "parse_args", "(", "args", "=", "clargs", ",", "namespace", "=", "args", ")", "# Print the help information if no subcommand ...
Parse arguments and return configuration settings.
[ "Parse", "arguments", "and", "return", "configuration", "settings", "." ]
python
train
Nic30/ipCorePackager
ipCorePackager/packager.py
https://github.com/Nic30/ipCorePackager/blob/0af4e56ebfdc3749fffa40d50d9ccbf8b5445881/ipCorePackager/packager.py#L67-L84
def mkAutoGui(self): """ :summary: automatically generate simple gui in TCL """ gui = GuiBuilder() p0 = gui.page("Main") handlers = [] for p in self.iterParams(self.top): name = self.getParamPhysicalName(p) p0.param(name) for fn...
[ "def", "mkAutoGui", "(", "self", ")", ":", "gui", "=", "GuiBuilder", "(", ")", "p0", "=", "gui", ".", "page", "(", "\"Main\"", ")", "handlers", "=", "[", "]", "for", "p", "in", "self", ".", "iterParams", "(", "self", ".", "top", ")", ":", "name",...
:summary: automatically generate simple gui in TCL
[ ":", "summary", ":", "automatically", "generate", "simple", "gui", "in", "TCL" ]
python
train
LordSputnik/mutagen
mutagen/apev2.py
https://github.com/LordSputnik/mutagen/blob/38e62c8dc35c72b16554f5dbe7c0fde91acc3411/mutagen/apev2.py#L386-L432
def save(self, filename=None): """Save changes to a file. If no filename is given, the one most recently loaded is used. Tags are always written at the end of the file, and include a header and a footer. """ filename = filename or self.filename try: ...
[ "def", "save", "(", "self", ",", "filename", "=", "None", ")", ":", "filename", "=", "filename", "or", "self", ".", "filename", "try", ":", "fileobj", "=", "open", "(", "filename", ",", "\"r+b\"", ")", "except", "IOError", ":", "fileobj", "=", "open", ...
Save changes to a file. If no filename is given, the one most recently loaded is used. Tags are always written at the end of the file, and include a header and a footer.
[ "Save", "changes", "to", "a", "file", "." ]
python
test
plivo/sharq
sharq/queue.py
https://github.com/plivo/sharq/blob/32bbfbdcbbaa8e154271ffd125ac4500382f3d19/sharq/queue.py#L76-L122
def _load_lua_scripts(self): """Loads all lua scripts required by SharQ.""" # load lua scripts lua_script_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'scripts/lua' ) with open(os.path.join( lua_script_path, ...
[ "def", "_load_lua_scripts", "(", "self", ")", ":", "# load lua scripts", "lua_script_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'scripts/lua...
Loads all lua scripts required by SharQ.
[ "Loads", "all", "lua", "scripts", "required", "by", "SharQ", "." ]
python
train
titusjan/argos
argos/config/qtctis.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/qtctis.py#L576-L592
def createPen(self, altStyle=None, altWidth=None): """ Creates a pen from the config values with the style overridden by altStyle if the None-option is selected in the combo box. """ pen = self.configValue if pen is not None: style = self.findByNodePath('style')....
[ "def", "createPen", "(", "self", ",", "altStyle", "=", "None", ",", "altWidth", "=", "None", ")", ":", "pen", "=", "self", ".", "configValue", "if", "pen", "is", "not", "None", ":", "style", "=", "self", ".", "findByNodePath", "(", "'style'", ")", "....
Creates a pen from the config values with the style overridden by altStyle if the None-option is selected in the combo box.
[ "Creates", "a", "pen", "from", "the", "config", "values", "with", "the", "style", "overridden", "by", "altStyle", "if", "the", "None", "-", "option", "is", "selected", "in", "the", "combo", "box", "." ]
python
train
swistakm/graceful
src/graceful/resources/mixins.py
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L168-L188
def on_delete(self, req, resp, handler=None, **kwargs): """Respond on DELETE HTTP request assuming resource deletion flow. This request handler assumes that DELETE requests are associated with resource deletion. Thus default flow for such requests is: * Delete existing resource instanc...
[ "def", "on_delete", "(", "self", ",", "req", ",", "resp", ",", "handler", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "handle", "(", "handler", "or", "self", ".", "delete", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")", ...
Respond on DELETE HTTP request assuming resource deletion flow. This request handler assumes that DELETE requests are associated with resource deletion. Thus default flow for such requests is: * Delete existing resource instance. * Set response status code to ``202 Accepted``. ...
[ "Respond", "on", "DELETE", "HTTP", "request", "assuming", "resource", "deletion", "flow", "." ]
python
train
python-openxml/python-docx
docx/opc/pkgreader.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L256-L270
def target_partname(self): """ |PackURI| instance containing partname targeted by this relationship. Raises ``ValueError`` on reference if target_mode is ``'External'``. Use :attr:`target_mode` to check before referencing. """ if self.is_external: msg = ('targ...
[ "def", "target_partname", "(", "self", ")", ":", "if", "self", ".", "is_external", ":", "msg", "=", "(", "'target_partname attribute on Relationship is undefined w'", "'here TargetMode == \"External\"'", ")", "raise", "ValueError", "(", "msg", ")", "# lazy-load _target_pa...
|PackURI| instance containing partname targeted by this relationship. Raises ``ValueError`` on reference if target_mode is ``'External'``. Use :attr:`target_mode` to check before referencing.
[ "|PackURI|", "instance", "containing", "partname", "targeted", "by", "this", "relationship", ".", "Raises", "ValueError", "on", "reference", "if", "target_mode", "is", "External", ".", "Use", ":", "attr", ":", "target_mode", "to", "check", "before", "referencing",...
python
train
iterative/dvc
dvc/config.py
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L455-L489
def save(self, config=None): """Saves config to config files. Args: config (configobj.ConfigObj): optional config object to save. Raises: dvc.config.ConfigError: thrown if failed to write config file. """ if config is not None: clist = [confi...
[ "def", "save", "(", "self", ",", "config", "=", "None", ")", ":", "if", "config", "is", "not", "None", ":", "clist", "=", "[", "config", "]", "else", ":", "clist", "=", "[", "self", ".", "_system_config", ",", "self", ".", "_global_config", ",", "s...
Saves config to config files. Args: config (configobj.ConfigObj): optional config object to save. Raises: dvc.config.ConfigError: thrown if failed to write config file.
[ "Saves", "config", "to", "config", "files", "." ]
python
train
rstoneback/pysatCDF
pysatCDF/_cdf.py
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L538-L667
def to_pysat(self, flatten_twod=True, units_label='UNITS', name_label='long_name', fill_label='FILLVAL', plot_label='FieldNam', min_label='ValidMin', max_label='ValidMax', notes_label='Var_Notes', desc_label='CatDesc', axi...
[ "def", "to_pysat", "(", "self", ",", "flatten_twod", "=", "True", ",", "units_label", "=", "'UNITS'", ",", "name_label", "=", "'long_name'", ",", "fill_label", "=", "'FILLVAL'", ",", "plot_label", "=", "'FieldNam'", ",", "min_label", "=", "'ValidMin'", ",", ...
Exports loaded CDF data into data, meta for pysat module Notes ----- The *_labels should be set to the values in the file, if present. Note that once the meta object returned from this function is attached to a pysat.Instrument object then the *_labels on the Instrument ...
[ "Exports", "loaded", "CDF", "data", "into", "data", "meta", "for", "pysat", "module", "Notes", "-----", "The", "*", "_labels", "should", "be", "set", "to", "the", "values", "in", "the", "file", "if", "present", ".", "Note", "that", "once", "the", "meta",...
python
valid
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L404-L412
def inverse_mercator(xy): """ Given coordinates in spherical mercator, return a lon,lat tuple. """ lon = (xy[0] / 20037508.34) * 180 lat = (xy[1] / 20037508.34) * 180 lat = 180 / math.pi * \ (2 * math.atan(math.exp(lat * math.pi / 180)) - math.pi / 2) return (lon, lat)
[ "def", "inverse_mercator", "(", "xy", ")", ":", "lon", "=", "(", "xy", "[", "0", "]", "/", "20037508.34", ")", "*", "180", "lat", "=", "(", "xy", "[", "1", "]", "/", "20037508.34", ")", "*", "180", "lat", "=", "180", "/", "math", ".", "pi", "...
Given coordinates in spherical mercator, return a lon,lat tuple.
[ "Given", "coordinates", "in", "spherical", "mercator", "return", "a", "lon", "lat", "tuple", "." ]
python
train
quantopian/empyrical
empyrical/perf_attrib.py
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/perf_attrib.py#L4-L97
def perf_attrib(returns, positions, factor_returns, factor_loadings): """ Attributes the performance of a returns stream to a set of risk factors. Performance attribution determines how much each risk factor, e.g., momentum, the technology sector, etc., c...
[ "def", "perf_attrib", "(", "returns", ",", "positions", ",", "factor_returns", ",", "factor_loadings", ")", ":", "risk_exposures_portfolio", "=", "compute_exposures", "(", "positions", ",", "factor_loadings", ")", "perf_attrib_by_factor", "=", "risk_exposures_portfolio", ...
Attributes the performance of a returns stream to a set of risk factors. Performance attribution determines how much each risk factor, e.g., momentum, the technology sector, etc., contributed to total returns, as well as the daily exposure to each of the risk factors. The returns that can be attributed...
[ "Attributes", "the", "performance", "of", "a", "returns", "stream", "to", "a", "set", "of", "risk", "factors", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xorbtreewidget/xorbtreewidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L1172-L1181
def emitRecordMiddleClicked(self, item): """ Emits the record clicked signal for the given item, provided the signals are not currently blocked. :param item | <QTreeWidgetItem> """ # emit that the record has been double clicked if isinstance(...
[ "def", "emitRecordMiddleClicked", "(", "self", ",", "item", ")", ":", "# emit that the record has been double clicked\r", "if", "isinstance", "(", "item", ",", "XOrbRecordItem", ")", "and", "not", "self", ".", "signalsBlocked", "(", ")", ":", "self", ".", "recordM...
Emits the record clicked signal for the given item, provided the signals are not currently blocked. :param item | <QTreeWidgetItem>
[ "Emits", "the", "record", "clicked", "signal", "for", "the", "given", "item", "provided", "the", "signals", "are", "not", "currently", "blocked", ".", ":", "param", "item", "|", "<QTreeWidgetItem", ">" ]
python
train
abourget/gevent-socketio
socketio/packet.py
https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/packet.py#L36-L103
def encode(data, json_dumps=default_json_dumps): """ Encode an attribute dict into a byte string. """ payload = '' msg = str(MSG_TYPES[data['type']]) if msg in ['0', '1']: # '1::' [path] [query] msg += '::' + data['endpoint'] if 'qs' in data and data['qs'] != '': ...
[ "def", "encode", "(", "data", ",", "json_dumps", "=", "default_json_dumps", ")", ":", "payload", "=", "''", "msg", "=", "str", "(", "MSG_TYPES", "[", "data", "[", "'type'", "]", "]", ")", "if", "msg", "in", "[", "'0'", ",", "'1'", "]", ":", "# '1::...
Encode an attribute dict into a byte string.
[ "Encode", "an", "attribute", "dict", "into", "a", "byte", "string", "." ]
python
valid
paramiko/paramiko
paramiko/sftp_client.py
https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/sftp_client.py#L402-L423
def rename(self, oldpath, newpath): """ Rename a file or folder from ``oldpath`` to ``newpath``. .. note:: This method implements 'standard' SFTP ``RENAME`` behavior; those seeking the OpenSSH "POSIX rename" extension behavior should use `posix_rename`. ...
[ "def", "rename", "(", "self", ",", "oldpath", ",", "newpath", ")", ":", "oldpath", "=", "self", ".", "_adjust_cwd", "(", "oldpath", ")", "newpath", "=", "self", ".", "_adjust_cwd", "(", "newpath", ")", "self", ".", "_log", "(", "DEBUG", ",", "\"rename(...
Rename a file or folder from ``oldpath`` to ``newpath``. .. note:: This method implements 'standard' SFTP ``RENAME`` behavior; those seeking the OpenSSH "POSIX rename" extension behavior should use `posix_rename`. :param str oldpath: existing name of the...
[ "Rename", "a", "file", "or", "folder", "from", "oldpath", "to", "newpath", "." ]
python
train
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/__init__.py
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L133-L147
def load_config_module(): """ If the config.py file exists, import it as a module. If it does not exist, call sys.exit() with a request to run oaepub configure. """ import imp config_path = config_location() try: config = imp.load_source('config', config_path) except IOError: ...
[ "def", "load_config_module", "(", ")", ":", "import", "imp", "config_path", "=", "config_location", "(", ")", "try", ":", "config", "=", "imp", ".", "load_source", "(", "'config'", ",", "config_path", ")", "except", "IOError", ":", "log", ".", "critical", ...
If the config.py file exists, import it as a module. If it does not exist, call sys.exit() with a request to run oaepub configure.
[ "If", "the", "config", ".", "py", "file", "exists", "import", "it", "as", "a", "module", ".", "If", "it", "does", "not", "exist", "call", "sys", ".", "exit", "()", "with", "a", "request", "to", "run", "oaepub", "configure", "." ]
python
train
apache/incubator-heron
heron/tools/explorer/src/python/physicalplan.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/explorer/src/python/physicalplan.py#L61-L72
def parse_topo_loc(cl_args): """ parse topology location """ try: topo_loc = cl_args['cluster/[role]/[env]'].split('/') topo_name = cl_args['topology-name'] topo_loc.append(topo_name) if len(topo_loc) != 4: raise return topo_loc except Exception: Log.error('Invalid topology location'...
[ "def", "parse_topo_loc", "(", "cl_args", ")", ":", "try", ":", "topo_loc", "=", "cl_args", "[", "'cluster/[role]/[env]'", "]", ".", "split", "(", "'/'", ")", "topo_name", "=", "cl_args", "[", "'topology-name'", "]", "topo_loc", ".", "append", "(", "topo_name...
parse topology location
[ "parse", "topology", "location" ]
python
valid
tradenity/python-sdk
tradenity/resources/gateway.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/gateway.py#L291-L313
def list_all_gateways(cls, **kwargs): """List Gateways Return a list of Gateways This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.list_all_gateways(async=True) >>> result = thread.get()...
[ "def", "list_all_gateways", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_list_all_gateways_with_http_info", "(", "*",...
List Gateways Return a list of Gateways This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.list_all_gateways(async=True) >>> result = thread.get() :param async bool :param int pa...
[ "List", "Gateways" ]
python
train