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 dict_lookup(dict_, keys, default=None):
'Looks up :attr:`keys` in the dict, returns the corresponding values.\n\n The :attr:`default` is used for keys not present in the dict.\n\n Args:\n dict_ (dict): A dictionary for lookup.\n keys: A numpy array or a (possibly nested) list of keys.\n ... | 2,886,590,621,723,122,700 | Looks up :attr:`keys` in the dict, returns the corresponding values.
The :attr:`default` is used for keys not present in the dict.
Args:
dict_ (dict): A dictionary for lookup.
keys: A numpy array or a (possibly nested) list of keys.
default (optional): Value to be returned when a key is not in
:at... | texar/tf/utils/utils.py | dict_lookup | awesomemachinelearning/texar | python | def dict_lookup(dict_, keys, default=None):
'Looks up :attr:`keys` in the dict, returns the corresponding values.\n\n The :attr:`default` is used for keys not present in the dict.\n\n Args:\n dict_ (dict): A dictionary for lookup.\n keys: A numpy array or a (possibly nested) list of keys.\n ... |
def dict_fetch(src_dict, tgt_dict_or_keys):
'Fetches a sub dict of :attr:`src_dict` with the keys in\n :attr:`tgt_dict_or_keys`.\n\n Args:\n src_dict: A dict or instance of :class:`~texar.tf.HParams`.\n The source dict to fetch values from.\n tgt_dict_or_keys: A dict, instance of :cla... | -8,687,013,080,932,570,000 | Fetches a sub dict of :attr:`src_dict` with the keys in
:attr:`tgt_dict_or_keys`.
Args:
src_dict: A dict or instance of :class:`~texar.tf.HParams`.
The source dict to fetch values from.
tgt_dict_or_keys: A dict, instance of :class:`~texar.tf.HParams`,
or a list (or a dict_keys) of keys to be in... | texar/tf/utils/utils.py | dict_fetch | awesomemachinelearning/texar | python | def dict_fetch(src_dict, tgt_dict_or_keys):
'Fetches a sub dict of :attr:`src_dict` with the keys in\n :attr:`tgt_dict_or_keys`.\n\n Args:\n src_dict: A dict or instance of :class:`~texar.tf.HParams`.\n The source dict to fetch values from.\n tgt_dict_or_keys: A dict, instance of :cla... |
def dict_pop(dict_, pop_keys, default=None):
'Removes keys from a dict and returns their values.\n\n Args:\n dict_ (dict): A dictionary from which items are removed.\n pop_keys: A key or a list of keys to remove and return respective\n values or :attr:`default`.\n default (optiona... | -5,061,628,030,914,188,000 | Removes keys from a dict and returns their values.
Args:
dict_ (dict): A dictionary from which items are removed.
pop_keys: A key or a list of keys to remove and return respective
values or :attr:`default`.
default (optional): Value to be returned when a key is not in
:attr:`dict_`. The def... | texar/tf/utils/utils.py | dict_pop | awesomemachinelearning/texar | python | def dict_pop(dict_, pop_keys, default=None):
'Removes keys from a dict and returns their values.\n\n Args:\n dict_ (dict): A dictionary from which items are removed.\n pop_keys: A key or a list of keys to remove and return respective\n values or :attr:`default`.\n default (optiona... |
def flatten_dict(dict_, parent_key='', sep='.'):
'Flattens a nested dictionary. Namedtuples within the dictionary are\n converted to dicts.\n\n Adapted from:\n https://github.com/google/seq2seq/blob/master/seq2seq/models/model_base.py\n\n Args:\n dict_ (dict): The dictionary to flatten.\n ... | 2,483,426,072,466,088,400 | Flattens a nested dictionary. Namedtuples within the dictionary are
converted to dicts.
Adapted from:
https://github.com/google/seq2seq/blob/master/seq2seq/models/model_base.py
Args:
dict_ (dict): The dictionary to flatten.
parent_key (str): A prefix to prepend to each key.
sep (str): Separator that inter... | texar/tf/utils/utils.py | flatten_dict | awesomemachinelearning/texar | python | def flatten_dict(dict_, parent_key=, sep='.'):
'Flattens a nested dictionary. Namedtuples within the dictionary are\n converted to dicts.\n\n Adapted from:\n https://github.com/google/seq2seq/blob/master/seq2seq/models/model_base.py\n\n Args:\n dict_ (dict): The dictionary to flatten.\n pa... |
def default_str(str_, default_str):
'Returns :attr:`str_` if it is not `None` or empty, otherwise returns\n :attr:`default_str`.\n\n Args:\n str_: A string.\n default_str: A string.\n\n Returns:\n Either :attr:`str_` or :attr:`default_str`.\n '
if ((str_ is not None) and (str_ !... | 506,481,686,451,076,000 | Returns :attr:`str_` if it is not `None` or empty, otherwise returns
:attr:`default_str`.
Args:
str_: A string.
default_str: A string.
Returns:
Either :attr:`str_` or :attr:`default_str`. | texar/tf/utils/utils.py | default_str | awesomemachinelearning/texar | python | def default_str(str_, default_str):
'Returns :attr:`str_` if it is not `None` or empty, otherwise returns\n :attr:`default_str`.\n\n Args:\n str_: A string.\n default_str: A string.\n\n Returns:\n Either :attr:`str_` or :attr:`default_str`.\n '
if ((str_ is not None) and (str_ !... |
def uniquify_str(str_, str_set):
"Uniquifies :attr:`str_` if :attr:`str_` is included in :attr:`str_set`.\n\n This is done by appending a number to :attr:`str_`. Returns\n :attr:`str_` directly if it is not included in :attr:`str_set`.\n\n Args:\n str_ (string): A string to uniquify.\n str_se... | -2,783,406,203,036,694,000 | Uniquifies :attr:`str_` if :attr:`str_` is included in :attr:`str_set`.
This is done by appending a number to :attr:`str_`. Returns
:attr:`str_` directly if it is not included in :attr:`str_set`.
Args:
str_ (string): A string to uniquify.
str_set (set, dict, or list): A collection of strings. The returned
... | texar/tf/utils/utils.py | uniquify_str | awesomemachinelearning/texar | python | def uniquify_str(str_, str_set):
"Uniquifies :attr:`str_` if :attr:`str_` is included in :attr:`str_set`.\n\n This is done by appending a number to :attr:`str_`. Returns\n :attr:`str_` directly if it is not included in :attr:`str_set`.\n\n Args:\n str_ (string): A string to uniquify.\n str_se... |
def _recur_split(s, dtype_as):
'Splits (possibly nested list of) strings recursively.\n '
if is_str(s):
return _maybe_list_to_array(s.split(), dtype_as)
else:
s_ = [_recur_split(si, dtype_as) for si in s]
return _maybe_list_to_array(s_, s) | 2,575,277,361,996,269,000 | Splits (possibly nested list of) strings recursively. | texar/tf/utils/utils.py | _recur_split | awesomemachinelearning/texar | python | def _recur_split(s, dtype_as):
'\n '
if is_str(s):
return _maybe_list_to_array(s.split(), dtype_as)
else:
s_ = [_recur_split(si, dtype_as) for si in s]
return _maybe_list_to_array(s_, s) |
def strip_token(str_, token, is_token_list=False, compat=True):
"Returns a copy of strings with leading and trailing tokens removed.\n\n Note that besides :attr:`token`, all leading and trailing whitespace\n characters are also removed.\n\n If :attr:`is_token_list` is False, then the function assumes token... | -3,285,159,593,065,620,000 | Returns a copy of strings with leading and trailing tokens removed.
Note that besides :attr:`token`, all leading and trailing whitespace
characters are also removed.
If :attr:`is_token_list` is False, then the function assumes tokens in
:attr:`str_` are separated with whitespace character.
Args:
str_: A `str`, o... | texar/tf/utils/utils.py | strip_token | awesomemachinelearning/texar | python | def strip_token(str_, token, is_token_list=False, compat=True):
"Returns a copy of strings with leading and trailing tokens removed.\n\n Note that besides :attr:`token`, all leading and trailing whitespace\n characters are also removed.\n\n If :attr:`is_token_list` is False, then the function assumes token... |
def strip_eos(str_, eos_token='<EOS>', is_token_list=False, compat=True):
"Remove the EOS token and all subsequent tokens.\n\n If :attr:`is_token_list` is False, then the function assumes tokens in\n :attr:`str_` are separated with whitespace character.\n\n Args:\n str_: A `str`, or an `n`-D numpy a... | -6,987,736,455,651,290,000 | Remove the EOS token and all subsequent tokens.
If :attr:`is_token_list` is False, then the function assumes tokens in
:attr:`str_` are separated with whitespace character.
Args:
str_: A `str`, or an `n`-D numpy array or (possibly nested)
list of `str`.
eos_token (str): The EOS token. Default is '<EOS... | texar/tf/utils/utils.py | strip_eos | awesomemachinelearning/texar | python | def strip_eos(str_, eos_token='<EOS>', is_token_list=False, compat=True):
"Remove the EOS token and all subsequent tokens.\n\n If :attr:`is_token_list` is False, then the function assumes tokens in\n :attr:`str_` are separated with whitespace character.\n\n Args:\n str_: A `str`, or an `n`-D numpy a... |
def strip_bos(str_, bos_token='<BOS>', is_token_list=False, compat=True):
"Remove all leading BOS tokens.\n\n Note that besides :attr:`bos_token`, all leading and trailing whitespace\n characters are also removed.\n\n If :attr:`is_token_list` is False, then the function assumes tokens in\n :attr:`str_` ... | 2,917,346,976,797,500,000 | Remove all leading BOS tokens.
Note that besides :attr:`bos_token`, all leading and trailing whitespace
characters are also removed.
If :attr:`is_token_list` is False, then the function assumes tokens in
:attr:`str_` are separated with whitespace character.
Args:
str_: A `str`, or an `n`-D numpy array or (possib... | texar/tf/utils/utils.py | strip_bos | awesomemachinelearning/texar | python | def strip_bos(str_, bos_token='<BOS>', is_token_list=False, compat=True):
"Remove all leading BOS tokens.\n\n Note that besides :attr:`bos_token`, all leading and trailing whitespace\n characters are also removed.\n\n If :attr:`is_token_list` is False, then the function assumes tokens in\n :attr:`str_` ... |
def strip_special_tokens(str_, strip_pad='<PAD>', strip_bos='<BOS>', strip_eos='<EOS>', is_token_list=False, compat=True):
"Removes special tokens in strings, including:\n\n - Removes EOS and all subsequent tokens\n - Removes leading and and trailing PAD tokens\n - Removes leading BOS tokens\n\... | 8,869,456,144,817,604,000 | Removes special tokens in strings, including:
- Removes EOS and all subsequent tokens
- Removes leading and and trailing PAD tokens
- Removes leading BOS tokens
Note that besides the special tokens, all leading and trailing whitespace
characters are also removed.
This is a joint function of :func:`strip_... | texar/tf/utils/utils.py | strip_special_tokens | awesomemachinelearning/texar | python | def strip_special_tokens(str_, strip_pad='<PAD>', strip_bos='<BOS>', strip_eos='<EOS>', is_token_list=False, compat=True):
"Removes special tokens in strings, including:\n\n - Removes EOS and all subsequent tokens\n - Removes leading and and trailing PAD tokens\n - Removes leading BOS tokens\n\... |
def str_join(tokens, sep=' ', compat=True):
'Concats :attr:`tokens` along the last dimension with intervening\n occurrences of :attr:`sep`.\n\n Args:\n tokens: An `n`-D numpy array or (possibly nested) list of `str`.\n sep (str): The string intervening between the tokens.\n compat (bool):... | -414,424,562,989,632,100 | Concats :attr:`tokens` along the last dimension with intervening
occurrences of :attr:`sep`.
Args:
tokens: An `n`-D numpy array or (possibly nested) list of `str`.
sep (str): The string intervening between the tokens.
compat (bool): Whether to convert tokens into `unicode` (Python 2)
or `str` (Pyth... | texar/tf/utils/utils.py | str_join | awesomemachinelearning/texar | python | def str_join(tokens, sep=' ', compat=True):
'Concats :attr:`tokens` along the last dimension with intervening\n occurrences of :attr:`sep`.\n\n Args:\n tokens: An `n`-D numpy array or (possibly nested) list of `str`.\n sep (str): The string intervening between the tokens.\n compat (bool):... |
def map_ids_to_strs(ids, vocab, join=True, strip_pad='<PAD>', strip_bos='<BOS>', strip_eos='<EOS>', compat=True):
"Transforms `int` indexes to strings by mapping ids to tokens,\n concatenating tokens into sentences, and stripping special tokens, etc.\n\n Args:\n ids: An n-D numpy array or (possibly nes... | 2,363,225,252,825,321,000 | Transforms `int` indexes to strings by mapping ids to tokens,
concatenating tokens into sentences, and stripping special tokens, etc.
Args:
ids: An n-D numpy array or (possibly nested) list of `int` indexes.
vocab: An instance of :class:`~texar.tf.data.Vocab`.
join (bool): Whether to concat along the last ... | texar/tf/utils/utils.py | map_ids_to_strs | awesomemachinelearning/texar | python | def map_ids_to_strs(ids, vocab, join=True, strip_pad='<PAD>', strip_bos='<BOS>', strip_eos='<EOS>', compat=True):
"Transforms `int` indexes to strings by mapping ids to tokens,\n concatenating tokens into sentences, and stripping special tokens, etc.\n\n Args:\n ids: An n-D numpy array or (possibly nes... |
def ceildiv(a, b):
'Divides with ceil.\n\n E.g., `5 / 2 = 2.5`, `ceildiv(5, 2) = 3`.\n\n Args:\n a (int): Dividend integer.\n b (int): Divisor integer.\n\n Returns:\n int: Ceil quotient.\n '
return (- ((- a) // b)) | -7,981,933,774,480,831,000 | Divides with ceil.
E.g., `5 / 2 = 2.5`, `ceildiv(5, 2) = 3`.
Args:
a (int): Dividend integer.
b (int): Divisor integer.
Returns:
int: Ceil quotient. | texar/tf/utils/utils.py | ceildiv | awesomemachinelearning/texar | python | def ceildiv(a, b):
'Divides with ceil.\n\n E.g., `5 / 2 = 2.5`, `ceildiv(5, 2) = 3`.\n\n Args:\n a (int): Dividend integer.\n b (int): Divisor integer.\n\n Returns:\n int: Ceil quotient.\n '
return (- ((- a) // b)) |
def straight_through(fw_tensor, bw_tensor):
'Use a tensor in forward pass while backpropagating gradient to another.\n\n Args:\n fw_tensor: A tensor to be used in the forward pass.\n bw_tensor: A tensor to which gradient is backpropagated. Must have the\n same shape and type with :attr:`... | 3,524,259,948,960,443,000 | Use a tensor in forward pass while backpropagating gradient to another.
Args:
fw_tensor: A tensor to be used in the forward pass.
bw_tensor: A tensor to which gradient is backpropagated. Must have the
same shape and type with :attr:`fw_tensor`.
Returns:
A tensor of the same shape and value with :a... | texar/tf/utils/utils.py | straight_through | awesomemachinelearning/texar | python | def straight_through(fw_tensor, bw_tensor):
'Use a tensor in forward pass while backpropagating gradient to another.\n\n Args:\n fw_tensor: A tensor to be used in the forward pass.\n bw_tensor: A tensor to which gradient is backpropagated. Must have the\n same shape and type with :attr:`... |
def truncate_seq_pair(tokens_a: Union[(List[int], List[str])], tokens_b: Union[(List[int], List[str])], max_length: int):
"Truncates a sequence pair in place to the maximum length.\n\n This is a simple heuristic which will always truncate the longer sequence\n one token at a time. This makes more sense than t... | 2,531,554,402,548,770,000 | Truncates a sequence pair in place to the maximum length.
This is a simple heuristic which will always truncate the longer sequence
one token at a time. This makes more sense than truncating an equal
percent of tokens from each, since if one sequence is very short then
each token that's truncated likely contains more ... | texar/tf/utils/utils.py | truncate_seq_pair | awesomemachinelearning/texar | python | def truncate_seq_pair(tokens_a: Union[(List[int], List[str])], tokens_b: Union[(List[int], List[str])], max_length: int):
"Truncates a sequence pair in place to the maximum length.\n\n This is a simple heuristic which will always truncate the longer sequence\n one token at a time. This makes more sense than t... |
def run_on_app_servers(command):
'\n A helper to copy a single file across app servers\n '
log.info(('Running %s on app servers' % command))
ret_val = 0
if getattr(settings, 'MULTIPLE_APP_SERVERS', None):
for server in settings.MULTIPLE_APP_SERVERS:
ret = os.system(('ssh %s@%s ... | -740,737,386,652,347,800 | A helper to copy a single file across app servers | readthedocs/core/utils/__init__.py | run_on_app_servers | ank-forked/readthedocs.org | python | def run_on_app_servers(command):
'\n \n '
log.info(('Running %s on app servers' % command))
ret_val = 0
if getattr(settings, 'MULTIPLE_APP_SERVERS', None):
for server in settings.MULTIPLE_APP_SERVERS:
ret = os.system(('ssh %s@%s %s' % (SYNC_USER, server, command)))
... |
def trigger_build(project, version=None, record=True, force=False, basic=False):
'\n An API to wrap the triggering of a build.\n '
from readthedocs.projects.tasks import update_docs
if project.skip:
return None
if (not version):
version = project.versions.get(slug=LATEST)
if re... | 6,877,365,090,643,703,000 | An API to wrap the triggering of a build. | readthedocs/core/utils/__init__.py | trigger_build | ank-forked/readthedocs.org | python | def trigger_build(project, version=None, record=True, force=False, basic=False):
'\n \n '
from readthedocs.projects.tasks import update_docs
if project.skip:
return None
if (not version):
version = project.versions.get(slug=LATEST)
if record:
build = Build.objects.creat... |
def send_email(recipient, subject, template, template_html, context=None, request=None):
'\n Send multipart email\n\n recipient\n Email recipient address\n\n subject\n Email subject header\n\n template\n Plain text template to send\n\n template_html\n HTML template to send... | -415,740,951,742,102,200 | Send multipart email
recipient
Email recipient address
subject
Email subject header
template
Plain text template to send
template_html
HTML template to send as new message part
context
A dictionary to pass into the template calls
request
Request object for determining absolute URL | readthedocs/core/utils/__init__.py | send_email | ank-forked/readthedocs.org | python | def send_email(recipient, subject, template, template_html, context=None, request=None):
'\n Send multipart email\n\n recipient\n Email recipient address\n\n subject\n Email subject header\n\n template\n Plain text template to send\n\n template_html\n HTML template to send... |
@staticmethod
def get_schema(max_nesting_depth: Optional[int]=6, nesting_depth: int=0, nesting_list: List[str]=[], max_recursion_limit: Optional[int]=2, include_extension: Optional[bool]=False, extension_fields: Optional[List[str]]=None, extension_depth: int=0, max_extension_depth: Optional[int]=2, include_modifierExte... | -3,726,750,171,931,559,000 | Information about a medication that is used to support knowledge.
id: Unique id for the element within a resource (for internal references). This
may be any string value that does not contain spaces.
extension: May be used to represent additional information that is not part of the basic
definition of the el... | spark_fhir_schemas/r4/complex_types/medicationknowledge_administrationguidelines.py | get_schema | icanbwell/SparkFhirSchemas | python | @staticmethod
def get_schema(max_nesting_depth: Optional[int]=6, nesting_depth: int=0, nesting_list: List[str]=[], max_recursion_limit: Optional[int]=2, include_extension: Optional[bool]=False, extension_fields: Optional[List[str]]=None, extension_depth: int=0, max_extension_depth: Optional[int]=2, include_modifierExte... |
def handler(event, context):
'\n Boto3 Proxy API Handler\n '
headers = event.get('Headers', event.get('headers'))
if ('request-context-id' in headers):
logger.set_uuid(headers['request-context-id'])
logger.info({'Incoming event': event})
logger.info('Incoming context: %s', context)
... | -4,410,066,952,002,910,000 | Boto3 Proxy API Handler | boto3_proxy/index.py | handler | aws-samples/boto3-proxy-api-sls | python | def handler(event, context):
'\n \n '
headers = event.get('Headers', event.get('headers'))
if ('request-context-id' in headers):
logger.set_uuid(headers['request-context-id'])
logger.info({'Incoming event': event})
logger.info('Incoming context: %s', context)
request_body = json.lo... |
def test_wait_for_db_ready(self):
'Test waiting for db when db is available'
with patch('django.db.utils.ConnectionHandler.__getitem__') as gi:
gi.return_value = True
call_command('wait_for_db')
self.assertEqual(gi.call_count, 1) | -6,795,844,142,386,390,000 | Test waiting for db when db is available | app/core/tests/test_commands.py | test_wait_for_db_ready | anirudhs1998/recipe-app-api | python | def test_wait_for_db_ready(self):
with patch('django.db.utils.ConnectionHandler.__getitem__') as gi:
gi.return_value = True
call_command('wait_for_db')
self.assertEqual(gi.call_count, 1) |
@patch('time.sleep', return_value=True)
def test_wait_for_db(self, ts):
'Test waiting for db'
with patch('django.db.utils.ConnectionHandler.__getitem__') as gi:
gi.side_effect = (([OperationalError] * 5) + [True])
call_command('wait_for_db')
self.assertEqual(gi.call_count, 6) | -1,949,014,688,296,956,200 | Test waiting for db | app/core/tests/test_commands.py | test_wait_for_db | anirudhs1998/recipe-app-api | python | @patch('time.sleep', return_value=True)
def test_wait_for_db(self, ts):
with patch('django.db.utils.ConnectionHandler.__getitem__') as gi:
gi.side_effect = (([OperationalError] * 5) + [True])
call_command('wait_for_db')
self.assertEqual(gi.call_count, 6) |
def csrf_failure(request, reason=''):
'\n customize the response for csrf_token invalid\n '
get_token(request)
return JResponse(codes.get('csrf_invalid'), status=403) | -6,097,828,015,095,883,000 | customize the response for csrf_token invalid | apps/core/views.py | csrf_failure | dlooto/driver-vision | python | def csrf_failure(request, reason=):
'\n \n '
get_token(request)
return JResponse(codes.get('csrf_invalid'), status=403) |
def handle_exception(self, exc):
'\n Handle any exception that occurs, by returning an appropriate response,\n or re-raising the error.\n '
if isinstance(exc, exceptions.Throttled):
self.headers['X-Throttle-Wait-Seconds'] = ('%d' % exc.wait)
if isinstance(exc, (exceptions.NotAut... | 632,493,756,669,750,400 | Handle any exception that occurs, by returning an appropriate response,
or re-raising the error. | apps/core/views.py | handle_exception | dlooto/driver-vision | python | def handle_exception(self, exc):
'\n Handle any exception that occurs, by returning an appropriate response,\n or re-raising the error.\n '
if isinstance(exc, exceptions.Throttled):
self.headers['X-Throttle-Wait-Seconds'] = ('%d' % exc.wait)
if isinstance(exc, (exceptions.NotAut... |
def import_migration_script(filepath: Path) -> ModuleType:
'\n 像导入模块一样导入迁移脚本。\n\n :param filepath: 文件路径对象。\n :return:\n '
spec = importlib.util.spec_from_file_location(filepath.stem, filepath)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module | -2,049,019,262,425,342,000 | 像导入模块一样导入迁移脚本。
:param filepath: 文件路径对象。
:return: | scripts/benchmark_migration.py | import_migration_script | psbsgic/rabbitai | python | def import_migration_script(filepath: Path) -> ModuleType:
'\n 像导入模块一样导入迁移脚本。\n\n :param filepath: 文件路径对象。\n :return:\n '
spec = importlib.util.spec_from_file_location(filepath.stem, filepath)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module |
def extract_modified_tables(module: ModuleType) -> Set[str]:
'\n 提取由迁移脚本修改的表。\n\n 此函数使用一种简单的方法来查看迁移脚本的源代码以查找模式。它可以通过实际遍历AST来改进。\n '
tables: Set[str] = set()
for function in {'upgrade', 'downgrade'}:
source = getsource(getattr(module, function))
tables.update(re.findall('alter_table\... | -3,717,283,260,242,543,600 | 提取由迁移脚本修改的表。
此函数使用一种简单的方法来查看迁移脚本的源代码以查找模式。它可以通过实际遍历AST来改进。 | scripts/benchmark_migration.py | extract_modified_tables | psbsgic/rabbitai | python | def extract_modified_tables(module: ModuleType) -> Set[str]:
'\n 提取由迁移脚本修改的表。\n\n 此函数使用一种简单的方法来查看迁移脚本的源代码以查找模式。它可以通过实际遍历AST来改进。\n '
tables: Set[str] = set()
for function in {'upgrade', 'downgrade'}:
source = getsource(getattr(module, function))
tables.update(re.findall('alter_table\... |
def find_models(module: ModuleType) -> List[Type[Model]]:
'\n 在迁移脚本中查找所有模型。\n\n :param module:\n :return:\n '
models: List[Type[Model]] = []
tables = extract_modified_tables(module)
queue = list(module.__dict__.values())
while queue:
obj = queue.pop()
if hasattr(obj, '__t... | 84,442,892,764,014,050 | 在迁移脚本中查找所有模型。
:param module:
:return: | scripts/benchmark_migration.py | find_models | psbsgic/rabbitai | python | def find_models(module: ModuleType) -> List[Type[Model]]:
'\n 在迁移脚本中查找所有模型。\n\n :param module:\n :return:\n '
models: List[Type[Model]] = []
tables = extract_modified_tables(module)
queue = list(module.__dict__.values())
while queue:
obj = queue.pop()
if hasattr(obj, '__t... |
def testCollection(self):
'Test Collection'
pass | -6,335,657,216,248,031,000 | Test Collection | test/test_collection.py | testCollection | FlatIO/api-client-python | python | def testCollection(self):
pass |
def main():
'Run administrative tasks.'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projeto_curso_2.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError("Couldn't import Django. Are you sure it's installed and avai... | 6,405,390,842,609,496,000 | Run administrative tasks. | Python/Django/projeto_curso_2/manage.py | main | Jhonattan-rocha/Meus-Projetos | python | def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projeto_curso_2.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError("Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH en... |
def __init__(__self__, *, event_time_feature_name: pulumi.Input[str], feature_definitions: pulumi.Input[Sequence[pulumi.Input['FeatureGroupFeatureDefinitionArgs']]], record_identifier_feature_name: pulumi.Input[str], description: Optional[pulumi.Input[str]]=None, feature_group_name: Optional[pulumi.Input[str]]=None, of... | 4,726,648,118,209,927,000 | The set of arguments for constructing a FeatureGroup resource.
:param pulumi.Input[str] event_time_feature_name: The Event Time Feature Name.
:param pulumi.Input[Sequence[pulumi.Input['FeatureGroupFeatureDefinitionArgs']]] feature_definitions: An Array of Feature Definition
:param pulumi.Input[str] record_identifier_fe... | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | __init__ | AaronFriel/pulumi-aws-native | python | def __init__(__self__, *, event_time_feature_name: pulumi.Input[str], feature_definitions: pulumi.Input[Sequence[pulumi.Input['FeatureGroupFeatureDefinitionArgs']]], record_identifier_feature_name: pulumi.Input[str], description: Optional[pulumi.Input[str]]=None, feature_group_name: Optional[pulumi.Input[str]]=None, of... |
@property
@pulumi.getter(name='eventTimeFeatureName')
def event_time_feature_name(self) -> pulumi.Input[str]:
'\n The Event Time Feature Name.\n '
return pulumi.get(self, 'event_time_feature_name') | -6,416,241,475,527,700,000 | The Event Time Feature Name. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | event_time_feature_name | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='eventTimeFeatureName')
def event_time_feature_name(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'event_time_feature_name') |
@property
@pulumi.getter(name='featureDefinitions')
def feature_definitions(self) -> pulumi.Input[Sequence[pulumi.Input['FeatureGroupFeatureDefinitionArgs']]]:
'\n An Array of Feature Definition\n '
return pulumi.get(self, 'feature_definitions') | -5,340,760,594,595,287,000 | An Array of Feature Definition | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | feature_definitions | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='featureDefinitions')
def feature_definitions(self) -> pulumi.Input[Sequence[pulumi.Input['FeatureGroupFeatureDefinitionArgs']]]:
'\n \n '
return pulumi.get(self, 'feature_definitions') |
@property
@pulumi.getter(name='recordIdentifierFeatureName')
def record_identifier_feature_name(self) -> pulumi.Input[str]:
'\n The Record Identifier Feature Name.\n '
return pulumi.get(self, 'record_identifier_feature_name') | 6,774,048,955,246,120,000 | The Record Identifier Feature Name. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | record_identifier_feature_name | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='recordIdentifierFeatureName')
def record_identifier_feature_name(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'record_identifier_feature_name') |
@property
@pulumi.getter
def description(self) -> Optional[pulumi.Input[str]]:
'\n Description about the FeatureGroup.\n '
return pulumi.get(self, 'description') | -3,992,035,966,188,649,500 | Description about the FeatureGroup. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | description | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter
def description(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'description') |
@property
@pulumi.getter(name='featureGroupName')
def feature_group_name(self) -> Optional[pulumi.Input[str]]:
'\n The Name of the FeatureGroup.\n '
return pulumi.get(self, 'feature_group_name') | 2,869,057,682,488,510,500 | The Name of the FeatureGroup. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | feature_group_name | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='featureGroupName')
def feature_group_name(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'feature_group_name') |
@property
@pulumi.getter(name='roleArn')
def role_arn(self) -> Optional[pulumi.Input[str]]:
'\n Role Arn\n '
return pulumi.get(self, 'role_arn') | 1,805,397,546,919,502,800 | Role Arn | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | role_arn | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='roleArn')
def role_arn(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'role_arn') |
@property
@pulumi.getter
def tags(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['FeatureGroupTagArgs']]]]:
'\n An array of key-value pair to apply to this resource.\n '
return pulumi.get(self, 'tags') | -8,411,379,860,920,348,000 | An array of key-value pair to apply to this resource. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | tags | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter
def tags(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['FeatureGroupTagArgs']]]]:
'\n \n '
return pulumi.get(self, 'tags') |
@overload
def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions]=None, description: Optional[pulumi.Input[str]]=None, event_time_feature_name: Optional[pulumi.Input[str]]=None, feature_definitions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['FeatureGroupFeatureDefinitionArgs... | 7,006,342,061,316,322,000 | Resource Type definition for AWS::SageMaker::FeatureGroup
:param str resource_name: The name of the resource.
:param pulumi.ResourceOptions opts: Options for the resource.
:param pulumi.Input[str] description: Description about the FeatureGroup.
:param pulumi.Input[str] event_time_feature_name: The Event Time Feature ... | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | __init__ | AaronFriel/pulumi-aws-native | python | @overload
def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions]=None, description: Optional[pulumi.Input[str]]=None, event_time_feature_name: Optional[pulumi.Input[str]]=None, feature_definitions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['FeatureGroupFeatureDefinitionArgs... |
@overload
def __init__(__self__, resource_name: str, args: FeatureGroupArgs, opts: Optional[pulumi.ResourceOptions]=None):
"\n Resource Type definition for AWS::SageMaker::FeatureGroup\n\n :param str resource_name: The name of the resource.\n :param FeatureGroupArgs args: The arguments to use t... | 4,174,137,226,898,446,000 | Resource Type definition for AWS::SageMaker::FeatureGroup
:param str resource_name: The name of the resource.
:param FeatureGroupArgs args: The arguments to use to populate this resource's properties.
:param pulumi.ResourceOptions opts: Options for the resource. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | __init__ | AaronFriel/pulumi-aws-native | python | @overload
def __init__(__self__, resource_name: str, args: FeatureGroupArgs, opts: Optional[pulumi.ResourceOptions]=None):
"\n Resource Type definition for AWS::SageMaker::FeatureGroup\n\n :param str resource_name: The name of the resource.\n :param FeatureGroupArgs args: The arguments to use t... |
@staticmethod
def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions]=None) -> 'FeatureGroup':
"\n Get an existing FeatureGroup resource's state with the given name, id, and optional extra\n properties used to qualify the lookup.\n\n :param str resource_name: T... | 1,944,888,711,795,488,300 | Get an existing FeatureGroup resource's state with the given name, id, and optional extra
properties used to qualify the lookup.
:param str resource_name: The unique name of the resulting resource.
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
:param pulumi.ResourceOptions opts: Option... | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | get | AaronFriel/pulumi-aws-native | python | @staticmethod
def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions]=None) -> 'FeatureGroup':
"\n Get an existing FeatureGroup resource's state with the given name, id, and optional extra\n properties used to qualify the lookup.\n\n :param str resource_name: T... |
@property
@pulumi.getter
def description(self) -> pulumi.Output[Optional[str]]:
'\n Description about the FeatureGroup.\n '
return pulumi.get(self, 'description') | 7,839,220,219,234,934,000 | Description about the FeatureGroup. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | description | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter
def description(self) -> pulumi.Output[Optional[str]]:
'\n \n '
return pulumi.get(self, 'description') |
@property
@pulumi.getter(name='eventTimeFeatureName')
def event_time_feature_name(self) -> pulumi.Output[str]:
'\n The Event Time Feature Name.\n '
return pulumi.get(self, 'event_time_feature_name') | 2,729,640,645,715,223,000 | The Event Time Feature Name. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | event_time_feature_name | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='eventTimeFeatureName')
def event_time_feature_name(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'event_time_feature_name') |
@property
@pulumi.getter(name='featureDefinitions')
def feature_definitions(self) -> pulumi.Output[Sequence['outputs.FeatureGroupFeatureDefinition']]:
'\n An Array of Feature Definition\n '
return pulumi.get(self, 'feature_definitions') | -5,263,120,084,766,599,000 | An Array of Feature Definition | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | feature_definitions | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='featureDefinitions')
def feature_definitions(self) -> pulumi.Output[Sequence['outputs.FeatureGroupFeatureDefinition']]:
'\n \n '
return pulumi.get(self, 'feature_definitions') |
@property
@pulumi.getter(name='featureGroupName')
def feature_group_name(self) -> pulumi.Output[str]:
'\n The Name of the FeatureGroup.\n '
return pulumi.get(self, 'feature_group_name') | 76,128,626,260,792,700 | The Name of the FeatureGroup. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | feature_group_name | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='featureGroupName')
def feature_group_name(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'feature_group_name') |
@property
@pulumi.getter(name='recordIdentifierFeatureName')
def record_identifier_feature_name(self) -> pulumi.Output[str]:
'\n The Record Identifier Feature Name.\n '
return pulumi.get(self, 'record_identifier_feature_name') | -413,171,169,813,399,740 | The Record Identifier Feature Name. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | record_identifier_feature_name | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='recordIdentifierFeatureName')
def record_identifier_feature_name(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'record_identifier_feature_name') |
@property
@pulumi.getter(name='roleArn')
def role_arn(self) -> pulumi.Output[Optional[str]]:
'\n Role Arn\n '
return pulumi.get(self, 'role_arn') | -1,009,756,846,288,155,300 | Role Arn | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | role_arn | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter(name='roleArn')
def role_arn(self) -> pulumi.Output[Optional[str]]:
'\n \n '
return pulumi.get(self, 'role_arn') |
@property
@pulumi.getter
def tags(self) -> pulumi.Output[Optional[Sequence['outputs.FeatureGroupTag']]]:
'\n An array of key-value pair to apply to this resource.\n '
return pulumi.get(self, 'tags') | -6,255,290,692,497,689,000 | An array of key-value pair to apply to this resource. | sdk/python/pulumi_aws_native/sagemaker/feature_group.py | tags | AaronFriel/pulumi-aws-native | python | @property
@pulumi.getter
def tags(self) -> pulumi.Output[Optional[Sequence['outputs.FeatureGroupTag']]]:
'\n \n '
return pulumi.get(self, 'tags') |
def deleteByUrl(self, url):
'\n called by the user handler when a user file is deleted\n @param url:\n @return:\n '
if (url is None):
return
for addon in self.addonList:
if ((addon.get('canDelete') == True) and (addon.get('url') == url)):
self.handleDelete(addon.get('... | 7,618,676,562,966,029,000 | called by the user handler when a user file is deleted
@param url:
@return: | server/handler/avnuserapps.py | deleteByUrl | Littlechay/avnav | python | def deleteByUrl(self, url):
'\n called by the user handler when a user file is deleted\n @param url:\n @return:\n '
if (url is None):
return
for addon in self.addonList:
if ((addon.get('canDelete') == True) and (addon.get('url') == url)):
self.handleDelete(addon.get('... |
@home.route('/edit/<page>')
def edit(page: str=None):
'\n The edit page allows for direct editing of a top-level element such as\n title, abstract, creators, etc. This function simply redirects to the\n specified page, passing the packageid as the only parameter.\n '
if (current_user.is_authenticate... | -8,779,591,209,362,613,000 | The edit page allows for direct editing of a top-level element such as
title, abstract, creators, etc. This function simply redirects to the
specified page, passing the packageid as the only parameter. | webapp/home/views.py | edit | mother-db/ezEMLmotherDB | python | @home.route('/edit/<page>')
def edit(page: str=None):
'\n The edit page allows for direct editing of a top-level element such as\n title, abstract, creators, etc. This function simply redirects to the\n specified page, passing the packageid as the only parameter.\n '
if (current_user.is_authenticate... |
def _parse_dsn(self, dsn):
'Method parses dsn\n\n Args: \n dsn (str): dsn\n\n Returns:\n bool: True\n\n Raises:\n exception: Exception\n\n '
dsn_opt = dsn.split(':')[1]
dsn_opt_tokens = dsn_opt.split(';')
for dsn_opt_token in dsn_opt_tokens:
... | 5,464,980,362,926,090,000 | Method parses dsn
Args:
dsn (str): dsn
Returns:
bool: True
Raises:
exception: Exception | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | _parse_dsn | hydratk/hydratk-lib-network | python | def _parse_dsn(self, dsn):
'Method parses dsn\n\n Args: \n dsn (str): dsn\n\n Returns:\n bool: True\n\n Raises:\n exception: Exception\n\n '
dsn_opt = dsn.split(':')[1]
dsn_opt_tokens = dsn_opt.split(';')
for dsn_opt_token in dsn_opt_tokens:
... |
def _apply_driver_options(self, driver_options):
'Method sets driver options\n\n Args: \n driver_option (dict): driver options\n\n Returns:\n void\n\n '
for (optname, optval) in driver_options.items():
if (optname in self._driver_options):
self._dri... | 5,377,836,542,734,329,000 | Method sets driver options
Args:
driver_option (dict): driver options
Returns:
void | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | _apply_driver_options | hydratk/hydratk-lib-network | python | def _apply_driver_options(self, driver_options):
'Method sets driver options\n\n Args: \n driver_option (dict): driver options\n\n Returns:\n void\n\n '
for (optname, optval) in driver_options.items():
if (optname in self._driver_options):
self._dri... |
def connect(self):
'Method connects to database\n\n Args: \n none\n\n Returns:\n void\n\n '
self._dbcon = pymssql.connect(server=self._host, port=self._port, database=self._dbname, user=self._username, password=self._password)
self.result_as_dict(self._result_as_di... | 4,906,923,915,497,192,000 | Method connects to database
Args:
none
Returns:
void | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | connect | hydratk/hydratk-lib-network | python | def connect(self):
'Method connects to database\n\n Args: \n none\n\n Returns:\n void\n\n '
self._dbcon = pymssql.connect(server=self._host, port=self._port, database=self._dbname, user=self._username, password=self._password)
self.result_as_dict(self._result_as_di... |
def close(self):
'Method disconnects from database\n\n Args: \n none \n\n Returns:\n void\n\n Raises:\n exception: DBODriverException\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
self._dbcon.close()
else:
raise dbod... | 3,477,112,732,506,575,000 | Method disconnects from database
Args:
none
Returns:
void
Raises:
exception: DBODriverException | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | close | hydratk/hydratk-lib-network | python | def close(self):
'Method disconnects from database\n\n Args: \n none \n\n Returns:\n void\n\n Raises:\n exception: DBODriverException\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
self._dbcon.close()
else:
raise dbod... |
def commit(self):
'Method commits transaction\n\n Args:\n none \n\n Returns:\n void\n\n Raises:\n exception: DBODriverException\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
self._dbcon.commit()
else:
raise dbodrive... | -362,832,216,166,127,700 | Method commits transaction
Args:
none
Returns:
void
Raises:
exception: DBODriverException | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | commit | hydratk/hydratk-lib-network | python | def commit(self):
'Method commits transaction\n\n Args:\n none \n\n Returns:\n void\n\n Raises:\n exception: DBODriverException\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
self._dbcon.commit()
else:
raise dbodrive... |
def execute(self, sql, *parameters):
'Method executes query\n\n Args: \n sql (str): SQL query\n parameters (args): query parameters\n\n Returns:\n obj: cursor\n\n '
self._cursor.execute(sql, tuple(parameters))
return self._cursor | -4,254,376,136,096,039,000 | Method executes query
Args:
sql (str): SQL query
parameters (args): query parameters
Returns:
obj: cursor | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | execute | hydratk/hydratk-lib-network | python | def execute(self, sql, *parameters):
'Method executes query\n\n Args: \n sql (str): SQL query\n parameters (args): query parameters\n\n Returns:\n obj: cursor\n\n '
self._cursor.execute(sql, tuple(parameters))
return self._cursor |
def rollback(self):
'Method rollbacks transaction\n\n Args: \n none \n\n Returns:\n void\n\n Raises:\n exception: DBODriverException\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
self._dbcon.rollback()
else:
raise db... | -8,367,256,448,439,113,000 | Method rollbacks transaction
Args:
none
Returns:
void
Raises:
exception: DBODriverException | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | rollback | hydratk/hydratk-lib-network | python | def rollback(self):
'Method rollbacks transaction\n\n Args: \n none \n\n Returns:\n void\n\n Raises:\n exception: DBODriverException\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
self._dbcon.rollback()
else:
raise db... |
def __getitem__(self, name):
'Method gets item\n\n Args: \n name (str): item name\n\n Returns:\n obj: item value\n\n '
if hasattr(pymssql, name):
return getattr(pymssql, name) | -8,807,495,268,656,493,000 | Method gets item
Args:
name (str): item name
Returns:
obj: item value | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | __getitem__ | hydratk/hydratk-lib-network | python | def __getitem__(self, name):
'Method gets item\n\n Args: \n name (str): item name\n\n Returns:\n obj: item value\n\n '
if hasattr(pymssql, name):
return getattr(pymssql, name) |
def __getattr__(self, name):
'Method gets attribute\n\n Args: \n name (str): attribute name\n\n Returns:\n obj: attribute value\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
if hasattr(self._dbcon, name):
return getattr(self._dbcon,... | 6,261,033,816,165,780,000 | Method gets attribute
Args:
name (str): attribute name
Returns:
obj: attribute value | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | __getattr__ | hydratk/hydratk-lib-network | python | def __getattr__(self, name):
'Method gets attribute\n\n Args: \n name (str): attribute name\n\n Returns:\n obj: attribute value\n\n '
if (type(self._dbcon).__name__.lower() == 'connection'):
if hasattr(self._dbcon, name):
return getattr(self._dbcon,... |
def table_exists(self, table_name):
'Method checks if table exists\n\n Args: \n table_name (str): table\n\n Returns:\n bool: result\n\n '
if ((table_name is not None) and (table_name != '')):
query = "SELECT count(*) found FROM information_schema.tables WHERE t... | 5,841,529,789,103,357,000 | Method checks if table exists
Args:
table_name (str): table
Returns:
bool: result | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | table_exists | hydratk/hydratk-lib-network | python | def table_exists(self, table_name):
'Method checks if table exists\n\n Args: \n table_name (str): table\n\n Returns:\n bool: result\n\n '
if ((table_name is not None) and (table_name != )):
query = "SELECT count(*) found FROM information_schema.tables WHERE tab... |
def result_as_dict(self, state):
'Method enables query result in dictionary form\n\n Args: \n state (bool): enable dictionary\n\n Returns:\n void\n\n Raises:\n error: TypeError\n\n '
if (state in (True, False)):
self._result_as_dict = state
... | -2,179,482,725,482,715,100 | Method enables query result in dictionary form
Args:
state (bool): enable dictionary
Returns:
void
Raises:
error: TypeError | src/hydratk/lib/database/dbo/drivers/mssql/driver.py | result_as_dict | hydratk/hydratk-lib-network | python | def result_as_dict(self, state):
'Method enables query result in dictionary form\n\n Args: \n state (bool): enable dictionary\n\n Returns:\n void\n\n Raises:\n error: TypeError\n\n '
if (state in (True, False)):
self._result_as_dict = state
... |
def decode_annotations(annotaitons_str):
'decode annotations in string to list of dict'
return literal_eval(annotaitons_str) | 1,117,040,142,727,590,400 | decode annotations in string to list of dict | src/util.py | decode_annotations | VincentWang25/Kaggle_TGBR | python | def decode_annotations(annotaitons_str):
return literal_eval(annotaitons_str) |
def calc_is_correct(gt_bboxes, pred_bboxes, iou_th=0.5):
'\n gt_bboxes: (N, 4) np.array in xywh format\n pred_bboxes: (N, 5) np.array in conf+xywh format\n '
if ((len(gt_bboxes) == 0) and (len(pred_bboxes) == 0)):
(tps, fps, fns) = (0, 0, 0)
return (tps, fps, fns)
elif (len(gt_bboxe... | -4,513,493,385,936,297,000 | gt_bboxes: (N, 4) np.array in xywh format
pred_bboxes: (N, 5) np.array in conf+xywh format | src/util.py | calc_is_correct | VincentWang25/Kaggle_TGBR | python | def calc_is_correct(gt_bboxes, pred_bboxes, iou_th=0.5):
'\n gt_bboxes: (N, 4) np.array in xywh format\n pred_bboxes: (N, 5) np.array in conf+xywh format\n '
if ((len(gt_bboxes) == 0) and (len(pred_bboxes) == 0)):
(tps, fps, fns) = (0, 0, 0)
return (tps, fps, fns)
elif (len(gt_bboxe... |
def calc_f2_score(gt_bboxes_list, pred_bboxes_list, verbose=False):
'\n gt_bboxes_list: list of (N, 4) np.array in xywh format\n pred_bboxes_list: list of (N, 5) np.array in conf+xywh format\n '
f2_dict = {'f2': 0, 'P': 0, 'R': 0}
all_tps = [list(([0] * 11)) for _ in range(len(gt_bboxes_list))]
... | 2,122,643,224,007,596,000 | gt_bboxes_list: list of (N, 4) np.array in xywh format
pred_bboxes_list: list of (N, 5) np.array in conf+xywh format | src/util.py | calc_f2_score | VincentWang25/Kaggle_TGBR | python | def calc_f2_score(gt_bboxes_list, pred_bboxes_list, verbose=False):
'\n gt_bboxes_list: list of (N, 4) np.array in xywh format\n pred_bboxes_list: list of (N, 5) np.array in conf+xywh format\n '
f2_dict = {'f2': 0, 'P': 0, 'R': 0}
all_tps = [list(([0] * 11)) for _ in range(len(gt_bboxes_list))]
... |
def voc2yolo(image_height, image_width, bboxes):
'\n voc => [x1, y1, x2, y1]\n yolo => [xmid, ymid, w, h] (normalized)\n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] / image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] / image_height)
w = (... | 2,176,480,684,608,862,700 | voc => [x1, y1, x2, y1]
yolo => [xmid, ymid, w, h] (normalized) | src/util.py | voc2yolo | VincentWang25/Kaggle_TGBR | python | def voc2yolo(image_height, image_width, bboxes):
'\n voc => [x1, y1, x2, y1]\n yolo => [xmid, ymid, w, h] (normalized)\n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] / image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] / image_height)
w = (... |
def yolo2voc(image_height, image_width, bboxes):
'\n yolo => [xmid, ymid, w, h] (normalized)\n voc => [x1, y1, x2, y1]\n \n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] * image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] * image_height)
... | -8,946,346,664,116,537,000 | yolo => [xmid, ymid, w, h] (normalized)
voc => [x1, y1, x2, y1] | src/util.py | yolo2voc | VincentWang25/Kaggle_TGBR | python | def yolo2voc(image_height, image_width, bboxes):
'\n yolo => [xmid, ymid, w, h] (normalized)\n voc => [x1, y1, x2, y1]\n \n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] * image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] * image_height)
... |
def coco2yolo(image_height, image_width, bboxes):
'\n coco => [xmin, ymin, w, h]\n yolo => [xmid, ymid, w, h] (normalized)\n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] / image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] / image_height)
bb... | -7,745,974,295,583,745,000 | coco => [xmin, ymin, w, h]
yolo => [xmid, ymid, w, h] (normalized) | src/util.py | coco2yolo | VincentWang25/Kaggle_TGBR | python | def coco2yolo(image_height, image_width, bboxes):
'\n coco => [xmin, ymin, w, h]\n yolo => [xmid, ymid, w, h] (normalized)\n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] / image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] / image_height)
bb... |
def yolo2coco(image_height, image_width, bboxes):
'\n yolo => [xmid, ymid, w, h] (normalized)\n coco => [xmin, ymin, w, h]\n \n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] * image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] * image_height)
... | -199,636,694,656,450,980 | yolo => [xmid, ymid, w, h] (normalized)
coco => [xmin, ymin, w, h] | src/util.py | yolo2coco | VincentWang25/Kaggle_TGBR | python | def yolo2coco(image_height, image_width, bboxes):
'\n yolo => [xmid, ymid, w, h] (normalized)\n coco => [xmin, ymin, w, h]\n \n '
bboxes = bboxes.copy().astype(float)
bboxes[(..., [0, 2])] = (bboxes[(..., [0, 2])] * image_width)
bboxes[(..., [1, 3])] = (bboxes[(..., [1, 3])] * image_height)
... |
def py_cpu_softnms(dets, sc, Nt=0.3, sigma=0.5, thresh=0.001, method=2):
'\n py_cpu_softnms\n :param dets: boexs 坐标矩阵 format [y1, x1, y2, x2]\n :param sc: 每个 boxes 对应的分数\n :param Nt: iou 交叠门限\n :param sigma: 使用 gaussian 函数的方差\n :param thresh: 最后的分数门限\n :param method: 使用的方法\n :retu... | 2,295,457,227,040,895,200 | py_cpu_softnms
:param dets: boexs 坐标矩阵 format [y1, x1, y2, x2]
:param sc: 每个 boxes 对应的分数
:param Nt: iou 交叠门限
:param sigma: 使用 gaussian 函数的方差
:param thresh: 最后的分数门限
:param method: 使用的方法
:return: 留下的 boxes 的 index | src/util.py | py_cpu_softnms | VincentWang25/Kaggle_TGBR | python | def py_cpu_softnms(dets, sc, Nt=0.3, sigma=0.5, thresh=0.001, method=2):
'\n py_cpu_softnms\n :param dets: boexs 坐标矩阵 format [y1, x1, y2, x2]\n :param sc: 每个 boxes 对应的分数\n :param Nt: iou 交叠门限\n :param sigma: 使用 gaussian 函数的方差\n :param thresh: 最后的分数门限\n :param method: 使用的方法\n :retu... |
@pytest.fixture(autouse=True)
def mock_upnp_device():
'Mock homeassistant.components.upnp.Device.'
async def mock_async_create_upnp_device(hass: HomeAssistant, location: str) -> UpnpDevice:
'Create UPnP device.'
return MockUpnpDevice(location)
with patch('homeassistant.components.upnp.devic... | 1,470,672,891,934,273,500 | Mock homeassistant.components.upnp.Device. | tests/components/upnp/conftest.py | mock_upnp_device | Aeroid/home-assistant-core | python | @pytest.fixture(autouse=True)
def mock_upnp_device():
async def mock_async_create_upnp_device(hass: HomeAssistant, location: str) -> UpnpDevice:
'Create UPnP device.'
return MockUpnpDevice(location)
with patch('homeassistant.components.upnp.device.async_create_upnp_device', side_effect=moc... |
@pytest.fixture
def mock_setup_entry():
'Mock async_setup_entry.'
with patch('homeassistant.components.upnp.async_setup_entry', return_value=AsyncMock(True)) as mock_setup:
(yield mock_setup) | 7,327,902,129,160,842,000 | Mock async_setup_entry. | tests/components/upnp/conftest.py | mock_setup_entry | Aeroid/home-assistant-core | python | @pytest.fixture
def mock_setup_entry():
with patch('homeassistant.components.upnp.async_setup_entry', return_value=AsyncMock(True)) as mock_setup:
(yield mock_setup) |
@pytest.fixture(autouse=True)
async def silent_ssdp_scanner(hass):
'Start SSDP component and get Scanner, prevent actual SSDP traffic.'
with patch('homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners'), patch('homeassistant.components.ssdp.Scanner._async_stop_ssdp_listeners'), patch('homeassistant... | -6,081,952,182,349,832,000 | Start SSDP component and get Scanner, prevent actual SSDP traffic. | tests/components/upnp/conftest.py | silent_ssdp_scanner | Aeroid/home-assistant-core | python | @pytest.fixture(autouse=True)
async def silent_ssdp_scanner(hass):
with patch('homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners'), patch('homeassistant.components.ssdp.Scanner._async_stop_ssdp_listeners'), patch('homeassistant.components.ssdp.Scanner.async_scan'):
(yield) |
@pytest.fixture
async def ssdp_instant_discovery():
'Instance discovery.'
async def register_callback(hass, callback, match_dict):
'Immediately do callback.'
(await callback(TEST_DISCOVERY, ssdp.SsdpChange.ALIVE))
return MagicMock()
with patch('homeassistant.components.ssdp.async_re... | 8,603,913,981,920,339,000 | Instance discovery. | tests/components/upnp/conftest.py | ssdp_instant_discovery | Aeroid/home-assistant-core | python | @pytest.fixture
async def ssdp_instant_discovery():
async def register_callback(hass, callback, match_dict):
'Immediately do callback.'
(await callback(TEST_DISCOVERY, ssdp.SsdpChange.ALIVE))
return MagicMock()
with patch('homeassistant.components.ssdp.async_register_callback', sid... |
@pytest.fixture
async def ssdp_no_discovery():
'No discovery.'
async def register_callback(hass, callback, match_dict):
"Don't do callback."
return MagicMock()
with patch('homeassistant.components.ssdp.async_register_callback', side_effect=register_callback) as mock_register, patch('homeass... | -4,688,020,496,969,370,000 | No discovery. | tests/components/upnp/conftest.py | ssdp_no_discovery | Aeroid/home-assistant-core | python | @pytest.fixture
async def ssdp_no_discovery():
async def register_callback(hass, callback, match_dict):
"Don't do callback."
return MagicMock()
with patch('homeassistant.components.ssdp.async_register_callback', side_effect=register_callback) as mock_register, patch('homeassistant.componen... |
@pytest.fixture
async def setup_integration(hass: HomeAssistant, mock_get_source_ip, ssdp_instant_discovery, mock_upnp_device):
'Create an initialized integration.'
entry = MockConfigEntry(domain=DOMAIN, data={CONFIG_ENTRY_UDN: TEST_UDN, CONFIG_ENTRY_ST: TEST_ST})
entry.add_to_hass(hass)
(await hass.con... | 8,657,213,048,427,507,000 | Create an initialized integration. | tests/components/upnp/conftest.py | setup_integration | Aeroid/home-assistant-core | python | @pytest.fixture
async def setup_integration(hass: HomeAssistant, mock_get_source_ip, ssdp_instant_discovery, mock_upnp_device):
entry = MockConfigEntry(domain=DOMAIN, data={CONFIG_ENTRY_UDN: TEST_UDN, CONFIG_ENTRY_ST: TEST_ST})
entry.add_to_hass(hass)
(await hass.config_entries.async_setup(entry.entry_... |
def __init__(self, location: str) -> None:
'Initialize.'
self.device_url = location | -5,251,167,248,682,339,000 | Initialize. | tests/components/upnp/conftest.py | __init__ | Aeroid/home-assistant-core | python | def __init__(self, location: str) -> None:
self.device_url = location |
@property
def manufacturer(self) -> str:
'Get manufacturer.'
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_MANUFACTURER] | -1,840,653,333,174,673,000 | Get manufacturer. | tests/components/upnp/conftest.py | manufacturer | Aeroid/home-assistant-core | python | @property
def manufacturer(self) -> str:
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_MANUFACTURER] |
@property
def name(self) -> str:
'Get name.'
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME] | -168,337,571,497,190,340 | Get name. | tests/components/upnp/conftest.py | name | Aeroid/home-assistant-core | python | @property
def name(self) -> str:
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME] |
@property
def model_name(self) -> str:
'Get the model name.'
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_MODEL_NAME] | 7,037,925,087,428,130,000 | Get the model name. | tests/components/upnp/conftest.py | model_name | Aeroid/home-assistant-core | python | @property
def model_name(self) -> str:
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_MODEL_NAME] |
@property
def device_type(self) -> str:
'Get the device type.'
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_DEVICE_TYPE] | 6,534,857,306,003,408,000 | Get the device type. | tests/components/upnp/conftest.py | device_type | Aeroid/home-assistant-core | python | @property
def device_type(self) -> str:
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_DEVICE_TYPE] |
@property
def udn(self) -> str:
'Get the UDN.'
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_UDN] | -4,505,216,607,875,272,700 | Get the UDN. | tests/components/upnp/conftest.py | udn | Aeroid/home-assistant-core | python | @property
def udn(self) -> str:
return TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_UDN] |
@property
def usn(self) -> str:
'Get the USN.'
return f'{self.udn}::{self.device_type}' | -9,055,645,516,802,463,000 | Get the USN. | tests/components/upnp/conftest.py | usn | Aeroid/home-assistant-core | python | @property
def usn(self) -> str:
return f'{self.udn}::{self.device_type}' |
@property
def unique_id(self) -> str:
'Get the unique id.'
return self.usn | -1,300,460,451,944,561,700 | Get the unique id. | tests/components/upnp/conftest.py | unique_id | Aeroid/home-assistant-core | python | @property
def unique_id(self) -> str:
return self.usn |
def reinit(self, new_upnp_device: UpnpDevice) -> None:
'Reinitialize.'
self.device_url = new_upnp_device.device_url | -3,690,047,482,408,017,000 | Reinitialize. | tests/components/upnp/conftest.py | reinit | Aeroid/home-assistant-core | python | def reinit(self, new_upnp_device: UpnpDevice) -> None:
self.device_url = new_upnp_device.device_url |
def __init__(self, device: MockUpnpDevice, event_handler: UpnpEventHandler) -> None:
'Initialize mock device.'
self.device = device
self.profile_device = device
self._timestamp = dt.utcnow()
self.traffic_times_polled = 0
self.status_times_polled = 0
self.traffic_data = {BYTES_RECEIVED: 0, BY... | 1,895,974,175,736,167,700 | Initialize mock device. | tests/components/upnp/conftest.py | __init__ | Aeroid/home-assistant-core | python | def __init__(self, device: MockUpnpDevice, event_handler: UpnpEventHandler) -> None:
self.device = device
self.profile_device = device
self._timestamp = dt.utcnow()
self.traffic_times_polled = 0
self.status_times_polled = 0
self.traffic_data = {BYTES_RECEIVED: 0, BYTES_SENT: 0, PACKETS_RECE... |
@property
def name(self) -> str:
'Get the name of the device.'
return self.profile_device.name | 8,179,922,228,888,954,000 | Get the name of the device. | tests/components/upnp/conftest.py | name | Aeroid/home-assistant-core | python | @property
def name(self) -> str:
return self.profile_device.name |
@property
def manufacturer(self) -> str:
'Get the manufacturer of this device.'
return self.profile_device.manufacturer | 2,394,092,014,073,006,600 | Get the manufacturer of this device. | tests/components/upnp/conftest.py | manufacturer | Aeroid/home-assistant-core | python | @property
def manufacturer(self) -> str:
return self.profile_device.manufacturer |
@property
def model_name(self) -> str:
'Get the model name of this device.'
return self.profile_device.model_name | 7,306,830,325,269,109,000 | Get the model name of this device. | tests/components/upnp/conftest.py | model_name | Aeroid/home-assistant-core | python | @property
def model_name(self) -> str:
return self.profile_device.model_name |
@property
def udn(self) -> str:
'Get the UDN of the device.'
return self.profile_device.udn | -2,713,029,806,131,443,700 | Get the UDN of the device. | tests/components/upnp/conftest.py | udn | Aeroid/home-assistant-core | python | @property
def udn(self) -> str:
return self.profile_device.udn |
@property
def device_type(self) -> str:
'Get the device type of this device.'
return self.profile_device.device_type | -5,713,704,791,920,005,000 | Get the device type of this device. | tests/components/upnp/conftest.py | device_type | Aeroid/home-assistant-core | python | @property
def device_type(self) -> str:
return self.profile_device.device_type |
async def async_get_total_bytes_received(self) -> Optional[int]:
'Get total bytes received.'
self.traffic_times_polled += 1
return self.traffic_data[BYTES_RECEIVED] | 3,561,064,990,076,080,600 | Get total bytes received. | tests/components/upnp/conftest.py | async_get_total_bytes_received | Aeroid/home-assistant-core | python | async def async_get_total_bytes_received(self) -> Optional[int]:
self.traffic_times_polled += 1
return self.traffic_data[BYTES_RECEIVED] |
async def async_get_total_bytes_sent(self) -> Optional[int]:
'Get total bytes sent.'
return self.traffic_data[BYTES_SENT] | -8,137,145,791,173,879,000 | Get total bytes sent. | tests/components/upnp/conftest.py | async_get_total_bytes_sent | Aeroid/home-assistant-core | python | async def async_get_total_bytes_sent(self) -> Optional[int]:
return self.traffic_data[BYTES_SENT] |
async def async_get_total_packets_received(self) -> Optional[int]:
'Get total packets received.'
return self.traffic_data[PACKETS_RECEIVED] | -42,403,311,728,915,400 | Get total packets received. | tests/components/upnp/conftest.py | async_get_total_packets_received | Aeroid/home-assistant-core | python | async def async_get_total_packets_received(self) -> Optional[int]:
return self.traffic_data[PACKETS_RECEIVED] |
async def async_get_total_packets_sent(self) -> Optional[int]:
'Get total packets sent.'
return self.traffic_data[PACKETS_SENT] | -4,864,117,032,536,250,000 | Get total packets sent. | tests/components/upnp/conftest.py | async_get_total_packets_sent | Aeroid/home-assistant-core | python | async def async_get_total_packets_sent(self) -> Optional[int]:
return self.traffic_data[PACKETS_SENT] |
async def async_get_external_ip_address(self, services: Optional[Sequence[str]]=None) -> Optional[str]:
'\n Get the external IP address.\n\n :param services List of service names to try to get action from, defaults to [WANIPC,WANPPP]\n '
return self.status_data[ROUTER_IP] | -1,945,486,992,808,566,300 | Get the external IP address.
:param services List of service names to try to get action from, defaults to [WANIPC,WANPPP] | tests/components/upnp/conftest.py | async_get_external_ip_address | Aeroid/home-assistant-core | python | async def async_get_external_ip_address(self, services: Optional[Sequence[str]]=None) -> Optional[str]:
'\n Get the external IP address.\n\n :param services List of service names to try to get action from, defaults to [WANIPC,WANPPP]\n '
return self.status_data[ROUTER_IP] |
async def async_get_status_info(self, services: Optional[Sequence[str]]=None) -> Optional[StatusInfo]:
'\n Get status info.\n\n :param services List of service names to try to get action from, defaults to [WANIPC,WANPPP]\n '
self.status_times_polled += 1
return StatusInfo(self.status_da... | 4,109,035,423,599,629,300 | Get status info.
:param services List of service names to try to get action from, defaults to [WANIPC,WANPPP] | tests/components/upnp/conftest.py | async_get_status_info | Aeroid/home-assistant-core | python | async def async_get_status_info(self, services: Optional[Sequence[str]]=None) -> Optional[StatusInfo]:
'\n Get status info.\n\n :param services List of service names to try to get action from, defaults to [WANIPC,WANPPP]\n '
self.status_times_polled += 1
return StatusInfo(self.status_da... |
async def mock_async_create_upnp_device(hass: HomeAssistant, location: str) -> UpnpDevice:
'Create UPnP device.'
return MockUpnpDevice(location) | 7,088,582,572,463,551,000 | Create UPnP device. | tests/components/upnp/conftest.py | mock_async_create_upnp_device | Aeroid/home-assistant-core | python | async def mock_async_create_upnp_device(hass: HomeAssistant, location: str) -> UpnpDevice:
return MockUpnpDevice(location) |
async def register_callback(hass, callback, match_dict):
'Immediately do callback.'
(await callback(TEST_DISCOVERY, ssdp.SsdpChange.ALIVE))
return MagicMock() | 4,879,946,810,967,589,000 | Immediately do callback. | tests/components/upnp/conftest.py | register_callback | Aeroid/home-assistant-core | python | async def register_callback(hass, callback, match_dict):
(await callback(TEST_DISCOVERY, ssdp.SsdpChange.ALIVE))
return MagicMock() |
async def register_callback(hass, callback, match_dict):
"Don't do callback."
return MagicMock() | 4,131,950,536,775,038,000 | Don't do callback. | tests/components/upnp/conftest.py | register_callback | Aeroid/home-assistant-core | python | async def register_callback(hass, callback, match_dict):
return MagicMock() |
def test():
'Initiate poliastro testing\n\n '
pytest.main([os.path.dirname(os.path.abspath(__file__))]) | -6,125,574,878,467,370,000 | Initiate poliastro testing | src/poliastro/testing.py | test | AunSiro/poliastro | python | def test():
'\n\n '
pytest.main([os.path.dirname(os.path.abspath(__file__))]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.