body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def __init__(self, name, width, height):
'Create a representation of a CIF resolution.\n\n :param name: CIF standard name of the resolution.\n :type name: basestring\n :param width: Width of the resolution in pixels.\n :type width: int\n :param height: Height of the resolution in ... | -4,374,105,267,372,580,400 | Create a representation of a CIF resolution.
:param name: CIF standard name of the resolution.
:type name: basestring
:param width: Width of the resolution in pixels.
:type width: int
:param height: Height of the resolution in pixels.
:type height: int | nodes/axis.py | __init__ | MarcoStb1993/axis_camera | python | def __init__(self, name, width, height):
'Create a representation of a CIF resolution.\n\n :param name: CIF standard name of the resolution.\n :type name: basestring\n :param width: Width of the resolution in pixels.\n :type width: int\n :param height: Height of the resolution in ... |
def set_application(self, app, callback=None):
'\n Set ``CommandLineInterface`` instance for this connection.\n (This can be replaced any time.)\n\n :param cli: CommandLineInterface instance.\n :param callback: Callable that takes the result of the CLI.\n '
assert isinstance(a... | -4,972,495,098,842,824,000 | Set ``CommandLineInterface`` instance for this connection.
(This can be replaced any time.)
:param cli: CommandLineInterface instance.
:param callback: Callable that takes the result of the CLI. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | set_application | sainjusajan/django-oscar | python | def set_application(self, app, callback=None):
'\n Set ``CommandLineInterface`` instance for this connection.\n (This can be replaced any time.)\n\n :param cli: CommandLineInterface instance.\n :param callback: Callable that takes the result of the CLI.\n '
assert isinstance(a... |
def feed(self, data):
'\n Handler for incoming data. (Called by TelnetServer.)\n '
assert isinstance(data, binary_type)
self.parser.feed(data)
self.cli._redraw()
if self.cli.is_returning:
try:
return_value = self.cli.return_value()
except (EOFError, Keyboard... | 8,441,465,389,694,218,000 | Handler for incoming data. (Called by TelnetServer.) | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | feed | sainjusajan/django-oscar | python | def feed(self, data):
'\n \n '
assert isinstance(data, binary_type)
self.parser.feed(data)
self.cli._redraw()
if self.cli.is_returning:
try:
return_value = self.cli.return_value()
except (EOFError, KeyboardInterrupt) as e:
logger.info('%s, closin... |
def _handle_command(self, command):
'\n Handle command. This will run in a separate thread, in order not\n to block the event loop.\n '
logger.info('Handle command %r', command)
def in_executor():
self.handling_command = True
try:
if (self.callback is not No... | 5,887,364,486,101,096,000 | Handle command. This will run in a separate thread, in order not
to block the event loop. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | _handle_command | sainjusajan/django-oscar | python | def _handle_command(self, command):
'\n Handle command. This will run in a separate thread, in order not\n to block the event loop.\n '
logger.info('Handle command %r', command)
def in_executor():
self.handling_command = True
try:
if (self.callback is not No... |
def erase_screen(self):
'\n Erase output screen.\n '
self.vt100_output.erase_screen()
self.vt100_output.cursor_goto(0, 0)
self.vt100_output.flush() | 862,328,611,296,033,400 | Erase output screen. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | erase_screen | sainjusajan/django-oscar | python | def erase_screen(self):
'\n \n '
self.vt100_output.erase_screen()
self.vt100_output.cursor_goto(0, 0)
self.vt100_output.flush() |
def send(self, data):
'\n Send text to the client.\n '
assert isinstance(data, text_type)
self.stdout.write(data.replace('\n', '\r\n'))
self.stdout.flush() | 8,521,474,259,566,262,000 | Send text to the client. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | send | sainjusajan/django-oscar | python | def send(self, data):
'\n \n '
assert isinstance(data, text_type)
self.stdout.write(data.replace('\n', '\r\n'))
self.stdout.flush() |
def close(self):
'\n Close the connection.\n '
self.application.client_leaving(self)
self.conn.close()
self.closed = True | 1,440,076,575,365,623,600 | Close the connection. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | close | sainjusajan/django-oscar | python | def close(self):
'\n \n '
self.application.client_leaving(self)
self.conn.close()
self.closed = True |
def close(self):
' Ignore. ' | 7,883,102,787,620,217,000 | Ignore. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | close | sainjusajan/django-oscar | python | def close(self):
' ' |
def stop(self):
' Ignore. ' | 2,207,530,068,346,443,300 | Ignore. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | stop | sainjusajan/django-oscar | python | def stop(self):
' ' |
def _process_callbacks(self):
'\n Process callbacks from `call_from_executor` in eventloop.\n '
os.read(self._schedule_pipe[0], 1024)
(calls_from_executor, self._calls_from_executor) = (self._calls_from_executor, [])
for c in calls_from_executor:
c() | -1,612,742,384,304,309,500 | Process callbacks from `call_from_executor` in eventloop. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | _process_callbacks | sainjusajan/django-oscar | python | def _process_callbacks(self):
'\n \n '
os.read(self._schedule_pipe[0], 1024)
(calls_from_executor, self._calls_from_executor) = (self._calls_from_executor, [])
for c in calls_from_executor:
c() |
def run(self):
'\n Run the eventloop for the telnet server.\n '
listen_socket = self.create_socket(self.host, self.port)
logger.info('Listening for telnet connections on %s port %r', self.host, self.port)
try:
while True:
self.connections = set([c for c in self.connecti... | 2,312,991,810,713,612,300 | Run the eventloop for the telnet server. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | run | sainjusajan/django-oscar | python | def run(self):
'\n \n '
listen_socket = self.create_socket(self.host, self.port)
logger.info('Listening for telnet connections on %s port %r', self.host, self.port)
try:
while True:
self.connections = set([c for c in self.connections if (not c.closed)])
conn... |
def _accept(self, listen_socket):
'\n Accept new incoming connection.\n '
(conn, addr) = listen_socket.accept()
connection = TelnetConnection(conn, addr, self.application, self, encoding=self.encoding)
self.connections.add(connection)
logger.info('New connection %r %r', *addr) | 6,325,692,078,672,708,000 | Accept new incoming connection. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | _accept | sainjusajan/django-oscar | python | def _accept(self, listen_socket):
'\n \n '
(conn, addr) = listen_socket.accept()
connection = TelnetConnection(conn, addr, self.application, self, encoding=self.encoding)
self.connections.add(connection)
logger.info('New connection %r %r', *addr) |
def _handle_incoming_data(self, conn):
'\n Handle incoming data on socket.\n '
connection = [c for c in self.connections if (c.conn == conn)][0]
data = conn.recv(1024)
if data:
connection.feed(data)
else:
self.connections.remove(connection) | -6,780,554,973,943,267,000 | Handle incoming data on socket. | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | _handle_incoming_data | sainjusajan/django-oscar | python | def _handle_incoming_data(self, conn):
'\n \n '
connection = [c for c in self.connections if (c.conn == conn)][0]
data = conn.recv(1024)
if data:
connection.feed(data)
else:
self.connections.remove(connection) |
def data_received(data):
" TelnetProtocolParser 'data_received' callback "
assert isinstance(data, binary_type)
try:
result = stdin_decoder[0].decode(data)
inputstream.feed(result)
except UnicodeDecodeError:
stdin_decoder[0] = stdin_decoder_cls()
return '' | -8,787,866,247,884,166,000 | TelnetProtocolParser 'data_received' callback | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | data_received | sainjusajan/django-oscar | python | def data_received(data):
" "
assert isinstance(data, binary_type)
try:
result = stdin_decoder[0].decode(data)
inputstream.feed(result)
except UnicodeDecodeError:
stdin_decoder[0] = stdin_decoder_cls()
return |
def size_received(rows, columns):
" TelnetProtocolParser 'size_received' callback "
self.size = Size(rows=rows, columns=columns)
cb.terminal_size_changed() | 1,583,678,943,765,159,400 | TelnetProtocolParser 'size_received' callback | oscar/lib/python2.7/site-packages/prompt_toolkit/contrib/telnet/server.py | size_received | sainjusajan/django-oscar | python | def size_received(rows, columns):
" "
self.size = Size(rows=rows, columns=columns)
cb.terminal_size_changed() |
def kraken2_transformer(all_rank_summary, output_rank_summaries, ranks):
'Converts a summary of all ranks from kraken into rank-wise profiles\n similar to the CAMI-SIM output\n\n Parameters\n ----------\n all_rank_summary\n output_rank_summaries\n ranks\n\n Returns\n -------\n\n '
all... | 31,499,075,654,049,030 | Converts a summary of all ranks from kraken into rank-wise profiles
similar to the CAMI-SIM output
Parameters
----------
all_rank_summary
output_rank_summaries
ranks
Returns
------- | benchutils/transformers.py | kraken2_transformer | qiyunzhu/taxa-assign-benchmarking | python | def kraken2_transformer(all_rank_summary, output_rank_summaries, ranks):
'Converts a summary of all ranks from kraken into rank-wise profiles\n similar to the CAMI-SIM output\n\n Parameters\n ----------\n all_rank_summary\n output_rank_summaries\n ranks\n\n Returns\n -------\n\n '
all... |
def define_argparse():
' todo, find a way to use this effectively '
import argparse
parser = argparse.ArgumentParser(description='IBEIS super setup')
def add_flag(group, name, help=None):
group.add_argument(name.replace('--', ''), action='store_true', default=False, help=help)
g1 = parser.a... | -2,534,346,957,582,279,000 | todo, find a way to use this effectively | super_setup.py | define_argparse | brmscheiner/ibeis | python | def define_argparse():
' '
import argparse
parser = argparse.ArgumentParser(description='IBEIS super setup')
def add_flag(group, name, help=None):
group.add_argument(name.replace('--', ), action='store_true', default=False, help=help)
g1 = parser.add_argument_group('setup')
add_flag(g1... |
def get_plat_specifier():
'\n Standard platform specifier used by distutils\n '
import setuptools
import distutils
plat_name = distutils.util.get_platform()
plat_specifier = ('.%s-%s' % (plat_name, sys.version[0:3]))
if hasattr(sys, 'gettotalrefcount'):
plat_specifier += '-pydebug'... | 7,519,424,281,882,282,000 | Standard platform specifier used by distutils | super_setup.py | get_plat_specifier | brmscheiner/ibeis | python | def get_plat_specifier():
'\n \n '
import setuptools
import distutils
plat_name = distutils.util.get_platform()
plat_specifier = ('.%s-%s' % (plat_name, sys.version[0:3]))
if hasattr(sys, 'gettotalrefcount'):
plat_specifier += '-pydebug'
return plat_specifier |
def import_module_from_fpath(module_fpath):
' imports module from a file path '
import platform
from os.path import basename, splitext
python_version = platform.python_version()
modname = splitext(basename(module_fpath))[0]
if python_version.startswith('2.7'):
import imp
module =... | -8,750,936,844,449,273,000 | imports module from a file path | super_setup.py | import_module_from_fpath | brmscheiner/ibeis | python | def import_module_from_fpath(module_fpath):
' '
import platform
from os.path import basename, splitext
python_version = platform.python_version()
modname = splitext(basename(module_fpath))[0]
if python_version.startswith('2.7'):
import imp
module = imp.load_source(modname, modul... |
def define_custom_scripts(tpl_rman, ibeis_rman, PY2, PY3):
'\n export THEANO_FLAGS="device=cpu,print_active_device=True,enable_initial_driver_test=True"\n set THEANO_FLAGS=device=cpu,print_active_device=True,enable_initial_driver_test=True,print_test_value=True\n\n python -c "import pydot; print(pydot.__fi... | 1,498,355,901,527,397,600 | export THEANO_FLAGS="device=cpu,print_active_device=True,enable_initial_driver_test=True"
set THEANO_FLAGS=device=cpu,print_active_device=True,enable_initial_driver_test=True,print_test_value=True
python -c "import pydot; print(pydot.__file__)"
python -c "import pydot; print(pydot.__version__)"
python -c "import pydot... | super_setup.py | define_custom_scripts | brmscheiner/ibeis | python | def define_custom_scripts(tpl_rman, ibeis_rman, PY2, PY3):
'\n export THEANO_FLAGS="device=cpu,print_active_device=True,enable_initial_driver_test=True"\n set THEANO_FLAGS=device=cpu,print_active_device=True,enable_initial_driver_test=True,print_test_value=True\n\n python -c "import pydot; print(pydot.__fi... |
def is_running_as_root():
'\n References:\n http://stackoverflow.com/questions/5721529/running-python-script-as-root\n http://stackoverflow.com/questions/2806897/checking-script-has-root\n '
return (os.getenv('USER') == 'root') | 5,363,990,343,443,253,000 | References:
http://stackoverflow.com/questions/5721529/running-python-script-as-root
http://stackoverflow.com/questions/2806897/checking-script-has-root | super_setup.py | is_running_as_root | brmscheiner/ibeis | python | def is_running_as_root():
'\n References:\n http://stackoverflow.com/questions/5721529/running-python-script-as-root\n http://stackoverflow.com/questions/2806897/checking-script-has-root\n '
return (os.getenv('USER') == 'root') |
async def m001_initial(db):
'\n Initial wallet table.\n '
(await db.execute("\n CREATE TABLE IF NOT EXISTS charges (\n id TEXT NOT NULL PRIMARY KEY,\n user TEXT,\n description TEXT,\n onchainwallet TEXT,\n onchainaddress TEXT,\n lnbi... | 2,438,347,391,264,433,700 | Initial wallet table. | lnbits/extensions/satspay/migrations.py | m001_initial | bliotti/lnbits | python | async def m001_initial(db):
'\n \n '
(await db.execute("\n CREATE TABLE IF NOT EXISTS charges (\n id TEXT NOT NULL PRIMARY KEY,\n user TEXT,\n description TEXT,\n onchainwallet TEXT,\n onchainaddress TEXT,\n lnbitswallet TEXT,\n ... |
def check_auth(args):
"\n Checks courseraprogramming's connectivity to the coursera.org API servers\n "
oauth2_instance = oauth2.build_oauth2(args)
auth = oauth2_instance.build_authorizer()
my_profile_url = 'https://api.coursera.org/api/externalBasicProfiles.v1?q=me&fields=name'
r = requests.g... | -6,796,528,488,771,106,000 | Checks courseraprogramming's connectivity to the coursera.org API servers | courseraprogramming/commands/config.py | check_auth | andres-zartab/courseraprogramming | python | def check_auth(args):
"\n \n "
oauth2_instance = oauth2.build_oauth2(args)
auth = oauth2_instance.build_authorizer()
my_profile_url = 'https://api.coursera.org/api/externalBasicProfiles.v1?q=me&fields=name'
r = requests.get(my_profile_url, auth=auth)
if (r.status_code != 200):
logg... |
def display_auth_cache(args):
'\n Writes to the screen the state of the authentication cache. (For debugging\n authentication issues.) BEWARE: DO NOT email the output of this command!!!\n You must keep the tokens secure. Treat them as passwords.\n '
oauth2_instance = oauth2.build_oauth2(args)
if... | -7,257,325,178,374,705,000 | Writes to the screen the state of the authentication cache. (For debugging
authentication issues.) BEWARE: DO NOT email the output of this command!!!
You must keep the tokens secure. Treat them as passwords. | courseraprogramming/commands/config.py | display_auth_cache | andres-zartab/courseraprogramming | python | def display_auth_cache(args):
'\n Writes to the screen the state of the authentication cache. (For debugging\n authentication issues.) BEWARE: DO NOT email the output of this command!!!\n You must keep the tokens secure. Treat them as passwords.\n '
oauth2_instance = oauth2.build_oauth2(args)
if... |
def parser(subparsers):
'Build an argparse argument parser to parse the command line.'
parser_config = subparsers.add_parser('configure', help='Configure %(prog)s for operation!')
config_subparsers = parser_config.add_subparsers()
parser_check_auth = config_subparsers.add_parser('check-auth', help=check... | -8,423,254,587,157,504,000 | Build an argparse argument parser to parse the command line. | courseraprogramming/commands/config.py | parser | andres-zartab/courseraprogramming | python | def parser(subparsers):
parser_config = subparsers.add_parser('configure', help='Configure %(prog)s for operation!')
config_subparsers = parser_config.add_subparsers()
parser_check_auth = config_subparsers.add_parser('check-auth', help=check_auth.__doc__)
parser_check_auth.set_defaults(func=check_a... |
def forward(self, img):
'\n Your code here\n Predict the aim point in image coordinate, given the supertuxkart image\n @img: (B,3,96,128)\n return (B,2)\n '
x = self._conv(img)
return spatial_argmax(x[:, 0]) | 5,731,895,734,911,100,000 | Your code here
Predict the aim point in image coordinate, given the supertuxkart image
@img: (B,3,96,128)
return (B,2) | planner/regressor/models.py | forward | aljubrmj/CS342-Final-Project | python | def forward(self, img):
'\n Your code here\n Predict the aim point in image coordinate, given the supertuxkart image\n @img: (B,3,96,128)\n return (B,2)\n '
x = self._conv(img)
return spatial_argmax(x[:, 0]) |
def make_state_space_controller(Phi_x, Phi_u, n, p):
'\n Converts FIR transfer functions to a state\n space realization of the dynamic controller,\n mapping states to inputs.\n\n '
assert (len(Phi_x.shape) == 2)
assert (len(Phi_u.shape) == 2)
assert (Phi_x.shape[1] == n)
assert (Phi_u.sh... | -5,705,819,204,201,010,000 | Converts FIR transfer functions to a state
space realization of the dynamic controller,
mapping states to inputs. | python/sls.py | make_state_space_controller | DuttaAbhigyan/robust-adaptive-lqr | python | def make_state_space_controller(Phi_x, Phi_u, n, p):
'\n Converts FIR transfer functions to a state\n space realization of the dynamic controller,\n mapping states to inputs.\n\n '
assert (len(Phi_x.shape) == 2)
assert (len(Phi_u.shape) == 2)
assert (Phi_x.shape[1] == n)
assert (Phi_u.sh... |
def h2_squared_norm(A, B, Phi_x, Phi_u, Q, R, sigma_w):
'\n Gets the squared infinite horizon LQR cost for system\n (A,B) in feedback with the controller defined by Phi_x\n and Phi_u. \n\n '
(n, p) = B.shape
(A_k, B_k, C_k, D_k) = make_state_space_controller(Phi_x, Phi_u, n, p)
A_cl = np.blo... | 702,728,122,757,241,200 | Gets the squared infinite horizon LQR cost for system
(A,B) in feedback with the controller defined by Phi_x
and Phi_u. | python/sls.py | h2_squared_norm | DuttaAbhigyan/robust-adaptive-lqr | python | def h2_squared_norm(A, B, Phi_x, Phi_u, Q, R, sigma_w):
'\n Gets the squared infinite horizon LQR cost for system\n (A,B) in feedback with the controller defined by Phi_x\n and Phi_u. \n\n '
(n, p) = B.shape
(A_k, B_k, C_k, D_k) = make_state_space_controller(Phi_x, Phi_u, n, p)
A_cl = np.blo... |
def roll_forward(A, B, K, x0, psi0, sigma_w, horizon, rng=None):
'Apply an LTI controller K = (A_k,B_k,C_k,D_k)\n\n Roll the true system (A, B) forward with the SS realization of the LTI\n controller given. horizon is the length of the trajectory, and\n sigma_w is the stddev of the Gaussian process noise.\... | -8,283,106,643,702,540,000 | Apply an LTI controller K = (A_k,B_k,C_k,D_k)
Roll the true system (A, B) forward with the SS realization of the LTI
controller given. horizon is the length of the trajectory, and
sigma_w is the stddev of the Gaussian process noise. | python/sls.py | roll_forward | DuttaAbhigyan/robust-adaptive-lqr | python | def roll_forward(A, B, K, x0, psi0, sigma_w, horizon, rng=None):
'Apply an LTI controller K = (A_k,B_k,C_k,D_k)\n\n Roll the true system (A, B) forward with the SS realization of the LTI\n controller given. horizon is the length of the trajectory, and\n sigma_w is the stddev of the Gaussian process noise.\... |
def sls_synth(Q, R, Ahat, Bhat, eps_A, eps_B, T, gamma, alpha, logger=None):
'\n Solves the SLS synthesis problem for length T FIR filters\n using CVXPY\n\n '
assert ((len(Q.shape) == 2) and (Q.shape[0] == Q.shape[1]))
assert ((len(R.shape) == 2) and (R.shape[0] == R.shape[1]))
assert ((len(Aha... | -6,528,772,309,714,675,000 | Solves the SLS synthesis problem for length T FIR filters
using CVXPY | python/sls.py | sls_synth | DuttaAbhigyan/robust-adaptive-lqr | python | def sls_synth(Q, R, Ahat, Bhat, eps_A, eps_B, T, gamma, alpha, logger=None):
'\n Solves the SLS synthesis problem for length T FIR filters\n using CVXPY\n\n '
assert ((len(Q.shape) == 2) and (Q.shape[0] == Q.shape[1]))
assert ((len(R.shape) == 2) and (R.shape[0] == R.shape[1]))
assert ((len(Aha... |
def sls_common_lyapunov(A, B, Q, R, eps_A, eps_B, tau, logger=None):
'\n Solves the common Lyapunov relaxation to the robust \n synthesis problem.\n\n Taken from\n lstd-lqr/blob/master/code/policy_iteration.ipynb\n learning-lqr/experiments/matlab/sls_synth_yalmip/common_lyap_synth_var2_alpha.m\n\n ... | 1,971,846,414,437,250,600 | Solves the common Lyapunov relaxation to the robust
synthesis problem.
Taken from
lstd-lqr/blob/master/code/policy_iteration.ipynb
learning-lqr/experiments/matlab/sls_synth_yalmip/common_lyap_synth_var2_alpha.m | python/sls.py | sls_common_lyapunov | DuttaAbhigyan/robust-adaptive-lqr | python | def sls_common_lyapunov(A, B, Q, R, eps_A, eps_B, tau, logger=None):
'\n Solves the common Lyapunov relaxation to the robust \n synthesis problem.\n\n Taken from\n lstd-lqr/blob/master/code/policy_iteration.ipynb\n learning-lqr/experiments/matlab/sls_synth_yalmip/common_lyap_synth_var2_alpha.m\n\n ... |
@staticmethod
def compute_spawn(adjusted_fitness, previous_sizes, pop_size, min_species_size):
'Compute the proper number of offspring per species (proportional to fitness).'
af_sum = sum(adjusted_fitness)
spawn_amounts = []
for (af, ps) in zip(adjusted_fitness, previous_sizes):
if (af_sum > 0):... | 5,170,954,133,230,951,000 | Compute the proper number of offspring per species (proportional to fitness). | neat_local/reproduction.py | compute_spawn | Osrip/Novelty_criticality_PyTorch-NEAT | python | @staticmethod
def compute_spawn(adjusted_fitness, previous_sizes, pop_size, min_species_size):
af_sum = sum(adjusted_fitness)
spawn_amounts = []
for (af, ps) in zip(adjusted_fitness, previous_sizes):
if (af_sum > 0):
s = max(min_species_size, ((af / af_sum) * pop_size))
else... |
def reproduce(self, config, species, pop_size, generation):
'\n Handles creation of genomes, either from scratch or by sexual or\n asexual reproduction from parents.\n '
all_fitnesses = []
remaining_species = []
for (stag_sid, stag_s, stagnant) in self.stagnation.update(species, gen... | 4,567,077,984,153,027,000 | Handles creation of genomes, either from scratch or by sexual or
asexual reproduction from parents. | neat_local/reproduction.py | reproduce | Osrip/Novelty_criticality_PyTorch-NEAT | python | def reproduce(self, config, species, pop_size, generation):
'\n Handles creation of genomes, either from scratch or by sexual or\n asexual reproduction from parents.\n '
all_fitnesses = []
remaining_species = []
for (stag_sid, stag_s, stagnant) in self.stagnation.update(species, gen... |
def get_config_file_for_auto_config(self) -> Optional[Text]:
'Returns config file path for auto-config only if there is a single one.'
return None | 2,301,328,750,709,688,300 | Returns config file path for auto-config only if there is a single one. | rasa/shared/importers/multi_project.py | get_config_file_for_auto_config | mukulbalodi/rasa | python | def get_config_file_for_auto_config(self) -> Optional[Text]:
return None |
def training_paths(self) -> Set[Text]:
'Returns the paths which should be searched for training data.'
training_paths = {i for i in self._imports if ((not self._project_directory) or (self._project_directory not in i))}
if self._project_directory:
training_paths.add(self._project_directory)
retu... | 1,007,461,871,642,578,800 | Returns the paths which should be searched for training data. | rasa/shared/importers/multi_project.py | training_paths | mukulbalodi/rasa | python | def training_paths(self) -> Set[Text]:
training_paths = {i for i in self._imports if ((not self._project_directory) or (self._project_directory not in i))}
if self._project_directory:
training_paths.add(self._project_directory)
return training_paths |
def is_imported(self, path: Text) -> bool:
'\n Checks whether a path is imported by a skill.\n Args:\n path: File or directory path which should be checked.\n\n Returns:\n `True` if path is imported by a skill, `False` if not.\n '
absolute_path = os.path.abspath... | -3,549,763,832,062,905,000 | Checks whether a path is imported by a skill.
Args:
path: File or directory path which should be checked.
Returns:
`True` if path is imported by a skill, `False` if not. | rasa/shared/importers/multi_project.py | is_imported | mukulbalodi/rasa | python | def is_imported(self, path: Text) -> bool:
'\n Checks whether a path is imported by a skill.\n Args:\n path: File or directory path which should be checked.\n\n Returns:\n `True` if path is imported by a skill, `False` if not.\n '
absolute_path = os.path.abspath... |
def get_domain(self) -> Domain:
'Retrieves model domain (see parent class for full docstring).'
domains = [Domain.load(path) for path in self._domain_paths]
return reduce((lambda merged, other: merged.merge(other)), domains, Domain.empty()) | 1,445,008,905,624,248,800 | Retrieves model domain (see parent class for full docstring). | rasa/shared/importers/multi_project.py | get_domain | mukulbalodi/rasa | python | def get_domain(self) -> Domain:
domains = [Domain.load(path) for path in self._domain_paths]
return reduce((lambda merged, other: merged.merge(other)), domains, Domain.empty()) |
def get_stories(self, exclusion_percentage: Optional[int]=None) -> StoryGraph:
'Retrieves training stories / rules (see parent class for full docstring).'
return utils.story_graph_from_paths(self._story_paths, self.get_domain(), exclusion_percentage) | -8,375,057,380,450,402,000 | Retrieves training stories / rules (see parent class for full docstring). | rasa/shared/importers/multi_project.py | get_stories | mukulbalodi/rasa | python | def get_stories(self, exclusion_percentage: Optional[int]=None) -> StoryGraph:
return utils.story_graph_from_paths(self._story_paths, self.get_domain(), exclusion_percentage) |
def get_conversation_tests(self) -> StoryGraph:
'Retrieves conversation test stories (see parent class for full docstring).'
return utils.story_graph_from_paths(self._e2e_story_paths, self.get_domain()) | -1,269,685,561,277,907,700 | Retrieves conversation test stories (see parent class for full docstring). | rasa/shared/importers/multi_project.py | get_conversation_tests | mukulbalodi/rasa | python | def get_conversation_tests(self) -> StoryGraph:
return utils.story_graph_from_paths(self._e2e_story_paths, self.get_domain()) |
def get_config(self) -> Dict:
'Retrieves model config (see parent class for full docstring).'
return self.config | -5,574,769,534,619,931,000 | Retrieves model config (see parent class for full docstring). | rasa/shared/importers/multi_project.py | get_config | mukulbalodi/rasa | python | def get_config(self) -> Dict:
return self.config |
def get_nlu_data(self, language: Optional[Text]='en') -> TrainingData:
'Retrieves NLU training data (see parent class for full docstring).'
return utils.training_data_from_paths(self._nlu_paths, language) | 6,064,696,292,484,832,000 | Retrieves NLU training data (see parent class for full docstring). | rasa/shared/importers/multi_project.py | get_nlu_data | mukulbalodi/rasa | python | def get_nlu_data(self, language: Optional[Text]='en') -> TrainingData:
return utils.training_data_from_paths(self._nlu_paths, language) |
def encode(value, unpicklable=True, make_refs=True, keys=False, max_depth=None, reset=True, backend=None, warn=False, context=None, max_iter=None, use_decimal=False, numeric_keys=False, use_base85=False, fail_safe=None, indent=None, separators=None):
'Return a JSON formatted representation of value, a Python object... | -1,162,178,576,800,201,200 | Return a JSON formatted representation of value, a Python object.
:param unpicklable: If set to False then the output will not contain the
information necessary to turn the JSON data back into Python objects,
but a simpler JSON stream is produced.
:param max_depth: If set to a non-negative integer then jsonpic... | jsonpickle/pickler.py | encode | JHP4911/jsonpickle | python | def encode(value, unpicklable=True, make_refs=True, keys=False, max_depth=None, reset=True, backend=None, warn=False, context=None, max_iter=None, use_decimal=False, numeric_keys=False, use_base85=False, fail_safe=None, indent=None, separators=None):
'Return a JSON formatted representation of value, a Python object... |
def _in_cycle(obj, objs, max_reached, make_refs):
'Detect cyclic structures that would lead to infinite recursion'
return ((max_reached or ((not make_refs) and (id(obj) in objs))) and (not util.is_primitive(obj)) and (not util.is_enum(obj))) | 6,015,507,567,758,734,000 | Detect cyclic structures that would lead to infinite recursion | jsonpickle/pickler.py | _in_cycle | JHP4911/jsonpickle | python | def _in_cycle(obj, objs, max_reached, make_refs):
return ((max_reached or ((not make_refs) and (id(obj) in objs))) and (not util.is_primitive(obj)) and (not util.is_enum(obj))) |
def _mktyperef(obj):
"Return a typeref dictionary\n\n >>> _mktyperef(AssertionError) == {'py/type': 'builtins.AssertionError'}\n True\n\n "
return {tags.TYPE: util.importable_name(obj)} | 474,281,545,766,140,800 | Return a typeref dictionary
>>> _mktyperef(AssertionError) == {'py/type': 'builtins.AssertionError'}
True | jsonpickle/pickler.py | _mktyperef | JHP4911/jsonpickle | python | def _mktyperef(obj):
"Return a typeref dictionary\n\n >>> _mktyperef(AssertionError) == {'py/type': 'builtins.AssertionError'}\n True\n\n "
return {tags.TYPE: util.importable_name(obj)} |
def _wrap_string_slot(string):
"Converts __slots__ = 'a' into __slots__ = ('a',)"
if isinstance(string, string_types):
return (string,)
return string | -4,815,382,499,170,634,000 | Converts __slots__ = 'a' into __slots__ = ('a',) | jsonpickle/pickler.py | _wrap_string_slot | JHP4911/jsonpickle | python | def _wrap_string_slot(string):
if isinstance(string, string_types):
return (string,)
return string |
def _push(self):
'Steps down one level in the namespace.'
self._depth += 1 | 9,082,772,851,002,886,000 | Steps down one level in the namespace. | jsonpickle/pickler.py | _push | JHP4911/jsonpickle | python | def _push(self):
self._depth += 1 |
def _pop(self, value):
"Step up one level in the namespace and return the value.\n If we're at the root, reset the pickler's state.\n "
self._depth -= 1
if (self._depth == (- 1)):
self.reset()
return value | -313,070,934,508,439,300 | Step up one level in the namespace and return the value.
If we're at the root, reset the pickler's state. | jsonpickle/pickler.py | _pop | JHP4911/jsonpickle | python | def _pop(self, value):
"Step up one level in the namespace and return the value.\n If we're at the root, reset the pickler's state.\n "
self._depth -= 1
if (self._depth == (- 1)):
self.reset()
return value |
def _log_ref(self, obj):
'\n Log a reference to an in-memory object.\n Return True if this object is new and was assigned\n a new ID. Otherwise return False.\n '
objid = id(obj)
is_new = (objid not in self._objs)
if is_new:
new_id = len(self._objs)
self._objs[... | -3,513,475,387,688,375,300 | Log a reference to an in-memory object.
Return True if this object is new and was assigned
a new ID. Otherwise return False. | jsonpickle/pickler.py | _log_ref | JHP4911/jsonpickle | python | def _log_ref(self, obj):
'\n Log a reference to an in-memory object.\n Return True if this object is new and was assigned\n a new ID. Otherwise return False.\n '
objid = id(obj)
is_new = (objid not in self._objs)
if is_new:
new_id = len(self._objs)
self._objs[... |
def _mkref(self, obj):
'\n Log a reference to an in-memory object, and return\n if that object should be considered newly logged.\n '
is_new = self._log_ref(obj)
pretend_new = ((not self.unpicklable) or (not self.make_refs))
return (pretend_new or is_new) | 1,706,100,071,685,022,200 | Log a reference to an in-memory object, and return
if that object should be considered newly logged. | jsonpickle/pickler.py | _mkref | JHP4911/jsonpickle | python | def _mkref(self, obj):
'\n Log a reference to an in-memory object, and return\n if that object should be considered newly logged.\n '
is_new = self._log_ref(obj)
pretend_new = ((not self.unpicklable) or (not self.make_refs))
return (pretend_new or is_new) |
def flatten(self, obj, reset=True):
"Takes an object and returns a JSON-safe representation of it.\n\n Simply returns any of the basic builtin datatypes\n\n >>> p = Pickler()\n >>> p.flatten('hello world') == 'hello world'\n True\n >>> p.flatten(49)\n 49\n >>> p.flat... | -3,647,423,070,333,986,300 | Takes an object and returns a JSON-safe representation of it.
Simply returns any of the basic builtin datatypes
>>> p = Pickler()
>>> p.flatten('hello world') == 'hello world'
True
>>> p.flatten(49)
49
>>> p.flatten(350.0)
350.0
>>> p.flatten(True)
True
>>> p.flatten(False)
False
>>> r = p.flatten(None)
>>> r is None... | jsonpickle/pickler.py | flatten | JHP4911/jsonpickle | python | def flatten(self, obj, reset=True):
"Takes an object and returns a JSON-safe representation of it.\n\n Simply returns any of the basic builtin datatypes\n\n >>> p = Pickler()\n >>> p.flatten('hello world') == 'hello world'\n True\n >>> p.flatten(49)\n 49\n >>> p.flat... |
def _ref_obj_instance(self, obj):
'Reference an existing object or flatten if new'
if self.unpicklable:
if self._mkref(obj):
return self._flatten_obj_instance(obj)
return self._getref(obj)
else:
max_reached = self._max_reached()
in_cycle = _in_cycle(obj, self._obj... | 6,787,927,570,877,706,000 | Reference an existing object or flatten if new | jsonpickle/pickler.py | _ref_obj_instance | JHP4911/jsonpickle | python | def _ref_obj_instance(self, obj):
if self.unpicklable:
if self._mkref(obj):
return self._flatten_obj_instance(obj)
return self._getref(obj)
else:
max_reached = self._max_reached()
in_cycle = _in_cycle(obj, self._objs, max_reached, False)
if in_cycle:
... |
def _flatten_file(self, obj):
'\n Special case file objects\n '
assert ((not PY3) and isinstance(obj, types.FileType))
return None | -7,222,675,722,203,146,000 | Special case file objects | jsonpickle/pickler.py | _flatten_file | JHP4911/jsonpickle | python | def _flatten_file(self, obj):
'\n \n '
assert ((not PY3) and isinstance(obj, types.FileType))
return None |
def _flatten_obj_instance(self, obj):
'Recursively flatten an instance and return a json-friendly dict'
data = {}
has_class = hasattr(obj, '__class__')
has_dict = hasattr(obj, '__dict__')
has_slots = ((not has_dict) and hasattr(obj, '__slots__'))
has_getnewargs = util.has_method(obj, '__getnewar... | -5,174,354,392,125,870,000 | Recursively flatten an instance and return a json-friendly dict | jsonpickle/pickler.py | _flatten_obj_instance | JHP4911/jsonpickle | python | def _flatten_obj_instance(self, obj):
data = {}
has_class = hasattr(obj, '__class__')
has_dict = hasattr(obj, '__dict__')
has_slots = ((not has_dict) and hasattr(obj, '__slots__'))
has_getnewargs = util.has_method(obj, '__getnewargs__')
has_getnewargs_ex = util.has_method(obj, '__getnewargs... |
def _flatten_dict_obj(self, obj, data=None):
'Recursively call flatten() and return json-friendly dict'
if (data is None):
data = obj.__class__()
if self.keys:
flatten = self._flatten_string_key_value_pair
for (k, v) in util.items(obj):
flatten(k, v, data)
flatten... | -7,268,695,046,591,207,000 | Recursively call flatten() and return json-friendly dict | jsonpickle/pickler.py | _flatten_dict_obj | JHP4911/jsonpickle | python | def _flatten_dict_obj(self, obj, data=None):
if (data is None):
data = obj.__class__()
if self.keys:
flatten = self._flatten_string_key_value_pair
for (k, v) in util.items(obj):
flatten(k, v, data)
flatten = self._flatten_non_string_key_value_pair
for (k,... |
def _flatten_newstyle_with_slots(self, obj, data):
'Return a json-friendly dict for new-style objects with __slots__.'
allslots = [_wrap_string_slot(getattr(cls, '__slots__', tuple())) for cls in obj.__class__.mro()]
if (not self._flatten_obj_attrs(obj, chain(*allslots), data)):
attrs = [x for x in ... | 4,563,973,177,544,642,000 | Return a json-friendly dict for new-style objects with __slots__. | jsonpickle/pickler.py | _flatten_newstyle_with_slots | JHP4911/jsonpickle | python | def _flatten_newstyle_with_slots(self, obj, data):
allslots = [_wrap_string_slot(getattr(cls, '__slots__', tuple())) for cls in obj.__class__.mro()]
if (not self._flatten_obj_attrs(obj, chain(*allslots), data)):
attrs = [x for x in dir(obj) if ((not x.startswith('__')) and (not x.endswith('__')))]
... |
def _flatten_key_value_pair(self, k, v, data):
'Flatten a key/value pair into the passed-in dictionary.'
if (not util.is_picklable(k, v)):
return data
if (k is None):
k = 'null'
if (self.numeric_keys and isinstance(k, numeric_types)):
pass
elif (not isinstance(k, string_types... | 2,156,137,296,504,074,500 | Flatten a key/value pair into the passed-in dictionary. | jsonpickle/pickler.py | _flatten_key_value_pair | JHP4911/jsonpickle | python | def _flatten_key_value_pair(self, k, v, data):
if (not util.is_picklable(k, v)):
return data
if (k is None):
k = 'null'
if (self.numeric_keys and isinstance(k, numeric_types)):
pass
elif (not isinstance(k, string_types)):
try:
k = repr(k)
except E... |
def _flatten_non_string_key_value_pair(self, k, v, data):
'Flatten only non-string key/value pairs'
if (not util.is_picklable(k, v)):
return data
if (self.keys and (not isinstance(k, string_types))):
k = self._escape_key(k)
data[k] = self._flatten(v)
return data | 1,580,031,440,237,875,000 | Flatten only non-string key/value pairs | jsonpickle/pickler.py | _flatten_non_string_key_value_pair | JHP4911/jsonpickle | python | def _flatten_non_string_key_value_pair(self, k, v, data):
if (not util.is_picklable(k, v)):
return data
if (self.keys and (not isinstance(k, string_types))):
k = self._escape_key(k)
data[k] = self._flatten(v)
return data |
def _flatten_string_key_value_pair(self, k, v, data):
'Flatten string key/value pairs only.'
if (not util.is_picklable(k, v)):
return data
if self.keys:
if (not isinstance(k, string_types)):
return data
elif k.startswith(tags.JSON_KEY):
k = self._escape_key(k)... | -7,087,045,067,066,155,000 | Flatten string key/value pairs only. | jsonpickle/pickler.py | _flatten_string_key_value_pair | JHP4911/jsonpickle | python | def _flatten_string_key_value_pair(self, k, v, data):
if (not util.is_picklable(k, v)):
return data
if self.keys:
if (not isinstance(k, string_types)):
return data
elif k.startswith(tags.JSON_KEY):
k = self._escape_key(k)
else:
if (k is None):
... |
def _flatten_sequence_obj(self, obj, data):
'Return a json-friendly dict for a sequence subclass.'
if hasattr(obj, '__dict__'):
self._flatten_dict_obj(obj.__dict__, data)
value = [self._flatten(v) for v in obj]
if self.unpicklable:
data[tags.SEQ] = value
else:
return value
... | 1,514,014,164,244,263,700 | Return a json-friendly dict for a sequence subclass. | jsonpickle/pickler.py | _flatten_sequence_obj | JHP4911/jsonpickle | python | def _flatten_sequence_obj(self, obj, data):
if hasattr(obj, '__dict__'):
self._flatten_dict_obj(obj.__dict__, data)
value = [self._flatten(v) for v in obj]
if self.unpicklable:
data[tags.SEQ] = value
else:
return value
return data |
def schedule_conv2d_hwcn(outs):
'Schedule for conv2d_hwcn and any element-wise operations.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of conv2d_hwcn in the format\n of an array of tensors.\n\n Returns\n -------\n s: Schedule\n The c... | 3,848,554,958,064,389,600 | Schedule for conv2d_hwcn and any element-wise operations.
Parameters
----------
outs: Array of Tensor
The computation graph description of conv2d_hwcn in the format
of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for conv2d_hwcn. | topi/python/topi/cuda/conv2d_hwcn.py | schedule_conv2d_hwcn | CortexFoundation/tvm-cvm | python | def schedule_conv2d_hwcn(outs):
'Schedule for conv2d_hwcn and any element-wise operations.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of conv2d_hwcn in the format\n of an array of tensors.\n\n Returns\n -------\n s: Schedule\n The c... |
def schedule(Apad, W, B):
'Schedule conv2d_hwcn'
sch[Apad].compute_inline()
AA = sch.cache_read(Apad, 'shared', [B])
WW = sch.cache_read(W, 'shared', [B])
AL = sch.cache_read(AA, 'local', [B])
WL = sch.cache_read(WW, 'local', [B])
if (B.op in sch.outputs):
Out = B
BL = sch.ca... | 8,421,041,648,292,286,000 | Schedule conv2d_hwcn | topi/python/topi/cuda/conv2d_hwcn.py | schedule | CortexFoundation/tvm-cvm | python | def schedule(Apad, W, B):
sch[Apad].compute_inline()
AA = sch.cache_read(Apad, 'shared', [B])
WW = sch.cache_read(W, 'shared', [B])
AL = sch.cache_read(AA, 'local', [B])
WL = sch.cache_read(WW, 'local', [B])
if (B.op in sch.outputs):
Out = B
BL = sch.cache_write(Out, 'local'... |
def traverse(operator):
'Traverse operators from computation graph'
if tag.is_broadcast(operator.tag):
if (operator not in sch.outputs):
sch[operator].compute_inline()
for tensor in operator.input_tensors:
if (tensor.op.input_tensors and (tensor.op not in scheduled_ops)):... | 1,486,942,041,922,143,200 | Traverse operators from computation graph | topi/python/topi/cuda/conv2d_hwcn.py | traverse | CortexFoundation/tvm-cvm | python | def traverse(operator):
if tag.is_broadcast(operator.tag):
if (operator not in sch.outputs):
sch[operator].compute_inline()
for tensor in operator.input_tensors:
if (tensor.op.input_tensors and (tensor.op not in scheduled_ops)):
traverse(tensor.op)
el... |
def lookup_class(self, new_class):
'Translate a new class name to the old class name.'
if (new_class in self.classes_dict):
(old_class, class_dict) = self.classes_dict[new_class]
if (old_class is not None):
return old_class
return None | 1,882,551,139,332,402,700 | Translate a new class name to the old class name. | tools/python/dex.py | lookup_class | gdawg/redex | python | def lookup_class(self, new_class):
if (new_class in self.classes_dict):
(old_class, class_dict) = self.classes_dict[new_class]
if (old_class is not None):
return old_class
return None |
def lookup_method(self, new_class, new_method):
'Translate a new class name and a new method into the old class\n name and the old method name.'
if (new_class in self.classes_dict):
(old_class, class_dict) = self.classes_dict[new_class]
if (new_method in class_dict):
return cl... | -4,073,838,217,049,182,000 | Translate a new class name and a new method into the old class
name and the old method name. | tools/python/dex.py | lookup_method | gdawg/redex | python | def lookup_method(self, new_class, new_method):
'Translate a new class name and a new method into the old class\n name and the old method name.'
if (new_class in self.classes_dict):
(old_class, class_dict) = self.classes_dict[new_class]
if (new_method in class_dict):
return cl... |
def get_method_id(self):
'Get the method_id_item for this method.'
if (self.method_id is None):
self.method_id = self.get_dex().get_method_id(self.encoded_method)
return self.method_id | -767,692,397,901,498,100 | Get the method_id_item for this method. | tools/python/dex.py | get_method_id | gdawg/redex | python | def get_method_id(self):
if (self.method_id is None):
self.method_id = self.get_dex().get_method_id(self.encoded_method)
return self.method_id |
def get_method_index(self):
'Get the method index into the method_ids array in the DEX file.'
return self.encoded_method.method_idx | -6,570,096,611,676,412,000 | Get the method index into the method_ids array in the DEX file. | tools/python/dex.py | get_method_index | gdawg/redex | python | def get_method_index(self):
return self.encoded_method.method_idx |
def get_code_offset(self):
'Get the code offset for this method.'
return self.encoded_method.code_off | 3,253,180,441,785,362,000 | Get the code offset for this method. | tools/python/dex.py | get_code_offset | gdawg/redex | python | def get_code_offset(self):
return self.encoded_method.code_off |
def get_code_item_index(self):
'Get the index into the code_items array in the dex file for the\n code for this method, or -1 if there is no code for this method.'
code_item = self.get_code_item()
if code_item:
return self.get_dex().get_code_item_index_from_code_off(code_item.get_offset())
... | -6,968,737,353,221,798,000 | Get the index into the code_items array in the dex file for the
code for this method, or -1 if there is no code for this method. | tools/python/dex.py | get_code_item_index | gdawg/redex | python | def get_code_item_index(self):
'Get the index into the code_items array in the dex file for the\n code for this method, or -1 if there is no code for this method.'
code_item = self.get_code_item()
if code_item:
return self.get_dex().get_code_item_index_from_code_off(code_item.get_offset())
... |
def get_name_in_file(self):
'Returns the name of the method as it is known in the current DEX\n file (no proguard remapping)'
if (self.name_in_file is None):
self.name_in_file = self.get_dex().get_string(self.get_method_id().name_idx)
return self.name_in_file | 8,711,479,776,300,216,000 | Returns the name of the method as it is known in the current DEX
file (no proguard remapping) | tools/python/dex.py | get_name_in_file | gdawg/redex | python | def get_name_in_file(self):
'Returns the name of the method as it is known in the current DEX\n file (no proguard remapping)'
if (self.name_in_file is None):
self.name_in_file = self.get_dex().get_string(self.get_method_id().name_idx)
return self.name_in_file |
def get_type_index(self):
'Get type ID index (class_idx) for this class.'
return self.class_def.class_idx | -8,132,714,876,377,389,000 | Get type ID index (class_idx) for this class. | tools/python/dex.py | get_type_index | gdawg/redex | python | def get_type_index(self):
return self.class_def.class_idx |
def get_name(self):
"Get the demangled name for a class if we have a proguard file or\n return the mangled name if we don't have a proguard file."
if (self.demangled is None):
mangled = self.get_mangled_name()
if mangled:
self.demangled = self.get_dex().demangle_class_name(man... | 3,952,231,635,240,121,000 | Get the demangled name for a class if we have a proguard file or
return the mangled name if we don't have a proguard file. | tools/python/dex.py | get_name | gdawg/redex | python | def get_name(self):
"Get the demangled name for a class if we have a proguard file or\n return the mangled name if we don't have a proguard file."
if (self.demangled is None):
mangled = self.get_mangled_name()
if mangled:
self.demangled = self.get_dex().demangle_class_name(man... |
def demangle_class_name(self, cls_mangled):
'Given a mangled type name as it would appear in a DEX file like\n "LX/JxK;", return the demangled version if we have a proguard file,\n otherwise return the original class typename'
if self.proguard:
cls_demangled = demangle_classname(cls_mangle... | 2,609,167,484,196,999,700 | Given a mangled type name as it would appear in a DEX file like
"LX/JxK;", return the demangled version if we have a proguard file,
otherwise return the original class typename | tools/python/dex.py | demangle_class_name | gdawg/redex | python | def demangle_class_name(self, cls_mangled):
'Given a mangled type name as it would appear in a DEX file like\n "LX/JxK;", return the demangled version if we have a proguard file,\n otherwise return the original class typename'
if self.proguard:
cls_demangled = demangle_classname(cls_mangle... |
def get_method_id(self, method_ref):
'method_ref can be one of:\n - a encoded_method object\n - integer method index'
method_ids = self.get_method_ids()
if method_ids:
if isinstance(method_ref, encoded_method):
if (method_ref.method_idx < len(method_ids)):
... | -8,282,719,921,504,232,000 | method_ref can be one of:
- a encoded_method object
- integer method index | tools/python/dex.py | get_method_id | gdawg/redex | python | def get_method_id(self, method_ref):
'method_ref can be one of:\n - a encoded_method object\n - integer method index'
method_ids = self.get_method_ids()
if method_ids:
if isinstance(method_ref, encoded_method):
if (method_ref.method_idx < len(method_ids)):
... |
def check_encoding(self, f=sys.stdout):
"Verify that this instruction can't be encoded more efficiently"
return 0 | 3,330,640,632,603,261,000 | Verify that this instruction can't be encoded more efficiently | tools/python/dex.py | check_encoding | gdawg/redex | python | def check_encoding(self, f=sys.stdout):
return 0 |
def new_encoding(self, f=sys.stdout):
'Look for bytes we can save by making new opcodes that are encoded\n as unsigned, or other optimizations'
return 0 | 3,116,464,888,852,868,600 | Look for bytes we can save by making new opcodes that are encoded
as unsigned, or other optimizations | tools/python/dex.py | new_encoding | gdawg/redex | python | def new_encoding(self, f=sys.stdout):
'Look for bytes we can save by making new opcodes that are encoded\n as unsigned, or other optimizations'
return 0 |
def opIsCommutative(self):
'Return True if the operation is commutative'
op = self.get_op()
return ((op == 144) or (op == 146) or (op == 149) or (op == 150) or (op == 151) or (op == 155) or (op == 157) or (op == 160) or (op == 161) or (op == 162) or (op == 166) or (op == 168) or (op == 171) or (op == 173)) | 3,570,157,811,082,132,000 | Return True if the operation is commutative | tools/python/dex.py | opIsCommutative | gdawg/redex | python | def opIsCommutative(self):
op = self.get_op()
return ((op == 144) or (op == 146) or (op == 149) or (op == 150) or (op == 151) or (op == 155) or (op == 157) or (op == 160) or (op == 161) or (op == 162) or (op == 166) or (op == 168) or (op == 171) or (op == 173)) |
def get_op(self):
'Return the 1 byte op field that tells us what instruction this is'
return (self.code_units[0] & 255) | 6,110,940,203,283,449,000 | Return the 1 byte op field that tells us what instruction this is | tools/python/dex.py | get_op | gdawg/redex | python | def get_op(self):
return (self.code_units[0] & 255) |
def get_A(self):
'Get the 4 bit value of A'
return ((self.code_units[0] >> 8) & 15) | 2,964,393,587,828,950,000 | Get the 4 bit value of A | tools/python/dex.py | get_A | gdawg/redex | python | def get_A(self):
return ((self.code_units[0] >> 8) & 15) |
def get_B(self):
'Get the 4 bit value of B'
return ((self.code_units[0] >> 12) & 15) | 413,042,585,781,201,150 | Get the 4 bit value of B | tools/python/dex.py | get_B | gdawg/redex | python | def get_B(self):
return ((self.code_units[0] >> 12) & 15) |
def get_AA(self):
'Get the 8 bit value of AA from the byte next to the Op'
return self.get_uint8_hi(0) | -6,221,053,770,818,469,000 | Get the 8 bit value of AA from the byte next to the Op | tools/python/dex.py | get_AA | gdawg/redex | python | def get_AA(self):
return self.get_uint8_hi(0) |
def __len__(self):
'Overload the length operator to give out the number of code units'
return len(self.code_units) | -5,097,450,298,375,161,000 | Overload the length operator to give out the number of code units | tools/python/dex.py | __len__ | gdawg/redex | python | def __len__(self):
return len(self.code_units) |
def __getitem__(self, key):
'Overload the [] operator to give out code units'
return self.code_units[key] | 4,717,513,790,348,059,000 | Overload the [] operator to give out code units | tools/python/dex.py | __getitem__ | gdawg/redex | python | def __getitem__(self, key):
return self.code_units[key] |
def setUp(self):
'Set up test fixtures, if any.' | 2,045,331,168,806,357,800 | Set up test fixtures, if any. | tests/test_calvestbr.py | setUp | IsaacHiguchi/calvestbr | python | def setUp(self):
|
def tearDown(self):
'Tear down test fixtures, if any.' | -1,468,603,304,420,127,200 | Tear down test fixtures, if any. | tests/test_calvestbr.py | tearDown | IsaacHiguchi/calvestbr | python | def tearDown(self):
|
def test_000_something(self):
'Test something.' | 7,145,567,716,661,586,000 | Test something. | tests/test_calvestbr.py | test_000_something | IsaacHiguchi/calvestbr | python | def test_000_something(self):
|
def download_pdc_id(pdc_id, _download_msg=True):
'Download a PDC dataset by its PDC study id.\n \n Returns:\n pandas.DataFrame: The clinical table for the study id.\n pandas.DataFrame: The quantitative table for the study id.\n '
if _download_msg:
clin_msg = f'Downloading clinical table f... | 1,277,476,623,142,595,600 | Download a PDC dataset by its PDC study id.
Returns:
pandas.DataFrame: The clinical table for the study id.
pandas.DataFrame: The quantitative table for the study id. | cptac/pancan/file_download.py | download_pdc_id | PayneLab/cptac | python | def download_pdc_id(pdc_id, _download_msg=True):
'Download a PDC dataset by its PDC study id.\n \n Returns:\n pandas.DataFrame: The clinical table for the study id.\n pandas.DataFrame: The quantitative table for the study id.\n '
if _download_msg:
clin_msg = f'Downloading clinical table f... |
def _pdc_download(dataset, version, redownload):
'Download data for the specified cancer type from the PDC.'
dataset = str.lower(dataset)
if (dataset == 'pdcall'):
overall_result = True
for dataset in STUDY_IDS_MAP.keys():
if (not pdc_download(dataset, version, redownload)):
... | -6,758,916,922,176,530,000 | Download data for the specified cancer type from the PDC. | cptac/pancan/file_download.py | _pdc_download | PayneLab/cptac | python | def _pdc_download(dataset, version, redownload):
dataset = str.lower(dataset)
if (dataset == 'pdcall'):
overall_result = True
for dataset in STUDY_IDS_MAP.keys():
if (not pdc_download(dataset, version, redownload)):
overall_result = False
return overall_r... |
def _download_study_clin(pdc_study_id):
'Download PDC clinical data for a particular study.'
clinical_query = (('\n query {\n clinicalPerStudy(pdc_study_id: "' + pdc_study_id) + '", acceptDUA: true) {\n age_at_diagnosis, ajcc_clinical_m, ajcc_clinical_n, ajcc_clinical_stage, ajcc_clinical_t... | -5,002,710,957,430,010,000 | Download PDC clinical data for a particular study. | cptac/pancan/file_download.py | _download_study_clin | PayneLab/cptac | python | def _download_study_clin(pdc_study_id):
clinical_query = (('\n query {\n clinicalPerStudy(pdc_study_id: "' + pdc_study_id) + '", acceptDUA: true) {\n age_at_diagnosis, ajcc_clinical_m, ajcc_clinical_n, ajcc_clinical_stage, ajcc_clinical_t, ajcc_pathologic_m,\n ajcc_pathologic_n,... |
def _download_study_biospecimen(pdc_study_id):
'Download PDC biospecimen data for a particular study.'
biospecimen_query = (('\n query {\n biospecimenPerStudy(pdc_study_id: "' + pdc_study_id) + '", acceptDUA: true) {\n aliquot_submitter_id\n case_submitter_id\n }\n }\n ... | 5,144,662,956,955,882,000 | Download PDC biospecimen data for a particular study. | cptac/pancan/file_download.py | _download_study_biospecimen | PayneLab/cptac | python | def _download_study_biospecimen(pdc_study_id):
biospecimen_query = (('\n query {\n biospecimenPerStudy(pdc_study_id: "' + pdc_study_id) + '", acceptDUA: true) {\n aliquot_submitter_id\n case_submitter_id\n }\n }\n ')
result_json = _query_pdc(biospecimen_query)
... |
def _download_study_quant(pdc_study_id):
'Download PDC quantitative data for a particular study.'
proteome_query = (('\n query {\n quantDataMatrix(pdc_study_id: "' + pdc_study_id) + '", data_type: "log2_ratio", acceptDUA: true)\n }\n ')
result_json = _query_pdc(proteome_query)
result_df ... | 8,883,478,036,025,754,000 | Download PDC quantitative data for a particular study. | cptac/pancan/file_download.py | _download_study_quant | PayneLab/cptac | python | def _download_study_quant(pdc_study_id):
proteome_query = (('\n query {\n quantDataMatrix(pdc_study_id: "' + pdc_study_id) + '", data_type: "log2_ratio", acceptDUA: true)\n }\n ')
result_json = _query_pdc(proteome_query)
result_df = pd.DataFrame(result_json['data']['quantDataMatrix'])
... |
def _query_pdc(query):
'Send a GraphQL query to the PDC and return the results.'
url = 'https://pdc.cancer.gov/graphql'
try:
response = requests.post(url, json={'query': query})
response.raise_for_status()
except requests.RequestException:
raise NoInternetError('Insufficient inte... | 5,755,614,470,036,070,000 | Send a GraphQL query to the PDC and return the results. | cptac/pancan/file_download.py | _query_pdc | PayneLab/cptac | python | def _query_pdc(query):
url = 'https://pdc.cancer.gov/graphql'
try:
response = requests.post(url, json={'query': query})
response.raise_for_status()
except requests.RequestException:
raise NoInternetError('Insufficient internet. Check your internet connection.') from None
ret... |
def _check_ids_match(ids_map):
"Check that the ids in the download function's STUDY_IDS_MAP match up."
for cancer in ids_map.values():
for data in cancer.values():
pdc_study_id = data['pdc_study_id']
study_submitter_id = data['study_submitter_id']
query = (('\n ... | 1,036,462,430,489,785,300 | Check that the ids in the download function's STUDY_IDS_MAP match up. | cptac/pancan/file_download.py | _check_ids_match | PayneLab/cptac | python | def _check_ids_match(ids_map):
for cancer in ids_map.values():
for data in cancer.values():
pdc_study_id = data['pdc_study_id']
study_submitter_id = data['study_submitter_id']
query = (('\n query {\n study (pdc_study_id: "' + pdc_study_id) + '... |
def get_content_details(content, instance_path, instance_profile_id, instance_url, instance_language_id=None):
'gets details of a content item'
global monitor_new_content, auto_search
images = content.get('images')
for image in images:
image['url'] = '{0}{1}'.format(instance_url, image.get('url'... | -798,187,230,711,055,700 | gets details of a content item | index.py | get_content_details | markschrik/syncarr | python | def get_content_details(content, instance_path, instance_profile_id, instance_url, instance_language_id=None):
global monitor_new_content, auto_search
images = content.get('images')
for image in images:
image['url'] = '{0}{1}'.format(instance_url, image.get('url'))
monitored = content.get('... |
def exit_system():
'we dont want to exit if in docker'
if is_in_docker:
raise Exception
else:
sys.exit(0) | 7,366,073,034,452,480,000 | we dont want to exit if in docker | index.py | exit_system | markschrik/syncarr | python | def exit_system():
if is_in_docker:
raise Exception
else:
sys.exit(0) |
def get_kernelspecs():
'Fetches the set of kernelspecs from the gateway, returning a dict of configured kernel specs'
end_point = '{}/api/kernelspecs'.format(gateway_host)
logger.info("Fetching kernelspecs from '{}' ...".format(end_point))
resp = requests.get(end_point)
if (not resp.ok):
rai... | -6,687,765,040,639,843,000 | Fetches the set of kernelspecs from the gateway, returning a dict of configured kernel specs | kernel_image_puller.py | get_kernelspecs | dummys/kernel-image-puller | python | def get_kernelspecs():
end_point = '{}/api/kernelspecs'.format(gateway_host)
logger.info("Fetching kernelspecs from '{}' ...".format(end_point))
resp = requests.get(end_point)
if (not resp.ok):
raise requests.exceptions.HTTPError('Gateway server response: {}'.format(resp.status_code))
r... |
def fetch_image_names():
'Fetches the image names by hitting the /api/kernelspecs endpoint of the Gateway.\n \n For process-proxy kernelspecs, the image names are contained in the config stanza - which\n resides in the process-proxy stanza located in the metadata.\n '
kspecs = None
try:
ksp... | -6,910,645,233,095,386,000 | Fetches the image names by hitting the /api/kernelspecs endpoint of the Gateway.
For process-proxy kernelspecs, the image names are contained in the config stanza - which
resides in the process-proxy stanza located in the metadata. | kernel_image_puller.py | fetch_image_names | dummys/kernel-image-puller | python | def fetch_image_names():
'Fetches the image names by hitting the /api/kernelspecs endpoint of the Gateway.\n \n For process-proxy kernelspecs, the image names are contained in the config stanza - which\n resides in the process-proxy stanza located in the metadata.\n '
kspecs = None
try:
ksp... |
def pull_image(image_name):
'Pulls the image.\n \n If the policy is `IfNotPresent` the set of pulled image names is\n checked and, if present, the method returns. Otherwise, the pull attempt is made\n and the set of pulled images is updated, when successful.\n \n Since NotFound exceptions are tolerated... | 1,680,901,528,725,841,700 | Pulls the image.
If the policy is `IfNotPresent` the set of pulled image names is
checked and, if present, the method returns. Otherwise, the pull attempt is made
and the set of pulled images is updated, when successful.
Since NotFound exceptions are tolerated, we trap for only that exception and let
the caller hand... | kernel_image_puller.py | pull_image | dummys/kernel-image-puller | python | def pull_image(image_name):
'Pulls the image.\n \n If the policy is `IfNotPresent` the set of pulled image names is\n checked and, if present, the method returns. Otherwise, the pull attempt is made\n and the set of pulled images is updated, when successful.\n \n Since NotFound exceptions are tolerated... |
def puller():
"Thread-based puller.\n \n Gets image name from the queue and attempts to pull the image. Any issues, except\n for NotFound, are retried up to num_retries times. Once the image has been pulled, it's not found or the\n retries have been exceeded, the queue task is marked as done.\n "
wh... | 2,182,722,637,967,463,000 | Thread-based puller.
Gets image name from the queue and attempts to pull the image. Any issues, except
for NotFound, are retried up to num_retries times. Once the image has been pulled, it's not found or the
retries have been exceeded, the queue task is marked as done. | kernel_image_puller.py | puller | dummys/kernel-image-puller | python | def puller():
"Thread-based puller.\n \n Gets image name from the queue and attempts to pull the image. Any issues, except\n for NotFound, are retried up to num_retries times. Once the image has been pulled, it's not found or the\n retries have been exceeded, the queue task is marked as done.\n "
wh... |
def flip_cihp(tail_list):
'\n\n :param tail_list: tail_list size is 1 x n_class x h x w\n :return:\n '
tail_list_rev = ([None] * 20)
for xx in range(14):
tail_list_rev[xx] = tail_list[xx].unsqueeze(0)
tail_list_rev[14] = tail_list[15].unsqueeze(0)
tail_list_rev[15] = tail_list[14].u... | 6,911,805,198,421,112,000 | :param tail_list: tail_list size is 1 x n_class x h x w
:return: | exp/inference/inference_dir.py | flip_cihp | ericwang0701/Graphonomy | python | def flip_cihp(tail_list):
'\n\n :param tail_list: tail_list size is 1 x n_class x h x w\n :return:\n '
tail_list_rev = ([None] * 20)
for xx in range(14):
tail_list_rev[xx] = tail_list[xx].unsqueeze(0)
tail_list_rev[14] = tail_list[15].unsqueeze(0)
tail_list_rev[15] = tail_list[14].u... |
def decode_labels(mask, num_images=1, num_classes=20):
'Decode batch of segmentation masks.\n\n Args:\n mask: result of inference after taking argmax.\n num_images: number of images to decode from the batch.\n num_classes: number of classes to predict (including background).\n\n Returns:\n ... | -6,977,466,826,084,187,000 | Decode batch of segmentation masks.
Args:
mask: result of inference after taking argmax.
num_images: number of images to decode from the batch.
num_classes: number of classes to predict (including background).
Returns:
A batch with num_images RGB images of the same size as the input. | exp/inference/inference_dir.py | decode_labels | ericwang0701/Graphonomy | python | def decode_labels(mask, num_images=1, num_classes=20):
'Decode batch of segmentation masks.\n\n Args:\n mask: result of inference after taking argmax.\n num_images: number of images to decode from the batch.\n num_classes: number of classes to predict (including background).\n\n Returns:\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.