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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ff4a4e23eaf03048578be8ff466e39e45a4bcb36 | 616 | py | Python | MT-MemOverload.py | MillenniumWare/MT-MemOverload | fb8033cda92c8862f536749001cced460e9d73d4 | [
"Unlicense"
] | null | null | null | MT-MemOverload.py | MillenniumWare/MT-MemOverload | fb8033cda92c8862f536749001cced460e9d73d4 | [
"Unlicense"
] | null | null | null | MT-MemOverload.py | MillenniumWare/MT-MemOverload | fb8033cda92c8862f536749001cced460e9d73d4 | [
"Unlicense"
] | null | null | null | import os
import multiprocessing
from multiprocessing import Process
def listfill():
filllist = []
for i in range(9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999):
filllist.append("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
cpucount = os.cpu_count()
cpucount = int(cpucount)
for i in range(cpucount):
if __name__ == '__main__':
p = Process(target=listfill)
p.start()
p.join()
| 29.333333 | 155 | 0.762987 | 42 | 616 | 10.97619 | 0.619048 | 0.017354 | 0.02603 | 0.047722 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.504912 | 0.173701 | 616 | 20 | 156 | 30.8 | 0.400786 | 0 | 0 | 0 | 0 | 0 | 0.22651 | 0.213087 | 0 | 0 | 0 | 0 | 0 | 1 | 0.071429 | false | 0 | 0.214286 | 0 | 0.285714 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 3 |
ff565662ef33de9329ae27dd0fa143e4dda7dd0e | 1,935 | py | Python | mirapy/visualization/visualize.py | awesome-archive/mirapy | f0cdc2cb024e9d09c1d40325c79bd486dacc50a0 | [
"MIT"
] | 42 | 2019-05-09T13:23:07.000Z | 2022-02-01T18:00:38.000Z | mirapy/visualization/visualize.py | awesome-archive/mirapy | f0cdc2cb024e9d09c1d40325c79bd486dacc50a0 | [
"MIT"
] | 18 | 2019-04-22T18:40:09.000Z | 2019-05-06T07:12:38.000Z | mirapy/visualization/visualize.py | awesome-archive/mirapy | f0cdc2cb024e9d09c1d40325c79bd486dacc50a0 | [
"MIT"
] | 10 | 2019-05-06T10:19:20.000Z | 2020-04-20T15:12:33.000Z | import pandas as pd
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # do not remove this line
def visualize_2d(x, y):
"""
Function for 2D visualization of data using Principal Component Analysis
(PCA).
:param x: Array of features.
:param y: Array of target values.
"""
pca = PCA(n_components=2)
principal_components = pca.fit_transform(x)
principal_df = pd.DataFrame(data=principal_components,
columns=['PC 1', 'PC 2'])
target = pd.DataFrame(y, columns=['target'])
new_df = pd.concat([principal_df, target], axis=1)
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(1, 1, 1)
ax.set_xlabel('Principal Component 1')
ax.set_ylabel('Principal Component 2')
ax.set_title('2D Feature Visualization')
im = ax.scatter(new_df[['PC 1']], new_df[['PC 2']],
c=new_df[['target']].values, s=2)
fig.colorbar(im, ax=ax)
ax.grid()
def visualize_3d(x, y):
"""
Function for 3D visualization of data using Principal Component Analysis
(PCA).
:param x: Array of features.
:param y: Array of target values.
"""
pca = PCA(n_components=3)
principal_components = pca.fit_transform(x)
principal_df = pd.DataFrame(data=principal_components,
columns=['PC 1', 'PC 2', 'PC 3'])
target = pd.DataFrame(y, columns=['target'])
new_df = pd.concat([principal_df, target], axis=1)
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')
im = ax.scatter(new_df[['PC 1']], new_df[['PC 2']], new_df[['PC 3']], c=y,
s=2)
ax.set_xlabel('Principal Component 1')
ax.set_ylabel('Principal Component 2')
ax.set_zlabel('Principal Component 3')
ax.set_title('3D Feature Visualization')
fig.colorbar(im, ax=ax)
ax.grid()
| 31.209677 | 78 | 0.62739 | 276 | 1,935 | 4.282609 | 0.271739 | 0.033841 | 0.029611 | 0.021997 | 0.724196 | 0.724196 | 0.724196 | 0.685279 | 0.685279 | 0.685279 | 0 | 0.02977 | 0.236176 | 1,935 | 61 | 79 | 31.721311 | 0.769959 | 0.16124 | 0 | 0.486486 | 0 | 0 | 0.135842 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.054054 | false | 0 | 0.108108 | 0 | 0.162162 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
ff5af4deccd51af355537a6566f33c85339b3657 | 168 | py | Python | micro-benchmark/snippets/classes/parameter_call/main.py | WenJinfeng/PyCG | b45e8e04fe697d8301cf27222a8f37646d69f168 | [
"Apache-2.0"
] | 121 | 2020-12-16T20:31:37.000Z | 2022-03-21T20:32:43.000Z | micro-benchmark/snippets/classes/parameter_call/main.py | WenJinfeng/PyCG | b45e8e04fe697d8301cf27222a8f37646d69f168 | [
"Apache-2.0"
] | 24 | 2021-03-13T00:04:00.000Z | 2022-03-21T17:28:11.000Z | micro-benchmark/snippets/classes/parameter_call/main.py | WenJinfeng/PyCG | b45e8e04fe697d8301cf27222a8f37646d69f168 | [
"Apache-2.0"
] | 19 | 2021-03-23T10:58:47.000Z | 2022-03-24T19:46:50.000Z | class MyClass:
def func3(self):
pass
def func2(self, a):
a()
def func1(self, a, b):
a(b)
a = MyClass()
a.func1(a.func2, a.func3)
| 12.923077 | 26 | 0.5 | 26 | 168 | 3.230769 | 0.384615 | 0.119048 | 0.071429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054545 | 0.345238 | 168 | 12 | 27 | 14 | 0.709091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0.111111 | 0 | 0 | 0.444444 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
ff7bba7bd6fc3103608b20a19be0e9e5e0dc4c4c | 65 | py | Python | tests/integration/ext.py | dreamingspires/flask-navigation | b322ff32764f080daab8ccf7a640a54e83479f1f | [
"MIT"
] | 13 | 2015-07-02T12:37:34.000Z | 2022-01-16T17:58:45.000Z | tests/integration/ext.py | dreamingspires/flask-navigation | b322ff32764f080daab8ccf7a640a54e83479f1f | [
"MIT"
] | 4 | 2015-03-09T10:09:25.000Z | 2016-09-23T07:01:32.000Z | tests/integration/ext.py | dreamingspires/flask-navigation | b322ff32764f080daab8ccf7a640a54e83479f1f | [
"MIT"
] | 10 | 2015-04-02T16:54:36.000Z | 2022-02-03T17:14:49.000Z | from flask.ext.navigation import Navigation
nav = Navigation()
| 13 | 43 | 0.784615 | 8 | 65 | 6.375 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138462 | 65 | 4 | 44 | 16.25 | 0.910714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
ff8ee25a7be9bd8845a4a4dcbbe0c81cd4fd2fc9 | 2,228 | py | Python | django_mri/analysis/interfaces/matlab/spm/cat12/longitudinal_segmentation/outputs.py | GalBenZvi/django_mri | 558e9187a6ba18b7ba69aced919a6f94d066a2fc | [
"Apache-2.0"
] | 4 | 2020-07-27T20:33:54.000Z | 2022-01-11T20:24:03.000Z | django_mri/analysis/interfaces/matlab/spm/cat12/longitudinal_segmentation/outputs.py | GalBenZvi/django_mri | 558e9187a6ba18b7ba69aced919a6f94d066a2fc | [
"Apache-2.0"
] | 107 | 2019-09-04T11:38:46.000Z | 2022-03-04T13:59:51.000Z | django_mri/analysis/interfaces/matlab/spm/cat12/longitudinal_segmentation/outputs.py | GalBenZvi/django_mri | 558e9187a6ba18b7ba69aced919a6f94d066a2fc | [
"Apache-2.0"
] | 2 | 2019-08-16T10:06:13.000Z | 2019-08-30T15:42:45.000Z | """
Dictionaries containing CAT12 longitudinal segmentation output file names by
key.
"""
#: Output file names by key.
SEGMENTATION_OUTPUT = {
"surface_estimation": [
"surf/lh.central.{file_name}.gii",
"surf/lh.sphere.{file_name}.gii",
"surf/lh.sphere.reg.{file_name}.gii",
"surf/lh.thickness.{file_name}",
"surf/rh.central.{file_name}.gii",
"surf/rh.sphere.{file_name}.gii",
"surf/rh.sphere.reg.{file_name}.gii",
"surf/rh.thickness.{file_name}",
"surf/lh.pbt.{file_name}",
"surf/rh.pbt.{file_name}",
"label/catROIs_{file_name}.mat",
"label/catROIs_{file_name}.xml",
],
"neuromorphometrics": [
"label/catROI_{file_name}.mat",
"label/catROI_{file_name}.xml",
],
"lpba40": ["label/catROI_{file_name}.mat", "label/catROI_{file_name}.xml"],
"cobra": ["label/catROI_{file_name}.mat", "label/catROI_{file_name}.xml"],
"hammers": [
"label/catROI_{file_name}.mat",
"label/catROI_{file_name}.xml",
],
"native_grey_matter": "mri/p1{file_name}.nii",
"modulated_grey_matter": "mri/mwp1{file_name}.nii",
"dartel_grey_matter": {
"rigid": "mri/rp1{file_name}_rigid.nii",
"affine": "mri/rp1{file_name}_affine.nii",
},
"native_white_matter": "mri/p2{file_name}.nii",
"modulated_white_matter": "mri/mwp2{file_name}.nii",
"dartel_white_matter": {
"rigid": "mri/rp2{file_name}_rigid.nii",
"affine": "mri/rp2{file_name}_affine.nii",
},
"native_pve": "mri/p0{file_name}.nii",
"warped_image": "mri/wm{file_name}.nii",
"jacobian_determinant": "mri/wj_{file_name}.nii",
"deformation_fields": {
"none": None,
"forward": "mri/y_{file_name}.nii",
"inverse": "mri/iy_{file_name}.nii",
"both": ["mri/y_{file_name}.nii", "mri/iy_{file_name}.nii"],
},
}
#: Artifacts created during execution.
AUXILIARY_OUTPUT = {
"batch_file": "segmentation.m",
"reports": [
"report/cat_{file_name}.mat",
"report/cat_{file_name}.xml",
"report/catlog_{file_name}.txt",
"report/catreport_{file_name}.pdf",
"report/catreportj_{file_name}.jpg",
],
}
| 33.757576 | 79 | 0.611311 | 281 | 2,228 | 4.548043 | 0.281139 | 0.250391 | 0.094679 | 0.118936 | 0.406886 | 0.276995 | 0.137715 | 0.137715 | 0.137715 | 0.137715 | 0 | 0.007279 | 0.198384 | 2,228 | 65 | 80 | 34.276923 | 0.708287 | 0.06553 | 0 | 0.140351 | 0 | 0 | 0.665702 | 0.538833 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ffa2c2e5ee7d841da202fb9e3b498dd3f2c6974f | 54 | py | Python | graduate/test.py | mxito3/graduate_pro | 7fca6e0387f741b8fc887cddd7e7fd8c9953a330 | [
"MIT"
] | 1 | 2020-01-02T01:40:57.000Z | 2020-01-02T01:40:57.000Z | graduate/test.py | mxito3/graduate_pro | 7fca6e0387f741b8fc887cddd7e7fd8c9953a330 | [
"MIT"
] | 1 | 2021-06-02T01:18:04.000Z | 2021-06-02T01:18:04.000Z | graduate/test.py | mxito3/graduate_pro | 7fca6e0387f741b8fc887cddd7e7fd8c9953a330 | [
"MIT"
] | null | null | null | import time
while True:
print(1)
time.sleep(3) | 13.5 | 17 | 0.648148 | 9 | 54 | 3.888889 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.04878 | 0.240741 | 54 | 4 | 17 | 13.5 | 0.804878 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.25 | 0 | 0.25 | 0.25 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ffba9d241fbcfcfe0bedf8a16d4fc1d9e4f660b5 | 231 | py | Python | gcody/__init__.py | rtZamb/pyGCODE | 5b5807910daa5a85cb232337ea4a58e857e6ce3d | [
"MIT"
] | 11 | 2018-11-06T21:02:55.000Z | 2022-03-14T01:46:50.000Z | gcody/__init__.py | rtZamb/pyGCODE | 5b5807910daa5a85cb232337ea4a58e857e6ce3d | [
"MIT"
] | 1 | 2020-04-10T02:13:38.000Z | 2020-08-14T03:16:28.000Z | gcody/__init__.py | rtZamb/pyGCODE | 5b5807910daa5a85cb232337ea4a58e857e6ce3d | [
"MIT"
] | 5 | 2018-05-05T18:59:54.000Z | 2021-05-14T15:08:08.000Z | # the init for the module gcody written by Ryan Zambrotta
# importing the core classes and functions
from .gsettings import gsettings
from .gcode import gcode
from .readg import read
from .stl import readstl, viewstl, viewmesh
| 21 | 57 | 0.792208 | 34 | 231 | 5.382353 | 0.705882 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.17316 | 231 | 10 | 58 | 23.1 | 0.958115 | 0.415584 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
4401090a8f51d88a48ad8f3ded4ef5cf77b36b48 | 2,664 | py | Python | src/polyswarmd/utils/bloom.py | polyswarm/polyswarmd | b732d60f0f829cc355c1f938bbe6de69f9985098 | [
"MIT"
] | 14 | 2018-04-16T18:04:23.000Z | 2019-11-26T06:39:23.000Z | src/polyswarmd/utils/bloom.py | polyswarm/polyswarmd | b732d60f0f829cc355c1f938bbe6de69f9985098 | [
"MIT"
] | 227 | 2018-04-03T01:10:34.000Z | 2021-03-25T21:49:58.000Z | src/polyswarmd/utils/bloom.py | polyswarm/polyswarmd | b732d60f0f829cc355c1f938bbe6de69f9985098 | [
"MIT"
] | 2 | 2018-04-23T18:37:47.000Z | 2021-04-26T10:58:39.000Z | # Based on eth-bloom (https://github.com/ethereum/eth-bloom, used under MIT
# license) with modifications
import logging
import numbers
import operator
from polyswarmd.utils import sha3
logger = logging.getLogger(__name__)
FILTER_BITS = 8 * 256
HASH_FUNCS = 8
def get_chunks_for_bloom(value_hash):
assert HASH_FUNCS * 2 <= len(value_hash)
for i in range(0, HASH_FUNCS):
yield value_hash[2 * i:2 * (i+1)] # noqa
def chunk_to_bloom_bits(chunk):
assert FILTER_BITS <= (1 << 16)
high, low = bytearray(chunk)
return 1 << ((low + (high << 8)) & (FILTER_BITS - 1))
def get_bloom_bits(value):
# Could decode the ipfs_hash and use it as is, but instead hash the
# multihash representation to side-step different hash formats going
# forward. Should rexamine this decision
value_hash = sha3(value)
for chunk in get_chunks_for_bloom(value_hash):
bloom_bits = chunk_to_bloom_bits(chunk)
yield bloom_bits
class BloomFilter(numbers.Number):
value = None
def __init__(self, value=0):
self.value = value
def __int__(self):
return self.value
def add(self, value):
if not isinstance(value, bytes):
raise TypeError("Value must be of type `bytes`")
for bloom_bits in get_bloom_bits(value):
self.value |= bloom_bits
def extend(self, iterable):
for value in iterable:
self.add(value)
@classmethod
def from_iterable(cls, iterable):
bloom = cls()
bloom.extend(iterable)
return bloom
def __contains__(self, value):
if not isinstance(value, bytes):
raise TypeError("Value must be of type `bytes`")
return all(self.value & bloom_bits for bloom_bits in get_bloom_bits(value))
def __index__(self):
return operator.index(self.value)
def _combine(self, other):
if not isinstance(other, (int, BloomFilter)):
raise TypeError("The `or` operator is only supported for other `BloomFilter` instances")
return BloomFilter(int(self) | int(other))
def __hash__(self):
return hash(self.value)
def __or__(self, other):
return self._combine(other)
def __add__(self, other):
return self._combine(other)
def _icombine(self, other):
if not isinstance(other, (int, BloomFilter)):
raise TypeError("The `or` operator is only supported for other `BloomFilter` instances")
self.value |= int(other)
return self
def __ior__(self, other):
return self._icombine(other)
def __iadd__(self, other):
return self._icombine(other)
| 28.042105 | 100 | 0.654655 | 354 | 2,664 | 4.69209 | 0.310734 | 0.059603 | 0.045154 | 0.045756 | 0.393739 | 0.368453 | 0.298615 | 0.257676 | 0.220349 | 0.220349 | 0 | 0.00951 | 0.25 | 2,664 | 94 | 101 | 28.340426 | 0.821822 | 0.104354 | 0 | 0.1875 | 0 | 0 | 0.082388 | 0 | 0 | 0 | 0 | 0 | 0.03125 | 1 | 0.265625 | false | 0 | 0.0625 | 0.109375 | 0.546875 | 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 | 1 | 1 | 0 | 0 | 3 |
4410b6ed455f1989fda6ed1abf932f434bd077aa | 67 | py | Python | python/591.tag-validator.py | stavanmehta/leetcode | 1224e43ce29430c840e65daae3b343182e24709c | [
"Apache-2.0"
] | null | null | null | python/591.tag-validator.py | stavanmehta/leetcode | 1224e43ce29430c840e65daae3b343182e24709c | [
"Apache-2.0"
] | null | null | null | python/591.tag-validator.py | stavanmehta/leetcode | 1224e43ce29430c840e65daae3b343182e24709c | [
"Apache-2.0"
] | null | null | null | class Solution:
def isValid(self, code: str) -> bool:
| 16.75 | 41 | 0.567164 | 8 | 67 | 4.75 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.313433 | 67 | 3 | 42 | 22.333333 | 0.826087 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4428eb5f32ca496fcaf7dfb2ea511f4594075317 | 2,228 | py | Python | Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/openedx/core/djangoapps/catalog/api.py | osoco/better-ways-of-thinking-about-software | 83e70d23c873509e22362a09a10d3510e10f6992 | [
"MIT"
] | 3 | 2021-12-15T04:58:18.000Z | 2022-02-06T12:15:37.000Z | Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/openedx/core/djangoapps/catalog/api.py | osoco/better-ways-of-thinking-about-software | 83e70d23c873509e22362a09a10d3510e10f6992 | [
"MIT"
] | null | null | null | Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/openedx/core/djangoapps/catalog/api.py | osoco/better-ways-of-thinking-about-software | 83e70d23c873509e22362a09a10d3510e10f6992 | [
"MIT"
] | 1 | 2019-01-02T14:38:50.000Z | 2019-01-02T14:38:50.000Z | """
Python APIs exposed by the catalog app to other in-process apps.
"""
from .utils import get_programs_by_type_slug as _get_programs_by_type_slug
from .utils import get_programs as _get_programs
from .utils import course_run_keys_for_program as _course_run_keys_for_program
from .utils import get_course_run_details as _get_course_run_details
def get_programs_by_type(site, program_type_slug):
"""
Retrieves a list of programs for the site whose type's slug matches the parameter.
Slug is used is used as a consistent value to check since ProgramType.name is
a field that gets translated.
Params:
site (Site): The corresponding Site object to fetch programs for.
program_type_slug (string): The type slug that matching programs must have.
Returns:
A list of programs (dicts) for the given site with the given type slug
"""
return _get_programs_by_type_slug(site, program_type_slug)
def get_programs_from_cache_by_uuid(uuids):
"""
Retrieves the programs for the provided UUIDS. Relies on
the Program cache, if it is not updated or data is missing the result
will be missing data or empty.
Params:
uuids (list): A list of Program UUIDs to get Program data for from the cache.
Returns:
(list): list of dictionaries representing programs.
"""
return _get_programs(uuids=uuids)
def get_course_run_key_for_program_from_cache(program):
"""
Retrieves a list of Course Run Keys from the Program.
Params:
program (dict): A dictionary from the program cache containing the data for a program.
Returns:
(set): A set of Course Run Keys.
"""
return _course_run_keys_for_program(parent_program=program)
def get_course_run_details(course_key, fields_list):
"""
Retrieves course run details for a given course run key.
Params:
course_key (CourseKey): The identifier for the course.
fields_list (List, string): A list of fields (as strings) of values we want returned.
Returns:
dict containing response from the Discovery API that includes the fields specified in `fields_list`
"""
return _get_course_run_details(course_key, fields_list)
| 34.8125 | 107 | 0.735189 | 337 | 2,228 | 4.635015 | 0.293769 | 0.069142 | 0.041613 | 0.043534 | 0.159411 | 0.048656 | 0.048656 | 0.048656 | 0 | 0 | 0 | 0 | 0.211849 | 2,228 | 63 | 108 | 35.365079 | 0.889522 | 0.601885 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.333333 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
444f3859382916cfd9a249a25c4e0c8254d3524b | 3,615 | py | Python | src/abstraits/id/__init__.py | TheProjecter/kassie | 1497f3cf8af661024086d25df86423568ed8d0c9 | [
"BSD-3-Clause"
] | 1 | 2017-01-08T05:09:29.000Z | 2017-01-08T05:09:29.000Z | src/abstraits/id/__init__.py | TheProjecter/kassie | 1497f3cf8af661024086d25df86423568ed8d0c9 | [
"BSD-3-Clause"
] | null | null | null | src/abstraits/id/__init__.py | TheProjecter/kassie | 1497f3cf8af661024086d25df86423568ed8d0c9 | [
"BSD-3-Clause"
] | null | null | null | # -*-coding:Utf-8 -*
# Copyright (c) 2010 LE GOFF Vincent
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Ce package définit les objets et fonctions nécessaires à la manipulation
d'objets identifiées par des ID. La classe ObjetID, détaillée plus bas,
donne plus d'informations sur ces objets.
"""
from abstraits.objet_id.id import ID
class ObjetID:
"""Cette classe abstraite peut être héritée des objets qui souhaitent
obtenir un identifiant unique, propre à chaque objet créé.
Celui-ci se base sur deux données :
- une chaîne de caractère identifiant le groupe d'objets. Ce préfixe
est nécessaire quand on souhaite grouper plusieurs objets dans
une structure, un dictionnaire par exemple. Le module primaire parid
associe un dictionnaire par groupe d'objet et cela permet de retrouver
la classe concernée par le préfixe. Quand on souhaite créer
un nouveau groupe, on doit hériter cette classe en lui donnant
un nom de groupe qui sera utilisé pour chaque objet créé
- un entier identifiant clairement le numéro de l'objet. Cet entier
s'incrémente à chaque fois que l'on créée un objet du groupe
Exemple : 'salles:45' fait référence à un objet du groupe 'salles'
(probablement une salle) dont le numéro identifiant est 45. Ainsi, on ne
risque pas de le confondre avec 'joueurs:45'.
"""
id_actuel = 1 # on compte à partir de 1
groupe = "" # la chaîne contenant le nom du groupe préfixant l'ID
def __init__(self):
"""Constructeur de la classe. On incrémente l'id_actuel du groupe.
Dans le même temps, on crée un attribut nommé id dans l'objet
manipulé. On associe à cet attribut un ID contenant le nom du groupe
et l'identifiant entier le caractérisant.
"""
self.id = ID(type(self).groupe, type(self).id_actuel)
type(self).id_actuel += 1
# Fonctions liées à la manipulation de ces objets
def est_objet_id(objet):
"""Cette fonction renvoie True si l'objet manipulé est un ObjetID ou
dérivé, False sinon.
"""
return isinstance(objet, ObjetID)
| 45.1875 | 79 | 0.735546 | 533 | 3,615 | 4.968105 | 0.499062 | 0.015106 | 0.01284 | 0.017372 | 0.086103 | 0.05136 | 0.05136 | 0.05136 | 0.05136 | 0.05136 | 0 | 0.004926 | 0.213831 | 3,615 | 79 | 80 | 45.759494 | 0.926812 | 0.859198 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
446ba693bb064a1ac9b554e472ae5f1766eb84f0 | 115 | py | Python | run.py | iKintosh/Tink2020_LMS | d5937658cec701af04be18cfae648ffc3bdadf53 | [
"MIT"
] | 1 | 2021-05-13T08:42:11.000Z | 2021-05-13T08:42:11.000Z | run.py | iKintosh/Tink2020_LMS | d5937658cec701af04be18cfae648ffc3bdadf53 | [
"MIT"
] | 3 | 2020-03-31T10:48:13.000Z | 2021-08-23T20:34:26.000Z | run.py | iKintosh/Tink2020_LMS | d5937658cec701af04be18cfae648ffc3bdadf53 | [
"MIT"
] | null | null | null | from flask.cli import FlaskGroup
from LMS import app
cli = FlaskGroup(app)
if __name__ == "__main__":
cli()
| 12.777778 | 32 | 0.704348 | 16 | 115 | 4.5625 | 0.625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 115 | 8 | 33 | 14.375 | 0.793478 | 0 | 0 | 0 | 0 | 0 | 0.069565 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
4476e6ec7d827485c90dea26ec5b6ead9c91cbee | 11,935 | py | Python | jetmontecarlo/tests/simple_tests/test_multem_simplecases.py | samcaf/JetMonteCarlo | 71f50f3bb53a4f68ed927eaeaed5ee258da0dd34 | [
"MIT"
] | null | null | null | jetmontecarlo/tests/simple_tests/test_multem_simplecases.py | samcaf/JetMonteCarlo | 71f50f3bb53a4f68ed927eaeaed5ee258da0dd34 | [
"MIT"
] | null | null | null | jetmontecarlo/tests/simple_tests/test_multem_simplecases.py | samcaf/JetMonteCarlo | 71f50f3bb53a4f68ed927eaeaed5ee258da0dd34 | [
"MIT"
] | null | null | null | from math import factorial
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import comb
# Local utils:
from jetmontecarlo.montecarlo.integrator import integrator
from jetmontecarlo.utils.plot_utils \
import aestheticfig, style_dashed, style_yerr, \
legend_darklight, labelLines
from jetmontecarlo.utils.color_utils import compcolors
# Local test utils:
from jetmontecarlo.tests.simple_tests.test_simpleSampler import simpleSampler
# Parameters
NUM_SAMPLES = 1000
NUM_BINS = 100
NUM_RVS = 3
X_MAX = [NUM_RVS, 2*NUM_RVS]
SHOW_PLOTS = True
SAVE_PLOTS = False
# ------------------------------------
# Test pdfs:
# ------------------------------------
rvtypes = ['Uniform (0,1)', 'Uniform (0,2)', 'Gaussian']
def simple_pdf(samples, algorithm=0):
"""Returns a test pdf for a set of samples, in order
to test the procedure we are using to generate pdfs
and cdfs for multiple emissions.
The particular test pdf depends on the algorithm
we are using to test the multiple emissions procedure
Parameters
----------
samples : list
A list of samples to which
algorithm : int
An integer that determines the particular pdf we use
to test our multiple emissions procedure:
0 - Uniform pdf from 0 to 1
1 - Uniform pdf from 0 to 2
Returns pdf
-------
list
A set of pdfs corresponding to the given samples,
for the given algorithm.
"""
assert algorithm in [0, 1, 2], "Unsupported pdf algorithm."
if algorithm == 0:
return np.ones(len(samples))
if algorithm == 1:
return np.ones(len(samples)) / 2.
return np.zeros(len(samples))
# ------------------------------------
# Analytic CDFs:
# ------------------------------------
def simple_cdf(x_vals, num_summed, algorithm=0):
"""Analytic expression for the cdf of a sum of
num_summed random variables distributed according
to an algorithm.
Parameters
----------
x_vals : list
List of x values for which we will return a cdf.
num_summed : type
Number of identically distributed random variables
we consider summing over.
algorithm : type
Algorithm which determines the distribution of our
random variables.
Returns cdf
-------
numpy array
An array containing a list of cdf values for the given x_vals
"""
cdf = []
if algorithm == 0:
# Uniform RVs from 0 to 1
# The Irwin-Hall distribution governs the sum of uniform rvs:
# https://en.wikipedia.org/wiki/Irwin–Hall_distribution
for x_val in x_vals:
cdf_x = 0
for k in range(int(np.floor(x_val)+1)):
cdf_x_k = (-1)**k*comb(num_summed, k)*(x_val-k)**num_summed
cdf_x += cdf_x_k/factorial(num_summed)
cdf.append(cdf_x)
cdf = np.array(cdf)
return cdf*(cdf < 1.) + (cdf >= 1.)
if algorithm == 1:
# Uniform RVs from 0 to 2
for x_val in x_vals:
cdf_x = 0
x_val = x_val/2.
for k in range(int(np.floor(x_val)+1)):
cdf_x_k = (-1)**k*comb(num_summed, k)*(x_val-k)**num_summed
cdf_x += cdf_x_k/factorial(num_summed)
cdf.append(cdf_x)
cdf = np.array(cdf)
return cdf*(cdf < 1.) + (cdf >= 1.)
# Gaussian RVs
cdf = np.zeros(len(x_vals))
return cdf*(cdf < 1.) + (cdf >= 1.)
# ------------------------------------
# Testing sums of RVs:
# ------------------------------------
def test_lin_sum_of_uniform_rvs(algorithm):
"""Produces pdfs associated with sums of identical random
variables (rvs), using linear MC integration.
The distribution of the rvs depends on a chosen algorithm.
In particular, this method samples over 3 rvs, and integrates
out 2, 1, or none of these rvs in order to produce several
distributions.
This is to make sure that the integration over multiple emissions
when we go to the case of jet observables does not have problems
when it comes to the way it integrates over the extra emissions.
Parameters
----------
algorithm : int
An integer that determines the particular pdf we use
to test our multiple emissions procedure:
0 - Uniform pdf from 0 to 1
1 - Uniform pdf from 0 to 2
Returns None
"""
# Setting up plot
_, axes = aestheticfig(xlabel='x', ylabel='CDF(x)',
title='CDFs of sums of '
+ str(rvtypes[algorithm]) + ' RVs',
xlim=(0, X_MAX[algorithm]),
ylim=(0, 1.1),
showdate=False,
ratio_plot=False)
# Plotting the analytic result for the sum of i rvs
pnts = np.linspace(0, X_MAX[algorithm], 1000)
for i in range(NUM_RVS):
axes[0].plot(pnts, simple_cdf(pnts, i+1, algorithm),
**style_dashed,
color=compcolors[(i%4, 'light')],
label=str(i+1) + ' RVs' if i != 0 else '1 RV')
# Labelling the lines for the analytic expressions
labelLines(axes[0].get_lines(),
xvals=np.linspace(.5*(algorithm+1), (NUM_RVS-.5)*(algorithm+1),
NUM_RVS))
# Setting up total integration weight, area, and observables
weights = 1.
area = 1.
# The first entry of obs_all will have rvs distributed by 'algorithm',
# the second will have the sum of two identically such distributed rvs,
# etc.
obs_all = []
for i in range(NUM_RVS):
# Generating samples
test_sampler = simpleSampler('lin')
test_sampler.generateSamples(NUM_SAMPLES)
if algorithm == 1:
test_sampler.samples *= 2.
test_sampler.area *= 2.
# Getting integration weight for all samples at once
weights = (weights * np.array(test_sampler.jacobians)
* simple_pdf(test_sampler.getSamples(), algorithm))
# Getting integration area for all samples at once
area = area * test_sampler.area
# Getting the sums of our identically distributed rvs
if i == 0:
obs_all.append(test_sampler.getSamples())
else:
obs_all.append(obs_all[-1]+test_sampler.getSamples())
# Setting up integrator
test_int = integrator()
test_int.setLastBinBndCondition((1., 'minus'))
# Enumerating over the relevant sets of samples, jacobians, and areas
# to find distributions for each possible sum of rvs:
for i, obs in enumerate(obs_all):
# Integration
test_int.setBins(NUM_BINS, obs, 'lin')
test_int.setDensity(obs, weights, area)
test_int.integrate()
# Plotting
_, _, bars = axes[0].errorbar(x=test_int.bins[:-1],
y=test_int.integral,
yerr=test_int.integralErr,
**style_yerr,
color=compcolors[(i%4, 'dark')],
ecolor=compcolors[(i%4, 'dark')])
bars = [b.set_alpha(.5) for b in bars]
# Legend
legend_darklight(axes[0], errtype='yerr', twosigma=False)
if SHOW_PLOTS:
plt.show()
elif SAVE_PLOTS:
plt.savefig('rv_lin_sum_'+str(algorithm)+'_test.pdf',
format='pdf')
def test_log_sum_of_uniform_rvs(algorithm):
"""Produces pdfs associated with sums of identical random
variables (rvs), using logarithmic MC integration.
The distribution of the rvs depends on a chosen algorithm.
In particular, this method samples over 3 rvs, and integrates
out 2, 1, or none of these rvs in order to produce several
distributions.
This is to make sure that the integration over multiple emissions
when we go to the case of jet observables does not have problems
when it comes to the way it integrates over the extra emissions.
Parameters
----------
algorithm : int
An integer that determines the particular pdf we use
to test our multiple emissions procedure:
0 - Uniform pdf from 0 to 1
1 - Uniform pdf from 0 to 2
Returns None
"""
# Setting up plot
_, axes = aestheticfig(xlabel='x', ylabel='CDF(x)',
title='CDFs of sums of '
+ str(rvtypes[algorithm]) + ' RVs',
xlim=(1e-3, X_MAX[algorithm]),
ylim=(0, 1.1),
showdate=False,
ratio_plot=False)
axes[0].set_xscale('log')
# Plotting the analytic result for the sum of i rvs
pnts = np.logspace(-3, np.log10(X_MAX[algorithm]), 1000)
for i in range(NUM_RVS):
axes[0].plot(pnts, simple_cdf(pnts, i+1, algorithm),
**style_dashed,
color=compcolors[(i%4, 'light')],
label=str(i+1) + ' RVs' if i != 0 else '1 RV')
# Labelling the lines for the analytic expressions
labelLines(axes[0].get_lines(),
xvals=np.logspace(np.log10(8e-2),
np.log10((NUM_RVS-2)*(algorithm+1.)),
NUM_RVS))
# Setting up total integration weight, area, and observables
weights = 1.
area = 1.
# The first entry of obs_all will have rvs distributed by 'algorithm',
# the second will have the sum of two identically such distributed rvs,
# etc.
obs_all = []
for i in range(NUM_RVS):
# Generating samples
test_sampler = simpleSampler('log', epsilon=1e-8)
test_sampler.generateSamples(NUM_SAMPLES)
if algorithm == 1:
test_sampler.samples = np.array(test_sampler.samples)*2.
test_sampler.jacobians = np.array(test_sampler.jacobians)*2.
# Getting integration weight for all samples at once
weights = (weights * np.array(test_sampler.jacobians)
* simple_pdf(test_sampler.getSamples(), algorithm))
# Getting integration area for all samples at once
area = area * test_sampler.area
# Getting the sums of our identically distributed rvs
if i == 0:
obs_all.append(test_sampler.getSamples())
else:
obs_all.append(obs_all[-1]+test_sampler.getSamples())
# Setting up integrator
test_int = integrator()
test_int.setLastBinBndCondition((1., 'minus'))
# Enumerating over the relevant sets of samples, jacobians, and areas
# to find distributions for each possible sum of rvs:
for i, obs in enumerate(obs_all):
# Integration
test_int.setBins(NUM_BINS, obs, 'log')
test_int.setDensity(obs, weights, area)
test_int.integrate()
# Plotting
_, _, bars = axes[0].errorbar(x=test_int.bins[:-1],
y=test_int.integral,
yerr=test_int.integralErr,
**style_yerr,
color=compcolors[(i%4, 'dark')],
ecolor=compcolors[(i%4, 'dark')])
bars = [b.set_alpha(.5) for b in bars]
# Legend
legend_darklight(axes[0], errtype='yerr', twosigma=False)
if SHOW_PLOTS:
plt.show()
elif SAVE_PLOTS:
plt.savefig('rv_log_sum_'+str(algorithm)+'_test.pdf',
format='pdf')
#########################################################
# Tests:
#########################################################
if __name__ == "__main__":
test_lin_sum_of_uniform_rvs(algorithm=0)
test_lin_sum_of_uniform_rvs(algorithm=1)
test_log_sum_of_uniform_rvs(algorithm=0)
test_log_sum_of_uniform_rvs(algorithm=1)
| 35.20649 | 78 | 0.578886 | 1,514 | 11,935 | 4.437252 | 0.167768 | 0.032748 | 0.008336 | 0.01563 | 0.748139 | 0.72983 | 0.72075 | 0.690682 | 0.690682 | 0.685025 | 0 | 0.017582 | 0.304231 | 11,935 | 338 | 79 | 35.310651 | 0.791305 | 0.363636 | 0 | 0.677215 | 0 | 0 | 0.034105 | 0 | 0 | 0 | 0 | 0 | 0.006329 | 1 | 0.025316 | false | 0 | 0.050633 | 0 | 0.113924 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
44843f6cb1c9d43433ac60af1e5d094d2d805843 | 127 | py | Python | plugins/sub_cookie.py | degemer/m-croissant | 0922e7a0164c9dbbad67a677428b530fb678f905 | [
"Unlicense"
] | 1 | 2015-05-27T18:00:56.000Z | 2015-05-27T18:00:56.000Z | plugins/sub_cookie.py | degemer/m-croissant | 0922e7a0164c9dbbad67a677428b530fb678f905 | [
"Unlicense"
] | null | null | null | plugins/sub_cookie.py | degemer/m-croissant | 0922e7a0164c9dbbad67a677428b530fb678f905 | [
"Unlicense"
] | null | null | null | from . import bot
@bot.subscribe('cookie')
def sub_cookie(message):
bot.speak('I see a cookie in "{0}"'.format(message))
| 18.142857 | 56 | 0.677165 | 20 | 127 | 4.25 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009259 | 0.149606 | 127 | 6 | 57 | 21.166667 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0.228346 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
448bbe506d98b3fcde86572a540d4a88de42c087 | 385 | py | Python | tests/class/param03.py | ktok07b6/polyphony | 657c5c7440520db6b4985970bd50547407693ac4 | [
"MIT"
] | 83 | 2015-11-30T09:59:13.000Z | 2021-08-03T09:12:28.000Z | tests/class/param03.py | jesseclin/polyphony | 657c5c7440520db6b4985970bd50547407693ac4 | [
"MIT"
] | 4 | 2017-02-10T01:43:11.000Z | 2020-07-14T03:52:25.000Z | tests/class/param03.py | jesseclin/polyphony | 657c5c7440520db6b4985970bd50547407693ac4 | [
"MIT"
] | 11 | 2016-11-18T14:39:15.000Z | 2021-02-23T10:05:20.000Z | from polyphony import testbench
class C:
def __init__(self, x):
self.x = x
def get_x(self):
return self.x
def c_get_x_mul(c1, c2):
return c1.get_x() * c2.get_x()
def param03(x):
c1 = C(x)
c2 = C(x+1)
return c_get_x_mul(c1, c2)
@testbench
def test():
assert 2 == param03(1)
assert 6 == param03(2)
assert 12 == param03(3)
test()
| 15.4 | 34 | 0.581818 | 67 | 385 | 3.149254 | 0.343284 | 0.094787 | 0.047393 | 0.075829 | 0.113744 | 0.113744 | 0 | 0 | 0 | 0 | 0 | 0.086643 | 0.280519 | 385 | 24 | 35 | 16.041667 | 0.67509 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.277778 | false | 0 | 0.055556 | 0.111111 | 0.555556 | 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 | 1 | 1 | 0 | 0 | 3 |
9225b3022c4cb1218844cd395b85fc7fc935b564 | 534 | py | Python | termlink/services.py | lifeomic/termlink | 61e376a23415288ec0c0e0e45da84c18aa68e94f | [
"MIT"
] | null | null | null | termlink/services.py | lifeomic/termlink | 61e376a23415288ec0c0e0e45da84c18aa68e94f | [
"MIT"
] | 23 | 2019-04-04T23:13:31.000Z | 2022-01-19T19:35:22.000Z | termlink/services.py | lifeomic/termlink | 61e376a23415288ec0c0e0e45da84c18aa68e94f | [
"MIT"
] | null | null | null | """Services
A collection of interfaces built for extending ontology transformations.
"""
from abc import ABC, abstractmethod
from typing import List
from termlink.models import Relationship
class RelationshipService(ABC):
"""
An interface for actions related to the `Relationship` model
"""
@abstractmethod
def get_relationships(self) -> List[Relationship]:
"""
Gets a `List` of `Relationship` objects
Returns:
A `List` of `Relationship` objects
"""
pass
| 20.538462 | 72 | 0.664794 | 56 | 534 | 6.321429 | 0.642857 | 0.028249 | 0.039548 | 0.107345 | 0.146893 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.254682 | 534 | 25 | 73 | 21.36 | 0.889447 | 0.434457 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0.142857 | 0.428571 | 0 | 0.714286 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
922858c3fd93afb0769f586f62787944b219a6c1 | 2,260 | py | Python | kg_core/models.py | alexisdurieux/kg-core-python | 35d416359ddc3df37cf3604a8488eeb36f27d5e5 | [
"Apache-2.0"
] | null | null | null | kg_core/models.py | alexisdurieux/kg-core-python | 35d416359ddc3df37cf3604a8488eeb36f27d5e5 | [
"Apache-2.0"
] | null | null | null | kg_core/models.py | alexisdurieux/kg-core-python | 35d416359ddc3df37cf3604a8488eeb36f27d5e5 | [
"Apache-2.0"
] | null | null | null | # Copyright (c) 2018, EPFL/Human Brain Project PCO
#
# 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.
class Pagination(object):
def __init__(self, start_from: int = 0, size: int = 50):
self.start_from = start_from
self.size = size
class Stage(str):
IN_PROGRESS = "IN_PROGRESS"
RELEASED = "RELEASED"
class ResponseConfiguration(object):
def __init__(self, return_payload=True, return_permissions=False, return_alternatives=False, return_embedded=False, return_incoming_links=False, sort_by_label=False):
self.return_payload = return_payload
self.return_permissions = return_permissions
self.return_alternatives = return_alternatives
self.return_embedded = return_embedded
self.return_incoming_links = return_incoming_links
self.sort_by_label = sort_by_label
class KGResult(object):
def __init__(self, json: dict, request_args: dict, payload):
self.payload = json
self.request_args = request_args
self.request_payload = payload
def data(self):
return self.payload["data"] if "data" in self.payload else None
def message(self):
return self.payload["message"] if "message" in self.payload else None
def start_time(self):
return self.payload["startTime"] if "startTime" in self.payload else None
def duration_in_ms(self):
return self.payload["durationInMs"] if "durationInMs" in self.payload else None
def total(self):
return self.payload["total"] if "total" in self.payload else 0
def size(self):
return self.payload["size"] if "size" in self.payload else 0
def start_from(self):
return self.payload["from"] if "from" in self.payload else 0
| 35.3125 | 170 | 0.70708 | 310 | 2,260 | 4.996774 | 0.351613 | 0.10652 | 0.063267 | 0.0949 | 0.10071 | 0.08909 | 0 | 0 | 0 | 0 | 0 | 0.00783 | 0.20885 | 2,260 | 63 | 171 | 35.873016 | 0.858501 | 0.260177 | 0 | 0 | 0 | 0 | 0.065821 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.294118 | false | 0 | 0 | 0.205882 | 0.676471 | 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 | 1 | 1 | 0 | 0 | 3 |
922c32256d052b5d36593dd23aaaa108c6f37d48 | 125 | py | Python | demos/prey-predator/prey_predator_sd/model/state_variables.py | neo-empresarial/covid-19 | cef10ee79d955c9e84148c3c8da542788a1f7395 | [
"MIT"
] | 3 | 2020-05-26T12:17:48.000Z | 2020-06-25T12:03:37.000Z | demos/prey-predator/prey_predator_sd/model/state_variables.py | neo-empresarial/covid-19 | cef10ee79d955c9e84148c3c8da542788a1f7395 | [
"MIT"
] | 4 | 2020-05-26T21:03:44.000Z | 2020-06-30T12:13:15.000Z | demos/prey-predator/prey_predator_sd/model/state_variables.py | neo-empresarial/epidemiological-analysis | cef10ee79d955c9e84148c3c8da542788a1f7395 | [
"MIT"
] | 1 | 2021-11-22T23:10:45.000Z | 2021-11-22T23:10:45.000Z | import random
import uuid
import numpy as np
genesis_states = {
'prey_population': 100,
'predator_population': 50
}
| 13.888889 | 29 | 0.72 | 16 | 125 | 5.4375 | 0.8125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.05 | 0.2 | 125 | 8 | 30 | 15.625 | 0.82 | 0 | 0 | 0 | 0 | 0 | 0.272 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.428571 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
923ee94618cf449258d806effa766a66007357e7 | 282 | py | Python | 2_PROGII/01-listas_13.py | Julymusso/IFES | 939277c375dacc7750705c5593537d80ab4cbc0e | [
"MIT"
] | null | null | null | 2_PROGII/01-listas_13.py | Julymusso/IFES | 939277c375dacc7750705c5593537d80ab4cbc0e | [
"MIT"
] | null | null | null | 2_PROGII/01-listas_13.py | Julymusso/IFES | 939277c375dacc7750705c5593537d80ab4cbc0e | [
"MIT"
] | null | null | null | def iguais (l1,l2):
same=0
for i in range (len(l1)):
if l1[i]==l2[i]:
same += 1
return same
testea=[1,5,6,3,2,4,8,9,6,5,3,7,5,6,4,8,3,2,5,6,4,5,4,8,9,9]
testeb=[5,4,6,9,8,7,5,5,3,2,1,4,6,5,7,8,9,6,3,2,1,4,5,6,9,8]
print(iguais(testea,testeb))
| 21.692308 | 60 | 0.510638 | 79 | 282 | 1.822785 | 0.316456 | 0.055556 | 0.041667 | 0.055556 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.263393 | 0.205674 | 282 | 12 | 61 | 23.5 | 0.379464 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0 | 0 | 0.222222 | 0.111111 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 3 |
925d8fae0efb3a1ced61d59ad3f8797c744c35ad | 393 | py | Python | HORT/HORT.py | Asim-Tahir/KGBTRBot-Tasks | 469ae0c85a2692f90ce4606ba4ff36ff55b91b81 | [
"Apache-2.0"
] | 1 | 2020-11-15T14:11:06.000Z | 2020-11-15T14:11:06.000Z | HORT/HORT.py | KGBTR/Reddit-Bot-Tasks | 469ae0c85a2692f90ce4606ba4ff36ff55b91b81 | [
"Apache-2.0"
] | null | null | null | HORT/HORT.py | KGBTR/Reddit-Bot-Tasks | 469ae0c85a2692f90ce4606ba4ff36ff55b91b81 | [
"Apache-2.0"
] | null | null | null | from Common import BaseBot
from Utils.Enums import LOGIN_METHOD, BOT_TYPE
class HORTBot(BaseBot):
Answer: str
_BOT_TYPE: BOT_TYPE
_LOGIN_METHOD: LOGIN_METHOD
def __init__(self, login_method: LOGIN_METHOD):
super().__init__(login_method, bot_type=BOT_TYPE.CURSER)
def ReplyComment(self, answer: str=None):
super().ReplyComment(answer)
def ReadMD(self):
raise NotImplementedError | 24.5625 | 58 | 0.791349 | 55 | 393 | 5.272727 | 0.436364 | 0.227586 | 0.096552 | 0.124138 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.119593 | 393 | 16 | 59 | 24.5625 | 0.83815 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.166667 | 0 | 0.75 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
92618c9e231b5d5f25fbff8661e2ea56af4da4c4 | 167 | py | Python | data/address.py | monikatrz/python_training | 30c0c9c6ec559a15dbea173ab1bd3c89bf2e3edd | [
"Apache-2.0"
] | null | null | null | data/address.py | monikatrz/python_training | 30c0c9c6ec559a15dbea173ab1bd3c89bf2e3edd | [
"Apache-2.0"
] | null | null | null | data/address.py | monikatrz/python_training | 30c0c9c6ec559a15dbea173ab1bd3c89bf2e3edd | [
"Apache-2.0"
] | null | null | null | from model.addres import Addres
testdata = [
Addres(firstname="f1", middlename="m1", lastname="l1"),
Addres(firstname="f2", middlename="m2", lastname="l2")
] | 23.857143 | 59 | 0.676647 | 20 | 167 | 5.65 | 0.7 | 0.265487 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.041667 | 0.137725 | 167 | 7 | 60 | 23.857143 | 0.743056 | 0 | 0 | 0 | 0 | 0 | 0.071429 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 1 | 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 | 3 |
927fd540222548d06554e11170028024529bf1bc | 134 | py | Python | ex1-hailstone.py | Omi0604/DCU-Einstein- | b35e2657b8e27904035e881021c9bdf9e51675bb | [
"MIT"
] | null | null | null | ex1-hailstone.py | Omi0604/DCU-Einstein- | b35e2657b8e27904035e881021c9bdf9e51675bb | [
"MIT"
] | null | null | null | ex1-hailstone.py | Omi0604/DCU-Einstein- | b35e2657b8e27904035e881021c9bdf9e51675bb | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
a = int(input())
b = int(input())
if a // 2 == b or (3 * a) + 1 == b:
print("yes")
else:
print("no")
| 13.4 | 35 | 0.477612 | 24 | 134 | 2.666667 | 0.708333 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.040404 | 0.261194 | 134 | 9 | 36 | 14.888889 | 0.606061 | 0.156716 | 0 | 0 | 0 | 0 | 0.044643 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0 | 0 | null | 1 | 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 | 3 |
9283b716a8b3d5235a9a1a1fc8af62c301b87013 | 752 | py | Python | tests/test_formulations.py | kzfm/pychembldb | 0dde6a05b2dc138e0be7f8f27f57b5c2a42e23c7 | [
"CC0-1.0"
] | 8 | 2020-01-16T00:43:46.000Z | 2021-11-27T18:26:12.000Z | tests/test_formulations.py | iwatobipen/pychembldb | 0dde6a05b2dc138e0be7f8f27f57b5c2a42e23c7 | [
"CC0-1.0"
] | null | null | null | tests/test_formulations.py | iwatobipen/pychembldb | 0dde6a05b2dc138e0be7f8f27f57b5c2a42e23c7 | [
"CC0-1.0"
] | 3 | 2020-05-31T05:54:33.000Z | 2021-11-15T04:31:07.000Z | import unittest
from pychembldb import chembldb, Formulation
class FormulationTest(unittest.TestCase):
def setUp(self):
self.target = chembldb.query(Formulation).filter_by(product_id="PRODUCT_017641_001").filter_by(molregno=674619).first()
def test_product_id(self):
self.assertEqual(self.target.product_id, "PRODUCT_017641_001")
def test_ingredient(self):
self.assertEqual(self.target.ingredient, "CALCIUM CHLORIDE")
def test_strength(self):
self.assertEqual(self.target.strength, "20MG/100ML")
def test_molregno(self):
self.assertEqual(self.target.molregno, 674619)
def test_formulation_backref(self):
self.assertEqual(self.target.molecule.pref_name, "CALCIUM CHLORIDE")
| 32.695652 | 127 | 0.739362 | 91 | 752 | 5.934066 | 0.384615 | 0.088889 | 0.175926 | 0.212963 | 0.361111 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054945 | 0.152926 | 752 | 22 | 128 | 34.181818 | 0.792779 | 0 | 0 | 0 | 0 | 0 | 0.103723 | 0 | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0.4 | false | 0 | 0.133333 | 0 | 0.6 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
9298dc1637a98b86618a3d65911afefd158f8855 | 948 | py | Python | main.py | JustinLohKingWei/Puzzle-Solver-9000 | fb564c50f11d20e3efb1b462bd79f0bbde143139 | [
"MIT"
] | null | null | null | main.py | JustinLohKingWei/Puzzle-Solver-9000 | fb564c50f11d20e3efb1b462bd79f0bbde143139 | [
"MIT"
] | null | null | null | main.py | JustinLohKingWei/Puzzle-Solver-9000 | fb564c50f11d20e3efb1b462bd79f0bbde143139 | [
"MIT"
] | null | null | null | from heuristics import a_star, best_first, breadth_first_search, depth_first_search, ham_distance, man_distance, perm_inversion
goalState = ["1", "2", "3", "8", "B", "4", "7", "6", "5"]
initial_State1 = ["5", "1", "4", "7", "B", "6", "3", "8", "2"]
initial_State2 = ["3", "5", "B", "2", "1", "4", "8", "7", "6"]
initial_State3 = ["2", "8", "3", "1", "6", "4", "7", "B", "5"]
if __name__ == '__main__':
# Uncomment for DFS, BFS
# print(depth_first_search(initial_State, goalState))
# print(breadth_first_search(initial_State, goalState))
print(best_first(ham_distance, initial_State3, goalState))
print(a_star(ham_distance, initial_State3, goalState))
print(best_first(man_distance, initial_State3, goalState))
print(a_star(man_distance, initial_State3, goalState))
print(best_first(perm_inversion, initial_State3, goalState))
print(a_star(perm_inversion, initial_State3, goalState))
| 41.217391 | 128 | 0.652954 | 131 | 948 | 4.389313 | 0.290076 | 0.158261 | 0.229565 | 0.234783 | 0.58087 | 0.497391 | 0.292174 | 0 | 0 | 0 | 0 | 0.051508 | 0.160338 | 948 | 22 | 129 | 43.090909 | 0.670854 | 0.135021 | 0 | 0 | 0 | 0 | 0.055416 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.083333 | 0 | 0.083333 | 0.5 | 0 | 0 | 0 | null | 0 | 1 | 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 | 1 | 0 | 3 |
92b9c198a77316423a9ea3deb88de734b32bfe98 | 98 | py | Python | site_details/apps.py | 501code/fletcher-street-urban-riding-club | 8a16a38280cde7dab1c8732613c52284b7ced1b3 | [
"MIT"
] | 1 | 2016-01-22T10:49:00.000Z | 2016-01-22T10:49:00.000Z | site_details/apps.py | 501code/fletcher-street-urban-riding-club | 8a16a38280cde7dab1c8732613c52284b7ced1b3 | [
"MIT"
] | 6 | 2016-01-30T06:52:40.000Z | 2016-01-30T16:42:08.000Z | site_details/apps.py | 501code/fletcher-street-urban-riding-club | 8a16a38280cde7dab1c8732613c52284b7ced1b3 | [
"MIT"
] | null | null | null | from django.apps import AppConfig
class SiteDetailsConfig(AppConfig):
name = 'site_details'
| 16.333333 | 35 | 0.77551 | 11 | 98 | 6.818182 | 0.909091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.153061 | 98 | 5 | 36 | 19.6 | 0.903614 | 0 | 0 | 0 | 0 | 0 | 0.122449 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
2b87f1dbbf2f2423eb9246b4d629fdaeac7653e6 | 10,924 | py | Python | gpn/utils/config.py | WodkaRHR/Graph-Posterior-Network | 139e7c45c37324c9286e0cca60360a4978b3f411 | [
"MIT"
] | null | null | null | gpn/utils/config.py | WodkaRHR/Graph-Posterior-Network | 139e7c45c37324c9286e0cca60360a4978b3f411 | [
"MIT"
] | null | null | null | gpn/utils/config.py | WodkaRHR/Graph-Posterior-Network | 139e7c45c37324c9286e0cca60360a4978b3f411 | [
"MIT"
] | null | null | null | from typing import Union, List, Tuple
import attr
from .object import HalfFrozenObject
import os.path as osp
@attr.s(frozen=True)
class RunConfiguration(HalfFrozenObject):
"""object specifying possible job configurations"""
# experiment name (relevant for saving/loading trained models)
experiment_name: str = attr.ib(default=None)
# experiment-name for evaluation (relevant e.g. for evasion attacks)
eval_experiment_name: str = attr.ib(default=None)
# root directory to save/load models to/from
experiment_directory: str = attr.ib(default=None)
# evaluation mode
# default: e.g. ood evasion or re-evaluation
# dropout: i.e. DropoutEnsemble evaluation
# ensemble: i.e. Ensemble evaluation (using model-init 1-10!!!)
eval_mode: str = attr.ib(default=None, validator=lambda i, a, v: v in (
'default', 'dropout', 'ensemble', 'energy_scoring'))
# flag whether to run a job as experiment ("train": training + evaluation)
# or only in "evaluation" mode (e.g. re-evaluating model,
# evlulating models on other datasets, or as dropout-models or ensembles)
job: str = attr.ib(default=None, validator=lambda i, a, v: v in ('train', 'evaluate'))
# save-flag (e.g. for not saving GridSearch experiments)
save_model: bool = attr.ib(default=None)
# gpu
gpu: int = attr.ib(default=None, validator=lambda i, a, v: v in (0, False))
# run multiple experiments at one
num_inits: int = attr.ib(default=None)
num_splits: int = attr.ib(default=None)
# running experiment
log: bool = attr.ib(default=True) # flag for logging training progress and metrics
debug: bool = attr.ib(default=True) # flag for running code in a "DEBUG" mode
ex_type: str = attr.ib(default='transductive', validator=lambda i, a, v: v in (
'transductive', 'transductive_ood'))
ood_loc: bool = attr.ib(default=True) # flag for running LOC in ood_experiment
ood_loc_only: bool = attr.ib(default=False) # flag for only runninig LOC in ood_experiment
ood_edge_perturbations: bool = attr.ib(default=True) # flag for running edge pert. exp. in ood_experiment
ood_isolated_perturbations: bool = attr.ib(default=False) # flag for running isolated exp. in ood_experiment
@attr.s(frozen=True)
class FileDataConfiguration(HalfFrozenObject):
""" object specifying possible dataset configurations linking to a dataset file"""
split_no: int = attr.ib(default=None, validator=lambda i, a, v: v is not None and v > 0)
directory: str = attr.ib(default=None, validator=lambda i, a, v: osp.exists(v))
ood_flag: bool = attr.ib(default=True)
ood_dataset_type: str = attr.ib(None, validator=lambda i, a, v: v in ('budget', 'isolated', None))
ood_setting: str = attr.ib(default=None, validator=lambda i, a, v: v in ('evasion', 'poisoning', None))
ood_type: str = attr.ib(default=None)
ood_val_dataset: str = attr.ib(default='ood-val')
ood_test_dataset: str = attr.ib(default='ood-test')
@attr.s(frozen=True)
class DataConfiguration(HalfFrozenObject):
"""object specifying possible dataset configurations"""
# sparseness
to_sparse: bool = attr.ib(default=False)
# ranomness
split_no: int = attr.ib(default=None, validator=lambda i, a, v: v is not None and v > 0)
# dataset parameters
dataset: str = attr.ib(default=None)
root: str = attr.ib(default=None)
split: str = attr.ib(default=None, validator=lambda i, a, v: v in ('public', 'random'))
# note that either the num-examples for the size values
# must be specified, but not both at the same time!
train_samples_per_class: Union[int, float] = attr.ib(default=None)
val_samples_per_class: Union[int, float] = attr.ib(default=None)
test_samples_per_class: Union[int, float] = attr.ib(default=None)
train_size: float = attr.ib(default=None)
val_size: float = attr.ib(default=None)
test_size: float = attr.ib(default=None)
# ood parameters
ood_flag: bool = attr.ib(default=False)
ood_setting: str = attr.ib(default=None, validator=lambda i, a, v: v in ('evasion', 'poisoning', None))
ood_type: str = attr.ib(default=None, validator=lambda i, a, v: v in (
None, 'perturb_features', 'leave_out_classes',
'leave_out_classes_evasion', 'random_attack_dice', 'random_attack_targeted', 'random_edge_perturbations'))
ood_dataset_type: str = attr.ib(None, validator=lambda i, a, v: v in ('budget', 'isolated', None))
# type of feature perturabtion, e.g. bernoulli_0.5
ood_perturbation_type: str = attr.ib(default=None)
ood_budget_per_graph: float = attr.ib(default=None)
ood_budget_per_node: float = attr.ib(default=None)
ood_noise_scale: float = attr.ib(default=None)
ood_num_left_out_classes: int = attr.ib(default=None)
ood_frac_left_out_classes: float = attr.ib(default=None)
ood_left_out_classes: List[int] = attr.ib(default=None)
ood_leave_out_last_classes: bool = attr.ib(default=None)
@attr.s(frozen=True)
class ModelConfiguration(HalfFrozenObject):
"""object specifying possible model configurations"""
# model name
model_name: str = attr.ib(default=None, validator=lambda i, a, v: v is not None and len(v) > 0)
# randomness
seed: int = attr.ib(default=None, validator=lambda i, a, v: v is not None and v > 0)
init_no: int = attr.ib(default=None, validator=lambda i, a, v: v is not None and v > 0)
# default parameters
num_classes: int = attr.ib(default=None)
dim_features: int = attr.ib(default=None)
dim_hidden: Union[int, List[int]] = attr.ib(default=None)
dropout_prob: float = attr.ib(default=None)
dropout_prob_adj: float = attr.ib(default=0.0)
# mainly relevant for ogbn-arxiv
batch_norm: bool = attr.ib(default=None)
# for constrained linear layers
k_lipschitz: float = attr.ib(default=None)
# for deeper networks
num_layers: int = attr.ib(default=None)
# GAT
heads_conv1: int = attr.ib(default=None)
heads_conv2: int = attr.ib(default=None)
negative_slope: float = attr.ib(default=None)
coefficient_dropout_prob: float = attr.ib(default=None)
# diffusion
K: int = attr.ib(default=None)
alpha_teleport: float = attr.ib(default=None)
add_self_loops: bool = attr.ib(default=None)
# PostNet / NormalizingFlows
radial_layers: int = attr.ib(default=None)
ft_radial_layers: int = attr.ib(default=None)
maf_layers: int = attr.ib(default=None)
ft_maf_layers: int = attr.ib(default=None)
gaussian_layers: int = attr.ib(default=None)
ft_gaussian_layers: int = attr.ib(default=None)
dim_latent: int = attr.ib(default=None)
alpha_evidence_scale: Union[int, str] = attr.ib(default=None)
entropy_reg: float = attr.ib(default=None)
factor_flow_lr: float = attr.ib(default=None)
flow_weight_decay: float = attr.ib(default=None)
share_flow: bool = attr.ib(default=None)
use_batched_flow: bool = attr.ib(default=None)
pre_train_mode: str = attr.ib(default=None, validator=lambda i, a, v: v in ('encoder', 'flow', 'none', None))
likelihood_type: str = attr.ib(
default=None,
validator=lambda i, a, v: v in ('UCE', 'nll_train', 'nll_train_and_val', 'nll_consistency', 'none', None))
gpn_loss_type: str = attr.ib(
default=None
)
# Natural PostNets
weight_evidence_transformation: str = attr.ib(default=None)
weight_evidence_scale: float = attr.ib(default=None)
latent_space_aggregation: str = attr.ib(default=None)
loss_nll_weight: float = attr.ib(default=None)
use_flow_mixture: bool = attr.ib(default=None)
node_normalization: str = attr.ib(default=None)
approximate_reg: bool = attr.ib(default=None)
neighborhood_evidence: str = attr.ib(default=None)
loss_reduction: str = attr.ib(default=None, validator=lambda i, a, v: v in (None, 'sum', 'mean'))
loss_nll_weight_with_classes: bool = attr.ib(default=None)
# RGCN
gamma: float = attr.ib(default=None)
beta_kl: float = attr.ib(default=None)
beta_reg: float = attr.ib(default=None)
# BayesianGCN
bayesian_samples: int = attr.ib(default=None)
pi: float = attr.ib(default=None)
sigma_1: float = attr.ib(default=None)
sigma_2: float = attr.ib(default=None)
# DUN
beta_dun: float = attr.ib(default=None)
depth_in_message_passing: bool = attr.ib(default=None)
# SGCN
teacher_training: bool = attr.ib(default=None)
teacher_params: dict = attr.ib(default=None)
use_bayesian_dropout: bool = attr.ib(default=None)
use_kernel: bool = attr.ib(default=None)
lambda_1: float = attr.ib(default=None)
sample_method: str = attr.ib(default=None, validator=lambda i, a, v: v in (None, 'log_evidence', 'alpha', 'none'))
epochs: int = attr.ib(default=None)
# dropout / ensemble
num_samples_dropout: int = attr.ib(default=None)
ensemble_min_init_no: int = attr.ib(default=None)
ensemble_max_init_no: int = attr.ib(default=None)
# scoring
temperature: float = attr.ib(default=None)
def default_ignore(self) -> List[str]:
"""define default attributes to ignore when loading/storing models
"""
ignore = [
'temperature',
'ensemble_max_init_no',
'ensemble_min_init_no',
'num_samples_dropout',
'init_no'
]
for i in ignore:
assert hasattr(self, i)
return ignore
@attr.s(frozen=True)
class TrainingConfiguration(HalfFrozenObject):
"""object specifying possible training configurations"""
lr: float = attr.ib(default=None)
weight_decay: float = attr.ib(default=None)
epochs: int = attr.ib(default=None)
warmup_epochs: int = attr.ib(default=None)
finetune_epochs: int = attr.ib(default=None)
stopping_mode: str = attr.ib(default=None, validator=lambda i, a, v: v in (None, 'default', 'average', 'multiple'))
stopping_patience: int = attr.ib(default=None)
stopping_restore_best: bool = attr.ib(default=None)
stopping_metric: str = attr.ib(default=None)
stopping_minimize: bool = attr.ib(default=None)
def configs_from_dict(d: dict) -> Tuple[RunConfiguration, DataConfiguration, ModelConfiguration, TrainingConfiguration]:
"""utility function converting a dictionary (e.g. coming from a .yaml file) into the corresponding configuration objects
Args:
d (dict): dictionary containing all relevant configuration parameters
Returns:
Tuple[RunConfiguration, DataConfiguration, ModelConfiguration, TrainingConfiguration]: tuple of corresponding objects for run, data, model, and training configuration
"""
run = RunConfiguration(**d['run'])
data = DataConfiguration(**d['data'])
model = ModelConfiguration(**d['model'])
training = TrainingConfiguration(**d['training'])
return run, data, model, training
| 41.854406 | 174 | 0.693885 | 1,559 | 10,924 | 4.732521 | 0.192431 | 0.098401 | 0.209677 | 0.24424 | 0.579832 | 0.444158 | 0.269721 | 0.177148 | 0.162917 | 0.162917 | 0 | 0.002026 | 0.186745 | 10,924 | 260 | 175 | 42.015385 | 0.828456 | 0.190956 | 0 | 0.08125 | 0 | 0 | 0.058251 | 0.00824 | 0 | 0 | 0 | 0 | 0.00625 | 1 | 0.0125 | false | 0.00625 | 0.025 | 0 | 0.8375 | 0 | 0 | 0 | 0 | null | 0 | 1 | 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 | 1 | 0 | 0 | 3 |
2bb92a38909e2227151f93c3a5e695aeb23a6740 | 6,134 | py | Python | tests/test_core/test_write/test_update_adjust_sql_objects.py | jwcook23/mssql_dataframe | ba7191e1b159a0b1292bf6825fcdf1fe5ce7c496 | [
"MIT"
] | null | null | null | tests/test_core/test_write/test_update_adjust_sql_objects.py | jwcook23/mssql_dataframe | ba7191e1b159a0b1292bf6825fcdf1fe5ce7c496 | [
"MIT"
] | 18 | 2021-08-05T19:29:25.000Z | 2022-03-02T16:08:08.000Z | tests/test_core/test_write/test_update_adjust_sql_objects.py | jwcook23/mssql_dataframe | ba7191e1b159a0b1292bf6825fcdf1fe5ce7c496 | [
"MIT"
] | 1 | 2022-02-08T09:14:56.000Z | 2022-02-08T09:14:56.000Z | import warnings
import pytest
import pandas as pd
from mssql_dataframe.connect import connect
from mssql_dataframe.core import custom_warnings, custom_errors, create, conversion
from mssql_dataframe.core.write import update
pd.options.mode.chained_assignment = "raise"
class package:
def __init__(self, connection):
self.connection = connection.connection
self.create = create.create(self.connection)
self.update = update.update(self.connection, autoadjust_sql_objects=True)
self.update_meta = update.update(self.connection, include_metadata_timestamps=True, autoadjust_sql_objects=True)
@pytest.fixture(scope="module")
def sql():
db = connect(database="tempdb", server="localhost")
yield package(db)
db.connection.close()
def test_update_create_table(sql):
"""Updating a table that doesn't exist should always raise an error, even
if autoadjust_sql_objects=True."""
table_name = "##test_update_create_table"
dataframe = pd.DataFrame({"_pk": [0, 1], "ColumnA": [1, 2]}).set_index(keys="_pk")
with pytest.raises(custom_errors.SQLTableDoesNotExist):
sql.update.update(table_name, dataframe)
def test_update_add_column(sql):
table_name = "##test_update_add_column"
dataframe = pd.DataFrame({"ColumnA": [1, 2]})
with warnings.catch_warnings(record=True) as warn:
dataframe = sql.create.table_from_dataframe(table_name, dataframe, primary_key="index")
assert len(warn) == 1
assert isinstance(warn[0].message, custom_warnings.SQLObjectAdjustment)
assert "Created table" in str(warn[0].message)
# update using the SQL primary key that came from the dataframe's index
dataframe["NewColumn"] = [3, 4]
with warnings.catch_warnings(record=True) as warn:
updated = sql.update_meta.update(table_name, dataframe[["NewColumn"]])
dataframe["NewColumn"] = updated["NewColumn"]
assert len(warn) == 2
assert all([isinstance(x.message, custom_warnings.SQLObjectAdjustment) for x in warn])
assert (
str(warn[0].message)
== f"Creating column _time_update in table {table_name} with data type DATETIME2."
)
assert (
str(warn[1].message)
== f"Creating column NewColumn in table {table_name} with data type tinyint."
)
schema,_ = conversion.get_schema(sql.connection, table_name)
result = conversion.read_values(
f"SELECT * FROM {table_name}", schema, sql.connection
)
assert result[dataframe.columns].equals(dataframe)
assert result["_time_update"].notna().all()
def test_update_alter_column(sql):
table_name = "##test_update_alter_column"
dataframe = pd.DataFrame(
{"ColumnA": [1, 2], "ColumnB": ["a", "b"], "ColumnC": [0, 0]}
)
with warnings.catch_warnings(record=True) as warn:
sql.create.table_from_dataframe(table_name, dataframe, primary_key=None)
assert len(warn) == 1
assert isinstance(warn[0].message, custom_warnings.SQLObjectAdjustment)
assert "Created table" in str(warn[0].message)
# update using ColumnA
dataframe["ColumnB"] = ["aaa", "bbb"]
dataframe["ColumnC"] = [256, 256]
with warnings.catch_warnings(record=True) as warn:
updated = sql.update_meta.update(
table_name, dataframe, match_columns=["ColumnA"]
)
dataframe[["ColumnB", "ColumnC"]] = updated[["ColumnB", "ColumnC"]]
assert len(warn) == 3
assert all([isinstance(x.message, custom_warnings.SQLObjectAdjustment) for x in warn])
assert (
str(warn[0].message)
== f"Creating column _time_update in table {table_name} with data type DATETIME2."
)
assert (
str(warn[1].message)
== f"Altering column ColumnB in table {table_name} to data type varchar(3) with is_nullable=False."
)
assert (
str(warn[2].message)
== f"Altering column ColumnC in table {table_name} to data type smallint with is_nullable=False."
)
schema,_ = conversion.get_schema(sql.connection, table_name)
result = conversion.read_values(
f"SELECT * FROM {table_name}", schema, sql.connection
)
assert result[dataframe.columns].equals(dataframe)
assert result["_time_update"].notna().all()
def test_update_add_and_alter_column(sql):
table_name = "##test_update_add_and_alter_column"
dataframe = pd.DataFrame({"ColumnA": [1, 2], "ColumnB": ["a", "b"]})
with warnings.catch_warnings(record=True) as warn:
dataframe = sql.create.table_from_dataframe(table_name, dataframe, primary_key="index")
assert len(warn) == 1
assert isinstance(warn[0].message, custom_warnings.SQLObjectAdjustment)
assert "Created table" in str(warn[0].message)
# update using the SQL primary key that came from the dataframe's index
dataframe["ColumnB"] = ["aaa", "bbb"]
dataframe["NewColumn"] = [3, 4]
with warnings.catch_warnings(record=True) as warn:
updated = sql.update_meta.update(
table_name, dataframe[["ColumnB", "NewColumn"]]
)
dataframe[["ColumnB", "NewColumn"]] = updated[["ColumnB", "NewColumn"]]
assert len(warn) == 3
assert all([isinstance(x.message, custom_warnings.SQLObjectAdjustment) for x in warn])
assert (
str(warn[0].message)
== f"Creating column _time_update in table {table_name} with data type DATETIME2."
)
assert (
str(warn[1].message)
== f"Creating column NewColumn in table {table_name} with data type tinyint."
)
assert (
str(warn[2].message)
== f"Altering column ColumnB in table {table_name} to data type varchar(3) with is_nullable=False."
)
schema,_ = conversion.get_schema(sql.connection, table_name)
result = conversion.read_values(
f"SELECT * FROM {table_name}", schema, sql.connection
)
assert result[dataframe.columns].equals(dataframe)
assert result["_time_update"].notna().all()
| 39.320513 | 120 | 0.665471 | 754 | 6,134 | 5.248011 | 0.17374 | 0.056861 | 0.027293 | 0.032348 | 0.723275 | 0.712156 | 0.709881 | 0.669194 | 0.646197 | 0.646197 | 0 | 0.009775 | 0.216172 | 6,134 | 155 | 121 | 39.574194 | 0.813228 | 0.043039 | 0 | 0.536585 | 0 | 0 | 0.199044 | 0.018778 | 0 | 0 | 0 | 0 | 0.235772 | 1 | 0.04878 | false | 0 | 0.04878 | 0 | 0.105691 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
2bbb0d15c7983a6788c619d85e5295f4ae1e6780 | 234 | py | Python | accounts/admin.py | talhaibnmahmud/django-crm | 63a286c241ee3cb221267431c6688a073190bdea | [
"MIT"
] | null | null | null | accounts/admin.py | talhaibnmahmud/django-crm | 63a286c241ee3cb221267431c6688a073190bdea | [
"MIT"
] | null | null | null | accounts/admin.py | talhaibnmahmud/django-crm | 63a286c241ee3cb221267431c6688a073190bdea | [
"MIT"
] | null | null | null | from django.contrib import admin
from accounts.models import Customer, Product, Tag, Order
# Register your models here.
admin.site.register(Customer)
admin.site.register(Tag)
admin.site.register(Product)
admin.site.register(Order)
| 21.272727 | 57 | 0.803419 | 33 | 234 | 5.69697 | 0.454545 | 0.191489 | 0.361702 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.098291 | 234 | 10 | 58 | 23.4 | 0.890995 | 0.111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.333333 | 0 | 0.333333 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
920d220eaef13b58c5d160b0601892892c7bd348 | 55 | py | Python | buildcdf/__init__.py | barsand/buildcdf | 053f132babb6bc965457cbbab09e57d5dd9311b4 | [
"MIT"
] | 2 | 2020-04-26T15:22:16.000Z | 2021-04-09T05:16:56.000Z | buildcdf/__init__.py | barsand/buildcdf | 053f132babb6bc965457cbbab09e57d5dd9311b4 | [
"MIT"
] | null | null | null | buildcdf/__init__.py | barsand/buildcdf | 053f132babb6bc965457cbbab09e57d5dd9311b4 | [
"MIT"
] | null | null | null | from .buildcdf import buildcdf
__all__ = ['buildcdf']
| 13.75 | 30 | 0.745455 | 6 | 55 | 6.166667 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.145455 | 55 | 3 | 31 | 18.333333 | 0.787234 | 0 | 0 | 0 | 0 | 0 | 0.145455 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
920f422e7a3723a1b788ce9bf468898e9466b7c3 | 849 | py | Python | tests/conftest.py | gugu/py_zipkin | f48ffeb8bb15608209b6eef449dac9a42246fe75 | [
"Apache-2.0"
] | null | null | null | tests/conftest.py | gugu/py_zipkin | f48ffeb8bb15608209b6eef449dac9a42246fe75 | [
"Apache-2.0"
] | null | null | null | tests/conftest.py | gugu/py_zipkin | f48ffeb8bb15608209b6eef449dac9a42246fe75 | [
"Apache-2.0"
] | null | null | null | import pytest
from py_zipkin.zipkin import ZipkinAttrs
from py_zipkin.transport import BaseTransportHandler
@pytest.fixture
def zipkin_attributes():
return {
'trace_id': '17133d482ba4f605',
'span_id': '27133d482ba4f605',
'parent_span_id': '37133d482ba4f605',
'flags': '45',
}
@pytest.fixture
def sampled_zipkin_attr(zipkin_attributes):
return ZipkinAttrs(is_sampled=True, **zipkin_attributes)
@pytest.fixture
def unsampled_zipkin_attr(zipkin_attributes):
return ZipkinAttrs(is_sampled=False, **zipkin_attributes)
class MockTransportHandler(BaseTransportHandler):
def __init__(self, max_payload_bytes=None):
self.max_payload_bytes = max_payload_bytes
def send(self, payload):
return payload
def get_max_payload_bytes(self):
return self.max_payload_bytes
| 22.945946 | 61 | 0.738516 | 96 | 849 | 6.197917 | 0.385417 | 0.134454 | 0.12605 | 0.095798 | 0.17479 | 0.17479 | 0.17479 | 0.17479 | 0 | 0 | 0 | 0.054286 | 0.175501 | 849 | 36 | 62 | 23.583333 | 0.795714 | 0 | 0 | 0.125 | 0 | 0 | 0.09894 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0.208333 | 0.625 | 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 | 1 | 1 | 0 | 0 | 3 |
92104f101c35e8a63ac68fa72eb6cce228699124 | 98 | py | Python | output/models/ms_data/regex/basic_latin_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 1 | 2021-08-14T17:59:21.000Z | 2021-08-14T17:59:21.000Z | output/models/ms_data/regex/basic_latin_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 4 | 2020-02-12T21:30:44.000Z | 2020-04-15T20:06:46.000Z | output/models/ms_data/regex/basic_latin_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | null | null | null | from output.models.ms_data.regex.basic_latin_xsd.basic_latin import Doc
__all__ = [
"Doc",
]
| 16.333333 | 71 | 0.744898 | 15 | 98 | 4.333333 | 0.8 | 0.307692 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 98 | 5 | 72 | 19.6 | 0.77381 | 0 | 0 | 0 | 0 | 0 | 0.030612 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 0 | 0 | null | 1 | 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 | 3 |
9212626a0175b79ef0d7ccda4bdd4cacc00db003 | 1,432 | py | Python | glance/api/v1/filters.py | cloudbau/glance | 616b097c052f5bf59b05326ed1d2d1ae1c703dc9 | [
"Apache-2.0"
] | 1 | 2018-05-03T03:52:39.000Z | 2018-05-03T03:52:39.000Z | glance/api/v1/filters.py | cloudbau/glance | 616b097c052f5bf59b05326ed1d2d1ae1c703dc9 | [
"Apache-2.0"
] | null | null | null | glance/api/v1/filters.py | cloudbau/glance | 616b097c052f5bf59b05326ed1d2d1ae1c703dc9 | [
"Apache-2.0"
] | null | null | null | # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012, Piston Cloud Computing, Inc.
# 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.
def validate(filter, value):
return FILTER_FUNCTIONS.get(filter, lambda v: True)(value)
def validate_int_in_range(min=0, max=None):
def _validator(v):
try:
if max is None:
return min <= int(v)
return min <= int(v) <= max
except ValueError:
return False
return _validator
def validate_boolean(v):
return v.lower() in ('none', 'true', 'false', '1', '0')
FILTER_FUNCTIONS = {'size_max': validate_int_in_range(), # build validator
'size_min': validate_int_in_range(), # build validator
'min_ram': validate_int_in_range(), # build validator
'protected': validate_boolean,
'is_public': validate_boolean, }
| 33.302326 | 75 | 0.663408 | 193 | 1,432 | 4.803109 | 0.523316 | 0.064725 | 0.056095 | 0.07767 | 0.10356 | 0.10356 | 0 | 0 | 0 | 0 | 0 | 0.012915 | 0.243017 | 1,432 | 42 | 76 | 34.095238 | 0.842251 | 0.469972 | 0 | 0 | 0 | 0 | 0.075676 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0 | 0.111111 | 0.555556 | 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 | 1 | 1 | 0 | 0 | 3 |
921803981b1cc1365e69b10737ce3280fb008b29 | 197 | py | Python | queue-based-ingestion/python-cdk/app.py | sumitdeshpande/serverless-samples | 2ca37f103f0a0b27d8e623d4cf5a4f214e25d615 | [
"MIT-0"
] | null | null | null | queue-based-ingestion/python-cdk/app.py | sumitdeshpande/serverless-samples | 2ca37f103f0a0b27d8e623d4cf5a4f214e25d615 | [
"MIT-0"
] | null | null | null | queue-based-ingestion/python-cdk/app.py | sumitdeshpande/serverless-samples | 2ca37f103f0a0b27d8e623d4cf5a4f214e25d615 | [
"MIT-0"
] | null | null | null | #!/usr/bin/env python3
from aws_cdk import App
from api_sqs_ingestion.api_sqs_ingestion_stack import ApiSqsIngestionStack
app = App()
ApiSqsLambdaStack(app, "ApiSqsIngestionStack")
app.synth()
| 17.909091 | 74 | 0.812183 | 26 | 197 | 5.923077 | 0.615385 | 0.077922 | 0.194805 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00565 | 0.101523 | 197 | 10 | 75 | 19.7 | 0.864407 | 0.106599 | 0 | 0 | 0 | 0 | 0.114286 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
a6202af5fa86d958696fb2502daa509ded35af47 | 358 | py | Python | vision-plugins/src/bsmu/vision/plugins/visualizers/registry.py | IvanKosik/vision | 74603d4b727e6d993b562eb4656952e29173323e | [
"BSD-3-Clause"
] | 2 | 2019-10-15T11:34:17.000Z | 2021-02-03T10:46:07.000Z | vision-plugins/src/bsmu/vision/plugins/visualizers/registry.py | IvanKosik/vision | 74603d4b727e6d993b562eb4656952e29173323e | [
"BSD-3-Clause"
] | null | null | null | vision-plugins/src/bsmu/vision/plugins/visualizers/registry.py | IvanKosik/vision | 74603d4b727e6d993b562eb4656952e29173323e | [
"BSD-3-Clause"
] | null | null | null | from __future__ import annotations
from bsmu.vision.core.plugins.processor.registry import ProcessorRegistryPlugin, ProcessorRegistry
from bsmu.vision.plugins.visualizers.base import DataVisualizerPlugin
class DataVisualizerRegistryPlugin(ProcessorRegistryPlugin):
def __init__(self):
super().__init__(ProcessorRegistry, DataVisualizerPlugin)
| 35.8 | 98 | 0.843575 | 32 | 358 | 9.0625 | 0.65625 | 0.055172 | 0.096552 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.094972 | 358 | 9 | 99 | 39.777778 | 0.895062 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.5 | 0 | 0.833333 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
a624d7856288b9390143598e21203f937c65ced6 | 499 | py | Python | tutorials/pyprjs/01-app-pydeps/repo_pydeps/pydeps/test_pydeps.py | ydzvulon/metacicd | 55e666475263265fa7e7bc82168c5c1ad78cd9bf | [
"MIT"
] | null | null | null | tutorials/pyprjs/01-app-pydeps/repo_pydeps/pydeps/test_pydeps.py | ydzvulon/metacicd | 55e666475263265fa7e7bc82168c5c1ad78cd9bf | [
"MIT"
] | 1 | 2020-04-25T15:30:37.000Z | 2020-04-25T15:30:37.000Z | tutorials/pyprjs/01-app-pydeps/repo_pydeps/pydeps/test_pydeps.py | ydzvulon/metacicd | 55e666475263265fa7e7bc82168c5c1ad78cd9bf | [
"MIT"
] | 3 | 2020-04-28T16:10:29.000Z | 2021-05-30T15:14:38.000Z | import pydeps
def assert_getpass_is_loaded(report):
loaded = report['modules.loaded.list']
assert ('getpass', '') in loaded, \
f'Missing module getpass. Not found in list of {len(loaded)} modules'
print(f"Success found getpass in list of {len(loaded)} modules")
def assert_pip_report(report):
assert 'requests' in report['pip_freeze_loaded']
def test__pydeps__analize():
report = pydeps.analize()
assert_getpass_is_loaded(report)
assert_pip_report(report)
| 24.95 | 77 | 0.717435 | 68 | 499 | 5.029412 | 0.367647 | 0.114035 | 0.087719 | 0.122807 | 0.298246 | 0.140351 | 0 | 0 | 0 | 0 | 0 | 0 | 0.174349 | 499 | 19 | 78 | 26.263158 | 0.830097 | 0 | 0 | 0 | 0 | 0 | 0.343373 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0.25 | false | 0.416667 | 0.083333 | 0 | 0.333333 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
a6357fe19ee06ff7bb0af39c816850665bacc18d | 3,513 | py | Python | 13 Djikstra, Bellman-Ford/tests.py | XuuRee/python-data-structures | a3972f5781d666d15d61c0d474877880d1b7c483 | [
"MIT"
] | null | null | null | 13 Djikstra, Bellman-Ford/tests.py | XuuRee/python-data-structures | a3972f5781d666d15d61c0d474877880d1b7c483 | [
"MIT"
] | null | null | null | 13 Djikstra, Bellman-Ford/tests.py | XuuRee/python-data-structures | a3972f5781d666d15d61c0d474877880d1b7c483 | [
"MIT"
] | null | null | null | print()
print("-- RELATIONS ------------------------------")
print()
print("GRAPH 1:\n0 0 0\n0 0 0\n0 0 0")
g1 = Graph(3)
print("REFLEXIVITA: " + str(is_reflexive(g1)) + " -> spravna odpoved: False")
print("SYMETRIE: " + str(is_symmetric(g1)) + " -> spravna odpoved: True")
print("ANTISYMETRIE: " + str(is_antisymmetric(g1)) + " -> spravna odpoved: True")
print("TRANZITIVITA: " + str(is_transitive(g1)) + " -> spravna odpoved: True")
print("-------------------------------------------")
print("GRAPH 2:\n1 0 0\n0 1 0\n0 0 1")
g2 = Graph(3)
g2.matrix[0][0] = True
g2.matrix[1][1] = True
g2.matrix[2][2] = True
print("REFLEXIVITA: " + str(is_reflexive(g2)) + " -> spravna odpoved: True")
print("SYMETRIE: " + str(is_symmetric(g2)) + " -> spravna odpoved: True")
print("ANTISYMETRIE: " + str(is_antisymmetric(g2)) + " -> spravna odpoved: False")
print("TRANZITIVITA: " + str(is_transitive(g2)) + " -> spravna odpoved: True")
print("- GOOD GRAPHS -----------------------------")
print("GRAPH 3:\n0 0 0\n0 1 0\n0 1 1")
g3 = Graph(3)
g3.matrix[1][1] = True
g3.matrix[2][1] = True
g3.matrix[2][2] = True
print("REFLEXIVITA: " + str(is_reflexive(g3)) + " -> spravna odpoved: False")
print("SYMETRIE: " + str(is_symmetric(g3)) + " -> spravna odpoved: False")
print("ANTISYMETRIE: " + str(is_antisymmetric(g3)) + " -> spravna odpoved: True")
print("TRANZITIVITA: " + str(is_transitive(g3)) + " -> spravna odpoved: True")
print("-------------------------------------------")
print("GRAPH 4:\n0 1 1\n0 1 1\n0 0 1")
g4 = Graph(3)
g4.matrix[0][1] = True
g4.matrix[0][2] = True
g4.matrix[1][1] = True
g4.matrix[1][2] = True
g4.matrix[2][2] = True
print("REFLEXIVITA: " + str(is_reflexive(g4)) + " -> spravna odpoved: False")
print("SYMETRIE: " + str(is_symmetric(g4)) + " -> spravna odpoved: False")
print("ANTISYMETRIE: " + str(is_antisymmetric(g4)) + " -> spravna odpoved: True")
print("TRANZITIVITA: " + str(is_transitive(g4)) + " -> spravna odpoved: True")
print("-------------------------------------------")
print("GRAPH 5:\n1 0 0\n0 0 0\n1 0 0")
g5 = Graph(3)
g5.matrix[0][0] = True
g5.matrix[2][0] = True
print("REFLEXIVITA: " + str(is_reflexive(g5)) + " -> spravna odpoved: False")
print("SYMETRIE: " + str(is_symmetric(g5)) + " -> spravna odpoved: False")
print("ANTISYMETRIE: " + str(is_antisymmetric(g5)) + " -> spravna odpoved: True")
print("TRANZITIVITA: " + str(is_transitive(g5)) + " -> spravna odpoved: True")
print("-------------------------------------------")
print("GRAPH 6:\n1 0 0\n1 1 0\n0 1 1")
g6 = Graph(3)
g6.matrix[0][0] = True
g6.matrix[1][0] = True
g6.matrix[1][1] = True
g6.matrix[2][1] = True
g6.matrix[2][2] = True
print("REFLEXIVITA: " + str(is_reflexive(g6)) + " -> spravna odpoved: True")
print("SYMETRIE: " + str(is_symmetric(g6)) + " -> spravna odpoved: False")
print("ANTISYMETRIE: " + str(is_antisymmetric(g6)) + " -> spravna odpoved: True")
print("TRANZITIVITA: " + str(is_transitive(g6)) + " -> spravna odpoved: False")
print()
print("- TRANSITIVE CLOSURE -------------------------")
print()
print("GRAPH 7:\n1 0 0\n1 1 0\n0 1 1")
g7 = Graph(3)
g7.matrix[0][0] = True
g7.matrix[1][0] = True
g7.matrix[1][1] = True
g7.matrix[2][1] = True
g7.matrix[2][2] = True
print("TRANZITIVITA: " + str(is_transitive(g7)) + " -> spravna odpoved: False")
transitive_closure(g7)
print(str(g7.matrix))
print("TRANZITIVITA: " + str(is_transitive(g7)) + " -> spravna odpoved: True")
| 39.033333 | 85 | 0.578138 | 477 | 3,513 | 4.201258 | 0.079665 | 0.06487 | 0.134731 | 0.160679 | 0.808383 | 0.664671 | 0.565868 | 0.565868 | 0.095808 | 0 | 0 | 0.061046 | 0.155992 | 3,513 | 89 | 86 | 39.47191 | 0.61484 | 0 | 0 | 0.105263 | 0 | 0 | 0.458298 | 0.072872 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.592105 | 0 | 0 | 0 | null | 0 | 0 | 1 | 1 | 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 | 3 |
a636d43a0fec32694a7489bd173c2fcb7500315f | 4,289 | py | Python | beancount_chase/credit_test.py | mtlynch/beancount-chase | fbad7c3b28dcb4ddbc39109e97d0b0accae115de | [
"MIT"
] | 1 | 2022-03-28T17:39:47.000Z | 2022-03-28T17:39:47.000Z | beancount_chase/credit_test.py | mtlynch/beancount-chase-bank | fe168306b2855732a111fbef79657f8f4dc506cc | [
"MIT"
] | 1 | 2022-02-06T16:41:18.000Z | 2022-02-06T16:41:18.000Z | beancount_chase/credit_test.py | mtlynch/beancount-chase | fbad7c3b28dcb4ddbc39109e97d0b0accae115de | [
"MIT"
] | 1 | 2022-02-14T18:31:19.000Z | 2022-02-14T18:31:19.000Z | import io
import textwrap
import pytest # NOQA, pylint: disable=unused-import
from beancount.ingest import extract
from . import CreditImporter
def _unindent(indented):
return textwrap.dedent(indented).lstrip()
def _stringify_directives(directives):
f = io.StringIO()
extract.print_extracted_entries(directives, f)
return f.getvalue()
def test_identifies_chase_credit_file(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity20210103_20210202_20210214.CSV'
chase_file.write_text(
_unindent("""
Card,Transaction Date,Post Date,Description,Category,Type,Amount,Memo
1234,01/06/2021,01/07/2021,AMZN Mktp US,Shopping,Sale,-20.54,
"""))
with chase_file.open() as f:
assert CreditImporter(account='Liabilities:Credit-Cards:Chase',
lastfour='1234').identify(f)
def test_extracts_spend(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity20210103_20210202_20210214.CSV'
chase_file.write_text(
_unindent("""
Card,Transaction Date,Post Date,Description,Category,Type,Amount,Memo
1234,10/29/2021,10/31/2021,GOOGLE *CLOUD_02BB66-C,Professional Services,Sale,-25.35,
"""))
with chase_file.open() as f:
directives = CreditImporter(account='Liabilities:Credit-Cards:Chase',
lastfour='1234').extract(f)
assert _unindent("""
2021-10-29 * "Google *Cloud_02bb66-C"
Liabilities:Credit-Cards:Chase -25.35 USD
""".rstrip()) == _stringify_directives(directives).strip()
def test_extracts_spend_with_matching_transaction(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity20210103_20210202_20210214.CSV'
chase_file.write_text(
_unindent("""
Card,Transaction Date,Post Date,Description,Category,Type,Amount,Memo
1234,10/29/2021,10/31/2021,GOOGLE *CLOUD_02BB66-C,Professional Services,Sale,-25.35,
"""))
with chase_file.open() as f:
directives = CreditImporter(
account='Liabilities:Credit-Cards:Chase',
lastfour='1234',
account_patterns=[
('Google.*Cloud',
'Expenses:Cloud-Services:Google-Cloud-Platform'),
]).extract(f)
assert _unindent("""
2021-10-29 * "Google *Cloud_02bb66-C"
Liabilities:Credit-Cards:Chase -25.35 USD
Expenses:Cloud-Services:Google-Cloud-Platform 25.35 USD
""".rstrip()) == _stringify_directives(directives).strip()
def test_extracts_refund(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity20210103_20210202_20210214.CSV'
chase_file.write_text(
_unindent("""
Card,Transaction Date,Post Date,Description,Category,Type,Amount,Memo
1234,01/06/2021,01/07/2021,AMZN Mktp US,Shopping,Return,413.54,
"""))
with chase_file.open() as f:
directives = CreditImporter(account='Liabilities:Credit-Cards:Chase',
lastfour='1234').extract(f)
assert _unindent("""
2021-01-06 * "AMZN MKTP US"
Liabilities:Credit-Cards:Chase 413.54 USD
""".rstrip()) == _stringify_directives(directives).strip()
def test_extracts_payment(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity20210103_20210202_20210214.CSV'
chase_file.write_text(
_unindent("""
Card,Transaction Date,Post Date,Description,Category,Type,Amount,Memo
1234,11/04/2021,11/04/2021,Payment Thank You - Web,,Payment,4000.00,
"""))
with chase_file.open() as f:
directives = CreditImporter(account='Liabilities:Credit-Cards:Chase',
lastfour='1234',
account_patterns=[
('Payment Thank You',
'Assets:Checking:Bank-of-America')
]).extract(f)
assert _unindent("""
2021-11-04 * "Payment Thank You - Web"
Liabilities:Credit-Cards:Chase 4000.00 USD
Assets:Checking:Bank-of-America -4000.00 USD
""".rstrip()) == _stringify_directives(directives).strip()
| 37.622807 | 96 | 0.625321 | 477 | 4,289 | 5.438155 | 0.222222 | 0.052043 | 0.07633 | 0.093678 | 0.778335 | 0.747494 | 0.700077 | 0.690825 | 0.667695 | 0.645335 | 0 | 0.113565 | 0.2609 | 4,289 | 113 | 97 | 37.955752 | 0.704732 | 0.00816 | 0 | 0.625 | 0 | 0.056818 | 0.465898 | 0.282926 | 0 | 0 | 0 | 0 | 0.056818 | 1 | 0.079545 | false | 0 | 0.113636 | 0.011364 | 0.215909 | 0.011364 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
a63d00ee650a1d10b4dce57a08abafdbc779a5e5 | 1,246 | py | Python | hw2/utils.py | david-joy/bmi203-hw2 | 8e16b57d43b3332bb1ea50f9546e8353b166d9cc | [
"Apache-2.0"
] | null | null | null | hw2/utils.py | david-joy/bmi203-hw2 | 8e16b57d43b3332bb1ea50f9546e8353b166d9cc | [
"Apache-2.0"
] | null | null | null | hw2/utils.py | david-joy/bmi203-hw2 | 8e16b57d43b3332bb1ea50f9546e8353b166d9cc | [
"Apache-2.0"
] | null | null | null | # Some utility classes to represent a PDB structure
class Atom:
"""
A simple class for an amino acid residue
"""
def __init__(self, type):
self.type = type
self.coords = (0.0, 0.0, 0.0)
# Overload the __repr__ operator to make printing simpler.
def __repr__(self):
return self.type
class Residue:
"""
A simple class for an amino acid residue
"""
def __init__(self, type, number):
self.type = type
self.number = number
self.atoms = []
# Overload the __repr__ operator to make printing simpler.
def __repr__(self):
return "{0} {1}".format(self.type, self.number)
@property
def alpha_carbon(self):
""" Lookup the atom representing the alpha carbon """
for atom in self.atoms:
if atom.type in ('CA', 'CA A', 'C A'):
return atom
# Le sad: no alpha carbon found
print(self.atoms)
return None
class ActiveSite:
"""
A simple class for an active site
"""
def __init__(self, name):
self.name = name
self.residues = []
# Overload the __repr__ operator to make printing simpler.
def __repr__(self):
return self.name
| 22.654545 | 62 | 0.58748 | 160 | 1,246 | 4.34375 | 0.3375 | 0.069065 | 0.017266 | 0.064748 | 0.446043 | 0.41295 | 0.41295 | 0.41295 | 0.41295 | 0.41295 | 0 | 0.009412 | 0.317817 | 1,246 | 54 | 63 | 23.074074 | 0.808235 | 0.332263 | 0 | 0.192308 | 0 | 0 | 0.021907 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.269231 | false | 0 | 0 | 0.115385 | 0.576923 | 0.038462 | 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 | 1 | 1 | 0 | 0 | 3 |
a663efc7ca59f23de2d7d0feb4893910e3366e63 | 2,733 | py | Python | ex35_punypy/punypy/productions.py | techieguy007/learn-more-python-the-hard-way-solutions | 7886c860f69d69739a41d6490b8dc3fa777f227b | [
"Zed",
"Unlicense"
] | 466 | 2016-11-01T19:40:59.000Z | 2022-03-23T16:34:13.000Z | ex35_punypy/punypy/productions.py | Desperaaado/learn-more-python-the-hard-way-solutions | 7886c860f69d69739a41d6490b8dc3fa777f227b | [
"Zed",
"Unlicense"
] | 2 | 2017-09-20T09:01:53.000Z | 2017-09-21T15:03:56.000Z | ex35_punypy/punypy/productions.py | Desperaaado/learn-more-python-the-hard-way-solutions | 7886c860f69d69739a41d6490b8dc3fa777f227b | [
"Zed",
"Unlicense"
] | 241 | 2017-06-17T08:02:26.000Z | 2022-03-30T09:09:39.000Z | class Production(object):
def analyze(self, world):
"""Implement your analyzer here."""
def interpret(self, world):
"""Implement your interpreter here."""
class FuncCall(Production):
def __init__(self, token, params):
self.name = token[1]
self.params = params
self.token = token
def analyze(self, world):
self.params.analyze(world)
def interpret(self, world):
funcdef = world.functions[self.name]
funcdef.call(world, self.params)
def __repr__(self):
return f"FuncCall({self.name}: {self.params})"
class Parameters(Production):
def __init__(self, expressions):
self.expressions = expressions
def analyze(self, world):
for expr in self.expressions:
expr.analyze(world)
def interpret(self, world):
return [x.interpret(world) for x in self.expressions]
def __repr__(self):
return f"Parameters({self.expressions})"
class Expr(Production): pass
class NameExpr(Expr):
def __init__(self, token):
self.name = token[1]
self.token = token
def interpret(self, world):
# This should point at an IntExpr for now
ref = world.variables.get(self.name)
return ref.interpret(world)
def __repr__(self):
return f"NameExpr({self.name})"
class IntExpr(Expr):
def __init__(self, token):
self.integer = int(token[1])
self.token = token
def __repr__(self):
return f"IntExpr({self.integer})"
def interpret(self, world):
return self.integer
class AddExpr(Expr):
def __init__(self, left, right):
self.left = left
self.right = right
def analyze(self, world):
self.left.analyze(world)
self.right.analyze(world)
def interpret(self, world):
return self.left.interpret(world) + self.right.interpret(world)
def __repr__(self):
return f"AddExpr({self.left}, {self.right})"
class FuncDef(Production):
def __init__(self, token, params, body):
self.name = token[1]
self.params = params
self.body = body
self.token = token
def analyze(self, world):
world.functions[self.name] = self
def __repr__(self):
return f"FuncDef({self.name}({self.params}): {self.body}"
def call(self, world, params):
params = params or Parameters()
scope = world.clone()
for i, p in enumerate(self.params.expressions):
scope.variables[p.name] = params.expressions[i]
for line in self.body:
line.interpret(scope)
class PrintFuncDef(Production):
def call(self, world, params):
print(*params.interpret(world))
| 24.185841 | 71 | 0.6191 | 329 | 2,733 | 4.99696 | 0.176292 | 0.071168 | 0.058394 | 0.076642 | 0.390511 | 0.30292 | 0.16545 | 0.041363 | 0 | 0 | 0 | 0.001981 | 0.261251 | 2,733 | 112 | 72 | 24.401786 | 0.812283 | 0.037688 | 0 | 0.405405 | 0 | 0 | 0.072984 | 0.049675 | 0 | 0 | 0 | 0 | 0 | 1 | 0.337838 | false | 0.013514 | 0 | 0.121622 | 0.594595 | 0.013514 | 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 | 1 | 1 | 0 | 0 | 3 |
a68a820f9d6c0a4cbdd2883e53d8274f7823b84d | 902 | py | Python | block_kit_builder/blocks.py | iflores12/slack-block-formatter | 4c7b2dbd80eb80bab7a22600fcf913edd3be4686 | [
"MIT"
] | null | null | null | block_kit_builder/blocks.py | iflores12/slack-block-formatter | 4c7b2dbd80eb80bab7a22600fcf913edd3be4686 | [
"MIT"
] | null | null | null | block_kit_builder/blocks.py | iflores12/slack-block-formatter | 4c7b2dbd80eb80bab7a22600fcf913edd3be4686 | [
"MIT"
] | null | null | null | from dataclasses import dataclass
from .composition import Text
from typing import List, Any
@dataclass
class Section:
type: str = 'section'
text: Text = None
block_id: str = None
fields: List[Text] = None
accessory: str = None
@dataclass
class Divider:
type: str = 'divider'
block_id: str = None
@dataclass
class Image:
type: str = 'image'
image_url: str = None
alt_text: str = None
title: Text = None
block_id: str = None
@dataclass
class Actions:
type: str
elements: str
block_id: str = None
@dataclass
class Context:
type: str
elements: List[Any]
block_id: str = None
@dataclass
class Input:
type: str
label: Text
elements: Any
block_id: str = None
hint: Text = None
optional: bool = None
@dataclass
class File:
type: str
external_id: str
source: str
block_id: str = None
| 15.033333 | 33 | 0.640798 | 120 | 902 | 4.733333 | 0.283333 | 0.123239 | 0.123239 | 0.172535 | 0.320423 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0.279379 | 902 | 59 | 34 | 15.288136 | 0.873846 | 0 | 0 | 0.4 | 0 | 0 | 0.021088 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.066667 | 0 | 0.844444 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
a6929cb46db6feedcc168686f7228663611ccd6a | 369 | py | Python | src/einsteinpy/symbolic/__init__.py | arnav257/einsteinpy | ccf08bb5b5ba7869fbf87c6cf1337532232549cd | [
"MIT"
] | null | null | null | src/einsteinpy/symbolic/__init__.py | arnav257/einsteinpy | ccf08bb5b5ba7869fbf87c6cf1337532232549cd | [
"MIT"
] | null | null | null | src/einsteinpy/symbolic/__init__.py | arnav257/einsteinpy | ccf08bb5b5ba7869fbf87c6cf1337532232549cd | [
"MIT"
] | null | null | null | from .christoffel import ChristoffelSymbols
from .einstein import EinsteinTensor
from .metric import MetricTensor
from .ricci import RicciScalar, RicciTensor
from .riemann import RiemannCurvatureTensor
from .stress_energy_momentum import StressEnergyMomentumTensor
from .tensor import Tensor
from .vacuum_metrics import SchwarzschildMetric
from .weyl import WeylTensor
| 36.9 | 62 | 0.872629 | 40 | 369 | 7.975 | 0.575 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.100271 | 369 | 9 | 63 | 41 | 0.960843 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
a6e0b81cf13ea677c9a4ee45bcc08d0f326589b3 | 5,219 | py | Python | tests/test_message_parse.py | 500-Error/weixin-SDK | d646ff34c58ca6a03ed6b08fb7c2b0c0fe244863 | [
"MIT"
] | 1 | 2017-12-01T11:17:22.000Z | 2017-12-01T11:17:22.000Z | tests/test_message_parse.py | 500-Error/weixin-SDK | d646ff34c58ca6a03ed6b08fb7c2b0c0fe244863 | [
"MIT"
] | null | null | null | tests/test_message_parse.py | 500-Error/weixin-SDK | d646ff34c58ca6a03ed6b08fb7c2b0c0fe244863 | [
"MIT"
] | 1 | 2019-03-29T16:59:11.000Z | 2019-03-29T16:59:11.000Z | # encoding=utf-8
from weixin.parse import *
def test_text_msg():
print('test_text_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[你好]]></Content>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'text'
assert msg.Content == '你好'
def test_image_msg():
print('test_image_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[image]]></MsgType>
<PicUrl><![CDATA[url]]></PicUrl>
<MediaId><![CDATA[media_id]]></MediaId>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'image'
assert msg.PicUrl == 'url'
assert msg.MediaId == 'media_id'
def test_voice_msg():
print('test_voice_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[voice]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<Format><![CDATA[Format]]></Format>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'voice'
assert msg.MediaId == 'media_id'
assert msg.Format == 'Format'
def test_video_msg():
print('test_video_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[video]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'video'
assert msg.MediaId == 'media_id'
assert msg.ThumbMediaId == 'thumb_media_id'
def test_shortvideo_msg():
print('test_shortvideo_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[shortvideo]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'shortvideo'
assert msg.MediaId == 'media_id'
assert msg.ThumbMediaId == 'thumb_media_id'
def test_location_msg():
print('test_location_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[location]]></MsgType>
<Location_X>23.134521</Location_X>
<Location_Y>113.358803</Location_Y>
<Scale>20</Scale>
<Label><![CDATA[位置信息]]></Label>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'location'
assert msg.Location_X == '23.134521'
assert msg.Location_Y == '113.358803'
assert msg.Scale == '20'
assert msg.Label == '位置信息'
def test_link_msg():
print('test_link_msg')
xml = """<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[link]]></MsgType>
<Title><![CDATA[公众平台官网链接]]></Title>
<Description><![CDATA[公众平台官网链接]]></Description>
<Url><![CDATA[url]]></Url>
<MsgId>123456789</MsgId>
</xml>
"""
msg = WeixinMsg(xml)
assert msg.ToUserName == 'toUser'
assert msg.FromUserName == 'fromUser'
assert msg.CreateTime == '123456789'
assert msg.MsgId == '123456789'
assert msg.MsgType == 'link'
assert msg.Title == '公众平台官网链接'
assert msg.Description == '公众平台官网链接'
assert msg.Url == 'url'
if __name__ == "__main__":
test_text_msg()
test_image_msg()
test_voice_msg()
test_video_msg()
test_shortvideo_msg()
test_location_msg()
test_link_msg()
| 28.210811 | 59 | 0.623874 | 546 | 5,219 | 5.831502 | 0.102564 | 0.144158 | 0.079146 | 0.041771 | 0.728643 | 0.713254 | 0.702889 | 0.692839 | 0.692839 | 0.692839 | 0 | 0.069517 | 0.197931 | 5,219 | 184 | 60 | 28.36413 | 0.691113 | 0.002683 | 0 | 0.627451 | 0 | 0 | 0.541034 | 0.361714 | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0.045752 | false | 0 | 0.006536 | 0 | 0.052288 | 0.045752 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
a6e3f601632d30b9897d54d51d250163a209f423 | 150 | py | Python | hymusic/__init__.py | frostming/hymusic | 82b1cff4e242a54a78fa495483949ab272268288 | [
"MIT"
] | 1 | 2022-03-20T19:32:23.000Z | 2022-03-20T19:32:23.000Z | hymusic/__init__.py | frostming/hymusic | 82b1cff4e242a54a78fa495483949ab272268288 | [
"MIT"
] | null | null | null | hymusic/__init__.py | frostming/hymusic | 82b1cff4e242a54a78fa495483949ab272268288 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from .sources.netease import NeteaseCloud
from .sources.qqmusic import QQMusic
netease = NeteaseCloud()
qqmusic = QQMusic()
| 18.75 | 41 | 0.733333 | 17 | 150 | 6.470588 | 0.529412 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007752 | 0.14 | 150 | 7 | 42 | 21.428571 | 0.844961 | 0.14 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
a6f0a587a036585eaaed60331de15fddecf07c54 | 690 | py | Python | qvapay/v1/__init__.py | lugodev/qvapay-python | 6a530933ca8252fc95ab4cdacec0ff142618bcb4 | [
"MIT"
] | 15 | 2021-08-28T12:45:30.000Z | 2022-02-09T23:41:43.000Z | qvapay/v1/__init__.py | lugodev/qvapay-python | 6a530933ca8252fc95ab4cdacec0ff142618bcb4 | [
"MIT"
] | 11 | 2021-08-30T20:30:37.000Z | 2021-10-31T18:05:41.000Z | qvapay/v1/__init__.py | leynier/qvapay-python | 6a530933ca8252fc95ab4cdacec0ff142618bcb4 | [
"MIT"
] | 6 | 2021-08-28T22:22:08.000Z | 2022-03-07T19:53:09.000Z | from ._async.client import AsyncQvaPayClient # noqa: F401
from ._sync.client import SyncQvaPayClient # noqa: F401
from .auth import QvaPayAuth # noqa: F401
from .errors import QvaPayError # noqa: F401
from .models.info import Info # noqa: F401
from .models.invoice import Invoice # noqa: F401
from .models.owner import Owner # noqa: F401
from .models.paginated_transactions import PaginatedTransactions # noqa: F401
from .models.paid_by import PaidBy # noqa: F401
from .models.transaction import Transaction # noqa: F401
from .models.transaction_detail import TransactionDetail # noqa: F401
__version__ = "0.3.0"
__author__ = "Carlos Lugones <contact@lugodev.com>"
__all__ = []
| 43.125 | 78 | 0.772464 | 89 | 690 | 5.797753 | 0.404494 | 0.170543 | 0.232558 | 0.244186 | 0.112403 | 0 | 0 | 0 | 0 | 0 | 0 | 0.061017 | 0.144928 | 690 | 15 | 79 | 46 | 0.813559 | 0.173913 | 0 | 0 | 0 | 0 | 0.073477 | 0.037634 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.785714 | 0 | 0.785714 | 0 | 0 | 0 | 0 | null | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
47117bdea2dc297e22209e49d84d12d93d524593 | 202 | py | Python | danceschool/prerequisites/urls.py | benjwrdill/django-danceschool | 9ecb2754502e62d0f49aa23d08ca6de6cae3c99a | [
"BSD-3-Clause"
] | 1 | 2019-02-04T02:11:32.000Z | 2019-02-04T02:11:32.000Z | danceschool/prerequisites/urls.py | benjwrdill/django-danceschool | 9ecb2754502e62d0f49aa23d08ca6de6cae3c99a | [
"BSD-3-Clause"
] | 2 | 2019-03-26T22:37:49.000Z | 2019-12-02T15:39:35.000Z | danceschool/prerequisites/urls.py | benjwrdill/django-danceschool | 9ecb2754502e62d0f49aa23d08ca6de6cae3c99a | [
"BSD-3-Clause"
] | 1 | 2019-03-19T22:49:01.000Z | 2019-03-19T22:49:01.000Z | from django.conf.urls import url
from .ajax import CustomerRequirementAjaxView
urlpatterns = [
url(r'^customer/$', CustomerRequirementAjaxView.as_view(), name='customerRequirementAjax'),
]
| 25.25 | 96 | 0.752475 | 19 | 202 | 7.947368 | 0.789474 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138614 | 202 | 7 | 97 | 28.857143 | 0.867816 | 0 | 0 | 0 | 0 | 0 | 0.174359 | 0.117949 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
471f90b782ab38c51b6756ed575c5b8f946510de | 553 | py | Python | Traingle_quest.py | Sandeep6262/Logical-questions-in-python | 2923a615622090fdb23699c7301d44c2975fec36 | [
"MIT"
] | null | null | null | Traingle_quest.py | Sandeep6262/Logical-questions-in-python | 2923a615622090fdb23699c7301d44c2975fec36 | [
"MIT"
] | null | null | null | Traingle_quest.py | Sandeep6262/Logical-questions-in-python | 2923a615622090fdb23699c7301d44c2975fec36 | [
"MIT"
] | null | null | null | # qution 1
# 1
# 1 1
# 1 2 1
# 1 2 3 1
# 1 2 3 4 1
# 1 2 3 4 5 1
# user=int(raw_input("Input any number "))
# for i in range(user):
# a = i+1
# for j in range(1,a):
# print j,
# print 1
# Qution 2 kackrang
# 1
# 1 2 1
# 1 2 3 2 1
# 1 2 3 4 3 2 1
# 1 2 3 4 5 4 3 2 1
# 1 2 3 4 5 6 5 4 3 2 1
# 1 2 3 4 5 6 7 6 5 4 3 2 1
# 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
user = int(raw_input("Input any number "))
for i in range(1,user):
c=''
for j in range(1,i+1):
b=j
c=str(b)+c
print b,
for k in range(1,len(c)):
print c[k],
print ''
| 12.860465 | 43 | 0.511754 | 155 | 553 | 1.812903 | 0.180645 | 0.099644 | 0.117438 | 0.128114 | 0.661922 | 0.558719 | 0.537367 | 0.448399 | 0.448399 | 0.419929 | 0 | 0.26257 | 0.352622 | 553 | 42 | 44 | 13.166667 | 0.522346 | 0.573237 | 0 | 0 | 0 | 0 | 0.085308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.3 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
472cbda9777dc451c5b3e146486eda8376bf108b | 979 | py | Python | materia/api/models/User.py | flaviogragnolati/materia_api | 38c32a4a7e9683be2c635180ec1f855a605c2c03 | [
"MIT"
] | null | null | null | materia/api/models/User.py | flaviogragnolati/materia_api | 38c32a4a7e9683be2c635180ec1f855a605c2c03 | [
"MIT"
] | null | null | null | materia/api/models/User.py | flaviogragnolati/materia_api | 38c32a4a7e9683be2c635180ec1f855a605c2c03 | [
"MIT"
] | null | null | null | from django.db import models
class User(models.Model):
"""Model definition for User."""
# TODO: Define fields here
name = models.CharField(max_length=50)
dob = models.DateField('date of birth', auto_now=False, auto_now_add=False)
email = models.EmailField('user email', max_length=254)
phone = models.CharField(max_length=50)
date_joined = models.DateField(auto_now=False, auto_now_add=True)
last_login = models.DateField(auto_now=False, auto_now_add=False)
modified_at = models.DateField(auto_now=True, auto_now_add=False)
class Meta:
"""Meta definition for User."""
verbose_name = 'User'
verbose_name_plural = 'Users'
def __str__(self):
"""Unicode representation of User."""
pass
def save(self):
"""Save method for User."""
pass
def get_absolute_url(self):
"""Return absolute url for User."""
return ('')
# TODO: Define custom methods here
| 27.971429 | 79 | 0.656793 | 128 | 979 | 4.8125 | 0.4375 | 0.090909 | 0.064935 | 0.077922 | 0.256494 | 0.172078 | 0.172078 | 0.12013 | 0 | 0 | 0 | 0.009259 | 0.227783 | 979 | 34 | 80 | 28.794118 | 0.805556 | 0.199183 | 0 | 0.111111 | 0 | 0 | 0.042272 | 0 | 0 | 0 | 0 | 0.029412 | 0 | 1 | 0.166667 | false | 0.111111 | 0.055556 | 0 | 0.777778 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
47327c104dccd95c6e4809268091c565928541ba | 407 | py | Python | pyskyqremote/country/const_deu.py | RogerSelwyn/pyskyqremote | e3bd11617b7529aa0920ad789ba7699169424c05 | [
"MIT"
] | null | null | null | pyskyqremote/country/const_deu.py | RogerSelwyn/pyskyqremote | e3bd11617b7529aa0920ad789ba7699169424c05 | [
"MIT"
] | null | null | null | pyskyqremote/country/const_deu.py | RogerSelwyn/pyskyqremote | e3bd11617b7529aa0920ad789ba7699169424c05 | [
"MIT"
] | null | null | null | """Constants for pyskyqremote- DE."""
SCHEDULE_URL = "https://www.sky.de/sgtvg/service/getBroadcasts"
LIVE_IMAGE_URL = "https://www.sky.de{0}"
PVR_IMAGE_URL = "https://www.sky.de{0}"
CHANNEL_IMAGE_URL = "https://www.sky.de{0}"
TIMEZONE = "Europe/Berlin"
CHANNEL_URL = "https://raw.githubusercontent.com/RogerSelwyn/skyq_remote/master/pyskyqremote/country/channels-de.json" # pylint: disable=line-too-long
| 45.222222 | 151 | 0.751843 | 60 | 407 | 4.95 | 0.583333 | 0.13468 | 0.148148 | 0.188552 | 0.276094 | 0.222222 | 0.222222 | 0 | 0 | 0 | 0 | 0.007895 | 0.066339 | 407 | 8 | 152 | 50.875 | 0.773684 | 0.152334 | 0 | 0 | 0 | 0.166667 | 0.660767 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5b2733f552c9898d36e19c5ece5a6aab98ad4f8e | 675 | py | Python | ml_toolkit/deep_learning/pytorch/optim/optimizer/ranger/ranger_lars.py | TSPereira/support_toolkit | d9b0488d69dccc38b73cd67ea33f4f53983cf77f | [
"MIT"
] | 4 | 2021-01-05T14:03:54.000Z | 2021-01-29T14:48:09.000Z | ml_toolkit/deep_learning/pytorch/optim/optimizer/ranger/ranger_lars.py | TSPereira/support_toolkit | d9b0488d69dccc38b73cd67ea33f4f53983cf77f | [
"MIT"
] | null | null | null | ml_toolkit/deep_learning/pytorch/optim/optimizer/ranger/ranger_lars.py | TSPereira/support_toolkit | d9b0488d69dccc38b73cd67ea33f4f53983cf77f | [
"MIT"
] | null | null | null | from ..lookahead import make_lookahead_optimizer
from ..ralamb import Ralamb
def RangerLars(params, alpha=0.5, k=6, *args, **kwargs):
"""
RAdam + LARS + LookAHead
Lookahead implementation from https://github.com/lonePatient/lookahead_pytorch/blob/master/optimizer.py
RAdam + LARS implementation from https://gist.github.com/redknightlois/c4023d393eb8f92bb44b2ab582d7ec20
:param params: net parameters
:param alpha: lookahead alpha parameter
:param k: lookahead k parameter
:param args: args for RaLamb
:param kwargs: kwargs for RaLamb
:return:
"""
return make_lookahead_optimizer(Ralamb(params, *args, **kwargs), alpha, k)
| 33.75 | 107 | 0.733333 | 81 | 675 | 6.049383 | 0.444444 | 0.053061 | 0.089796 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.039216 | 0.168889 | 675 | 19 | 108 | 35.526316 | 0.834225 | 0.602963 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
5b89559c3eb2ab5cec560961eb6cc0d57c9ff2c8 | 250 | py | Python | Python/Strings/StringFormatting.py | devansh-pratap-singh/hackerrank-solutions | 227817d90846424cd3078e60b225eb201e906cf9 | [
"MIT"
] | 1 | 2020-10-15T14:03:52.000Z | 2020-10-15T14:03:52.000Z | Python/Strings/StringFormatting.py | devansh-pratap-singh/HackerRank-Solutions | 227817d90846424cd3078e60b225eb201e906cf9 | [
"MIT"
] | null | null | null | Python/Strings/StringFormatting.py | devansh-pratap-singh/HackerRank-Solutions | 227817d90846424cd3078e60b225eb201e906cf9 | [
"MIT"
] | null | null | null | def print_formatted(N):
width = len(bin(N)[2:])
for i in range(1, N + 1):
print(' '.join(map(lambda x: x.rjust(width), [str(i), oct(i)[2:], hex(i)[2:].upper(), bin(i)[2:]])))
if __name__ == '__main__':
n = int(input())
print_formatted(n) | 31.25 | 104 | 0.572 | 45 | 250 | 2.955556 | 0.6 | 0.045113 | 0.225564 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028571 | 0.16 | 250 | 8 | 105 | 31.25 | 0.604762 | 0 | 0 | 0 | 0 | 0 | 0.035857 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0 | 0 | 0.142857 | 0.428571 | 0 | 0 | 0 | null | 0 | 1 | 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 | 1 | 0 | 3 |
5bb100e3b46f5ada40199134e6fad21387eee28d | 349 | py | Python | pyseus/formats/__init__.py | impergator493/PySeus | faa7e5741acea9c3b8e0acad066905fa3b1c301b | [
"X11"
] | 2 | 2020-02-17T09:20:50.000Z | 2022-03-22T13:05:22.000Z | pyseus/formats/__init__.py | impergator493/PySeus | faa7e5741acea9c3b8e0acad066905fa3b1c301b | [
"X11"
] | null | null | null | pyseus/formats/__init__.py | impergator493/PySeus | faa7e5741acea9c3b8e0acad066905fa3b1c301b | [
"X11"
] | 1 | 2021-05-26T08:14:58.000Z | 2021-05-26T08:14:58.000Z | """Formats model different data sources (file formats).
All formats extend the *BaseFormat* class, guaranteeing basic functionality
of checking files, loading scan pixeldata and metadata.
"""
from .base import BaseFormat, LoadError
from .raw import Raw
from .numpy import NumPy
from .h5 import H5
from .dicom import DICOM
from .nifti import NIfTI
| 26.846154 | 75 | 0.790831 | 49 | 349 | 5.632653 | 0.632653 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006734 | 0.148997 | 349 | 12 | 76 | 29.083333 | 0.922559 | 0.530086 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
5bc374d21ff3cf020f0eb6933ee39b3c2bafaad7 | 4,661 | py | Python | Aula_27/exercicios/geradorlista.py | Mateus-Silva11/AulasPython | d34dc4f62ade438e68b0a80e0baac4d6ec0d378e | [
"MIT"
] | null | null | null | Aula_27/exercicios/geradorlista.py | Mateus-Silva11/AulasPython | d34dc4f62ade438e68b0a80e0baac4d6ec0d378e | [
"MIT"
] | null | null | null | Aula_27/exercicios/geradorlista.py | Mateus-Silva11/AulasPython | d34dc4f62ade438e68b0a80e0baac4d6ec0d378e | [
"MIT"
] | null | null | null | import random
def lista_simples_int_str(numero_objetos = int(random.randint(5,100))):
'''
Retorna lista randômica, pura, composta de string ou inteiros, variando de 5 a 100 itens.
'''
tipo_lista = int(random.randint(0,1))
if tipo_lista == 0:
lista = lista_simples_str(numero_objetos)
else:
lista = lista_simples_int(numero_objetos)
return lista
def lista_simples_inpura_int_str(numero_objetos = int(random.randint(5,100))):
'''
Retorna lista randômica, impura, composta de string, inteiros ou alfanúmerica, variando de 5 a 100 itens.
'''
tipo_lista = int(random.randint(0,2))
if tipo_lista == 0:
lista = lista_simples_str(numero_objetos)
elif tipo_lista == 1:
lista = lista_simples_impura(numero_objetos)
else:
lista = lista_simples_int(numero_objetos)
return lista
def lista_simples_int(numero_objetos = int(random.randint(5,100))):
'''
Retorna uma lista randômica com inteiros contendo de 5 a 100 itens.
'''
lista = []
for i in range(numero_objetos):
lista.append(int(random.randint(1,1000)))
return lista
def lista_simples_str(numero_objetos = int(random.randint(5,100))):
'''
Retorna uma lista randômica com string, de 1 a 10 caracteres, contendo de 5 a 100 itens.
Os caracteres podem ser minusculos ou maiusculos.
'''
lista_alfabetica = ['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']
lista = []
for i in range(numero_objetos):
letra = ''
for i in range(int(random.randint(1,10))):
char = random.choice(lista_alfabetica)
if int(random.randint(0,1)) == 1:
letra = letra + char.upper()
else:
letra = letra + char
lista.append(letra)
return lista
def lista_simples_impura(numero_objetos = int(random.randint(5,100))):
'''
Retorna uma lista randômica com alfanumérica, de 1 a 10 caracteres, numeros de 0 a 1000,
contendo de 5 a 100 itens.
Os caracteres podem ser minusculos ou maiusculos.
'''
lista_alfabetica = ['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', '0', '1',
'2', '3', '4', '5', '6', '7', '8',
'9']
lista = []
for i in range(numero_objetos):
letra = ''
if int(random.randint(0,1)) == 0:
lista.append(random.randint(0,1000))
else:
for i in range(int(random.randint(1,10))):
char = random.choice(lista_alfabetica)
if int(random.randint(0,1)) == 0:
letra = letra + char.upper()
else:
letra = letra + char
lista.append(letra)
return lista
def lista_lista_int():
pass
def embaralhar(numero=3,numero_objetos=30,lista_return=None):
'''
Cria uma lista contendo várias listas, inteiras com 30 itens. Ela irá copiar estas listas e
embaralhar de forma que não se sabe se as listas são as mesmas ou são somente iguais!
'''
lista = []
lista1 = []
lista2 = []
for i in range(numero):
lista1.append(lista_simples_int(numero_objetos))
for i in lista1:
lista2.append(i.copy())
lista1.extend(lista2)
# quntas listas deve ser retornadas!
if lista_return == None:
for i in lista1:
lista.append(random.choice(lista1))
else:
for i in range(lista_return):
lista.append(random.choice(lista1))
return lista
def embaralhar_int_str_hard(numero=3,numero_objetos=30):
'''
Cria uma lista contendo várias listas, inteiras, string ou alfanunéricas com vários itens.
Ela irá copiar estas listas e embaralhar de forma que não se sabe se as listas são as mesmas
ou são somente iguais!
'''
lista = []
lista1 = []
lista2 = []
for i in range(numero):
lista1.append(lista_simples_inpura_int_str(numero_objetos))
for i in lista1:
lista2.append(i.copy())
lista1.extend(lista2)
multiplicador = random.randint(1,25)
for i in range(len(lista1) * multiplicador):
lista.append(random.choice(lista1))
return lista
def binario (numero_objetos=8):
lista = []
for i in range(numero_objetos):
lista.append(random.randint(0,1))
return lista | 32.368056 | 109 | 0.576915 | 617 | 4,661 | 4.252836 | 0.199352 | 0.094131 | 0.079268 | 0.041921 | 0.825838 | 0.739329 | 0.731707 | 0.685976 | 0.627287 | 0.595655 | 0 | 0.038415 | 0.296288 | 4,661 | 144 | 110 | 32.368056 | 0.761585 | 0.212615 | 0 | 0.694737 | 0 | 0 | 0.017519 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.094737 | false | 0.010526 | 0.010526 | 0 | 0.189474 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 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 | 3 |
5bc77bb41d5d6822fc6a6123ae42dd56f93e5867 | 770 | py | Python | gaia-sdk-python/gaia_sdk/api/client_options.py | leftshiftone/gaia-sdk | 7e0d1ce054fada8ae154da70b71e8a90347c9f97 | [
"MIT"
] | null | null | null | gaia-sdk-python/gaia_sdk/api/client_options.py | leftshiftone/gaia-sdk | 7e0d1ce054fada8ae154da70b71e8a90347c9f97 | [
"MIT"
] | 10 | 2019-11-14T07:55:47.000Z | 2022-02-26T19:36:45.000Z | gaia-sdk-python/gaia_sdk/api/client_options.py | leftshiftone/gaia-sdk | 7e0d1ce054fada8ae154da70b71e8a90347c9f97 | [
"MIT"
] | 2 | 2020-05-12T11:09:53.000Z | 2020-12-25T14:03:04.000Z | from typing import Any
from typing import Dict
class ClientOptions:
"""
This class stores the credentials (JWT or HMAC-ApiKey&SecretKey tuple) used by the transporter implementation
to establish a connection to G.A.I.A.
"""
def __init__(self, credentials, content_type="application/json", request_parameters={}):
self.credentials = credentials
self.content_type = content_type
self.request_parameters = request_parameters
def with_content_type(self, content_type: str):
return ClientOptions(self.credentials, content_type, self.request_parameters)
def with_request_parameters(self, request_parameters: Dict[str, Any]):
return ClientOptions(self.credentials, self.content_type, request_parameters)
| 36.666667 | 113 | 0.746753 | 94 | 770 | 5.904255 | 0.414894 | 0.138739 | 0.081081 | 0.093694 | 0.115315 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.176623 | 770 | 20 | 114 | 38.5 | 0.875394 | 0.190909 | 0 | 0 | 0 | 0 | 0.026534 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.181818 | 0.181818 | 0.727273 | 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 | 1 | 1 | 0 | 0 | 3 |
5bc842bce283a817cf89df111262d6c19d3d4b5d | 38 | py | Python | csv-extractor/__init__.py | kozhevnykov/datapoints-csv-extractor | b7d61891fa440be909eac8886f8c3406725beaba | [
"Apache-2.0"
] | 2 | 2020-08-29T08:52:57.000Z | 2020-10-22T11:36:32.000Z | csv-extractor/__init__.py | kozhevnykov/datapoints-csv-extractor | b7d61891fa440be909eac8886f8c3406725beaba | [
"Apache-2.0"
] | 9 | 2019-03-27T00:27:45.000Z | 2021-04-30T20:52:04.000Z | csv-extractor/__init__.py | kozhevnykov/datapoints-csv-extractor | b7d61891fa440be909eac8886f8c3406725beaba | [
"Apache-2.0"
] | 1 | 2020-02-17T15:28:52.000Z | 2020-02-17T15:28:52.000Z | # coding: utf-8
__version__ = "0.3.2"
| 12.666667 | 21 | 0.631579 | 7 | 38 | 2.857143 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | 0.157895 | 38 | 2 | 22 | 19 | 0.5 | 0.342105 | 0 | 0 | 0 | 0 | 0.217391 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
5bea143e2899835872cc4de41ba78e2ad3e98927 | 650 | py | Python | tests/test_autocorrect.py | snoopyjc/ssf | b995cae0e90d38e3758d4944fb144831f9bae0a5 | [
"Apache-2.0"
] | 3 | 2020-10-07T18:28:12.000Z | 2020-10-09T15:24:53.000Z | tests/test_autocorrect.py | snoopyjc/ssf | b995cae0e90d38e3758d4944fb144831f9bae0a5 | [
"Apache-2.0"
] | 15 | 2020-10-09T15:23:03.000Z | 2020-10-29T04:34:17.000Z | tests/test_autocorrect.py | snoopyjc/ssf | b995cae0e90d38e3758d4944fb144831f9bae0a5 | [
"Apache-2.0"
] | null | null | null | from ssf import SSF
ssf = SSF()
def test_autocorrect_format():
assert ssf.format('0E0', 1e2) == '1E+2'
assert ssf.format('0e0', 1e2) == '1E+2'
assert ssf.format('0.E-0', 1e2) == '1.E2'
assert ssf.format('0.e-0', 1e2) == '1.E2'
assert ssf.format('"e"0e0', 1e2) == 'e1E+2'
assert ssf.format('E', 1) == '1900'
assert ssf.format(r'\EE', 1) == 'E1900'
assert ssf.format('#.##,,', 1E7) == '10.'
assert ssf.format('#.,##,', 1E7) == '10.'
assert ssf.format('ShortDate', 1) == ssf.format('Short Date', 1)
assert ssf.format('longDate', 1) == ssf.format('Long Date', 1)
assert ssf.format('.m,m,', 1) == '1.1,1,'
| 38.235294 | 68 | 0.556923 | 102 | 650 | 3.529412 | 0.284314 | 0.35 | 0.5 | 0.133333 | 0.572222 | 0.461111 | 0.461111 | 0.461111 | 0.308333 | 0.308333 | 0 | 0.106061 | 0.187692 | 650 | 16 | 69 | 40.625 | 0.575758 | 0 | 0 | 0 | 0 | 0 | 0.186154 | 0 | 0 | 0 | 0 | 0 | 0.8 | 1 | 0.066667 | false | 0 | 0.066667 | 0 | 0.133333 | 0 | 0 | 0 | 0 | null | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
750af3673b6d8c7cb15ddc10de391596cce604ee | 212 | py | Python | 003/euler003 - Test5 timeout.py | MayankAgarwal/euler_py | 4cf32879f8f7746af6ba31b87b7d4f20a0c91f3f | [
"MIT"
] | null | null | null | 003/euler003 - Test5 timeout.py | MayankAgarwal/euler_py | 4cf32879f8f7746af6ba31b87b7d4f20a0c91f3f | [
"MIT"
] | null | null | null | 003/euler003 - Test5 timeout.py | MayankAgarwal/euler_py | 4cf32879f8f7746af6ba31b87b7d4f20a0c91f3f | [
"MIT"
] | null | null | null | tests = int(raw_input().strip())
for test in xrange(tests):
N = int(raw_input().strip())
a = 2
while N != 1:
if N%a == 0:
N = N/a
else:
a += 1
print a | 13.25 | 32 | 0.419811 | 32 | 212 | 2.71875 | 0.5625 | 0.137931 | 0.252874 | 0.367816 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033058 | 0.429245 | 212 | 16 | 33 | 13.25 | 0.68595 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.1 | 0 | 0 | 0 | null | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
75218c0396ed0af6f8bad5690c8c712d6d68be43 | 400 | py | Python | classer/models/base.py | alexdelin/model-lab | 37182fdadc3e369a1ad6d4dce23162ec2d3aa566 | [
"MIT"
] | 1 | 2019-04-20T14:58:25.000Z | 2019-04-20T14:58:25.000Z | classer/models/base.py | alexdelin/model-lab | 37182fdadc3e369a1ad6d4dce23162ec2d3aa566 | [
"MIT"
] | null | null | null | classer/models/base.py | alexdelin/model-lab | 37182fdadc3e369a1ad6d4dce23162ec2d3aa566 | [
"MIT"
] | null | null | null | """
Base Model Class
"""
from ..steps.base import BaseStep
class BaseModel(BaseStep):
"""Base Model class extended for implementing text classification models"""
def __init__(self):
super(BaseModel, self).__init__()
def train():
raise NotImplementedError('This is only a base class')
def process():
raise NotImplementedError('This is only a base class')
| 21.052632 | 79 | 0.6775 | 47 | 400 | 5.595745 | 0.553191 | 0.068441 | 0.106464 | 0.228137 | 0.334601 | 0.334601 | 0.334601 | 0.334601 | 0 | 0 | 0 | 0 | 0.22 | 400 | 18 | 80 | 22.222222 | 0.842949 | 0.215 | 0 | 0.25 | 0 | 0 | 0.166113 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.375 | false | 0 | 0.125 | 0 | 0.625 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
754f683fc1e4d4b5c77866f6a39faf0ef9a0e26b | 831 | py | Python | 3D-Geometry/3D Transformations.py | vinixhenri/AUTONAVx | f5e71bfd08648fc558f19d619bb23b816beeae61 | [
"MIT"
] | null | null | null | 3D-Geometry/3D Transformations.py | vinixhenri/AUTONAVx | f5e71bfd08648fc558f19d619bb23b816beeae61 | [
"MIT"
] | null | null | null | 3D-Geometry/3D Transformations.py | vinixhenri/AUTONAVx | f5e71bfd08648fc558f19d619bb23b816beeae61 | [
"MIT"
] | null | null | null | import numpy as np
class Pose3D:
def __init__(self, rotation, translation):
self.rotation = rotation
self.translation = translation
def inv(self):
inv_rotation = self.rotation.transpose()
inv_translation = -np.dot(inv_rotation, self.translation)
return Pose3D(inv_rotation, inv_translation)
def __mul__(self, other):
return Pose3D(np.dot(self.rotation, other.rotation), np.dot(self.rotation, other.translation) + self.translation)
def __str__(self):
return "rotation:\n" + str(self.rotation) + "\ntranslation:\n" + str(self.translation.transpose())
def compute_quadrotor_pose(global_marker_pose, observed_marker_pose):
global_quadrotor_pose = global_marker_pose * observed_marker_pose.inv()
return global_quadrotor_pose
| 34.625 | 121 | 0.697954 | 98 | 831 | 5.602041 | 0.265306 | 0.131148 | 0.083789 | 0.061931 | 0.251366 | 0.17122 | 0.17122 | 0.17122 | 0 | 0 | 0 | 0.004532 | 0.203369 | 831 | 23 | 122 | 36.130435 | 0.824773 | 0 | 0 | 0 | 0 | 0 | 0.032491 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3125 | false | 0 | 0.0625 | 0.125 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
7552c694cd7603a4eaf9b16153ebc88976d0d6ec | 222 | py | Python | utils/config.py | billchenchina/mooc-dl | a85e0ff81dec6b9e6a7b23f1d606424508c73ed2 | [
"MIT"
] | 9 | 2018-08-09T11:14:56.000Z | 2019-02-18T14:11:30.000Z | utils/config.py | cattidea/subtitle-location | 9587a8ebd0b03ffeff7a61ad95b6326ba51e701a | [
"MIT"
] | 1 | 2019-12-17T02:27:52.000Z | 2019-12-17T02:28:25.000Z | utils/config.py | cattidea/subtitle-location | 9587a8ebd0b03ffeff7a61ad95b6326ba51e701a | [
"MIT"
] | 2 | 2018-07-18T09:23:36.000Z | 2019-02-25T03:36:36.000Z | import json
class Config(dict):
PATH = "config.json"
def __init__(self):
with open(Config.PATH, 'r', encoding="utf8") as f:
self._jObject = json.load(f)
super().__init__(self._jObject)
| 24.666667 | 58 | 0.603604 | 29 | 222 | 4.275862 | 0.655172 | 0.129032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006024 | 0.252252 | 222 | 8 | 59 | 27.75 | 0.740964 | 0 | 0 | 0 | 0 | 0 | 0.072072 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0 | 0.571429 | 0 | 1 | 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 | 1 | 0 | 0 | 3 |
f32cb8920217499d89c1762dcff081cdb7dff0f1 | 436 | py | Python | test_import.py | Deesthortered/MetaprogrammingLab2 | b168160fcea7efb71e7291365af9ebe1e519557a | [
"Apache-2.0"
] | null | null | null | test_import.py | Deesthortered/MetaprogrammingLab2 | b168160fcea7efb71e7291365af9ebe1e519557a | [
"Apache-2.0"
] | 1 | 2019-12-01T19:46:17.000Z | 2019-12-01T21:00:37.000Z | test_import.py | Deesthortered/MetaprogrammingLab2 | b168160fcea7efb71e7291365af9ebe1e519557a | [
"Apache-2.0"
] | null | null | null | import tensorflow .keras . activations , gvno\
. jopa . ibanaz, pzda, joo
import io, email
from tensorflow\
. keras import activations , applications
import backcall\
. hiu
from kukarek.kokoko import pud, pu, dah
import it. was . joke
import numpy as \
np, mailbox\
as mb
from tensorflow.keras \
import layers as kuku,\
applications as \
app
| 25.647059 | 49 | 0.58945 | 49 | 436 | 5.244898 | 0.632653 | 0.175097 | 0.14786 | 0.194553 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.348624 | 436 | 16 | 50 | 27.25 | 0.90493 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f3420d1dca368f4baabcb5f61288c3d9007d5f2f | 569 | py | Python | ManejoArchivos/Vehiculo.py | manu9812/programming-oriented-objets | 650e22c8129299d69a4b3fc8722f861603a0302f | [
"Apache-2.0"
] | null | null | null | ManejoArchivos/Vehiculo.py | manu9812/programming-oriented-objets | 650e22c8129299d69a4b3fc8722f861603a0302f | [
"Apache-2.0"
] | null | null | null | ManejoArchivos/Vehiculo.py | manu9812/programming-oriented-objets | 650e22c8129299d69a4b3fc8722f861603a0302f | [
"Apache-2.0"
] | null | null | null | #Autor Manuela Garcia Monsalve
# 28 septiembre 2018
#Esta es la super clase Vehiculo donde se encuentran los atributos de marca, modelo y color que seran
#heredados para las subclases
class Vehiculo():
def __init__(self,marca,color, modelo): #Se generan los atributos para poder ser heredados
self.marca = marca
self.color = color
self.modelo = modelo
def Prender(self): #Metodo prender vehiculo
pass
def Arrancar(self):#Metodo arrancar vehiculo
pass
def Apagar(self):#Metodo apagar vehiculo
pass
| 23.708333 | 101 | 0.695958 | 75 | 569 | 5.226667 | 0.546667 | 0.076531 | 0.076531 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013986 | 0.246046 | 569 | 23 | 102 | 24.73913 | 0.899767 | 0.516696 | 0 | 0.272727 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043478 | 0 | 1 | 0.363636 | false | 0.272727 | 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 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
f346cea527285edd0919196eef59c70a07340874 | 175 | py | Python | Hello_Python/square.py | JaydenYL/Projects | b51c0476f7be80f0b0d6aa84592966ecb4343d76 | [
"MIT"
] | 5 | 2021-09-06T04:27:56.000Z | 2021-12-14T14:50:27.000Z | Hello_Python/square.py | JaydenYL/Projects | b51c0476f7be80f0b0d6aa84592966ecb4343d76 | [
"MIT"
] | null | null | null | Hello_Python/square.py | JaydenYL/Projects | b51c0476f7be80f0b0d6aa84592966ecb4343d76 | [
"MIT"
] | null | null | null | import math
for i in range(10001):
x = int(math.sqrt(i + 100))
y = int(math.sqrt(i + 268))
if (( x * x == i + 100) and ( y * y == i + 268)):
print(x,y,i)
| 21.875 | 53 | 0.474286 | 33 | 175 | 2.515152 | 0.484848 | 0.168675 | 0.26506 | 0.289157 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 0.32 | 175 | 7 | 54 | 25 | 0.554622 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0.166667 | 0 | 0 | 0 | null | 0 | 1 | 1 | 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 | 3 |
f355555f44df69e9289a7f1288ecf470ecb1629f | 196 | py | Python | examples/create_new_document.py | 13751742405/photoshop-python-api | 5fe9b46dd2b2b4e2e1e6ef99a68d68b4fc032a70 | [
"MIT"
] | null | null | null | examples/create_new_document.py | 13751742405/photoshop-python-api | 5fe9b46dd2b2b4e2e1e6ef99a68d68b4fc032a70 | [
"MIT"
] | null | null | null | examples/create_new_document.py | 13751742405/photoshop-python-api | 5fe9b46dd2b2b4e2e1e6ef99a68d68b4fc032a70 | [
"MIT"
] | null | null | null | """Create a new document."""
from photoshop import Session
with Session() as ps:
ps.app.preferences.rulerUnits = ps.Units.Pixels
ps.app.documents.add(1920, 1080, name="my_new_document")
| 24.5 | 60 | 0.72449 | 29 | 196 | 4.827586 | 0.758621 | 0.157143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.047619 | 0.142857 | 196 | 7 | 61 | 28 | 0.785714 | 0.112245 | 0 | 0 | 0 | 0 | 0.089286 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f36a50b1109f61788a72cbdfe3d00e451ba74f3a | 1,697 | py | Python | test-unit/PythonToJavascript/converters_test/TupleConverter_test.py | stoogoff/python-to-javascript | 4349b09b15ada544501e7091c7ff1574487e7598 | [
"MIT"
] | 1 | 2021-11-19T09:56:41.000Z | 2021-11-19T09:56:41.000Z | test-unit/PythonToJavascript/converters_test/TupleConverter_test.py | stoogoff/python-to-javascript | 4349b09b15ada544501e7091c7ff1574487e7598 | [
"MIT"
] | 2 | 2022-02-25T23:11:27.000Z | 2022-03-04T10:22:14.000Z | test-unit/PythonToJavascript/converters_test/TupleConverter_test.py | stoogoff/python-to-javascript | 4349b09b15ada544501e7091c7ff1574487e7598 | [
"MIT"
] | 4 | 2021-05-06T19:03:19.000Z | 2022-03-06T13:52:30.000Z | from utils import parseSource, nodesToString, nodesToLines, dumpNodes, dumpTree
from converters import TupleConverter
def test_TupleGather_01():
src = """
l = ( 1, 2, 3 )
"""
matches = TupleConverter().gather( parseSource( src ) )
assert matches[ 0 ].contents.toString() == "1, 2, 3"
def test_TupleGather_02():
src = """
l = ( 'a', ( 1, 2, 3 ), 'b' )
"""
matches = TupleConverter().gather( parseSource( src ) )
assert matches[ 0 ].contents.toString() == "'a', ( 1, 2, 3 ), 'b'"
assert matches[ 1 ].contents.toString() == "1, 2, 3"
def test_TupleGather_03():
src = """
( a, b, c ) = func( x, y, z )
"""
matches = TupleConverter().gather( parseSource( src ) )
assert matches[ 0 ].contents.toString() == "a, b, c"
assert len( matches ) == 1
def test_TupleProcess_01():
src = """
l = ( 1, 2, 3 )
"""
nodes = parseSource( src )
cvtr = TupleConverter()
matches = cvtr.gather( nodes )
cvtr.processAll( matches )
assert nodesToLines( nodes ) == [
"l = [ 1, 2, 3 ]",
]
def test_TupleProcess_02():
src = """
l = ( 'a', ( 1, 2, 3 ), 'b' )
"""
nodes = parseSource( src )
cvtr = TupleConverter()
matches = cvtr.gather( nodes )
cvtr.processAll( matches )
assert nodesToLines( nodes ) == [
"l = [ 'a', [ 1, 2, 3 ], 'b' ]",
]
def test_TupleProcess_03():
src = """
( a, b, c ) = func( x, y, z )
"""
nodes = parseSource( src )
cvtr = TupleConverter()
matches = cvtr.gather( nodes )
cvtr.processAll( matches )
assert nodesToLines( nodes ) == [
"[ a, b, c ] = func( x, y, z )",
]
| 24.594203 | 79 | 0.529169 | 191 | 1,697 | 4.638743 | 0.204188 | 0.020316 | 0.030474 | 0.018059 | 0.77088 | 0.755079 | 0.72912 | 0.717833 | 0.62754 | 0.593679 | 0 | 0.036882 | 0.296995 | 1,697 | 68 | 80 | 24.955882 | 0.705784 | 0 | 0 | 0.654545 | 0 | 0 | 0.2033 | 0 | 0 | 0 | 0 | 0 | 0.145455 | 1 | 0.109091 | false | 0 | 0.036364 | 0 | 0.145455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 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 | 3 |
f390104a9a5b3d0280b3c6731e11ac33ac8ee7d8 | 383 | py | Python | core/models.py | toy-program/friendship-test | cc1c7472964691d178d872fb7faf7aac2ef0b7ae | [
"MIT"
] | null | null | null | core/models.py | toy-program/friendship-test | cc1c7472964691d178d872fb7faf7aac2ef0b7ae | [
"MIT"
] | null | null | null | core/models.py | toy-program/friendship-test | cc1c7472964691d178d872fb7faf7aac2ef0b7ae | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
class Question(models.Model):
problem = models.CharField(max_length=100)
answer = models.CharField(max_length=100)
user = models.ForeignKey('User', on_delete=models.CASCADE, null=True)
class User(models.Model):
name = models.CharField(max_length=10)
friends_scoreboard = models.ManyToManyField('User')
| 25.533333 | 73 | 0.744125 | 50 | 383 | 5.6 | 0.58 | 0.160714 | 0.192857 | 0.257143 | 0.192857 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02439 | 0.143603 | 383 | 14 | 74 | 27.357143 | 0.829268 | 0.062663 | 0 | 0 | 0 | 0 | 0.022409 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 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 | 1 | 0 | 0 | 3 |
f3955ccc0197add1120c8b5c821e792262d2bed3 | 9,453 | py | Python | tonnikala/ir/nodes.py | tetframework/Tonnikala | d69e7c71d323221ad749082c4e653654bd63e819 | [
"Apache-2.0"
] | 13 | 2015-11-09T21:11:49.000Z | 2021-12-26T20:36:02.000Z | tonnikala/ir/nodes.py | tetframework/Tonnikala | d69e7c71d323221ad749082c4e653654bd63e819 | [
"Apache-2.0"
] | 3 | 2016-10-04T19:51:38.000Z | 2017-08-28T05:58:39.000Z | tonnikala/ir/nodes.py | tetframework/Tonnikala | d69e7c71d323221ad749082c4e653654bd63e819 | [
"Apache-2.0"
] | 3 | 2015-09-06T13:44:43.000Z | 2021-01-25T10:04:26.000Z | from tonnikala.helpers import escape
from collections import OrderedDict
import re
class BaseNode(object):
position = (None, None)
def __repr__(self):
return self.__class__.__name__ + '(%s)' % str(self)
def validate(self, validator):
pass
def get_children(self):
return []
class Text(BaseNode):
is_cdata = False
translatable = False
def __init__(self, text, is_cdata=False):
self.text = text
self.is_cdata = is_cdata
def __str__(self): # pragma: no cover
return self.text
def escaped(self):
if self.is_cdata:
return self.text
return escape(self.text)
class EmptyAttrVal(BaseNode):
is_cdata = False
translatable = False
def __init__(self):
pass
def __str__(self): # pragma: no cover
return "<empty>"
def escaped(self):
return ""
class TranslatableText(Text):
translatable = True
def __init__(self, text, is_cdata=False):
super(TranslatableText, self).__init__(text, is_cdata=is_cdata)
def __str__(self): # pragma: no cover
return '_t(%s)' % self.text
@property
def needs_escape(self):
return not self.is_cdata
def escaped(self):
if self.is_cdata:
return self.text
return escape(self.text)
def escape_comment(text):
if text.startswith('>'):
text = text.replace('>', '>', 1)
if text.endswith('-'):
text = text[:-1] + '-'
return text.replace('--', '--')
class Comment(BaseNode):
def __init__(self, text):
self.text = text
def escaped(self):
return escape_comment(self.text)
def __str__(self): # pragma: no cover
return self.text
class EscapedText(Text):
def __init__(self, string):
super(EscapedText, self).__init__(string)
def __str__(self): # pragma: no cover
return self.text
def escaped(self):
return self.text
class Expression(BaseNode):
is_cdata = False
def __init__(self, expression):
self.expression = expression
def __str__(self): # pragma: no cover
return self.expression
class Code(BaseNode):
is_cdata = False
def __init__(self, source):
self.source = source
def __str__(self): # pragma: no cover
return self.source
class InterpolatedExpression(Expression):
def __init__(self, full_string, expression):
super(InterpolatedExpression, self).__init__(expression)
self.string = full_string
class ContainerNode(BaseNode):
def __init__(self):
self.attributes = OrderedDict()
self.children = []
def add_child(self, child):
"""
Add a child to the tree. Subclasses may raise SyntaxError
"""
self.children.append(child)
def set_attribute(self, name, value):
self.attributes[name] = value
def __repr__(self):
return self.__class__.__name__ + '(%s)' % str(self)
def __str__(self): # pragma: no cover
return str(self.children)
def validate(self, validator):
for i in self.children:
i.validate(validator)
super(ContainerNode, self).validate(validator)
class Root(ContainerNode):
pass
class MutableAttribute(ContainerNode):
def __init__(self, name, value):
super(MutableAttribute, self).__init__()
self.name = name
self.value = value
self.children.append(value)
def __str__(self): # pragma: no cover
return str({self.name: self.value})
def get_children(self):
return self.children
class DynamicAttributes(BaseNode):
def __init__(self, expression):
super(DynamicAttributes, self).__init__()
self.expression = expression
def __str__(self): # pragma: no cover
return str(self.expression)
def get_children(self):
return [self.expression]
class DynamicText(ContainerNode):
def __init__(self):
super(DynamicText, self).__init__()
pass
def __str__(self): # pragma: no cover
return str(self.children)
class Element(ContainerNode):
def __init__(self, name, guard_expression=None):
super(Element, self).__init__()
self.name = name
self.guard_expression = guard_expression
self.constant_attributes = OrderedDict()
self.mutable_attributes = OrderedDict()
self.dynamic_attrs = None
def __str__(self): # pragma: no cover
attrs = str(self.attributes)
children = str(self.children)
return ', '.join([self.name, 'guard=%s' % self.guard_expression, attrs, children])
def get_guard_expression(self):
return self.guard_expression
def set_attribute(self, name, value):
if isinstance(value, (Text, EmptyAttrVal)) and not value.translatable:
self.constant_attributes[name] = value
else:
self.mutable_attributes[name] = value
self.attributes[name] = value
def set_dynamic_attrs(self, expression):
self.dynamic_attrs = expression
def get_constant_attributes(self):
return self.constant_attributes
def get_mutable_attributes(self):
return self.mutable_attributes
class For(ContainerNode):
IN_RE = re.compile('\s+in\s+')
def __init__(self, expression):
super(For, self).__init__()
self.expression = expression
self.parts = self.IN_RE.split(self.expression, 1)
def validate(self, validator):
if len(self.parts) != 2:
validator.syntax_error(
"for does not have proper format: var[, var...] in expression",
node=self)
super(For, self).validate(validator)
def __str__(self): # pragma: no cover
children = str(self.children)
return ', '.join([("(%s in %s)" % tuple(self.parts)), children])
class Define(ContainerNode):
def __init__(self, funcspec):
super(Define, self).__init__()
self.funcspec = funcspec
def __str__(self): # pragma: no cover
return ', '.join([self.funcspec, str(self.children)])
class Import(BaseNode):
def __init__(self, href, alias):
super(Import, self).__init__()
self.href = href
self.alias = alias
def __str__(self): # pragma: no cover
return ', '.join([self.href, self.alias])
class If(ContainerNode):
def __init__(self, expression):
super(If, self).__init__()
self.expression = expression
def __str__(self): # pragma: no cover
children = str(self.children)
return ', '.join([("(%s)" % self.expression), children])
class Unless(ContainerNode):
def __init__(self, expression):
super(Unless, self).__init__()
self.expression = expression
def __str__(self): # pragma: no cover
children = str(self.children)
return ', '.join([("(%s)" % self.expression), children])
class Block(ContainerNode):
def __init__(self, name):
super(Block, self).__init__()
self.name = name
def __str__(self): # pragma: no cover
children = str(self.children)
return "%s, %s" % (repr(self.name), children)
class With(ContainerNode):
def __init__(self, vars):
super(With, self).__init__()
self.vars = vars
def __str__(self): # pragma: no cover
children = str(self.children)
return "%s, %s" % (repr(self.vars), children)
class Extends(ContainerNode):
def __init__(self, href):
super(Extends, self).__init__()
self.href = href
def __str__(self): # pragma: no cover
children = str(self.children)
return ', '.join([("(%s)" % self.expression), children])
def add_child(self, child):
"""
Add a child to the tree. Extends discards all comments
and whitespace Text. On non-whitespace Text, and any
other nodes, raise a syntax error.
"""
if isinstance(child, Comment):
return
# ignore Text nodes with whitespace-only content
if isinstance(child, Text) and not child.text.strip():
return
super(Extends, self).add_child(child)
def validate(self, validator):
for child in self.children:
if isinstance(child, Text):
validator.syntax_error(
"No Text allowed within an Extends block", node=child)
if not isinstance(child, (Block, Define, Import)):
validator.syntax_error(
"Only nodes of type Block, Import or Define "
"allowed within an Extends block, not %s" %
child.__class__.__name__,
child
)
super(Extends, self).validate(validator)
class IRTree(object):
def __init__(self):
self.root = None
def add_child(self, root):
self.root = root
def get_root(self):
return self.root
def __str__(self): # pragma: no cover
return repr(self)
def __repr__(self):
return 'IRTree(%r)' % self.root
def __iter__(self):
stack = collections.deque()
stack.append(self.root)
while stack:
item = stack.popleft()
if hasattr(item, 'children'):
stack.extendleft(item.children or [])
yield item
| 24.681462 | 90 | 0.609965 | 1,074 | 9,453 | 5.064246 | 0.135009 | 0.046332 | 0.044493 | 0.061776 | 0.427284 | 0.35558 | 0.303181 | 0.266225 | 0.25262 | 0.206656 | 0 | 0.001468 | 0.279382 | 9,453 | 382 | 91 | 24.746073 | 0.796976 | 0.064001 | 0 | 0.416 | 0 | 0 | 0.03503 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.284 | false | 0.016 | 0.028 | 0.112 | 0.612 | 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 | 1 | 1 | 0 | 0 | 3 |
f39c8a118128dc44068482b4965bcc226d20016b | 82 | py | Python | bob/bio/face/config/annotator/facedetect.py | bioidiap/bob.bio.face | 2341e6423ca5a412ebe23fa18acacd69ea1ef914 | [
"BSD-3-Clause"
] | 4 | 2016-09-01T13:16:46.000Z | 2021-09-03T03:27:18.000Z | bob/bio/face/config/annotator/facedetect.py | bioidiap/bob.bio.face | 2341e6423ca5a412ebe23fa18acacd69ea1ef914 | [
"BSD-3-Clause"
] | 6 | 2015-09-02T19:31:15.000Z | 2016-10-10T21:48:39.000Z | bob/bio/face/config/annotator/facedetect.py | bioidiap/bob.bio.face | 2341e6423ca5a412ebe23fa18acacd69ea1ef914 | [
"BSD-3-Clause"
] | 6 | 2015-10-07T17:18:48.000Z | 2017-07-18T19:41:14.000Z | from bob.bio.face.annotator import BobIpFacedetect
annotator = BobIpFacedetect()
| 20.5 | 50 | 0.829268 | 9 | 82 | 7.555556 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.097561 | 82 | 3 | 51 | 27.333333 | 0.918919 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
f3a6d351f8c55e58f180d33294b744dd37af23a9 | 627 | py | Python | music_embedding/__init__.py | PooyaHekmati/music_embedding | 20072478c01dc2e433c1393298310213cf8745b6 | [
"MIT"
] | 19 | 2021-04-30T11:23:20.000Z | 2022-03-21T10:39:21.000Z | music_embedding/__init__.py | PooyaHekmati/music_embedding | 20072478c01dc2e433c1393298310213cf8745b6 | [
"MIT"
] | 1 | 2021-08-06T04:45:26.000Z | 2021-08-06T04:45:26.000Z | music_embedding/__init__.py | PooyaHekmati/music_embedding | 20072478c01dc2e433c1393298310213cf8745b6 | [
"MIT"
] | 3 | 2021-04-01T12:47:59.000Z | 2022-01-11T09:22:47.000Z | """A package for representing music data based on music theory.
Music Embedding is an open source python package for representing music data based on music theory. It provides tools to convert melodic and harmonic sequences to and from pianorolls.
Features
--------
- Representation for music intervals
- Create sequence of (harmonic or melodic) intervals from pianoroll presentation
- Create pianoroll from a sequence of (harmonic or melodic) intervals
- Break the sequence of intervals into smaller pieces e.g. bars
- Compress the sequence of intervals using Run Length Encoding (RLE)
"""
from . import interval, embedder | 41.8 | 183 | 0.791069 | 89 | 627 | 5.573034 | 0.58427 | 0.080645 | 0.08871 | 0.108871 | 0.342742 | 0.342742 | 0.197581 | 0.197581 | 0.197581 | 0 | 0 | 0 | 0.157895 | 627 | 15 | 184 | 41.8 | 0.939394 | 0.934609 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f3c3a1f851e226e2bf8b63b8fe8ebb4d55f870dc | 133 | py | Python | tests/test_import_numpy_ROOT.py | pyhf/pyhf-validation-root-base | 337803ae55ab42ecc12dd57436c3afaeb0dec46a | [
"Apache-2.0"
] | 1 | 2020-03-06T16:16:23.000Z | 2020-03-06T16:16:23.000Z | tests/test_import_numpy_ROOT.py | pyhf/pyhf-validation-root-base | 337803ae55ab42ecc12dd57436c3afaeb0dec46a | [
"Apache-2.0"
] | 6 | 2020-03-05T01:09:04.000Z | 2020-04-10T23:09:37.000Z | tests/test_import_numpy_ROOT.py | pyhf/pyhf-validation-root-base | 337803ae55ab42ecc12dd57436c3afaeb0dec46a | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python3
import numpy as np
import ROOT
def main():
print(np.arange(10))
if __name__ == "__main__":
main()
| 11.083333 | 26 | 0.639098 | 20 | 133 | 3.85 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028571 | 0.210526 | 133 | 11 | 27 | 12.090909 | 0.704762 | 0.157895 | 0 | 0 | 0 | 0 | 0.072072 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | true | 0 | 0.333333 | 0 | 0.5 | 0.166667 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
45fa3127d737e1ffe2beb711c2f053bda8b2e9f8 | 299 | py | Python | blatann/gap/__init__.py | eriknyquist/blatann | 0c895e3a85a295047b0bdc5c142eb42ed8e36132 | [
"BSD-3-Clause"
] | 1 | 2019-06-17T01:12:31.000Z | 2019-06-17T01:12:31.000Z | blatann/gap/__init__.py | eriknyquist/blatann | 0c895e3a85a295047b0bdc5c142eb42ed8e36132 | [
"BSD-3-Clause"
] | null | null | null | blatann/gap/__init__.py | eriknyquist/blatann | 0c895e3a85a295047b0bdc5c142eb42ed8e36132 | [
"BSD-3-Clause"
] | null | null | null | from blatann.nrf.nrf_types import BLEHci as _BLEHci
from blatann.gap.smp import SecurityStatus, IoCapabilities, AuthenticationKeyType, SecurityParameters
from blatann.gap.scanning import ScanParameters
from blatann.gap.advertising import AdvertisingData, AdvertisingFlags
HciStatus = _BLEHci
| 42.714286 | 102 | 0.849498 | 33 | 299 | 7.606061 | 0.575758 | 0.175299 | 0.167331 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.107023 | 299 | 6 | 103 | 49.833333 | 0.940075 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.8 | 0 | 0.8 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
45fbcd12768b4017b52a65ed7d7eb9573bb839aa | 4,744 | py | Python | janrain/tests/test_api.py | coxmediagroup/django-janrain | 5b503edaf3e9eb467946712844766b65c3f750d5 | [
"MIT"
] | null | null | null | janrain/tests/test_api.py | coxmediagroup/django-janrain | 5b503edaf3e9eb467946712844766b65c3f750d5 | [
"MIT"
] | null | null | null | janrain/tests/test_api.py | coxmediagroup/django-janrain | 5b503edaf3e9eb467946712844766b65c3f750d5 | [
"MIT"
] | null | null | null | import json
import mock
from unittest2 import TestCase
from janrain.api import JanrainClient
class MockRequestsJsonResponse(object):
def __init__(self, data):
self.content = json.dumps(data)
class TestAPI(TestCase):
def setUp(self):
self.client = JanrainClient(client_id=1, client_secret=2, api_url='test_endpoint')
self.reqs = mock.Mock()
def test__make_request_get(self):
self.reqs.get = mock.Mock(return_value=MockRequestsJsonResponse(dict(hello='there')))
with mock.patch('janrain.api.requests', self.reqs):
response = self.client._make_request('path')
self.assertEqual(len(response.keys()), 1, 'got back our json')
self.assertEqual(response['hello'], 'there', 'got back our json')
def test__make_request_get_args(self):
self.reqs.get = mock.Mock(return_value=MockRequestsJsonResponse(dict(hello='there')))
with mock.patch('janrain.api.requests', self.reqs):
self.client._make_request('path', data=dict(ohno='youdidnt'))
self.reqs.get.assert_called_with('path', headers=dict(), params=dict(ohno='youdidnt'))
def test__make_request_post(self):
self.reqs.post = mock.Mock(return_value=MockRequestsJsonResponse(dict(you='guys')))
with mock.patch('janrain.api.requests', self.reqs):
response = self.client._make_request('path', method='post')
self.assertEqual(len(response.keys()), 1, 'got back our json')
self.assertEqual(response['you'], 'guys', 'got back our json')
def test__make_request_post_args(self):
self.reqs.post = mock.Mock(return_value=MockRequestsJsonResponse(dict(you='guys')))
with mock.patch('janrain.api.requests', self.reqs):
self.client._make_request('path', method='post', data=dict(ohno='youdidnt'))
self.reqs.post.assert_called_with('path', headers=dict(), data=dict(ohno='youdidnt'))
def test__make_request_bad_method(self):
self.assertRaises(ValueError, self.client._make_request, 'path', method='foobarbaz')
def test__make_request_headers(self):
self.reqs.post = mock.Mock(return_value=MockRequestsJsonResponse(dict(you='guys')))
with mock.patch('janrain.api.requests', self.reqs):
self.client._make_request('path', method='post', headers=dict(Authorization="oauth"), data=dict(ohno='youdidnt'))
self.reqs.post.assert_called_with('path', headers=dict(Authorization="oauth"), data=dict(ohno='youdidnt'))
def test_clients_add_no_features(self):
self.reqs.post = mock.Mock(return_value=MockRequestsJsonResponse(dict(hello='there')))
with mock.patch('janrain.api.requests', self.reqs):
resp = self.client.clients_add('description')
self.assertEqual(resp['hello'], 'there', 'got back our json')
self.reqs.post.assert_called_with('clients/add', headers={}, data=dict(
client_id=1,
client_secret=2,
description='description'
))
def test_clients_add_with_features(self):
self.reqs.post = mock.Mock(return_value=MockRequestsJsonResponse(dict(hello='there')))
with mock.patch('janrain.api.requests', self.reqs):
resp = self.client.clients_add('description', ["feature"])
self.assertEqual(resp['hello'], 'there', 'got back our json')
self.reqs.post.assert_called_with('clients/add', headers={}, data=dict(
client_id=1,
client_secret=2,
features='["feature"]',
description='description'
))
def test_settings_set_multi(self):
self.reqs.post = mock.Mock(return_value=MockRequestsJsonResponse(dict(hello='there')))
with mock.patch('janrain.api.requests', self.reqs):
resp = self.client.settings_set_multi('for_client_id', {'setting': 'value'})
self.assertEqual(resp['hello'], 'there', 'got back our json')
self.reqs.post.assert_called_with('settings/set_multi', headers={}, data=dict(
client_id=1,
client_secret=2,
for_client_id='for_client_id',
items='{"setting": "value"}',
))
def test_clients_list(self):
self.reqs.get = mock.Mock(return_value=MockRequestsJsonResponse(dict(hello='there')))
with mock.patch('janrain.api.requests', self.reqs):
resp = self.client.clients_list()
self.assertEqual(resp['hello'], 'there', 'got back our json')
self.reqs.get.assert_called_with('clients/list', headers={}, params=dict(
client_id=1,
client_secret=2,
))
| 48.408163 | 125 | 0.644815 | 570 | 4,744 | 5.185965 | 0.138596 | 0.070365 | 0.044655 | 0.057848 | 0.797361 | 0.786536 | 0.7341 | 0.698917 | 0.654601 | 0.642084 | 0 | 0.003483 | 0.213322 | 4,744 | 97 | 126 | 48.907216 | 0.788585 | 0 | 0 | 0.493827 | 0 | 0 | 0.150717 | 0 | 0 | 0 | 0 | 0 | 0.197531 | 1 | 0.148148 | false | 0 | 0.049383 | 0 | 0.222222 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
34023e2ed6d04a37b882b38aa004e82ad1f0ed29 | 654 | py | Python | dfs/edge.py | GeorgEncinas/backtraking | 2f5dea16bb8ec4ccd951101d5a69d64d93f1e941 | [
"MIT"
] | null | null | null | dfs/edge.py | GeorgEncinas/backtraking | 2f5dea16bb8ec4ccd951101d5a69d64d93f1e941 | [
"MIT"
] | null | null | null | dfs/edge.py | GeorgEncinas/backtraking | 2f5dea16bb8ec4ccd951101d5a69d64d93f1e941 | [
"MIT"
] | null | null | null | from vertex import Vertex
class Edge(object):
def __init__(self, vertex_1, vertex_2, direction):
self.weigth = 0
#direction of vertex1 to vertex2
self.direction = direction
self.v1 = vertex_1
self.v2 = vertex_2
def get_vertexs(self):
return [self.v1, self.v2]
def get_weigth(self):
return self.weigth
def set_weigth(self, weigth_1):
self.weigth = weigth_1
def __str__(self):
return str(self.__dict__)
def __eq__(self, other):
answer = None
if other is not None:
answer = self.__dict__ == other.__dict__
return answer | 24.222222 | 54 | 0.610092 | 85 | 654 | 4.305882 | 0.388235 | 0.10929 | 0.076503 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028761 | 0.308869 | 654 | 27 | 55 | 24.222222 | 0.780973 | 0.047401 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.05 | 0.15 | 0.6 | 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 | 1 | 1 | 0 | 0 | 3 |
340a434eed8890d10141172cd6c3d40525b37843 | 215 | py | Python | video/serializers.py | scintiller/OnlineJudge | 4e66da0e366c8b950a1ccae2b435b81d9fe07e6c | [
"MIT"
] | null | null | null | video/serializers.py | scintiller/OnlineJudge | 4e66da0e366c8b950a1ccae2b435b81d9fe07e6c | [
"MIT"
] | 6 | 2020-06-05T21:37:42.000Z | 2022-01-13T01:19:55.000Z | video/serializers.py | scintiller/OnlineJudge | 4e66da0e366c8b950a1ccae2b435b81d9fe07e6c | [
"MIT"
] | null | null | null | from rest_framework import serializers
from .models import ProblemSolution
class ProblemSolutionSerializer(serializers.ModelSerializer):
class Meta():
model = ProblemSolution
fields = "__all__" | 30.714286 | 61 | 0.762791 | 19 | 215 | 8.368421 | 0.736842 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.181395 | 215 | 7 | 62 | 30.714286 | 0.903409 | 0 | 0 | 0 | 0 | 0 | 0.032407 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
341170887e1f57b81808360bd72477a33ad94126 | 147 | py | Python | codility/lesson-1/BinaryGap.py | juseongkr/BOJ | 8f10a2bf9a7d695455493fbe7423347a8b648416 | [
"Apache-2.0"
] | 7 | 2020-02-03T10:00:19.000Z | 2021-11-16T11:03:57.000Z | codility/lesson-1/BinaryGap.py | juseongkr/Algorithm-training | 8f10a2bf9a7d695455493fbe7423347a8b648416 | [
"Apache-2.0"
] | 1 | 2021-01-03T06:58:24.000Z | 2021-01-03T06:58:24.000Z | codility/lesson-1/BinaryGap.py | juseongkr/Algorithm-training | 8f10a2bf9a7d695455493fbe7423347a8b648416 | [
"Apache-2.0"
] | 1 | 2020-01-22T14:34:03.000Z | 2020-01-22T14:34:03.000Z | def solution(N):
num = bin(N)[2:].split('1')
if len(num[1:-1]) == 0:
return 0
return len(max(num[1:-1], key=lambda x: len(x)))
| 24.5 | 52 | 0.510204 | 28 | 147 | 2.678571 | 0.571429 | 0.106667 | 0.133333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.072072 | 0.244898 | 147 | 5 | 53 | 29.4 | 0.603604 | 0 | 0 | 0 | 0 | 0 | 0.006803 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0 | 0 | 0.6 | 0 | 1 | 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 | 1 | 0 | 0 | 3 |
34313dabea78d42f187f2d19990f3f3b293bb22b | 38 | py | Python | aaa.py | usha324/python | 7aa967b8dac8cd0c466652db448cb7e405821389 | [
"bzip2-1.0.6"
] | null | null | null | aaa.py | usha324/python | 7aa967b8dac8cd0c466652db448cb7e405821389 | [
"bzip2-1.0.6"
] | null | null | null | aaa.py | usha324/python | 7aa967b8dac8cd0c466652db448cb7e405821389 | [
"bzip2-1.0.6"
] | null | null | null | word = 'Python'
word[0] = 'M'
| 7.6 | 16 | 0.421053 | 5 | 38 | 3.2 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.041667 | 0.368421 | 38 | 4 | 17 | 9.5 | 0.625 | 0 | 0 | 0 | 0 | 0 | 0.205882 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
3440ec3258242e2629476c1e466d6ef210d7804a | 4,284 | py | Python | S4/S4 Library/simulation/situations/complex/single_sim_visitor_situation.py | NeonOcean/Environment | ca658cf66e8fd6866c22a4a0136d415705b36d26 | [
"CC-BY-4.0"
] | 1 | 2021-05-20T19:33:37.000Z | 2021-05-20T19:33:37.000Z | S4/S4 Library/simulation/situations/complex/single_sim_visitor_situation.py | NeonOcean/Environment | ca658cf66e8fd6866c22a4a0136d415705b36d26 | [
"CC-BY-4.0"
] | null | null | null | S4/S4 Library/simulation/situations/complex/single_sim_visitor_situation.py | NeonOcean/Environment | ca658cf66e8fd6866c22a4a0136d415705b36d26 | [
"CC-BY-4.0"
] | null | null | null | from sims4.tuning.instances import lock_instance_tunables
from sims4.tuning.tunable import Tunable
from sims4.utils import classproperty
from situations.ambient.walkby_limiting_tags_mixin import WalkbyLimitingTagsMixin
from situations.bouncer.bouncer_types import BouncerExclusivityCategory
from situations.situation import Situation
from situations.situation_complex import CommonInteractionCompletedSituationState, SituationState, SituationComplexCommon, TunableSituationJobAndRoleState, SituationStateData, CommonSituationState
from situations.situation_types import SituationCreationUIOption
import services
import situations
class _HasFrontDoorArrivalState(CommonInteractionCompletedSituationState):
def _on_interaction_of_interest_complete(self, **kwargs):
self._change_state(self.owner.visit_state())
def timer_expired(self):
self._change_state(self.owner.visit_state())
class _HasNoFrontDoorArrivalState(CommonInteractionCompletedSituationState):
def _on_interaction_of_interest_complete(self, **kwargs):
self._change_state(self.owner.visit_state())
def timer_expired(self):
self._change_state(self.owner.visit_state())
class _VisitState(CommonInteractionCompletedSituationState):
def _on_interaction_of_interest_complete(self, **kwargs):
self._change_state(self.owner.leave_state())
def timer_expired(self):
self._change_state(self.owner.leave_state())
class _LeaveState(CommonSituationState):
def timer_expired(self):
self.owner._self_destruct()
class SingleSimVisitorSituation(WalkbyLimitingTagsMixin, SituationComplexCommon):
INSTANCE_TUNABLES = {'visitor_job_and_role': TunableSituationJobAndRoleState(description='\n The job and role state for the visitor.\n '), 'has_front_door_arrival_state': _HasFrontDoorArrivalState.TunableFactory(description='\n The arrival state for the visitor if the lot has a front door.\n ', display_name='1. Has Front Door Arrival State', tuning_group=SituationComplexCommon.SITUATION_STATE_GROUP), 'has_no_front_door_arrival_state': _HasNoFrontDoorArrivalState.TunableFactory(description='\n The arrival state for the visitor if the lot has a front door.\n ', display_name='1. Has No Front Door Arrival State', tuning_group=SituationComplexCommon.SITUATION_STATE_GROUP), 'visit_state': _VisitState.TunableFactory(description="\n The state for the visitor to interact with the lot and it's owner.\n ", display_name='2. Visit State', tuning_group=SituationComplexCommon.SITUATION_STATE_GROUP), 'leave_state': _LeaveState.TunableFactory(description='\n The state for the visitor to leave the lot.\n ', display_name='3. Leave State', tuning_group=SituationComplexCommon.SITUATION_STATE_GROUP)}
REMOVE_INSTANCE_TUNABLES = Situation.NON_USER_FACING_REMOVE_INSTANCE_TUNABLES
@classmethod
def _states(cls):
return (SituationStateData(1, _HasFrontDoorArrivalState, factory=cls.has_front_door_arrival_state), SituationStateData(2, _HasNoFrontDoorArrivalState, factory=cls.has_no_front_door_arrival_state), SituationStateData(3, _VisitState, factory=cls.visit_state), SituationStateData(4, _LeaveState, factory=cls.leave_state))
@classmethod
def _get_tuned_job_and_default_role_state_tuples(cls):
return [(cls.visitor_job_and_role.job, cls.visitor_job_and_role.role_state)]
@classmethod
def default_job(cls):
pass
def start_situation(self):
super().start_situation()
if services.get_door_service().has_front_door():
self._change_state(self.has_front_door_arrival_state())
else:
self._change_state(self.has_no_front_door_arrival_state())
@classmethod
def get_sims_expected_to_be_in_situation(cls):
return 1
@property
def _should_cancel_leave_interaction_on_premature_removal(self):
return True
@classproperty
def situation_serialization_option(cls):
return situations.situation_types.SituationSerializationOption.OPEN_STREETS
lock_instance_tunables(SingleSimVisitorSituation, exclusivity=BouncerExclusivityCategory.WALKBY, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE) | 56.368421 | 1,209 | 0.788282 | 482 | 4,284 | 6.661826 | 0.248963 | 0.030832 | 0.037372 | 0.047337 | 0.421053 | 0.355964 | 0.33105 | 0.290875 | 0.290875 | 0.260355 | 0 | 0.003254 | 0.139122 | 4,284 | 76 | 1,210 | 56.368421 | 0.867408 | 0 | 0 | 0.303571 | 0 | 0 | 0.141424 | 0.013769 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.017857 | 0.178571 | 0.089286 | 0.642857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
3457c685773603b079cdd7a7826050e8d8fd8839 | 253 | py | Python | brain_games/scripts/brain_progression.py | AABur/python-pip-how-to | 96d7f24a1730d7f4cad5de3fc5ed2265df6cfa62 | [
"MIT"
] | null | null | null | brain_games/scripts/brain_progression.py | AABur/python-pip-how-to | 96d7f24a1730d7f4cad5de3fc5ed2265df6cfa62 | [
"MIT"
] | null | null | null | brain_games/scripts/brain_progression.py | AABur/python-pip-how-to | 96d7f24a1730d7f4cad5de3fc5ed2265df6cfa62 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
"""Progression game script."""
from brain_games.engine import run_game
from brain_games.games import progression
def main():
"""Progression game script."""
run_game(progression)
if __name__ == "__main__":
main()
| 15.8125 | 41 | 0.703557 | 32 | 253 | 5.1875 | 0.53125 | 0.180723 | 0.253012 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004739 | 0.166008 | 253 | 15 | 42 | 16.866667 | 0.781991 | 0.280632 | 0 | 0 | 0 | 0 | 0.046784 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | true | 0 | 0.333333 | 0 | 0.5 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
34620db067d38b53c0d5b852dcac2f249a56fc11 | 1,116 | py | Python | twelve_step/find_imported_packages/find_imported_packages.py | OLBEA20/twelve-step | ed4747fdee6dba7518f048b5dc4b520a3ba202df | [
"MIT"
] | 1 | 2021-08-10T05:35:08.000Z | 2021-08-10T05:35:08.000Z | twelve_step/find_imported_packages/find_imported_packages.py | OLBEA20/twelve-step | ed4747fdee6dba7518f048b5dc4b520a3ba202df | [
"MIT"
] | 1 | 2021-12-20T00:17:06.000Z | 2021-12-20T00:17:06.000Z | twelve_step/find_imported_packages/find_imported_packages.py | OLBEA20/twelve-step | ed4747fdee6dba7518f048b5dc4b520a3ba202df | [
"MIT"
] | null | null | null | from os.path import basename
from typing import List, Tuple
from jivago_streams import Stream
from twelve_step.constants import IMPORT_KEYWORD, FROM_KEYWORD
def find_imported_packages_in_imports(
file: str, imports: List[str]
) -> Tuple[str, List[str]]:
packages = (
Stream(imports)
.map(_keep_only_packages_portion_of_import_line)
.map(_extract_package)
.toList()
)
return (file, packages)
def _keep_only_packages_portion_of_import_line(import_line: str) -> str:
return import_line[
_from_keyword_location_in_line(import_line) : _import_location_in_line(
import_line
)
]
def _import_location_in_line(import_line: str) -> int:
return import_line.index(IMPORT_KEYWORD)
def _from_keyword_location_in_line(import_line: str) -> int:
return import_line.index(FROM_KEYWORD) + len(FROM_KEYWORD)
def _extract_package(from_package: str) -> str:
packages = [
package.replace(" ", "") for package in from_package.split(".") if package != ""
]
return packages[-2] if len(packages) > 1 else packages[-1]
| 25.953488 | 88 | 0.706989 | 147 | 1,116 | 4.979592 | 0.29932 | 0.136612 | 0.095628 | 0.10929 | 0.346995 | 0.346995 | 0.297814 | 0.139344 | 0.139344 | 0.139344 | 0 | 0.003352 | 0.198029 | 1,116 | 42 | 89 | 26.571429 | 0.814525 | 0 | 0 | 0 | 0 | 0 | 0.001792 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.172414 | false | 0 | 0.551724 | 0.103448 | 0.896552 | 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 | 1 | 1 | 0 | 0 | 3 |
346b7b4fb7bd3c2bbec78f5ec34d835ede061385 | 1,307 | py | Python | Codility/divisibility.py | Haroldgm/Python | ab0ae9c69e8b39882468529b73d24952b8725cd1 | [
"MIT"
] | null | null | null | Codility/divisibility.py | Haroldgm/Python | ab0ae9c69e8b39882468529b73d24952b8725cd1 | [
"MIT"
] | null | null | null | Codility/divisibility.py | Haroldgm/Python | ab0ae9c69e8b39882468529b73d24952b8725cd1 | [
"MIT"
] | null | null | null | #Exam
def solution(N):
if (N > 0) and (N < 1000): #Assume that N is an integer within 1 to 1000
list_of_coded_numbers = [] #List will contain the coded numbers in descending order
while N > 0:
if (N % 2 == 0) and (N % 3 == 0) and (N % 5 == 0):
list_of_coded_numbers.append("CodilityTestCoders")
elif (N % 3 == 0) and (N % 5 == 0):
list_of_coded_numbers.append("TestCoders")
elif (N % 2 == 0) and (N % 5 == 0):
list_of_coded_numbers.append("CodilityCoders")
elif (N % 2 == 0) and (N % 3 == 0):
list_of_coded_numbers.append("CodilityTest")
elif (N % 5 == 0):
list_of_coded_numbers.append("Coders")
elif (N % 3 == 0):
list_of_coded_numbers.append("Test")
elif (N % 2 == 0):
list_of_coded_numbers.append("Codility")
else:
list_of_coded_numbers.append(N)
N -= 1
list_of_coded_numbers.reverse() #Arrange the coded numbers in ascending order
for coded_number in list_of_coded_numbers:# Print the coded numbers in each line
print(coded_number)
if __name__ == '__main__':
solution(110) | 34.394737 | 91 | 0.527927 | 170 | 1,307 | 3.805882 | 0.3 | 0.25966 | 0.187017 | 0.306028 | 0.384853 | 0.347759 | 0.293663 | 0.275116 | 0.149923 | 0.149923 | 0 | 0.046931 | 0.364193 | 1,307 | 38 | 92 | 34.394737 | 0.731649 | 0.14078 | 0 | 0 | 0 | 0 | 0.071492 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.038462 | false | 0 | 0 | 0 | 0.038462 | 0.038462 | 0 | 0 | 0 | null | 1 | 1 | 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 | 3 |
caa1521810f543ac08c2ae927d6f06bacc19214d | 102 | py | Python | quiz1/ImportTest.py | sowmyamanojna/BT3051-Data-Structures-and-Algorithms | 09c17e42c2e173a6ab10339f08fbc1505db8ea56 | [
"MIT"
] | 1 | 2021-05-13T13:10:42.000Z | 2021-05-13T13:10:42.000Z | quiz1/ImportTest.py | sowmyamanojna/BT3051-Data-Structures-and-Algorithms | 09c17e42c2e173a6ab10339f08fbc1505db8ea56 | [
"MIT"
] | null | null | null | quiz1/ImportTest.py | sowmyamanojna/BT3051-Data-Structures-and-Algorithms | 09c17e42c2e173a6ab10339f08fbc1505db8ea56 | [
"MIT"
] | null | null | null | from ComplexNumberFile import ComplexNumber
print(__name__)
z1 = ComplexNumber(1, 2)
print()
print(z1) | 20.4 | 43 | 0.803922 | 13 | 102 | 6 | 0.692308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043478 | 0.098039 | 102 | 5 | 44 | 20.4 | 0.804348 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0.6 | 1 | 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 | 1 | 0 | 3 |
caa548a98dcbf4564d043b7b06ab190a2cc7c885 | 17,292 | py | Python | tests/modules/directory_search/test_directory_search.py | rlin0/donut | 5672df8e853b4b775d7d50665128b255cd695ec2 | [
"MIT"
] | null | null | null | tests/modules/directory_search/test_directory_search.py | rlin0/donut | 5672df8e853b4b775d7d50665128b255cd695ec2 | [
"MIT"
] | null | null | null | tests/modules/directory_search/test_directory_search.py | rlin0/donut | 5672df8e853b4b775d7d50665128b255cd695ec2 | [
"MIT"
] | null | null | null | """
Tests donut/modules/directory_search/
"""
from datetime import date
import flask
import pytest
from donut.testing.fixtures import client
from donut import app
import donut.modules.core.helpers as core_helpers
from donut.modules.directory_search import helpers
from donut.modules.directory_search import routes
#Helpers
def test_hidden_fields(client):
user_id = helpers.get_user_id('csander')
assert not helpers.get_hidden_fields('csander', user_id)
#dqu should see all fields via admin priviledges
assert not helpers.get_hidden_fields('dqu', user_id)
assert helpers.get_hidden_fields('dtardif', user_id)
assert helpers.get_hidden_fields(None, user_id)
def test_get_user(client):
user_data = helpers.get_user(helpers.get_user_id('csander'))
assert user_data == {
'address':
None,
'birthday':
date(1999, 5, 8),
'building_name':
'Ruddock House',
'city':
'Lincoln',
'country':
None,
'email':
'csander@caltech.edu',
'entry_year':
2017,
'first_name':
'Caleb',
'gender':
0,
'gender_custom':
'Male',
'gender_string':
'Male',
'graduation_year':
2021,
'hometown_string':
'Lincoln, MA',
'houses': [{
'group_name': 'Ruddock House',
'pos_name': 'Full Member'
}],
'image':
1,
'last_name':
'Sander',
'middle_name':
'Caldwell',
'msc':
707,
'options': [{
'option_name': 'CS',
'option_type': 'Major'
}, {
'option_name': 'MechE',
'option_type': 'Minor'
}],
'phone':
'6178003347',
'phone_string':
'(617) 800-3347',
'positions': (),
'preferred_name':
'Cleb',
'room':
'203',
'state':
'MA',
'uid':
'2078141',
'username':
'csander',
'zip':
None,
'timezone':
None
}
user_data2 = helpers.get_user(helpers.get_user_id('dqu'))
assert user_data2['image'] == 0
assert 'gender_string' not in user_data2
assert not user_data2['hometown_string']
assert 'phone_string' not in user_data2
user_data3 = helpers.get_user(helpers.get_user_id('reng'))
assert user_data3['phone_string'] == '+11234567890'
assert helpers.get_user(0) is None
def test_name_query(client):
assert helpers.get_users_by_name_query('ng') == [{
'full_name':
'Robert Eng',
'user_id':
2,
'graduation_year':
None
}]
assert helpers.get_users_by_name_query('eb cl san r') == [{
'full_name':
'Cleb Sander',
'user_id':
3,
'graduation_year':
2021
}]
assert helpers.get_users_by_name_query('x') == ()
def test_image(client):
user_id = helpers.get_user_id('csander')
assert helpers.get_image(user_id) == ('png', b'NOT_A_REAL_IMAGE')
core_helpers.set_image(user_id, 'jpg', 'FAKE_JPG')
assert helpers.get_image(user_id) == ('jpg', b'FAKE_JPG')
with pytest.raises(Exception):
helpers.get_image(helpers.get_user_id('dqu'))
def test_search(client):
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set([1, 2, 3])
assert set(user['user_id']
for user in helpers.execute_search(
email='san',
username='',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set([3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='noone',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set()
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='q',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set([1])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='noone',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set()
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name='ER',
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set([2, 3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name='abc',
house_id=None,
option_id=None,
building_id=None,
grad_year=None)) == set()
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=2,
option_id=None,
building_id=None,
grad_year=None)) == set([3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=100,
option_id=None,
building_id=None,
grad_year=None)) == set()
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=1,
building_id=None,
grad_year=None)) == set([3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=2,
building_id=None,
grad_year=None)) == set([3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=100,
building_id=None,
grad_year=None)) == set()
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=None,
building_id=1,
grad_year=None)) == set([3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=None,
building_id=10,
grad_year=None)) == set()
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=2021)) == set([3])
assert set(user['user_id']
for user in helpers.execute_search(
email='',
username='',
name=None,
house_id=None,
option_id=None,
building_id=None,
grad_year=2020)) == set()
def test_value_lists(client):
assert helpers.get_houses() == [{
'group_id': 2,
'group_name': 'Ruddock House'
}]
assert helpers.get_options() == [{
'option_id': 1,
'option_name': 'CS'
}, {
'option_id': 2,
'option_name': 'MechE'
}]
assert helpers.get_grad_years() == [2021]
def test_preferred_name(client):
user_id = helpers.get_user_id('csander')
assert core_helpers.get_preferred_name(user_id) == 'Cleb'
core_helpers.set_member_field(user_id, 'preferred_name', 'Belac')
assert core_helpers.get_preferred_name(user_id) == 'Belac'
assert core_helpers.get_preferred_name(helpers.get_user_id('reng')) == ''
def test_gender(client):
user_id = helpers.get_user_id('csander')
assert core_helpers.get_gender(user_id) == 'Male'
core_helpers.set_member_field(user_id, 'gender_custom', 'new_gender')
assert core_helpers.get_gender(user_id) == 'new_gender'
assert core_helpers.get_gender(helpers.get_user_id('dqu')) == ''
#Routes
def test_search_page(client):
assert client.get(
flask.url_for('directory_search.directory_search')).status_code == 200
def test_my_page(client):
with client.session_transaction() as sess:
sess['username'] = 'csander'
res = client.get(flask.url_for('core.my_directory_page'))
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
def test_view_user(client):
assert client.get(flask.url_for('directory_search.view_user',
user_id=3)).status_code == 200
assert client.get(
flask.url_for('directory_search.view_user',
user_id=100)).status_code == 200
def test_edit_page(client):
with client.session_transaction() as sess:
sess['username'] = 'csander'
assert client.get(flask.url_for('core.edit_user')).status_code == 200
def test_set_name(client):
with client.session_transaction() as sess:
sess['username'] = 'csander'
assert helpers.get_user(3)['preferred_name'] == 'Belac'
res = client.post(flask.url_for('core.set_name'), data={'name': 'Clb'})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
assert helpers.get_user(3)['preferred_name'] == 'Clb'
def test_set_name(client):
with client.session_transaction() as sess:
sess['username'] = 'csander'
assert helpers.get_user(3)['gender_string'] == 'new_gender'
res = client.post(
flask.url_for('core.set_gender'), data={'gender': 'Male'})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
assert helpers.get_user(3)['gender_string'] == 'Male'
def test_get_image(client):
assert client.get(flask.url_for('directory_search.get_image',
user_id=3)).status_code == 200
with pytest.raises(Exception):
client.get(flask.url_for('directory_search.get_image', user_id=1))
def test_name_search(client):
assert client.get(
flask.url_for('directory_search.search_by_name',
name_query='sander')).status_code == 200
def test_search(client):
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 200 #3 results
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': 'san',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '2',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '100',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 200 #no results
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '1',
'building_id': '',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '100',
'building_id': '',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 200 #no results
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '1',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '100',
'grad_year': '',
'username': '',
'email': ''
})
assert res.status_code == 200 #no results
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '2021',
'username': '',
'email': ''
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=3)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '2019',
'username': '',
'email': ''
})
assert res.status_code == 200 #no results
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': 'qu',
'email': ''
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=1)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': 'abc',
'email': ''
})
assert res.status_code == 200 #no results
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': '',
'email': 'reng'
})
assert res.status_code == 302
assert res.headers['location'] == flask.url_for(
'directory_search.view_user', user_id=2)
res = client.post(
flask.url_for('directory_search.search'),
data={
'name': '',
'house_id': '',
'option_id': '',
'building_id': '',
'grad_year': '',
'username': '',
'email': 'xyz'
})
assert res.status_code == 200 #no results
| 31.044883 | 78 | 0.493639 | 1,783 | 17,292 | 4.52664 | 0.095906 | 0.043861 | 0.046339 | 0.07434 | 0.787263 | 0.762979 | 0.738446 | 0.662124 | 0.647256 | 0.623219 | 0 | 0.020632 | 0.372137 | 17,292 | 556 | 79 | 31.100719 | 0.72276 | 0.009658 | 0 | 0.678295 | 0 | 0 | 0.167115 | 0.045125 | 0 | 0 | 0 | 0 | 0.151163 | 1 | 0.032946 | false | 0 | 0.015504 | 0 | 0.04845 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 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 | 3 |
cac4164d75fed7a958810bdf835052472d59a8ef | 169 | py | Python | files/exercises/command-line-programs-changing-flags.py | mforneris/introduction_to_python_course | 8075973ee89a921a5e2693f649adbf1fc0e0b2cb | [
"CC-BY-4.0"
] | null | null | null | files/exercises/command-line-programs-changing-flags.py | mforneris/introduction_to_python_course | 8075973ee89a921a5e2693f649adbf1fc0e0b2cb | [
"CC-BY-4.0"
] | null | null | null | files/exercises/command-line-programs-changing-flags.py | mforneris/introduction_to_python_course | 8075973ee89a921a5e2693f649adbf1fc0e0b2cb | [
"CC-BY-4.0"
] | 1 | 2020-01-09T10:58:56.000Z | 2020-01-09T10:58:56.000Z |
# Rewrite readings.py so that it uses -n, -m, and -x instead of --min, --mean, and --max respectively. Is the code easier to read? Is the program easier to understand?
| 56.333333 | 167 | 0.710059 | 30 | 169 | 4 | 0.833333 | 0.083333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.183432 | 169 | 2 | 168 | 84.5 | 0.869565 | 0.976331 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cac8dee4c737430df4486d19e00a81fbfc592b6e | 100 | py | Python | custom_components/airthings/const.py | siku2/hass-airthings | 6d39ad50bf4402eacdd8d43eadd629b39111a976 | [
"MIT"
] | 1 | 2020-06-21T02:29:06.000Z | 2020-06-21T02:29:06.000Z | custom_components/airthings/const.py | siku2/hass-airthings | 6d39ad50bf4402eacdd8d43eadd629b39111a976 | [
"MIT"
] | 2 | 2020-05-04T16:18:06.000Z | 2022-03-01T17:19:31.000Z | custom_components/airthings/const.py | siku2/hass-airthings | 6d39ad50bf4402eacdd8d43eadd629b39111a976 | [
"MIT"
] | null | null | null | DOMAIN = "airthings"
KEY_API = "api"
PLATFORMS = ("sensor",)
ERROR_LOGIN_FAILED = "login_failed"
| 12.5 | 35 | 0.7 | 12 | 100 | 5.5 | 0.75 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.15 | 100 | 7 | 36 | 14.285714 | 0.776471 | 0 | 0 | 0 | 0 | 0 | 0.3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 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 | 3 |
cae7d4435e64d6a012ead56c52698d559a724589 | 246 | py | Python | app/api/business/case_study_business.py | ArenaNetworks/dto-digitalmarketplace-api | d0d58924719d889503ed112b0d5801b528b0398c | [
"MIT"
] | 6 | 2017-06-09T03:38:53.000Z | 2021-12-22T02:42:15.000Z | app/api/business/case_study_business.py | ArenaNetworks/dto-digitalmarketplace-api | d0d58924719d889503ed112b0d5801b528b0398c | [
"MIT"
] | 47 | 2016-08-02T05:21:31.000Z | 2022-03-28T01:14:17.000Z | app/api/business/case_study_business.py | AusDTO/dto-digitalmarketplace-api | 937843c9c01a71518cf4688b4daa55bbe7df1965 | [
"MIT"
] | 7 | 2016-09-13T13:07:18.000Z | 2021-02-17T10:16:21.000Z | from app.api.services import (
case_study_service
)
def get_approved_case_studies(supplier_code, domain_id):
case_studies = case_study_service.get_approved_case_studies_by_supplier_code(supplier_code, domain_id)
return case_studies
| 27.333333 | 106 | 0.829268 | 36 | 246 | 5.138889 | 0.5 | 0.237838 | 0.172973 | 0.237838 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.117886 | 246 | 8 | 107 | 30.75 | 0.852535 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 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 | 3 |
1b01f88e54d9142d16a5e9684f22f66200702ab3 | 180 | py | Python | spycis/compat.py | marcwebbie/spycis | fa0cbad966ee0c10fbc0160048db35913f7dfe2a | [
"WTFPL",
"Unlicense"
] | 7 | 2015-10-24T07:06:15.000Z | 2017-03-25T18:44:20.000Z | spycis/compat.py | marcwebbie/spycis | fa0cbad966ee0c10fbc0160048db35913f7dfe2a | [
"WTFPL",
"Unlicense"
] | 2 | 2021-03-25T21:43:19.000Z | 2021-03-31T18:33:12.000Z | spycis/compat.py | marcwebbie/spycis | fa0cbad966ee0c10fbc0160048db35913f7dfe2a | [
"WTFPL",
"Unlicense"
] | null | null | null | import sys
if sys.version_info < (3,):
# fallback to python2
input = raw_input
str = unicode
try:
import StringIO
except ImportError:
from io import StringIO
| 15 | 27 | 0.677778 | 24 | 180 | 5 | 0.791667 | 0.233333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015038 | 0.261111 | 180 | 11 | 28 | 16.363636 | 0.887218 | 0.105556 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
1b105e458715d132d53060aebe391dbf0d97d2f6 | 1,438 | py | Python | trade_remedies_api/cases/models/utils.py | uktrade/trade-remedies-api | fbe2d142ef099c7244788a0f72dd1003eaa7edce | [
"MIT"
] | 1 | 2020-08-13T10:37:15.000Z | 2020-08-13T10:37:15.000Z | trade_remedies_api/cases/models/utils.py | uktrade/trade-remedies-api | fbe2d142ef099c7244788a0f72dd1003eaa7edce | [
"MIT"
] | 4 | 2020-09-10T13:41:52.000Z | 2020-12-16T09:00:21.000Z | trade_remedies_api/cases/models/utils.py | uktrade/trade-remedies-api | fbe2d142ef099c7244788a0f72dd1003eaa7edce | [
"MIT"
] | null | null | null | import uuid
from functools import singledispatch
from .case import Case
from .submissiontype import SubmissionType
from .submissionstatus import SubmissionStatus
@singledispatch
def get_case(case) -> Case:
"""
A single dispatch to return a case from either a case instance or
the case id.
"""
return case
@get_case.register(str)
def _(case) -> Case: # noqa
return Case.objects.get_case(id=case)
@get_case.register(uuid.UUID)
def _(case) -> Case: # noqa
return Case.objects.get_case(id=case)
@singledispatch
def get_submission_type(submission_type):
"""
A single dispatch to return a Submission Type from either an instance or
the name
"""
return submission_type
@get_submission_type.register(int)
def _(submission_type): # noqa
return SubmissionType.objects.get(id=submission_type)
@get_submission_type.register(str)
def _(submission_type): # noqa
if submission_type.isdigit():
return get_submission_type(int(submission_type))
else:
return SubmissionType.objects.get(name=submission_type)
@singledispatch
def get_submission_status(submission_status):
"""
A single dispatch to return a Submission Type from either an instance or
the name
"""
return submission_status
@get_submission_status.register(int)
def _(submission_status): # noqa
return SubmissionStatus.objects.select_related("type").get(id=submission_status)
| 23.57377 | 84 | 0.741307 | 186 | 1,438 | 5.543011 | 0.188172 | 0.190107 | 0.065955 | 0.049467 | 0.337536 | 0.337536 | 0.248303 | 0.248303 | 0.248303 | 0.248303 | 0 | 0 | 0.175243 | 1,438 | 60 | 85 | 23.966667 | 0.869309 | 0.18637 | 0 | 0.28125 | 0 | 0 | 0.00361 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.15625 | 0.125 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
1b1297474bde3e09c3f737ac5d788ffdb1a0d17d | 1,079 | py | Python | dkim/generate.py | Fourier1/dkim_generator | fa5fd1654060f2611383ab2aa645d6a21b4a013c | [
"MIT"
] | null | null | null | dkim/generate.py | Fourier1/dkim_generator | fa5fd1654060f2611383ab2aa645d6a21b4a013c | [
"MIT"
] | null | null | null | dkim/generate.py | Fourier1/dkim_generator | fa5fd1654060f2611383ab2aa645d6a21b4a013c | [
"MIT"
] | null | null | null | #!/usr/bin/env python2.7
# -*- encoding: utf-8 -*-
import os
# TODO comment ajouter la commande su zimbra avant execution.
# TODO les caracteres a suprimer dans le DKIM gener : " ,
def generate_dkim(_domaine):
""" Generate DKIM"""
cmd_dkim = "/opt/zimbra/libexec/zmdkimkeyutil -a -d " + _domaine
try:
dkim_ = os.system(cmd_dkim)
print(dkim_)
print("\n[ok] Create DKIM\n")
except os.error as e:
print(e)
def delete_dkim(_domaine):
""" Generate DKIM"""
cmd_dkim = "/opt/zimbra/libexec/zmdkimkeyutil -r -d " + _domaine
try:
print(os.system(cmd_dkim))
print("\n[ok] Delete DKIM\n")
except os.error as e:
print(e)
def print_dkim(_domaine):
""" Generate DKIM"""
cmd_dkim = "/opt/zimbra/libexec/zmdkimkeyutil -u -d " + _domaine
try:
print(os.system(cmd_dkim))
print("\n[ok] Print DKIM\n")
except os.error as e:
print(e)
# if __name__ == '__main__':
# generate_dkim("domainna.ci")
# print_dkim("domainna.ci")
# delete_dkim("domainna.ci")
| 24.522727 | 68 | 0.609824 | 147 | 1,079 | 4.285714 | 0.360544 | 0.066667 | 0.090476 | 0.109524 | 0.574603 | 0.542857 | 0.542857 | 0.542857 | 0.542857 | 0.5 | 0 | 0.003681 | 0.244671 | 1,079 | 43 | 69 | 25.093023 | 0.769325 | 0.294717 | 0 | 0.478261 | 1 | 0 | 0.243537 | 0.134694 | 0 | 0 | 0 | 0.023256 | 0 | 1 | 0.130435 | false | 0 | 0.043478 | 0 | 0.173913 | 0.434783 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
1b2474bda7902124c948d1f4c48333a97ba1b46d | 2,329 | py | Python | superspy/system/base_language.py | Kamik423/superspy | 27e46690e0608aa6a181967658afbd1db7e06196 | [
"MIT"
] | null | null | null | superspy/system/base_language.py | Kamik423/superspy | 27e46690e0608aa6a181967658afbd1db7e06196 | [
"MIT"
] | null | null | null | superspy/system/base_language.py | Kamik423/superspy | 27e46690e0608aa6a181967658afbd1db7e06196 | [
"MIT"
] | null | null | null | """Basic language structure for the superspy language.
"""
from typing import Any
from superspy import ast, language
# Delimit words with spaces
@language.register_word_delimiter(' ')
# Delimit commands with semicolons and newlines
@language.register_single_character_touching_token(';')
@language.register_single_character_touching_token('\n')
class NewLine(ast.Token):
"""Newline token.
"""
def deep_repr(self, indent='') -> str:
return super().deep_repr(indent) + '\n'
@language.register_command
class Line(ast.Command):
"""A line containing a single command.
Attributes:
command (ast.Command): The command making up the line.
"""
command: ast.Command
priority = ast.OrderOfOperations.COMMA
can_contain_self = False
def __init__(self, command: ast.Command, _: NewLine):
"""Initialize a line object.
Args:
command (ast.Command): The command.
_ (NewLine): The new line character token.
"""
super().__init__()
self.command = command
def execute(self) -> Any:
"""Execute the line by executing its single command.
Returns:
Any: The return value of the command.
"""
return self.command.execute()
def get_trace(self):
return f'LINE {self.line_number}'
def __repr__(self) -> str:
return f'LINE {self.line_number}: {repr(self.command)}\n'
def deep_repr(self, indent='') -> str:
return f'{indent}LINE[{self.line_number}]\n'\
f'{self.command.deep_repr(indent+self.addint)}\n'
@language.register_command
class EmptyLine(ast.Command):
"""An empty line not containing any command.
This is needed to, after all other lines have matched match the remaining
newline tokens.
"""
priority = ast.OrderOfOperations.COMMA + 0.1
def __init__(self, _: NewLine):
"""Initialize the empty line.
Args:
_ (NewLine): The new line character token.
"""
super().__init__()
def execute(self):
"""Execute an empty line - do nothing.
"""
pass
def __repr__(self) -> str:
return f'LINE {self.line_number}: EMPTY\n'
def deep_repr(self, indent='') -> str:
return f'{indent}LINE[{self.line_number}]: EMPTY\n'
| 26.465909 | 77 | 0.63289 | 283 | 2,329 | 5.021201 | 0.314488 | 0.033779 | 0.042224 | 0.063336 | 0.377199 | 0.298381 | 0.211119 | 0.190007 | 0.133709 | 0.133709 | 0 | 0.001143 | 0.248605 | 2,329 | 87 | 78 | 26.770115 | 0.810857 | 0.314298 | 0 | 0.25 | 0 | 0 | 0.158478 | 0.093426 | 0 | 0 | 0 | 0 | 0 | 1 | 0.277778 | false | 0.027778 | 0.055556 | 0.166667 | 0.722222 | 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 | 1 | 1 | 0 | 0 | 3 |
1b3da56d7a1b9e866bdb3653085a0d775f4754ac | 95 | py | Python | tuiuiu/api/__init__.py | caputomarcos/tuiuiu.io | d8fb57cf95487e7fe1454b2130ef18acc916da46 | [
"BSD-3-Clause"
] | 3 | 2019-08-08T09:09:35.000Z | 2020-12-15T18:04:17.000Z | tuiuiu/api/__init__.py | caputomarcos/tuiuiu.io | d8fb57cf95487e7fe1454b2130ef18acc916da46 | [
"BSD-3-Clause"
] | null | null | null | tuiuiu/api/__init__.py | caputomarcos/tuiuiu.io | d8fb57cf95487e7fe1454b2130ef18acc916da46 | [
"BSD-3-Clause"
] | 1 | 2017-09-09T20:10:40.000Z | 2017-09-09T20:10:40.000Z | from .conf import APIField # noqa
default_app_config = 'tuiuiu.api.apps.TuiuiuAPIAppConfig'
| 19 | 57 | 0.789474 | 12 | 95 | 6.083333 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126316 | 95 | 4 | 58 | 23.75 | 0.879518 | 0.042105 | 0 | 0 | 0 | 0 | 0.382022 | 0.382022 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
1b71c9f7df3306887109472898373e8d1c66ddf0 | 22,959 | py | Python | tests/test_dvh.py | randlet/dvh | 4b0127d58a5b689057e7290441de5a8c5ae02f6f | [
"BSD-3-Clause"
] | 5 | 2015-03-09T22:52:42.000Z | 2021-05-08T23:16:47.000Z | tests/test_dvh.py | randlet/dvh | 4b0127d58a5b689057e7290441de5a8c5ae02f6f | [
"BSD-3-Clause"
] | null | null | null | tests/test_dvh.py | randlet/dvh | 4b0127d58a5b689057e7290441de5a8c5ae02f6f | [
"BSD-3-Clause"
] | 3 | 2015-12-26T23:38:33.000Z | 2020-01-18T18:24:00.000Z | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_dvh
----------------------------------
Tests for `dvh` module.
"""
import json
import unittest2 as unittest
import numpy as np
from dvh import DVH, monotonic_increasing, monotonic_decreasing
class TestDvh(unittest.TestCase):
def setUp(self):
self.test_diff_vols = [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 2, 1, 0, 0, 0, 0, 0, 10, 20, 30, 40, 50, 60, 70, 60, 50, 40, 30, 20, 10, 0, 0]
self.test_cum_vols = [ 518, 518, 518, 518, 518, 518, 518, 518, 518, 517, 515, 512, 508, 503, 497, 493, 491, 490, 490, 490, 490, 490, 490, 480, 460, 430, 390, 340, 280, 210, 150, 100, 60, 30, 10, 0, 0.]
self.min_dose = 80
self.max_dose = 340
self.mean_dose = 285
self.test_doses = np.arange(0, 370, 10)
self.test_structs = {
"Ant Scalene" : {
"doses": [0, 395, 405, 415, 425, 435, 445, 465, 475, 485, 495, 505, 515, 525, 535, 545, 555, 565, 585, 595, 605, 615, 625, 635, 645, 655, 665, 675, 685, 715, 725, 735, 755, 765, 775, 795, 805, 815, 825, 835, 845, 855, 865, 875, 885, 895, 905, 915, 955, 965, 975, 985, 995, 1005, 1015, 1025, 1035, 1045, 1055, 1065, 1075, 1085, 1095, 1105, 1115, 1125, 1135, 1145, 1155, 1165, 1175, 1195, 1215, 1225, 1235, 1245, 1255, 1265, 1285, 1295, 1305, 1315, 1325, 1335, 1355, 1375, 1385, 1395, 1405, 1415, 1425, 1435, 1445, 1455, 1465, 1475, 1485, 1495, 1505, 1525, 1535, 1545, 1555, 1565, 1575, 1585, 1595, 1605, 1615, 1625, 1635, 1645, 1655, 1665, 1675, 1685, 1695, 1705, 1715, 1725, 1735, 1745, 1755, 1765, 1775, 1785, 1795, 1805, 1825, 1835, 1845, 1855, 1865, 1875, 1885, 1895, 1905, 1925, 1935, 1945, 1955, 1965, 1975, 1985, 1995, 2005, 2015, 2025, 2035, 2085, 2095, 2105, 2115, 2125, 2135, 2145, 2155, 2165, 2175, 2205, 2215, 2225, 2235, 2275, 2285, 2295, 2305, 2315, 2335, 2355, 2385, 2405, 2415, 2425, 2435, 2445, 2455, 2465, 2485, 2505, 2515, 2525, 2535, 2545, 2555, 2565, 2575, 2585, 2595, 2605, 2625, 2635, 2645, 2655, 2665, 2675, 2685, 2695, 2705, 2715, 2735, 2745, 2765, 2775, 2785, 2795, 2805, 2815, 2825, 2835, 2845, 2855, 2865, 2875, 2885, 2895, 2905, 2915, 2925, 2935, 2945, 2955, 2965, 2975, 2985, 2995, 3005, 3025, 3035, 3045, 3055, 3065, 3075, 3085, 3095, 3115, 3125, 3135, 3145, 3155, 3165, 3175, 3185, 3195, 3205, 3215, 3225, 3235, 3245, 3255, 3265, 3275, 3285, 3295, 3305, 3315, 3325, 3335, 3345, 3355, 3365, 3375, 3385, 3395, 3405, 3415, 3425, 3435, 3445, 3455, 3465, 3475, 3485, 3495, 3505, 3515, 3525, 3535, 3545, 3555, 3565, 3575, 3585, 3595, 3605, 3615, 3625, 3645, 3655, 3665, 3675, 3685, 3695, 3705, 3715, 3725, 3735, 3745, 3755, 3765, 3775, 3785, 3795, 3815, 3825, 3835, 3845, 3855, 3865, 3875, 3885, 3895, 3905, 3925, 3935, 3955, 3965, 3985, 3995, 4005, 4015, 4025, 4035, 4045, 4055, 4065, 4075, 4085, 4095, 4105, 4115, 4125, 4135, 4145, 4155, 4165, 4175, 4195, 4205, 4215, 4225, 4235, 4245, 4255, 4265, 4275, 4285, 4295, 4305, 4325, 4335, 4355, 4365, 4375, 4385, 4405, 4415, 4425, 4445, 4465, 4475, 4495, 4505, 4515, 4525, 4535, 4545, 4595, 4615, 4625, 4635, 4645, 4655, 4665, 4675, 4685, 4695, 4705, 4715, 4725, 4735, 4745, 4755, 4765, 4775, 4785, 4795, 4805, 4815, 4825, 4835, 4845, 4855, 4865, 4875, 4885, 4895, 4905, 4915, 4925, 4935, 4945, 4955, 4965, 4975, 4985, 4995, 5005, 5015, 5025, 5035, 5045, 5055, 5065, 5075, 5085, 5095, 5105, 5115, 5125, 5135, 5145, 5155, 5175, 5185, 5195, 5205, 5215, 5225, 5235, 5245, 5255, 5265, 5275, 5285, 5295, 5305, 5315, 5325, 5335, 5345, 5355, 5365, 5375, 5385, 5405, 5415, 5425, 5435, 5445, 5455, 5465, 5475, 5485, 5495, 5505, 5515, 5525, 5535, 5545, 5555, 5565, 5575, 5585, 5595, 5605, 5615, 5625, 5635, 5645, 5655, 5665, 5675, 5685, 5695, 5705, 5715, 5725, 5735, 5745, 5755, 5765, 5775, 5785, 5805, 5815, 5825, 6955, 6960],
"volumes": [8.155, 8.155, 8.132, 8.102, 8.058, 8.02, 7.969, 7.855, 7.793, 7.738, 7.69, 7.641, 7.604, 7.572, 7.55, 7.527, 7.503, 7.485, 7.427, 7.411, 7.393, 7.38, 7.363, 7.341, 7.32, 7.292, 7.273, 7.255, 7.234, 7.156, 7.125, 7.102, 7.06, 7.041, 7.021, 6.993, 6.984, 6.971, 6.962, 6.957, 6.949, 6.94, 6.926, 6.919, 6.911, 6.899, 6.891, 6.882, 6.854, 6.843, 6.836, 6.83, 6.819, 6.807, 6.796, 6.784, 6.773, 6.761, 6.755, 6.746, 6.738, 6.727, 6.72, 6.714, 6.706, 6.699, 6.693, 6.684, 6.676, 6.67, 6.659, 6.643, 6.623, 6.614, 6.607, 6.596, 6.59, 6.585, 6.565, 6.561, 6.548, 6.544, 6.537, 6.527, 6.513, 6.501, 6.494, 6.489, 6.485, 6.479, 6.474, 6.471, 6.465, 6.462, 6.454, 6.448, 6.444, 6.436, 6.431, 6.419, 6.415, 6.407, 6.4, 6.396, 6.388, 6.381, 6.372, 6.369, 6.36, 6.357, 6.346, 6.341, 6.332, 6.33, 6.324, 6.321, 6.315, 6.312, 6.308, 6.303, 6.301, 6.296, 6.293, 6.288, 6.284, 6.279, 6.273, 6.265, 6.255, 6.248, 6.244, 6.238, 6.23, 6.228, 6.22, 6.215, 6.209, 6.195, 6.19, 6.181, 6.175, 6.168, 6.163, 6.155, 6.151, 6.144, 6.139, 6.132, 6.127, 6.107, 6.102, 6.099, 6.092, 6.088, 6.083, 6.08, 6.075, 6.065, 6.061, 6.046, 6.04, 6.031, 6.027, 6.003, 5.994, 5.99, 5.984, 5.979, 5.965, 5.957, 5.939, 5.931, 5.925, 5.921, 5.918, 5.911, 5.907, 5.901, 5.893, 5.883, 5.879, 5.872, 5.868, 5.865, 5.855, 5.85, 5.846, 5.838, 5.833, 5.829, 5.813, 5.809, 5.803, 5.798, 5.79, 5.785, 5.778, 5.77, 5.767, 5.761, 5.747, 5.746, 5.734, 5.73, 5.724, 5.719, 5.716, 5.708, 5.702, 5.7, 5.695, 5.689, 5.684, 5.68, 5.675, 5.671, 5.662, 5.656, 5.653, 5.647, 5.639, 5.634, 5.63, 5.622, 5.619, 5.612, 5.603, 5.595, 5.589, 5.58, 5.576, 5.57, 5.566, 5.561, 5.557, 5.551, 5.545, 5.54, 5.536, 5.528, 5.525, 5.519, 5.514, 5.508, 5.5, 5.495, 5.489, 5.481, 5.476, 5.467, 5.463, 5.45, 5.446, 5.438, 5.432, 5.425, 5.415, 5.409, 5.401, 5.396, 5.388, 5.383, 5.375, 5.37, 5.366, 5.364, 5.358, 5.356, 5.352, 5.347, 5.345, 5.338, 5.332, 5.327, 5.324, 5.313, 5.309, 5.303, 5.295, 5.291, 5.274, 5.267, 5.257, 5.249, 5.242, 5.234, 5.227, 5.215, 5.204, 5.197, 5.192, 5.185, 5.181, 5.174, 5.168, 5.163, 5.157, 5.152, 5.144, 5.135, 5.128, 5.118, 5.112, 5.094, 5.08, 5.065, 5.056, 5.051, 5.045, 5.042, 5.034, 5.029, 5.019, 5.013, 5.007, 4.997, 4.994, 4.986, 4.978, 4.972, 4.963, 4.956, 4.936, 4.919, 4.911, 4.896, 4.883, 4.873, 4.866, 4.856, 4.852, 4.846, 4.844, 4.84, 4.838, 4.833, 4.83, 4.826, 4.82, 4.817, 4.811, 4.809, 4.801, 4.796, 4.786, 4.78, 4.766, 4.745, 4.723, 4.695, 4.687, 4.669, 4.663, 4.647, 4.639, 4.621, 4.613, 4.606, 4.594, 4.58, 4.575, 4.559, 4.55, 4.544, 4.54, 4.531, 4.525, 4.48, 4.458, 4.445, 4.431, 4.412, 4.396, 4.381, 4.361, 4.345, 4.335, 4.317, 4.291, 4.274, 4.252, 4.227, 4.198, 4.173, 4.142, 4.12, 4.093, 4.054, 4.025, 3.997, 3.956, 3.918, 3.879, 3.835, 3.775, 3.718, 3.662, 3.6, 3.541, 3.48, 3.418, 3.376, 3.324, 3.274, 3.221, 3.175, 3.142, 3.1, 3.052, 3.01, 2.96, 2.918, 2.872, 2.835, 2.791, 2.75, 2.712, 2.673, 2.639, 2.603, 2.548, 2.506, 2.455, 2.335, 2.279, 2.209, 2.141, 2.07, 1.994, 1.927, 1.846, 1.766, 1.689, 1.632, 1.565, 1.502, 1.434, 1.375, 1.318, 1.254, 1.204, 1.151, 1.097, 1.056, 1.005, 0.915, 0.868, 0.832, 0.792, 0.748, 0.711, 0.675, 0.638, 0.599, 0.563, 0.518, 0.492, 0.468, 0.436, 0.39, 0.359, 0.341, 0.319, 0.288, 0.266, 0.235, 0.211, 0.197, 0.181, 0.156, 0.137, 0.12, 0.106, 0.087, 0.075, 0.057, 0.048, 0.037, 0.027, 0.019, 0.014, 0.012, 0.008, 0.003, 0.001, 0.001, 0, 0, 0],
"monaco_dvh_mean_dose": 3752.2,
"monaco_dvh_max_dose":5810.4,
"monaco_dvh_min_dose":391.9,
"monaco_dvh_volume": 8.155
},
"PTV50": {
"doses":[0, 3555, 3585, 3595, 3605, 3615, 3625, 3635, 3655, 3665, 3675, 3685, 3705, 3715, 3725, 3735, 3745, 3755, 3775, 3785, 3795, 3805, 3815, 3825, 3835, 3855, 3875, 3885, 3895, 3905, 3915, 3925, 3945, 3955, 3965, 3975, 3985, 3995, 4005, 4015, 4025, 4045, 4055, 4065, 4075, 4085, 4095, 4105, 4115, 4125, 4135, 4145, 4155, 4165, 4175, 4185, 4205, 4215, 4225, 4235, 4245, 4255, 4265, 4275, 4285, 4295, 4305, 4315, 4325, 4335, 4345, 4355, 4365, 4375, 4385, 4395, 4405, 4415, 4425, 4435, 4445, 4455, 4465, 4475, 4485, 4495, 4505, 4515, 4525, 4535, 4545, 4555, 4565, 4575, 4585, 4595, 4605, 4615, 4625, 4635, 4645, 4655, 4665, 4675, 4685, 4695, 4705, 4715, 4725, 4735, 4745, 4755, 4765, 4775, 4785, 4795, 4805, 4815, 4825, 4835, 4845, 4855, 4865, 4875, 4885, 4895, 4905, 4915, 4925, 4935, 4945, 4955, 4965, 4975, 4985, 4995, 5005, 5015, 5025, 5035, 5045, 5055, 5065, 5075, 5085, 5095, 5105, 5115, 5125, 5135, 5145, 5155, 5165, 5175, 5185, 5195, 5205, 5215, 5225, 5235, 5245, 5255, 5265, 5275, 5285, 5295, 5305, 5315, 5325, 5335, 5345, 5355, 5365, 5375, 5385, 5395, 5405, 5415, 5425, 5435, 5445, 5455, 5465, 5475, 5485, 5495, 5505, 5515, 5525, 5535, 5545, 5555, 5565, 5575, 5585, 5595, 5605, 5615, 5625, 5635, 5645, 5655, 5665, 5675, 5685, 5695, 5705, 5715, 5725, 5735, 5745, 5755, 5765, 5775, 5785, 5795, 5805, 5815, 5825, 5835, 5845, 5855, 5865, 5875, 5885, 5895, 5905, 5915, 5935, 5945, 5955, 5965, 5975, 5985, 5995, 6005, 6015, 6025, 6035, 6045, 6055, 6065, 6075, 6085, 6095, 6105, 6115, 6125, 6135, 6145, 6155, 6165, 6175, 6185, 6195, 6205, 6215, 6225, 6235, 6245, 6255, 6275, 6285, 6295, 6305, 6315, 6325, 6335, 6345, 6355, 6365, 6375, 6385, 6395, 6405, 6415, 6425, 6435, 6445, 6455, 6465, 6475, 6495, 6505, 6515, 6525, 6535, 6545, 6555, 6565, 6575, 6585, 6595, 6615, 6625, 6635, 6645, 6655, 6665, 6675, 6685, 6705, 6715, 6725, 6735, 6745, 6755, 6765, 6775, 6785, 6795, 6805, 6835, 6845, 6855, 6865, 6875, 6885, 6895, 6915, 6925, 6955, 6960],
"volumes":[503.55, 503.55, 503.547, 503.547, 503.546, 503.546, 503.544, 503.543, 503.539, 503.538, 503.536, 503.535, 503.531, 503.527, 503.524, 503.524, 503.519, 503.516, 503.506, 503.504, 503.501, 503.496, 503.494, 503.488, 503.483, 503.475, 503.463, 503.456, 503.447, 503.444, 503.437, 503.431, 503.415, 503.403, 503.396, 503.39, 503.382, 503.372, 503.361, 503.351, 503.339, 503.313, 503.297, 503.28, 503.268, 503.252, 503.232, 503.219, 503.202, 503.182, 503.161, 503.142, 503.122, 503.095, 503.078, 503.055, 502.993, 502.965, 502.931, 502.89, 502.853, 502.824, 502.786, 502.742, 502.705, 502.658, 502.606, 502.549, 502.507, 502.47, 502.426, 502.364, 502.296, 502.215, 502.123, 502.021, 501.926, 501.812, 501.693, 501.572, 501.409, 501.259, 501.071, 500.901, 500.701, 500.509, 500.289, 500.082, 499.841, 499.631, 499.414, 499.155, 498.892, 498.602, 498.303, 498.013, 497.719, 497.379, 497.034, 496.671, 496.275, 495.834, 495.359, 494.892, 494.405, 493.9, 493.358, 492.778, 492.147, 491.507, 490.822, 490.076, 489.288, 488.457, 487.645, 486.765, 485.826, 484.908, 483.894, 482.79, 481.635, 480.475, 479.222, 477.921, 476.512, 475.076, 473.488, 471.788, 470, 468.173, 466.216, 464.019, 461.764, 459.476, 456.935, 454.375, 451.576, 448.685, 445.574, 442.376, 438.931, 435.272, 431.381, 427.266, 422.727, 417.732, 412.308, 406.508, 399.991, 393.073, 385.506, 377.4, 368.671, 359.176, 349.297, 339.141, 328.753, 317.937, 306.855, 295.682, 284.517, 273.104, 261.631, 250.185, 238.529, 227.263, 215.981, 205.16, 194.649, 184.384, 174.428, 164.929, 155.956, 147.426, 139.562, 132.239, 125.344, 118.648, 112.3, 106.306, 100.578, 95.438, 90.599, 85.996, 81.76, 77.718, 73.767, 70.076, 66.49, 62.922, 59.532, 56.333, 53.35, 50.513, 47.901, 45.409, 43.069, 40.826, 38.709, 36.767, 34.888, 33.286, 31.767, 30.349, 29.07, 27.846, 26.646, 25.562, 24.474, 23.416, 22.406, 21.452, 20.429, 19.51, 18.606, 17.767, 16.964, 16.129, 15.335, 14.598, 13.852, 13.165, 12.461, 11.826, 11.222, 10.7, 10.134, 9.664, 8.738, 8.28, 7.828, 7.411, 7.026, 6.634, 6.272, 5.954, 5.658, 5.351, 5.051, 4.745, 4.463, 4.212, 3.977, 3.756, 3.523, 3.311, 3.13, 2.963, 2.815, 2.692, 2.58, 2.467, 2.359, 2.269, 2.182, 2.09, 2.008, 1.925, 1.834, 1.742, 1.655, 1.505, 1.426, 1.36, 1.284, 1.221, 1.168, 1.101, 1.028, 0.964, 0.918, 0.879, 0.841, 0.795, 0.762, 0.727, 0.691, 0.665, 0.634, 0.614, 0.587, 0.557, 0.517, 0.496, 0.469, 0.449, 0.42, 0.406, 0.379, 0.363, 0.351, 0.327, 0.308, 0.272, 0.258, 0.236, 0.216, 0.192, 0.173, 0.159, 0.142, 0.114, 0.103, 0.097, 0.085, 0.07, 0.061, 0.057, 0.055, 0.048, 0.038, 0.031, 0.019, 0.017, 0.012, 0.01, 0.01, 0.006, 0.005, 0.005, 0.002, 0.002, 0],
"monaco_dvh_mean_dose": 5277.2,
"monaco_dvh_max_dose": 6959.8,
"monaco_dvh_min_dose": 3552.2,
"monaco_dvh_volume": 503.55,
},
"prv cord": {
"doses": [0, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 405, 415, 425, 435, 445, 455, 465, 475, 485, 495, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 605, 615, 625, 635, 645, 655, 665, 675, 685, 695, 705, 715, 725, 735, 745, 755, 765, 775, 785, 795, 805, 815, 825, 835, 845, 855, 865, 875, 885, 895, 905, 915, 925, 935, 945, 955, 965, 975, 985, 995, 1005, 1015, 1025, 1035, 1045, 1055, 1065, 1075, 1085, 1095, 1105, 1115, 1125, 1135, 1145, 1155, 1165, 1175, 1185, 1195, 1205, 1215, 1225, 1235, 1245, 1255, 1265, 1275, 1285, 1295, 1305, 1315, 1325, 1335, 1345, 1355, 1365, 1375, 1385, 1395, 1405, 1415, 1425, 1435, 1445, 1455, 1465, 1475, 1485, 1495, 1505, 1515, 1525, 1535, 1545, 1555, 1565, 1575, 1585, 1595, 1605, 1625, 1635, 1645, 1655, 1665, 1675, 1685, 1695, 1705, 1715, 1725, 1735, 1745, 1755, 1765, 1775, 1785, 1795, 1805, 1815, 1825, 1835, 1845, 1855, 1865, 1875, 1885, 1895, 1905, 1915, 1925, 1935, 1945, 1955, 1965, 1975, 1985, 1995, 2005, 2015, 2025, 2035, 2045, 2065, 2075, 2085, 2095, 2105, 2115, 2125, 2135, 2145, 2155, 2165, 2175, 2185, 2195, 2205, 2215, 2225, 2235, 2245, 2255, 2265, 2275, 2285, 2295, 2305, 2315, 2325, 2335, 2345, 2355, 2365, 2375, 2385, 2395, 2405, 2425, 2435, 2445, 2465, 2475, 2485, 2495, 2505, 2515, 2525, 2535, 2545, 2555, 2565, 2575, 2585, 2595, 2605, 2615, 2625, 2635, 2655, 2665, 2685, 2695, 2705, 2715, 2725, 2735, 2745, 2755, 2765, 2775, 2785, 2795, 2805, 2835, 2845, 2855, 2865, 2885, 2895, 6955, 6960],
"volumes" : [202.215, 202.215, 185.281, 178.426, 171.883, 166.421, 162.144, 157.958, 154.472, 151.367, 148.431, 145.753, 143.439, 141.707, 140.066, 138.441, 136.694, 135.114, 133.489, 131.856, 129.909, 127.67, 124.556, 121.016, 117.495, 113.781, 110.265, 107.293, 104.206, 101.475, 98.956, 96.835, 95.416, 94.425, 93.538, 92.733, 91.921, 91.097, 90.15, 88.896, 87.359, 85.697, 83.861, 81.868, 79.835, 77.708, 75.325, 72.962, 70.615, 68.584, 66.794, 65.322, 63.94, 62.758, 61.605, 60.413, 59.285, 58.128, 57.042, 55.941, 55, 54.143, 53.374, 52.683, 51.949, 51.262, 50.66, 50.156, 49.664, 49.189, 48.707, 48.205, 47.698, 47.239, 46.783, 46.353, 45.919, 45.523, 45.088, 44.702, 44.364, 44.045, 43.729, 43.462, 43.205, 42.962, 42.736, 42.508, 42.301, 42.107, 41.9, 41.728, 41.535, 41.366, 41.178, 41.005, 40.827, 40.621, 40.423, 40.224, 40.008, 39.794, 39.567, 39.353, 39.114, 38.882, 38.646, 38.408, 38.118, 37.882, 37.568, 37.307, 37.045, 36.732, 36.432, 36.127, 35.824, 35.502, 35.141, 34.793, 34.446, 34.062, 33.688, 33.277, 32.875, 32.393, 31.967, 31.485, 31.006, 30.481, 29.97, 29.379, 28.812, 28.202, 27.566, 26.877, 26.193, 25.525, 24.791, 24.072, 23.345, 22.586, 21.809, 20.975, 20.188, 19.355, 18.582, 17.762, 16.988, 16.176, 15.425, 14.745, 14.056, 13.373, 12.746, 12.11, 11.542, 10.978, 10.418, 9.902, 9.441, 8.991, 8.191, 7.822, 7.482, 7.169, 6.887, 6.598, 6.352, 6.087, 5.867, 5.65, 5.434, 5.225, 5.032, 4.862, 4.67, 4.501, 4.325, 4.172, 4.016, 3.874, 3.728, 3.602, 3.455, 3.322, 3.198, 3.082, 2.972, 2.861, 2.747, 2.644, 2.558, 2.476, 2.383, 2.298, 2.199, 2.138, 2.061, 1.989, 1.928, 1.852, 1.791, 1.734, 1.669, 1.557, 1.498, 1.45, 1.398, 1.347, 1.29, 1.251, 1.2, 1.163, 1.12, 1.072, 1.036, 1.001, 0.959, 0.921, 0.889, 0.847, 0.815, 0.782, 0.75, 0.724, 0.691, 0.666, 0.637, 0.61, 0.582, 0.553, 0.525, 0.502, 0.477, 0.456, 0.426, 0.409, 0.388, 0.372, 0.33, 0.311, 0.29, 0.256, 0.243, 0.221, 0.206, 0.197, 0.181, 0.168, 0.158, 0.143, 0.132, 0.129, 0.12, 0.112, 0.1, 0.093, 0.082, 0.072, 0.069, 0.059, 0.05, 0.04, 0.038, 0.03, 0.026, 0.025, 0.022, 0.018, 0.016, 0.013, 0.013, 0.012, 0.012, 0.009, 0.006, 0.006, 0.003, 0.002, 0.002, 0, 0, 0],
"monaco_dvh_mean_dose": 496.7,
"monaco_dvh_max_dose": 2889.2,
"monaco_dvh_min_dose": 0,
"monaco_dvh_volume": 202.215,
}
}
def test_realistic_mean_dose(self):
"""test mean dose within 1cGy"""
for struct, data in self.test_structs.items():
dvh = DVH(data["doses"], data["volumes"])
diff = dvh.mean_dose - data["monaco_dvh_mean_dose"]
self.assertLessEqual(abs(diff), 1)
def test_realistic_min_dose(self):
"""test min dose within 1cGy"""
# min and max dose can only really hope to be within half a bin width
for struct, data in self.test_structs.items():
dvh = DVH(data["doses"], data["volumes"])
diff = dvh.min_dose - data["monaco_dvh_min_dose"]
self.assertLessEqual(abs(diff), 5.)
def test_realistic_max_dose(self):
"""test max dose within 5cGy"""
# min and max dose can only really hope to be within half a bin width
for struct, data in self.test_structs.items():
dvh = DVH(data["doses"], data["volumes"])
diff = dvh.max_dose - data["monaco_dvh_max_dose"]
self.assertLessEqual(abs(diff), 5.)
def test_missing_doses(self):
with self.assertRaises(ValueError):
dvh = DVH(volumes=[1,2])
def test_missing_volumes(self):
with self.assertRaises(ValueError):
dvh = DVH(doses=[1,2])
def test_no_zero_dose_dif(self):
doses = [1, 2, 3]
volumes = [30, 0, 10]
dvh = DVH(doses, volumes)
self.assertEqual(dvh.mean_dose, 1.5)
def test_no_zero_dose_cum(self):
doses = [1, 2, 3, 4]
volumes = [30, 30, 10, 5]
dvh = DVH(doses, volumes)
self.assertEqual(dvh.mean_dose, (5.*4. + 5*3 +20*2)/(5. + 5 + 20))
def test_dmax(self):
dvh = DVH(self.test_doses, self.test_diff_vols)
self.assertEqual(dvh.max_dose, self.max_dose)
def test_dmin(self):
dvh = DVH(self.test_doses, self.test_diff_vols)
self.assertEqual(dvh.min_dose, self.min_dose)
def test_dmean(self):
"""TODO: Develop real worlds tests"""
doses = [0, 1, 2, 3]
volumes = [10, 0, 0, 10]
dvh = DVH(doses, volumes)
self.assertEqual(dvh.mean_dose, 1.5)
def test_monotonic_increasing_strict(self):
self.assertTrue(monotonic_increasing(range(4)))
self.assertFalse(monotonic_increasing(self.test_diff_vols))
def test_monotonic_decreasing(self):
self.assertFalse(monotonic_decreasing(self.test_diff_vols))
self.assertTrue(monotonic_decreasing(list(reversed(range(4)))))
def test_diff_converted_to_cumulative(self):
dvh = DVH(self.test_doses, self.test_diff_vols)
self.assertAlmostEqual(dvh.cum_volumes[0], 1)
def test_invalid_bin_count(self):
with self.assertRaises(ValueError):
dvh = DVH(self.test_doses[:-1], self.test_diff_vols)
def test_invalid_bins(self):
with self.assertRaises(ValueError):
dvh = DVH([1,3,1], [2,4])
def test_cumulative_to_diff(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
dvh2 = DVH(self.test_doses, dvh.diff_volumes)
self.assertAlmostEqual(sum(dvh2.cum_volumes - dvh.cum_volumes), 0)
def test_dose_to_volume_fraction_0(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
self.assertAlmostEqual(dvh.dose_to_volume_fraction(0), self.max_dose)
def test_dose_to_volume_fraction_1(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
self.assertAlmostEqual(dvh.dose_to_volume_fraction(1), self.min_dose)
def test_dose_to_volume_fraction_mid(self):
""" A volume fraction of 0.9999999999 should give just slightly more than min dose"""
dvh = DVH(self.test_doses, self.test_cum_vols)
self.assertAlmostEqual(dvh.dose_to_volume_fraction(0.9999999999), self.min_dose, places=4)
self.assertGreater(dvh.dose_to_volume_fraction(0.9999999999), self.min_dose)
def test_dose_to_volume_fraction_invalid(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
with self.assertRaises(ValueError):
dvh.dose_to_volume_fraction(100)
def test_volume_fraction_receiving_zero_or_more_dose(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
self.assertAlmostEqual(dvh.volume_fraction_receiving_dose(0), 1)
def test_volume_fraction_receiving_more_than_max_dose(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
self.assertAlmostEqual(dvh.volume_fraction_receiving_dose(dvh.max_dose+1), 0)
def test_volume_fraction_receiving_dose(self):
doses = [0, 1, 2, 3]
volumes = [10, 0, 0, 10]
dvh = DVH(doses, volumes)
self.assertAlmostEqual(dvh.volume_fraction_receiving_dose(dvh.mean_dose), 0.5)
def test_to_dict(self):
doses = [1, 2, 3, 4, 5]
volumes = [1, 1, 0.5, 0.5, 0]
dvh = DVH(doses, volumes)
expected = {
'diff_volumes': [0.0, 0.0, 0.5, 0.0, 0.5, 0.0],
'cum_volumes': [1.0, 1.0, 1.0, 0.5, 0.5, 0.0],
'doses': [0.0, 1.0, 2.0, 3.0, 4.0, 5.0],
'mean_dose': 3.0,
'max_dose': 4.0,
'min_dose': 2.0
}
self.assertDictEqual(expected, dvh.to_dict())
def test_to_dict_no_diff(self):
doses = [1, 2, 3, 4, 5]
volumes = [1, 1, 0.5, 0.5, 0]
dvh = DVH(doses, volumes)
expected = {
'cum_volumes': [1.0, 1.0, 1.0, 0.5, 0.5, 0.0],
'doses': [0.0, 1.0, 2.0, 3.0, 4.0, 5.0],
'mean_dose': 3.0,
'max_dose': 4.0,
'min_dose': 2.0
}
self.assertDictEqual(expected, dvh.to_dict(False))
def test_json_serialze(self):
doses = [1, 2, 3, 4, 5]
volumes = [1, 1, 0.5, 0.5, 0]
dvh = DVH(doses, volumes)
expected = {
'diff_volumes': [0.0, 0.0, 0.5, 0.0, 0.5, 0.0],
'cum_volumes': [1.0, 1.0, 1.0, 0.5, 0.5, 0.0],
'doses': [0.0, 1.0, 2.0, 3.0, 4.0, 5.0],
'mean_dose': 3.0,
'max_dose': 4.0,
'min_dose': 2.0
}
self.assertDictEqual(json.loads(json.dumps(expected)), json.loads(dvh.serialize()))
def test_json_serialze_invalid(self):
doses = [1, 2, 3, 4, 5]
volumes = [1, 1, 0.5, 0.5, 0]
dvh = DVH(doses, volumes)
with self.assertRaises(TypeError):
dvh.serialize(method="blah")
if __name__ == '__main__':
unittest.main()
def test_dose_to_volume_fraction_invalid(self):
dvh = DVH(self.test_doses, self.test_cum_vols)
with self.assertRaises(ValueError):
dvh.dose_to_volume_fraction(100)
if __name__ == '__main__':
unittest.main()
| 92.204819 | 3,382 | 0.607692 | 4,486 | 22,959 | 3.048596 | 0.33103 | 0.006142 | 0.004607 | 0.015209 | 0.402822 | 0.362679 | 0.339207 | 0.321732 | 0.310325 | 0.293799 | 0 | 0.52045 | 0.199181 | 22,959 | 248 | 3,383 | 92.576613 | 0.223376 | 0.019034 | 0 | 0.426136 | 0 | 0 | 0.024283 | 0 | 0 | 0 | 0 | 0.004032 | 0.176136 | 1 | 0.164773 | false | 0 | 0.022727 | 0 | 0.193182 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
1b837bfdda505d808bea5d5cb0f138e08c143f2b | 806 | py | Python | zcalc/stdlib/unit/si.py | blackchip-org/zcalc | dbfd09938c5cad7b0adb5004ad3858f1edf560bf | [
"MIT"
] | null | null | null | zcalc/stdlib/unit/si.py | blackchip-org/zcalc | dbfd09938c5cad7b0adb5004ad3858f1edf560bf | [
"MIT"
] | null | null | null | zcalc/stdlib/unit/si.py | blackchip-org/zcalc | dbfd09938c5cad7b0adb5004ad3858f1edf560bf | [
"MIT"
] | null | null | null | from zcalc.lib import ops
@ops()
def units():
return [
('yotta', lambda z: '1e24'),
('zetta', lambda z: '1e21'),
('exa', lambda z: '1e18'),
('peta', lambda z: '1e15'),
('tera', lambda z: '1e12'),
('giga', lambda z: '1e9'),
('mega', lambda z: '1e6'),
('kilo', lambda z: '1e3'),
('hecto', lambda z: '1e2'),
('deca', lambda z: '1e1'),
('deci', lambda z: '1e-1'),
('centi', lambda z: '1e-2'),
('milli', lambda z: '1e-3'),
('micro', lambda z: '1e-6'),
('nano', lambda z: '1e-9'),
('pico', lambda z: '1e-12'),
('femto', lambda z: '1e-15'),
('atto', lambda z: '1e-18'),
('zepto', lambda z: '1e-21'),
('yocto', lambda z: '1e-24'),
]
| 29.851852 | 37 | 0.416873 | 99 | 806 | 3.393939 | 0.515152 | 0.416667 | 0.267857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.093458 | 0.336228 | 806 | 26 | 38 | 31 | 0.534579 | 0 | 0 | 0 | 0 | 0 | 0.208437 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.04 | true | 0 | 0.04 | 0.04 | 0.12 | 0 | 0 | 0 | 0 | null | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
1b89000b4bac6621cbe7efadee1bc8df07301f48 | 279 | py | Python | lodestar-backend/controllers/scatter_controller.py | barblin/lodestar | b36c9b76374c111b24abad87fa4f573bfd129d0e | [
"MIT"
] | null | null | null | lodestar-backend/controllers/scatter_controller.py | barblin/lodestar | b36c9b76374c111b24abad87fa4f573bfd129d0e | [
"MIT"
] | null | null | null | lodestar-backend/controllers/scatter_controller.py | barblin/lodestar | b36c9b76374c111b24abad87fa4f573bfd129d0e | [
"MIT"
] | null | null | null | import json
from flask import Blueprint
from services import scatter_service
scatter_controller = Blueprint('scatter_controller', __name__)
@scatter_controller.route('/api/v1/scatters/<filename>')
def scatters(filename):
return json.dumps(scatter_service.get(filename))
| 21.461538 | 62 | 0.802867 | 34 | 279 | 6.323529 | 0.558824 | 0.237209 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003984 | 0.100358 | 279 | 12 | 63 | 23.25 | 0.85259 | 0 | 0 | 0 | 0 | 0 | 0.16129 | 0.096774 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0.142857 | 0.714286 | 0.285714 | 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 | 1 | 1 | 0 | 0 | 0 | 3 |
1bad06cbba7be61ab1d45ce1e8634396866f4162 | 179 | py | Python | src/spyd/utils/truncate.py | DanSeraf/spyd | af893b7f9c67785613b25754eb2cf150523a9fe4 | [
"Zlib"
] | 4 | 2015-05-05T16:44:42.000Z | 2020-10-27T09:45:23.000Z | src/spyd/utils/truncate.py | DanSeraf/spyd | af893b7f9c67785613b25754eb2cf150523a9fe4 | [
"Zlib"
] | null | null | null | src/spyd/utils/truncate.py | DanSeraf/spyd | af893b7f9c67785613b25754eb2cf150523a9fe4 | [
"Zlib"
] | 2 | 2016-12-13T22:21:08.000Z | 2020-03-14T16:44:20.000Z | def truncate(string, length):
"Ensure a string is no longer than a given length."
if len(string) <= length:
return string
else:
return string[:length]
| 25.571429 | 55 | 0.631285 | 24 | 179 | 4.708333 | 0.625 | 0.318584 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.27933 | 179 | 6 | 56 | 29.833333 | 0.875969 | 0.273743 | 0 | 0 | 0 | 0 | 0.273743 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 1 | 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 | 3 |
1bb4a8c8ebd46957abfa4179ffa1ca77aa6ed4b8 | 56 | py | Python | django_ariadne_jwt_gaid/__init__.py | MrClemRkz/django-ariadne-jwt | ede1dc6353192c751f7e9119f42419f0955ce44f | [
"MIT"
] | 2 | 2021-02-06T19:19:07.000Z | 2021-07-18T04:59:25.000Z | django_ariadne_jwt_gaid/__init__.py | MrClemRkz/django-ariadne-jwt | ede1dc6353192c751f7e9119f42419f0955ce44f | [
"MIT"
] | null | null | null | django_ariadne_jwt_gaid/__init__.py | MrClemRkz/django-ariadne-jwt | ede1dc6353192c751f7e9119f42419f0955ce44f | [
"MIT"
] | 1 | 2021-07-15T14:03:21.000Z | 2021-07-15T14:03:21.000Z | from . import resolvers as types
__version__ = "0.2.1"
| 14 | 32 | 0.714286 | 9 | 56 | 4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.065217 | 0.178571 | 56 | 3 | 33 | 18.666667 | 0.717391 | 0 | 0 | 0 | 0 | 0 | 0.089286 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
1bcb0839f77683c67e5ff43e8454e47e2e606524 | 7,546 | py | Python | starshipcreator/generator/models.py | pahrens82/StarfinderShipCreator | 0f7af8cf1fad8bbd8f8d1edbeea25133eefb3c59 | [
"MIT"
] | 1 | 2021-07-29T03:56:54.000Z | 2021-07-29T03:56:54.000Z | starshipcreator/generator/models.py | pahrens82/StarfinderShipCreator | 0f7af8cf1fad8bbd8f8d1edbeea25133eefb3c59 | [
"MIT"
] | null | null | null | starshipcreator/generator/models.py | pahrens82/StarfinderShipCreator | 0f7af8cf1fad8bbd8f8d1edbeea25133eefb3c59 | [
"MIT"
] | null | null | null | from django.db import models
ARC = (
('Forward', 'Forward'),
('Aft', 'Aft'),
('Port', 'Port'),
('Starboard', 'Starboard'),
)
COMPUTER_BONUS = (
('+0', '+0'),
('+1', '+1'),
('+1/+1', '+1/+1'),
('+1/+1/+1', '+1/+1/+1'),
('+1/+1/+1/+1', '+1/+1/+1/+1'),
('+2', '+2'),
('+2/+2', '+2/+2'),
('+2/+2/+2', '+2/+2/+2'),
('+2/+2/+2/+2', '+2/+2/+2/+2'),
('+3', '+3'),
('+3/+3', '+3/+3'),
('+3/+3/+3', '+3/+3/+3'),
('+3/+3/+3/+3', '+3/+3/+3/+3'),
('+4', '+4'),
('+4/+4', '+4/+4'),
('+4/+4/+4', '+4/+4/+4'),
('+5', '+5'),
('+5/+5', '+5/+5'),
('+5/+5/+5', '+5/+5/+5'),
('+6', '+6'),
('+6/+6', '+6/+6'),
('+7', '+7'),
('+7/+7', '+7/+7'),
('+8', '+8'),
('+8/+8', '+8/+8'),
)
WEIGHT = (
('Light', 'Light'),
('Heavy', 'Heavy'),
('Capital', 'Capital'),
)
TYPE = (
('Direct Fire', 'Direct Fire'),
('Tracking', 'Tracking'),
)
RANGES = (
('Short', 'Short'),
('Medium', 'Medium'),
('Long', 'Long'),
)
DICE = (
('d4', 'd4'),
('d6', 'd6'),
('d8', 'd8'),
('d10', 'd10'),
('d12', 'd12'),
('d20', 'd20'),
)
class Size(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Size'
)
length = models.PositiveIntegerField
weight = models.PositiveIntegerField
ac_tl_mod = models.IntegerField
class Tier(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Tier',
)
build_points = models.PositiveIntegerField(default=0)
special = models.BooleanField
class Maneuverability(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Tier',
)
distance = models.PositiveIntegerField(default=2)
pilot_modifier = models.IntegerField(default=0)
class Frame(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Frame',
)
size = models.ForeignKey(
Size,
on_delete=models.CASCADE,
)
maneuverability = models.ForeignKey(
Maneuverability,
on_delete=models.CASCADE,
)
hitpoints = models.PositiveIntegerField(default=0)
DT = models.PositiveIntegerField(default=0)
CT = models.PositiveIntegerField(default=0)
arc = models.CharField(
max_length=100,
choices=ARC,
)
expansions = models.PositiveIntegerField(default=0)
min_crew = models.PositiveIntegerField(default=0)
max_crew = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class Core(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Power Core',
)
size = models.ForeignKey(
Size,
on_delete=models.CASCADE,
)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class Thruster(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Thruster',
)
size = models.ForeignKey(
Size,
on_delete=models.CASCADE,
)
speed = models.PositiveIntegerField(default=0)
pilot_mod = models.IntegerField(default=0)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class Armor(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Armor',
)
ac_bonus = models.PositiveIntegerField(default=0)
# special = models.ForeignKey
cost = models.PositiveIntegerField(default=0)
class Computer(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Computer',
)
bonus = models.CharField(
max_length=100,
choices=COMPUTER_BONUS,
)
nodes = models.PositiveIntegerField(default=0)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class CrewQuarter(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Quarters',
)
cost = models.PositiveIntegerField(default=0)
class Countermeasure(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Countermeasure',
)
bonus = models.PositiveIntegerField(default=0)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class DriftEngine(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Drift Engine',
)
rating = models.PositiveIntegerField(default=0)
min_pcu = models.PositiveIntegerField(default=0)
max_size = models.ForeignKey(
Size,
on_delete=models.CASCADE,
)
class ExpansionBay(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Expansion Bay',
)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class Security(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Security',
)
cost = models.PositiveIntegerField(default=0)
class Sensors(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Sensor',
)
range = models.CharField(
max_length=100,
choices=RANGES,
)
modifier = models.IntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class Shields(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Shield',
)
shield_points = models.PositiveIntegerField(default=0)
regen = models.PositiveIntegerField(default=0)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
class Weapons(models.Model):
name = models.CharField(
max_length=100,
verbose_name='Name',
)
weight = models.CharField(
max_length=100,
choices=WEIGHT,
)
type = models.CharField(
max_length=100,
choices=TYPE,
)
range = models.CharField(
max_length=100,
choices=RANGES,
)
speed = models.PositiveIntegerField(default=0)
damage_number = models.PositiveIntegerField(default=0)
damage_die = models.CharField(
max_length=100,
verbose_name='Damage Die',
choices=DICE,
)
pcu = models.PositiveIntegerField(default=0)
cost = models.PositiveIntegerField(default=0)
# properties = models.ForeignKey(
# Properties,
# on_delete=models.CASCADE,
# )
class Starship(models.Model):
tier = models.ForeignKey(Tier, on_delete=models.CASCADE)
frame = models.ForeignKey(Frame, on_delete=models.CASCADE)
core = models.ForeignKey(Core, on_delete=models.CASCADE)
thrusters = models.ForeignKey(Thruster, on_delete=models.CASCADE)
armor = models.ForeignKey(Armor, on_delete=models.CASCADE)
computer = models.ForeignKey(Computer, on_delete=models.CASCADE)
crew_quarters = models.ForeignKey(CrewQuarter, on_delete=models.CASCADE)
countermeasures = models.ForeignKey(Countermeasure, on_delete=models.CASCADE)
drift_engine = models.ForeignKey(DriftEngine, on_delete=models.CASCADE)
expansion_bays = models.ForeignKey(ExpansionBay, on_delete=models.CASCADE)
security = models.ForeignKey(Security, on_delete=models.CASCADE)
sensors = models.ForeignKey(Sensors, on_delete=models.CASCADE)
shields = models.ForeignKey(Shields, on_delete=models.CASCADE)
weapons = models.ForeignKey(Weapons, on_delete=models.CASCADE)
| 25.931271 | 81 | 0.622714 | 821 | 7,546 | 5.628502 | 0.133983 | 0.219433 | 0.264229 | 0.264878 | 0.616317 | 0.519368 | 0.441679 | 0.433456 | 0.36399 | 0.36399 | 0 | 0.039366 | 0.222369 | 7,546 | 290 | 82 | 26.02069 | 0.748125 | 0.01418 | 0 | 0.319672 | 0 | 0 | 0.076561 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.004098 | 0 | 0.42623 | 0 | 0 | 0 | 0 | null | 1 | 1 | 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 | 3 |
1bdb08803ddd92f53dc0c20f3fd83fb0d5fb3bd0 | 1,915 | py | Python | tvaf/auth.py | AllSeeingEyeTolledEweSew/tvaf-ftp | c53ed4b8b6715d10567fca85847000356a2c7793 | [
"0BSD"
] | null | null | null | tvaf/auth.py | AllSeeingEyeTolledEweSew/tvaf-ftp | c53ed4b8b6715d10567fca85847000356a2c7793 | [
"0BSD"
] | null | null | null | tvaf/auth.py | AllSeeingEyeTolledEweSew/tvaf-ftp | c53ed4b8b6715d10567fca85847000356a2c7793 | [
"0BSD"
] | null | null | null | # Copyright (c) 2020 AllSeeingEyeTolledEweSew
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
import contextlib
import threading
from typing import cast
from typing import ContextManager
from typing import Optional
class Error(Exception):
pass
class AuthenticationFailed(Error):
pass
class _UserContext(contextlib.AbstractContextManager):
def __init__(self, auth_service: "AuthService") -> None:
self.auth_service = auth_service
def __enter__(self) -> None:
pass
def __exit__(self, exc_type, exc_value, traceback) -> None:
self.auth_service.pop_user()
class AuthService:
USER = "tvaf"
PASSWORD = "U15OwvGt"
def __init__(self) -> None:
self._local = threading.local()
def auth_password_plain(self, user: str, password: str) -> None:
if (user, password) == (self.USER, self.PASSWORD):
return
raise AuthenticationFailed()
def push_user(self, user: str) -> ContextManager[None]:
assert self.get_user() is None
ctx = _UserContext(self)
self._local.user = user
return ctx
def get_user(self) -> Optional[str]:
return cast(Optional[str], getattr(self._local, "user", None))
def pop_user(self) -> None:
assert self.get_user() is not None
self._local.user = None
| 29.015152 | 79 | 0.703916 | 249 | 1,915 | 5.269076 | 0.433735 | 0.033537 | 0.036585 | 0.028963 | 0.035061 | 0.035061 | 0 | 0 | 0 | 0 | 0 | 0.003992 | 0.215144 | 1,915 | 65 | 80 | 29.461538 | 0.868929 | 0.338903 | 0 | 0.085714 | 0 | 0 | 0.021548 | 0 | 0 | 0 | 0 | 0 | 0.057143 | 1 | 0.228571 | false | 0.171429 | 0.142857 | 0.028571 | 0.628571 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
59f3f938a9fdcb844f9bbabcbcc6ee6635d2c71d | 3,508 | py | Python | notepad.py | Aman817/chatbot_app | ac0dc8e01af1be022598f98f2e9a6d545b53593a | [
"MIT"
] | null | null | null | notepad.py | Aman817/chatbot_app | ac0dc8e01af1be022598f98f2e9a6d545b53593a | [
"MIT"
] | null | null | null | notepad.py | Aman817/chatbot_app | ac0dc8e01af1be022598f98f2e9a6d545b53593a | [
"MIT"
] | null | null | null | import os
import time
import pyttsx3
import commands
import speech_recognition as sr
import start1
def start():
os.system("cls")
print("\n\n\n\t\t ###>>+++... ,,,,.._____")
print("\t\t ########### ########### ##### ## ## ## ###################### ")
print("\t\t ########### ########### ## ## ## ## ## ## ## ")
print("\t\t ########### ########### ## ### ## ## ## ## ## ")
print("\t\t ########### ########### ## ## ## ## ## ## ")
print("\t\t ^^^^^^^^^^^ ^^--++::### ## ########### ############## ## ")
print("\t\t ########### ########### ## ## ## ## ## ## ")
print("\t\t ########### ########### ## ## ## ## ## ## ")
print("\t\t ########### ########### ## ## ## ## ## ## ## ")
print("\t\t ########### ########### ## ## ## ## ## ## ## ")
print("\t\t ^^^^^^^^^^^ ^^^^^^++++: ##### ## ## ## ## ## \n\n")
speak()
editors()
def speak():
pyttsx3.speak("WELCOME TO THE EDIT MENU")
print("=="*60 , end="")
print("EDITORS")
print("=="*60 , end="")
def editors():
pyttsx3.speak("HERE ARE SOME OF THE EDITORS")
while True:
start1.start2()
print('''\n
[1] NOTEPAD
[2] NOTEPAD++
[3] WORDPAD
[0] BACK
''')
print("=="*60 , end="")
pyttsx3.speak("WHICH EDITOR SHOULD I OPEN")
a = input("ASK ME ANYTHING: ")
if ((("open" in a) or ("start" in a)) and (("notepad" in a) and ("++" not in a))):
pyttsx3.speak("NOTEPAD SUCCESSFULLY OPENED")
os.system("notepad")
elif ((("open" in a) or ("start" in a)) and (("notepad" in a) and ("++" in a))):
pyttsx3.speak("NOTEPAD PLUS PLUS SUCCESSFULLY OPENED")
os.system("notepad++")
time.sleep(3)
elif ((("open" in a) or ("start" in a)) and ("wordpad" in a)):
pyttsx3.speak("WORDPRESS SUCCESSFULLY OPENED")
os.system("wordpad")
elif(("previous" in a) or ("return" in a) or ("back" in a)):
commands.start()
else:
print('''
.....
@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@
@@@@ @@@@@@ @@@@@
@@@@@@@@@@@@@@@@@@@
@@@@@ @@@@@
@@@ @@@
@@@@@@@@@@@@@
^^^^^^
WRONG SEARCH
''')
pyttsx3.speak("YOU HAVE SEARCHED SOMETHING IRRELEVANT")
time.sleep(1)
| 43.85 | 134 | 0.243444 | 216 | 3,508 | 3.925926 | 0.328704 | 0.049528 | 0.082547 | 0.09434 | 0.325472 | 0.195755 | 0.195755 | 0.195755 | 0.195755 | 0.162736 | 0 | 0.013756 | 0.523375 | 3,508 | 79 | 135 | 44.405063 | 0.493421 | 0 | 0 | 0.19697 | 0 | 0 | 0.63512 | 0.006271 | 0 | 0 | 0 | 0 | 0 | 1 | 0.045455 | false | 0 | 0.090909 | 0 | 0.136364 | 0.257576 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9438f6c87582fc0aca444296b22942452c48455d | 94 | py | Python | pakage_lists.py | ryuya1123/pc_status_app | 89dc1e0ff16380de7306fde325463dfead2d62df | [
"MIT"
] | null | null | null | pakage_lists.py | ryuya1123/pc_status_app | 89dc1e0ff16380de7306fde325463dfead2d62df | [
"MIT"
] | null | null | null | pakage_lists.py | ryuya1123/pc_status_app | 89dc1e0ff16380de7306fde325463dfead2d62df | [
"MIT"
] | null | null | null | import platform
from pip import _internal
v = platform.platform()
_internal.main(['list'])
| 11.75 | 25 | 0.744681 | 12 | 94 | 5.666667 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138298 | 94 | 7 | 26 | 13.428571 | 0.839506 | 0 | 0 | 0 | 0 | 0 | 0.042553 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
943b6d6156f2a021ff0c62cb1bf6ad02c74fb90d | 235 | py | Python | VariableScope1.py | stevoWinke1/python | 70649dd2a3801584af1394b0a68e6f1befa39ef2 | [
"MIT"
] | null | null | null | VariableScope1.py | stevoWinke1/python | 70649dd2a3801584af1394b0a68e6f1befa39ef2 | [
"MIT"
] | null | null | null | VariableScope1.py | stevoWinke1/python | 70649dd2a3801584af1394b0a68e6f1befa39ef2 | [
"MIT"
] | 9 | 2016-10-14T15:22:31.000Z | 2016-10-14T15:50:47.000Z | var = 'foo'
def ex2():
var = 'bar'
print ('inside the function var is ', var)
ex2()
def ex3():
global var
var = 'bar'
print ('inside the function var is ', var)
ex3()
print ('outside the function var is ', var)
| 14.6875 | 46 | 0.578723 | 35 | 235 | 3.885714 | 0.371429 | 0.242647 | 0.308824 | 0.352941 | 0.669118 | 0.529412 | 0.529412 | 0.529412 | 0.529412 | 0 | 0 | 0.023529 | 0.276596 | 235 | 15 | 47 | 15.666667 | 0.776471 | 0 | 0 | 0.363636 | 0 | 0 | 0.387234 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0 | 0 | 0 | 0.181818 | 0.272727 | 0 | 0 | 0 | null | 1 | 1 | 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 | 3 |
94519f27c908a4780bc6a2fd607a200dbcfd3e42 | 311 | py | Python | engine/timer.py | UnidayStudio/Easy-2D-Game-Engine | 1a8501cba538d7542b0e24bf64eead388085480f | [
"MIT"
] | 8 | 2019-12-15T22:32:30.000Z | 2021-06-14T07:38:51.000Z | engine/timer.py | UnidayStudio/Easy-2D-Game-Engine | 1a8501cba538d7542b0e24bf64eead388085480f | [
"MIT"
] | null | null | null | engine/timer.py | UnidayStudio/Easy-2D-Game-Engine | 1a8501cba538d7542b0e24bf64eead388085480f | [
"MIT"
] | 2 | 2020-09-10T17:34:23.000Z | 2021-03-11T09:26:26.000Z | import pygame
class Timer():
def __init__(self):
self._time = 0
self.reset()
def _getTicks(self): # in seconds
return pygame.time.get_ticks() / 1000
def set(self, value):
self._time = self._getTicks() - value
def reset(self):
self.set(0)
def get(self):
return self._getTicks() - self._time | 17.277778 | 39 | 0.675241 | 46 | 311 | 4.326087 | 0.413043 | 0.120603 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023622 | 0.18328 | 311 | 18 | 40 | 17.277778 | 0.759843 | 0.032154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.384615 | false | 0 | 0.076923 | 0.153846 | 0.692308 | 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 | 1 | 1 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.