body_hash
stringlengths
64
64
body
stringlengths
23
109k
docstring
stringlengths
1
57k
path
stringlengths
4
198
name
stringlengths
1
115
repository_name
stringlengths
7
111
repository_stars
float64
0
191k
lang
stringclasses
1 value
body_without_docstring
stringlengths
14
108k
unified
stringlengths
45
133k
b6c137c7b44ca3bf231f95025762f26405e517ef1c07fd81da07be6c5edacd5e
def ToMixedPrecision(mixed_precision_type='float16', missing_op_mode=1): '\n Automatic mixed precision rewriter. Rewrite an FP32 relay graph into a version\n where as many operations as possible are in the target mixed_precision_type.\n\n Parameters\n ----------\n mixed_precision_type: str\n The...
Automatic mixed precision rewriter. Rewrite an FP32 relay graph into a version where as many operations as possible are in the target mixed_precision_type. Parameters ---------- mixed_precision_type: str The target datatype to transform operations in the graph to use. missing_op_mode: int Determines how to handle...
python/tvm/relay/transform/transform.py
ToMixedPrecision
ryanstout/tvm
2,084
python
def ToMixedPrecision(mixed_precision_type='float16', missing_op_mode=1): '\n Automatic mixed precision rewriter. Rewrite an FP32 relay graph into a version\n where as many operations as possible are in the target mixed_precision_type.\n\n Parameters\n ----------\n mixed_precision_type: str\n The...
def ToMixedPrecision(mixed_precision_type='float16', missing_op_mode=1): '\n Automatic mixed precision rewriter. Rewrite an FP32 relay graph into a version\n where as many operations as possible are in the target mixed_precision_type.\n\n Parameters\n ----------\n mixed_precision_type: str\n The...
fa650b45e359f6702edf0f56f463969041a6f2b86c9cff893ece195bf3dae3cb
def SplitArgs(max_function_args): 'Split function with huge number of arguments to smaller pieces.\n\n Returns\n -------\n ret : tvm.transform.Pass\n The registered pass for constant folding.\n ' return _ffi_api.SplitArgs(max_function_args)
Split function with huge number of arguments to smaller pieces. Returns ------- ret : tvm.transform.Pass The registered pass for constant folding.
python/tvm/relay/transform/transform.py
SplitArgs
ryanstout/tvm
2,084
python
def SplitArgs(max_function_args): 'Split function with huge number of arguments to smaller pieces.\n\n Returns\n -------\n ret : tvm.transform.Pass\n The registered pass for constant folding.\n ' return _ffi_api.SplitArgs(max_function_args)
def SplitArgs(max_function_args): 'Split function with huge number of arguments to smaller pieces.\n\n Returns\n -------\n ret : tvm.transform.Pass\n The registered pass for constant folding.\n ' return _ffi_api.SplitArgs(max_function_args)<|docstring|>Split function with huge number of argum...
4e11ba26e6553ad37db21277518d63636c70087e2468fc68b830a997e977f30b
def create_function_pass(pass_arg): 'Internal function that creates a function pass' fname = (name if name else pass_arg.__name__) info = tvm.transform.PassInfo(opt_level, fname, required) if inspect.isclass(pass_arg): return _wrap_class_function_pass(pass_arg, info) if (not isinstance(pass_...
Internal function that creates a function pass
python/tvm/relay/transform/transform.py
create_function_pass
ryanstout/tvm
2,084
python
def create_function_pass(pass_arg): fname = (name if name else pass_arg.__name__) info = tvm.transform.PassInfo(opt_level, fname, required) if inspect.isclass(pass_arg): return _wrap_class_function_pass(pass_arg, info) if (not isinstance(pass_arg, (types.FunctionType, types.LambdaType))): ...
def create_function_pass(pass_arg): fname = (name if name else pass_arg.__name__) info = tvm.transform.PassInfo(opt_level, fname, required) if inspect.isclass(pass_arg): return _wrap_class_function_pass(pass_arg, info) if (not isinstance(pass_arg, (types.FunctionType, types.LambdaType))): ...
ebf49680dc3a9339e745d2d4982fc2310655034f159e5fbb04a8d887eab792be
def makedirs(config): 'Create directories if not exist.' if (not os.path.exists(config.log_dir)): os.makedirs(config.log_dir) if (not os.path.exists(config.model_save_dir)): os.makedirs(config.model_save_dir) if (not os.path.exists(config.sample_dir)): os.makedirs(config.sample_d...
Create directories if not exist.
torchbenchmark/models/pytorch_stargan/main.py
makedirs
ramiro050/benchmark
384
python
def makedirs(config): if (not os.path.exists(config.log_dir)): os.makedirs(config.log_dir) if (not os.path.exists(config.model_save_dir)): os.makedirs(config.model_save_dir) if (not os.path.exists(config.sample_dir)): os.makedirs(config.sample_dir) if (not os.path.exists(con...
def makedirs(config): if (not os.path.exists(config.log_dir)): os.makedirs(config.log_dir) if (not os.path.exists(config.model_save_dir)): os.makedirs(config.model_save_dir) if (not os.path.exists(config.sample_dir)): os.makedirs(config.sample_dir) if (not os.path.exists(con...
08f99e65fa1fec8ca5b82e9cb35f5f02c05c87ab481de3ee039604f8bcb6796e
def __init__(self, dungeon_type, dungeon_num) -> None: 'コンストラクタ\n lv,hp,atk,skill[0]~[2],exp,moneyはリストとなっており、[0]がプレイヤーの値、[1]が敵の値\n ' self.ans = ['12345', 'abcde'] self.turn_count = [0, 0] self.hist = [[], []] self.max_ans = 16 self.length = 5 self.dungeon_type = dungeon_type ...
コンストラクタ lv,hp,atk,skill[0]~[2],exp,moneyはリストとなっており、[0]がプレイヤーの値、[1]が敵の値
game_system/systems/boss.py
__init__
TakenokoEmpire/mypj
0
python
def __init__(self, dungeon_type, dungeon_num) -> None: 'コンストラクタ\n lv,hp,atk,skill[0]~[2],exp,moneyはリストとなっており、[0]がプレイヤーの値、[1]が敵の値\n ' self.ans = ['12345', 'abcde'] self.turn_count = [0, 0] self.hist = [[], []] self.max_ans = 16 self.length = 5 self.dungeon_type = dungeon_type ...
def __init__(self, dungeon_type, dungeon_num) -> None: 'コンストラクタ\n lv,hp,atk,skill[0]~[2],exp,moneyはリストとなっており、[0]がプレイヤーの値、[1]が敵の値\n ' self.ans = ['12345', 'abcde'] self.turn_count = [0, 0] self.hist = [[], []] self.max_ans = 16 self.length = 5 self.dungeon_type = dungeon_type ...
4964595e05db089d3e229e690c6cfe79fdcc044caccce5ab0ddf10a55070b57d
def vlookup(self, sheet, index, column_order): 'excelのvlookup関数を再現。\n 「完全一致」のみ。\n ' for i in range(500): output = 0 if (str(sheet.cell(row=(i + 1), column=1).value) == index): output = sheet.cell(row=(i + 1), column=column_order).value return output retu...
excelのvlookup関数を再現。 「完全一致」のみ。
game_system/systems/boss.py
vlookup
TakenokoEmpire/mypj
0
python
def vlookup(self, sheet, index, column_order): 'excelのvlookup関数を再現。\n 「完全一致」のみ。\n ' for i in range(500): output = 0 if (str(sheet.cell(row=(i + 1), column=1).value) == index): output = sheet.cell(row=(i + 1), column=column_order).value return output retu...
def vlookup(self, sheet, index, column_order): 'excelのvlookup関数を再現。\n 「完全一致」のみ。\n ' for i in range(500): output = 0 if (str(sheet.cell(row=(i + 1), column=1).value) == index): output = sheet.cell(row=(i + 1), column=column_order).value return output retu...
eaef01d308fa89381d7f8c7b24af79dbb789c025d2c04e502c2fea5408d4d9ce
def x_index(self, sheet, index): 'excelのindex関数もどきを再現\n 該当する文字がある行番号を返す(先頭列に限る)' for i in range(500): output = 0 if (str(sheet.cell(row=(i + 1), column=1).value) == index): return (i + 1) return 'False'
excelのindex関数もどきを再現 該当する文字がある行番号を返す(先頭列に限る)
game_system/systems/boss.py
x_index
TakenokoEmpire/mypj
0
python
def x_index(self, sheet, index): 'excelのindex関数もどきを再現\n 該当する文字がある行番号を返す(先頭列に限る)' for i in range(500): output = 0 if (str(sheet.cell(row=(i + 1), column=1).value) == index): return (i + 1) return 'False'
def x_index(self, sheet, index): 'excelのindex関数もどきを再現\n 該当する文字がある行番号を返す(先頭列に限る)' for i in range(500): output = 0 if (str(sheet.cell(row=(i + 1), column=1).value) == index): return (i + 1) return 'False'<|docstring|>excelのindex関数もどきを再現 該当する文字がある行番号を返す(先頭列に限る)<|endoftext|>
10f946eda5d7eb2677fa236b44f9ffbcbb248a51f2d78dd4a47f9f9e326025e3
def after_battle(self): '戦闘後の処理\n ステータスの更新\n 経験値の更新\n 金の更新\n アイテムの更新\n 以上の情報をエクセルファイルに更新・保存\n ' new_lv = self.lv[0] new_hp = self.vlookup(self.book['level_table'], str(new_lv), 3) new_atk = self.vlookup(self.book['level_table'], str(new_lv), 4) self.mysheet....
戦闘後の処理 ステータスの更新 経験値の更新 金の更新 アイテムの更新 以上の情報をエクセルファイルに更新・保存
game_system/systems/boss.py
after_battle
TakenokoEmpire/mypj
0
python
def after_battle(self): '戦闘後の処理\n ステータスの更新\n 経験値の更新\n 金の更新\n アイテムの更新\n 以上の情報をエクセルファイルに更新・保存\n ' new_lv = self.lv[0] new_hp = self.vlookup(self.book['level_table'], str(new_lv), 3) new_atk = self.vlookup(self.book['level_table'], str(new_lv), 4) self.mysheet....
def after_battle(self): '戦闘後の処理\n ステータスの更新\n 経験値の更新\n 金の更新\n アイテムの更新\n 以上の情報をエクセルファイルに更新・保存\n ' new_lv = self.lv[0] new_hp = self.vlookup(self.book['level_table'], str(new_lv), 3) new_atk = self.vlookup(self.book['level_table'], str(new_lv), 4) self.mysheet....
02df5a0b305666f620331c2ada8ef5f48f683419355754f80d540f56280ef4ba
@pytest.mark.settings(redirect_host='localhost:8081', redirect_behavior='spa', post_login_view='/login-redirect') def test_spa_get(app, client): "\n Test 'single-page-application' style redirects\n This uses json only.\n " with capture_flashes() as flashes: with capture_passwordless_login_reque...
Test 'single-page-application' style redirects This uses json only.
tests/test_passwordless.py
test_spa_get
biofool/flask-security
317
python
@pytest.mark.settings(redirect_host='localhost:8081', redirect_behavior='spa', post_login_view='/login-redirect') def test_spa_get(app, client): "\n Test 'single-page-application' style redirects\n This uses json only.\n " with capture_flashes() as flashes: with capture_passwordless_login_reque...
@pytest.mark.settings(redirect_host='localhost:8081', redirect_behavior='spa', post_login_view='/login-redirect') def test_spa_get(app, client): "\n Test 'single-page-application' style redirects\n This uses json only.\n " with capture_flashes() as flashes: with capture_passwordless_login_reque...
910dec77783c9a862ff163c8359ba6a090615f2b8be22d50ab6bd4c67aaff1f4
@pytest.mark.settings(login_within='1 milliseconds', redirect_host='localhost:8081', redirect_behavior='spa', login_error_view='/login-error') def test_spa_get_bad_token(app, client, get_message): 'Test expired and invalid token' with capture_flashes() as flashes: with capture_passwordless_login_request...
Test expired and invalid token
tests/test_passwordless.py
test_spa_get_bad_token
biofool/flask-security
317
python
@pytest.mark.settings(login_within='1 milliseconds', redirect_host='localhost:8081', redirect_behavior='spa', login_error_view='/login-error') def test_spa_get_bad_token(app, client, get_message): with capture_flashes() as flashes: with capture_passwordless_login_requests() as requests: res...
@pytest.mark.settings(login_within='1 milliseconds', redirect_host='localhost:8081', redirect_behavior='spa', login_error_view='/login-error') def test_spa_get_bad_token(app, client, get_message): with capture_flashes() as flashes: with capture_passwordless_login_requests() as requests: res...
31569f5b4c66b2d86fd2ba6aec365648f73ea086b201048eecca63267af95f54
def test_pull_as_echo_argument(call_centos7, capstrip): '--pull should only be interpreted as an dog argument if it comes before the first argument' call_centos7('echo', '-n', '--pull') captured = capstrip.get() assert (captured == ('--pull', ''))
--pull should only be interpreted as an dog argument if it comes before the first argument
tests/test_dog_arguments.py
test_pull_as_echo_argument
marqvart/dog
2
python
def test_pull_as_echo_argument(call_centos7, capstrip): call_centos7('echo', '-n', '--pull') captured = capstrip.get() assert (captured == ('--pull', ))
def test_pull_as_echo_argument(call_centos7, capstrip): call_centos7('echo', '-n', '--pull') captured = capstrip.get() assert (captured == ('--pull', ))<|docstring|>--pull should only be interpreted as an dog argument if it comes before the first argument<|endoftext|>
5c5fa394fed362d20e559126fc3146e1e74bd91b76b1bcdbdf22df3d946487b8
def test_version(call_dog, capfd): '--version should just return the current dog version' call_dog('--version') captured = capfd.readouterr() assert re.match('dog version [0-9]+', captured.out)
--version should just return the current dog version
tests/test_dog_arguments.py
test_version
marqvart/dog
2
python
def test_version(call_dog, capfd): call_dog('--version') captured = capfd.readouterr() assert re.match('dog version [0-9]+', captured.out)
def test_version(call_dog, capfd): call_dog('--version') captured = capfd.readouterr() assert re.match('dog version [0-9]+', captured.out)<|docstring|>--version should just return the current dog version<|endoftext|>
50da369323770c478dc3039a02b18306b3dc3fe6d6b58d1bcdc521b84b74b7b5
def test_verbose(call_centos7, capfd): '--verbose should report the actual setup' call_centos7('--verbose', 'id') captured = capfd.readouterr() assert ('Dog Config' in captured.out) assert ("'verbose': True" in captured.out)
--verbose should report the actual setup
tests/test_dog_arguments.py
test_verbose
marqvart/dog
2
python
def test_verbose(call_centos7, capfd): call_centos7('--verbose', 'id') captured = capfd.readouterr() assert ('Dog Config' in captured.out) assert ("'verbose': True" in captured.out)
def test_verbose(call_centos7, capfd): call_centos7('--verbose', 'id') captured = capfd.readouterr() assert ('Dog Config' in captured.out) assert ("'verbose': True" in captured.out)<|docstring|>--verbose should report the actual setup<|endoftext|>
8ebc17e622c7753cb3100a78c58cf6da7e7803c0201b3a9caf75f14d0b5a8d2d
def test_stdin_testing_works(call_shell, capstrip): 'Just verifying that my stdin testing works before testing it with dog.' call_shell('echo hello world | cat -') captured = capstrip.get() assert (captured == ('hello world', ''))
Just verifying that my stdin testing works before testing it with dog.
tests/test_dog_arguments.py
test_stdin_testing_works
marqvart/dog
2
python
def test_stdin_testing_works(call_shell, capstrip): call_shell('echo hello world | cat -') captured = capstrip.get() assert (captured == ('hello world', ))
def test_stdin_testing_works(call_shell, capstrip): call_shell('echo hello world | cat -') captured = capstrip.get() assert (captured == ('hello world', ))<|docstring|>Just verifying that my stdin testing works before testing it with dog.<|endoftext|>
f9bd7a233fe5b61f96c2a9c8da605bd7fb48d5274b48c976d16dcbbf1c8e507e
def test_stdin(call_shell, capstrip, dog_env): 'stdin should be available from inside dog.' call_shell(f'echo hello world | {dog_env} cat') captured = capstrip.get() assert (captured == ('hello world', ''))
stdin should be available from inside dog.
tests/test_dog_arguments.py
test_stdin
marqvart/dog
2
python
def test_stdin(call_shell, capstrip, dog_env): call_shell(f'echo hello world | {dog_env} cat') captured = capstrip.get() assert (captured == ('hello world', ))
def test_stdin(call_shell, capstrip, dog_env): call_shell(f'echo hello world | {dog_env} cat') captured = capstrip.get() assert (captured == ('hello world', ))<|docstring|>stdin should be available from inside dog.<|endoftext|>
37e105858a366815c67e468f69766734e99bc0d9615b588931a29dbb2c6689cd
def test_auto_mount_works(call_centos7, capstrip): 'auto-mount is on by default, and should therefore show the files in the current directory.' call_centos7('ls') captured = capstrip.get() assert (captured == ('dog.config', ''))
auto-mount is on by default, and should therefore show the files in the current directory.
tests/test_dog_arguments.py
test_auto_mount_works
marqvart/dog
2
python
def test_auto_mount_works(call_centos7, capstrip): call_centos7('ls') captured = capstrip.get() assert (captured == ('dog.config', ))
def test_auto_mount_works(call_centos7, capstrip): call_centos7('ls') captured = capstrip.get() assert (captured == ('dog.config', ))<|docstring|>auto-mount is on by default, and should therefore show the files in the current directory.<|endoftext|>
5345e776e6fc9dc2efa17385b3cc71bf18dc9ec042c445c47d6dad43e2123040
def test_disabled_auto_mount(call_centos7, capstrip, tmp_path): 'disable auto-mount and make sure that we do not see the files in the current directory.' append_to_dog_config(tmp_path, ['auto-mount=False']) call_centos7('ls') captured = capstrip.get() assert (captured == ('', ''))
disable auto-mount and make sure that we do not see the files in the current directory.
tests/test_dog_arguments.py
test_disabled_auto_mount
marqvart/dog
2
python
def test_disabled_auto_mount(call_centos7, capstrip, tmp_path): append_to_dog_config(tmp_path, ['auto-mount=False']) call_centos7('ls') captured = capstrip.get() assert (captured == (, ))
def test_disabled_auto_mount(call_centos7, capstrip, tmp_path): append_to_dog_config(tmp_path, ['auto-mount=False']) call_centos7('ls') captured = capstrip.get() assert (captured == (, ))<|docstring|>disable auto-mount and make sure that we do not see the files in the current directory.<|endoftext|...
04b1c42c7ace50cea7999a366252bc4d7a735d14f0b6e5cc0cac882b613fce3c
def test_volumes(call_centos7, capstrip, tmp_path, system_temp_dir): 'Try adding the "system temp dir" as a volume in the dog.config.' append_to_dog_config(tmp_path, ['[volumes]', f'/dog_test_of_system_temp={system_temp_dir}']) call_centos7('mountpoint', '/dog_test_of_system_temp') captured = capstrip.g...
Try adding the "system temp dir" as a volume in the dog.config.
tests/test_dog_arguments.py
test_volumes
marqvart/dog
2
python
def test_volumes(call_centos7, capstrip, tmp_path, system_temp_dir): append_to_dog_config(tmp_path, ['[volumes]', f'/dog_test_of_system_temp={system_temp_dir}']) call_centos7('mountpoint', '/dog_test_of_system_temp') captured = capstrip.get() assert (captured == ('/dog_test_of_system_temp is a moun...
def test_volumes(call_centos7, capstrip, tmp_path, system_temp_dir): append_to_dog_config(tmp_path, ['[volumes]', f'/dog_test_of_system_temp={system_temp_dir}']) call_centos7('mountpoint', '/dog_test_of_system_temp') captured = capstrip.get() assert (captured == ('/dog_test_of_system_temp is a moun...
4cf38f5edf20f59a5fd5f5e5483dc9a490af04eab3d19b3e44128ba59977fff6
def test_dog_config_not_found(my_dog, system_temp_dir, capfd): 'If no dog.config is found, report an error.\n\n We run this test in the system_temp_dir to be more sure that no-one has a dog.config file somewhere in the parent directories.' for parent in Path(system_temp_dir).parents: assert (not (par...
If no dog.config is found, report an error. We run this test in the system_temp_dir to be more sure that no-one has a dog.config file somewhere in the parent directories.
tests/test_dog_arguments.py
test_dog_config_not_found
marqvart/dog
2
python
def test_dog_config_not_found(my_dog, system_temp_dir, capfd): 'If no dog.config is found, report an error.\n\n We run this test in the system_temp_dir to be more sure that no-one has a dog.config file somewhere in the parent directories.' for parent in Path(system_temp_dir).parents: assert (not (par...
def test_dog_config_not_found(my_dog, system_temp_dir, capfd): 'If no dog.config is found, report an error.\n\n We run this test in the system_temp_dir to be more sure that no-one has a dog.config file somewhere in the parent directories.' for parent in Path(system_temp_dir).parents: assert (not (par...
15d1da9abf72d8606165eeae38b732159a7f531ed84515c004f5ff0fd7a98241
@pytest.mark.skipif(('TEAMCITY_PROJECT_NAME' not in os.environ), reason='This test only works inside Demant (sorry!)') def test_pull_latest_demant_debian(basic_dog_config, call_dog, tmp_path, capstrip): 'This test only exists to pull the latest image before the next test - this is to make sure that the test does n...
This test only exists to pull the latest image before the next test - this is to make sure that the test does not fail due to lots of "pullling layer ....blah.balh... output.
tests/test_dog_arguments.py
test_pull_latest_demant_debian
marqvart/dog
2
python
@pytest.mark.skipif(('TEAMCITY_PROJECT_NAME' not in os.environ), reason='This test only works inside Demant (sorry!)') def test_pull_latest_demant_debian(basic_dog_config, call_dog, tmp_path, capstrip): 'This test only exists to pull the latest image before the next test - this is to make sure that the test does n...
@pytest.mark.skipif(('TEAMCITY_PROJECT_NAME' not in os.environ), reason='This test only works inside Demant (sorry!)') def test_pull_latest_demant_debian(basic_dog_config, call_dog, tmp_path, capstrip): 'This test only exists to pull the latest image before the next test - this is to make sure that the test does n...
df79446cbcd1a5ee485195b8e5db7bc8af18c55ad34d461d6b6bde380c560f9b
def run_experiment(): '\n Experiment I: ELIZA --> https://en.wikipedia.org/wiki/ELIZA\n ' eliza_context = 'ELIZA is an early natural language processing computer program created from 1964 to 1966 at the MIT Artificial Intelligence Laboratory by Joseph Weizenbaum. Created to demonstra...
Experiment I: ELIZA --> https://en.wikipedia.org/wiki/ELIZA
experiments/eliza.py
run_experiment
kjahan/bert_squad_demo
0
python
def run_experiment(): '\n \n ' eliza_context = 'ELIZA is an early natural language processing computer program created from 1964 to 1966 at the MIT Artificial Intelligence Laboratory by Joseph Weizenbaum. Created to demonstrate the superficiality of communication be...
def run_experiment(): '\n \n ' eliza_context = 'ELIZA is an early natural language processing computer program created from 1964 to 1966 at the MIT Artificial Intelligence Laboratory by Joseph Weizenbaum. Created to demonstrate the superficiality of communication be...
16cb26783e999b62506d915f3f157f11c651ecb4ec9a6513dc6b0036fa025ee5
def get_manager(): '\n gets the cli core manager instance.\n\n :rtype: CLICoreManager\n ' return CLICoreManager()
gets the cli core manager instance. :rtype: CLICoreManager
src/pyrin/cli/core/services.py
get_manager
wilsonGmn/pyrin
0
python
def get_manager(): '\n gets the cli core manager instance.\n\n :rtype: CLICoreManager\n ' return CLICoreManager()
def get_manager(): '\n gets the cli core manager instance.\n\n :rtype: CLICoreManager\n ' return CLICoreManager()<|docstring|>gets the cli core manager instance. :rtype: CLICoreManager<|endoftext|>
e688b8d6d1e393938c322ce5b0cf3e7a18ba727971ee97a0ecfa8d0132523ebb
def create(handler_name): '\n creates the required templates using relevant handlers.\n\n :param str handler_name: handler name to be used.\n\n :raises CLICoreTemplateHandlerNotFoundError: cli core template handler not found error.\n ' return get_manager().create(handler_name)
creates the required templates using relevant handlers. :param str handler_name: handler name to be used. :raises CLICoreTemplateHandlerNotFoundError: cli core template handler not found error.
src/pyrin/cli/core/services.py
create
wilsonGmn/pyrin
0
python
def create(handler_name): '\n creates the required templates using relevant handlers.\n\n :param str handler_name: handler name to be used.\n\n :raises CLICoreTemplateHandlerNotFoundError: cli core template handler not found error.\n ' return get_manager().create(handler_name)
def create(handler_name): '\n creates the required templates using relevant handlers.\n\n :param str handler_name: handler name to be used.\n\n :raises CLICoreTemplateHandlerNotFoundError: cli core template handler not found error.\n ' return get_manager().create(handler_name)<|docstring|>creates th...
1eb8066eb5fffc7c9234c3c3e905c29cd2077c0ba73be18f645322c49c26f969
def show_result(self, img, result, thickness=1, font_scale=0.5, show=False, out_file=None, wait_time=0, backend='cv2', **kwargs): "Visualize tracking results.\n\n Args:\n img (str | ndarray): Filename of loaded image.\n result (dict): Tracking result.\n The value of key '...
Visualize tracking results. Args: img (str | ndarray): Filename of loaded image. result (dict): Tracking result. The value of key 'track_results' is ndarray with shape (n, 6) in [id, tl_x, tl_y, br_x, br_y, score] format. The value of key 'bbox_results' is ndarray with shape (n, 5) ...
tutorials/qdtrack/qdtrack.py
show_result
namtranase/ByteTrack
1,039
python
def show_result(self, img, result, thickness=1, font_scale=0.5, show=False, out_file=None, wait_time=0, backend='cv2', **kwargs): "Visualize tracking results.\n\n Args:\n img (str | ndarray): Filename of loaded image.\n result (dict): Tracking result.\n The value of key '...
def show_result(self, img, result, thickness=1, font_scale=0.5, show=False, out_file=None, wait_time=0, backend='cv2', **kwargs): "Visualize tracking results.\n\n Args:\n img (str | ndarray): Filename of loaded image.\n result (dict): Tracking result.\n The value of key '...
67a4dcbbee31589b52c2d091761c6bc2056c27b38fde80928cbfa34600131451
def __init__(self, predictions, labels, desc, probabilities=None): 'Initialize attributes: predictions-vector of predicted values for Y, labels-vector of labels for Y' 'probabilities-optional, probability that Y is equal to True' self.probabilities = probabilities self.performance_df = pd.concat([pd.Dat...
Initialize attributes: predictions-vector of predicted values for Y, labels-vector of labels for Y
data/my_measures.py
__init__
3milychu/notesonperspective_journal
0
python
def __init__(self, predictions, labels, desc, probabilities=None): 'probabilities-optional, probability that Y is equal to True' self.probabilities = probabilities self.performance_df = pd.concat([pd.DataFrame(predictions), pd.DataFrame(labels)], axis=1) self.performance_df.columns = ['preds', 'lab...
def __init__(self, predictions, labels, desc, probabilities=None): 'probabilities-optional, probability that Y is equal to True' self.probabilities = probabilities self.performance_df = pd.concat([pd.DataFrame(predictions), pd.DataFrame(labels)], axis=1) self.performance_df.columns = ['preds', 'lab...
0023475cc3c5d71dd39216eacbc075e8d7d1d5616c8073ada7a79394931900bf
def compute_measures(self): 'Compute performance measures defined by Flach p. 57' self.performance_measures['Pos'] = self.performance_df['labls'].sum() self.performance_measures['Neg'] = (self.performance_df.shape[0] - self.performance_df['labls'].sum()) self.performance_measures['TP'] = ((self.performa...
Compute performance measures defined by Flach p. 57
data/my_measures.py
compute_measures
3milychu/notesonperspective_journal
0
python
def compute_measures(self): self.performance_measures['Pos'] = self.performance_df['labls'].sum() self.performance_measures['Neg'] = (self.performance_df.shape[0] - self.performance_df['labls'].sum()) self.performance_measures['TP'] = ((self.performance_df['preds'] == True) & (self.performance_df['labl...
def compute_measures(self): self.performance_measures['Pos'] = self.performance_df['labls'].sum() self.performance_measures['Neg'] = (self.performance_df.shape[0] - self.performance_df['labls'].sum()) self.performance_measures['TP'] = ((self.performance_df['preds'] == True) & (self.performance_df['labl...
09190562f9b48657bdf5b509d6d05ddfd660e80fe7ea6e527017680496bd966a
def img_indices(self): 'Get the indices of true and false positives to be able to locate the corresponding images in a list of image names' self.performance_df['tp_ind'] = ((self.performance_df['preds'] == True) & (self.performance_df['labls'] == True)) self.performance_df['fp_ind'] = ((self.performance_df[...
Get the indices of true and false positives to be able to locate the corresponding images in a list of image names
data/my_measures.py
img_indices
3milychu/notesonperspective_journal
0
python
def img_indices(self): self.performance_df['tp_ind'] = ((self.performance_df['preds'] == True) & (self.performance_df['labls'] == True)) self.performance_df['fp_ind'] = ((self.performance_df['preds'] == True) & (self.performance_df['labls'] == False)) self.performance_df['fn_ind'] = ((self.performance_...
def img_indices(self): self.performance_df['tp_ind'] = ((self.performance_df['preds'] == True) & (self.performance_df['labls'] == True)) self.performance_df['fp_ind'] = ((self.performance_df['preds'] == True) & (self.performance_df['labls'] == False)) self.performance_df['fn_ind'] = ((self.performance_...
4693f5b4fbf7f5501594a39e5788857cc52e4da4fdc7bc94c7be0a7966e66901
def wrapper_function_header(fn: FuncIR, names: NameGenerator) -> str: 'Return header of a vectorcall wrapper function.\n\n See comment above for a summary of the arguments.\n ' return 'PyObject *{prefix}{name}(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames)'.format(prefix=PREFIX, n...
Return header of a vectorcall wrapper function. See comment above for a summary of the arguments.
mypyc/codegen/emitwrapper.py
wrapper_function_header
srittau/mypy
12,496
python
def wrapper_function_header(fn: FuncIR, names: NameGenerator) -> str: 'Return header of a vectorcall wrapper function.\n\n See comment above for a summary of the arguments.\n ' return 'PyObject *{prefix}{name}(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames)'.format(prefix=PREFIX, n...
def wrapper_function_header(fn: FuncIR, names: NameGenerator) -> str: 'Return header of a vectorcall wrapper function.\n\n See comment above for a summary of the arguments.\n ' return 'PyObject *{prefix}{name}(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames)'.format(prefix=PREFIX, n...
002c90ffedba1253008b03c1147b3203e4da74b20cd913fedb4a45a04520793e
def make_arg_groups(args: List[RuntimeArg]) -> Dict[(ArgKind, List[RuntimeArg])]: 'Group arguments by kind.' return {k: [arg for arg in args if (arg.kind == k)] for k in ArgKind}
Group arguments by kind.
mypyc/codegen/emitwrapper.py
make_arg_groups
srittau/mypy
12,496
python
def make_arg_groups(args: List[RuntimeArg]) -> Dict[(ArgKind, List[RuntimeArg])]: return {k: [arg for arg in args if (arg.kind == k)] for k in ArgKind}
def make_arg_groups(args: List[RuntimeArg]) -> Dict[(ArgKind, List[RuntimeArg])]: return {k: [arg for arg in args if (arg.kind == k)] for k in ArgKind}<|docstring|>Group arguments by kind.<|endoftext|>
95c823f05edff54e564a7b9528804dce7f098b45499f123c114a08fb19b42069
def reorder_arg_groups(groups: Dict[(ArgKind, List[RuntimeArg])]) -> List[RuntimeArg]: 'Reorder argument groups to match their order in a format string.' return (((groups[ARG_POS] + groups[ARG_OPT]) + groups[ARG_NAMED_OPT]) + groups[ARG_NAMED])
Reorder argument groups to match their order in a format string.
mypyc/codegen/emitwrapper.py
reorder_arg_groups
srittau/mypy
12,496
python
def reorder_arg_groups(groups: Dict[(ArgKind, List[RuntimeArg])]) -> List[RuntimeArg]: return (((groups[ARG_POS] + groups[ARG_OPT]) + groups[ARG_NAMED_OPT]) + groups[ARG_NAMED])
def reorder_arg_groups(groups: Dict[(ArgKind, List[RuntimeArg])]) -> List[RuntimeArg]: return (((groups[ARG_POS] + groups[ARG_OPT]) + groups[ARG_NAMED_OPT]) + groups[ARG_NAMED])<|docstring|>Reorder argument groups to match their order in a format string.<|endoftext|>
07c5b1f79a41e3444f968c4468eea1df8459b199d97e176d37239491368f6f63
def make_format_string(func_name: Optional[str], groups: Dict[(ArgKind, List[RuntimeArg])]) -> str: "Return a format string that specifies the accepted arguments.\n\n The format string is an extended subset of what is supported by\n PyArg_ParseTupleAndKeywords(). Only the type 'O' is used, and we\n also su...
Return a format string that specifies the accepted arguments. The format string is an extended subset of what is supported by PyArg_ParseTupleAndKeywords(). Only the type 'O' is used, and we also support some extensions: - Required keyword-only arguments are introduced after '@' - If the function receives *args or **...
mypyc/codegen/emitwrapper.py
make_format_string
srittau/mypy
12,496
python
def make_format_string(func_name: Optional[str], groups: Dict[(ArgKind, List[RuntimeArg])]) -> str: "Return a format string that specifies the accepted arguments.\n\n The format string is an extended subset of what is supported by\n PyArg_ParseTupleAndKeywords(). Only the type 'O' is used, and we\n also su...
def make_format_string(func_name: Optional[str], groups: Dict[(ArgKind, List[RuntimeArg])]) -> str: "Return a format string that specifies the accepted arguments.\n\n The format string is an extended subset of what is supported by\n PyArg_ParseTupleAndKeywords(). Only the type 'O' is used, and we\n also su...
cd82012252399b4a2448d939efb402929896e3729b13c4f2023d0c0835c7078c
def generate_wrapper_function(fn: FuncIR, emitter: Emitter, source_path: str, module_name: str) -> None: 'Generate a CPython-compatible vectorcall wrapper for a native function.\n\n In particular, this handles unboxing the arguments, calling the native function, and\n then boxing the return value.\n ' ...
Generate a CPython-compatible vectorcall wrapper for a native function. In particular, this handles unboxing the arguments, calling the native function, and then boxing the return value.
mypyc/codegen/emitwrapper.py
generate_wrapper_function
srittau/mypy
12,496
python
def generate_wrapper_function(fn: FuncIR, emitter: Emitter, source_path: str, module_name: str) -> None: 'Generate a CPython-compatible vectorcall wrapper for a native function.\n\n In particular, this handles unboxing the arguments, calling the native function, and\n then boxing the return value.\n ' ...
def generate_wrapper_function(fn: FuncIR, emitter: Emitter, source_path: str, module_name: str) -> None: 'Generate a CPython-compatible vectorcall wrapper for a native function.\n\n In particular, this handles unboxing the arguments, calling the native function, and\n then boxing the return value.\n ' ...
b67bdc7643fa029bb4766f8d0fb7d858a36b93855cb4eeef18551ed4f9cec07c
def generate_legacy_wrapper_function(fn: FuncIR, emitter: Emitter, source_path: str, module_name: str) -> None: 'Generates a CPython-compatible legacy wrapper for a native function.\n\n In particular, this handles unboxing the arguments, calling the native function, and\n then boxing the return value.\n ' ...
Generates a CPython-compatible legacy wrapper for a native function. In particular, this handles unboxing the arguments, calling the native function, and then boxing the return value.
mypyc/codegen/emitwrapper.py
generate_legacy_wrapper_function
srittau/mypy
12,496
python
def generate_legacy_wrapper_function(fn: FuncIR, emitter: Emitter, source_path: str, module_name: str) -> None: 'Generates a CPython-compatible legacy wrapper for a native function.\n\n In particular, this handles unboxing the arguments, calling the native function, and\n then boxing the return value.\n ' ...
def generate_legacy_wrapper_function(fn: FuncIR, emitter: Emitter, source_path: str, module_name: str) -> None: 'Generates a CPython-compatible legacy wrapper for a native function.\n\n In particular, this handles unboxing the arguments, calling the native function, and\n then boxing the return value.\n ' ...
2d895a160411363017b72f33097e393d7de985f3f33942ad3aa696428db2e92b
def generate_dunder_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __dunder__ methods to be able to fit into the mapping\n protocol slot. This specifically means that the arguments are taken as *PyObjects and returned\n as *PyObjects.\n ' gen = WrapperGenerat...
Generates a wrapper for native __dunder__ methods to be able to fit into the mapping protocol slot. This specifically means that the arguments are taken as *PyObjects and returned as *PyObjects.
mypyc/codegen/emitwrapper.py
generate_dunder_wrapper
srittau/mypy
12,496
python
def generate_dunder_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __dunder__ methods to be able to fit into the mapping\n protocol slot. This specifically means that the arguments are taken as *PyObjects and returned\n as *PyObjects.\n ' gen = WrapperGenerat...
def generate_dunder_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __dunder__ methods to be able to fit into the mapping\n protocol slot. This specifically means that the arguments are taken as *PyObjects and returned\n as *PyObjects.\n ' gen = WrapperGenerat...
27612451da5533d7f9b93e8db6f3bd695eeb21bc846b9d2a680b0e28464854b6
def generate_bin_op_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for a native binary dunder method.\n\n The same wrapper that handles the forward method (e.g. __add__) also handles\n the corresponding reverse method (e.g. __radd__), if defined.\n\n Both arguments and the ...
Generates a wrapper for a native binary dunder method. The same wrapper that handles the forward method (e.g. __add__) also handles the corresponding reverse method (e.g. __radd__), if defined. Both arguments and the return value are PyObject *.
mypyc/codegen/emitwrapper.py
generate_bin_op_wrapper
srittau/mypy
12,496
python
def generate_bin_op_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for a native binary dunder method.\n\n The same wrapper that handles the forward method (e.g. __add__) also handles\n the corresponding reverse method (e.g. __radd__), if defined.\n\n Both arguments and the ...
def generate_bin_op_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for a native binary dunder method.\n\n The same wrapper that handles the forward method (e.g. __add__) also handles\n the corresponding reverse method (e.g. __radd__), if defined.\n\n Both arguments and the ...
c4e83fc8934d9caef85a4db9cc0a2a7495ffe9c4dab71e9841651fd0e9f3bbdf
def generate_richcompare_wrapper(cl: ClassIR, emitter: Emitter) -> Optional[str]: 'Generates a wrapper for richcompare dunder methods.' matches = sorted([name for name in RICHCOMPARE_OPS if cl.has_method(name)]) if (not matches): return None name = '{}_RichCompare_{}'.format(DUNDER_PREFIX, cl.na...
Generates a wrapper for richcompare dunder methods.
mypyc/codegen/emitwrapper.py
generate_richcompare_wrapper
srittau/mypy
12,496
python
def generate_richcompare_wrapper(cl: ClassIR, emitter: Emitter) -> Optional[str]: matches = sorted([name for name in RICHCOMPARE_OPS if cl.has_method(name)]) if (not matches): return None name = '{}_RichCompare_{}'.format(DUNDER_PREFIX, cl.name_prefix(emitter.names)) emitter.emit_line('stat...
def generate_richcompare_wrapper(cl: ClassIR, emitter: Emitter) -> Optional[str]: matches = sorted([name for name in RICHCOMPARE_OPS if cl.has_method(name)]) if (not matches): return None name = '{}_RichCompare_{}'.format(DUNDER_PREFIX, cl.name_prefix(emitter.names)) emitter.emit_line('stat...
00169aa8929fa7b1b49108a51025bc20a3d31869435312a5dcecf63dce2fe479
def generate_get_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __get__ methods.' name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static PyObject *{name}(PyObject *self, PyObject *instance, PyObject *owner) {{'.form...
Generates a wrapper for native __get__ methods.
mypyc/codegen/emitwrapper.py
generate_get_wrapper
srittau/mypy
12,496
python
def generate_get_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static PyObject *{name}(PyObject *self, PyObject *instance, PyObject *owner) {{'.format(name=name)) emitter.emit_line('instance = ...
def generate_get_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static PyObject *{name}(PyObject *self, PyObject *instance, PyObject *owner) {{'.format(name=name)) emitter.emit_line('instance = ...
34f31bd1e1efa052359411c64fa33b2c5cdc2d480d1a9072a64791e237ccdd10
def generate_hash_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __hash__ methods.' name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static Py_ssize_t {name}(PyObject *self) {{'.format(name=name)) emitter.emit_li...
Generates a wrapper for native __hash__ methods.
mypyc/codegen/emitwrapper.py
generate_hash_wrapper
srittau/mypy
12,496
python
def generate_hash_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static Py_ssize_t {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}retval = {}{}{}(self);'.format(emitter.ctype...
def generate_hash_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static Py_ssize_t {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}retval = {}{}{}(self);'.format(emitter.ctype...
a2bde8f3fb42a1f6735e7322d4675b2f588d06103f8b00ef8981f3f397e0ef27
def generate_len_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __len__ methods.' name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static Py_ssize_t {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line...
Generates a wrapper for native __len__ methods.
mypyc/codegen/emitwrapper.py
generate_len_wrapper
srittau/mypy
12,496
python
def generate_len_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static Py_ssize_t {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}retval = {}{}{}(self);'.format(emitter.ctype_...
def generate_len_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static Py_ssize_t {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}retval = {}{}{}(self);'.format(emitter.ctype_...
4d7a4a56f7379787520d545943a29af58c77b3b53a2c1aed896dde80a90bf4ad
def generate_bool_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __bool__ methods.' name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static int {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}v...
Generates a wrapper for native __bool__ methods.
mypyc/codegen/emitwrapper.py
generate_bool_wrapper
srittau/mypy
12,496
python
def generate_bool_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static int {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}val = {}{}(self);'.format(emitter.ctype_spaced(fn.r...
def generate_bool_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static int {name}(PyObject *self) {{'.format(name=name)) emitter.emit_line('{}val = {}{}(self);'.format(emitter.ctype_spaced(fn.r...
08c5c468c6eac458ee584587eff3aa943c12dad24cceaa6477aa2d51dca3f0b9
def generate_del_item_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __delitem__.\n\n This is only called from a combined __delitem__/__setitem__ wrapper.\n ' name = '{}{}{}'.format(DUNDER_PREFIX, '__delitem__', cl.name_prefix(emitter.names)) input_args = ',...
Generates a wrapper for native __delitem__. This is only called from a combined __delitem__/__setitem__ wrapper.
mypyc/codegen/emitwrapper.py
generate_del_item_wrapper
srittau/mypy
12,496
python
def generate_del_item_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __delitem__.\n\n This is only called from a combined __delitem__/__setitem__ wrapper.\n ' name = '{}{}{}'.format(DUNDER_PREFIX, '__delitem__', cl.name_prefix(emitter.names)) input_args = ',...
def generate_del_item_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __delitem__.\n\n This is only called from a combined __delitem__/__setitem__ wrapper.\n ' name = '{}{}{}'.format(DUNDER_PREFIX, '__delitem__', cl.name_prefix(emitter.names)) input_args = ',...
25cc8c58e729867b447717f8dd7d305674974f8fbff9bcdf83dc539e346a5a0c
def generate_set_del_item_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __setitem__ method (also works for __delitem__).\n\n This is used with the mapping protocol slot. Arguments are taken as *PyObjects and we\n return a negative C int on error.\n\n Create a se...
Generates a wrapper for native __setitem__ method (also works for __delitem__). This is used with the mapping protocol slot. Arguments are taken as *PyObjects and we return a negative C int on error. Create a separate wrapper function for __delitem__ as needed and have the __setitem__ wrapper call it if the value is ...
mypyc/codegen/emitwrapper.py
generate_set_del_item_wrapper
srittau/mypy
12,496
python
def generate_set_del_item_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __setitem__ method (also works for __delitem__).\n\n This is used with the mapping protocol slot. Arguments are taken as *PyObjects and we\n return a negative C int on error.\n\n Create a se...
def generate_set_del_item_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for native __setitem__ method (also works for __delitem__).\n\n This is used with the mapping protocol slot. Arguments are taken as *PyObjects and we\n return a negative C int on error.\n\n Create a se...
4a1de36dffe13bcb4c49106970fc582b825c1694b415891651c42bbecdee9732
def generate_contains_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: 'Generates a wrapper for a native __contains__ method.' name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static int {name}(PyObject *self, PyObject *obj_item) {{'.format(name=name...
Generates a wrapper for a native __contains__ method.
mypyc/codegen/emitwrapper.py
generate_contains_wrapper
srittau/mypy
12,496
python
def generate_contains_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static int {name}(PyObject *self, PyObject *obj_item) {{'.format(name=name)) generate_arg_check('item', fn.args[1].type, emit...
def generate_contains_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: name = '{}{}{}'.format(DUNDER_PREFIX, fn.name, cl.name_prefix(emitter.names)) emitter.emit_line('static int {name}(PyObject *self, PyObject *obj_item) {{'.format(name=name)) generate_arg_check('item', fn.args[1].type, emit...
1862172396140f810f8c1d8c8256b58200a00644cd361d57bd35965665813455
def generate_wrapper_core(fn: FuncIR, emitter: Emitter, optional_args: Optional[List[RuntimeArg]]=None, arg_names: Optional[List[str]]=None, cleanups: Optional[List[str]]=None, traceback_code: Optional[str]=None) -> None: 'Generates the core part of a wrapper function for a native function.\n\n This expects each...
Generates the core part of a wrapper function for a native function. This expects each argument as a PyObject * named obj_{arg} as a precondition. It converts the PyObject *s to the necessary types, checking and unboxing if necessary, makes the call, then boxes the result if necessary and returns it.
mypyc/codegen/emitwrapper.py
generate_wrapper_core
srittau/mypy
12,496
python
def generate_wrapper_core(fn: FuncIR, emitter: Emitter, optional_args: Optional[List[RuntimeArg]]=None, arg_names: Optional[List[str]]=None, cleanups: Optional[List[str]]=None, traceback_code: Optional[str]=None) -> None: 'Generates the core part of a wrapper function for a native function.\n\n This expects each...
def generate_wrapper_core(fn: FuncIR, emitter: Emitter, optional_args: Optional[List[RuntimeArg]]=None, arg_names: Optional[List[str]]=None, cleanups: Optional[List[str]]=None, traceback_code: Optional[str]=None) -> None: 'Generates the core part of a wrapper function for a native function.\n\n This expects each...
5452df23ef39c1bf343d01db1bcd457f797697a3eab91ca58c672c93ae1506e5
def generate_arg_check(name: str, typ: RType, emitter: Emitter, error: Optional[ErrorHandler]=None, *, optional: bool=False, raise_exception: bool=True) -> None: 'Insert a runtime check for argument and unbox if necessary.\n\n The object is named PyObject *obj_{}. This is expected to generate\n a value of nam...
Insert a runtime check for argument and unbox if necessary. The object is named PyObject *obj_{}. This is expected to generate a value of name arg_{} (unboxed if necessary). For each primitive a runtime check ensures the correct type.
mypyc/codegen/emitwrapper.py
generate_arg_check
srittau/mypy
12,496
python
def generate_arg_check(name: str, typ: RType, emitter: Emitter, error: Optional[ErrorHandler]=None, *, optional: bool=False, raise_exception: bool=True) -> None: 'Insert a runtime check for argument and unbox if necessary.\n\n The object is named PyObject *obj_{}. This is expected to generate\n a value of nam...
def generate_arg_check(name: str, typ: RType, emitter: Emitter, error: Optional[ErrorHandler]=None, *, optional: bool=False, raise_exception: bool=True) -> None: 'Insert a runtime check for argument and unbox if necessary.\n\n The object is named PyObject *obj_{}. This is expected to generate\n a value of nam...
8d6797d9118a61e18fee9ac22e8f3bb84012ef310bdd0a50811c65d84951416c
def set_target(self, fn: FuncIR) -> None: "Set the wrapped function.\n\n It's fine to modify the attributes initialized here later to customize\n the wrapper function.\n " self.target_name = fn.name self.target_cname = fn.cname(self.emitter.names) self.arg_names = [arg.name for arg ...
Set the wrapped function. It's fine to modify the attributes initialized here later to customize the wrapper function.
mypyc/codegen/emitwrapper.py
set_target
srittau/mypy
12,496
python
def set_target(self, fn: FuncIR) -> None: "Set the wrapped function.\n\n It's fine to modify the attributes initialized here later to customize\n the wrapper function.\n " self.target_name = fn.name self.target_cname = fn.cname(self.emitter.names) self.arg_names = [arg.name for arg ...
def set_target(self, fn: FuncIR) -> None: "Set the wrapped function.\n\n It's fine to modify the attributes initialized here later to customize\n the wrapper function.\n " self.target_name = fn.name self.target_cname = fn.cname(self.emitter.names) self.arg_names = [arg.name for arg ...
53e5039341b87f219c240f467d46f0102a3846de7e4ad94010abfc6c46c2ba5a
def wrapper_name(self) -> str: 'Return the name of the wrapper function.' return '{}{}{}'.format(DUNDER_PREFIX, self.target_name, self.cl.name_prefix(self.emitter.names))
Return the name of the wrapper function.
mypyc/codegen/emitwrapper.py
wrapper_name
srittau/mypy
12,496
python
def wrapper_name(self) -> str: return '{}{}{}'.format(DUNDER_PREFIX, self.target_name, self.cl.name_prefix(self.emitter.names))
def wrapper_name(self) -> str: return '{}{}{}'.format(DUNDER_PREFIX, self.target_name, self.cl.name_prefix(self.emitter.names))<|docstring|>Return the name of the wrapper function.<|endoftext|>
a847f3d78060ddd9a59edcae45b9c58b05cbc763249266602997c6b040e2d49e
def use_goto(self) -> bool: 'Do we use a goto for error handling (instead of straight return)?' return bool((self.cleanups or self.traceback_code))
Do we use a goto for error handling (instead of straight return)?
mypyc/codegen/emitwrapper.py
use_goto
srittau/mypy
12,496
python
def use_goto(self) -> bool: return bool((self.cleanups or self.traceback_code))
def use_goto(self) -> bool: return bool((self.cleanups or self.traceback_code))<|docstring|>Do we use a goto for error handling (instead of straight return)?<|endoftext|>
476b93f6e6f55f869c7d9fb13127b8f21f900cf98da766aaa78b6868555628f1
def emit_header(self) -> None: 'Emit the function header of the wrapper implementation.' input_args = ', '.join(('PyObject *obj_{}'.format(arg) for arg in self.arg_names)) self.emitter.emit_line('static PyObject *{name}({input_args}) {{'.format(name=self.wrapper_name(), input_args=input_args))
Emit the function header of the wrapper implementation.
mypyc/codegen/emitwrapper.py
emit_header
srittau/mypy
12,496
python
def emit_header(self) -> None: input_args = ', '.join(('PyObject *obj_{}'.format(arg) for arg in self.arg_names)) self.emitter.emit_line('static PyObject *{name}({input_args}) {{'.format(name=self.wrapper_name(), input_args=input_args))
def emit_header(self) -> None: input_args = ', '.join(('PyObject *obj_{}'.format(arg) for arg in self.arg_names)) self.emitter.emit_line('static PyObject *{name}({input_args}) {{'.format(name=self.wrapper_name(), input_args=input_args))<|docstring|>Emit the function header of the wrapper implementation.<|e...
7f4cd9b38e627332de5c6b207437838ceec5319b1cb6686ee9d63e956e01d836
def emit_arg_processing(self, error: Optional[ErrorHandler]=None, raise_exception: bool=True) -> None: 'Emit validation and unboxing of arguments.' error = (error or self.error()) for (arg_name, arg) in zip(self.arg_names, self.args): typ = (arg.type if (arg.kind not in (ARG_STAR, ARG_STAR2)) else o...
Emit validation and unboxing of arguments.
mypyc/codegen/emitwrapper.py
emit_arg_processing
srittau/mypy
12,496
python
def emit_arg_processing(self, error: Optional[ErrorHandler]=None, raise_exception: bool=True) -> None: error = (error or self.error()) for (arg_name, arg) in zip(self.arg_names, self.args): typ = (arg.type if (arg.kind not in (ARG_STAR, ARG_STAR2)) else object_rprimitive) generate_arg_check...
def emit_arg_processing(self, error: Optional[ErrorHandler]=None, raise_exception: bool=True) -> None: error = (error or self.error()) for (arg_name, arg) in zip(self.arg_names, self.args): typ = (arg.type if (arg.kind not in (ARG_STAR, ARG_STAR2)) else object_rprimitive) generate_arg_check...
a2edc369503f3529f5f936ae90dec8218d51bed871ae1f3e24b0b3f578417439
def emit_call(self, not_implemented_handler: str='') -> None: "Emit call to the wrapper function.\n\n If not_implemented_handler is non-empty, use this C code to handle\n a NotImplemented return value (if it's possible based on the return type).\n " native_args = ', '.join(('arg_{}'.format(...
Emit call to the wrapper function. If not_implemented_handler is non-empty, use this C code to handle a NotImplemented return value (if it's possible based on the return type).
mypyc/codegen/emitwrapper.py
emit_call
srittau/mypy
12,496
python
def emit_call(self, not_implemented_handler: str=) -> None: "Emit call to the wrapper function.\n\n If not_implemented_handler is non-empty, use this C code to handle\n a NotImplemented return value (if it's possible based on the return type).\n " native_args = ', '.join(('arg_{}'.format(ar...
def emit_call(self, not_implemented_handler: str=) -> None: "Emit call to the wrapper function.\n\n If not_implemented_handler is non-empty, use this C code to handle\n a NotImplemented return value (if it's possible based on the return type).\n " native_args = ', '.join(('arg_{}'.format(ar...
12eb4f3f3fa68cf1f17c1d85526c0f6cfbb824eb3bb4038d605451aebd25d83c
def error(self) -> ErrorHandler: 'Figure out how to deal with errors in the wrapper.' if (self.cleanups or self.traceback_code): return GotoHandler('fail') else: return ReturnHandler('NULL')
Figure out how to deal with errors in the wrapper.
mypyc/codegen/emitwrapper.py
error
srittau/mypy
12,496
python
def error(self) -> ErrorHandler: if (self.cleanups or self.traceback_code): return GotoHandler('fail') else: return ReturnHandler('NULL')
def error(self) -> ErrorHandler: if (self.cleanups or self.traceback_code): return GotoHandler('fail') else: return ReturnHandler('NULL')<|docstring|>Figure out how to deal with errors in the wrapper.<|endoftext|>
220c6d9997885388f5cbfb5cea70a450400821223a163663942cf1203b48f89d
def emit_error_handling(self) -> None: 'Emit error handling block at the end of the wrapper, if needed.' emitter = self.emitter if self.use_goto(): emitter.emit_label('fail') emitter.emit_lines(*self.cleanups) if self.traceback_code: emitter.emit_line(self.traceback_code)...
Emit error handling block at the end of the wrapper, if needed.
mypyc/codegen/emitwrapper.py
emit_error_handling
srittau/mypy
12,496
python
def emit_error_handling(self) -> None: emitter = self.emitter if self.use_goto(): emitter.emit_label('fail') emitter.emit_lines(*self.cleanups) if self.traceback_code: emitter.emit_line(self.traceback_code) emitter.emit_line('return NULL;')
def emit_error_handling(self) -> None: emitter = self.emitter if self.use_goto(): emitter.emit_label('fail') emitter.emit_lines(*self.cleanups) if self.traceback_code: emitter.emit_line(self.traceback_code) emitter.emit_line('return NULL;')<|docstring|>Emit error...
6d76747af264ddfcda136ba2579155d115193b2bbe698bda6a4f87f52c16a184
def add_target(graph_path, target_name, target_list, sep=' '): "Add a target to all the graphs contains in hdf5 files\n\n Args:\n graph_path (str, list(str)): either a directory containing all the hdf5 files,\n or a single hdf5 filename\n ...
Add a target to all the graphs contains in hdf5 files Args: graph_path (str, list(str)): either a directory containing all the hdf5 files, or a single hdf5 filename or a list of hdf5 filenames target_name (str): the name of the new target ta...
deeprankcore/tools/CustomizeGraph.py
add_target
DeepRank/deeprank-gnn-2
0
python
def add_target(graph_path, target_name, target_list, sep=' '): "Add a target to all the graphs contains in hdf5 files\n\n Args:\n graph_path (str, list(str)): either a directory containing all the hdf5 files,\n or a single hdf5 filename\n ...
def add_target(graph_path, target_name, target_list, sep=' '): "Add a target to all the graphs contains in hdf5 files\n\n Args:\n graph_path (str, list(str)): either a directory containing all the hdf5 files,\n or a single hdf5 filename\n ...
5cb1c0b3d4515a4a43d7e7e69f6e2548d63c9feb01095787dea8e181230ea47d
def start_payment(request, pk): 'Start payment for a form' api = PolyBanking(settings.POLYBANKING_SERVER, settings.POLYBANKING_ID, settings.POLYBANKING_KEY_REQUEST, settings.POLYBANKING_KEY_IPN, settings.POLYBANKING_KEY_API) entry = get_object_or_404(FormEntry, pk=pk) if (not entry.form.need_payment): ...
Start payment for a form
mezzanine/forms/views.py
start_payment
agepoly/mezzanine
0
python
def start_payment(request, pk): api = PolyBanking(settings.POLYBANKING_SERVER, settings.POLYBANKING_ID, settings.POLYBANKING_KEY_REQUEST, settings.POLYBANKING_KEY_IPN, settings.POLYBANKING_KEY_API) entry = get_object_or_404(FormEntry, pk=pk) if (not entry.form.need_payment): raise Http404 p...
def start_payment(request, pk): api = PolyBanking(settings.POLYBANKING_SERVER, settings.POLYBANKING_ID, settings.POLYBANKING_KEY_REQUEST, settings.POLYBANKING_KEY_IPN, settings.POLYBANKING_KEY_API) entry = get_object_or_404(FormEntry, pk=pk) if (not entry.form.need_payment): raise Http404 p...
9d3d4215975006c13edb83eda3db04eaa9bbcfa1d9b5e3089c28444afe280da0
def partial_schema(schema, filtered_fields): '\n Validator for part of a schema, ignoring some fields\n\n :param schema: the Schema\n :param filtered_fields: fields to filter out\n ' return Schema({k: v for (k, v) in schema.schema.items() if (getattr(k, 'schema', k) not in filtered_fields)}, extra=A...
Validator for part of a schema, ignoring some fields :param schema: the Schema :param filtered_fields: fields to filter out
perch/validators.py
partial_schema
OpenPermissions/perch
3
python
def partial_schema(schema, filtered_fields): '\n Validator for part of a schema, ignoring some fields\n\n :param schema: the Schema\n :param filtered_fields: fields to filter out\n ' return Schema({k: v for (k, v) in schema.schema.items() if (getattr(k, 'schema', k) not in filtered_fields)}, extra=A...
def partial_schema(schema, filtered_fields): '\n Validator for part of a schema, ignoring some fields\n\n :param schema: the Schema\n :param filtered_fields: fields to filter out\n ' return Schema({k: v for (k, v) in schema.schema.items() if (getattr(k, 'schema', k) not in filtered_fields)}, extra=A...
3266c3cc9c1a9b5a642e880a49eb5d55e0e94d9b6f60bc2c249e477a916e9f11
def valid_email(email): 'Validate email.' if ('@' not in email): raise Invalid('This email is invalid.') return email
Validate email.
perch/validators.py
valid_email
OpenPermissions/perch
3
python
def valid_email(email): if ('@' not in email): raise Invalid('This email is invalid.') return email
def valid_email(email): if ('@' not in email): raise Invalid('This email is invalid.') return email<|docstring|>Validate email.<|endoftext|>
7f50d557f8ba04a7852d6346197a70f4e92924dbd66b89dfcd9655d1e79533c7
def validate_hex(color): '\n Validate string is a hex color code\n ' hex_re = '^#(?:[0-9a-fA-F]{3}){1,2}$' if (not re.match(hex_re, color)): raise Invalid('Invalid Hex Color') return color
Validate string is a hex color code
perch/validators.py
validate_hex
OpenPermissions/perch
3
python
def validate_hex(color): '\n \n ' hex_re = '^#(?:[0-9a-fA-F]{3}){1,2}$' if (not re.match(hex_re, color)): raise Invalid('Invalid Hex Color') return color
def validate_hex(color): '\n \n ' hex_re = '^#(?:[0-9a-fA-F]{3}){1,2}$' if (not re.match(hex_re, color)): raise Invalid('Invalid Hex Color') return color<|docstring|>Validate string is a hex color code<|endoftext|>
bb4c12579594ea012f26a31d999dcd149c7fe856ba19c3bd2fb4211fbe8788fa
def validate_url(url): 'Validate URL is valid\n\n NOTE: only support http & https\n ' schemes = ['http', 'https'] netloc_re = re.compile('^(?:\\S+(?::\\S*)?@)?(?:[a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])(?:\\.(?:[a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9]))*(?::[0-9]{2,5})?$', re.IGNORECASE) try:...
Validate URL is valid NOTE: only support http & https
perch/validators.py
validate_url
OpenPermissions/perch
3
python
def validate_url(url): 'Validate URL is valid\n\n NOTE: only support http & https\n ' schemes = ['http', 'https'] netloc_re = re.compile('^(?:\\S+(?::\\S*)?@)?(?:[a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])(?:\\.(?:[a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9]))*(?::[0-9]{2,5})?$', re.IGNORECASE) try:...
def validate_url(url): 'Validate URL is valid\n\n NOTE: only support http & https\n ' schemes = ['http', 'https'] netloc_re = re.compile('^(?:\\S+(?::\\S*)?@)?(?:[a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])(?:\\.(?:[a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9]))*(?::[0-9]{2,5})?$', re.IGNORECASE) try:...
eaf0a9e4a6296a8be66547737dafa3846c93e7ca9adb837b1555779699d8d414
def validate_reference_links(reference_links): '\n Vaidate reference links data structure\n\n Expected data structure:\n {\n "links": {\n id_type1: url1,\n id_type2: url2\n },\n "redirect_id_type": id_type1 | id1_type2\n }\n\n whe...
Vaidate reference links data structure Expected data structure: { "links": { id_type1: url1, id_type2: url2 }, "redirect_id_type": id_type1 | id1_type2 } where links is an optional key but must be a dictionary with id types to URLs if it exists, and redirect_id_...
perch/validators.py
validate_reference_links
OpenPermissions/perch
3
python
def validate_reference_links(reference_links): '\n Vaidate reference links data structure\n\n Expected data structure:\n {\n "links": {\n id_type1: url1,\n id_type2: url2\n },\n "redirect_id_type": id_type1 | id1_type2\n }\n\n whe...
def validate_reference_links(reference_links): '\n Vaidate reference links data structure\n\n Expected data structure:\n {\n "links": {\n id_type1: url1,\n id_type2: url2\n },\n "redirect_id_type": id_type1 | id1_type2\n }\n\n whe...
5e2faa4196553647597c84b354ef59d989cf1f3ace75e4e259c5d515602d57ae
def _validate_state(state, valid_states): 'Validate a state string' if (state in State): return state.name elif (state in valid_states): return state else: raise Invalid('Invalid state')
Validate a state string
perch/validators.py
_validate_state
OpenPermissions/perch
3
python
def _validate_state(state, valid_states): if (state in State): return state.name elif (state in valid_states): return state else: raise Invalid('Invalid state')
def _validate_state(state, valid_states): if (state in State): return state.name elif (state in valid_states): return state else: raise Invalid('Invalid state')<|docstring|>Validate a state string<|endoftext|>
975f4949c126cfdcfcc1c0e8d47bc71796f2a85507c67bb2a5b9ff4a8f299cdd
def __init__(self, key=None): '\n init key variable\n :param key:\n :return:\n ' self.key = key self._set_key_parms(['type']) self._set_prhb_parms(['type'])
init key variable :param key: :return:
skp_edu_docker/code/master/workflow/evalconf/workflow_evalconf.py
__init__
TensorMSA/hoyai_docker
8
python
def __init__(self, key=None): '\n init key variable\n :param key:\n :return:\n ' self.key = key self._set_key_parms(['type']) self._set_prhb_parms(['type'])
def __init__(self, key=None): '\n init key variable\n :param key:\n :return:\n ' self.key = key self._set_key_parms(['type']) self._set_prhb_parms(['type'])<|docstring|>init key variable :param key: :return:<|endoftext|>
0d2e146200072634e06a6735c567e54dd01defb220d106bc0c9c9a650ec1c81d
def get_eval_type(self): '\n get eval type ( regression, classification.. )\n :return:\n ' if ('conf' not in self.__dict__): self.conf = self.get_view_obj(self.key) return self.conf.get('type')
get eval type ( regression, classification.. ) :return:
skp_edu_docker/code/master/workflow/evalconf/workflow_evalconf.py
get_eval_type
TensorMSA/hoyai_docker
8
python
def get_eval_type(self): '\n get eval type ( regression, classification.. )\n :return:\n ' if ('conf' not in self.__dict__): self.conf = self.get_view_obj(self.key) return self.conf.get('type')
def get_eval_type(self): '\n get eval type ( regression, classification.. )\n :return:\n ' if ('conf' not in self.__dict__): self.conf = self.get_view_obj(self.key) return self.conf.get('type')<|docstring|>get eval type ( regression, classification.. ) :return:<|endoftext|>
8a76778d847e4a2a1507e0b69d250a026a22738c4f19ff7f4f6c721969cd9fda
def read_file(path): 'Read a file and return its contents as a string.' with open(path, 'r') as f: return f.read()
Read a file and return its contents as a string.
zazu/style.py
read_file
stopthatcow/zazu
2
python
def read_file(path): with open(path, 'r') as f: return f.read()
def read_file(path): with open(path, 'r') as f: return f.read()<|docstring|>Read a file and return its contents as a string.<|endoftext|>
2ba86b8d49a971e1e7b23e264dca8c3b7ddf238cf8b55097b28e362796afabfd
def write_file(path, _, styled_string): 'Write styled_string string to a file.' with open(path, 'w') as f: return f.write(styled_string)
Write styled_string string to a file.
zazu/style.py
write_file
stopthatcow/zazu
2
python
def write_file(path, _, styled_string): with open(path, 'w') as f: return f.write(styled_string)
def write_file(path, _, styled_string): with open(path, 'w') as f: return f.write(styled_string)<|docstring|>Write styled_string string to a file.<|endoftext|>
67ac19e01b23d602e3c83bdc00d2cbd659495dfa4ccc011e23c0a2b6d7a0d6a8
def stage_patch(path, input_string, styled_string): 'Create a patch between input_string and output_string and add the patch to the git staging area.\n\n Args:\n path: the path of the file being patched.\n input_string: the current state of the file in the git stage.\n styled_string: the pro...
Create a patch between input_string and output_string and add the patch to the git staging area. Args: path: the path of the file being patched. input_string: the current state of the file in the git stage. styled_string: the properly styled string to stage.
zazu/style.py
stage_patch
stopthatcow/zazu
2
python
def stage_patch(path, input_string, styled_string): 'Create a patch between input_string and output_string and add the patch to the git staging area.\n\n Args:\n path: the path of the file being patched.\n input_string: the current state of the file in the git stage.\n styled_string: the pro...
def stage_patch(path, input_string, styled_string): 'Create a patch between input_string and output_string and add the patch to the git staging area.\n\n Args:\n path: the path of the file being patched.\n input_string: the current state of the file in the git stage.\n styled_string: the pro...
e30691a41f7fe98b8937919fbd78538ca19e1f65abf9bf2c3beb40711e81b0a1
def style_file(stylers, path, read_fn, write_fn): 'Style a file.\n\n Args:\n styler: the styler to use to style the file.\n path: the file path.\n read_fn: function used to read in the file contents.\n write_fn: function used to write out the styled file, or None\n\n ' input_st...
Style a file. Args: styler: the styler to use to style the file. path: the file path. read_fn: function used to read in the file contents. write_fn: function used to write out the styled file, or None
zazu/style.py
style_file
stopthatcow/zazu
2
python
def style_file(stylers, path, read_fn, write_fn): 'Style a file.\n\n Args:\n styler: the styler to use to style the file.\n path: the file path.\n read_fn: function used to read in the file contents.\n write_fn: function used to write out the styled file, or None\n\n ' input_st...
def style_file(stylers, path, read_fn, write_fn): 'Style a file.\n\n Args:\n styler: the styler to use to style the file.\n path: the file path.\n read_fn: function used to read in the file contents.\n write_fn: function used to write out the styled file, or None\n\n ' input_st...
2fac8af2f0e0c9dc2d12227bd7968fa71501843d5569b0c79b0828ded5d0d312
def styler_list(file, sets, keys): 'Get the list of stylers to apply to a file based on the file set of each styler.' return [s for s in keys if (file in sets[s])]
Get the list of stylers to apply to a file based on the file set of each styler.
zazu/style.py
styler_list
stopthatcow/zazu
2
python
def styler_list(file, sets, keys): return [s for s in keys if (file in sets[s])]
def styler_list(file, sets, keys): return [s for s in keys if (file in sets[s])]<|docstring|>Get the list of stylers to apply to a file based on the file set of each styler.<|endoftext|>
bd4c0959b8512f83c461f666b61d4019fd43dd45dcabf4e462f354e7a6d5df8a
@click.command() @zazu.config.pass_config @click.option('-v', '--verbose', is_flag=True, help='print files that are dirty') @click.option('--check', is_flag=True, help='only check the repo for style violations, do not correct them') @click.option('--cached', is_flag=True, help='only examine/fix files that are staged fo...
Style repo files or check that they are valid style.
zazu/style.py
style
stopthatcow/zazu
2
python
@click.command() @zazu.config.pass_config @click.option('-v', '--verbose', is_flag=True, help='print files that are dirty') @click.option('--check', is_flag=True, help='only check the repo for style violations, do not correct them') @click.option('--cached', is_flag=True, help='only examine/fix files that are staged fo...
@click.command() @zazu.config.pass_config @click.option('-v', '--verbose', is_flag=True, help='print files that are dirty') @click.option('--check', is_flag=True, help='only check the repo for style violations, do not correct them') @click.option('--cached', is_flag=True, help='only examine/fix files that are staged fo...
f44753f4c397986d45af048e94a93e39114d8d6d76a560205b6fa328a01753cb
def __init__(self, name: str, parameters: TrainingParameters) -> None: '\n\n :param name: A unique name for this trainer used to create the data on the\n caffe2 workspace\n :param parameters: The set of training parameters\n ' self.optimizer = parameters.optimizer self.learni...
:param name: A unique name for this trainer used to create the data on the caffe2 workspace :param parameters: The set of training parameters
Section_6_BlueWhale/ml/rl/training/ml_trainer.py
__init__
PacktPublishing/Hands-On-Deep-Learning-with-Caffe2
7
python
def __init__(self, name: str, parameters: TrainingParameters) -> None: '\n\n :param name: A unique name for this trainer used to create the data on the\n caffe2 workspace\n :param parameters: The set of training parameters\n ' self.optimizer = parameters.optimizer self.learni...
def __init__(self, name: str, parameters: TrainingParameters) -> None: '\n\n :param name: A unique name for this trainer used to create the data on the\n caffe2 workspace\n :param parameters: The set of training parameters\n ' self.optimizer = parameters.optimizer self.learni...
0c5cbb629e9524b8d6c31d313c5177c9512763e04f057435c579f734f83072e5
def generateLossOps(self, model: ModelHelper, output_blob: str, label_blob: str) -> str: '\n Adds loss operators to net. The loss function is computed by a squared L2\n distance, and then averaged over all items in the minibatch.\n\n :param model: ModelHelper object to add loss operators to.\n ...
Adds loss operators to net. The loss function is computed by a squared L2 distance, and then averaged over all items in the minibatch. :param model: ModelHelper object to add loss operators to. :param model_id: String identifier. :param output_blob: Blob containing output of net. :param label_blob: Blob containing lab...
Section_6_BlueWhale/ml/rl/training/ml_trainer.py
generateLossOps
PacktPublishing/Hands-On-Deep-Learning-with-Caffe2
7
python
def generateLossOps(self, model: ModelHelper, output_blob: str, label_blob: str) -> str: '\n Adds loss operators to net. The loss function is computed by a squared L2\n distance, and then averaged over all items in the minibatch.\n\n :param model: ModelHelper object to add loss operators to.\n ...
def generateLossOps(self, model: ModelHelper, output_blob: str, label_blob: str) -> str: '\n Adds loss operators to net. The loss function is computed by a squared L2\n distance, and then averaged over all items in the minibatch.\n\n :param model: ModelHelper object to add loss operators to.\n ...
2dbedd921022c3e06a7021d6bbd079c84660f949ff4e1cf57c948e236f94427e
def cache_set_max(mx): 'Set the maximum number of operations libvips will cache.' vips_lib.vips_cache_set_max(mx)
Set the maximum number of operations libvips will cache.
pyvips/voperation.py
cache_set_max
timgates42/pyvips
142
python
def cache_set_max(mx): vips_lib.vips_cache_set_max(mx)
def cache_set_max(mx): vips_lib.vips_cache_set_max(mx)<|docstring|>Set the maximum number of operations libvips will cache.<|endoftext|>
f91c8584f6235005caf12b2594e08581528e2a8eae423b4b6a48af219aef94fc
def cache_set_max_mem(mx): 'Limit the operation cache by memory use.' vips_lib.vips_cache_set_max_mem(mx)
Limit the operation cache by memory use.
pyvips/voperation.py
cache_set_max_mem
timgates42/pyvips
142
python
def cache_set_max_mem(mx): vips_lib.vips_cache_set_max_mem(mx)
def cache_set_max_mem(mx): vips_lib.vips_cache_set_max_mem(mx)<|docstring|>Limit the operation cache by memory use.<|endoftext|>
bfd7257da9dd0ca2d30c99db52b1504f15d2f5bb8b23563a60a04ba41676354d
def cache_set_max_files(mx): 'Limit the operation cache by number of open files.' vips_lib.vips_cache_set_max_files(mx)
Limit the operation cache by number of open files.
pyvips/voperation.py
cache_set_max_files
timgates42/pyvips
142
python
def cache_set_max_files(mx): vips_lib.vips_cache_set_max_files(mx)
def cache_set_max_files(mx): vips_lib.vips_cache_set_max_files(mx)<|docstring|>Limit the operation cache by number of open files.<|endoftext|>
219910eebf661a10a1a00c2a89b2c91f110c2c2b8cca0320508aad087140ae9a
def cache_set_trace(trace): 'Turn on libvips cache tracing.' vips_lib.vips_cache_set_trace(trace)
Turn on libvips cache tracing.
pyvips/voperation.py
cache_set_trace
timgates42/pyvips
142
python
def cache_set_trace(trace): vips_lib.vips_cache_set_trace(trace)
def cache_set_trace(trace): vips_lib.vips_cache_set_trace(trace)<|docstring|>Turn on libvips cache tracing.<|endoftext|>
ab9f6433a5342ab87e6cce302e8033e311173fc9bff896e130a8b1805b254e98
@staticmethod def call(operation_name, *args, **kwargs): "Call a libvips operation.\n\n Use this method to call any libvips operation. For example::\n\n black_image = pyvips.Operation.call('black', 10, 10)\n\n See the Introduction for notes on how this works.\n\n " logger.debug('...
Call a libvips operation. Use this method to call any libvips operation. For example:: black_image = pyvips.Operation.call('black', 10, 10) See the Introduction for notes on how this works.
pyvips/voperation.py
call
timgates42/pyvips
142
python
@staticmethod def call(operation_name, *args, **kwargs): "Call a libvips operation.\n\n Use this method to call any libvips operation. For example::\n\n black_image = pyvips.Operation.call('black', 10, 10)\n\n See the Introduction for notes on how this works.\n\n " logger.debug('...
@staticmethod def call(operation_name, *args, **kwargs): "Call a libvips operation.\n\n Use this method to call any libvips operation. For example::\n\n black_image = pyvips.Operation.call('black', 10, 10)\n\n See the Introduction for notes on how this works.\n\n " logger.debug('...
b401edba6ec30cbd2373bb29cec1056111503f8d2e3d693363afa0ead263af94
@staticmethod def generate_docstring(operation_name): 'Make a google-style docstring.\n\n This is used to generate help() output.\n\n ' if (operation_name in Operation._docstring_cache): return Operation._docstring_cache[operation_name] intro = Introspect.get(operation_name) if ((i...
Make a google-style docstring. This is used to generate help() output.
pyvips/voperation.py
generate_docstring
timgates42/pyvips
142
python
@staticmethod def generate_docstring(operation_name): 'Make a google-style docstring.\n\n This is used to generate help() output.\n\n ' if (operation_name in Operation._docstring_cache): return Operation._docstring_cache[operation_name] intro = Introspect.get(operation_name) if ((i...
@staticmethod def generate_docstring(operation_name): 'Make a google-style docstring.\n\n This is used to generate help() output.\n\n ' if (operation_name in Operation._docstring_cache): return Operation._docstring_cache[operation_name] intro = Introspect.get(operation_name) if ((i...
424d5cdaf8ca8f20247891c4e6133b313797de4c3309a19bdb1b2d7ac1d6138d
@staticmethod def generate_sphinx(operation_name): 'Make a sphinx-style docstring.\n\n This is used to generate the off-line docs.\n\n ' intro = Introspect.get(operation_name) if ((intro.flags & _OPERATION_DEPRECATED) != 0): raise Error('No such operator.', 'operator "{0}" is deprecate...
Make a sphinx-style docstring. This is used to generate the off-line docs.
pyvips/voperation.py
generate_sphinx
timgates42/pyvips
142
python
@staticmethod def generate_sphinx(operation_name): 'Make a sphinx-style docstring.\n\n This is used to generate the off-line docs.\n\n ' intro = Introspect.get(operation_name) if ((intro.flags & _OPERATION_DEPRECATED) != 0): raise Error('No such operator.', 'operator "{0}" is deprecate...
@staticmethod def generate_sphinx(operation_name): 'Make a sphinx-style docstring.\n\n This is used to generate the off-line docs.\n\n ' intro = Introspect.get(operation_name) if ((intro.flags & _OPERATION_DEPRECATED) != 0): raise Error('No such operator.', 'operator "{0}" is deprecate...
a656d41c32d48677bc0f6130ef11330724d8260c87ca9549f303c6365f22f664
@staticmethod def generate_sphinx_all(): 'Generate sphinx documentation.\n\n This generates a .rst file for all auto-generated image methods. Use it\n to regenerate the docs with something like::\n\n $ python -c "import pyvips; pyvips.Operation.generate_sphinx_all()" > x\n\n And copy...
Generate sphinx documentation. This generates a .rst file for all auto-generated image methods. Use it to regenerate the docs with something like:: $ python -c "import pyvips; pyvips.Operation.generate_sphinx_all()" > x And copy-paste the file contents into doc/vimage.rst in the appropriate place.
pyvips/voperation.py
generate_sphinx_all
timgates42/pyvips
142
python
@staticmethod def generate_sphinx_all(): 'Generate sphinx documentation.\n\n This generates a .rst file for all auto-generated image methods. Use it\n to regenerate the docs with something like::\n\n $ python -c "import pyvips; pyvips.Operation.generate_sphinx_all()" > x\n\n And copy...
@staticmethod def generate_sphinx_all(): 'Generate sphinx documentation.\n\n This generates a .rst file for all auto-generated image methods. Use it\n to regenerate the docs with something like::\n\n $ python -c "import pyvips; pyvips.Operation.generate_sphinx_all()" > x\n\n And copy...
0abf8978274c0159cf207a87dc60978a7e0f2694733a2011c22f1885b946eba5
def edit(self, name): '\n if name is in database edit else add\n\n :param name:\n :return:\n ' db = self.get_database() with db.session_ctx(): dbuser = db.get_user(name) if dbuser: self._edit_user(db, dbuser) else: self.user = n...
if name is in database edit else add :param name: :return:
pychron/entry/entry_views/user_entry.py
edit
ASUPychron/pychron
31
python
def edit(self, name): '\n if name is in database edit else add\n\n :param name:\n :return:\n ' db = self.get_database() with db.session_ctx(): dbuser = db.get_user(name) if dbuser: self._edit_user(db, dbuser) else: self.user = n...
def edit(self, name): '\n if name is in database edit else add\n\n :param name:\n :return:\n ' db = self.get_database() with db.session_ctx(): dbuser = db.get_user(name) if dbuser: self._edit_user(db, dbuser) else: self.user = n...
ca0b58312a33ade488bb71650476fb394d77e7ace0501850b06c37de722398d6
def test_user_can_register(self): 'Test new user can be added to the system.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='testpassword', first_name='test', last_name='username')), content_type='application/json') self.assertEqual(response.status_...
Test new user can be added to the system.
tests/v2/test_user.py
test_user_can_register
ThaDeveloper/weConnect
1
python
def test_user_can_register(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='testpassword', first_name='test', last_name='username')), content_type='application/json') self.assertEqual(response.status_code, 201) response_msg = json.loads(re...
def test_user_can_register(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='testpassword', first_name='test', last_name='username')), content_type='application/json') self.assertEqual(response.status_code, 201) response_msg = json.loads(re...
dedcc7727d24f669f283f8a190713c815b694f377c714ab50138baa3a5e9b268
def test_blank_username(self): 'Tests error raised with username missing.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='', password='testpass', first_name='blank', last_name='username')), content_type='application/json') self.assertEqual(response.status_code, 400) res...
Tests error raised with username missing.
tests/v2/test_user.py
test_blank_username
ThaDeveloper/weConnect
1
python
def test_blank_username(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username=, password='testpass', first_name='blank', last_name='username')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decode('...
def test_blank_username(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username=, password='testpass', first_name='blank', last_name='username')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decode('...
5631c81e36fee5344abdb789dc40689ae3a11748d4cd26d453f6d28d591207cb
def test_username_has_space(self): 'Tests error raised when username contains spaces.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='first last', password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_...
Tests error raised when username contains spaces.
tests/v2/test_user.py
test_username_has_space
ThaDeveloper/weConnect
1
python
def test_username_has_space(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='first last', password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.d...
def test_username_has_space(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='first last', password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.d...
3de5fa3097468c7f7b96733ce2350c87e8b33e1ffbb316d0337418d574514233
def test_username_has_enough_characters(self): 'Tests error raised when username has less then 3 characters.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='am', password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(r...
Tests error raised when username has less then 3 characters.
tests/v2/test_user.py
test_username_has_enough_characters
ThaDeveloper/weConnect
1
python
def test_username_has_enough_characters(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='am', password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(respon...
def test_username_has_enough_characters(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='am', password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(respon...
d88b822d6a367e887c3c9c0d2ad10e23ae7fb447b736fbf08dc2793be5378280
def test_missing_password(self): 'Tests error raised when password is missing.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) ...
Tests error raised when password is missing.
tests/v2/test_user.py
test_missing_password
ThaDeveloper/weConnect
1
python
def test_missing_password(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password=, first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decode...
def test_missing_password(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password=, first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decode...
2a0126cb12e6628fcd6ae8d9873be0e36cb532dfe0f18f5c71bce93a58e1a9c2
def test_missing_first_or_last_name(self): 'Tests error raised when first name or last name is missing.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='testpassword', first_name='', last_name='last')), content_type='application/json') self.assertEqu...
Tests error raised when first name or last name is missing.
tests/v2/test_user.py
test_missing_first_or_last_name
ThaDeveloper/weConnect
1
python
def test_missing_first_or_last_name(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='testpassword', first_name=, last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(res...
def test_missing_first_or_last_name(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testusername', password='testpassword', first_name=, last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(res...
24add8ea6c54dd08e9257f3289a7bb79c0fbe4ff7a0c180b6420530dca81af6d
def test_username_isstring(self): 'Tests error raised when wrong username format is provided.' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username=1234, password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_...
Tests error raised when wrong username format is provided.
tests/v2/test_user.py
test_username_isstring
ThaDeveloper/weConnect
1
python
def test_username_isstring(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username=1234, password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decod...
def test_username_isstring(self): response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username=1234, password='testpass', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decod...
9a4f3c3e165f77b23f9ca8ab865c79f1f20b4e6f78bf72fd8be5857e4ef69a65
def test_duplicate_users(self): '\n Tests for duplicate usernames\n ' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testuser', password='password', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code,...
Tests for duplicate usernames
tests/v2/test_user.py
test_duplicate_users
ThaDeveloper/weConnect
1
python
def test_duplicate_users(self): '\n \n ' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testuser', password='password', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json...
def test_duplicate_users(self): '\n \n ' response = self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testuser', password='password', first_name='first', last_name='last')), content_type='application/json') self.assertEqual(response.status_code, 400) response_msg = json...
8f7d956f6b24a02be3b63397e9605786cdd0ec9f81b27a9272670fd6090ff317
def test_valid_login_generates_token(self): 'Tests token is generated on successful login.' response = self.app.post('/api/v2/auth/login', data=json.dumps(self.user), content_type='application/json') self.assertEqual(response.status_code, 200) response_msg = json.loads(response.data.decode('UTF-8')) ...
Tests token is generated on successful login.
tests/v2/test_user.py
test_valid_login_generates_token
ThaDeveloper/weConnect
1
python
def test_valid_login_generates_token(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(self.user), content_type='application/json') self.assertEqual(response.status_code, 200) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('token', response_msg)
def test_valid_login_generates_token(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(self.user), content_type='application/json') self.assertEqual(response.status_code, 200) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('token', response_msg)<|docstrin...
20bc72a11b999a831d2e8bda3e09d688e881a504abf26b7592fa5c20767c4a37
def test_missing_credentials(self): 'Tests error raised for missing auth details.' response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='', password='')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('...
Tests error raised for missing auth details.
tests/v2/test_user.py
test_missing_credentials
ThaDeveloper/weConnect
1
python
def test_missing_credentials(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username=, password=)), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('required', response_ms...
def test_missing_credentials(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username=, password=)), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('required', response_ms...
15171ceeb1592d4aea4203dd284c2d857d21b9ca7f77c1d2956deb1019c33796
def test_invalid_username_login(self): 'Tests unauthorized error raised with invalid username.' response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='invalid', password='testpass')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json....
Tests unauthorized error raised with invalid username.
tests/v2/test_user.py
test_invalid_username_login
ThaDeveloper/weConnect
1
python
def test_invalid_username_login(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='invalid', password='testpass')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('...
def test_invalid_username_login(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='invalid', password='testpass')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('...
e6e89b79dca68c88d74c0eb72b4214bb34f311f7ce42939b2d12f2020cb24e0d
def test_invalid_password_login(self): 'Tests unauthorized error raised with invalid password.' response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='testuser', password='invalid')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json....
Tests unauthorized error raised with invalid password.
tests/v2/test_user.py
test_invalid_password_login
ThaDeveloper/weConnect
1
python
def test_invalid_password_login(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='testuser', password='invalid')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('...
def test_invalid_password_login(self): response = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='testuser', password='invalid')), content_type='application/json') self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('...
7e5677c34f1ea235117b954fa1f1070e582d69eb30ca0938ee9a7d9960530be6
def test_logout(self): 'Test logout success' response = self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 200) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('out', response_msg['Message'])
Test logout success
tests/v2/test_user.py
test_logout
ThaDeveloper/weConnect
1
python
def test_logout(self): response = self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 200) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('out', response_msg['Message'])
def test_logout(self): response = self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 200) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('out', response_msg['Message'])<|docstring|>Test logout success<|endoft...
7f59f1871c9f1f813ae2a8375a295f4182b85fd8e54b70b84e8e6d2ba203c13b
def test_double_logout(self): 'Test Re-logout' self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) response = self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data....
Test Re-logout
tests/v2/test_user.py
test_double_logout
ThaDeveloper/weConnect
1
python
def test_double_logout(self): self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) response = self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decode('UTF-8'))...
def test_double_logout(self): self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) response = self.app.delete('/api/v2/auth/logout', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 400) response_msg = json.loads(response.data.decode('UTF-8'))...
6b7117c50ff326c37edd90a39e103769d89cbf4a16faf6a5ceb1555269aaa7f9
def test_reset_password(self): 'Register a user' self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testreset', password='pass', first_name='first', last_name='last')), headers={'content-type': 'application/json'}) self.login = self.app.post('/api/v2/auth/login', data=json.dumps(dict(user...
Register a user
tests/v2/test_user.py
test_reset_password
ThaDeveloper/weConnect
1
python
def test_reset_password(self): self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testreset', password='pass', first_name='first', last_name='last')), headers={'content-type': 'application/json'}) self.login = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='testreset',...
def test_reset_password(self): self.app.post('/api/v2/auth/register', data=json.dumps(dict(username='testreset', password='pass', first_name='first', last_name='last')), headers={'content-type': 'application/json'}) self.login = self.app.post('/api/v2/auth/login', data=json.dumps(dict(username='testreset',...
e3579f083468afdf687ecef8376559562dcb6985b2860c244596bccfcc90041f
def test_get_one_user(self): 'Tests authorized user can get a specific user profile' response = self.app.get('/api/v2/auth/users/{}'.format(User.query.order_by(User.created_at).first().id), content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 2...
Tests authorized user can get a specific user profile
tests/v2/test_user.py
test_get_one_user
ThaDeveloper/weConnect
1
python
def test_get_one_user(self): response = self.app.get('/api/v2/auth/users/{}'.format(User.query.order_by(User.created_at).first().id), content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 200)
def test_get_one_user(self): response = self.app.get('/api/v2/auth/users/{}'.format(User.query.order_by(User.created_at).first().id), content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 200)<|docstring|>Tests authorized user can get a specifi...
c10e3846692f2e605e457bfbee07e290949027f0baee159be034326caf07bfc8
def test_get_all_users(self): 'Test if get method gets all registered users' response = self.app.get('/api/v2/auth/users', content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 200)
Test if get method gets all registered users
tests/v2/test_user.py
test_get_all_users
ThaDeveloper/weConnect
1
python
def test_get_all_users(self): response = self.app.get('/api/v2/auth/users', content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 200)
def test_get_all_users(self): response = self.app.get('/api/v2/auth/users', content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 200)<|docstring|>Test if get method gets all registered users<|endoftext|>
e16b9697af5b9b6180558d0e3b2b4ec037cd148c39b841761406906f7dcf9ad9
def test_get_all_users_unauthorized(self): 'Tests error raised for accessing user list for non-admins' response = self.app.get('/api/v2/auth/users', content_type='application/json', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 401) response_msg = json.loads(response.dat...
Tests error raised for accessing user list for non-admins
tests/v2/test_user.py
test_get_all_users_unauthorized
ThaDeveloper/weConnect
1
python
def test_get_all_users_unauthorized(self): response = self.app.get('/api/v2/auth/users', content_type='application/json', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('Cannot perform', resp...
def test_get_all_users_unauthorized(self): response = self.app.get('/api/v2/auth/users', content_type='application/json', headers={'x-access-token': self.token}) self.assertEqual(response.status_code, 401) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('Cannot perform', resp...
7ca20055c1cb9b3edf43f446600e92ef8118e5ce0c7a840d1adc375ba64fb361
def test_get_one_user_unauthorized(self): 'Tests error raised for accessing a user for non-admin' response = self.app.get('/api/v2/auth/users/{}'.format(User.query.order_by(User.created_at).first().id), content_type='application/json', headers={'x-access-token': self.unkowntoken}) self.assertEqual(response....
Tests error raised for accessing a user for non-admin
tests/v2/test_user.py
test_get_one_user_unauthorized
ThaDeveloper/weConnect
1
python
def test_get_one_user_unauthorized(self): response = self.app.get('/api/v2/auth/users/{}'.format(User.query.order_by(User.created_at).first().id), content_type='application/json', headers={'x-access-token': self.unkowntoken}) self.assertEqual(response.status_code, 401) response_msg = json.loads(respons...
def test_get_one_user_unauthorized(self): response = self.app.get('/api/v2/auth/users/{}'.format(User.query.order_by(User.created_at).first().id), content_type='application/json', headers={'x-access-token': self.unkowntoken}) self.assertEqual(response.status_code, 401) response_msg = json.loads(respons...
50b685b89027e8c71f5fc223d6d7c6bd46ff7b40e112275cedaa6fcfae476554
def test_get_user_404(self): 'Test error raised when accessing nonexisting user' response = self.app.get('/api/v2/auth/users/00', content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 404) response_msg = json.loads(response.data.decode('UTF-...
Test error raised when accessing nonexisting user
tests/v2/test_user.py
test_get_user_404
ThaDeveloper/weConnect
1
python
def test_get_user_404(self): response = self.app.get('/api/v2/auth/users/00', content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 404) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('not found', response_msg['M...
def test_get_user_404(self): response = self.app.get('/api/v2/auth/users/00', content_type='application/json', headers={'x-access-token': self.admintoken}) self.assertEqual(response.status_code, 404) response_msg = json.loads(response.data.decode('UTF-8')) self.assertIn('not found', response_msg['M...