uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0e0b295402afed799148f87f | train | function | def create_updated_copyright_line(line, last_git_change_year):
copyright_splitter = 'Copyright (c) '
copyright_split = line.split(copyright_splitter)
# Preserve characters on line that are ahead of the start of the copyright
# notice - they are part of the comment block and vary from file-to-file.
b... | def create_updated_copyright_line(line, last_git_change_year):
| copyright_splitter = 'Copyright (c) '
copyright_split = line.split(copyright_splitter)
# Preserve characters on line that are ahead of the start of the copyright
# notice - they are part of the comment block and vary from file-to-file.
before_copyright = copyright_split[0]
after_copyright = copy... | _year
return start_year, year_split[1]
def year_range_to_str(start_year, end_year):
if start_year == end_year:
return start_year
return "%s-%s" % (start_year, end_year)
def create_updated_copyright_line(line, last_git_change_year):
| 64 | 64 | 173 | 13 | 51 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | create_updated_copyright_line | create_updated_copyright_line | 368 | 383 | 368 | 368 | 3db11764e940dee6517e17a1ddd796ebf4f4f8d5 | bigcode/the-stack | train |
4a878374a1c9d869af9bcb63 | train | function | def call_git_ls():
out = subprocess.check_output(GIT_LS_CMD.split(' '))
return [f for f in out.decode("utf-8").split('\n') if f != '']
| def call_git_ls():
| out = subprocess.check_output(GIT_LS_CMD.split(' '))
return [f for f in out.decode("utf-8").split('\n') if f != '']
| return ((EXCLUDE_COMPILED.match(filename) is None) and
(INCLUDE_COMPILED.match(filename) is not None))
################################################################################
# obtain list of files in repo according to INCLUDE and EXCLUDE
#######################################################... | 64 | 64 | 42 | 5 | 59 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | call_git_ls | call_git_ls | 56 | 58 | 56 | 56 | b475bde529e241e5f875474eca60b850854c01e5 | bigcode/the-stack | train |
84892e617c731efa89db6058 | train | function | def update_updatable_copyright(filename):
file_lines = read_file_lines(filename)
index, line = get_updatable_copyright_line(file_lines)
if not line:
print_file_action_message(filename, "No updatable copyright.")
return
last_git_change_year = get_most_recent_git_change_year(filename)
... | def update_updatable_copyright(filename):
| file_lines = read_file_lines(filename)
index, line = get_updatable_copyright_line(file_lines)
if not line:
print_file_action_message(filename, "No updatable copyright.")
return
last_git_change_year = get_most_recent_git_change_year(filename)
new_line = create_updated_copyright_line(l... | _range(year_range)
if end_year == last_git_change_year:
return line
return (before_copyright + copyright_splitter +
year_range_to_str(start_year, last_git_change_year) + ' ' +
' '.join(space_split[1:]))
def update_updatable_copyright(filename):
| 64 | 64 | 146 | 8 | 56 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | update_updatable_copyright | update_updatable_copyright | 385 | 399 | 385 | 385 | cdfad236f2c0d938b71dcc78099f5b4b3c174c4b | bigcode/the-stack | train |
393ba22a12b314365ca717fb | train | function | def gather_file_info(filename):
info = {}
info['filename'] = filename
c = read_file(filename)
info['contents'] = c
info['all_copyrights'] = get_count_of_copyrights_of_any_style_any_holder(c)
info['classified_copyrights'] = 0
info['dominant_style'] = {}
info['year_list_style'] = {}
... | def gather_file_info(filename):
| info = {}
info['filename'] = filename
c = read_file(filename)
info['contents'] = c
info['all_copyrights'] = get_count_of_copyrights_of_any_style_any_holder(c)
info['classified_copyrights'] = 0
info['dominant_style'] = {}
info['year_list_style'] = {}
info['without_c_style'] = {}
... | not None
def file_has_without_c_style_copyright_for_holder(contents, holder_name):
match = WITHOUT_C_STYLE_COMPILED[holder_name].search(contents)
return match is not None
################################################################################
# get file info
#########################################... | 79 | 79 | 264 | 6 | 73 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | gather_file_info | gather_file_info | 151 | 175 | 151 | 151 | 45b12a3ccca2c3c1f8ed635bd9ea2fdffd8deafa | bigcode/the-stack | train |
21f48aba2629b5813576cd80 | train | function | def get_filenames_to_examine():
filenames = call_git_ls()
return sorted([filename for filename in filenames if
applies_to_file(filename)])
| def get_filenames_to_examine():
| filenames = call_git_ls()
return sorted([filename for filename in filenames if
applies_to_file(filename)])
|
################################################################################
GIT_LS_CMD = 'git ls-files'
def call_git_ls():
out = subprocess.check_output(GIT_LS_CMD.split(' '))
return [f for f in out.decode("utf-8").split('\n') if f != '']
def get_filenames_to_examine():
| 64 | 64 | 32 | 8 | 56 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_filenames_to_examine | get_filenames_to_examine | 60 | 63 | 60 | 60 | 3087fac2badd6b7aba7cd5672f46d8f2960d1b2b | bigcode/the-stack | train |
d7a5edee6306d60606e9499b | train | function | def file_has_dominant_style_copyright_for_holder(contents, holder_name):
match = DOMINANT_STYLE_COMPILED[holder_name].search(contents)
return match is not None
| def file_has_dominant_style_copyright_for_holder(contents, holder_name):
| match = DOMINANT_STYLE_COMPILED[holder_name].search(contents)
return match is not None
| _STYLE,
holder_name))
################################################################################
# search file contents for copyright message of particular category
################################################################################
def get_count_of_copyrights_of_any... | 64 | 64 | 40 | 16 | 48 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | file_has_dominant_style_copyright_for_holder | file_has_dominant_style_copyright_for_holder | 132 | 134 | 132 | 132 | b07b185bfa580fb1d67a75807df04abed9099196 | bigcode/the-stack | train |
1bdcc1c9d526df95d3d25e79 | train | function | def compile_copyright_regex(copyright_style, year_style, name):
return re.compile('%s %s %s' % (copyright_style, year_style, name))
| def compile_copyright_regex(copyright_style, year_style, name):
| return re.compile('%s %s %s' % (copyright_style, year_style, name))
| (YEAR_RANGE, YEAR_LIST)
ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE = ("%s %s" % (ANY_COPYRIGHT_STYLE,
ANY_YEAR_STYLE))
ANY_COPYRIGHT_COMPILED = re.compile(ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE)
def compile_copyright_regex(copyright_style, year_style, name):
| 64 | 64 | 35 | 14 | 50 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | compile_copyright_regex | compile_copyright_regex | 83 | 84 | 83 | 83 | 5411bb081a899acde3acef295b0a3ab1dd8ac85c | bigcode/the-stack | train |
710b1c6b71727a0d14dd736b | train | function | def insert_python_header(filename, file_lines, start_year, end_year):
if file_has_hashbang(file_lines):
insert_idx = 1
else:
insert_idx = 0
header_lines = get_python_header_lines_to_insert(start_year, end_year)
for line in header_lines:
file_lines.insert(insert_idx, line)
wri... | def insert_python_header(filename, file_lines, start_year, end_year):
| if file_has_hashbang(file_lines):
insert_idx = 1
else:
insert_idx = 0
header_lines = get_python_header_lines_to_insert(start_year, end_year)
for line in header_lines:
file_lines.insert(insert_idx, line)
write_file_lines(filename, file_lines)
| _has_hashbang(file_lines):
if len(file_lines) < 1:
return False
if len(file_lines[0]) <= 2:
return False
return file_lines[0][:2] == '#!'
def insert_python_header(filename, file_lines, start_year, end_year):
| 63 | 64 | 82 | 15 | 48 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | insert_python_header | insert_python_header | 507 | 515 | 507 | 507 | 4cd37d0d408af61ce5dd9b017ece046ad8c7493e | bigcode/the-stack | train |
a31992e42e12ea70caee75b8 | train | function | def get_python_header_lines_to_insert(start_year, end_year):
return reversed(get_header_lines(PYTHON_HEADER, start_year, end_year))
| def get_python_header_lines_to_insert(start_year, end_year):
| return reversed(get_header_lines(PYTHON_HEADER, start_year, end_year))
| start_year, end_year))
PYTHON_HEADER = '''
# Copyright (c) %s The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
def get_python_header_lines_to_insert(start_year, end_year):
| 64 | 64 | 30 | 13 | 51 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_python_header_lines_to_insert | get_python_header_lines_to_insert | 477 | 478 | 477 | 477 | 46041f410bb3648285612ca8f927d1ecdf13bfcc | bigcode/the-stack | train |
8c2d8596a2b837d04a2e15fe | train | function | def file_already_has_core_copyright(file_lines):
index, _ = get_updatable_copyright_line(file_lines)
return index != None
| def file_already_has_core_copyright(file_lines):
| index, _ = get_updatable_copyright_line(file_lines)
return index != None
| ))
################################################################################
# query git for year of last change
################################################################################
def get_git_change_year_range(filename):
years = get_git_change_years(filename)
return min(years), max(years)... | 64 | 64 | 31 | 11 | 52 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | file_already_has_core_copyright | file_already_has_core_copyright | 492 | 494 | 492 | 492 | 7a4dc58c2443f7cf596a5f187ba7451b4ccd0645 | bigcode/the-stack | train |
94d0e14b1bc5e6165e5c1e0a | train | function | def file_has_hashbang(file_lines):
if len(file_lines) < 1:
return False
if len(file_lines[0]) <= 2:
return False
return file_lines[0][:2] == '#!'
| def file_has_hashbang(file_lines):
| if len(file_lines) < 1:
return False
if len(file_lines[0]) <= 2:
return False
return file_lines[0][:2] == '#!'
| ), max(years)
################################################################################
# check for existing core copyright
################################################################################
def file_already_has_core_copyright(file_lines):
index, _ = get_updatable_copyright_line(file_lines)
... | 64 | 64 | 50 | 8 | 55 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | file_has_hashbang | file_has_hashbang | 500 | 505 | 500 | 500 | 496b73187c352b3720dd832240e264d3bfc4f22e | bigcode/the-stack | train |
3883ac1f2ef3997da5c2fa88 | train | function | def write_file_lines(filename, file_lines):
f = open(os.path.abspath(filename), 'w', encoding="utf8")
f.write(''.join(file_lines))
f.close()
| def write_file_lines(filename, file_lines):
| f = open(os.path.abspath(filename), 'w', encoding="utf8")
f.write(''.join(file_lines))
f.close()
| _change_years(filename))
################################################################################
# read and write to file
################################################################################
def read_file_lines(filename):
f = open(os.path.abspath(filename), 'r', encoding="utf8")
file_line... | 64 | 64 | 39 | 9 | 54 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | write_file_lines | write_file_lines | 333 | 336 | 333 | 333 | 8ec9e190c0485b4b4bc28652cb0a70b1212cd884 | bigcode/the-stack | train |
8f9e39f197cd6f3cf790adad | train | function | def applies_to_file(filename):
return ((EXCLUDE_COMPILED.match(filename) is None) and
(INCLUDE_COMPILED.match(filename) is not None))
| def applies_to_file(filename):
| return ((EXCLUDE_COMPILED.match(filename) is None) and
(INCLUDE_COMPILED.match(filename) is not None))
| re.compile('|'.join([fnmatch.translate(m) for m in EXCLUDE]))
INCLUDE = ['*.h', '*.cpp', '*.cc', '*.c', '*.py']
INCLUDE_COMPILED = re.compile('|'.join([fnmatch.translate(m) for m in INCLUDE]))
def applies_to_file(filename):
| 64 | 64 | 36 | 6 | 58 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | applies_to_file | applies_to_file | 46 | 48 | 46 | 46 | a5d4d3741d5ef5d6d1c496ae7feacfb7bc09a285 | bigcode/the-stack | train |
310e047b22515eb88f732941 | train | function | def get_most_recent_git_change_year(filename):
return max(get_git_change_years(filename))
| def get_most_recent_git_change_year(filename):
| return max(get_git_change_years(filename))
| year]
# timestamp is in ISO 8601 format. e.g. "2016-09-05 14:25:32 -0600"
return [line.split(' ')[0].split('-')[0] for line in git_log_lines]
def get_most_recent_git_change_year(filename):
| 64 | 64 | 20 | 10 | 54 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_most_recent_git_change_year | get_most_recent_git_change_year | 320 | 321 | 320 | 320 | 92035253ff2db05ec1b66199364778cd24704468 | bigcode/the-stack | train |
0c6c2c0d87722ece3c8a25c5 | train | function | def get_cpp_header_lines_to_insert(start_year, end_year):
return reversed(get_header_lines(CPP_HEADER, start_year, end_year))
| def get_cpp_header_lines_to_insert(start_year, end_year):
| return reversed(get_header_lines(CPP_HEADER, start_year, end_year))
| n' for line in lines]
CPP_HEADER = '''
// Copyright (c) %s The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
def get_cpp_header_lines_to_insert(start_year, end_year):
| 64 | 64 | 29 | 13 | 51 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_cpp_header_lines_to_insert | get_cpp_header_lines_to_insert | 468 | 469 | 468 | 468 | 733fb7f7bdcd5620197d7a932c7eb7d14e42281b | bigcode/the-stack | train |
e20c41e0d53cc7744a1b1d8c | train | function | def print_report(file_infos, verbose):
print(SEPARATOR)
examined = [i['filename'] for i in file_infos]
print("%d files examined according to INCLUDE and EXCLUDE fnmatch rules" %
len(examined))
print_filenames(examined, verbose)
print(SEPARATOR)
print('')
zero_copyrights = [i['file... | def print_report(file_infos, verbose):
| print(SEPARATOR)
examined = [i['filename'] for i in file_infos]
print("%d files examined according to INCLUDE and EXCLUDE fnmatch rules" %
len(examined))
print_filenames(examined, verbose)
print(SEPARATOR)
print('')
zero_copyrights = [i['filename'] for i in file_infos if
... | info['year_list_style'] = {}
info['without_c_style'] = {}
for holder_name in EXPECTED_HOLDER_NAMES:
has_dominant_style = (
file_has_dominant_style_copyright_for_holder(c, holder_name))
has_year_list_style = (
file_has_year_list_style_copyright_for_holder(c, holder_nam... | 251 | 251 | 837 | 8 | 243 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | print_report | print_report | 189 | 260 | 189 | 189 | 388945ff1db24c23eb5714edf0b5fa2931eee621 | bigcode/the-stack | train |
690de101c9602e7f91dff1be | train | function | def read_file_lines(filename):
f = open(os.path.abspath(filename), 'r', encoding="utf8")
file_lines = f.readlines()
f.close()
return file_lines
| def read_file_lines(filename):
| f = open(os.path.abspath(filename), 'r', encoding="utf8")
file_lines = f.readlines()
f.close()
return file_lines
| :32 -0600"
return [line.split(' ')[0].split('-')[0] for line in git_log_lines]
def get_most_recent_git_change_year(filename):
return max(get_git_change_years(filename))
################################################################################
# read and write to file
###################################... | 64 | 64 | 39 | 6 | 57 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | read_file_lines | read_file_lines | 327 | 331 | 327 | 327 | fa12ad3825cd40b6bdf5a03c2801c8c9f71c1fa8 | bigcode/the-stack | train |
7fa5ebc4b70f9d4c26f5b6fa | train | function | def file_has_without_c_style_copyright_for_holder(contents, holder_name):
match = WITHOUT_C_STYLE_COMPILED[holder_name].search(contents)
return match is not None
| def file_has_without_c_style_copyright_for_holder(contents, holder_name):
| match = WITHOUT_C_STYLE_COMPILED[holder_name].search(contents)
return match is not None
| ].search(contents)
return match is not None
def file_has_year_list_style_copyright_for_holder(contents, holder_name):
match = YEAR_LIST_STYLE_COMPILED[holder_name].search(contents)
return match is not None
def file_has_without_c_style_copyright_for_holder(contents, holder_name):
| 64 | 64 | 38 | 15 | 48 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | file_has_without_c_style_copyright_for_holder | file_has_without_c_style_copyright_for_holder | 140 | 142 | 140 | 140 | 48ba9cf2559a054e752341e562cf49931ff667e6 | bigcode/the-stack | train |
bf2f257e3f7c8b10ab4a5172 | train | function | def get_header_lines(header, start_year, end_year):
lines = header.split('\n')[1:-1]
lines[0] = lines[0] % year_range_to_str(start_year, end_year)
return [line + '\n' for line in lines]
| def get_header_lines(header, start_year, end_year):
| lines = header.split('\n')[1:-1]
lines[0] = lines[0] % year_range_to_str(start_year, end_year)
return [line + '\n' for line in lines]
| _USAGE)
base_directory = argv[2]
if not os.path.exists(base_directory):
sys.exit("*** bad base_directory: %s" % base_directory)
exec_update_header_year(base_directory)
################################################################################
# inserted copyright header format
##############... | 64 | 64 | 58 | 12 | 51 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_header_lines | get_header_lines | 457 | 460 | 457 | 457 | 63ba3663d9cfde7973e51a77f50f88f06473174a | bigcode/the-stack | train |
2d988312a6d5b42a58f0bc83 | train | function | def update_cmd(argv):
if len(argv) != 3:
sys.exit(UPDATE_USAGE)
base_directory = argv[2]
if not os.path.exists(base_directory):
sys.exit("*** bad base_directory: %s" % base_directory)
exec_update_header_year(base_directory)
| def update_cmd(argv):
| if len(argv) != 3:
sys.exit(UPDATE_USAGE)
base_directory = argv[2]
if not os.path.exists(base_directory):
sys.exit("*** bad base_directory: %s" % base_directory)
exec_update_header_year(base_directory)
| appropriate.
Usage:
$ ./copyright_header.py update <base_directory>
Arguments:
<base_directory> - The base directory of a learncoin source code repository.
"""
def print_file_action_message(filename, action):
print("%-52s %s" % (filename, action))
def update_cmd(argv):
| 64 | 64 | 61 | 5 | 59 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | update_cmd | update_cmd | 444 | 451 | 444 | 444 | 4a9bd77fa7bee6d0c4c4e6623cbee275ac25c0c3 | bigcode/the-stack | train |
24752d2fd966934602da6123 | train | function | def exec_update_header_year(base_directory):
original_cwd = os.getcwd()
os.chdir(base_directory)
for filename in get_filenames_to_examine():
update_updatable_copyright(filename)
os.chdir(original_cwd)
| def exec_update_header_year(base_directory):
| original_cwd = os.getcwd()
os.chdir(base_directory)
for filename in get_filenames_to_examine():
update_updatable_copyright(filename)
os.chdir(original_cwd)
| print_file_action_message(filename, "Copyright up-to-date.")
return
file_lines[index] = new_line
write_file_lines(filename, file_lines)
print_file_action_message(filename,
"Copyright updated! -> %s" % last_git_change_year)
def exec_update_header_year(base_direct... | 64 | 64 | 48 | 8 | 56 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | exec_update_header_year | exec_update_header_year | 401 | 406 | 401 | 401 | 0c36da64670844167b46a68c0d14c5ec51f61377 | bigcode/the-stack | train |
2441b284cf9d4ba092f9fec3 | train | function | def insert_cpp_header(filename, file_lines, start_year, end_year):
header_lines = get_cpp_header_lines_to_insert(start_year, end_year)
for line in header_lines:
file_lines.insert(0, line)
write_file_lines(filename, file_lines)
| def insert_cpp_header(filename, file_lines, start_year, end_year):
| header_lines = get_cpp_header_lines_to_insert(start_year, end_year)
for line in header_lines:
file_lines.insert(0, line)
write_file_lines(filename, file_lines)
| :
insert_idx = 0
header_lines = get_python_header_lines_to_insert(start_year, end_year)
for line in header_lines:
file_lines.insert(insert_idx, line)
write_file_lines(filename, file_lines)
def insert_cpp_header(filename, file_lines, start_year, end_year):
| 64 | 64 | 56 | 15 | 49 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | insert_cpp_header | insert_cpp_header | 517 | 521 | 517 | 517 | b4116632c7cfb822aa8d7143964dfcb5bc194f23 | bigcode/the-stack | train |
d25285e77a194cdbddf6ce2e | train | function | def get_updatable_copyright_line(file_lines):
index = 0
for line in file_lines:
if UPDATEABLE_LINE_COMPILED.search(line) is not None:
return index, line
index = index + 1
return None, None
| def get_updatable_copyright_line(file_lines):
| index = 0
for line in file_lines:
if UPDATEABLE_LINE_COMPILED.search(line) is not None:
return index, line
index = index + 1
return None, None
| -9][0-9]"
YEAR_RANGE = '(%s)(-%s)?' % (YEAR, YEAR)
HOLDER = 'The Bitcoin Core developers'
UPDATEABLE_LINE_COMPILED = re.compile(' '.join([COPYRIGHT, YEAR_RANGE, HOLDER]))
def get_updatable_copyright_line(file_lines):
| 64 | 64 | 58 | 10 | 54 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_updatable_copyright_line | get_updatable_copyright_line | 348 | 354 | 348 | 348 | 32bce573e0d4927cac0e681804041ef0eed0eade | bigcode/the-stack | train |
23889c7854111efad902d957 | train | function | def print_file_action_message(filename, action):
print("%-52s %s" % (filename, action))
| def print_file_action_message(filename, action):
| print("%-52s %s" % (filename, action))
| (c) <year>-<lastModifiedYear> The Bitcoin Core developers
where the update is appropriate.
Usage:
$ ./copyright_header.py update <base_directory>
Arguments:
<base_directory> - The base directory of a learncoin source code repository.
"""
def print_file_action_message(filename, action):
| 64 | 64 | 24 | 9 | 55 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | print_file_action_message | print_file_action_message | 441 | 442 | 441 | 441 | c515f082d61d3fda6af13f8156b15805fb7c188d | bigcode/the-stack | train |
b8419e1124d432b9ee88c49b | train | function | def get_git_change_year_range(filename):
years = get_git_change_years(filename)
return min(years), max(years)
| def get_git_change_year_range(filename):
| years = get_git_change_years(filename)
return min(years), max(years)
| or http://www.opensource.org/licenses/mit-license.php.
'''
def get_python_header_lines_to_insert(start_year, end_year):
return reversed(get_header_lines(PYTHON_HEADER, start_year, end_year))
################################################################################
# query git for year of last change
#####... | 64 | 64 | 28 | 8 | 55 | JBaczuk/learncoin | contrib/devtools/copyright_header.py | Python | get_git_change_year_range | get_git_change_year_range | 484 | 486 | 484 | 484 | 24c74925fe822f868a271175de3cac86f5b06992 | bigcode/the-stack | train |
cf9e4fbcd2fd48e74103d8cf | train | class | class WelcomeController:
"""Controller For Welcoming The User
"""
def show(self, view: View, request: Request):
"""Shows the welcome page.
Arguments:
view {masonite.view.View} -- The Masonite view class.
Application {config.application} -- The application co... | class WelcomeController:
| """Controller For Welcoming The User
"""
def show(self, view: View, request: Request):
"""Shows the welcome page.
Arguments:
view {masonite.view.View} -- The Masonite view class.
Application {config.application} -- The application config module.
... | """ Welcome The User To Masonite """
from masonite.view import View
from masonite.request import Request
from app.User import User
class WelcomeController:
| 32 | 64 | 129 | 4 | 27 | girardinsamuel/api | app/http/controllers/WelcomeController.py | Python | WelcomeController | WelcomeController | 7 | 24 | 7 | 7 | 431776b4fc320cd2806c323d58a9d543a2abcdd5 | bigcode/the-stack | train |
28aa90b4897d59d26d9b4a42 | train | function | def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "hf", ["help", "file="])
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
file_name = None
for k, v in opts:
if k in ("-h", "--help"):
usage()
sys.exit()
... | def main():
| try:
opts, args = getopt.getopt(sys.argv[1:], "hf", ["help", "file="])
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
file_name = None
for k, v in opts:
if k in ("-h", "--help"):
usage()
sys.exit()
elif k in ... | ("REQ:" + msg)
else:
print("RES:" + msg)
#if packet[2] == 0x0A:
# ba = bytearray(packet[6:8])
# (temperature,) = struct.unpack("<H", ba)
# print(str(temperature) + "," + str(packet[8]) + "," + str(packet[9]) + "," + str(packet[10]))
# Main
def main():
| 97 | 97 | 326 | 3 | 93 | openersa/minicon | scripts/parse-bin.py | Python | main | main | 34 | 86 | 34 | 34 | 9d5c4904628d4d4360e4edec275b369e6d489952 | bigcode/the-stack | train |
3cb806ba386afc2686158194 | train | function | def usage():
print("Usage: python3 " + sys.argv[0] + " [options]")
print("""
Options:
-h, --help Display this information"
--file=FILENAME Parse file""")
| def usage():
| print("Usage: python3 " + sys.argv[0] + " [options]")
print("""
Options:
-h, --help Display this information"
--file=FILENAME Parse file""")
| #!/usr/bin/env python3
import getopt
import fileinput
import struct
import sys
# Usage
def usage():
| 26 | 64 | 49 | 3 | 22 | openersa/minicon | scripts/parse-bin.py | Python | usage | usage | 9 | 14 | 9 | 9 | 1d43ad8570b045d3092f29e082a4ddf3b8674a73 | bigcode/the-stack | train |
467a37b6ce30717516c4e001 | train | function | def print_packet(packet):
if not packet:
return
msg = ""
for v in packet:
msg += " " + format(v, "02X")
if len(packet) == 8:
print("REQ:" + msg)
else:
print("RES:" + msg)
| def print_packet(packet):
| if not packet:
return
msg = ""
for v in packet:
msg += " " + format(v, "02X")
if len(packet) == 8:
print("REQ:" + msg)
else:
print("RES:" + msg)
| sys
# Usage
def usage():
print("Usage: python3 " + sys.argv[0] + " [options]")
print("""
Options:
-h, --help Display this information"
--file=FILENAME Parse file""")
# Print print packet
def print_packet(packet):
| 64 | 64 | 64 | 5 | 58 | openersa/minicon | scripts/parse-bin.py | Python | print_packet | print_packet | 17 | 26 | 17 | 17 | a7517667f010921af3f755570fce45e21a8e25d0 | bigcode/the-stack | train |
bc7e3da61fd2d25a27a1434f | train | class | class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 576)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.set... | class Ui_MainWindow(object):
| def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 576)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
si... | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'layouts/base.ui'
#
# Created by: PyQt4 UI code generator 4.12.1
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(... | 178 | 256 | 4,432 | 6 | 172 | italogsfernandes/ib1 | py_app/views/base_qt4.py | Python | Ui_MainWindow | Ui_MainWindow | 25 | 315 | 25 | 25 | 7c0730d1d1fc6a74f21a766b07de521d45d8ce5c | bigcode/the-stack | train |
844b06f036a62b6eaf2b37a8 | train | function | def setup(bot):
bot.add_cog(CogName(bot))
| def setup(bot):
| bot.add_cog(CogName(bot))
| ping(self, ctx):
"""Say pong"""
now = ctx.message.created_at
msg = await ctx.send('Pong')
sub = msg.created_at - now
await msg.edit(content=f'Pong, {sub.total_seconds() * 1000}')
def setup(bot):
| 61 | 64 | 14 | 4 | 57 | SVengat03/Sebi-Machine | src/cogs/example.py | Python | setup | setup | 23 | 24 | 23 | 23 | b5a60d7fdae2b223a1293c2e6e220be3a4953b4e | bigcode/the-stack | train |
76272904a1c46e428571fee2 | train | class | class CogName:
"""
CogName should be the name of the cog
"""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
"""Say pong"""
now = ctx.message.created_at
msg = await ctx.send('Pong')
sub = msg.created_at -... | class CogName:
| """
CogName should be the name of the cog
"""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
"""Say pong"""
now = ctx.message.created_at
msg = await ctx.send('Pong')
sub = msg.created_at - now
aw... | #!/usr/bin/python
# -*- coding: <encoding name> -*-
from discord.ext import commands
import discord
class CogName:
| 28 | 64 | 100 | 4 | 23 | SVengat03/Sebi-Machine | src/cogs/example.py | Python | CogName | CogName | 7 | 20 | 7 | 7 | 68e270c85ebb3d9907c96e6354c43c51d446c1a0 | bigcode/the-stack | train |
945b502b8228d2d03ba92323 | train | class | class ListContributors(BaseDialog):
"""docstring for ListTodos"""
def __init__(self, contributors=[]):
BaseDialog.__init__(self, _('List of contributors'), None,
ok_button=True, cancel_button=True)
self.load(contributors)
def init_ui(self):
BaseDialog.ini... | class ListContributors(BaseDialog):
| """docstring for ListTodos"""
def __init__(self, contributors=[]):
BaseDialog.__init__(self, _('List of contributors'), None,
ok_button=True, cancel_button=True)
self.load(contributors)
def init_ui(self):
BaseDialog.init_ui(self)
self.contributor... | of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTH... | 185 | 186 | 622 | 7 | 178 | atareao/readmemaker | src/list_contributors.py | Python | ListContributors | ListContributors | 42 | 120 | 42 | 42 | 0ff5e574c74825ab253b45cc272aa08b4dc9e8fa | bigcode/the-stack | train |
6e350e585d72169a04fdcf46 | train | function | def create(name, *args, **kwargs):
if name not in __factory:
raise KeyError("Unknown clip model:", name)
return __factory[name](*args, **kwargs) | def create(name, *args, **kwargs):
| if name not in __factory:
raise KeyError("Unknown clip model:", name)
return __factory[name](*args, **kwargs) | ': CLIPViTB16,
# custom
'RN101_448': CLIPRN101_448,
'ViT-B/32_448': CLIPViTB32_448
}
def names():
return sorted(__factory.keys())
def create(name, *args, **kwargs):
| 64 | 64 | 41 | 10 | 54 | jianjieluo/OpenAI-CLIP-Feature | visual_extractor/__init__.py | Python | create | create | 18 | 21 | 18 | 18 | 2e65ec8b7b037c5b673697a3ee91e9bf2593907d | bigcode/the-stack | train |
cb177707649f671c52e2ac22 | train | function | def names():
return sorted(__factory.keys())
| def names():
| return sorted(__factory.keys())
| -B/32': CLIPViTB32,
'ViT-B/16': CLIPViTB16,
# custom
'RN101_448': CLIPRN101_448,
'ViT-B/32_448': CLIPViTB32_448
}
def names():
| 64 | 64 | 10 | 3 | 61 | jianjieluo/OpenAI-CLIP-Feature | visual_extractor/__init__.py | Python | names | names | 15 | 16 | 15 | 15 | f24513bd3e26aa17dc8c88bd816208756b4a1547 | bigcode/the-stack | train |
2cbe5a7b64dff5bf13280354 | train | class | class measure_metrics:
def __init__(self):
self.log = logger.log()
def compute_r2_score(self, y_true, y_pred):
return r2_score(y_true, y_pred)
def compute_mean_squared_error(self, y_true, y_pred):
return mean_squared_error(y_true, y_pred)
def compute_mean_absolute_error(self, ... | class measure_metrics:
| def __init__(self):
self.log = logger.log()
def compute_r2_score(self, y_true, y_pred):
return r2_score(y_true, y_pred)
def compute_mean_squared_error(self, y_true, y_pred):
return mean_squared_error(y_true, y_pred)
def compute_mean_absolute_error(self, y_true, y_pred):
... | from src.logger import logger
from sklearn.metrics import r2_score, mean_squared_error, mean_absolute_error
class measure_metrics:
| 26 | 64 | 176 | 4 | 21 | IamVicky90/Zomato | src/Training_Service/metrics/metrics.py | Python | measure_metrics | measure_metrics | 5 | 23 | 5 | 5 | 89151f860b60bb23c73fbe3c8517ef087bf88a50 | bigcode/the-stack | train |
97a36e926b50f8119ca5eee3 | train | function | def parseArguments():
desc = "Program that converts a trajectory from a non-pdb format into a pdb."
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("trajectory", help="Trajectory files to convert")
parser.add_argument("-o", type=str, default="", help="Output file")
parser.add_... | def parseArguments():
| desc = "Program that converts a trajectory from a non-pdb format into a pdb."
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("trajectory", help="Trajectory files to convert")
parser.add_argument("-o", type=str, default="", help="Output file")
parser.add_argument("--dir", type... | from __future__ import absolute_import, division, print_function, unicode_literals
from AdaptivePELE.utilities import utilities
import argparse
import os
def parseArguments():
| 34 | 64 | 126 | 4 | 29 | danielSoler93/msm_pele | msm_pele/AdaptivePELE/analysis/convertTrajectory.py | Python | parseArguments | parseArguments | 7 | 15 | 7 | 7 | 4e2cb7a2008c1e8361e0d8d174e5833921331176 | bigcode/the-stack | train |
fcb58452655db1096e30b29c | train | function | def main(trajectory, output_file, output_path, topology):
if output_path:
utilities.makeFolder(output_path)
if not output_file:
output_file = "%s.pdb" % os.path.splitext(os.path.split(trajectory)[1])[0]
utilities.convert_trajectory_to_pdb(trajectory, topology, output_file, output_path)
| def main(trajectory, output_file, output_path, topology):
| if output_path:
utilities.makeFolder(output_path)
if not output_file:
output_file = "%s.pdb" % os.path.splitext(os.path.split(trajectory)[1])[0]
utilities.convert_trajectory_to_pdb(trajectory, topology, output_file, output_path)
| ="", help="Output dir")
parser.add_argument("--top", type=str, default=None, help="Topology file for non-pdb trajectories")
args = parser.parse_args()
return args.trajectory, args.o, args.dir, args.top
def main(trajectory, output_file, output_path, topology):
| 64 | 64 | 73 | 13 | 50 | danielSoler93/msm_pele | msm_pele/AdaptivePELE/analysis/convertTrajectory.py | Python | main | main | 18 | 23 | 18 | 18 | 09a4155ca6d84d1ab91a6d30088f71ad2a2860eb | bigcode/the-stack | train |
3946ceb5655bf55ba787b37c | train | class | class HPacker(PackerBase):
"""
The HPacker has its children packed horizontally. It automatically
adjusts the relative positions of children at draw time.
"""
def __init__(self, pad=None, sep=None, width=None, height=None,
align="baseline", mode="fixed",
children=No... | class HPacker(PackerBase):
| """
The HPacker has its children packed horizontally. It automatically
adjusts the relative positions of children at draw time.
"""
def __init__(self, pad=None, sep=None, width=None, height=None,
align="baseline", mode="fixed",
children=None):
"""
Pa... | .align)
pack_list = [(h, yd) for w, h, xd, yd in whd_list]
height, yoffsets_ = _get_packed_offsets(pack_list, self.height,
sep, self.mode)
yoffsets = yoffsets_ + [yd for w, h, xd, yd in whd_list]
ydescent = height - yoffsets[0]
yo... | 178 | 178 | 596 | 7 | 171 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | HPacker | HPacker | 415 | 491 | 415 | 415 | c66bcca99ba0b1d518c8d7e745c66ca401b0ecbe | bigcode/the-stack | train |
d3e274896e433f221a2b95a7 | train | function | def bbox_artist(*args, **kwargs):
if DEBUG:
mbbox_artist(*args, **kwargs)
| def bbox_artist(*args, **kwargs):
| if DEBUG:
mbbox_artist(*args, **kwargs)
| rcParams
from matplotlib import docstring
#from bboximage import BboxImage
from matplotlib.image import BboxImage
from matplotlib.patches import bbox_artist as mbbox_artist
from matplotlib.text import _AnnotationBase
DEBUG = False
# for debuging use
def bbox_artist(*args, **kwargs):
| 64 | 64 | 23 | 9 | 54 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | bbox_artist | bbox_artist | 48 | 50 | 48 | 48 | 642d57b1e5cc163e42aa294354cb46bc5c95433d | bigcode/the-stack | train |
76c20facf4b46d2c98f04c27 | train | class | class AuxTransformBox(OffsetBox):
"""
Offset Box with the aux_transform . Its children will be
transformed with the aux_transform first then will be
offseted. The absolute coordinate of the aux_transform is meaning
as it will be automatically adjust so that the left-lower corner
of the bounding ... | class AuxTransformBox(OffsetBox):
| """
Offset Box with the aux_transform . Its children will be
transformed with the aux_transform first then will be
offseted. The absolute coordinate of the aux_transform is meaning
as it will be automatically adjust so that the left-lower corner
of the bounding box of children will be set to (0,... | # last line
self._baseline_transform.clear()
if len(info) > 1 and self._multilinebaseline:
d_new = 0.5 * h - 0.5 * (h_ - d_)
self._baseline_transform.translate(0, d - d_new)
d = d_new
else: # single line
h_d = max(h_ - d_, h - d)
... | 221 | 221 | 738 | 8 | 212 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | AuxTransformBox | AuxTransformBox | 873 | 977 | 873 | 873 | 98afe6911d0dda48db6d21db9f965d580266136a | bigcode/the-stack | train |
f31b4c3c6a46c4ded21a61d8 | train | function | def _get_packed_offsets(wd_list, total, sep, mode="fixed"):
"""
Geiven a list of (width, xdescent) of each boxes, calculate the
total width and the x-offset positions of each items according to
*mode*. xdescent is analagous to the usual descent, but along the
x-direction. xdescent values are current... | def _get_packed_offsets(wd_list, total, sep, mode="fixed"):
| """
Geiven a list of (width, xdescent) of each boxes, calculate the
total width and the x-offset positions of each items according to
*mode*. xdescent is analagous to the usual descent, but along the
x-direction. xdescent values are currently ignored.
*wd_list* : list of (width, xdescent) of bo... | bboximage import BboxImage
from matplotlib.image import BboxImage
from matplotlib.patches import bbox_artist as mbbox_artist
from matplotlib.text import _AnnotationBase
DEBUG = False
# for debuging use
def bbox_artist(*args, **kwargs):
if DEBUG:
mbbox_artist(*args, **kwargs)
# _get_packed_offsets() a... | 124 | 124 | 414 | 18 | 106 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | _get_packed_offsets | _get_packed_offsets | 57 | 104 | 57 | 57 | 71605eda7eda208f6607d24036725073457e7050 | bigcode/the-stack | train |
c793035fcb0ba4f9e46927c9 | train | class | class AnchoredText(AnchoredOffsetbox):
"""
AnchoredOffsetbox with Text.
"""
def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
"""
Parameters
----------
s : string
Text.
loc : str
Location code.
pad : float,... | class AnchoredText(AnchoredOffsetbox):
| """
AnchoredOffsetbox with Text.
"""
def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
"""
Parameters
----------
s : string
Text.
loc : str
Location code.
pad : float, optional
Pad between the t... | R: "E",
CL: "W",
CR: "E",
LC: "S",
UC: "N",
C: "C"}
c = anchor_coefs[loc]
container = parentbbox.padded(-borderpad)
anchored_box = bbox.anchored(c, container=container)
... | 91 | 91 | 304 | 10 | 80 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | AnchoredText | AnchoredText | 1,207 | 1,253 | 1,207 | 1,207 | 8d206549aa5f3a67c53d29077211f26767e7f44b | bigcode/the-stack | train |
96e9dde69717ed3e44a20662 | train | class | class DrawingArea(OffsetBox):
"""
The DrawingArea can contain any Artist as a child. The DrawingArea
has a fixed width and height. The position of children relative to
the parent is fixed. The children can be clipped at the
boundaries of the parent.
"""
def __init__(self, width, height, xde... | class DrawingArea(OffsetBox):
| """
The DrawingArea can contain any Artist as a child. The DrawingArea
has a fixed width and height. The position of children relative to
the parent is fixed. The children can be clipped at the
boundaries of the parent.
"""
def __init__(self, width, height, xdescent=0.,
yde... | renderer):
"""
Update the location of children if necessary and draw them
to the given *renderer*.
"""
width, height, xdescent, ydescent, offsets = self.get_extent_offsets(
renderer)
px, py = self.get_offset(width... | 256 | 256 | 890 | 7 | 249 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | DrawingArea | DrawingArea | 577 | 703 | 577 | 577 | f8b61304f7bcac983e686af42bcb745968acdbd2 | bigcode/the-stack | train |
0b3392dccf1a7949e3e22a8c | train | class | class OffsetBox(martist.Artist):
"""
The OffsetBox is a simple container artist. The child artist are meant
to be drawn at a relative position to its parent.
"""
def __init__(self, *args, **kwargs):
super(OffsetBox, self).__init__(*args, **kwargs)
# Clipping has not been implemente... | class OffsetBox(martist.Artist):
| """
The OffsetBox is a simple container artist. The child artist are meant
to be drawn at a relative position to its parent.
"""
def __init__(self, *args, **kwargs):
super(OffsetBox, self).__init__(*args, **kwargs)
# Clipping has not been implemented in the OffesetBox family, so
... | : spacing between boxes
*height* : Intended total length. None if not used.
*align* : align mode. 'baseline', 'top', 'bottom', or 'center'.
"""
if height is None:
height = max([h for h, d in hd_list])
if align == "baseline":
height_descent = max([h - d for h, d in hd_list])
... | 256 | 256 | 970 | 8 | 247 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | OffsetBox | OffsetBox | 144 | 289 | 144 | 144 | ca28205ae3e9b5a68a8c819b09b8d77ae5c0dd69 | bigcode/the-stack | train |
21fee570740b727753a03576 | train | class | class OffsetImage(OffsetBox):
def __init__(self, arr,
zoom=1,
cmap=None,
norm=None,
interpolation=None,
origin=None,
filternorm=1,
filterrad=4.0,
resample=False,
d... | class OffsetImage(OffsetBox):
| def __init__(self, arr,
zoom=1,
cmap=None,
norm=None,
interpolation=None,
origin=None,
filternorm=1,
filterrad=4.0,
resample=False,
dpi_cor=True,
... | Properties`
Font properties.
Notes
-----
Other keyword parameters of `AnchoredOffsetbox` are also
allowed.
"""
if prop is None:
prop = {}
propkeys = list(six.iterkeys(prop))
badkwargs = ('ha', 'horizontalalignment', 'va', 'vertica... | 178 | 178 | 595 | 7 | 171 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | OffsetImage | OffsetImage | 1,256 | 1,355 | 1,256 | 1,256 | 979a7a867c0985c5fa5252a81d9863d9d3c82ff0 | bigcode/the-stack | train |
be798bca755f5808e5b009f3 | train | class | class VPacker(PackerBase):
"""
The VPacker has its children packed vertically. It automatically
adjust the relative positions of children in the drawing time.
"""
def __init__(self, pad=None, sep=None, width=None, height=None,
align="baseline", mode="fixed",
childre... | class VPacker(PackerBase):
| """
The VPacker has its children packed vertically. It automatically
adjust the relative positions of children in the drawing time.
"""
def __init__(self, pad=None, sep=None, width=None, height=None,
align="baseline", mode="fixed",
children=None):
"""
... | optional
Width and height of the container box, calculated if
`None`.
align : str, optional
Alignment of boxes. Can be one of ``top``, ``bottom``,
``left``, ``right``, ``center`` and ``baseline``
mode : str, optional
Packing mode.
Not... | 178 | 178 | 594 | 7 | 170 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | VPacker | VPacker | 336 | 412 | 336 | 336 | 0718bb80d495d1cd5b0e0ce104148222d5cc390e | bigcode/the-stack | train |
d956df139b9c34b105385877 | train | class | class PaddedBox(OffsetBox):
def __init__(self, child, pad=None, draw_frame=False, patch_attrs=None):
"""
*pad* : boundary pad
.. note::
*pad* need to given in points and will be
scale with the renderer dpi, while *width* and *height*
need to be in pixels.
... | class PaddedBox(OffsetBox):
| def __init__(self, child, pad=None, draw_frame=False, patch_attrs=None):
"""
*pad* : boundary pad
.. note::
*pad* need to given in points and will be
scale with the renderer dpi, while *width* and *height*
need to be in pixels.
"""
super(Padded... | s = _get_aligned_offsets(hd_list,
self.height,
self.align)
pack_list = [(w, xd) for w, h, xd, yd in whd_list]
width, xoffsets_ = _get_packed_offsets(pack_list, self.width,
... | 167 | 167 | 558 | 8 | 159 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | PaddedBox | PaddedBox | 494 | 574 | 494 | 494 | 077775f58c98e092a21e3b09d48cb5e4ae80be79 | bigcode/the-stack | train |
080e08c06bb3c9331b81ce7c | train | class | class AnnotationBbox(martist.Artist, _AnnotationBase):
"""
Annotation-like class, but with offsetbox instead of Text.
"""
zorder = 3
def __str__(self):
return "AnnotationBbox(%g,%g)" % (self.xy[0], self.xy[1])
@docstring.dedent_interpd
def __init__(self, offsetbox, xy,
... | class AnnotationBbox(martist.Artist, _AnnotationBase):
| """
Annotation-like class, but with offsetbox instead of Text.
"""
zorder = 3
def __str__(self):
return "AnnotationBbox(%g,%g)" % (self.xy[0], self.xy[1])
@docstring.dedent_interpd
def __init__(self, offsetbox, xy,
xybox=None,
xycoords='data',
... | ):
"""
return offset of the container.
"""
return self._offset
def get_children(self):
return [self.image]
def get_window_extent(self, renderer):
'''
get the bounding box in display space.
'''
w, h, xd, yd = self.get_extent(renderer)
... | 256 | 256 | 1,729 | 13 | 242 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | AnnotationBbox | AnnotationBbox | 1,358 | 1,597 | 1,358 | 1,358 | 3cbc9c18735f4c311f5c13ce3b76243272a7dfc2 | bigcode/the-stack | train |
188b186bb4ac022183495d2a | train | class | class AnchoredOffsetbox(OffsetBox):
"""
An offset box placed according to the legend location
loc. AnchoredOffsetbox has a single child. When multiple children
is needed, use other OffsetBox class to enclose them. By default,
the offset box is anchored against its parent axes. You may
explicitl... | class AnchoredOffsetbox(OffsetBox):
| """
An offset box placed according to the legend location
loc. AnchoredOffsetbox has a single child. When multiple children
is needed, use other OffsetBox class to enclose them. By default,
the offset box is anchored against its parent axes. You may
explicitly specify the bbox_to_anchor.
""... | _extent(renderer)
ox, oy = self.get_offset() # w, h, xd, yd)
return mtransforms.Bbox.from_bounds(ox - xd, oy - yd, w, h)
def get_extent(self, renderer):
# clear the offset transforms
_off = self.offset_transform.to_values() # to be restored later
self.ref_offset_transform... | 256 | 256 | 1,694 | 9 | 246 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | AnchoredOffsetbox | AnchoredOffsetbox | 980 | 1,204 | 980 | 980 | 0b0c64f24a38b20f021c176c6b448cfe0c4670f5 | bigcode/the-stack | train |
62cfe01c19a1d2cae5007e49 | train | class | class DraggableBase(object):
"""
helper code for a draggable artist (legend, offsetbox)
The derived class must override following two method.
def saveoffset(self):
pass
def update_offset(self, dx, dy):
pass
*saveoffset* is called when the object is picked for dragging ... | class DraggableBase(object):
| """
helper code for a draggable artist (legend, offsetbox)
The derived class must override following two method.
def saveoffset(self):
pass
def update_offset(self, dx, dy):
pass
*saveoffset* is called when the object is picked for dragging and it is
meant to save r... | ox0, oy0), (ox1, oy1))
fs = self.prop.get_size_in_points()
mutation_scale = d.pop("mutation_scale", fs)
mutation_scale = renderer.points_to_pixels(mutation_scale)
self.arrow_patch.set_mutation_scale(mutation_scale)
patchA = d.pop("patchA", self.patch)
... | 239 | 239 | 799 | 6 | 232 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | DraggableBase | DraggableBase | 1,600 | 1,713 | 1,600 | 1,600 | e219ef3034996617d2e8086d93401c03fe4421e5 | bigcode/the-stack | train |
6cbcd6ad0d1ea44913dde752 | train | class | class DraggableOffsetBox(DraggableBase):
def __init__(self, ref_artist, offsetbox, use_blit=False):
DraggableBase.__init__(self, ref_artist, use_blit=use_blit)
self.offsetbox = offsetbox
def save_offset(self):
offsetbox = self.offsetbox
renderer = offsetbox.figure._cachedRendere... | class DraggableOffsetBox(DraggableBase):
| def __init__(self, ref_artist, offsetbox, use_blit=False):
DraggableBase.__init__(self, ref_artist, use_blit=use_blit)
self.offsetbox = offsetbox
def save_offset(self):
offsetbox = self.offsetbox
renderer = offsetbox.figure._cachedRenderer
w, h, xd, yd = offsetbox.get_ex... |
else:
self.canvas.mpl_disconnect(c1)
def artist_picker(self, artist, evt):
return self.ref_artist.contains(evt)
def save_offset(self):
pass
def update_offset(self, dx, dy):
pass
def finalize_offset(self):
pass
class DraggableOffsetBox(DraggableBas... | 72 | 72 | 243 | 10 | 61 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | DraggableOffsetBox | DraggableOffsetBox | 1,716 | 1,741 | 1,716 | 1,716 | 8d202f51888251760f58bc6c4d71191c58841b5e | bigcode/the-stack | train |
3ed91e952db86e590e44bd6c | train | class | class DraggableAnnotation(DraggableBase):
def __init__(self, annotation, use_blit=False):
DraggableBase.__init__(self, annotation, use_blit=use_blit)
self.annotation = annotation
def save_offset(self):
ann = self.annotation
self.ox, self.oy = ann.get_transform().transform(ann.xy... | class DraggableAnnotation(DraggableBase):
| def __init__(self, annotation, use_blit=False):
DraggableBase.__init__(self, annotation, use_blit=use_blit)
self.annotation = annotation
def save_offset(self):
ann = self.annotation
self.ox, self.oy = ann.get_transform().transform(ann.xyann)
def update_offset(self, dx, dy):... | renderer = offsetbox.figure._cachedRenderer
w, h, xd, yd = offsetbox.get_extent(renderer)
ox, oy = offsetbox._offset
loc_in_canvas = (ox - xd, oy - yd)
return loc_in_canvas
class DraggableAnnotation(DraggableBase):
| 64 | 64 | 123 | 9 | 54 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | DraggableAnnotation | DraggableAnnotation | 1,744 | 1,756 | 1,744 | 1,744 | 4ec1b53532cd6cc496c430e151fa6948c7435464 | bigcode/the-stack | train |
824912e18972e0c52f319f32 | train | class | class TextArea(OffsetBox):
"""
The TextArea is contains a single Text instance. The text is
placed at (0,0) with baseline+left alignment. The width and height
of the TextArea instance is the width and height of the its child
text.
"""
def __init__(self, s,
textprops=None,
... | class TextArea(OffsetBox):
| """
The TextArea is contains a single Text instance. The text is
placed at (0,0) with baseline+left alignment. The width and height
of the TextArea instance is the width and height of the its child
text.
"""
def __init__(self, s,
textprops=None,
multilinebas... | self._children.append(a)
if not a.is_transform_set():
a.set_transform(self.get_transform())
if self.axes is not None:
a.axes = self.axes
fig = self.figure
if fig is not None:
a.set_figure(fig)
def draw(self, renderer):
"""
Draw th... | 256 | 256 | 1,076 | 7 | 248 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | TextArea | TextArea | 706 | 870 | 706 | 706 | f6908e8fa28fabc797703c4ec07e2a7248d446a8 | bigcode/the-stack | train |
6cf60fd76b2d5d00c84f93de | train | function | def _get_aligned_offsets(hd_list, height, align="baseline"):
"""
Given a list of (height, descent) of each boxes, align the boxes
with *align* and calculate the y-offsets of each boxes.
total width and the offset positions of each items according to
*mode*. xdescent is analogous to the usual descent... | def _get_aligned_offsets(hd_list, height, align="baseline"):
| """
Given a list of (height, descent) of each boxes, align the boxes
with *align* and calculate the y-offsets of each boxes.
total width and the offset positions of each items according to
*mode*. xdescent is analogous to the usual descent, but along the
x-direction. xdescent values are currentl... | maxh = max(w_list)
if total is None:
total = (maxh + sep) * len(w_list)
else:
sep = float(total) / (len(w_list)) - maxh
offsets = np.array([(maxh + sep) * i for i in range(len(w_list))])
return total, offsets
else:
raise ValueError("Unknown ... | 109 | 110 | 367 | 16 | 94 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | _get_aligned_offsets | _get_aligned_offsets | 107 | 141 | 107 | 107 | 8b7f58fb0f027742d0029380c8933bde36d6015c | bigcode/the-stack | train |
c21d527092ff50da46de0218 | train | class | class PackerBase(OffsetBox):
def __init__(self, pad=None, sep=None, width=None, height=None,
align=None, mode=None,
children=None):
"""
Parameters
----------
pad : float, optional
Boundary pad.
sep : float, optional
S... | class PackerBase(OffsetBox):
| def __init__(self, pad=None, sep=None, width=None, height=None,
align=None, mode=None,
children=None):
"""
Parameters
----------
pad : float, optional
Boundary pad.
sep : float, optional
Spacing between items.
... | ydescent, renderer)
for c, (ox, oy) in zip(self.get_visible_children(), offsets):
c.set_offset((px + ox, py + oy))
c.draw(renderer)
bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
self.stale = False
class PackerBase(OffsetBox):
| 75 | 75 | 252 | 8 | 66 | wfehrnstrom/harmonize | lib/python2.7/site-packages/matplotlib/offsetbox.py | Python | PackerBase | PackerBase | 292 | 333 | 292 | 292 | 8abfdc73777aec86ac8bb6f8c7665fb283916f8d | bigcode/the-stack | train |
39b56879427c9e99814333c2 | train | class | class TestOperationsCallBuilder:
def test_init(self):
builder = OperationsCallBuilder(horizon_url, client)
assert builder.endpoint == "operations"
assert builder.params == {}
def test_operation(self):
operation_id = 2243214
builder = OperationsCallBuilder(horizon_url, cl... | class TestOperationsCallBuilder:
| def test_init(self):
builder = OperationsCallBuilder(horizon_url, client)
assert builder.endpoint == "operations"
assert builder.params == {}
def test_operation(self):
operation_id = 2243214
builder = OperationsCallBuilder(horizon_url, client).operation(operation_id)
... | from stellar_sdk.call_builder.call_builder_sync import OperationsCallBuilder
from tests.call_builder.call_builder_sync import client, horizon_url
class TestOperationsCallBuilder:
| 32 | 256 | 919 | 6 | 25 | Shaptic/py-stellar-base | tests/call_builder/call_builder_sync/test_operations_call_builder.py | Python | TestOperationsCallBuilder | TestOperationsCallBuilder | 5 | 102 | 5 | 5 | cfc71f6f88bccdc1f24e68d67bfbd79bed353051 | bigcode/the-stack | train |
015de3f1a78a09c47f388d69 | train | class | class MyWidget(QWidget):
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
btn = "left button"
elif event.button() == Qt.RightButton:
btn = "right button"
elif event.button() == Qt.MidButton:
btn = "mid button"
else:
... | class MyWidget(QWidget):
| def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
btn = "left button"
elif event.button() == Qt.RightButton:
btn = "right button"
elif event.button() == Qt.MidButton:
btn = "mid button"
else:
btn = "unknown button"
... | 03/PyQt-Dessin.pdf
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QVBoxLayout
from PyQt5.QtGui import QPainter, QColor, QPen
from PyQt5.QtCore import Qt
import random
class MyWidget(QWidget):
| 64 | 64 | 169 | 5 | 58 | jeremiedecock/snippets | python/pyqt/pyqt5/widget_QPainter_mousse_event.py | Python | MyWidget | MyWidget | 13 | 34 | 13 | 14 | 35eacef0d29b267a245358e8c02b41c4ae3742c9 | bigcode/the-stack | train |
f1ac4a710515930dd040624c | train | class | class V1SELinuxOptions(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.... | class V1SELinuxOptions(object):
| """NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The... | # coding: utf-8
"""
Kubernetes
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: v1.15.11
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
f... | 101 | 256 | 1,303 | 8 | 92 | jnschaeffer/kubernetes_asyncio | kubernetes_asyncio/client/models/v1_se_linux_options.py | Python | V1SELinuxOptions | V1SELinuxOptions | 21 | 206 | 21 | 21 | e526367b9cd76ebbc35877a0a4ce4010a523ea0b | bigcode/the-stack | train |
949414c42530d0af4a00d002 | train | function | def stream(grid):
for i in range(1,9):
grid[i] = np.roll(grid[i],velocity_set[i], axis = (0,1))
| def stream(grid):
| for i in range(1,9):
grid[i] = np.roll(grid[i],velocity_set[i], axis = (0,1))
| 3] + grid[6] + grid[7])) / rho
uy = ((grid[2] + grid[5] + grid[6]) - (grid[4] + grid[7] + grid[8])) / rho
return rho,ux,uy
def stream(grid):
| 64 | 64 | 35 | 4 | 59 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | stream | stream | 55 | 57 | 55 | 55 | 972b6a7072bb6640b391ea8ae6c6f17b8610a6d0 | bigcode/the-stack | train |
3b0fc516be3478a239c1be67 | train | function | def equilibrium_on_array(rho,ux,uy):
uxy_3plus = 3 * (ux + uy)
uxy_3miuns = 3 * (ux - uy)
uu = 3 * (ux * ux + uy * uy)
ux_6 = 6 * ux
uy_6 = 6 * uy
uxx_9 = 9 * ux * ux
uyy_9 = 9 * uy * uy
uxy_9 = 9 * ux * uy
return np.array([(2 * rho / 9) * (2 - uu),
(rho / 18) * ... | def equilibrium_on_array(rho,ux,uy):
| uxy_3plus = 3 * (ux + uy)
uxy_3miuns = 3 * (ux - uy)
uu = 3 * (ux * ux + uy * uy)
ux_6 = 6 * ux
uy_6 = 6 * uy
uxx_9 = 9 * ux * ux
uyy_9 = 9 * uy * uy
uxy_9 = 9 * ux * uy
return np.array([(2 * rho / 9) * (2 - uu),
(rho / 18) * (2 + ux_6 + uxx_9 - uu),
... | = np.array([[0, 1, 0, -1, 0, 1, -1, -1, 1],
[0,0,1,0,-1,1,1,-1,-1]]).T
rho_null = 1
diff = 0.001
shear_viscosity = (1/relaxation-0.5)/3
def equilibrium_on_array(rho,ux,uy):
| 96 | 96 | 320 | 11 | 84 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | equilibrium_on_array | equilibrium_on_array | 25 | 42 | 25 | 25 | f7cd810c898b7a9edf1e310573f55a1a716d9454 | bigcode/the-stack | train |
8d70500aec08d87078a257df | train | function | def poiseuille_flow():
# main code
print("Poiseuille Flow")
uw = 0.000
steps = 4000 # crashes 4533
rho_in = rho_null+diff
rho_out = rho_null-diff
# initialize
rho = np.ones((size_x+2, size_y + 2))
ux = np.zeros((size_x+2, size_y + 2))
uy = np.zeros((size_x+2, size_y + 2))
gri... | def poiseuille_flow():
# main code
| print("Poiseuille Flow")
uw = 0.000
steps = 4000 # crashes 4533
rho_in = rho_null+diff
rho_out = rho_null-diff
# initialize
rho = np.ones((size_x+2, size_y + 2))
ux = np.zeros((size_x+2, size_y + 2))
uy = np.zeros((size_x+2, size_y + 2))
grid = equilibrium_on_array(rho, ux, uy)
... | plot_every = plot_every*2
plt.plot(ux[50, 1:-1],label = "Step {}".format(i))
# visualize
#
x = np.arange(0,50)
y = uw*1/50*x
plt.plot(y, label ="Analytical")
plt.legend()
plt.xlabel('Position in cross section')
plt.ylabel('Velocity [m/s]')
plt.title('Couette flow')
... | 127 | 127 | 425 | 11 | 116 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | poiseuille_flow | poiseuille_flow | 129 | 169 | 129 | 130 | aeac4795b2b24b1c00158f27352b8d53558a14e9 | bigcode/the-stack | train |
10573b9153315ea9c8bbd0cf | train | function | def pouisuelle_flow_fancy():
# main code
print("Poiseuille Flow fancy")
runs = 10
uw = 0.000
steps = 5000 # crashes 4533
rho_in = rho_null + diff
rho_out = rho_null - diff
# initialize
rho = np.ones((size_x + 2, size_y + 2))
ux = np.zeros((size_x + 2, size_y + 2))
uy = np.ze... | def pouisuelle_flow_fancy():
# main code
| print("Poiseuille Flow fancy")
runs = 10
uw = 0.000
steps = 5000 # crashes 4533
rho_in = rho_null + diff
rho_out = rho_null - diff
# initialize
rho = np.ones((size_x + 2, size_y + 2))
ux = np.zeros((size_x + 2, size_y + 2))
uy = np.zeros((size_x + 2, size_y + 2))
grid = equi... | ,number_of_cuts_in_x):
point = int(i*size_x/number_of_cuts_in_x)
plt.plot(ux[point, 1:-1],label = "Calculated" )
plt.legend()
plt.xlabel('Position in cross section')
plt.ylabel('Velocity [m/s]')
plt.title('Pouisuelle flow')
savestring = "PouisuelleFlow.png"
plt.savefig(savestring... | 109 | 109 | 364 | 13 | 96 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | pouisuelle_flow_fancy | pouisuelle_flow_fancy | 171 | 210 | 171 | 172 | c7ed3f2dda921bc66c1fc55d8fc804d97d7045c2 | bigcode/the-stack | train |
a923449e94758b3eb13dbe2d | train | function | def bounce_back(grid,uw):
# baunce back without any velocity gain
# btw why am i doing this from 1:-1 ???
# rho_wall = np.average(np.sum(grid,axis=0)) # doesnt do anything
# rho_wall = grid[0,:,-2] + grid[1,:,-2] + 2* grid[2,:,2]+ grid[3,:,-2] +2*grid[5,:,-2]+2*grid[6,:,-2] # neither do you
# for bo... | def bounce_back(grid,uw):
# baunce back without any velocity gain
# btw why am i doing this from 1:-1 ???
# rho_wall = np.average(np.sum(grid,axis=0)) # doesnt do anything
# rho_wall = grid[0,:,-2] + grid[1,:,-2] + 2* grid[2,:,2]+ grid[3,:,-2] +2*grid[5,:,-2]+2*grid[6,:,-2] # neither do you
# for bo... | grid[2, 1:-1, 1] = grid[4, 1:-1, 0]
grid[5, 1:-1, 1] = grid[7, 1:-1, 0]
grid[6, 1:-1, 1] = grid[8, 1:-1, 0]
# for top y = -1
grid[4, 1:-1, -2] = grid[2, 1:-1, -1]
# grid[7, 1:-1, -2] = grid[5, 1:-1, -1] - 1 / 6 * uw * rho_wall[1:-1]
# grid[8, 1:-1, -2] = grid[6, 1:-1, -1] + 1 / 6 * uw * rho_... | def bounce_back(grid,uw):
# baunce back without any velocity gain
# btw why am i doing this from 1:-1 ???
# rho_wall = np.average(np.sum(grid,axis=0)) # doesnt do anything
# rho_wall = grid[0,:,-2] + grid[1,:,-2] + 2* grid[2,:,2]+ grid[3,:,-2] +2*grid[5,:,-2]+2*grid[6,:,-2] # neither do you
# for bo... | 122 | 120 | 401 | 122 | 0 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | bounce_back | bounce_back | 59 | 74 | 59 | 64 | b534e494a86b08ee1d7a88229bdef91042c1942c | bigcode/the-stack | train |
e6efae211a3058230f6018ee | train | function | def caluculate_real_values(grid):
rho = np.sum(grid, axis=0) # sums over each one individually
ux = ((grid[1] + grid[5] + grid[8]) - (grid[3] + grid[6] + grid[7])) / rho
uy = ((grid[2] + grid[5] + grid[6]) - (grid[4] + grid[7] + grid[8])) / rho
return rho,ux,uy
| def caluculate_real_values(grid):
| rho = np.sum(grid, axis=0) # sums over each one individually
ux = ((grid[1] + grid[5] + grid[8]) - (grid[3] + grid[6] + grid[7])) / rho
uy = ((grid[2] + grid[5] + grid[6]) - (grid[4] + grid[7] + grid[8])) / rho
return rho,ux,uy
| * (1 + uxy_3miuns - uxy_9 + uu)])
def collision(grid,rho,ux,uy):
# calculate equilibrium + apply collision
grid -= relaxation * (grid-equilibrium_on_array(rho, ux, uy))
def caluculate_real_values(grid):
| 64 | 64 | 109 | 8 | 56 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | caluculate_real_values | caluculate_real_values | 49 | 53 | 49 | 49 | 3da626759068d21f717522e75bab8d84c70b849a | bigcode/the-stack | train |
63f0c2184fafd545e5111e43 | train | function | def couette_flow():
# main code
print("couette Flow")
steps = 4000
plot_every = 10
uw = 0.1
# initialize
rho = np.ones((size_x,size_y+2))
ux = np.zeros((size_x, size_y + 2))
uy = np.zeros((size_x,size_y + 2))
grid = equilibrium_on_array(rho,ux,uy)
# loop
for i in range(... | def couette_flow():
# main code
| print("couette Flow")
steps = 4000
plot_every = 10
uw = 0.1
# initialize
rho = np.ones((size_x,size_y+2))
ux = np.zeros((size_x, size_y + 2))
uy = np.zeros((size_x,size_y + 2))
grid = equilibrium_on_array(rho,ux,uy)
# loop
for i in range(steps):
rho, ux, uy = calucu... | , :])
# outlet 3,6,7
equilibrium_out = equilibrium_on_array(rho_out, ux[1, :], uy[1, :])
# check for correct sizes
grid[:, -1, :] = equilibrium_out + (grid[:, 1, :] - equilibrium[:, 1, :])
#########
def couette_flow():
# main code
| 82 | 82 | 274 | 10 | 72 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | couette_flow | couette_flow | 93 | 127 | 93 | 94 | 2f10a90c519571dd755e0f6f625ac9ab269a7f28 | bigcode/the-stack | train |
596a3e6b50bdf52ffa9912d0 | train | function | def constant_velocity_in_boundary_flow():
print("Constant thingi")
# constants
uw = 0
# cant really go higher it just crashes :(
steps = 3000
# initilazion
rho = np.ones((size_x + 2, size_y + 2))
ux = np.zeros((size_x + 2, size_y + 2))
uy = np.zeros((size_x + 2, size_y + 2))
gri... | def constant_velocity_in_boundary_flow():
| print("Constant thingi")
# constants
uw = 0
# cant really go higher it just crashes :(
steps = 3000
# initilazion
rho = np.ones((size_x + 2, size_y + 2))
ux = np.zeros((size_x + 2, size_y + 2))
uy = np.zeros((size_x + 2, size_y + 2))
grid = equilibrium_on_array(rho, ux, uy)
... | ux[point, 1:-1], label="uw = {}".format(uw))
## end plot
plt.legend()
plt.xlabel('Position in cross section')
plt.ylabel('Velocity [m/s]')
plt.title('Pouisuelle flow with diffrent u-Walls')
savestring = "PouisuelleFlowFancy.png"
plt.savefig(savestring)
plt.show()
def constant_velocity_in... | 91 | 92 | 308 | 7 | 84 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | constant_velocity_in_boundary_flow | constant_velocity_in_boundary_flow | 216 | 249 | 216 | 216 | 9f6337cbdb7add238826a9fd8cf854ebbe163b40 | bigcode/the-stack | train |
f1e7b55bc9b135147aed61cb | train | function | def collision(grid,rho,ux,uy):
# calculate equilibrium + apply collision
grid -= relaxation * (grid-equilibrium_on_array(rho, ux, uy))
| def collision(grid,rho,ux,uy):
# calculate equilibrium + apply collision
| grid -= relaxation * (grid-equilibrium_on_array(rho, ux, uy))
| 36) * (1 - uxy_3plus + uxy_9 + uu),
(rho / 36) * (1 + uxy_3miuns - uxy_9 + uu)])
def collision(grid,rho,ux,uy):
# calculate equilibrium + apply collision
| 63 | 64 | 37 | 18 | 45 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | collision | collision | 45 | 47 | 45 | 46 | 7c480f86eaf894dac645ea2f8b301005488909da | bigcode/the-stack | train |
8c8135efa039e4fee2e7780e | train | function | def periodic_boundary_with_pressure_variations(grid,rho_in,rho_out):
# get all the values
rho, ux, uy = caluculate_real_values(grid)
equilibrium = equilibrium_on_array(rho, ux, uy)
##########
equilibrium_in = equilibrium_on_array(rho_in, ux[-2,:], uy[-2, :])
# inlet 1,5,8
grid[:, 0, :] = equ... | def periodic_boundary_with_pressure_variations(grid,rho_in,rho_out):
# get all the values
| rho, ux, uy = caluculate_real_values(grid)
equilibrium = equilibrium_on_array(rho, ux, uy)
##########
equilibrium_in = equilibrium_on_array(rho_in, ux[-2,:], uy[-2, :])
# inlet 1,5,8
grid[:, 0, :] = equilibrium_in + (grid[:, -2, :] - equilibrium[:, -2, :])
# outlet 3,6,7
equilibrium_out... | 1 / 6 * uw
grid[8, 1:-1, -2] = grid[6, 1:-1, -1] + 1 / 6 * uw
def periodic_boundary_with_pressure_variations(grid,rho_in,rho_out):
# get all the values
| 64 | 64 | 176 | 22 | 41 | pastewka/LBWithPython | simulators/SimpleFlows/PoiseuilleFlow.py | Python | periodic_boundary_with_pressure_variations | periodic_boundary_with_pressure_variations | 76 | 88 | 76 | 77 | 3ad9f0e7196ff90f1b223c6bfe88c16ffa5eafaf | bigcode/the-stack | train |
353b4ce7ebab73b486e5b39d | train | class | class TocMachine(GraphMachine):
def __init__(self, **machine_configs):
self.machine = GraphMachine(
model = self,
**machine_configs
)
# Translate function Here
def is_going_to_translation_mode(self, update, bot):
text = update.message.text
print(... | class TocMachine(GraphMachine):
| def __init__(self, **machine_configs):
self.machine = GraphMachine(
model = self,
**machine_configs
)
# Translate function Here
def is_going_to_translation_mode(self, update, bot):
text = update.message.text
print("translate detect")
if (text.... | # -*- coding: utf-8 -*-
from transitions.extensions import GraphMachine
from googletrans import Translator
from lxml import etree, html
import requests
import json
import urllib.request
import pymysql
# Machine Learning
from keras.applications import InceptionV3
from keras.applications import imagenet_utils
from ker... | 216 | 256 | 2,595 | 7 | 209 | laochanlam/Personal_Assistant | fsm.py | Python | TocMachine | TocMachine | 30 | 303 | 30 | 31 | 5d4c1f7085027ac01d44d98d124756ed8a9c7370 | bigcode/the-stack | train |
f970a32832de448ddc8f4894 | train | class | class KerasLearningCurve():
"""Keras.callback interface to draw learning curve
This attempts to dynamically construct a learning curve plot
based on the keras model configuration. This depends on `metrics`
in `model.compile()`, `epochs` and `validation_data` in
`model.fit()`.
Example:
... | class KerasLearningCurve():
| """Keras.callback interface to draw learning curve
This attempts to dynamically construct a learning curve plot
based on the keras model configuration. This depends on `metrics`
in `model.compile()`, `epochs` and `validation_data` in
`model.fit()`.
Example:
model.fit(x_train, y_train,
... |
from .plot_learning_curve import PlotLearningCurve
#import tensorflow.keras as keras
#class KerasLearningCurve(keras.callbacks.Callback):
class KerasLearningCurve():
| 34 | 256 | 1,195 | 6 | 28 | Chen-Zhao/python-lrcurve | lrcurve/keras_learning_curve.py | Python | KerasLearningCurve | KerasLearningCurve | 6 | 140 | 6 | 6 | ef25b385b5af9c78409c29019384ce4eaed58fa8 | bigcode/the-stack | train |
60d09f674f14c0e85dec2761 | train | class | class AwaitableGetWebTestResult(GetWebTestResult):
# pylint: disable=using-constant-test
def __await__(self):
if False:
yield self
return GetWebTestResult(
configuration=self.configuration,
content_validation=self.content_validation,
description=se... | class AwaitableGetWebTestResult(GetWebTestResult):
# pylint: disable=using-constant-test
| def __await__(self):
if False:
yield self
return GetWebTestResult(
configuration=self.configuration,
content_validation=self.content_validation,
description=self.description,
enabled=self.enabled,
expected_http_status_code=self.... | (name="webTestName")
def web_test_name(self) -> str:
"""
User defined name if this WebTest.
"""
return pulumi.get(self, "web_test_name")
class AwaitableGetWebTestResult(GetWebTestResult):
# pylint: disable=using-constant-test
| 64 | 64 | 208 | 23 | 41 | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/insights/v20201005preview/get_web_test.py | Python | AwaitableGetWebTestResult | AwaitableGetWebTestResult | 279 | 307 | 279 | 280 | d7409225fddf6b3fcfd0dead17e3cab1832bd7cb | bigcode/the-stack | train |
aba29e560104bcbcbbd7fc5c | train | function | def get_web_test(resource_group_name: Optional[str] = None,
web_test_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetWebTestResult:
"""
An Application Insights WebTest definition.
:param str resource_group_name: The name of the reso... | def get_web_test(resource_group_name: Optional[str] = None,
web_test_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetWebTestResult:
| """
An Application Insights WebTest definition.
:param str resource_group_name: The name of the resource group. The name is case insensitive.
:param str web_test_name: The name of the Application Insights WebTest resource.
"""
__args__ = dict()
__args__['resourceGroupName'] = resource_grou... | _state=self.provisioning_state,
request=self.request,
retry_enabled=self.retry_enabled,
s_sl_cert_remaining_lifetime_check=self.s_sl_cert_remaining_lifetime_check,
s_sl_check=self.s_sl_check,
synthetic_monitor_id=self.synthetic_monitor_id,
tags=sel... | 133 | 133 | 444 | 46 | 87 | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/insights/v20201005preview/get_web_test.py | Python | get_web_test | get_web_test | 310 | 352 | 310 | 312 | d42df82aef8a92f0c54c6e3a8ca76b2f7395b92e | bigcode/the-stack | train |
0f953ed1059463d62010741f | train | class | @pulumi.output_type
class GetWebTestResult:
"""
An Application Insights WebTest definition.
"""
def __init__(__self__, configuration=None, content_validation=None, description=None, enabled=None, expected_http_status_code=None, frequency=None, id=None, ignore_https_status_code=None, kind=None, location=... | @pulumi.output_type
class GetWebTestResult:
| """
An Application Insights WebTest definition.
"""
def __init__(__self__, configuration=None, content_validation=None, description=None, enabled=None, expected_http_status_code=None, frequency=None, id=None, ignore_https_status_code=None, kind=None, location=None, locations=None, name=None, provisionin... | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from ... import _utilities, _tables
from... | 120 | 256 | 2,320 | 12 | 108 | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/insights/v20201005preview/get_web_test.py | Python | GetWebTestResult | GetWebTestResult | 18 | 276 | 18 | 19 | 399ef1af16e591f1b87157b8d1309f2177b1e810 | bigcode/the-stack | train |
acf15ac9429a35f6d591aeda | train | function | def d21p2(puzzle_input):
p1, p2 = parse(puzzle_input)
return max(quantum(p1, 0, p2, 0, 21))
| def d21p2(puzzle_input):
| p1, p2 = parse(puzzle_input)
return max(quantum(p1, 0, p2, 0, 21))
| args, memo)
memo[args] = result
w2, w1 = result
w2s = w2s + w2
w1s = w1s + w1
return w1s, w2s
def d21p2(puzzle_input):
| 64 | 64 | 42 | 9 | 54 | aewens/aoc21 | solutions/day21.py | Python | d21p2 | d21p2 | 56 | 58 | 56 | 56 | 6425567035adfd9d81969ea041f1e3d51873d4d2 | bigcode/the-stack | train |
65329166ccbb7211f7db9c87 | train | function | def d21p1(puzzle_input):
p1, p2 = parse(puzzle_input)
dice = 1
rolls = 0
scores = 0, 0
turn = 0
while scores[0] < 1000 and scores[1] < 1000:
rolls = rolls+3
move = dice*3+3
dice = dice+3
if turn == 0:
p1 = (p1 + move) % 10
scores = scores[0... | def d21p1(puzzle_input):
| p1, p2 = parse(puzzle_input)
dice = 1
rolls = 0
scores = 0, 0
turn = 0
while scores[0] < 1000 and scores[1] < 1000:
rolls = rolls+3
move = dice*3+3
dice = dice+3
if turn == 0:
p1 = (p1 + move) % 10
scores = scores[0]+p1+1, scores[1]
... | def parse(lines):
player1 = int(lines[0].split(": ", 1)[1])-1
player2 = int(lines[1].split(": ", 1)[1])-1
return player1, player2
def d21p1(puzzle_input):
| 59 | 64 | 181 | 9 | 49 | aewens/aoc21 | solutions/day21.py | Python | d21p1 | d21p1 | 6 | 26 | 6 | 6 | 55eb9548af1a1de15ddb1d0da9f54953d13c2709 | bigcode/the-stack | train |
eea6f2fb21ae8d49144118d9 | train | function | def solve(puzzle_input):
return d21p1(puzzle_input), d21p2(puzzle_input)
| def solve(puzzle_input):
| return d21p1(puzzle_input), d21p2(puzzle_input)
| 1s + w1
return w1s, w2s
def d21p2(puzzle_input):
p1, p2 = parse(puzzle_input)
return max(quantum(p1, 0, p2, 0, 21))
def solve(puzzle_input):
| 64 | 64 | 24 | 6 | 58 | aewens/aoc21 | solutions/day21.py | Python | solve | solve | 60 | 61 | 60 | 60 | fb466ded0316abf5cc8324fe7709a3db59cbfdcf | bigcode/the-stack | train |
f1b9077cb0a2d3512399416c | train | function | def quantum(p1, s1, p2, s2, e, memo=dict()):
if s1 >= e:
return 1, 0
if s2 >= e:
return 0, 1
w1s, w2s = 0, 0
for a in range(3):
for b in range(3):
for c in range(3):
move = a+1 + b+1 + c+1
p = (p1 + move) % 10
s = s1 ... | def quantum(p1, s1, p2, s2, e, memo=dict()):
| if s1 >= e:
return 1, 0
if s2 >= e:
return 0, 1
w1s, w2s = 0, 0
for a in range(3):
for b in range(3):
for c in range(3):
move = a+1 + b+1 + c+1
p = (p1 + move) % 10
s = s1 + p + 1
args = p2, s2, p, s,... | p2 + move) % 10
scores = scores[0], scores[1]+p2+1
turn = (turn + 1) % 2
return rolls * min(scores)
def quantum(p1, s1, p2, s2, e, memo=dict()):
| 64 | 64 | 215 | 19 | 45 | aewens/aoc21 | solutions/day21.py | Python | quantum | quantum | 28 | 54 | 28 | 28 | 63e8d661dbf844520036f0d08b2430275c4ef7c3 | bigcode/the-stack | train |
ff55b2b3298bd99047a6fa73 | train | function | def parse(lines):
player1 = int(lines[0].split(": ", 1)[1])-1
player2 = int(lines[1].split(": ", 1)[1])-1
return player1, player2
| def parse(lines):
| player1 = int(lines[0].split(": ", 1)[1])-1
player2 = int(lines[1].split(": ", 1)[1])-1
return player1, player2
| def parse(lines):
| 4 | 64 | 50 | 4 | 0 | aewens/aoc21 | solutions/day21.py | Python | parse | parse | 1 | 4 | 1 | 1 | 069aae7eda67c967543eb1d18f9ac246dfdc09fb | bigcode/the-stack | train |
d6e8641abecda4d0eb39f3bc | train | class | class TestCreateEmailInput(unittest.TestCase):
"""CreateEmailInput unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test CreateEmailInput
include_option is a boolean, when False only required
... | class TestCreateEmailInput(unittest.TestCase):
| """CreateEmailInput unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test CreateEmailInput
include_option is a boolean, when False only required
params are included, when True both required ... | .com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import metal
from metal.types.create_email_input import CreateEmailInput # noqa: E501
from metal.rest import ApiException
class TestCreateEmailInput(unittest.TestCase):
| 64 | 64 | 174 | 9 | 54 | displague/metal-python | test/test_create_email_input.py | Python | TestCreateEmailInput | TestCreateEmailInput | 23 | 50 | 23 | 23 | 12016b801b2e2d3e0136ec1de3142b5b9999f27a | bigcode/the-stack | train |
b27b85f62777b868d42daf81 | train | class | class UnitTestsFreeForexApi(unittest.TestCase):
def test_current_rate_EUR_USD(self):
print('test_current_rate_EUR_USD')
url = "https://www.freeforexapi.com/api/live?pairs=EURUSD"
response = requests.request("GET", url)
rate = json.loads(response.text)['rates']['EURUSD']['rate']
... | class UnitTestsFreeForexApi(unittest.TestCase):
| def test_current_rate_EUR_USD(self):
print('test_current_rate_EUR_USD')
url = "https://www.freeforexapi.com/api/live?pairs=EURUSD"
response = requests.request("GET", url)
rate = json.loads(response.text)['rates']['EURUSD']['rate']
print("EUR_USD_rate : " + str(rate))
... | import json
import unittest
import requests
class UnitTestsFreeForexApi(unittest.TestCase):
| 19 | 221 | 737 | 10 | 8 | Jay4C/Cloud_Computing | Free_Forex_API/unit_tests.py | Python | UnitTestsFreeForexApi | UnitTestsFreeForexApi | 6 | 104 | 6 | 6 | 70d4d86c0d4c7f75f605cd705ba462c8da99b9c4 | bigcode/the-stack | train |
b08db2b833b399fd51c81f7e | train | class | class AbstractPlotRenderer(PlotComponent):
""" This is the minimal interface that all plot renderers must support.
Higher-dimensionality plot renderers can implement a richer subclass of
this abstract class.
This interface exists mostly to support the development of generic
interactors and ... | class AbstractPlotRenderer(PlotComponent):
| """ This is the minimal interface that all plot renderers must support.
Higher-dimensionality plot renderers can implement a richer subclass of
this abstract class.
This interface exists mostly to support the development of generic
interactors and plot tools.
"""
origin = Enum("b... | """ Defines a base class for plot renderers.
"""
# Enthought library imports.
from traits.api import Enum
# Local relative imports
from .plot_component import PlotComponent
class AbstractPlotRenderer(PlotComponent):
| 44 | 179 | 597 | 8 | 35 | janvonrickenbach/Chaco_wxPhoenix_py3 | chaco/abstract_plot_renderer.py | Python | AbstractPlotRenderer | AbstractPlotRenderer | 10 | 84 | 10 | 10 | 49a53e84294b01fc5abb313015747340c5505a14 | bigcode/the-stack | train |
77f0e93510b8cd3af095eb40 | train | function | def _update_file_node_stat_result(file_node: Dict, stat_result) -> Dict:
file_node["lastModified"] = _format_time(stat_result.st_mtime)
file_node["size"] = stat_result.st_size
return file_node
| def _update_file_node_stat_result(file_node: Dict, stat_result) -> Dict:
| file_node["lastModified"] = _format_time(stat_result.st_mtime)
file_node["size"] = stat_result.st_size
return file_node
| ": is_dir
}
if child_nodes is not None:
file_node["childNodes"] = child_nodes
if status is not None:
file_node["status"] = status
return file_node
def _update_file_node_stat_result(file_node: Dict, stat_result) -> Dict:
| 64 | 64 | 52 | 18 | 45 | CCI-Tools/cate | cate/webapi/websocket.py | Python | _update_file_node_stat_result | _update_file_node_stat_result | 537 | 540 | 537 | 537 | 890e5e09d3e7dfd0b4277f6176ccb081d26fe86c | bigcode/the-stack | train |
d6f1dc4090b73ea1b08ebe73 | train | class | class WebSocketService:
"""
Object which implements Cate's server-side methods.
All methods receive inputs deserialized from JSON-RPC requests and must
return JSON-serializable outputs.
:param: workspace_manager The current workspace manager.
"""
def __init__(self, workspace_manager: Work... | class WebSocketService:
| """
Object which implements Cate's server-side methods.
All methods receive inputs deserialized from JSON-RPC requests and must
return JSON-serializable outputs.
:param: workspace_manager The current workspace manager.
"""
def __init__(self, workspace_manager: WorkspaceManager):
s... | , DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import datetime
import os
import platform
from typing import List, Sequence, Optional, Any, Tuple, Dict
import xarray as xr
fr... | 256 | 256 | 4,081 | 5 | 250 | CCI-Tools/cate | cate/webapi/websocket.py | Python | WebSocketService | WebSocketService | 49 | 519 | 49 | 49 | 32c5bd0a6eece6e81c918070142eb74de1583c22 | bigcode/the-stack | train |
931a5dce389318760b673b25 | train | function | def _new_file_node(name: str,
is_dir: bool = False,
child_nodes: List[Dict] = None,
status=None) -> Dict:
file_node = {
"name": name,
"isDir": is_dir
}
if child_nodes is not None:
file_node["childNodes"] = child_nodes
if st... | def _new_file_node(name: str,
is_dir: bool = False,
child_nodes: List[Dict] = None,
status=None) -> Dict:
| file_node = {
"name": name,
"isDir": is_dir
}
if child_nodes is not None:
file_node["childNodes"] = child_nodes
if status is not None:
file_node["status"] = status
return file_node
| _file_node_stat_result(file_node, stat_result)
except OSError as error:
return _update_file_node_error(file_node, error)
def _new_file_node(name: str,
is_dir: bool = False,
child_nodes: List[Dict] = None,
status=None) -> Dict:
| 64 | 64 | 96 | 35 | 29 | CCI-Tools/cate | cate/webapi/websocket.py | Python | _new_file_node | _new_file_node | 522 | 534 | 522 | 525 | 38bb3584d85dfc6e2463717ca1649f82257f6bf4 | bigcode/the-stack | train |
bd449e15abdaf3a0e4b62987 | train | function | def _format_time(seconds):
text = datetime.datetime.fromtimestamp(seconds).isoformat()
if '.' in text:
text = text[0:text.rindex('.')]
if 'T' in text:
text = text.replace('T', ' ')
return text
| def _format_time(seconds):
| text = datetime.datetime.fromtimestamp(seconds).isoformat()
if '.' in text:
text = text[0:text.rindex('.')]
if 'T' in text:
text = text.replace('T', ' ')
return text
| file_node["size"] = stat_result.st_size
return file_node
def _update_file_node_error(file_node: Dict, error) -> Dict:
file_node["status"] = "error"
file_node["message"] = f'{error}'
return file_node
def _format_time(seconds):
| 64 | 64 | 57 | 6 | 57 | CCI-Tools/cate | cate/webapi/websocket.py | Python | _format_time | _format_time | 549 | 555 | 549 | 549 | a7c38ea550b902e825bb075cfbd365f89ffb3771 | bigcode/the-stack | train |
6c659abe813ff687ffb9e34d | train | function | def _update_file_node_error(file_node: Dict, error) -> Dict:
file_node["status"] = "error"
file_node["message"] = f'{error}'
return file_node
| def _update_file_node_error(file_node: Dict, error) -> Dict:
| file_node["status"] = "error"
file_node["message"] = f'{error}'
return file_node
| _node_stat_result(file_node: Dict, stat_result) -> Dict:
file_node["lastModified"] = _format_time(stat_result.st_mtime)
file_node["size"] = stat_result.st_size
return file_node
def _update_file_node_error(file_node: Dict, error) -> Dict:
| 64 | 64 | 42 | 16 | 47 | CCI-Tools/cate | cate/webapi/websocket.py | Python | _update_file_node_error | _update_file_node_error | 543 | 546 | 543 | 543 | 73f6bb70364e3839f873b7962d1c5f470ec429da | bigcode/the-stack | train |
81f4aa501619ddf7f86564fa | train | function | def natural_key(string_):
import re
"""See https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/"""
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)]
| def natural_key(string_):
| import re
"""See https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/"""
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)]
| def natural_key(string_):
| 6 | 64 | 59 | 6 | 0 | meramsey/python-scripts-collection | scripts/natural_sort.py | Python | natural_key | natural_key | 1 | 4 | 1 | 1 | 4b72b60d8ce9f55f5de7b63a906c0b864f3db7d6 | bigcode/the-stack | train |
c3630c32e37c106bbf099ca9 | train | class | class TableClient(AsyncTablesBaseClient): # pylint: disable=client-accepts-api-version-keyword
"""A client to interact with a specific Table in an Azure Tables account.
:ivar str account_name: The name of the Tables account.
:ivar str table_name: The name of the table.
:ivar str url: The full URL to th... | class TableClient(AsyncTablesBaseClient): # pylint: disable=client-accepts-api-version-keyword
| """A client to interact with a specific Table in an Azure Tables account.
:ivar str account_name: The name of the Tables account.
:ivar str table_name: The name of the table.
:ivar str url: The full URL to the Tables account.
"""
def __init__( # pylint: disable=missing-client-constructor-para... | azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from .._base_client import parse_connection_str
from .._entity import TableEntity
from .._generated.models import SignedIdentifier, TableProperties, QueryOptions
from .._models import TableAcce... | 256 | 256 | 5,826 | 23 | 232 | vincenttran-msft/azure-sdk-for-python | sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py | Python | TableClient | TableClient | 45 | 721 | 45 | 45 | 918b3174e1d7d46a34d71155d6303effbff6767e | bigcode/the-stack | train |
0b91f55fbd297646f659b5f1 | train | class | class AcceptedPaymentV3(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type... | class AcceptedPaymentV3(object):
| """NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The... | 93fd-4747-b229-00507bbc991f\", \"token_type\":\"bearer\", \"expires_in\":1799, \"scope\":\"...\" } ``` ## API access following authentication Following successful authentication, the value of the access_token field in the response (indicated in green above) should then be presented with all subsequent API... | 256 | 256 | 2,343 | 7 | 248 | velopaymentsapi/velo-python | velo_payments/models/accepted_payment_v3.py | Python | AcceptedPaymentV3 | AcceptedPaymentV3 | 19 | 307 | 19 | 19 | be6bcef35c62ec068d40e35a54d808ae6de0eb6d | bigcode/the-stack | train |
9bbdcf7d27bacd10bfaa19a2 | train | function | def main():
cli = argparse.ArgumentParser("Search all passwords match syllable pattern")
cli.add_argument("-i", "--input", required=False, dest="input", default=sys.stdin, type=argparse.FileType('r'),
help="input password file. one password one line")
cli.add_argument("-o", "--outpu... | def main():
| cli = argparse.ArgumentParser("Search all passwords match syllable pattern")
cli.add_argument("-i", "--input", required=False, dest="input", default=sys.stdin, type=argparse.FileType('r'),
help="input password file. one password one line")
cli.add_argument("-o", "--output", required=... | Pettern.findall(pwd.pwd)
# for subword in subwords:
# res = self.pinyinPettern.match(subword)
# if res is not None:
# pwd.pattern = res[0]+'<PinYin>'
# return True
res = self.pinyinPettern.fullmatch(pwd.pwd)
if res is None:
... | 190 | 190 | 636 | 3 | 186 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | main | main | 108 | 155 | 108 | 108 | f422b81e3d902a2322a81415d5ce9dc7a9e322d7 | bigcode/the-stack | train |
551dc6cfa9c880fd87206ed8 | train | class | class PwdFilter:
def __init__(self, block:BlockList=BlockList()):
self.block = block
self.total = 0
self.filter_number = 0
def isValid(self, pwd:Record)->bool:
return True
def filter(self, pwdList:List[Record])->List[Record]:
return list(filter(lambda x : ... | class PwdFilter:
| def __init__(self, block:BlockList=BlockList()):
self.block = block
self.total = 0
self.filter_number = 0
def isValid(self, pwd:Record)->bool:
return True
def filter(self, pwdList:List[Record])->List[Record]:
return list(filter(lambda x : self.isValid(x), p... | self.table.add(item)
def isNotBlockSegment(self, pwd:str)->bool:
if isinstance(pwd, Tuple):
pwd = pwd[0]
return pwd not in self.table
def getDefaultList(self)->List[str]:
list = []
return list
class PwdFilter:
| 64 | 64 | 158 | 5 | 58 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | PwdFilter | PwdFilter | 36 | 49 | 36 | 36 | 2bac5087827ff7dbbbd274893cb6ce1f73e79b1d | bigcode/the-stack | train |
0ecdd70d7a6c378a42f381ae | train | class | class PinYinFilter(PwdFilter):
def __init__(self, list:List[str]):
super().__init__()
self.dict = list
list = filter(lambda x : len(x) > 1, list)
self.letterPettern = re.compile(r'[A-Za-z]+')
self.pinyinPettern = re.compile('^('+'|'.join(list)+')+$')
def isValid(... | class PinYinFilter(PwdFilter):
| def __init__(self, list:List[str]):
super().__init__()
self.dict = list
list = filter(lambda x : len(x) > 1, list)
self.letterPettern = re.compile(r'[A-Za-z]+')
self.pinyinPettern = re.compile('^('+'|'.join(list)+')+$')
def isValid(self, pwd:Record):
# su... |
# return True
for check in self.checkList:
res = check.fullmatch(pwd.pwd)
if res is not None:
pwd.pattern = res.group()+'<Syllable>'
return True
return False
class PinYinFilter(PwdFilter):
| 64 | 64 | 211 | 9 | 54 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | PinYinFilter | PinYinFilter | 74 | 93 | 74 | 74 | e35cb492eba186d4b9c98212bb8768e6d4ce4278 | bigcode/the-stack | train |
246d1103854e02bc682d8cfd | train | class | class CombinationPwdFilter(PwdFilter):
def __init__(self, list:List[PwdFilter]):
super().__init__()
self.list = list
def isValid(self, pwd):
self.total += pwd.freq
for checker in self.list:
if checker.isValid(pwd):
return True
self.f... | class CombinationPwdFilter(PwdFilter):
| def __init__(self, list:List[PwdFilter]):
super().__init__()
self.list = list
def isValid(self, pwd):
self.total += pwd.freq
for checker in self.list:
if checker.isValid(pwd):
return True
self.filter_number += pwd.freq
return... | +'<PinYin>'
# return True
res = self.pinyinPettern.fullmatch(pwd.pwd)
if res is None:
return False
pwd.pattern = res.group() + '<PinYin>'
return True
class CombinationPwdFilter(PwdFilter):
| 64 | 64 | 81 | 8 | 55 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | CombinationPwdFilter | CombinationPwdFilter | 95 | 106 | 95 | 95 | ea1c66d3c93e5268b3402d7e2a6f0cd07ae3cac6 | bigcode/the-stack | train |
475529e88fa1dd314d5cc442 | train | class | class Record:
def __init__(self, pwd:str, freq:int=1):
self.pwd = pwd
self.pattern = ""
self.freq = freq
| class Record:
| def __init__(self, pwd:str, freq:int=1):
self.pwd = pwd
self.pattern = ""
self.freq = freq
| #!/usr/bin/env python3
"""
Select passwords with syllable patterns from input dataset
"""
import argparse
import json
import sys
from collections import defaultdict
from typing import TextIO, Tuple, Callable, List
import re
class Record:
| 51 | 64 | 36 | 3 | 47 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | Record | Record | 12 | 16 | 12 | 12 | abf51e543d0f6747960cbbbab23d2c3cdb4f3029 | bigcode/the-stack | train |
40cc52d5a371aee813a651ef | train | class | class SyllablePwdFilter(PwdFilter):
def __init__(self, ll:List[str]):
super().__init__()
self.dict = list
self.letterPettern = re.compile(r'[A-Za-z]+')
self.checkList = list(map(lambda s : re.compile('^'+s), ll)) + list(map(lambda s : re.compile(s+'$'), ll))
def isValid(s... | class SyllablePwdFilter(PwdFilter):
| def __init__(self, ll:List[str]):
super().__init__()
self.dict = list
self.letterPettern = re.compile(r'[A-Za-z]+')
self.checkList = list(map(lambda s : re.compile('^'+s), ll)) + list(map(lambda s : re.compile(s+'$'), ll))
def isValid(self, pwd:Record):
# subwords... | Total password checked: %d\nFilter password number: %d\nmeet pattern password: %d, %5.2f\n" % (self.total, self.filter_number, self.total-self.filter_number, (self.total-self.filter_number)/ self.total * 100))
class SyllablePwdFilter(PwdFilter):
| 66 | 66 | 220 | 10 | 56 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | SyllablePwdFilter | SyllablePwdFilter | 51 | 71 | 51 | 51 | b9b17aa73892b724e0ad2bcfef16fd15e36a50e1 | bigcode/the-stack | train |
fbbf9be7c9cdd9c817014900 | train | class | class BlockList:
def __init__(self, blocks:List[str]=[]):
self.list = self.getDefaultList()
self.list = self.list + blocks
self.table = set()
for item in self.list:
self.table.add(item)
def isNotBlockSegment(self, pwd:str)->bool:
if isinstance(pwd, T... | class BlockList:
| def __init__(self, blocks:List[str]=[]):
self.list = self.getDefaultList()
self.list = self.list + blocks
self.table = set()
for item in self.list:
self.table.add(item)
def isNotBlockSegment(self, pwd:str)->bool:
if isinstance(pwd, Tuple):
... |
import sys
from collections import defaultdict
from typing import TextIO, Tuple, Callable, List
import re
class Record:
def __init__(self, pwd:str, freq:int=1):
self.pwd = pwd
self.pattern = ""
self.freq = freq
class BlockList:
| 64 | 64 | 109 | 4 | 59 | Ming-Xu-research/CKL_PSM | pattern_recognization/syllable.py | Python | BlockList | BlockList | 18 | 33 | 18 | 18 | 3fba5b2251ce3e89bc78d4f8314d9f449d21d77e | bigcode/the-stack | train |
3d69b62700deb5c0f47d0a77 | train | class | class BaseMessage(AddressBase):
"""Base class for all message classes, abstracting out
common functionality and facilitating differences via
property and method overrides"""
def __init__(self):
super().__init__()
self._message_type_name = get_message_type_name(self.message_type)
de... | class BaseMessage(AddressBase):
| """Base class for all message classes, abstracting out
common functionality and facilitating differences via
property and method overrides"""
def __init__(self):
super().__init__()
self._message_type_name = get_message_type_name(self.message_type)
def _register(self):
"""Re... | on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------------
# pylint: disable=too-many-public-method... | 256 | 256 | 5,052 | 6 | 250 | Nonj/sawtooth-next-directory | rbac/common/base/base_message.py | Python | BaseMessage | BaseMessage | 43 | 684 | 43 | 43 | e06e639980088f3455f50cbafbee2842832877b4 | bigcode/the-stack | train |
2854c1533e13caea7140a88f | train | class | class NodeHealthEvaluation(HealthEvaluation):
"""Represents health evaluation for a node, containing information about the
data and the algorithm used by health store to evaluate health. The
evaluation is returned only when the aggregated health state is either
Error or Warning.
:param aggregated_h... | class NodeHealthEvaluation(HealthEvaluation):
| """Represents health evaluation for a node, containing information about the
data and the algorithm used by health store to evaluate health. The
evaluation is returned only when the aggregated health state is either
Error or Warning.
:param aggregated_health_state: Possible values include: 'Invalid... | # coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes ... | 93 | 116 | 388 | 8 | 84 | v-Ajnava/azure-sdk-for-python | azure-servicefabric/azure/servicefabric/models/node_health_evaluation.py | Python | NodeHealthEvaluation | NodeHealthEvaluation | 15 | 52 | 15 | 15 | 092af75e66a4fb3f549bc0806c82f55b776b1a76 | bigcode/the-stack | train |
f4b96d5e300c36ff1c553d70 | train | function | def process_recording(args, recording):
freq_center, sample_rate, sample_dtype, sample_len, _sample_type, _sample_bits = parse_filename(recording)
spectrogram_filename = replace_ext(recording, args.iext, all_ext=True)
if args.skip_exist and os.path.exists(spectrogram_filename):
print(f'skipping {rec... | def process_recording(args, recording):
| freq_center, sample_rate, sample_dtype, sample_len, _sample_type, _sample_bits = parse_filename(recording)
spectrogram_filename = replace_ext(recording, args.iext, all_ext=True)
if args.skip_exist and os.path.exists(spectrogram_filename):
print(f'skipping {recording}')
return
if is_fft(r... | _locator(plt.NullLocator())
plt.sci(im)
plt.savefig(spectrogram_filename)
# must call this in specific order to avoid pyplot leak
axes.images.remove(im)
fig.clear()
plt.close()
plt.cla()
plt.clf()
def process_recording(args, recording):
| 65 | 65 | 217 | 8 | 57 | cglewis/gamutRF | gamutrf/specgram.py | Python | process_recording | process_recording | 251 | 277 | 251 | 251 | 93334f5e9273c5dbad5c15621193d579e68a1e9a | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.