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
961f8e0ded1739e7f84175c2bdac8bbf64966432
8,270
py
Python
test/xslt/borrowed/sm_20000304.py
zepheira/amara
d3ffe07d6e2266b34d72b012a82d572c8edbf1e7
[ "Apache-2.0" ]
6
2015-01-30T03:50:36.000Z
2022-03-20T16:09:58.000Z
test/xslt/borrowed/sm_20000304.py
zepheira/amara
d3ffe07d6e2266b34d72b012a82d572c8edbf1e7
[ "Apache-2.0" ]
2
2015-02-04T17:18:47.000Z
2019-09-27T23:39:52.000Z
test/xslt/borrowed/sm_20000304.py
zepheira/amara
d3ffe07d6e2266b34d72b012a82d572c8edbf1e7
[ "Apache-2.0" ]
6
2015-02-04T16:16:18.000Z
2019-10-30T20:07:48.000Z
######################################################################## # test/xslt/sm20000304.py # Example from Steve Muench <smuench@us.oracle.com> # to Jon Smirl <jonsmirl@mediaone.net> # on 4 March 2000 """ From: "Steve Muench" <smuench@us.oracle.com> To: <xsl-list@mulberrytech.com> Subject: Re: SVG charts and graphs from XML input Date: Sat, 4 Mar 2000 18:02:53 -0800 (19:02 MST) This is by no means a bullet-proof, one-size-fits all charting stylesheet, but it *was* my first foray into SVG from XSLT. Given XML results of an Oracle XSQL Page like: <xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo"> select ename, sal from dept </xsql:query> Which under the covers produces a dynamic XML doc like: [SNIP source] The following "salchart.xsl" XSLT stylesheet renders a dynamic bar chart with "cool colors" for the employees in the department. You may have to modify the namespace of the Java extension functions to get it to work in XT or Saxon or other XSLT engines. [SNIP stylesheet] """ import os import cStringIO import unittest from amara.lib import treecompare from amara.test import test_main from amara.test.xslt import xslt_test, filesource, stringsource ### dalke - added to make the imports work def NumberValue(x): return x #Extensions ORACLE_JAVA_NS = 'http://www.oracle.com/XSL/Transform/java' JAVA_COLOR_NS = ORACLE_JAVA_NS + '/java.awt.Color' JAVA_INTEGER_NS = ORACLE_JAVA_NS + '/java.lang.Integer' def Java_Color_GetHSBColor(context, hue, saturation, brightness): hue = NumberValue(hue) saturation = NumberValue(saturation) brightness = NumberValue(brightness) if saturation == 0: r = g = b = int(brightness * 255) else: r = g = b = 0 h = (hue - int(hue)) * 6.0 f = h - int(h) p = brightness * (1.0 - saturation) q = brightness * (1.0 - saturation * f) t = brightness * (1.0 - (saturation * (1.0 - f))) h = int(h) if h == 0: r = int(brightness * 255) g = int(t * 255) b = int(p * 255) elif h == 1: r = int(q * 255) g = int(brightness * 255) b = int(p * 255) elif h == 2: r = int(p * 255) g = int(brightness * 255) b = int(t * 255) elif h == 3: r = int(p * 255) g = int(q * 255) b = int(brightness * 255) elif h == 4: r = int(t * 255) g = int(p * 255) b = int(brightness * 255) elif h == 5: r = int(brightness * 255) g = int(p * 255) b = int(q * 255) return 0xff000000L | (r << 16) | (g << 8) | (b << 0) def Java_Color_GetRed(context, color): color = NumberValue(color) return (long(color) >> 16) & 0xff def Java_Color_GetGreen(context, color): color = NumberValue(color) return (long(color) >> 8) & 0xff def Java_Color_GetBlue(context, color): color = NumberValue(color) return long(color) & 0xff def Java_Integer_ToHexString(context, number): return '%X' % NumberValue(number) ExtFunctions = { (JAVA_COLOR_NS, 'getHSBColor') : Java_Color_GetHSBColor, (JAVA_COLOR_NS, 'getRed') : Java_Color_GetRed, (JAVA_COLOR_NS, 'getGreen') : Java_Color_GetGreen, (JAVA_COLOR_NS, 'getBlue') : Java_Color_GetBlue, (JAVA_INTEGER_NS, 'toHexString') : Java_Integer_ToHexString, } class test_xslt_call_template_ed_20010101(xslt_test): source = stringsource("""<?xml version = '1.0'?> <ROWSET> <ROW num="1"> <ENAME>CLARK</ENAME> <SAL>2450</SAL> </ROW> <ROW num="2"> <ENAME>KING</ENAME> <SAL>3900</SAL> </ROW> <ROW num="3"> <ENAME>MILLER</ENAME> <SAL>1300</SAL> </ROW> </ROWSET> """) transform = stringsource('''<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:Color="http://www.oracle.com/XSL/Transform/java/java.awt.Color" xmlns:Integer="http://www.oracle.com/XSL/Transform/java/java.lang.Integer" exclude-result-prefixes="Color Integer"> <xsl:output media-type="image/svg"/> <xsl:template match="/"> <svg xml:space="preserve" width="1000" height="1000"> <desc>Salary Chart</desc> <g style="stroke:#000000;stroke-width:1;font-family:Arial;font-size:16"> <xsl:for-each select="ROWSET/ROW"> <xsl:call-template name="drawBar"> <xsl:with-param name="rowIndex" select="position()"/> <xsl:with-param name="ename" select="ENAME"/> <xsl:with-param name="sal" select="number(SAL)"/> </xsl:call-template> </xsl:for-each> </g> </svg> </xsl:template> <xsl:template name="drawBar"> <xsl:param name="rowIndex" select="number(0)"/> <xsl:param name="ename"/> <xsl:param name="sal" select="number(0)"/> <xsl:variable name="xOffset" select="number(100)"/> <xsl:variable name="yOffset" select="number(20)"/> <xsl:variable name="barHeight" select="number(25)"/> <xsl:variable name="gap" select="number(10)"/> <xsl:variable name="x" select="$xOffset"/> <xsl:variable name="y" select="$yOffset + $rowIndex * ($barHeight + $gap)"/> <xsl:variable name="barWidth" select="$sal div number(10)"/> <rect x="{$x}" y="{$y}" height="{$barHeight}" width="{$barWidth}"> <xsl:attribute name="style"> <xsl:text>fill:#</xsl:text> <xsl:call-template name="getCoolColorStr" xml:space="default"> <xsl:with-param name="colorIndex" select="$rowIndex"/> <xsl:with-param name="totalColors" select="number(14)"/> </xsl:call-template> <xsl:text> </xsl:text> </xsl:attribute> </rect> <xsl:variable name="fontHeight" select="number(18)"/> <text x="20" y="{$y + $fontHeight}"> <xsl:value-of select="$ename"/> </text> <xsl:variable name="x2" select="$xOffset + $barWidth + 10"/> <text x="{$x2}" y="{$y + $fontHeight}"> <xsl:value-of select="$sal"/> </text> </xsl:template> <xsl:template name="getCoolColorStr"> <xsl:param name="colorIndex"/> <xsl:param name="totalColors"/> <xsl:variable name="SATURATION" select="number(0.6)"/> <xsl:variable name="BRIGHTNESS" select="number(0.9)"/> <xsl:variable name="hue" select="$colorIndex div $totalColors"/> <xsl:variable name="c" select="Color:getHSBColor($hue, $SATURATION, $BRIGHTNESS)"/> <xsl:variable name="r" select="Color:getRed($c)"/> <xsl:variable name="g" select="Color:getGreen($c)"/> <xsl:variable name="b" select="Color:getBlue($c)"/> <xsl:variable name="rs" select="Integer:toHexString($r)"/> <xsl:variable name="gs" select="Integer:toHexString($g)"/> <xsl:variable name="bs" select="Integer:toHexString($b)"/> <xsl:if test="$r &lt; 16">0</xsl:if><xsl:value-of select="$rs"/> <xsl:if test="$g &lt; 16">0</xsl:if><xsl:value-of select="$gs"/> <xsl:if test="$b &lt; 16">0</xsl:if><xsl:value-of select="$bs"/> </xsl:template> </xsl:stylesheet> ''') parameters = {} expected = """<?xml version='1.0' encoding='UTF-8'?> <svg height='1000' xml:space='preserve' width='1000'> <desc>Salary Chart</desc> <g style='stroke:#000000;stroke-width:1;font-family:Arial;font-size:16'> <rect height='25' x='100' style='fill:#E5965B ' width='245' y='55'/><text x='20' y='73'>CLARK</text><text x='355' y='73'>2450</text> <rect height='25' x='100' style='fill:#E5D15B ' width='390' y='90'/><text x='20' y='108'>KING</text><text x='500' y='108'>3900</text> <rect height='25' x='100' style='fill:#BEE55B ' width='130' y='125'/><text x='20' y='143'>MILLER</text><text x='240' y='143'>1300</text> </g> </svg>""" # def test_transform(self): # import sys # from amara.xslt import transform # # result = transform(self.source, self.transform, output=io) # # #FIXME: the numerics break under Python 2.3 # test_harness.XsltTest(tester, source, [sheet], expected_1, # extensionModules=[__name__]) # # self.assert_(treecompare.html_compare(self.expected, io.getvalue())) # # return # Hide the test framework from nose del xslt_test if __name__ == '__main__': test_main()
32.687747
143
0.606167
1,128
8,270
4.384752
0.257979
0.042256
0.057622
0.016175
0.220178
0.18055
0.170036
0.124141
0.047311
0.031541
0
0.048328
0.21185
8,270
252
144
32.81746
0.710494
0.072914
0
0.173653
0
0.071856
0.624723
0.131894
0
0
0.001774
0.003968
0
0
null
null
0
0.035928
null
null
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
2
9625303d504fb10bd57521a4e704cb6335319f31
984
py
Python
src/count_targets.py
kahvel/MAProject
1c17d0c3fde6d9acc7dd3861f926e8af0ddac222
[ "MIT" ]
null
null
null
src/count_targets.py
kahvel/MAProject
1c17d0c3fde6d9acc7dd3861f926e8af0ddac222
[ "MIT" ]
null
null
null
src/count_targets.py
kahvel/MAProject
1c17d0c3fde6d9acc7dd3861f926e8af0ddac222
[ "MIT" ]
null
null
null
from main import readData, getTrueLabels, binariseLabels, removePacketsAfterChange label_data = list() label_data.append(readData("..\\data\\test5_targets_1.csv")) label_data.append(readData("..\\data\\test5_targets_2.csv")) label_data.append(readData("..\\data\\test5_targets_3.csv")) labels = [getTrueLabels(label) for label in label_data] binarised_labels = dict() binarised_labels[1] = [binariseLabels(label, 1) for label in labels] binarised_labels[2] = [binariseLabels(label, 2) for label in labels] binarised_labels[3] = [binariseLabels(label, 3) for label in labels] for target in [1,2,3]: for dataset in [0,1,2]: _, binarised_labels[target][dataset] =\ removePacketsAfterChange(binarised_labels[target][dataset], binarised_labels[target][dataset], label_data[dataset], 256) for target in [1,2,3]: for dataset in [0,1,2]: print "Dataset:", str(dataset+1), "Target:", str(target), "Count:", str(sum(binarised_labels[target][dataset]))
41
132
0.727642
134
984
5.186567
0.223881
0.172662
0.057554
0.161151
0.34964
0.34964
0.260432
0.204317
0.083453
0.083453
0
0.03237
0.120935
984
23
133
42.782609
0.771098
0
0
0.235294
0
0
0.109756
0.088415
0
0
0
0
0
0
null
null
0
0.058824
null
null
0.058824
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
2
96262446beb9d081c0d44d53817c947e2939b91a
711
py
Python
src/actionsold.py
Grumpy-Old-Tech/WorkshopAssistant
704e8080e76ba6feabd6eee3e1965439336306ad
[ "MIT" ]
null
null
null
src/actionsold.py
Grumpy-Old-Tech/WorkshopAssistant
704e8080e76ba6feabd6eee3e1965439336306ad
[ "MIT" ]
null
null
null
src/actionsold.py
Grumpy-Old-Tech/WorkshopAssistant
704e8080e76ba6feabd6eee3e1965439336306ad
[ "MIT" ]
null
null
null
#!/usr/bin/env python #This is different from AIY Kit's actions #Copying and Pasting AIY Kit's actions commands will not work from googleapiclient.discovery import build from googleapiclient.errors import HttpError from gmusicapi import Mobileclient from googletrans import Translator from gtts import gTTS import requests import os import os.path import RPi.GPIO as GPIO import time import re import subprocess import json import urllib.request import pafy #API Key for YouTube and KS Search Engine google_cloud_api_key='ENTER-YOUR-GOOGLE-CLOUD-API-KEY-HERE' #YouTube API Constants DEVELOPER_KEY = google_cloud_api_key YOUTUBE_API_SERVICE_NAME = 'youtube' YOUTUBE_API_VERSION = 'v3' playshell = None
19.75
61
0.819972
109
711
5.238532
0.577982
0.042032
0.073555
0.089317
0
0
0
0
0
0
0
0.001623
0.133615
711
35
62
20.314286
0.925325
0.254571
0
0
0
0
0.086372
0.069098
0
0
0
0
0
1
0
false
0
0.75
0
0.75
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
2
8251357bc0686fc467cb6924c7a1a83a74692825
973
py
Python
ietf/utils/resources.py
wpjesus/codematch
eee7405259cce9239ea0545a2a1300ee1accfe94
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2015-09-02T19:53:12.000Z
2015-09-02T19:53:12.000Z
ietf/utils/resources.py
wpjesus/codematch
eee7405259cce9239ea0545a2a1300ee1accfe94
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
ietf/utils/resources.py
wpjesus/codematch
eee7405259cce9239ea0545a2a1300ee1accfe94
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
# Autogenerated by the mkresources management command 2014-11-13 05:39 from tastypie.resources import ModelResource from tastypie.fields import CharField from tastypie.constants import ALL from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from ietf import api from ietf.utils.models import DumpInfo class UserResource(ModelResource): username = CharField() class Meta: queryset = User.objects.all() serializer = api.Serializer() class ContentTypeResource(ModelResource): username = CharField() class Meta: queryset = ContentType.objects.all() serializer = api.Serializer() class DumpInfoResource(ModelResource): class Meta: queryset = DumpInfo.objects.all() serializer = api.Serializer() #resource_name = 'dumpinfo' filtering = { "date": ALL, "host": ALL, } api.utils.register(DumpInfoResource())
27.8
70
0.70298
102
973
6.696078
0.45098
0.052709
0.074671
0.101025
0.297218
0.248902
0
0
0
0
0
0.015686
0.213772
973
34
71
28.617647
0.877124
0.096608
0
0.307692
1
0
0.009143
0
0
0
0
0
0
1
0
false
0
0.269231
0
0.576923
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
2
8253b8de6bfcb3c4b2705d87c3cbd83db498bfb5
1,129
py
Python
153_find_minimum_in_rotated_sorted_array.py
gengwg/leetcode
0af5256ec98149ef5863f3bba78ed1e749650f6e
[ "Apache-2.0" ]
2
2018-04-24T19:17:40.000Z
2018-04-24T19:33:52.000Z
153_find_minimum_in_rotated_sorted_array.py
gengwg/leetcode
0af5256ec98149ef5863f3bba78ed1e749650f6e
[ "Apache-2.0" ]
null
null
null
153_find_minimum_in_rotated_sorted_array.py
gengwg/leetcode
0af5256ec98149ef5863f3bba78ed1e749650f6e
[ "Apache-2.0" ]
3
2020-06-17T05:48:52.000Z
2021-01-02T06:08:25.000Z
# 153. Find Minimum in Rotated Sorted Array # # Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. # # (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). # # Find the minimum element. # # You may assume no duplicate exists in the array. class Solution(object): # http://bookshadow.com/weblog/2014/10/16/leetcode-find-minimum-rotated-sorted-array/ def findMin(self, nums): """ :type nums: List[int] :rtype: int """ l, r = 0, len(nums) - 1 while l < r: m = (l + r) / 2 # if nums[m] <= nums[r]: if nums[m] < nums[r]: r = m else: l = m + 1 return nums[l] # http://www.cnblogs.com/zuoyuan/p/4045742.html def findMin(self, nums): l, r = 0, len(nums) - 1 while l < r and nums[l] > nums[r]: m = (l + r) / 2 if nums[m] < nums[r]: r = m else: l = m + 1 return nums[l] if __name__ == '__main__': print Solution().findMin([4, 5, 6, 7, 0, 1, 2])
26.255814
96
0.495128
169
1,129
3.260355
0.43787
0.021779
0.016334
0.021779
0.245009
0.245009
0.245009
0.219601
0.219601
0.15608
0
0.066384
0.372896
1,129
42
97
26.880952
0.711864
0.366696
0
0.761905
0
0
0.012559
0
0
0
0
0
0
0
null
null
0
0
null
null
0.047619
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
2
8254e7450b3c4e0f6d891fdfe8c1ab7c064377f8
1,423
py
Python
babylon_server/babylon/config.py
ajponte/babylon
e743f5b3bb5b2eb864247414c4f51962eea9108e
[ "MIT" ]
null
null
null
babylon_server/babylon/config.py
ajponte/babylon
e743f5b3bb5b2eb864247414c4f51962eea9108e
[ "MIT" ]
2
2021-11-08T18:09:22.000Z
2021-11-09T19:22:33.000Z
babylon_server/babylon/config.py
ajponte/babylon
e743f5b3bb5b2eb864247414c4f51962eea9108e
[ "MIT" ]
null
null
null
import os class Config: # Statement for enabling the development environment DEBUG = True # Define the application directory BASE_DIR = os.path.abspath(os.path.dirname(__file__)) # Logging config. LOG_DIR = "logs" LOG_TYPE = ["LOG_TYPE", "watched"] LOG_LEVEL = "DEBUG" APP_LOG_NAME = "babylon_server.log" # WWW_LOG_NAME is for log rotation, which is currently not set up. # Log files sit in the `logs` directory. WWW_LOG_NAME = "babylon_server.log" LOG_MAX_BYTES = 100_000_000 # 100MB in bytes LOG_COPIES = 5 # All the MySql options are under the assumption that the only database at this time is the # `activity` database. MYSQL_DATABASE_HOST = "localhost" MYSQL_DATABASE_NAME = "activity" MYSQL_DATABASE_PORT = "3308" MYSQL_DATABASE_USER = "application" MYSQL_DATABASE_PWD = "application123" MYSQL_UNIX_SOCKET = "/var/run/mysqld/mysqld.sock" SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{MYSQL_DATABASE_USER}:{MYSQL_DATABASE_PWD}@{MYSQL_DATABASE_HOST}:{MYSQL_DATABASE_PORT}/{MYSQL_DATABASE_NAME}?{MYSQL_UNIX_SOCKET}' # noqa # Pool recycle is recommended for MySQL. # See https://docs.sqlalchemy.org/en/14/core/pooling.html#setting-pool-recycle SQLALCHEMY_POOL_RECYCLE = 3600 SQLALCHEMY_BINDS = { 'db2': 'mysql://user:pass@localhost/activity', 'db3': 'mysql://user:pass@localhost/user' }
37.447368
185
0.709065
191
1,423
5.015707
0.513089
0.135699
0.029228
0.041754
0.048017
0
0
0
0
0
0
0.024306
0.190443
1,423
37
186
38.459459
0.807292
0.315531
0
0
0
0
0.365245
0.248699
0
0
0
0
0
1
0
false
0.086957
0.043478
0
0.869565
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
82559085472d1981739859824315a98440b83c6f
131
py
Python
etherscan_py/__init__.py
saltduck/etherscan_py
1a4ac48733d832d6dc4c8f74fafd7af4c3ce675e
[ "MIT" ]
6
2021-02-20T10:32:36.000Z
2022-02-10T17:00:00.000Z
etherscan_py/__init__.py
saltduck/etherscan_py
1a4ac48733d832d6dc4c8f74fafd7af4c3ce675e
[ "MIT" ]
2
2020-11-19T04:39:25.000Z
2021-03-05T12:40:21.000Z
etherscan_py/__init__.py
saltduck/etherscan_py
1a4ac48733d832d6dc4c8f74fafd7af4c3ce675e
[ "MIT" ]
3
2021-03-03T18:37:26.000Z
2021-04-04T14:14:05.000Z
"""Top-level package for etherscan-py.""" __author__ = """Julian Koh""" __email__ = 'juliankohtx@gmail.com' __version__ = '0.1.0'
21.833333
41
0.687023
17
131
4.588235
0.941176
0
0
0
0
0
0
0
0
0
0
0.025862
0.114504
131
5
42
26.2
0.646552
0.267176
0
0
0
0
0.4
0.233333
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
825ed7b070e5aaac9e764b86a1c9c4bdbe9ea988
4,656
py
Python
new_scraper.py
Baw25/HomeSavvy
e07fb6f78e6f68fb981c92b15df5eef981e4d0ea
[ "MIT" ]
null
null
null
new_scraper.py
Baw25/HomeSavvy
e07fb6f78e6f68fb981c92b15df5eef981e4d0ea
[ "MIT" ]
null
null
null
new_scraper.py
Baw25/HomeSavvy
e07fb6f78e6f68fb981c92b15df5eef981e4d0ea
[ "MIT" ]
null
null
null
#!/bin/python # -*- coding: utf-8 -*- # Droplet Name: ubuntu-512mb-sfo2-01 # IP Address: 138.68.252.152 # Username: root # Password: fbe29a96430704766b5054c4d9 # New Password: Rowing525 # https://medium.com/@hoppy/how-to-test-or-scrape-javascript-rendered-websites-with-python-selenium-a-beginner-step-by-c137892216aa from time import sleep from random import randint from selenium import webdriver from pyvirtualdisplay import Display class RealTassaSpider(): def __init__(self): self.url_to_crawl = "https://app.realtaasa.com/homes" self.url_login = "http://app.realtaasa.com/signin" self.all_items = [] # Open headless chromedriver def start_driver(self): print 'starting driver...' self.display = Display(visible=0, size=(800, 600)) self.display.start() self.driver = webdriver.Chrome() sleep(4) # Close chromedriver def close_driver(self): print 'closing driver...' self.display.stop() self.driver.quit() print 'closed!' # Tell the browser to get a page def get_page(self, url): print 'getting page...' self.driver.get(url) sleep(randint(2,3)) # <button type="submit" class="input mbs button--primary">Continue</button> # Getting past login def login(self): print 'getting pass the gate page...' try: form = self.driver.find_element_by_xpath('//*[@id="signInForm"]') form.find_element_by_xpath('.//*[@id="email"]').send_keys('bsteve5205@gmail.com') form.find_element_by_xpath('.//*[@id="password"]').send_keys('Rowing525') form.find_element_by_xpath('.//*[@class="input.mbs.button--primary"]').click() sleep(randint(3,5)) except Exception: pass def get_login_then_homes(self,url): print 'logging in...' self.driver.get(url_login) print 'getting pass the gate page...' try: form = self.driver.find_element_by_xpath('//*[@id="signInForm"]') form.find_element_by_xpath('.//*[@id="email"]').send_keys('bsteve5205@gmail.com') form.find_element_by_xpath('.//*[@id="password"]').send_keys('Rowing525') form.find_element_by_xpath('.//*[@class="input.mbs.button--primary"]').click() sleep(randint(3,5)) except Exception: pass home_button = self.driver.find_element_by_xpath('//*[@id="nav-homes"]') home_button.click() # <div class="desk--ten-twelfths push--desk--one-twelfth"> url for mlax address 1 address 2 Neighborhood 1 Building type BedBath Price Coowners Monthly cost Tax savings Down payment Description div#content --> main content area for all content div.grid__item one-whole > span.grid__item > a#more-photos div.one-whole > div.one-whole > div.prop-info > div.grid_item h1.alpha --> address div.beta --> address div.beta --> neighborhood div.grid__item.desk--one-third.lap--one-third.one-whole.pln --> select all div.delta.mbn.tc-cove.fw-500 --> select all div.delta.mbs --> select all div.grid__item.one-whole.pln --> select all def grab_a_tags(self): print 'grabbing list of items...' for a in self.driver.find_elements_by_xpath('//*[@class="desk--ten-twelfths push--desk--one-twelfth"]//a'): data = self.process_elements(a) if data: self.all_items.append(data) else: pass def process_elements(self, a): url = '' address_1 = '' address_2 = '' prd_price = '' neighborhood = '' building_type = '' bedbath ='' price = '' coowners = '' monthly_cost = '' tax_savings = '' down_payment = '' description = '' try: url = a.find_element_by_xpath('.//*[@id="more-photos"]').get_attribute('href') address_1 = a.find_element_by_xpath('.//*[@class="alpha mbn fw-500"]').text address_2 = a.find_element_by_xpath('.//*[@class="beta fw-300]').text prd_price = a.find_element_by_xpath('.//*[@class="price ng-scope ng-binding"]').text except Exception: pass if prd_image and prd_title and prd_price: single_item_info = { 'image': prd_image.encode('UTF-8'), 'title': prd_title.encode('UTF-8'), 'price': prd_price.encode('UTF-8') } return single_item_info else: return False def parse(self): self.start_driver() self.get_page(self.url_login) self.login() self.grab_a_tags() self.close_driver() if self.all_items: return self.all_items else: return False # Run spider RealTassa = RealTassaSpider() items_list = RealTassa.parse() # Do something with the data touched for item in items_list: print item
27.550296
131
0.649055
627
4,656
4.647528
0.323764
0.033631
0.057996
0.080302
0.333905
0.293754
0.269046
0.258751
0.23267
0.23267
0
0.026054
0.200387
4,656
168
132
27.714286
0.756648
0.135739
0
0.221311
0
0
0.174988
0.050674
0
0
0
0
0
0
null
null
0.065574
0.032787
null
null
0.07377
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
1
0
0
0
0
0
2
825ff6c34b7f590f5f9226ffd0a964d853a9a998
532
py
Python
gdsfactory/simulation/gmeep/__init__.py
gdsfactory/gdsfactory
ee761ae0b4429fbec7035bbea5d1e5206c66bea7
[ "MIT" ]
42
2020-05-25T09:33:45.000Z
2022-03-29T03:41:19.000Z
gdsfactory/simulation/gmeep/__init__.py
gdsfactory/gdsfactory
ee761ae0b4429fbec7035bbea5d1e5206c66bea7
[ "MIT" ]
133
2020-05-28T18:29:04.000Z
2022-03-31T22:21:42.000Z
gdsfactory/simulation/gmeep/__init__.py
gdsfactory/gdsfactory
ee761ae0b4429fbec7035bbea5d1e5206c66bea7
[ "MIT" ]
17
2020-06-30T07:07:50.000Z
2022-03-17T15:45:27.000Z
from gdsfactory.simulation.gmeep.add_monitors import add_monitors from gdsfactory.simulation.gmeep.get_simulation import get_simulation from gdsfactory.simulation.gmeep.get_transmission_2ports import ( get_transmission_2ports, plot2D, plot3D, ) from gdsfactory.simulation.gmeep.plot_xsection import plot_xsection __all__ = [ "add_monitors", "get_simulation", "get_sparameters1x2", "get_transmission_2ports", "plot2D", "plot3D", "plot_xsection", "plot_eigenmode", ] __version__ = "0.0.2"
25.333333
69
0.757519
60
532
6.3
0.333333
0.148148
0.253968
0.306878
0.343915
0
0
0
0
0
0
0.026549
0.150376
532
20
70
26.6
0.809735
0
0
0
0
0
0.208647
0.043233
0
0
0
0
0
1
0
false
0
0.210526
0
0.210526
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
827b053defe8919cad9935212546496cfc58073c
1,040
py
Python
kornia/constants.py
carlosb1/kornia
a2b34d497314e7ed65f114401efdd3cc9ba2077c
[ "ECL-2.0", "Apache-2.0" ]
1
2020-06-17T16:57:14.000Z
2020-06-17T16:57:14.000Z
kornia/constants.py
carlosb1/kornia
a2b34d497314e7ed65f114401efdd3cc9ba2077c
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
kornia/constants.py
carlosb1/kornia
a2b34d497314e7ed65f114401efdd3cc9ba2077c
[ "ECL-2.0", "Apache-2.0" ]
1
2022-01-26T13:39:34.000Z
2022-01-26T13:39:34.000Z
from typing import Union, TypeVar from enum import Enum import torch pi = torch.tensor(3.14159265358979323846) T = TypeVar('T', bound='Resample') U = TypeVar('U', bound='BorderType') class Resample(Enum): NEAREST = 0 BILINEAR = 1 BICUBIC = 2 @classmethod def get(cls, value: Union[str, int, T]) -> T: # type: ignore if type(value) == str: return cls[value.upper()] # type: ignore if type(value) == int: return cls(value) # type: ignore if type(value) == cls: return value # type: ignore raise TypeError() class BorderType(Enum): CONSTANT = 0 REFLECT = 1 REPLICATE = 2 CIRCULAR = 3 @classmethod def get(cls, value: Union[str, int, U]) -> U: # type: ignore if type(value) == str: return cls[value.upper()] # type: ignore if type(value) == int: return cls(value) # type: ignore if type(value) == cls: return value # type: ignore raise TypeError()
24.761905
65
0.567308
128
1,040
4.609375
0.320313
0.135593
0.122034
0.162712
0.59661
0.59661
0.59661
0.59661
0.474576
0.474576
0
0.039161
0.3125
1,040
41
66
25.365854
0.786014
0.099038
0
0.484848
0
0
0.021552
0
0
0
0
0
0
1
0.060606
false
0
0.090909
0
0.606061
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
8281775b2d035df5a898df5ea5c2730c011f5d85
109
py
Python
practice/practice_perfect/ex7.py
recursivelycurious/wordnik-repl
9d9e96a8ebc79b95f135d5bc871602b65d2d2b79
[ "MIT" ]
null
null
null
practice/practice_perfect/ex7.py
recursivelycurious/wordnik-repl
9d9e96a8ebc79b95f135d5bc871602b65d2d2b79
[ "MIT" ]
8
2017-12-29T21:19:00.000Z
2018-04-01T05:05:05.000Z
practice/practice_perfect/ex7.py
recursivelycurious/wordnik-repl
9d9e96a8ebc79b95f135d5bc871602b65d2d2b79
[ "MIT" ]
1
2017-12-27T23:45:58.000Z
2017-12-27T23:45:58.000Z
def remove_duplicates(lst): new = [] for x in lst: if x not in new: new.append(x) return new
15.571429
27
0.59633
19
109
3.368421
0.631579
0
0
0
0
0
0
0
0
0
0
0
0.302752
109
6
28
18.166667
0.842105
0
0
0
0
0
0
0
0
0
0
0
0
1
0.166667
false
0
0
0
0.333333
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
82857e9a33dbe718b0d5cc5a60fda6fb7a1add58
4,666
py
Python
env/lib/python3.8/site-packages/unidecode/x093.py
avdhari/enigma
b7e965a91ca5f0e929c4c719d695f15ccb8b5a2c
[ "MIT" ]
48
2021-11-20T08:17:53.000Z
2022-03-19T13:57:15.000Z
venv/lib/python3.6/site-packages/unidecode/x093.py
mrsaicharan1/iiita-updates
a22a0157b90d29b946d0f020e5f76744f73a6bff
[ "Apache-2.0" ]
392
2015-07-30T14:37:05.000Z
2022-03-21T16:56:09.000Z
venv/lib/python3.6/site-packages/unidecode/x093.py
mrsaicharan1/iiita-updates
a22a0157b90d29b946d0f020e5f76744f73a6bff
[ "Apache-2.0" ]
15
2015-10-01T21:31:08.000Z
2020-05-05T00:03:27.000Z
data = ( 'Lun ', # 0x00 'Kua ', # 0x01 'Ling ', # 0x02 'Bei ', # 0x03 'Lu ', # 0x04 'Li ', # 0x05 'Qiang ', # 0x06 'Pou ', # 0x07 'Juan ', # 0x08 'Min ', # 0x09 'Zui ', # 0x0a 'Peng ', # 0x0b 'An ', # 0x0c 'Pi ', # 0x0d 'Xian ', # 0x0e 'Ya ', # 0x0f 'Zhui ', # 0x10 'Lei ', # 0x11 'A ', # 0x12 'Kong ', # 0x13 'Ta ', # 0x14 'Kun ', # 0x15 'Du ', # 0x16 'Wei ', # 0x17 'Chui ', # 0x18 'Zi ', # 0x19 'Zheng ', # 0x1a 'Ben ', # 0x1b 'Nie ', # 0x1c 'Cong ', # 0x1d 'Qun ', # 0x1e 'Tan ', # 0x1f 'Ding ', # 0x20 'Qi ', # 0x21 'Qian ', # 0x22 'Zhuo ', # 0x23 'Qi ', # 0x24 'Yu ', # 0x25 'Jin ', # 0x26 'Guan ', # 0x27 'Mao ', # 0x28 'Chang ', # 0x29 'Tian ', # 0x2a 'Xi ', # 0x2b 'Lian ', # 0x2c 'Tao ', # 0x2d 'Gu ', # 0x2e 'Cuo ', # 0x2f 'Shu ', # 0x30 'Zhen ', # 0x31 'Lu ', # 0x32 'Meng ', # 0x33 'Lu ', # 0x34 'Hua ', # 0x35 'Biao ', # 0x36 'Ga ', # 0x37 'Lai ', # 0x38 'Ken ', # 0x39 'Kazari ', # 0x3a 'Bu ', # 0x3b 'Nai ', # 0x3c 'Wan ', # 0x3d 'Zan ', # 0x3e '[?] ', # 0x3f 'De ', # 0x40 'Xian ', # 0x41 '[?] ', # 0x42 'Huo ', # 0x43 'Liang ', # 0x44 '[?] ', # 0x45 'Men ', # 0x46 'Kai ', # 0x47 'Ying ', # 0x48 'Di ', # 0x49 'Lian ', # 0x4a 'Guo ', # 0x4b 'Xian ', # 0x4c 'Du ', # 0x4d 'Tu ', # 0x4e 'Wei ', # 0x4f 'Cong ', # 0x50 'Fu ', # 0x51 'Rou ', # 0x52 'Ji ', # 0x53 'E ', # 0x54 'Rou ', # 0x55 'Chen ', # 0x56 'Ti ', # 0x57 'Zha ', # 0x58 'Hong ', # 0x59 'Yang ', # 0x5a 'Duan ', # 0x5b 'Xia ', # 0x5c 'Yu ', # 0x5d 'Keng ', # 0x5e 'Xing ', # 0x5f 'Huang ', # 0x60 'Wei ', # 0x61 'Fu ', # 0x62 'Zhao ', # 0x63 'Cha ', # 0x64 'Qie ', # 0x65 'She ', # 0x66 'Hong ', # 0x67 'Kui ', # 0x68 'Tian ', # 0x69 'Mou ', # 0x6a 'Qiao ', # 0x6b 'Qiao ', # 0x6c 'Hou ', # 0x6d 'Tou ', # 0x6e 'Cong ', # 0x6f 'Huan ', # 0x70 'Ye ', # 0x71 'Min ', # 0x72 'Jian ', # 0x73 'Duan ', # 0x74 'Jian ', # 0x75 'Song ', # 0x76 'Kui ', # 0x77 'Hu ', # 0x78 'Xuan ', # 0x79 'Duo ', # 0x7a 'Jie ', # 0x7b 'Zhen ', # 0x7c 'Bian ', # 0x7d 'Zhong ', # 0x7e 'Zi ', # 0x7f 'Xiu ', # 0x80 'Ye ', # 0x81 'Mei ', # 0x82 'Pai ', # 0x83 'Ai ', # 0x84 'Jie ', # 0x85 '[?] ', # 0x86 'Mei ', # 0x87 'Chuo ', # 0x88 'Ta ', # 0x89 'Bang ', # 0x8a 'Xia ', # 0x8b 'Lian ', # 0x8c 'Suo ', # 0x8d 'Xi ', # 0x8e 'Liu ', # 0x8f 'Zu ', # 0x90 'Ye ', # 0x91 'Nou ', # 0x92 'Weng ', # 0x93 'Rong ', # 0x94 'Tang ', # 0x95 'Suo ', # 0x96 'Qiang ', # 0x97 'Ge ', # 0x98 'Shuo ', # 0x99 'Chui ', # 0x9a 'Bo ', # 0x9b 'Pan ', # 0x9c 'Sa ', # 0x9d 'Bi ', # 0x9e 'Sang ', # 0x9f 'Gang ', # 0xa0 'Zi ', # 0xa1 'Wu ', # 0xa2 'Ying ', # 0xa3 'Huang ', # 0xa4 'Tiao ', # 0xa5 'Liu ', # 0xa6 'Kai ', # 0xa7 'Sun ', # 0xa8 'Sha ', # 0xa9 'Sou ', # 0xaa 'Wan ', # 0xab 'Hao ', # 0xac 'Zhen ', # 0xad 'Zhen ', # 0xae 'Luo ', # 0xaf 'Yi ', # 0xb0 'Yuan ', # 0xb1 'Tang ', # 0xb2 'Nie ', # 0xb3 'Xi ', # 0xb4 'Jia ', # 0xb5 'Ge ', # 0xb6 'Ma ', # 0xb7 'Juan ', # 0xb8 'Kasugai ', # 0xb9 'Habaki ', # 0xba 'Suo ', # 0xbb '[?] ', # 0xbc '[?] ', # 0xbd '[?] ', # 0xbe 'Na ', # 0xbf 'Lu ', # 0xc0 'Suo ', # 0xc1 'Ou ', # 0xc2 'Zu ', # 0xc3 'Tuan ', # 0xc4 'Xiu ', # 0xc5 'Guan ', # 0xc6 'Xuan ', # 0xc7 'Lian ', # 0xc8 'Shou ', # 0xc9 'Ao ', # 0xca 'Man ', # 0xcb 'Mo ', # 0xcc 'Luo ', # 0xcd 'Bi ', # 0xce 'Wei ', # 0xcf 'Liu ', # 0xd0 'Di ', # 0xd1 'Qiao ', # 0xd2 'Cong ', # 0xd3 'Yi ', # 0xd4 'Lu ', # 0xd5 'Ao ', # 0xd6 'Keng ', # 0xd7 'Qiang ', # 0xd8 'Cui ', # 0xd9 'Qi ', # 0xda 'Chang ', # 0xdb 'Tang ', # 0xdc 'Man ', # 0xdd 'Yong ', # 0xde 'Chan ', # 0xdf 'Feng ', # 0xe0 'Jing ', # 0xe1 'Biao ', # 0xe2 'Shu ', # 0xe3 'Lou ', # 0xe4 'Xiu ', # 0xe5 'Cong ', # 0xe6 'Long ', # 0xe7 'Zan ', # 0xe8 'Jian ', # 0xe9 'Cao ', # 0xea 'Li ', # 0xeb 'Xia ', # 0xec 'Xi ', # 0xed 'Kang ', # 0xee '[?] ', # 0xef 'Beng ', # 0xf0 '[?] ', # 0xf1 '[?] ', # 0xf2 'Zheng ', # 0xf3 'Lu ', # 0xf4 'Hua ', # 0xf5 'Ji ', # 0xf6 'Pu ', # 0xf7 'Hui ', # 0xf8 'Qiang ', # 0xf9 'Po ', # 0xfa 'Lin ', # 0xfb 'Suo ', # 0xfc 'Xiu ', # 0xfd 'San ', # 0xfe 'Cheng ', # 0xff )
18.015444
21
0.388556
503
4,666
3.604374
0.827038
0
0
0
0
0
0
0
0
0
0
0.200697
0.384912
4,666
258
22
18.085271
0.43101
0.274111
0
0.593023
0
0
0.342173
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
82884c2f951413f34a94ee10615c1c83e1f50fe8
1,540
py
Python
utility_parseCMUMovie.py
bipulkumar22/pyTextClassification
7ed92949aa5648d3198588d0c5d6db89b48025ac
[ "Apache-2.0" ]
11
2016-09-16T10:38:19.000Z
2021-12-13T19:38:24.000Z
utility_parseCMUMovie.py
tyiannak/pyTextClassification
7ed92949aa5648d3198588d0c5d6db89b48025ac
[ "Apache-2.0" ]
null
null
null
utility_parseCMUMovie.py
tyiannak/pyTextClassification
7ed92949aa5648d3198588d0c5d6db89b48025ac
[ "Apache-2.0" ]
6
2016-11-19T15:35:13.000Z
2020-03-29T17:09:22.000Z
import os import csv import ast # used to generate folder-seperated corpus from CMUMovie dataset # just type python utility_parseCMUMovie.py in a terminal and the data will be downloaded and split to subfolders in the moviePlots/ path os.system("wget http://www.cs.cmu.edu/~ark/personas/data/MovieSummaries.tar.gz") os.system("tar -xvzf MovieSummaries.tar.gz") minRevenue = 20000000 movieMetadata = {} with open('MovieSummaries/movie.metadata.tsv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter='\t', quotechar='|') for row in reader: rev = 0 if len(row[4])>1: rev = int(row[4]) if (minRevenue < 0) or ( (minRevenue > 0) and (rev>minRevenue) ): movieMetadata[row[0]] = {} movieMetadata[row[0]]['title'] = row[2] movieMetadata[row[0]]['genres'] = ast.literal_eval(row[8]).values() print len(movieMetadata) with open("MovieSummaries/plot_summaries.txt") as f: content = f.readlines() for c in content: d = c.split("\t") id = d[0] plot = d[1] if id in movieMetadata: print id, movieMetadata[id]['title'] for g in movieMetadata[id]['genres']: if not os.path.exists("moviePlots" + os.sep + g.replace("/","-")): os.makedirs("moviePlots" + os.sep + g.replace("/","-")) f = open("moviePlots" + os.sep + g.replace("/","-") + os.sep + id + "_" + movieMetadata[id]["title"].replace("/","-"), 'w') f.write(plot) f.close()
37.560976
143
0.595455
201
1,540
4.542289
0.477612
0.021906
0.05586
0.052574
0.079956
0.054765
0
0
0
0
0
0.017995
0.242208
1,540
40
144
38.5
0.764353
0.129221
0
0
1
0.03125
0.177877
0.065022
0
0
0
0
0
0
null
null
0
0.09375
null
null
0.0625
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
2
828aa1df6ebc3553389f760e5439ccc3f6c4765d
981
py
Python
App/items/models/items.py
fmgar/BlackMarker-API
a185d61d518ad505d2fd8882f0e8cd15474786cb
[ "MIT" ]
null
null
null
App/items/models/items.py
fmgar/BlackMarker-API
a185d61d518ad505d2fd8882f0e8cd15474786cb
[ "MIT" ]
null
null
null
App/items/models/items.py
fmgar/BlackMarker-API
a185d61d518ad505d2fd8882f0e8cd15474786cb
[ "MIT" ]
null
null
null
"""Items model. """ # Django from django.db import models # Utilities from App.utils.models import BlackMarketModel # Models from .category import Category from .unit import Unit from .owner import Owner class Item(BlackMarketModel): """Items model. Is a model to items we goin to sell """ name = models.CharField(max_length=100, unique=True, blank=False, null=False) category = models.ForeignKey(Category, blank=True, on_delete=models.SET_NULL, null=True) description = models.TextField(max_length=200, blank=True) type_item = models.CharField(max_length=15, blank=True) unit = models.ForeignKey(Unit, blank=True, on_delete=models.SET_NULL, null=True) price = models.DecimalField(max_digits=5, decimal_places=2, blank=False, null=False) owner = models.ForeignKey(Owner, blank=True, on_delete=models.SET_NULL, null=True) is_active = models.BooleanField(default=True) def __str__(self): return 'name:{}'.format(self.name)
32.7
92
0.734964
137
981
5.138686
0.408759
0.06392
0.046875
0.072443
0.161932
0.161932
0.161932
0.161932
0.161932
0
0
0.012005
0.150866
981
29
93
33.827586
0.833133
0.090724
0
0
0
0
0.008
0
0
0
0
0
0
1
0.0625
false
0
0.3125
0.0625
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
8297797069048f1e64c87757d3ccf7043bd8704b
3,690
py
Python
src/tests/dao_test/guild_roles_dao_test.py
Veloxization/likahbot
24e22711f514fc0878cf6fb9e516ad44425ea6a7
[ "MIT" ]
null
null
null
src/tests/dao_test/guild_roles_dao_test.py
Veloxization/likahbot
24e22711f514fc0878cf6fb9e516ad44425ea6a7
[ "MIT" ]
null
null
null
src/tests/dao_test/guild_roles_dao_test.py
Veloxization/likahbot
24e22711f514fc0878cf6fb9e516ad44425ea6a7
[ "MIT" ]
null
null
null
import unittest import os from dao.guild_roles_dao import GuildRolesDAO from dao.guild_role_categories_dao import GuildRoleCategoriesDAO class TestGuildRolesDAO(unittest.TestCase): def setUp(self): self.db_addr = "database/test_db.db" os.popen(f"sqlite3 {self.db_addr} < database/schema.sql") self.guild_roles_dao = GuildRolesDAO(self.db_addr) self.guild_role_categories_dao = GuildRoleCategoriesDAO(self.db_addr) self.guild_role_categories_dao.add_guild_role_category(1234, "TEST") self.guild_role_categories_dao.add_guild_role_category(2345, "TEST") self.category_id1 = self.guild_role_categories_dao.get_all_guild_role_categories(1234)[0]["id"] self.category_id2 = self.guild_role_categories_dao.get_all_guild_role_categories(2345)[0]["id"] def tearDown(self): self.guild_roles_dao.clear_guild_roles_table() self.guild_role_categories_dao.clear_guild_role_categories_table() def test_guild_role_is_added_correctly(self): roles = self.guild_roles_dao.get_all_guild_roles(1234) self.assertEqual(len(roles), 0) self.guild_roles_dao.add_guild_role(9876, self.category_id1) roles = self.guild_roles_dao.get_all_guild_roles(1234) self.assertEqual(len(roles), 1) def test_guild_role_is_removed_correctly(self): self.guild_role_categories_dao.add_guild_role_category(1234, "TEST2") cat_id = self.guild_role_categories_dao.get_all_guild_role_categories(1234)[1]["id"] self.guild_roles_dao.add_guild_role(9876, self.category_id1) self.guild_roles_dao.add_guild_role(9876, cat_id) roles = self.guild_roles_dao.get_all_guild_roles(1234) self.assertEqual(len(roles), 2) self.guild_roles_dao.remove_guild_role_from_category(9876, self.category_id1) roles = self.guild_roles_dao.get_all_guild_roles(1234) self.assertEqual(len(roles), 1) def test_all_guild_roles_are_removed_correctly(self): self.guild_roles_dao.add_guild_role(9876, self.category_id1) self.guild_roles_dao.add_guild_role(8765, self.category_id2) roles1 = self.guild_roles_dao.get_all_guild_roles(1234) roles2 = self.guild_roles_dao.get_all_guild_roles(2345) self.assertEqual(len(roles1), 1) self.assertEqual(len(roles2), 1) self.guild_roles_dao.delete_guild_roles(1234) roles1 = self.guild_roles_dao.get_all_guild_roles(1234) roles2 = self.guild_roles_dao.get_all_guild_roles(2345) self.assertEqual(len(roles1), 0) self.assertEqual(len(roles2), 1) def test_guild_roles_of_type_are_returned_correctly(self): self.guild_role_categories_dao.add_guild_role_category(1234, "TEST2") cat_id = self.guild_role_categories_dao.get_all_guild_role_categories(1234)[1]["id"] self.guild_roles_dao.add_guild_role(9876, self.category_id1) self.guild_roles_dao.add_guild_role(8765, self.category_id1) self.guild_roles_dao.add_guild_role(7654, cat_id) roles = self.guild_roles_dao.get_guild_roles_of_type("TEST", 1234) self.assertEqual(len(roles), 2) roles = self.guild_roles_dao.get_guild_roles_of_type("TEST2", 1234) self.assertEqual(len(roles), 1) def test_guild_role_is_returned_correctly_with_id(self): self.guild_roles_dao.add_guild_role(9876, self.category_id1) self.guild_roles_dao.add_guild_role(8765, self.category_id2) role = self.guild_roles_dao.get_guild_roles_by_role_id(9876)[0] self.assertEqual(role["role_id"], 9876) self.assertEqual(role["guild_id"], 1234) self.assertEqual(role["category"], "TEST")
52.714286
103
0.746612
545
3,690
4.623853
0.113761
0.162698
0.134127
0.168651
0.730159
0.669444
0.657937
0.646032
0.622222
0.603968
0
0.054698
0.157724
3,690
69
104
53.478261
0.756113
0
0
0.419355
0
0
0.033875
0
0
0
0
0
0.209677
1
0.112903
false
0
0.064516
0
0.193548
0
0
0
0
null
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
829dd5cc20b5aa7c14726c3c740aa687c0a9650d
194
py
Python
Data_Analyst/Step_2_Intermediate_Python_and_Pandas/2_Data_Analysis_with_Pandas_Intermediate/3_Introduction_to_Pandas/7_Selecting_a_row/script.py
ustutz/dataquest
6fa64fc824a060b19649ef912d11bee9ed671025
[ "MIT" ]
8
2017-01-20T13:24:26.000Z
2019-04-05T19:02:13.000Z
Data_Analyst/Step_2_Intermediate_Python_and_Pandas/2_Data_Analysis_with_Pandas_Intermediate/3_Introduction_to_Pandas/7_Selecting_a_row/script.py
ustutz/dataquest
6fa64fc824a060b19649ef912d11bee9ed671025
[ "MIT" ]
null
null
null
Data_Analyst/Step_2_Intermediate_Python_and_Pandas/2_Data_Analysis_with_Pandas_Intermediate/3_Introduction_to_Pandas/7_Selecting_a_row/script.py
ustutz/dataquest
6fa64fc824a060b19649ef912d11bee9ed671025
[ "MIT" ]
25
2016-10-27T16:27:54.000Z
2021-07-06T14:36:40.000Z
import pandas as pandas_Pandas_Module class Script: @staticmethod def main(): food_info = pandas_Pandas_Module.read_csv("../food_info.csv") print(str(food_info.dtypes)) Script.main()
14.923077
63
0.752577
28
194
4.928571
0.571429
0.173913
0.26087
0
0
0
0
0
0
0
0
0
0.128866
194
13
64
14.923077
0.816568
0
0
0
0
0
0.082051
0
0
0
0
0
0
1
0.142857
false
0
0.142857
0
0.428571
0.142857
1
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
82a91b76040314d727ba1163f259b5cbea984d08
838
py
Python
vshare/user_/urls.py
jeyrce/vshare
269fe05a4dc36f6fbf831ddf5057af95312b75ca
[ "Apache-2.0" ]
4
2019-11-30T06:07:14.000Z
2020-10-27T08:48:23.000Z
vshare/user_/urls.py
jeeyshe/vshare
269fe05a4dc36f6fbf831ddf5057af95312b75ca
[ "Apache-2.0" ]
null
null
null
vshare/user_/urls.py
jeeyshe/vshare
269fe05a4dc36f6fbf831ddf5057af95312b75ca
[ "Apache-2.0" ]
null
null
null
# coding = utf-8 # env = python3.5.2 # author = lujianxin # time = 201x-xx-xx # purpose= - - - from django.urls import re_path from . import views urlpatterns = [ # 此模块下的路径映射 re_path(r'usercenter$', views.UserCenter.as_view()), re_path(r'details/(\d+)$', views.UserDetails.as_view()), re_path(r'login$', views.Login.as_view()), re_path(r'regist$', views.Regist.as_view()), re_path(r'logout$', views.Logout.as_view()), re_path(r'securecenter$', views.SecureCenter.as_view()), re_path(r'write_article$', views.WriteArticle.as_view()), re_path(r'change_art/(\d+)$', views.ChangeArt.as_view()), re_path(r'cpwd$', views.ModifyPwd.as_view()), re_path(r'findpwd$', views.FindPwd.as_view()), re_path(r'cpwdsafe$', views.ModifyPwdSafe.as_view()), ] if __name__ == '__main__': pass
27.032258
61
0.656325
121
838
4.272727
0.396694
0.139265
0.148936
0.232108
0.251451
0
0
0
0
0
0
0.009859
0.152745
838
30
62
27.933333
0.71831
0.120525
0
0
0
0
0.163237
0
0
0
0
0
0
1
0
false
0.058824
0.117647
0
0.117647
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
82aec0d620a3d2b504e341e4b1d842730a0ba06a
586
py
Python
config.py
laundmo/counter-generator
52b96ede55ea0d961c414102762c6430275d9fb9
[ "MIT" ]
null
null
null
config.py
laundmo/counter-generator
52b96ede55ea0d961c414102762c6430275d9fb9
[ "MIT" ]
4
2021-02-27T07:56:25.000Z
2021-02-27T08:00:10.000Z
config.py
laundmo/counter-generator
52b96ede55ea0d961c414102762c6430275d9fb9
[ "MIT" ]
null
null
null
from sys import platform try: from yaml import CSafeLoader as Loader # use the C loader when possible except ImportError: from yaml import SafeLoader as Loader import yaml with open("config.yml") as f: config = yaml.load(f, Loader=Loader) # load the config yaml if platform in ("linux", "linux2", "win32"): import PySimpleGUI elif ( platform == "darwin" ): # Have to use web/remi on MacOS as the normal tkinter version causes a OS error # TODO: Test on MacOS with tkinter possibly figure out how to get it working. import PySimpleGUIWeb as PySimpleGUI
30.842105
83
0.721843
88
586
4.806818
0.613636
0.037825
0.066194
0
0
0
0
0
0
0
0
0.006494
0.211604
586
18
84
32.555556
0.909091
0.349829
0
0
0
0
0.085106
0
0
0
0
0.055556
0
1
0
false
0
0.5
0
0.5
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
1
0
0
0
0
2
82affa262e4e61eb46885268e69de57c9213002a
25,609
py
Python
pysnmp/CISCO-IETF-PW-MIB.py
agustinhenze/mibs.snmplabs.com
1fc5c07860542b89212f4c8ab807057d9a9206c7
[ "Apache-2.0" ]
11
2021-02-02T16:27:16.000Z
2021-08-31T06:22:49.000Z
pysnmp/CISCO-IETF-PW-MIB.py
agustinhenze/mibs.snmplabs.com
1fc5c07860542b89212f4c8ab807057d9a9206c7
[ "Apache-2.0" ]
75
2021-02-24T17:30:31.000Z
2021-12-08T00:01:18.000Z
pysnmp/CISCO-IETF-PW-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 CISCO-IETF-PW-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-IETF-PW-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:43:40 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) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, ConstraintsIntersection, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion") CpwVcType, CpwGroupID, CpwVcIndexType, CpwOperStatus, CpwVcIDType = mibBuilder.importSymbols("CISCO-IETF-PW-TC-MIB", "CpwVcType", "CpwGroupID", "CpwVcIndexType", "CpwOperStatus", "CpwVcIDType") ciscoExperiment, = mibBuilder.importSymbols("CISCO-SMI", "ciscoExperiment") InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType") SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") Counter32, MibIdentifier, experimental, ModuleIdentity, Unsigned32, NotificationType, IpAddress, TimeTicks, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, Gauge32, ObjectIdentity, Counter64, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "MibIdentifier", "experimental", "ModuleIdentity", "Unsigned32", "NotificationType", "IpAddress", "TimeTicks", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "Gauge32", "ObjectIdentity", "Counter64", "Integer32") TruthValue, TimeStamp, StorageType, RowStatus, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TruthValue", "TimeStamp", "StorageType", "RowStatus", "TextualConvention", "DisplayString") cpwVcMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 10, 106)) cpwVcMIB.setRevisions(('2004-03-17 12:00', '2003-02-26 12:00', '2002-05-26 12:00', '2002-01-30 12:00', '2001-11-07 12:00', '2001-07-11 12:00',)) if mibBuilder.loadTexts: cpwVcMIB.setLastUpdated('200403171200Z') if mibBuilder.loadTexts: cpwVcMIB.setOrganization('Cisco Systems, Inc.') cpwVcObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 106, 1)) cpwVcNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 106, 2)) cpwVcConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 106, 3)) cpwVcIndexNext = MibScalar((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 1), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcIndexNext.setStatus('current') cpwVcTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2), ) if mibBuilder.loadTexts: cpwVcTable.setStatus('current') cpwVcEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1), ).setIndexNames((0, "CISCO-IETF-PW-MIB", "cpwVcIndex")) if mibBuilder.loadTexts: cpwVcEntry.setStatus('current') cpwVcIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 1), CpwVcIndexType()) if mibBuilder.loadTexts: cpwVcIndex.setStatus('current') cpwVcType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 2), CpwVcType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcType.setStatus('current') cpwVcOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("manual", 1), ("maintenanceProtocol", 2), ("other", 3)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcOwner.setStatus('current') cpwVcPsnType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("mpls", 1), ("l2tp", 2), ("ip", 3), ("mplsOverIp", 4), ("gre", 5), ("other", 6)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcPsnType.setStatus('current') cpwVcSetUpPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcSetUpPriority.setStatus('current') cpwVcHoldingPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcHoldingPriority.setStatus('current') cpwVcInboundMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("loose", 1), ("strict", 2))).clone('loose')).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcInboundMode.setStatus('current') cpwVcPeerAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 8), InetAddressType().clone('ipv4')).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcPeerAddrType.setStatus('current') cpwVcPeerAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 9), InetAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcPeerAddr.setStatus('current') cpwVcID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 10), CpwVcIDType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcID.setStatus('current') cpwVcLocalGroupID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 11), CpwGroupID()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcLocalGroupID.setStatus('current') cpwVcControlWord = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 12), TruthValue().clone('false')).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcControlWord.setStatus('current') cpwVcLocalIfMtu = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 13), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcLocalIfMtu.setStatus('current') cpwVcLocalIfString = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 14), TruthValue().clone('false')).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcLocalIfString.setStatus('current') cpwVcRemoteGroupID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 15), CpwGroupID()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcRemoteGroupID.setStatus('current') cpwVcRemoteControlWord = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("noControlWord", 1), ("withControlWord", 2), ("notYetKnown", 3)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcRemoteControlWord.setStatus('current') cpwVcRemoteIfMtu = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 17), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcRemoteIfMtu.setStatus('current') cpwVcRemoteIfString = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 18), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 80))).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcRemoteIfString.setStatus('current') cpwVcOutboundVcLabel = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 19), Unsigned32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcOutboundVcLabel.setStatus('current') cpwVcInboundVcLabel = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 20), Unsigned32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcInboundVcLabel.setStatus('current') cpwVcName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 21), SnmpAdminString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcName.setStatus('current') cpwVcDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 22), SnmpAdminString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcDescr.setStatus('current') cpwVcCreateTime = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 23), TimeStamp()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcCreateTime.setStatus('current') cpwVcUpTime = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 24), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcUpTime.setStatus('current') cpwVcAdminStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("up", 1), ("down", 2), ("testing", 3)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcAdminStatus.setStatus('current') cpwVcOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 26), CpwOperStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcOperStatus.setStatus('current') cpwVcInboundOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 27), CpwOperStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcInboundOperStatus.setStatus('current') cpwVcOutboundOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 28), CpwOperStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcOutboundOperStatus.setStatus('current') cpwVcTimeElapsed = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 29), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 900))).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcTimeElapsed.setStatus('current') cpwVcValidIntervals = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 30), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 96))).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcValidIntervals.setStatus('current') cpwVcRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 31), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcRowStatus.setStatus('current') cpwVcStorageType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 2, 1, 32), StorageType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cpwVcStorageType.setStatus('current') cpwVcPerfCurrentTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 3), ) if mibBuilder.loadTexts: cpwVcPerfCurrentTable.setStatus('current') cpwVcPerfCurrentEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 3, 1), ).setIndexNames((0, "CISCO-IETF-PW-MIB", "cpwVcIndex")) if mibBuilder.loadTexts: cpwVcPerfCurrentEntry.setStatus('current') cpwVcPerfCurrentInHCPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 3, 1, 1), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfCurrentInHCPackets.setStatus('current') cpwVcPerfCurrentInHCBytes = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 3, 1, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfCurrentInHCBytes.setStatus('current') cpwVcPerfCurrentOutHCPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 3, 1, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfCurrentOutHCPackets.setStatus('current') cpwVcPerfCurrentOutHCBytes = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 3, 1, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfCurrentOutHCBytes.setStatus('current') cpwVcPerfIntervalTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4), ) if mibBuilder.loadTexts: cpwVcPerfIntervalTable.setStatus('current') cpwVcPerfIntervalEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1), ).setIndexNames((0, "CISCO-IETF-PW-MIB", "cpwVcIndex"), (0, "CISCO-IETF-PW-MIB", "cpwVcPerfIntervalNumber")) if mibBuilder.loadTexts: cpwVcPerfIntervalEntry.setStatus('current') cpwVcPerfIntervalNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 96))) if mibBuilder.loadTexts: cpwVcPerfIntervalNumber.setStatus('current') cpwVcPerfIntervalValidData = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 2), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfIntervalValidData.setStatus('current') cpwVcPerfIntervalTimeElapsed = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfIntervalTimeElapsed.setStatus('current') cpwVcPerfIntervalInHCPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfIntervalInHCPackets.setStatus('current') cpwVcPerfIntervalInHCBytes = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 5), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfIntervalInHCBytes.setStatus('current') cpwVcPerfIntervalOutHCPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 6), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfIntervalOutHCPackets.setStatus('current') cpwVcPerfIntervalOutHCBytes = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 4, 1, 7), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfIntervalOutHCBytes.setStatus('current') cpwVcPerfTotalTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5), ) if mibBuilder.loadTexts: cpwVcPerfTotalTable.setStatus('current') cpwVcPerfTotalEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5, 1), ).setIndexNames((0, "CISCO-IETF-PW-MIB", "cpwVcIndex")) if mibBuilder.loadTexts: cpwVcPerfTotalEntry.setStatus('current') cpwVcPerfTotalInHCPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5, 1, 1), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfTotalInHCPackets.setStatus('current') cpwVcPerfTotalInHCBytes = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5, 1, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfTotalInHCBytes.setStatus('current') cpwVcPerfTotalOutHCPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5, 1, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfTotalOutHCPackets.setStatus('current') cpwVcPerfTotalOutHCBytes = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5, 1, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfTotalOutHCBytes.setStatus('current') cpwVcPerfTotalDiscontinuityTime = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 5, 1, 5), TimeStamp()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfTotalDiscontinuityTime.setStatus('current') cpwVcPerfTotalErrorPackets = MibScalar((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 6), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPerfTotalErrorPackets.setStatus('current') cpwVcIdMappingTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7), ) if mibBuilder.loadTexts: cpwVcIdMappingTable.setStatus('current') cpwVcIdMappingEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7, 1), ).setIndexNames((0, "CISCO-IETF-PW-MIB", "cpwVcIdMappingVcType"), (0, "CISCO-IETF-PW-MIB", "cpwVcIdMappingVcID"), (0, "CISCO-IETF-PW-MIB", "cpwVcIdMappingPeerAddrType"), (0, "CISCO-IETF-PW-MIB", "cpwVcIdMappingPeerAddr"), (0, "CISCO-IETF-PW-MIB", "cpwVcIdMappingVcIndex")) if mibBuilder.loadTexts: cpwVcIdMappingEntry.setStatus('current') cpwVcIdMappingVcType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7, 1, 1), CpwVcType()) if mibBuilder.loadTexts: cpwVcIdMappingVcType.setStatus('current') cpwVcIdMappingVcID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7, 1, 2), CpwVcIDType()) if mibBuilder.loadTexts: cpwVcIdMappingVcID.setStatus('current') cpwVcIdMappingPeerAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7, 1, 3), InetAddressType()) if mibBuilder.loadTexts: cpwVcIdMappingPeerAddrType.setStatus('current') cpwVcIdMappingPeerAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7, 1, 4), InetAddress()) if mibBuilder.loadTexts: cpwVcIdMappingPeerAddr.setStatus('current') cpwVcIdMappingVcIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 7, 1, 5), CpwVcIndexType()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcIdMappingVcIndex.setStatus('current') cpwVcPeerMappingTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8), ) if mibBuilder.loadTexts: cpwVcPeerMappingTable.setStatus('current') cpwVcPeerMappingEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8, 1), ).setIndexNames((0, "CISCO-IETF-PW-MIB", "cpwVcPeerMappingPeerAddrType"), (0, "CISCO-IETF-PW-MIB", "cpwVcPeerMappingPeerAddr"), (0, "CISCO-IETF-PW-MIB", "cpwVcPeerMappingVcType"), (0, "CISCO-IETF-PW-MIB", "cpwVcPeerMappingVcID"), (0, "CISCO-IETF-PW-MIB", "cpwVcPeerMappingVcIndex")) if mibBuilder.loadTexts: cpwVcPeerMappingEntry.setStatus('current') cpwVcPeerMappingPeerAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8, 1, 1), InetAddressType()) if mibBuilder.loadTexts: cpwVcPeerMappingPeerAddrType.setStatus('current') cpwVcPeerMappingPeerAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8, 1, 2), InetAddress()) if mibBuilder.loadTexts: cpwVcPeerMappingPeerAddr.setStatus('current') cpwVcPeerMappingVcType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8, 1, 3), CpwVcType()) if mibBuilder.loadTexts: cpwVcPeerMappingVcType.setStatus('current') cpwVcPeerMappingVcID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8, 1, 4), CpwVcIDType()) if mibBuilder.loadTexts: cpwVcPeerMappingVcID.setStatus('current') cpwVcPeerMappingVcIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 8, 1, 5), CpwVcIndexType()).setMaxAccess("readonly") if mibBuilder.loadTexts: cpwVcPeerMappingVcIndex.setStatus('current') cpwVcUpDownNotifEnable = MibScalar((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 9), TruthValue().clone('false')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cpwVcUpDownNotifEnable.setStatus('current') cpwVcNotifRate = MibScalar((1, 3, 6, 1, 4, 1, 9, 10, 106, 1, 10), Unsigned32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cpwVcNotifRate.setStatus('current') cpwVcDown = NotificationType((1, 3, 6, 1, 4, 1, 9, 10, 106, 2, 1)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcOperStatus"), ("CISCO-IETF-PW-MIB", "cpwVcOperStatus")) if mibBuilder.loadTexts: cpwVcDown.setStatus('current') cpwVcUp = NotificationType((1, 3, 6, 1, 4, 1, 9, 10, 106, 2, 2)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcOperStatus"), ("CISCO-IETF-PW-MIB", "cpwVcOperStatus")) if mibBuilder.loadTexts: cpwVcUp.setStatus('current') cpwVcGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 1)) cpwVcCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 2)) cpwModuleCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 2, 1)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcGroup"), ("CISCO-IETF-PW-MIB", "cpwVcPeformanceGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cpwModuleCompliance = cpwModuleCompliance.setStatus('current') cpwVcGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 1, 1)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcIndexNext"), ("CISCO-IETF-PW-MIB", "cpwVcType"), ("CISCO-IETF-PW-MIB", "cpwVcOwner"), ("CISCO-IETF-PW-MIB", "cpwVcPsnType"), ("CISCO-IETF-PW-MIB", "cpwVcSetUpPriority"), ("CISCO-IETF-PW-MIB", "cpwVcHoldingPriority"), ("CISCO-IETF-PW-MIB", "cpwVcInboundMode"), ("CISCO-IETF-PW-MIB", "cpwVcPeerAddrType"), ("CISCO-IETF-PW-MIB", "cpwVcPeerAddr"), ("CISCO-IETF-PW-MIB", "cpwVcID"), ("CISCO-IETF-PW-MIB", "cpwVcLocalGroupID"), ("CISCO-IETF-PW-MIB", "cpwVcControlWord"), ("CISCO-IETF-PW-MIB", "cpwVcLocalIfMtu"), ("CISCO-IETF-PW-MIB", "cpwVcLocalIfString"), ("CISCO-IETF-PW-MIB", "cpwVcRemoteGroupID"), ("CISCO-IETF-PW-MIB", "cpwVcRemoteControlWord"), ("CISCO-IETF-PW-MIB", "cpwVcRemoteIfMtu"), ("CISCO-IETF-PW-MIB", "cpwVcRemoteIfString"), ("CISCO-IETF-PW-MIB", "cpwVcOutboundVcLabel"), ("CISCO-IETF-PW-MIB", "cpwVcInboundVcLabel"), ("CISCO-IETF-PW-MIB", "cpwVcName"), ("CISCO-IETF-PW-MIB", "cpwVcDescr"), ("CISCO-IETF-PW-MIB", "cpwVcCreateTime"), ("CISCO-IETF-PW-MIB", "cpwVcUpTime"), ("CISCO-IETF-PW-MIB", "cpwVcAdminStatus"), ("CISCO-IETF-PW-MIB", "cpwVcOperStatus"), ("CISCO-IETF-PW-MIB", "cpwVcOutboundOperStatus"), ("CISCO-IETF-PW-MIB", "cpwVcInboundOperStatus"), ("CISCO-IETF-PW-MIB", "cpwVcTimeElapsed"), ("CISCO-IETF-PW-MIB", "cpwVcValidIntervals"), ("CISCO-IETF-PW-MIB", "cpwVcRowStatus"), ("CISCO-IETF-PW-MIB", "cpwVcStorageType"), ("CISCO-IETF-PW-MIB", "cpwVcUpDownNotifEnable"), ("CISCO-IETF-PW-MIB", "cpwVcNotifRate")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cpwVcGroup = cpwVcGroup.setStatus('current') cpwVcPeformanceGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 1, 2)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcPerfCurrentInHCPackets"), ("CISCO-IETF-PW-MIB", "cpwVcPerfCurrentInHCBytes"), ("CISCO-IETF-PW-MIB", "cpwVcPerfCurrentOutHCPackets"), ("CISCO-IETF-PW-MIB", "cpwVcPerfCurrentOutHCBytes"), ("CISCO-IETF-PW-MIB", "cpwVcPerfIntervalValidData"), ("CISCO-IETF-PW-MIB", "cpwVcPerfIntervalTimeElapsed"), ("CISCO-IETF-PW-MIB", "cpwVcPerfIntervalInHCPackets"), ("CISCO-IETF-PW-MIB", "cpwVcPerfIntervalInHCBytes"), ("CISCO-IETF-PW-MIB", "cpwVcPerfIntervalOutHCPackets"), ("CISCO-IETF-PW-MIB", "cpwVcPerfIntervalOutHCBytes"), ("CISCO-IETF-PW-MIB", "cpwVcPerfTotalInHCPackets"), ("CISCO-IETF-PW-MIB", "cpwVcPerfTotalInHCBytes"), ("CISCO-IETF-PW-MIB", "cpwVcPerfTotalOutHCPackets"), ("CISCO-IETF-PW-MIB", "cpwVcPerfTotalOutHCBytes"), ("CISCO-IETF-PW-MIB", "cpwVcPerfTotalDiscontinuityTime"), ("CISCO-IETF-PW-MIB", "cpwVcPerfTotalErrorPackets")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cpwVcPeformanceGroup = cpwVcPeformanceGroup.setStatus('current') cpwVcMappingTablesGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 1, 3)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcIdMappingVcIndex"), ("CISCO-IETF-PW-MIB", "cpwVcPeerMappingVcIndex")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cpwVcMappingTablesGroup = cpwVcMappingTablesGroup.setStatus('current') cpwVcNotificationsGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 9, 10, 106, 3, 1, 4)).setObjects(("CISCO-IETF-PW-MIB", "cpwVcUp"), ("CISCO-IETF-PW-MIB", "cpwVcDown")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cpwVcNotificationsGroup = cpwVcNotificationsGroup.setStatus('current') mibBuilder.exportSymbols("CISCO-IETF-PW-MIB", cpwVcDown=cpwVcDown, cpwVcIdMappingVcType=cpwVcIdMappingVcType, cpwVcControlWord=cpwVcControlWord, cpwVcPerfIntervalValidData=cpwVcPerfIntervalValidData, cpwVcSetUpPriority=cpwVcSetUpPriority, cpwVcPsnType=cpwVcPsnType, cpwVcStorageType=cpwVcStorageType, cpwVcPeerMappingVcID=cpwVcPeerMappingVcID, cpwVcPeerMappingTable=cpwVcPeerMappingTable, cpwVcPerfTotalInHCBytes=cpwVcPerfTotalInHCBytes, PYSNMP_MODULE_ID=cpwVcMIB, cpwVcPerfIntervalTimeElapsed=cpwVcPerfIntervalTimeElapsed, cpwVcIdMappingPeerAddrType=cpwVcIdMappingPeerAddrType, cpwVcPeerAddrType=cpwVcPeerAddrType, cpwVcHoldingPriority=cpwVcHoldingPriority, cpwVcPerfTotalInHCPackets=cpwVcPerfTotalInHCPackets, cpwVcIndexNext=cpwVcIndexNext, cpwVcIdMappingTable=cpwVcIdMappingTable, cpwVcMappingTablesGroup=cpwVcMappingTablesGroup, cpwVcPeformanceGroup=cpwVcPeformanceGroup, cpwVcEntry=cpwVcEntry, cpwVcPeerAddr=cpwVcPeerAddr, cpwVcInboundVcLabel=cpwVcInboundVcLabel, cpwVcPerfTotalOutHCBytes=cpwVcPerfTotalOutHCBytes, cpwVcMIB=cpwVcMIB, cpwVcValidIntervals=cpwVcValidIntervals, cpwVcOwner=cpwVcOwner, cpwVcRemoteGroupID=cpwVcRemoteGroupID, cpwVcPerfIntervalTable=cpwVcPerfIntervalTable, cpwVcPeerMappingPeerAddr=cpwVcPeerMappingPeerAddr, cpwVcConformance=cpwVcConformance, cpwVcPerfIntervalOutHCPackets=cpwVcPerfIntervalOutHCPackets, cpwVcInboundOperStatus=cpwVcInboundOperStatus, cpwVcPerfCurrentTable=cpwVcPerfCurrentTable, cpwVcPerfTotalDiscontinuityTime=cpwVcPerfTotalDiscontinuityTime, cpwVcOutboundVcLabel=cpwVcOutboundVcLabel, cpwVcUp=cpwVcUp, cpwVcIdMappingVcID=cpwVcIdMappingVcID, cpwVcLocalIfString=cpwVcLocalIfString, cpwVcUpTime=cpwVcUpTime, cpwVcPeerMappingPeerAddrType=cpwVcPeerMappingPeerAddrType, cpwVcType=cpwVcType, cpwVcPeerMappingVcType=cpwVcPeerMappingVcType, cpwVcPerfIntervalEntry=cpwVcPerfIntervalEntry, cpwVcPerfIntervalNumber=cpwVcPerfIntervalNumber, cpwVcName=cpwVcName, cpwVcPerfIntervalOutHCBytes=cpwVcPerfIntervalOutHCBytes, cpwVcRemoteIfMtu=cpwVcRemoteIfMtu, cpwVcIdMappingPeerAddr=cpwVcIdMappingPeerAddr, cpwVcID=cpwVcID, cpwVcPerfIntervalInHCPackets=cpwVcPerfIntervalInHCPackets, cpwVcPerfTotalEntry=cpwVcPerfTotalEntry, cpwVcNotificationsGroup=cpwVcNotificationsGroup, cpwVcCreateTime=cpwVcCreateTime, cpwVcNotifRate=cpwVcNotifRate, cpwVcPerfCurrentInHCBytes=cpwVcPerfCurrentInHCBytes, cpwVcRemoteControlWord=cpwVcRemoteControlWord, cpwVcLocalIfMtu=cpwVcLocalIfMtu, cpwVcNotifications=cpwVcNotifications, cpwVcInboundMode=cpwVcInboundMode, cpwVcRemoteIfString=cpwVcRemoteIfString, cpwVcGroup=cpwVcGroup, cpwVcPerfTotalTable=cpwVcPerfTotalTable, cpwVcPerfTotalOutHCPackets=cpwVcPerfTotalOutHCPackets, cpwVcPeerMappingEntry=cpwVcPeerMappingEntry, cpwVcTable=cpwVcTable, cpwVcGroups=cpwVcGroups, cpwVcPerfIntervalInHCBytes=cpwVcPerfIntervalInHCBytes, cpwModuleCompliance=cpwModuleCompliance, cpwVcPerfCurrentOutHCPackets=cpwVcPerfCurrentOutHCPackets, cpwVcObjects=cpwVcObjects, cpwVcPeerMappingVcIndex=cpwVcPeerMappingVcIndex, cpwVcCompliances=cpwVcCompliances, cpwVcLocalGroupID=cpwVcLocalGroupID, cpwVcTimeElapsed=cpwVcTimeElapsed, cpwVcIndex=cpwVcIndex, cpwVcRowStatus=cpwVcRowStatus, cpwVcPerfTotalErrorPackets=cpwVcPerfTotalErrorPackets, cpwVcIdMappingEntry=cpwVcIdMappingEntry, cpwVcDescr=cpwVcDescr, cpwVcPerfCurrentEntry=cpwVcPerfCurrentEntry, cpwVcPerfCurrentInHCPackets=cpwVcPerfCurrentInHCPackets, cpwVcIdMappingVcIndex=cpwVcIdMappingVcIndex, cpwVcOperStatus=cpwVcOperStatus, cpwVcOutboundOperStatus=cpwVcOutboundOperStatus, cpwVcAdminStatus=cpwVcAdminStatus, cpwVcUpDownNotifEnable=cpwVcUpDownNotifEnable, cpwVcPerfCurrentOutHCBytes=cpwVcPerfCurrentOutHCBytes)
130.658163
3,605
0.7545
2,910
25,609
6.639175
0.092784
0.010663
0.014752
0.018012
0.382816
0.304451
0.248395
0.240735
0.193944
0.191097
0
0.071517
0.082159
25,609
195
3,606
131.328205
0.750436
0.012808
0
0.026738
0
0
0.186174
0.031299
0
0
0
0
0
1
0
false
0
0.053476
0
0.053476
0
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
82c5022208b58d4f46a1d7ce39f5bdeb44953f3f
566
py
Python
MechOS/simple_messages/int.py
PierceATronics/MechOS
8eeb68b65b8c20b642db52baad1379fd0847b362
[ "MIT" ]
null
null
null
MechOS/simple_messages/int.py
PierceATronics/MechOS
8eeb68b65b8c20b642db52baad1379fd0847b362
[ "MIT" ]
null
null
null
MechOS/simple_messages/int.py
PierceATronics/MechOS
8eeb68b65b8c20b642db52baad1379fd0847b362
[ "MIT" ]
null
null
null
''' ''' import struct class Int: ''' ''' def __init__(self): ''' ''' #construct the message format self.message_constructor = 'i' #number of bytes for this message self.size = 4 def _pack(self, message): ''' ''' encoded_message = struct.pack(self.message_constructor, message) return(encoded_message) def _unpack(self, encoded_message): ''' ''' message = struct.unpack(self.message_constructor, encoded_message)[0] return(message)
20.962963
77
0.556537
55
566
5.490909
0.454545
0.145695
0.218543
0
0
0
0
0
0
0
0
0.005222
0.323322
566
26
78
21.769231
0.78329
0.106007
0
0
0
0
0.002268
0
0
0
0
0
0
1
0.272727
false
0
0.090909
0
0.454545
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
2
82c56d7c16636bc69a537283da6c0edaf26dd821
377
py
Python
Curso Python/PythonExercicios/ex017.py
marcos-saba/Cursos
1c063392867e9ed86d141dad8861a2a35488b1c6
[ "MIT" ]
null
null
null
Curso Python/PythonExercicios/ex017.py
marcos-saba/Cursos
1c063392867e9ed86d141dad8861a2a35488b1c6
[ "MIT" ]
null
null
null
Curso Python/PythonExercicios/ex017.py
marcos-saba/Cursos
1c063392867e9ed86d141dad8861a2a35488b1c6
[ "MIT" ]
null
null
null
#from math import hypot import math print('='*5, 'Cálculo triângulo retângulo', '='*5) cat_op = float(input('Digite o comprimento do cateto oposto: ')) cat_adj = float(input('Digite o comprimento do cateto adjacente: ')) hip = math.hypot(cat_op, cat_adj) print(f'O comprimento da hipotenusa do triângulo retângulo, cujos catetos são {cat_op:.2f} e {cat_adj:.2f} é {hip:.2f}.')
47.125
121
0.729443
61
377
4.409836
0.508197
0.055762
0.118959
0.126394
0.267658
0.267658
0.267658
0
0
0
0
0.015198
0.127321
377
7
122
53.857143
0.802432
0.058355
0
0
0
0.166667
0.624294
0
0
0
0
0
0
1
0
false
0
0.166667
0
0.166667
0.333333
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
82c9034910103390615809d1175c2317626103b0
4,705
py
Python
pysport/horseracing/lattice_calibration.py
notbanker/pysport
fbeb1f1efa493aa26ffb58156b86ce2aee3482bf
[ "MIT" ]
null
null
null
pysport/horseracing/lattice_calibration.py
notbanker/pysport
fbeb1f1efa493aa26ffb58156b86ce2aee3482bf
[ "MIT" ]
null
null
null
pysport/horseracing/lattice_calibration.py
notbanker/pysport
fbeb1f1efa493aa26ffb58156b86ce2aee3482bf
[ "MIT" ]
null
null
null
from .lattice import skew_normal_density, center_density,\ state_prices_from_offsets, densities_and_coefs_from_offsets, winner_of_many,\ expected_payoff, densities_from_offsets, implicit_state_prices, densitiesPlot import pandas as pd # todo: get rid of this dependency import numpy as np def dividend_implied_racing_ability( dividends ): return dividend_implied_ability( dividends=dividends, density=racing_density( loc=0.0 ) ) def racing_ability_implied_dividends( ability ): return ability_implied_dividends( ability, density=racing_density( loc=0.0 ) ) RACING_L = 500 RACING_UNIT = 0.1 RACING_SCALE = 1.0 RACING_A = 1.0 def make_nan_2000( x ) : """ Longshots """ if pd.isnull( x ): return 2000. else: return x def normalize( p ): """ Naive renormalization of probabilities """ S = sum( p ) return [ pr/S for pr in p ] def prices_from_dividends( dividends ): """ Risk neutral probabilities using naive renormalization """ return normalize( [ 1. / make_nan_2000(x) for x in dividends ] ) def dividends_from_prices( prices ): """ Australian style dividends """ return [ 1./d for d in normalize( prices ) ] def normalize_dividends( dividends ): return dividends_from_prices( prices_from_dividends( dividends )) def racing_density( loc ): """ A rough and ready distribution of performance distributions for one round """ density = skew_normal_density( L=RACING_L, unit=RACING_UNIT, loc=0, scale=RACING_SCALE, a=RACING_A ) return center_density( density ) def dividend_implied_ability( dividends, density ): """ Infer risk-neutral implied_ability from Australian style dividends :param dividends: [ 7.6, 12.0, ... ] :return: [ float ] Implied ability """ state_prices = prices_from_dividends( dividends ) implied_offsets_guess = [ 0 for _ in state_prices] L = len( density )/2 offset_samples = list( xrange( -L/4, L/4 ))[::-1] ability = implied_ability( prices = state_prices, density = density, \ offset_samples = offset_samples, implied_offsets_guess = implied_offsets_guess, nIter = 3) return ability def ability_implied_dividends( ability, density ): """ Return betfair style prices :param ability: :return: [ 7.6, 12.3, ... ] """ state_prices = state_prices_from_offsets( density=density, offsets = ability) return [ 1./sp for sp in state_prices ] def implied_ability( prices, density, offset_samples = None, implied_offsets_guess = None, nIter = 3, verbose = False, visualize = False): """ Finds location translations of a fixed density so as to replicate given state prices for winning """ L = len( density ) if offset_samples is None: offset_samples = list( xrange( -L/4, L/4 ))[::-1] # offset_samples should be descending TODO: add check for this else: _assert_descending( offset_samples ) if implied_offsets_guess is None: implied_offsets_guess = range( len(prices) ) # First guess at densities densities, coefs = densities_and_coefs_from_offsets( density, implied_offsets_guess ) densityAllGuess, multiplicityAllGuess = winner_of_many( densities ) densityAll = densityAllGuess.copy() multiplicityAll = multiplicityAllGuess.copy() guess_prices = [ np.sum( expected_payoff( density, densityAll, multiplicityAll, cdf = None, cdfAll = None)) for density in densities] for _ in xrange( nIter ): if visualize: # temporary hack to check progress of optimization densitiesPlot( [ densityAll] + densities , unit=0.1 ) implied_prices = implicit_state_prices( density=density, densityAll=densityAll, multiplicityAll = multiplicityAll, offsets=offset_samples ) implied_offsets = np.interp( prices, implied_prices, offset_samples ) densities = densities_from_offsets( density, implied_offsets ) densityAll, multiplicityAll = winner_of_many( densities ) guess_prices = [ np.sum(expected_payoff(density, densityAll, multiplicityAll, cdf = None, cdfAll = None)) for density in densities ] approx_prices = [ np.round( pri, 3 ) for pri in prices] approx_guesses = [ np.round( pri, 3 ) for pri in guess_prices] if verbose: print zip( approx_prices, approx_guesses )[:5] return implied_offsets def _assert_descending( xs ): for d in np.diff( xs ): if d>0: raise ValueError("Not descending")
42.772727
160
0.671413
565
4,705
5.366372
0.247788
0.03628
0.043865
0.029683
0.193931
0.113456
0.096966
0.084433
0.084433
0.065963
0
0.015467
0.244208
4,705
110
161
42.772727
0.837177
0.035494
0
0.084507
0
0
0.003559
0
0
0
0
0.018182
0.028169
0
null
null
0
0.042254
null
null
0.014085
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
1
0
0
0
0
0
0
0
0
2
82de56b86e1e73fa5d0bacfcbe9e4a18d9698647
1,256
py
Python
webpages/views.py
18praneeth/udayagiri-scl-maxo
67ac939265d7837e39329162d7dd935a52130978
[ "MIT" ]
8
2021-01-01T17:04:45.000Z
2021-06-24T05:53:13.000Z
webpages/views.py
18praneeth/udayagiri-scl-maxo
67ac939265d7837e39329162d7dd935a52130978
[ "MIT" ]
11
2021-01-01T15:04:04.000Z
2021-01-10T07:47:12.000Z
webpages/views.py
18praneeth/udayagiri-scl-maxo
67ac939265d7837e39329162d7dd935a52130978
[ "MIT" ]
7
2020-12-14T12:44:17.000Z
2021-01-15T14:29:13.000Z
from django.shortcuts import render, redirect from django.contrib import messages from .models import Contact from django.contrib.auth.decorators import login_required def home(request): if request.user.is_authenticated: return render(request, 'webpages/home.html') else: return render(request, 'webpages/index.html') def about(request): return render(request, 'webpages/about.html') @login_required def team(request): return render(request, 'webpages/team.html') @login_required def privacy(request): return render(request, 'webpages/privacy.html') @login_required def license(request): return render(request, 'webpages/license.html') @login_required def contact(request): if request.POST: name = request.POST['name'] email = request.POST['email'] subject = request.POST['subject'] comment = request.POST['message'] message = Contact() message.name = name message.email = email message.subject = subject message.comments = comment message.save() messages.success(request, 'Your response is recorded') return redirect('contact') else: return render(request, 'webpages/contact.html',{})
26.166667
62
0.680732
143
1,256
5.937063
0.293706
0.09894
0.156655
0.222615
0.233216
0
0
0
0
0
0
0
0.210987
1,256
47
63
26.723404
0.85671
0
0
0.162162
0
0
0.152866
0.050159
0
0
0
0
0
1
0.162162
false
0
0.108108
0.108108
0.486486
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
1
0
0
0
2
82e49f1ad3ed1e40ba856944b5ae80363654a869
133
py
Python
ska_skeleton/__init__.py
Vinod-Sathe-Company-Limited/ska-skeleton
e93d131fc4d33d5b2f0cd715553fd5907955eccd
[ "BSD-3-Clause" ]
null
null
null
ska_skeleton/__init__.py
Vinod-Sathe-Company-Limited/ska-skeleton
e93d131fc4d33d5b2f0cd715553fd5907955eccd
[ "BSD-3-Clause" ]
null
null
null
ska_skeleton/__init__.py
Vinod-Sathe-Company-Limited/ska-skeleton
e93d131fc4d33d5b2f0cd715553fd5907955eccd
[ "BSD-3-Clause" ]
null
null
null
# -*- coding: utf-8 -*- """Module init code.""" __version__ = '0.0.0' __author__ = 'Your Name' __email__ = 'your.email@mail.com'
13.3
33
0.609023
18
133
3.833333
0.777778
0.057971
0
0
0
0
0
0
0
0
0
0.036036
0.165414
133
9
34
14.777778
0.585586
0.300752
0
0
0
0
0.37931
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
7d5335d6ee6e5dd4d8013184f474bc8d3185581f
337
py
Python
mxfield/models.py
krescruz/django-mxfield
98855412d4414e239a74370380aed5d28b52eeb1
[ "MIT" ]
null
null
null
mxfield/models.py
krescruz/django-mxfield
98855412d4414e239a74370380aed5d28b52eeb1
[ "MIT" ]
null
null
null
mxfield/models.py
krescruz/django-mxfield
98855412d4414e239a74370380aed5d28b52eeb1
[ "MIT" ]
null
null
null
from django.db.models import CharField from django.utils.translation import ugettext_lazy as _ import validators class CURPField(CharField): default_validators = [validators.CURPValidator()] description = _("CURP") def __init__(self, *args, **kwargs): kwargs['max_length'] = 18 super(CURPField, self).__init__(*args, **kwargs)
25.923077
55
0.759644
40
337
6.075
0.675
0.082305
0
0
0
0
0
0
0
0
0
0.006734
0.118694
337
12
56
28.083333
0.811448
0
0
0
0
0
0.041543
0
0
0
0
0
0
1
0.111111
false
0
0.333333
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
0
1
0
1
0
0
2
7d553204536b771ce8440161d9597d5690c1a810
2,804
py
Python
tests/components/test_power_output.py
Shivam60/j5
18069737644c8f1c95944386773c7643d5df5aeb
[ "MIT" ]
null
null
null
tests/components/test_power_output.py
Shivam60/j5
18069737644c8f1c95944386773c7643d5df5aeb
[ "MIT" ]
null
null
null
tests/components/test_power_output.py
Shivam60/j5
18069737644c8f1c95944386773c7643d5df5aeb
[ "MIT" ]
null
null
null
"""Tests for the power output classes.""" from typing import List, Optional, Type from j5.backends import Backend from j5.boards import Board from j5.components.power_output import PowerOutput, PowerOutputInterface class MockPowerOutputDriver(PowerOutputInterface): """A testing driver for power outputs.""" def __init__(self): self._enabled = False def get_power_output_enabled(self, board: Board, identifier: int) -> bool: """Get whether a power output is enabled.""" return self._enabled def set_power_output_enabled( self, board: Board, identifier: int, enabled: bool, ) -> None: """Set whether a power output is enabled.""" self._enabled = enabled def get_power_output_current(self, board: Board, identifier: int) -> float: """Get the current being drawn on a power output, in amperes.""" return 8.1 class MockPowerOutputBoard(Board): """A testing board for the power output.""" @property def name(self) -> str: """The name of this board.""" return "Testing Power Output Board" @property def serial(self) -> str: """The serial number of this board.""" return "SERIAL" @property def firmware_version(self) -> Optional[str]: """Get the firmware version of this board.""" return self._backend.get_firmware_version(self) @property def supported_components(self) -> List[Type["Component"]]: """List the types of component that this Board supports.""" return [PowerOutput] def make_safe(self): """Make this board safe.""" pass @staticmethod def discover(backend: Backend): """Detect all of the boards on a given backend.""" return [] def test_power_output_interface_implementation(): """Test that we can implement the PowerOutputInterface.""" MockPowerOutputDriver() def test_power_output_instantiation(): """Test that we can instantiate a PowerOutput.""" PowerOutput(0, MockPowerOutputBoard(), MockPowerOutputDriver()) def test_power_output_interface(): """Test that the class returns the correct interface.""" assert PowerOutput.interface_class() is PowerOutputInterface def test_power_output_enabled(): """Test the is_enabled property of a PowerOutput.""" power_output = PowerOutput(0, MockPowerOutputBoard(), MockPowerOutputDriver()) assert power_output.is_enabled is False power_output.is_enabled = True assert power_output.is_enabled is True def test_power_output_current(): """Test the current property of a PowerOutput.""" power_output = PowerOutput(0, MockPowerOutputBoard(), MockPowerOutputDriver()) assert type(power_output.current) is float assert power_output.current == 8.1
30.813187
82
0.690442
334
2,804
5.643713
0.254491
0.128382
0.034483
0.05305
0.276393
0.201592
0.145358
0.145358
0.097613
0.097613
0
0.004511
0.209344
2,804
90
83
31.155556
0.845737
0.250713
0
0.125
0
0
0.020347
0
0
0
0
0
0.104167
1
0.3125
false
0.020833
0.083333
0
0.583333
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
7d5889cacaec1535d87725d19f570fd238dc7beb
724
py
Python
autosa_tests/large/mm_int16/unroll.py
mfkiwl/AutoSA-SystolicArray
699742eefda66bd3fd6cac608f7c96f5bf60a2a0
[ "MIT" ]
102
2020-05-18T04:52:26.000Z
2022-03-29T06:53:10.000Z
autosa_tests/large/mm_int16/unroll.py
mfkiwl/AutoSA-SystolicArray
699742eefda66bd3fd6cac608f7c96f5bf60a2a0
[ "MIT" ]
14
2020-06-04T11:12:33.000Z
2022-03-14T20:55:00.000Z
autosa_tests/large/mm_int16/unroll.py
mfkiwl/AutoSA-SystolicArray
699742eefda66bd3fd6cac608f7c96f5bf60a2a0
[ "MIT" ]
26
2020-05-20T02:47:04.000Z
2022-03-16T15:09:41.000Z
import math # Modify the parameters here UNROLL_FACTOR = 32 DATA_T = 'unsigned short' # Generate the code data_type = DATA_T level = int(math.log2(UNROLL_FACTOR)) for layer in range(level - 1, -1, -1): pair = int(math.pow(2, layer)) for i in range(pair): # data_t tmp_[layer]_[pair] = tmp_[layer+1]_[pair*2]_[pair*2+1] if layer == level - 1: print(f'{data_type} mul_{layer}_{i}_0 = local_A[0][{i*2}] * local_B[0][{i*2}];') print(f'{data_type} add_{layer}_{i} = mul_{layer}_{i}_0 + local_A[0][{i*2+1}] * local_B[0][{i*2+1}];') else: print(f'{data_type} add_{layer}_{i} = add_{layer+1}_{i*2} + add_{layer+1}_{i*2+1};') print('local_C[c7][c6] += add_0_0;')
36.2
114
0.592541
130
724
3.030769
0.323077
0.030457
0.030457
0.106599
0.314721
0.213198
0.213198
0.096447
0.096447
0
0
0.056995
0.200276
724
19
115
38.105263
0.623489
0.146409
0
0
1
0.214286
0.45114
0.035831
0
0
0
0
0
1
0
false
0
0.071429
0
0.071429
0.285714
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
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
7d6a678fc2e4bddc6ad3dc6d90062ac0ebecff7e
915
py
Python
Desafios Finais Python - Cognizant Data Cloud Engineer #2/Preenchimento de Vetor I.py
italocreator/heros-journey
76a867b3c9addf2c8b6c06999f9993e12a5b4e46
[ "MIT" ]
null
null
null
Desafios Finais Python - Cognizant Data Cloud Engineer #2/Preenchimento de Vetor I.py
italocreator/heros-journey
76a867b3c9addf2c8b6c06999f9993e12a5b4e46
[ "MIT" ]
null
null
null
Desafios Finais Python - Cognizant Data Cloud Engineer #2/Preenchimento de Vetor I.py
italocreator/heros-journey
76a867b3c9addf2c8b6c06999f9993e12a5b4e46
[ "MIT" ]
null
null
null
""" Desafio Você recebeu o desafio de ler um valor e criar um programa que coloque o valor lido na primeira posição de um vetor N[10]. Em cada posição subsequente, coloque o dobro do valor da posição anterior. Por exemplo, se o valor lido for 1, os valores do vetor devem ser 1,2,4,8 e assim sucessivamente. Mostre o vetor em seguida. Entrada A entrada contém um valor inteiro (V<=50). Saída Para cada posição do vetor, escreva "N[i] = X", onde i é a posição do vetor e X é o valor armazenado na posição i. O primeiro número do vetor N (N[0]) irá receber o valor de V. Exemplo de Entrada Exemplo de Saída 1 N[0] = 1 N[1] = 2 N[2] = 4 ... """ x = int(input()) n = list() # TODO: Complete os espaços em branco com uma solução possível para o problema. for i in range(10): n.append(x) x = x*2 print(f"N[{i}] = {n[i]}")
30.5
123
0.632787
164
915
3.530488
0.481707
0.041451
0.034542
0
0
0
0
0
0
0
0
0.030349
0.279781
915
29
124
31.551724
0.848255
0.877596
0
0
0
0
0.137615
0
0
0
0
0.034483
0
1
0
false
0
0
0
0
0.166667
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
1
0
0
0
0
0
0
0
0
0
0
2
7d85c7a93fbd0155d7bd1fe3e1af5e36cc75c497
484
py
Python
sshspawner/tests/__init__.py
1kastner/SSHSpawner
2634b3ed863f1dcbc3b48d7bee1ac3d98042e75e
[ "BSD-3-Clause" ]
5
2019-09-23T19:04:59.000Z
2020-08-06T18:07:48.000Z
sshspawner/tests/__init__.py
1kastner/SSHSpawner
2634b3ed863f1dcbc3b48d7bee1ac3d98042e75e
[ "BSD-3-Clause" ]
1
2020-08-08T12:41:35.000Z
2020-08-10T18:21:48.000Z
sshspawner/tests/__init__.py
1kastner/SSHSpawner
2634b3ed863f1dcbc3b48d7bee1ac3d98042e75e
[ "BSD-3-Clause" ]
4
2020-02-25T22:37:02.000Z
2021-04-13T14:43:16.000Z
############################################################################### # Copyright (c) 2018, Lawrence Livermore National Security, LLC # Produced at the Lawrence Livermore National Laboratory # Written by Thomas Mendoza mendoza33@llnl.gov # LLNL-CODE-771750 # All rights reserved # # This file is part of SSHSpawner: https://github.com/LLNL/SSHSpawner # # SPDX-License-Identifier: BSD-3-Clause ###############################################################################
37.230769
79
0.520661
45
484
5.6
0.866667
0.134921
0.198413
0
0
0
0
0
0
0
0
0.029613
0.092975
484
12
80
40.333333
0.544419
0.628099
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
2
7d8c64c1f1dba35610d7552ede42b4b2192a13c9
419
py
Python
augur/routes/__init__.py
Nayan-Das/augur
857f4a4e7d688fd54356aa0f546834071fbabbf2
[ "MIT" ]
3
2019-10-31T19:07:48.000Z
2019-11-20T23:14:15.000Z
augur/routes/__init__.py
Nayan-Das/augur
857f4a4e7d688fd54356aa0f546834071fbabbf2
[ "MIT" ]
3
2021-03-09T22:54:52.000Z
2021-05-10T19:19:00.000Z
augur/routes/__init__.py
Nayan-Das/augur
857f4a4e7d688fd54356aa0f546834071fbabbf2
[ "MIT" ]
4
2019-11-05T20:22:12.000Z
2019-12-12T18:08:30.000Z
import importlib import os import glob from .user import create_user_routes from .repo import create_repo_routes from .broker import create_broker_routes def create_routes(server): create_user_routes(server) create_repo_routes(server) create_broker_routes(server) # for plugin_name in server._augur._loaded_plugins: # module = server._augur[plugin_name] # module.create_routes(server)
26.1875
55
0.778043
57
419
5.368421
0.350877
0.196078
0.176471
0
0
0
0
0
0
0
0
0
0.162291
419
15
56
27.933333
0.871795
0.291169
0
0
0
0
0
0
0
0
0
0
0
1
0.1
false
0
0.6
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
0
1
0
1
0
0
2
7d9293e84f4a03376c976e40854cc463c3d0b2fe
529
py
Python
2808.py
heltonricardo/URI
160cca22d94aa667177c9ebf2a1c9864c5e55b41
[ "MIT" ]
6
2021-04-13T00:33:43.000Z
2022-02-10T10:23:59.000Z
2808.py
heltonricardo/URI
160cca22d94aa667177c9ebf2a1c9864c5e55b41
[ "MIT" ]
null
null
null
2808.py
heltonricardo/URI
160cca22d94aa667177c9ebf2a1c9864c5e55b41
[ "MIT" ]
3
2021-03-23T18:42:24.000Z
2022-02-10T10:24:07.000Z
def conv(s): if s[0] == 'a': v = '1' elif s[0] == 'b': v = '2' elif s[0] == 'c': v = '3' elif s[0] == 'd': v = '4' elif s[0] == 'e': v = '5' elif s[0] == 'f': v = '6' elif s[0] == 'g': v = '7' elif s[0] == 'h': v = '8' v += s[1] return v e = str(input()).split() a = conv(e[0]) b = conv(e[1]) ax = int(a[0]) ay = int(a[1]) bx = int(b[0]) by = int(b[1]) if (abs(ax - bx) == 1 and abs(ay - by) == 2) or (abs(ax - bx) == 2 and abs(ay - by) == 1): print('VALIDO') else: print('INVALIDO')
23
90
0.404537
109
529
1.963303
0.357798
0.074766
0.196262
0.093458
0
0
0
0
0
0
0
0.072386
0.294896
529
22
91
24.045455
0.50134
0
0
0
0
0
0.056711
0
0
0
0
0
0
1
0.047619
false
0
0
0
0.095238
0.095238
0
0
1
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
7da45f218ab8516fdf8f91e39f9a7c42a449c690
1,740
py
Python
model/kubernetes.py
adracus/cc-utils
dcd1ff544d8b18a391188903789d1cac929f50f9
[ "Apache-2.0" ]
null
null
null
model/kubernetes.py
adracus/cc-utils
dcd1ff544d8b18a391188903789d1cac929f50f9
[ "Apache-2.0" ]
null
null
null
model/kubernetes.py
adracus/cc-utils
dcd1ff544d8b18a391188903789d1cac929f50f9
[ "Apache-2.0" ]
null
null
null
# Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed # under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from model.base import ( NamedModelElement, ModelBase, ) class KubernetesConfig(NamedModelElement): def _required_attributes(self): return { 'kubeconfig', 'version', 'monitoring', } def kubeconfig(self): return self.raw.get('kubeconfig') def cluster_version(self): return self.raw.get('version') def monitoring(self): return MonitoringConfig(self.raw.get('monitoring')) class MonitoringConfig(ModelBase): def _required_attributes(self): return { 'namespace', 'kube_state_metrics_namespaces_to_monitor', 'kube_state_metrics_collectors', } def namespace(self): return self.raw.get('namespace') def kube_state_metrics_namespaces_to_monitor(self): return self.raw.get('kube_state_metrics_namespaces_to_monitor') def kube_state_metrics_collectors(self): return self.raw.get('kube_state_metrics_collectors')
31.071429
99
0.7
220
1,740
5.404545
0.440909
0.067283
0.050463
0.071489
0.238015
0.135408
0.060555
0.060555
0
0
0
0.006632
0.220115
1,740
55
100
31.636364
0.869565
0.405747
0
0.133333
0
0
0.206084
0.135427
0
0
0
0
0
1
0.266667
false
0
0.033333
0.266667
0.633333
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
7da9f98f6db4dd526d7eaf26e1220f285a37877a
7,933
bzl
Python
util/import/raze/crates.bzl
silas-enf/rules_rust
41b39f0c9951dfda3bd0a95df31695578dd3f5ea
[ "Apache-2.0" ]
1
2017-06-12T02:10:48.000Z
2017-06-12T02:10:48.000Z
util/import/raze/crates.bzl
silas-enf/rules_rust
41b39f0c9951dfda3bd0a95df31695578dd3f5ea
[ "Apache-2.0" ]
null
null
null
util/import/raze/crates.bzl
silas-enf/rules_rust
41b39f0c9951dfda3bd0a95df31695578dd3f5ea
[ "Apache-2.0" ]
null
null
null
""" @generated cargo-raze generated Bazel file. DO NOT EDIT! Replaced on runs of cargo-raze """ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load def rules_rust_util_import_fetch_remote_crates(): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, name = "rules_rust_util_import__aho_corasick__0_7_15", url = "https://crates.io/api/v1/crates/aho-corasick/0.7.15/download", type = "tar.gz", sha256 = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5", strip_prefix = "aho-corasick-0.7.15", build_file = Label("//util/import/raze/remote:BUILD.aho-corasick-0.7.15.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__cfg_if__1_0_0", url = "https://crates.io/api/v1/crates/cfg-if/1.0.0/download", type = "tar.gz", sha256 = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd", strip_prefix = "cfg-if-1.0.0", build_file = Label("//util/import/raze/remote:BUILD.cfg-if-1.0.0.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__env_logger__0_8_4", url = "https://crates.io/api/v1/crates/env_logger/0.8.4/download", type = "tar.gz", sha256 = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3", strip_prefix = "env_logger-0.8.4", build_file = Label("//util/import/raze/remote:BUILD.env_logger-0.8.4.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__getrandom__0_2_3", url = "https://crates.io/api/v1/crates/getrandom/0.2.3/download", type = "tar.gz", sha256 = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753", strip_prefix = "getrandom-0.2.3", build_file = Label("//util/import/raze/remote:BUILD.getrandom-0.2.3.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__lazy_static__1_4_0", url = "https://crates.io/api/v1/crates/lazy_static/1.4.0/download", type = "tar.gz", sha256 = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646", strip_prefix = "lazy_static-1.4.0", build_file = Label("//util/import/raze/remote:BUILD.lazy_static-1.4.0.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__libc__0_2_112", url = "https://crates.io/api/v1/crates/libc/0.2.112/download", type = "tar.gz", sha256 = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125", strip_prefix = "libc-0.2.112", build_file = Label("//util/import/raze/remote:BUILD.libc-0.2.112.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__log__0_4_14", url = "https://crates.io/api/v1/crates/log/0.4.14/download", type = "tar.gz", sha256 = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710", strip_prefix = "log-0.4.14", build_file = Label("//util/import/raze/remote:BUILD.log-0.4.14.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__memchr__2_4_1", url = "https://crates.io/api/v1/crates/memchr/2.4.1/download", type = "tar.gz", sha256 = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a", strip_prefix = "memchr-2.4.1", build_file = Label("//util/import/raze/remote:BUILD.memchr-2.4.1.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__proc_macro2__1_0_33", url = "https://crates.io/api/v1/crates/proc-macro2/1.0.33/download", type = "tar.gz", sha256 = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a", strip_prefix = "proc-macro2-1.0.33", build_file = Label("//util/import/raze/remote:BUILD.proc-macro2-1.0.33.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__quickcheck__1_0_3", url = "https://crates.io/api/v1/crates/quickcheck/1.0.3/download", type = "tar.gz", sha256 = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6", strip_prefix = "quickcheck-1.0.3", build_file = Label("//util/import/raze/remote:BUILD.quickcheck-1.0.3.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__quote__1_0_10", url = "https://crates.io/api/v1/crates/quote/1.0.10/download", type = "tar.gz", sha256 = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05", strip_prefix = "quote-1.0.10", build_file = Label("//util/import/raze/remote:BUILD.quote-1.0.10.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__rand__0_8_4", url = "https://crates.io/api/v1/crates/rand/0.8.4/download", type = "tar.gz", sha256 = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8", strip_prefix = "rand-0.8.4", build_file = Label("//util/import/raze/remote:BUILD.rand-0.8.4.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__rand_core__0_6_3", url = "https://crates.io/api/v1/crates/rand_core/0.6.3/download", type = "tar.gz", sha256 = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7", strip_prefix = "rand_core-0.6.3", build_file = Label("//util/import/raze/remote:BUILD.rand_core-0.6.3.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__regex__1_4_6", url = "https://crates.io/api/v1/crates/regex/1.4.6/download", type = "tar.gz", sha256 = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759", strip_prefix = "regex-1.4.6", build_file = Label("//util/import/raze/remote:BUILD.regex-1.4.6.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__regex_syntax__0_6_25", url = "https://crates.io/api/v1/crates/regex-syntax/0.6.25/download", type = "tar.gz", sha256 = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b", strip_prefix = "regex-syntax-0.6.25", build_file = Label("//util/import/raze/remote:BUILD.regex-syntax-0.6.25.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__syn__1_0_82", url = "https://crates.io/api/v1/crates/syn/1.0.82/download", type = "tar.gz", sha256 = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59", strip_prefix = "syn-1.0.82", build_file = Label("//util/import/raze/remote:BUILD.syn-1.0.82.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__unicode_xid__0_2_2", url = "https://crates.io/api/v1/crates/unicode-xid/0.2.2/download", type = "tar.gz", sha256 = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3", strip_prefix = "unicode-xid-0.2.2", build_file = Label("//util/import/raze/remote:BUILD.unicode-xid-0.2.2.bazel"), ) maybe( http_archive, name = "rules_rust_util_import__wasi__0_10_2_wasi_snapshot_preview1", url = "https://crates.io/api/v1/crates/wasi/0.10.2+wasi-snapshot-preview1/download", type = "tar.gz", sha256 = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6", strip_prefix = "wasi-0.10.2+wasi-snapshot-preview1", build_file = Label("//util/import/raze/remote:BUILD.wasi-0.10.2+wasi-snapshot-preview1.bazel"), )
41.103627
103
0.658767
988
7,933
5.035425
0.121457
0.074372
0.049648
0.072563
0.621106
0.499296
0.475176
0.397387
0.26593
0.135678
0
0.160847
0.202193
7,933
192
104
41.317708
0.625217
0.031388
0
0.325301
1
0.144578
0.573608
0.391446
0
0
0
0
0
1
0.006024
true
0
0.222892
0
0.228916
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
7dab84050bffe62a65b369edcbc5f292e22e4734
747
py
Python
scripts/print_thread_name.py
Satheeshcharon/Multithreading-python
4dcc18d5d417701d8f67f4d92ffa915e5c051a60
[ "MIT" ]
null
null
null
scripts/print_thread_name.py
Satheeshcharon/Multithreading-python
4dcc18d5d417701d8f67f4d92ffa915e5c051a60
[ "MIT" ]
null
null
null
scripts/print_thread_name.py
Satheeshcharon/Multithreading-python
4dcc18d5d417701d8f67f4d92ffa915e5c051a60
[ "MIT" ]
null
null
null
#!/usr/bin/python ## This program creates a thread, ## officially names it and ## tries to print the name import threading import time def ThreadFunction(): print(threading.currentThread().getName(), "Starting") time.sleep(2) print(threading.currentThread().getName(), "Exiting") def ServiceFunction(): print(threading.currentThread().getName(), "Starting") time.sleep(3) print(threading.currentThread().getName(), "Exiting") def Main(): myThread = threading.Thread( name='Service Function', target=ServiceFunction ) w = threading.Thread( name='Thread function', target=ThreadFunction ) w2 = threading.Thread( target=ThreadFunction ) w.start() w2.start() myThread.start() if __name__ == "__main__": Main()
16.977273
55
0.710843
84
747
6.22619
0.464286
0.107075
0.206501
0.260038
0.363289
0.363289
0.195029
0
0
0
0
0.00624
0.141901
747
43
56
17.372093
0.809672
0.129853
0
0.222222
0
0
0.107309
0
0
0
0
0
0
1
0.111111
false
0
0.074074
0
0.185185
0.148148
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
7daf7e347025b6adafd5d8ff1bdd20e4296b68c6
15,533
py
Python
gcloud/bigtable/_generated/bigtable_table_service_messages_pb2.py
scrapinghub/gcloud-python
1ec6d636ebf2c4d618aca6b2485fbbfa5f0fde29
[ "Apache-2.0" ]
null
null
null
gcloud/bigtable/_generated/bigtable_table_service_messages_pb2.py
scrapinghub/gcloud-python
1ec6d636ebf2c4d618aca6b2485fbbfa5f0fde29
[ "Apache-2.0" ]
null
null
null
gcloud/bigtable/_generated/bigtable_table_service_messages_pb2.py
scrapinghub/gcloud-python
1ec6d636ebf2c4d618aca6b2485fbbfa5f0fde29
[ "Apache-2.0" ]
2
2017-07-30T16:18:23.000Z
2020-10-14T11:24:18.000Z
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: google/bigtable/admin/table/v1/bigtable_table_service_messages.proto from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() from gcloud.bigtable._generated import bigtable_table_data_pb2 as google_dot_bigtable_dot_admin_dot_table_dot_v1_dot_bigtable__table__data__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='google/bigtable/admin/table/v1/bigtable_table_service_messages.proto', package='google.bigtable.admin.table.v1', syntax='proto3', serialized_pb=b'\nDgoogle/bigtable/admin/table/v1/bigtable_table_service_messages.proto\x12\x1egoogle.bigtable.admin.table.v1\x1a\x38google/bigtable/admin/table/v1/bigtable_table_data.proto\"\x86\x01\n\x12\x43reateTableRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x10\n\x08table_id\x18\x02 \x01(\t\x12\x34\n\x05table\x18\x03 \x01(\x0b\x32%.google.bigtable.admin.table.v1.Table\x12\x1a\n\x12initial_split_keys\x18\x04 \x03(\t\"!\n\x11ListTablesRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"K\n\x12ListTablesResponse\x12\x35\n\x06tables\x18\x01 \x03(\x0b\x32%.google.bigtable.admin.table.v1.Table\"\x1f\n\x0fGetTableRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\"\n\x12\x44\x65leteTableRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"2\n\x12RenameTableRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06new_id\x18\x02 \x01(\t\"\x88\x01\n\x19\x43reateColumnFamilyRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x18\n\x10\x63olumn_family_id\x18\x02 \x01(\t\x12\x43\n\rcolumn_family\x18\x03 \x01(\x0b\x32,.google.bigtable.admin.table.v1.ColumnFamily\")\n\x19\x44\x65leteColumnFamilyRequest\x12\x0c\n\x04name\x18\x01 \x01(\tBI\n\"com.google.bigtable.admin.table.v1B!BigtableTableServiceMessagesProtoP\x01\x62\x06proto3' , dependencies=[google_dot_bigtable_dot_admin_dot_table_dot_v1_dot_bigtable__table__data__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _CREATETABLEREQUEST = _descriptor.Descriptor( name='CreateTableRequest', full_name='google.bigtable.admin.table.v1.CreateTableRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.CreateTableRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='table_id', full_name='google.bigtable.admin.table.v1.CreateTableRequest.table_id', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='table', full_name='google.bigtable.admin.table.v1.CreateTableRequest.table', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='initial_split_keys', full_name='google.bigtable.admin.table.v1.CreateTableRequest.initial_split_keys', index=3, number=4, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=163, serialized_end=297, ) _LISTTABLESREQUEST = _descriptor.Descriptor( name='ListTablesRequest', full_name='google.bigtable.admin.table.v1.ListTablesRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.ListTablesRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=299, serialized_end=332, ) _LISTTABLESRESPONSE = _descriptor.Descriptor( name='ListTablesResponse', full_name='google.bigtable.admin.table.v1.ListTablesResponse', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='tables', full_name='google.bigtable.admin.table.v1.ListTablesResponse.tables', index=0, number=1, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=334, serialized_end=409, ) _GETTABLEREQUEST = _descriptor.Descriptor( name='GetTableRequest', full_name='google.bigtable.admin.table.v1.GetTableRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.GetTableRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=411, serialized_end=442, ) _DELETETABLEREQUEST = _descriptor.Descriptor( name='DeleteTableRequest', full_name='google.bigtable.admin.table.v1.DeleteTableRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.DeleteTableRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=444, serialized_end=478, ) _RENAMETABLEREQUEST = _descriptor.Descriptor( name='RenameTableRequest', full_name='google.bigtable.admin.table.v1.RenameTableRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.RenameTableRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='new_id', full_name='google.bigtable.admin.table.v1.RenameTableRequest.new_id', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=480, serialized_end=530, ) _CREATECOLUMNFAMILYREQUEST = _descriptor.Descriptor( name='CreateColumnFamilyRequest', full_name='google.bigtable.admin.table.v1.CreateColumnFamilyRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.CreateColumnFamilyRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='column_family_id', full_name='google.bigtable.admin.table.v1.CreateColumnFamilyRequest.column_family_id', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='column_family', full_name='google.bigtable.admin.table.v1.CreateColumnFamilyRequest.column_family', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=533, serialized_end=669, ) _DELETECOLUMNFAMILYREQUEST = _descriptor.Descriptor( name='DeleteColumnFamilyRequest', full_name='google.bigtable.admin.table.v1.DeleteColumnFamilyRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='google.bigtable.admin.table.v1.DeleteColumnFamilyRequest.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=671, serialized_end=712, ) _CREATETABLEREQUEST.fields_by_name['table'].message_type = google_dot_bigtable_dot_admin_dot_table_dot_v1_dot_bigtable__table__data__pb2._TABLE _LISTTABLESRESPONSE.fields_by_name['tables'].message_type = google_dot_bigtable_dot_admin_dot_table_dot_v1_dot_bigtable__table__data__pb2._TABLE _CREATECOLUMNFAMILYREQUEST.fields_by_name['column_family'].message_type = google_dot_bigtable_dot_admin_dot_table_dot_v1_dot_bigtable__table__data__pb2._COLUMNFAMILY DESCRIPTOR.message_types_by_name['CreateTableRequest'] = _CREATETABLEREQUEST DESCRIPTOR.message_types_by_name['ListTablesRequest'] = _LISTTABLESREQUEST DESCRIPTOR.message_types_by_name['ListTablesResponse'] = _LISTTABLESRESPONSE DESCRIPTOR.message_types_by_name['GetTableRequest'] = _GETTABLEREQUEST DESCRIPTOR.message_types_by_name['DeleteTableRequest'] = _DELETETABLEREQUEST DESCRIPTOR.message_types_by_name['RenameTableRequest'] = _RENAMETABLEREQUEST DESCRIPTOR.message_types_by_name['CreateColumnFamilyRequest'] = _CREATECOLUMNFAMILYREQUEST DESCRIPTOR.message_types_by_name['DeleteColumnFamilyRequest'] = _DELETECOLUMNFAMILYREQUEST CreateTableRequest = _reflection.GeneratedProtocolMessageType('CreateTableRequest', (_message.Message,), dict( DESCRIPTOR = _CREATETABLEREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.CreateTableRequest) )) _sym_db.RegisterMessage(CreateTableRequest) ListTablesRequest = _reflection.GeneratedProtocolMessageType('ListTablesRequest', (_message.Message,), dict( DESCRIPTOR = _LISTTABLESREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.ListTablesRequest) )) _sym_db.RegisterMessage(ListTablesRequest) ListTablesResponse = _reflection.GeneratedProtocolMessageType('ListTablesResponse', (_message.Message,), dict( DESCRIPTOR = _LISTTABLESRESPONSE, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.ListTablesResponse) )) _sym_db.RegisterMessage(ListTablesResponse) GetTableRequest = _reflection.GeneratedProtocolMessageType('GetTableRequest', (_message.Message,), dict( DESCRIPTOR = _GETTABLEREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.GetTableRequest) )) _sym_db.RegisterMessage(GetTableRequest) DeleteTableRequest = _reflection.GeneratedProtocolMessageType('DeleteTableRequest', (_message.Message,), dict( DESCRIPTOR = _DELETETABLEREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.DeleteTableRequest) )) _sym_db.RegisterMessage(DeleteTableRequest) RenameTableRequest = _reflection.GeneratedProtocolMessageType('RenameTableRequest', (_message.Message,), dict( DESCRIPTOR = _RENAMETABLEREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.RenameTableRequest) )) _sym_db.RegisterMessage(RenameTableRequest) CreateColumnFamilyRequest = _reflection.GeneratedProtocolMessageType('CreateColumnFamilyRequest', (_message.Message,), dict( DESCRIPTOR = _CREATECOLUMNFAMILYREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.CreateColumnFamilyRequest) )) _sym_db.RegisterMessage(CreateColumnFamilyRequest) DeleteColumnFamilyRequest = _reflection.GeneratedProtocolMessageType('DeleteColumnFamilyRequest', (_message.Message,), dict( DESCRIPTOR = _DELETECOLUMNFAMILYREQUEST, __module__ = 'google.bigtable.admin.table.v1.bigtable_table_service_messages_pb2' # @@protoc_insertion_point(class_scope:google.bigtable.admin.table.v1.DeleteColumnFamilyRequest) )) _sym_db.RegisterMessage(DeleteColumnFamilyRequest) DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), b'\n\"com.google.bigtable.admin.table.v1B!BigtableTableServiceMessagesProtoP\001') import abc from grpc.beta import implementations as beta_implementations from grpc.early_adopter import implementations as early_adopter_implementations from grpc.framework.alpha import utilities as alpha_utilities from grpc.framework.common import cardinality from grpc.framework.interfaces.face import utilities as face_utilities # @@protoc_insertion_point(module_scope)
39.224747
1,208
0.771905
1,865
15,533
6.130295
0.101877
0.034986
0.077145
0.082218
0.674101
0.6441
0.622321
0.62031
0.535642
0.513951
0
0.03132
0.107899
15,533
395
1,209
39.324051
0.79375
0.059229
0
0.652299
1
0.002874
0.26089
0.222945
0
0
0
0
0
1
0
false
0
0.034483
0
0.034483
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
7db0ea31fec60827935b4f0a8b82bcb2927b7b8f
2,218
py
Python
discord_ui/errors.py
brotherelric/discord-ui
6f8cd994aff66fb51f385d23907b3a612546cbe9
[ "MIT" ]
26
2021-08-21T15:34:13.000Z
2022-03-26T13:50:48.000Z
discord_ui/errors.py
brotherelric/discord-ui
6f8cd994aff66fb51f385d23907b3a612546cbe9
[ "MIT" ]
12
2021-08-21T15:24:00.000Z
2022-02-25T02:49:01.000Z
discord_ui/errors.py
brotherelric/discord-ui
6f8cd994aff66fb51f385d23907b3a612546cbe9
[ "MIT" ]
10
2021-09-03T12:31:13.000Z
2022-03-29T06:24:06.000Z
from discord.ext.commands import BadArgument class InvalidLength(BadArgument): """This exception is thrown whenever a invalid length was provided""" def __init__(self, my_name, _min=None, _max=None, *args: object) -> None: if _min is not None and _max is not None: err = "Length of '" + my_name + "' must be between " + str(_min) + " and " + str(_max) elif _min is None and _max is not None: err = "Length of '" + my_name + "' must be less than " + str(_max) elif _min is not None and _max is None: err = "Lenght of '" + my_name + "' must be more than " + str(_min) super().__init__(err) class OutOfValidRange(BadArgument): """This exception is thrown whenever a value was ot of its valid range""" def __init__(self, name, _min, _max, *args: object) -> None: super().__init__("'" + name + "' must be in range " + str(_min) + " and " + str(_max)) class WrongType(BadArgument): """This exception is thrown whenever a value is of the wrong type""" def __init__(self, name, me, valid_type, *args: object) -> None: super().__init__("'" + name + "' must be of type " + (str(valid_type) if not isinstance(valid_type, list) else ' or '.join(valid_type)) + ", not " + str(type(me))) class InvalidEvent(BadArgument): """This exception is thrown whenever a invalid eventname was passed""" def __init__(self, name, events, *args: object) -> None: super().__init__("Invalid event name, event must be " + " or ".join(events) + ", not " + str(name)) class MissingListenedComponentParameters(BadArgument): """This exception is thrown whenever a callback for a listening component is missing parameters""" def __init__(self, *args: object) -> None: super().__init__("Callback function for listening components needs to accept one parameter (the used component)", *args) class CouldNotParse(BadArgument): """This exception is thrown whenever the libary was unable to parse the data with the given method""" def __init__(self, data, type, method, *args: object) -> None: super().__init__("Could not parse '" + str(data) + " [" + str(type) + "]' with method " + str(method), *args)
69.3125
171
0.656898
301
2,218
4.601329
0.295681
0.064982
0.103971
0.112635
0.418051
0.322744
0.293863
0.244043
0.06065
0.06065
0
0
0.213706
2,218
32
172
69.3125
0.794151
0.201984
0
0
0
0
0.184483
0
0
0
0
0
0
1
0.24
false
0
0.04
0
0.52
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
7dd9c7a745a3b97ae9face412cad220abf628e7d
402
py
Python
certbot_dns_cfproxy/__init__.py
ProfFan/certbot-dns-cfproxy
999038999642e5ba070e7089d62146b4f05caa46
[ "Apache-1.1" ]
2
2019-02-04T06:06:00.000Z
2022-03-04T09:12:31.000Z
certbot_dns_cfproxy/__init__.py
ProfFan/certbot-dns-cfproxy
999038999642e5ba070e7089d62146b4f05caa46
[ "Apache-1.1" ]
null
null
null
certbot_dns_cfproxy/__init__.py
ProfFan/certbot-dns-cfproxy
999038999642e5ba070e7089d62146b4f05caa46
[ "Apache-1.1" ]
null
null
null
""" The `~certbot_dns_cfproxy.dns_cfproxy` plugin automates the process of completing a ``dns-01`` challenge (`~acme.challenges.DNS01`) by creating, and subsequently removing, TXT records using the CFProxy API. Examples -------- .. code-block:: bash :caption: To acquire a certificate for ``example.com`` certbot certonly \\ -a certbot-dns-cfproxy:dns-cfproxy \\ -d example.com """
23.647059
77
0.699005
53
402
5.245283
0.698113
0.143885
0.122302
0.143885
0.194245
0
0
0
0
0
0
0.011869
0.161692
402
16
78
25.125
0.813056
0.970149
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
7dec49d76923ecb9be4b17a5cb4c2e8eb1b3a170
510
py
Python
lib/clckwrkbdgr/time.py
umi0451/dotfiles
c618811be788d995fe01f6a16b355828d7efdd36
[ "MIT" ]
2
2017-04-16T14:54:17.000Z
2020-11-12T04:15:00.000Z
lib/clckwrkbdgr/time.py
clckwrkbdgr/dotfiles
292dac8c3211248b490ddbae55fe2adfffcfcf58
[ "MIT" ]
null
null
null
lib/clckwrkbdgr/time.py
clckwrkbdgr/dotfiles
292dac8c3211248b490ddbae55fe2adfffcfcf58
[ "MIT" ]
null
null
null
from __future__ import absolute_import from time import * import datetime import six def get_utctimestamp(mtime=None): # pragma: no cover """ Converts local mtime (timestamp) to integer UTC timestamp. If mtime is None, returns current UTC time. """ if mtime is None: if six.PY2: return int((datetime.datetime.now() - datetime.datetime(1970, 1, 1)).total_seconds()) return int(datetime.datetime.utcnow().timestamp()) return int(calendar.timegm(datetime.datetime.fromtimestamp(mtime).timetuple()))
31.875
88
0.754902
70
510
5.4
0.542857
0.169312
0.047619
0.068783
0
0
0
0
0
0
0
0.015766
0.129412
510
15
89
34
0.835586
0.235294
0
0
0
0
0
0
0
0
0
0
0
1
0.1
false
0
0.4
0
0.8
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
7dee18b24646c7a504a2809135076549b5a544fa
135
py
Python
configutator/__version.py
innovate-invent/configutator
372b45c44a10171b8518e61f2a7974969304c33a
[ "MIT" ]
null
null
null
configutator/__version.py
innovate-invent/configutator
372b45c44a10171b8518e61f2a7974969304c33a
[ "MIT" ]
1
2017-09-22T05:52:54.000Z
2017-09-22T05:52:54.000Z
configutator/__version.py
innovate-invent/configutator
372b45c44a10171b8518e61f2a7974969304c33a
[ "MIT" ]
null
null
null
__version__ = [1, 0, 2] __versionstr__ = '.'.join([str(i) for i in __version__]) if __name__ == '__main__': print(__versionstr__)
22.5
56
0.666667
17
135
3.882353
0.823529
0
0
0
0
0
0
0
0
0
0
0.026549
0.162963
135
6
57
22.5
0.557522
0
0
0
0
0
0.066176
0
0
0
0
0
0
1
0
false
0
0
0
0
0.25
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
816115c45af8c3075e38530126280e891f465fb7
1,657
py
Python
level2/huge/split_huge_from_tar_strace.py
fishilico/sstic-2016
9a05bb18df4c8d2e76f1e30fda6b38b1bc930e8c
[ "Beerware" ]
null
null
null
level2/huge/split_huge_from_tar_strace.py
fishilico/sstic-2016
9a05bb18df4c8d2e76f1e30fda6b38b1bc930e8c
[ "Beerware" ]
null
null
null
level2/huge/split_huge_from_tar_strace.py
fishilico/sstic-2016
9a05bb18df4c8d2e76f1e30fda6b38b1bc930e8c
[ "Beerware" ]
1
2020-04-03T06:19:11.000Z
2020-04-03T06:19:11.000Z
#!/usr/bin/env python3 import codecs import re def trans_addr(addr): """Traduit une position de fichier en une adresse du programme""" if addr < 0x1000: return 0 if 0x0000000000001000 <= addr < 0x0000000000001000 + 0x00001ef000000000: return 0x00002b0000000000 + addr - 0x0000000000001000 if 0x00002afffffe1000 <= addr < 0x00002afffffe1000 + 0x0000161000000000: return 0x000049f000000000 + addr - 0x00002afffffe1000 if 0x000049effffe1000 <= addr < 0x000049effffe1000 + 0x00002afffffe0000: return 0x0000000000020000 + addr - 0x000049effffe1000 raise Exception("Invalid addr {:#x}".format(addr)) blobs = {} with open('strace_tar_output.log', 'r') as f: curseek = 0 for line in f: m = re.match(r'lseek\(4, ([^,]*), SEEK_SET\)', line) if m is not None: curseek = int(m.group(1)) continue if line.startswith('write(4, "'): m = re.match(r'write\(4, "(.*)", ([0-9]*)\) = ([0-9]*)', line) assert m is not None: rawdata, count1, count2 = m.groups() assert count1 == count2 addr = curseek curseek += int(count1) data = codecs.escape_decode(rawdata.encode('ascii'))[0] # Trouve le premier octet non-nul dans le bloc de données i = 0 while i < len(data) and not data[i]: i += 1 if i >= len(data): continue addr = trans_addr(addr + i) data = data[i:].rstrip(b'\0') with open('out/blob-{:016x}.bin'.format(addr), 'wb') as f: f.write(data)
36.822222
76
0.569101
192
1,657
4.880208
0.5
0.01921
0.027748
0.01921
0
0
0
0
0
0
0
0.202962
0.307182
1,657
44
77
37.659091
0.61324
0.04647
0
0.054054
0
0
0.097158
0.01388
0
0
0.182419
0
0.054054
0
null
null
0
0.054054
null
null
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
0
1
0
0
0
0
0
0
0
0
2
817aa92cbced1c3e3227a2a7dec4ed035c84f33f
1,589
py
Python
Assignment 4/src/optim/lr_scheduler.py
vamsi3/CS763-IIT-Bombay
2c4650587eee8bb15944b95101b7434746ec03af
[ "MIT" ]
1
2022-01-28T12:21:36.000Z
2022-01-28T12:21:36.000Z
Assignment 4/src/optim/lr_scheduler.py
vamsi3/IITB-Computer-Vision
2c4650587eee8bb15944b95101b7434746ec03af
[ "MIT" ]
null
null
null
Assignment 4/src/optim/lr_scheduler.py
vamsi3/IITB-Computer-Vision
2c4650587eee8bb15944b95101b7434746ec03af
[ "MIT" ]
null
null
null
import math import torch from bisect import bisect_right class _LRScheduler: def __init__(self, optimizer, last_epoch=-1): self.optimizer = optimizer self.base_lr = optimizer.lr self.last_epoch = last_epoch def step(self): self.last_epoch += 1 self.optimizer.lr = self.get_lr() class StepLR(_LRScheduler): def __init__(self, optimizer, step_size, gamma=0.1, last_epoch=-1): super().__init__(optimizer, last_epoch) self.step_size = step_size self.gamma = gamma def get_lr(self): return self.base_lr * self.gamma ** (self.last_epoch // self.step_size) class MultiStepLR(_LRScheduler): def __init__(self, optimizer, milestones, gamma=0.1, last_epoch=-1): super().__init__(optimizer, last_epoch) self.milestones = milestones self.gamma = gamma def get_lr(self): return self.base_lr * self.gamma ** bisect_right(self.milestones, self.last_epoch) class ExponentialLR(_LRScheduler): def __init__(self, optimizer, gamma, last_epoch=-1): super().__init__(optimizer, last_epoch) self.gamma = gamma def get_lr(self): return self.base_lr * self.gamma ** self.last_epoch class CosineAnnealingLR(_LRScheduler): def __init__(self, optimizer, T_max, eta_min=0, last_epoch=-1): super().__init__(optimizer, last_epoch) self.T_max = T_max self.eta_min = eta_min def get_lr(self): return self.eta_min + (self.base_lr - self.eta_min) * (1 + math.cos(math.pi * self.last_epoch / self.T_max)) / 2
29.425926
120
0.668345
218
1,589
4.495413
0.165138
0.146939
0.061224
0.112245
0.629592
0.382653
0.360204
0.360204
0.360204
0.280612
0
0.010501
0.220894
1,589
53
121
29.981132
0.781099
0
0
0.289474
0
0
0
0
0
0
0
0
0
1
0.263158
false
0
0.078947
0.105263
0.578947
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
2
817e1fdfe583e5b2b44c9f5c5fb7e9b12305519f
305
py
Python
list_s3_buckets.py
MarijaKalebota/aws-playground
2aaf3da65ba3f0cc5c2c222a10659d219f9136e8
[ "MIT" ]
null
null
null
list_s3_buckets.py
MarijaKalebota/aws-playground
2aaf3da65ba3f0cc5c2c222a10659d219f9136e8
[ "MIT" ]
null
null
null
list_s3_buckets.py
MarijaKalebota/aws-playground
2aaf3da65ba3f0cc5c2c222a10659d219f9136e8
[ "MIT" ]
null
null
null
from dotenv import load_dotenv load_dotenv() import os import boto3 #s3 = boto3.resource('s3') s3 = boto3.resource('s3', aws_access_key_id=os.environ.get("AWS_KEY_ID"), aws_secret_access_key=os.environ.get("AWS_SECRET_KEY")) for bucket in s3.buckets.all(): print(bucket.name)
23.461538
77
0.704918
48
305
4.229167
0.458333
0.118227
0.147783
0.167488
0
0
0
0
0
0
0
0.031496
0.167213
305
12
78
25.416667
0.767717
0.081967
0
0
0
0
0.09319
0
0
0
0
0
0
1
0
false
0
0.375
0
0.375
0.125
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
2
819ee9aceebbd56d2a4d4ed207f6ae47bb68ff70
5,468
py
Python
back/db.py
belshoff/Agenda
a9d3d1a80d6b3c00e4d0055847d5ed2bb6c6d7d1
[ "Apache-2.0" ]
null
null
null
back/db.py
belshoff/Agenda
a9d3d1a80d6b3c00e4d0055847d5ed2bb6c6d7d1
[ "Apache-2.0" ]
null
null
null
back/db.py
belshoff/Agenda
a9d3d1a80d6b3c00e4d0055847d5ed2bb6c6d7d1
[ "Apache-2.0" ]
null
null
null
import sqlite3 with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute( """ CREATE TABLE IF NOT EXISTS Produtos ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, price REAL, compra_id INTEGER, FOREIGN KEY (compra_id) REFERENCES Compras(id) ); """ ) cursor.execute( """ CREATE TABLE IF NOT EXISTS Compras ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL ); """ ) class Produto(object): def getAll(self): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute("SELECT * FROM Produtos;") return [ { "id": items[0], "name": items[1], "price": items[2], "compra_id": items[3] } for items in cursor.fetchall() ] def getByCompra(self, compraId): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() print(f"SELECT * FROM Produtos WHERE compra_id = {compraId}") cursor.execute(f"SELECT * FROM Produtos WHERE compra_id = {compraId}") return [ { "id": items[0], "name": items[1], "price": items[2], } for items in cursor.fetchall() ] def insert(self, *args): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() print(f"INSERT INTO Produtos (name, price, compra_id) VALUES ('{args[0]}', {args[1]}, {args[2]})") cursor.execute(f"INSERT INTO Produtos (name, price, compra_id) VALUES ('{args[0]}', {args[1]}, {args[2]})") def getById(self, id): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute(f"SELECT * FROM Produtos WHERE id = {id} ;") return [ { "id": items[0], "name": items[1], "price": items[2] } for items in cursor.fetchall() ][0] def update(self, id, *args): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute(f"UPDATE Produtos SET name = {args[0]}, price = {args[1]}, compra_id = {args[2]} WHERE id = {id};") def delete(self, id): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute(f"DELETE FROM Produtos WHERE id = {id}") def deleteByCompra(self, compraId): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() print(f"DELETE FROM Produtos WHERE compra_id = {compraId}") cursor.execute(f"DELETE FROM Produtos WHERE compra_id = {compraId}") class Compra(object): def __init__(self): self.produto = Produto() def getAll(self): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() print("SELECT * FROM Compras;") cursor.execute("SELECT * FROM Compras;") return [ { "id": items[0], "date": items[1], "produtos": self.produto.getByCompra(items[0]) } for items in cursor.fetchall() ] def insert(self, *args): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() print(f"INSERT INTO Compras (date) VALUES ('{args[0]}')") cursor.execute(f"INSERT INTO Compras (date) VALUES ('{args[0]}')") c = self.getAll()[-1] ps = list(args[1]) for p in ps: self.produto.insert(str(p["name"]), p["price"], c["id"]) # return self.getById(c.id) def getById(self, id): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute(f"SELECT * FROM Compras WHERE id = {id} ;") return [ { "id": items[0], "date": items[1], "produtos": self.produto.getByCompra(id) } for items in cursor.fetchall() ][0] def getByDate(self, date): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute(f"SELECT * FROM Compras WHERE date = '{date}' ;") return [ { "id": items[0], "date": items[1], "produtos": self.produto.getByCompra(items[0]) } for items in cursor.fetchall() ] def update(self, id, *args): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() cursor.execute( """ UPDATE Compras SET date = ?, produto_id = ? WHERE id = ?; """, (*args, id) ) def delete(self, id): with sqlite3.connect('storage.db') as conn: cursor = conn.cursor() self.produto.deleteByCompra(self.getById(id)["id"]) print(f"DELETE FROM Compras WHERE id = {id}") cursor.execute(f"DELETE FROM Compras WHERE id = {id}")
35.277419
126
0.492502
582
5,468
4.601375
0.118557
0.104556
0.0941
0.130695
0.797237
0.78118
0.771098
0.673264
0.619119
0.584018
0
0.014118
0.3782
5,468
155
127
35.277419
0.773529
0.004572
0
0.596639
0
0.02521
0.225436
0
0
0
0
0
0
1
0.117647
false
0
0.008403
0
0.193277
0.05042
0
0
0
null
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
81a62c5963fc9b6615ab457b4e524e86f8ffa6af
1,918
py
Python
src/plugins/database.py
Blitz-Raynor/Kiba
a73b5b6212a5446d218a80f1a6aba108e0a1912b
[ "MIT" ]
4
2022-01-24T05:33:34.000Z
2022-03-25T06:29:19.000Z
src/plugins/database.py
Blitz-Raynor/Kiba
a73b5b6212a5446d218a80f1a6aba108e0a1912b
[ "MIT" ]
null
null
null
src/plugins/database.py
Blitz-Raynor/Kiba
a73b5b6212a5446d218a80f1a6aba108e0a1912b
[ "MIT" ]
3
2022-02-08T13:24:59.000Z
2022-03-13T06:42:40.000Z
import aiosqlite import sqlite3 import asyncio import nonebot from nonebot.log import logger driver: nonebot.Driver = nonebot.get_driver() config: nonebot.config.Config = driver.config @driver.on_startup async def init_db(): config.db = await aiosqlite.connect("src/static/Kiba.db") logger.info("Kiba Kernel -> Starting to Create \"Kiba Database\"") try: await config.db.executescript( "create table group_poke_table (group_id bigint primary key not null, last_trigger_time int, triggered int, disabled bit, strategy text);" "create table user_poke_table (user_id bigint, group_id bigint, triggered int);" "create table guess_table (group_id bigint, enabled bit);" "create table waiting_table (shop text, location text, wait int, updated text);" "create table plp_table (id bigint, user_id bigint, nickname text, message text, is_picture bit, view bigint, reply bigint);" "create table plp_reply_table (id bigint, plpid bigint, userid bigint, nickname text, message text);" "create table group_plp_table (group_id bigint, disableinsert int, disabletake int, disablereply int, slowmode int, limit int, time bigint);" "create table plp_blacklist_table (id bigint, lastbanner bigint, disableinsert int, disabletake int, disablereply int);" "create table gld_table (qq bigint, uid bigint);" "create table sign_table (no bigint, id bigint, day int);" "create table acard_table (id bigint, times int, six int, five int, four int, three int, two int, one int);" ) logger.info("Kiba Kernel -> Create \"Kiba Database\" successfully") except Exception as e: logger.info(f"Kiba Kernel --Skip-> Database Created....Skipped Creating Databases. \n[SKIP ERR]{e}") pass @driver.on_shutdown async def free_db(): await config.db.close()
53.277778
153
0.696038
258
1,918
5.05814
0.399225
0.09272
0.039847
0.041379
0.122605
0.078161
0.078161
0
0
0
0
0.000661
0.211157
1,918
36
154
53.277778
0.861864
0
0
0
0
0.125
0.630016
0
0
0
0
0
0
1
0
true
0.03125
0.15625
0
0.15625
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
81ac62bd68434ff2ce3767d63cce77c07cbf51c7
305
py
Python
PyObjCTest/test_nspdfinfo.py
linuxfood/pyobjc-framework-Cocoa-test
3475890f165ab26a740f13d5afe4c62b4423a140
[ "MIT" ]
null
null
null
PyObjCTest/test_nspdfinfo.py
linuxfood/pyobjc-framework-Cocoa-test
3475890f165ab26a740f13d5afe4c62b4423a140
[ "MIT" ]
null
null
null
PyObjCTest/test_nspdfinfo.py
linuxfood/pyobjc-framework-Cocoa-test
3475890f165ab26a740f13d5afe4c62b4423a140
[ "MIT" ]
null
null
null
import AppKit from PyObjCTools.TestSupport import TestCase, min_os_level class TestNSPDFInfo(TestCase): @min_os_level("10.9") def testMethods(self): self.assertResultIsBOOL(AppKit.NSPDFInfo.isFileExtensionHidden) self.assertArgIsBOOL(AppKit.NSPDFInfo.setFileExtensionHidden_, 0)
30.5
73
0.783607
32
305
7.3125
0.6875
0.094017
0.111111
0.153846
0
0
0
0
0
0
0
0.015152
0.134426
305
9
74
33.888889
0.871212
0
0
0
0
0
0.013115
0
0
0
0
0
0.285714
1
0.142857
false
0
0.285714
0
0.571429
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
2
81b791765a1072aa2be9a40bf2e9fca71ca77b5d
555
py
Python
app/migrations/0010_auto_20200709_1512.py
RuijiaX/w3hacks
79e1eb81836b766737e8f053a26495ec2c6fd963
[ "MIT" ]
1
2020-08-30T04:49:20.000Z
2020-08-30T04:49:20.000Z
app/migrations/0010_auto_20200709_1512.py
RuijiaX/w3hacks
79e1eb81836b766737e8f053a26495ec2c6fd963
[ "MIT" ]
44
2020-06-21T03:10:35.000Z
2020-08-08T23:55:19.000Z
app/migrations/0010_auto_20200709_1512.py
RuijiaX/w3hacks
79e1eb81836b766737e8f053a26495ec2c6fd963
[ "MIT" ]
2
2020-07-01T16:54:58.000Z
2020-07-13T21:13:06.000Z
# Generated by Django 3.0.7 on 2020-07-09 22:12 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('app', '0009_auto_20200709_1430'), ] operations = [ migrations.AlterField( model_name='location', name='lat', field=models.IntegerField(blank=True, null=True), ), migrations.AlterField( model_name='location', name='lng', field=models.IntegerField(blank=True, null=True), ), ]
23.125
61
0.574775
57
555
5.508772
0.649123
0.127389
0.159236
0.184713
0.515924
0.515924
0.254777
0
0
0
0
0.080519
0.306306
555
23
62
24.130435
0.735065
0.081081
0
0.470588
1
0
0.094488
0.045276
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
81b9e4775c9ff677415dc6ea782a4181f1639a50
22,100
py
Python
python/scripts/wavsep/wavsep.py
rugheid/OSS-ZAP
d486dde326a9120c9ddd52a3d4dcf1b9a2b4d042
[ "Apache-2.0" ]
4
2016-08-11T05:35:26.000Z
2021-11-15T11:27:28.000Z
python/scripts/wavsep/wavsep.py
rugheid/OSS-ZAP
d486dde326a9120c9ddd52a3d4dcf1b9a2b4d042
[ "Apache-2.0" ]
1
2018-06-12T13:55:16.000Z
2018-06-12T15:27:59.000Z
python/scripts/wavsep/wavsep.py
rugheid/OSS-ZAP
d486dde326a9120c9ddd52a3d4dcf1b9a2b4d042
[ "Apache-2.0" ]
12
2018-05-15T10:14:00.000Z
2019-11-10T07:03:16.000Z
# Zed Attack Proxy (ZAP) and its related class files. # # ZAP is an HTTP/HTTPS proxy for assessing web application security. # # Copyright 2012 ZAP Development Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This script tests ZAP against wavsep: http://code.google.com/p/wavsep/ # Note wavsep has to be installed somewhere - the above link is to the # project not the test suite! # # To this script: # * Install the ZAP Python API: # Use 'pip install python-owasp-zap-v2' or # download from https://github.com/zaproxy/zaproxy/wiki/Downloads # * Start ZAP (as this is for testing purposes you might not want the # 'standard' ZAP to be started) # * Access wavsep via your browser, proxying through ZAP # * Vist all of the wavsep top level URLs, eg # http://localhost:8080/wavsep/index-active.jsp # http://localhost:8080/wavsep/index-passive.jsp # * Run the Spider against http://localhost:8080 # * Run the Active Scanner against http://localhost:8080/wavsep # * Run this script # * Open the report.html file generated in your browser # # Notes: # This has been tested against wavsep 1.5 from zapv2 import ZAPv2 import datetime, sys, getopt def main(argv): # ------------------------------------------------------------------------- # Default Configurations - use -h and -p for different host and port # ------------------------------------------------------------------------- zapHost = '127.0.0.1' zapPort = '8090' try: opts, args = getopt.getopt(argv,"h:p:") except getopt.GetoptError: print 'wavsep.py -h <ZAPhost> -p <ZAPport>' sys.exit(2) for opt, arg in opts: if opt == '-h': zapHost = arg elif opt == '-p': zapPort = arg zapUrl = 'http://' + zapHost + ':' + zapPort # Dictionary of abbreviation to keep the output a bit shorter abbrev = { 'Active Vulnerability title' : 'Ex',\ 'Cross Site Scripting (DOM Based)' : 'DXSS',\ 'Cross Site Scripting (Reflected)' : 'RXSS',\ 'Absence of Anti-CSRF Tokens' : 'NoCSRF',\ 'Application Error Disclosure' : 'AppError',\ 'Anti CSRF Tokens Scanner' : 'ACSRF',\ 'Buffer Overflow' : 'Buffer',\ 'Cookie set without HttpOnly flag' : 'HttpOnly',\ 'Cookie Slack Detector' : 'CookieSlack',\ 'Cross Site Request Forgery' : 'CSRF',\ 'External Redirect' : 'ExtRedir',\ 'Format String Error' : 'Format',\ 'HTTP Parameter Override' : 'ParamOver',\ 'Information disclosure - database error messages' : 'InfoDb',\ 'Information disclosure - debug error messages' : 'InfoDebug',\ 'Information Disclosure - Sensitive Informations in URL' : 'InfoUrl',\ 'LDAP Injection' : 'LDAP',\ 'Loosely Scoped Cookie' : 'CookieLoose',\ 'None. Warning only.' : 'NoCSRF2',\ 'Password Autocomplete in browser' : 'Auto',\ 'Path Traversal' : 'PathTrav',\ 'Private IP Disclosure' : 'PrivIP',\ 'Remote File Inclusion' : 'RFI',\ 'Session ID in URL Rewrite' : 'SessRewrite',\ 'Source Code Disclosure - File Inclusion' : 'SrcInc',\ 'SQL Injection' : 'SQLi',\ 'SQL Injection - MySQL' : 'SqlMySql',\ 'SQL Injection - Generic SQL RDBMS' : 'SqlGen',\ 'SQL Injection - Boolean Based' : 'SqlBool',\ 'SQL Injection - Error Based - Generic SQL RDBMS' : 'SqlGenE',\ 'SQL Injection - Error Based - MySQL' : 'SqlMySqlE',\ 'SQL Injection - Error Based - Java' : 'SqlJavaE',\ 'SQL Injection - Hypersonic SQL - Time Based' : 'SqlHyperT',\ 'SQL Injection - MySQL - Time Based' : 'SqlMySqlT',\ 'SQL Injection - Oracle - Time Based' : 'SqlOracleT',\ 'SQL Injection - PostgreSQL - Time Based' : 'SqlPostgreT',\ 'URL Redirector Abuse' : 'UrlRedir',\ 'Viewstate without MAC signature (Unsure)' : 'ViewstateNoMac',\ 'Weak Authentication Method' : 'WeakAuth',\ 'Web Browser XSS Protection Not Enabled' : 'XSSoff',\ 'X-Content-Type-Options Header Missing' : 'XContent',\ 'X-Frame-Options Header Not Set' : 'XFrame'} # The rules to apply: # Column 1: String to match against an alert URL # Column 2: Alert abbreviation to match # Column 3: pass, fail, ignore # rules = [ \ # All these appear to be valid ;) ['-', 'InfoDebug', 'ignore'], \ ['-', 'InfoUrl', 'ignore'], \ ['-', 'ACSRF', 'ignore'], \ ['-', 'ACSRF', 'ignore'], \ ['-', 'Ex', 'ignore'], \ ['-', 'CookieLoose', 'ignore'], \ ['-', 'CookieSlack', 'ignore'], \ ['-', 'NoCSRF2', 'ignore'], \ ['-', 'ParamOver', 'ignore'], \ ['-', 'PrivIP', 'ignore'], \ ['-', 'SrcInc', 'ignore'], \ ['-', 'XFrame', 'ignore'], \ ['-', 'XContent', 'ignore'], \ ['-', 'XSSoff', 'ignore'], \ ['LFI-', 'AppError', 'ignore'], \ ['LFI-', 'Buffer', 'ignore'], \ ['LFI-', 'Format', 'ignore'], \ ['LFI-', 'NoCSRF', 'ignore'], \ ['LFI-', 'RFI', 'ignore'], \ ['LFI-', 'DXSS', 'ignore'], \ ['LFI-', 'RXSS', 'ignore'], \ ['LFI-', 'SqlHyperT', 'ignore'], \ ['LFI-', 'SqlMySql', 'ignore'], \ ['LFI-', 'SqlOracleT', 'ignore'], \ ['LFI-', 'SqlPostgreT', 'ignore'], \ ['Redirect-', 'LDAP', 'ignore'], \ ['Redirect-', 'NoCSRF', 'ignore'], \ ['Redirect-', 'RFI', 'ignore'], \ ['Redirect-', 'DXSS', 'ignore'], \ ['Redirect-', 'RXSS', 'ignore'], \ ['Redirect-', 'SqlHyperT', 'ignore'], \ ['Redirect-', 'SqlMySql', 'ignore'], \ ['Redirect-', 'SqlOracleT', 'ignore'], \ ['Redirect-', 'SqlPostgreT', 'ignore'], \ ['RFI-', 'AppError', 'ignore'], \ ['RFI-', 'Buffer', 'ignore'], \ ['RFI-', 'Format', 'ignore'], \ ['RFI-', 'NoCSRF', 'ignore'], \ ['RFI-', 'DXSS', 'ignore'], \ ['RFI-', 'RXSS', 'ignore'], \ ['RFI-', 'SqlHyperT', 'ignore'], \ ['RFI-', 'SqlMySql', 'ignore'], \ ['RFI-', 'SqlOracleT', 'ignore'], \ ['RFI-', 'SqlPostgreT', 'ignore'], \ ['RXSS-', 'Auto', 'ignore'], \ ['RXSS-', 'Buffer', 'ignore'], \ ['RXSS-', 'Format', 'ignore'], \ ['RXSS-', 'HttpOnly', 'ignore'], \ ['RXSS-', 'NoCSRF', 'ignore'], \ ['RXSS-', 'SqlOracleT', 'ignore'], \ ['RXSS-', 'SqlPostgreT', 'ignore'], \ ['RXSS-', 'SqlMySql', 'ignore'], \ ['RXSS-', 'SqlOracleT', 'ignore'], \ ['RXSS-', 'ViewstateNoMac', 'ignore'], \ ['SInjection-', 'AppError', 'ignore'], \ ['SInjection-', 'Auto', 'ignore'], \ ['SInjection-', 'Buffer', 'ignore'], \ ['SInjection-', 'NoCSRF', 'ignore'], \ ['SInjection-', 'Format', 'ignore'], \ ['SInjection-', 'LDAP', 'ignore'], \ ['SInjection-', 'RXSS', 'ignore'], \ ['SInjection-', 'SqlHyperT', 'ignore'], \ ['LoginBypass', 'Auto', 'ignore'], \ ['CrlfRemovalInHttpHeader', 'HttpOnly', 'ignore'], \ ['Tag2HtmlPageScopeValidViewstateRequired', 'ViewstateNoMac', 'ignore'], \ ['session-password-autocomplete', 'NoCSRF', 'ignore'], \ # ['LFI-Detection-Evaluation', 'PathTrav', 'pass'], \ ['LFI-FalsePositives', 'PathTrav', 'fail'], \ ['Redirect-', 'ExtRedir', 'pass'], \ ['RFI-Detection-Evaluation', 'RFI', 'pass'], \ ['RFI-FalsePositives', 'RFI', 'fail'], \ ['RXSS-Detection-Evaluation', 'DXSS', 'pass'], \ ['RXSS-Detection-Evaluation', 'RXSS', 'pass'], \ ['RXSS-FalsePositives-GET', 'DXSS', 'fail'], \ ['RXSS-FalsePositives-GET', 'RXSS', 'fail'], \ ['SInjection-Detection-Evaluation', 'SQLfp', 'pass'], \ ['SInjection-Detection-Evaluation', 'SQLi', 'pass'], \ #['SInjection-Detection-Evaluation', 'SqlHyper', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlBool', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlGen', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlGenE', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlMySql', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlMySqlE', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlMySqlT', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlOracleT', 'pass'], \ ['SInjection-Detection-Evaluation', 'SqlPostgreT', 'pass'], \ ['SInjection-FalsePositives', 'SQLfp', 'fail'], \ ['SInjection-FalsePositives', 'SQLi', 'fail'], \ ['SInjection-FalsePositives', 'SqlBool', 'fail'], \ ['SInjection-FalsePositives', 'SqlGen', 'fail'], \ ['SInjection-FalsePositives', 'SqlGenE', 'fail'], \ ['SInjection-FalsePositives', 'SqlMySql', 'fail'], \ ['SInjection-FalsePositives', 'SqlMySqlE', 'fail'], \ ['SInjection-FalsePositives', 'SqlMySqlT', 'fail'], \ ['SInjection-FalsePositives', 'SqlHyperT', 'fail'], \ ['SInjection-FalsePositives', 'SqlMySqlT', 'fail'], \ ['SInjection-FalsePositives', 'SqlOracleT', 'fail'], \ ['SInjection-FalsePositives', 'SqlPostgreT', 'fail'], \ ['info-cookie-no-httponly', 'HttpOnly', 'pass'], \ ['info-server-stack-trace', 'AppError', 'pass'], \ ['session-password-autocomplete', 'Auto', 'pass'], \ ['weak-authentication-basic', 'WeakAuth', 'pass'], \ ] zap = ZAPv2(proxies={'http': zapUrl, 'https': zapUrl}) uniqueUrls = set([]) # alertsPerUrl is a disctionary of urlsummary to a dictionary of type to set of alertshortnames ;) alertsPerUrl = {} plugins = set([]) alertPassCount = {} alertFailCount = {} alertIgnoreCount = {} alertOtherCount = {} zapVersion = zap.core.version totalAlerts = 0 offset = 0 page = 100 # Page through the alerts as otherwise ZAP can hang... alerts = zap.core.alerts('', offset, page) while len(alerts) > 0: totalAlerts += len(alerts) for alert in alerts: url = alert.get('url') # Grab the url before any '?' url = url.split('?')[0] #print 'URL: ' + url urlEl = url.split('/') if (len(urlEl) > 6): #print 'URL 4:' + urlEl[4] + ' 6:' + urlEl[6].split('-')[0] if (urlEl[3] != 'wavsep'): print 'Ignoring non wavsep URL 4:' + urlEl[4] + ' URL 5:' + urlEl[5] + ' URL 6:' + urlEl[6] continue if (urlEl[6].split('-')[0][:9] == 'index.jsp'): #print 'Ignoring index URL 4:' + urlEl[4] + ' URL 5:' + urlEl[5] + ' URL 6:' + urlEl[6] continue if (len(urlEl) > 7 and urlEl[4] == 'active'): if (urlEl[7].split('-')[0][:4] != 'Case'): #print 'Ignoring index URL 4:' + urlEl[4] + ' URL 5:' + urlEl[5] + ' URL 6:' + urlEl[6] + ' URL 7:' + urlEl[7] continue urlSummary = urlEl[4] + ' : ' + urlEl[5] + ' : ' + urlEl[6] + ' : ' + urlEl[7].split('-')[0] else: # Passive URLs have different format urlSummary = urlEl[4] + ' : ' + urlEl[5] + ' : ' + urlEl[6] #print 'URL summary:' + urlSummary short = abbrev.get(alert.get('alert')) if (short is None): short = 'UNKNOWN' print 'Unknown alert: ' + alert.get('alert') aDict = alertsPerUrl.get(urlSummary, {'pass' : set([]), 'fail' : set([]), 'ignore' : set([]), 'other' : set([])}) added = False for rule in rules: if (rule[0] in urlSummary and rule[1] == short): aDict[rule[2]].add(short) # Counts per alert if (rule[2] == 'pass'): alertPassCount[short] = alertPassCount.get(short, 0) + 1 elif (rule[2] == 'fail'): alertFailCount[short] = alertFailCount.get(short, 0) + 1 elif (rule[2] == 'ignore'): alertIgnoreCount[short] = alertIgnoreCount.get(short, 0) + 1 added = True break if (not added): aDict['other'].add(short) alertOtherCount[short] = alertOtherCount.get(short, 0) + 1 alertsPerUrl[urlSummary] = aDict plugins.add(alert.get('alert')) uniqueUrls.add(url) offset += page alerts = zap.core.alerts('', offset, page) #for key, value in alertsPerUrl.iteritems(): # print key, value # Generate report file reportFile = open('report.html', 'w') reportFile.write("<html>\n") reportFile.write(" <head>\n") reportFile.write(" <title>ZAP Wavsep Report</title>\n") reportFile.write(" <!--Load the AJAX API-->\n") reportFile.write(" <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>\n") reportFile.write(" </head>\n") reportFile.write("<body>\n") reportFile.write("<h1><img src=\"https://raw.githubusercontent.com/zaproxy/zaproxy/develop/src/resource/zap64x64.png\" align=\"middle\">OWASP ZAP wavsep results</h1>\n") reportFile.write("Generated: " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + "\n") topResults = [] thisTop = ['', 0, 0] groupResults = [] thisGroup = ['', 0, 0] totalPass = 0 totalFail = 0 # Calculate the top level scores for key, value in sorted(alertsPerUrl.iteritems()): top = key.split(' : ')[1] if ('-' in top): top = top.split('-')[0] + '-' + top.split('-')[1] if (top != thisTop[0]): thisTop = [top, 0, 0] # top, pass, fail topResults.append(thisTop) if (len(value.get('pass')) > 0): thisTop[1] += 1 elif (len(value.get('fail')) > 0): thisTop[2] += 1 elif ('FalsePositive' in key): thisTop[1] += 1 else: thisTop[2] += 1 # Calculate the group scores for key, value in sorted(alertsPerUrl.iteritems()): group = key.split(' : ')[1] if (group != thisGroup[0]): thisGroup = [group, 0, 0] # group, pass, fail groupResults.append(thisGroup) if (len(value.get('pass')) > 0): totalPass += 1 thisGroup[1] += 1 elif (len(value.get('fail')) > 0): totalFail += 1 thisGroup[2] += 1 elif ('FalsePositive' in key): totalPass += 1 thisGroup[1] += 1 else: totalFail += 1 thisGroup[2] += 1 # Output the summary scale=8 reportFile.write("<h3>Total Score</h3>\n") reportFile.write("<font style=\"BACKGROUND-COLOR: GREEN\">") for i in range (totalPass/scale): reportFile.write("&nbsp;") reportFile.write("</font>") reportFile.write("<font style=\"BACKGROUND-COLOR: RED\">") for i in range (totalFail/scale): reportFile.write("&nbsp;") reportFile.write("</font>") total = 100 * totalPass / (totalPass + totalFail) reportFile.write(str(total) + "%<br/><br/>\n") reportFile.write('ZAP Version: ' + zapVersion + '<br/>\n') reportFile.write('URLs found: ' + str(len(uniqueUrls))) # Output the top level table reportFile.write("<h3>Top Level Scores</h3>\n") reportFile.write("<table border=\"1\">\n") reportFile.write("<tr><th>Top Level</th><th>Pass</th><th>Fail</th><th>Score</th><th>Chart</th></tr>\n") scale=6 for topResult in topResults: #print "%s Pass: %i Fail: %i Score: %i\%" % (topResult[0], topResult[1], topResult[2], (100*topResult[1]/topResult[1]+topResult[2])) reportFile.write("<tr>") reportFile.write("<td>" + topResult[0] + "</td>") reportFile.write("<td align=\"right\">" + str(topResult[1]) + "</td>") reportFile.write("<td align=\"right\">" + str(topResult[2]) + "</td>") score = 100 * topResult[1] / (topResult[1] + topResult[2]) reportFile.write("<td align=\"right\">" + str(score) + "%</td>") reportFile.write("<td>") reportFile.write("<font style=\"BACKGROUND-COLOR: GREEN\">") for i in range (topResult[1]/scale): reportFile.write("&nbsp;") reportFile.write("</font>") reportFile.write("<font style=\"BACKGROUND-COLOR: RED\">") for i in range (topResult[2]/scale): reportFile.write("&nbsp;") reportFile.write("</font>") reportFile.write("</td>") reportFile.write("</tr>\n") reportFile.write("</table><br/>\n") reportFile.write("<h3>Alerts</h3>\n") reportFile.write("<table border=\"1\">\n") reportFile.write("<tr><th>Alert</th><th>Description</th><th>Pass</th><th>Fail</th><th>Ignore</th><th>Other</th></tr>\n") #for key, value in abbrev.items(): for (k, v) in sorted(abbrev.items(), key=lambda (k,v): v): reportFile.write("<tr>") reportFile.write("<td>" + v + "</td>") reportFile.write("<td>" + k + "</td>") reportFile.write("<td>" + str(alertPassCount.get(v, 0)) +"&nbsp;</td>") reportFile.write("<td>" + str(alertFailCount.get(v, 0)) +"&nbsp;</td>") reportFile.write("<td>" + str(alertIgnoreCount.get(v, 0)) +"&nbsp;</td>") reportFile.write("<td>" + str(alertOtherCount.get(v, 0)) +"&nbsp;</td>") reportFile.write("</tr>\n") reportFile.write("</table><br/>\n") # Output the group table reportFile.write("<h3>Group Scores</h3>\n") reportFile.write("<table border=\"1\">\n") reportFile.write("<tr><th>Group</th><th>Pass</th><th>Fail</th><th>Score</th><th>Chart</th></tr>\n") scale=4 for groupResult in groupResults: #print "%s Pass: %i Fail: %i Score: %i\%" % (groupResult[0], groupResult[1], groupResult[2], (100*groupResult[1]/groupResult[1]+groupResult[2])) reportFile.write("<tr>") reportFile.write("<td>" + groupResult[0] + "</td>") reportFile.write("<td align=\"right\">" + str(groupResult[1]) + "</td>") reportFile.write("<td align=\"right\">" + str(groupResult[2]) + "</td>") score = 100 * groupResult[1] / (groupResult[1] + groupResult[2]) reportFile.write("<td align=\"right\">" + str(score) + "%</td>") reportFile.write("<td>") reportFile.write("<font style=\"BACKGROUND-COLOR: GREEN\">") for i in range (groupResult[1]/scale): reportFile.write("&nbsp;") reportFile.write("</font>") reportFile.write("<font style=\"BACKGROUND-COLOR: RED\">") for i in range (groupResult[2]/scale): reportFile.write("&nbsp;") reportFile.write("</font>") reportFile.write("</td>") reportFile.write("</tr>\n") reportFile.write("</table><br/>\n") # Output the detail table reportFile.write("<h3>Detailed Results</h3>\n") reportFile.write("<table border=\"1\">\n") reportFile.write("<tr><th>Page</th><th>Result</th><th>Pass</th><th>Fail</th><th>Ignore</th><th>Other</th></tr>\n") for key, value in sorted(alertsPerUrl.iteritems()): reportFile.write("<tr>") keyArray = key.split(':') if (len(keyArray) == 4): reportFile.write("<td>" + keyArray[0] + keyArray[2] + keyArray[3] + "</td>") else: reportFile.write("<td>" + keyArray[0] + keyArray[2] + "</td>") reportFile.write("<td>") if (len(value.get('pass')) > 0): reportFile.write("<font style=\"BACKGROUND-COLOR: GREEN\">&nbsp;PASS&nbsp</font>") elif (len(value.get('fail')) > 0): reportFile.write("<font style=\"BACKGROUND-COLOR: RED\">&nbsp;FAIL&nbsp</font>") elif ('FalsePositive' in key): reportFile.write("<font style=\"BACKGROUND-COLOR: GREEN\">&nbsp;PASS&nbsp</font>") else: reportFile.write("<font style=\"BACKGROUND-COLOR: RED\">&nbsp;FAIL&nbsp</font>") reportFile.write("</td>") reportFile.write("<td>") if (value.get('pass') is not None): reportFile.write(" ".join(value.get('pass'))) reportFile.write("&nbsp;</td>") reportFile.write("<td>") if (value.get('fail') is not None): reportFile.write(" ".join(value.get('fail'))) reportFile.write("&nbsp;</td>") reportFile.write("<td>") if (value.get('ignore') is not None): reportFile.write(" ".join(value.get('ignore'))) reportFile.write("&nbsp;</td>") reportFile.write("<td>") if (value.get('other') is not None): reportFile.write(" ".join(value.get('other'))) reportFile.write("&nbsp;</td>") reportFile.write("</tr>\n") reportFile.write("</table><br/>\n") reportFile.write("<h3>Plugin Times</h3>\n") # The start of the chart script reportFile.write("<script type=\"text/javascript\">\n") reportFile.write(" // Load the Visualization API and the piechart package.\n") reportFile.write(" google.load('visualization', '1.0', {'packages':['corechart']});\n") reportFile.write(" // Set a callback to run when the Google Visualization API is loaded.\n") reportFile.write(" google.setOnLoadCallback(drawChart);\n") reportFile.write(" function drawChart() {\n") reportFile.write(" // Create the data table.\n") reportFile.write(" var data = new google.visualization.DataTable();\n") reportFile.write(" data.addColumn('string', 'Plugin');\n") reportFile.write(" data.addColumn('number', 'Time in ms');\n") reportFile.write(" data.addRows([\n") progress = zap.ascan.scan_progress() # Loop through first time for the chart for plugin in progress[1]['HostProcess']: reportFile.write(" ['" + plugin['Plugin'][0] + "', " + plugin['Plugin'][3] + "],\n") # The end of the chart script reportFile.write(" ]);\n") reportFile.write(" // Set chart options\n") reportFile.write(" var options = {'title':'Plugin times',\n") reportFile.write(" 'width':600,\n") reportFile.write(" 'height':500};\n") reportFile.write(" // Instantiate and draw our chart, passing in some options.\n") reportFile.write(" var chart = new google.visualization.PieChart(document.getElementById('chart_div'));\n") reportFile.write(" chart.draw(data, options);\n") reportFile.write(" }\n") reportFile.write("</script>\n") reportFile.write("<div id=\"chart_div\"></div>\n") reportFile.write("<table border=\"1\">\n") reportFile.write("<tr><th>Plugin</th><th>ms</th></tr>\n") # Loop through second time for the table totalTime = 0 for plugin in progress[1]['HostProcess']: reportFile.write("<tr>") reportFile.write("<td>" + plugin['Plugin'][0] + "</td>") # Convert ms into something more readable t = int(plugin['Plugin'][3]) totalTime += t s, ms = divmod(t, 1000) m, s = divmod(s, 60) h, m = divmod(m, 60) time = "%d:%02d:%02d.%03d" % (h, m, s, ms) reportFile.write("<td>" + time + "</td>") reportFile.write("</tr>\n") reportFile.write("<tr><td></td><td></td></tr>") reportFile.write("<tr>") reportFile.write("<td>Total</td>") # Convert ms into something more readable s, ms = divmod(totalTime, 1000) m, s = divmod(s, 60) h, m = divmod(m, 60) time = "%d:%02d:%02d.%03d" % (h, m, s, ms) reportFile.write("<td>" + time + "</td>") reportFile.write("</tr>\n") reportFile.write("</table><br/>\n") reportFile.write("</body></html>\n") reportFile.close() #for key, value in sorted(alertsPerUrl.iteritems()): # print "%s: %s" % (key, value) #print '' print '' print 'Got ' + str(totalAlerts) + ' alerts' print 'Got ' + str(len(uniqueUrls)) + ' unique urls' print 'Took ' + time print 'Score ' + str(total) if __name__ == "__main__": main(sys.argv[1:])
38.368056
170
0.611403
2,662
22,100
5.071751
0.196093
0.144434
0.059255
0.022517
0.332938
0.297385
0.266277
0.220206
0.176654
0.157025
0
0.014942
0.164208
22,100
575
171
38.434783
0.715987
0.156063
0
0.252294
0
0.009174
0.385995
0.092432
0
0
0
0
0
0
null
null
0.100917
0.004587
null
null
0.018349
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
1
0
0
0
0
0
2
81d02a1b1d708206e4f47e1ceb3bcbc7a7b7f3aa
4,386
py
Python
picklesize/test_picklesize.py
pydron/picklesize
c524ccae7beecfada663fbcf251c4166158f2995
[ "MIT" ]
null
null
null
picklesize/test_picklesize.py
pydron/picklesize
c524ccae7beecfada663fbcf251c4166158f2995
[ "MIT" ]
null
null
null
picklesize/test_picklesize.py
pydron/picklesize
c524ccae7beecfada663fbcf251c4166158f2995
[ "MIT" ]
null
null
null
''' Created on 20.07.2015 @author: stefan ''' import unittest import pickle import picklesize import copy_reg class TestEstimator(unittest.TestCase): def setUp(self): self.target = picklesize.PickleSize() def compare(self, obj): data = pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL) expected = len(data) actual = self.target.picklesize(obj, pickle.HIGHEST_PROTOCOL) self.assertEqual(expected, actual, "Wrong estimate (%s instead of %s) for %r." % (actual, expected, obj)) def test_None(self): self.compare(None) def test_True(self): self.compare(True) def test_False(self): self.compare(False) def test_int(self): self.compare(0) self.compare(1) self.compare(0xFF-1) self.compare(0xFF) self.compare(0xFF+1) self.compare(0xFFFF-1) self.compare(0xFFFF) self.compare(0xFFFF+1) self.compare(-0xFF-1) self.compare(-0xFF) self.compare(-0xFF+1) self.compare(-0xFFFF-1) self.compare(-0xFFFF) self.compare(-0xFFFF+1) def test_long(self): self.compare(0L) self.compare(1L) self.compare(10L**100) self.compare(10L**1000) def test_float(self): self.compare(0.0) self.compare(-42.42) def test_string(self): self.compare("") self.compare(255*"x") self.compare(256*"x") self.compare(257*"x") def test_unicode(self): self.compare(u"") self.compare(255*u"x") self.compare(256*u"x") self.compare(257*u"x") def test_tuple(self): self.compare(tuple()) self.compare((1,)) self.compare((1,2)) self.compare((1,2,3)) self.compare((1,2,3,4)) def test_list(self): self.compare([]) self.compare([1]) self.compare(999*[1]) self.compare(1000*[1]) self.compare(1001*[1]) self.compare(1002*[1]) self.compare(5412*[1]) def test_dict(self): self.compare({}) self.compare({1:2}) self.compare({1:1, 2:2}) def test_instance(self): self.compare(OldStyle_WithAttribs()) self.compare(OldStyle_WithInit()) def test_Type(self): self.compare(long) self.compare(OldStyle_WithAttribs) self.compare(global_function) self.compare(max) def test_Ref(self): x = "abc" self.compare([x,x]) def test_Reducer(self): self.compare(NewStyle_Reducer()) def test_NewStyleInstance(self): self.compare(NewStyle_WithAttribs()) def test_numpy(self): import numpy as np self.compare(np.ones((10,10))) self.compare(np.ones((10,10))[0:5,:]) self.compare(np.ones((10,10))[:,0:5]) def test_numpy_multiple_arrays(self): import numpy as np self.compare([np.ones((10,10)), np.ones((10,10))]) def test_numpy_large(self): import numpy as np self.compare(np.ones(1024*1024)) class TestFast(TestEstimator): def setUp(self): self.target = picklesize.FastPickleSize() def compare(self, obj): data = pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL) expected = len(data) actual = self.target.picklesize(obj, pickle.HIGHEST_PROTOCOL) self.assertLessEqual(actual, 2*expected+100, "Over estimate (%s instead of %s) for %r." % (actual, expected, obj)) self.assertGreaterEqual(actual, 0.5*expected-100, "Gross under estimate (%s instead of %s) for %r." % (actual, expected, obj)) class OldStyle_WithAttribs(): def __init__(self): self.a = 12 self.b = 42 class OldStyle_WithInit(): def __getinitargs__(self): return (1,2,3) class NewStyle_Reducer(object): pass class NewStyle_WithAttribs(object): def __init__(self): self.a = 12 self.b = 42 def tuple_reducer(obj): return (NewStyle_Reducer, tuple()) copy_reg.pickle(NewStyle_Reducer, tuple_reducer) def global_function(): pass
24.779661
110
0.564979
529
4,386
4.58034
0.206049
0.27239
0.09286
0.03508
0.459348
0.427982
0.350392
0.329757
0.310772
0.275279
0
0.052511
0.30529
4,386
177
111
24.779661
0.742698
0
0
0.192
0
0
0.03156
0
0
0
0.013822
0
0.024
0
null
null
0.016
0.056
null
null
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
1
0
0
0
0
0
0
0
0
2
81e5f55f1de69308bb6ff205c3967683e8097ccc
3,806
py
Python
gammapy/data/tests/test_pointing.py
Rishank2610/gammapy
3cd64fdb2c53c8e5c697a9b85ef8d0486bff0b76
[ "BSD-3-Clause" ]
155
2015-02-25T12:38:02.000Z
2022-03-13T17:54:30.000Z
gammapy/data/tests/test_pointing.py
Rishank2610/gammapy
3cd64fdb2c53c8e5c697a9b85ef8d0486bff0b76
[ "BSD-3-Clause" ]
3,131
2015-01-06T15:36:23.000Z
2022-03-31T17:30:57.000Z
gammapy/data/tests/test_pointing.py
Rishank2610/gammapy
3cd64fdb2c53c8e5c697a9b85ef8d0486bff0b76
[ "BSD-3-Clause" ]
158
2015-03-16T20:36:44.000Z
2022-03-30T16:05:37.000Z
# Licensed under a 3-clause BSD style license - see LICENSE.rst from numpy.testing import assert_allclose from astropy.time import Time from gammapy.data import FixedPointingInfo, PointingInfo from gammapy.utils.testing import assert_time_allclose, requires_data @requires_data() class TestFixedPointingInfo: @classmethod def setup_class(cls): filename = "$GAMMAPY_DATA/tests/pointing_table.fits.gz" cls.fpi = FixedPointingInfo.read(filename) def test_location(self): lon, lat, height = self.fpi.location.geodetic assert_allclose(lon.deg, 16.5002222222222) assert_allclose(lat.deg, -23.2717777777778) assert_allclose(height.value, 1834.999999999783) def test_time_ref(self): expected = Time(51910.00074287037, format="mjd", scale="tt") assert_time_allclose(self.fpi.time_ref, expected) def test_time_start(self): time = self.fpi.time_start expected = Time(53025.826414166666, format="mjd", scale="tt") assert_time_allclose(time, expected) def test_time_stop(self): time = self.fpi.time_stop expected = Time(53025.844770648146, format="mjd", scale="tt") assert_time_allclose(time, expected) def test_duration(self): duration = self.fpi.duration assert_allclose(duration.sec, 1586.0000000044238) def test_radec(self): pos = self.fpi.radec assert_allclose(pos.ra.deg, 83.633333333333) assert_allclose(pos.dec.deg, 24.51444444) assert pos.name == "icrs" def test_altaz(self): pos = self.fpi.altaz assert_allclose(pos.az.deg, 7.48272) assert_allclose(pos.alt.deg, 41.84191) assert pos.name == "altaz" @requires_data() class TestPointingInfo: @classmethod def setup_class(cls): filename = "$GAMMAPY_DATA/tests/pointing_table.fits.gz" cls.pointing_info = PointingInfo.read(filename) def test_str(self): ss = str(self.pointing_info) assert "Pointing info" in ss def test_location(self): lon, lat, height = self.pointing_info.location.geodetic assert_allclose(lon.deg, 16.5002222222222) assert_allclose(lat.deg, -23.2717777777778) assert_allclose(height.value, 1834.999999999783) def test_time_ref(self): expected = Time(51910.00074287037, format="mjd", scale="tt") assert_time_allclose(self.pointing_info.time_ref, expected) def test_table(self): assert len(self.pointing_info.table) == 100 def test_time(self): time = self.pointing_info.time assert len(time) == 100 expected = Time(53025.826414166666, format="mjd", scale="tt") assert_time_allclose(time[0], expected) def test_duration(self): duration = self.pointing_info.duration assert_allclose(duration.sec, 1586.0000000044238) def test_radec(self): pos = self.pointing_info.radec[0] assert_allclose(pos.ra.deg, 83.633333333333) assert_allclose(pos.dec.deg, 24.51444444) assert pos.name == "icrs" def test_altaz(self): pos = self.pointing_info.altaz[0] assert_allclose(pos.az.deg, 11.45751357) assert_allclose(pos.alt.deg, 41.34088901) assert pos.name == "altaz" def test_altaz_from_table(self): pos = self.pointing_info.altaz_from_table[0] assert_allclose(pos.az.deg, 11.20432353385406) assert_allclose(pos.alt.deg, 41.37921408774436) assert pos.name == "altaz" def test_altaz_interpolate(self): time = self.pointing_info.time[0] pos = self.pointing_info.altaz_interpolate(time) assert_allclose(pos.az.deg, 11.45751357) assert_allclose(pos.alt.deg, 41.34088901) assert pos.name == "altaz"
34.6
69
0.679453
488
3,806
5.125
0.206967
0.117553
0.081567
0.031987
0.716513
0.660536
0.60016
0.547781
0.519792
0.519792
0
0.118434
0.214661
3,806
109
70
34.917431
0.7183
0.016027
0
0.528736
0
0
0.040075
0.022442
0
0
0
0
0.413793
1
0.218391
false
0
0.045977
0
0.287356
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
1
0
1
0
0
0
0
0
0
0
2
c48f34eb08cb0b005af06224c4565e27b18c0cb3
672
py
Python
pyTuplingUtils/io.py
umd-lhcb/pyTuplingUtils
dd2efe154f1418a70295eabd8919e16ace2785cc
[ "BSD-2-Clause" ]
null
null
null
pyTuplingUtils/io.py
umd-lhcb/pyTuplingUtils
dd2efe154f1418a70295eabd8919e16ace2785cc
[ "BSD-2-Clause" ]
7
2020-04-20T17:25:45.000Z
2021-06-13T21:05:14.000Z
pyTuplingUtils/io.py
umd-lhcb/pyTuplingUtils
dd2efe154f1418a70295eabd8919e16ace2785cc
[ "BSD-2-Clause" ]
null
null
null
#!/usr/bin/env python3 # # Author: Yipeng Sun # License: BSD 2-clause # Last Change: Sun May 09, 2021 at 02:52 AM +0200 import numpy as np ARRAY_TYPE = 'np' def read_branch(ntp, tree, branch, idx=None): data = ntp[tree][branch].array(library=ARRAY_TYPE) return data if not idx else data[idx] def read_branches_dict(ntp, tree, branches): return ntp[tree].arrays(branches, library=ARRAY_TYPE) def read_branches(ntp, tree, branches, idx=None, transpose=False): data = list(ntp[tree].arrays(branches, library=ARRAY_TYPE).values()) if idx is not None: data = [d[idx] for d in data] return np.column_stack(data) if transpose else data
23.172414
72
0.699405
109
672
4.229358
0.486239
0.091106
0.104121
0.091106
0.160521
0.160521
0.160521
0
0
0
0
0.029091
0.181548
672
28
73
24
0.809091
0.16369
0
0
0
0
0.003591
0
0
0
0
0
0
1
0.25
false
0
0.083333
0.083333
0.583333
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
c49cdbfcdbfea8b874ccc9f3311ef29e7510510a
716
py
Python
tests/test_primitive_roots.py
greysonDEV/rng
5af76f5edff4de1b502c21ca1c1ce93243a618c8
[ "MIT" ]
null
null
null
tests/test_primitive_roots.py
greysonDEV/rng
5af76f5edff4de1b502c21ca1c1ce93243a618c8
[ "MIT" ]
null
null
null
tests/test_primitive_roots.py
greysonDEV/rng
5af76f5edff4de1b502c21ca1c1ce93243a618c8
[ "MIT" ]
null
null
null
from prng.util.util import primitive_roots import pytest def test_primitive_roots(): prim_roots_sets = [ [3, [2]], [7, [3,5]], [13, [2,6,7,11]], [17, [3,5,6,7,10,11,12,14]], [19, [2,3,10,13,14,15]], [31, [3,11,12,13,17,21,22,24]], [53, [2,3,5,8,12,14,18,19,20,21,22,26,27,31,32,33,34,35,39,41,45,48,50,51]], [61, [2,6,7,10,17,18,26,30,31,35,43,44,51,54,55,59]], [79, [3,6,7,28,29,30,34,35,37,39,43,47,48,53,54,59,60,63,66,68,70,74,75,77]], [103, [5,6,11,12,20,21,35,40,43,44,45,48,51,53,54,62,65,67,70,71,74,75,77,78,84,85,86,87,88,96,99,101]], ] assert all(sorted(primitive_roots(a)) == prs for a,prs in prim_roots_sets)
37.684211
112
0.544693
165
716
2.315152
0.521212
0.020942
0.068063
0
0
0
0
0
0
0
0
0.420962
0.187151
716
18
113
39.777778
0.235395
0
0
0
0
0
0
0
0
0
0
0
0.0625
1
0.0625
false
0
0.125
0
0.1875
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
c4a251a0e7e64524dd68b799ffbb2a257e20933b
894
py
Python
python-essential-training/4_operators/main.py
alexprodan99/python-workspace
8c805afc29fafe3916759d1cf07e597f945b8b45
[ "MIT" ]
null
null
null
python-essential-training/4_operators/main.py
alexprodan99/python-workspace
8c805afc29fafe3916759d1cf07e597f945b8b45
[ "MIT" ]
null
null
null
python-essential-training/4_operators/main.py
alexprodan99/python-workspace
8c805afc29fafe3916759d1cf07e597f945b8b45
[ "MIT" ]
null
null
null
def main(): # Arithmetic operators a = 7 b = 2 print(f'{a} + {b} = {a+b}') print(f'{a} - {b} = {a-b}') print(f'{a} * {b} = {a*b}') print(f'{a} / {b} = {a/b}') print(f'{a} // {b} = {a//b}') print(f'{a} % {b} = {a%b}') print(f'{a} ^ {b} = {a**b}') # Bitwise operators # &, |, ^, <<, >> print(f'{a} & {b} = {a&b}') print(f'{a} | {b} = {a|b}') print(f'{a} ^ {b} = {a^b}') print(f'{a} << {b} = {a<<b}') print(f'{a} >> {b} = {a>>b}') a = 0xff print(a) # 255 # fill with zeroes and second arg is the minimum number of bits that will be displayed print(f'hex(a)={a:03x}') # 0ff print(f'bin(a)={a:09b}') # Comparison operators # >,<,==,!=, >=, <= # Boolean operators # and, or, not, in, not in, is, is not if __name__ == '__main__': main()
21.804878
90
0.401566
133
894
2.639098
0.308271
0.136752
0.111111
0.273504
0.34188
0.34188
0.34188
0.34188
0.34188
0.34188
0
0.018364
0.329978
894
41
91
21.804878
0.567613
0.269575
0
0
0
0
0.384137
0
0
0
0.006221
0
0
1
0.047619
false
0
0
0
0.047619
0.714286
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
2
c4a4edff90f57692413fd77c390b6d607d322a51
251
py
Python
BasicPythonPrograms/PythonDestructor.py
Pushkar745/PythonProgramming
ea60e97b70d46fb63ef203913c8b3f9570232dd3
[ "Apache-2.0" ]
null
null
null
BasicPythonPrograms/PythonDestructor.py
Pushkar745/PythonProgramming
ea60e97b70d46fb63ef203913c8b3f9570232dd3
[ "Apache-2.0" ]
null
null
null
BasicPythonPrograms/PythonDestructor.py
Pushkar745/PythonProgramming
ea60e97b70d46fb63ef203913c8b3f9570232dd3
[ "Apache-2.0" ]
null
null
null
class Employee: #Initializaing def __init__(self): print('Employee created ') #Deleting (Calling destructor) def __del__(self): print('Destructor called,Employee deleted') obj=Employee() del obj
25.1
55
0.609562
24
251
6.041667
0.625
0.124138
0
0
0
0
0
0
0
0
0
0
0.298805
251
10
56
25.1
0.823864
0.167331
0
0
0
0
0.245192
0
0
0
0
0
0
1
0.285714
false
0
0
0
0.428571
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
1
0
0
0
0
0
0
0
2
c4ad485be7bdd5e1ac650e5ab444023836dc2e62
257
py
Python
protocols/tpkt.py
dparnishchev/s7scan
87a7aeeb3c932491745dfded2577d221083f87df
[ "Unlicense" ]
98
2018-10-12T10:36:55.000Z
2022-03-31T15:55:46.000Z
protocols/tpkt.py
FOGSEC/s7scan
d7f9c3bbd6a97a7f83991ea865be95b0e9280346
[ "Unlicense" ]
null
null
null
protocols/tpkt.py
FOGSEC/s7scan
d7f9c3bbd6a97a7f83991ea865be95b0e9280346
[ "Unlicense" ]
35
2018-10-12T17:08:25.000Z
2022-03-28T20:12:27.000Z
from scapy.fields import ByteField, ShortField from scapy.packet import Packet class TPKT(Packet): name = "TPKT" fields_desc = [ByteField("version", 3), ByteField("reserved", 0), ShortField("length", 0x0000)]
25.7
48
0.614786
27
257
5.814815
0.62963
0.11465
0
0
0
0
0
0
0
0
0
0.037433
0.272374
257
9
49
28.555556
0.802139
0
0
0
0
0
0.097276
0
0
0
0.023346
0
0
1
0
false
0
0.285714
0
0.714286
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
c4b06868e47596162a61d75f212de04777f1a9b9
160
py
Python
git_management/clone.py
afsantaliestra/scripts
06f9a1c269749570061a42c5c5b586944e8c9a45
[ "MIT" ]
null
null
null
git_management/clone.py
afsantaliestra/scripts
06f9a1c269749570061a42c5c5b586944e8c9a45
[ "MIT" ]
null
null
null
git_management/clone.py
afsantaliestra/scripts
06f9a1c269749570061a42c5c5b586944e8c9a45
[ "MIT" ]
null
null
null
import os filepath = 'list.txt' with open(filepath) as fp: while line := fp.readline(): line = line.strip() os.system(f'git clone {line}')
20
38
0.6
23
160
4.173913
0.73913
0
0
0
0
0
0
0
0
0
0
0
0.25
160
7
39
22.857143
0.8
0
0
0
0
0
0.15
0
0
0
0
0
0
1
0
false
0
0.166667
0
0.166667
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
c4d1976decbf19efd19f6e692e1b54b98d652ff7
2,422
py
Python
List_5/Task_1/instructions.py
Szpila123/Advanced_python_course
cd45506dec621768d59b2245aa0ae30b758160cc
[ "MIT" ]
null
null
null
List_5/Task_1/instructions.py
Szpila123/Advanced_python_course
cd45506dec621768d59b2245aa0ae30b758160cc
[ "MIT" ]
null
null
null
List_5/Task_1/instructions.py
Szpila123/Advanced_python_course
cd45506dec621768d59b2245aa0ae30b758160cc
[ "MIT" ]
null
null
null
import expressions import abc import copy class Instruction(abc.ABC): @abc.abstractmethod def __init__(): ... @abc.abstractmethod def wykonaj(self, zmienne) -> dict[str, int]: '''Evaluate the instruction''' ... @abc.abstractmethod def __str__(self): ... class If(Instruction): def __init__(self, cond: expressions.Wyrazenie, branch_true: Instruction, branch_false: Instruction): self._cond = cond self._branch_true = branch_true self._branch_false = branch_false def wykonaj(self, zmienne): if self._cond.oblicz(zmienne) == 0: lokalne_zmienne = self._branch_true.wykonaj(copy.copy(zmienne)) else: lokalne_zmienne = self._branch_false.wykonaj(copy.copy(zmienne)) for key in lokalne_zmienne: if key in zmienne: zmienne[key] = lokalne_zmienne[key] return zmienne def __str__(self): tab, nl = '\n\t\t', '\n' return f'if {str(self._cond)}\n\n\tthen\t{tab.join(str(self._branch_true).split(nl))}\n\n\telse\t{tab.join(str(self._branch_false).split(nl))}\n' class While(Instruction): def __init__(self, cond: expressions.Wyrazenie, branch: Instruction): self._cond = cond self._branch = branch def wykonaj(self, zmienne): while self._cond.oblicz(zmienne): lokalne_zmienne = self._branch.wykonaj(copy.copy(zmienne)) for key in lokalne_zmienne: if key in zmienne: zmienne[key] = lokalne_zmienne[key] return zmienne def __str__(self): tab, nl = '\n\t\t', '\n' return f'while {str(self._cond)}\n\n\tdo\t{tab.join(str(self._branch).split(nl))}\n' class Chain(Instruction): def __init__(self, instructions: list[Instruction]): self._chain = instructions def wykonaj(self, zmienne): for inst in self._chain: zmienne = inst.wykonaj(zmienne) return zmienne def __str__(self): return '\n'.join([str(inst) for inst in self._chain]) class Assign(Instruction): def __init__(self, var: expressions.Zmienna, val: expressions.Wyrazenie): self._var = var self._val = val def wykonaj(self, zmienne): zmienne[str(self._var)] = self._val.oblicz(zmienne) return zmienne def __str__(self): return f'{self._var} = {self._val}'
28.833333
153
0.623865
302
2,422
4.735099
0.165563
0.053846
0.048951
0.073427
0.43007
0.386713
0.296504
0.246154
0.173427
0.173427
0
0.000552
0.252271
2,422
83
154
29.180723
0.789067
0.009909
0
0.416667
0
0.033333
0.105351
0.083612
0
0
0
0
0
1
0.25
false
0
0.05
0.033333
0.516667
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
c4d2c7e50ad2259a426f3b12ba7e12df56ef68ae
298
py
Python
frames/rocket/rocket_frames.py
rkinwork/dvmn_async-console-game
c8072a47a9cac1772c099436c91649ebf544dc70
[ "Unlicense" ]
null
null
null
frames/rocket/rocket_frames.py
rkinwork/dvmn_async-console-game
c8072a47a9cac1772c099436c91649ebf544dc70
[ "Unlicense" ]
null
null
null
frames/rocket/rocket_frames.py
rkinwork/dvmn_async-console-game
c8072a47a9cac1772c099436c91649ebf544dc70
[ "Unlicense" ]
null
null
null
from pathlib import Path def get_rockets_frames(): """Init rocket animation frames.""" frames_files = ['rocket_frame_1.txt', 'rocket_frame_2.txt'] frames = [(Path(__file__).resolve().parent / frame_file_name).read_text() for frame_file_name in frames_files] return tuple(frames)
29.8
114
0.728188
42
298
4.761905
0.619048
0.11
0.13
0
0
0
0
0
0
0
0
0.007874
0.147651
298
9
115
33.111111
0.779528
0.097315
0
0
0
0
0.136882
0
0
0
0
0
0
1
0.2
false
0
0.2
0
0.6
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
2
c4e5c92095ff07343908dc4ad5fe4a10a7b5ac03
498
pyde
Python
sketches/noll/noll.pyde
kantel/processingpy
74aae222e46f68d1c8f06307aaede3cdae65c8ec
[ "MIT" ]
4
2018-06-03T02:11:46.000Z
2021-08-18T19:55:15.000Z
sketches/noll/noll.pyde
kantel/processingpy
74aae222e46f68d1c8f06307aaede3cdae65c8ec
[ "MIT" ]
null
null
null
sketches/noll/noll.pyde
kantel/processingpy
74aae222e46f68d1c8f06307aaede3cdae65c8ec
[ "MIT" ]
3
2019-12-23T19:12:51.000Z
2021-04-30T14:00:31.000Z
from random import randint margin = 5 def setup(): size(400, 600) this.surface.setTitle("Re-Enactment A. Michael Noll") noLoop() def draw(): background(235, 215, 182) strokeWeight(2) x1 = randint(margin, width - margin) y1 = randint(margin, height - margin) for _ in range(50): x2 = randint(margin, width - margin) y2 = randint(margin, height - margin) line(x1, y1, x1, y2) line(x1, y2, x2, y2) x1 = x2 y1 = y2
22.636364
57
0.574297
66
498
4.318182
0.575758
0.22807
0.126316
0.168421
0
0
0
0
0
0
0
0.100865
0.303213
498
21
58
23.714286
0.720461
0
0
0
0
0
0.056225
0
0
0
0
0
0
1
0.111111
false
0
0.055556
0
0.166667
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
c4f11548c4eb952f26c0dd99e9fd5c3f5a59fc56
376
py
Python
sqlitedb/settings.py
BelovN/orm
3dc9633a703369b99069a64fab3795c233a665cc
[ "Apache-2.0" ]
1
2021-02-10T13:49:36.000Z
2021-02-10T13:49:36.000Z
sqlitedb/settings.py
BelovN/orm
3dc9633a703369b99069a64fab3795c233a665cc
[ "Apache-2.0" ]
null
null
null
sqlitedb/settings.py
BelovN/orm
3dc9633a703369b99069a64fab3795c233a665cc
[ "Apache-2.0" ]
null
null
null
class BaseCommand: def __init__(self, table_name): self.table_name = table_name self._can_add = True @staticmethod def _convert_values(values): converted = [SQLType.convert(v) for v in values] return converted def check_intersection(self, other): return self.where.check_intersection(other) DB_NAME = 'database.db'
22.117647
56
0.672872
46
376
5.195652
0.543478
0.112971
0.108787
0
0
0
0
0
0
0
0
0
0.244681
376
16
57
23.5
0.841549
0
0
0
0
0
0.029333
0
0
0
0
0
0
1
0.272727
false
0
0
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
c4f425e58c4e41f24eec096d7a9387bcf27859e2
3,619
py
Python
2020/src/day11.py
pantaryl/adventofcode
d53255c55be0447f3cef7bd93818c41b0eeae997
[ "MIT" ]
2
2021-12-01T05:23:25.000Z
2021-12-11T05:58:00.000Z
2020/src/day11.py
pantaryl/adventofcode
d53255c55be0447f3cef7bd93818c41b0eeae997
[ "MIT" ]
null
null
null
2020/src/day11.py
pantaryl/adventofcode
d53255c55be0447f3cef7bd93818c41b0eeae997
[ "MIT" ]
null
null
null
from collections import defaultdict from helpers import memoize from copy import deepcopy with open("../input/day11.txt", 'r') as inputFile: data = [x.rstrip() for x in inputFile.readlines()] #data = [int(x) for x in data] map = {} yMax = len(data) xMax = len(data[0]) for y in range(yMax): line = data[y] for x in range(xMax): map[(x, y)] = line[x] def anyAdjacentOccupied(x, y, oldMap) -> bool: for xVals in [-1, 0, 1]: for yVals in [-1, 0, 1]: if xVals == 0 and yVals == 0: continue if (xVals+x, yVals+y) in oldMap and oldMap[(xVals+x, yVals+y)] == "#": return True return False def alsoOccupied(x, y, oldMap) -> bool: count = 0 for xVals in [-1, 0, 1]: for yVals in [-1, 0, 1]: if xVals == 0 and yVals == 0: continue if (xVals+x, yVals+y) in oldMap and oldMap[(xVals+x, yVals+y)] == "#": count += 1 return count >= 4 def printMap(map): for y in range(yMax): for x in range(xMax): print(map[(x, y)], end='') print() # Part 1 oldMap = deepcopy(map) for i in range(5000): changed = False newMap = deepcopy(oldMap) for x in range(xMax): for y in range(yMax): if oldMap[(x, y)] == "L" and anyAdjacentOccupied(x, y, oldMap) is False: newMap[(x, y)] = "#" changed = True elif oldMap[(x, y)] == "#" and alsoOccupied(x, y, oldMap): newMap[(x, y)] = "L" changed = True if changed is False: occupied = 0 for _, value in newMap.items(): occupied += 1 if value == "#" else 0 print(occupied) break else: oldMap = newMap #printMap(oldMap) #print() #print() # Part 2 def anyAdjacentOccupied2(x, y, oldMap) -> bool: slopes = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] for slope in slopes: currentXY = (x + slope[0], y + slope[1]) while currentXY in oldMap: if oldMap[currentXY] == "L": break elif oldMap[currentXY] == "#": return True currentXY = (currentXY[0] + slope[0], currentXY[1] + slope[1]) return False def alsoOccupied2(x, y, oldMap) -> bool: count = 0 slopes = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] for slope in slopes: currentXY = (x + slope[0], y + slope[1]) while currentXY in oldMap: if oldMap[currentXY] == "L": break elif oldMap[currentXY] == "#": count += 1 break currentXY = (currentXY[0] + slope[0], currentXY[1] + slope[1]) return count >= 5 oldMap = deepcopy(map) for i in range(500000): changed = False newMap = deepcopy(oldMap) for x in range(xMax): for y in range(yMax): if oldMap[(x, y)] == "L" and anyAdjacentOccupied2(x, y, oldMap) is False: newMap[(x, y)] = "#" changed = True elif oldMap[(x, y)] == "#" and alsoOccupied2(x, y, oldMap): newMap[(x, y)] = "L" changed = True if changed is False: occupied = 0 for _, value in newMap.items(): occupied += 1 if value == "#" else 0 print(occupied) break else: oldMap = newMap #printMap(oldMap) #print() #print() #input()
28.496063
85
0.481625
458
3,619
3.80131
0.157205
0.020678
0.020678
0.013785
0.712234
0.677771
0.657094
0.624928
0.624928
0.624928
0
0.039947
0.370544
3,619
127
86
28.496063
0.72432
0.030395
0
0.75
0
0
0.01
0
0
0
0
0
0
1
0.05
false
0
0.03
0
0.14
0.05
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
c4f7c343c369e93c89a12020beddb2954ee8b536
485
py
Python
api/pub/sensor/ds18b20.py
rtaft/pi-sensor-dashboard
e7f711e8ecd9e4c32976583c32dbc716b165d56a
[ "MIT" ]
null
null
null
api/pub/sensor/ds18b20.py
rtaft/pi-sensor-dashboard
e7f711e8ecd9e4c32976583c32dbc716b165d56a
[ "MIT" ]
null
null
null
api/pub/sensor/ds18b20.py
rtaft/pi-sensor-dashboard
e7f711e8ecd9e4c32976583c32dbc716b165d56a
[ "MIT" ]
null
null
null
import flask from flask import request import flask_restful as restful from marshmallow import Schema, fields, validate from api.helpers import success, created from api.exceptions import NotFound from sensors.ds18b20 import lookup class DS18B20Query (restful.Resource): def __init__(self, *args, **kwargs): self.sensor_service = kwargs['sensor_service'] def get(self): available = lookup(self.sensor_service.get_config()) return success(available)
26.944444
60
0.756701
61
485
5.868852
0.540984
0.108939
0.094972
0
0
0
0
0
0
0
0
0.019851
0.169072
485
17
61
28.529412
0.868486
0
0
0
0
0
0.028926
0
0
0
0
0
0
1
0.153846
false
0
0.538462
0
0.846154
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
c4fdb48e5cd50b1b15ab2ef20eb3414a3c36712f
1,402
py
Python
tfx/dsl/components/base/node_registry.py
johnPertoft/tfx
c6335684a54651adbcbe50aa52918b9b9948326e
[ "Apache-2.0" ]
null
null
null
tfx/dsl/components/base/node_registry.py
johnPertoft/tfx
c6335684a54651adbcbe50aa52918b9b9948326e
[ "Apache-2.0" ]
null
null
null
tfx/dsl/components/base/node_registry.py
johnPertoft/tfx
c6335684a54651adbcbe50aa52918b9b9948326e
[ "Apache-2.0" ]
null
null
null
# Copyright 2021 Google LLC. 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. """Node registry.""" import threading from typing import Any, FrozenSet # To resolve circular dependency caused by type annotations. base_node = Any # base_node.py imports this module. class _NodeRegistry(threading.local): """Stores registered nodes in the local thread.""" def __init__(self): super().__init__() self._nodes = set() def register(self, node: 'base_node.BaseNode'): self._nodes.add(node) def registered_nodes(self): return self._nodes _node_registry = _NodeRegistry() def register_node(node: 'base_node.BaseNode'): """Register a node in the local thread.""" _node_registry.register(node) def registered_nodes() -> FrozenSet['base_node.BaseNode']: """Get registered nodes in the local thread.""" return frozenset(_node_registry.registered_nodes())
30.478261
74
0.745364
197
1,402
5.162437
0.507614
0.058997
0.029499
0.047198
0.060964
0.060964
0
0
0
0
0
0.006785
0.159058
1,402
45
75
31.155556
0.85581
0.57204
0
0
0
0
0.095575
0
0
0
0
0
0
1
0.3125
false
0
0.125
0.0625
0.625
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
2
f2082b7572a268703ff36753a9f8e86b4e7ec828
814
py
Python
step/lambdas/get_image_status.py
mbeacom/cloudendure-python
b854b1b2ea47c18a8ef03908abcdd653b77684ac
[ "MIT" ]
7
2019-06-28T23:30:47.000Z
2019-08-23T16:57:12.000Z
step/lambdas/get_image_status.py
mbeacom/cloudendure-python
b854b1b2ea47c18a8ef03908abcdd653b77684ac
[ "MIT" ]
27
2019-06-14T20:39:10.000Z
2019-08-30T17:20:40.000Z
step/lambdas/get_image_status.py
mbeacom/cloudendure-python
b854b1b2ea47c18a8ef03908abcdd653b77684ac
[ "MIT" ]
2
2019-08-23T16:50:20.000Z
2019-08-30T18:22:23.000Z
#!/usr/bin/env python # -*- coding: utf-8 -*- """Check the state of an AWS AMI.""" from __future__ import annotations import json from typing import Any, Dict import boto3 print("Loading function get_image_status") ec2_client = boto3.client("ec2") # { # "instance_id": "i-identifier", # "kms_id": "KMS ID", # "account": "account_number", # "instance_status": "should be there if in loop" # "migrated_ami_id": "ami-identifier" # } def lambda_handler(event: Dict[str, Any], context: Any) -> str: """Handle signaling and entry into the AWS Lambda.""" print("Received event: " + json.dumps(event, indent=2)) migrated_ami_id: str = event["migrated_ami_id"] ami_state: Dict[str, Any] = ec2_client.describe_images(ImageIds=[migrated_ami_id]) return ami_state["Images"][0]["State"]
24.666667
86
0.683047
115
814
4.626087
0.565217
0.082707
0.097744
0.06015
0
0
0
0
0
0
0
0.011713
0.160934
814
32
87
25.4375
0.767204
0.367322
0
0
0
0
0.157258
0
0
0
0
0
0
1
0.090909
false
0
0.363636
0
0.545455
0.181818
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
f2095b25bea143e9b82c7fbfb9522beac7c96f69
344
py
Python
starfish/types.py
kne42/starfish
78b348c9756f367221dcca725cfa5107e5520b33
[ "MIT" ]
null
null
null
starfish/types.py
kne42/starfish
78b348c9756f367221dcca725cfa5107e5520b33
[ "MIT" ]
null
null
null
starfish/types.py
kne42/starfish
78b348c9756f367221dcca725cfa5107e5520b33
[ "MIT" ]
null
null
null
# constants from starfish.core.types import ( # noqa: F401 Axes, Clip, Coordinates, CORE_DEPENDENCIES, Features, LOG, OverlapStrategy, PHYSICAL_COORDINATE_DIMENSION, PhysicalCoordinateTypes, STARFISH_EXTRAS_KEY, TransformType, ) from starfish.core.types import CoordinateValue, Number # noqa: F401
21.5
69
0.715116
33
344
7.30303
0.727273
0.099585
0.13278
0.174274
0.224066
0
0
0
0
0
0
0.022305
0.218023
344
15
70
22.933333
0.873606
0.090116
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.142857
0
0.142857
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
2
f20f24fc882a6bfe17d609d7a92bcf0cfdf1dd3a
464
py
Python
learn-to-code-with-python/10-Lists-Iteration/iterate-in-reverse-with-the-reversed-function.py
MaciejZurek/python_practicing
0a426f2aed151573e1f8678e0239ff596d92bbde
[ "MIT" ]
null
null
null
learn-to-code-with-python/10-Lists-Iteration/iterate-in-reverse-with-the-reversed-function.py
MaciejZurek/python_practicing
0a426f2aed151573e1f8678e0239ff596d92bbde
[ "MIT" ]
null
null
null
learn-to-code-with-python/10-Lists-Iteration/iterate-in-reverse-with-the-reversed-function.py
MaciejZurek/python_practicing
0a426f2aed151573e1f8678e0239ff596d92bbde
[ "MIT" ]
null
null
null
the_simpsons = ["Homer", "Marge", "Bart", "Lisa", "Maggie"] print(the_simpsons[::-1]) for char in the_simpsons[::-1]: print(f"{char} has a total of {len(char)} characters.") print(reversed(the_simpsons)) print(type(reversed(the_simpsons))) # generator object for char in reversed(the_simpsons): # laduje za kazda iteracja jeden element listy, a nie cala liste od razu, dobre przy duzych listach print(f"{char} has a total of {len(char)} characters.")
33.142857
135
0.709052
71
464
4.549296
0.549296
0.204334
0.176471
0.080495
0.235294
0.235294
0.235294
0.235294
0.235294
0.235294
0
0.005025
0.142241
464
13
136
35.692308
0.806533
0.24569
0
0.25
0
0
0.32948
0
0
0
0
0
0
1
0
false
0
0
0
0
0.625
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
f22667e27e25306a81ed4197a3f3283e37b3daea
846
py
Python
NLP4CCB/migrations/0005_auto_20170415_2236.py
rossmechanic/know_your_nyms
805ca845121fa93a38088f09cd0a430ddb9f95cf
[ "BSD-3-Clause" ]
1
2020-02-12T13:24:15.000Z
2020-02-12T13:24:15.000Z
NLP4CCB/migrations/0005_auto_20170415_2236.py
rossmechanic/know_your_nyms
805ca845121fa93a38088f09cd0a430ddb9f95cf
[ "BSD-3-Clause" ]
null
null
null
NLP4CCB/migrations/0005_auto_20170415_2236.py
rossmechanic/know_your_nyms
805ca845121fa93a38088f09cd0a430ddb9f95cf
[ "BSD-3-Clause" ]
1
2017-10-25T11:24:51.000Z
2017-10-25T11:24:51.000Z
# -*- coding: utf-8 -*- # Generated by Django 1.10.3 on 2017-04-15 22:36 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [("NLP4CCB", "0004_auto_20170330_0255")] operations = [ migrations.RenameField( model_name="userstat", old_name="index", new_name="meronyms_index" ), migrations.AddField( model_name="userstat", name="antonyms_index", field=models.IntegerField(default=0), ), migrations.AddField( model_name="userstat", name="hyponyms_index", field=models.IntegerField(default=0), ), migrations.AddField( model_name="userstat", name="synonyms_index", field=models.IntegerField(default=0), ), ]
26.4375
78
0.582742
83
846
5.783133
0.542169
0.075
0.141667
0.16875
0.46875
0.46875
0.3125
0.3125
0.3125
0.3125
0
0.062081
0.295508
846
31
79
27.290323
0.743289
0.080378
0
0.565217
1
0
0.15871
0.029677
0
0
0
0
0
1
0
false
0
0.043478
0
0.173913
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
1ef590187d92be6eb1062c6742984e4a21a536f0
212
py
Python
trainer/__init__.py
Greeser/gate-decorator-pruning
1069fc89099100091412b6f89ead0519d382c518
[ "Apache-2.0" ]
192
2019-09-18T10:02:16.000Z
2022-03-24T16:31:18.000Z
trainer/__init__.py
pawopawo/gate-decorator-pruning
d89021802fa56b1eba97921db3d8cadcacdd2073
[ "Apache-2.0" ]
25
2019-09-24T10:53:51.000Z
2022-01-18T07:13:52.000Z
trainer/__init__.py
pawopawo/gate-decorator-pruning
d89021802fa56b1eba97921db3d8cadcacdd2073
[ "Apache-2.0" ]
33
2019-09-19T02:21:58.000Z
2022-03-31T10:04:20.000Z
from trainer.normal import NormalTrainer from config import cfg def get_trainer(): pair = { 'normal': NormalTrainer } assert (cfg.train.trainer in pair) return pair[cfg.train.trainer]()
19.272727
40
0.679245
26
212
5.5
0.538462
0.111888
0.20979
0
0
0
0
0
0
0
0
0
0.226415
212
10
41
21.2
0.871951
0
0
0
0
0
0.028302
0
0
0
0
0
0.125
1
0.125
false
0
0.25
0
0.5
0
1
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
1efb1e54ed275e79479018453c75c13bf653026c
330
py
Python
docs/api/conf.py
kagemeka/selext
1882e518f8698f6d257549cdb36c79e05e801d39
[ "MIT" ]
1
2022-02-15T12:02:02.000Z
2022-02-15T12:02:02.000Z
docs/api/conf.py
kagemeka/filesystem-python
565beb128326f5ee41a5bb2b3a751788d4a02e4c
[ "MIT" ]
6
2022-01-05T09:15:54.000Z
2022-01-09T05:48:43.000Z
docs/api/conf.py
kagemeka/python-algorithms
dface89b8c618845cf524429aa8e97c4b2b10ceb
[ "MIT" ]
null
null
null
import os import sys def find_docs_root() -> str: filepath = os.path.abspath(__file__) path_chunks = filepath.split(os.path.sep) while path_chunks[-1] != "docs": path_chunks.pop() return os.path.sep.join(path_chunks) sys.path.append(find_docs_root()) from _rtd_conf import * from _sphinx_conf import *
20.625
45
0.70303
50
330
4.32
0.5
0.185185
0.111111
0
0
0
0
0
0
0
0
0.003676
0.175758
330
15
46
22
0.790441
0
0
0
0
0
0.012121
0
0
0
0
0
0
1
0.090909
false
0
0.363636
0
0.545455
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
2
48126352dee9a8d203347caa05ca59556d920c18
268
py
Python
test.py
ewuerfel66/lambdata-mjh09
7f87f923ec351e7af139d098d84a320861632616
[ "MIT" ]
null
null
null
test.py
ewuerfel66/lambdata-mjh09
7f87f923ec351e7af139d098d84a320861632616
[ "MIT" ]
4
2020-03-24T17:42:54.000Z
2021-06-02T00:22:30.000Z
test.py
ewuerfel66/lambdata-mjh09
7f87f923ec351e7af139d098d84a320861632616
[ "MIT" ]
1
2019-08-14T15:17:22.000Z
2019-08-14T15:17:22.000Z
import unittest class TestSum(unittest.TestCase): def test_sum(self): self.assertEqual(sum([1,2,3]), 6, 'Should be 6') def test_sum_tuple(self): self.assertEqual(sum((1,2,2)), 6, 'Should be 6') if __name__ == '__main__': unittest.main()
22.333333
56
0.634328
40
268
3.975
0.5
0.08805
0.125786
0.27673
0.301887
0.301887
0
0
0
0
0
0.046729
0.201493
268
12
57
22.333333
0.696262
0
0
0
0
0
0.111524
0
0
0
0
0
0.25
1
0.25
false
0
0.125
0
0.5
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
2
481e2d50c4328a17ebca8a6fc8ec42de2e15ed63
3,986
py
Python
activatable_model/models.py
wesleykendall/django-activatable-model
e039db72e6a94f622293cabbbac47f88b1c1c4dc
[ "MIT" ]
null
null
null
activatable_model/models.py
wesleykendall/django-activatable-model
e039db72e6a94f622293cabbbac47f88b1c1c4dc
[ "MIT" ]
null
null
null
activatable_model/models.py
wesleykendall/django-activatable-model
e039db72e6a94f622293cabbbac47f88b1c1c4dc
[ "MIT" ]
null
null
null
from django.db import models from manager_utils import ManagerUtilsQuerySet, ManagerUtilsManager from activatable_model.signals import model_activations_changed class ActivatableQuerySet(ManagerUtilsQuerySet): """ Provides bulk activation/deactivation methods. """ def update(self, *args, **kwargs): if self.model.ACTIVATABLE_FIELD_NAME in kwargs: # Fetch the instances that are about to be updated if they have an activatable flag. This # is because their activatable flag may be changed in the subsequent update, causing us # to potentially lose what this original query referenced updated_instance_ids = list(self.values_list('id', flat=True)) ret_val = super(ActivatableQuerySet, self).update(*args, **kwargs) if self.model.ACTIVATABLE_FIELD_NAME in kwargs and updated_instance_ids: # Refetch the instances that were updated and send them to the activation signal model_activations_changed.send( self.model, instance_ids=updated_instance_ids, is_active=kwargs[self.model.ACTIVATABLE_FIELD_NAME]) return ret_val def activate(self): return self.update(**{ self.model.ACTIVATABLE_FIELD_NAME: True }) def deactivate(self): return self.update(**{ self.model.ACTIVATABLE_FIELD_NAME: False }) def delete(self, force=False): return super(ActivatableQuerySet, self).delete() if force else self.deactivate() class ActivatableManager(ManagerUtilsManager): def get_queryset(self): return ActivatableQuerySet(self.model) def activate(self): return self.get_queryset().activate() def deactivate(self): return self.get_queryset().deactivate() class BaseActivatableModel(models.Model): """ Adds an is_active flag and processes information about when an is_active flag is changed. """ class Meta: abstract = True # The name of the Boolean field that determines if this model is active or inactive. A field # must be defined with this name, and it must be a BooleanField. Note that the reason we don't # define a BooleanField is because this would eliminate the ability for the user to easily # define default values for the field and if it is indexed. ACTIVATABLE_FIELD_NAME = 'is_active' objects = ActivatableManager() # The original activatable field value, for determining when it changes __original_activatable_value = None def __init__(self, *args, **kwargs): super(BaseActivatableModel, self).__init__(*args, **kwargs) # Keep track of the original activatable value to know when it changes self.__original_activatable_value = getattr(self, self.ACTIVATABLE_FIELD_NAME) def save(self, *args, **kwargs): """ A custom save method that handles figuring out when something is activated or deactivated. """ current_activable_value = getattr(self, self.ACTIVATABLE_FIELD_NAME) is_active_changed = self.id is None or self.__original_activatable_value != current_activable_value self.__original_activatable_value = current_activable_value ret_val = super(BaseActivatableModel, self).save(*args, **kwargs) # Emit the signal for when the is_active flag is changed if is_active_changed: model_activations_changed.send(self.__class__, instance_ids=[self.id], is_active=current_activable_value) return ret_val def delete(self, force=False, **kwargs): """ It is impossible to delete an activatable model unless force is True. This function instead sets it to inactive. """ if force: return super(BaseActivatableModel, self).delete(**kwargs) else: setattr(self, self.ACTIVATABLE_FIELD_NAME, False) return self.save(update_fields=[self.ACTIVATABLE_FIELD_NAME])
39.078431
120
0.699448
490
3,986
5.504082
0.295918
0.065258
0.074156
0.046348
0.265109
0.138673
0.138673
0.072673
0.072673
0.036337
0
0
0.230557
3,986
101
121
39.465347
0.879361
0.294782
0
0.188679
0
0
0.004038
0
0
0
0
0
0
1
0.188679
false
0
0.056604
0.113208
0.566038
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
48253cfafc062954525ca06fd5152e38d4e70a79
295
py
Python
Modulos/Modulo2/app3.py
Trallyan/Curso_Udemy
2a5c0becd14352f2cc2bf2362d1e5494edd6198d
[ "MIT" ]
null
null
null
Modulos/Modulo2/app3.py
Trallyan/Curso_Udemy
2a5c0becd14352f2cc2bf2362d1e5494edd6198d
[ "MIT" ]
null
null
null
Modulos/Modulo2/app3.py
Trallyan/Curso_Udemy
2a5c0becd14352f2cc2bf2362d1e5494edd6198d
[ "MIT" ]
null
null
null
idade = 18 carteiramotorista = True print (idade >= 18 and carteiramotorista == True) print ("Pode Dirigir") velocidade = 90 radar = 100 radarfuncionando = False print (velocidade > radar and radarfuncionando == True) print ("Não foi multado") velocidade1 = 101 print (velocidade1 >= radar)
18.4375
55
0.735593
34
295
6.382353
0.558824
0.124424
0.239631
0
0
0
0
0
0
0
0
0.056911
0.166102
295
16
56
18.4375
0.825203
0
0
0
0
0
0.091216
0
0
0
0
0
0
1
0
false
0
0
0
0
0.454545
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
2
482eeb2176d1d54a0f7e399cf1d1c1710f4d9f12
454
py
Python
mintools/zmqmin/client.py
jtimon/elements-explorer
397089593e860c4bdceb3a1222687a9120db0022
[ "MIT" ]
9
2018-01-25T16:32:18.000Z
2018-10-10T18:47:33.000Z
mintools/zmqmin/client.py
jtimon/elements-explorer
397089593e860c4bdceb3a1222687a9120db0022
[ "MIT" ]
2
2018-03-13T20:50:33.000Z
2018-03-13T21:01:22.000Z
mintools/zmqmin/client.py
jtimon/elements-explorer
397089593e860c4bdceb3a1222687a9120db0022
[ "MIT" ]
2
2018-02-20T17:50:18.000Z
2018-02-26T07:29:15.000Z
# Copyright (c) 2012-2018 The Mintools developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. import pyzmq from .messenger import Messenger class Client(Messenger): def _init_socket(self): self.socket = self.context.socket(pyzmq.REQ) def send_request(self, request): self.send_message(request) return self.receive_message()
26.705882
69
0.737885
60
454
5.5
0.666667
0.060606
0
0
0
0
0
0
0
0
0
0.021277
0.171806
454
16
70
28.375
0.856383
0.396476
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.25
0
0.75
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
2
484bd025db2a6036894e42cd251bae437f17440a
329
py
Python
python/__init__.py
seangal/xAODAnaHelpers
49f15c8525bf4aed9beceec2c58e58964d57e034
[ "Apache-2.0" ]
null
null
null
python/__init__.py
seangal/xAODAnaHelpers
49f15c8525bf4aed9beceec2c58e58964d57e034
[ "Apache-2.0" ]
null
null
null
python/__init__.py
seangal/xAODAnaHelpers
49f15c8525bf4aed9beceec2c58e58964d57e034
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env python # -*- coding: utf-8 -*-, from __future__ import absolute_import from __future__ import print_function from . import logging as xAH_logging try: from .config import Config except: xAH_logging.logger.warning("xAH::Config could not be imported.") __version__ = "1.0.0" __all__ = ["utils", "config"]
21.933333
68
0.723404
46
329
4.73913
0.652174
0.091743
0.146789
0
0
0
0
0
0
0
0
0.014337
0.151976
329
14
69
23.5
0.767025
0.130699
0
0
0
0
0.176056
0
0
0
0
0
0
1
0
false
0
0.555556
0
0.555556
0.111111
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
2
48544b3690b1859057fd2e593fbf385719c5db3e
14,076
py
Python
mainwin.py
hatmann1944/pyqt-http-file-svr
3e95a222dc7d662921da44654aadb1721cba0382
[ "Apache-2.0" ]
1
2015-08-27T13:22:42.000Z
2015-08-27T13:22:42.000Z
mainwin.py
hatmann1944/pyqt-http-file-svr
3e95a222dc7d662921da44654aadb1721cba0382
[ "Apache-2.0" ]
null
null
null
mainwin.py
hatmann1944/pyqt-http-file-svr
3e95a222dc7d662921da44654aadb1721cba0382
[ "Apache-2.0" ]
null
null
null
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/mnt/hgfs/tmpcode/pyqt-http/untitled.ui' # # Created: Fri Jun 5 10:59:33 2015 # by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui import socket import signal import errno import sys import os import platform import time #from sendfile import sendfile class Worker(QtCore.QThread): trigger = QtCore.pyqtSignal(int, int, str) def __init__(self,parent=None): super(Worker,self).__init__(parent) def __del__(self): self.wait() def set(self, strHost, port, httpheader, fullFileName, totalLen): self.ip = strHost self.p = port self.hdr = httpheader self.fn = fullFileName self.fileLen = totalLen def run(self): #signal.signal(signal.SIGUSR1,sigHander) global lisfd lisfd = socket.socket(socket.AF_INET,socket.SOCK_STREAM) lisfd.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) lisfd.bind((self.ip, self.p)) lisfd.listen(10) self.runflag = True lisfd.setblocking(0) while self.runflag: if self.runflag == False: break try: confd,addr = lisfd.accept() except socket.error, msg: if msg.errno == errno.EINTR or msg.errno == errno.EAGAIN or msg.errno == errno.EWOULDBLOCK: print msg else: raise time.sleep(1) continue print "connect by ",addr ip = addr[0] port = addr[1] addrStr = "%s:%d"%(ip, port) confd.settimeout(10) try: #print "recving" #data = confd.recv(1024, socket.MSG_DONTWAIT) data = confd.recv(1024) except socket.error, msg: #print msg confd.close() continue #print "recv end" if not data: break print(data) confd.send(self.hdr) print addrStr self.trigger.emit(0, self.fileLen, addrStr) file = open(self.fn, "rb") #offset = 0 #totalSent = long(0); while True: if self.runflag == False: return chunk = file.read(65536) if not chunk: break # EOF try: confd.sendall(chunk) except socket.error, msg: print msg lisfd.close() return #totalSent += 65536 self.trigger.emit(65536, self.fileLen, addrStr) #confd.send('\n\n') confd.close() self.trigger.emit(self.fileLen, self.fileLen, addrStr) print "send fin" else: lisfd.close() print "stop" def GetFileSize(filename): len = os.path.getsize(filename) return len def HttpResponse(header,filename): f = open(filename, "rb") contxtlist = f.readlines() size=os.path.getsize(filename) context = ''.join(contxtlist) response = "%s %d\n\n%s\n\n" % (header,size,context) return response def TestPlatform(): print ("----------Operation System--------------------------") #Windows will be : (32bit, WindowsPE) #Linux will be : (32bit, ELF) print(platform.architecture()) #Windows will be : Windows-XP-5.1.2600-SP3 or Windows-post2008Server-6.1.7600 #Linux will be : Linux-2.6.18-128.el5-i686-with-redhat-5.3-Final print(platform.platform()) #Windows will be : Windows #Linux will be : Linux print(platform.system()) print ("--------------Python Version-------------------------") #Windows and Linux will be : 3.1.1 or 3.1.3 print(platform.python_version()) def WhichPlatform(): sysstr = platform.system() if(sysstr =="Windows"): print ("Call Windows tasks") return "windows" elif(sysstr == "Linux"): print ("Call Linux tasks") return "linux" else: print ("Other System tasks") return "others" try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) from PyQt4 import QtGui, QtCore from PIL import ImageQt import qrcode class Image(qrcode.image.base.BaseImage): def __init__(self, border, width, box_size): self.border = border self.width = width self.box_size = box_size size = (width + border * 2) * box_size self._image = QtGui.QImage( size, size, QtGui.QImage.Format_RGB16) self._image.fill(QtCore.Qt.white) def pixmap(self): return QtGui.QPixmap.fromImage(self._image) def drawrect(self, row, col): painter = QtGui.QPainter(self._image) painter.fillRect( (col + self.border) * self.box_size, (row + self.border) * self.box_size, self.box_size, self.box_size, QtCore.Qt.black) def save(self, stream, kind=None): pass class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.pushButton = QtGui.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(650, 220, 100, 50)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.linkLabel = QtGui.QLabel(self.centralwidget) self.linkLabel.setGeometry(QtCore.QRect(450, 0, 300, 160)) self.linkLabel.setObjectName(_fromUtf8("label")) self.label = QtGui.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(455, 160, 200, 60)) self.label.setObjectName(_fromUtf8("label")) self.label.setWordWrap(True) self.addr = QtGui.QLabel(self.centralwidget) self.addr.setGeometry(QtCore.QRect(450, 105, 150, 30)) self.addr.setObjectName(_fromUtf8("addr")) self.addr.setWordWrap(True) self.addr.setText("remoteaddr"); self.ratio = QtGui.QLabel(self.centralwidget) self.ratio.setGeometry(QtCore.QRect(610, 105, 250, 30)) self.ratio.setObjectName(_fromUtf8("ratio")) self.ratio.setWordWrap(True) self.ratio.setText("ratio"); self.textEdit = QtGui.QTextEdit(self.centralwidget) self.textEdit.setGeometry(QtCore.QRect(680, 180, 50, 30)) self.textEdit.setObjectName(_fromUtf8("textEdit")) self.pushButton_2 = QtGui.QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(450, 220, 100, 50)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pb = QtGui.QProgressBar(self.centralwidget) self.pb.setGeometry(QtCore.QRect(450, 130, 300, 20)) self.pb.setObjectName(_fromUtf8("pb")) self.pb.setRange(0, 0) self.pb.setRange(0, 100) self.pb.setValue(0) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 23)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.qrLabel = QtGui.QLabel(self.centralwidget) self.qrLabel.setGeometry(QtCore.QRect(20, 2, 300, 300)) self.qrLabel.setObjectName(_fromUtf8("label")) #self.refreshQRCode() self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def refreshQRCode(self, port): global localIP text = unicode("http://%s:%d"%(localIP, port)) self.linkLabel.setText("Please visit: %s"%text); print text self.qrLabel.setPixmap( qrcode.make(text, image_factory=Image).pixmap()) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.pushButton.setText(_translate("MainWindow", "run", None)) self.label.setText(_translate("MainWindow", "choose a file", None)) self.textEdit.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">1234</p></body></html>", None)) self.pushButton_2.setText(_translate("MainWindow", "choose file", None)) class Window( QtGui.QMainWindow ): def __init__( self ): super( Window, self ).__init__() self.setWindowTitle( "hello" ) self.resize( 200, 300 ) self.uiWin = Ui_MainWindow() self.uiWin.setupUi(self) self.fullFileName = "" self.fileName = "" self.thread=Worker() self.connect(self.uiWin.pushButton, QtCore.SIGNAL('clicked()'), self.runHttpSvr) self.connect(self.uiWin.pushButton_2, QtCore.SIGNAL('clicked()'), self.chooseFile) self.running = False self.thread.trigger.connect(self.updatePb) def updatePb(self, sent2, total2, addr): if sent2 == 0: self.sentLen = 0 #print sent #print total2 self.sentLen += sent2 total = self.fileLen #print total val = self.sentLen/float(total)*100 if val <= 100: self.uiWin.pb.setValue(val) self.uiWin.addr.setText(addr) self.uiWin.ratio.setText("%d/%d"%(self.sentLen, total)) else: self.uiWin.pb.setValue(100) self.uiWin.addr.setText(addr) self.uiWin.ratio.setText("%d/%d"%(total, total)) def runHttpSvr(self): if self.running : #global lisfd #lisfd.close() self.thread.runflag = False self.running = False #self.uiWin.label.setText("svr is not running") self.uiWin.pushButton.setText("run") #os.kill(1234, signal.SIGUSR1) return if len(self.fullFileName) == 0 or len(self.fileName) == 0: msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, "error", "not choose file", QtGui.QMessageBox.NoButton, self) msgBox.show() return if self.fileName and os.path.exists(self.fullFileName): print 'OK, the "%s" file exists.'%self.fullFileName else: msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, "error", "Sorry, I cannot find the '%s' file."%self.fullFileName, QtGui.QMessageBox.NoButton, self) msgBox.show() return port = int(self.uiWin.textEdit.toPlainText()) if port < 1 or port > 65535: msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, "error", "port[%s] error"%self.uiWin.textEdit.toPlainText(), QtGui.QMessageBox.NoButton, self) msgBox.show() return strHost = "0.0.0.0" self.fileLen = GetFileSize(self.fullFileName) httpheader = '''\ HTTP/1.1 200 OK Context-Type: bin;charset=UTF-8 Server: Python-slp version 1.0 ''' httpheader += "Content-Disposition: attachment;filename=%s\n" % self.fileName httpheader += 'Context-Length: %d\n\n'% self.fileLen print httpheader self.sentLen = 0 self.thread.set(strHost, port, httpheader, self.fullFileName, self.fileLen) self.thread.start() self.running = True self.uiWin.refreshQRCode(port) #self.uiWin.label.setText("svr is running") self.uiWin.pushButton.setText("stop") def chooseFile(self): #self.uiWin.label.setText("choosefile") name = QtGui.QFileDialog.getOpenFileName(self) if name: self.fullFileName = unicode(name , "utf8") saperator = '/' self.fileName = self.fullFileName.split(saperator)[-1] #print self.fullFileName #print self.fileName self.uiWin.label.setText(self.fullFileName) import socket if WhichPlatform() == "linux": import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) if __name__ == '__main__': global localIP #localIP = socket.gethostbyname(socket.gethostname()) if WhichPlatform() != "windows": localIP = get_ip_address("eth0") print "local ip:%s "%localIP app = QtGui.QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
32.210526
157
0.586957
1,549
14,076
5.274371
0.264687
0.02093
0.025704
0.017136
0.155936
0.103182
0.074419
0.031579
0.031579
0.031579
0
0.032123
0.287866
14,076
436
158
32.284404
0.782921
0.078005
0
0.184466
1
0
0.076447
0.00858
0
0
0.000464
0
0
0
null
null
0.003236
0.045307
null
null
0.064725
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
1
0
0
0
0
0
0
0
0
2
486e93474bb833e6c69bd39f0e367b929c5bddaf
2,442
py
Python
acestream/ACEStream/Core/RequestPolicy.py
GrandPaRPi/p2ptv-pi
6f79c00f9055a3763ddfe1dc41e14d2cb533f4c3
[ "MIT" ]
null
null
null
acestream/ACEStream/Core/RequestPolicy.py
GrandPaRPi/p2ptv-pi
6f79c00f9055a3763ddfe1dc41e14d2cb533f4c3
[ "MIT" ]
null
null
null
acestream/ACEStream/Core/RequestPolicy.py
GrandPaRPi/p2ptv-pi
6f79c00f9055a3763ddfe1dc41e14d2cb533f4c3
[ "MIT" ]
2
2018-04-17T17:34:39.000Z
2020-07-26T03:43:33.000Z
#Embedded file name: ACEStream\Core\RequestPolicy.pyo from ACEStream.Core.simpledefs import * from ACEStream.Core.exceptions import * from ACEStream.Core.BitTornado.BT1.MessageID import * DEBUG = False MAX_QUERIES_FROM_RANDOM_PEER = 1000 class AbstractRequestPolicy: def __init__(self): pass def allowed(self, permid, messageID): raise NotYetImplementedException() class AllowAllRequestPolicy(AbstractRequestPolicy): def allowed(self, permid, messageID): return self.allowAllRequestsAllPeers(permid, messageID) def allowAllRequestsAllPeers(self, permid, messageID): return True class CommonRequestPolicy(AbstractRequestPolicy): def __init__(self, session): self.session = session self.friendsdb = session.open_dbhandler(NTFY_FRIENDS) self.peerdb = session.open_dbhandler(NTFY_PEERS) AbstractRequestPolicy.__init__(self) def isFriend(self, permid): fs = self.friendsdb.getFriendState(permid) return fs == FS_MUTUAL or fs == FS_I_INVITED def isSuperPeer(self, permid): return permid in self.session.lm.superpeer_db.getSuperPeers() def isCrawler(self, permid): return permid in self.session.lm.crawler_db.getCrawlers() def benign_random_peer(self, permid): if MAX_QUERIES_FROM_RANDOM_PEER > 0: nqueries = self.get_peer_nqueries(permid) return nqueries < MAX_QUERIES_FROM_RANDOM_PEER else: return True def get_peer_nqueries(self, permid): peer = self.peerdb.getPeer(permid) if peer is None: return 0 else: return peer['num_queries'] class AllowFriendsRequestPolicy(CommonRequestPolicy): def allowed(self, permid, messageID): if messageID in (CRAWLER_REQUEST, CRAWLER_REPLY): return self.isCrawler(permid) else: return self.allowAllRequestsFromFriends(permid, messageID) def allowAllRequestsFromFriends(self, permid, messageID): return self.isFriend(permid) class FriendsCoopDLOtherRQueryQuotumCrawlerAllowAllRequestPolicy(CommonRequestPolicy): def allowed(self, permid, messageID): if messageID == CRAWLER_REQUEST: return self.isCrawler(permid) elif messageID == QUERY and not (self.isFriend(permid) or self.benign_random_peer(permid)): return False else: return True
30.525
99
0.700246
256
2,442
6.503906
0.308594
0.066066
0.068468
0.048048
0.216817
0.115315
0.115315
0.115315
0
0
0
0.0037
0.225225
2,442
79
100
30.911392
0.876321
0.021294
0
0.232143
0
0
0.004604
0
0
0
0
0
0
1
0.232143
false
0.017857
0.053571
0.089286
0.642857
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
2
487b34c0ca841971125a8b74fe964b7cec0a6a76
13,227
py
Python
py_proto/modules/drivers/camera/proto/camera_conf_pb2.py
yujianyi/fusion_localization
c0057e29cbf690d6260f021080fd951c1a6b6baa
[ "Apache-2.0" ]
2
2019-03-04T02:11:04.000Z
2019-04-18T11:19:45.000Z
py_proto/modules/drivers/camera/proto/camera_conf_pb2.py
yujianyi/fusion_localization
c0057e29cbf690d6260f021080fd951c1a6b6baa
[ "Apache-2.0" ]
1
2019-03-15T08:37:53.000Z
2019-03-15T08:37:53.000Z
py_proto/modules/drivers/camera/proto/camera_conf_pb2.py
yujianyi/fusion_localization
c0057e29cbf690d6260f021080fd951c1a6b6baa
[ "Apache-2.0" ]
1
2019-03-04T02:11:09.000Z
2019-03-04T02:11:09.000Z
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: modules/drivers/camera/proto/camera_conf.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() DESCRIPTOR = _descriptor.FileDescriptor( name='modules/drivers/camera/proto/camera_conf.proto', package='apollo.drivers.camera', syntax='proto2', serialized_pb=_b('\n.modules/drivers/camera/proto/camera_conf.proto\x12\x15\x61pollo.drivers.camera\"\xe3\x05\n\nCameraConf\x12\x10\n\x05index\x18\x01 \x02(\r:\x01\x30\x12\x18\n\x08position\x18\x02 \x01(\t:\x06\x63\x65ntre\x12\x14\n\ntopic_name\x18\x03 \x01(\t:\x00\x12!\n\x0cvideo_device\x18\x04 \x01(\t:\x0b/dev/video0\x12 \n\x0b\x63\x61mera_name\x18\x05 \x01(\t:\x0bhead_camera\x12\x19\n\x0f\x63\x61mera_info_url\x18\x06 \x01(\t:\x00\x12\x19\n\x0f\x63\x61mera_frame_id\x18\x07 \x01(\t:\x00\x12\x1c\n\x0e\x63\x61mera_timeout\x18\x08 \x01(\r:\x04\x31\x30\x30\x30\x12\x1c\n\rspin_interval\x18\t \x01(\x01:\x05\x30.005\x12\x17\n\tio_method\x18\n \x01(\t:\x04mmap\x12\x1b\n\x0cpixel_format\x18\x0b \x01(\t:\x05mjpeg\x12\x18\n\x0bimage_width\x18\x0c \x01(\r:\x03\x36\x34\x30\x12\x19\n\x0cimage_height\x18\r \x01(\r:\x03\x34\x38\x30\x12\x16\n\nframe_rate\x18\x0e \x01(\x04:\x02\x33\x30\x12\x16\n\nbrightness\x18\x0f \x01(\x05:\x02-1\x12\x14\n\x08\x63ontrast\x18\x10 \x01(\x05:\x02-1\x12\x16\n\nsaturation\x18\x11 \x01(\x05:\x02-1\x12\x15\n\tsharpness\x18\x12 \x01(\x05:\x02-1\x12\x10\n\x04gain\x18\x13 \x01(\x05:\x02-1\x12\x1a\n\x0c\x61utoexposure\x18\x14 \x01(\x08:\x04true\x12\x15\n\x08\x65xposure\x18\x15 \x01(\r:\x03\x31\x30\x30\x12\x18\n\tautofocus\x18\x16 \x01(\x08:\x05\x66\x61lse\x12\x11\n\x05\x66ocus\x18\x17 \x01(\x05:\x02-1\x12 \n\x12\x61uto_white_balance\x18\x18 \x01(\x08:\x04true\x12\x1b\n\rwhite_balance\x18\x19 \x01(\x05:\x04\x34\x30\x30\x30\x12\x1b\n\x10trigger_internal\x18\x1a \x01(\r:\x01\x30\x12\x17\n\x0btrigger_fps\x18\x1b \x01(\r:\x02\x33\x30\x12\x15\n\nerror_code\x18\x1c \x01(\r:\x01\x30') ) _CAMERACONF = _descriptor.Descriptor( name='CameraConf', full_name='apollo.drivers.camera.CameraConf', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='index', full_name='apollo.drivers.camera.CameraConf.index', index=0, number=1, type=13, cpp_type=3, label=2, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='position', full_name='apollo.drivers.camera.CameraConf.position', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("centre").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='topic_name', full_name='apollo.drivers.camera.CameraConf.topic_name', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='video_device', full_name='apollo.drivers.camera.CameraConf.video_device', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("/dev/video0").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_name', full_name='apollo.drivers.camera.CameraConf.camera_name', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("head_camera").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_info_url', full_name='apollo.drivers.camera.CameraConf.camera_info_url', index=5, number=6, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_frame_id', full_name='apollo.drivers.camera.CameraConf.camera_frame_id', index=6, number=7, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_timeout', full_name='apollo.drivers.camera.CameraConf.camera_timeout', index=7, number=8, type=13, cpp_type=3, label=1, has_default_value=True, default_value=1000, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='spin_interval', full_name='apollo.drivers.camera.CameraConf.spin_interval', index=8, number=9, type=1, cpp_type=5, label=1, has_default_value=True, default_value=float(0.005), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='io_method', full_name='apollo.drivers.camera.CameraConf.io_method', index=9, number=10, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("mmap").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='pixel_format', full_name='apollo.drivers.camera.CameraConf.pixel_format', index=10, number=11, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("mjpeg").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='image_width', full_name='apollo.drivers.camera.CameraConf.image_width', index=11, number=12, type=13, cpp_type=3, label=1, has_default_value=True, default_value=640, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='image_height', full_name='apollo.drivers.camera.CameraConf.image_height', index=12, number=13, type=13, cpp_type=3, label=1, has_default_value=True, default_value=480, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='frame_rate', full_name='apollo.drivers.camera.CameraConf.frame_rate', index=13, number=14, type=4, cpp_type=4, label=1, has_default_value=True, default_value=30, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='brightness', full_name='apollo.drivers.camera.CameraConf.brightness', index=14, number=15, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='contrast', full_name='apollo.drivers.camera.CameraConf.contrast', index=15, number=16, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='saturation', full_name='apollo.drivers.camera.CameraConf.saturation', index=16, number=17, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='sharpness', full_name='apollo.drivers.camera.CameraConf.sharpness', index=17, number=18, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='gain', full_name='apollo.drivers.camera.CameraConf.gain', index=18, number=19, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='autoexposure', full_name='apollo.drivers.camera.CameraConf.autoexposure', index=19, number=20, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='exposure', full_name='apollo.drivers.camera.CameraConf.exposure', index=20, number=21, type=13, cpp_type=3, label=1, has_default_value=True, default_value=100, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='autofocus', full_name='apollo.drivers.camera.CameraConf.autofocus', index=21, number=22, type=8, cpp_type=7, label=1, has_default_value=True, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='focus', full_name='apollo.drivers.camera.CameraConf.focus', index=22, number=23, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='auto_white_balance', full_name='apollo.drivers.camera.CameraConf.auto_white_balance', index=23, number=24, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='white_balance', full_name='apollo.drivers.camera.CameraConf.white_balance', index=24, number=25, type=5, cpp_type=1, label=1, has_default_value=True, default_value=4000, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='trigger_internal', full_name='apollo.drivers.camera.CameraConf.trigger_internal', index=25, number=26, type=13, cpp_type=3, label=1, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='trigger_fps', full_name='apollo.drivers.camera.CameraConf.trigger_fps', index=26, number=27, type=13, cpp_type=3, label=1, has_default_value=True, default_value=30, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='error_code', full_name='apollo.drivers.camera.CameraConf.error_code', index=27, number=28, type=13, cpp_type=3, label=1, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=74, serialized_end=813, ) DESCRIPTOR.message_types_by_name['CameraConf'] = _CAMERACONF _sym_db.RegisterFileDescriptor(DESCRIPTOR) CameraConf = _reflection.GeneratedProtocolMessageType('CameraConf', (_message.Message,), dict( DESCRIPTOR = _CAMERACONF, __module__ = 'modules.drivers.camera.proto.camera_conf_pb2' # @@protoc_insertion_point(class_scope:apollo.drivers.camera.CameraConf) )) _sym_db.RegisterMessage(CameraConf) # @@protoc_insertion_point(module_scope)
51.069498
1,613
0.730476
1,885
13,227
4.896552
0.127321
0.073673
0.063814
0.094258
0.686349
0.670531
0.588191
0.533044
0.518418
0.518418
0
0.06131
0.134346
13,227
258
1,614
51.267442
0.744803
0.019279
0
0.560669
1
0.004184
0.260913
0.223045
0
0
0
0
0
1
0
false
0
0.025105
0
0.025105
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
48847182743877e2207fafdce5ef0b412ca3a606
55,929
py
Python
colour/colorimetry/tests/test_spectrum.py
aurelienpierre/colour
3ac45c12fbc0493e49ba4d4b2cb253df9fe14c47
[ "BSD-3-Clause" ]
null
null
null
colour/colorimetry/tests/test_spectrum.py
aurelienpierre/colour
3ac45c12fbc0493e49ba4d4b2cb253df9fe14c47
[ "BSD-3-Clause" ]
null
null
null
colour/colorimetry/tests/test_spectrum.py
aurelienpierre/colour
3ac45c12fbc0493e49ba4d4b2cb253df9fe14c47
[ "BSD-3-Clause" ]
null
null
null
"""Defines the unit tests for the :mod:`colour.colorimetry.spectrum` module.""" import colour import numpy as np import unittest import scipy from distutils.version import LooseVersion from colour.algebra import CubicSplineInterpolator from colour.colorimetry.spectrum import SPECTRAL_SHAPE_DEFAULT from colour.colorimetry.spectrum import ( SpectralShape, SpectralDistribution, MultiSpectralDistributions, reshape_sd, reshape_msds, sds_and_msds_to_sds, sds_and_msds_to_msds, ) from colour.hints import Dict, Tuple from colour.utilities import tstack __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" __all__ = [ "DATA_SAMPLE", "DATA_SAMPLE_NON_UNIFORM", "DATA_SAMPLE_INTERPOLATED", "DATA_SAMPLE_INTERPOLATED_NON_UNIFORM", "DATA_SAMPLE_NORMALISED", "DATA_STANDARD_OBSERVER_2_DEGREE_CIE1931", "DATA_CMFS", "DATA_SAMPLE_ABRIDGED", "DATA_MULTI_SAMPLE_ABRIDGED", "TestSpectralShape", "TestSpectralDistribution", "TestMultiSpectralDistributions", "TestReshapeSd", "TestSdsAndMdsToSds", "TestSdsAndMsdsToMsds", ] DATA_SAMPLE: Dict = { 340: 0.0000, 360: 0.0000, 380: 0.0000, 400: 0.0641, 420: 0.0645, 440: 0.0562, 460: 0.0537, 480: 0.0559, 500: 0.0651, 520: 0.0705, 540: 0.0772, 560: 0.0870, 580: 0.1128, 600: 0.1360, 620: 0.1511, 640: 0.1688, 660: 0.1996, 680: 0.2397, 700: 0.2852, 720: 0.0000, 740: 0.0000, 760: 0.0000, 780: 0.0000, 800: 0.0000, 820: 0.0000, } DATA_SAMPLE_NON_UNIFORM: Dict = { 391.898: 16.331740, 392.069: 16.333122, 405.606: 40.197224, 406.794: 39.923366, 406.891: 39.924098, 407.026: 39.925138, 416.286: 40.064293, 418.690: 40.009950, 426.700: 18.045809, 426.726: 18.045986, 432.556: 38.435883, 464.742: 29.534647, 465.025: 29.534647, 465.147: 29.534647, 466.586: 38.226470, 477.175: 7.487795, 493.205: 7.684766, 505.217: 7.684766, 513.294: 20.701285, 513.328: 20.704211, 514.349: 20.704211, 514.516: 20.709788, 515.109: 20.709788, 538.034: 7.684766, 564.807: 20.704211, 566.247: 20.709788, 569.592: 32.103387, 580.133: 37.548490, 581.198: 37.548490, 582.642: 40.197224, 588.977: 18.045986, 589.159: 18.045809, 600.113: 8.643020, 600.603: 8.647157, 600.718: 8.640394, 601.068: 8.640394, 601.322: 8.647157, 601.484: 8.643020, 657.805: 14.448826, 658.288: 14.448826, 658.761: 8.537097, 674.438: 38.22647, 678.390: 20.709788, 703.725: 38.435883, 711.318: 8.647157, 711.519: 8.640394, 711.563: 22.532398, 711.699: 8.647157, 711.990: 22.536906, 723.132: 16.33174, 723.642: 16.333122, 761.265: 41.342187, 786.089: 8.850659, 805.862: 8.850659, } DATA_SAMPLE_INTERPOLATED: Tuple = ( 0.000000000000000, 0.000230709627131, 0.000384144814593, 0.000507137093115, 0.000632114832536, 0.000778810112328, 0.000955965592105, 0.001163041382140, 0.001391921913876, 0.001628622810444, 0.001854997757177, 0.002050445372122, 0.002193616076555, 0.002264118965498, 0.002244228678230, 0.002120592268802, 0.001885936076555, 0.001540772596628, 0.001095107350478, 0.000570145756392, 0.000000000000000, -0.000581325882457, -0.001183945630981, -0.001820338942229, -0.002492278660287, -0.003192248184715, -0.003904858878589, -0.004608267476544, -0.005275593492823, -0.005876336629317, -0.006377794183612, -0.006746478457031, -0.006949534162679, -0.006956155833489, -0.006739005230263, -0.006275628749720, -0.005549874832536, -0.004553311371393, -0.003286643119019, -0.001761129096236, 0.000000000000000, 0.001979832128906, 0.004221516875000, 0.006762744980469, 0.009617760000000, 0.012780285644531, 0.016226453125000, 0.019917728496094, 0.023803840000000, 0.027825705410156, 0.031918359375000, 0.036013880761719, 0.040044320000000, 0.043944626425781, 0.047655575625000, 0.051126696777344, 0.054319200000000, 0.057208903691406, 0.059789161875000, 0.062073791542969, 0.064100000000000, 0.065908998066406, 0.067477265625000, 0.068776060136719, 0.069791040000000, 0.070520520019531, 0.070973726875000, 0.071169054589844, 0.071132320000000, 0.070895018222656, 0.070492578125000, 0.069962617792969, 0.069343200000000, 0.068671087675781, 0.067979999375000, 0.067298864746094, 0.066650080000000, 0.066047763378906, 0.065496010625000, 0.064987150449219, 0.064500000000000, 0.064007805449219, 0.063510900625000, 0.063016138378906, 0.062528640000000, 0.062051989746094, 0.061588429375000, 0.061139052675781, 0.060704000000000, 0.060282652792969, 0.059873828125000, 0.059475973222656, 0.059087360000000, 0.058706279589844, 0.058331236875000, 0.057961145019531, 0.057595520000000, 0.057234675136719, 0.056879915625000, 0.056533733066406, 0.056200000000000, 0.055883811757812, 0.055589516250000, 0.055320009023437, 0.055076960000000, 0.054860961914063, 0.054671678750000, 0.054507994179687, 0.054368160000000, 0.054249944570312, 0.054150781250000, 0.054067916835938, 0.053998560000000, 0.053940029726562, 0.053889903750000, 0.053846166992187, 0.053807360000000, 0.053772727382813, 0.053742366250000, 0.053717374648438, 0.053700000000000, 0.053692483144531, 0.053693175625000, 0.053700270058594, 0.053712960000000, 0.053731311035156, 0.053756131875000, 0.053788845449219, 0.053831360000000, 0.053885940175781, 0.053955078125000, 0.054041364589844, 0.054147360000000, 0.054275465566406, 0.054427794375000, 0.054606042480469, 0.054811360000000, 0.055044222207031, 0.055304300625000, 0.055590334121094, 0.055900000000000, 0.056231407851562, 0.056587597500000, 0.056971279335937, 0.057383360000000, 0.057823168945313, 0.058288685000000, 0.058776762929688, 0.059283360000000, 0.059803762539063, 0.060332812500000, 0.060865134023438, 0.061395360000000, 0.061918358632813, 0.062429460000000, 0.062924682617188, 0.063400960000000, 0.063856367226563, 0.064290347500000, 0.064703938710938, 0.065100000000000, 0.065481647265625, 0.065846786250000, 0.066192982265625, 0.066519040000000, 0.066824853515625, 0.067111256250000, 0.067379871015625, 0.067632960000000, 0.067873274765625, 0.068103906250000, 0.068328134765625, 0.068549280000000, 0.068770551015625, 0.068994896250000, 0.069224853515625, 0.069462400000000, 0.069708802265625, 0.069964466250000, 0.070228787265625, 0.070500000000000, 0.070776270703125, 0.071059446250000, 0.071351597578125, 0.071653920000000, 0.071966845703125, 0.072290156250000, 0.072623095078125, 0.072964480000000, 0.073312815703125, 0.073666406250000, 0.074023467578125, 0.074382240000000, 0.074741100703125, 0.075098676250000, 0.075453955078125, 0.075806400000000, 0.076156060703125, 0.076503686250000, 0.076850837578125, 0.077200000000000, 0.077552701992188, 0.077904262500000, 0.078250762070313, 0.078590880000000, 0.078925561523438, 0.079257685000000, 0.079591729101562, 0.079933440000000, 0.080289498554688, 0.080667187500000, 0.081074058632813, 0.081517600000000, 0.082004903085938, 0.082542330000000, 0.083135180664063, 0.083787360000000, 0.084501045117188, 0.085276352500000, 0.086111005195313, 0.087000000000000, 0.087938453242188, 0.088930890000000, 0.089981833007812, 0.091092960000000, 0.092263452148438, 0.093490342500000, 0.094768864414062, 0.096092800000000, 0.097454828554687, 0.098846875000000, 0.100260458320312, 0.101687040000000, 0.103118372460937, 0.104546847500000, 0.105965844726563, 0.107370080000000, 0.108755953867188, 0.110121900000000, 0.111468733632812, 0.112800000000000, 0.114120657988281, 0.115431176875000, 0.116730532871094, 0.118017600000000, 0.119291174316406, 0.120549998125000, 0.121792784199219, 0.123018240000000, 0.124225091894531, 0.125412109375000, 0.126578129277344, 0.127722080000000, 0.128843005722656, 0.129940090625000, 0.131012683105469, 0.132060320000000, 0.133082750800781, 0.134079961875000, 0.135052200683594, 0.136000000000000, 0.136923531484375, 0.137820920000000, 0.138690739765625, 0.139532640000000, 0.140347216796875, 0.141135885000000, 0.141900750078125, 0.142644480000000, 0.143370177109375, 0.144081250000000, 0.144781285390625, 0.145473920000000, 0.146162712421875, 0.146851015000000, 0.147541845703125, 0.148237760000000, 0.148940722734375, 0.149651980000000, 0.150371931015625, 0.151100000000000, 0.151834687363281, 0.152574745625000, 0.153319862089844, 0.154070560000000, 0.154828088378906, 0.155594311875000, 0.156371600605469, 0.157162720000000, 0.157970720644531, 0.158798828125000, 0.159650332871094, 0.160528480000000, 0.161436359160156, 0.162376794375000, 0.163352233886719, 0.164364640000000, 0.165415378925781, 0.166505110625000, 0.167633678652344, 0.168800000000000, 0.170002988242187, 0.171244585000000, 0.172526722382812, 0.173850400000000, 0.175215795898437, 0.176622377500000, 0.178069012539063, 0.179554080000000, 0.181075581054688, 0.182631250000000, 0.184218665195313, 0.185835360000000, 0.187478933710938, 0.189147162500000, 0.190838110351563, 0.192550240000000, 0.194282523867188, 0.196034555000000, 0.197806658007813, 0.199600000000000, 0.201405046894531, 0.203174116875000, 0.204868198964844, 0.206468000000000, 0.207971350097656, 0.209390608125000, 0.210750067167969, 0.212083360000000, 0.213430864550781, 0.214837109375000, 0.216348179121094, 0.218009120000000, 0.219861345253906, 0.221940040625000, 0.224271569824219, 0.226870880000000, 0.229738907207031, 0.232859981875000, 0.236199234277344, 0.239700000000000, 0.243337282929688, 0.247262056250000, 0.251598942851562, 0.256394240000000, 0.261625952148438, 0.267213823750000, 0.273029372070313, 0.278905920000000, 0.284648628867188, 0.290044531250000, 0.294872563789062, 0.298913600000000, 0.301960483085938, 0.303828058750000, 0.304363208007813, 0.303454880000000, 0.301044124804688, 0.297134126250000, 0.291800234726562, 0.285200000000000, 0.277470396855469, 0.268408756875000, 0.257826504003906, 0.245651040000000, 0.231911267089844, 0.216723110625000, 0.200275041738281, 0.182813600000000, 0.164628916074219, 0.146040234375000, 0.127381435722656, 0.108986560000000, 0.091175328808594, 0.074238668125000, 0.058424230957031, 0.043921920000000, 0.030849410292969, 0.019237671875000, 0.009016492441406, 0.000000000000000, -0.008014721386719, -0.014901410625000, -0.020510217441406, -0.024767360000000, -0.027665856933594, -0.029256259375000, -0.029637382988281, -0.028947040000000, -0.027352771230469, -0.025042578125000, -0.022215654785156, -0.019073120000000, -0.015808749277344, -0.012599706875000, -0.009597277832031, -0.006917600000000, -0.004632396074219, -0.002759705625000, -0.001254617128906, 0.000000000000000, 0.001146203203125, 0.002165737500000, 0.003010363984375, 0.003650560000000, 0.004073291015625, 0.004279782500000, 0.004283291796875, 0.004106880000000, 0.003781183828125, 0.003342187500000, 0.002828994609375, 0.002281600000000, 0.001738661640625, 0.001235272500000, 0.000800732421875, 0.000456320000000, 0.000213064453125, 0.000069517500000, 0.000009525234375, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, ) DATA_SAMPLE_INTERPOLATED_NON_UNIFORM: Tuple = ( 16.329808636577400, 16.722487609243078, 17.780769796558388, 19.388440919210822, 21.429286697887836, 23.787092853276910, 26.345645106065515, 28.988729176941121, 31.600130786591194, 34.063635655703216, 36.263029504964656, 38.082098055062993, 39.404627026685688, 40.114402140520198, 40.111247588026082, 39.925103635141149, 39.890167058876870, 39.799323872976096, 39.680556569501256, 39.561845869769570, 39.471172495098209, 39.436517166804364, 39.485860606205222, 39.647183534617994, 39.948466673359860, 40.374181475729280, 40.480943048717741, 39.587763146544347, 37.399010971904012, 34.259517350145224, 30.574008069142096, 26.747208916768866, 23.183845680899680, 20.288644149408725, 18.466330110170176, 18.131455040802454, 19.618408431271092, 22.601624593221480, 26.621530082560952, 31.218551455196845, 35.933115267036499, 40.312773209586069, 44.121677838324345, 47.374686358105983, 50.100647613008405, 52.328410447109043, 54.086823704485290, 55.404736229214613, 56.310996865374428, 56.834454457042114, 57.003957848295137, 56.848355883210893, 56.396497405866839, 55.677231260340363, 54.719406290708918, 53.551871341049903, 52.203475255440743, 50.703066877958868, 49.079495052681693, 47.361608623686649, 45.578256435051173, 43.758287330852653, 41.930550155168532, 40.123893752076235, 38.367166965653183, 36.689218639976801, 35.118897619124496, 33.685052747173714, 32.416532868201863, 31.342186826286373, 30.490863465504646, 29.891411629934137, 29.572680163652254, 29.538621481156376, 33.594913456316092, 41.048330705400552, 45.551744552213606, 47.142069193311166, 46.264235269850914, 43.363173422990592, 38.883814293887831, 33.271088523700378, 26.969926753585888, 20.425259624702068, 14.082017778206605, 8.385131855257200, 3.728429425651282, 0.156961054721180, -2.429909888236355, -4.133307786198728, -5.054357022143353, -5.294181979047651, -4.953907039889023, -4.134656587644884, -2.937555005292646, -1.463726675809728, 0.185704017826468, 1.909612692638526, 3.606874965649032, 5.176366453880572, 6.516962774355742, 7.527539544097118, 8.122379803803623, 8.331483144611147, 8.237444938631239, 7.923124732066758, 7.471382071120567, 6.965076501995521, 6.487067570894484, 6.120214824020312, 5.947377807575871, 6.051416067764015, 6.515189150787608, 7.421556602849507, 8.833103319101975, 10.654113909347958, 12.714472051171430, 14.843629856075644, 16.871039435563851, 18.626152901139314, 19.938422364305275, 20.637299936564997, 20.706835013628812, 20.713132276905259, 20.620587314150111, 20.396819412610807, 20.054405097058748, 19.605938071902443, 19.064012041550384, 18.441220710411045, 17.750157782892924, 17.003416963404511, 16.213591956354293, 15.393276466150766, 14.555064197202412, 13.711548853917725, 12.875324140705192, 12.058983761973309, 11.275121422130562, 10.536330825585436, 9.855205676746426, 9.244339680022023, 8.716326539820709, 8.283759960550988, 7.959233646621334, 7.755341302440248, 7.684676632416213, 7.756084346822568, 7.961801724157814, 8.289468950531905, 8.726726048591537, 9.261213040983417, 9.880569950354237, 10.572436799350699, 11.324453610619505, 12.124260406807357, 12.959497210560945, 13.817804044526978, 14.686820931352152, 15.554187893683173, 16.407544954166731, 17.234532135449530, 18.022789460178267, 18.759956950999651, 19.433674630560375, 20.031582521507140, 20.541320646486646, 20.950529028145592, 21.246847689130675, 21.417916652088600, 21.451375939666065, 21.334865574509770, 21.056025579266414, 20.604750276779001, 20.494345115463702, 22.221705466331883, 25.661450384670388, 29.775598875658655, 33.531925166546948, 36.383260993760757, 38.399428506854193, 39.690190939354423, 40.365311524788659, 40.534553496684069, 40.307680088567857, 39.794454533967205, 39.104640066409281, 38.347999919421312, 37.634297326530451, 37.374685121273394, 39.119690201154867, 40.253206513156250, 38.299118522290833, 34.130306343480264, 28.883500017392159, 23.695429584694160, 19.702825086053920, 18.042370406596557, 17.942146149526579, 17.437952042997388, 16.603615436175311, 15.527509997088327, 14.298009393764401, 13.003487294231499, 11.732317366517600, 10.572873278650665, 9.613528698658669, 8.942657294569587, 8.648632734411382, 8.638275005914387, 8.608461770725761, 8.468358277399256, 8.236485894689265, 7.918459394063972, 7.519893546991550, 7.046403124940173, 6.503602899378026, 5.897107641773280, 5.232532123594114, 4.515491116308703, 3.751599391385226, 2.946471720291860, 2.105722874496783, 1.234967625468170, 0.339820744674198, -0.574102996416954, -1.501188826337108, -2.435821973618090, -3.372387666791723, -4.305271134389827, -5.228857604944231, -6.137532306986749, -7.025680469049206, -7.887687319663434, -8.717938087361247, -9.510818000674471, -10.260712288134929, -10.962006178274445, -11.609084899624833, -12.196333680717927, -12.718137750085543, -13.168882336259514, -13.542952667771653, -13.834733973153785, -14.038611480937735, -14.148970419655322, -14.160196017838375, -14.066673504018716, -13.862788106728164, -13.542925054498539, -13.101469575861673, -12.532806899349385, -11.831322253493493, -10.991400866825831, -10.007427967878208, -8.873788785182459, -7.584868547270405, -6.135052482673858, -4.518725819924658, -2.730273787554616, -0.764081614095559, 1.385465471920696, 3.723982241962316, 6.257083467497486, 8.990383919994379, 11.929498370921175, 14.976162260830137, 5.084237255461949, -6.729230790271000, -14.622433089729542, -19.038838171389944, -20.421914563728482, -19.215130795221405, -15.861955394344996, -10.805856889575507, -4.490303809389212, 2.641235317737622, 10.145291963328749, 17.578397598907866, 24.497083695998736, 30.457881726125084, 35.017323160810655, 37.731939471579153, 38.169944675202451, 36.103648065327157, 31.478944095141092, 24.247257545409393, 14.377470469911161, 2.089605892978410, -12.208009328653077, -28.102486071018522, -45.180935210153116, -63.030467622092019, -81.238194182870473, -99.391225768523640, -117.076673255086732, -133.881647518594917, -149.393259435083451, -163.198619880587444, -174.884839731142108, -184.039029862782684, -190.248301151544382, -193.099764473462415, -192.180530704571822, -187.077710720907902, -177.378415398505837, -162.669755613400923, -142.538842241628146, -116.572786159222886, -84.358698242220214, -45.483689366655454, 0.465129591436323, 53.867241377821607, 111.906385750398641, 165.969680931356891, 206.832112792864763, 225.268667207090687, 212.054330046203120, 157.964087182370434, 53.772924487761195, 24.128558965593012, 155.948189345952358, 238.667542187567193, 279.823268952005947, 286.952021100836475, 267.590450095627091, 229.275207397946076, 179.542944469361430, 125.930312771441450, 75.973963765754249, 37.210548913868003, 17.176719677350921, 17.152394375030820, 19.379794324130732, 21.517434431022508, 23.565545988087592, 25.524360287707406, 27.394108622263396, 29.175022284136993, 30.867332565709628, 32.471270759362753, 33.987068157477793, 35.414956052436175, 36.755165736619354, 38.007928502408760, 39.173475642185821, 40.252038448331973, 41.243848213228674, 42.149136229257330, 42.968133788799399, 43.701072184236310, 44.348182707949491, 44.909696652320392, 45.385845309730442, 45.776859972561077, 46.082971933193733, 46.304412484009845, 46.441412917390849, 46.494204525718175, 46.463018601373285, 46.348086436737596, 46.149639324192542, 45.867908556119552, 45.503125424900077, 45.055521222915552, 44.525327242547419, 43.912774776177095, 43.218095116186007, 42.441519554955640, 41.583279384867382, 40.643991169034841, 39.627797988936805, 38.540734852902020, 37.388854826093969, 36.178210973676094, 34.914856360811882, 33.604844052664760, 32.254227114398248, 30.869058611175774, 29.455391608160820, 28.019279170516839, 26.566774363407301, 25.103930251995678, 23.636799901445418, 22.171436376920010, 20.713892743582907, 19.270222066597562, 17.846477411127466, 16.448711842336071, 15.082978425386836, 13.755330225443233, 12.471820307668732, 11.238501737226787, 10.061427579280879, 8.946650898994456, 7.900224761530997, 6.928202232053956, 6.036636375726809, 5.231580257713018, 4.519086943176044, 3.905209497279358, 3.396000985186418, 2.997514472060695, 2.715803023065654, 2.556919703364760, 2.526917578121476, 2.631849712499274, 2.877769171661610, 3.270729020771954, 3.816782324993773, 4.521982149490528, 5.392381559425689, 6.434033619962720, 7.652991396265083, ) DATA_SAMPLE_NORMALISED: Tuple = ( 0.000000000000000, 0.000000000000000, 0.000000000000000, 22.475455820476860, 22.615708274894811, 19.705469845722302, 18.828892005610097, 19.600280504908834, 22.826086956521742, 24.719495091164092, 27.068723702664798, 30.504908835904626, 39.551192145862551, 47.685834502103788, 52.980364656381497, 59.186535764375883, 69.985974754558200, 84.046283309957929, 100.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, ) DATA_STANDARD_OBSERVER_2_DEGREE_CIE1931: Dict = { 380: (0.001368, 0.000039, 0.006450), 385: (0.002236, 0.000064, 0.010550), 390: (0.004243, 0.000120, 0.020050), 395: (0.007650, 0.000217, 0.036210), 400: (0.014310, 0.000396, 0.067850), 405: (0.023190, 0.000640, 0.110200), 410: (0.043510, 0.001210, 0.207400), 415: (0.077630, 0.002180, 0.371300), 420: (0.134380, 0.004000, 0.645600), 425: (0.214770, 0.007300, 1.039050), 430: (0.283900, 0.011600, 1.385600), 435: (0.328500, 0.016840, 1.622960), 440: (0.348280, 0.023000, 1.747060), 445: (0.348060, 0.029800, 1.782600), 450: (0.336200, 0.038000, 1.772110), 455: (0.318700, 0.048000, 1.744100), 460: (0.290800, 0.060000, 1.669200), 465: (0.251100, 0.073900, 1.528100), 470: (0.195360, 0.090980, 1.287640), 475: (0.142100, 0.112600, 1.041900), 480: (0.095640, 0.139020, 0.812950), 485: (0.057950, 0.169300, 0.616200), 490: (0.032010, 0.208020, 0.465180), 495: (0.014700, 0.258600, 0.353300), 500: (0.004900, 0.323000, 0.272000), 505: (0.002400, 0.407300, 0.212300), 510: (0.009300, 0.503000, 0.158200), 515: (0.029100, 0.608200, 0.111700), 520: (0.063270, 0.710000, 0.078250), 525: (0.109600, 0.793200, 0.057250), 530: (0.165500, 0.862000, 0.042160), 535: (0.225750, 0.914850, 0.029840), 540: (0.290400, 0.954000, 0.020300), 545: (0.359700, 0.980300, 0.013400), 550: (0.433450, 0.994950, 0.008750), 555: (0.512050, 1.000000, 0.005750), 560: (0.594500, 0.995000, 0.003900), 565: (0.678400, 0.978600, 0.002750), 570: (0.762100, 0.952000, 0.002100), 575: (0.842500, 0.915400, 0.001800), 580: (0.916300, 0.870000, 0.001650), 585: (0.978600, 0.816300, 0.001400), 590: (1.026300, 0.757000, 0.001100), 595: (1.056700, 0.694900, 0.001000), 600: (1.062200, 0.631000, 0.000800), 605: (1.045600, 0.566800, 0.000600), 610: (1.002600, 0.503000, 0.000340), 615: (0.938400, 0.441200, 0.000240), 620: (0.854450, 0.381000, 0.000190), 625: (0.751400, 0.321000, 0.000100), 630: (0.642400, 0.265000, 0.000050), 635: (0.541900, 0.217000, 0.000030), 640: (0.447900, 0.175000, 0.000020), 645: (0.360800, 0.138200, 0.000010), 650: (0.283500, 0.107000, 0.000000), 655: (0.218700, 0.081600, 0.000000), 660: (0.164900, 0.061000, 0.000000), 665: (0.121200, 0.044580, 0.000000), 670: (0.087400, 0.032000, 0.000000), 675: (0.063600, 0.023200, 0.000000), 680: (0.046770, 0.017000, 0.000000), 685: (0.032900, 0.011920, 0.000000), 690: (0.022700, 0.008210, 0.000000), 695: (0.015840, 0.005723, 0.000000), 700: (0.011359, 0.004102, 0.000000), 705: (0.008111, 0.002929, 0.000000), 710: (0.005790, 0.002091, 0.000000), 715: (0.004109, 0.001484, 0.000000), 720: (0.002899, 0.001047, 0.000000), 725: (0.002049, 0.000740, 0.000000), 730: (0.001440, 0.000520, 0.000000), 735: (0.001000, 0.000361, 0.000000), 740: (0.000690, 0.000249, 0.000000), 745: (0.000476, 0.000172, 0.000000), 750: (0.000332, 0.000120, 0.000000), 755: (0.000235, 0.000085, 0.000000), 760: (0.000166, 0.000060, 0.000000), 765: (0.000117, 0.000042, 0.000000), 770: (0.000083, 0.000030, 0.000000), 775: (0.000059, 0.000021, 0.000000), 780: (0.000042, 0.000015, 0.000000), } DATA_CMFS: Dict = { 380: np.array([0.001368, 3.90e-05, 0.006450]), 385: np.array([0.002236, 6.40e-05, 0.010550]), 390: np.array([0.004243, 0.000120, 0.020050]), 395: np.array([0.007650, 0.000217, 0.036210]), 400: np.array([0.014310, 0.000396, 0.067850]), 405: np.array([0.023190, 0.000640, 0.110200]), 410: np.array([0.043510, 0.001210, 0.207400]), 415: np.array([0.077630, 0.002180, 0.371300]), 420: np.array([0.134380, 0.004000, 0.645600]), 425: np.array([0.214770, 0.007300, 1.039050]), 430: np.array([0.283900, 0.011600, 1.385600]), 435: np.array([0.328500, 0.016840, 1.622960]), 440: np.array([0.348280, 0.023000, 1.747060]), 445: np.array([0.348060, 0.029800, 1.782600]), 450: np.array([0.336200, 0.038000, 1.772110]), 455: np.array([0.318700, 0.048000, 1.744100]), 460: np.array([0.290800, 0.060000, 1.669200]), 465: np.array([0.251100, 0.073900, 1.528100]), 470: np.array([0.195360, 0.090980, 1.287640]), 475: np.array([0.142100, 0.112600, 1.041900]), 480: np.array([0.095640, 0.139020, 0.812950]), 485: np.array([0.057950, 0.169300, 0.616200]), 490: np.array([0.032010, 0.208020, 0.465180]), 495: np.array([0.014700, 0.258600, 0.353300]), 500: np.array([0.004900, 0.323000, 0.272000]), 505: np.array([0.002400, 0.407300, 0.212300]), 510: np.array([0.009300, 0.503000, 0.158200]), 515: np.array([0.029100, 0.608200, 0.111700]), 520: np.array([0.063270, 0.710000, 0.078250]), 525: np.array([0.109600, 0.793200, 0.057250]), 530: np.array([0.165500, 0.862000, 0.042160]), 535: np.array([0.225750, 0.914850, 0.029840]), 540: np.array([0.290400, 0.954000, 0.020300]), 545: np.array([0.359700, 0.980300, 0.013400]), 550: np.array([0.433450, 0.994950, 0.008750]), 555: np.array([0.512050, 1.000000, 0.005750]), 560: np.array([0.594500, 0.995000, 0.003900]), 565: np.array([0.678400, 0.978600, 0.002750]), 570: np.array([0.762100, 0.952000, 0.002100]), 575: np.array([0.842500, 0.915400, 0.001800]), 580: np.array([0.916300, 0.870000, 0.001650]), 585: np.array([0.978600, 0.816300, 0.001400]), 590: np.array([1.026300, 0.757000, 0.001100]), 595: np.array([1.056700, 0.694900, 0.001000]), 600: np.array([1.062200, 0.631000, 0.000800]), 605: np.array([1.045600, 0.566800, 0.000600]), 610: np.array([1.002600, 0.503000, 0.000340]), 615: np.array([0.938400, 0.441200, 0.000240]), 620: np.array([0.854450, 0.381000, 0.000190]), 625: np.array([0.751400, 0.321000, 0.000100]), 630: np.array([0.642400, 0.265000, 5.00e-05]), 635: np.array([0.541900, 0.217000, 3.00e-05]), 640: np.array([0.447900, 0.175000, 2.00e-05]), 645: np.array([0.360800, 0.138200, 1.00e-05]), 650: np.array([0.283500, 0.107000, 0.000000]), 655: np.array([0.218700, 0.081600, 0.000000]), 660: np.array([0.164900, 0.061000, 0.000000]), 665: np.array([0.121200, 0.044580, 0.000000]), 670: np.array([0.087400, 0.032000, 0.000000]), 675: np.array([0.063600, 0.023200, 0.000000]), 680: np.array([0.046770, 0.017000, 0.000000]), 685: np.array([0.032900, 0.011920, 0.000000]), 690: np.array([0.022700, 0.008210, 0.000000]), 695: np.array([0.015840, 0.005723, 0.000000]), 700: np.array([0.011359, 0.004102, 0.000000]), 705: np.array([0.008111, 0.002929, 0.000000]), 710: np.array([0.005790, 0.002091, 0.000000]), 715: np.array([0.004109, 0.001484, 0.000000]), 720: np.array([0.002899, 0.001047, 0.000000]), 725: np.array([0.002049, 0.000740, 0.000000]), 730: np.array([0.001440, 0.000520, 0.000000]), 735: np.array([0.001000, 0.000361, 0.000000]), 740: np.array([0.000690, 0.000249, 0.000000]), 745: np.array([0.000476, 0.000172, 0.000000]), 750: np.array([0.000332, 0.000120, 0.000000]), 755: np.array([0.000235, 8.50e-05, 0.000000]), 760: np.array([0.000166, 6.00e-05, 0.000000]), 765: np.array([0.000117, 4.20e-05, 0.000000]), 770: np.array([8.30e-05, 3.00e-05, 0.000000]), 775: np.array([5.90e-05, 2.10e-05, 0.000000]), 780: np.array([4.20e-05, 1.50e-05, 0.000000]), } DATA_SAMPLE_ABRIDGED: Dict = { 500: 0.0651, 520: 0.0705, 540: 0.0772, 560: 0.0870, 580: 0.1128, 600: 0.1360, } DATA_MULTI_SAMPLE_ABRIDGED: Dict = { 500: (0.004900, 0.323000, 0.272000), 510: (0.009300, 0.503000, 0.158200), 520: (0.063270, 0.710000, 0.078250), 530: (0.165500, 0.862000, 0.042160), 540: (0.290400, 0.954000, 0.020300), 550: (0.433450, 0.994950, 0.008750), 560: (0.594500, 0.995000, 0.003900), } class TestSpectralShape(unittest.TestCase): """ Define :class:`colour.colorimetry.spectrum.SpectralShape` class unit tests methods. """ def test_required_attributes(self): """Test the presence of required attributes.""" required_attributes = ("start", "end", "interval", "boundaries") for attribute in required_attributes: self.assertIn(attribute, dir(SpectralShape)) def test_required_methods(self): """Test the presence of required methods.""" required_methods = ( "__init__", "__str__", "__repr__", "__hash__", "__iter__", "__contains__", "__len__", "__eq__", "__ne__", "range", ) for method in required_methods: self.assertIn(method, dir(SpectralShape)) def test_start(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.start` attribute. """ self.assertEqual(SpectralShape(360, 830, 1).start, 360) self.assertRaises(AssertionError, lambda: SpectralShape(360, 360, 1)) self.assertRaises(AssertionError, lambda: SpectralShape(360, 0, 1)) def test_end(self): """Test :attr:`colour.colorimetry.spectrum.SpectralShape.end` property.""" self.assertEqual(SpectralShape(360, 830, 1).end, 830) self.assertRaises(AssertionError, lambda: SpectralShape(830, 830, 1)) self.assertRaises(AssertionError, lambda: SpectralShape(830, 0, 1)) def test_interval(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.interval` property. """ self.assertEqual(SpectralShape(360, 830, 1).interval, 1) def test_boundaries(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.boundaries` property. """ shape = SpectralShape(400, 700, 1) shape.boundaries = (360, 830) self.assertEqual(shape.start, 360) self.assertEqual(shape.end, 830) def test__hash__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__hash__` method. """ self.assertIsInstance(hash(SpectralShape(0, 10, 0.1)), int) def test__iter__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__iter__` method. """ np.testing.assert_almost_equal( [wavelength for wavelength in SpectralShape(0, 10, 0.1)], np.arange(0, 10 + 0.1, 0.1), ) def test__contains__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__contains__` method. """ self.assertIn(360.1, SpectralShape(360, 830, 0.1)) self.assertNotIn(360.11, SpectralShape(360, 830, 0.1)) self.assertIn(np.array([0.5, 0.6]), SpectralShape(0, 10, 0.1)) self.assertNotIn(np.array([0.5, 0.61]), SpectralShape(0, 10, 0.1)) def test__len__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__len__` method. """ self.assertEqual(len(SpectralShape(0, 10, 0.1)), 101) def test__eq__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__eq__` method. """ self.assertEqual(SpectralShape(0, 10, 0.1), SpectralShape(0, 10, 0.1)) self.assertNotEqual(SpectralShape(0, 10, 0.1), None) def test__ne__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__ne__` method. """ self.assertNotEqual( SpectralShape(0, 10, 0.1), SpectralShape(1, 10, 0.1) ) def test_range(self): """Test :func:`colour.colorimetry.spectrum.SpectralShape.range` method.""" np.testing.assert_almost_equal( [wavelength for wavelength in SpectralShape(0, 10, 0.1)], np.arange(0, 10 + 0.1, 0.1), ) class TestSpectralDistribution(unittest.TestCase): """ Define :class:`colour.colorimetry.spectrum.SpectralDistribution` class unit tests methods. """ def setUp(self): """Initialise the common tests attributes.""" self._sd = SpectralDistribution(DATA_SAMPLE, name="Sample") self._non_uniform_sd = SpectralDistribution( DATA_SAMPLE_NON_UNIFORM, name="Non Uniform Sample", strict_name="Strict Non Uniform Sample", ) self._phi = (1 + np.sqrt(5)) / 2 def test_required_attributes(self): """Test the presence of required attributes.""" required_attributes = ("strict_name", "wavelengths", "values", "shape") for attribute in required_attributes: self.assertIn(attribute, dir(SpectralDistribution)) def test_required_methods(self): """Test the presence of required methods.""" required_methods = ( "__init__", "interpolate", "extrapolate", "align", "trim", "normalise", ) for method in required_methods: self.assertIn(method, dir(SpectralDistribution)) def test_strict_name(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.strict_name` property. """ self.assertEqual(self._sd.strict_name, "Sample") self.assertEqual( self._non_uniform_sd.strict_name, "Strict Non Uniform Sample" ) def test_wavelengths(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.wavelengths` property. """ np.testing.assert_array_equal(self._sd.wavelengths, self._sd.domain) sd = self._sd.copy() sd.wavelengths = sd.wavelengths + 10 np.testing.assert_array_equal(sd.wavelengths, sd.domain) def test_values(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.values` property. """ np.testing.assert_array_equal(self._sd.values, self._sd.range) sd = self._sd.copy() sd.values = sd.values + 10 np.testing.assert_array_equal(sd.values, sd.range) def test_shape(self): """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.shape` property. """ self.assertEqual(self._sd.shape, SpectralShape(340, 820, 20)) def test__init__(self): """ Test :meth:`colour.colorimetry.spectrum.SpectralDistribution.__init__` method. """ np.testing.assert_almost_equal( SpectralDistribution(DATA_SAMPLE).wavelengths, SpectralDistribution( DATA_SAMPLE.values(), SpectralShape(340, 820, 20), ).wavelengths, ) def test_interpolate(self): """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.interpolate` method. """ np.testing.assert_almost_equal( reshape_sd( self._sd, SpectralShape(self._sd.shape.start, self._sd.shape.end, 1), "Interpolate", ).values, DATA_SAMPLE_INTERPOLATED, decimal=7, ) # TODO: Remove statement whenever we make "Scipy" 0.19.0 the minimum # version. # Skipping tests because of "Scipy" 0.19.0 interpolation code changes. if LooseVersion(scipy.__version__) < LooseVersion("0.19.0"): return # pragma: no cover np.testing.assert_allclose( reshape_sd( self._non_uniform_sd, SpectralShape( self._non_uniform_sd.shape.start, self._non_uniform_sd.shape.end, 1, ), "Interpolate", ).values, DATA_SAMPLE_INTERPOLATED_NON_UNIFORM, rtol=0.0000001, atol=0.0000001, ) def test_extrapolate(self): """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.extrapolate` method. """ data = dict(zip(range(25, 35), [0] * 5 + [1] * 5)) sd = SpectralDistribution(data) sd.extrapolate(SpectralShape(10, 50, 5)) self.assertAlmostEqual(sd[10], 0, places=7) self.assertAlmostEqual(sd[50], 1, places=7) sd = SpectralDistribution( np.linspace(0, 1, 10), np.linspace(25, 35, 10) ) sd.extrapolate( SpectralShape(10, 50, 10), extrapolator_kwargs={ "method": "Linear", "left": None, "right": None, }, ) self.assertAlmostEqual(sd[10], -1.5000000000000004, places=7) self.assertAlmostEqual(sd[50], 2.4999999999999964, places=7) def test_align(self): """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.align` method. """ shape = SpectralShape(100, 900, 5) self.assertEqual(self._sd.copy().align(shape).shape, shape) shape = SpectralShape(600, 650, 1) self.assertEqual(self._sd.copy().align(shape).shape, shape) def test_trim(self): """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.trim` method. """ shape = SpectralShape(400, 700, 20) self.assertEqual(self._sd.copy().trim(shape).shape, shape) shape = SpectralShape(200, 900, 1) self.assertEqual(self._sd.copy().trim(shape).shape, self._sd.shape) def test_normalise(self): """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.normalise` method. """ np.testing.assert_almost_equal( self._sd.copy().normalise(100).values, DATA_SAMPLE_NORMALISED ) class TestMultiSpectralDistributions(unittest.TestCase): """ Define :class:`colour.colorimetry.spectrum.MultiSpectralDistributions` class unit tests methods. """ def setUp(self): """Initialise the common tests attributes.""" self._labels = ("x_bar", "y_bar", "z_bar") self._strict_labels = ( "Strict x_bar", "Strict y_bar", "Strict z_bar", ) self._msds = MultiSpectralDistributions( DATA_STANDARD_OBSERVER_2_DEGREE_CIE1931, name="Observer", labels=self._labels, ) sd = SpectralDistribution(DATA_SAMPLE) domain = sd.domain range_ = tstack([sd.values, sd.values, sd.values]) self._sample_msds = MultiSpectralDistributions( range_, domain, name="Sample Observer", labels=self._labels, ) sd = SpectralDistribution(DATA_SAMPLE_NON_UNIFORM) domain = sd.domain range_ = tstack([sd.values, sd.values, sd.values]) self._non_uniform_sample_msds = MultiSpectralDistributions( range_, domain, name="Non Uniform Sample Observer", strict_name="Strict Non Uniform Sample Observer", labels=self._labels, strict_labels=("Strict x_bar", "Strict y_bar", "Strict z_bar"), ) self._phi = (1 + np.sqrt(5)) / 2 def test_required_attributes(self): """Test the presence of required attributes.""" required_attributes = ( "strict_name", "strict_labels", "wavelengths", "values", "shape", ) for attribute in required_attributes: self.assertIn(attribute, dir(MultiSpectralDistributions)) def test_required_methods(self): """Test the presence of required methods.""" required_methods = ( "__init__", "interpolate", "extrapolate", "align", "trim", "normalise", "to_sds", ) for method in required_methods: self.assertIn(method, dir(MultiSpectralDistributions)) def test_strict_name(self): """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.strict_name` property. """ self.assertEqual(self._sample_msds.strict_name, "Sample Observer") self.assertEqual( self._non_uniform_sample_msds.strict_name, "Strict Non Uniform Sample Observer", ) def test_wavelengths(self): """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.wavelengths` property. """ np.testing.assert_array_equal( self._msds.wavelengths, self._msds.domain ) msds = self._msds.copy() msds.wavelengths = msds.wavelengths + 10 np.testing.assert_array_equal(msds.wavelengths, msds.domain) def test_values(self): """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.values` property. """ np.testing.assert_array_equal(self._msds.values, self._msds.range) msds = self._msds.copy() msds.values = msds.values + 10 np.testing.assert_array_equal(msds.values, msds.range) def test_strict_labels(self): """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.\ strict_labels` property. """ self.assertTupleEqual( tuple(self._sample_msds.strict_labels), self._labels ) self.assertEqual( tuple(self._non_uniform_sample_msds.strict_labels), ("Strict x_bar", "Strict y_bar", "Strict z_bar"), ) def test_shape(self): """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.shape` property. """ self.assertEqual(self._msds.shape, SpectralShape(380, 780, 5)) def test__init__(self): """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.__init__` method. """ np.testing.assert_almost_equal( MultiSpectralDistributions(DATA_CMFS).wavelengths, MultiSpectralDistributions( DATA_CMFS.values(), SpectralShape(380, 780, 5), ).wavelengths, ) def test_interpolate(self): """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.interpolate` method. """ # pylint: disable=E1102 msds = reshape_msds( self._sample_msds, SpectralShape( self._sample_msds.shape.start, self._sample_msds.shape.end, 1 ), "Interpolate", ) for signal in msds.signals.values(): np.testing.assert_almost_equal( signal.values, DATA_SAMPLE_INTERPOLATED, decimal=7 ) # TODO: Remove statement whenever we make "Scipy" 0.19.0 the minimum # version. # Skipping tests because of "Scipy" 0.19.0 interpolation code changes. if LooseVersion(scipy.__version__) < LooseVersion("0.19.0"): return # pragma: no cover # pylint: disable=E1102 msds = reshape_msds( self._non_uniform_sample_msds, SpectralShape( self._non_uniform_sample_msds.shape.start, self._non_uniform_sample_msds.shape.end, 1, ), "Interpolate", ) for signal in msds.signals.values(): np.testing.assert_allclose( signal.values, DATA_SAMPLE_INTERPOLATED_NON_UNIFORM, rtol=0.0000001, atol=0.0000001, ) def test_extrapolate(self): """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.extrapolate` method. """ data = dict(zip(range(25, 35), tstack([[0] * 5 + [1] * 5] * 3))) msds = MultiSpectralDistributions(data) msds.extrapolate(SpectralShape(10, 50, 5)) np.testing.assert_almost_equal( msds[10], np.array([0.0, 0.0, 0.0]), decimal=7 ) np.testing.assert_almost_equal( msds[50], np.array([1.0, 1.0, 1.0]), decimal=7 ) msds = MultiSpectralDistributions( tstack([np.linspace(0, 1, 10)] * 3), np.linspace(25, 35, 10) ) msds.extrapolate( SpectralShape(10, 50, 10), extrapolator_kwargs={ "method": "Linear", "left": None, "right": None, }, ) np.testing.assert_almost_equal( msds[10], np.array([-1.5, -1.5, -1.5]), decimal=7 ) np.testing.assert_almost_equal( msds[50], np.array([2.5, 2.5, 2.5]), decimal=7 ) def test_align(self): """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.align` method. """ msds = self._sample_msds.copy() shape = SpectralShape(100, 900, 5) self.assertEqual(msds.align(shape).shape, shape) shape = SpectralShape(600, 650, 1) self.assertEqual(msds.align(shape).shape, shape) def test_trim(self): """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.trim` method. """ shape = SpectralShape(400, 700, 5) self.assertEqual(self._msds.copy().trim(shape).shape, shape) shape = SpectralShape(200, 900, 1) self.assertEqual(self._msds.copy().trim(shape).shape, self._msds.shape) def test_normalise(self): """ Test :func:`colour.colorimetry.spectrum. MultiSpectralDistributions.normalise` method. """ np.testing.assert_almost_equal( self._sample_msds.copy().normalise(100).values, tstack([DATA_SAMPLE_NORMALISED] * 3), ) def test_to_sds(self): """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.to_sds` method. """ sds = self._non_uniform_sample_msds.to_sds() self.assertEqual(len(sds), 3) for i, sd in enumerate(sds): self.assertEqual(sd.name, self._labels[i]) self.assertEqual(sd.strict_name, self._strict_labels[i]) class TestReshapeSd(unittest.TestCase): """ Define :func:`colour.colorimetry.spectrum.reshape_sd` definition unit tests methods. """ def test_reshape_sd(self): """Test :func:`colour.colorimetry.spectrum.reshape_sd` definition.""" sd = SpectralDistribution(DATA_SAMPLE_ABRIDGED) sd_reshaped = reshape_sd(sd) self.assertEqual(sd_reshaped, sd.copy().align(SPECTRAL_SHAPE_DEFAULT)) self.assertEqual(reshape_sd(sd), sd_reshaped) shape = colour.SpectralShape(100, 900, 1) extrapolator_kwargs = { "method": "Constant", "left": 0.05, "right": 0.15, } sd_reshaped = reshape_sd( sd, shape, method="Extrapolate", extrapolator_kwargs=extrapolator_kwargs, ) self.assertEqual( sd_reshaped, sd.copy().extrapolate( shape, extrapolator_kwargs=extrapolator_kwargs ), ) shape = colour.SpectralShape(400, 700, 1) interpolator_kwargs = {"fill_value": 0} sd_reshaped = reshape_sd( sd, shape, method="Interpolate", interpolator=CubicSplineInterpolator, interpolator_kwargs=interpolator_kwargs, ) self.assertEqual( sd_reshaped, sd.copy().interpolate( shape, interpolator=CubicSplineInterpolator, interpolator_kwargs=interpolator_kwargs, ), ) sd = SpectralDistribution(DATA_SAMPLE) shape = colour.SpectralShape(500, 600, 1) sd_reshaped = reshape_sd(sd, shape, method="Trim") self.assertEqual(sd_reshaped, sd.copy().trim(shape)) class TestSdsAndMdsToSds(unittest.TestCase): """ Define :func:`colour.colorimetry.spectrum.sds_and_msds_to_sds` definition unit tests methods. """ def test_sds_and_msds_to_sds(self): """ Test :func:`colour.colorimetry.spectrum.sds_and_msds_to_sds` definition. """ sd_1 = SpectralDistribution(DATA_SAMPLE_ABRIDGED) sd_2 = SpectralDistribution(DATA_SAMPLE_ABRIDGED) multi_sds_1 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) multi_sds_2 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) self.assertEqual( len( sds_and_msds_to_sds( [ sd_1, sd_2, multi_sds_1, multi_sds_2, ] ) ), 8, ) self.assertEqual(len(sds_and_msds_to_sds(multi_sds_1)), 3) class TestSdsAndMsdsToMsds(unittest.TestCase): """ Define :func:`colour.colorimetry.spectrum.sds_and_msds_to_msds` definition unit tests methods. """ def test_sds_and_msds_to_msds(self): """ Test :func:`colour.colorimetry.spectrum.sds_and_msds_to_msds` definition. """ sd_1 = SpectralDistribution(DATA_SAMPLE_ABRIDGED) sd_2 = SpectralDistribution(DATA_SAMPLE_ABRIDGED) multi_sds_1 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) multi_sds_2 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) self.assertEqual(sds_and_msds_to_msds(multi_sds_1), multi_sds_1) multi_sds_0 = sds_and_msds_to_msds([multi_sds_1]) np.testing.assert_array_equal(multi_sds_0.range, multi_sds_1.range) self.assertEqual(sds_and_msds_to_msds([multi_sds_1]), multi_sds_1) shape = SpectralShape(500, 560, 10) self.assertEqual( sds_and_msds_to_msds([sd_1, sd_2, multi_sds_1, multi_sds_2]).shape, shape, ) np.testing.assert_almost_equal( sds_and_msds_to_msds( [sd_1, sd_2, multi_sds_1, multi_sds_2] ).wavelengths, shape.range(), decimal=7, ) np.testing.assert_almost_equal( sds_and_msds_to_msds( [sd_1, sd_2, multi_sds_1, multi_sds_2] ).values, tstack( [sd_1.align(shape).values, sd_2.align(shape).values] + [ sd.values for sd in sds_and_msds_to_sds(multi_sds_1.align(shape)) ] + [ sd.values for sd in sds_and_msds_to_sds(multi_sds_2.align(shape)) ] ), decimal=7, ) if __name__ == "__main__": unittest.main()
27.687624
87
0.63248
6,027
55,929
5.758918
0.259831
0.017546
0.017517
0.061771
0.426748
0.400242
0.361174
0.201706
0.179003
0.162811
0
0.49085
0.246741
55,929
2,019
88
27.701337
0.333025
0.074291
0
0.172126
0
0
0.025573
0.005134
0
0
0
0.000991
0.048839
1
0.026206
false
0
0.005956
0
0.036927
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
6f949785191c10e7a989c8350cfc26a75e30b461
3,967
py
Python
test/test_strings.py
harthur/celestial-snips-app
5dfb86002e0d109c16c8d01ee77b0e909c263270
[ "MIT" ]
1
2021-11-23T02:44:14.000Z
2021-11-23T02:44:14.000Z
test/test_strings.py
harthur/celestial-snips-app
5dfb86002e0d109c16c8d01ee77b0e909c263270
[ "MIT" ]
null
null
null
test/test_strings.py
harthur/celestial-snips-app
5dfb86002e0d109c16c8d01ee77b0e909c263270
[ "MIT" ]
null
null
null
import unittest from celestial import Celestial from strings import CelestialStrings from datetime import datetime import pytest import math class TestCelestial(unittest.TestCase): """Testing the CelestialStrings class for generating celestial answers for TTS to read aloud""" def setUp(self): ... def test_get_local_time_str(self): input = datetime(2019, 12, 1, 13, 24) expected = "08:24AM" self.assertEqual(CelestialStrings._get_local_time_str(input), expected) def test_get_day_str_today(self): start_dt = datetime(2019, 12, 1, 0, 0) event_dt = datetime(2019, 12, 1, 3, 4) expected = "today" self.assertEqual(CelestialStrings._get_day_str(start_dt, event_dt), expected) def test_get_day_str_tomorrow(self): start_dt = datetime(2019, 12, 1, 0, 0) event_dt = datetime(2019, 12, 2, 3, 4) expected = "tomorrow" self.assertEqual(CelestialStrings._get_day_str(start_dt, event_dt), expected) def test_get_day_str_next_week(self): start_dt = datetime(2019, 12, 1, 0, 0) event_dt = datetime(2019, 12, 8, 3, 4) expected = "Saturday, December 07" self.assertEqual(CelestialStrings._get_day_str(start_dt, event_dt), expected) def test_get_cardinal_str(self): self.assertEqual( CelestialStrings._get_cardinal_str(0), "north", "0 degrees is North" ) self.assertEqual( CelestialStrings._get_cardinal_str(50), "northeast", "50 degrees is NE", ) self.assertEqual( CelestialStrings._get_cardinal_str(88), "east", "88 degrees is East" ) self.assertEqual( CelestialStrings._get_cardinal_str(180), "south", "180 degrees is South" ) self.assertEqual( CelestialStrings._get_cardinal_str(350), "north", "350 degrees is North" ) def test_get_cardinal_str_from_abbr(self): self.assertEqual(CelestialStrings._get_cardinal_str_from_abbr("N"), "north") self.assertEqual( CelestialStrings._get_cardinal_str_from_abbr("SSE"), "south southeast" ) def test_get_event_message(self): body = "moon" event = "rise" dt = datetime(2019, 12, 1, 13, 24) event_info = (dt, 120) self.assertEqual( CelestialStrings.get_event_message(body, event, event_info), "The next moonrise is at 08:24AM Sunday, December 01, in the southeast", ) def test_get_event_message_planet(self): body = "venus" event = "set" dt = datetime(2019, 12, 1, 13, 24) event_info = (dt, 120) self.assertEqual( CelestialStrings.get_event_message(body, event, event_info), "The next venus set is at 08:24AM Sunday, December 01, in the southeast", ) def test_get_moon_phase_message(self): phase_info = ("waning", "crescent", 10) self.assertEqual( CelestialStrings.get_moon_phase_message(phase_info), "The moon is a waning crescent", ) def test_get_next_moon_event_message(self): start_dt = datetime(2019, 12, 1, 0, 0) event_dt = datetime(2019, 12, 8, 3, 4) expected = "The next full moon is on Saturday, December 07, at 10:04PM" self.assertEqual( CelestialStrings.get_next_moon_event_message("full", event_dt), expected ) def test_get_next_iss_sighting_message(self): sighting = { "alt_degrees": 66, "approach_dir": "NW", "depart_dir": "SE", "duration_mins": 6, "time": datetime(2020, 2, 7, 23, 51), } expected = "You can see the space station Friday, February 07 at 06:51PM, moving from the northwest to the southeast" self.assertEqual( CelestialStrings.get_next_iss_sighting_message(sighting), expected )
34.198276
125
0.633224
494
3,967
4.834008
0.242915
0.100503
0.207705
0.227806
0.592127
0.51005
0.407035
0.361809
0.31742
0.31742
0
0.061443
0.269725
3,967
115
126
34.495652
0.762858
0.022435
0
0.282609
0
0.01087
0.155733
0
0
0
0
0
0.173913
1
0.130435
false
0
0.065217
0
0.206522
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
6f9bfb5d1846d96697c801d792f6539b53696861
75
py
Python
Lista5/Lista5ex1.py
hugo-paiva/IntroducaoCienciasDaComputacao
a563f2fd5b773acbffaf4c858b86423b1130ae1f
[ "MIT" ]
null
null
null
Lista5/Lista5ex1.py
hugo-paiva/IntroducaoCienciasDaComputacao
a563f2fd5b773acbffaf4c858b86423b1130ae1f
[ "MIT" ]
null
null
null
Lista5/Lista5ex1.py
hugo-paiva/IntroducaoCienciasDaComputacao
a563f2fd5b773acbffaf4c858b86423b1130ae1f
[ "MIT" ]
null
null
null
frase = input().split() for palavra in frase: print(palavra[2], end='')
25
29
0.64
11
75
4.363636
0.818182
0
0
0
0
0
0
0
0
0
0
0.015873
0.16
75
3
29
25
0.746032
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.333333
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
6faf92769295dcd3722767bcf2f74a8c180b6d9e
3,558
py
Python
src/pyshark/packet/fields.py
Lovemma/pyshark
06d00edacf75aa4a9abd77e0c8cab8de33ea27fb
[ "MIT" ]
10
2018-09-13T15:50:43.000Z
2021-01-30T19:55:36.000Z
src/pyshark/packet/fields.py
Lovemma/pyshark
06d00edacf75aa4a9abd77e0c8cab8de33ea27fb
[ "MIT" ]
1
2019-09-09T14:15:34.000Z
2019-09-09T14:15:34.000Z
src/pyshark/packet/fields.py
Lovemma/pyshark
06d00edacf75aa4a9abd77e0c8cab8de33ea27fb
[ "MIT" ]
9
2018-07-24T09:32:55.000Z
2021-01-22T21:23:06.000Z
import binascii from pyshark.packet.common import Pickleable, SlotsPickleable class LayerField(SlotsPickleable): """ Holds all data about a field of a layer, both its actual value and its name and nice representation. """ # Note: We use this object with slots and not just a dict because # it's much more memory-efficient (cuts about a third of the memory). __slots__ = ['name', 'showname', 'raw_value', 'show', 'hide', 'pos', 'size', 'unmaskedvalue'] def __init__(self, name=None, showname=None, value=None, show=None, hide=None, pos=None, size=None, unmaskedvalue=None): self.name = name self.showname = showname self.raw_value = value self.show = show self.pos = pos self.size = size self.unmaskedvalue = unmaskedvalue if hide and hide == 'yes': self.hide = True else: self.hide = False def __repr__(self): return '<LayerField %s: %s>' % (self.name, self.get_default_value()) def get_default_value(self): """ Gets the best 'value' string this field has. """ val = self.show if not val: val = self.raw_value if not val: val = self.showname return val @property def showname_value(self): """ For fields which do not contain a normal value, we attempt to take their value from the showname. """ if self.showname and ': ' in self.showname: return self.showname.split(': ', 1)[1] @property def showname_key(self): if self.showname and ': ' in self.showname: return self.showname.split(': ', 1)[0] @property def binary_value(self): """ Converts this field to binary (assuming it's a binary string) """ return binascii.unhexlify(self.raw_value) @property def int_value(self): """ Returns the int value of this field (assuming it's an integer integer). """ return int(self.raw_value) @property def hex_value(self): """ Returns the int value of this field if it's in base 16 (either as a normal number or in a "0xFFFF"-style hex value) """ return int(self.raw_value, 16) base16_value = hex_value class LayerFieldsContainer(str, Pickleable): """ An object which contains one or more fields (of the same name). When accessing member, such as showname, raw_value, etc. the appropriate member of the main (first) field saved in this container will be shown. """ def __new__(cls, main_field, *args, **kwargs): value = main_field.get_default_value() if value is None: value = '' obj = str.__new__(cls, value, *args, **kwargs) obj.fields = [main_field] return obj def __dir__(self): return dir(type(self)) + list(self.__dict__.keys()) + dir(self.main_field) def add_field(self, field): self.fields.append(field) @property def main_field(self): return self.fields[0] @property def alternate_fields(self): """ Return the alternate values of this field containers (non-main ones). """ return self.fields[1:] @property def all_fields(self): """ Returns all fields in a list, the main field followed by the alternate fields. """ return self.fields def __getattr__(self, item): return getattr(self.main_field, item)
29.65
124
0.603991
459
3,558
4.54902
0.313725
0.045977
0.028736
0.010536
0.139847
0.08908
0.08908
0.08908
0.08908
0.052682
0
0.005192
0.296234
3,558
120
125
29.65
0.828674
0.27656
0
0.181818
0
0
0.03339
0
0
0
0
0
0
1
0.227273
false
0
0.030303
0.060606
0.515152
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
6fb0bb046f2c82f4fc248ab9913d7e957fa16a08
1,397
py
Python
test_service.py
cmput401-fall2018/web-app-ci-cd-with-travis-ci-derek-repka
c724a2b921fdb1e6ba1200b477a4add291941107
[ "MIT" ]
null
null
null
test_service.py
cmput401-fall2018/web-app-ci-cd-with-travis-ci-derek-repka
c724a2b921fdb1e6ba1200b477a4add291941107
[ "MIT" ]
4
2018-10-09T17:16:38.000Z
2021-06-10T20:56:30.000Z
test_service.py
cmput401-fall2018/web-app-ci-cd-with-travis-ci-derek-repka
c724a2b921fdb1e6ba1200b477a4add291941107
[ "MIT" ]
null
null
null
from service import Service from unittest import TestCase from mock import patch import sys class TestService(TestCase): @patch('service.Service.bad_random', return_value=10) def test_bad_random(self, bad_random): self.assertEqual(bad_random(), 10) @patch('service.Service.bad_random', return_value=10) def test_divide(self, bad_random): x = Service() self.assertEqual(x.divide(2),5) self.assertEqual(x.divide(-2),-5) bad_random.return_value=-10 self.assertEqual(x.divide(2),-5) bad_random.return_value=0 self.assertEqual(x.divide(sys.maxsize),0) self.assertEqual(x.divide(-sys.maxsize+1),0) def test_abs_plus(self): x=Service() self.assertEqual(x.abs_plus(10),11) self.assertEqual(x.abs_plus(0),1) self.assertEqual(x.abs_plus(-10),11) self.assertEqual(x.abs_plus(-sys.maxsize+1),sys.maxsize) self.assertEqual(x.abs_plus(10),11) @patch('service.Service.bad_random', return_value=10) def test_complicated_function(self, bad_random): x = Service() results = x.complicated_function(20) self.assertEqual(results[0], 0.5) self.assertEqual(results[1], 0) bad_random.return_value=-13 results = x.complicated_function(-1) self.assertEqual(results[0], 13) self.assertEqual(results[1], 1) bad_random.return_value=0 results = x.complicated_function(sys.maxsize) self.assertEqual(results[0], 0) self.assertEqual(results[1], 0)
27.94
58
0.740873
215
1,397
4.660465
0.15814
0.254491
0.159681
0.139721
0.616766
0.448104
0.424152
0.331337
0.331337
0.331337
0
0.044426
0.113815
1,397
50
59
27.94
0.764943
0
0
0.307692
0
0
0.055794
0.055794
0
0
0
0
0.435897
1
0.102564
false
0
0.102564
0
0.230769
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
1
0
0
0
0
0
0
0
0
0
2
6fb2b10f3d4883634b84a549a2f3de0c0993ed24
1,512
py
Python
libweasyl/libweasyl/alembic/versions/eff79a07a88d_use_timestamp_column_for_latest_.py
akash143143/weasyl
be42a2313e657e97c4a48432379e37b6a3d4a4af
[ "Apache-2.0" ]
111
2016-05-18T04:18:18.000Z
2021-11-03T02:05:19.000Z
libweasyl/libweasyl/alembic/versions/eff79a07a88d_use_timestamp_column_for_latest_.py
akash143143/weasyl
be42a2313e657e97c4a48432379e37b6a3d4a4af
[ "Apache-2.0" ]
1,103
2016-05-29T05:17:53.000Z
2022-03-31T18:12:40.000Z
libweasyl/libweasyl/alembic/versions/eff79a07a88d_use_timestamp_column_for_latest_.py
TheWug/weasyl
a568a542cc58c11e30621fb672c701531d4306a8
[ "Apache-2.0" ]
47
2016-05-29T20:48:37.000Z
2021-11-12T09:40:40.000Z
"""Use TIMESTAMP column for latest submission Revision ID: eff79a07a88d Revises: 83e6b2a46191 Create Date: 2017-01-08 22:20:43.814375 """ # revision identifiers, used by Alembic. revision = 'eff79a07a88d' down_revision = '83e6b2a46191' from alembic import op # lgtm[py/unused-import] import sqlalchemy as sa # lgtm[py/unused-import] import libweasyl from libweasyl.legacy import UNIXTIME_OFFSET def upgrade(): op.alter_column( 'profile', 'latest_submission_time', new_column_name='latest_submission_time_old', ) op.add_column( 'profile', sa.Column('latest_submission_time', libweasyl.models.helpers.ArrowColumn(), nullable=False, server_default='epoch'), ) op.execute( "UPDATE profile SET latest_submission_time = TIMESTAMP WITHOUT TIME ZONE 'epoch' + " "(latest_submission_time_old - %d) * INTERVAL '1 second'" % (UNIXTIME_OFFSET,)) op.drop_column('profile', 'latest_submission_time_old') def downgrade(): op.alter_column( 'profile', 'latest_submission_time', new_column_name='latest_submission_time_new', ) op.add_column( 'profile', sa.Column('latest_submission_time', libweasyl.models.helpers.WeasylTimestampColumn(), nullable=False, server_default='0'), ) op.execute( "UPDATE profile SET latest_submission_time = extract(epoch from latest_submission_time_new) + %d" % (UNIXTIME_OFFSET,)) op.drop_column('profile', 'latest_submission_time_new')
30.857143
130
0.707011
179
1,512
5.715084
0.385475
0.203324
0.234604
0.112414
0.517107
0.470186
0.467253
0.467253
0.379277
0.27566
0
0.042105
0.183201
1,512
48
131
31.5
0.786235
0.143519
0
0.363636
0
0
0.385992
0.225681
0
0
0
0
0
1
0.060606
false
0
0.121212
0
0.181818
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
6fb7c5d5fb34e77d36095b18c408e6edbe184b8f
2,952
py
Python
experiments/2d_shallowwater/gen.py
flabowski/POD-UQNN
1c81be432e69d24ae894828f42918fbc1fe54bc1
[ "MIT" ]
15
2020-05-29T11:42:14.000Z
2022-03-20T03:53:44.000Z
experiments/2d_shallowwater/gen.py
flabowski/POD-UQNN
1c81be432e69d24ae894828f42918fbc1fe54bc1
[ "MIT" ]
null
null
null
experiments/2d_shallowwater/gen.py
flabowski/POD-UQNN
1c81be432e69d24ae894828f42918fbc1fe54bc1
[ "MIT" ]
11
2020-06-09T01:16:22.000Z
2021-04-27T08:53:02.000Z
"""POD-NN modeling for 1D, unsteady Burger Equation.""" #%% Imports import sys import os import pickle import numpy as np sys.path.append(os.path.join("..", "..")) from poduqnn.podnnmodel import PodnnModel from poduqnn.mesh import read_multi_space_sol_input_mesh from poduqnn.handling import clean_dir, split_dataset from hyperparams import HP as hp resdir = "cache" clean_dir(resdir) # Getting data from the files # fake_x = np.zeros(hp["n_s"] + hp["n_s_tst"]) # test_size = hp["n_s_tst"] / (hp["n_s"] + hp["n_s_tst"]) # train_tst_idx = split_dataset(fake_x, fake_x, test_size, idx_only=True) train_tst_idx = ([129, 13, 161, 10, 3, 4, 68, 19, 108, 63, 62, 147, 117, 113, 165, 80, 124, 33, 41, 37, 79, 184, 154, 83, 102, 190, 195, 148, 46, 114, 16, 155, 121, 104, 120, 58, 53, 78, 160, 193, 126, 115, 95, 127, 166, 131, 49, 100, 84, 35, 12, 27, 118, 167, 66, 56, 106, 175, 143, 97, 87, 1, 183, 111, 36, 158, 153, 199, 17, 31, 177, 194, 182, 59, 187, 130, 163, 92, 48, 96, 82, 6, 123, 98, 192, 43, 26, 181, 170, 134, 72, 50, 24, 174, 122, 103, 71, 138, 110, 7, 65, 51, 28, 173, 172, 34, 90, 119, 185, 15, 186, 101, 85, 60, 75, 39, 38, 5, 141, 89, 57, 144, 64, 67, 171, 157, 94, 70, 142, 54, 74, 146, 191, 112, 107, 189, 30, 32, 133, 169, 151, 23, 21, 99, 2, 22, 116, 91, 145, 178, 137, 135, 40, 73, 47, 52, 25, 93, 128, 88, 109, 44, 29, 198, 159, 125, 11, 45, 197, 149, 69, 188, 164, 0, 18, 176, 9, 168, 77, 132], [76, 42, 179, 61, 105, 136, 86, 196, 8, 14, 139, 20, 150, 152, 180, 162, 140, 81, 55, 156]) with open(os.path.join("cache", "train_tst_idx.pkl"), "wb") as f: pickle.dump(train_tst_idx, f) datadir = "data" mu_path = os.path.join(datadir, "INPUT_MONTE_CARLO.dat") # x_mesh, connectivity, X_v, U = \ # read_multi_space_sol_input_mesh(hp["n_s"], 1, 1, train_tst_idx[0], # hp["mesh_idx"], datadir, mu_path, # hp["mu_idx"]) # np.save(os.path.join("cache", "x_mesh.npy"), x_mesh) # np.save(os.path.join("cache", "connectivity.npy"), connectivity) # np.save(os.path.join("cache", "X_v.npy"), X_v) # np.save(os.path.join("cache", "U.npy"), U) x_mesh = np.load(os.path.join("cache", "x_mesh.npy")) connectivity = np.load(os.path.join("cache", "connectivity.npy")) X_v = np.load(os.path.join("cache", "X_v.npy")) U = np.load(os.path.join("cache", "U.npy")) # x_mesh = np.load(os.path.join("cache", "x_mesh.npy")) # connectivity = np.load(os.path.join("cache", "connectivity.npy")) # X_v = np.load(os.path.join("cache", "X_v.npy")) # U = np.load(os.path.join("cache", "U.npy")) #%% Init the model model = PodnnModel(resdir, hp["n_v"], x_mesh, hp["n_t"]) #%% Generate the dataset from the mesh and params X_v_train, v_train, \ X_v_val, v_val, \ U_val = model.convert_multigpu_data(U, X_v, hp["train_val"], hp["eps"]) model.initVNNs(hp["n_M"], hp["h_layers"], hp["lr"], hp["lambda"], hp["adv_eps"], hp["soft_0"], hp["norm"])
50.033898
910
0.618225
552
2,952
3.166667
0.523551
0.051487
0.085812
0.111556
0.264302
0.264302
0.199657
0.155606
0.155606
0.155606
0
0.203872
0.177507
2,952
58
911
50.896552
0.516063
0.332656
0
0
0
0
0.087359
0.010791
0
0
0
0
0
1
0
false
0
0.307692
0
0.307692
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
0
0
0
0
0
1
0
0
0
0
2
6fb8b1b58b2f38e1b4575b537fc9d0698a19d441
565
py
Python
day1/ex4.py
dsky1990/python_30days
3a9d8a29bd32979be1f4ef01be44999073dab5c4
[ "MIT" ]
1
2018-10-20T14:45:31.000Z
2018-10-20T14:45:31.000Z
day1/ex4.py
dsky1990/python_30days
3a9d8a29bd32979be1f4ef01be44999073dab5c4
[ "MIT" ]
null
null
null
day1/ex4.py
dsky1990/python_30days
3a9d8a29bd32979be1f4ef01be44999073dab5c4
[ "MIT" ]
null
null
null
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars -drivers cars_driven = drivers carpool_carpacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven print("There are", cars, "cars available") print("There are only", drivers, "drivers available") print("There will be", cars_not_driven, "empty cars today") print("We can transport", carpool_carpacity, "people today") print("We have", passengers, "to carpool today") print("We need to put about", average_passengers_per_car, "people in each car")
37.666667
79
0.771681
87
565
4.770115
0.425287
0.072289
0.086747
0.053012
0
0
0
0
0
0
0
0.018145
0.122124
565
15
79
37.666667
0.818548
0
0
0
0
0
0.303887
0
0
0
0
0
0
1
0
false
0.285714
0
0
0
0.428571
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
1
0
2
6fbc9ebec03dc29c3a7fc5b24ded057f188d61a0
1,401
py
Python
FPN_Backend/api_utility/validators.py
DeeMATT/friendly-invention
c308168b088ad8e65ab6eddcdba22552a9c6987a
[ "MIT" ]
null
null
null
FPN_Backend/api_utility/validators.py
DeeMATT/friendly-invention
c308168b088ad8e65ab6eddcdba22552a9c6987a
[ "MIT" ]
null
null
null
FPN_Backend/api_utility/validators.py
DeeMATT/friendly-invention
c308168b088ad8e65ab6eddcdba22552a9c6987a
[ "MIT" ]
null
null
null
import re from data_transformer.views import stringIsInteger def validateEmailFormat(email): emailPattern = r'^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$' if(re.search(emailPattern, email)): return True return False def validatePhoneFormat(phone): if not stringIsInteger(phone): return False # valid phone format for Nigeria without international dialing code e.g 081******** if phone.startswith('+'): return len(phone) == 14 elif phone.startswith('234'): return len(phone) == 13 else: return len(phone) == 11 def validateThatAStringIsClean(value): regex = re.compile(r'[@_!#$%^&*()<>?/\|}{~:]') return (regex.search(value) == None) def validateThatStringIsEmpty(value): return (len(value.strip()) > 0) def validateThatStringIsEmptyAndClean(value): is_clean = (re.compile(r'[@_!#$%^&*()<>?/\|}{~:]').search(value) == None) not_empty = (len(value.strip()) != 0) return (is_clean and not_empty) def validateThatListIsEmpty(value): return (len(value) > 0) def validateKeys(payload, requiredKeys): # extract keys from payload payloadKeys = list(payload.keys()) # check if extracted keys is present in requiredKeys missingKeys = [] for key in requiredKeys: if key not in payloadKeys: missingKeys.append(key) return missingKeys
24.155172
87
0.635974
161
1,401
5.478261
0.459627
0.05102
0.047619
0.013605
0.017007
0.017007
0
0
0
0
0
0.018885
0.206281
1,401
57
88
24.578947
0.774281
0.112777
0
0.058824
0
0.029412
0.087167
0.083939
0
0
0
0
0
1
0.205882
false
0
0.058824
0.058824
0.588235
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
6fca5a30c5488af2b1fdbc0fc7967e56d0f30371
619
py
Python
ypricemagic/magic.py
cartercarlson/ypricemagic
f17fec155db7fb44ee624cd6e75193f17c6238cf
[ "MIT" ]
1
2022-03-28T16:07:07.000Z
2022-03-28T16:07:07.000Z
ypricemagic/magic.py
cartercarlson/ypricemagic
f17fec155db7fb44ee624cd6e75193f17c6238cf
[ "MIT" ]
null
null
null
ypricemagic/magic.py
cartercarlson/ypricemagic
f17fec155db7fb44ee624cd6e75193f17c6238cf
[ "MIT" ]
null
null
null
import logging from typing import Optional from y import magic from y.datatypes import UsdPrice from y.typing import AnyAddressType, Block logger = logging.getLogger(__name__) def get_price(token: AnyAddressType, block: Optional[Block] = None) -> UsdPrice: logger.warn('ypricemagic is in the process of being migrated to y.' 'y can do all of the same old stuff you expect, plus some new stuff.' 'This method still works for now, but will be removed soon.' 'Please update your scripts to use `y.get_price(token, block)`.') return magic.get_price(token, block)
36.411765
85
0.704362
90
619
4.766667
0.633333
0.034965
0.090909
0.083916
0
0
0
0
0
0
0
0
0.22294
619
16
86
38.6875
0.891892
0
0
0
0
0
0.38835
0
0
0
0
0
0
1
0.083333
false
0
0.416667
0
0.583333
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
6fe49f0a6289892c3834db40f35fd362645dee89
6,966
py
Python
botnet/fabfile.py
MrScytheLULZ/Simple-python-cnc
23adc7ae553239a0c23da63d6eb97da24054fd93
[ "MIT" ]
23
2016-05-31T22:42:07.000Z
2022-03-30T13:37:44.000Z
botnet/fabfile.py
MrScytheLULZ/Simple-python-cnc
23adc7ae553239a0c23da63d6eb97da24054fd93
[ "MIT" ]
null
null
null
botnet/fabfile.py
MrScytheLULZ/Simple-python-cnc
23adc7ae553239a0c23da63d6eb97da24054fd93
[ "MIT" ]
18
2017-03-15T08:22:33.000Z
2020-11-14T23:37:06.000Z
import os from fabric.api import env, run, sudo, execute, local, settings, \ hide, open_shell, parallel, serial, put from fabric.decorators import hosts from fabric.contrib.console import confirm import fabric.colors as fab_col import paramiko import getpass from tabulate import tabulate file_hosts = "hosts.txt" paramiko.util.log_to_file("paramiko.log") env.colorize_errors = True # The selected hosts are the hosts in env (at the beginning) selected_hosts = env.hosts running_hosts = {} env.connection_attempts = 2 # env.skip_bad_hosts = True def load_hosts(): """ Load hosts from hosts.txt. A host can either be in form username@host[:port] password or username@host[:port] If no port is specified, port 22 is selected. """ with open(file_hosts, "r") as f: data = f.readlines() for line in data: try: host, password = line.strip().split() except ValueError: host = line.strip() password = None if len(host.split(':')) == 1: host = host + ":22" env.hosts.append(host) if password is not None: env.passwords[host] = password.strip() env.hosts = list(set(env.hosts)) # Remove duplicates def add_host(): """ Add a new host to the running hosts. The user can decide whether to add the host also to the external hosts.txt file. """ name = raw_input("Username: ") host = raw_input("Host: ") port = input("Port: ") new_host = name + "@" + host + ":" + str(port) selected_hosts.append(new_host) password = None if confirm("Authenticate using a password? "): password = getpass.getpass("Password: ").strip() env.passwords[new_host] = password # Append the new host to the hosts file if confirm("Add the new host to the hosts file? "): if password is not None: line = new_host + " " + password + "\n" else: line = new_host + "\n" with open(file_hosts, 'a') as f: f.write(line) def print_hosts(): """ Print selected hosts. If hosts haven't been hand-selected yet, all hosts are selected. """ hosts = map(lambda x: [x, env.passwords.get(x, None)], selected_hosts) print(fab_col.green(tabulate(hosts, ["Host", "Password"]))) def check_hosts(): """ Check if hosts are active or not and print the result. """ global running_hosts running_hosts = dict() for host in selected_hosts: print(fab_col.magenta("\nPing host %d of %d" % (selected_hosts.index(host) + 1, len(selected_hosts)))) response = os.system("ping -c 1 " + host.split("@")[1].split(":")[0]) if response == 0: running_hosts[host] = True else: running_hosts[host] = False # Convert running_hosts in order to print it as table mylist = map(lambda index: [index[0], str(index[1])], running_hosts.items()) print(fab_col.green(tabulate(mylist, ["Host", "Running"]))) def select_running_hosts(): """ Select all active hosts. """ global selected_hosts with hide('stdout'): check_hosts() host_up = filter(lambda x: running_hosts.get(x, False), running_hosts.keys()) selected_hosts = host_up def choose_hosts(): """ Select the hosts to be used. """ global selected_hosts mylist = map(lambda (num, h): [num, h], enumerate(env.hosts)) print(fab_col.blue("Select Hosts (space-separated):")) print(fab_col.blue(tabulate(mylist, ["Number", "Host"]))) choices = raw_input("> ").split() # Avoid letters in string index choices = filter(lambda x: x.isdigit(), choices) # Convert to int list choices = map(int, choices) # Avoid IndexError choices = filter(lambda x: x < len(env.hosts), choices) # Remove duplicates choices = list(set(choices)) # If no hosts are selected, keep the current hosts if len(choices) == 0: return # Get only selected hosts selected_hosts = map(lambda i: env.hosts[i], choices) def run_locally(cmd=None): """ Execute a command locally. """ if cmd is None: cmd = raw_input("Insert command: ") with settings(warn_only=True): local(cmd) # This function cannot have the parallel decorator since # a sudo command must receive the user password @serial def _execute_sudo(command): """ Execute a sudo command on a host. Returns: The results of the execution. """ with settings(warn_only=True): return sudo(command[4:].strip(), shell=True) @parallel def _execute_command(command): """ Execute a command on a host. Returns: The results of the execution. """ with settings(warn_only=True): try: return run(command) except: print(fab_col.red("Error execution in host %s" % env.host)) return None @parallel def run_command(cmd=None): """ Execute a command on hosts. """ if cmd is None: cmd = raw_input("Insert command: ") if cmd.strip()[:4] == "sudo": execute(_execute_sudo, cmd, hosts=selected_hosts) else: execute(_execute_command, cmd, hosts=selected_hosts) @hosts(selected_hosts) def execute_script(): """ Execute a script file. """ # Attention to script name. # Add security checks script_file = raw_input("Name of the script: ") remote_path = "~/" if len(script_file) < 4 or ".." in script_file: # Invalid script print(fab_col.red("Error. Invalid script name.")) return for h in selected_hosts: with settings(host_string=h): with hide('running'): put(script_file, remote_path, mode=777) # Remove the path from the name of the script script_file = script_file.split("/")[-1] # Execution extension = script_file.split(".")[-1] if extension == script_file: print(fab_col.red("Invalid script")) return if extension == 'py': run_command("python " + remote_path + script_file) elif extension == "sh" or extension == "bash": run_command("bash " + remote_path + script_file) else: print(fab_col.red("Extension not supported")) # Delete the script with hide('running', 'stdout'): run_command("rm -f " + remote_path + script_file) def open_sh(): """ Open a shell on a host. """ mylist = map(lambda (num, h): [num, h], enumerate(selected_hosts)) print(fab_col.blue(tabulate(mylist, ["Number", "Host"]))) try: n = input("Open shell in host number: ") h = selected_hosts[n] execute(open_shell, host=h) except (NameError, IndexError): print(fab_col.red("Error: invalid host selection.")) print(fab_col.red("Shell not opened."))
28.904564
80
0.611111
913
6,966
4.547645
0.226725
0.06262
0.031792
0.020231
0.177505
0.109345
0.096821
0.096821
0.050096
0.033237
0
0.004315
0.268016
6,966
240
81
29.025
0.809963
0.083836
0
0.190141
0
0
0.095987
0
0
0
0
0
0
0
null
null
0.091549
0.056338
null
null
0.091549
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
1
0
0
0
0
0
2
6ff1787c0118af1f7695392c705c973f44490257
352
py
Python
src/rics/utility/perf/__init__.py
rsundqvist/rics
c67ff6703facb3170535dcf173d7e55734cedbc6
[ "MIT" ]
1
2022-02-24T22:12:13.000Z
2022-02-24T22:12:13.000Z
src/rics/utility/perf/__init__.py
rsundqvist/rics
c67ff6703facb3170535dcf173d7e55734cedbc6
[ "MIT" ]
26
2022-02-24T21:08:51.000Z
2022-03-19T19:55:26.000Z
src/rics/utility/perf/__init__.py
rsundqvist/rics
c67ff6703facb3170535dcf173d7e55734cedbc6
[ "MIT" ]
null
null
null
"""Performance testing utility.""" from ._format_perf_counter import format_perf_counter from ._multi_case_timer import MultiCaseTimer from ._util import plot_run, to_dataframe from ._wrappers import run_multivariate_test __all__ = [ "MultiCaseTimer", "run_multivariate_test", "format_perf_counter", "plot_run", "to_dataframe", ]
23.466667
53
0.769886
42
352
5.880952
0.5
0.121457
0.206478
0.145749
0
0
0
0
0
0
0
0
0.144886
352
14
54
25.142857
0.820598
0.079545
0
0
0
0
0.232704
0.066038
0
0
0
0
0
1
0
false
0
0.363636
0
0.363636
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
2
b50e4ff7686cf0dbd4629ae146083491535bb7be
1,028
py
Python
precompressed/context_processors.py
EightMedia/django-precompressed
1b135b4784a96948237f93bf0648d3ab747fcfb3
[ "MIT" ]
4
2015-05-05T06:58:35.000Z
2018-10-15T18:53:50.000Z
precompressed/context_processors.py
EightMedia/django-precompressed
1b135b4784a96948237f93bf0648d3ab747fcfb3
[ "MIT" ]
2
2015-02-04T10:48:00.000Z
2020-01-27T15:36:39.000Z
precompressed/context_processors.py
EightMedia/django-precompressed
1b135b4784a96948237f93bf0648d3ab747fcfb3
[ "MIT" ]
1
2019-02-20T20:40:04.000Z
2019-02-20T20:40:04.000Z
# ***************************************************************************** # precompressed/context_processors.py # ***************************************************************************** """ A set of request processors that return dictionaries to be merged into a template context. Each function takes the request object as its only parameter and returns a dictionary to add to the context. These are referenced from the setting TEMPLATE_CONTEXT_PROCESSORS and used by RequestContext. """ from __future__ import absolute_import, division from __future__ import print_function, unicode_literals from precompressed import utils # ***************************************************************************** # accepts_gzip # ***************************************************************************** def accepts_gzip(request): """ defines ACCEPTS_GZIP -- a boolean which reflects whether the request accepts Content-Type: gzip. """ return {'ACCEPTS_GZIP': utils.accepts_gzip(request)}
30.235294
79
0.539883
95
1,028
5.642105
0.578947
0.102612
0.059701
0
0
0
0
0
0
0
0
0
0.120623
1,028
33
80
31.151515
0.59292
0.73249
0
0
0
0
0.049793
0
0
0
0
0
0
1
0.2
false
0
0.6
0
1
0.2
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
2
82f077676382d093577f0c067da14ea95e4000cd
1,557
py
Python
core_get/actions/module.py
core-get/core-get
8fb960e4e51d0d46b5e3b2f4832eb4a39e0e60f7
[ "MIT" ]
null
null
null
core_get/actions/module.py
core-get/core-get
8fb960e4e51d0d46b5e3b2f4832eb4a39e0e60f7
[ "MIT" ]
null
null
null
core_get/actions/module.py
core-get/core-get
8fb960e4e51d0d46b5e3b2f4832eb4a39e0e60f7
[ "MIT" ]
null
null
null
from typing import Dict, Type from injector import Module, Binder from core_get.actions.action import Action from core_get.actions.init.init import Init from core_get.actions.init.init_options import InitOptions from core_get.actions.install.install import Install from core_get.actions.install.install_options import InstallOptions from core_get.actions.login.login import Login from core_get.actions.login.login_options import LoginOptions from core_get.actions.package.package import Package from core_get.actions.package.package_options import PackageOptions from core_get.actions.publish.publish import Publish from core_get.actions.publish.publish_options import PublishOptions from core_get.actions.remove.remove import Remove from core_get.actions.remove.remove_options import RemoveOptions from core_get.actions.test.test import Test from core_get.actions.test.test_options import TestOptions from core_get.actions.yank.yank import Yank from core_get.actions.yank.yank_options import YankOptions from core_get.options.options import Options from core_get.utils.injection import MultiMapClassProvider class ActionsModule(Module): def configure(self, binder: Binder) -> None: binder.multibind(Dict[Type[Options], Action], to=MultiMapClassProvider({ InitOptions: Init, InstallOptions: Install, LoginOptions: Login, PackageOptions: Package, PublishOptions: Publish, RemoveOptions: Remove, TestOptions: Test, YankOptions: Yank, }))
39.923077
80
0.787412
200
1,557
5.995
0.2
0.126772
0.174312
0.255213
0.386989
0.386989
0
0
0
0
0
0
0.150931
1,557
38
81
40.973684
0.906959
0
0
0
0
0
0
0
0
0
0
0
0
1
0.030303
false
0
0.636364
0
0.69697
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
82fd84aa8cc3e3cc7d56b2efc824a18ff2e55d25
368
py
Python
tests/Parser/701isNotSubtitleFile_test.py
Bas-Man/TVShowFile
2f341c97dcbe52eee0c0e71752173c9e9442450c
[ "MIT" ]
null
null
null
tests/Parser/701isNotSubtitleFile_test.py
Bas-Man/TVShowFile
2f341c97dcbe52eee0c0e71752173c9e9442450c
[ "MIT" ]
null
null
null
tests/Parser/701isNotSubtitleFile_test.py
Bas-Man/TVShowFile
2f341c97dcbe52eee0c0e71752173c9e9442450c
[ "MIT" ]
null
null
null
import unittest from context import parser class TVShowFileParserTests(unittest.TestCase): def setUp(self): self.filename = parser.Parser("test.2018.S01E01E02.mkv") def tearDown(self): self.filename = None def testisSubtitleFileSRT(self): self.assertFalse(self.filename.isSubs) if __name__ == '__main__': unittest.main()
19.368421
64
0.69837
40
368
6.225
0.6
0.096386
0.128514
0
0
0
0
0
0
0
0
0.033898
0.19837
368
18
65
20.444444
0.810169
0
0
0
0
0
0.084239
0.0625
0
0
0
0
0.090909
1
0.272727
false
0
0.181818
0
0.545455
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
2
d2013debcc235b195c7f8a356464f5f2511b9b80
4,173
py
Python
service_matcher_app/service_matcher/models.py
City-of-Turku/PaohServiceMatchEngine
39f580003f9c0d10708acd93644f796f764ec2f0
[ "MIT" ]
null
null
null
service_matcher_app/service_matcher/models.py
City-of-Turku/PaohServiceMatchEngine
39f580003f9c0d10708acd93644f796f764ec2f0
[ "MIT" ]
null
null
null
service_matcher_app/service_matcher/models.py
City-of-Turku/PaohServiceMatchEngine
39f580003f9c0d10708acd93644f796f764ec2f0
[ "MIT" ]
null
null
null
from datetime import datetime from pydantic import BaseModel from typing import Optional, List from fastapi import Query class Service(BaseModel): """ A class for single service """ id: str ptvId: Optional[str] = None type: Optional[str] = None subtype: Optional[str] = None organizations: list name: dict descriptions: dict requirement: dict targetGroups: dict serviceClasses: dict lifeEvents: dict areas: dict lastUpdated: datetime nameAutoTranslated: dict class ServiceClass(BaseModel): """ A class for single service class """ name: str code: str class ServiceChannel(BaseModel): """ A class for single service channel """ id: str ptvId: Optional[str] = None type: Optional[str] = None areaType: Optional[str] = None organizationId: Optional[str] = None serviceIds: list name: dict descriptions: dict webPages: dict emails: dict phoneNumbers: dict areas: dict addresses: dict channelUrls: dict lastUpdated: datetime class ServiceQuery(BaseModel): """ A class for request payoad for service filtering """ include_channels: Optional[bool] = False priorization: Optional[str] = Query("local", regex="^(local|national)$") municipalities: Optional[List[str]] = [] life_events: Optional[List[str]] = [] service_classes: Optional[List[str]] = [] limit_k: Optional[int] = 20 translate_missing_texts: Optional[bool] = False class ServiceRecommendQuery(BaseModel): """ A class for payload for free text service recommendation """ need_text: str municipalities: Optional[List[str]] = [] life_events: Optional[List[str]] = [] service_classes: Optional[List[str]] = [] top_k: Optional[int] = 20 score_threshold: Optional[float] = 0.0 text_recommender: Optional[str] = Query("all", regex="^(nlp|lexical|all)$") language: Optional[str] = Query("fi", regex="^(fi|en|sv)$") translate_missing_texts: Optional[bool] = False class ServiceRecommendConversationQuery(BaseModel): """ A class for payload for service recommendation based on conversation """ mode: Optional[str] = Query("infer", regex="^(search|intent|conversation|infer)$") municipalities: Optional[List[str]] = [] life_events: Optional[List[str]] = [] service_classes: Optional[List[str]] = [] top_k: Optional[int] = 20 score_threshold: Optional[float] = 0.0 text_recommender: Optional[str] = Query("all", regex="^(nlp|lexical|all)$") language: Optional[str] = Query("fi", regex="^(fi|en|sv)$") translate_missing_texts: Optional[bool] = False class ServiceRecommendIntentQuery(BaseModel): """ A class for payload for intent based service recommendation """ intent: str municipalities: Optional[List[str]] = [] life_events: Optional[List[str]] = [] service_classes: Optional[List[str]] = [] translate_missing_texts: Optional[bool] = False class ServiceRecommendIntentAndOptionsQuery(BaseModel): """ A class for payload for intent and options based service recommendation, options can be got from database or can be overwritten in the interface """ intent: str municipalities: Optional[List[str]] = [] life_events: Optional[List[str]] = [] service_classes: Optional[List[str]] = [] score_threshold: Optional[float] = 0.0 need_text: Optional[str] = None text_recommender: Optional[str] = Query("all", regex="^(nlp|lexical|all)$") language: Optional[str] = Query("fi", regex="^(fi|en|sv)$") priorization: Optional[str] = Query("local", regex="^(local|national)$") limit_k: Optional[int] = 20 translate_missing_texts: Optional[bool] = False class ServiceClassRecommendQuery(BaseModel): """ A class for payload for free text service class recommendation """ need_text: str top_k: Optional[int] = 20 class ServiceClassRecommendConversationQuery(BaseModel): """ A class for payload for service class recommendation based on conversation """ top_k: Optional[int] = 20
29.595745
148
0.671699
472
4,173
5.862288
0.230932
0.067582
0.081316
0.065052
0.606072
0.579689
0.52837
0.462956
0.426093
0.395013
0
0.005456
0.209442
4,173
140
149
29.807143
0.833283
0.146657
0
0.617978
0
0
0.057353
0.010588
0
0
0
0
0
1
0
true
0
0.044944
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
1
0
0
2
d2037084e3cebaba8f3eced7b0c24bf337957571
1,926
py
Python
build/scripts/gen_mx_table.py
r1nadeg/04_catboost
6755bbbd1496540b92ded57eea1974f64bef87c5
[ "Apache-2.0" ]
null
null
null
build/scripts/gen_mx_table.py
r1nadeg/04_catboost
6755bbbd1496540b92ded57eea1974f64bef87c5
[ "Apache-2.0" ]
null
null
null
build/scripts/gen_mx_table.py
r1nadeg/04_catboost
6755bbbd1496540b92ded57eea1974f64bef87c5
[ "Apache-2.0" ]
1
2018-08-06T14:13:12.000Z
2018-08-06T14:13:12.000Z
import sys tmpl = """ #include "yabs_mx_calc_table.h" #include <kernel/matrixnet/mn_sse.h> #include <library/archive/yarchive.h> #include <util/memory/blob.h> #include <util/generic/hash.h> #include <util/generic/ptr.h> #include <util/generic/singleton.h> using namespace NMatrixnet; extern "C" { extern const unsigned char MxFormulas[]; extern const ui32 MxFormulasSize; } namespace { struct TFml: public TBlob, public TMnSseInfo { inline TFml(const TBlob& b) : TBlob(b) , TMnSseInfo(Data(), Size()) { } }; struct TFormulas: public THashMap<size_t, TAutoPtr<TFml>> { inline TFormulas() { TBlob b = TBlob::NoCopy(MxFormulas, MxFormulasSize); TArchiveReader ar(b); %s } inline const TMnSseInfo& at(size_t n) const throw () { return *find(n)->second; } }; %s static func_descr_t yabs_funcs[] = { %s }; } yabs_mx_calc_table_t yabs_mx_calc_table = {YABS_MX_CALC_VERSION, 10000, 0, yabs_funcs}; """ if __name__ == '__main__': init = [] body = [] defs = {} for i in sys.argv[1:]: name = i.replace('.', '_') num = long(name.split('_')[1]) init.append('(*this)[%s] = new TFml(ar.ObjectBlobByKey("%s"));' % (num, '/' + i)) f1 = 'static void yabs_%s(size_t count, const float** args, double* res) {Singleton<TFormulas>()->at(%s).DoCalcRelevs(args, res, count);}' % (name, num) f2 = 'static size_t yabs_%s_factor_count() {return Singleton<TFormulas>()->at(%s).MaxFactorIndex() + 1;}' % (name, num) body.append(f1) body.append(f2) d1 = 'yabs_%s' % name d2 = 'yabs_%s_factor_count' % name defs[num] = '{%s, %s}' % (d1, d2) print tmpl % ('\n'.join(init), '\n\n'.join(body), ',\n'.join((defs.get(i, '{nullptr, nullptr}') for i in range(0, 10000))))
25.342105
160
0.576324
244
1,926
4.385246
0.413934
0.04486
0.037383
0.042056
0
0
0
0
0
0
0
0.017409
0.254413
1,926
75
161
25.68
0.727716
0
0
0.109091
0
0.036364
0.728972
0.166667
0
0
0
0
0
0
null
null
0
0.018182
null
null
0.018182
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
d203709221f68ac2daa8de8a8dbe4b58bcd9f4f3
497
py
Python
Src/StdLib/Lib/test/xmltests.py
cwensley/ironpython2
f854444e1e08afc8850cb7c1a739a7dd2d10d32a
[ "Apache-2.0" ]
2,293
2015-01-02T12:46:10.000Z
2022-03-29T09:45:43.000Z
Src/StdLib/Lib/test/xmltests.py
cwensley/ironpython2
f854444e1e08afc8850cb7c1a739a7dd2d10d32a
[ "Apache-2.0" ]
1,074
2016-12-07T05:02:48.000Z
2022-03-22T02:09:11.000Z
Src/StdLib/Lib/test/xmltests.py
cwensley/ironpython2
f854444e1e08afc8850cb7c1a739a7dd2d10d32a
[ "Apache-2.0" ]
1,033
2015-01-04T07:48:40.000Z
2022-03-24T09:34:37.000Z
# Convenience test module to run all of the XML-related tests in the # standard library. import sys import test.test_support test.test_support.verbose = 0 def runtest(name): __import__(name) module = sys.modules[name] if hasattr(module, "test_main"): module.test_main() runtest("test.test_minidom") runtest("test.test_pyexpat") runtest("test.test_sax") runtest("test.test_xml_etree") runtest("test.test_xml_etree_c") runtest("test.test_xmllib") runtest("test.test_xmlrpc")
22.590909
68
0.748491
74
497
4.783784
0.445946
0.20339
0.29661
0.101695
0.129944
0
0
0
0
0
0
0.002309
0.128773
497
21
69
23.666667
0.815242
0.169014
0
0
0
0
0.312195
0.05122
0
0
0
0
0
1
0.066667
false
0
0.2
0
0.266667
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
d2054031cc7f367ae05b0c0f073e7b256fa4a564
238
py
Python
Aula 01/ConversaoMedidas.py
eduardojpsena/EstruturaDeDados-Python-IESP
97c22fc1411dfdae2d1085e9a3ca0c334ee07988
[ "MIT" ]
null
null
null
Aula 01/ConversaoMedidas.py
eduardojpsena/EstruturaDeDados-Python-IESP
97c22fc1411dfdae2d1085e9a3ca0c334ee07988
[ "MIT" ]
null
null
null
Aula 01/ConversaoMedidas.py
eduardojpsena/EstruturaDeDados-Python-IESP
97c22fc1411dfdae2d1085e9a3ca0c334ee07988
[ "MIT" ]
null
null
null
print("---CONVERSÃO DE MEDIDAS---") valor_metros = float(input("Informe o valor em metros à ser convertido: ")) valor_centimetros = valor_metros * 100 print("{} metros equivale a {} centimetros.".format(valor_metros, valor_centimetros))
39.666667
85
0.747899
31
238
5.580645
0.612903
0.190751
0
0
0
0
0
0
0
0
0
0.014218
0.113445
238
6
85
39.666667
0.805687
0
0
0
0
0
0.443515
0
0
0
0
0
0
1
0
false
0
0
0
0
0.5
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
2
d2057f4c0253aa5e357b86320d8d2148ad029e12
385
py
Python
src/easymql/__init__.py
vivek-shrikhande/easy-mql
8cbf6a77aed8230bd92cee5585227ea4a09001b8
[ "MIT" ]
null
null
null
src/easymql/__init__.py
vivek-shrikhande/easy-mql
8cbf6a77aed8230bd92cee5585227ea4a09001b8
[ "MIT" ]
null
null
null
src/easymql/__init__.py
vivek-shrikhande/easy-mql
8cbf6a77aed8230bd92cee5585227ea4a09001b8
[ "MIT" ]
null
null
null
from pyparsing import ParseException from easymql.exc import EasyMQLSyntaxError from easymql.pipeline import Pipeline, encode class EasyMQL: def parse(self, query_string): try: return encode(Pipeline.parse(query_string, explode=False)) except ParseException as e: raise EasyMQLSyntaxError(query_string, str(e), e.lineno, e.col) from None
29.615385
85
0.724675
47
385
5.87234
0.574468
0.119565
0
0
0
0
0
0
0
0
0
0
0.207792
385
12
86
32.083333
0.904918
0
0
0
0
0
0
0
0
0
0
0
0
1
0.111111
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
d210d3e4fc7f26c1bc84d6a2851b1aad30445d94
2,185
py
Python
notebook/datetime_fromisoformat.py
vhn0912/python-snippets
80b2e1d6b2b8f12ae30d6dbe86d25bb2b3a02038
[ "MIT" ]
174
2018-05-30T21:14:50.000Z
2022-03-25T07:59:37.000Z
notebook/datetime_fromisoformat.py
vhn0912/python-snippets
80b2e1d6b2b8f12ae30d6dbe86d25bb2b3a02038
[ "MIT" ]
5
2019-08-10T03:22:02.000Z
2021-07-12T20:31:17.000Z
notebook/datetime_fromisoformat.py
vhn0912/python-snippets
80b2e1d6b2b8f12ae30d6dbe86d25bb2b3a02038
[ "MIT" ]
53
2018-04-27T05:26:35.000Z
2022-03-25T07:59:37.000Z
import datetime s = '2018-12-31' d = datetime.date.fromisoformat(s) print(d) # 2018-12-31 print(type(d)) # <class 'datetime.date'> # print(datetime.date.fromisoformat('2018-12')) # ValueError: Invalid isoformat string: '2018-12' print(datetime.date.fromisoformat('2018-01-01')) # 2018-01-01 # print(datetime.date.fromisoformat('2018-1-1')) # ValueError: Invalid isoformat string: '2018-1-1' s = '05:00:30.001000' t = datetime.time.fromisoformat(s) print(t) # 05:00:30.001000 print(type(t)) # <class 'datetime.time'> print(datetime.time.fromisoformat('05')) # 05:00:00 # print(datetime.time.fromisoformat('5:00:30')) # ValueError: Invalid isoformat string: '5:00:30' s = '2018-12-31T05:00:30.001000' dt = datetime.datetime.fromisoformat(s) print(dt) # 2018-12-31 05:00:30.001000 print(type(dt)) # <class 'datetime.datetime'> print(datetime.datetime.fromisoformat('2018-12-31x05:00:30.001000')) # 2018-12-31 05:00:30.001000 # print(datetime.datetime.fromisoformat('2018-12-31xx05:00:30.001000')) # ValueError: Invalid isoformat string: '2018-12-31xx05:00:30.001000' print(datetime.datetime.fromisoformat('2018-12-31T05')) # 2018-12-31 05:00:00 print(datetime.datetime.fromisoformat('2018-12-31')) # 2018-12-31 00:00:00 # print(datetime.datetime.fromisoformat('2018-12-31T5:00')) # ValueError: Invalid isoformat string: '2018-12-31T5:00' s = '2018-12-31T05:00:30.001000' # print(datetime.date.fromisoformat(s)) # ValueError: Invalid isoformat string: '2018-12-31T05:00:30.001000' # print(datetime.time.fromisoformat(s)) # ValueError: Invalid isoformat string: '2018-12-31T05:00:30.001000' d = datetime.datetime.fromisoformat(s).date() print(d) # 2018-12-31 print(type(d)) # <class 'datetime.date'> t = datetime.datetime.fromisoformat(s).time() print(t) # 05:00:30.001000 print(type(t)) # <class 'datetime.time'> s = '2018-12-31T05:00:30' s_basic = s.replace('-', '').replace(':', '') print(s_basic) # 20181231T050030 s = '2018-12-31T05:00:30.001000' s_basic = s.split('.')[0].replace('-', '').replace(':', '') print(s_basic) # 20181231T050030 s_ex = datetime.datetime.strptime(s_basic, '%Y%m%dT%H%M%S').isoformat() print(s_ex) # 2018-12-31T05:00:30
20.809524
71
0.707551
335
2,185
4.59403
0.119403
0.089669
0.08447
0.145549
0.701754
0.583496
0.45614
0.374269
0.263808
0.19883
0
0.223964
0.094737
2,185
104
72
21.009615
0.554095
0.498398
0
0.393939
0
0
0.189087
0.097836
0
0
0
0
0
1
0
false
0
0.030303
0
0.030303
0.545455
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
0
0
0
0
0
0
0
0
1
0
2
d220ea28079528b416680ff1ccebd74a80b37141
4,438
py
Python
python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_input_defaults.py
bitdotioinc/dagster
4fe395a37b206b1a48b956fa5dd72bf698104cca
[ "Apache-2.0" ]
1
2021-04-27T19:49:59.000Z
2021-04-27T19:49:59.000Z
python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_input_defaults.py
bitdotioinc/dagster
4fe395a37b206b1a48b956fa5dd72bf698104cca
[ "Apache-2.0" ]
7
2022-03-16T06:55:04.000Z
2022-03-18T07:03:25.000Z
python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_input_defaults.py
bitdotioinc/dagster
4fe395a37b206b1a48b956fa5dd72bf698104cca
[ "Apache-2.0" ]
null
null
null
import pytest from dagster import ( DagsterInvalidDefinitionError, InputDefinition, Nothing, Optional, composite_solid, execute_pipeline, execute_solid, lambda_solid, pipeline, ) def test_none(): @lambda_solid(input_defs=[InputDefinition("x", Optional[int], default_value=None)]) def none_x(x): return x result = execute_solid(none_x) assert result.output_value() == None def test_none_infer(): @lambda_solid def none_x(x=None): return x result = execute_solid(none_x) assert result.output_value() == None def test_int(): @lambda_solid(input_defs=[InputDefinition("x", Optional[int], default_value=1337)]) def int_x(x): return x result = execute_solid(int_x) assert result.output_value() == 1337 def test_int_infer(): @lambda_solid def int_x(x=1337): return x result = execute_solid(int_x) assert result.output_value() == 1337 def test_early_fail(): with pytest.raises( DagsterInvalidDefinitionError, match="Type check failed for the default_value of InputDefinition x of type Int", ): @lambda_solid(input_defs=[InputDefinition("x", int, default_value="foo")]) def _int_x(x): return x with pytest.raises( DagsterInvalidDefinitionError, match="Type check failed for the default_value of InputDefinition x of type String", ): @lambda_solid(input_defs=[InputDefinition("x", str, default_value=1337)]) def _int_x(x): return x # we can't catch bad default_values except for scalars until runtime since the type_check function depends on # a context that has access to resources etc. @lambda_solid(input_defs=[InputDefinition("x", Optional[int], default_value="number")]) def bad_default(x): return x def test_mismatch(): result = execute_solid(bad_default, raise_on_error=False) assert result.success == False assert result.input_events_during_compute[0].step_input_data.type_check_data.success == False def test_env_precedence(): result = execute_solid( bad_default, run_config={"solids": {"bad_default": {"inputs": {"x": 1}}}}, raise_on_error=False, ) assert result.success == True assert result.output_value() == 1 def test_input_precedence(): @lambda_solid def emit_one(): return 1 @pipeline def pipe(): bad_default(emit_one()) result = execute_pipeline(pipe) assert result.success assert result.output_for_solid("bad_default") == 1 def test_nothing(): with pytest.raises(DagsterInvalidDefinitionError): @lambda_solid(input_defs=[InputDefinition("x", Nothing, default_value=None)]) def _nothing(): pass def test_composite_outer_default(): @lambda_solid(input_defs=[InputDefinition("x", Optional[int])]) def int_x(x): return x @composite_solid(input_defs=[InputDefinition("y", Optional[int], default_value=42)]) def wrap(y): return int_x(y) result = execute_solid(wrap) assert result.success assert result.output_value() == 42 def test_composite_inner_default(): @lambda_solid(input_defs=[InputDefinition("x", Optional[int], default_value=1337)]) def int_x(x): return x @composite_solid(input_defs=[InputDefinition("y", Optional[int])]) def wrap(y): return int_x(y) result = execute_solid(wrap) assert result.success assert result.output_value() == 1337 def test_composite_precedence_default(): @lambda_solid(input_defs=[InputDefinition("x", Optional[int], default_value=1337)]) def int_x(x): return x @composite_solid(input_defs=[InputDefinition("y", Optional[int], default_value=42)]) def wrap(y): return int_x(y) result = execute_solid(wrap) assert result.success assert result.output_value() == 42 def test_composite_mid_default(): @lambda_solid(input_defs=[InputDefinition("x", Optional[int])]) def int_x(x): return x @composite_solid(input_defs=[InputDefinition("y", Optional[int], default_value=42)]) def wrap(y): return int_x(y) @composite_solid(input_defs=[InputDefinition("z", Optional[int])]) def outter_wrap(z): return wrap(z) result = execute_solid(outter_wrap) assert result.success assert result.output_value() == 42
25.36
109
0.677332
569
4,438
5.031634
0.168717
0.075445
0.07335
0.151939
0.675864
0.643032
0.599721
0.555362
0.555362
0.527768
0
0.01398
0.21023
4,438
174
110
25.505747
0.802853
0.034024
0
0.516129
0
0
0.048086
0
0
0
0
0
0.145161
1
0.258065
false
0.008065
0.016129
0.137097
0.41129
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
d22b9934bc74f943c4699852c43f6be8c7246c45
3,027
py
Python
insights/parsers/tests/test_zipl_conf.py
lhuett/insights-core
1c84eeffc037f85e2bbf60c9a302c83aa1a50cf8
[ "Apache-2.0" ]
121
2017-05-30T20:23:25.000Z
2022-03-23T12:52:15.000Z
insights/parsers/tests/test_zipl_conf.py
lhuett/insights-core
1c84eeffc037f85e2bbf60c9a302c83aa1a50cf8
[ "Apache-2.0" ]
1,977
2017-05-26T14:36:03.000Z
2022-03-31T10:38:53.000Z
insights/parsers/tests/test_zipl_conf.py
lhuett/insights-core
1c84eeffc037f85e2bbf60c9a302c83aa1a50cf8
[ "Apache-2.0" ]
244
2017-05-30T20:22:57.000Z
2022-03-26T10:09:39.000Z
from insights.parsers.zipl_conf import ZiplConf from insights.tests import context_wrap from insights.parsers import ParseException import pytest ZIPL_CONF = """ [defaultboot] defaultauto prompt=1 timeout=5 default=linux target=/boot [linux] image=/boot/vmlinuz-3.10.0-693.el7.s390x ramdisk=/boot/initramfs-3.10.0-693.el7.s390x.img parameters="root=/dev/mapper/rhel_gss5-root crashkernel=auto rd.dasd=0.0.0100 rd.dasd=0.0.0101 rd.dasd=0.0.0102 rd.lvm.lv=rhel_gss5/root rd.lvm.lv=rhel_gss5/swap net.ifnames=0 rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=0,portname=gss5,portno=0 LANG=en_US.UTF-8" [linux-0-rescue-a27932c8d57248e390cee3798bbd3709] image=/boot/vmlinuz-0-rescue-a27932c8d57248e390cee3798bbd3709 ramdisk=/boot/initramfs-0-rescue-a27932c8d57248e390cee3798bbd3709.img parameters="root=/dev/mapper/rhel_gss5-root crashkernel=auto rd.dasd=0.0.0100 rd.dasd=0.0.0101 rd.dasd=0.0.0102 rd.lvm.lv=rhel_gss5/root rd.lvm.lv=rhel_gss5/swap net.ifnames=0 rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=0,portname=gss5,portno=0" [other] image=/boot/vmlinuz ramdisk=/boot/initramfs.img parameters="root=/dev/mapper/rhel_gss5-root crashkernel=auto rd.dasd=0.0.0100 # Configuration for dumping to SCSI disk # Separate IPL and dump partitions [dumpscsi] target=/boot dumptofs=/dev/sda2 parameters="dump_dir=/mydumps dump_compress=none dump_mode=auto" # Menu containing two DASD boot configurations :menu1 1=linux 2=linux-0-rescue-a27932c8d57248e390cee3798bbd3709 default=1 prompt=1 timeout=30 """.strip() ZIPL_CONF_INVALID = """ prompt=1 timeout=5 default=linux [linux] image=/boot/vmlinuz-3.10.0-693.el7.s390x ramdisk=/boot/initramfs-3.10.0-693.el7.s390x.img parameters="root=/dev/mapper/rhel_gss5-root crashkernel=auto rd.dasd=0.0.0100 rd.dasd=0.0.0101 rd.dasd=0.0.0102 rd.lvm.lv=rhel_gss5/root rd.lvm.lv=rhel_gss5/swap net.ifnames=0 rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=0,portname=gss5,portno=0 LANG=en_US.UTF-8" """.strip() def test_zipl_conf(): res = ZiplConf(context_wrap(ZIPL_CONF)) assert res.get('linux').get('image') == "/boot/vmlinuz-3.10.0-693.el7.s390x" assert res['linux']['image'] == "/boot/vmlinuz-3.10.0-693.el7.s390x" assert res[':menu1']['1'] == 'linux' assert 'defaultauto' in res['defaultboot'] assert res['defaultboot']['defaultauto'] is True assert res['other']['parameters'] == '"root=/dev/mapper/rhel_gss5-root crashkernel=auto rd.dasd=0.0.0100' assert res.images == { 'linux': '/boot/vmlinuz-3.10.0-693.el7.s390x', 'linux-0-rescue-a27932c8d57248e390cee3798bbd3709': '/boot/vmlinuz-0-rescue-a27932c8d57248e390cee3798bbd3709', 'other': '/boot/vmlinuz' } assert res.dumptofses == {'dumpscsi': '/dev/sda2'} def test_zipl_conf_invalid(): with pytest.raises(ParseException) as pe: ZiplConf(context_wrap(ZIPL_CONF_INVALID)) assert "Invalid zipl configuration file is found." in str(pe)
41.465753
269
0.720846
476
3,027
4.518908
0.235294
0.018596
0.035797
0.040911
0.552301
0.480707
0.455602
0.455602
0.443515
0.443515
0
0.143128
0.127519
3,027
72
270
42.041667
0.671337
0
0
0.296875
0
0.078125
0.732739
0.405021
0
0
0
0
0.140625
1
0.03125
false
0
0.0625
0
0.09375
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
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
2
d2366db96566571009998f46fd017359e1980f42
325
py
Python
comm_lib/import_lib.py
GUTLY/machine_learning_in_action
7820c948014c615ed10f693f03ea116a0f7d6b96
[ "Apache-2.0" ]
null
null
null
comm_lib/import_lib.py
GUTLY/machine_learning_in_action
7820c948014c615ed10f693f03ea116a0f7d6b96
[ "Apache-2.0" ]
null
null
null
comm_lib/import_lib.py
GUTLY/machine_learning_in_action
7820c948014c615ed10f693f03ea116a0f7d6b96
[ "Apache-2.0" ]
null
null
null
""" @Time : 12/4/2020 13:57 @Author : Young lee @File : import_lib @Project : machine_learning_in_action """ import collections import math import os import random import sys import tarfile import time import zipfile import operator from IPython import display from matplotlib import pyplot as plt import numpy as np
16.25
37
0.775385
49
325
5.061224
0.693878
0
0
0
0
0
0
0
0
0
0
0.040892
0.172308
325
19
38
17.105263
0.881041
0.329231
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
2