hexsha
string
size
int64
ext
string
lang
string
max_stars_repo_path
string
max_stars_repo_name
string
max_stars_repo_head_hexsha
string
max_stars_repo_licenses
list
max_stars_count
int64
max_stars_repo_stars_event_min_datetime
string
max_stars_repo_stars_event_max_datetime
string
max_issues_repo_path
string
max_issues_repo_name
string
max_issues_repo_head_hexsha
string
max_issues_repo_licenses
list
max_issues_count
int64
max_issues_repo_issues_event_min_datetime
string
max_issues_repo_issues_event_max_datetime
string
max_forks_repo_path
string
max_forks_repo_name
string
max_forks_repo_head_hexsha
string
max_forks_repo_licenses
list
max_forks_count
int64
max_forks_repo_forks_event_min_datetime
string
max_forks_repo_forks_event_max_datetime
string
content
string
avg_line_length
float64
max_line_length
int64
alphanum_fraction
float64
qsc_code_num_words_quality_signal
int64
qsc_code_num_chars_quality_signal
float64
qsc_code_mean_word_length_quality_signal
float64
qsc_code_frac_words_unique_quality_signal
float64
qsc_code_frac_chars_top_2grams_quality_signal
float64
qsc_code_frac_chars_top_3grams_quality_signal
float64
qsc_code_frac_chars_top_4grams_quality_signal
float64
qsc_code_frac_chars_dupe_5grams_quality_signal
float64
qsc_code_frac_chars_dupe_6grams_quality_signal
float64
qsc_code_frac_chars_dupe_7grams_quality_signal
float64
qsc_code_frac_chars_dupe_8grams_quality_signal
float64
qsc_code_frac_chars_dupe_9grams_quality_signal
float64
qsc_code_frac_chars_dupe_10grams_quality_signal
float64
qsc_code_frac_chars_replacement_symbols_quality_signal
float64
qsc_code_frac_chars_digital_quality_signal
float64
qsc_code_frac_chars_whitespace_quality_signal
float64
qsc_code_size_file_byte_quality_signal
float64
qsc_code_num_lines_quality_signal
float64
qsc_code_num_chars_line_max_quality_signal
float64
qsc_code_num_chars_line_mean_quality_signal
float64
qsc_code_frac_chars_alphabet_quality_signal
float64
qsc_code_frac_chars_comments_quality_signal
float64
qsc_code_cate_xml_start_quality_signal
float64
qsc_code_frac_lines_dupe_lines_quality_signal
float64
qsc_code_cate_autogen_quality_signal
float64
qsc_code_frac_lines_long_string_quality_signal
float64
qsc_code_frac_chars_string_length_quality_signal
float64
qsc_code_frac_chars_long_word_length_quality_signal
float64
qsc_code_frac_lines_string_concat_quality_signal
float64
qsc_code_cate_encoded_data_quality_signal
float64
qsc_code_frac_chars_hex_words_quality_signal
float64
qsc_code_frac_lines_prompt_comments_quality_signal
float64
qsc_code_frac_lines_assert_quality_signal
float64
qsc_codepython_cate_ast_quality_signal
float64
qsc_codepython_frac_lines_func_ratio_quality_signal
float64
qsc_codepython_cate_var_zero_quality_signal
bool
qsc_codepython_frac_lines_pass_quality_signal
float64
qsc_codepython_frac_lines_import_quality_signal
float64
qsc_codepython_frac_lines_simplefunc_quality_signal
float64
qsc_codepython_score_lines_no_logic_quality_signal
float64
qsc_codepython_frac_lines_print_quality_signal
float64
qsc_code_num_words
int64
qsc_code_num_chars
int64
qsc_code_mean_word_length
int64
qsc_code_frac_words_unique
null
qsc_code_frac_chars_top_2grams
int64
qsc_code_frac_chars_top_3grams
int64
qsc_code_frac_chars_top_4grams
int64
qsc_code_frac_chars_dupe_5grams
int64
qsc_code_frac_chars_dupe_6grams
int64
qsc_code_frac_chars_dupe_7grams
int64
qsc_code_frac_chars_dupe_8grams
int64
qsc_code_frac_chars_dupe_9grams
int64
qsc_code_frac_chars_dupe_10grams
int64
qsc_code_frac_chars_replacement_symbols
int64
qsc_code_frac_chars_digital
int64
qsc_code_frac_chars_whitespace
int64
qsc_code_size_file_byte
int64
qsc_code_num_lines
int64
qsc_code_num_chars_line_max
int64
qsc_code_num_chars_line_mean
int64
qsc_code_frac_chars_alphabet
int64
qsc_code_frac_chars_comments
int64
qsc_code_cate_xml_start
int64
qsc_code_frac_lines_dupe_lines
int64
qsc_code_cate_autogen
int64
qsc_code_frac_lines_long_string
int64
qsc_code_frac_chars_string_length
int64
qsc_code_frac_chars_long_word_length
int64
qsc_code_frac_lines_string_concat
null
qsc_code_cate_encoded_data
int64
qsc_code_frac_chars_hex_words
int64
qsc_code_frac_lines_prompt_comments
int64
qsc_code_frac_lines_assert
int64
qsc_codepython_cate_ast
int64
qsc_codepython_frac_lines_func_ratio
int64
qsc_codepython_cate_var_zero
int64
qsc_codepython_frac_lines_pass
int64
qsc_codepython_frac_lines_import
int64
qsc_codepython_frac_lines_simplefunc
int64
qsc_codepython_score_lines_no_logic
int64
qsc_codepython_frac_lines_print
int64
effective
string
hits
int64
e45d9ac1d7f7347063075b259a658688aa945eb7
415
py
Python
category/urls.py
amin-bahiraei-75/shop_back
afcc5907fe33de2db1615f14df71443d1a35bbd0
[ "MIT" ]
1
2021-12-24T15:20:37.000Z
2021-12-24T15:20:37.000Z
category/urls.py
amin-bahiraei-75/shop_back
afcc5907fe33de2db1615f14df71443d1a35bbd0
[ "MIT" ]
null
null
null
category/urls.py
amin-bahiraei-75/shop_back
afcc5907fe33de2db1615f14df71443d1a35bbd0
[ "MIT" ]
null
null
null
from django.urls import path from category.views import List,Detail,Create,Delete,Update,Search,All urlpatterns = [ path('all',All.as_view()), path('list/<int:pk>',List.as_view()), path('search/<str:pk>',Search.as_view()), path('detail/<int:pk>',Detail.as_view()), path('create', Create.as_view()), path('delete/<int:pk>', Delete.as_view()), path('update/<int:pk>', Update.as_view()), ]
34.583333
70
0.653012
62
415
4.258065
0.322581
0.159091
0.227273
0
0
0
0
0
0
0
0
0
0.120482
415
12
71
34.583333
0.723288
0
0
0
0
0
0.197115
0
0
0
0
0
0
1
0
false
0
0.181818
0
0.181818
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
e4966893077ea1b5b172e99b11516e9d34d31ec5
585
py
Python
Python/problem0852.py
1050669722/LeetCode-Answers
c8f4d1ccaac09cda63b60d75144335347b06dc81
[ "MIT" ]
null
null
null
Python/problem0852.py
1050669722/LeetCode-Answers
c8f4d1ccaac09cda63b60d75144335347b06dc81
[ "MIT" ]
null
null
null
Python/problem0852.py
1050669722/LeetCode-Answers
c8f4d1ccaac09cda63b60d75144335347b06dc81
[ "MIT" ]
null
null
null
class Solution: def peakIndexInMountainArray(self, A: List[int]) -> int: if not A: return None #前向差分 for k in range(1, len(A)-1): if A[k-1]<A[k] and A[k]>A[k+1]: return k return None #最大值 return A.index(max(A)) #二分查找 p, q = 0, len(A)-1 while p < q: k = (p+q) // 2 if A[k-1]<A[k]<A[k+1]: p = k+1 elif A[k-1]>A[k]>A[k+1]: q = k-1 else: return k return p
20.892857
60
0.362393
88
585
2.409091
0.352273
0.09434
0.084906
0.056604
0.141509
0.117925
0.075472
0.075472
0
0
0
0.044521
0.500855
585
27
61
21.666667
0.681507
0.018803
0
0.210526
0
0
0
0
0
0
0
0
0
1
0.052632
false
0
0
0
0.421053
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
e49a3917364c39b81a8dd470087dc69990edf5b7
1,431
py
Python
finace/utils/rong_city.py
pythonyhd/finace
614d98ad92e1bbaa6cf7dc1d6dfaba4f24431688
[ "Apache-2.0" ]
1
2020-08-18T01:55:14.000Z
2020-08-18T01:55:14.000Z
finace/utils/rong_city.py
pythonyhd/finace
614d98ad92e1bbaa6cf7dc1d6dfaba4f24431688
[ "Apache-2.0" ]
null
null
null
finace/utils/rong_city.py
pythonyhd/finace
614d98ad92e1bbaa6cf7dc1d6dfaba4f24431688
[ "Apache-2.0" ]
null
null
null
# -*- coding: utf-8 -*- from pymongo import MongoClient from finace import settings class SpiderCity(object): """获取所有城市列表""" def __init__(self, ip=settings.MONGODB_HOST, port=settings.MONGODB_PORT, db_name=settings.MONGO_DATA_BASE, user=settings.MONGO_USER, password=settings.MONGO_PWD): self.db_name = db_name self.connection = MongoClient(ip, port) db_auth = self.connection.admin db_auth.authenticate(user, password) self.db = self.connection[db_name] self.table = self.db[settings.MONGO_CITY] def find(self, *args): """ 指定查找,默认是pymongo.cursor.Cursor,需要遍历获取单条 :param args: 字典 :return:mongo的cursor对象 """ return self.table.find(*args) def find_all(self): """ 返回所有,默认是pymongo.cursor.Cursor,需要遍历获取单条 :return: mongo的cursor对象 """ return self.table.find({}) def count(self): """ 返回数据总量 :return: """ return self.table.find({}).count() def get(self): start_urls = [] datas = self.find_all() for data in datas: url = data.get('url') name = data.get('name') item = dict(name=name, url=url) start_urls.append(item) return start_urls if __name__ == '__main__': spider = SpiderCity() url_list = spider.get() print(url_list)
26.018182
110
0.583508
163
1,431
4.92638
0.386503
0.029888
0.05604
0.070984
0.097136
0.097136
0
0
0
0
0
0.000993
0.296296
1,431
55
111
26.018182
0.796425
0.131377
0
0
0
0
0.013193
0
0
0
0
0
0
1
0.166667
false
0.066667
0.066667
0
0.4
0.033333
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
e4a25083351a643d4c8f2b90bb9ef5552f4ba55d
483
py
Python
src/stackoverflow/56339991/tests.py
mrdulin/python-codelab
3d960a14a96b3a673b7dc2277d202069b1f8e778
[ "MIT" ]
null
null
null
src/stackoverflow/56339991/tests.py
mrdulin/python-codelab
3d960a14a96b3a673b7dc2277d202069b1f8e778
[ "MIT" ]
null
null
null
src/stackoverflow/56339991/tests.py
mrdulin/python-codelab
3d960a14a96b3a673b7dc2277d202069b1f8e778
[ "MIT" ]
3
2020-02-19T08:02:04.000Z
2021-06-08T13:27:51.000Z
import unittest from test_base import TestBaseImporter from test_child import TestChildImporter if __name__ == '__main__': test_loader = unittest.TestLoader() test_classes_to_run = [TestBaseImporter, TestChildImporter] suites_list = [] for test_class in test_classes_to_run: suite = test_loader.loadTestsFromTestCase(test_class) suites_list.append(suite) big_suite = unittest.TestSuite(suites_list) unittest.TextTestRunner().run(big_suite)
30.1875
63
0.766046
56
483
6.160714
0.482143
0.086957
0.075362
0.092754
0
0
0
0
0
0
0
0
0.163561
483
15
64
32.2
0.85396
0
0
0
0
0
0.016563
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.333333
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
e4a86bcd74faf3a16d79362c4832a1d23917c50f
3,696
py
Python
SortingComparison.py
kogol99/MSiD
bbe0ee535f785476a3fe75f0654f496c185565e4
[ "MIT" ]
null
null
null
SortingComparison.py
kogol99/MSiD
bbe0ee535f785476a3fe75f0654f496c185565e4
[ "MIT" ]
10
2020-03-15T20:17:04.000Z
2020-06-05T01:58:35.000Z
SortingComparison.py
kogol99/MSiD
bbe0ee535f785476a3fe75f0654f496c185565e4
[ "MIT" ]
37
2020-03-15T17:30:40.000Z
2020-04-11T20:16:28.000Z
from timeit import default_timer as timer import random def insertion_sort(list_to_sort): for step in range(1, len(list_to_sort)): key = list_to_sort[step] j = step - 1 while j >= 0 and list_to_sort[j] > key: list_to_sort[j + 1] = list_to_sort[j] j -= 1 list_to_sort[j + 1] = key def quick_sort(list_to_sort): def partition(sub_list, low, hi): pivot = sub_list[(low + hi) // 2] left = low right = hi while left <= right: while sub_list[left] < pivot: left += 1 while sub_list[right] > pivot: right -= 1 if left <= right: sub_list[left], sub_list[right] = sub_list[right], sub_list[left] left += 1 right -= 1 return left, right def quick_sort_fun(list_to_sort, low, hi): if low < hi: left, right = partition(list_to_sort, low, hi) quick_sort_fun(list_to_sort, low, right) quick_sort_fun(list_to_sort, left, hi) quick_sort_fun(list_to_sort, 0, len(list_to_sort) - 1) # shell sort using Knuth's sequence def shell_sort(list_to_sort): def sublist_sort(list_to_sort, start_index, gap): for i in range(start_index + gap, len(list_to_sort), gap): current_val = list_to_sort[i] index = i while index >= gap and list_to_sort[index - gap] > current_val: list_to_sort[index] = list_to_sort[index - gap] index -= gap list_to_sort[index] = current_val n = len(list_to_sort) gap = 1 while gap < n // 3: gap = 3 * gap + 1 while gap > 0: for i in range(gap): sublist_sort(list_to_sort, i, gap) gap //= 3 def heap_sort(list_to_sort): def heapify(list_to_sort, n, i): largest_index = i left_index = 2 * i + 1 right_index = 2 * i + 2 if left_index < n and list_to_sort[i] < list_to_sort[left_index]: largest_index = left_index if right_index < n and list_to_sort[largest_index] < list_to_sort[right_index]: largest_index = right_index if largest_index != i: list_to_sort[i], list_to_sort[largest_index] = list_to_sort[largest_index], list_to_sort[i] heapify(list_to_sort, n, largest_index) n = len(list_to_sort) for i in range(n, -1, -1): heapify(list_to_sort, n, i) for i in range(n - 1, 0, -1): list_to_sort[i], list_to_sort[0] = list_to_sort[0], list_to_sort[i] heapify(list_to_sort, i, 0) def benchmark_sorting_algorithms(functions_list, list_to_sort): print("BENCHMARK START (Times in ms)") def benchmark_one_function(function_to_benchmark, *arguments): start = timer() function_to_benchmark(*arguments) end = timer() print("{0}: {1}".format(function_to_benchmark.__name__, (end - start) * 1000)) for function in functions_list: benchmark_one_function(function, list_to_sort.copy()) def main(): list_to_sort_1 = [random.randint(-10000, 10000) for _ in range(10000)] list_to_sort_2 = list(range(10000)) list_to_sort_3 = list(range(10000, 0, -1)) print("Random list") benchmark_sorting_algorithms([quick_sort, heap_sort, shell_sort, insertion_sort], list_to_sort_1) print("Increasing list") benchmark_sorting_algorithms([quick_sort, heap_sort, shell_sort, insertion_sort], list_to_sort_2) print("Decreasing list") benchmark_sorting_algorithms([quick_sort, heap_sort, shell_sort, insertion_sort], list_to_sort_3) if __name__ == "__main__": main()
33.297297
103
0.619048
551
3,696
3.798548
0.130672
0.143335
0.238892
0.060201
0.466794
0.327759
0.243669
0.176302
0.113235
0.113235
0
0.026257
0.27868
3,696
110
104
33.6
0.758815
0.008929
0
0.068966
0
0
0.023491
0
0
0
0
0
0
1
0.126437
false
0
0.022989
0
0.16092
0.057471
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
e4c0d071d3b7e4c6ad479ab79343874462a2daf0
2,173
py
Python
tests/openwisp2/settings.py
MiHiR151203/django-x509
fed09c9948fb81ab79ab9e541590ce2e398dd81e
[ "BSD-3-Clause" ]
410
2016-07-18T20:07:34.000Z
2022-03-28T11:21:58.000Z
tests/openwisp2/settings.py
devkapilbansal/django-x509
fe67255028a5437ac8e918831e39698c7e6c661a
[ "BSD-3-Clause" ]
120
2016-09-13T10:36:10.000Z
2022-02-24T15:36:42.000Z
tests/openwisp2/settings.py
devkapilbansal/django-x509
fe67255028a5437ac8e918831e39698c7e6c661a
[ "BSD-3-Clause" ]
85
2016-09-05T21:36:12.000Z
2022-03-19T13:44:13.000Z
import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) DEBUG = True ALLOWED_HOSTS = [] DATABASES = { 'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'djangox509.db'} } SECRET_KEY = 'fn)t*+$)ugeyip6-#txyy$5wf2ervc0d2n#h)qb)y5@ly$t*@w' INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django_x509', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'openwisp2.urls' TIME_ZONE = 'Europe/Rome' LANGUAGE_CODE = 'en-gb' USE_TZ = True USE_I18N = False USE_L10N = False STATIC_URL = '/static/' CORS_ORIGIN_ALLOW_ALL = True TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'OPTIONS': { 'loaders': [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'openwisp_utils.loaders.DependencyLoader', ], 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, } ] if os.environ.get('SAMPLE_APP', False): INSTALLED_APPS.remove('django_x509') EXTENDED_APPS = ['django_x509'] INSTALLED_APPS.append('openwisp2.sample_x509') DJANGO_X509_CA_MODEL = 'sample_x509.Ca' DJANGO_X509_CERT_MODEL = 'sample_x509.Cert' # local settings must be imported before test runner otherwise they'll be ignored try: from local_settings import * # noqa except ImportError: pass
28.592105
81
0.678785
227
2,173
6.312775
0.537445
0.099791
0.03559
0.043266
0
0
0
0
0
0
0
0.022857
0.194662
2,173
75
82
28.973333
0.796
0.038656
0
0.032258
0
0.016129
0.529243
0.424257
0
0
0
0
0
1
0
false
0.016129
0.048387
0
0.048387
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
e4c526448ad55197755fe945ed7cc9cdffa6ce97
1,522
py
Python
setup.py
camp-zju/HHypermap
f65133f2a45188ccc91dca48ea5a7f6d5afa1c18
[ "MIT" ]
6
2018-04-17T03:07:06.000Z
2022-01-11T00:14:42.000Z
setup.py
camp-zju/HHypermap
f65133f2a45188ccc91dca48ea5a7f6d5afa1c18
[ "MIT" ]
23
2018-05-14T21:13:58.000Z
2022-03-21T22:16:40.000Z
setup.py
camp-zju/HHypermap
f65133f2a45188ccc91dca48ea5a7f6d5afa1c18
[ "MIT" ]
2
2019-09-18T05:48:03.000Z
2020-03-19T07:06:29.000Z
import os from distutils.core import setup from distutils.command.install import INSTALL_SCHEMES from setuptools import find_packages from hypermap import __version__, __description__ def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as ff: return ff.read() setup( name=__description__, version=__version__, author='', author_email='', url='https://github.com/cga-harvard/HHypermap', download_url='https://github.com/cga-harvard/HHypermap', description='Django Registry by Harvard CGA', long_description=(read('README.md')), classifiers=[ 'Development Status :: 1 - Planning', ], license="BSD", keywords="hypermap django", packages=find_packages(), include_package_data=True, install_requires=[ 'amqplib', 'arcrest', 'celery', 'Django>=1.8, <1.9a0', 'django-debug-toolbar', 'django-pagination', 'django-taggit', 'django-extensions', 'dj-database-url', 'django-cache-url', 'django-basic-authentication-decorator', 'elasticsearch', 'pika', 'pycsw>=2.0.2', 'flake8', 'httmock', 'djmp>=0.2.10', 'MapProxy>=1.9', 'djangorestframework', 'django-celery', 'isodate', 'nose', 'OWSLib', 'Paver', 'Pillow', 'python-memcached', 'psycopg2', 'pysolr', 'requests', 'webtest', ] )
24.548387
70
0.581472
151
1,522
5.668874
0.635762
0.030374
0.03271
0.03972
0.084112
0.084112
0.084112
0
0
0
0
0.015371
0.273325
1,522
61
71
24.95082
0.75859
0
0
0
0
0
0.339685
0.02431
0
0
0
0
0
1
0.017544
true
0
0.087719
0
0.122807
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
1
e4d7579cdae9a7c92d24f6e21579f1d1d07cf7c1
4,054
py
Python
setup.py
crcrewso/qatrackplus
b9da3bc542d9e3eca8b7291bb631d1c7255d528e
[ "MIT" ]
20
2021-03-11T18:37:32.000Z
2022-03-23T19:38:07.000Z
setup.py
crcrewso/qatrackplus
b9da3bc542d9e3eca8b7291bb631d1c7255d528e
[ "MIT" ]
75
2021-02-12T02:37:33.000Z
2022-03-29T20:56:16.000Z
setup.py
crcrewso/qatrackplus
b9da3bc542d9e3eca8b7291bb631d1c7255d528e
[ "MIT" ]
5
2021-04-07T15:46:53.000Z
2021-09-18T16:55:00.000Z
import os import re from setuptools import find_packages, setup root = os.path.dirname(__file__) settingsf = open(os.path.join(root, 'qatrack', 'settings.py'), 'r') __version__ = re.findall(r"""VERSION\s+=\s+['"]+(.*)['"]""", settingsf.read())[0] setup( name='qatrackplus', version=__version__, packages=find_packages(exclude=["local_settings", "local_test_settings"]), include_package_data=True, description=( "QATrack+ is an open source application for managing QC data in radiotherapy and diagnostic imaging clinics" ), long_description=open('README.md').read(), zip_safe=False, url='http://qatrackplus.com/', keywords="QATrack+ medical physics TG142 quality assurance linac CT MRI radiotherapy diagnostic imaging", author='QATrack+ contributors', author_email='[email protected]', dependency_links=[ "git+https://github.com/randlet/django-genericdropdown.git@473ff52610af659f7d2a3616a6e3322e21673b4d#egg=django_genericdropdown" # noqa: E501 "git+https://github.com/randlet/django-recurrence.git@b3a73e8e03952107e58382922fec37aead31fd6f#egg=django-recurrence" # noqa: E501 "git+https://github.com/randlet/django-sql-explorer.git@12802fe83f9c45fd0bbe9610cb442dcfc5666d44#egg=django-sql-explorer" # noqa: E501 ], build_requires=[ "numpy<1.21", ], setup_requires=[ "numpy<1.21", ], install_requires=[ "django-genericdropdown", "django-recurrence", "django-sql-explorer", "black>=20.8b1,<20.9", "Django>=2.2.18,<3", "django-q>=1.3.4,<1.4", "PyVirtualDisplay>=2.0,<2.1", "beautifulsoup4>=4.9.3,<5", "concurrent-log-handler>=0.9.19,<0.10", "coreapi>=2.3.3,2.4", "coverage>=5.4,<5.5", "django-admin-views>=0.8.0,<0.9", "django-auth-adfs>=1.6.0,<1.7", "django-braces>=1.13.0,<1.14", "django-contrib-comments>=1.8.0,<1.9", "django-coverage>=1.2.4,<1.3", "django-crispy-forms>=1.6.0,<1.7", "django-debug-toolbar>=2.0,<2.1", "django-dynamic-raw-id>=2.8,<2.9", "django-extensions>=3.1.0,<3.2", "django-filter>=2.1.0,<2.2", "django-form-utils>=1.0.3,<1.1", "django-formtools>=2.1,<2.2", "django-listable>=0.5.0,<0.6", "django-mptt>=0.10.0,<0.11", "django-mptt-admin>=0.7.2,<0.8", "django-picklefield>=2.0,<2.1", "django-registration>=3.1.1,<3.2", "djangorestframework>=3.12.2,<3.13", "djangorestframework-filters>=1.0.0_dev0,<1.1", "django-widget-tweaks>=1.4.1,<1.5", "freezegun>=0.3.15,<0.4", "html5lib>=1.1,<1.2", "markdown>=2.6.11,<2.7", "matplotlib>=2.2.2,<2.3", "numpy>=1.20.0,<1.21", "pandas>=1.1,<1.2", "pep8>=1.7.0,<1.8", "pydicom>=2.1.2,<2.2", "pylinac-qatrackplus>=2.3.1.5", "pynliner>=0.8.0,<0.9", "pytest-cov>=2.11.1,<2.12", "pytest-django>=4.1.0,<4.2", "pytest-sugar>=0.9.4,<0.10", "pytest>=6.2.2,<6.3", "python-dateutil>=2.8.1,<2.9", "pytz>=2021.1", "reportlab>=3.5.59,<3.6", "requests>=2.21.0,<2.22", "scipy<=1.5.4,<1.6", "selenium>=3.141.0,<3.142", "XlsxWriter>=1.3.7,<1.4", ], license='MIT', test_suite='tests', classifiers=[ "Development Status :: 5 - Production/Stable", "Framework :: Django 1.11", "Intended Audience :: Developers", "Intended Audience :: Healthcare Industry", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python", "Programming Language :: JavaScript", "Topic :: Scientific/Engineering :: Medical Science Apps.", "Topic :: Scientific/Engineering :: Physics", "Topic :: Software Development :: Version Control :: Git", ] )
37.192661
149
0.580168
546
4,054
4.254579
0.373626
0.007749
0.01808
0.021954
0.068016
0.055101
0.032716
0.032716
0
0
0
0.114827
0.218056
4,054
108
150
37.537037
0.617981
0.007893
0
0.058252
0
0.029126
0.624938
0.263813
0
0
0
0
0
1
0
false
0
0.029126
0
0.029126
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
e4ea6b87c9f84a19ddcae37e83769662706b405e
2,164
py
Python
test_interactions.py
testlnord/bomberman
15d52073f26df970a0548e07b79514061017c73e
[ "Apache-2.0" ]
null
null
null
test_interactions.py
testlnord/bomberman
15d52073f26df970a0548e07b79514061017c73e
[ "Apache-2.0" ]
null
null
null
test_interactions.py
testlnord/bomberman
15d52073f26df970a0548e07b79514061017c73e
[ "Apache-2.0" ]
null
null
null
def player_interaction(player, object): if object[0] == 'coin': old_objects.append(object) game_objects[player]['coins'] += 1 def wave_interaction(wave, object): if object[0] == 'player' or object[0] == 'soft_wall': old_objects.append(object) ################3 old_objects = [] game_objects = { ('wall', 0): {'position': (0, 0), 'passable': False, 'interactable': False, 'char': '#'}, ('wall', 1): {'position': (0, 1), 'passable': False, 'interactable': False, 'char': '#'}, ('coin', 2): {'position': (2, 1), 'passable': True, 'interactable': True, 'char': '$'}, ('player',): {'position': (1, 1), 'passable': True, 'interactable': True, 'char': '@', 'coins': 0}, ('heatwave', 3): {'position': (2, 3), 'passable': True, 'interactable': True, 'char': '+'}, ('soft_wall', 11): {'position': (1, 4), 'passable': False, 'interactable': True, 'char': '%'} } interactions = [] interaction_funs = { 'player': player_interaction, 'heatwave': wave_interaction, } def idle_interaction(o1, o2): pass def process_interactions(): for obj1, obj2 in interactions: interaction_funs.get(obj1[0], idle_interaction)(obj1, obj2) interaction_funs.get(obj2[0], idle_interaction)(obj2, obj1) interactions.clear() interactions = [(('player', ), ('heatwave', 3))] process_interactions() assert old_objects == [('player', )] assert not interactions old_objects.clear() interactions = [(('player', ), ('coin', 2))] process_interactions() assert old_objects == [('coin', 2)] assert not interactions old_objects.clear() interactions = [(('player', ), ('wall', 0))] process_interactions() assert old_objects == [] assert not interactions old_objects.clear() interactions = [(('heatwave', 3), ('wall', 0))] process_interactions() assert old_objects == [] assert not interactions old_objects.clear() interactions = [(('wall', 1), ('heatwave', 3))] process_interactions() assert old_objects == [] assert not interactions old_objects.clear() interactions = [(('heatwave', 3), ('soft_wall', 11))] process_interactions() assert old_objects == [('soft_wall', 11)] assert not interactions
26.390244
103
0.636322
243
2,164
5.514403
0.176955
0.104478
0.11194
0.125373
0.502985
0.376119
0.326866
0.287313
0.206716
0.206716
0
0.026776
0.154344
2,164
81
104
26.716049
0.705464
0.000462
0
0.385965
0
0
0.172575
0
0
0
0
0
0.210526
1
0.070175
false
0.122807
0
0
0.070175
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
e4f1e6378706bc71078bf3d61ef72f03d3aa0d3c
3,013
py
Python
tests/test_simple_polygon.py
CompMaterSci/python-geometry
403244252b9d8521cd4d001ec63cd768d75f5393
[ "BSD-3-Clause" ]
3
2016-07-12T13:22:53.000Z
2019-09-20T07:48:02.000Z
tests/test_simple_polygon.py
CompMaterSci/python-geometry
403244252b9d8521cd4d001ec63cd768d75f5393
[ "BSD-3-Clause" ]
3
2016-12-07T07:20:33.000Z
2017-02-08T09:14:58.000Z
tests/test_simple_polygon.py
CompMaterSci/python-geometry
403244252b9d8521cd4d001ec63cd768d75f5393
[ "BSD-3-Clause" ]
5
2016-07-13T10:40:29.000Z
2020-07-01T07:20:41.000Z
# -*- coding: utf-8 -*- from numpy import array from numpy.testing import assert_allclose from python_geometry.simple_polygon import SimplePolygon class TestEquality(object): def test_SelfPolygon_ReturnTrue(self): polygon = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ]) assert polygon == polygon def test_TwoIdenticalPolygons_ReturnTrue(self): polygon_0 = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ]) polygon_1 = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ]) assert polygon_0 == polygon_1 def test_TwoEqualPolygonsWithDifferentVertexOrder_ReturnTrue(self): polygon_0 = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ]) polygon_1 = SimplePolygon( vertices=[ (1, 1, 0), (0, 1, 0), (0, 0, 0), (1, 0, 0) ]) assert polygon_0 == polygon_1 def test_TwoUnequalPolygonsWithCommonVertices_ReturnFalse(self): polygon_0 = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ]) polygon_1 = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (0, 1, 0) ]) assert not polygon_0 == polygon_1 def test_TwoUnequalPolygonsWithoutCommonVertices_ReturnFalse(self): polygon_0 = SimplePolygon( vertices=[ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ]) polygon_1 = SimplePolygon( vertices=[ (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1) ]) assert not polygon_0 == polygon_1 class TestNormalVector(object): def test_SimplePolygonNormalVector_ReturnNormalVector_0(self): simple_polygon = SimplePolygon( array([ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0) ])) expected = array([0, 0, 1]) assert_allclose(simple_polygon.normal_vector, expected) def test_SimplePolygonNormalVector_ReturnNormalVector_1(self): simple_polygon = SimplePolygon( array([ (0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0) ])) expected = array([0, 0, -1]) assert_allclose(simple_polygon.normal_vector, expected)
27.144144
71
0.419184
284
3,013
4.295775
0.133803
0.072131
0.071311
0.062295
0.62541
0.612295
0.553279
0.553279
0.455738
0.455738
0
0.09589
0.466976
3,013
110
72
27.390909
0.663761
0.00697
0
0.793814
0
0
0
0
0
0
0
0
0.082474
1
0.072165
false
0
0.030928
0
0.123711
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
900fb0840db60165c43f29441d88fb00f6f55c09
718
py
Python
fastapi_crud/fastapicrud.py
miikapo/fastapi-crud
d8517d93068b0e71fb114a695a41f48570387b9a
[ "Apache-2.0" ]
5
2021-11-02T20:13:41.000Z
2022-03-19T00:01:53.000Z
fastapi_crud/fastapicrud.py
miikapo/fastapi-crud
d8517d93068b0e71fb114a695a41f48570387b9a
[ "Apache-2.0" ]
null
null
null
fastapi_crud/fastapicrud.py
miikapo/fastapi-crud
d8517d93068b0e71fb114a695a41f48570387b9a
[ "Apache-2.0" ]
null
null
null
from fastapi import Depends from sqlalchemy.ext.asyncio import AsyncEngine from sqlalchemy.orm import sessionmaker from typing import AsyncGenerator from fastapi_crud.session import Session from fastapi_crud.router import ModelRouter from fastapi_crud.types import Model class FastapiCRUD: def __init__(self, engine: AsyncEngine) -> None: self._session_maker = sessionmaker(engine, class_=Session) self.session: Session = Depends(self._session) async def _session(self) -> AsyncGenerator[Session, None]: async with self._session_maker() as session: yield session def create_router(self, model: Model) -> ModelRouter: return ModelRouter(model, self.session)
32.636364
66
0.754875
86
718
6.127907
0.372093
0.104364
0.085389
0
0
0
0
0
0
0
0
0
0.17688
718
21
67
34.190476
0.891709
0
0
0
0
0
0
0
0
0
0
0
0
1
0.125
false
0
0.4375
0.0625
0.6875
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
901370bb81cfb113acd130dc5b682b50dbdb76b2
1,133
py
Python
NLP/DuSQL-Baseline/text2sql/models/grammar/__init__.py
pkulzb/Research
88da4910a356f1e95e1e1e05316500055533683d
[ "Apache-2.0" ]
53
2020-03-31T16:20:53.000Z
2021-11-16T11:48:38.000Z
NLP/DuSQL-Baseline/text2sql/models/grammar/__init__.py
pkulzb/Research
88da4910a356f1e95e1e1e05316500055533683d
[ "Apache-2.0" ]
1
2020-04-06T08:10:12.000Z
2020-04-06T08:10:12.000Z
NLP/DuSQL-Baseline/text2sql/models/grammar/__init__.py
pkulzb/Research
88da4910a356f1e95e1e1e05316500055533683d
[ "Apache-2.0" ]
53
2020-04-01T01:59:08.000Z
2022-03-14T07:59:58.000Z
# -*- coding:utf8 -*- # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed 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. """grammar model""" from collections import namedtuple DecoderInputsWrapper = namedtuple("DecoderInputsWrapper", "input action gmr_mask") DecoderDynamicVocab = namedtuple("DecoderDynamicVocab", "table table_len column column_len value value_len column2table_mask") from text2sql.models.grammar.nets import grammar_output from text2sql.models.grammar.infer_decoder import GrammarInferDecoder from text2sql.models.grammar.dynamic_decode import decode_with_grammar
41.962963
103
0.770521
149
1,133
5.791946
0.637584
0.069525
0.062572
0.086906
0
0
0
0
0
0
0
0.013641
0.15887
1,133
26
104
43.576923
0.89192
0.54722
0
0
0
0
0.257606
0
0
0
0
0
0
1
0
false
0
0.571429
0
0.571429
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
901749f4d47b3e2fe3385b589ae5e10eae1bbab0
13,064
py
Python
mcd2c/cfile/__init__.py
Asdew95/mcd2c
bcec95276a45b4bfd90ece5569246bd5a247368b
[ "Zlib" ]
3
2020-08-18T19:11:39.000Z
2021-06-13T12:16:41.000Z
mcd2c/cfile/__init__.py
Asdew95/mcd2c
bcec95276a45b4bfd90ece5569246bd5a247368b
[ "Zlib" ]
null
null
null
mcd2c/cfile/__init__.py
Asdew95/mcd2c
bcec95276a45b4bfd90ece5569246bd5a247368b
[ "Zlib" ]
2
2021-06-13T12:16:47.000Z
2021-12-07T18:52:43.000Z
# Inspired by https://github.com/cogu/cfile c_indent_char = ' ' def set_indent_char(char): global c_indent_char c_indent_char = char class blank: def __init__(self, num=1): self.indent = 0 #Irrelevant, kept because it simplifies sequences self.num = num def __str__(self): # Sequences automatically insert one line break for each element, so # we substract one line break to account for that return (self.num - 1) * '\n' # line and its subclasses can be used as container classes for sequences, which # can span multiple lines. When used on its own though it's a single line class line: def __init__(self, elem, indent=0): self.elem = elem self._indent = 0 self.indent = indent @property def indent(self): return self._indent @indent.setter def indent(self, val): if hasattr(self.elem, 'indent'): self.elem.indent = val self._indent = val def __str__(self): return f'{c_indent_char * self.indent}{self.elem}' class statement(line): def __str__(self): return super().__str__() + ';' class returnval(line): def __str__(self): return f'{c_indent_char * self.indent}return {self.elem};' class typedef(line): def __init__(self, elem, name, indent=0): super().__init__(elem, indent) self.name = name def __str__(self): return f'{c_indent_char * self.indent}typedef {self.elem} {self.name};' class linecomment(line): def __str__(self): return f'{c_indent_char * self.indent}// {self.elem}' class include(line): def __init__(self, path, sys=False, indent=0): super().__init__( f'#include <{path}>' if sys else f'#include "{path}"', indent ) class preprocessor(line): directive = '' def __init__(self, val, indent=0): super().__init__(f'#{self.directive} {val}', indent) class define(preprocessor): directive = 'define' class indef(preprocessor): directive = 'ifndef' class endif(line): def __init__(self, indent=0): super().__init__('#endif', indent) from collections.abc import MutableSequence # Group of elements at the same indentation level class sequence(MutableSequence): def __init__(self, elems=None, indent=0): self.elems = [] if elems is None else elems self._indent = indent self.indent = indent def __getitem__(self, key): return self.elems[key] def __setitem__(self, key, item): if(isinstance(item, str)): item = line(item) item.indent = self.indent self.elems[key] = item def __delitem__(self, key): del self.elems[key] def __len__(self): return len(self.elems) def insert(self, key, item): if(isinstance(item, str)): item = line(item) item.indent = self.indent self.elems.insert(key, item) @property def indent(self): return self._indent @indent.setter def indent(self, val): for elem in self.elems: elem.indent = val self._indent = val def __str__(self): return '\n'.join([str(elem) for elem in self.elems]) #Like sequence, but joins on space instead of newline class linesequence(sequence): def __setitem__(self, key, item): if(isinstance(item, str)): item = line(item) item.indent = self.indent if(isinstance(item, sequence)) else 0 self.elems[key] = item def insert(self, key, item): if(isinstance(item, str)): item = line(item) item.indent = self.indent if(isinstance(item, sequence)) else 0 self.elems.insert(key, item) @property def indent(self): return self._indent @indent.setter def indent(self, val): for elem in self.elems: elem.indent = val if(isinstance(elem, sequence)) else 0 self._indent = val def __str__(self): i = c_indent_char * self.indent return i + ' '.join([str(elem) for elem in self.elems]) # Common for block comments and block scope items class _block(sequence): def __init__(self, elems=None, inner_indent=1, indent=1): self._inner_indent = inner_indent super().__init__(elems, indent) @property def inner_indent(self): return self._inner_indent @inner_indent.setter def inner_indent(self, val): for elem in self.elems: elem.indent = self._indent + val self._inner_indent = val @property def indent(self): return self._indent @indent.setter def indent(self, val): for elem in self.elems: elem.indent = val + self._inner_indent self._indent = val # Curly bracket {} grouped elements, optionally at different indentation level # Does not indent first line, that's expected to be done by a wrapping class # such as line, statement, or typedef class block(_block): def __str__(self): return f'{{\n{super().__str__()}\n{self.indent * c_indent_char}}}' # Similar to block but with block comment /* */ delimiters instead of {} # Doesn't need to be wrapped in anything to get indentation correct class blockcomment(_block): def __str__(self): i = self.indent * c_indent_char return f'{i}/*\n{super().__str__()}\n{i}*/' class blocktype(block): keyword = '' def __init__(self, name=None, elems=None, inner_indent=1, indent=0): super().__init__(indent=indent, inner_indent=inner_indent, elems=elems) self.name = name def __str__(self): if self.name: return f'{self.keyword} {self.name} {super().__str__()}' return f'{self.keyword} {super().__str__()}' class struct(blocktype): keyword = 'struct' class union(blocktype): keyword = 'union' class enum(blocktype): keyword = 'enum' def __str__(self): inner = ',\n'.join([str(elem) for elem in self.elems]) i = self.indent * c_indent_char if self.name: return f'{self.keyword} {self.name} {{\n{inner}\n{i}}}' return f'{self.keyword} {{\n{inner}\n{i}}}' class commablock(blocktype): def __str__(self): for elem in self.elems: elem.indent = self.indent + self._inner_indent inner = ',\n'.join([str(elem) for elem in self.elems]) return f'{{\n{inner}\n{self.indent * c_indent_char}}}' class conditional(block): keyword = '' def __init__(self, condition, elems=None, inner_indent=1, indent=0): super().__init__(indent=indent, inner_indent=inner_indent, elems=elems) self.condition = condition def __str__(self): i = self.indent * c_indent_char return f'{i}{self.keyword}({self.condition}) {super().__str__()}' class _unspacedconditional(block): keyword = '' def __init__(self, condition, elems=None, inner_indent=1, indent=0): super().__init__(indent=indent, inner_indent=inner_indent, elems=elems) self.condition = condition def __str__(self): return f'{self.keyword}({self.condition}) {super().__str__()}' class ifcond(conditional): keyword = 'if' class nospace_ifcond(_unspacedconditional): keyword = 'if' class elifcond(_unspacedconditional): keyword = 'else if' class elsecond(block): keyword = 'else' def __str__(self): return f'{self.keyword} {super().__str__()}' class switch(conditional): keyword = 'switch' def __str__(self): s = '' for elem in self.elems[:-1]: s += str(elem) if elem.fall and not len(elem) else f'{elem}\n' s += str(self.elems[-1]) i = self.indent * c_indent_char return f'{i}{self.keyword}({self.condition}) {{\n{s}\n{i}}}' class case(_block): def __init__(self, val, elems=None, fall=False, inner_indent=1, indent=0): super().__init__(elems, inner_indent, indent) self.val = val self.fall = fall def __str__(self): o = self.indent * c_indent_char i = (self.indent + self.inner_indent) * c_indent_char if self.fall: return f'{o}case {self.val}:\n{super().__str__()}' return f'{o}case {self.val}:\n{super().__str__()}\n{i}break;' class defaultcase(_block): def __init__(self, elems=None, fall=True, inner_indent=1, indent=0): super().__init__(elems, inner_indent, indent) self.fall = fall def __str__(self): o = self.indent * c_indent_char i = (self.indent + self.inner_indent) * c_indent_char if self.fall: return f'{o}default:\n{super().__str__()}' return f'{o}default:\n{super().__str__()}\n{i}break;' class inlineif(statement): keyword = 'if' def __init__(self, condition, elem, indent=0): super().__init__(elem, indent) self.condition = condition def __str__(self): i = c_indent_char * self.indent return i + f'{self.keyword}({self.condition}) {self.elem}' @property def indent(self): return self._indent @indent.setter def indent(self, val): self._indent = val class forloop(block): keyword = 'for' def __init__(self, vars=None, cond=None, post=None, elems=None, inner_indent=1, indent=0): super().__init__(elems, inner_indent, indent) self.vars = '' if vars is None else vars self.cond = '' if cond is None else cond self.post = '' if post is None else post def __str__(self): l1 = f'{self.vars}; {self.cond}' if self.cond else self.vars + ';' l2 = f'{l1}; {self.post}' if self.post else l1 + ';' i = self.indent * c_indent_char return f'{i}{self.keyword}({l2}) {super().__str__()}' class variable: def __init__(self, name, typename=None, array=0): self.name = name self.typename = typename self.array = array @property def decl(self): return variabledecl(self.name, self.typename, self.array) def __str__(self): return str(self.name) class variabledecl(variable): def __str__(self): if self.array: return f'{self.typename} {self.name}[{self.array}]' return f'{self.typename} {self.name}' class monop: op = '' def __init__(self, val, preop = True): self.val = val self.preop = preop def __str__(self): if self.preop: return f'{self.op}{self.val}' return f'{self.op}{self.val}' class defop(monop): op = '*' class refop(monop): op = '&' class incop(monop): op = '++' class decop(monop): op = '--' class operator: op = '' def __init__(self, lvalue, rvalue): self.lvalue = lvalue self.rvalue = rvalue def __str__(self): return f'{self.lvalue} {self.op} {self.rvalue}' class assign(operator): op = '=' class addop(operator): op = '+' class subop(operator): op = '-' class mulop(operator): op = '*' class addeq(operator): op = '+=' class subeq(operator): op = '-=' class noteq(operator): op = '!=' class eqeq(operator): op = '==' class lth(operator): op = '<' class ltheq(operator): op = '<=' class gth(operator): op = '>' class gtheq(operator): op = '>=' class wrap: def __init__(self, val, invert=False): self.val = val self.invert = invert def __str__(self): if self.invert: return f'!({self.val})' return f'({self.val})' class fcall(MutableSequence): def __init__(self, name, typename, args=None): self.name = name self.typename = typename self.args = [] if args is None else list(args) def __getitem__(self, key): return self.args[key] def __setitem__(self, key, item): self.args[key] = item def __delitem__(self, key): del self.args[key] def __len__(self): return len(self.args) def insert(self, key, item): self.args.insert(key, item) @property def decl(self): return fdecl(name, typename, [a.decl for a in self.args]) def __str__(self): a = ', '.join([str(arg) for arg in self.args]) return f'{self.name}({a})' class fdecl(fcall): def __str__(self): a = ', '.join([str(arg) for arg in self.args]) return f'{self.typename} {self.name}({a})' class _file(sequence): def __init__(self, path, elems=None): self.path = path super().__init__(elems) class cfile(_file): pass import os class hfile(_file): def __init__(self, path, elems=None, guard=None): super().__init__(path, elems) if guard is None: bn = os.path.basename(path) self.guard = f'{os.path.splitext(bn)[0].upper()}_H' else: self.guard = guard def __str__(self): t = sequence([indef(self.guard), define(self.guard), blank(2)]) t.extend(self) t.append(endif()) t.append(blank()) return str(t)
26.770492
79
0.606782
1,714
13,064
4.363477
0.132439
0.052146
0.038775
0.023533
0.526541
0.453403
0.407407
0.354593
0.332799
0.306324
0
0.003921
0.25819
13,064
487
80
26.825462
0.767826
0.063304
0
0.429752
0
0.002755
0.113975
0.039683
0
0
0
0
0
1
0.214876
false
0.002755
0.00551
0.066116
0.606061
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
90179942b479c02a62c0f83dc133fc47dd16d363
906
py
Python
typed_python/compiler/tests/subclass_of_test.py
APrioriInvestments/nativepython
94e6b09d788e49cbe34b9b0d3c948218d7a8dcc5
[ "Apache-2.0" ]
52
2019-04-12T18:07:56.000Z
2019-10-07T10:26:19.000Z
typed_python/compiler/tests/subclass_of_test.py
APrioriInvestments/nativepython
94e6b09d788e49cbe34b9b0d3c948218d7a8dcc5
[ "Apache-2.0" ]
135
2019-04-15T12:52:56.000Z
2019-10-08T18:39:58.000Z
typed_python/compiler/tests/subclass_of_test.py
APrioriInvestments/nativepython
94e6b09d788e49cbe34b9b0d3c948218d7a8dcc5
[ "Apache-2.0" ]
1
2019-04-12T13:03:38.000Z
2019-04-12T13:03:38.000Z
from typed_python import Entrypoint, SubclassOf, Class, Final, Function, ListOf class A(Class): pass class B(A): pass class C(B, Final): pass def test_can_cast_subclass_of_correctly(): @Function def f(c: SubclassOf(C)): return "C" @f.overload def f(c: SubclassOf(B)): return "B" @f.overload def f(c: SubclassOf(A)): return "A" def checkIt(): assert f(C) == "C", f(C) assert f(B) == "B", f(B) assert f(A) == "A", f(A) checkIt() Entrypoint(checkIt)() @Entrypoint def checkItList(x): res = ListOf(str)() for cls in x: res.append(f(cls)) return res assert checkItList(ListOf(SubclassOf(A))([A, B, C])) == ["A", "B", "C"] assert checkItList(ListOf(SubclassOf(B))([B, C])) == ["B", "C"] assert checkItList(ListOf(SubclassOf(C))([C])) == ["C"]
18.12
79
0.540839
123
906
3.934959
0.276423
0.020661
0.030992
0.092975
0.243802
0.243802
0
0
0
0
0
0
0.284768
906
49
80
18.489796
0.746914
0
0
0.15625
0
0
0.013245
0
0
0
0
0
0.1875
1
0.1875
false
0.09375
0.03125
0.09375
0.4375
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
901d3f9a5542e6bed0daf35f7574ccf1740c36b8
1,046
py
Python
game-watch-api/games/admin.py
fouadsan/game_watch
ca38d283ef8f55499ea520eb52a78ebfac8a77a4
[ "MIT" ]
null
null
null
game-watch-api/games/admin.py
fouadsan/game_watch
ca38d283ef8f55499ea520eb52a78ebfac8a77a4
[ "MIT" ]
null
null
null
game-watch-api/games/admin.py
fouadsan/game_watch
ca38d283ef8f55499ea520eb52a78ebfac8a77a4
[ "MIT" ]
null
null
null
from django.contrib import admin from admin_interface.models import Theme as Th from .models import Genre, Platform, Screenshot, Artwork, Mode, PlayerPerspective, Engine, Theme, Game admin.site.unregister(Th) admin.site.register(Genre) admin.site.register(Platform) admin.site.register(Mode) admin.site.register(PlayerPerspective) admin.site.register(Engine) admin.site.register(Theme) admin.site.register(Screenshot) admin.site.register(Artwork) class GameAdmin(admin.ModelAdmin): fields = ('name', 'genre', 'poster', 'platforms', 'release_date', 'is_popular', 'description', 'rating', 'developer', 'publisher', 'game_modes', 'game_engines', 'player_perspective', 'themes', 'storyline', 'screenshots', 'artworks') list_display = ('name', 'id', 'genre', 'poster_tag', 'release_date', 'is_released', 'get_users') def get_users(self, obj): return "\n".join([f'#{u.id}' for u in obj.users.all()]) get_users.short_description = 'users favorite' admin.site.register(Game, GameAdmin)
32.6875
209
0.711281
129
1,046
5.658915
0.496124
0.123288
0.209589
0
0
0
0
0
0
0
0
0
0.137667
1,046
31
210
33.741935
0.809313
0
0
0
0
0
0.220841
0
0
0
0
0
0
1
0.047619
false
0
0.142857
0.047619
0.380952
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
9021ca74c4cfd208803fde68aec8f4729d95dd36
1,156
py
Python
setup.py
loic-simon/asyncode
5f9873acf93f1a3ae6d4ca0b3dfc55acc7598969
[ "MIT" ]
1
2021-12-22T16:09:52.000Z
2021-12-22T16:09:52.000Z
setup.py
loic-simon/asyncode
5f9873acf93f1a3ae6d4ca0b3dfc55acc7598969
[ "MIT" ]
null
null
null
setup.py
loic-simon/asyncode
5f9873acf93f1a3ae6d4ca0b3dfc55acc7598969
[ "MIT" ]
null
null
null
import setuptools version = "1.0.0" with open("README.md", "r", encoding="utf-8") as fh: readme = fh.read() setuptools.setup( name="asyncode", version=version, author="Loïc Simon", author_email="[email protected]", description="Emulating Python's interactive interpreter in asynchronous contexts", long_description=readme, long_description_content_type="text/markdown", url="https://github.com/loic-simon/asyncode", py_modules=["asyncode"], classifiers=[ "Development Status :: 5 - Production/Stable", "Framework :: AsyncIO", "Intended Audience :: Developers", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Topic :: Software Development :: Interpreters", ], install_requires=[], python_requires='>=3.5', ) # python3 setup.py sdist bdist_wheel # twine upload dist/*
31.243243
86
0.634948
126
1,156
5.753968
0.65873
0.131034
0.172414
0.17931
0
0
0
0
0
0
0
0.019956
0.219723
1,156
36
87
32.111111
0.783814
0.046713
0
0
0
0
0.532302
0
0
0
0
0
0
1
0
false
0
0.033333
0
0.033333
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
902524521dfdcde30b78e79a7e608392d647a998
6,127
py
Python
modules/msa/msa/contrib/uniqauth/views.py
haoyutan/MSA-Framework
7c5553b244347f26029729161e15e60b0cc805f5
[ "MIT" ]
2
2016-11-22T11:44:52.000Z
2017-08-29T02:38:01.000Z
modules/msa/msa/contrib/uniqauth/views.py
haoyutan/MSA-Framework
7c5553b244347f26029729161e15e60b0cc805f5
[ "MIT" ]
null
null
null
modules/msa/msa/contrib/uniqauth/views.py
haoyutan/MSA-Framework
7c5553b244347f26029729161e15e60b0cc805f5
[ "MIT" ]
null
null
null
from django.contrib.auth import authenticate from msa.utils.ipware import get_ip from msa.views import LoggedAPIView from rest_framework import status from rest_framework.authentication import TokenAuthentication, BasicAuthentication from rest_framework.authtoken.models import Token from rest_framework.permissions import AllowAny, IsAuthenticated, IsAdminUser from rest_framework.response import Response from .serializers import * class Register(LoggedAPIView): authentication_classes = () permission_classes = (AllowAny,) serializer_class = RegisterSerializer def post(self, request): pp = self.serializer_class(data=request.data) if pp.is_valid(): username = pp.validated_data['username'] password = pp.validated_data['password'] if Account.objects.count() <= 0: user = User.objects.create_superuser(username=username, password=password, email=None) else: user = User.objects.create_user(username=username, password=password, email=None) account = Account(user=user) #account.save() password_history = PasswordHistory(account=account, ip=get_ip(request), password=password) password_history.save() return Response(status=status.HTTP_201_CREATED) else: raise BadRequest(pp.errors) class LogIn(LoggedAPIView): authentication_classes = () permission_classes = (AllowAny,) serializer_class = LogInSerializer def get(self, request): pp = self.serializer_class(data=request.GET) if pp.is_valid(): username = pp.validated_data['username'] password = pp.validated_data['password'] user = authenticate(username=username, password=password) if user is not None: token, created = Token.objects.get_or_create(user=user) ''' if not created: token.created = timezone.now() token.save() ''' account = Account.objects.get(user=user) access_log = AccessLog(account=account, ip=get_ip(request), token=token) access_log.save() return Response({'token': token.key}) else: raise Unauthorized() else: raise BadRequest(pp.errors) class Verify(LoggedAPIView): authentication_classes = (TokenAuthentication, BasicAuthentication) permission_classes = (IsAuthenticated,) serializer_class = None def get(self, request): return Response(status=status.HTTP_200_OK) class Password(LoggedAPIView): authentication_classes = (TokenAuthentication, BasicAuthentication) permission_classes = (IsAuthenticated,) serializer_class = PasswordSerializer def post(self, request): pp = self.serializer_class(data=request.data) if pp.is_valid(): username = pp.validated_data['username'] password_old = pp.validated_data['password_old'] password_new = pp.validated_data['password_new'] user = authenticate(username=username, password=password_old) if user is not None: user.set_password(password_new) user.save() account = Account.objects.get(user=user) #account.update = timezone.now() account.save() password_history = PasswordHistory(account=account, ip=get_ip(request), password=password_new) password_history.save() user.auth_token.delete() return Response(status=status.HTTP_202_ACCEPTED) else: raise Unauthorized() else: raise BadRequest(pp.errors) class Detail(LoggedAPIView): authentication_classes = (TokenAuthentication, BasicAuthentication) permission_classes = (IsAuthenticated,) serializer_class = AccountSerializer def get(self, request): return Response(self.serializer_class(Account.objects.get(user=request.user)).data) class Misc(LoggedAPIView): authentication_classes = (TokenAuthentication, BasicAuthentication) permission_classes = (IsAuthenticated,) serializer_class = MiscSerializer def post(self, request): pp = self.serializer_class(data=request.data) if pp.is_valid(): account = Account.objects.get(user=request.user) if account.misc: misc = json.loads(account.misc) else: misc = dict() misc[pp.validated_data['field']] = pp.validated_data['value'] account.misc = json.dumps(misc) account.save() return Response(status=status.HTTP_201_CREATED) else: raise BadRequest(pp.errors) class AdminList(LoggedAPIView): authentication_classes = (TokenAuthentication, BasicAuthentication) permission_classes = (IsAdminUser,) serializer_class = AccountSerializer def get(self, request): return Response(self.serializer_class(Account.objects.all(), many=True).data) class AdminReset(LoggedAPIView): authentication_classes = (TokenAuthentication, BasicAuthentication) permission_classes = (IsAdminUser,) serializer_class = AdminResetSerializer def put(self, request): pp = self.serializer_class(data=request.data) if pp.is_valid(): username = pp.validated_data['username'] password = pp.validated_data['password'] user = User.objects.get(username=username) user.set_password(password) user.save() account = Account.objects.get(user=user) #account.update = timezone.now() account.save() password_history = PasswordHistory(account=account, ip=get_ip(request), password=password) password_history.save() user.auth_token.delete() return Response(status=status.HTTP_202_ACCEPTED) else: raise BadRequest(pp.errors)
37.588957
110
0.647299
607
6,127
6.385502
0.172982
0.05805
0.04257
0.082043
0.714396
0.696078
0.623065
0.613777
0.564499
0.539474
0
0.003545
0.263261
6,127
162
111
37.820988
0.855117
0.012404
0
0.609375
0
0
0.016077
0
0
0
0
0
0
1
0.0625
false
0.148438
0.070313
0.023438
0.445313
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
903b18672626ab4ad3a5e3aded8aea7688abd5d5
757
py
Python
standards/tests/models.py
GROCCAD/groccad
1d461043030bebe277d74b1c9df9877436baa270
[ "MIT" ]
1
2022-03-05T03:11:51.000Z
2022-03-05T03:11:51.000Z
standards/tests/models.py
rocdata/rocserver
1d461043030bebe277d74b1c9df9877436baa270
[ "MIT" ]
null
null
null
standards/tests/models.py
rocdata/rocserver
1d461043030bebe277d74b1c9df9877436baa270
[ "MIT" ]
null
null
null
from functools import partial from django.db import models from standards.fields import CharIdField # MODEL FIXTURES ################################################################################ class CharIdModel(models.Model): field = CharIdField() class CharIdModelWithPrefix(models.Model): field = CharIdField(prefix='WP', length=10) class NullableCharIdModel(models.Model): field = CharIdField(blank=True, null=True) class PrimaryKeyCharIdModel(models.Model): id = CharIdField(primary_key=True) class RelatedToCharIdModel(models.Model): char_fk = models.ForeignKey('PrimaryKeyCharIdModel', models.CASCADE) class CharIdChildModel(PrimaryKeyCharIdModel): pass class CharIdGrandchildModel(CharIdChildModel): pass
23.65625
80
0.698811
70
757
7.528571
0.514286
0.104364
0.091082
0.1537
0
0
0
0
0
0
0
0.002999
0.11889
757
31
81
24.419355
0.787106
0.018494
0
0.117647
0
0
0.034796
0.03177
0
0
0
0
0
1
0
false
0.117647
0.176471
0
0.882353
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
5f3bba72b50ee67716dbeda71e53db5b079da28f
2,435
py
Python
Code/Python/pract_fund1_sol.py
kunal-mulki/Materials
b76bba123002972e4063b9b24cd5dc3d980e16e9
[ "MIT" ]
27
2016-12-07T17:38:41.000Z
2021-06-28T06:19:49.000Z
Code/Python/pract_fund1_sol.py
kunal-mulki/Materials
b76bba123002972e4063b9b24cd5dc3d980e16e9
[ "MIT" ]
27
2016-05-28T21:32:24.000Z
2016-12-08T16:47:09.000Z
Code/Python/pract_fund1_sol.py
NYUDataBootcamp/Materials
b76bba123002972e4063b9b24cd5dc3d980e16e9
[ "MIT" ]
50
2016-10-12T11:04:50.000Z
2021-06-01T23:24:45.000Z
""" Practice problems, Python fundamentals 1 -- Solutions @authors: Balint Szoke, Daniel Csaba @date: 06/02/2017 """ #------------------------------------------------------- # 1) Solution good_string = "Sarah's code" #or good_string = """Sarah's code""" #------------------------------------------------------- # 2) Solution i = 1234 list(str(i)) #------------------------------------------------------- # 3) Solution year = '2016' next_year = str(int(year) + 1) #------------------------------------------------------- # 4) Solution x, y = 3, 'hello' print(x, y) z = x x = y y = z print(x, y) #------------------------------------------------------- # 5) Solution name = 'Jones' print(name.upper()) #------------------------------------------------------- # 6) Solution name = 'Ulysses' print(name.count('s')) #------------------------------------------------------- # 7) Solution long_string = 'salamandroid' long_string = long_string.replace('a', '*') print(long_string) #------------------------------------------------------- # 8) Solution ll = [1, 2, 3, 4, 5] ll.reverse() print(ll) #ll.pop(1) # or better ll.pop(ll.index(4)) print(ll) ll.append(1.5) print(ll) ll.sort() print(ll) #%% #------------------------------------------------------- # 9) Solution number = "32,054.23" number_no_comma = number.replace(',', '') number_float = float(number_no_comma) print(number_float) #or print(float(number.replace(',', ''))) #------------------------------------------------------- # 10) Solution firstname_lastname = 'john_doe' firstname, lastname = firstname_lastname.split('_') Firstname = firstname.capitalize() Lastname = lastname.capitalize() print(Firstname, Lastname) #------------------------------------------------------- # 11-12) Solution l = [0, 1, 2, 4, 5] index = l.index(4) l.insert(index, 3) print(l) #------------------------------------------------------- # 13) Solution s = 'www.example.com' s = s.lstrip('w.') s = s.rstrip('.c') # or in a single line (s.lstrip('w.')).rstrip('.com') #------------------------------------------------------- # 14) Solution link = 'https://play.spotify.com/collection/albums' splitted_link = link.rsplit('/', 1) print(splitted_link[0]) #or link.rsplit('/', 1)[0] #------------------------------------------------------- # 15) Solution amount = "32.054,23" ms = amount.maketrans(',.', '.,') amount = amount.translate(ms) print(amount)
21.936937
62
0.433265
252
2,435
4.111111
0.40873
0.007722
0.026062
0.030888
0.03861
0
0
0
0
0
0
0.034275
0.113347
2,435
110
63
22.136364
0.445577
0.465708
0
0.111111
0
0
0.128674
0
0
0
0
0
0
1
0
false
0
0
0
0
0.277778
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
5f47bfe261a0653163329656400b45e38dc2e334
2,103
py
Python
tests/functional_tests/authors/test_authors_login.py
Kaique425/recipes
ab188dbe1ca3891160f65a7858613b8750faa721
[ "MIT" ]
null
null
null
tests/functional_tests/authors/test_authors_login.py
Kaique425/recipes
ab188dbe1ca3891160f65a7858613b8750faa721
[ "MIT" ]
null
null
null
tests/functional_tests/authors/test_authors_login.py
Kaique425/recipes
ab188dbe1ca3891160f65a7858613b8750faa721
[ "MIT" ]
null
null
null
import pytest from django.contrib.auth.models import User from django.urls import reverse from selenium.webdriver.common.by import By from .base import AuthorBaseFunctionalTest @pytest.mark.functional_test class AuthorLoginTest(AuthorBaseFunctionalTest): def test_user_valid_data_can_login_successfully(self): password = "testpassword" user = User.objects.create_user(username="teste123", password=password) self.browser.get(self.live_server_url + reverse("author:login")) form = self.get_form() username_field = self.get_by_id("id_username", form) password_field = self.get_by_id("id_password", form) username_field.send_keys(user.username) password_field.send_keys(password) form.submit() body = self.browser.find_element(By.TAG_NAME, "body") self.assertIn(f"Your logged as {user.username}", body.text) def test_if_login_form_is_invalid(self): self.browser.get(self.live_server_url + reverse("author:login")) form = self.browser.find_element( By.XPATH, "/html/body/main/div[1]/div/div[2]/form" ) form.click() username = self.get_by_id("id_username", form) password = self.get_by_id("id_password", form) username.send_keys(" ") password.send_keys(" ") form.submit() self.assertIn( "Invalid form data.", self.browser.find_element(By.TAG_NAME, "body").text ) def test_if_login_credentials_is_invalid(self): self.browser.get(self.live_server_url + reverse("author:login")) form = self.browser.find_element( By.XPATH, "/html/body/main/div[1]/div/div[2]/form" ) form.click() username = self.get_by_id("id_username", form) password = self.get_by_id("id_password", form) username.send_keys("invalid_username") password.send_keys("invalid_password") form.submit() self.assertIn( "Invalid password or username.", self.browser.find_element(By.TAG_NAME, "body").text, )
37.553571
85
0.661912
269
2,103
4.94052
0.256506
0.066215
0.040632
0.049661
0.576373
0.532731
0.498119
0.498119
0.422122
0.363431
0
0.004266
0.219686
2,103
55
86
38.236364
0.805606
0
0
0.375
0
0
0.152639
0.036139
0
0
0
0
0.0625
1
0.0625
false
0.1875
0.104167
0
0.1875
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
5f548523f9dcf1f62a0e2fe0f345f22d699939d1
1,728
py
Python
codejam/2020-qualification/d.py
Ashindustry007/competitive-programming
2eabd3975c029d235abb7854569593d334acae2f
[ "WTFPL" ]
506
2018-08-22T10:30:38.000Z
2022-03-31T10:01:49.000Z
codejam/2020-qualification/d.py
Ashindustry007/competitive-programming
2eabd3975c029d235abb7854569593d334acae2f
[ "WTFPL" ]
13
2019-08-07T18:31:18.000Z
2020-12-15T21:54:41.000Z
codejam/2020-qualification/d.py
Ashindustry007/competitive-programming
2eabd3975c029d235abb7854569593d334acae2f
[ "WTFPL" ]
234
2018-08-06T17:11:41.000Z
2022-03-26T10:56:42.000Z
#!/usr/bin/env python3 # https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/0000000000209a9e t, b = map(int, input().split()) for _ in range(t): xs = [None] * b q, k, k1, k2 = 0, 0, None, None def query(k): global q q += 1 print(k) r = int(input()) return r def complement(): global xs for i in range(b): if xs[i] == 0: xs[i] = 1 elif xs[i] == 1: xs[i] = 0 def solve(): print(''.join(str(x) for x in xs)) assert(input() == 'Y') while True: if q > 0 and q % 10 == 0: if k1 is not None and k2 is not None: v1 = query(k1+1) v2 = query(k2+1) if xs[k1] == v1 and xs[k2] == v2: pass elif xs[k1] != v1 and xs[k2] != v2: complement() elif xs[k1] != v1: xs = xs[::-1] complement() else: xs = xs[::-1] elif k1 is not None: v1 = query(k1+1) v1 = query(k1+1) if xs[k1] != v1: complement() else: v2 = query(k2+1) v2 = query(k2+1) if xs[k2] != v2: xs = xs[::-1] else: v1 = query(k+1) v2 = query(b-k) xs[k] = v1 xs[b-k-1] = v2 if v1 == v2 and k1 is None: k1 = k elif v1 != v2 and k2 is None: k2 = k k += 1 if k*2 == b: solve() break
27
91
0.358218
217
1,728
2.847926
0.262673
0.02589
0.038835
0.048544
0.168285
0.153722
0.153722
0
0
0
0
0.114833
0.516204
1,728
63
92
27.428571
0.624402
0.064236
0
0.263158
0
0
0.000619
0
0
0
0
0
0.017544
1
0.052632
false
0.017544
0
0
0.070175
0.035088
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
5f71554b9254c1a62eba83f18f61c6f664cfe709
2,485
py
Python
bdd/contact_stepts.py
LukinVV/python_training
9e6eb57fe9527fd591d563b4219c19e49188c4de
[ "Apache-2.0" ]
null
null
null
bdd/contact_stepts.py
LukinVV/python_training
9e6eb57fe9527fd591d563b4219c19e49188c4de
[ "Apache-2.0" ]
null
null
null
bdd/contact_stepts.py
LukinVV/python_training
9e6eb57fe9527fd591d563b4219c19e49188c4de
[ "Apache-2.0" ]
null
null
null
from pytest_bdd import given, when, then from model.contact import Contact import random @given('a contact list') def contact_list(orm): return orm.get_contact_list() @given('a contact with <firstname>, <lastname> and <address>') def new_contact(firstname, lastname, address): return Contact(firstname=firstname, lastname=lastname, address=address) @when('I add the contact to the list') def add_new_contact(app, new_contact): app.contact.create_new(new_contact) @then('the new contact list is equal to the old contact list with the added contact') def verify_contact_added(orm, contact_list, new_contact): old_contacts = contact_list new_contacts = orm.get_contact_list() old_contacts.append(new_contact) assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max) @given('a non-empty contact list') def non_empty_contact_list(app, orm): if len(orm.get_contact_list()) < 0: app.group.create_new(Contact(firstname='some firstname')) return orm.get_contact_list() @given('a random contact from the list') def random_contact(non_empty_contact_list): return random.choice(non_empty_contact_list) @when('I delete the contact from the list') def delete_contact(app, random_contact): app.contact.del_contact_by_id(random_contact.id) @then('the new contact list is equal to the old contact list without the contact') def verify_contact_del(orm, non_empty_contact_list, random_contact): old_contacts = non_empty_contact_list new_contacts = orm.get_contact_list() old_contacts.remove(random_contact) assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max) @when('I modify the contact from the list') def modify_contact(app, new_contact, random_contact): new_contact.id = random_contact.id app.contact.mod_contact_by_id(new_contact) @then('the new contact list is equal to the old contact list with the modified contact') def verify_contact_del(orm, non_empty_contact_list, random_contact, new_contact): old_contacts = non_empty_contact_list non_empty_contact_list.remove(random_contact) random_contact.firstname = new_contact.firstname random_contact.lastname = new_contact.lastname random_contact.address = new_contact.address old_contacts.append(new_contact) new_contacts = orm.get_contact_list() assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max)
42.118644
101
0.781087
382
2,485
4.793194
0.149215
0.150191
0.07373
0.093392
0.480612
0.449481
0.407974
0.345713
0.345713
0.345713
0
0.000462
0.12837
2,485
59
102
42.118644
0.844875
0
0
0.244898
0
0
0.184634
0
0
0
0
0
0.061224
1
0.204082
false
0
0.061224
0.061224
0.346939
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
5f72dad431a7abe4ecae9aa703b14fc2183ff13a
2,998
py
Python
pyv6m/ha/v6m.py
dubnom/pyv6m
d56bf3f3d39b7c2f747b08bc1974dc3dbe6ccff8
[ "MIT" ]
1
2020-02-16T00:42:17.000Z
2020-02-16T00:42:17.000Z
pyv6m/ha/v6m.py
dubnom/pyv6m
d56bf3f3d39b7c2f747b08bc1974dc3dbe6ccff8
[ "MIT" ]
null
null
null
pyv6m/ha/v6m.py
dubnom/pyv6m
d56bf3f3d39b7c2f747b08bc1974dc3dbe6ccff8
[ "MIT" ]
null
null
null
"""Component to control v6m relays and sensors. For more details about this component, please refer to the documentation at https://home-assistant.io/components/v6m/ """ import logging import voluptuous as vol from homeassistant.const import ( EVENT_HOMEASSISTANT_STOP, CONF_HOST, CONF_PORT, CONF_NAME) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['pyv6m==0.0.1'] _LOGGER = logging.getLogger(__name__) DOMAIN = 'v6m' CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Required(CONF_HOST): cv.string, vol.Required(CONF_PORT): cv.port, vol.Optional(CONF_NAME, default=DOMAIN): cv.string, }), }, extra=vol.ALLOW_EXTRA) def setup(hass, base_config): """Start V6M controller.""" from pyv6m.pyv6m import V6M class V6MController(V6M): """Interface between HASS and V6M controller.""" def __init__(self, host, port): """Host and port of the controller.""" V6M.__init__(self, host, port, self.relay_callback, self.sensor_callback) self._relay_subs = {} self._sensor_subs = {} def register_relay(self, device): """Add a device to subscribe to events.""" self._register(self._relay_subs, device) def relay_callback(self, num, old_state, new_state): """Process relay states.""" self._dispatch(self._relay_subs, num, new_state) def register_sensor(self, device): """Add a device to subscribe to events.""" self._register(self._sensor_subs, device) def sensor_callback(self, num, old_state, new_state): """Process sensor states.""" self._dispatch(self._sensor_subs, num, new_state) def _register(self, subs, device): if device.num not in subs: subs[device.num] = [] subs[device.num].append(device) def _dispatch(self, subs, num, new_state): if num in subs: for sub in subs[num]: if sub.callback(new_state): sub.schedule_update_ha_state() config = base_config.get(DOMAIN) host = config[CONF_HOST] port = config[CONF_PORT] controller = V6MController(host, port) hass.data[config[CONF_NAME]] = controller def cleanup(event): controller.close() hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup) return True class V6MDevice(): """Base class of a V6M device.""" def __init__(self, controller, num, name): """Controller, address, and name of the device.""" self._num = num self._name = name self._controller = controller @property def num(self): """Device number.""" return self._num @property def name(self): """Device name.""" return self._name @property def should_poll(self): """No need to poll.""" return False
28.552381
75
0.615744
361
2,998
4.900277
0.304709
0.027134
0.022046
0.025438
0.134539
0.134539
0.105144
0.105144
0.062182
0.062182
0
0.008272
0.274183
2,998
104
76
28.826923
0.804688
0.166111
0
0.047619
0
0
0.006165
0
0
0
0
0
0
1
0.206349
false
0
0.079365
0
0.380952
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
5f92da5358e075a34f655feb29ca353ec1f92807
2,833
py
Python
src/jenova/components/common.py
inova-tecnologias/jenova
c975f0894b8663c6a9c9fdc7fa33590a219a6ad3
[ "Apache-2.0" ]
2
2016-08-10T15:08:47.000Z
2016-10-25T14:27:51.000Z
src/jenova/components/common.py
inova-tecnologias/jenova
c975f0894b8663c6a9c9fdc7fa33590a219a6ad3
[ "Apache-2.0" ]
41
2016-08-04T20:19:49.000Z
2017-03-07T20:05:53.000Z
src/jenova/components/common.py
inova-tecnologias/jenova
c975f0894b8663c6a9c9fdc7fa33590a219a6ad3
[ "Apache-2.0" ]
3
2016-09-26T19:04:51.000Z
2017-10-26T22:13:45.000Z
import uuid, hashlib, os, yaml, logging.config, json, requests, re from bcrypt import hashpw, gensalt from collections import namedtuple from sqlalchemy import create_engine from datetime import datetime CONFIG_FILE = os.environ.get('CONFIG_PATH_FILE') ZimbraGrant = namedtuple( 'ZimbraGrant', [ 'target_name', 'target_type', 'grantee_name', 'grantee_type', 'right', 'deny' ] ) class CallLogger(object): @classmethod def logger(cls): with open(CONFIG_FILE) as f: logger_config = yaml.load(f) logging.config.dictConfig(logger_config['logger']) return logging.getLogger(os.environ.get('HOSTNAME')) logger = CallLogger.logger() class Config(object): @classmethod def load(cls): with open(CONFIG_FILE) as f: main_config = yaml.load(f) return main_config @classmethod def gen_zimbra_grants(cls, zgrants, target_name, target_dlist, grantee_type='grp'): """ :param grantee_type: usr|grp|egp|all|dom|edom|gst|key|pub|email """ result_grants = [] for zgrant in zgrants: result_grants.append( ZimbraGrant( target_name = target_name, target_type = 'domain', grantee_name = target_dlist, grantee_type = grantee_type, right = zgrant, deny = 0 ) ) return result_grants class InvalidCredentials(Exception): status_code = 400 def __init__(self, message, status_code=None): Exception.__init__(self) self.msg = message self.status_code = status_code class Security(object): def __init__(self, auth, authtoken, apikey, secretkey): self.auth = auth self.authtoken = authtoken self.apikey = apikey self.secretkey = secretkey def is_valid_credentials(self): if self.authtoken and self.is_valid_token(): return True elif self.apikey and self.secretkey: if not self.is_valid_secret_key(): raise InvalidCredentials('Wrong credentials!', 401) else: return False def is_valid_token(self): return False def is_valid_secret_key(self): return self.check_password(self.auth.secret_key, self.secretkey) @classmethod def gen_secret_key(cls, password): plain_secretkey = hashpw(password, gensalt(log_rounds=13)).split('13$')[1] hashed_secretkey = hashpw(plain_secretkey, gensalt(log_rounds=13)) return plain_secretkey, hashed_secretkey @classmethod def hash_password(cls, password): return hashpw(password, gensalt(log_rounds=13)) @classmethod def check_password(cls, hashed_password, user_password): return hashpw(user_password, hashed_password) == hashed_password @classmethod def get_jwt_skey(self): if os.environ.get('NODE_ENV') == 'development': return 'changeme' return os.environ.get('JWT_SECRET_KEY')
26.726415
85
0.693611
352
2,833
5.349432
0.335227
0.052045
0.025491
0.028678
0.1094
0.05948
0.025491
0
0
0
0
0.007117
0.206495
2,833
106
86
26.726415
0.830516
0.022238
0
0.129412
0
0
0.060617
0
0
0
0
0
0
1
0.141176
false
0.082353
0.058824
0.047059
0.4
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
5f9463815346a08c07f5a3a2ec02e760f4e9de1f
3,569
py
Python
hbutils/binary/base.py
HansBug/hbutils
6872311c8a441c5955572e0093b10189a2b90708
[ "Apache-2.0" ]
null
null
null
hbutils/binary/base.py
HansBug/hbutils
6872311c8a441c5955572e0093b10189a2b90708
[ "Apache-2.0" ]
25
2021-10-03T06:19:05.000Z
2022-03-27T12:48:57.000Z
hbutils/binary/base.py
HansBug/hbutils
6872311c8a441c5955572e0093b10189a2b90708
[ "Apache-2.0" ]
null
null
null
import struct from typing import BinaryIO class CIOType: """ Overview: Basic IO type. Used as base class of all the IO types. """ def read(self, file: BinaryIO): """ Read from binary IO object. :param file: Binary file, ``io.BytesIO`` is supported as well. :return: Reading result. .. warning:: Need to be implemented. """ raise NotImplementedError # pragma: no cover def write(self, file: BinaryIO, val): """ Write object to binary IO object. :param file: Binary file, ``io.BytesIO`` is supported as well. :param val: Object to write. .. warning:: Need to be implemented. """ raise NotImplementedError # pragma: no cover class CFixedType(CIOType): """ Overview: Type with fixed size (such as ``int``, ``uint`` and ``float``). """ def __init__(self, size: int): """ Constructor of :class:`CFixedType`. :param size: Size of the type. """ self.__size = size @property def size(self) -> int: """ Size of the given type. """ return self.__size def read(self, file: BinaryIO): raise NotImplementedError # pragma: no cover def write(self, file: BinaryIO, val): raise NotImplementedError # pragma: no cover class CRangedIntType(CFixedType): """ Overview: Type with fixed size and range (such as ``int`` and ``uint``). """ def __init__(self, size: int, minimum: int, maximum: int): """ Constructor of :class:`CRangedIntType`. :param size: Size of the type. :param minimum: Min value of the type. :param maximum: Max value of the type. """ CFixedType.__init__(self, size) self.__size = size self.__minimum = minimum self.__maximum = maximum @property def minimum(self) -> int: """ Min value of the type. """ return self.__minimum @property def maximum(self) -> int: """ Max value of the type. """ return self.__maximum def read(self, file: BinaryIO): raise NotImplementedError # pragma: no cover def write(self, file: BinaryIO, val): raise NotImplementedError # pragma: no cover class CMarkedType(CFixedType): """ Overview: Type with struct mark, which can be directly read by ``struct`` module. """ def __init__(self, mark: str, size: int): """ Constructor of :class:`CMarkedType`. :param mark: Mark of the type. :param size: Size of the type. """ CFixedType.__init__(self, size) self.__mark = mark @property def mark(self) -> str: """ Mark of the type, will be used to read from binary data with ``struct`` module. """ return self.__mark def read(self, file: BinaryIO): """ Read from binary with ``struct`` module. :param file: Binary file, ``io.BytesIO`` is supported as well. :return: Result value. """ r, = struct.unpack(self.mark, file.read(self.size)) return r def write(self, file: BinaryIO, val): """ Write value to binary IO with ``struct`` module. :param file: Binary file, ``io.BytesIO`` is supported as well. :param val: Writing value. """ file.write(struct.pack(self.mark, float(val)))
24.445205
87
0.55842
405
3,569
4.82716
0.192593
0.025575
0.041432
0.09821
0.574936
0.493095
0.436829
0.417903
0.347315
0.347315
0
0
0.330905
3,569
145
88
24.613793
0.818677
0.414682
0
0.488889
0
0
0
0
0
0
0
0
0
1
0.333333
false
0
0.044444
0
0.577778
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
5f981f7b480688c0f261ed48cbccc55b236c176c
2,266
py
Python
tests/test_statistics.py
BENR0/textory
0f81b8b6726298b9181be27da7aaac2dd25bd763
[ "MIT" ]
1
2020-07-01T14:40:10.000Z
2020-07-01T14:40:10.000Z
tests/test_statistics.py
BENR0/textory
0f81b8b6726298b9181be27da7aaac2dd25bd763
[ "MIT" ]
9
2020-02-07T11:58:51.000Z
2021-09-07T16:23:38.000Z
tests/test_statistics.py
BENR0/textory
0f81b8b6726298b9181be27da7aaac2dd25bd763
[ "MIT" ]
1
2019-11-20T05:53:13.000Z
2019-11-20T05:53:13.000Z
#! /usr/bin/python # -*- coding: utf-8 -*- import pytest import numpy as np from textory.util import neighbour_diff_squared, num_neighbours, neighbour_count, create_kernel from textory.statistics import variogram, pseudo_cross_variogram @pytest.fixture def init_np_arrays(): """Inits two random np arrays""" np.random.seed(42) n = 50 a1 = np.random.random((n,n)) * 157 a2 = np.random.random((n,n)) * 237 return a1.astype(np.float32), a2.astype(np.float32) def test_variogram(init_np_arrays): """THIS TEST ONLY COVERS THE VERSION WITH INEXACT NEIGHBOUR COUNT ON THE EDGES This test needs improvement in calculation and what is tested. Much code is shared with the "neighbour_diff_squared" test in test_util. """ a, _ = init_np_arrays tmp = np.zeros_like(a) lag = 1 lags = range(-lag, lag + 1) rows, cols = a.shape #calculate variogram difference for i in range(0, cols): for j in range(0, rows): for l in lags: for k in lags: if (i+l < 0) | (i+l >= cols) | (j+k < 0) | (j+k >= rows) | ((l == 0) & (k == 0)): continue else: tmp[i,j] += np.square((a[i, j] - a[i+l, j+k])) tmp = np.nansum(tmp) res = tmp / 40000 assert variogram(a, lag=1) == res def test_pseudo_cross_variogram(init_np_arrays): """THIS TEST ONLY COVERS THE VERSION WITH INEXACT NEIGHBOUR COUNT ON THE EDGES This test needs improvement in calculation and what is tested. Much code is shared with the "neighbour_diff_squared" test in test_util. """ a, b = init_np_arrays tmp = np.zeros_like(a) lag = 1 lags = range(-lag, lag + 1) rows, cols = a.shape #calculate variogram difference for i in range(0, cols): for j in range(0, rows): for l in lags: for k in lags: if (i+l < 0) | (i+l >= cols) | (j+k < 0) | (j+k >= rows) | ((l == 0) & (k == 0)): continue else: tmp[i,j] += np.square((a[i, j] - b[i+l, j+k])) tmp = np.nansum(tmp) res = tmp / 40000 assert pseudo_cross_variogram(a, b, lag=1) == res
27.634146
101
0.566637
339
2,266
3.693215
0.274336
0.038339
0.047923
0.023962
0.699681
0.674121
0.674121
0.674121
0.674121
0.674121
0
0.030128
0.311562
2,266
81
102
27.975309
0.772436
0.242718
0
0.577778
0
0
0
0
0
0
0
0
0.044444
1
0.066667
false
0
0.088889
0
0.177778
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
5f9c54619428b0b6d3296e3c0080e9ec17335d9c
2,807
py
Python
elecalc.py
shka86/py_calc
780167bc10e2a74741ac9620dbc859c0d310e299
[ "MIT" ]
null
null
null
elecalc.py
shka86/py_calc
780167bc10e2a74741ac9620dbc859c0d310e299
[ "MIT" ]
null
null
null
elecalc.py
shka86/py_calc
780167bc10e2a74741ac9620dbc859c0d310e299
[ "MIT" ]
null
null
null
#!/usr/bin/python3 # -*- coding: utf-8 -*- # calculation tool for a bridge circuit with two input current sources # two current sources can supply from both of top of the bridge and middle of the bridge # define the voltage name as follows: # Vp: voltage at the top of the bridge # Vn: voltage at the middle of the bridge def paraR(R1, R2): return R1*R2/(R1+R2) def unbalanced_bridge( I = 1, Ra = 1, Rb = 1, Rc = 1, Rd = 1, Re = 1, Rf = 1): print("# --- calc unbalanced bridge ---------------") # params print("I=", I, "A") print("Ra=", Ra, "ohm") print("Rb=", Rb, "ohm") print("Rc=", Rc, "ohm") print("Rd=", Rd, "ohm") print("Re=", Re, "ohm") print("Rf=", Rf, "ohm") # delta-Y transpose denom = Ra + Rb + (Rc + Rd) Ralpha = Ra * Rb / denom Rbeta = (Rc + Rd) * Ra / denom Rgamma = Rb * (Rc + Rd) / denom print("denom=", denom, "ohm") print("Ralpha=", Ralpha, "ohm") print("Rbeta=", Rbeta, "ohm") print("Rgamma=", Rgamma, "ohm") # I sprit Il = (Rgamma + Rf) / ((Rbeta + Re) + (Rgamma + Rf)) * I Ir = (Rbeta + Re) / ((Rbeta + Re) + (Rgamma + Rf)) * I print("Il=", Il, "A") print("Ir=", Ir, "A") # calc Vtop and Vmid Vl = Re * Il Vr = Rf * Ir print("Vl=", Vl, "V") print("Vr=", Vr, "V") Vtop = (Ralpha + (paraR((Rbeta + Re), (Rgamma + Rf)))) * I Vmid = (Rd * Vl + Rc * Vr) / (Rc + Rd) print("Vtop=", Vtop, "V") print("Vmid=", Vmid, "V") return Vtop, Vmid def main(): # current of two input sources current1 = 2.5e-3 current2 = 1.25e-3 # unbaranced brigde params # branch on input side Ra = 100 Rb = 100 # bridge part (series resistor) Rc = 100 Rd = 100 # branch on ground side Re = 50 Rf = 50 current1 = 2 current2 = 1 Vtop1, Vmid1 = unbalanced_bridge(current1, Ra, Rb, Rc, Rd, Re, Rf) Vtop2, Vmid2 = unbalanced_bridge(current2, Ra, Rb, Rc, Rd, Re, Rf) print("# --- sum based on superposition theorem ---------------") print("# when two current sources supply from top") Vp = Vtop1 + Vtop2 Vn = Vmid1 + Vmid2 print("Vp=", Vp, "V") print("Vn=", Vn, "V") # same meaning # unbalanced_bridge(current1+current2, Ra, Rb, Rc, Rd, Re, Rf) print("# when current1 from the top, current2 from the middle") Vp = Vtop1 + Vmid2 Vn = Vmid1 + Vtop2 print("Vp=", Vp, "V") print("Vn=", Vn, "V") print("# when current2 from the top, current1 from the middle") Vp = Vmid1 + Vtop2 Vn = Vtop1 + Vmid2 print("Vp=", Vp, "V") print("Vn=", Vn, "V") print("# when two current sources from middle") Vp = Vmid1 + Vmid2 Vn = Vtop1 + Vtop2 print("Vp=", Vp, "V") print("Vn=", Vn, "V") if __name__ == '__main__': main()
25.990741
88
0.540791
404
2,807
3.727723
0.240099
0.042497
0.01992
0.021248
0.179947
0.119522
0.111554
0.111554
0.078353
0.038513
0
0.035591
0.279302
2,807
107
89
26.233645
0.708848
0.199858
0
0.117647
0
0
0.194345
0
0
0
0
0
0
1
0.044118
false
0
0
0.014706
0.073529
0.455882
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
1
5f9d943e1c5e5e036c07d0eb1ed8c96b9fd06019
4,038
py
Python
sixx/plugins/images.py
TildeBeta/6X
1814eb8f394b7c25b49decdd7d7249567c85f30f
[ "MIT" ]
2
2018-03-06T20:39:49.000Z
2018-03-17T04:28:57.000Z
sixx/plugins/images.py
TildeBeta/TwitterImages
1814eb8f394b7c25b49decdd7d7249567c85f30f
[ "MIT" ]
2
2018-03-06T20:39:46.000Z
2018-03-15T17:03:03.000Z
sixx/plugins/images.py
TildeBeta/TwitterImages
1814eb8f394b7c25b49decdd7d7249567c85f30f
[ "MIT" ]
1
2018-04-25T22:24:40.000Z
2018-04-25T22:24:40.000Z
from math import sqrt import asks import datetime import numpy as np import random from PIL import Image from PIL.ImageDraw import Draw from PIL.ImageEnhance import Brightness from PIL.ImageFont import truetype from curio import spawn_thread from curious.commands import Context, Plugin, command from io import BytesIO from sixx.plugins.utils.pillow import add_noise, add_scanlines, antialiased_text, save_image SCANLINES, NOISE, BOTH = range(3) class Images(Plugin): """ Commands for image manipulation stuffs. """ @command() async def vcr(self, ctx: Context, *, url: str): # TODO support attachments buffer = BytesIO() resp = await asks.get(url, stream=True) async for chunk in resp.body: buffer.write(chunk) async with ctx.channel.typing: async with spawn_thread(): with Image.open(buffer) as image: filter = np.random.choice(range(3), p=[0.7, 0.2, 0.1]) if filter == SCANLINES: image = add_scanlines(image) elif filter == NOISE: image = add_noise(image) else: image = add_scanlines(image) image = add_noise(image) Brightness(image).enhance(2.5) # hoo boy text = np.random.choice(['PLAY', ' PAUSE'], p=[0.8, 0.2]) font = truetype('VCR_OSD_MONO.ttf', size=int(min(image.size) / 10)) start = datetime.datetime(1980, 1, 1, 0, 0) now = datetime.datetime.utcnow() # https://stackoverflow.com/a/8170651/7581432 random_date = start + datetime.timedelta(seconds=random.randint(0, int((now - start).total_seconds()))) topleft_text = antialiased_text(text, font, image.width, image.height, offset_x=1 / 30, offset_y=1 / 15) image.paste(topleft_text, (0, 0), mask=topleft_text) draw = Draw(image) if text == 'PLAY': width, height = font.getsize(text) offset_x = width + image.width * (1 / 30) * 1.5 offset_y = image.height * (1 / 15) draw.polygon( [ (offset_x, offset_y), (offset_x, offset_y + height), (offset_x + sqrt(height ** 2 - (height / 2) ** 2), offset_y + height / 2) ], fill=(255, 255, 255) ) else: _, height = font.getsize(' ') offset_x = image.width * (1 / 35) offset_y = image.height * (1 / 15) part = (height - offset_x / 2) / 8 draw.rectangle( [(offset_x, offset_y + part), (offset_x + 3 * part, offset_y - part + height)], fill=(255, 255, 255)) draw.rectangle( [(offset_x + 5 * part, offset_y + part), (offset_x + 8 * part, offset_y - part + height)], fill=(255, 255, 255)) # This is a nasty hack but oh well time, date = random_date.strftime('%H:%M|%b. %d %Y').split('|') wrap_width = len(date) botleft_text = antialiased_text(time.ljust(wrap_width + 1) + date, font, image.width, image.height, offset_x=1 / 35, offset_y=13 / 15, wrap_width=wrap_width) image.paste(botleft_text, (0, 0), mask=botleft_text) buffer = save_image(image, format=image.format) await ctx.channel.messages.upload(buffer, filename='shoutouts.' + image.format)
40.38
124
0.488856
437
4,038
4.398169
0.345538
0.043704
0.027055
0.021852
0.110302
0.091571
0.069719
0.069719
0.03538
0
0
0.044845
0.409113
4,038
99
125
40.787879
0.760687
0.037147
0
0.169014
0
0
0.015249
0
0
0
0
0.010101
0
1
0
false
0
0.183099
0
0.197183
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
1
5fb1ba21e31a7c2b9e588c895f10ae57243ce651
3,137
py
Python
star/star.py
gd-star-pp/star-pp
24c7289199215961fe5462b99ec600907b305d3f
[ "MIT" ]
2
2021-10-10T23:42:30.000Z
2022-03-31T19:43:13.000Z
star/star.py
lotus-gd/azalea
24c7289199215961fe5462b99ec600907b305d3f
[ "MIT" ]
null
null
null
star/star.py
lotus-gd/azalea
24c7289199215961fe5462b99ec600907b305d3f
[ "MIT" ]
null
null
null
import gd, itertools from cube import calculate_cube from ball import calculate_ball from helpers import average client = gd.Client() def calculate_ship(editor: gd.api.Editor, level: gd.Level, portal: gd.api.Object, speed, portal_count: int): pass def calculate_ufo(editor: gd.api.Editor, level: gd.Level, portal: gd.api.Object, speed, portal_count: int): pass def calculate_wave(editor: gd.api.Editor, level: gd.Level, portal: gd.api.Object, speed, portal_count: int): pass def calculate_robot(editor: gd.api.Editor, level: gd.Level, portal: gd.api.Object, speed, portal_count: int): pass def calculate_spider(editor: gd.api.Editor, level: gd.Level, portal: gd.api.Object, speed, portal_count: int): pass modes = {gd.PortalType.CUBE: calculate_cube, gd.PortalType.SHIP: calculate_ship, gd.PortalType.BALL: calculate_ball, gd.PortalType.BALL: calculate_ufo, gd.PortalType.UFO: calculate_ufo, gd.PortalType.WAVE: calculate_wave, gd.PortalType.ROBOT: calculate_robot, gd.PortalType.SPIDER: calculate_spider, gd.Gamemode.CUBE: calculate_cube, gd.Gamemode.SHIP: calculate_ship, gd.Gamemode.BALL: calculate_ball, gd.Gamemode.BALL: calculate_ufo, gd.Gamemode.UFO: calculate_ufo, gd.Gamemode.WAVE: calculate_wave, gd.Gamemode.ROBOT: calculate_robot, gd.Gamemode.SPIDER: calculate_spider} def main(): totalstar = [] database = gd.api.save.load() levels = database.load_my_levels() #level = levels.get_by_name("star test") level = client.run(client.get_level(3884458)) # id editor = level.open_editor() startspeed = editor.get_start_speed() mode = modes.get(editor.header.gamemode) star = mode(editor, level, gd.api.Object(x=0), startspeed, -1) totalstar.append(star) portal_count = 0 for portal, speed in itertools.zip_longest(editor.get_portals(), editor.get_speeds()): try: speed = gd.Speed.from_name(gd.SpeedChange(speed.id).name) except AttributeError: # fix speed later pass if portal.id == 10 or portal.id == 11 or portal.id == 45 or portal.id == 46 or portal.id == 101 or portal.id == 99 or portal.id == 286 or portal.id == 287 or portal.id == 747 or portal.id == 749: # speed portals and other extra portals continue mode = modes.get(gd.PortalType(portal.id)) if mode: star = mode(editor, level, portal, speed, portal_count) if star is not None: totalstar.append(star) portal_count += 1 totalstar.sort(reverse=True) weights = [1.25, 1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0] i = 0 for star, weight in itertools.zip_longest(totalstar, weights): if weight is None: weight = 0 if star is None: break print(star, weight) totalstar[i] = round(star*weight, 2) i += 1 print(totalstar) return round(average(totalstar), 2) if __name__ == "__main__": star = main() print(star)
36.057471
203
0.646159
435
3,137
4.54023
0.234483
0.03038
0.04557
0.043038
0.229367
0.198987
0.198987
0.198987
0.198987
0.198987
0
0.026823
0.239401
3,137
87
204
36.057471
0.800922
0.030602
0
0.112676
0
0
0.002633
0
0
0
0
0
0
1
0.084507
false
0.084507
0.056338
0
0.15493
0.042254
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
5fba9266d157d784d487f4f6d96c252ab58bc927
221
py
Python
modules/module0/02_datastructures_and_geometry/datastructures_0b.py
tetov/ITA19
1af68a8885caf83acd98f4136d0286539ccbe63b
[ "MIT" ]
7
2019-11-13T20:29:54.000Z
2020-02-26T14:30:54.000Z
modules/module0/02_datastructures_and_geometry/datastructures_0b.py
GeneKao/ITA19
c4b10dc183599eed4ed60d922b6ef5922d173bdb
[ "MIT" ]
4
2019-11-07T20:57:51.000Z
2020-03-04T11:43:18.000Z
modules/module0/02_datastructures_and_geometry/datastructures_0b.py
GeneKao/ITA19
c4b10dc183599eed4ed60d922b6ef5922d173bdb
[ "MIT" ]
6
2019-10-30T13:25:54.000Z
2020-02-14T14:06:09.000Z
import os import compas from compas.datastructures import Mesh HERE = os.path.dirname(__file__) DATA = os.path.join(HERE, 'data') FILE = os.path.join(DATA, 'faces.obj') mesh = Mesh.from_obj(FILE) print(mesh.summary())
18.416667
38
0.737557
35
221
4.514286
0.457143
0.113924
0.126582
0
0
0
0
0
0
0
0
0
0.117647
221
11
39
20.090909
0.810256
0
0
0
0
0
0.058824
0
0
0
0
0
0
1
0
false
0
0.375
0
0.375
0.125
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
5fbebd443ba2cc788cd34ccb4de7f2967a894072
3,957
py
Python
vis_utils/animation/group_animation_controller.py
eherr/vis_utils
b757b01f42e6da02ad62130c3b0e61e9eaa3886f
[ "MIT" ]
4
2020-05-20T03:55:19.000Z
2020-12-24T06:33:40.000Z
vis_utils/animation/group_animation_controller.py
eherr/vis_utils
b757b01f42e6da02ad62130c3b0e61e9eaa3886f
[ "MIT" ]
1
2020-05-18T11:21:35.000Z
2020-07-07T21:25:57.000Z
vis_utils/animation/group_animation_controller.py
eherr/vis_utils
b757b01f42e6da02ad62130c3b0e61e9eaa3886f
[ "MIT" ]
1
2020-07-20T06:57:13.000Z
2020-07-20T06:57:13.000Z
#!/usr/bin/env python # # Copyright 2019 DFKI GmbH. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the # following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions 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 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. from PySignal import Signal from .animation_controller import AnimationController from ..scene.components import ComponentBase class GroupAnimationController(ComponentBase, AnimationController): updated_animation_frame = Signal() reached_end_of_animation = Signal() def __init__(self, scene_object): ComponentBase.__init__(self, scene_object) self.mainContext = 0 AnimationController.__init__(self) self._animation_controllers = [] def add_animation_controller(self, animation_controller): self._animation_controllers.append(animation_controller) self.frameTime = animation_controller.frameTime def get_animation_controllers(self): return self._animation_controllers def update(self, dt): """ update current frame and global joint transformation matrices """ dt *= self.animationSpeed if self.isLoadedCorrectly(): if self.playAnimation: # frame and transformation matrices self.animationTime += dt self.currentFrameNumber = int(self.animationTime / self.getFrameTime()) self.updateTransformation(self.currentFrameNumber) # update gui if self.currentFrameNumber > self.getNumberOfFrames(): self.resetAnimationTime() self.reached_end_of_animation.emit(self.loopAnimation) else: self.updated_animation_frame.emit(self.currentFrameNumber) def draw(self, modelMatrix, viewMatrix, projectionMatrix, lightSources): return def updateTransformation(self, frameNumber=None): for controller in self._animation_controllers: if frameNumber is not None: controller.setCurrentFrameNumber(frameNumber) controller.updateTransformation() def resetAnimationTime(self): AnimationController.resetAnimationTime(self) self.currentFrameNumber = 0 self.updateTransformation(self.currentFrameNumber) def setCurrentFrameNumber(self, frameNumber): self.currentFrameNumber = frameNumber self.updateTransformation(self.currentFrameNumber) self.animationTime = self.getFrameTime() * self.currentFrameNumber def getNumberOfFrames(self): n_frames = [0] n_frames += [controller.getNumberOfFrames() for controller in self._animation_controllers] return max(n_frames) def isLoadedCorrectly(self): return len(self._animation_controllers) > 0 def getFrameTime(self): if self.isLoadedCorrectly(): # print self.frameTime return self.frameTime else: return 0 def toggle_animation_loop(self): self.loopAnimation = not self.loopAnimation
39.57
98
0.706849
421
3,957
6.527316
0.384798
0.072052
0.052402
0.050218
0.055313
0.028384
0
0
0
0
0
0.002951
0.229214
3,957
100
99
39.57
0.898033
0.304271
0
0.125
0
0
0
0
0
0
0
0
0
1
0.214286
false
0
0.053571
0.053571
0.428571
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
5fcaa9f085f2d78ed188a66c5c69d0728b2a6373
2,640
py
Python
tools/common.py
JamzumSum/yNet
78506738e64321cfd26f0af70a62dd2119948e39
[ "MIT" ]
5
2021-06-09T02:11:19.000Z
2021-10-04T09:00:31.000Z
tools/common.py
JamzumSum/yNet
78506738e64321cfd26f0af70a62dd2119948e39
[ "MIT" ]
null
null
null
tools/common.py
JamzumSum/yNet
78506738e64321cfd26f0af70a62dd2119948e39
[ "MIT" ]
null
null
null
from dataclasses import dataclass from typing import Iterable import torch from torchmetrics import ConfusionMatrix from collections import defaultdict argmax = lambda l: l.index(max(l)) BIRAD_MAP = ['2', '3', '4', '5'] def _lbm(): global BIRAD_MAP BIRAD_MAP = torch.load("./data/BIRADs/meta.pt")['classname']['Yb'] @dataclass(frozen=True) class DiagBag: pid: str pm: float pb: list ym: int yb: int @staticmethod def header(): return [ 'pid', 'malignant prob', 'BIRADs prob distrib', 'malignant anno', 'BIRADs anno' ] def __iter__(self): yield self.pid yield f"{self.pm:.4f}" yield '-' if self.pb is None else f"{BIRAD_MAP[argmax(self.pb)]}类 ({', '.join('%.4f' % i for i in self.pb)})" yield str(self.ym) yield '-' if self.yb is None else f"{BIRAD_MAP[self.yb]}类" class Counter: def __init__(self, diags: Iterable[DiagBag], thresh: float) -> None: self.raw = tuple(diags) self.K = len(BIRAD_MAP) assert self.K >= 2 self.allInOne(thresh) def allInOne(self, thresh): cm = ConfusionMatrix(2, threshold=thresh) cb = ConfusionMatrix(self.K) cbm = ConfusionMatrix(self.K) for d in self.raw: cm.update(preds=torch.Tensor([d.pm]), target=torch.LongTensor([d.ym])) cbm.update(preds=torch.Tensor([d.pb]), target=torch.LongTensor([int(d.pm > thresh)])) if d.yb is not None: cb.update(preds=torch.Tensor([d.pb]), target=torch.LongTensor([[d.yb]])) self.cm = cm.compute() self.cb = cb.compute() self.cbm = cbm.compute() @staticmethod def _acc(cf): return float(cf.diag().sum() / cf.sum()) @staticmethod def _prec(cf: torch.Tensor): return (cf.diag() / cf.sum(dim=1).clamp_min_(1e-5)).tolist() @staticmethod def _recall(cf: torch.Tensor): return (cf.diag() / cf.sum(dim=0).clamp_min_(1e-5)).tolist() @property def pb_acc(self): return self._acc(self.cb) @property def pm_acc(self): return self._acc(self.cm) @property def pb_precision(self): return self._prec(self.cb) @property def pb_recall(self): return self._recall(self.cb) @property def pm_precision(self): return self._prec(self.cm) @property def pm_recall(self): return self._recall(self.cm) @property def m_birad(self): return self.cbm[1].int().tolist() @property def b_birad(self): return self.cbm[0].int().tolist() _lbm()
24.220183
117
0.591667
360
2,640
4.236111
0.288889
0.057705
0.073443
0.043279
0.325902
0.24
0.103607
0.103607
0.103607
0
0
0.008214
0.262121
2,640
108
118
24.444444
0.774641
0
0
0.148148
0
0.012346
0.077652
0.026894
0
0
0
0
0.012346
1
0.197531
false
0
0.061728
0.148148
0.493827
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
1
0
0
0
1
39563b416a76edc246cc669718217ec4a6dc8d69
199
py
Python
tools/stress_test.py
chouette254/quo
8979afd118e77d3d0f93f9fbe8711efada7158c5
[ "MIT" ]
5
2021-06-17T21:06:39.000Z
2022-03-11T06:45:51.000Z
tools/stress_test.py
chouette254/quo
8979afd118e77d3d0f93f9fbe8711efada7158c5
[ "MIT" ]
39
2021-07-19T19:36:18.000Z
2022-02-23T14:55:08.000Z
tools/stress_test.py
secretuminc/quo
c4f77d52f015c612d32ed0fc2fc79545af598f10
[ "MIT" ]
1
2021-05-31T17:19:15.000Z
2021-05-31T17:19:15.000Z
from quo import Console from quo.pretty import Pretty from quo.panel import Panel DATA = "My name is Quo" console = Console() for w in range(130): console.echo(Panel(Pretty(DATA), width=w))
15.307692
46
0.718593
33
199
4.333333
0.515152
0.146853
0
0
0
0
0
0
0
0
0
0.018405
0.180905
199
12
47
16.583333
0.858896
0
0
0
0
0
0.070352
0
0
0
0
0
0
1
0
false
0
0.428571
0
0.428571
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
395f4cf60fb9e63158d7823964bdae4a063e3899
665
py
Python
zk_shell/tests/test_acl_reader.py
sellers/zk_shell
5f5972c4362212f97de91a75e44d2a551c7bcd51
[ "Apache-2.0" ]
163
2015-01-24T06:17:34.000Z
2021-12-17T22:58:46.000Z
zk_shell/tests/test_acl_reader.py
sellers/zk_shell
5f5972c4362212f97de91a75e44d2a551c7bcd51
[ "Apache-2.0" ]
86
2015-01-01T00:22:57.000Z
2022-03-02T14:50:59.000Z
zk_shell/tests/test_acl_reader.py
sellers/zk_shell
5f5972c4362212f97de91a75e44d2a551c7bcd51
[ "Apache-2.0" ]
32
2015-02-18T17:33:16.000Z
2021-12-28T03:43:45.000Z
# -*- coding: utf-8 -*- """ ACLReader test cases """ import unittest from kazoo.security import ACL, Id from zk_shell.acl import ACLReader class ACLReaderTestCase(unittest.TestCase): """ test watcher """ def test_extract_acl(self): acl = ACLReader.extract_acl('world:anyone:cdrwa') expected = ACL(perms=31, id=Id(scheme='world', id='anyone')) self.assertEqual(expected, acl) def test_username_password(self): acl = ACLReader.extract_acl('username_password:user:secret:cdrwa') expected = ACL(perms=31, id=Id(scheme='digest', id=u'user:5w9W4eL3797Y4Wq8AcKUPPk8ha4=')) self.assertEqual(expected, acl)
28.913043
97
0.685714
82
665
5.463415
0.45122
0.098214
0.071429
0.102679
0.263393
0.147321
0.147321
0.147321
0
0
0
0.02925
0.177444
665
22
98
30.227273
0.789762
0.087218
0
0.166667
0
0
0.173401
0.114478
0
0
0
0
0.166667
1
0.166667
false
0.166667
0.25
0
0.5
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
39637ce1898c8dbfd20a89d25579fc15ae6c2bcd
432
py
Python
events_calendar/urls.py
mkbeh/Site-Nordic-Walking-
ba98f41db09ed448ecc4db175f65ef4fa2d64979
[ "MIT" ]
null
null
null
events_calendar/urls.py
mkbeh/Site-Nordic-Walking-
ba98f41db09ed448ecc4db175f65ef4fa2d64979
[ "MIT" ]
8
2021-04-08T21:57:55.000Z
2022-03-12T00:50:38.000Z
events_calendar/urls.py
mkbeh/Site-Nordic-Walking-
ba98f41db09ed448ecc4db175f65ef4fa2d64979
[ "MIT" ]
null
null
null
from django.urls import path from .views import events_calendar, calendar_event_detail, past_competitions app_name = 'events_calendar' urlpatterns = [ path('past_competitions/', past_competitions, name='past_competitions'), path('<int:year>/<int:month>/<int:day>/<int:hour>/<slug:event>/', calendar_event_detail, name='calendar_event_detail'), path('<int:days>', events_calendar, name='events_calendar'), ]
30.857143
76
0.733796
54
432
5.592593
0.407407
0.18543
0.188742
0
0
0
0
0
0
0
0
0
0.118056
432
13
77
33.230769
0.792651
0
0
0
0
0.111111
0.354167
0.180556
0
0
0
0
0
1
0
false
0
0.222222
0
0.222222
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
3965e8f70ee4cbba8c4a1ffa659f82e9962bbdcf
619
py
Python
migrations/versions/6f98e24760d_session_speaker.py
jace/goafunnel
5ff25f0e6a247ff1f6e87fce2a793d1775476cc0
[ "BSD-2-Clause" ]
null
null
null
migrations/versions/6f98e24760d_session_speaker.py
jace/goafunnel
5ff25f0e6a247ff1f6e87fce2a793d1775476cc0
[ "BSD-2-Clause" ]
null
null
null
migrations/versions/6f98e24760d_session_speaker.py
jace/goafunnel
5ff25f0e6a247ff1f6e87fce2a793d1775476cc0
[ "BSD-2-Clause" ]
null
null
null
"""session speaker Revision ID: 6f98e24760d Revises: 58588eba8cb8 Create Date: 2013-11-22 17:28:47.751025 """ # revision identifiers, used by Alembic. revision = '6f98e24760d' down_revision = '58588eba8cb8' from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('session', sa.Column('speaker', sa.Unicode(length=200), nullable=True)) ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_column('session', 'speaker') ### end Alembic commands ###
22.925926
89
0.6979
76
619
5.644737
0.578947
0.062937
0.097902
0.107226
0.205128
0.205128
0.205128
0.205128
0
0
0
0.102913
0.168013
619
26
90
23.807692
0.730097
0.471729
0
0
0
0
0.173469
0
0
0
0
0
0
1
0.25
false
0
0.25
0
0.5
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
396b128eaea90d279b0b41fb297fa2fa82ed6d87
1,930
py
Python
nanome/api/user/presenter_info.py
nanome-ai/nanome-plugin-api
f2ce6a5e3123ee7449a90c2659f3891124289f4a
[ "MIT" ]
3
2020-07-02T13:08:27.000Z
2021-11-24T14:32:53.000Z
nanome/api/user/presenter_info.py
nanome-ai/nanome-plugin-api
f2ce6a5e3123ee7449a90c2659f3891124289f4a
[ "MIT" ]
11
2020-09-14T17:01:47.000Z
2022-02-18T04:00:52.000Z
nanome/api/user/presenter_info.py
nanome-ai/nanome-plugin-api
f2ce6a5e3123ee7449a90c2659f3891124289f4a
[ "MIT" ]
5
2020-08-12T16:30:03.000Z
2021-12-06T18:04:23.000Z
class PresenterInfo(): """ | Class to fetch information about the current nanome session's presenter. """ def __init__(self): self._account_id = "" self._account_name = "" self._account_email = "" self._has_org = False self._org_id = 0 self._org_name = "" @property def account_id(self): """ | The Nanome account ID of the presenter :type: :class:`str` """ return self._account_id @account_id.setter def account_id(self, value): self._account_id = value @property def account_name(self): """ | The Nanome account name of the presenter :type: :class:`str` """ return self._account_name @account_name.setter def account_name(self, value): self._account_name = value @property def account_email(self): """ | The Nanome account email of the presenter :type: :class:`str` """ return self._account_email @account_email.setter def account_email(self, value): self._account_email = value @property def has_org(self): """ | If the presenter belongs to an organization :type: :class:`bool` """ return self._has_org @has_org.setter def has_org(self, value): self._has_org = value @property def org_id(self): """ | The ID of the organization the presenter belongs to :type: :class:`int` """ return self._org_id @org_id.setter def org_id(self, value): self._org_id = value @property def org_name(self): """ | The name of the organization the presenter belongs to :type: :class:`str` """ return self._org_name @org_name.setter def org_name(self, value): self._org_name = value
21.208791
78
0.564249
226
1,930
4.561947
0.159292
0.096023
0.075655
0.069835
0.228904
0.216295
0.216295
0.216295
0.216295
0
0
0.000781
0.336788
1,930
90
79
21.444444
0.804688
0.251295
0
0.136364
0
0
0
0
0
0
0
0
0
1
0.295455
false
0
0
0
0.454545
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
396d4f672042b6ba26b0ebbbfccf8610a433735a
2,976
py
Python
scripts/staging/sklearn/mappers/supervised.py
mgd-hin/systemds
08944a7305cbc4f4d9cbbd4565efa8bcc93b82e3
[ "Apache-2.0" ]
372
2017-06-09T01:02:53.000Z
2020-06-24T05:45:00.000Z
scripts/staging/sklearn/mappers/supervised.py
ywcb00/systemds
5cc523971854cdf4f22e6199987a86e213fae4e2
[ "Apache-2.0" ]
418
2017-06-08T16:27:44.000Z
2020-06-25T12:15:54.000Z
scripts/staging/sklearn/mappers/supervised.py
ywcb00/systemds
5cc523971854cdf4f22e6199987a86e213fae4e2
[ "Apache-2.0" ]
190
2017-06-08T19:32:54.000Z
2020-06-15T12:26:12.000Z
# ------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed 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. # # ------------------------------------------------------------- from .mapper import Mapper class LinearSVMMapper(Mapper): name = 'l2svm' sklearn_name = 'linearsvc' is_supervised = True mapped_output = [ 'model' ] def map_params(self): self.mapped_params = [ 'TRUE' if self.params.get('fit_intercept', False) else 'FALSE', self.params.get('tol', 0.001), self.params.get('C', 1.0), self.params.get('max_iter', 100), 20, # maxii parameter is unkown in sklearn and not documented in dml 'TRUE' if self.params.get('verbose', False) else 'FALSE', -1 # column_id is unkown in sklearn ] class TweedieRegressorMapper(Mapper): name = 'glm' sklearn_name = 'tweedieregressor' is_supervised = True mapped_output = [ 'beta' ] def map_params(self): # TODO: many parameters cannot be mapped directly: # how to handle defaults for dml? self.mapped_params = [ 1, # sklearn impl supports power only, dfam self.params.get('power', 0.0), # vpow 0, # link 1.0, # lpow 0.0, # yneg # sklearn does not know last case 0 if self.params.get('fit_intercept', 1) else 1, # icpt 0.0, # disp 0.0, # reg self.params.get('tol', 0.000001), # tol 200, # moi 0, # mii, 'TRUE' if self.params.get('verbose', False) else 'FALSE' ] class LogisticRegressionMapper(Mapper): name = 'multiLogReg' sklearn_name = 'logisticregression' is_supervised = True mapped_output = [ 'beta' ] def map_params(self): self.mapped_params = [ # sklearn does not know last case 0 if self.params.get('fit_intercept', 1) else 1, self.params.get('tol', 0.000001), # tol self.params.get('C', 0.0), # reg 100, # maxi 0, # maxii 'TRUE' if self.params.get('verbose', False) else 'FALSE' ]
33.438202
80
0.576277
364
2,976
4.656593
0.409341
0.076696
0.099705
0.053097
0.302065
0.273156
0.257227
0.19823
0.19823
0.127434
0
0.027856
0.288306
2,976
88
81
33.818182
0.772427
0.409946
0
0.464286
0
0
0.113769
0
0
0
0
0.011364
0
1
0.053571
false
0
0.017857
0
0.339286
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
1
3980310409feb9f0ac71dbf46448b126022d5366
1,258
py
Python
support.py
ipascual1/spootnik_bot
ad7658f49705b1ce57bcc5ed84006ef658f63fa3
[ "Unlicense" ]
null
null
null
support.py
ipascual1/spootnik_bot
ad7658f49705b1ce57bcc5ed84006ef658f63fa3
[ "Unlicense" ]
null
null
null
support.py
ipascual1/spootnik_bot
ad7658f49705b1ce57bcc5ed84006ef658f63fa3
[ "Unlicense" ]
null
null
null
import re import os def extract(regularE : str, init : str, stop : str, string : str): """ regularE: RE to catch string init: First string to replace stop: Last string to replace string: String to apply the RE With a regular expression and init and stop to replace, gets a substring from string argument and returns it. """ return re.findall(regularE, string)[0]\ .replace(init, "")\ .replace(stop, "") def get_term_clock_pid(): """ return: int with the PID of term_clock; -1 if process doesn't exist. Extracts the PID of term_clock process with systemctl. """ # sputnikDriver prints in their own console all the PIDs of its subprocesses ret = os.popen("systemctl status sputnikDriver.service").read() if ret == "": return -1 return int(extract(r"term_clock .+ PID", "term_clock ", " PID", ret)) def check_alive(): """ return: True if java process is running; False otherwise Check if a java process in sputnikDriver (i.e. the Minecraft Server) is running """ ret = os.popen("systemctl status sputnikDriver.service").read() return "java" in ret
29.255814
83
0.612878
165
1,258
4.624242
0.442424
0.058978
0.047182
0.031455
0.173001
0.12844
0.12844
0.12844
0
0
0
0.003382
0.294913
1,258
42
84
29.952381
0.856821
0.500795
0
0.142857
0
0
0.208178
0.078067
0
0
0
0
0
1
0.214286
false
0
0.142857
0
0.642857
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
39812282916a91f854eceaec095dab9dd29955a6
1,783
py
Python
igvc_ws/src/igvc_nav/src/path_planner/node.py
SoonerRobotics/igvc_software_2022
906e6a4fca22d2b0c06ef1b8a4a3a9df7f1d17dd
[ "MIT" ]
4
2020-07-07T14:56:56.000Z
2021-08-13T23:31:07.000Z
igvc_ws/src/igvc_nav/src/path_planner/node.py
pradumn203/igvc-winners-2021
658233609054eafac59603a77b2a092dc002e145
[ "MIT" ]
13
2019-11-12T02:57:54.000Z
2020-03-17T17:04:22.000Z
igvc_ws/src/igvc_nav/src/path_planner/node.py
pradumn203/igvc-winners-2021
658233609054eafac59603a77b2a092dc002e145
[ "MIT" ]
3
2021-06-29T05:21:18.000Z
2021-08-23T05:03:27.000Z
""" """ class Node: INFINITY = 1000000000 def __init__(self, row, col, cost = 0): self.row = row self.col = col # Default node value self.G = self.INFINITY self.rhs = self.INFINITY self.par = None self.key = (None, None) # Cost (for obstacles and such) self.cost = cost def set_g(self, G): if G > self.INFINITY: G = self.INFINITY self.G = G def set_rhs(self, rhs): if rhs > self.INFINITY: rhs = self.INFINITY self.rhs = rhs def set_par(self, par): self.par = par def set_key(self, key): self.key = key def set_cost(self, cost): self.cost = cost def __cmp__(self, other): """ Sort keys with lowest priority to the top of the list""" # Sort by the first key comp_val = cmp(self.key[0], other.key[0]) if comp_val != 0: return comp_val # If there was a tie, use the second key as a tiebreaker return cmp(self.key[1], other.key[1]) def __lt__(self, other): comp_val = (self.key[0] < other.key[0]) if comp_val is True: return True elif self.key[0] == other.key[0]: return self.key[1] < other.key[1] return False def __gt__(self, other): comp_val = (self.key[0] > other.key[0]) if comp_val is True: return True elif self.key[0] == other.key[0]: return self.key[1] > other.key[1] return False def __eq__(self, other): if other == None: return False return (self.row == other.row) and (self.col == other.col) def __hash__(self): return hash((self.row, self.col))
22.858974
68
0.528884
251
1,783
3.613546
0.231076
0.084895
0.044101
0.071665
0.303197
0.303197
0.284454
0.284454
0.284454
0.255788
0
0.024412
0.356702
1,783
77
69
23.155844
0.766347
0.100953
0
0.22449
0
0
0
0
0
0
0
0
0
1
0.22449
false
0
0
0.020408
0.489796
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
398533491570a42901637e1afb785d157af6a86a
809
py
Python
accounts/forms.py
mohsenamoon1160417237/Social_app
79fa0871f7b83648894941f9010f1d99f1b27ab3
[ "MIT" ]
null
null
null
accounts/forms.py
mohsenamoon1160417237/Social_app
79fa0871f7b83648894941f9010f1d99f1b27ab3
[ "MIT" ]
null
null
null
accounts/forms.py
mohsenamoon1160417237/Social_app
79fa0871f7b83648894941f9010f1d99f1b27ab3
[ "MIT" ]
null
null
null
from django.contrib.auth.models import User from django import forms from .models import UserProfile class UserRegistrationForm(forms.ModelForm): password = forms.CharField(max_length=20 , widget=forms.PasswordInput , label='Password') password2 = forms.CharField(max_length=20 , widget=forms.PasswordInput , label="Repeat password") class Meta: model = User fields = ['username' , 'email'] def clean_password2(self): cd = self.cleaned_data if cd['password'] != cd['password2']: raise forms.ValidationError("Passwords must match") return cd['password2'] class UserEditProfileForm(forms.ModelForm): class Meta: model = UserProfile fields = ['image' , 'age'] class UserEditForm(forms.ModelForm): class Meta: model = User fields = ['first_name' , 'last_name']
17.212766
98
0.721879
95
809
6.084211
0.494737
0.072664
0.072664
0.079585
0.342561
0.186851
0.186851
0.186851
0.186851
0
0
0.011782
0.160692
809
47
99
17.212766
0.83947
0
0
0.227273
0
0
0.134568
0
0
0
0
0
0
1
0.045455
false
0.272727
0.136364
0
0.590909
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
3986c0e0bd792870f8eee7d99d0e2fa5761fa22e
1,429
py
Python
blueprints/accounts/manage/config.py
GetmeUK/h51
17d4003336857514765a42a0853995fbe3da6525
[ "MIT" ]
null
null
null
blueprints/accounts/manage/config.py
GetmeUK/h51
17d4003336857514765a42a0853995fbe3da6525
[ "MIT" ]
4
2021-06-08T22:58:13.000Z
2022-03-12T00:53:18.000Z
blueprints/accounts/manage/config.py
GetmeUK/h51
17d4003336857514765a42a0853995fbe3da6525
[ "MIT" ]
null
null
null
from manhattan.manage import config from manhattan.nav import Nav, NavItem from blueprints.accounts.manage import blueprint from blueprints.accounts.models import Account __all__ = ['AccountConfig'] class AccountConfig(config.ManageConfig): frame_cls = Account blueprint = blueprint @classmethod def tabs(cls, view_type, document=None): tabs = Nav.local_menu() if view_type in ['api_log', 'change_log', 'activity', 'view']: tabs.add( NavItem( 'Details', endpoint=AccountConfig.get_endpoint('view'), view_args={'account': document._id} ) ) tabs.add( NavItem( 'Activity', endpoint=AccountConfig.get_endpoint('activity'), view_args={'account': document._id} ) ) tabs.add( NavItem( 'API log', endpoint=AccountConfig.get_endpoint('api_log'), view_args={'account': document._id} ) ) tabs.add( NavItem( 'Change log', endpoint=AccountConfig.get_endpoint('change_log'), view_args={'account': document._id} ) ) return tabs
26.462963
70
0.491952
118
1,429
5.754237
0.338983
0.041237
0.082474
0.188513
0.32106
0.217968
0.172312
0.172312
0
0
0
0
0.416375
1,429
53
71
26.962264
0.814149
0
0
0.292683
0
0
0.091673
0
0
0
0
0
0
1
0.02439
false
0
0.097561
0
0.219512
0.073171
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
39a0dad5efbaf0ea7f66987d69ed3575a2e7b7d0
1,068
py
Python
python/easy/1342_Number_of_Steps_to_Reduce_a_Number_to_Zero.py
JackWang0107/leetcode
c02932190b639ef87a8d0fcd07d9cd6ec7344a67
[ "MIT" ]
1
2021-05-22T03:27:33.000Z
2021-05-22T03:27:33.000Z
python/easy/1342_Number_of_Steps_to_Reduce_a_Number_to_Zero.py
JackWang0107/leetcode
c02932190b639ef87a8d0fcd07d9cd6ec7344a67
[ "MIT" ]
null
null
null
python/easy/1342_Number_of_Steps_to_Reduce_a_Number_to_Zero.py
JackWang0107/leetcode
c02932190b639ef87a8d0fcd07d9cd6ec7344a67
[ "MIT" ]
null
null
null
from typing import * class Solution: # 32 ms, faster than 53.97% of Python3 online submissions for Number of Steps to Reduce a Number to Zero. # 14.2 MB, less than 35.20% of Python3 online submissions for Number of Steps to Reduce a Number to Zero. def numberOfSteps(self, num: int) -> int: ans = 0 while num != 0: if num & 1: num -= 1 else: num = int(num/2 ) ans += 1 return ans # 20 ms, faster than 98.79% of Python3 online submissions for Number of Steps to Reduce a Number to Zero. # 14.3 MB, less than 35.20% of Python3 online submissions for Number of Steps to Reduce a Number to Zer def numberOfSteps(self, num: int) -> int: def rec(num): if num == 0 or num == 1: return num elif num % 2: return 2 + rec(num // 2) else: return 1 + rec(num // 2) return rec(num) if __name__ == "__main__": so = Solution() print(so.numberOfSteps(123))
34.451613
110
0.553371
155
1,068
3.76129
0.335484
0.06175
0.102916
0.178388
0.57976
0.57976
0.480274
0.480274
0.480274
0.480274
0
0.067747
0.364232
1,068
31
111
34.451613
0.790869
0.38764
0
0.173913
0
0
0.012308
0
0
0
0
0
0
1
0.130435
false
0
0.043478
0
0.434783
0.043478
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
39a92e95003cf25b12c9d62aa465b8c0ddd75afb
5,510
py
Python
HyperGui.py
MIC-Surgery-Heidelberg/HyperGUI_1.0
0ee8e0da85049076bb22a542d15d6c3adf6ea106
[ "MIT" ]
null
null
null
HyperGui.py
MIC-Surgery-Heidelberg/HyperGUI_1.0
0ee8e0da85049076bb22a542d15d6c3adf6ea106
[ "MIT" ]
null
null
null
HyperGui.py
MIC-Surgery-Heidelberg/HyperGUI_1.0
0ee8e0da85049076bb22a542d15d6c3adf6ea106
[ "MIT" ]
null
null
null
""" @author: Alexander Studier-Fischer, Jan Odenthal, Berkin Oezdemir, Isabella Camplisson, University of Heidelberg """ from HyperGuiModules import * import logging import os #logging.basicConfig(level=logging.DEBUG) xSize=None ySize=None def main(): (window, introduction, input_output, image_diagram, hist_calculation, spec_calculation, bp, circles, rectangles, crop, bs, measure, mda, spec_invest) = init() listener = ModuleListener() # introduction Introduction(introduction) # histogram calculation HistCalculation(hist_calculation, listener) # histogram calculation SpecCalculation(spec_calculation, listener) # analysis and form analysis_and_form_frame = frame(input_output, BACKGROUND, 1, 0, 4, 2) analysis_and_form_module = AnalysisAndForm(analysis_and_form_frame, listener) listener.attach_module(ANALYSIS_AND_FORM, analysis_and_form_module) # source and output source_and_output_frame = frame(input_output, BACKGROUND, 0, 0, 1, 2) source_and_output_module = SourceAndOutput(source_and_output_frame, listener) listener.attach_module(SOURCE_AND_OUTPUT, source_and_output_module) # save save_frame = frame(input_output, BACKGROUND, 5, 0, 1, 1) save_module = Save(save_frame, listener) listener.attach_module(SAVE, save_module) # save csvs csv_frame = frame(input_output, BACKGROUND, 0, 2, 6, 1) csv_module = CSVSaver(csv_frame, listener) listener.attach_module(CSV, csv_module) # info info_frame = frame(input_output, BACKGROUND, 5, 1, 1, 1) info_module = Info(info_frame, listener) listener.attach_module(INFO, info_module) # parameter specification #parameter_frame = frame(input_output, BACKGROUND, 0, 3, 2, 1) #parameter_module = Parameter(parameter_frame, listener) #listener.attach_module(PARAMETER, parameter_module) # original colour og_color_frame = frame(image_diagram, BACKGROUND, 0, 0, 7, 6) og_color_module = OGColour(og_color_frame, listener) listener.attach_module(ORIGINAL_COLOUR, og_color_module) # original colour data og_color_data_frame = frame(image_diagram, BACKGROUND, 2, 12, 3, 2) og_color_data_module = OGColourData(og_color_data_frame, listener) listener.attach_module(ORIGINAL_COLOUR_DATA, og_color_data_module) # recreated colour recreated_color_frame = frame(image_diagram, BACKGROUND, 7, 0, 7, 3) recreated_color_module = RecColour(recreated_color_frame, listener) listener.attach_module(RECREATED_COLOUR, recreated_color_module) # recreated colour data rec_color_data_frame = frame(image_diagram, BACKGROUND, 5, 12, 4, 2) rec_color_data_module = RecreatedColourData(rec_color_data_frame, listener) listener.attach_module(RECREATED_COLOUR_DATA, rec_color_data_module) # new colour new_color_frame = frame(image_diagram, BACKGROUND, 7, 3, 7, 3) new_color_module = NewColour(new_color_frame, listener) listener.attach_module(NEW_COLOUR, new_color_module) # new colour data new_color_data_frame = frame(image_diagram, BACKGROUND, 9, 12, 3, 2) new_color_data_module = NewColourData(new_color_data_frame, listener) listener.attach_module(NEW_COLOUR_DATA, new_color_data_module) # diagram diagram_frame = frame(image_diagram, BACKGROUND, 0, 12, 2, 2) diagram_module = Diagram(diagram_frame, listener) listener.attach_module(DIAGRAM, diagram_module) # histogram histogram_frame = frame(image_diagram, BACKGROUND, 0, 6, 8, 6) histogram_module = Histogram(histogram_frame, listener) listener.attach_module(HISTOGRAM, histogram_module) # absorption absorption_spec_frame = frame(image_diagram, BACKGROUND, 8, 6, 6, 6) absorption_module = AbsorptionSpec(absorption_spec_frame, listener) listener.attach_module(ABSORPTION_SPEC, absorption_module) # Batch Processing BP_frame = frame(bp, BACKGROUND, 0, 0, 16, 16) BP_module = BP(BP_frame, listener) listener.attach_module(BP, BP_module) rectangles_frame = frame(rectangles, BACKGROUND, 0, 0, 16, 16) rectangles_module = Rectangle(rectangles_frame, listener) listener.attach_module(rectangles, rectangles_module) circles_frame = frame(circles, BACKGROUND, 0, 0, 16, 16) circles_module = Circle(circles_frame, listener) listener.attach_module(circles, circles_module) BS_frame = frame(bs, BACKGROUND, 0, 0, 16, 16) BS_module = BS(BS_frame, listener) listener.attach_module(BS, BS_module) measure_frame = frame(measure, BACKGROUND, 0, 0, 16, 16) measure_module = Measure(measure_frame, listener) listener.attach_module(MEASURE, measure_module) crops_frame = frame(crop, BACKGROUND, 0, 0, 16, 16) crops_module = crops(crops_frame, listener) listener.attach_module(crop, crops_module) mda_frame = frame(mda, BACKGROUND, 0, 0, 16, 16) mda_module = MDA(mda_frame, listener) listener.attach_module(mda, mda_module) spec_invest_frame = frame(spec_invest, BACKGROUND, 0, 0, 16, 16) spec_invest_module = SpecInvest(spec_invest_frame, listener) listener.attach_module(spec_invest, spec_invest_module) # colourbar colour_frame = frame(image_diagram, BACKGROUND, 12, 12, 2, 2) colour_module = Colour(colour_frame, listener) if xSize is not None and ySize is not None: window.geometry(str(xSize) + "x" + str(ySize)) window.mainloop() if __name__ == '__main__': main()
36.979866
162
0.741561
712
5,510
5.425562
0.15309
0.062128
0.125032
0.160756
0.494693
0.267668
0.179912
0
0
0
0
0.025849
0.171506
5,510
148
163
37.22973
0.820372
0.111797
0
0
0
0
0.001851
0
0
0
0
0
0
1
0.011905
false
0
0.035714
0
0.047619
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
39ab9e369da24d4871a1bbc5c6f073cf0d4fed1f
743
py
Python
Test_data/database.py
mayowak/SQLite_test
a1185650dffe360d033e0691567ec2b2e075cae5
[ "MIT" ]
null
null
null
Test_data/database.py
mayowak/SQLite_test
a1185650dffe360d033e0691567ec2b2e075cae5
[ "MIT" ]
null
null
null
Test_data/database.py
mayowak/SQLite_test
a1185650dffe360d033e0691567ec2b2e075cae5
[ "MIT" ]
null
null
null
#!usr/bin/env python3 #import dependecies import sqlite3 import csv #connect to test_data conn = sqlite3.connect('test_data.db') #create a cursor c = conn.cursor() c.execute("DROP TABLE test_data") #create a test_data table c.execute("""CREATE TABLE test_data(age integer, sex text, bmi real, children integer, smoker text, region text)""") #get test_data file get_file = open('test_data.csv') #read test_data file read_file = csv.reader(get_file) c.executemany("INSERT INTO test_data VALUES (?, ?, ?, ?, ?, ?,?)", read_file) conn.commit() conn.close()
22.515152
78
0.549125
88
743
4.488636
0.465909
0.182278
0.065823
0
0
0
0
0
0
0
0
0.00616
0.344549
743
33
79
22.515152
0.804928
0.18035
0
0
0
0
0.620232
0
0
0
0
0
0
1
0
false
0
0.125
0
0.125
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
39b39323fb50875fc0c540df3d833adc6f094d24
2,583
py
Python
definition.example.py
JoshData/represent-boundaries
0a77bad99758bc77140c6c6def4f8d5e68810367
[ "MIT" ]
2
2016-07-05T06:10:21.000Z
2016-10-20T17:55:13.000Z
definition.example.py
JoshData/represent-boundaries
0a77bad99758bc77140c6c6def4f8d5e68810367
[ "MIT" ]
null
null
null
definition.example.py
JoshData/represent-boundaries
0a77bad99758bc77140c6c6def4f8d5e68810367
[ "MIT" ]
2
2016-07-05T06:10:25.000Z
2020-03-04T02:22:24.000Z
from datetime import date import boundaries boundaries.register('federal-electoral-districts', # The slug of the boundary set # The name of the boundary set for display. name='Federal electoral districts', # Generic singular name for a boundary from this set. Optional if the # boundary set's name ends in "s". singular='Federal electoral district', # If this were omitted, the same value would be generated # Geographic extents which the boundary set encompasses domain='Canada', # Path to the shapefile directory. Relative to the current file, so if this file # is in the same directory as the shapefile -- usually the case -- you can omit # this parameter. file='', # Last time the source was updated or checked for new data last_updated=date(1970, 1, 1), # A function that's passed the feature and should return a name string # The boundaries model provides some simple function factories for this. name_func=boundaries.clean_attr('FEDENAME'), # Function to extract a feature's "external_id" property id_func=boundaries.attr('FEDUID'), # Function to provide the slug (URL component) of the boundary # If not provided, uses the name to generate the slug; this is usually # what you want. #slug_func=boundaries.attr('FEDUID'), # Function that returns true/false to determine whether a given feature should be included # By default, all features are included. #is_valid_func=lambda f: True, # Authority that is responsible for the accuracy of this data authority='H.R.M. Queen Elizabeth II', # A URL to the source of this data source_url='http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-eng.cfm', # A URL to the license for this data licence_url='http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/license-eng.cfm?lang=_e&year=11&type=fed000a&format=a', # A URL to the data file, e.g. a ZIP archive data_url='http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/gfed000a11a_e.zip', # Notes identifying any pecularities about the data, such as columns that # were deleted or files which were merged notes='', # Encoding of the text fields in the shapefile, e.g. 'utf-8'. Default: 'ascii' encoding='iso-8859-1', # Used only by the represent-maps app -- if you're not using that, ignore label_point_func. # A function from a feature object to a Point where to display a label for feature on a map. #label_point_func = lambda feature: None, )
52.714286
139
0.722416
401
2,583
4.610973
0.453865
0.029746
0.030287
0.014602
0.127096
0.092482
0.092482
0.092482
0.092482
0.092482
0
0.019185
0.192799
2,583
48
140
53.8125
0.867626
0.629113
0
0
0
0.176471
0.474649
0.029126
0
0
0
0
0
1
0
true
0
0.117647
0
0.117647
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
1
39b549fc5da98ce81d958623dcf67a57d0a50eec
2,962
py
Python
tyo_mq_client/publisher.py
e-tang/tyo-mq-client-python
82ea47bf8cf8a924b515149456eaecb5557a0f3e
[ "MIT" ]
null
null
null
tyo_mq_client/publisher.py
e-tang/tyo-mq-client-python
82ea47bf8cf8a924b515149456eaecb5557a0f3e
[ "MIT" ]
1
2018-06-19T23:42:27.000Z
2018-06-20T07:06:25.000Z
tyo_mq_client/publisher.py
e-tang/tyo-mq-client-python
82ea47bf8cf8a924b515149456eaecb5557a0f3e
[ "MIT" ]
null
null
null
# # from .subscriber import Subscriber from .logger import Logger from .constants import Constants from .events import Events # import json class Publisher(Subscriber): def __init__(self, name, eventDefault=None, host=None, port=None, protocol=None): super(Publisher, self).__init__(name, host, port, protocol) self.type = 'PRODUCER' self.eventDefault = eventDefault if eventDefault is not None else Constants.EVENT_DEFAULT self.on_subscription_listener = None self.subscribers = {} # // Initialisation futureFunc = lambda : self.set_on_subscription_listener() self.add_on_connect_listener(futureFunc) # Logger.debug("creating producer: " + self.name) def broadcast (self, data, event=None): self.produce(data, event, Constants.METHOD_BROADCAST) def produce (self, data, event=None, method=None) : if (data is None): raise Exception("data can't be null") if (event is None): if (self.eventDefault is None): raise Exception("please specifiy event") else: event = self.eventDefault message = {"event":event, "message":data, "from":self.name, "method":method} self.send_message('PRODUCE', message) # /** # * On Subscribe # */ def __on_subscription (self, data) : Logger.log("Received subscription information: " + json.dumps(data)) self.subscribers[data["id"]] = data # // further listener if (self.on_subscription_listener is not None): self.on_subscription_listener(data) def set_on_subscription_listener (self) : event = Events.to_onsubscribe_event(self.get_id()) self.on(event, self.__on_subscription) # /** # * On Lost connections with subscriber(s) # */ def __on_lost_subscriber (self, callback, data) : Logger.log("Lost subscriber's connection") if (callback is not None): callback(data) def set_on_subscriber_lost_listener (self, callback) : event = Events.to_ondisconnect_event(self.get_id()) futureFunc = lambda data : (lambda data, cb=callback : self.__on_lost_subscriber(cb, data))(data) self.on(event, futureFunc) def on_subscriber_lost (self, callback) : self.set_on_subscriber_lost_listener(callback) # /** # * On Unsubsribe # */ def __on_unsubscribed (self, callback, data) : if callback is not None: callback(data) def set_on_unsubscribed_listener (self, event, callback) : event = Events.to_onunsubscribe_event(event, self.get_id()) futureFunc = lambda data : (lambda data, cb=callback: self.__on_unsubscribed(cb, data))(data) self.on(event, futureFunc) def on_unsubscribed (self, event, callback) : self.set_on_unsubscribed_listener(event, callback)
33.280899
105
0.641458
338
2,962
5.408284
0.218935
0.02954
0.060175
0.04267
0.206236
0.147702
0.147702
0.147702
0.147702
0.108315
0
0
0.255571
2,962
88
106
33.659091
0.829025
0.045915
0
0.074074
0
0
0.05694
0
0
0
0
0
0
1
0.203704
false
0
0.092593
0
0.314815
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
39b57868be76cc021f5f1127464558d697a138df
3,560
py
Python
app/authenticate.py
directedbyshawn/Secure-Login
15f2a6168986b11ffbde318333415671fb62578f
[ "MIT" ]
null
null
null
app/authenticate.py
directedbyshawn/Secure-Login
15f2a6168986b11ffbde318333415671fb62578f
[ "MIT" ]
null
null
null
app/authenticate.py
directedbyshawn/Secure-Login
15f2a6168986b11ffbde318333415671fb62578f
[ "MIT" ]
null
null
null
''' Authentication methods for cs166 final project. ''' import random, hashlib from .db import retrieve_accounts lower_case = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] upper_case = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'] special = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '?', '[', ']', '{', '}', ':', ';', '"', '/', '.', ',', '<', '>'] def authenticate(username, password): ''' Authenticates user upon login ''' # retrieves users from database users = retrieve_accounts() stored_username = '' stored_password = '' # finds user in records for user in users: if user[0] == username: stored_username = user[0] stored_password = user[1] # if user is not found, false if (stored_username == '' or stored_password == ''): return False # retrieves salt and stored password from pw string salt_length = 40 salt = stored_password[:salt_length] stored_hash = stored_password[salt_length:] # compares inputted password with hash and returns result hashable = salt + password hashable = hashable.encode('utf-8') this_hash = hashlib.sha1(hashable).hexdigest() return this_hash == stored_hash def verify_new_account(username, password): ''' Method used to determine if new account credentials are valid Parameters: username (str) : username entered by user password (str) : password entered by user Returns: status (bool) : status of if the new credentials are good or not ''' global lower_case, upper_case, nums, special # retrieves all users from db and makes a list of all usernames users = retrieve_accounts() taken_usernames = [] for accounts in users: taken_usernames.append(accounts[0]) # status of whether or not password contains the requirements requirement_one = len(password) >= 8 requirement_two = len(password) <= 25 requirement_three = username not in taken_usernames requirement_lower = False requierment_upper = False requirement_nums = False requirement_special = False for char in password: if char in lower_case: requirement_lower = True if char in upper_case: requierment_upper = True if char in nums: requirement_nums = True if char in special: requirement_special = True # SQL injection prevention for char in username: if char in special: return False status = False if (requirement_one and requirement_two and requirement_three and requirement_lower and requierment_upper and requirement_nums and requirement_special): status = True return status def random_password(): ''' Function to return randomly generated password Returns: password (str) : randomly generated password ''' global lower_case, upper_case, nums, special chars = [lower_case, upper_case, nums, special] password_length = random.randint(12, 16) password = '' for i in range(password_length): lib = chars[random.randint(0, 3)] char = lib[random.randint(0, len(lib) - 1)] password += char return password
28.709677
156
0.589045
431
3,560
4.740139
0.334107
0.020558
0.019579
0.026432
0.077827
0.077827
0.063632
0.029369
0.029369
0.029369
0
0.01236
0.272753
3,560
124
157
28.709677
0.776748
0.214607
0
0.129032
0
0
0.033784
0
0
0
0
0
0
1
0.048387
false
0.274194
0.032258
0
0.16129
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
39c13236092aa20981aa814b36bf7e898a69daef
343
py
Python
app.py
victorathanasio/KPI-test
cbc24ebc9b6e9304c7ff0428458c827d09bd99aa
[ "MIT" ]
null
null
null
app.py
victorathanasio/KPI-test
cbc24ebc9b6e9304c7ff0428458c827d09bd99aa
[ "MIT" ]
null
null
null
app.py
victorathanasio/KPI-test
cbc24ebc9b6e9304c7ff0428458c827d09bd99aa
[ "MIT" ]
null
null
null
from WebApp.mainapp import app import dash_html_components as html import flask from REST_API.rest_api import API from WebApp.Layout import Layout app.layout = Layout() app.server.register_blueprint(API) server = app.server if __name__ == '__main__': # app.run_server(debug=False, host='0.0.0.0', port=90) app.run_server(debug=True)
24.5
58
0.766764
56
343
4.428571
0.482143
0.024194
0.096774
0.137097
0
0
0
0
0
0
0
0.020067
0.12828
343
13
59
26.384615
0.809365
0.151604
0
0
0
0
0.027682
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0.1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
39cd57d3e96930bf2512f61084f0ec5dbd909936
2,129
py
Python
django_project/apps/qfauth/forms.py
gaohj/nzflask_bbs
36a94c380b78241ed5d1e07edab9618c3e8d477b
[ "Apache-2.0" ]
null
null
null
django_project/apps/qfauth/forms.py
gaohj/nzflask_bbs
36a94c380b78241ed5d1e07edab9618c3e8d477b
[ "Apache-2.0" ]
27
2020-02-12T07:55:58.000Z
2022-03-12T00:19:09.000Z
django_project/apps/qfauth/forms.py
gaohj/nzflask_bbs
36a94c380b78241ed5d1e07edab9618c3e8d477b
[ "Apache-2.0" ]
2
2020-02-18T01:54:55.000Z
2020-02-21T11:36:28.000Z
from django import forms from apps.forms import FormMixin from django.core import validators from .models import User from django.core.cache import cache class LoginForm(forms.Form,FormMixin): telephone = forms.CharField(max_length=11,min_length=11) password = forms.CharField(max_length=30,min_length=6,error_messages={"max_length":"密码最多不能超过30个字符","min_length":"密码最少不能少于6个字符"}) remember = forms.IntegerField(required=False) class RegisterForm(forms.Form,FormMixin): telephone = forms.CharField(max_length=11, min_length=11,validators=[validators.RegexValidator(r'1[3-9]\d{9}',message="请输入正确的手机号")]) username = forms.CharField(max_length=30) password1 = forms.CharField(max_length=30,min_length=6,error_messages={"max_length":"密码最多不能超过30个字符","min_length":"密码最少不能少于6个字符"}) password2 = forms.CharField(max_length=30,min_length=6,error_messages={"max_length":"密码最多不能超过30个字符","min_length":"密码最少不能少于6个字符"}) img_captcha = forms.CharField(max_length=4,min_length=4) sms_captcha = forms.CharField(max_length=4,min_length=4) def clean(self): cleaned_data = super(RegisterForm, self).clean() password1 = cleaned_data.get('password1') password2 = cleaned_data.get('password2') if password1 != password2: raise forms.ValidationError('两次密码输入不一致') #验证图形验证码 img_captcha = cleaned_data.get('img_captcha')#用户输入的 cache_img_captcha = cache.get(img_captcha.lower()) #缓存中的 print(cache_img_captcha) if not cache_img_captcha or img_captcha.lower() != cache_img_captcha.lower(): raise forms.ValidationError('图形验证码输入错误') #验证短信验证码 telephone = cleaned_data.get('telephone') sms_captcha = cleaned_data.get('sms_captcha') # 用户输入的 cache_sms_captcha = cache.get(telephone) # 缓存中的 if not cache_sms_captcha or sms_captcha.lower() != cache_sms_captcha.lower(): raise forms.ValidationError('短信验证码输入错误') exists = User.objects.filter(telephone=telephone).exists() if exists: forms.ValidationError('该手机号已经被注册') return cleaned_data
43.44898
136
0.716768
263
2,129
5.596958
0.277567
0.067255
0.092391
0.125
0.394022
0.326766
0.326766
0.326766
0.326766
0.27106
0
0.024803
0.166745
2,129
48
137
44.354167
0.804961
0.01597
0
0
0
0
0.115053
0
0
0
0
0
0
1
0.027778
false
0.166667
0.138889
0
0.5
0.027778
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
f2d302744caca38acace037f6391b1ffee2c8630
1,432
py
Python
src/minescrubber/controller.py
alok1974/minescrubber
0c18d960b385a4a59ac0cf38bc69271a23c667e7
[ "MIT" ]
1
2020-08-11T23:08:34.000Z
2020-08-11T23:08:34.000Z
src/minescrubber/controller.py
alok1974/minescrubber
0c18d960b385a4a59ac0cf38bc69271a23c667e7
[ "MIT" ]
null
null
null
src/minescrubber/controller.py
alok1974/minescrubber
0c18d960b385a4a59ac0cf38bc69271a23c667e7
[ "MIT" ]
null
null
null
from minescrubber_core import abstract from . import mainwindow class UI(abstract.UI): def __init__(self): self.main_window = mainwindow.MainWidget() def init_board(self, board): self.main_window.init_board(board) def refresh(self, board, init_image=True): self.main_window.refresh(board=board, init_image=init_image) def game_over(self, board): self.main_window.game_over(board=board) def game_solved(self, board): self.main_window.game_solved(board=board) def run(self): self.main_window.show() @property def new_game_signal(self): return self.main_window.NEW_GAME_SIGNAL @property def cell_selected_signal(self): return self.main_window.CELL_SELECTED_SIGNAL @property def cell_flagged_signal(self): return self.main_window.CELL_FLAGGED_SIGNAL @property def wiring_method_name(self): return 'connect' class Controller(abstract.Controller): def pre_callback(self): import sys from PySide2 import QtWidgets QtWidgets.QApplication(sys.argv) def post_callback(self): import sys from PySide2 import QtWidgets app = ( QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv) ) sys.exit(app.exec_()) def run(): controller = Controller() controller.run(ui_class=UI)
22.730159
68
0.670391
176
1,432
5.221591
0.272727
0.078346
0.137106
0.055495
0.292709
0.267682
0.176279
0.102285
0
0
0
0.001845
0.243017
1,432
62
69
23.096774
0.845941
0
0
0.232558
0
0
0.004888
0
0
0
0
0
0
1
0.302326
false
0
0.139535
0.093023
0.581395
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
f2d93f0a50f1963382d3895bbaf47dcf3e2de6e0
1,124
py
Python
routes/class_incoming.py
fingerecho/proms-4.0
6c3a1fd62c9394761664e100fc1dde50fd79dc11
[ "CC-BY-4.0" ]
2
2019-11-23T03:56:28.000Z
2019-12-03T15:48:34.000Z
routes/class_incoming.py
fingerecho/proms-4.0
6c3a1fd62c9394761664e100fc1dde50fd79dc11
[ "CC-BY-4.0" ]
null
null
null
routes/class_incoming.py
fingerecho/proms-4.0
6c3a1fd62c9394761664e100fc1dde50fd79dc11
[ "CC-BY-4.0" ]
3
2019-04-12T18:09:35.000Z
2020-03-14T14:38:45.000Z
from abc import ABCMeta, abstractmethod import database from . import w_l class IncomingClass(metaclass=ABCMeta): @abstractmethod def __init__(self, request): self.request = request self.graph = None self.uri = None self.named_graph_uri = None self.error_messages = None @abstractmethod def valid(self): pass @abstractmethod def determine_uri(self): pass def stored(self): """ Add an item to PROMS""" if self.graph is None or self.named_graph_uri is None: msg = 'The graph and the named_grapoh_uri properties of this class instance must not be None when trying ' \ 'to store this instance in the provenance DB.' self.error_messages = msg return False try: w_l(str(self.graph)) w_l(str(self.named_graph_uri)) database.insert(self.graph, self.named_graph_uri) return True except Exception as e: self.error_messages = ['Could not connect to the provenance database'] return False
29.578947
120
0.615658
141
1,124
4.758865
0.439716
0.053651
0.083458
0.101341
0
0
0
0
0
0
0
0
0.318505
1,124
37
121
30.378378
0.875979
0.017794
0
0.225806
0
0
0.169553
0
0
0
0
0
0
1
0.129032
false
0.064516
0.096774
0
0.354839
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
f2db2b20dcde6fe54280e2d0105ffc23c0015da0
404
py
Python
setup.py
TDGerve/ramCOH
328f27891906e7207344fb3c5a685648a0924dd2
[ "MIT" ]
2
2022-03-08T12:30:55.000Z
2022-03-29T19:46:59.000Z
setup.py
TDGerve/ramCOH
328f27891906e7207344fb3c5a685648a0924dd2
[ "MIT" ]
null
null
null
setup.py
TDGerve/ramCOH
328f27891906e7207344fb3c5a685648a0924dd2
[ "MIT" ]
null
null
null
import setuptools setuptools.setup( name= 'ramCOH', version= '0.1', description= '...', author= 'Thomas van Gerve', packages= setuptools.find_packages( exclude= ['examples'] ), # package_dir= {'' : 'petroPy'}, package_data= {'ramCOH': ['static/*']}, install_requires= [ 'pandas', 'matplotlib', 'numpy', 'scipy', 'csaps' ] )
17.565217
44
0.534653
34
404
6.235294
0.852941
0
0
0
0
0
0
0
0
0
0
0.00692
0.284653
404
23
45
17.565217
0.726644
0.074257
0
0
0
0
0.217158
0
0
0
0
0
0
1
0
true
0
0.055556
0
0.055556
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
1
f2e49a7f41a62f84a3de746b66ce03eb20e0b955
1,395
py
Python
ipython/data/parseSource/input.py
cainja/RMG-Py
f9ad0f4244e476a28768c8a4a37410ad55bcd556
[ "MIT" ]
1
2020-01-14T09:12:22.000Z
2020-01-14T09:12:22.000Z
ipython/data/parseSource/input.py
speth/RMG-Py
1d2c2b684580396e984459d9347628a5ceb80e2e
[ "MIT" ]
72
2016-06-06T18:18:49.000Z
2019-11-17T03:21:10.000Z
ipython/data/parseSource/input.py
speth/RMG-Py
1d2c2b684580396e984459d9347628a5ceb80e2e
[ "MIT" ]
3
2017-09-22T15:47:37.000Z
2021-12-30T23:51:47.000Z
# Data sources database( thermoLibraries = ['primaryThermoLibrary'], reactionLibraries = [('C3', False)], seedMechanisms = ['GRI-Mech3.0'], kineticsDepositories = ['training'], kineticsFamilies = 'default', kineticsEstimator = 'rate rules', ) # List of species species( label='ethane', reactive=True, structure=SMILES("CC"), ) species( label='N2', reactive=False, structure=adjacencyList(""" 1 N u0 p1 c0 {2,T} 2 N u0 p1 c0 {1,T} """), ) # Reaction systems simpleReactor( temperature=(1350,'K'), pressure=(1.0,'bar'), initialMoleFractions={ "ethane": 0.1, "N2": 0.9 }, terminationConversion={ 'ethane': 0.9, }, terminationTime=(1e6,'s'), ) simulator( atol=1e-16, rtol=1e-8, ) model( toleranceKeepInEdge=0.0, toleranceMoveToCore=0.1, toleranceInterruptSimulation=0.1, maximumEdgeSpecies=100000, ) options( units='si', saveRestartPeriod=None, generateOutputHTML=True, generatePlots=False, saveEdgeSpecies=True, saveSimulationProfiles=True, verboseComments=True, ) pressureDependence( method='modified strong collision', maximumGrainSize=(0.5,'kcal/mol'), minimumNumberOfGrains=250, temperatures=(300,2200,'K',2), pressures=(0.01,100,'bar',3), interpolation=('Chebyshev', 6, 4), maximumAtoms=15, )
19.375
47
0.632258
138
1,395
6.391304
0.710145
0.006803
0.011338
0.015873
0
0
0
0
0
0
0
0.064044
0.216487
1,395
71
48
19.647887
0.742909
0.032258
0
0.032787
0
0
0.138187
0
0
0
0
0
0
1
0
true
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
1
f2e593a65e27e8bb4c6dbcd20c5d00538ad0aa1c
438
py
Python
simbench/__init__.py
BaraaUniKassel/simbench
eca679bbef2b7c61d4a42dd9d9716ad969ff6f77
[ "BSD-3-Clause" ]
null
null
null
simbench/__init__.py
BaraaUniKassel/simbench
eca679bbef2b7c61d4a42dd9d9716ad969ff6f77
[ "BSD-3-Clause" ]
null
null
null
simbench/__init__.py
BaraaUniKassel/simbench
eca679bbef2b7c61d4a42dd9d9716ad969ff6f77
[ "BSD-3-Clause" ]
null
null
null
# Copyright (c) 2019-2021 by University of Kassel, Tu Dortmund, RWTH Aachen University and Fraunhofer # Institute for Energy Economics and Energy System Technology (IEE) Kassel and individual # contributors (see AUTHORS file for details). All rights reserved. __version__ = "1.3.0" __author__ = "smeinecke" import os sb_dir = os.path.dirname(os.path.realpath(__file__)) from simbench.converter import * from simbench.networks import *
33.692308
101
0.783105
61
438
5.409836
0.770492
0.036364
0
0
0
0
0
0
0
0
0
0.029101
0.136986
438
12
102
36.5
0.843915
0.577626
0
0
0
0
0.077348
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
8401c1577e1e3475bf83b16d801193d6422761d2
2,735
py
Python
dashboard/urls.py
playfulMIT/kimchi
66802cc333770932a8c8b1a44ea5d235d916a8f1
[ "MIT" ]
null
null
null
dashboard/urls.py
playfulMIT/kimchi
66802cc333770932a8c8b1a44ea5d235d916a8f1
[ "MIT" ]
16
2019-12-10T19:40:27.000Z
2022-02-10T11:51:06.000Z
dashboard/urls.py
playfulMIT/kimchi
66802cc333770932a8c8b1a44ea5d235d916a8f1
[ "MIT" ]
null
null
null
from django.conf.urls import include, url, re_path from rest_framework import routers from . import views urlpatterns = [ re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/versiontime", views.get_last_processed_time), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/players", views.get_player_list), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/sessions", views.get_player_to_session_map), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/puzzles", views.get_puzzles), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/puzzlekeys", views.get_puzzle_keys), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/snapshotsperpuzzle", views.get_snapshot_metrics), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/attempted", views.get_attempted_puzzles), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/completed", views.get_completed_puzzles), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/timeperpuzzle", views.get_time_per_puzzle), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/funnelperpuzzle", views.get_funnel_per_puzzle), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/shapesperpuzzle", views.get_shapes_per_puzzle), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/modesperpuzzle", views.get_modes_per_puzzle), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/levelsofactivity", views.get_levels_of_activity), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/sequencebetweenpuzzles", views.get_sequence_between_puzzles), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/mloutliers", views.get_machine_learning_outliers), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/persistence", views.get_persistence_by_attempt_data), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/puzzlepersistence", views.get_persistence_by_puzzle_data), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/insights", views.get_insights), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/difficulty", views.get_puzzle_difficulty_mapping), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/misconceptions", views.get_misconceptions_data), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/competency", views.get_competency_data), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/report/(?P<start>[0-9]+)/(?P<end>[0-9]+)", views.get_report_summary), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/report", views.get_report_summary), re_path(r"^api/dashboard/(?P<slug>[a-zA-Z0-9-_]+)/(?P<player>[a-zA-Z0-9-_.]+)/(?P<level>[a-zA-Z0-9-_.]+)/replayurls", views.get_replay_urls), re_path(r"^(?P<slug>[a-zA-Z0-9-_]+)/dashboard/", views.dashboard), re_path(r"^(?P<slug>[a-zA-Z0-9-_]+)/thesisdashboard/", views.thesis_dashboard) ]
80.441176
145
0.697623
460
2,735
3.891304
0.180435
0.046927
0.078212
0.093855
0.501676
0.497207
0.497207
0.497207
0.497207
0.477095
0
0.023447
0.064351
2,735
33
146
82.878788
0.676045
0
0
0
0
0.064516
0.51298
0.51298
0
0
0
0
0
1
0
false
0
0.096774
0
0.096774
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
841b950a79e8d2aae01b030de733c8d1017b6718
3,649
py
Python
libs/token.py
yareally/twitter-clone-python
1323c3fa4bf66f479a3092c09fb165a323eb1c85
[ "MIT" ]
1
2020-05-22T22:13:48.000Z
2020-05-22T22:13:48.000Z
libs/token.py
yareally/twitter-clone-python
1323c3fa4bf66f479a3092c09fb165a323eb1c85
[ "MIT" ]
null
null
null
libs/token.py
yareally/twitter-clone-python
1323c3fa4bf66f479a3092c09fb165a323eb1c85
[ "MIT" ]
null
null
null
# coding=utf-8 from operator import xor import os import scrypt import time from libs.rediswrapper import UserHelper try: xrange except NameError: xrange = range class Token(object): """ @param user_id: @type user_id: @param password: @type password: """ __BLOCK_SIZE = 256 __TRANS_5C = "".join(chr(x ^ 0x5c) for x in xrange(256)) __TRANS_36 = "".join(chr(x ^ 0x36) for x in xrange(256)) __I_SALT = os.urandom(16).encode('base_64') __O_SALT = os.urandom(16).encode('base_64') def __init__(self, user_id, password=None): self.user_id = user_id # get or create some password to encrypt the user verification token self.password = password #if password else self.redis.get('token_pass') if not self.password: salt = os.urandom(16).encode('base_64') self.password = scrypt.hash(os.urandom(24).encode('base_64'), salt) def generate_token(self): """ Generates an encrypted token for validating a user @return: the encrypted token (a random value and the date as a timestamp @rtype: str """ # random value, user_id, timestamp values = '%s,%s,%s' % (os.urandom(16).encode('base_64'), self.user_id, time.time()) return scrypt.encrypt(values, self.password) def generate_hmac(self, key, message): """ @param key: The user's generated password @type key: str @param message: message to hash for client-server authentication @type message: str @return: the hash based message auth code (to verify against the client sent one) @rtype: str @see: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code """ if len(key) > self.__BLOCK_SIZE: salt = os.urandom(16).encode('base_64') key = scrypt.hash(key, salt) key += chr(0) * (self.__BLOCK_SIZE - len(key)) o_key_pad = xor(self.__TRANS_5C, key) i_key_pad = xor(self.__TRANS_36, key) return scrypt.hash(o_key_pad + scrypt.hash(i_key_pad + message, self.__I_SALT), self.__O_SALT) def validate_token(self, client_token, server_token, expire_time=15): """ @param client_token: @type client_token: str @param server_token: @type server_token: str @param expire_time: @type expire_time: int @return: True if still valid @rtype: bool """ if client_token != server_token: return False tokens = scrypt.decrypt(client_token, self.password).split(',') if len(tokens) != 3: return False expired = ((time.time() - int(tokens[1])) / 3600) >= expire_time if expired: return False return True class RedisToken(Token): """ @param user_id: @type user_id: int @param redis_connection: @type redis_connection: StrictRedis @param password: @type password: str """ def __init__(self, user_id, redis_connection, password=None): """ @param user_id: @type user_id: int @param redis_connection @type redis_connection: StrictRedis @param password: @type password: str @return: @rtype: """ # get or create some password to encrypt the user verification token self.redis = UserHelper(redis_connection, user_id) self.password = password if password else self.redis.get('token_pass') super(RedisToken, self).__init__(user_id, password)
28.960317
102
0.609482
465
3,649
4.567742
0.270968
0.039548
0.033898
0.040019
0.324859
0.277778
0.267891
0.202448
0.202448
0.202448
0
0.020737
0.28638
3,649
125
103
29.192
0.794931
0.326391
0
0.106383
0
0
0.029285
0
0
0
0.003841
0
0
1
0.106383
false
0.191489
0.106383
0
0.489362
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
8438a4e8ec614cde523653248e7af3039519099a
463
py
Python
mqtt_sender.py
kehtolaulu/iot-ccs811
611ca30ffaec067d730ac95c59b6800fda2cf148
[ "MIT" ]
null
null
null
mqtt_sender.py
kehtolaulu/iot-ccs811
611ca30ffaec067d730ac95c59b6800fda2cf148
[ "MIT" ]
null
null
null
mqtt_sender.py
kehtolaulu/iot-ccs811
611ca30ffaec067d730ac95c59b6800fda2cf148
[ "MIT" ]
null
null
null
import json from paho.mqtt.client import Client from subscriber import Subscriber from datetime import datetime class MqttSender(Subscriber): def __init__(self, client: Client, topic: str): self.client = client self.topic = topic def on_next(self, message: dict): json_message = json.dumps(message) print(f'[{datetime.now().isoformat()}] Sending: {json_message}') self.client.publish(self.topic, json_message)
25.722222
72
0.695464
58
463
5.413793
0.448276
0.095541
0.101911
0
0
0
0
0
0
0
0
0
0.200864
463
17
73
27.235294
0.848649
0
0
0
0
0
0.116631
0.064795
0
0
0
0
0
1
0.166667
false
0
0.333333
0
0.583333
0.083333
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
844a39e610cb54a65514ca7f805b41f45b503518
3,021
py
Python
jarvis/resume/tests/test_utils.py
Anubhav722/blahblah
160698e06a02e671ac40de3113cd37d642e72e96
[ "MIT" ]
1
2019-01-03T06:10:04.000Z
2019-01-03T06:10:04.000Z
jarvis/resume/tests/test_utils.py
Anubhav722/blahblah
160698e06a02e671ac40de3113cd37d642e72e96
[ "MIT" ]
1
2021-03-31T19:11:52.000Z
2021-03-31T19:11:52.000Z
jarvis/resume/tests/test_utils.py
Anubhav722/blahblah
160698e06a02e671ac40de3113cd37d642e72e96
[ "MIT" ]
null
null
null
from django.test import TestCase from jarvis.resume.utils.extractor import get_text from jarvis.resume.utils.parser_helper import get_urls, get_url_response, url_categories, get_github_username, get_stackoverflow_userid, get_stackoverflow_username, get_name, get_id_from_linkedin_url, get_email from unidecode import unidecode path_to_test_data = 'resume/tests/test_data/1.pdf' urls = ['https://github.com/imnithin', 'http://imnithin.github.io', 'https://gist.github.com/imnithin', 'http://stackoverflow.com/users/2231236/nithin', 'https://www.linkedin.com/in/imnithink'] categories = {'blog': ['http://imnithin.github.io'], 'coding': [], 'contributions': ['https://github.com/imnithin', 'https://gist.github.com/imnithin'], 'forums': ['http://stackoverflow.com/users/2231236/nithin'], 'others': [], 'social': ['https://www.linkedin.com/in/imnithink']} url_response = [{'name': 'https://github.com/imnithin', 'type': 'contributions'}, {'name': 'https://gist.github.com/imnithin', 'type': 'contributions'}, {'name': 'https://www.linkedin.com/in/imnithink', 'type': 'social'}, {'name': 'http://imnithin.github.io', 'type': 'blog'}, {'name': 'http://stackoverflow.com/users/2231236/nithin', 'type': 'forums'}] class ParserHelperUtilsTest(TestCase): """Unit tests for Parser Helper Functions""" def setUp(self): self.text = get_text(path_to_test_data) def test_get_name(self): """Test User Name Obtained from jarvis.resume""" name = 'nithin' self.assertEqual(get_name(self.text)[0], name) def test_github_username(self): """Test GitHub Username""" github_user_name = 'imnithin' self.assertEqual(get_github_username(self.text), github_user_name) def test_stackoverflow_user_id(self): """Test StackOverflow user id""" stackoverflow_user_id = '2231236' self.assertEqual(get_stackoverflow_userid(self.text), stackoverflow_user_id) def test_stackoverflow_user_name(self): """Test StackOverflow User Name""" stackoverflow_user_name = 'nithin' self.assertEqual(get_stackoverflow_username(self.text), stackoverflow_user_name) def test_get_urls(self): self.assertEqual(get_urls(self.text), urls) def test_url_categories(self): values = list(categories.values()).sort() self.assertEqual(list(url_categories(urls).values()).sort(), values) def test_get_url_response(self): sorted_url_response = url_response.sort() self.assertEqual(get_url_response(categories).sort(), sorted_url_response) def test_get_id_from_linkedin_url(self): linkedin_id = 'imnithink' self.assertEqual(unidecode(get_id_from_linkedin_url(self.text)).strip(), linkedin_id) def test_get_email(self): email = '[email protected]' self.assertEqual(get_email(self.text)[0], email)
43.782609
210
0.676266
365
3,021
5.361644
0.191781
0.032192
0.064384
0.02606
0.237609
0.170158
0.043945
0
0
0
0
0.013333
0.180735
3,021
68
211
44.426471
0.777374
0.052301
0
0
0
0
0.249295
0.01763
0
0
0
0
0.2
1
0.222222
false
0
0.088889
0
0.333333
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
8463673ccc7d5d8251d46b1bed4eb08caa70dd68
1,054
py
Python
src/the_tale/the_tale/game/pvp/objects.py
al-arz/the-tale
542770257eb6ebd56a5ac44ea1ef93ff4ab19eb5
[ "BSD-3-Clause" ]
85
2017-11-21T12:22:02.000Z
2022-03-27T23:07:17.000Z
src/the_tale/the_tale/game/pvp/objects.py
al-arz/the-tale
542770257eb6ebd56a5ac44ea1ef93ff4ab19eb5
[ "BSD-3-Clause" ]
545
2017-11-04T14:15:04.000Z
2022-03-27T14:19:27.000Z
src/the_tale/the_tale/game/pvp/objects.py
al-arz/the-tale
542770257eb6ebd56a5ac44ea1ef93ff4ab19eb5
[ "BSD-3-Clause" ]
45
2017-11-11T12:36:30.000Z
2022-02-25T06:10:44.000Z
import smart_imports smart_imports.all() class BattleRequest: __slots__ = ('id', 'initiator_id', 'matchmaker_type', 'created_at', 'updated_at') def __init__(self, id, initiator_id, matchmaker_type, created_at, updated_at): self.id = id self.initiator_id = initiator_id self.matchmaker_type = matchmaker_type self.created_at = created_at self.updated_at = updated_at def ui_info(self): return {'id': self.id, 'initiator_id': self.initiator_id, 'matchmaker_type': self.matchmaker_type.value, 'created_at': time.mktime(self.created_at.timetuple()), 'updated_at': time.mktime(self.updated_at.timetuple())} class Battle: __slots__ = ('id', 'matchmaker_type', 'participants_ids', 'created_at') def __init__(self, id, matchmaker_type, participants_ids, created_at): self.id = id self.matchmaker_type = matchmaker_type self.participants_ids = participants_ids self.created_at = created_at
31.939394
85
0.66129
126
1,054
5.095238
0.214286
0.218069
0.124611
0.116822
0.507788
0.383178
0.383178
0.140187
0.140187
0
0
0
0.233397
1,054
32
86
32.9375
0.794554
0
0
0.26087
0
0
0.133903
0
0
0
0
0
0
1
0.130435
false
0
0.086957
0.043478
0.434783
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
8465fe705e2203a309cb2f80aab7f362306bc341
1,111
py
Python
testesDuranteAulas/aula019.py
Igor3550/Exercicios-de-python
e0f6e043df4f0770ac15968485fbb19698b4ac6b
[ "MIT" ]
null
null
null
testesDuranteAulas/aula019.py
Igor3550/Exercicios-de-python
e0f6e043df4f0770ac15968485fbb19698b4ac6b
[ "MIT" ]
null
null
null
testesDuranteAulas/aula019.py
Igor3550/Exercicios-de-python
e0f6e043df4f0770ac15968485fbb19698b4ac6b
[ "MIT" ]
null
null
null
# Dicionarios pessoas = {'nome': 'Igor', 'sexo': 'M', 'idade': 20} print(f'O {pessoas["nome"]} tem {pessoas["idade"]} anos.') print(pessoas.keys()) #chaves do dicionario print(pessoas.values())#valores das chaves print(pessoas.items())#mostra os itens do dicionario print() for k in pessoas.keys(): print(k) for v in pessoas.values(): print(v) for k, v in pessoas.items(): print(k, v) print() for k, v in pessoas.items(): print(f'{k} = {v}') print() del pessoas['sexo']# deleta uma chave pessoas['peso'] = 72# adiciona uma nova chave for k, v in pessoas.items(): print(f'{k} = {v}') print() # Dicionario dentro de uma lista brasil = [] estado1 = {'uf': 'Rio de Janeiro', 'sigla': 'RJ'} estado2 = {'uf': 'São Paulo', 'sigla': 'SP'} brasil.append(estado1) brasil.append(estado2) print(brasil[0]['uf']) print() brasil = list() estado = dict() for c in range(0, 3): estado['uf'] = str(input('Unidade federativa: ')) estado['sigla'] = str(input('Sigla: ')) brasil.append(estado.copy())# cópia de um dicionario for e in brasil: for k, v in e.items(): print(f'{k} = {v}')
26.452381
58
0.629163
170
1,111
4.111765
0.388235
0.02289
0.057225
0.040057
0.144492
0.125894
0.125894
0.091559
0.091559
0.091559
0
0.011905
0.168317
1,111
41
59
27.097561
0.744589
0.155716
0
0.297297
0
0
0.191604
0
0
0
0
0
0
1
0
false
0
0
0
0
0.432432
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
1
ffc1d0bbd0644054a0b22502249482b17c06c941
2,532
py
Python
tests/utils/test_commons.py
jajomi/flow
c984be6f7de1a34192601c129dbc19f2ce45f135
[ "Apache-2.0" ]
null
null
null
tests/utils/test_commons.py
jajomi/flow
c984be6f7de1a34192601c129dbc19f2ce45f135
[ "Apache-2.0" ]
6
2021-03-05T16:39:42.000Z
2021-06-11T01:04:57.000Z
tests/utils/test_commons.py
jajomi/flow
c984be6f7de1a34192601c129dbc19f2ce45f135
[ "Apache-2.0" ]
null
null
null
from unittest.mock import mock_open from unittest.mock import patch import flow.utils.commons as commons def test_extract_story_id_with_empty_list(): story_list = commons.extract_story_id_from_commit_messages([]) assert len(story_list) == 0 commit_example = [ "223342f Adding ability to specify artifactory user [#134082057]", "4326d00 Adding slack channel option for errors [#130798449]", "09c1983 Merge pull request #25 from ci-cd/revert-18-github-version-fix", "445fd02 Revert \"GitHub version fix\"" ] def test_extract_story_id_with_two_stories(): story_list = commons.extract_story_id_from_commit_messages(commit_example) assert len(story_list) == 2 commit_example_nested_brackets = [ "223342f Adding ability to specify artifactory user [#134082057, [bubba]]", "4326d00 Adding slack channel option for errors [#130798449]", "09c1983 Merge pull request #25 from ci-cd/revert-18-github-version-fix", "445fd02 Revert \"GitHub version fix\"" ] def test_extract_story_id_with_nested_brackets(): story_list = commons.extract_story_id_from_commit_messages(commit_example_nested_brackets) print(str(story_list)) assert len(story_list) == 1 commit_example_multiple_per_brackets = [ "223342f Adding ability to specify artifactory user [#134082057,#134082058]", "4326d00 Adding slack channel option for errors [#130798449,123456]", "09c1983 Merge pull request #25 from ci-cd/revert-18-github-version-fix", "445fd02 Revert \"GitHub version fix\"" ] def test_extract_story_id_with_multiple_per_brackets(): story_list = commons.extract_story_id_from_commit_messages(commit_example_multiple_per_brackets) print(str(story_list)) assert len(story_list) == 4 commit_example_dedup = [ "223342f Adding ability to specify artifactory user [#134082057,#134082057]", "4326d00 Adding slack channel option for errors [#134082057,134082057]", "09c1983 Merge pull request #25 from ci-cd/revert-18-github-version-fix", "445fd02 Revert \"GitHub version fix\"" ] def test_extract_story_id_with_dedup(): story_list = commons.extract_story_id_from_commit_messages(commit_example_dedup) print(str(story_list)) assert len(story_list) == 1 def test_write_to_file(): open_mock = mock_open() with patch('__main__.open', open_mock, create=True): commons.write_to_file("somefilepath", "test_write_to_file", open_func=open_mock) open_mock.assert_called_once_with("somefilepath", "a") file_mock = open_mock() file_mock.write.assert_called_once_with("test_write_to_file")
36.171429
100
0.781991
361
2,532
5.155125
0.213296
0.062869
0.075228
0.051048
0.750672
0.711445
0.698012
0.698012
0.588393
0.430951
0
0.097846
0.120063
2,532
69
101
36.695652
0.737433
0
0
0.288462
0
0
0.376777
0.080569
0
0
0
0
0.134615
1
0.115385
false
0
0.057692
0
0.173077
0.057692
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
ffc57756064cdbfdff55d925646e8ab713a50ba6
1,675
py
Python
timeseries/test.py
zoobree/MachineLearning
67fd35e67469d9f03afd5c090f2ca23f514bebfd
[ "Apache-2.0" ]
null
null
null
timeseries/test.py
zoobree/MachineLearning
67fd35e67469d9f03afd5c090f2ca23f514bebfd
[ "Apache-2.0" ]
1
2018-04-07T05:24:40.000Z
2018-04-07T05:24:40.000Z
timeseries/test.py
joybree/MachineLearning
69a381efa35436a6d211005c320576db966eea11
[ "Apache-2.0" ]
null
null
null
# -*- coding: utf-8 -*- import unittest import arima import os import pandas as pd class Arima_Test(unittest.TestCase): def set_data_dir(self): print("set_data_dir") self.dir = "E:/code/python/MachineLearning/data/test_data/" self.error = 0.001 self.num_percent = 0.9 def test_result_one_point(self): true_num = 0 false_num = 0 print("****test_result_compare****") self.set_data_dir() filelist = os.listdir(self.dir) list_ts_data = [] for file_name in filelist: df_data = pd.read_csv(self.dir+file_name, encoding='utf-8', index_col='date') df_data.index = pd.to_datetime(df_data.index) ts_data = df_data['value'] list_ts_data.append(ts_data) prediction_value, prediction_var, prediction_con = arima.prediction(ts_data, pre_num=1) print(prediction_value[0]) print(ts_data[-1]) if abs(prediction_value[0] - ts_data[-1])/ts_data[-1] <= self.error: true_num = true_num + 1 else: false_num = false_num + 1 print(true_num) print(false_num) self.assertGreaterEqual(true_num / (true_num + false_num), self.num_percent) def test_result_two_point(self): pass def test_result_three_point(self): pass def test_trend(self): """ increase or decrease """ pass def test_obj_number(self): pass def test_run_time(self): pass def test_write_result(self): pass if __name__ == "__main__": unittest.main()
25.769231
99
0.587463
220
1,675
4.145455
0.345455
0.052632
0.060307
0.065789
0.04386
0
0
0
0
0
0
0.015491
0.306269
1,675
64
100
26.171875
0.769363
0.025672
0
0.130435
0
0
0.066542
0.045398
0
0
0
0
0.021739
1
0.173913
false
0.130435
0.086957
0
0.282609
0.130435
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
ffde4e382f893654ea15768c8c27165eee09e3a4
3,720
py
Python
src/Control/Sign.py
hieuhdh/Multi-tasking-program
2f064a554f647247c84979b7a27f0797d1e1b5af
[ "MIT" ]
null
null
null
src/Control/Sign.py
hieuhdh/Multi-tasking-program
2f064a554f647247c84979b7a27f0797d1e1b5af
[ "MIT" ]
null
null
null
src/Control/Sign.py
hieuhdh/Multi-tasking-program
2f064a554f647247c84979b7a27f0797d1e1b5af
[ "MIT" ]
null
null
null
from tkinter.font import BOLD from PIL import ImageTk from tkinter import* from PIL import Image from tkinter import messagebox from Tools.log_db import* class Sign: def __init__(self, root): self.root = root ## Init frame and button Frame_sign = Frame(self.root, bg="#120b26") Frame_sign.place(x = 300,y = 0, height = 540, width=660) global image_default_signup image_default_signup = ImageTk.PhotoImage(file = 'images/interfaces/signup.png') logo_default = Label(Frame_sign, image = image_default_signup ) logo_default.place( x = 0, y = 0, relheight = 1, relwidth = 1 ) self.txt_name = Entry(Frame_sign, font=("Times New Roman",15), fg = "#8078c4", bg = "#120b26", cursor="hand2", bd = 0, width = 10) self.txt_name.place(x = 180, y = 175, height= 34, width= 326) self.txt_username = Entry(Frame_sign, font=("Times New Roman", 15), fg = "#8078c4", bg = "#120b26", cursor = "hand2", bd = 0) self.txt_username.place(x = 180, y = 248, height= 34, width= 326) self.txt_password = Entry(Frame_sign, font=("Times New Roman",15), fg = "#8078c4",bg = "#120b26", cursor = "hand2", show = "*", bd = 0, highlightbackground = "#b0bde0") self.txt_password.place(x = 180, y = 321, height= 34, width= 326) self.txt_password_comfirm = Entry(Frame_sign, font = ("Times New Roman",15), fg = "#8078c4",bg = "#120b26", cursor = "hand2", show = "*", bd = 0) self.txt_password_comfirm.place(x = 180, y = 394, height= 34, width= 326) ## Make sign in button self.sign_btn = Button(Frame_sign, activebackground="#823af7", activeforeground="white",command=self.sign, text = "Submit", font = ("Times New Roman",12,"bold"), fg = "#211c49", bg = "#823af7", relief = "flat", cursor = "hand2", borderwidth = 0, width = 38) self.sign_btn.place(x = 156, y = 470) ## Action for Sign in def sign(self): if self.txt_name.get() != "" and self.txt_username.get() != "" and self.txt_password.get() != "" and self.txt_password_comfirm !="": if self.txt_password.get() != self.txt_password_comfirm.get(): messagebox.showerror("Error","Your password didn't get match!", parent = self.root) else: ## Add username and password in file log.txt, Dont see username and password you just entered in database, add it username = self.txt_username.get() password = encode(self.txt_password.get()) arr = [username, password] if checkDB_Sign(arr) == False: file = open("src/Documents/log_sign.txt","a", encoding= "utf-8") file.writelines(f"name-username-password: {self.txt_name.get()}; {username}; {password}\n") messagebox.showinfo("Welcome","You are registered successfully!", parent = self.root) file.close() else: messagebox.showerror("Error","Account already exists!", parent = self.root) else: if self.txt_name.get() == "": messagebox.showerror("Error","Please, enter your full name!", parent = self.root) elif self.txt_username.get() == "": messagebox.showerror("Error","Please, enter your username!", parent = self.root) elif self.txt_password.get() == "": messagebox.showerror("Error","Please, enter your password!", parent = self.root) elif self.txt_password_comfirm.get() == "": messagebox.showerror("Error","Please, enter your password comfirm!", parent = self.root)
53.913043
265
0.596774
466
3,720
4.654506
0.291845
0.067773
0.076072
0.039189
0.344398
0.311664
0.289534
0.198709
0.119871
0.119871
0
0.054241
0.261559
3,720
69
266
53.913043
0.735348
0.045968
0
0.061224
0
0
0.165772
0.027958
0
0
0
0
0
1
0.040816
false
0.285714
0.122449
0
0.183673
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
ffe63e2dda8d22501b711fdd07b98a6cfff2ea5a
2,484
py
Python
bot/PythonProject/Commands.py
RamaDev09/CrateBot
34b9f50b88da42cc1c449466402897340ec142df
[ "MIT" ]
null
null
null
bot/PythonProject/Commands.py
RamaDev09/CrateBot
34b9f50b88da42cc1c449466402897340ec142df
[ "MIT" ]
null
null
null
bot/PythonProject/Commands.py
RamaDev09/CrateBot
34b9f50b88da42cc1c449466402897340ec142df
[ "MIT" ]
null
null
null
import os from bot.TextInput import TextInput from bot.prompt import color_msg def PythonCommands(file, name, category, description, slash): here = os.getcwd() # Writing a new import line cogs = file['config']['commands'] = [] cogs.append(name) with open(here + "/main.py", "r") as f : lines = f.readlines() line = 0 for i in lines : line += 1 if lines[line - 1] == "\n" : break lines[line - 1] = f"from cogs.commands.{category}.{name} import {category}\n" with open(here + "/main.py", "w") as f : f.writelines(lines) f.close() if not slash['slash-command'] : try : dir = os.path.join(here + "/cogs/commands", category) os.mkdir(dir) try : with open(here + "/cogs/commands/" + category + "/" + name + ".py", "x") as f : f.write( TextInput.CommandPy(self=TextInput(), name=name, category=category, description=description)) color_msg("#00FF00", "Command Created") except FileExistsError : color_msg("#ff0000", "Command Already Exits") except FileNotFoundError : color_msg("#ff0000", "Make sure you are in CrateBot Project") except FileExistsError : try : with open(here + "/cogs/commands/" + category + "/" + name + ".py", "x") as f : f.write( TextInput.CommandPy(self=TextInput(), name=name, category=category, description=description)) color_msg("#00FF00", "Command Created") except FileExistsError : color_msg("#ff0000", "Command Already Exits") else : try : dir = os.path.join(here + "/cogs/commands", category) os.mkdir(dir) try : with open(here + "/cogs/commands/" + category + "/" + name + ".py", "x") as f : f.write( TextInput.CommandSlashPy(self=TextInput(), name=name, category=category, description=description)) color_msg("#00FF00", "Command Created") except FileExistsError : color_msg("#ff0000", "Command Already Exits") except FileNotFoundError : color_msg("#ff0000", "Make sure you are in CrateBot Project")
45.163636
118
0.517311
252
2,484
5.063492
0.285714
0.056426
0.094044
0.094044
0.699843
0.67163
0.67163
0.67163
0.67163
0.67163
0
0.022556
0.357488
2,484
55
119
45.163636
0.776942
0.010064
0
0.596154
0
0
0.178453
0.012895
0
0
0
0
0
1
0.019231
false
0
0.076923
0
0.096154
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
fff46233cd9fc6a4821a3755e7bb2b8fd09e058e
1,030
py
Python
read_trials.py
Volkarl/P10-ExoskeletonTransferLearning
311daf3791c65838ff9c496eeb6526b096b41d4c
[ "MIT" ]
null
null
null
read_trials.py
Volkarl/P10-ExoskeletonTransferLearning
311daf3791c65838ff9c496eeb6526b096b41d4c
[ "MIT" ]
2
2020-11-13T18:39:27.000Z
2021-08-25T15:59:36.000Z
read_trials.py
Volkarl/P10-ExoskeletonTransferLearning
311daf3791c65838ff9c496eeb6526b096b41d4c
[ "MIT" ]
null
null
null
import pickle import matplotlib.pyplot as plt import pandas as pd trials = pickle.load(open("trials.p", "rb")) print("Set breakpoint here") #for item in trials.trials: # args = item["vals"] # res = item["result"]["loss"] #itemtuples = [(item["misc"]["vals"]["dilation_group"], item["misc"]["vals"]["use_ref_points"], item["result"]["loss"]) for item in trials.trials] #(dil, ref, loss) = zip(*itemtuples) #plt.figure() #plt.plot(dil, 'ro') #plt.title('Use_dilation (1 is true, 0 is false)') #plt.plot(loss) #plt.plot(pd.DataFrame(loss).ewm(span=1).mean()) #plt.title('MAE') #plt.plot(ref, 'g^') #plt.legend() #plt.show() print("Set breakpoint here") print("PRINT BEST TRIALS") myitems = [(trial["result"]["loss"], str(trial["misc"]["vals"])) for trial in trials.trials if trial["result"]["status"] == "ok"] myitems.sort(key=lambda tup: tup[0]) for item in myitems[:10]: print("--------------------------\n") print(item) print("\n\n") # If you want to print training times use attemptid["book_time"]
24.52381
146
0.635922
154
1,030
4.220779
0.467532
0.043077
0.041538
0.067692
0.064615
0
0
0
0
0
0
0.006659
0.125243
1,030
41
147
25.121951
0.714761
0.506796
0
0.153846
0
0
0.262195
0.056911
0
0
0
0
0
1
0
false
0
0.230769
0
0.230769
0.461538
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
1
fff5fae09ca4ba6758cfde4e7471355a0e7af098
3,506
py
Python
RecRoomAnimatedProfilePicture.py
zigzatuzoo/Rec-Room-Animated-Profile-Picture
b8eeabf478613f47d3bdb9195ad2f5051e7aaaad
[ "Apache-2.0" ]
4
2021-08-17T01:13:03.000Z
2022-03-19T04:03:01.000Z
RecRoomAnimatedProfilePicture.py
zigzatuzoo/Rec-Room-Animated-Profile-Picture
b8eeabf478613f47d3bdb9195ad2f5051e7aaaad
[ "Apache-2.0" ]
null
null
null
RecRoomAnimatedProfilePicture.py
zigzatuzoo/Rec-Room-Animated-Profile-Picture
b8eeabf478613f47d3bdb9195ad2f5051e7aaaad
[ "Apache-2.0" ]
null
null
null
''' Stuff you need to update for this to work ''' 'Enter your username here' user = '' 'Enter your password here' passwd = '' image1 = '2d83af05944d49c69fa9565fb238a91b.jpg' image2 = '49b2788b672e4088a25eb0a9eff35c17.jpg' image3 = '355c2c7e87f0489bb5f0308cdec108f6.jpg' " ^ You need to change EACH of these to whatever you want the 3 pics to be (Currently set to a waving red zigzag)" ''' Stuff that will change how the program works ''' speed = 0.2 "^ As you can probably guess, this changes how long the PFP stays on each image" import time try: import requests except: print('''You do not have the requests library installed, you need to install it via the following command: pip install requests Thank you!''') try: import recnetlogin as rnl except: print('''You do not have the RecNetLogin package installed, you need to install it via the following command: python -m pip install git+https://github.com/Jegarde/RecNet-Login.git#egg=recnetlogin Thank you!''') ''' Just Initializing some values ''' login = rnl.login_to_recnet(username=user,password=passwd) x = 0 BToken = '' ''' Making the strings into the format read by the rec.net image api ''' imageName1 = 'imageName=' + image1 imageName2 = 'imageName=' + image2 imageName3 = 'imageName=' + image3 ''' Initial token request ''' BToken = login.access_token print(BToken) ''' The loop program that actually makes the picure move ''' while 1 == 1: ''' The HTTP header for changing your In-Game pfp ''' Headers = {'sec-ch-ua':'";Not A Brand";v="99", "Chromium";v="88"', 'Accept' : '*/*', 'sec-ch-ua-mobile' : '?0', 'Authorization' : BToken, 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8', 'Origin' : 'https://rec.net', 'Sec-Fetch-Site' : 'same-site', 'Sec-Fetch-Mode' : 'cors', 'Sec-Fetch-Dest' : 'empty', 'Referer' : 'https://rec.net/', 'Accept-Encoding' : 'gzip, deflate', 'Accept-Language' : 'en-US,en;q=0.9', } ''' The easy way to edit what pfp plays after what ''' def i1(): r = requests.put('https://accounts.rec.net/account/me/profileImage', headers = Headers, data = imageName1) print(str(r) + " num of requests: " + str(x)) time.sleep(speed) def i2(): r = requests.put('https://accounts.rec.net/account/me/profileImage', headers = Headers, data = imageName2) print(str(r) + " num of requests: " + str(x)) time.sleep(speed) def i3(): r = requests.put('https://accounts.rec.net/account/me/profileImage', headers = Headers, data = imageName3) print(str(r) + " num of requests: " + str(x)) time.sleep(speed) ''' In this default format, it will show image 1 first, then image 2, then image 3, then image 2 again and will LOOP this. The x value in the function calls is to make the counter function, if you don't add it to your function calls or you delete them, THE COUNTER WILL NOT WORK. ''' x = x + 1 i1() x = x + 1 i2() x = x + 1 i3() x = x + 1 i2() ''' Requests a new auth token when that one is no longer valid ''' r = requests.put('https://accounts.rec.net/account/me/profileImage', headers = Headers) if r.status_code == 401: print('Invalid Token') login = rnl.login_to_recnet(username=user,password=passwd) BToken = login.access_token print(BToken)
35.77551
287
0.634341
487
3,506
4.552361
0.431212
0.018945
0.016238
0.030672
0.321155
0.321155
0.291385
0.26793
0.26793
0.22553
0
0.039508
0.23474
3,506
97
288
36.14433
0.786806
0.011694
0
0.338028
0
0.028169
0.470738
0.051618
0
0
0
0
0
1
0.042254
false
0.056338
0.042254
0
0.084507
0.112676
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
ffff1e4cd8bc9bad42ca402b2c639f4b45a16abe
791
py
Python
pirates/quest/QuestHolderBase.py
itsyaboyrocket/pirates
6ca1e7d571c670b0d976f65e608235707b5737e3
[ "BSD-3-Clause" ]
3
2021-02-25T06:38:13.000Z
2022-03-22T07:00:15.000Z
pirates/quest/QuestHolderBase.py
itsyaboyrocket/pirates
6ca1e7d571c670b0d976f65e608235707b5737e3
[ "BSD-3-Clause" ]
null
null
null
pirates/quest/QuestHolderBase.py
itsyaboyrocket/pirates
6ca1e7d571c670b0d976f65e608235707b5737e3
[ "BSD-3-Clause" ]
1
2021-02-25T06:38:17.000Z
2021-02-25T06:38:17.000Z
# uncompyle6 version 3.2.0 # Python bytecode 2.4 (62061) # Decompiled from: Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] # Embedded file name: pirates.quest.QuestHolderBase class QuestHolderBase: __module__ = __name__ def __init__(self): self._rewardCollectors = {} def getQuests(self): raise 'derived must implement' def _addQuestRewardCollector(self, collector): cId = collector._serialNum self._rewardCollectors[cId] = collector def _removeQuestRewardCollector(self, collector): cId = collector._serialNum del self._rewardCollectors[cId] def _trackRewards(self, trade): for collector in self._rewardCollectors.itervalues(): collector.collect(trade)
30.423077
104
0.694058
89
791
5.932584
0.629213
0.151515
0.060606
0.094697
0.128788
0
0
0
0
0
0
0.072231
0.212389
791
26
105
30.423077
0.775281
0.259166
0
0.133333
0
0
0.037801
0
0
0
0
0
0
1
0.333333
false
0
0
0
0.466667
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0811b7481588bc53cfde102ac50bffe1f9e0e41c
161
py
Python
velocity/constants.py
aisthesis/mfstockmkt
d442ec4cb3b379f6984397926b4466420236c032
[ "MIT" ]
null
null
null
velocity/constants.py
aisthesis/mfstockmkt
d442ec4cb3b379f6984397926b4466420236c032
[ "MIT" ]
1
2015-12-27T17:37:54.000Z
2015-12-31T05:06:06.000Z
velocity/constants.py
aisthesis/mfstockmkt
d442ec4cb3b379f6984397926b4466420236c032
[ "MIT" ]
1
2020-05-02T08:25:35.000Z
2020-05-02T08:25:35.000Z
""" .. Copyright (c) 2015 Marshall Farrier license http://opensource.org/licenses/MIT Constants ========= """ UPVEL_COL = 'Up Vel' DOWNVEL_COL = 'Down Vel'
14.636364
45
0.652174
20
161
5.15
0.9
0
0
0
0
0
0
0
0
0
0
0.029412
0.15528
161
10
46
16.1
0.727941
0.652174
0
0
0
0
0.291667
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
081745d5d369bb388f32e0870139795f7243852c
213
py
Python
tuples-and-sets/3_unique_names.py
Minkov/python-advanced-2020-01
f2ee26f1325d943529673457a1cbba5657ae5905
[ "MIT" ]
5
2020-01-16T18:17:08.000Z
2020-04-12T06:42:47.000Z
tuples-and-sets/3_unique_names.py
Minkov/python-advanced-2020-01
f2ee26f1325d943529673457a1cbba5657ae5905
[ "MIT" ]
null
null
null
tuples-and-sets/3_unique_names.py
Minkov/python-advanced-2020-01
f2ee26f1325d943529673457a1cbba5657ae5905
[ "MIT" ]
null
null
null
n = int(input()) # names = {input() for _ in range(n)} names = [] for _ in range(n): names.append(input()) unique_names = list(set(names)) [print(name) for name in sorted(unique_names, key=names.index)]
15.214286
42
0.643192
33
213
4.030303
0.484848
0.075188
0.150376
0.165414
0.240602
0
0
0
0
0
0
0
0.178404
213
13
43
16.384615
0.76
0.164319
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.125
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
08217e660e94837e28763173bb72fbc25fe9ee5e
216
py
Python
locale/pot/api/plotting/_autosummary/pyvista-Plotter-enable_lightkit-1.py
tkoyama010/pyvista-doc-translations
23bb813387b7f8bfe17e86c2244d5dd2243990db
[ "MIT" ]
4
2020-08-07T08:19:19.000Z
2020-12-04T09:51:11.000Z
locale/pot/api/plotting/_autosummary/pyvista-Plotter-enable_lightkit-1.py
tkoyama010/pyvista-doc-translations
23bb813387b7f8bfe17e86c2244d5dd2243990db
[ "MIT" ]
19
2020-08-06T00:24:30.000Z
2022-03-30T19:22:24.000Z
locale/pot/api/plotting/_autosummary/pyvista-Plotter-enable_lightkit-1.py
tkoyama010/pyvista-doc-translations
23bb813387b7f8bfe17e86c2244d5dd2243990db
[ "MIT" ]
1
2021-03-09T07:50:40.000Z
2021-03-09T07:50:40.000Z
# Create a plotter without any lights and then enable the # default light kit. # import pyvista pl = pyvista.Plotter(lighting=None) pl.enable_lightkit() actor = pl.add_mesh(pyvista.Cube(), show_edges=True) pl.show()
24
57
0.763889
34
216
4.764706
0.764706
0
0
0
0
0
0
0
0
0
0
0
0.125
216
8
58
27
0.857143
0.342593
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.2
0
0.2
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0822f1091f07394bee07ab3fa63b7142aa217e7c
1,353
py
Python
sphinx/environment/managers/__init__.py
rweickelt/sphinx
1a4c41a7691e8f78d42e2db221192962c53b27df
[ "BSD-2-Clause" ]
null
null
null
sphinx/environment/managers/__init__.py
rweickelt/sphinx
1a4c41a7691e8f78d42e2db221192962c53b27df
[ "BSD-2-Clause" ]
null
null
null
sphinx/environment/managers/__init__.py
rweickelt/sphinx
1a4c41a7691e8f78d42e2db221192962c53b27df
[ "BSD-2-Clause" ]
null
null
null
# -*- coding: utf-8 -*- """ sphinx.environment.managers ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Manager components for sphinx.environment. :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ if False: # For type annotation from typing import Any # NOQA from docutils import nodes # NOQA from sphinx.environment import BuildEnvironment # NOQA class EnvironmentManager(object): """Base class for sphinx.environment managers.""" name = None # type: unicode env = None # type: BuildEnvironment def __init__(self, env): # type: (BuildEnvironment) -> None self.env = env def attach(self, env): # type: (BuildEnvironment) -> None self.env = env if self.name: setattr(env, self.name, self) def detach(self, env): # type: (BuildEnvironment) -> None self.env = None if self.name: delattr(env, self.name) def clear_doc(self, docname): # type: (unicode) -> None raise NotImplementedError def merge_other(self, docnames, other): # type: (List[unicode], Any) -> None raise NotImplementedError def process_doc(self, docname, doctree): # type: (unicode, nodes.Node) -> None raise NotImplementedError
26.529412
68
0.604582
146
1,353
5.554795
0.40411
0.051788
0.040691
0.099877
0.147965
0.147965
0.147965
0.10111
0
0
0
0.009165
0.274205
1,353
50
69
27.06
0.816701
0.397635
0
0.304348
0
0
0
0
0
0
0
0
0
1
0.26087
false
0
0.130435
0
0.521739
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
08235f7faf3865296eebd91470431d320d7b228e
370
py
Python
createGlobalMap.py
abhi20sc/autoClim
b131a19e935e8ba7778a2c73107a183df37e92da
[ "MIT" ]
2
2021-07-28T05:58:20.000Z
2021-08-16T18:27:27.000Z
createGlobalMap.py
abhi20sc/autoClim
b131a19e935e8ba7778a2c73107a183df37e92da
[ "MIT" ]
null
null
null
createGlobalMap.py
abhi20sc/autoClim
b131a19e935e8ba7778a2c73107a183df37e92da
[ "MIT" ]
3
2021-08-05T15:21:05.000Z
2021-10-04T03:42:16.000Z
import cartopy.crs as ccrs import cartopy.feature as cf from matplotlib import pyplot as plt from matplotlib import image as img def createMap(): fig = plt.figure() ax = plt.axes(projection=ccrs.PlateCarree()) ax.coastlines(linewidth=1) ax.add_feature(cf.BORDERS,linestyle='-',linewidth=1) fig.savefig('globalMap.png', bbox_inches='tight', pad_inches=0) return 0.
30.833333
64
0.767568
57
370
4.929825
0.631579
0.092527
0.142349
0
0
0
0
0
0
0
0
0.012158
0.110811
370
12
65
30.833333
0.841945
0
0
0
0
0
0.051213
0
0
0
0
0
0
1
0.090909
false
0
0.363636
0
0.545455
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
08248ac0b1e2686f247d443d0208fc7018480282
1,327
py
Python
test/test_merge.py
tawiesn/sclblonnx
0cf73112db5df13009cd2ddb5d49744689096209
[ "MIT" ]
null
null
null
test/test_merge.py
tawiesn/sclblonnx
0cf73112db5df13009cd2ddb5d49744689096209
[ "MIT" ]
null
null
null
test/test_merge.py
tawiesn/sclblonnx
0cf73112db5df13009cd2ddb5d49744689096209
[ "MIT" ]
null
null
null
from sclblonnx import add_output, add_input, add_node, node, empty_graph, add_constant, display, merge, run import numpy as np def test_merge(): # Subgraph 1 sg1 = empty_graph("Graph 1") n1 = node('Add', inputs=['x1', 'x2'], outputs=['sum']) sg1 = add_node(sg1, n1) sg1 = add_input(sg1, 'x1', "FLOAT", [1]) sg1 = add_input(sg1, 'x2', "FLOAT", [1]) sg1 = add_output(sg1, 'sum', "FLOAT", [1]) # Subgraph 2 sg2 = empty_graph("Graph 2") sg2 = add_constant(sg2, "const", np.array([7]), "FLOAT") n2 = node("Equal", inputs=['sum', 'const'], outputs=['equal']) sg2 = add_node(sg2, n2) sg2 = add_input(sg2, 'sum', "FLOAT", [1]) sg2 = add_output(sg2, 'equal', "BOOL", [1]) g = merge(sg1, sg2, outputs=["sum"], inputs=["sum"]) in1 = {"x1": np.array([2]).astype(np.float32), "x2": np.array([5]).astype(np.float32)} result = run(g, inputs=in1, outputs=["equal"]) assert result[0], "Sum of 2 and 5 should be equal to constant 7." in2 = {"x1": np.array([4]).astype(np.float32), "x2": np.array([5]).astype(np.float32)} result = run(g, inputs=in2, outputs=["equal"]) assert not result[0], "Sum of 4 and 5 should not be equal to constant 7." # todo(McK): Add tests for multiple inputs-outputs # todo(McK): Add tests for graphs containing If
34.025641
107
0.605124
206
1,327
3.820388
0.291262
0.044473
0.076239
0.035578
0.233799
0.142313
0.142313
0.142313
0.142313
0.142313
0
0.06203
0.198191
1,327
38
108
34.921053
0.677632
0.087415
0
0
0
0
0.173732
0
0
0
0
0.026316
0.090909
1
0.045455
false
0
0.090909
0
0.136364
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0836babd9f72c506519d713c961b9257fd759c19
447
py
Python
tests/my_select_group.py
oldjun/PyMyORM
ac49910f21d3f3d3d4b3d75a0f998526963f0a2a
[ "MIT" ]
1
2021-12-01T23:47:24.000Z
2021-12-01T23:47:24.000Z
tests/my_select_group.py
oldjun/PyMyORM
ac49910f21d3f3d3d4b3d75a0f998526963f0a2a
[ "MIT" ]
null
null
null
tests/my_select_group.py
oldjun/PyMyORM
ac49910f21d3f3d3d4b3d75a0f998526963f0a2a
[ "MIT" ]
2
2022-01-03T15:03:37.000Z
2022-02-16T09:00:58.000Z
from pymyorm.database import Database from config import db from models.user import User if __name__ == '__main__': Database.connect(**db) # # case 1 # all = User.find().select('count(*) as count', 'money').group('money').order('count asc').all() # for one in all: # print(one) all = User.find().select('gender', 'count(*) as count', 'avg(money) as avg').group('gender').all() for one in all: print(one)
27.9375
102
0.615213
63
447
4.238095
0.460317
0.052434
0.082397
0.127341
0.164794
0.164794
0.164794
0
0
0
0
0.002825
0.208054
447
15
103
29.8
0.751412
0.295302
0
0
0
0
0.175325
0
0
0
0
0
0
1
0
false
0
0.375
0
0.375
0.125
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
083f30db4f011f2e287409fe5ae43ef0e966b47a
3,943
py
Python
tests/test_step.py
arup-group/mc
50b8faa8b9d40dece88e0a27f911edd427ebc064
[ "MIT" ]
null
null
null
tests/test_step.py
arup-group/mc
50b8faa8b9d40dece88e0a27f911edd427ebc064
[ "MIT" ]
12
2021-12-14T15:10:43.000Z
2022-03-31T13:39:25.000Z
tests/test_step.py
arup-group/mc
50b8faa8b9d40dece88e0a27f911edd427ebc064
[ "MIT" ]
null
null
null
from pathlib import Path import pytest from copy import deepcopy import os from mc.base import BaseConfig from mc import step @pytest.fixture() def config(): in_file = Path("tests/test_data/test_config.xml") return BaseConfig(in_file) def test_set_write_path(config): step.set_write_path(config, {'outputDirectory': 'testing'}) assert config['controler']['outputDirectory'] == 'testing' def test_set_input_paths(config): step.set_input_paths(config, {'matsim_source': 'test/ing'}) assert config['network']['inputNetworkFile'] == 'test/ing/network.xml' assert config['plans']['inputPlansFile'] == 'test/ing/population.xml.gz' assert config['plans']['inputPersonAttributesFile'] == 'test/ing/population_attributes.xml.gz' assert config['transit']['transitScheduleFile'] == 'test/ing/schedule-merged.xml' assert config['transit']['vehiclesFile'] == 'test/ing/vehicles.xml' assert config['transit']['transitLinesAttributesFile'] == 'null' def test_set_step(config): step.set_last_iteration(config, {'step': '999'}) assert config['controler']['lastIteration'] == '999' def test_find_and_set_param(config): step.find_and_set_overrides( config, {"modeParams:car/constant": "-1.0"} ) assert config['planCalcScore']['scoringParameters:default']['modeParams:car']["constant"] == "-1.0" assert config['planCalcScore']['scoringParameters:unknown']['modeParams:car']["constant"] == "-1.0" assert config['planCalcScore']['scoringParameters:unknown']['modeParams:bus']["constant"] == "0.0" def test_find_and_set_params(config): step.find_and_set_overrides( config, { "modeParams:car/constant": "-1.0", "scoringParameters:unknown/modeParams:bus/constant": "-1.0" } ) assert config['planCalcScore']['scoringParameters:default']['modeParams:car']["constant"] == "-1.0" assert config['planCalcScore']['scoringParameters:unknown']['modeParams:car']["constant"] == "-1.0" assert config['planCalcScore']['scoringParameters:unknown']['modeParams:bus']["constant"] == "-1.0" def test_find_and_set_bad_param(config): cnfg = deepcopy(config) step.find_and_set_overrides( config, {"modeParams:*/horseback": "-1.0"} ) assert cnfg == config def test_construct_overrides_map_from_tuple(): assert step.construct_override_map_from_tuple( ('a','b','c','d') ) == {'a':'b', 'c':'d'} def test_step_config(tmp_path): in_file = "tests/test_data/test_config.xml" out_file = os.path.join(tmp_path, "test_config.xml") step.step_config( input_file=in_file, output_file=out_file, overrides=( 'matsim_source', 'test/ing', 'outputDirectory', 'testing', 'step', '999', "modeParams:car/constant", "-1.0", "scoringParameters:unknown/modeParams:bus/constant", "-1.0" ) ) assert os.path.exists(out_file) config = BaseConfig(out_file) assert config['controler']['lastIteration'] == '999' assert config['controler']['outputDirectory'] == 'testing' assert config['network']['inputNetworkFile'] == 'test/ing/network.xml' assert config['plans']['inputPlansFile'] == 'test/ing/population.xml.gz' assert config['plans']['inputPersonAttributesFile'] == 'test/ing/population_attributes.xml.gz' assert config['transit']['transitScheduleFile'] == 'test/ing/schedule-merged.xml' assert config['transit']['vehiclesFile'] == 'test/ing/vehicles.xml' assert config['transit']['transitLinesAttributesFile'] == 'null' assert config['planCalcScore']['scoringParameters:default']['modeParams:car']["constant"] == "-1.0" assert config['planCalcScore']['scoringParameters:unknown']['modeParams:car']["constant"] == "-1.0" assert config['planCalcScore']['scoringParameters:unknown']['modeParams:bus']["constant"] == "-1.0"
39.43
103
0.672331
441
3,943
5.854875
0.190476
0.116189
0.050349
0.076685
0.725019
0.656468
0.622773
0.622773
0.605345
0.605345
0
0.01259
0.153944
3,943
99
104
39.828283
0.761391
0
0
0.37037
0
0
0.420238
0.203398
0
0
0
0
0.345679
1
0.111111
false
0
0.074074
0
0.197531
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0840e1f2cca91c8f40fea1035d91f9ed0ea2c8f1
15,552
py
Python
lambda_functions.py
intirix/serverless-secrets-manager
2c89b2c497f7078c38885125dfa79db944a214db
[ "Apache-2.0" ]
2
2018-05-23T06:04:13.000Z
2020-11-04T23:16:09.000Z
lambda_functions.py
intirix/serverless-secrets-manager
2c89b2c497f7078c38885125dfa79db944a214db
[ "Apache-2.0" ]
null
null
null
lambda_functions.py
intirix/serverless-secrets-manager
2c89b2c497f7078c38885125dfa79db944a214db
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/python import system import db import client import server import logging import json import base64 import os from aws_xray_sdk.core import patch_all if "AWS_REGION" in os.environ: patch_all() class LambdaCommon: def __init__(self, ddb_client=None): self.log = logging.getLogger("Lambda") self.system = system.System() userTable = "secrets-users" if "USERS_TABLE" in os.environ: userTable = os.environ["USERS_TABLE"] secretsTable = "secrets-secrets" if "SECRETS_TABLE" in os.environ: secretsTable = os.environ["SECRETS_TABLE"] self.db = db.CacheDB(db.DynamoDB(userTable, secretsTable, ddb_client)) self.system.setDB(self.db) self.system.init() self.client = client.Client(client.ClientSystemInterface(self.system)) self.server = server.Server(self.system) self.resp = None self.ctx = None self.mockUser = None if "MOCK_USER" in os.environ and len(os.environ["MOCK_USER"]) > 0: self.mockUser = os.environ["MOCK_USER"] def _response401(self): self.resp = {"statusCode": 401} def authenticate(self, event): if self.mockUser != None: self.ctx = self.server.mockAuthentication(self.mockUser) return if ( event == None or not "headers" in event or event["headers"] == None or not "Authorization" in event["headers"] ): self._response401() return self.ctx = self.server.validateAuthenticationHeader( event["headers"]["Authorization"] ) if self.ctx == None: self._response401() return def getResponse(self): return self.resp def get_body(event): if not "body" in event: return None if event["body"] == None: return None if "isBase64Encoded" in event and event["isBase64Encoded"] == True: return base64.b64decode(event["body"]) return event["body"] def matches(event, meth, path): log = logging.getLogger("Lambda") if event == None: return False if not "httpMethod" in event or meth != event["httpMethod"]: return False if "requestContext" in event and "resourcePath" in event["requestContext"]: if path == event["requestContext"]["resourcePath"]: log.info("Matched " + meth + " to " + path) return True return False _singleton = None def get_lambda_common(): global _singleton if _singleton is None: _singleton = LambdaCommon() return _singleton def single_func(event, context): # print(json.dumps(event,indent=2)) if matches(event, "GET", "/v1/users"): return list_users(event, context) if matches(event, "GET", "/v1/users/{username}"): return get_user(event, context) if matches(event, "PUT", "/v1/users/{username}"): return update_user(event, context) if matches(event, "POST", "/v1/users/{username}"): return create_user(event, context) if matches(event, "GET", "/v1/users/{username}/keys/public"): return get_user_public_key(event, context) if matches(event, "PUT", "/v1/users/{username}/keys/public"): return set_user_public_key(event, context) if matches(event, "POST", "/v1/users/{username}/keys/public"): return set_user_public_key(event, context) if matches(event, "POST", "/v1/users/{username}/keys"): return generate_user_keys(event, context) if matches(event, "GET", "/v1/users/{username}/keys/private/encrypted"): return get_user_private_key_encrypted(event, context) if matches(event, "PUT", "/v1/users/{username}/keys/private/encrypted"): return set_user_private_key_encrypted(event, context) if matches(event, "POST", "/v1/users/{username}/keys/private/encrypted"): return set_user_private_key_encrypted(event, context) if matches(event, "GET", "/v1/users/{username}/secrets"): return get_user_secrets(event, context) if matches(event, "GET", "/v1/secrets/{sid}"): return get_secret(event, context) if matches(event, "PUT", "/v1/secrets/{sid}"): return update_secret(event, context) if matches(event, "POST", "/v1/secrets"): return add_secret(event, context) if matches(event, "PUT", "/v1/secrets/{sid}/users/{username}"): return share_secret(event, context) if matches(event, "DELETE", "/v1/secrets/{sid}/users/{username}"): return unshare_secret(event, context) print("Did not match the event") return {"statusCode": 404} def list_users(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: return { "statusCode": 200, "body": json.dumps(obj.server.listUsers(obj.ctx), indent=2), } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def get_user(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] return { "statusCode": 200, "body": json.dumps(obj.server.getUser(obj.ctx, user), indent=2), } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def update_user(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] body = get_body(event) if obj.server.updateUser(obj.ctx, user, body): return { "statusCode": 200, "body": json.dumps(obj.server.getUser(obj.ctx, user), indent=2), } return {"statusCode": 404} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def set_user_public_key(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] body = get_body(event) keyType = obj.server.getPublicKeyType(body) if obj.server.setUserPublicKey(obj.ctx, user, body, keyType): return { "statusCode": 200, "body": json.dumps(obj.server.getUser(obj.ctx, user), indent=2), } return {"statusCode": 404} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def create_user(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] body = get_body(event) if obj.server.addUser(obj.ctx, user, body): if obj.server.addUser(obj.ctx, user, body): return { "statusCode": 201, "body": json.dumps(obj.server.getUser(obj.ctx, user), indent=2), } return {"statusCode": 404} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def get_user_public_key(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] pem = obj.server.getUserPublicKey(obj.ctx, user) if pem == None: return {"statusCode": 404} return { "statusCode": 200, "body": pem, "headers": {"Content-Type": "application/x-pem-file"}, } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def get_user_private_key_encrypted(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] data = obj.server.getUserEncryptedPrivateKey(obj.ctx, user) if isinstance(data, str): data = data.encode("UTF-8") b64 = base64.b64encode(data).decode("UTF-8") return { "statusCode": 200, "body": b64, "headers": {"Content-Type": "application/octet-stream"}, "isBase64Encoded": True, } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def generate_user_keys(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] body = get_body(event) if body is None: obj.log.exception("Password not provided in body") return {"statusCode": 400} body = body.strip() generate = False if ( "queryStringParameters" in event and "generate" in event["queryStringParameters"] ): generate = "true" == event["queryStringParameters"]["generate"] if generate: pem = obj.server.generateKeysForUser(obj.ctx, user, body) return { "statusCode": 200, "body": pem, "headers": {"Content-Type": "application/x-pem-file"}, } return {"statusCode": 404} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def set_user_private_key_encrypted(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] body = get_body(event) if obj.server.setUserEncryptedPrivateKey(obj.ctx, user, body): return { "statusCode": 200, "body": json.dumps(obj.server.getUser(obj.ctx, user), indent=2), } return {"statusCode": 404} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def get_user_secrets(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: user = event["pathParameters"]["username"] return { "statusCode": 200, "body": json.dumps(obj.server.getMySecrets(obj.ctx, user), indent=2), } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def get_secret(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: sid = event["pathParameters"]["sid"] return { "statusCode": 200, "body": json.dumps(obj.server.getSecret(obj.ctx, sid), indent=2), } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def update_secret(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: sid = event["pathParameters"]["sid"] body = get_body(event) if obj.server.updateSecret(obj.ctx, sid, body): return { "statusCode": 200, "body": json.dumps(obj.server.getSecret(obj.ctx, sid), indent=2), } return {"statusCode": 404} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def add_secret(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: body = get_body(event) sid = obj.server.addSecret(obj.ctx, body) return { "statusCode": 201, "body": json.dumps(obj.server.getSecret(obj.ctx, sid), indent=2), } except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def share_secret(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: sid = event["pathParameters"]["sid"] user = event["pathParameters"]["username"] body = get_body(event) ret = obj.server.shareSecret(obj.ctx, sid, user, body) return {"statusCode": 200, "body": json.dumps(ret, indent=2)} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} def unshare_secret(event, context): obj = get_lambda_common() obj.authenticate(event) if obj.getResponse() != None: return obj.getResponse() try: sid = event["pathParameters"]["sid"] user = event["pathParameters"]["username"] ret = obj.server.unshareSecret(obj.ctx, sid, user) return {"statusCode": 200, "body": json.dumps(ret, indent=2)} except server.AccessDeniedException: obj.log.exception("Access Denied") return {"statusCode": 403} except: obj.log.exception("Error") return {"statusCode": 500} return {"statusCode": 404} FORMAT = "%(asctime)-15s %(message)s" logging.basicConfig(format=FORMAT)
29.622857
84
0.600244
1,676
15,552
5.49284
0.102625
0.119922
0.050511
0.036498
0.703237
0.69748
0.682381
0.669889
0.654573
0.630241
0
0.024065
0.267876
15,552
524
85
29.679389
0.784472
0.003215
0
0.633178
0
0
0.160839
0.030774
0
0
0
0
0
1
0.053738
false
0.002336
0.021028
0.002336
0.343458
0.002336
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0845d2588d5c55abf24f9ab405009bd284d758d8
833
py
Python
tests/test_composition.py
gregorynicholas/proto-pigeon
65a5d961e7a8506f3a968b21aaf68f625fd13190
[ "Apache-2.0" ]
null
null
null
tests/test_composition.py
gregorynicholas/proto-pigeon
65a5d961e7a8506f3a968b21aaf68f625fd13190
[ "Apache-2.0" ]
null
null
null
tests/test_composition.py
gregorynicholas/proto-pigeon
65a5d961e7a8506f3a968b21aaf68f625fd13190
[ "Apache-2.0" ]
null
null
null
from protorpc.messages import Message, IntegerField, StringField import protopigeon class MessageOne(Message): one = IntegerField(1) two = IntegerField(2) class MessageTwo(Message): three = StringField(1) four = StringField(2) def test(): ComposedMessage = protopigeon.compose(MessageOne, MessageTwo) assert hasattr(ComposedMessage, 'one') assert hasattr(ComposedMessage, 'two') assert hasattr(ComposedMessage, 'three') assert hasattr(ComposedMessage, 'four') # Make sure these fields weren't modified assert MessageOne.one.number == 1 assert MessageOne.two.number == 2 assert MessageTwo.three.number == 1 assert MessageTwo.four.number == 2 instance = ComposedMessage( one=1, two=2, three='three', four='four') assert instance
23.138889
65
0.686675
89
833
6.426966
0.359551
0.090909
0.195804
0
0
0
0
0
0
0
0
0.015314
0.216086
833
35
66
23.8
0.860643
0.046819
0
0
0
0
0.030303
0
0
0
0
0
0.375
1
0.041667
false
0
0.083333
0
0.375
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
084d1fd01b6f648a85848dd0310b96b0d8966a0e
651
py
Python
yotta/options/registry.py
microbit-foundation/yotta
82d854b43d391abb5a006b05e7beffe7d0d6ffbf
[ "Apache-2.0" ]
176
2015-01-02T07:31:59.000Z
2022-03-21T12:40:02.000Z
yotta/options/registry.py
microbit-foundation/yotta
82d854b43d391abb5a006b05e7beffe7d0d6ffbf
[ "Apache-2.0" ]
549
2015-01-05T16:19:54.000Z
2021-01-15T13:46:42.000Z
yotta/options/registry.py
microbit-foundation/yotta
82d854b43d391abb5a006b05e7beffe7d0d6ffbf
[ "Apache-2.0" ]
84
2015-01-10T21:01:00.000Z
2022-03-24T16:04:42.000Z
# Copyright 2014-2015 ARM Limited # # Licensed under the Apache License, Version 2.0 # See LICENSE file for details. # standard library options from argparse import Action, SUPPRESS class RegistryAction(Action): def __init__(self, *args, **kwargs): kwargs['nargs'] = 1 self.dest = kwargs['dest'] super(RegistryAction, self).__init__(*args, **kwargs) def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, values[0]) def addTo(parser): parser.add_argument( '--registry', default=None, dest='registry', help=SUPPRESS, action=RegistryAction )
27.125
70
0.680492
77
651
5.571429
0.649351
0.04662
0
0
0
0
0
0
0
0
0
0.023077
0.201229
651
23
71
28.304348
0.801923
0.204301
0
0
0
0
0.052734
0
0
0
0
0
0
1
0.230769
false
0
0.076923
0
0.384615
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
084edafd90972abf12ce9cf828ac494b0afdd467
4,453
py
Python
src/pybraingym/environment.py
anetczuk/pybraingym
4f930021d7802e88c75a1a0aed135dd4de66cc1b
[ "MIT" ]
null
null
null
src/pybraingym/environment.py
anetczuk/pybraingym
4f930021d7802e88c75a1a0aed135dd4de66cc1b
[ "MIT" ]
null
null
null
src/pybraingym/environment.py
anetczuk/pybraingym
4f930021d7802e88c75a1a0aed135dd4de66cc1b
[ "MIT" ]
null
null
null
# MIT License # # Copyright (c) 2019 Arkadiusz Netczuk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions 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 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. # from pybrain.rl.environments.environment import Environment from gym.spaces.discrete import Discrete class GymEnvironment(Environment): def __init__(self, gymRawEnv): Environment.__init__(self) observationSpace = gymRawEnv.observation_space if type(observationSpace) == Discrete: self.outdim = 1 self.discreteStates = True self.numStates = observationSpace.n actionSpace = gymRawEnv.action_space if type(actionSpace) == Discrete: self.indim = 1 self.discreteActions = True self.numActions = actionSpace.n self.env = gymRawEnv self.observation = None self.reward = 0 self.cumReward = 0 self.done = True self.info = None self.transform = None self.doCumulative = False self.doRender = False def setRendering(self, render=True): self.doRender = render def getCumulativeRewardMode(self): return self.doCumulative def setCumulativeRewardMode(self, cumulativeReward=True): self.doCumulative = cumulativeReward def setTransformation(self, transformation): self.transform = transformation self.transform.env = self # ========================================================================== def getSensors(self): return self.observation def performAction(self, action): if self.transform is not None: action = self.transform.action(action) self.observation, self.reward, self.done, self.info = self.env.step(action) if self.transform is not None: self.observation = self.transform.observation(self.observation) self.reward = self.transform.reward(self.reward) self.cumReward += self.reward def reset(self): self.done = False self.reward = 0 self.cumReward = 0 self.info = None self.observation = self.env.reset() if self.transform is not None: self.observation = self.transform.observation(self.observation) # ========================================================================== def getReward(self): if self.doCumulative: return self.cumReward else: return self.reward def sampleAction(self): return self.env.action_space.sample() def render(self): self.env.render() def close(self): self.env.close() class Transformation: def __init__(self): self._env = None @property def env(self): return self._env @env.setter def env(self, new_env): self._env = new_env def observation(self, observationValue): """Transform observation value received from OpenAi Gym. Transformed value is passed to PyBrain. For discrete observations Gym often returns single value, but PyBrain always requires array. """ return observationValue def action(self, actionValue): """Transform action value received from PyBrain and pass result to OpenAi Gym.""" return actionValue def reward(self, rewardValue): """Transform reward value received from OpenAi Gym and pass result to PyBrain.""" return rewardValue
32.50365
104
0.651246
511
4,453
5.636008
0.348337
0.045139
0.032986
0.017708
0.119792
0.086806
0.086806
0.054167
0.054167
0.054167
0
0.002978
0.245902
4,453
136
105
32.742647
0.854675
0.355042
0
0.142857
0
0
0
0
0
0
0
0
0
1
0.233766
false
0
0.025974
0.051948
0.402597
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
f23153ff9da39e77238d222d2874c0c47b3effe7
1,765
py
Python
tests/test_copies.py
mschmidtkorth/shallow-backup
6629fed7d5a3a13eb068c7ef0168cfa8ffbd3bbf
[ "MIT" ]
1
2021-07-25T19:26:47.000Z
2021-07-25T19:26:47.000Z
tests/test_copies.py
mschmidtkorth/shallow-backup
6629fed7d5a3a13eb068c7ef0168cfa8ffbd3bbf
[ "MIT" ]
null
null
null
tests/test_copies.py
mschmidtkorth/shallow-backup
6629fed7d5a3a13eb068c7ef0168cfa8ffbd3bbf
[ "MIT" ]
null
null
null
import os import sys import pytest import shutil from .test_utils import setup_env_vars, unset_env_vars, BACKUP_DEST_DIR, FAKE_HOME_DIR, DIRS sys.path.insert(0, "../shallow_backup") from shallow_backup.utils import copy_dir_if_valid TEST_TEXT_FILE = os.path.join(FAKE_HOME_DIR, 'test-file.txt') class TestCopyMethods: """ Test the functionality of copying """ @staticmethod def setup_method(): setup_env_vars() try: os.mkdir(FAKE_HOME_DIR) except FileExistsError: shutil.rmtree(FAKE_HOME_DIR) os.mkdir(FAKE_HOME_DIR) print(f"Created {TEST_TEXT_FILE}") open(TEST_TEXT_FILE, "w+").close() @staticmethod def teardown_method(): for directory in DIRS: if os.path.isdir(directory): shutil.rmtree(directory) unset_env_vars() def test_copy_dir(self): """ Test that copying a directory works as expected """ # TODO: Test that all subfiles and folders are copied. test_dir = 'subdir-to-copy' test_path = os.path.join(FAKE_HOME_DIR, test_dir) os.mkdir(test_path) copy_dir_if_valid(FAKE_HOME_DIR, BACKUP_DEST_DIR) assert os.path.isdir(test_path) assert os.path.isfile(os.path.join(BACKUP_DEST_DIR, os.path.split(TEST_TEXT_FILE)[1])) assert os.path.isdir(os.path.join(BACKUP_DEST_DIR, test_dir)) @pytest.mark.parametrize('invalid', {".Trash", ".npm", ".cache", ".rvm"}) def test_copy_dir_invalid(self, invalid): """ Test that attempting to copy an invalid directory fails """ copy_dir_if_valid(invalid, FAKE_HOME_DIR) assert not os.path.isdir(os.path.join(BACKUP_DEST_DIR, invalid))
32.090909
94
0.65779
245
1,765
4.465306
0.342857
0.060329
0.080439
0.038391
0.161792
0.128885
0.107861
0.062157
0.062157
0
0
0.001487
0.23796
1,765
54
95
32.685185
0.811896
0.108215
0
0.108108
0
0
0.064153
0
0
0
0
0.018519
0.108108
1
0.108108
false
0
0.162162
0
0.297297
0.027027
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
1
f2320f768e412bebfaa5c2e31eeb4a3c480eacaf
1,395
py
Python
loan/killeragent.py
Casper-Smet/LOAN
3aabf80cf4314bcba33779329fc6e4971b85e742
[ "MIT" ]
null
null
null
loan/killeragent.py
Casper-Smet/LOAN
3aabf80cf4314bcba33779329fc6e4971b85e742
[ "MIT" ]
null
null
null
loan/killeragent.py
Casper-Smet/LOAN
3aabf80cf4314bcba33779329fc6e4971b85e742
[ "MIT" ]
null
null
null
from collections import namedtuple import networkx as nx from mesa import Agent, Model class KillerAgent(Agent): def __init__(self, unique_id: int, model: Model, creator, pos: int, target_location: int, target_disease: str) -> None: super().__init__(unique_id, model) self.creator = creator self.pos = pos self.target_location = target_location self.target_disease = target_disease self.arrived_on_location = False self.shortest_path_to_target_node = [] def perceive(self) -> None: self.arrived_on_location = self.pos == self.target_location self.shortest_path_to_target_node = nx.shortest_path(G=self.model.network, source=self.pos, target=self.target_location) def act(self) -> None: ... def update(self) -> None: if self.arrived_on_location: if self.pos in self.model.ill_vertices: self.model.restore_vertex(self.pos) self.model.grid._remove_agent(self, self.pos) self.model.schedule.remove(self) else: self.model.grid.move_agent(self, self.shortest_path_to_target_node[1]) def __repr__(self) -> str: return f"{self.__class__.__name__} {self.model}/{self.unique_id}: Position {self.pos}" def __str__(self) -> str: return self.__repr__() def emojify(self): return " 💉"
34.875
128
0.658065
182
1,395
4.703297
0.318681
0.057243
0.063084
0.073598
0.098131
0.098131
0
0
0
0
0
0.000939
0.236559
1,395
40
129
34.875
0.801878
0
0
0
0
0.032258
0.055874
0.039398
0
0
0
0
0
1
0.225806
false
0
0.096774
0.096774
0.451613
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
f23e9e3046350977154c8ce79c350de302fd2dce
197
py
Python
04_While/Step03/gamjapark.py
StudyForCoding/BEAKJOON
84e1c5e463255e919ccf6b6a782978c205420dbf
[ "MIT" ]
null
null
null
04_While/Step03/gamjapark.py
StudyForCoding/BEAKJOON
84e1c5e463255e919ccf6b6a782978c205420dbf
[ "MIT" ]
3
2020-11-04T05:38:53.000Z
2021-03-02T02:15:19.000Z
04_While/Step03/gamjapark.py
StudyForCoding/BEAKJOON
84e1c5e463255e919ccf6b6a782978c205420dbf
[ "MIT" ]
null
null
null
n = int(input()) temp_n = n k=0 while True: a = int(temp_n / 10) b = temp_n % 10 c = (a + b) % 10 new = b*10 + c k += 1 if new == n: break temp_n = new print(k)
14.071429
24
0.446701
38
197
2.210526
0.447368
0.238095
0.166667
0
0
0
0
0
0
0
0
0.084746
0.401015
197
13
25
15.153846
0.627119
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.076923
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f23ec9a0fbd46e6d9b5f8659349c47ab52aec354
333
py
Python
bbtest/steps/appliance_steps.py
jancajthaml-openbank/e2e
a2ef84b6564022e95de76438fc795e2ef927aa2b
[ "Apache-2.0" ]
null
null
null
bbtest/steps/appliance_steps.py
jancajthaml-openbank/e2e
a2ef84b6564022e95de76438fc795e2ef927aa2b
[ "Apache-2.0" ]
30
2018-03-18T05:58:32.000Z
2022-01-19T23:21:31.000Z
bbtest/steps/appliance_steps.py
jancajthaml-openbank/e2e
a2ef84b6564022e95de76438fc795e2ef927aa2b
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from behave import * from helpers.eventually import eventually @given('appliance is running') def appliance_running(context): @eventually(5) def wait_for_appliance_up(): assert context.appliance.running(), 'appliance did not start within 5 seconds' wait_for_appliance_up()
23.785714
82
0.744745
45
333
5.355556
0.622222
0.13278
0.13278
0.149378
0
0
0
0
0
0
0
0.013937
0.138138
333
13
83
25.615385
0.825784
0.129129
0
0
0
0
0.208333
0
0
0
0
0
0.125
1
0.25
false
0
0.25
0
0.5
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
f23fb929e898694417f38446747b98726264f0e7
1,211
py
Python
irkshop/urls.py
Beomi/irkshop
c109a62216cb6550add64fbf402883debc5011d1
[ "Apache-2.0" ]
19
2016-11-06T10:28:14.000Z
2020-11-01T02:04:51.000Z
irkshop/urls.py
Beomi/irkshop
c109a62216cb6550add64fbf402883debc5011d1
[ "Apache-2.0" ]
17
2016-10-19T11:58:48.000Z
2022-01-13T00:32:34.000Z
irkshop/urls.py
Beomi/irkshop
c109a62216cb6550add64fbf402883debc5011d1
[ "Apache-2.0" ]
4
2016-11-06T10:54:26.000Z
2019-08-31T16:08:56.000Z
from django.conf.urls import url, include from django.contrib import admin from django.contrib.auth.views import login, logout from django.conf import settings from django.views.static import serve from django.views.generic import TemplateView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^accounts/login/$', login, {'template_name': 'login_page/login.html'}, name='login'), url(r'^accounts/logout/$', logout, name='logout'), url('', include('social_django.urls', namespace='social')), # 이 줄을 등록해주면 됩니다. url(r'^ckeditor/', include('ckeditor_uploader.urls')), url(r'^ht/', include('health_check.urls')), url(r'^paypal/', include('paypal.standard.ipn.urls')), url(r'^shop/', include('goods.urls', namespace='shop')), url(r'^$', TemplateView.as_view(template_name='index.html')), ] if settings.DEBUG: import debug_toolbar from django.conf.urls.static import static urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), url(r'^uploads/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
41.758621
101
0.663088
155
1,211
5.064516
0.348387
0.050955
0.050955
0.04586
0
0
0
0
0
0
0
0
0.168456
1,211
28
102
43.25
0.779543
0.012386
0
0
0
0
0.229481
0.074539
0
0
0
0
0
1
0
false
0
0.32
0
0.32
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
f2414f0188cf0460b22148b0732eea50d4b58390
5,142
py
Python
plag/urls.py
neetu6860/plagiarism-detection-software
7f05210aafdccf33a2bc732a40348eff43f46fba
[ "MIT" ]
19
2018-09-03T09:10:20.000Z
2021-12-24T13:52:18.000Z
plag/urls.py
neetu6860/plagiarism-detection-software
7f05210aafdccf33a2bc732a40348eff43f46fba
[ "MIT" ]
3
2019-10-31T18:42:38.000Z
2021-06-10T21:37:23.000Z
plag/urls.py
neetu6860/plagiarism-detection-software
7f05210aafdccf33a2bc732a40348eff43f46fba
[ "MIT" ]
16
2018-06-06T15:04:59.000Z
2022-03-29T04:53:07.000Z
from django.conf.urls import patterns, url from django.contrib import admin from django.contrib.auth.decorators import login_required from django.views.generic import TemplateView admin.autodiscover() from plag import views, const urlpatterns = patterns('', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^index-trial/$', views.IndexTrialView.as_view(), name='index_trial'), url(r'^download/(?P<prot_res_id>\d+)$', views.download_file, name='download'), url(r'^products/$', TemplateView.as_view(template_name='plag/static/products.html'), name='products'), url(r'^features-screenshots/$', TemplateView.as_view(template_name='plag/static/features_and_screenshots.html'), name='features'), url(r'^url-protection/$', TemplateView.as_view(template_name='plag/static/url_protection.html'), name='url_prot'), url(r'^document-protection/$', TemplateView.as_view(template_name='plag/static/doc_protection.html'), name='doc_prot'), url(r'^pricing/$', TemplateView.as_view(template_name='plag/static/pricing.html'), name='pricing'), url(r'^risks-of-plagiarism/$', TemplateView.as_view(template_name='plag/static/risks_of_plagiarism.html'), name='risks_plag'), url(r'^about-us/$', TemplateView.as_view(template_name='plag/static/about.html'), name='about'), url(r'^our-customers/$', TemplateView.as_view(template_name='plag/static/our_customers.html'), name='our_customers'), url(r'^contact-us/$', TemplateView.as_view(template_name='plag/static/contact_us.html'), name='contact'), url(r'^order/$', views.OrderView.as_view(), name='order'), url(r'^ajax/username-check/$', views.username_unique, name='ajax_username_unique'), url(r'^account/$', views.account, name='account'), url(r'^account/profile/$', login_required(views.ProfileView.as_view()), name='profile'), url(r'^account/invoice/(?P<pk>\d+)$', views.invoice, name='invoice'), url(r'^account/invoice/pay/(?P<pk>\d+)$', views.pay_invoice, name='pay_invoice'), url(r'^account/invoice/subscribe/(?P<pk>\d+)$', views.subscribe_invoice, name='subscribe_invoice'), url(r'^ipn-endpoint/$', views.ipn, name='ipn'), url(r'^account/recent-scans/$', views.recent_scans, name='recent_scans_default'), url(r'^account/recent-scans/(?P<num_days>\d+)$', views.recent_scans, name='recent_scans'), url(r'^account/recent-scans/(?P<num_days>\d+)/(?P<hide_zero>hide-zero)$', views.recent_scans, name='recent_scans_hide_zero'), url(r'^account/scan-history/$', views.scan_history, name='scan_history'), url(r'^account/scan-history/(?P<hide_zero>hide-zero)$', views.scan_history, name='scan_history_hide_zero'), url(r'^ajax/plag-results/$', views.plagiarism_results, name='ajax_plag_results_default'), url(r'^ajax/plag-results/(?P<scan_id>\d+)$', views.plagiarism_results, name='plag_results'), url(r'^ajax/sitemap/$', views.sitemap_to_urls, name='ajax_urls'), url(r'^account/protected-resources/$', login_required(views.ProtectedResources.as_view()), name='protected_resources'), url(r'^sitemap/$', TemplateView.as_view(template_name='plag/static/sitemap.html'), name='sitemap'), url(r'^terms-of-service/$', TemplateView.as_view(template_name='plag/static/terms_of_service.html'), name='terms_of_service'), url(r'^privacy-policy/$', TemplateView.as_view(template_name='plag/static/privacy_policy.html'), name='privacy_policy'), # TODO Remove url(r'^data-cleanse/$', views.data_cleanse, name='data_cleanse'), url(r'^copyright/$', TemplateView.as_view(template_name='plag/static/copyright.html'), name='copyright'), url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'plag/static/login_error.html'}), url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': 'index'}, name='logout'), )
57.775281
119
0.532283
536
5,142
4.923507
0.18097
0.054566
0.084881
0.116711
0.359606
0.30125
0.229632
0.093217
0.023494
0
0
0
0.317581
5,142
88
120
58.431818
0.752066
0.002139
0
0
0
0.014925
0.32092
0.200039
0
0
0
0.011364
0
1
0
false
0
0.074627
0
0.074627
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
1
f249ee34b1745d4a243c396362c75f872d9af531
687
py
Python
Software_Carpentry/Conway/test_conway.py
dgasmith/SICM2-Software-Summer-School-2014
af97770cbade3bf4a246f21e607e8be66c9df7da
[ "MIT" ]
2
2015-07-16T14:00:27.000Z
2016-01-10T20:21:48.000Z
Software_Carpentry/Conway/test_conway.py
dgasmith/SICM2-Software-Summer-School-2014
af97770cbade3bf4a246f21e607e8be66c9df7da
[ "MIT" ]
null
null
null
Software_Carpentry/Conway/test_conway.py
dgasmith/SICM2-Software-Summer-School-2014
af97770cbade3bf4a246f21e607e8be66c9df7da
[ "MIT" ]
null
null
null
from conway import * def test_neighbors_at_origin(): result = [(1,1), (-1,-1), (0,1), (1,0), (-1,1), (1,-1), (-1,0), (0,-1)] nb = neighbors((0,0)) assert( set(result) == set(nb) ) def test_neighbors_at_negative_quadrant(): result = [(0, -1), (-2, -1), (-1, 0), (-1, -2), (0, 0), (0, -2), (-2, 0), (-2, -2)] nb = neighbors((-1,-1)) assert( set(result) == set(nb) ) def test_blinker(): blinker = [(-1,0), (0,0), (1,0)] result = conway(blinker, generations=2) assert( set(result) == set(blinker) ) def test_block(): block = [(0,0), (0,1), (1,0), (1,1)] result = conway(block, generations=2) assert( set(result) == set(block) )
28.625
87
0.513828
108
687
3.185185
0.185185
0.069767
0.043605
0.046512
0.389535
0.366279
0.156977
0
0
0
0
0.096475
0.215429
687
23
88
29.869565
0.541744
0
0
0.117647
0
0
0
0
0
0
0
0
0.235294
1
0.235294
false
0
0.058824
0
0.294118
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
f24a5dc578f63a0c2e113a798ce9969cd7ed080c
5,426
py
Python
app_backend/__init__.py
zhanghe06/bearing_project
78a20fc321f72d3ae05c7ab7e52e01d02904e3fc
[ "MIT" ]
1
2020-06-21T04:08:26.000Z
2020-06-21T04:08:26.000Z
app_backend/__init__.py
zhanghe06/bearing_project
78a20fc321f72d3ae05c7ab7e52e01d02904e3fc
[ "MIT" ]
13
2019-10-18T17:19:32.000Z
2022-01-13T00:44:43.000Z
app_backend/__init__.py
zhanghe06/bearing_project
78a20fc321f72d3ae05c7ab7e52e01d02904e3fc
[ "MIT" ]
5
2019-02-07T03:15:16.000Z
2021-09-04T14:06:28.000Z
#!/usr/bin/env python # encoding: utf-8 """ @author: zhanghe @software: PyCharm @file: __init__.py @time: 2018-03-06 00:00 """ from __future__ import unicode_literals import eventlet eventlet.monkey_patch() from logging.config import dictConfig from config import current_config from flask import Flask from flask_wtf.csrf import CSRFProtect from flask_login import LoginManager from flask_moment import Moment from flask_oauthlib.client import OAuth from flask_mail import Mail from flask_principal import Principal import flask_excel as excel # from flask_socketio import SocketIO from flask_sqlalchemy import SQLAlchemy from flask_babel import Babel, gettext as _ from app_common.libs.redis_session import RedisSessionInterface from app_backend.clients.client_redis import redis_client app = Flask(__name__) app.config.from_object(current_config) app.config['REMEMBER_COOKIE_NAME'] = app.config['REMEMBER_COOKIE_NAME_BACKEND'] app.session_cookie_name = app.config['SESSION_COOKIE_NAME_BACKEND'] app.session_interface = RedisSessionInterface( redis=redis_client, prefix=app.config['REDIS_SESSION_PREFIX_BACKEND'], ) # CSRF Protection AJAX requests csrf = CSRFProtect(app) login_manager = LoginManager() login_manager.init_app(app) # setup_app 方法已淘汰 login_manager.login_view = 'auth.index' login_manager.login_message = _('Please log in to access this page.') login_manager.login_message_category = 'warning' # 设置消息分类 login_manager.localize_callback = _ # 设置翻译回调 login_manager.session_protection = 'basic' # 设置安全等级(basic、strong、None) # 用户电脑的标识(基本上是 IP 地址和 User Agent 的 MD5 hash 值) # basic 模式下,如果该标识未匹配,会话会简单地被标记为非活 跃的,且任何需要活跃登入的东西会强制用户重新验证。 # strong模式下,如果该标识未匹配,整个会话(记住的令牌如果存在,则同样)被删除。 # Moment 时间插件 moment = Moment(app) # 权限管理插件 principals = Principal(app, skip_static=True) # 国际化 本地化 babel = Babel(app) excel.init_excel(app) # SocketIO # socketio = SocketIO() # socketio.init_app(app, async_mode='eventlet', message_queue=app.config['REDIS_URL']) # 第三方开放授权登录 oauth = OAuth(app) # 邮件 mail = Mail(app) # GitHub oauth_github = oauth.remote_app( 'github', **app.config['GITHUB_OAUTH'] ) # QQ oauth_qq = oauth.remote_app( 'qq', **app.config['QQ_OAUTH'] ) # WeiBo oauth_weibo = oauth.remote_app( 'weibo', **app.config['WEIBO_OAUTH'] ) # Google # 要银子,妹的 # 配置日志 dictConfig(app.config['LOG_CONFIG']) # 这个 import 语句放在这里, 防止views, models import发生循环import from app_backend import views from app_backend.views.permissions import bp_permissions from app_backend.views.captcha import bp_captcha from app_backend.views.customer import bp_customer from app_backend.views.customer_contact import bp_customer_contact from app_backend.views.customer_invoice import bp_customer_invoice from app_backend.views.supplier import bp_supplier from app_backend.views.supplier_contact import bp_supplier_contact from app_backend.views.supplier_invoice import bp_supplier_invoice from app_backend.views.user import bp_user from app_backend.views.user_auth import bp_auth from app_backend.views.production import bp_production from app_backend.views.production_sensitive import bp_production_sensitive from app_backend.views.quotation import bp_quotation from app_backend.views.quotation_items import bp_quotation_items from app_backend.views.enquiry import bp_enquiry from app_backend.views.enquiry_items import bp_enquiry_items from app_backend.views.buyer_order import bp_buyer_order from app_backend.views.purchase import bp_purchase from app_backend.views.sales_order import bp_sales_order from app_backend.views.delivery import bp_delivery from app_backend.views.warehouse import bp_warehouse from app_backend.views.rack import bp_rack from app_backend.views.inventory import bp_inventory from app_backend.views.futures import bp_futures from app_backend.views.purchase import bp_purchase from app_backend.views.delivery import bp_delivery from app_backend.views.system import bp_system # from app_backend.views.socket_io import bp_socket_io from app_backend.views.price import bp_price from app_backend.views.bank import bp_bank from app_backend.views.cash import bp_cash from app_backend.views.bank_account import bp_bank_account # 注册蓝图 app.register_blueprint(bp_permissions) app.register_blueprint(bp_captcha) app.register_blueprint(bp_customer) app.register_blueprint(bp_customer_contact) app.register_blueprint(bp_customer_invoice) app.register_blueprint(bp_supplier) app.register_blueprint(bp_supplier_contact) app.register_blueprint(bp_supplier_invoice) app.register_blueprint(bp_user) app.register_blueprint(bp_auth) app.register_blueprint(bp_production) app.register_blueprint(bp_production_sensitive) app.register_blueprint(bp_quotation) app.register_blueprint(bp_quotation_items) app.register_blueprint(bp_enquiry) app.register_blueprint(bp_enquiry_items) app.register_blueprint(bp_buyer_order) app.register_blueprint(bp_purchase) app.register_blueprint(bp_sales_order) app.register_blueprint(bp_delivery) app.register_blueprint(bp_warehouse) app.register_blueprint(bp_rack) app.register_blueprint(bp_inventory) app.register_blueprint(bp_futures) app.register_blueprint(bp_purchase) app.register_blueprint(bp_delivery) app.register_blueprint(bp_system) # app.register_blueprint(bp_socket_io) app.register_blueprint(bp_price) app.register_blueprint(bp_bank) app.register_blueprint(bp_cash) app.register_blueprint(bp_bank_account) # 导入自定义过滤器 from app_backend import filters
30.483146
86
0.838555
792
5,426
5.435606
0.215909
0.058537
0.113821
0.141231
0.35029
0.0964
0.0964
0.0964
0.0964
0.053194
0
0.002829
0.08791
5,426
177
87
30.655367
0.867044
0.134353
0
0.068966
0
0
0.045708
0.017811
0
0
0
0
0
1
0
false
0
0.422414
0
0.422414
0.267241
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
f251f3a1ac391e245be08c921c85c8b349b00732
1,924
py
Python
fineDinner.py
SMartQi/whose-treat
85f1d27dfb2b728a33cf8b6fcd73213ca24edb0b
[ "MIT" ]
1
2020-01-30T11:09:31.000Z
2020-01-30T11:09:31.000Z
fineDinner.py
SMartQi/whose-treat
85f1d27dfb2b728a33cf8b6fcd73213ca24edb0b
[ "MIT" ]
null
null
null
fineDinner.py
SMartQi/whose-treat
85f1d27dfb2b728a33cf8b6fcd73213ca24edb0b
[ "MIT" ]
null
null
null
#!/usr/bin/env python #-*- encoding:UTF-8 -*- """ Background: JJ and MM want to have a fine dinner, celebrating their annual bonuses. They make this rule: This dinner is on the person who gets more annual bonus. And the cost of the dinner is the diff of money they make mod 300, per capita. Requirement: Decide the money amount and the money provider, without letting one know how much the other's annual bonus is. Method: Hide the input. Use the method "Best two out of three" in case of any typo, since the input strings are hidden. """ import getpass def cal(): """ Decide the money amount and the money provider. """ incomejj = validInput("JJ: ") incomemm = validInput("MM: ") diff = incomejj - incomemm onWhom = "JJ" if diff < 0: onWhom = "MM" result = int(round(abs(diff) % 300)) return result, onWhom def validInput(prompt): """ Get a valid input and convert it to a float number. """ while 1: inputStr = getpass.getpass(prompt) try: inputFloat = float(inputStr) return inputFloat except ValueError: print("Invalid input. Try again.") pass if __name__ == "__main__": """ Use the method "Best two out of three" in case of any typo, since the input strings are hidden. """ (result1, onWhom1) = cal() print("Let's double check.") (result2, onWhom2) = cal() if result1 == result2 and onWhom1 == onWhom2: if result1 == 0: print("No dinner at all. But go to buy some lottery~") else : print("OK. Let's have dinner. " + str(result1) + " yuan per person on " + onWhom1 + ".") else : print("Something's wrong. Let's triple check.") (result3, onWhom3) = cal() if (result1 == result3 and onWhom1 == onWhom3) or (result2 == result3 and onWhom2 == onWhom3): if result3 == 0: print("No dinner at all. But go to buy some lottery~") else : print("OK. " + str(result3) + " it is. It's on " + onWhom3 + ".") else: print("Are you kidding me? I quit!")
29.6
135
0.670478
292
1,924
4.390411
0.458904
0.024961
0.021841
0.031201
0.25429
0.25429
0.25429
0.25429
0.193448
0.193448
0
0.022981
0.20842
1,924
64
136
30.0625
0.818779
0.327963
0
0.157895
0
0
0.244617
0
0
0
0
0
0
1
0.052632
false
0.078947
0.026316
0
0.131579
0.210526
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
f263dc6e6df0ca9888bd8e9bcfdb5d8ed564b445
507
py
Python
yaga_ga/evolutionary_algorithm/operators/base.py
alessandrolenzi/yaga
872503ad04a2831135143750bc309188e5685284
[ "MIT" ]
null
null
null
yaga_ga/evolutionary_algorithm/operators/base.py
alessandrolenzi/yaga
872503ad04a2831135143750bc309188e5685284
[ "MIT" ]
null
null
null
yaga_ga/evolutionary_algorithm/operators/base.py
alessandrolenzi/yaga
872503ad04a2831135143750bc309188e5685284
[ "MIT" ]
null
null
null
from typing import Generic, TypeVar from typing_extensions import Final from yaga_ga.evolutionary_algorithm.individuals import IndividualStructure class InvalidOperatorError(ValueError): pass IndividualType = TypeVar("IndividualType") GeneType = TypeVar("GeneType") class GeneticOperator(Generic[IndividualType, GeneType]): def __init__( self, individual_structure: IndividualStructure[IndividualType, GeneType] ): self.individual_structure: Final = individual_structure
24.142857
81
0.792899
47
507
8.340426
0.531915
0.168367
0.117347
0
0
0
0
0
0
0
0
0
0.142012
507
20
82
25.35
0.901149
0
0
0
0
0
0.043393
0
0
0
0
0
0
1
0.083333
false
0.083333
0.25
0
0.5
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
1
f26a5c6b870f2f9eb67aa2735878c21021be7143
324
py
Python
leetcode/easy/plus-one.py
vtemian/interviews-prep
ddef96b5ecc699a590376a892a804c143fe18034
[ "Apache-2.0" ]
8
2019-05-14T12:50:29.000Z
2022-03-01T09:08:27.000Z
leetcode/easy/plus-one.py
vtemian/interviews-prep
ddef96b5ecc699a590376a892a804c143fe18034
[ "Apache-2.0" ]
46
2019-03-24T20:59:29.000Z
2019-04-09T16:28:43.000Z
leetcode/easy/plus-one.py
vtemian/interviews-prep
ddef96b5ecc699a590376a892a804c143fe18034
[ "Apache-2.0" ]
1
2022-01-28T12:46:29.000Z
2022-01-28T12:46:29.000Z
class Solution: def plusOne(self, digits: List[int]) -> List[int]: carry = 1 result = [] for digit in digits[::-1]: digit += carry result.append(digit % 10) carry = digit // 10 if carry: result.append(carry) return result[::-1]
20.25
54
0.475309
35
324
4.4
0.514286
0.090909
0.220779
0
0
0
0
0
0
0
0
0.036082
0.401235
324
15
55
21.6
0.757732
0
0
0
0
0
0
0
0
0
0
0
0
1
0.090909
false
0
0
0
0.272727
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f26cee0b9842c7bd2fa3f00e76d7e1a08850c951
450
py
Python
coloredterm/__init__.py
hostedposted/coloredterm
72d07a0bd12eb797e4b2772dfe45aca5234d27b6
[ "MIT" ]
1
2021-02-12T01:21:44.000Z
2021-02-12T01:21:44.000Z
coloredterm/__init__.py
hostedposted/coloredterm
72d07a0bd12eb797e4b2772dfe45aca5234d27b6
[ "MIT" ]
4
2021-07-07T04:09:58.000Z
2022-02-03T04:05:30.000Z
coloredterm/__init__.py
hostedposted/coloredterm
72d07a0bd12eb797e4b2772dfe45aca5234d27b6
[ "MIT" ]
1
2021-02-20T22:58:31.000Z
2021-02-20T22:58:31.000Z
"""Collection of tools for changing the text of your terminal.""" from coloredterm.coloredterm import ( Back, bg, colored, colors, cprint, fg, Fore, names, pattern_input, pattern_print, rand, Style ) __version__ = "0.1.9" __all__ = [ 'Back', 'bg', 'colored', 'colors', 'cprint', 'fg', 'Fore', 'names', 'pattern_input', 'pattern_print', 'rand', 'Style' ]
14.516129
65
0.542222
47
450
4.93617
0.638298
0.051724
0.112069
0.163793
0.594828
0.594828
0.594828
0.594828
0.594828
0.594828
0
0.00974
0.315556
450
31
66
14.516129
0.743506
0.131111
0
0
0
0
0.196891
0
0
0
0
0
0
1
0
false
0
0.034483
0
0.034483
0.137931
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f27341117d08bd618bf3ac5014feb6d7ff7d069e
801
py
Python
kafka_client_decorators/util/logging_helper.py
cdsedson/kafka-decorator
f2c958df88c5698148aae4c5314dd39e31e995c3
[ "MIT" ]
null
null
null
kafka_client_decorators/util/logging_helper.py
cdsedson/kafka-decorator
f2c958df88c5698148aae4c5314dd39e31e995c3
[ "MIT" ]
null
null
null
kafka_client_decorators/util/logging_helper.py
cdsedson/kafka-decorator
f2c958df88c5698148aae4c5314dd39e31e995c3
[ "MIT" ]
null
null
null
#!/usr/bin/python3 # -*- coding: utf-8 -*- """Define function used on logging.""" import logging __KAFKA_DECORATOR_DEBUG__ = None def set_debug_level(level): """Set the level of log. Set logging level for all loggers create by get_logger function Parameters ---------- level: log level define in logging module """ global __KAFKA_DECORATOR_DEBUG__ __KAFKA_DECORATOR_DEBUG__ = level def get_logger(name): """Create and return a logger. Parameters ---------- name: str Logger name Returns ------- logging.Logger A standard python logger """ logger = logging.getLogger(name) if __KAFKA_DECORATOR_DEBUG__ is not None: logger.setLevel(__KAFKA_DECORATOR_DEBUG__) return logger
19.536585
67
0.636704
93
801
5.11828
0.494624
0.147059
0.19958
0
0
0
0
0
0
0
0
0.003384
0.262172
801
40
68
20.025
0.80203
0.475655
0
0
0
0
0
0
0
0
0
0
0
1
0.2
false
0
0.1
0
0.4
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f27f8a655e82f556df2399b3f99f4848f377c47b
375
py
Python
app/models/word.py
shiniao/soul-api
1438281c2dce237d735f7309c2ddb606c8d01e1e
[ "Apache-2.0" ]
1
2021-02-27T09:05:40.000Z
2021-02-27T09:05:40.000Z
app/models/word.py
shiniao/soulapi
1438281c2dce237d735f7309c2ddb606c8d01e1e
[ "Apache-2.0" ]
null
null
null
app/models/word.py
shiniao/soulapi
1438281c2dce237d735f7309c2ddb606c8d01e1e
[ "Apache-2.0" ]
null
null
null
from sqlalchemy import Column, Integer, String from app.database import Base class Word(Base): id = Column(Integer, primary_key=True, index=True, autoincrement=True) origin = Column(String, index=True, unique=True, nullable=False) pronunciation = Column(String) translation = Column(String) created_at = Column(String) updated_at = Column(String)
26.785714
74
0.733333
47
375
5.787234
0.553191
0.220588
0.102941
0
0
0
0
0
0
0
0
0
0.170667
375
13
75
28.846154
0.874598
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.222222
0
1
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f280236c60f310af1d18ad0b782faeb404b108be
912
py
Python
anomaly/Read_img.py
Jun-CEN/Open-World-Semantic-Segmentation
a95bac374e573055c23220e299789f34292988bc
[ "MIT" ]
19
2021-08-09T15:34:10.000Z
2022-03-14T09:20:58.000Z
anomaly/Read_img.py
Jun-CEN/Open-World-Semantic-Segmentation
a95bac374e573055c23220e299789f34292988bc
[ "MIT" ]
4
2021-11-08T07:10:35.000Z
2022-01-16T01:53:06.000Z
anomaly/Read_img.py
Jun-CEN/Open-World-Semantic-Segmentation
a95bac374e573055c23220e299789f34292988bc
[ "MIT" ]
4
2021-10-06T09:28:16.000Z
2022-01-14T08:26:54.000Z
from PIL import Image import matplotlib.pyplot as plt import numpy as np import bdlb import torch import json # path_img = './data/test_result/t5/' # path_img = './results_18_ce_noshuffle/2_' # # image = Image.open(path_img + '100.png') # plt.imshow(image) # plt.show() # # overlay = Image.open(path_img + 'overlay.png') # plt.imshow(overlay) # plt.show() # # pred = Image.open(path_img + 'pred.png') # plt.imshow(pred) # plt.show() # # target = Image.open(path_img + 'target.png') # plt.imshow(target) # plt.show() # # scores = Image.open(path_img + 'scores.png') # scores = np.array(scores) / 255 # plt.imshow(scores) # plt.show() # # dis_sum = np.load(path_img + 'dis_sum.npy') # plt.imshow(dis_sum) # plt.show() with open('logit_dict.json','r',encoding='utf8')as fp: json_data = json.load(fp) for i in range(13): print(len(json_data[i])) plt.figure() plt.hist(json_data[i]) plt.show()
20.727273
54
0.667763
146
912
4.034247
0.376712
0.095076
0.110357
0.135823
0
0
0
0
0
0
0
0.016731
0.148026
912
43
55
21.209302
0.741313
0.604167
0
0
0
0
0.06006
0
0
0
0
0
0
1
0
false
0
0.461538
0
0.461538
0.076923
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
1
f28637ac36ec4e4cf9bd05dd4661f26ee82946dd
900
py
Python
ejercicios_resueltos/t04/t04ejer03.py
workready/pythonbasic
59bd82caf99244f5e711124e1f6f4dec8de22141
[ "MIT" ]
null
null
null
ejercicios_resueltos/t04/t04ejer03.py
workready/pythonbasic
59bd82caf99244f5e711124e1f6f4dec8de22141
[ "MIT" ]
null
null
null
ejercicios_resueltos/t04/t04ejer03.py
workready/pythonbasic
59bd82caf99244f5e711124e1f6f4dec8de22141
[ "MIT" ]
null
null
null
import os def gcat(filenames): for filename in filenames: with open(filename) as f: for line in f: yield line def ggrep(pattern, filenames): for filename in filenames: with open(filename) as f: for line in f: if pattern in line: yield line # Codigo de pruebas para gcat print("Fichero linea a linea") print("-----------------------------") for line in gcat([os.path.join(os.path.dirname(os.path.realpath(__file__)), 'quijote.txt')]): print(line) print("-----------------------------") print() print() # Codigo de pruebas para ggrep print("Lineas del fichero que contienen la palabra 'los'") print("-----------------------------") for l in list(ggrep("los", [os.path.join(os.path.dirname(os.path.realpath(__file__)), 'quijote.txt')])): print(l) print("-----------------------------")
25
104
0.537778
111
900
4.288288
0.369369
0.07563
0.056723
0.092437
0.487395
0.487395
0.487395
0.487395
0.487395
0.487395
0
0
0.221111
900
35
105
25.714286
0.67903
0.062222
0
0.583333
0
0
0.25119
0.138095
0
0
0
0
0
1
0.083333
false
0
0.041667
0
0.125
0.416667
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
1
f2904abee88ac63551da7aa60f4599002d25cdcf
2,757
py
Python
side_scroller/game.py
pecjas/Sidescroller-PyGame
dfcaf4ff95a1733714eaaeb00dc00cd876ab1468
[ "MIT" ]
null
null
null
side_scroller/game.py
pecjas/Sidescroller-PyGame
dfcaf4ff95a1733714eaaeb00dc00cd876ab1468
[ "MIT" ]
null
null
null
side_scroller/game.py
pecjas/Sidescroller-PyGame
dfcaf4ff95a1733714eaaeb00dc00cd876ab1468
[ "MIT" ]
null
null
null
import pygame from side_scroller.constants import BLACK from side_scroller.settings import GameSettings, Fonts from side_scroller.player import Player, Hitbox from side_scroller.constants import GAME_NAME class Game(): def __init__(self): self.player = Player(0, Player.y_bottom_barrier) self.screen = pygame.display.set_mode((GameSettings.width, GameSettings.height)) self.game_fps = GameSettings.minFps self.fps_clock = pygame.time.Clock() self.fps_over_min = 1 self.per_loop_adjustment = 1 self.neutral_count = 0 self.obstacles = list() self.initialize_game() def initialize_game(self): pygame.init() pygame.display.set_caption(GAME_NAME) self.initialize_background() def initialize_background(self): self.screen.blit(GameSettings.background.image, GameSettings.background.rect) def refresh_player_location_background(self): self.screen.blit(GameSettings.background.image, self.player.rect, self.player.rect) def update_score_hud(self): score_text = Fonts.hud_font.render( f"Score: {int(self.player.score.score)}", True, BLACK ) self.screen.blit( GameSettings.background.image, score_text.get_rect(), score_text.get_rect()) self.screen.blit(score_text, score_text.get_rect()) def update_high_score(self): self.player.adjust_high_scores() def prepare_new_game(self): self.player.prepare_new_game() self.obstacles = list() self.initialize_background() self.neutral_count = 0 def set_current_fps_over_min_fps(self): self.fps_over_min = self.game_fps / GameSettings.minFps def set_per_loop_adjustment(self): self.per_loop_adjustment = GameSettings.minFps / self.game_fps def is_hover_limit_reached(self): return self.neutral_count > GameSettings.hoverLimit * self.fps_over_min def increase_count_to_obstacle_tick(self): self.player.score.countToObstacleTick += self.per_loop_adjustment def increase_count_to_level_tick(self): self.player.score.countToLevelTick += self.per_loop_adjustment def tick_game_fps_clock(self): self.fps_clock.tick(self.game_fps) def get_obstacles_in_player_path_y(self) -> list: """ Returns a list of obstacles that could be hit if the player moved along y axis. """ player_path_y = Hitbox( pygame.Rect( 0, 0, self.player.width, 10000 ), "neutral" ) return pygame.sprite.spritecollide(player_path_y, self.obstacles, False)
31.329545
91
0.66848
341
2,757
5.1261
0.284457
0.045767
0.040046
0.048055
0.244279
0.086384
0.062929
0.062929
0
0
0
0.005764
0.244831
2,757
87
92
31.689655
0.833814
0.028654
0
0.126984
0
0
0.016579
0.011304
0
0
0
0
0
1
0.222222
false
0
0.079365
0.015873
0.349206
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
1
f2909580065a2556ae0c58be271bee9537858bf1
366
py
Python
solutions/problem_230.py
ksvr444/daily-coding-problem
5d9f488f81c616847ee4e9e48974523ec2d598d7
[ "MIT" ]
1,921
2018-11-13T18:19:56.000Z
2021-11-15T14:25:41.000Z
solutions/problem_230.py
MohitIndian/daily-coding-problem
5d9f488f81c616847ee4e9e48974523ec2d598d7
[ "MIT" ]
2
2019-07-19T01:06:16.000Z
2019-08-01T22:21:36.000Z
solutions/problem_230.py
MohitIndian/daily-coding-problem
5d9f488f81c616847ee4e9e48974523ec2d598d7
[ "MIT" ]
1,066
2018-11-19T19:06:55.000Z
2021-11-13T12:33:56.000Z
def get_min_drops(N, k): if N == 0 or N == 1 or k == 1: return N possibilities = list() for i in range(1, N + 1): possibilities.append( max(get_min_drops(i-1, k-1), get_min_drops(N-i, k)) ) return min(possibilities) + 1 # Tests assert get_min_drops(20, 2) == 6 assert get_min_drops(15, 3) == 5
20.333333
40
0.538251
61
366
3.065574
0.442623
0.160428
0.294118
0.128342
0
0
0
0
0
0
0
0.065306
0.330601
366
17
41
21.529412
0.697959
0.013661
0
0
0
0
0
0
0
0
0
0
0.166667
1
0.083333
false
0
0
0
0.25
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f291aa8b92b2b817f77cb42f08e1e15a9557dcfe
240
py
Python
JaroEliCall/src/functionality/sending_activation_key.py
jaroslaw-wieczorek/Project_IP_Telephony_Python_Voip
05143356fe91f745c286db8c3e2432714ab122e7
[ "MIT" ]
null
null
null
JaroEliCall/src/functionality/sending_activation_key.py
jaroslaw-wieczorek/Project_IP_Telephony_Python_Voip
05143356fe91f745c286db8c3e2432714ab122e7
[ "MIT" ]
null
null
null
JaroEliCall/src/functionality/sending_activation_key.py
jaroslaw-wieczorek/Project_IP_Telephony_Python_Voip
05143356fe91f745c286db8c3e2432714ab122e7
[ "MIT" ]
1
2018-03-20T21:22:40.000Z
2018-03-20T21:22:40.000Z
import smtplib server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login("[email protected]", "AureliaK1609") msg = "YOUR MESSAGE!" server.sendmail("[email protected]", "[email protected]", msg) server.quit()
21.818182
70
0.7375
32
240
5.53125
0.5625
0.180791
0.19209
0
0
0
0
0
0
0
0
0.104545
0.083333
240
10
71
24
0.7
0
0
0
0
0
0.41841
0.096234
0
0
0
0
0
1
0
false
0
0.142857
0
0.142857
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
f293d5631b8815a984d95fcfd9fd7e627ddefdd5
484
py
Python
tests/conftest.py
12rambau/commitizen
4309813974b6be72a246d47fc77f4c7f8ef64be1
[ "MIT" ]
866
2020-03-18T06:09:07.000Z
2022-03-30T15:46:17.000Z
tests/conftest.py
12rambau/commitizen
4309813974b6be72a246d47fc77f4c7f8ef64be1
[ "MIT" ]
364
2020-03-18T02:13:09.000Z
2022-03-31T01:57:12.000Z
tests/conftest.py
12rambau/commitizen
4309813974b6be72a246d47fc77f4c7f8ef64be1
[ "MIT" ]
136
2020-03-20T18:06:32.000Z
2022-03-31T00:02:34.000Z
import pytest from commitizen import cmd @pytest.fixture(scope="function") def tmp_git_project(tmpdir): with tmpdir.as_cwd(): cmd.run("git init") yield tmpdir @pytest.fixture(scope="function") def tmp_commitizen_project(tmp_git_project): with tmp_git_project.as_cwd(): tmp_commitizen_cfg_file = tmp_git_project.join("pyproject.toml") tmp_commitizen_cfg_file.write("[tool.commitizen]\n" 'version="0.1.0"\n') yield tmp_git_project
23.047619
80
0.71281
69
484
4.710145
0.434783
0.092308
0.2
0.16
0.196923
0.196923
0
0
0
0
0
0.007463
0.169421
484
20
81
24.2
0.800995
0
0
0.153846
0
0
0.152893
0
0
0
0
0
0
1
0.153846
false
0
0.153846
0
0.307692
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1