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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f0427336f5a088f6235ec97b84daa0096a2a175a
| 31
|
py
|
Python
|
chapter08/my_test.py
|
niyunsheng/Mtianyan-AdvancePython
|
c6976f08161aa398a91328654266911d75359441
|
[
"Apache-2.0"
] | null | null | null |
chapter08/my_test.py
|
niyunsheng/Mtianyan-AdvancePython
|
c6976f08161aa398a91328654266911d75359441
|
[
"Apache-2.0"
] | null | null | null |
chapter08/my_test.py
|
niyunsheng/Mtianyan-AdvancePython
|
c6976f08161aa398a91328654266911d75359441
|
[
"Apache-2.0"
] | null | null | null |
from property_test import User
| 15.5
| 30
| 0.870968
| 5
| 31
| 5.2
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.129032
| 31
| 1
| 31
| 31
| 0.962963
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
f05632e4e26107e8dfc87a08f3622eba4e955052
| 4,726
|
py
|
Python
|
navigation.py
|
Blue-IT-Marketing/sa-loans
|
ff574766f1ae8bc051e5ba07acc47418118a3704
|
[
"MIT"
] | 1
|
2020-07-02T16:34:43.000Z
|
2020-07-02T16:34:43.000Z
|
navigation.py
|
Blue-IT-Marketing/hotelmanager
|
f20120ed2009b7d720a0d92a901c92ba5237b573
|
[
"MIT"
] | null | null | null |
navigation.py
|
Blue-IT-Marketing/hotelmanager
|
f20120ed2009b7d720a0d92a901c92ba5237b573
|
[
"MIT"
] | null | null | null |
import os
import webapp2
import jinja2
from google.appengine.ext import ndb
from google.appengine.api import users
import logging
template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))
from tasks import Tasks
class SidebarHandler(webapp2.RequestHandler):
"""
Check if the User Logged in load all defaults for the user on the sidebar including username
profile information and others
Sidebar variables
vstrUsername
vstrLogoutURL
vstrLoginURL
"""
def get(self):
Guser = users.get_current_user()
vstrLogoutURL = users.create_logout_url(dest_url="/")
vstrLoginURL = users.create_login_url(dest_url="/")
if Guser:
vstrUsername = Guser.nickname()
template = template_env.get_template('templates/dynamic/navigation/sidebar.html')
context = {'vstrUsername': vstrUsername,
'vstrLogoutURL': vstrLogoutURL}
self.response.write(template.render(context))
else:
template = template_env.get_template('templates/dynamic/navigation/sidebar.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class AdminSideBar(webapp2.RequestHandler):
def get(self):
Guser = users.get_current_user()
vstrLogoutURL = users.create_logout_url(dest_url="/")
vstrLoginURL = users.create_login_url(dest_url="/")
if Guser:
vstrUsername = Guser.nickname()
template = template_env.get_template('templates/dynamic/admin/navigation/sidebar.html')
context = {'vstrUsername': vstrUsername,
'vstrLogoutURL': vstrLogoutURL}
self.response.write(template.render(context))
else:
template = template_env.get_template('templates/dynamic/admin/navigation/sidebar.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class HeaderHandler(webapp2.RequestHandler):
"""
Header Variables
vstrUsername
vstrDesignation
vstrTotalMessages
vstrTotalNotifications
vstrTotalTasks
vstrLogoutURL
"""
def get(self):
Guser = users.get_current_user()
if Guser:
vstrUsername = Guser.nickname()
vstrLogoutURL = users.create_logout_url(dest_url="/")
findRequest = Tasks.query(Tasks.strToReference == Guser.user_id())
TaskList = findRequest.fetch()
vstrTotalTasks = len(TaskList)
template = template_env.get_template('templates/dynamic/navigation/header.html')
context = {'vstrUsername': vstrUsername, 'vstrLogoutURL': vstrLogoutURL,
'TaskList':TaskList,'vstrTotalTasks':vstrTotalTasks}
self.response.write(template.render(context))
else:
vstrLoginURL = users.create_login_url(dest_url="/")
template = template_env.get_template('templates/dynamic/navigation/header.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class AdminHeader(webapp2.RequestHandler):
def get(self):
Guser = users.get_current_user()
if Guser:
vstrUsername = Guser.nickname()
vstrLogoutURL = users.create_logout_url(dest_url="/")
findRequest = Tasks.query(Tasks.strToReference == Guser.user_id())
TaskList = findRequest.fetch()
vstrTotalTasks = len(TaskList)
template = template_env.get_template('templates/dynamic/admin/navigation/header.html')
context = {'vstrUsername': vstrUsername,'vstrLogoutURL': vstrLogoutURL,
'TaskList':TaskList,'vstrTotalTasks':vstrTotalTasks}
self.response.write(template.render(context))
else:
vstrLoginURL = users.create_login_url(dest_url="/")
template = template_env.get_template('templates/dynamic/admin/navigation/header.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class FooterHandler(webapp2.RequestHandler):
def get(self):
template = template_env.get_template('templates/dynamic/navigation/footer.html')
context = {}
self.response.write(template.render(context))
app = webapp2.WSGIApplication([
('/navigation/sidebar', SidebarHandler),
('/navigation/admin/header',AdminHeader),
('/navigation/header', HeaderHandler),
('/navigation/admin/sidebar',AdminSideBar),
('/navigation/footer', FooterHandler)
], debug=True)
| 38.422764
| 100
| 0.656369
| 441
| 4,726
| 6.913832
| 0.195011
| 0.036077
| 0.056084
| 0.064939
| 0.746146
| 0.735979
| 0.723516
| 0.723516
| 0.705149
| 0.705149
| 0
| 0.002785
| 0.240161
| 4,726
| 123
| 101
| 38.422764
| 0.846282
| 0.062844
| 0
| 0.744186
| 0
| 0
| 0.160893
| 0.101604
| 0
| 0
| 0
| 0
| 0
| 1
| 0.05814
| false
| 0
| 0.081395
| 0
| 0.197674
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
b2ced46a15f852a9d3ecebce572c25a27f887c81
| 11,276
|
py
|
Python
|
ExtractFeaturesFromBlocksSlices.py
|
guoqingbao/DeepAdipose
|
62af7a767f8f0f91e06b3f0b556dde5f9ead5d32
|
[
"Apache-2.0"
] | null | null | null |
ExtractFeaturesFromBlocksSlices.py
|
guoqingbao/DeepAdipose
|
62af7a767f8f0f91e06b3f0b556dde5f9ead5d32
|
[
"Apache-2.0"
] | null | null | null |
ExtractFeaturesFromBlocksSlices.py
|
guoqingbao/DeepAdipose
|
62af7a767f8f0f91e06b3f0b556dde5f9ead5d32
|
[
"Apache-2.0"
] | null | null | null |
from __future__ import print_function
import os, time
import collections
import platform
import csv
import SimpleITK as sitk
import six
from radiomics import firstorder, glcm, imageoperations, shape, glrlm, glszm, featureextractor
import numpy as np
# import matplotlib.pyplot as plt
import imp
import datetime
import pandas as pd
import gc
gc.enable()
data_path = "./data/"
frame = pd.read_csv(data_path + 'segment_results.csv')
tif_path = mask_path = data_path + 'tiff/'
output_path = "./data/block/"
ids = [int(item[item.find('_')+1:]) for item in list(frame.ID)]
frame.ix[:,'BKID'] = frame.ID
frame.ix[:,'ID'] = ids
def getpos(Diaphragm,PubicSymphysis):
pos = int((PubicSymphysis-Diaphragm) * POSITION/10) + int(Diaphragm)
endpos = int(Diaphragm) + pos + int((PubicSymphysis-Diaphragm)/10)
if endpos + 1 >=PubicSymphysis:
endpos = PubicSymphysis -1
return pos, endpos
# Extract blocks from CTs (umbilicus block)
POSITION = 5
for index, row in frame.iterrows():
file = tif_path+str(row["BKID"])+".tif"
if os.path.exists(file):
if os.path.exists(output_path+str(row["ID"])+".tif"):
print("skip "+ file)
continue
else:
print("file not found: "+ file)
continue
image = sitk.ReadImage(file)
image_s = sitk.GetArrayFromImage(image)
pos, endpos = getpos(row["Diaphragm Index"],row["PubicSymphysis Index"])
img = sitk.GetImageFromArray(image_s[pos:endpos])
sitk.WriteImage(img, output_path + str(row["ID"])+'.tif')
del img
del image_s
gc.collect()
print("Extracted block from " + str(row["ID"]))
innerHeader = pd.read_excel(data_path + "full_block_features.xlsx")
header = innerHeader.columns.tolist()
header.append("StartIndex")
# Extract features from umbilicus CT block
FEATURE_TYPES = {1:"shape", 2:"firstorder", 3:"glcm", 4:"glrlm", 5:"glszm", 6:"wavelet-glcm", 7:"wavelet-glrlm"}
import random
IS_OUTER_FAT = False
TASK_LIST = [2,3,4,5,6,7]
POSITION = 5
first = True
FINISHED_ID = ""
try:
with open(output_path + "blocks.txt", 'r') as sf:
FINISHED_ID = sf.readline()
print(FINISHED_ID)
if FINISHED_ID != "":
first = False;
except:
pass
Found = False
positions = []
if IS_OUTER_FAT:
CSV_FILE = "block_outer.csv"
else:
CSV_FILE = "block_inner.csv"
for index, row in frame.iterrows():
if FINISHED_ID!="" and Found==False and str(row["ID"]) != FINISHED_ID:
continue
elif str(row["ID"]) == FINISHED_ID:
Found = True
print("Continue from {}".format(row["ID"]))
continue
file = output_path+str(row["ID"])+".tif"
if os.path.exists(file):
mask_file = mask_path+str(row["BKID"])+"_mask.nrrd"
if not os.path.exists(mask_file):
print("mask file not found: "+ mask_file)
continue
else:
print("file not found: "+ file)
continue
image_block = sitk.ReadImage(file)
mask = sitk.ReadImage(mask_file)
mask_s = sitk.GetArrayFromImage(mask)
if IS_OUTER_FAT:
mask_s[mask_s!=2] = 0
mask_s[mask_s==2] = 1
else:
mask_s[mask_s!=5] = 0
mask_s[mask_s==5] = 1
pos, endpos = getpos(row["Diaphragm Index"],row["PubicSymphysis Index"])
mask_block = sitk.GetImageFromArray(mask_s[pos:endpos])
del mask
del mask_s
print("\r\n*******************************************************\n")
print("Case {}, pos {} - {}".format(row["ID"], pos, endpos))
settings = {}
spacing = ['1.0','1.0','1.0']
settings['binWidth'] = 25
settings['resampledPixelSpacing'] = None
settings['interpolator'] = 'sitkBSpline'
settings['verbose'] = True
values = {'ID':row["ID"], "StartIndex":pos}
for FEATURE_ID in TASK_LIST:
# print("Start analyze feature: {}...".format(FEATURE_TYPES[FEATURE_ID]))
if FEATURE_ID == 6:
paramPath = output_path + 'Params-glcm.yaml'
else:
paramPath = output_path + 'Params-glrlm.yaml'
selected_feature = None
if FEATURE_TYPES[FEATURE_ID] == "firstorder":
extractor = firstorder.RadiomicsFirstOrder(image_block, mask_block, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "glcm":
extractor = glcm.RadiomicsGLCM(image_block, mask_block, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "glrlm":
extractor = glrlm.RadiomicsGLRLM(image_block, mask_block, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "glszm":
extractor = glszm.RadiomicsGLSZM(image_block, mask_block, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "wavelet-glcm" or FEATURE_TYPES[FEATURE_ID] == "wavelet-glrlm":
extractor = featureextractor.RadiomicsFeaturesExtractor(paramPath)
else:
raise Exception("Invalid feature selected!")
# print('Calculating feature {} '.format(FEATURE_TYPES[FEATURE_ID]))
featureValues= {}
if FEATURE_ID == 6 or FEATURE_ID == 7:
featureValues = extractor.execute(image_block,mask_block)
elif extractor != None:
extractor.enableAllFeatures()
extractor.calculateFeatures()
featureValues = extractor.featureValues
else:
raise Exception("Invalid feature configuration!")
new_values = {k.replace('wavelet-',''):v for k, v in featureValues.items() if not k.startswith('general_')}
nm = FEATURE_TYPES[FEATURE_ID].upper()
if FEATURE_ID == 6 or FEATURE_ID == 7:
nm = 'WAVELET'
new_values = { nm+ '_' +k:v for k, v in new_values.items()}
values.update(new_values)
# print('Calculated feature {} '.format(FEATURE_TYPES[FEATURE_ID]))
# for (key, val) in six.iteritems(featureValues):
# print(' ', key, ':', val)
with open(output_path + CSV_FILE, 'a', newline='') as f:
writer = csv.DictWriter(f, fieldnames=header)
if first:
writer.writeheader()
writer.writerow(values)
f.flush()
first = False
del image_block
del mask_block
del extractor
gc.collect()
with open(output_path + "blocks.txt", 'w+') as f:
f.write(str(row["ID"]))
f.flush()
# Extract any three consecutive slices from umbilicus CT block (10 times of random position)
first = True
FINISHED_ID = ""
try:
with open(output_path + "slices.txt", 'r') as sf:
FINISHED_ID = sf.readline()
print(FINISHED_ID)
if FINISHED_ID != "":
first = False;
except:
pass
Found = False
positions = []
if IS_OUTER_FAT:
CSV_FILE = "block_slices.csv"
else:
CSV_FILE = "block_slices.csv"
for index, row in frame.iterrows():
if FINISHED_ID!="" and Found==False and str(row["ID"]) != FINISHED_ID:
continue
elif str(row["ID"]) == FINISHED_ID:
Found = True
print("Continue from {}".format(row["ID"]))
continue
file = output_path+str(row["ID"])+".tif"
if os.path.exists(file):
mask_file = mask_path+str(row["BKID"])+"_mask.nrrd"
if not os.path.exists(mask_file):
print("mask file not found: "+ mask_file)
continue
else:
print("file not found: "+ file)
continue
image = sitk.ReadImage(file)
image_s = sitk.GetArrayFromImage(image)
mask = sitk.ReadImage(mask_file)
mask_s = sitk.GetArrayFromImage(mask)
if IS_OUTER_FAT:
mask_s[mask_s!=2] = 0
mask_s[mask_s==2] = 1
else:
mask_s[mask_s!=5] = 0
mask_s[mask_s==5] = 1
pos, endpos = getpos(row["Diaphragm Index"],row["PubicSymphysis Index"])
print("\r\n*******************************************************\n")
for i in range(10):
start = random.randint(pos,endpos-5)
image_slices = sitk.GetImageFromArray(image_s[start-pos:start-pos+3])
mask_slices = sitk.GetImageFromArray(mask_s[start:start+3])
print("Case {}, slice pos {} - {}".format(row["ID"], start, start+3))
settings = {}
spacing = ['1.0','1.0','1.0']
settings['binWidth'] = 25
settings['resampledPixelSpacing'] = None
settings['interpolator'] = 'sitkBSpline'
settings['verbose'] = True
values = {'ID':row["ID"], "StartIndex":start}
for FEATURE_ID in TASK_LIST:
# print("Start analyze feature: {}...".format(FEATURE_TYPES[FEATURE_ID]))
if FEATURE_ID == 6:
paramPath = output_path + 'Params-glcm.yaml'
else:
paramPath = output_path + 'Params-glrlm.yaml'
selected_feature = None
if FEATURE_TYPES[FEATURE_ID] == "firstorder":
extractor = firstorder.RadiomicsFirstOrder(image_slices, mask_slices, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "glcm":
extractor = glcm.RadiomicsGLCM(image_slices, mask_slices, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "glrlm":
extractor = glrlm.RadiomicsGLRLM(image_slices, mask_slices, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "glszm":
extractor = glszm.RadiomicsGLSZM(image_slices, mask_slices, **settings)
elif FEATURE_TYPES[FEATURE_ID] == "wavelet-glcm" or FEATURE_TYPES[FEATURE_ID] == "wavelet-glrlm":
extractor = featureextractor.RadiomicsFeaturesExtractor(paramPath)
else:
raise Exception("Invalid feature selected!")
# print('Calculating feature {} '.format(FEATURE_TYPES[FEATURE_ID]))
featureValues= {}
if FEATURE_ID == 6 or FEATURE_ID == 7:
featureValues = extractor.execute(image_slices,mask_slices)
elif extractor != None:
extractor.enableAllFeatures()
extractor.calculateFeatures()
featureValues = extractor.featureValues
else:
raise Exception("Invalid feature configuration!")
new_values = {k.replace('wavelet-',''):v for k, v in featureValues.items() if not k.startswith('general_')}
nm = FEATURE_TYPES[FEATURE_ID].upper()
if FEATURE_ID == 6 or FEATURE_ID == 7:
nm = 'WAVELET'
new_values = { nm+ '_' +k:v for k, v in new_values.items()}
values.update(new_values)
# print('Calculated feature {} '.format(FEATURE_TYPES[FEATURE_ID]))
# for (key, val) in six.iteritems(featureValues):
# print(' ', key, ':', val)
with open(output_path + CSV_FILE, 'a', newline='') as f:
writer = csv.DictWriter(f, fieldnames=header)
if first:
writer.writeheader()
writer.writerow(values)
f.flush()
first = False
del image_slices
del mask_slices
del extractor
del mask
del mask_s
del image
del image_s
gc.collect()
with open(output_path + "slices.txt", 'w+') as f:
f.write(str(row["ID"]))
f.flush()
| 32.495677
| 120
| 0.594271
| 1,329
| 11,276
| 4.887886
| 0.153499
| 0.044335
| 0.058498
| 0.064655
| 0.758313
| 0.741841
| 0.716133
| 0.716133
| 0.716133
| 0.695505
| 0
| 0.00873
| 0.268624
| 11,276
| 346
| 121
| 32.589595
| 0.77895
| 0.075825
| 0
| 0.725191
| 0
| 0
| 0.119016
| 0.018073
| 0
| 0
| 0
| 0
| 0
| 1
| 0.003817
| false
| 0.007634
| 0.053435
| 0
| 0.061069
| 0.061069
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
6520db39a55ddccb201467fde759e292dcd5ab7d
| 5,313
|
py
|
Python
|
test/test_download.py
|
hnrd/PlaystoreDownloader
|
57b54463ad4ad88326603ca85f3e2c5f52423ff1
|
[
"MIT"
] | 2
|
2021-06-21T22:15:34.000Z
|
2021-08-12T11:23:06.000Z
|
test/test_download.py
|
hnrd/PlaystoreDownloader
|
57b54463ad4ad88326603ca85f3e2c5f52423ff1
|
[
"MIT"
] | null | null | null |
test/test_download.py
|
hnrd/PlaystoreDownloader
|
57b54463ad4ad88326603ca85f3e2c5f52423ff1
|
[
"MIT"
] | null | null | null |
#!/usr/bin/env python3
import os
import pytest
import download
from playstore.playstore import Playstore
# noinspection PyUnresolvedReferences
from test.test_playstore_api import (
playstore,
VALID_PACKAGE_NAME,
BAD_PACKAGE_NAME,
APK_WITH_OBB,
APK_WITH_SPLIT_APK,
)
# noinspection PyUnresolvedReferences
from test.test_session_fixtures import (
valid_credentials_path,
wrong_credentials_path,
download_folder_path,
)
# noinspection PyShadowingNames
class TestDownload(object):
def test_valid_download_specific_location(
self, download_folder_path, valid_credentials_path, monkeypatch
):
downloaded_apk_path = (
f"{os.path.join(download_folder_path, VALID_PACKAGE_NAME)}.apk"
)
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{VALID_PACKAGE_NAME}" '
f'-c "{valid_credentials_path}" '
f'-o "{downloaded_apk_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
download.main()
assert os.path.isfile(downloaded_apk_path) is True
def test_valid_download_specific_location_with_tag(
self, download_folder_path, valid_credentials_path, monkeypatch
):
downloaded_apk_path = (
f"{os.path.join(download_folder_path, VALID_PACKAGE_NAME)}.apk"
)
downloaded_apk_path_with_tag = (
f"{os.path.join(download_folder_path, f'[TEST] {VALID_PACKAGE_NAME}')}.apk"
)
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{VALID_PACKAGE_NAME}" '
f'-c "{valid_credentials_path}" '
f'-o "{downloaded_apk_path}" -t "TEST"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
download.main()
assert os.path.isfile(downloaded_apk_path_with_tag) is True
def test_valid_download_default_location(self, valid_credentials_path, monkeypatch):
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{VALID_PACKAGE_NAME}" -c "{valid_credentials_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
# If this runs without errors, the apk will be saved in the Downloads folder
# (created in the same folder as download.py).
download.main()
def test_valid_download_additional_files(self, valid_credentials_path, monkeypatch):
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{APK_WITH_OBB}" -b -c "{valid_credentials_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
# If this runs without errors, the apk and the additional files will be saved
# in the Downloads folder (created in the same folder as download.py).
download.main()
def test_valid_download_split_apk(self, valid_credentials_path, monkeypatch):
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{APK_WITH_SPLIT_APK}" -s -c "{valid_credentials_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
# If this runs without errors, the apk and the split apk(s) will be saved in
# the Downloads folder (created in the same folder as download.py).
download.main()
def test_download_app_details_error(self, valid_credentials_path, monkeypatch):
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{VALID_PACKAGE_NAME}" -c "{valid_credentials_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
# Mock the Playstore.
monkeypatch.setattr(Playstore, "app_details", lambda self, package: None)
with pytest.raises(SystemExit) as err:
download.main()
assert err.value.code == 1
def test_download_error(
self, download_folder_path, valid_credentials_path, monkeypatch
):
downloaded_apk_path = (
f"{os.path.join(download_folder_path, 'error', VALID_PACKAGE_NAME)}.apk"
)
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{VALID_PACKAGE_NAME}" '
f'-c "{valid_credentials_path}" '
f'-o "{downloaded_apk_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
# Mock the Playstore.
monkeypatch.setattr(
Playstore,
"download",
lambda self, package, path, download_obb, download_split_apks: False,
)
with pytest.raises(SystemExit) as err:
download.main()
assert err.value.code == 1
def test_download_wrong_credentials(self, wrong_credentials_path, monkeypatch):
# Mock the command line parser.
arguments = download.get_cmd_args(
f'"{VALID_PACKAGE_NAME}" -c "{wrong_credentials_path}"'.split()
)
monkeypatch.setattr(download, "get_cmd_args", lambda: arguments)
with pytest.raises(SystemExit) as err:
download.main()
assert err.value.code == 1
| 34.72549
| 88
| 0.657068
| 628
| 5,313
| 5.273885
| 0.146497
| 0.081522
| 0.067633
| 0.086957
| 0.834843
| 0.797705
| 0.766304
| 0.757548
| 0.757548
| 0.757548
| 0
| 0.001005
| 0.250518
| 5,313
| 152
| 89
| 34.953947
| 0.830738
| 0.152268
| 0
| 0.495146
| 0
| 0
| 0.196922
| 0.14942
| 0
| 0
| 0
| 0
| 0.048544
| 1
| 0.07767
| false
| 0
| 0.058252
| 0
| 0.145631
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
653a22ae30b862481e6537646edd2ab9fb92fe69
| 11,338
|
py
|
Python
|
Fon_web_selenium_parser.py
|
ghobtr/Colaboratory_Public
|
39c9109c8d55919e033fa4ffcb728e989c13c3b5
|
[
"MIT"
] | null | null | null |
Fon_web_selenium_parser.py
|
ghobtr/Colaboratory_Public
|
39c9109c8d55919e033fa4ffcb728e989c13c3b5
|
[
"MIT"
] | null | null | null |
Fon_web_selenium_parser.py
|
ghobtr/Colaboratory_Public
|
39c9109c8d55919e033fa4ffcb728e989c13c3b5
|
[
"MIT"
] | null | null | null |
# coding=utf-8
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import pathlib
from docx import Document
from datetime import datetime, timedelta
import time
import os
from docx.shared import Inches
import pandas as pd
# Requirements
# pip install selenium
# pip install python-docx
# pip install openpyxl
# Date var
now = datetime.now() # current date and time
past = datetime.now() - timedelta(7) # for last week
past2 = datetime.now() - timedelta(14) # for 2 last week
date_time = now.strftime("%d/%m/%Y, %H:%M")
date_time_file = now.strftime("%d_%m_%Y")
today = now.strftime("%d.%m.%Y")
past = past.strftime("%d.%m.%Y")
past2 = past2.strftime("%d.%m.%Y")
# selenium var
current_path = pathlib.Path().absolute()
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--start-maximized')
prefs = {"download.default_directory" : str(current_path),
"download.prompt_for_download": False}
chrome_options.add_experimental_option('prefs', prefs)
# clear old files
try:
os.remove(str(current_path) + "/FonTurkey_Fon_Karsilastirma.xlsx")
print("old files are deleted")
except:
pass
chromedriver = str(current_path) + "/chromedriver"
driver = webdriver.Chrome(executable_path=chromedriver, options=chrome_options)
fon_list = ["NNF"]
#fon_list = ["NNF","TCD","AOY","AFS","MAC","AFV","AFA","TGE","GTA","GPU","GUH","GPB","OPH","OPI","ODV","ARM"]
# begin program
document = Document()
document.add_heading('Fon Report', 0)
document.add_paragraph("Rapor üretilme zamanı: " + str(date_time))
for fon_name in fon_list:
the_url = "https://www.tefas.gov.tr/FonAnaliz.aspx?FonKod=" + fon_name
driver.get(the_url)
# xpath
fon_name_xpath = '//span[@id="MainContent_FormViewMainIndicators_LabelFund"]'
day_price_xpath = '//li[text()="Günlük Getiri (%)"]/span'
last_month_price_xpath = '//li[text()="Son 1 Ay Getirisi"]/span'
last_year_price_xpath = '//li[text()="Son 1 Yıl Getirisi"]/span'
fon_detail_name = driver.find_element_by_xpath(fon_name_xpath)
day_price = driver.find_element_by_xpath(day_price_xpath)
last_month_price = driver.find_element_by_xpath(last_month_price_xpath)
last_year_price = driver.find_element_by_xpath(last_year_price_xpath)
# Generate docx
document.add_heading(fon_name, level=1)
document.add_paragraph(fon_detail_name.text)
document.add_paragraph("Günlük Getiri")
document.add_paragraph(day_price.text)
document.add_paragraph("Aylık Getiri")
document.add_paragraph(last_month_price.text)
document.add_paragraph("Yıllık Getiri")
document.add_paragraph(last_year_price.text)
# download xlsx
the_url = "https://www.tefas.gov.tr/FonKarsilastirma.aspx"
driver.get(the_url)
input_element_start_date=driver.find_element_by_css_selector('input[id = "MainContent_TextBoxStartDate"]')
input_element_start_date.send_keys(past)
input_element_finish_date=driver.find_element_by_css_selector('input[id = "MainContent_TextBoxEndDate"]')
input_element_finish_date.send_keys(today)
submit_button=driver.find_element_by_css_selector('input#MainContent_ButtonSearchDates.fund-compare-button')
submit_button.click()
time.sleep(2)
driver.set_window_size(1280, 1800)
time.sleep(2)
screent_shoot = str(current_path) + "/1.png"
driver.save_screenshot(screent_shoot)
save_button=driver.find_element_by_css_selector('input#MainContent_ImageButtonExcelGenel.export-img')
save_button.click()
time.sleep(2)
driver.execute_script("""__doPostBack('ctl00$MainContent$GridViewFundReturn','Page$2')""")
time.sleep(2)
driver.set_window_size(1280, 1800)
time.sleep(2)
screent_shoot = str(current_path) + "/1a.png"
driver.save_screenshot(screent_shoot)
## XLSX
xls = pd.ExcelFile(str(current_path) + "/FonTurkey_Fon_Karsilastirma.xlsx",engine='openpyxl')
df1 = pd.read_excel(xls, 'Getiri Bazlı')
df1 = df1[~df1['Şemsiye Fon Türü'].isin(['Serbest Şemsiye Fonu'])]
df1=df1.sort_values(by='Getiri', ascending=False)
df2=df1.sort_values(by='Getiri', ascending=True)
document.add_page_break()
document.add_heading("Geçen Haftanın en iyileri - Tablo ", level=1)
document.add_paragraph('Tarih aralığı ' + str(past) + "----" + str(today), style='Intense Quote')
table = document.add_table(rows=1, cols=4,style='Table Grid')
table.allow_autofit=True
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Fon Kodu'
hdr_cells[1].text = 'Fon Adı'
hdr_cells[2].text = 'Şemsiye Fon Türü'
hdr_cells[3].text = 'Getiri'
for i in range (20):
row_cells = table.add_row().cells
row_cells[0].text = df1.iloc[i]['Fon Kodu']
row_cells[1].text = df1.iloc[i]['Fon Adı']
row_cells[2].text = df1.iloc[i]['Şemsiye Fon Türü']
row_cells[3].text = str(df1.iloc[i]['Getiri'])
###
document.add_page_break()
document.add_heading('Geçen Hafta Bizimkiler - Tablo' , level=1)
document.add_paragraph('Tarih aralığı ' + str(past) + "----" + str(today), style='Intense Quote')
table = document.add_table(rows=1, cols=4,style='Table Grid')
table.allow_autofit=True
parsing_df1=df1[df1['Fon Kodu'].str.contains("NNF|TCD|AOY|AFS|MAC|AFV|AFA|TGE|GTA|GPU|GUH|GPB|OPH|OPI|ODV|ARM") == True]
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Fon Kodu'
hdr_cells[1].text = 'Fon Adı'
hdr_cells[2].text = 'Şemsiye Fon Türü'
hdr_cells[3].text = 'Getiri'
for i in range (len(parsing_df1)):
row_cells = table.add_row().cells
row_cells[0].text = parsing_df1.iloc[i]['Fon Kodu']
row_cells[1].text = parsing_df1.iloc[i]['Fon Adı']
row_cells[2].text = parsing_df1.iloc[i]['Şemsiye Fon Türü']
row_cells[3].text = str(parsing_df1.iloc[i]['Getiri'])
###
# Kaybedenler Geçen hafta
document.add_page_break()
document.add_heading("Geçen Haftanın en Kötüler - Tablo ", level=1)
document.add_paragraph('Tarih aralığı ' + str(past) + "----" + str(today), style='Intense Quote')
table = document.add_table(rows=1, cols=4,style='Table Grid')
table.allow_autofit=True
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Fon Kodu'
hdr_cells[1].text = 'Fon Adı'
hdr_cells[2].text = 'Şemsiye Fon Türü'
hdr_cells[3].text = 'Getiri'
for i in range (20):
row_cells = table.add_row().cells
row_cells[0].text = df2.iloc[i]['Fon Kodu']
row_cells[1].text = df2.iloc[i]['Fon Adı']
row_cells[2].text = df2.iloc[i]['Şemsiye Fon Türü']
row_cells[3].text = str(df2.iloc[i]['Getiri'])
###
document.add_page_break()
###
document.add_page_break()
document.add_heading('Geçen Haftanın En İyileri - Resim' , level=1)
document.add_paragraph('Tarih aralığı ' + str(past) + "----" + str(today), style='Intense Quote')
p = document.add_paragraph()
r = p.add_run()
r.add_picture(str(current_path) + "/1.png",width=Inches(5.5), height=Inches(7.7))
r = p.add_run()
r.add_picture(str(current_path) + "/1a.png",width=Inches(5.5), height=Inches(7.7))
the_url = "https://www.tefas.gov.tr/FonKarsilastirma.aspx"
driver.get(the_url)
input_element_start_date=driver.find_element_by_css_selector('input[id = "MainContent_TextBoxStartDate"]')
input_element_start_date.send_keys(past2)
input_element_finish_date=driver.find_element_by_css_selector('input[id = "MainContent_TextBoxEndDate"]')
input_element_finish_date.send_keys(today)
submit_button=driver.find_element_by_css_selector('input#MainContent_ButtonSearchDates.fund-compare-button')
submit_button.click()
time.sleep(2)
driver.set_window_size(1280, 1800)
time.sleep(2)
screent_shoot = str(current_path) + "/2.png"
driver.save_screenshot(screent_shoot)
time.sleep(2)
os.remove(str(current_path) + "/FonTurkey_Fon_Karsilastirma.xlsx")
save_button=driver.find_element_by_css_selector('input#MainContent_ImageButtonExcelGenel.export-img')
save_button.click()
time.sleep(2)
driver.execute_script("""__doPostBack('ctl00$MainContent$GridViewFundReturn','Page$2')""")
time.sleep(2)
driver.set_window_size(1280, 1800)
time.sleep(2)
screent_shoot = str(current_path) + "/2a.png"
driver.save_screenshot(screent_shoot)
driver.close()
## XLSX
xls = pd.ExcelFile(str(current_path) + "/FonTurkey_Fon_Karsilastirma.xlsx",engine='openpyxl')
df1 = pd.read_excel(xls, 'Getiri Bazlı')
df1 = df1[~df1['Şemsiye Fon Türü'].isin(['Serbest Şemsiye Fonu'])]
df1=df1.sort_values(by='Getiri', ascending=False)
df2=df1.sort_values(by='Getiri', ascending=True)
document.add_page_break()
document.add_heading("Geçen 2 Haftanın en iyileri - Tablo", level=1)
document.add_paragraph('Tarih aralığı ' + str(past2) + "----" + str(today), style='Intense Quote')
table = document.add_table(rows=1, cols=4,style='Table Grid')
table.allow_autofit=True
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Fon Kodu'
hdr_cells[1].text = 'Fon Adı'
hdr_cells[2].text = 'Şemsiye Fon Türü'
hdr_cells[3].text = 'Getiri'
for i in range (20):
row_cells = table.add_row().cells
row_cells[0].text = df1.iloc[i]['Fon Kodu']
row_cells[1].text = df1.iloc[i]['Fon Adı']
row_cells[2].text = df1.iloc[i]['Şemsiye Fon Türü']
row_cells[3].text = str(df1.iloc[i]['Getiri'])
###
##
document.add_page_break()
document.add_heading('Geçen 2 Hafta Bizimkiler - Tablo' , level=1)
document.add_paragraph('Tarih aralığı ' + str(past2) + "----" + str(today), style='Intense Quote')
table = document.add_table(rows=1, cols=4,style='Table Grid')
table.allow_autofit=True
parsing_df1=df1[df1['Fon Kodu'].str.contains("NNF|TCD|AOY|AFS|MAC|AFV|AFA|TGE|GTA|GPU|GUH|GPB|OPH|OPI|ODV|ARM") == True]
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Fon Kodu'
hdr_cells[1].text = 'Fon Adı'
hdr_cells[2].text = 'Şemsiye Fon Türü'
hdr_cells[3].text = 'Getiri'
for i in range (len(parsing_df1)):
row_cells = table.add_row().cells
row_cells[0].text = parsing_df1.iloc[i]['Fon Kodu']
row_cells[1].text = parsing_df1.iloc[i]['Fon Adı']
row_cells[2].text = parsing_df1.iloc[i]['Şemsiye Fon Türü']
row_cells[3].text = str(parsing_df1.iloc[i]['Getiri'])
##
document.add_page_break()
##
# En kötüler geçen 2 hafta
document.add_page_break()
document.add_heading("Geçen 2 Haftanın en Kötüler - Tablo ", level=1)
document.add_paragraph('Tarih aralığı ' + str(past2) + "----" + str(today), style='Intense Quote')
table = document.add_table(rows=1, cols=4,style='Table Grid')
table.allow_autofit=True
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Fon Kodu'
hdr_cells[1].text = 'Fon Adı'
hdr_cells[2].text = 'Şemsiye Fon Türü'
hdr_cells[3].text = 'Getiri'
for i in range (20):
row_cells = table.add_row().cells
row_cells[0].text = df2.iloc[i]['Fon Kodu']
row_cells[1].text = df2.iloc[i]['Fon Adı']
row_cells[2].text = df2.iloc[i]['Şemsiye Fon Türü']
row_cells[3].text = str(df2.iloc[i]['Getiri'])
###
document.add_page_break()
#
document.add_heading('Geçen 2 Haftanın En İyileri - Resim', level=1)
document.add_paragraph('Tarih aralığı ' + str(past2) + "----" + str(today), style='Intense Quote')
p = document.add_paragraph()
r = p.add_run()
r.add_picture(str(current_path) + "/2.png",width=Inches(6.0), height=Inches(7.7))
r = p.add_run()
r.add_picture(str(current_path) + "/2a.png",width=Inches(6.0), height=Inches(7.7))
document.save('Fon_Report_' + str(date_time_file) + '.docx')
| 31.320442
| 122
| 0.716617
| 1,732
| 11,338
| 4.484411
| 0.142032
| 0.062315
| 0.04635
| 0.029355
| 0.802755
| 0.774173
| 0.747264
| 0.735677
| 0.733102
| 0.706837
| 0
| 0.022636
| 0.123302
| 11,338
| 361
| 123
| 31.407202
| 0.758551
| 0.035103
| 0
| 0.684211
| 0
| 0.008772
| 0.24169
| 0.078063
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.004386
| 0.039474
| 0
| 0.039474
| 0.004386
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
3309bab48297a641cac1d4a314e783f4dd5823ad
| 3,648
|
py
|
Python
|
psa/migrations/0019_auto_20210603_1606.py
|
Nels885/csd_dashboard
|
aa5a3b970c50a2a93af722f962bd87c3728f233c
|
[
"MIT"
] | null | null | null |
psa/migrations/0019_auto_20210603_1606.py
|
Nels885/csd_dashboard
|
aa5a3b970c50a2a93af722f962bd87c3728f233c
|
[
"MIT"
] | null | null | null |
psa/migrations/0019_auto_20210603_1606.py
|
Nels885/csd_dashboard
|
aa5a3b970c50a2a93af722f962bd87c3728f233c
|
[
"MIT"
] | null | null | null |
# Generated by Django 3.2.3 on 2021-06-03 14:06
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('psa', '0018_delete_emfmodel'),
]
operations = [
migrations.AlterField(
model_name='corvet',
name='bsi',
field=models.ForeignKey(blank=True, limit_choices_to={'type': 'BSI'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='psa.ecu'),
),
migrations.AlterField(
model_name='corvet',
name='bsm',
field=models.ForeignKey(blank=True, limit_choices_to={'type': 'BSM'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='psa.ecu'),
),
migrations.AlterField(
model_name='corvet',
name='btel',
field=models.ForeignKey(blank=True, limit_choices_to={'type': 'NAV'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='psa.multimedia'),
),
migrations.AlterField(
model_name='corvet',
name='cmm',
field=models.ForeignKey(blank=True, limit_choices_to={'type': 'CMM'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='psa.ecu'),
),
migrations.AlterField(
model_name='corvet',
name='emf',
field=models.ForeignKey(blank=True, limit_choices_to={'type': 'EMF'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='psa.ecu'),
),
migrations.AlterField(
model_name='corvet',
name='radio',
field=models.ForeignKey(blank=True, limit_choices_to={'type': 'RAD'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='psa.multimedia'),
),
migrations.CreateModel(
name='CorvetProduct',
fields=[
('corvet', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='prods', serialize=False, to='psa.corvet')),
('bsi', models.ForeignKey(blank=True, limit_choices_to={'type': 'BSI'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_bsi', to='psa.ecu')),
('bsm', models.ForeignKey(blank=True, limit_choices_to={'type': 'BSM'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_bsm', to='psa.ecu')),
('btel', models.ForeignKey(blank=True, limit_choices_to={'type': 'NAV'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_btel', to='psa.multimedia')),
('cmm', models.ForeignKey(blank=True, limit_choices_to={'type': 'CMM'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_cmm', to='psa.ecu')),
('emf', models.ForeignKey(blank=True, limit_choices_to={'type': 'EMF'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_emf', to='psa.ecu')),
('hdc', models.ForeignKey(blank=True, limit_choices_to={'type': 'HDC'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_hdc', to='psa.ecu')),
('radio', models.ForeignKey(blank=True, limit_choices_to={'type': 'RAD'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corvet_radio', to='psa.multimedia')),
],
options={
'verbose_name': 'produits CORVET',
'ordering': ['corvet'],
},
),
]
| 58.83871
| 198
| 0.629386
| 447
| 3,648
| 4.948546
| 0.143177
| 0.057866
| 0.094937
| 0.149186
| 0.78255
| 0.78255
| 0.738246
| 0.738246
| 0.718807
| 0.705244
| 0
| 0.006543
| 0.203947
| 3,648
| 61
| 199
| 59.803279
| 0.755165
| 0.012336
| 0
| 0.345455
| 1
| 0
| 0.129964
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.036364
| 0
| 0.090909
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
331590520b7b7016620955ae851d9646c86ad9ad
| 70
|
py
|
Python
|
fingym/__init__.py
|
entrpn/fingym
|
9d73b93a3f287981e6353525f7405c9af910c663
|
[
"Apache-2.0"
] | 17
|
2020-02-26T07:24:11.000Z
|
2021-09-03T17:49:10.000Z
|
fingym/__init__.py
|
entrpn/fingym
|
9d73b93a3f287981e6353525f7405c9af910c663
|
[
"Apache-2.0"
] | 3
|
2020-02-24T23:07:48.000Z
|
2020-03-24T21:48:53.000Z
|
fingym/__init__.py
|
entrpn/fingym
|
9d73b93a3f287981e6353525f7405c9af910c663
|
[
"Apache-2.0"
] | 4
|
2020-02-20T15:15:55.000Z
|
2021-07-05T01:15:29.000Z
|
from fingym.fingym import make
from fingym.envs.spy_envs import SpyEnv
| 35
| 39
| 0.857143
| 12
| 70
| 4.916667
| 0.583333
| 0.338983
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.1
| 70
| 2
| 39
| 35
| 0.936508
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
3332d2614a66b60c544476b2a419135f007b0b90
| 2,163
|
py
|
Python
|
hog/tests/04.py
|
luv-sic/composing-programs
|
27391ac844df045b865524f1936682a0872569b5
|
[
"MIT"
] | 1
|
2021-11-27T08:53:01.000Z
|
2021-11-27T08:53:01.000Z
|
hog/tests/04.py
|
luvsic3/composing-programs
|
27391ac844df045b865524f1936682a0872569b5
|
[
"MIT"
] | null | null | null |
hog/tests/04.py
|
luvsic3/composing-programs
|
27391ac844df045b865524f1936682a0872569b5
|
[
"MIT"
] | null | null | null |
test = {
'name': 'Question 4',
'points': 1,
'suites': [
{
'cases': [
{
'code': r"""
>>> is_swap(19, 91)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(19, 19)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(123, 12)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(1, 2)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(12, 2)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(2, 2)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(36, 35)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(114, 12)
True
>>> is_swap(108, 7)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(18, 108)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(8, 108)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(20, 0)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(10, 16)
True
""",
'hidden': False,
'locked': False
}
],
'scored': True,
'setup': r"""
>>> from hog import *
""",
'teardown': '',
'type': 'doctest'
}
]
}
| 18.808696
| 30
| 0.279242
| 155
| 2,163
| 3.812903
| 0.258065
| 0.13198
| 0.142132
| 0.22335
| 0.780034
| 0.71066
| 0.71066
| 0.71066
| 0.71066
| 0.263959
| 0
| 0.052254
| 0.548775
| 2,163
| 114
| 31
| 18.973684
| 0.553279
| 0
| 0
| 0.54386
| 0
| 0
| 0.465557
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.008772
| 0
| 0.008772
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
333f49c16549c2bfda1ac914d9a8635eff77d421
| 139
|
py
|
Python
|
movieapp/admin.py
|
jejurkarganesh/gbjmovieapi
|
3642ddfcee4ed7a9ba6d90fd90175da866ddc1fe
|
[
"MIT"
] | null | null | null |
movieapp/admin.py
|
jejurkarganesh/gbjmovieapi
|
3642ddfcee4ed7a9ba6d90fd90175da866ddc1fe
|
[
"MIT"
] | null | null | null |
movieapp/admin.py
|
jejurkarganesh/gbjmovieapi
|
3642ddfcee4ed7a9ba6d90fd90175da866ddc1fe
|
[
"MIT"
] | null | null | null |
from django.contrib import admin
from . models import *
admin.site.register(Movie)
admin.site.register(Genre)
admin.site.register(Poster)
| 19.857143
| 32
| 0.798561
| 20
| 139
| 5.55
| 0.55
| 0.243243
| 0.459459
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.093525
| 139
| 7
| 33
| 19.857143
| 0.880952
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.4
| 0
| 0.4
| 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
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
6828c45f2930d146f6b649683845488d3eb80dde
| 32
|
py
|
Python
|
project/tasks/models/__init__.py
|
maguayo/django-todo-api
|
b15b9a6dbb662d5bddb55f0b4152ad3d13b6b756
|
[
"MIT"
] | null | null | null |
project/tasks/models/__init__.py
|
maguayo/django-todo-api
|
b15b9a6dbb662d5bddb55f0b4152ad3d13b6b756
|
[
"MIT"
] | null | null | null |
project/tasks/models/__init__.py
|
maguayo/django-todo-api
|
b15b9a6dbb662d5bddb55f0b4152ad3d13b6b756
|
[
"MIT"
] | null | null | null |
from .tasks import Task # noqa
| 16
| 31
| 0.71875
| 5
| 32
| 4.6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.21875
| 32
| 1
| 32
| 32
| 0.92
| 0.125
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
6862db50b2263310b7a8518ce5587406a9112cc3
| 168
|
py
|
Python
|
backend/pugorugh/admin.py
|
adamkielar/pugorugh_api
|
f21dcb007595568756d98c2a08f8d8d31401c263
|
[
"MIT"
] | null | null | null |
backend/pugorugh/admin.py
|
adamkielar/pugorugh_api
|
f21dcb007595568756d98c2a08f8d8d31401c263
|
[
"MIT"
] | null | null | null |
backend/pugorugh/admin.py
|
adamkielar/pugorugh_api
|
f21dcb007595568756d98c2a08f8d8d31401c263
|
[
"MIT"
] | null | null | null |
from django.contrib import admin
from pugorugh import models
admin.site.register(models.Dog)
admin.site.register(models.UserPref)
admin.site.register(models.UserDog)
| 21
| 36
| 0.827381
| 24
| 168
| 5.791667
| 0.5
| 0.194245
| 0.366906
| 0.496403
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.077381
| 168
| 7
| 37
| 24
| 0.896774
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.4
| 0
| 0.4
| 0
| 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
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
68736d3decdf8333625195170923c14457739186
| 39
|
py
|
Python
|
sensorLoggers/logentry.py
|
zjcers/ecohawks-battery
|
dd214584fc141aca64702d1093f218a3238ab22a
|
[
"MIT"
] | 2
|
2016-11-16T05:53:03.000Z
|
2017-09-27T15:12:20.000Z
|
sensorLoggers/logentry.py
|
zjcers/ecohawks-battery
|
dd214584fc141aca64702d1093f218a3238ab22a
|
[
"MIT"
] | 2
|
2016-04-29T01:38:30.000Z
|
2016-09-21T15:41:20.000Z
|
sensorLoggers/logentry.py
|
zjcers/ecohawks-battery
|
dd214584fc141aca64702d1093f218a3238ab22a
|
[
"MIT"
] | null | null | null |
class Entry(dict):
def derp():
pass
| 9.75
| 18
| 0.641026
| 6
| 39
| 4.166667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.205128
| 39
| 3
| 19
| 13
| 0.806452
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| true
| 0.333333
| 0
| 0
| 0.666667
| 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
| 1
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
688dd6bb2b274d68840eef03670bdd70713973d4
| 34
|
py
|
Python
|
accounts/admin/__init__.py
|
UserGraund/main_application
|
a814daf816858c94035191e01adae0a6b4d0bb42
|
[
"MIT"
] | null | null | null |
accounts/admin/__init__.py
|
UserGraund/main_application
|
a814daf816858c94035191e01adae0a6b4d0bb42
|
[
"MIT"
] | null | null | null |
accounts/admin/__init__.py
|
UserGraund/main_application
|
a814daf816858c94035191e01adae0a6b4d0bb42
|
[
"MIT"
] | null | null | null |
from .account import AccountAdmin
| 17
| 33
| 0.852941
| 4
| 34
| 7.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.117647
| 34
| 1
| 34
| 34
| 0.966667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
d79fe6225d869da5f302b92dd41e05f3a1ce4788
| 32
|
py
|
Python
|
scripts/__init__.py
|
Mr-TalhaIlyas/EMPatches
|
c2785952bbcbac2a8b7bac30c9b64f239f33e8dc
|
[
"MIT"
] | null | null | null |
scripts/__init__.py
|
Mr-TalhaIlyas/EMPatches
|
c2785952bbcbac2a8b7bac30c9b64f239f33e8dc
|
[
"MIT"
] | null | null | null |
scripts/__init__.py
|
Mr-TalhaIlyas/EMPatches
|
c2785952bbcbac2a8b7bac30c9b64f239f33e8dc
|
[
"MIT"
] | null | null | null |
from .empatches import EMPatches
| 32
| 32
| 0.875
| 4
| 32
| 7
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.09375
| 32
| 1
| 32
| 32
| 0.965517
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
cc0e17ee0bc188f5e8239bf0cbd35a92b56bb5ec
| 33,675
|
py
|
Python
|
Packs/OpsGenie/Integrations/OpsGenieV3/OpsGenieV3_test.py
|
diCagri/content
|
c532c50b213e6dddb8ae6a378d6d09198e08fc9f
|
[
"MIT"
] | 799
|
2016-08-02T06:43:14.000Z
|
2022-03-31T11:10:11.000Z
|
Packs/OpsGenie/Integrations/OpsGenieV3/OpsGenieV3_test.py
|
diCagri/content
|
c532c50b213e6dddb8ae6a378d6d09198e08fc9f
|
[
"MIT"
] | 9,317
|
2016-08-07T19:00:51.000Z
|
2022-03-31T21:56:04.000Z
|
Packs/OpsGenie/Integrations/OpsGenieV3/OpsGenieV3_test.py
|
diCagri/content
|
c532c50b213e6dddb8ae6a378d6d09198e08fc9f
|
[
"MIT"
] | 1,297
|
2016-08-04T13:59:00.000Z
|
2022-03-31T23:43:06.000Z
|
import pytest
import io
from CommonServerPython import *
import OpsGenieV3
from unittest import mock
def util_load_json(path):
with io.open(path, mode='r', encoding='utf-8') as f:
return json.loads(f.read())
def test_create_alert_wrong_responders():
"""
Given:
- An app client object
When:
- Calling function create_alert with argument responders in the wrong format
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.create_alert(mock_client, {'responders': ['team', 'id']})
def test_create_alert(mocker):
"""
Given:
- An app client object
- Responders "team,id,123"
When:
- Calling function create_alert with argument responders in the right format
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'create_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/create_alert.json'))
res = OpsGenieV3.create_alert(mock_client, {'responders': "team,id,123"})
assert (res.raw_response == util_load_json('test_data/create_alert.json'))
def test_get_alerts(mocker):
"""
Given:
- An app client object
- Limit = 1
When:
- Calling function list_alerts
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_alerts',
return_value=util_load_json('test_data/get_alerts.json'))
res = OpsGenieV3.get_alerts(mock_client, {"limit": 1})
assert (len(res.outputs) == 1)
def test_get_alerts_going_to_right_function():
"""
Given:
- An app client object
When:
- Calling function get_alerts
Case A: "alert-id" = 1234
Case B: No arguments
Then:
- Ensure the right function was called
Case A: Called get_alert
Case B: Called list_alerts
"""
mock_client = OpsGenieV3.Client(base_url="")
mock_client.get_alert = mock.MagicMock()
OpsGenieV3.get_alerts(mock_client, {"alert-id": 1234})
assert mock_client.get_alert.called
OpsGenieV3.list_alerts = mock.MagicMock()
OpsGenieV3.get_alerts(mock_client, {})
assert OpsGenieV3.list_alerts.called
def test_delete_alert(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
When:
- Calling function delete_alert
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'delete_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/delete_alert.json'))
res = OpsGenieV3.delete_alert(mock_client, {"alert-id": 1234})
assert (res.raw_response == util_load_json('test_data/delete_alert.json'))
def test_ack_alert(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
When:
- Calling function ack_alert
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'ack_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/ack_alert.json'))
res = OpsGenieV3.ack_alert(mock_client, {"alert-id": 1234})
assert (res.raw_response == util_load_json('test_data/ack_alert.json'))
def test_close_alert(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
When:
- Calling function close_alert
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'close_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/close_alert.json'))
res = OpsGenieV3.close_alert(mock_client, {"alert-id": 1234})
assert (res.raw_response == util_load_json('test_data/close_alert.json'))
def test_assign_alert_without_args():
"""
Given:
- An app client object
When:
- Calling function assign_alert with no arguments
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.assign_alert(mock_client, {})
def test_assign_alert(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
- Owner_id = 123
When:
- Calling function assign_alert
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'assign_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/assign_alert.json'))
res = OpsGenieV3.assign_alert(mock_client, {"alert-id": 1234, "owner_id": 123})
assert (res.raw_response == util_load_json('test_data/assign_alert.json'))
def test_add_responder_alert_wrong_responders():
"""
Given:
- An app client object
When:
- Calling function add_responder_alert with argument responders in the wrong format
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.add_responder_alert(mock_client, {'responders': ['team', 'id']})
def test_add_responder_alert(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
- owner_id = 123
When:
- Calling function add_responder_alert
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'add_responder_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/add_responder_alert.json'))
res = OpsGenieV3.add_responder_alert(mock_client, {"alert-id": 1234, "owner_id": 123})
assert (res.raw_response == util_load_json('test_data/add_responder_alert.json'))
def test_get_escalations_without_args():
"""
Given:
- An app client object
When:
- Calling function escalate_alert with no arguments
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.escalate_alert(mock_client, {})
def test_get_escalations(mocker):
"""
Given:
- An app client object
When:
- Calling function get_escalations
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'get_escalations',
return_value=util_load_json('test_data/get_escalations.json'))
res = OpsGenieV3.get_escalations(mock_client, {})
assert len(res.outputs) == 2
def test_get_escalation(mocker):
"""
Given:
- An app client object
- escalation_id = 123
When:
- Calling function get_escalations
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'get_escalation',
return_value=util_load_json('test_data/get_escalations.json'))
res = OpsGenieV3.get_escalations(mock_client, {"escalation_id": 123})
assert len(res.outputs) == 2
def test_escalate_alert_without_args():
"""
Given:
- An app client object
When:
- Calling function escalate_alert with no arguments
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.escalate_alert(mock_client, {})
def test_escalate_alert(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
= escalation_id = 123
When:
- Calling function escalate_alert
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'escalate_alert',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/escalate_alert.json'))
res = OpsGenieV3.escalate_alert(mock_client, {"alert-id": 1234, "escalation_id": 123})
assert (res.raw_response == util_load_json('test_data/escalate_alert.json'))
def test_add_alert_tag(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
- tags = [1,2]
When:
- Calling function add_alert_tag
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'add_alert_tag',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/add_alert_tag.json'))
res = OpsGenieV3.add_alert_tag(mock_client, {"alert-id": 1234, "tags": [1, 2]})
assert (res.raw_response == util_load_json('test_data/add_alert_tag.json'))
def test_remove_alert_tag(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
- tags = [1,2]
When:
- Calling function remove_alert_tag
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'remove_alert_tag',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/remove_alert_tag.json'))
res = OpsGenieV3.remove_alert_tag(mock_client, {"alert-id": 1234, "tags": [1, 2]})
assert (res.raw_response == util_load_json('test_data/remove_alert_tag.json'))
def test_get_alert_attachments(mocker):
"""
Given:
- An app client object
- Alert-id = 1234
When:
- Calling function get_alert_attachments
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'get_alert_attachments',
return_value=util_load_json('test_data/get_alert_attachments.json'))
res = OpsGenieV3.get_alert_attachments(mock_client, {"alert-id": 1234})
assert (res.readable_output == "### OpsGenie Attachment\n**No entries.**\n")
def test_get_schedules():
"""
Given:
- An app client object
When:
- Calling function get_schedules
Case A: "schedule_id" = 1234
Case B: No arguments
Then:
- Ensure the right function was called
Case A: Called get_schedule
Case B: Called list_schedules
"""
mock_client = OpsGenieV3.Client(base_url="")
mock_client.get_schedule = mock.MagicMock()
OpsGenieV3.get_schedules(mock_client, {"schedule_id": 1234})
assert mock_client.get_schedule.called
mock_client.list_schedules = mock.MagicMock()
OpsGenieV3.get_schedules(mock_client, {})
assert mock_client.list_schedules.called
def test_get_schedule_overrides_without_args():
"""
Given:
- An app client object
When:
- Calling function get_schedule_overrides with no arguments
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.get_schedule_overrides(mock_client, {})
def test_get_schedule_without_args():
"""
Given:
- An app client object
When:
- Calling function get_schedule with no arguments
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
mock_client.get_schedule({})
def test_get_schedule_overrides():
"""
Given:
- An app client object
When:
- Calling function get_schedule_overrides
Case A: "schedule_id" = 1234 , override_alias = 123
Case B: No arguments
Then:
- Ensure the right function was called
Case A: Called get_schedule_override
Case B: Called list_schedule_overrides
"""
mock_client = OpsGenieV3.Client(base_url="")
mock_client.get_schedule_override = mock.MagicMock()
OpsGenieV3.get_schedule_overrides(mock_client, {"schedule_id": 1234, "override_alias": 123})
assert mock_client.get_schedule_override.called
mock_client.list_schedule_overrides = mock.MagicMock()
OpsGenieV3.get_schedule_overrides(mock_client, {"schedule_id": 1234})
assert mock_client.list_schedule_overrides.called
def test_get_on_call_without_args():
"""
Given:
- An app client object
When:
- Calling function get_on_call with no arguments
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.get_on_call(mock_client, {})
def test_get_on_call(mocker):
"""
Given:
- An app client object
- schedule_id = 1234
When:
- Calling function get_on_call
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'get_on_call',
return_value=util_load_json('test_data/delete_incident.json'))
res = OpsGenieV3.get_on_call(mock_client, {"schedule_id": 1234})
assert (res.raw_response == util_load_json('test_data/delete_incident.json'))
def test_create_incident_wrong_args():
"""
Given:
- An app client object
When:
- Calling function create_incident with argument responders in the wrong format
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.create_incident(mock_client, {'responders': ['team', 'id']})
def test_create_incident(mocker):
"""
Given:
- An app client object
When:
- Calling function create_incident
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'create_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/create_incident.json'))
res = OpsGenieV3.create_incident(mock_client, {})
assert (res.raw_response == util_load_json('test_data/create_incident.json'))
def test_delete_incident(mocker):
"""
Given:
- incident_id = 1234
When:
- Calling function delete_incident
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'delete_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/delete_incident.json'))
res = OpsGenieV3.delete_incident(mock_client, {"incident_id": 1234})
assert (res.raw_response == util_load_json('test_data/delete_incident.json'))
def test_get_incidents(mocker):
"""
Given:
- An app client object
- limit = 1
When:
- Calling function get_incidents
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_incidents',
return_value=util_load_json('test_data/get_incidents.json'))
res = OpsGenieV3.get_incidents(mock_client, {"limit": 1})
assert (len(res.outputs) == 1)
def test_responders_to_json():
"""
Given:
- An app client object
- responders = ["team", "id", 1, "schedule", "name", "a"]
- responder_key = 'responders'
When:
- Calling function responders_to_json
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
res = mock_client.responders_to_json(responders=["team", "id", 1, "schedule", "name", "a"],
responder_key='responders')
assert (res == {'responders': [{'id': 1, 'type': 'team'}, {'name': 'a', 'type': 'schedule'}]})
def test_get_incidents_going_to_right_function():
"""
Given:
- An app client object
When:
- Calling function get_incidents
Case A: "incident_id" = 1234
Case B: No arguments
Then:
- Ensure the right function was called
Case A: Called get_incident
Case B: Called list_incidents
"""
mock_client = OpsGenieV3.Client(base_url="")
mock_client.get_incident = mock.MagicMock()
OpsGenieV3.get_incidents(mock_client, {"incident_id": 1234})
assert mock_client.get_incident.called
OpsGenieV3.list_incidents = mock.MagicMock()
OpsGenieV3.get_incidents(mock_client, {})
assert OpsGenieV3.list_incidents.called
def test_close_incident(mocker):
"""
Given:
- An app client object
- incident_id = 1234
When:
- Calling function close_incident
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'close_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/close_incident.json'))
res = OpsGenieV3.close_incident(mock_client, {"incident_id": 1234})
assert (res.raw_response == util_load_json('test_data/close_incident.json'))
def test_resolve_incident(mocker):
"""
Given:
- An app client object
- incident_id = 1234
When:
- Calling function resolve_incident
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'resolve_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/resolve_incident.json'))
res = OpsGenieV3.resolve_incident(mock_client, {"incident_id": 1234})
assert (res.raw_response == util_load_json('test_data/resolve_incident.json'))
def test_add_responder_incident_wrong_args():
"""
Given:
- An app client object
When:
- Calling function add_responder_incident with argument responders in the wrong format
Then:
- Ensure the resulted will raise an exception.
"""
mock_client = OpsGenieV3.Client(base_url="")
with pytest.raises(DemistoException):
OpsGenieV3.add_responder_incident(mock_client, {'responders': ['team', 'id']})
def test_add_responder_incident(mocker):
"""
Given:
- An app client object
- incident_id = 1234
- responders = ["team", "id", "name"]
When:
- Calling function add_responder_incident
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'add_responder_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/add_responder_incident.json'))
res = OpsGenieV3.add_responder_incident(mock_client, {"incident_id": 1234, "responders": ["team", "id", "name"]})
assert (res.raw_response == util_load_json('test_data/add_responder_incident.json'))
def test_add_tag_incident(mocker):
"""
Given:
- An app client object
- incident_id = 1234
- tags = [1, 2]
When:
- Calling function add_tag_incident
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'add_tag_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/add_tag_incident.json'))
res = OpsGenieV3.add_tag_incident(mock_client, {"incident_id": 1234, "tags": [1, 2]})
assert (res.raw_response == util_load_json('test_data/add_tag_incident.json'))
def test_remove_tag_incident(mocker):
"""
Given:
- An app client object
- incident_id = 1234
- tags = [1, 2]
When:
- Calling function remove_tag_incident
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'remove_tag_incident',
return_value=util_load_json('test_data/request.json'))
mocker.patch.object(mock_client, 'get_request',
return_value=util_load_json('test_data/remove_tag_incident.json'))
res = OpsGenieV3.remove_tag_incident(mock_client, {"incident_id": 1234, "tags": [1, 2]})
assert (res.raw_response == util_load_json('test_data/remove_tag_incident.json'))
def test_get_teams(mocker):
"""
Given:
- An app client object
When:
- Calling function get_teams
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_teams',
return_value=util_load_json('test_data/get_teams.json'))
res = OpsGenieV3.get_teams(mock_client, {})
assert len(res.outputs) == 2
def test_get_teams_going_to_right_function():
"""
Given:
- An app client object
When:
- Calling function get_teams
Case A: "team_id" = 1234
Case B: No arguments
Then:
- Ensure the right function was called
Case A: Called get_team
Case B: Called list_teams
"""
mock_client = OpsGenieV3.Client(base_url="")
mock_client.get_team = mock.MagicMock()
OpsGenieV3.get_teams(mock_client, {"team_id": 1234})
assert mock_client.get_team.called
mock_client.list_teams = mock.MagicMock()
OpsGenieV3.get_teams(mock_client, {})
assert mock_client.list_teams.called
def test_fetch_incidents_command(mocker):
"""
Given:
- An app client object
When:
- Calling function fetch_incidents_command
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_alerts',
return_value=util_load_json('test_data/get_alerts.json'))
mocker.patch.object(mock_client, 'list_incidents',
return_value=util_load_json('test_data/get_incidents.json'))
mocker.patch.object(OpsGenieV3, '_get_utc_now', return_value=datetime(2021, 11, 26))
mocker.patch.object(OpsGenieV3, '_parse_fetch_time', return_value='2021-11-23T12:19:48Z')
res, last_run = OpsGenieV3.fetch_incidents_command(mock_client, {"max_fetch": 1})
assert len(res) == 2
assert last_run == {'Alerts': {'lastRun': '2021-11-26T00:00:00Z',
'next_page': 'https://api.opsgenie.com/v2/alerts?limit=1&sort='
'createdAt&offset=1&order=desc'},
'Incidents': {'lastRun': '2021-11-26T00:00:00Z',
'next_page': 'https://api.opsgenie.com/v1/incidents?limit=1&'
'sort=insertedAt&offset=1&order=desc'}}
def test_fetch_incidents_command_no_result(mocker):
"""
Given:
- An app client object
- max_fetch = 1
When:
- Calling function fetch_incidents_command
- The list_alerts and list_incidents functions returns empty response
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_alerts',
return_value=util_load_json('test_data/empty_response.json'))
mocker.patch.object(mock_client, 'list_incidents',
return_value=util_load_json('test_data/empty_response.json'))
mocker.patch.object(OpsGenieV3, '_get_utc_now', return_value=datetime(2021, 11, 26))
mocker.patch.object(OpsGenieV3, '_parse_fetch_time', return_value='2021-11-23T12:19:48Z')
res, last_run = OpsGenieV3.fetch_incidents_command(mock_client, {"max_fetch": 1})
assert len(res) == 0
assert last_run == {'Alerts': {'lastRun': '2021-11-26T00:00:00Z', 'next_page': None},
'Incidents': {'lastRun': '2021-11-26T00:00:00Z', 'next_page': None}}
def test_fetch_with_paging_only_alerts(mocker):
"""
Given:
- An app client object
- max_fetch = 2
- event_types = OpsGenieV3.ALERT_TYPE
When:
- Calling function fetch_incidents_command
- The list_alerts function returns result with paging
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_alerts',
return_value=util_load_json('test_data/get_alerts.json'))
mocker.patch.object(mock_client, 'get_paged',
return_value=util_load_json('test_data/get_alerts_without_next.json'))
mocker.patch.object(OpsGenieV3, '_get_utc_now', return_value=datetime(2021, 11, 26))
mocker.patch.object(OpsGenieV3, '_parse_fetch_time', return_value='2021-11-23T12:19:48Z')
res, last_run = OpsGenieV3.fetch_incidents_command(mock_client, {"max_fetch": 2,
"event_types": OpsGenieV3.ALERT_TYPE})
assert (last_run == {'Alerts': {'lastRun': '2021-11-26T00:00:00Z',
'next_page': 'https://api.opsgenie.com/v2/alerts?limit=1&sort=createdAt&offset=1&order=desc'},
'Incidents': {'lastRun': None, 'next_page': None}})
mocker.patch.object(demisto, 'getLastRun', return_value=last_run)
res, last_run = OpsGenieV3.fetch_incidents_command(mock_client,
{"max_fetch": 2, "event_types": OpsGenieV3.ALERT_TYPE},
last_run)
assert (last_run == {'Alerts': {'lastRun': '2021-11-26T00:00:00Z', 'next_page': None},
'Incidents': {'lastRun': None, 'next_page': None}})
def test_fetch_with_paging_only_incidents(mocker):
"""
Given:
- An app client object
- max_fetch = 2
- event_types = OpsGenieV3.INCIDENT_TYPE
When:
- Calling function fetch_incidents_command
- The list_incidents function returns result with paging
Then:
- Ensure the return data is correct
"""
mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.2.0"})
mock_client = OpsGenieV3.Client(base_url="")
mocker.patch.object(mock_client, 'list_incidents',
return_value=util_load_json('test_data/get_incidents.json'))
mocker.patch.object(mock_client, 'get_paged',
return_value=util_load_json('test_data/get_incidents_without_next.json'))
mocker.patch.object(OpsGenieV3, '_get_utc_now', return_value=datetime(2021, 11, 26))
mocker.patch.object(OpsGenieV3, '_parse_fetch_time', return_value='2021-11-23T12:19:48Z')
res, last_run = OpsGenieV3.fetch_incidents_command(mock_client, {"max_fetch": 2,
"event_types": OpsGenieV3.INCIDENT_TYPE})
assert (last_run == {'Incidents': {'lastRun': '2021-11-26T00:00:00Z',
'next_page': 'https://api.opsgenie.com/v1/incidents?limit='
'1&sort=insertedAt&offset=1&order=desc'},
'Alerts': {'lastRun': None, 'next_page': None}})
mocker.patch.object(demisto, 'getLastRun', return_value=last_run)
res, last_run = OpsGenieV3.fetch_incidents_command(mock_client,
{"max_fetch": 2, "event_types": OpsGenieV3.INCIDENT_TYPE},
last_run)
assert (last_run == {'Incidents': {'lastRun': '2021-11-26T00:00:00Z', 'next_page': None},
'Alerts': {'lastRun': None, 'next_page': None}})
def test_build_query_fetch():
"""
Given:
- An app client object
- args
- is_fetch_query = True
When:
- Calling function build_query
Then:
- Ensure the return data is correct
"""
args = {
"query": "createdAt < 147039484114",
"status": "Open",
"is_fetch_query": True,
"priority": "P1,P3",
"tags": "1,2"
}
mock_client = OpsGenieV3.Client(base_url="")
res = mock_client.build_query(args)
assert (res == "createdAt < 147039484114 AND status=open AND priority: (P1 OR P3) AND tag: (1 OR 2)")
def test_build_query_not_fetch():
"""
Given:
- An app client object
- args
- is_fetch_query = False
When:
- Calling function build_query
Then:
- Ensure the return data is correct
"""
args = {
"query": "createdAt < 147039484114",
"status": "Open",
"is_fetch_query": False,
"priority": "P1,P3",
"tags": "1,2"
}
mock_client = OpsGenieV3.Client(base_url="")
res = mock_client.build_query(args)
assert (res == "createdAt < 147039484114")
def test_build_query_not_fetch_without_query():
"""
Given:
- An app client object
- args
- is_fetch_query = False
When:
- Calling function build_query
Then:
- Ensure the return data is correct
"""
args = {
"status": "Open",
"is_fetch_query": False,
"priority": "P1,P3",
"tags": "1,2"
}
mock_client = OpsGenieV3.Client(base_url="")
res = mock_client.build_query(args)
assert (res == "status=open AND priority: (P1 OR P3) AND tag: (1 OR 2)")
def test_responders_to_json_empty_value():
"""
Given:
- An app client object
- responders = {}
When:
- Calling function responders_to_json
Then:
- Ensure the return data is correct
"""
mock_client = OpsGenieV3.Client(base_url="")
res = mock_client.responders_to_json(responders={},
responder_key="responder")
assert (res == {})
| 36.523861
| 130
| 0.640891
| 4,061
| 33,675
| 5.039399
| 0.044817
| 0.080137
| 0.038114
| 0.050037
| 0.930418
| 0.896115
| 0.861129
| 0.835231
| 0.805033
| 0.769216
| 0
| 0.027404
| 0.245791
| 33,675
| 921
| 131
| 36.563518
| 0.778368
| 0.24288
| 0
| 0.464935
| 0
| 0.005195
| 0.2212
| 0.110452
| 0
| 0
| 0
| 0
| 0.119481
| 1
| 0.124675
| false
| 0
| 0.012987
| 0
| 0.14026
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
0415ad7afe66decfca2d68b8a0ef5dfe5697f876
| 22
|
py
|
Python
|
exercises/alphametics/alphametics.py
|
RJTK/python
|
f9678d629735f75354bbd543eb7f10220a498dae
|
[
"MIT"
] | 1
|
2021-05-15T19:59:04.000Z
|
2021-05-15T19:59:04.000Z
|
exercises/alphametics/alphametics.py
|
RJTK/python
|
f9678d629735f75354bbd543eb7f10220a498dae
|
[
"MIT"
] | null | null | null |
exercises/alphametics/alphametics.py
|
RJTK/python
|
f9678d629735f75354bbd543eb7f10220a498dae
|
[
"MIT"
] | 2
|
2018-03-03T08:32:12.000Z
|
2019-08-22T11:55:53.000Z
|
def solve():
pass
| 7.333333
| 12
| 0.545455
| 3
| 22
| 4
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.318182
| 22
| 2
| 13
| 11
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| true
| 0.5
| 0
| 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
| 1
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
042933e60196763a5e5267f2a0d9e23f6f5449ad
| 112
|
py
|
Python
|
lightning_transformers/task/nlp/translation/datasets/__init__.py
|
maksym-taranukhin/lightning-transformers
|
aa7202657973b5b65c3c36eb745621043859ebc4
|
[
"Apache-2.0"
] | 451
|
2021-04-21T15:53:59.000Z
|
2022-03-29T10:39:45.000Z
|
lightning_transformers/task/nlp/translation/datasets/__init__.py
|
mathemusician/lightning-transformers
|
b2ef06113433e6a178ce4d3c9df7ede8064e247f
|
[
"Apache-2.0"
] | 92
|
2021-04-21T18:42:58.000Z
|
2022-03-30T05:29:54.000Z
|
lightning_transformers/task/nlp/translation/datasets/__init__.py
|
mathemusician/lightning-transformers
|
b2ef06113433e6a178ce4d3c9df7ede8064e247f
|
[
"Apache-2.0"
] | 51
|
2021-04-22T05:35:28.000Z
|
2022-03-17T13:08:12.000Z
|
from lightning_transformers.task.nlp.translation.datasets.wmt16 import WMT16TranslationDataModule # noqa: F401
| 56
| 111
| 0.866071
| 12
| 112
| 8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.067308
| 0.071429
| 112
| 1
| 112
| 112
| 0.855769
| 0.089286
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
04330e4123d4015cbc52d2e213d143e69a15582a
| 37
|
py
|
Python
|
bumblebee/bees/__init__.py
|
nosoyyo/bumblebee
|
60452b03b2cd255ae4582a830b463fe7183e209e
|
[
"Apache-2.0"
] | null | null | null |
bumblebee/bees/__init__.py
|
nosoyyo/bumblebee
|
60452b03b2cd255ae4582a830b463fe7183e209e
|
[
"Apache-2.0"
] | null | null | null |
bumblebee/bees/__init__.py
|
nosoyyo/bumblebee
|
60452b03b2cd255ae4582a830b463fe7183e209e
|
[
"Apache-2.0"
] | null | null | null |
from .abstractbee import AbstractBee
| 18.5
| 36
| 0.864865
| 4
| 37
| 8
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.108108
| 37
| 1
| 37
| 37
| 0.969697
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
04334a418c192f5b8374e982f57a5fa84d4e8017
| 50
|
py
|
Python
|
aiomatrix/types/events/relationships/__init__.py
|
Forden/aiomatrix
|
d258076bae8eb776495b92be46ee9f4baec8d9a6
|
[
"MIT"
] | 2
|
2021-10-29T18:07:08.000Z
|
2021-11-19T00:25:43.000Z
|
aiomatrix/types/events/relationships/__init__.py
|
Forden/aiomatrix
|
d258076bae8eb776495b92be46ee9f4baec8d9a6
|
[
"MIT"
] | 1
|
2022-03-06T11:17:43.000Z
|
2022-03-06T11:17:43.000Z
|
aiomatrix/types/events/relationships/__init__.py
|
Forden/aiomatrix
|
d258076bae8eb776495b92be46ee9f4baec8d9a6
|
[
"MIT"
] | null | null | null |
from .reaction import ReactionRelationshipContent
| 25
| 49
| 0.9
| 4
| 50
| 11.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.08
| 50
| 1
| 50
| 50
| 0.978261
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
|
0
| 6
|
f0adc4202353ee00b0ca2c448aab7957d335b934
| 971
|
py
|
Python
|
Taller de Estructuras de Control Selectivas/Ejercicio_10.py
|
JRobayo99/Talleres-de-algotimos
|
684ad3a4a21ada2f8347a6bae6eaa845d5abb2dc
|
[
"MIT"
] | null | null | null |
Taller de Estructuras de Control Selectivas/Ejercicio_10.py
|
JRobayo99/Talleres-de-algotimos
|
684ad3a4a21ada2f8347a6bae6eaa845d5abb2dc
|
[
"MIT"
] | null | null | null |
Taller de Estructuras de Control Selectivas/Ejercicio_10.py
|
JRobayo99/Talleres-de-algotimos
|
684ad3a4a21ada2f8347a6bae6eaa845d5abb2dc
|
[
"MIT"
] | null | null | null |
cat=int(input("Ingrese la categoria del trbajdor: "))
suel=int(input("Ingrese el sueldo bruto del trabajador: "))
if(cat==1):
suelt1=suel* 0.10
suelt= suelt1+suel
print("Categoria: " +str(cat))
print("Susueldo bruto con aumento es de: ""{:.0f}".format(suelt)," COP")
elif(cat==2):
suelt1=suel* 0.15
suelt= suelt1+suel
print("Categoria: " +str(cat))
print("Susueldo bruto con aumento es de: ""{:.0f}".format(suelt)," COP")
elif(cat==3):
suelt1=suel* 0.20
suelt= suelt1+suel
print("Categoria: " +str(cat))
print("Susueldo bruto con aumento es de: ""{:.0f}".format(suelt)," COP")
elif(cat==4):
suelt1=suel* 0.40
suelt= suelt1+suel
print("Categoria: " +str(cat))
print("Susueldo bruto con aumento es de: ""{:.0f}".format(suelt)," COP")
elif(cat==5):
suelt1=suel* 0.60
suelt= suelt1+suel
print("Categoria: " +str(cat))
print("Susueldo bruto con aumento es de: ""{:.0f}".format(suelt)," COP")
| 34.678571
| 76
| 0.621009
| 142
| 971
| 4.246479
| 0.267606
| 0.165837
| 0.091211
| 0.165837
| 0.73466
| 0.73466
| 0.73466
| 0.73466
| 0.73466
| 0.73466
| 0
| 0.044081
| 0.182286
| 971
| 28
| 77
| 34.678571
| 0.715365
| 0
| 0
| 0.555556
| 0
| 0
| 0.360082
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.37037
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 1
| 1
| 1
| 1
| 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
| 6
|
f0ed9ba1a527149a84c4884a7565173336cc71d7
| 45
|
py
|
Python
|
signbank/settings/testing.py
|
r-tae/signbank-modular
|
0c558fa0965c65d5e9def07b2e7b4b70f383a270
|
[
"BSD-3-Clause"
] | 5
|
2016-01-19T04:06:40.000Z
|
2020-05-01T17:10:46.000Z
|
signbank/settings/testing.py
|
r-tae/signbank-modular
|
0c558fa0965c65d5e9def07b2e7b4b70f383a270
|
[
"BSD-3-Clause"
] | 8
|
2020-06-05T16:37:24.000Z
|
2022-01-12T04:21:10.000Z
|
signbank/settings/testing.py
|
r-tae/signbank-modular
|
0c558fa0965c65d5e9def07b2e7b4b70f383a270
|
[
"BSD-3-Clause"
] | 1
|
2022-03-07T01:27:25.000Z
|
2022-03-07T01:27:25.000Z
|
from signbank.settings.development import *
| 15
| 43
| 0.822222
| 5
| 45
| 7.4
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.111111
| 45
| 2
| 44
| 22.5
| 0.925
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
0b17f11cd7c2dad3b2b46b55186f2163af4098b6
| 198,910
|
py
|
Python
|
raysect/core/math/function/float/function2d/interpolate/tests/data/interpolator2d_test_data.py
|
raysect/source
|
11f03089d0379fc7fb4d23c6f60c3d255673cec9
|
[
"BSD-3-Clause"
] | 71
|
2015-10-25T16:50:18.000Z
|
2022-03-02T03:46:19.000Z
|
raysect/core/math/function/float/function2d/interpolate/tests/data/interpolator2d_test_data.py
|
raysect/source
|
11f03089d0379fc7fb4d23c6f60c3d255673cec9
|
[
"BSD-3-Clause"
] | 336
|
2015-02-11T22:39:54.000Z
|
2022-02-22T18:42:32.000Z
|
raysect/core/math/function/float/function2d/interpolate/tests/data/interpolator2d_test_data.py
|
raysect/source
|
11f03089d0379fc7fb4d23c6f60c3d255673cec9
|
[
"BSD-3-Clause"
] | 24
|
2016-09-11T17:12:10.000Z
|
2022-02-24T22:57:09.000Z
|
import numpy as np
class TestInterpolatorLoadValues:
"""
Base class for loading values for a 2D sinc function test.
Storage for interpolation and extrapolation data to be test against.
These data are saved to 12 significant figures. self.data is generated by applying the sinc function to an
(NB_X = 10, NB_Y = 10) dimension xy data, which is used as the spline knots. The precalc_interpolation
is setup for cubic interpolation separately using the generate_2d_splines script moved into Cherab.
The data for nearest extrapolation is also generated through Cherab, but linear extrapolation is handled
differently (Cherab duplicates the edge border to calculate derivatives, these interpolators handle each edge
as a special case). Linear interpolation is calculated from interp2d(kind=linear), with nearest neighbour
extrapolation having fill_value=None. Interpolation data is generated on a 13X13 grid. The extrapolation positions
are 1 point outside from the middle of each edge of the 2D grid in every direction. Linear extrapolation from both
interpolator types were generated from these interpolators on 12/07/2021, so are not mathematical tests and
just highlight if something changes unexpectedly.
"""
def __init__(self):
# Define in setup_cubic or setup_linear
self.precalc_interpolation = None
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = None
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = None
#: array holding precalculated quadratic extrapolation data
self.precalc_extrapolation_quadratic: np.array = None
class TestInterpolatorLoadNormalValues(TestInterpolatorLoadValues):
"""
Loading normal sized values for a 2D sinc function test.
For description of data storage, see TestInterpolatorLoadValues.
"""
def __init__(self):
super().__init__()
#: data array from a function sampled on self.x. dtype should be np.float64
self.data: np.array = np.array(
[[7.049456954407E-02, -5.031133752816E-03, -8.474851229653E-02, -7.975908114097E-02,
-4.876973734940E-02, -4.876973734940E-02, -7.975908114097E-02, -8.474851229653E-02,
-5.031133752816E-03, 7.049456954407E-02],
[-5.031133752816E-03, -9.121921863446E-02, -9.251264987298E-04, 1.052139178127E-01,
1.283205555674E-01, 1.283205555674E-01, 1.052139178127E-01, -9.251264987298E-04,
-9.121921863446E-02, -5.031133752816E-03],
[-8.474851229653E-02, -9.251264987298E-04, 1.283205555674E-01, 1.734970013481E-02,
-1.140407180451E-01, -1.140407180451E-01, 1.734970013481E-02, 1.283205555674E-01,
-9.251264987298E-04, -8.474851229653E-02],
[-7.975908114097E-02, 1.052139178127E-01, 1.734970013481E-02, -2.145503300375E-01,
-9.241435356589E-02, -9.241435356589E-02, -2.145503300375E-01, 1.734970013480E-02,
1.052139178127E-01, -7.975908114097E-02],
[-4.876973734940E-02, 1.283205555674E-01, -1.140407180451E-01, -9.241435356589E-02,
6.446759109720E-01, 6.446759109720E-01, -9.241435356589E-02, -1.140407180451E-01,
1.283205555674E-01, -4.876973734940E-02],
[-4.876973734940E-02, 1.283205555674E-01, -1.140407180451E-01, -9.241435356589E-02,
6.446759109720E-01, 6.446759109720E-01, -9.241435356589E-02, -1.140407180451E-01,
1.283205555674E-01, -4.876973734940E-02],
[-7.975908114097E-02, 1.052139178127E-01, 1.734970013481E-02, -2.145503300375E-01,
-9.241435356589E-02, -9.241435356589E-02, -2.145503300375E-01, 1.734970013480E-02,
1.052139178127E-01, -7.975908114097E-02],
[-8.474851229653E-02, -9.251264987298E-04, 1.283205555674E-01, 1.734970013480E-02,
-1.140407180451E-01, -1.140407180451E-01, 1.734970013480E-02, 1.283205555674E-01,
-9.251264987296E-04, -8.474851229653E-02],
[-5.031133752816E-03, -9.121921863446E-02, -9.251264987298E-04, 1.052139178127E-01,
1.283205555674E-01, 1.283205555674E-01, 1.052139178127E-01, -9.251264987296E-04,
-9.121921863446E-02, -5.031133752816E-03],
[7.049456954407E-02, -5.031133752816E-03, -8.474851229653E-02, -7.975908114097E-02,
-4.876973734940E-02, -4.876973734940E-02, -7.975908114097E-02, -8.474851229653E-02,
-5.031133752816E-03, 7.049456954407E-02]],
dtype=np.float64
)
def setup_cubic(self):
self.precalc_interpolation = np.array(
[[7.049456954263E-02, 1.414501923625E-02, -4.992201892798E-02, -9.006647501680E-02,
-7.975908114097E-02, -5.494750801437E-02, -4.489606937545E-02, -5.494750801435E-02,
-7.975908114097E-02, -9.006647501693E-02, -4.992201892798E-02, 1.414501923767E-02,
7.049456954405E-02],
[1.414501923605E-02, -6.879873015310E-02, -6.604387574170E-02, -9.273861046803E-04,
7.815453486867E-02, 1.087722976395E-01, 1.179639375775E-01, 1.087722976395E-01,
7.815453486865E-02, -9.273861047998E-04, -6.604387574172E-02, -6.879873015206E-02,
1.414501923718E-02],
[-4.992201892793E-02, -6.604387574169E-02, 7.662704616627E-03, 8.927226959204E-02,
8.733637329408E-02, 3.144134389937E-02, 8.046419412819E-03, 3.144134389941E-02,
8.733637329409E-02, 8.927226959202E-02, 7.662704616474E-03, -6.604387574166E-02,
-4.992201892771E-02],
[-9.006647501696E-02, -9.273861048698E-04, 8.927226959221E-02, 9.500724468553E-02,
-3.879550824800E-02, -1.262756473835E-01, -1.571105597160E-01, -1.262756473836E-01,
-3.879550824809E-02, 9.500724468562E-02, 8.927226959157E-02, -9.273861044683E-04,
-9.006647501561E-02],
[-7.975908114100E-02, 7.815453486864E-02, 8.733637329436E-02, -3.879550824802E-02,
-2.145503300371E-01, -1.226583807440E-01, -7.714735650690E-02, -1.226583807460E-01,
-2.145503300375E-01, -3.879550824901E-02, 8.733637329762E-02, 7.815453486872E-02,
-7.975908114039E-02],
[-5.494750801440E-02, 1.087722976394E-01, 3.144134389962E-02, -1.262756473835E-01,
-1.226583807429E-01, 3.691392206500E-01, 5.727262813613E-01, 3.691392206475E-01,
-1.226583807439E-01, -1.262756473872E-01, 3.144134391206E-02, 1.087722976398E-01,
-5.494750801420E-02],
[-4.489606937547E-02, 1.179639375774E-01, 8.046419412844E-03, -1.571105597160E-01,
-7.714735650701E-02, 5.727262813612E-01, 8.385571378575E-01, 5.727262813612E-01,
-7.714735650690E-02, -1.571105597160E-01, 8.046419413157E-03, 1.179639375770E-01,
-4.489606937618E-02],
[-5.494750801430E-02, 1.087722976395E-01, 3.144134390001E-02, -1.262756473835E-01,
-1.226583807419E-01, 3.691392206490E-01, 5.727262813611E-01, 3.691392206364E-01,
-1.226583807442E-01, -1.262756473844E-01, 3.144134390361E-02, 1.087722976398E-01,
-5.494750801408E-02],
[-7.975908114226E-02, 7.815453486758E-02, 8.733637329316E-02, -3.879550824867E-02,
-2.145503300372E-01, -1.226583807424E-01, -7.714735650698E-02, -1.226583807482E-01,
-2.145503300413E-01, -3.879550825780E-02, 8.733637330092E-02, 7.815453489359E-02,
-7.975908108233E-02],
[-9.006647501836E-02, -9.273861060066E-04, 8.927226959113E-02, 9.500724468497E-02,
-3.879550824717E-02, -1.262756473835E-01, -1.571105597161E-01, -1.262756473903E-01,
-3.879550824831E-02, 9.500724467413E-02, 8.927226957006E-02, -9.273860602121E-04,
-9.006647496468E-02],
[-4.992201892777E-02, -6.604387574152E-02, 7.662704615258E-03, 8.927226959362E-02,
8.733637329806E-02, 3.144134391022E-02, 8.046419412349E-03, 3.144134390902E-02,
8.733637328552E-02, 8.927226957102E-02, 7.662704628725E-03, -6.604387573864E-02,
-4.992201892713E-02],
[1.414501923638E-02, -6.879873015296E-02, -6.604387574257E-02, -9.273861067053E-04,
7.815453486814E-02, 1.087722976396E-01, 1.179639375771E-01, 1.087722976389E-01,
7.815453487338E-02, -9.273860952677E-04, -6.604387573003E-02, -6.879873013669E-02,
1.414501929255E-02],
[7.049456954365E-02, 1.414501923699E-02, -4.992201892895E-02, -9.006647501957E-02,
-7.975908114108E-02, -5.494750801466E-02, -4.489606937580E-02, -5.494750801505E-02,
-7.975908112863E-02, -9.006647503033E-02, -4.992201892673E-02, 1.414501928696E-02,
7.049456960033E-02]], dtype=np.float64
)
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954263E-02, 7.049456954263E-02, 7.049456954263E-02, 7.049456954263E-02,
1.414501923625E-02, -4.992201892798E-02, -9.006647501680E-02, -7.975908114097E-02,
-5.494750801437E-02, -4.489606937545E-02, -5.494750801435E-02, -7.975908114097E-02,
-9.006647501693E-02, -4.992201892798E-02, 1.414501923767E-02, 7.049456954405E-02,
7.049456954405E-02, 7.049456954405E-02, 7.049456954405E-02, 7.049456954263E-02,
7.049456954263E-02, 7.049456954263E-02, 7.049456954263E-02, 1.414501923625E-02,
-4.992201892798E-02, -9.006647501680E-02, -7.975908114097E-02, -5.494750801437E-02,
-4.489606937545E-02, -5.494750801435E-02, -7.975908114097E-02, -9.006647501693E-02,
-4.992201892798E-02, 1.414501923767E-02, 7.049456954405E-02, 7.049456954405E-02,
7.049456954405E-02, 7.049456954405E-02, 7.049456954263E-02, 7.049456954263E-02,
7.049456954263E-02, 7.049456954263E-02, 1.414501923625E-02, -4.992201892798E-02,
-9.006647501680E-02, -7.975908114097E-02, -5.494750801437E-02, -4.489606937545E-02,
-5.494750801435E-02, -7.975908114097E-02, -9.006647501693E-02, -4.992201892798E-02,
1.414501923767E-02, 7.049456954405E-02, 7.049456954405E-02, 7.049456954405E-02,
7.049456954405E-02, 7.049456954263E-02, 7.049456954263E-02, 7.049456954263E-02,
7.049456954405E-02, 7.049456954405E-02, 7.049456954405E-02, 1.414501923605E-02,
1.414501923605E-02, 1.414501923605E-02, 1.414501923718E-02, 1.414501923718E-02,
1.414501923718E-02, -4.992201892793E-02, -4.992201892793E-02, -4.992201892793E-02,
-4.992201892771E-02, -4.992201892771E-02, -4.992201892771E-02, -9.006647501696E-02,
-9.006647501696E-02, -9.006647501696E-02, -9.006647501561E-02, -9.006647501561E-02,
-9.006647501561E-02, -7.975908114100E-02, -7.975908114100E-02, -7.975908114100E-02,
-7.975908114039E-02, -7.975908114039E-02, -7.975908114039E-02, -5.494750801440E-02,
-5.494750801440E-02, -5.494750801440E-02, -5.494750801420E-02, -5.494750801420E-02,
-5.494750801420E-02, -4.489606937547E-02, -4.489606937547E-02, -4.489606937547E-02,
-4.489606937618E-02, -4.489606937618E-02, -4.489606937618E-02, -5.494750801430E-02,
-5.494750801430E-02, -5.494750801430E-02, -5.494750801408E-02, -5.494750801408E-02,
-5.494750801408E-02, -7.975908114226E-02, -7.975908114226E-02, -7.975908114226E-02,
-7.975908108233E-02, -7.975908108233E-02, -7.975908108233E-02, -9.006647501836E-02,
-9.006647501836E-02, -9.006647501836E-02, -9.006647496468E-02, -9.006647496468E-02,
-9.006647496468E-02, -4.992201892777E-02, -4.992201892777E-02, -4.992201892777E-02,
-4.992201892713E-02, -4.992201892713E-02, -4.992201892713E-02, 1.414501923638E-02,
1.414501923638E-02, 1.414501923638E-02, 1.414501929255E-02, 1.414501929255E-02,
1.414501929255E-02, 7.049456954365E-02, 7.049456954365E-02, 7.049456954365E-02,
7.049456960033E-02, 7.049456960033E-02, 7.049456960033E-02, 7.049456954365E-02,
7.049456954365E-02, 7.049456954365E-02, 7.049456954365E-02, 1.414501923699E-02,
-4.992201892895E-02, -9.006647501957E-02, -7.975908114108E-02, -5.494750801466E-02,
-4.489606937580E-02, -5.494750801505E-02, -7.975908112863E-02, -9.006647503033E-02,
-4.992201892673E-02, 1.414501928696E-02, 7.049456960033E-02, 7.049456960033E-02,
7.049456960033E-02, 7.049456960033E-02, 7.049456954365E-02, 7.049456954365E-02,
7.049456954365E-02, 7.049456954365E-02, 1.414501923699E-02, -4.992201892895E-02,
-9.006647501957E-02, -7.975908114108E-02, -5.494750801466E-02, -4.489606937580E-02,
-5.494750801505E-02, -7.975908112863E-02, -9.006647503033E-02, -4.992201892673E-02,
1.414501928696E-02, 7.049456960033E-02, 7.049456960033E-02, 7.049456960033E-02,
7.049456960033E-02, 7.049456954365E-02, 7.049456954365E-02, 7.049456954365E-02,
7.049456954365E-02, 1.414501923699E-02, -4.992201892895E-02, -9.006647501957E-02,
-7.975908114108E-02, -5.494750801466E-02, -4.489606937580E-02, -5.494750801505E-02,
-7.975908112863E-02, -9.006647503033E-02, -4.992201892673E-02, 1.414501928696E-02,
7.049456960033E-02, 7.049456960033E-02, 7.049456960033E-02, 7.049456960033E-02], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[5.663043205226E-01, 6.276115134204E-01, 6.889187063182E-01, 7.502258992160E-01,
8.801800967422E-01, 2.361337399095E-02, -1.138639225842E+00, -1.744516071724E+00,
-1.684506962764E+00, -1.629840661335E+00, -1.684506962764E+00, -1.744516071724E+00,
-1.138639225842E+00, 2.361337399095E-02, 8.801800967422E-01, 7.502258992160E-01,
6.889187063182E-01, 6.276115134204E-01, 5.663043205226E-01, 6.276115134204E-01,
5.929572720554E-01, 5.583030306904E-01, 5.236487893254E-01, 5.915017375739E-01,
-8.984236486837E-04, -7.891149755669E-01, -1.189597074863E+00, -1.141320477848E+00,
-1.101525797349E+00, -1.141320477848E+00, -1.189597074863E+00, -7.891149755669E-01,
-8.984236486838E-04, 5.915017375739E-01, 5.236487893254E-01, 5.583030306904E-01,
5.929572720554E-01, 6.276115134204E-01, 6.889187063182E-01, 5.583030306904E-01,
4.276873550626E-01, 2.970716794347E-01, 3.028233784055E-01, -2.541022128832E-02,
-4.395907252919E-01, -6.346780780020E-01, -5.981339929310E-01, -5.732109333620E-01,
-5.981339929310E-01, -6.346780780020E-01, -4.395907252919E-01, -2.541022128832E-02,
3.028233784055E-01, 2.970716794347E-01, 4.276873550626E-01, 5.583030306904E-01,
6.889187063182E-01, 7.502258992160E-01, 5.236487893254E-01, 2.970716794347E-01,
2.970716794347E-01, 5.236487893254E-01, 7.502258992160E-01, 8.801800967422E-01,
5.915017375739E-01, 3.028233784055E-01, 3.028233784055E-01, 5.915017375739E-01,
8.801800967422E-01, 2.361337399095E-02, -8.984236486837E-04, -2.541022128832E-02,
-2.541022128832E-02, -8.984236486847E-04, 2.361337399095E-02, -1.138639225842E+00,
-7.891149755669E-01, -4.395907252919E-01, -4.395907252919E-01, -7.891149755669E-01,
-1.138639225842E+00, -1.744516071724E+00, -1.189597074863E+00, -6.346780780020E-01,
-6.346780780020E-01, -1.189597074863E+00, -1.744516071724E+00, -1.684506962764E+00,
-1.141320477848E+00, -5.981339929310E-01, -5.981339929310E-01, -1.141320477848E+00,
-1.684506962764E+00, -1.629840661335E+00, -1.101525797349E+00, -5.732109333620E-01,
-5.732109333620E-01, -1.101525797349E+00, -1.629840661335E+00, -1.684506962764E+00,
-1.141320477848E+00, -5.981339929310E-01, -5.981339929310E-01, -1.141320477848E+00,
-1.684506962764E+00, -1.744516071724E+00, -1.189597074863E+00, -6.346780780020E-01,
-6.346780780020E-01, -1.189597074863E+00, -1.744516071724E+00, -1.138639225842E+00,
-7.891149755669E-01, -4.395907252919E-01, -4.395907252919E-01, -7.891149755669E-01,
-1.138639225842E+00, 2.361337399095E-02, -8.984236486838E-04, -2.541022128832E-02,
-2.541022128832E-02, -8.984236486829E-04, 2.361337399095E-02, 8.801800967422E-01,
5.915017375739E-01, 3.028233784055E-01, 3.028233784055E-01, 5.915017375739E-01,
8.801800967422E-01, 7.502258992160E-01, 5.236487893254E-01, 2.970716794347E-01,
2.970716794347E-01, 5.236487893254E-01, 7.502258992160E-01, 6.889187063182E-01,
5.583030306904E-01, 4.276873550626E-01, 2.970716794347E-01, 3.028233784055E-01,
-2.541022128832E-02, -4.395907252919E-01, -6.346780780020E-01, -5.981339929310E-01,
-5.732109333620E-01, -5.981339929310E-01, -6.346780780020E-01, -4.395907252919E-01,
-2.541022128832E-02, 3.028233784055E-01, 2.970716794347E-01, 4.276873550626E-01,
5.583030306904E-01, 6.889187063182E-01, 6.276115134204E-01, 5.929572720554E-01,
5.583030306904E-01, 5.236487893254E-01, 5.915017375739E-01, -8.984236486841E-04,
-7.891149755669E-01, -1.189597074863E+00, -1.141320477848E+00, -1.101525797349E+00,
-1.141320477848E+00, -1.189597074863E+00, -7.891149755669E-01, -8.984236486832E-04,
5.915017375739E-01, 5.236487893254E-01, 5.583030306904E-01, 5.929572720554E-01,
6.276115134204E-01, 5.663043205226E-01, 6.276115134204E-01, 6.889187063182E-01,
7.502258992160E-01, 8.801800967422E-01, 2.361337399095E-02, -1.138639225842E+00,
-1.744516071724E+00, -1.684506962764E+00, -1.629840661335E+00, -1.684506962764E+00,
-1.744516071724E+00, -1.138639225842E+00, 2.361337399095E-02, 8.801800967422E-01,
7.502258992160E-01, 6.889187063182E-01, 6.276115134204E-01, 5.663043205226E-01], dtype=np.float64
)
def setup_linear(self):
self.precalc_interpolation = np.array(
[[7.049456954407E-02, 1.385029207141E-02, -4.488982302467E-02, -8.350115450764E-02,
-7.975908114097E-02, -5.651707329729E-02, -4.876973734940E-02, -5.651707329729E-02,
-7.975908114097E-02, -8.350115450764E-02, -4.488982302467E-02, 1.385029207141E-02,
7.049456954407E-02],
[1.385029207141E-02, -4.879157504269E-02, -4.577658518112E-02, -1.668062692568E-03,
5.897066807427E-02, 7.777865377223E-02, 8.404798233821E-02, 7.777865377223E-02,
5.897066807427E-02, -1.668062692568E-03, -4.577658518112E-02, -4.879157504269E-02,
1.385029207141E-02],
[-4.488982302467E-02, -4.577658518112E-02, 8.812770983874E-03, 6.309373814419E-02,
6.128180897374E-02, 2.067539131431E-02, 7.139918761166E-03, 2.067539131431E-02,
6.128180897374E-02, 6.309373814419E-02, 8.812770983874E-03, -4.577658518112E-02,
-4.488982302467E-02],
[-8.350115450764E-02, -1.668062692568E-03, 6.309373814419E-02, 6.527705442988E-02,
-4.062530740828E-02, -9.163192204604E-02, -1.086341269253E-01, -9.163192204604E-02,
-4.062530740828E-02, 6.527705442988E-02, 6.309373814419E-02, -1.668062692568E-03,
-8.350115450764E-02],
[-7.975908114097E-02, 5.897066807427E-02, 6.128180897374E-02, -4.062530740828E-02,
-2.145503300375E-01, -1.229483476838E-01, -9.241435356589E-02, -1.229483476838E-01,
-2.145503300375E-01, -4.062530740828E-02, 6.128180897374E-02, 5.897066807427E-02,
-7.975908114097E-02],
[-5.651707329729E-02, 7.777865377223E-02, 2.067539131431E-02, -9.163192204604E-02,
-1.229483476838E-01, 3.145654217072E-01, 4.604033448375E-01, 3.145654217072E-01,
-1.229483476838E-01, -9.163192204604E-02, 2.067539131431E-02, 7.777865377223E-02,
-5.651707329729E-02],
[-4.876973734940E-02, 8.404798233821E-02, 7.139918761166E-03, -1.086341269253E-01,
-9.241435356589E-02, 4.604033448375E-01, 6.446759109720E-01, 4.604033448375E-01,
-9.241435356589E-02, -1.086341269253E-01, 7.139918761166E-03, 8.404798233821E-02,
-4.876973734940E-02],
[-5.651707329729E-02, 7.777865377223E-02, 2.067539131431E-02, -9.163192204604E-02,
-1.229483476838E-01, 3.145654217072E-01, 4.604033448375E-01, 3.145654217072E-01,
-1.229483476838E-01, -9.163192204604E-02, 2.067539131431E-02, 7.777865377223E-02,
-5.651707329729E-02],
[-7.975908114097E-02, 5.897066807427E-02, 6.128180897374E-02, -4.062530740828E-02,
-2.145503300375E-01, -1.229483476838E-01, -9.241435356589E-02, -1.229483476838E-01,
-2.145503300375E-01, -4.062530740828E-02, 6.128180897374E-02, 5.897066807427E-02,
-7.975908114097E-02],
[-8.350115450764E-02, -1.668062692568E-03, 6.309373814419E-02, 6.527705442988E-02,
-4.062530740828E-02, -9.163192204604E-02, -1.086341269253E-01, -9.163192204604E-02,
-4.062530740828E-02, 6.527705442988E-02, 6.309373814419E-02, -1.668062692568E-03,
-8.350115450764E-02],
[-4.488982302467E-02, -4.577658518112E-02, 8.812770983874E-03, 6.309373814419E-02,
6.128180897374E-02, 2.067539131431E-02, 7.139918761166E-03, 2.067539131431E-02,
6.128180897374E-02, 6.309373814419E-02, 8.812770983874E-03, -4.577658518112E-02,
-4.488982302467E-02],
[1.385029207141E-02, -4.879157504269E-02, -4.577658518112E-02, -1.668062692568E-03,
5.897066807427E-02, 7.777865377223E-02, 8.404798233821E-02, 7.777865377223E-02,
5.897066807427E-02, -1.668062692568E-03, -4.577658518112E-02, -4.879157504269E-02,
1.385029207141E-02],
[7.049456954407E-02, 1.385029207141E-02, -4.488982302467E-02, -8.350115450764E-02,
-7.975908114097E-02, -5.651707329729E-02, -4.876973734940E-02, -5.651707329729E-02,
-7.975908114097E-02, -8.350115450764E-02, -4.488982302467E-02, 1.385029207141E-02,
7.049456954407E-02]], dtype=np.float64
)
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
1.385029207141E-02, -4.488982302467E-02, -8.350115450764E-02, -7.975908114097E-02,
-5.651707329729E-02, -4.876973734940E-02, -5.651707329729E-02, -7.975908114097E-02,
-8.350115450764E-02, -4.488982302467E-02, 1.385029207141E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 1.385029207141E-02,
-4.488982302467E-02, -8.350115450764E-02, -7.975908114097E-02, -5.651707329729E-02,
-4.876973734940E-02, -5.651707329729E-02, -7.975908114097E-02, -8.350115450764E-02,
-4.488982302467E-02, 1.385029207141E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 1.385029207141E-02, -4.488982302467E-02,
-8.350115450764E-02, -7.975908114097E-02, -5.651707329729E-02, -4.876973734940E-02,
-5.651707329729E-02, -7.975908114097E-02, -8.350115450764E-02, -4.488982302467E-02,
1.385029207141E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 1.385029207141E-02,
1.385029207141E-02, 1.385029207141E-02, 1.385029207141E-02, 1.385029207141E-02,
1.385029207141E-02, -4.488982302467E-02, -4.488982302467E-02, -4.488982302467E-02,
-4.488982302467E-02, -4.488982302467E-02, -4.488982302467E-02, -8.350115450764E-02,
-8.350115450764E-02, -8.350115450764E-02, -8.350115450764E-02, -8.350115450764E-02,
-8.350115450764E-02, -7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02,
-7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02, -5.651707329729E-02,
-5.651707329729E-02, -5.651707329729E-02, -5.651707329729E-02, -5.651707329729E-02,
-5.651707329729E-02, -4.876973734940E-02, -4.876973734940E-02, -4.876973734940E-02,
-4.876973734940E-02, -4.876973734940E-02, -4.876973734940E-02, -5.651707329729E-02,
-5.651707329729E-02, -5.651707329729E-02, -5.651707329729E-02, -5.651707329729E-02,
-5.651707329729E-02, -7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02,
-7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02, -8.350115450764E-02,
-8.350115450764E-02, -8.350115450764E-02, -8.350115450764E-02, -8.350115450764E-02,
-8.350115450764E-02, -4.488982302467E-02, -4.488982302467E-02, -4.488982302467E-02,
-4.488982302467E-02, -4.488982302467E-02, -4.488982302467E-02, 1.385029207141E-02,
1.385029207141E-02, 1.385029207141E-02, 1.385029207141E-02, 1.385029207141E-02,
1.385029207141E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 1.385029207141E-02,
-4.488982302467E-02, -8.350115450764E-02, -7.975908114097E-02, -5.651707329729E-02,
-4.876973734940E-02, -5.651707329729E-02, -7.975908114097E-02, -8.350115450764E-02,
-4.488982302467E-02, 1.385029207141E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 1.385029207141E-02, -4.488982302467E-02,
-8.350115450764E-02, -7.975908114097E-02, -5.651707329729E-02, -4.876973734940E-02,
-5.651707329729E-02, -7.975908114097E-02, -8.350115450764E-02, -4.488982302467E-02,
1.385029207141E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 1.385029207141E-02, -4.488982302467E-02, -8.350115450764E-02,
-7.975908114097E-02, -5.651707329729E-02, -4.876973734940E-02, -5.651707329729E-02,
-7.975908114097E-02, -8.350115450764E-02, -4.488982302467E-02, 1.385029207141E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[5.663043205226E-01, 6.276115134204E-01, 6.889187063182E-01, 7.502258992160E-01,
7.655526974405E-01, -3.424867714738E-02, -1.065498256289E+00, -1.744516071724E+00,
-1.668065798131E+00, -1.642582373601E+00, -1.668065798131E+00, -1.744516071724E+00,
-1.065498256289E+00, -3.424867714738E-02, 7.655526974405E-01, 7.502258992160E-01,
6.889187063182E-01, 6.276115134204E-01, 5.663043205226E-01, 6.276115134204E-01,
5.929572720554E-01, 5.583030306904E-01, 5.236487893254E-01, 5.149852289841E-01,
-3.779572577314E-02, -7.381658890282E-01, -1.189597074863E+00, -1.130882889853E+00,
-1.111311494850E+00, -1.130882889853E+00, -1.189597074863E+00, -7.381658890282E-01,
-3.779572577314E-02, 5.149852289841E-01, 5.236487893254E-01, 5.583030306904E-01,
5.929572720554E-01, 6.276115134204E-01, 6.889187063182E-01, 5.583030306904E-01,
4.276873550626E-01, 2.970716794347E-01, 2.644177605278E-01, -4.134277439891E-02,
-4.108335217679E-01, -6.346780780020E-01, -5.936999815753E-01, -5.800406160998E-01,
-5.936999815753E-01, -6.346780780020E-01, -4.108335217679E-01, -4.134277439891E-02,
2.644177605278E-01, 2.970716794347E-01, 4.276873550626E-01, 5.583030306904E-01,
6.889187063182E-01, 7.502258992160E-01, 5.236487893254E-01, 2.970716794347E-01,
2.970716794347E-01, 5.236487893254E-01, 7.502258992160E-01, 7.655526974405E-01,
5.149852289841E-01, 2.644177605278E-01, 2.644177605278E-01, 5.149852289841E-01,
7.655526974405E-01, -3.424867714738E-02, -3.779572577314E-02, -4.134277439891E-02,
-4.134277439891E-02, -3.779572577314E-02, -3.424867714738E-02, -1.065498256289E+00,
-7.381658890282E-01, -4.108335217679E-01, -4.108335217679E-01, -7.381658890282E-01,
-1.065498256289E+00, -1.744516071724E+00, -1.189597074863E+00, -6.346780780020E-01,
-6.346780780020E-01, -1.189597074863E+00, -1.744516071724E+00, -1.668065798131E+00,
-1.130882889853E+00, -5.936999815753E-01, -5.936999815753E-01, -1.130882889853E+00,
-1.668065798131E+00, -1.642582373601E+00, -1.111311494850E+00, -5.800406160998E-01,
-5.800406160998E-01, -1.111311494850E+00, -1.642582373601E+00, -1.668065798131E+00,
-1.130882889853E+00, -5.936999815753E-01, -5.936999815753E-01, -1.130882889853E+00,
-1.668065798131E+00, -1.744516071724E+00, -1.189597074863E+00, -6.346780780020E-01,
-6.346780780020E-01, -1.189597074863E+00, -1.744516071724E+00, -1.065498256289E+00,
-7.381658890282E-01, -4.108335217679E-01, -4.108335217679E-01, -7.381658890282E-01,
-1.065498256289E+00, -3.424867714738E-02, -3.779572577314E-02, -4.134277439891E-02,
-4.134277439891E-02, -3.779572577314E-02, -3.424867714738E-02, 7.655526974405E-01,
5.149852289841E-01, 2.644177605278E-01, 2.644177605278E-01, 5.149852289841E-01,
7.655526974405E-01, 7.502258992160E-01, 5.236487893254E-01, 2.970716794347E-01,
2.970716794347E-01, 5.236487893254E-01, 7.502258992160E-01, 6.889187063182E-01,
5.583030306904E-01, 4.276873550626E-01, 2.970716794347E-01, 2.644177605278E-01,
-4.134277439891E-02, -4.108335217679E-01, -6.346780780020E-01, -5.936999815753E-01,
-5.800406160998E-01, -5.936999815753E-01, -6.346780780020E-01, -4.108335217679E-01,
-4.134277439891E-02, 2.644177605278E-01, 2.970716794347E-01, 4.276873550626E-01,
5.583030306904E-01, 6.889187063182E-01, 6.276115134204E-01, 5.929572720554E-01,
5.583030306904E-01, 5.236487893254E-01, 5.149852289841E-01, -3.779572577314E-02,
-7.381658890282E-01, -1.189597074863E+00, -1.130882889853E+00, -1.111311494850E+00,
-1.130882889853E+00, -1.189597074863E+00, -7.381658890282E-01, -3.779572577314E-02,
5.149852289841E-01, 5.236487893254E-01, 5.583030306904E-01, 5.929572720554E-01,
6.276115134204E-01, 5.663043205226E-01, 6.276115134204E-01, 6.889187063182E-01,
7.502258992160E-01, 7.655526974405E-01, -3.424867714738E-02, -1.065498256289E+00,
-1.744516071724E+00, -1.668065798131E+00, -1.642582373601E+00, -1.668065798131E+00,
-1.744516071724E+00, -1.065498256289E+00, -3.424867714738E-02, 7.655526974405E-01,
7.502258992160E-01, 6.889187063182E-01, 6.276115134204E-01, 5.663043205226E-01], dtype=np.float64
)
class TestInterpolatorLoadBigValues(TestInterpolatorLoadValues):
"""
Loading small values (10^-20 times the original) instead of the original 2D sinc function test.
For description of data storage, see TestInterpolatorLoadValues.
"""
def __init__(self):
super().__init__()
#: data array from a function sampled on self.x. dtype should be np.float64
# self.data: np.array = np.sin(self.x)
self.data: np.array = np.array(
[[7.049456954407E+18, -5.031133752816E+17, -8.474851229653E+18, -7.975908114097E+18,
-4.876973734940E+18, -4.876973734940E+18, -7.975908114097E+18, -8.474851229653E+18,
-5.031133752816E+17, 7.049456954407E+18],
[-5.031133752816E+17, -9.121921863446E+18, -9.251264987298E+16, 1.052139178127E+19,
1.283205555674E+19, 1.283205555674E+19, 1.052139178127E+19, -9.251264987298E+16,
-9.121921863446E+18, -5.031133752816E+17],
[-8.474851229653E+18, -9.251264987298E+16, 1.283205555674E+19, 1.734970013481E+18,
-1.140407180451E+19, -1.140407180451E+19, 1.734970013481E+18, 1.283205555674E+19,
-9.251264987298E+16, -8.474851229653E+18],
[-7.975908114097E+18, 1.052139178127E+19, 1.734970013481E+18, -2.145503300375E+19,
-9.241435356589E+18, -9.241435356589E+18, -2.145503300375E+19, 1.734970013480E+18,
1.052139178127E+19, -7.975908114097E+18],
[-4.876973734940E+18, 1.283205555674E+19, -1.140407180451E+19, -9.241435356589E+18,
6.446759109720E+19, 6.446759109720E+19, -9.241435356589E+18, -1.140407180451E+19,
1.283205555674E+19, -4.876973734940E+18],
[-4.876973734940E+18, 1.283205555674E+19, -1.140407180451E+19, -9.241435356589E+18,
6.446759109720E+19, 6.446759109720E+19, -9.241435356589E+18, -1.140407180451E+19,
1.283205555674E+19, -4.876973734940E+18],
[-7.975908114097E+18, 1.052139178127E+19, 1.734970013481E+18, -2.145503300375E+19,
-9.241435356589E+18, -9.241435356589E+18, -2.145503300375E+19, 1.734970013480E+18,
1.052139178127E+19, -7.975908114097E+18],
[-8.474851229653E+18, -9.251264987298E+16, 1.283205555674E+19, 1.734970013480E+18,
-1.140407180451E+19, -1.140407180451E+19, 1.734970013480E+18, 1.283205555674E+19,
-9.251264987296E+16, -8.474851229653E+18],
[-5.031133752816E+17, -9.121921863446E+18, -9.251264987298E+16, 1.052139178127E+19,
1.283205555674E+19, 1.283205555674E+19, 1.052139178127E+19, -9.251264987296E+16,
-9.121921863446E+18, -5.031133752816E+17],
[7.049456954407E+18, -5.031133752816E+17, -8.474851229653E+18, -7.975908114097E+18,
-4.876973734940E+18, -4.876973734940E+18, -7.975908114097E+18, -8.474851229653E+18,
-5.031133752816E+17, 7.049456954407E+18]], dtype=np.float64
)
#: array holding precalculated quadratic extrapolation data
self.precalc_extrapolation_quadratic: np.array = np.array(
[], dtype=np.float64
)
def setup_cubic(self):
self.precalc_interpolation = np.array(
[[7.049456954460E+18, 1.414501923721E+18, -4.992201892784E+18, -9.006647501706E+18,
-7.975908114096E+18, -5.494750801436E+18, -4.489606937545E+18, -5.494750801434E+18,
-7.975908114100E+18, -9.006647501698E+18, -4.992201892788E+18, 1.414501923683E+18,
7.049456954376E+18],
[1.414501923764E+18, -6.879873015236E+18, -6.604387574162E+18, -9.273861048722E+16,
7.815453486867E+18, 1.087722976395E+19, 1.179639375775E+19, 1.087722976395E+19,
7.815453486864E+18, -9.273861048516E+16, -6.604387574163E+18, -6.879873015260E+18,
1.414501923709E+18],
[-4.992201892782E+18, -6.604387574159E+18, 7.662704616480E+17, 8.927226959209E+18,
8.733637329413E+18, 3.144134389938E+18, 8.046419412828E+17, 3.144134389934E+18,
8.733637329421E+18, 8.927226959216E+18, 7.662704616522E+17, -6.604387574177E+18,
-4.992201892789E+18],
[-9.006647501668E+18, -9.273861045643E+16, 8.927226959223E+18, 9.500724468548E+18,
-3.879550824799E+18, -1.262756473835E+19, -1.571105597160E+19, -1.262756473838E+19,
-3.879550824803E+18, 9.500724468565E+18, 8.927226959332E+18, -9.273861058776E+16,
-9.006647501760E+18],
[-7.975908114094E+18, 7.815453486869E+18, 8.733637329383E+18, -3.879550824786E+18,
-2.145503300374E+19, -1.226583807440E+19, -7.714735650690E+18, -1.226583807425E+19,
-2.145503300392E+19, -3.879550825037E+18, 8.733637328991E+18, 7.815453486779E+18,
-7.975908114134E+18],
[-5.494750801433E+18, 1.087722976395E+19, 3.144134389889E+18, -1.262756473834E+19,
-1.226583807434E+19, 3.691392206497E+19, 5.727262813613E+19, 3.691392206533E+19,
-1.226583807459E+19, -1.262756473889E+19, 3.144134390513E+18, 1.087722976389E+19,
-5.494750801509E+18],
[-4.489606937542E+18, 1.179639375775E+19, 8.046419412881E+17, -1.571105597160E+19,
-7.714735650701E+18, 5.727262813612E+19, 8.385571378575E+19, 5.727262813618E+19,
-7.714735650696E+18, -1.571105597161E+19, 8.046419412838E+17, 1.179639375773E+19,
-4.489606937591E+18],
[-5.494750801434E+18, 1.087722976395E+19, 3.144134390093E+18, -1.262756473833E+19,
-1.226583807460E+19, 3.691392206464E+19, 5.727262813614E+19, 3.691392206388E+19,
-1.226583807413E+19, -1.262756473809E+19, 3.144134391132E+18, 1.087722976399E+19,
-5.494750801389E+18],
[-7.975908114416E+18, 7.815453486610E+18, 8.733637329526E+18, -3.879550824930E+18,
-2.145503300385E+19, -1.226583807444E+19, -7.714735650699E+18, -1.226583807452E+19,
-2.145503300371E+19, -3.879550825350E+18, 8.733637329826E+18, 7.815453486864E+18,
-7.975908110886E+18],
[-9.006647502091E+18, -9.273861080508E+16, 8.927226959362E+18, 9.500724468432E+18,
-3.879550824923E+18, -1.262756473862E+19, -1.571105597161E+19, -1.262756473885E+19,
-3.879550824244E+18, 9.500724467988E+18, 8.927226956139E+18, -9.273860862352E+16,
-9.006647499242E+18],
[-4.992201892748E+18, -6.604387574117E+18, 7.662704614151E+17, 8.927226959268E+18,
8.733637329008E+18, 3.144134390448E+18, 8.046419412263E+17, 3.144134389968E+18,
8.733637329917E+18, 8.927226958675E+18, 7.662704629822E+17, -6.604387573416E+18,
-4.992201892348E+18],
[1.414501923439E+18, -6.879873015445E+18, -6.604387573988E+18, -9.273861059517E+16,
7.815453486837E+18, 1.087722976397E+19, 1.179639375772E+19, 1.087722976397E+19,
7.815453486894E+18, -9.273860926067E+16, -6.604387573672E+18, -6.879873017304E+18,
1.414501925358E+18],
[7.049456954108E+18, 1.414501923499E+18, -4.992201892571E+18, -9.006647501872E+18,
-7.975908114100E+18, -5.494750801478E+18, -4.489606937572E+18, -5.494750801431E+18,
-7.975908113487E+18, -9.006647502955E+18, -4.992201893463E+18, 1.414501925348E+18,
7.049456956398E+18]], dtype=np.float64
)
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954460E+18, 7.049456954460E+18, 7.049456954460E+18, 7.049456954460E+18,
1.414501923721E+18, -4.992201892784E+18, -9.006647501706E+18, -7.975908114096E+18,
-5.494750801436E+18, -4.489606937545E+18, -5.494750801434E+18, -7.975908114100E+18,
-9.006647501698E+18, -4.992201892788E+18, 1.414501923683E+18, 7.049456954376E+18,
7.049456954376E+18, 7.049456954376E+18, 7.049456954376E+18, 7.049456954460E+18,
7.049456954460E+18, 7.049456954460E+18, 7.049456954460E+18, 1.414501923721E+18,
-4.992201892784E+18, -9.006647501706E+18, -7.975908114096E+18, -5.494750801436E+18,
-4.489606937545E+18, -5.494750801434E+18, -7.975908114100E+18, -9.006647501698E+18,
-4.992201892788E+18, 1.414501923683E+18, 7.049456954376E+18, 7.049456954376E+18,
7.049456954376E+18, 7.049456954376E+18, 7.049456954460E+18, 7.049456954460E+18,
7.049456954460E+18, 7.049456954460E+18, 1.414501923721E+18, -4.992201892784E+18,
-9.006647501706E+18, -7.975908114096E+18, -5.494750801436E+18, -4.489606937545E+18,
-5.494750801434E+18, -7.975908114100E+18, -9.006647501698E+18, -4.992201892788E+18,
1.414501923683E+18, 7.049456954376E+18, 7.049456954376E+18, 7.049456954376E+18,
7.049456954376E+18, 7.049456954460E+18, 7.049456954460E+18, 7.049456954460E+18,
7.049456954376E+18, 7.049456954376E+18, 7.049456954376E+18, 1.414501923764E+18,
1.414501923764E+18, 1.414501923764E+18, 1.414501923709E+18, 1.414501923709E+18,
1.414501923709E+18, -4.992201892782E+18, -4.992201892782E+18, -4.992201892782E+18,
-4.992201892789E+18, -4.992201892789E+18, -4.992201892789E+18, -9.006647501668E+18,
-9.006647501668E+18, -9.006647501668E+18, -9.006647501760E+18, -9.006647501760E+18,
-9.006647501760E+18, -7.975908114094E+18, -7.975908114094E+18, -7.975908114094E+18,
-7.975908114134E+18, -7.975908114134E+18, -7.975908114134E+18, -5.494750801433E+18,
-5.494750801433E+18, -5.494750801433E+18, -5.494750801509E+18, -5.494750801509E+18,
-5.494750801509E+18, -4.489606937542E+18, -4.489606937542E+18, -4.489606937542E+18,
-4.489606937591E+18, -4.489606937591E+18, -4.489606937591E+18, -5.494750801434E+18,
-5.494750801434E+18, -5.494750801434E+18, -5.494750801389E+18, -5.494750801389E+18,
-5.494750801389E+18, -7.975908114416E+18, -7.975908114416E+18, -7.975908114416E+18,
-7.975908110886E+18, -7.975908110886E+18, -7.975908110886E+18, -9.006647502091E+18,
-9.006647502091E+18, -9.006647502091E+18, -9.006647499242E+18, -9.006647499242E+18,
-9.006647499242E+18, -4.992201892748E+18, -4.992201892748E+18, -4.992201892748E+18,
-4.992201892348E+18, -4.992201892348E+18, -4.992201892348E+18, 1.414501923439E+18,
1.414501923439E+18, 1.414501923439E+18, 1.414501925358E+18, 1.414501925358E+18,
1.414501925358E+18, 7.049456954108E+18, 7.049456954108E+18, 7.049456954108E+18,
7.049456956398E+18, 7.049456956398E+18, 7.049456956398E+18, 7.049456954108E+18,
7.049456954108E+18, 7.049456954108E+18, 7.049456954108E+18, 1.414501923499E+18,
-4.992201892571E+18, -9.006647501872E+18, -7.975908114100E+18, -5.494750801478E+18,
-4.489606937572E+18, -5.494750801431E+18, -7.975908113487E+18, -9.006647502955E+18,
-4.992201893463E+18, 1.414501925348E+18, 7.049456956398E+18, 7.049456956398E+18,
7.049456956398E+18, 7.049456956398E+18, 7.049456954108E+18, 7.049456954108E+18,
7.049456954108E+18, 7.049456954108E+18, 1.414501923499E+18, -4.992201892571E+18,
-9.006647501872E+18, -7.975908114100E+18, -5.494750801478E+18, -4.489606937572E+18,
-5.494750801431E+18, -7.975908113487E+18, -9.006647502955E+18, -4.992201893463E+18,
1.414501925348E+18, 7.049456956398E+18, 7.049456956398E+18, 7.049456956398E+18,
7.049456956398E+18, 7.049456954108E+18, 7.049456954108E+18, 7.049456954108E+18,
7.049456954108E+18, 1.414501923499E+18, -4.992201892571E+18, -9.006647501872E+18,
-7.975908114100E+18, -5.494750801478E+18, -4.489606937572E+18, -5.494750801431E+18,
-7.975908113487E+18, -9.006647502955E+18, -4.992201893463E+18, 1.414501925348E+18,
7.049456956398E+18, 7.049456956398E+18, 7.049456956398E+18, 7.049456956398E+18], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[5.663043205226E+19, 6.276115134204E+19, 6.889187063182E+19, 7.502258992160E+19,
8.801800967422E+19, 2.361337399095E+18, -1.138639225842E+20, -1.744516071724E+20,
-1.684506962764E+20, -1.629840661335E+20, -1.684506962764E+20, -1.744516071724E+20,
-1.138639225842E+20, 2.361337399095E+18, 8.801800967422E+19, 7.502258992160E+19,
6.889187063182E+19, 6.276115134204E+19, 5.663043205226E+19, 6.276115134204E+19,
5.929572720554E+19, 5.583030306904E+19, 5.236487893254E+19, 5.915017375739E+19,
-8.984236486837E+16, -7.891149755669E+19, -1.189597074863E+20, -1.141320477848E+20,
-1.101525797349E+20, -1.141320477848E+20, -1.189597074863E+20, -7.891149755669E+19,
-8.984236486841E+16, 5.915017375739E+19, 5.236487893254E+19, 5.583030306904E+19,
5.929572720554E+19, 6.276115134204E+19, 6.889187063182E+19, 5.583030306904E+19,
4.276873550626E+19, 2.970716794347E+19, 3.028233784055E+19, -2.541022128832E+18,
-4.395907252919E+19, -6.346780780020E+19, -5.981339929310E+19, -5.732109333620E+19,
-5.981339929310E+19, -6.346780780020E+19, -4.395907252919E+19, -2.541022128832E+18,
3.028233784055E+19, 2.970716794347E+19, 4.276873550626E+19, 5.583030306904E+19,
6.889187063182E+19, 7.502258992160E+19, 5.236487893254E+19, 2.970716794347E+19,
2.970716794347E+19, 5.236487893254E+19, 7.502258992160E+19, 8.801800967422E+19,
5.915017375739E+19, 3.028233784055E+19, 3.028233784055E+19, 5.915017375739E+19,
8.801800967422E+19, 2.361337399095E+18, -8.984236486837E+16, -2.541022128832E+18,
-2.541022128832E+18, -8.984236486841E+16, 2.361337399095E+18, -1.138639225842E+20,
-7.891149755669E+19, -4.395907252919E+19, -4.395907252919E+19, -7.891149755669E+19,
-1.138639225842E+20, -1.744516071724E+20, -1.189597074863E+20, -6.346780780020E+19,
-6.346780780020E+19, -1.189597074863E+20, -1.744516071724E+20, -1.684506962764E+20,
-1.141320477848E+20, -5.981339929310E+19, -5.981339929310E+19, -1.141320477848E+20,
-1.684506962764E+20, -1.629840661335E+20, -1.101525797349E+20, -5.732109333620E+19,
-5.732109333620E+19, -1.101525797349E+20, -1.629840661335E+20, -1.684506962764E+20,
-1.141320477848E+20, -5.981339929310E+19, -5.981339929310E+19, -1.141320477848E+20,
-1.684506962764E+20, -1.744516071724E+20, -1.189597074863E+20, -6.346780780020E+19,
-6.346780780020E+19, -1.189597074863E+20, -1.744516071724E+20, -1.138639225842E+20,
-7.891149755669E+19, -4.395907252919E+19, -4.395907252920E+19, -7.891149755669E+19,
-1.138639225842E+20, 2.361337399095E+18, -8.984236486840E+16, -2.541022128832E+18,
-2.541022128832E+18, -8.984236486853E+16, 2.361337399095E+18, 8.801800967422E+19,
5.915017375739E+19, 3.028233784055E+19, 3.028233784055E+19, 5.915017375739E+19,
8.801800967422E+19, 7.502258992160E+19, 5.236487893254E+19, 2.970716794347E+19,
2.970716794347E+19, 5.236487893254E+19, 7.502258992161E+19, 6.889187063182E+19,
5.583030306904E+19, 4.276873550626E+19, 2.970716794347E+19, 3.028233784055E+19,
-2.541022128832E+18, -4.395907252919E+19, -6.346780780020E+19, -5.981339929310E+19,
-5.732109333620E+19, -5.981339929310E+19, -6.346780780020E+19, -4.395907252919E+19,
-2.541022128832E+18, 3.028233784055E+19, 2.970716794347E+19, 4.276873550626E+19,
5.583030306905E+19, 6.889187063183E+19, 6.276115134204E+19, 5.929572720554E+19,
5.583030306904E+19, 5.236487893254E+19, 5.915017375739E+19, -8.984236486838E+16,
-7.891149755669E+19, -1.189597074863E+20, -1.141320477848E+20, -1.101525797349E+20,
-1.141320477848E+20, -1.189597074863E+20, -7.891149755669E+19, -8.984236486857E+16,
5.915017375739E+19, 5.236487893254E+19, 5.583030306905E+19, 5.929572720555E+19,
6.276115134206E+19, 5.663043205226E+19, 6.276115134204E+19, 6.889187063182E+19,
7.502258992160E+19, 8.801800967422E+19, 2.361337399095E+18, -1.138639225842E+20,
-1.744516071724E+20, -1.684506962764E+20, -1.629840661335E+20, -1.684506962764E+20,
-1.744516071724E+20, -1.138639225842E+20, 2.361337399095E+18, 8.801800967422E+19,
7.502258992161E+19, 6.889187063183E+19, 6.276115134206E+19, 5.663043205228E+19], dtype=np.float64
)
def setup_linear(self):
self.precalc_interpolation = np.array(
[[7.049456954407E+18, 1.385029207141E+18, -4.488982302467E+18, -8.350115450764E+18,
-7.975908114097E+18, -5.651707329729E+18, -4.876973734940E+18, -5.651707329729E+18,
-7.975908114097E+18, -8.350115450764E+18, -4.488982302467E+18, 1.385029207141E+18,
7.049456954407E+18],
[1.385029207141E+18, -4.879157504269E+18, -4.577658518112E+18, -1.668062692568E+17,
5.897066807427E+18, 7.777865377223E+18, 8.404798233821E+18, 7.777865377223E+18,
5.897066807427E+18, -1.668062692568E+17, -4.577658518112E+18, -4.879157504269E+18,
1.385029207141E+18],
[-4.488982302467E+18, -4.577658518112E+18, 8.812770983874E+17, 6.309373814419E+18,
6.128180897374E+18, 2.067539131431E+18, 7.139918761166E+17, 2.067539131431E+18,
6.128180897374E+18, 6.309373814419E+18, 8.812770983874E+17, -4.577658518112E+18,
-4.488982302467E+18],
[-8.350115450764E+18, -1.668062692568E+17, 6.309373814419E+18, 6.527705442988E+18,
-4.062530740828E+18, -9.163192204604E+18, -1.086341269253E+19, -9.163192204604E+18,
-4.062530740828E+18, 6.527705442988E+18, 6.309373814419E+18, -1.668062692568E+17,
-8.350115450764E+18],
[-7.975908114097E+18, 5.897066807427E+18, 6.128180897374E+18, -4.062530740828E+18,
-2.145503300375E+19, -1.229483476838E+19, -9.241435356589E+18, -1.229483476838E+19,
-2.145503300375E+19, -4.062530740828E+18, 6.128180897374E+18, 5.897066807427E+18,
-7.975908114097E+18],
[-5.651707329729E+18, 7.777865377223E+18, 2.067539131431E+18, -9.163192204604E+18,
-1.229483476838E+19, 3.145654217072E+19, 4.604033448375E+19, 3.145654217072E+19,
-1.229483476838E+19, -9.163192204604E+18, 2.067539131431E+18, 7.777865377223E+18,
-5.651707329729E+18],
[-4.876973734940E+18, 8.404798233821E+18, 7.139918761166E+17, -1.086341269253E+19,
-9.241435356589E+18, 4.604033448375E+19, 6.446759109720E+19, 4.604033448375E+19,
-9.241435356589E+18, -1.086341269253E+19, 7.139918761166E+17, 8.404798233821E+18,
-4.876973734940E+18],
[-5.651707329729E+18, 7.777865377223E+18, 2.067539131431E+18, -9.163192204604E+18,
-1.229483476838E+19, 3.145654217072E+19, 4.604033448375E+19, 3.145654217072E+19,
-1.229483476838E+19, -9.163192204604E+18, 2.067539131431E+18, 7.777865377223E+18,
-5.651707329729E+18],
[-7.975908114097E+18, 5.897066807427E+18, 6.128180897374E+18, -4.062530740828E+18,
-2.145503300375E+19, -1.229483476838E+19, -9.241435356589E+18, -1.229483476838E+19,
-2.145503300375E+19, -4.062530740828E+18, 6.128180897374E+18, 5.897066807427E+18,
-7.975908114097E+18],
[-8.350115450764E+18, -1.668062692568E+17, 6.309373814419E+18, 6.527705442988E+18,
-4.062530740828E+18, -9.163192204604E+18, -1.086341269253E+19, -9.163192204604E+18,
-4.062530740828E+18, 6.527705442988E+18, 6.309373814419E+18, -1.668062692568E+17,
-8.350115450764E+18],
[-4.488982302467E+18, -4.577658518112E+18, 8.812770983874E+17, 6.309373814419E+18,
6.128180897374E+18, 2.067539131431E+18, 7.139918761166E+17, 2.067539131431E+18,
6.128180897374E+18, 6.309373814419E+18, 8.812770983874E+17, -4.577658518112E+18,
-4.488982302467E+18],
[1.385029207141E+18, -4.879157504269E+18, -4.577658518112E+18, -1.668062692568E+17,
5.897066807427E+18, 7.777865377223E+18, 8.404798233821E+18, 7.777865377223E+18,
5.897066807427E+18, -1.668062692568E+17, -4.577658518112E+18, -4.879157504269E+18,
1.385029207141E+18],
[7.049456954407E+18, 1.385029207141E+18, -4.488982302467E+18, -8.350115450764E+18,
-7.975908114097E+18, -5.651707329729E+18, -4.876973734940E+18, -5.651707329729E+18,
-7.975908114097E+18, -8.350115450764E+18, -4.488982302467E+18, 1.385029207141E+18,
7.049456954407E+18]], dtype=np.float64
)
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
1.385029207141E+18, -4.488982302467E+18, -8.350115450764E+18, -7.975908114097E+18,
-5.651707329729E+18, -4.876973734940E+18, -5.651707329729E+18, -7.975908114097E+18,
-8.350115450764E+18, -4.488982302467E+18, 1.385029207141E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 1.385029207141E+18,
-4.488982302467E+18, -8.350115450764E+18, -7.975908114097E+18, -5.651707329729E+18,
-4.876973734940E+18, -5.651707329729E+18, -7.975908114097E+18, -8.350115450764E+18,
-4.488982302467E+18, 1.385029207141E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 1.385029207141E+18, -4.488982302467E+18,
-8.350115450764E+18, -7.975908114097E+18, -5.651707329729E+18, -4.876973734940E+18,
-5.651707329729E+18, -7.975908114097E+18, -8.350115450764E+18, -4.488982302467E+18,
1.385029207141E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 1.385029207141E+18,
1.385029207141E+18, 1.385029207141E+18, 1.385029207141E+18, 1.385029207141E+18,
1.385029207141E+18, -4.488982302467E+18, -4.488982302467E+18, -4.488982302467E+18,
-4.488982302467E+18, -4.488982302467E+18, -4.488982302467E+18, -8.350115450764E+18,
-8.350115450764E+18, -8.350115450764E+18, -8.350115450764E+18, -8.350115450764E+18,
-8.350115450764E+18, -7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18,
-7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18, -5.651707329729E+18,
-5.651707329729E+18, -5.651707329729E+18, -5.651707329729E+18, -5.651707329729E+18,
-5.651707329729E+18, -4.876973734940E+18, -4.876973734940E+18, -4.876973734940E+18,
-4.876973734940E+18, -4.876973734940E+18, -4.876973734940E+18, -5.651707329729E+18,
-5.651707329729E+18, -5.651707329729E+18, -5.651707329729E+18, -5.651707329729E+18,
-5.651707329729E+18, -7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18,
-7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18, -8.350115450764E+18,
-8.350115450764E+18, -8.350115450764E+18, -8.350115450764E+18, -8.350115450764E+18,
-8.350115450764E+18, -4.488982302467E+18, -4.488982302467E+18, -4.488982302467E+18,
-4.488982302467E+18, -4.488982302467E+18, -4.488982302467E+18, 1.385029207141E+18,
1.385029207141E+18, 1.385029207141E+18, 1.385029207141E+18, 1.385029207141E+18,
1.385029207141E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 1.385029207141E+18,
-4.488982302467E+18, -8.350115450764E+18, -7.975908114097E+18, -5.651707329729E+18,
-4.876973734940E+18, -5.651707329729E+18, -7.975908114097E+18, -8.350115450764E+18,
-4.488982302467E+18, 1.385029207141E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 1.385029207141E+18, -4.488982302467E+18,
-8.350115450764E+18, -7.975908114097E+18, -5.651707329729E+18, -4.876973734940E+18,
-5.651707329729E+18, -7.975908114097E+18, -8.350115450764E+18, -4.488982302467E+18,
1.385029207141E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 1.385029207141E+18, -4.488982302467E+18, -8.350115450764E+18,
-7.975908114097E+18, -5.651707329729E+18, -4.876973734940E+18, -5.651707329729E+18,
-7.975908114097E+18, -8.350115450764E+18, -4.488982302467E+18, 1.385029207141E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[5.663043205226E+19, 6.276115134204E+19, 6.889187063182E+19, 7.502258992160E+19,
7.655526974405E+19, -3.424867714738E+18, -1.065498256289E+20, -1.744516071724E+20,
-1.668065798131E+20, -1.642582373601E+20, -1.668065798131E+20, -1.744516071724E+20,
-1.065498256289E+20, -3.424867714738E+18, 7.655526974405E+19, 7.502258992160E+19,
6.889187063182E+19, 6.276115134204E+19, 5.663043205226E+19, 6.276115134204E+19,
5.929572720554E+19, 5.583030306904E+19, 5.236487893254E+19, 5.149852289841E+19,
-3.779572577314E+18, -7.381658890282E+19, -1.189597074863E+20, -1.130882889853E+20,
-1.111311494850E+20, -1.130882889853E+20, -1.189597074863E+20, -7.381658890282E+19,
-3.779572577314E+18, 5.149852289841E+19, 5.236487893254E+19, 5.583030306904E+19,
5.929572720554E+19, 6.276115134204E+19, 6.889187063182E+19, 5.583030306904E+19,
4.276873550626E+19, 2.970716794347E+19, 2.644177605278E+19, -4.134277439891E+18,
-4.108335217679E+19, -6.346780780020E+19, -5.936999815753E+19, -5.800406160998E+19,
-5.936999815753E+19, -6.346780780020E+19, -4.108335217679E+19, -4.134277439891E+18,
2.644177605278E+19, 2.970716794347E+19, 4.276873550626E+19, 5.583030306904E+19,
6.889187063182E+19, 7.502258992160E+19, 5.236487893254E+19, 2.970716794347E+19,
2.970716794347E+19, 5.236487893254E+19, 7.502258992160E+19, 7.655526974405E+19,
5.149852289841E+19, 2.644177605278E+19, 2.644177605278E+19, 5.149852289841E+19,
7.655526974405E+19, -3.424867714738E+18, -3.779572577314E+18, -4.134277439891E+18,
-4.134277439891E+18, -3.779572577314E+18, -3.424867714738E+18, -1.065498256289E+20,
-7.381658890282E+19, -4.108335217679E+19, -4.108335217679E+19, -7.381658890282E+19,
-1.065498256289E+20, -1.744516071724E+20, -1.189597074863E+20, -6.346780780020E+19,
-6.346780780020E+19, -1.189597074863E+20, -1.744516071724E+20, -1.668065798131E+20,
-1.130882889853E+20, -5.936999815753E+19, -5.936999815753E+19, -1.130882889853E+20,
-1.668065798131E+20, -1.642582373601E+20, -1.111311494850E+20, -5.800406160998E+19,
-5.800406160998E+19, -1.111311494850E+20, -1.642582373601E+20, -1.668065798131E+20,
-1.130882889853E+20, -5.936999815753E+19, -5.936999815753E+19, -1.130882889853E+20,
-1.668065798131E+20, -1.744516071724E+20, -1.189597074863E+20, -6.346780780020E+19,
-6.346780780020E+19, -1.189597074863E+20, -1.744516071724E+20, -1.065498256289E+20,
-7.381658890282E+19, -4.108335217679E+19, -4.108335217679E+19, -7.381658890282E+19,
-1.065498256289E+20, -3.424867714738E+18, -3.779572577314E+18, -4.134277439891E+18,
-4.134277439891E+18, -3.779572577314E+18, -3.424867714738E+18, 7.655526974405E+19,
5.149852289841E+19, 2.644177605278E+19, 2.644177605278E+19, 5.149852289841E+19,
7.655526974405E+19, 7.502258992160E+19, 5.236487893254E+19, 2.970716794347E+19,
2.970716794347E+19, 5.236487893254E+19, 7.502258992160E+19, 6.889187063182E+19,
5.583030306904E+19, 4.276873550626E+19, 2.970716794347E+19, 2.644177605278E+19,
-4.134277439891E+18, -4.108335217679E+19, -6.346780780020E+19, -5.936999815753E+19,
-5.800406160998E+19, -5.936999815753E+19, -6.346780780020E+19, -4.108335217679E+19,
-4.134277439891E+18, 2.644177605278E+19, 2.970716794347E+19, 4.276873550626E+19,
5.583030306904E+19, 6.889187063182E+19, 6.276115134204E+19, 5.929572720554E+19,
5.583030306904E+19, 5.236487893254E+19, 5.149852289841E+19, -3.779572577314E+18,
-7.381658890282E+19, -1.189597074863E+20, -1.130882889853E+20, -1.111311494850E+20,
-1.130882889853E+20, -1.189597074863E+20, -7.381658890282E+19, -3.779572577314E+18,
5.149852289841E+19, 5.236487893254E+19, 5.583030306904E+19, 5.929572720554E+19,
6.276115134204E+19, 5.663043205226E+19, 6.276115134204E+19, 6.889187063182E+19,
7.502258992160E+19, 7.655526974405E+19, -3.424867714738E+18, -1.065498256289E+20,
-1.744516071724E+20, -1.668065798131E+20, -1.642582373601E+20, -1.668065798131E+20,
-1.744516071724E+20, -1.065498256289E+20, -3.424867714738E+18, 7.655526974405E+19,
7.502258992160E+19, 6.889187063182E+19, 6.276115134204E+19, 5.663043205226E+19], dtype=np.float64
)
class TestInterpolatorLoadSmallValues(TestInterpolatorLoadValues):
"""
Loading small values (10^-20 times the original) instead of the original np.sin(x)
These data are saved to 12 significant figures.
"""
def __init__(self):
super().__init__()
#: data array from a function sampled on self.x. dtype should be np.float64
# self.data: np.array = np.sin(self.x)
self.data: np.array = np.array(
[[7.049456954407E-22, -5.031133752816E-23, -8.474851229653E-22, -7.975908114097E-22,
-4.876973734940E-22, -4.876973734940E-22, -7.975908114097E-22, -8.474851229653E-22,
-5.031133752816E-23, 7.049456954407E-22],
[-5.031133752816E-23, -9.121921863446E-22, -9.251264987298E-24, 1.052139178127E-21,
1.283205555674E-21, 1.283205555674E-21, 1.052139178127E-21, -9.251264987298E-24,
-9.121921863446E-22, -5.031133752816E-23],
[-8.474851229653E-22, -9.251264987298E-24, 1.283205555674E-21, 1.734970013481E-22,
-1.140407180451E-21, -1.140407180451E-21, 1.734970013481E-22, 1.283205555674E-21,
-9.251264987298E-24, -8.474851229653E-22],
[-7.975908114097E-22, 1.052139178127E-21, 1.734970013481E-22, -2.145503300375E-21,
-9.241435356589E-22, -9.241435356589E-22, -2.145503300375E-21, 1.734970013480E-22,
1.052139178127E-21, -7.975908114097E-22],
[-4.876973734940E-22, 1.283205555674E-21, -1.140407180451E-21, -9.241435356589E-22,
6.446759109720E-21, 6.446759109720E-21, -9.241435356589E-22, -1.140407180451E-21,
1.283205555674E-21, -4.876973734940E-22],
[-4.876973734940E-22, 1.283205555674E-21, -1.140407180451E-21, -9.241435356589E-22,
6.446759109720E-21, 6.446759109720E-21, -9.241435356589E-22, -1.140407180451E-21,
1.283205555674E-21, -4.876973734940E-22],
[-7.975908114097E-22, 1.052139178127E-21, 1.734970013481E-22, -2.145503300375E-21,
-9.241435356589E-22, -9.241435356589E-22, -2.145503300375E-21, 1.734970013480E-22,
1.052139178127E-21, -7.975908114097E-22],
[-8.474851229653E-22, -9.251264987298E-24, 1.283205555674E-21, 1.734970013480E-22,
-1.140407180451E-21, -1.140407180451E-21, 1.734970013480E-22, 1.283205555674E-21,
-9.251264987296E-24, -8.474851229653E-22],
[-5.031133752816E-23, -9.121921863446E-22, -9.251264987298E-24, 1.052139178127E-21,
1.283205555674E-21, 1.283205555674E-21, 1.052139178127E-21, -9.251264987296E-24,
-9.121921863446E-22, -5.031133752816E-23],
[7.049456954407E-22, -5.031133752816E-23, -8.474851229653E-22, -7.975908114097E-22,
-4.876973734940E-22, -4.876973734940E-22, -7.975908114097E-22, -8.474851229653E-22,
-5.031133752816E-23, 7.049456954407E-22]], dtype=np.float64
)
#: array holding precalculated quadratic extrapolation data
self.precalc_extrapolation_quadratic: np.array = np.array(
[], dtype=np.float64
)
def setup_cubic(self):
self.precalc_interpolation = np.array(
[[7.049456954264E-22, 1.414501923508E-22, -4.992201892787E-22, -9.006647501692E-22,
-7.975908114097E-22, -5.494750801435E-22, -4.489606937545E-22, -5.494750801436E-22,
-7.975908114100E-22, -9.006647501711E-22, -4.992201892810E-22, 1.414501923847E-22,
7.049456954556E-22],
[1.414501923618E-22, -6.879873015399E-22, -6.604387574163E-22, -9.273861047815E-24,
7.815453486868E-22, 1.087722976395E-21, 1.179639375774E-21, 1.087722976395E-21,
7.815453486864E-22, -9.273861049481E-24, -6.604387574180E-22, -6.879873015137E-22,
1.414501923837E-22],
[-4.992201892795E-22, -6.604387574171E-22, 7.662704616648E-23, 8.927226959196E-22,
8.733637329416E-22, 3.144134389939E-22, 8.046419412826E-23, 3.144134389938E-22,
8.733637329419E-22, 8.927226959212E-22, 7.662704616608E-23, -6.604387574155E-22,
-4.992201892762E-22],
[-9.006647501697E-22, -9.273861047635E-24, 8.927226959229E-22, 9.500724468556E-22,
-3.879550824799E-22, -1.262756473835E-21, -1.571105597160E-21, -1.262756473839E-21,
-3.879550824817E-22, 9.500724468550E-22, 8.927226959408E-22, -9.273861038222E-24,
-9.006647501493E-22],
[-7.975908114093E-22, 7.815453486870E-22, 8.733637329381E-22, -3.879550824787E-22,
-2.145503300374E-21, -1.226583807440E-21, -7.714735650690E-22, -1.226583807454E-21,
-2.145503300370E-21, -3.879550824826E-22, 8.733637328991E-22, 7.815453486854E-22,
-7.975908114063E-22],
[-5.494750801431E-22, 1.087722976395E-21, 3.144134389893E-22, -1.262756473834E-21,
-1.226583807434E-21, 3.691392206497E-21, 5.727262813613E-21, 3.691392206474E-21,
-1.226583807439E-21, -1.262756473868E-21, 3.144134390512E-22, 1.087722976396E-21,
-5.494750801446E-22],
[-4.489606937538E-22, 1.179639375775E-21, 8.046419412696E-23, -1.571105597160E-21,
-7.714735650701E-22, 5.727262813612E-21, 8.385571378575E-21, 5.727262813618E-21,
-7.714735650696E-22, -1.571105597161E-21, 8.046419412846E-23, 1.179639375773E-21,
-4.489606937591E-22],
[-5.494750801434E-22, 1.087722976395E-21, 3.144134390008E-22, -1.262756473844E-21,
-1.226583807433E-21, 3.691392206488E-21, 5.727262813614E-21, 3.691392206419E-21,
-1.226583807457E-21, -1.262756473861E-21, 3.144134391132E-22, 1.087722976390E-21,
-5.494750801485E-22],
[-7.975908114306E-22, 7.815453486712E-22, 8.733637329342E-22, -3.879550824792E-22,
-2.145503300377E-21, -1.226583807429E-21, -7.714735650699E-22, -1.226583807452E-21,
-2.145503300310E-21, -3.879550824614E-22, 8.733637328587E-22, 7.815453486866E-22,
-7.975908110894E-22],
[-9.006647501952E-22, -9.273861067304E-24, 8.927226959138E-22, 9.500724468601E-22,
-3.879550824810E-22, -1.262756473846E-21, -1.571105597161E-21, -1.262756473885E-21,
-3.879550824035E-22, 9.500724468340E-22, 8.927226955189E-22, -9.273860862048E-24,
-9.006647499257E-22],
[-4.992201892821E-22, -6.604387574194E-22, 7.662704617160E-23, 8.927226959387E-22,
8.733637329469E-22, 3.144134390697E-22, 8.046419413383E-23, 3.144134392460E-22,
8.733637329685E-22, 8.927226958359E-22, 7.662704629676E-23, -6.604387573915E-22,
-4.992201893027E-22],
[1.414501923332E-22, -6.879873015551E-22, -6.604387574050E-22, -9.273861079956E-24,
7.815453486878E-22, 1.087722976402E-21, 1.179639375773E-21, 1.087722976395E-21,
7.815453486844E-22, -9.273860941952E-24, -6.604387571973E-22, -6.879873019460E-22,
1.414501922245E-22],
[7.049456953963E-22, 1.414501923357E-22, -4.992201892648E-22, -9.006647502111E-22,
-7.975908114054E-22, -5.494750801416E-22, -4.489606937555E-22, -5.494750801446E-22,
-7.975908113966E-22, -9.006647503577E-22, -4.992201891716E-22, 1.414501923407E-22,
7.049456953362E-22]], dtype=np.float64
)
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954264E-22, 7.049456954264E-22, 7.049456954264E-22, 7.049456954264E-22,
1.414501923508E-22, -4.992201892787E-22, -9.006647501692E-22, -7.975908114097E-22,
-5.494750801435E-22, -4.489606937545E-22, -5.494750801436E-22, -7.975908114100E-22,
-9.006647501711E-22, -4.992201892810E-22, 1.414501923847E-22, 7.049456954556E-22,
7.049456954556E-22, 7.049456954556E-22, 7.049456954556E-22, 7.049456954264E-22,
7.049456954264E-22, 7.049456954264E-22, 7.049456954264E-22, 1.414501923508E-22,
-4.992201892787E-22, -9.006647501692E-22, -7.975908114097E-22, -5.494750801435E-22,
-4.489606937545E-22, -5.494750801436E-22, -7.975908114100E-22, -9.006647501711E-22,
-4.992201892810E-22, 1.414501923847E-22, 7.049456954556E-22, 7.049456954556E-22,
7.049456954556E-22, 7.049456954556E-22, 7.049456954264E-22, 7.049456954264E-22,
7.049456954264E-22, 7.049456954264E-22, 1.414501923508E-22, -4.992201892787E-22,
-9.006647501692E-22, -7.975908114097E-22, -5.494750801435E-22, -4.489606937545E-22,
-5.494750801436E-22, -7.975908114100E-22, -9.006647501711E-22, -4.992201892810E-22,
1.414501923847E-22, 7.049456954556E-22, 7.049456954556E-22, 7.049456954556E-22,
7.049456954556E-22, 7.049456954264E-22, 7.049456954264E-22, 7.049456954264E-22,
7.049456954556E-22, 7.049456954556E-22, 7.049456954556E-22, 1.414501923618E-22,
1.414501923618E-22, 1.414501923618E-22, 1.414501923837E-22, 1.414501923837E-22,
1.414501923837E-22, -4.992201892795E-22, -4.992201892795E-22, -4.992201892795E-22,
-4.992201892762E-22, -4.992201892762E-22, -4.992201892762E-22, -9.006647501697E-22,
-9.006647501697E-22, -9.006647501697E-22, -9.006647501493E-22, -9.006647501493E-22,
-9.006647501493E-22, -7.975908114093E-22, -7.975908114093E-22, -7.975908114093E-22,
-7.975908114063E-22, -7.975908114063E-22, -7.975908114063E-22, -5.494750801431E-22,
-5.494750801431E-22, -5.494750801431E-22, -5.494750801446E-22, -5.494750801446E-22,
-5.494750801446E-22, -4.489606937538E-22, -4.489606937538E-22, -4.489606937538E-22,
-4.489606937591E-22, -4.489606937591E-22, -4.489606937591E-22, -5.494750801434E-22,
-5.494750801434E-22, -5.494750801434E-22, -5.494750801485E-22, -5.494750801485E-22,
-5.494750801485E-22, -7.975908114306E-22, -7.975908114306E-22, -7.975908114306E-22,
-7.975908110894E-22, -7.975908110894E-22, -7.975908110894E-22, -9.006647501952E-22,
-9.006647501952E-22, -9.006647501952E-22, -9.006647499257E-22, -9.006647499257E-22,
-9.006647499257E-22, -4.992201892821E-22, -4.992201892821E-22, -4.992201892821E-22,
-4.992201893027E-22, -4.992201893027E-22, -4.992201893027E-22, 1.414501923332E-22,
1.414501923332E-22, 1.414501923332E-22, 1.414501922245E-22, 1.414501922245E-22,
1.414501922245E-22, 7.049456953963E-22, 7.049456953963E-22, 7.049456953963E-22,
7.049456953362E-22, 7.049456953362E-22, 7.049456953362E-22, 7.049456953963E-22,
7.049456953963E-22, 7.049456953963E-22, 7.049456953963E-22, 1.414501923357E-22,
-4.992201892648E-22, -9.006647502111E-22, -7.975908114054E-22, -5.494750801416E-22,
-4.489606937555E-22, -5.494750801446E-22, -7.975908113966E-22, -9.006647503577E-22,
-4.992201891716E-22, 1.414501923407E-22, 7.049456953362E-22, 7.049456953362E-22,
7.049456953362E-22, 7.049456953362E-22, 7.049456953963E-22, 7.049456953963E-22,
7.049456953963E-22, 7.049456953963E-22, 1.414501923357E-22, -4.992201892648E-22,
-9.006647502111E-22, -7.975908114054E-22, -5.494750801416E-22, -4.489606937555E-22,
-5.494750801446E-22, -7.975908113966E-22, -9.006647503577E-22, -4.992201891716E-22,
1.414501923407E-22, 7.049456953362E-22, 7.049456953362E-22, 7.049456953362E-22,
7.049456953362E-22, 7.049456953963E-22, 7.049456953963E-22, 7.049456953963E-22,
7.049456953963E-22, 1.414501923357E-22, -4.992201892648E-22, -9.006647502111E-22,
-7.975908114054E-22, -5.494750801416E-22, -4.489606937555E-22, -5.494750801446E-22,
-7.975908113966E-22, -9.006647503577E-22, -4.992201891716E-22, 1.414501923407E-22,
7.049456953362E-22, 7.049456953362E-22, 7.049456953362E-22, 7.049456953362E-22], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[5.663043205226E-21, 6.276115134204E-21, 6.889187063182E-21, 7.502258992160E-21,
8.801800967422E-21, 2.361337399095E-22, -1.138639225842E-20, -1.744516071724E-20,
-1.684506962764E-20, -1.629840661335E-20, -1.684506962764E-20, -1.744516071724E-20,
-1.138639225842E-20, 2.361337399095E-22, 8.801800967422E-21, 7.502258992160E-21,
6.889187063182E-21, 6.276115134204E-21, 5.663043205226E-21, 6.276115134204E-21,
5.929572720554E-21, 5.583030306904E-21, 5.236487893254E-21, 5.915017375739E-21,
-8.984236486835E-24, -7.891149755669E-21, -1.189597074863E-20, -1.141320477848E-20,
-1.101525797349E-20, -1.141320477848E-20, -1.189597074863E-20, -7.891149755669E-21,
-8.984236486840E-24, 5.915017375739E-21, 5.236487893254E-21, 5.583030306904E-21,
5.929572720554E-21, 6.276115134204E-21, 6.889187063182E-21, 5.583030306904E-21,
4.276873550626E-21, 2.970716794347E-21, 3.028233784055E-21, -2.541022128832E-22,
-4.395907252919E-21, -6.346780780020E-21, -5.981339929310E-21, -5.732109333620E-21,
-5.981339929310E-21, -6.346780780020E-21, -4.395907252919E-21, -2.541022128832E-22,
3.028233784055E-21, 2.970716794347E-21, 4.276873550626E-21, 5.583030306904E-21,
6.889187063182E-21, 7.502258992160E-21, 5.236487893254E-21, 2.970716794347E-21,
2.970716794347E-21, 5.236487893254E-21, 7.502258992160E-21, 8.801800967422E-21,
5.915017375739E-21, 3.028233784055E-21, 3.028233784055E-21, 5.915017375739E-21,
8.801800967422E-21, 2.361337399095E-22, -8.984236486836E-24, -2.541022128832E-22,
-2.541022128832E-22, -8.984236486841E-24, 2.361337399095E-22, -1.138639225842E-20,
-7.891149755669E-21, -4.395907252919E-21, -4.395907252919E-21, -7.891149755669E-21,
-1.138639225842E-20, -1.744516071724E-20, -1.189597074863E-20, -6.346780780020E-21,
-6.346780780020E-21, -1.189597074863E-20, -1.744516071724E-20, -1.684506962764E-20,
-1.141320477848E-20, -5.981339929310E-21, -5.981339929310E-21, -1.141320477848E-20,
-1.684506962764E-20, -1.629840661335E-20, -1.101525797349E-20, -5.732109333620E-21,
-5.732109333620E-21, -1.101525797349E-20, -1.629840661335E-20, -1.684506962764E-20,
-1.141320477848E-20, -5.981339929310E-21, -5.981339929310E-21, -1.141320477848E-20,
-1.684506962764E-20, -1.744516071724E-20, -1.189597074863E-20, -6.346780780020E-21,
-6.346780780020E-21, -1.189597074863E-20, -1.744516071724E-20, -1.138639225842E-20,
-7.891149755669E-21, -4.395907252919E-21, -4.395907252919E-21, -7.891149755669E-21,
-1.138639225842E-20, 2.361337399095E-22, -8.984236486840E-24, -2.541022128832E-22,
-2.541022128832E-22, -8.984236486847E-24, 2.361337399095E-22, 8.801800967422E-21,
5.915017375739E-21, 3.028233784055E-21, 3.028233784055E-21, 5.915017375739E-21,
8.801800967422E-21, 7.502258992160E-21, 5.236487893254E-21, 2.970716794347E-21,
2.970716794347E-21, 5.236487893254E-21, 7.502258992160E-21, 6.889187063182E-21,
5.583030306904E-21, 4.276873550626E-21, 2.970716794347E-21, 3.028233784055E-21,
-2.541022128832E-22, -4.395907252919E-21, -6.346780780020E-21, -5.981339929310E-21,
-5.732109333620E-21, -5.981339929310E-21, -6.346780780020E-21, -4.395907252919E-21,
-2.541022128832E-22, 3.028233784055E-21, 2.970716794347E-21, 4.276873550626E-21,
5.583030306904E-21, 6.889187063182E-21, 6.276115134204E-21, 5.929572720554E-21,
5.583030306904E-21, 5.236487893254E-21, 5.915017375739E-21, -8.984236486850E-24,
-7.891149755669E-21, -1.189597074863E-20, -1.141320477848E-20, -1.101525797349E-20,
-1.141320477848E-20, -1.189597074863E-20, -7.891149755669E-21, -8.984236486845E-24,
5.915017375739E-21, 5.236487893254E-21, 5.583030306904E-21, 5.929572720554E-21,
6.276115134204E-21, 5.663043205226E-21, 6.276115134204E-21, 6.889187063182E-21,
7.502258992160E-21, 8.801800967422E-21, 2.361337399095E-22, -1.138639225842E-20,
-1.744516071724E-20, -1.684506962764E-20, -1.629840661335E-20, -1.684506962764E-20,
-1.744516071724E-20, -1.138639225842E-20, 2.361337399095E-22, 8.801800967422E-21,
7.502258992160E-21, 6.889187063182E-21, 6.276115134204E-21, 5.663043205226E-21], dtype=np.float64
)
def setup_linear(self):
self.precalc_interpolation = np.array(
[[7.049456954407E-22, 1.385029207141E-22, -4.488982302467E-22, -8.350115450764E-22,
-7.975908114097E-22, -5.651707329729E-22, -4.876973734940E-22, -5.651707329729E-22,
-7.975908114097E-22, -8.350115450764E-22, -4.488982302467E-22, 1.385029207141E-22,
7.049456954407E-22],
[1.385029207141E-22, -4.879157504269E-22, -4.577658518112E-22, -1.668062692568E-23,
5.897066807427E-22, 7.777865377223E-22, 8.404798233821E-22, 7.777865377223E-22,
5.897066807427E-22, -1.668062692568E-23, -4.577658518112E-22, -4.879157504269E-22,
1.385029207141E-22],
[-4.488982302467E-22, -4.577658518112E-22, 8.812770983874E-23, 6.309373814419E-22,
6.128180897374E-22, 2.067539131431E-22, 7.139918761166E-23, 2.067539131431E-22,
6.128180897374E-22, 6.309373814419E-22, 8.812770983874E-23, -4.577658518112E-22,
-4.488982302467E-22],
[-8.350115450764E-22, -1.668062692568E-23, 6.309373814419E-22, 6.527705442988E-22,
-4.062530740828E-22, -9.163192204604E-22, -1.086341269253E-21, -9.163192204604E-22,
-4.062530740828E-22, 6.527705442988E-22, 6.309373814419E-22, -1.668062692568E-23,
-8.350115450764E-22],
[-7.975908114097E-22, 5.897066807427E-22, 6.128180897374E-22, -4.062530740828E-22,
-2.145503300375E-21, -1.229483476838E-21, -9.241435356589E-22, -1.229483476838E-21,
-2.145503300375E-21, -4.062530740828E-22, 6.128180897374E-22, 5.897066807427E-22,
-7.975908114097E-22],
[-5.651707329729E-22, 7.777865377223E-22, 2.067539131431E-22, -9.163192204604E-22,
-1.229483476838E-21, 3.145654217072E-21, 4.604033448375E-21, 3.145654217072E-21,
-1.229483476838E-21, -9.163192204604E-22, 2.067539131431E-22, 7.777865377223E-22,
-5.651707329729E-22],
[-4.876973734940E-22, 8.404798233821E-22, 7.139918761166E-23, -1.086341269253E-21,
-9.241435356589E-22, 4.604033448375E-21, 6.446759109720E-21, 4.604033448375E-21,
-9.241435356589E-22, -1.086341269253E-21, 7.139918761166E-23, 8.404798233821E-22,
-4.876973734940E-22],
[-5.651707329729E-22, 7.777865377223E-22, 2.067539131431E-22, -9.163192204604E-22,
-1.229483476838E-21, 3.145654217072E-21, 4.604033448375E-21, 3.145654217072E-21,
-1.229483476838E-21, -9.163192204604E-22, 2.067539131431E-22, 7.777865377223E-22,
-5.651707329729E-22],
[-7.975908114097E-22, 5.897066807427E-22, 6.128180897374E-22, -4.062530740828E-22,
-2.145503300375E-21, -1.229483476838E-21, -9.241435356589E-22, -1.229483476838E-21,
-2.145503300375E-21, -4.062530740828E-22, 6.128180897374E-22, 5.897066807427E-22,
-7.975908114097E-22],
[-8.350115450764E-22, -1.668062692568E-23, 6.309373814419E-22, 6.527705442988E-22,
-4.062530740828E-22, -9.163192204604E-22, -1.086341269253E-21, -9.163192204604E-22,
-4.062530740828E-22, 6.527705442988E-22, 6.309373814419E-22, -1.668062692568E-23,
-8.350115450764E-22],
[-4.488982302467E-22, -4.577658518112E-22, 8.812770983874E-23, 6.309373814419E-22,
6.128180897374E-22, 2.067539131431E-22, 7.139918761166E-23, 2.067539131431E-22,
6.128180897374E-22, 6.309373814419E-22, 8.812770983874E-23, -4.577658518112E-22,
-4.488982302467E-22],
[1.385029207141E-22, -4.879157504269E-22, -4.577658518112E-22, -1.668062692568E-23,
5.897066807427E-22, 7.777865377223E-22, 8.404798233821E-22, 7.777865377223E-22,
5.897066807427E-22, -1.668062692568E-23, -4.577658518112E-22, -4.879157504269E-22,
1.385029207141E-22],
[7.049456954407E-22, 1.385029207141E-22, -4.488982302467E-22, -8.350115450764E-22,
-7.975908114097E-22, -5.651707329729E-22, -4.876973734940E-22, -5.651707329729E-22,
-7.975908114097E-22, -8.350115450764E-22, -4.488982302467E-22, 1.385029207141E-22,
7.049456954407E-22]], dtype=np.float64
)
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
1.385029207141E-22, -4.488982302467E-22, -8.350115450764E-22, -7.975908114097E-22,
-5.651707329729E-22, -4.876973734940E-22, -5.651707329729E-22, -7.975908114097E-22,
-8.350115450764E-22, -4.488982302467E-22, 1.385029207141E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 1.385029207141E-22,
-4.488982302467E-22, -8.350115450764E-22, -7.975908114097E-22, -5.651707329729E-22,
-4.876973734940E-22, -5.651707329729E-22, -7.975908114097E-22, -8.350115450764E-22,
-4.488982302467E-22, 1.385029207141E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 1.385029207141E-22, -4.488982302467E-22,
-8.350115450764E-22, -7.975908114097E-22, -5.651707329729E-22, -4.876973734940E-22,
-5.651707329729E-22, -7.975908114097E-22, -8.350115450764E-22, -4.488982302467E-22,
1.385029207141E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 1.385029207141E-22,
1.385029207141E-22, 1.385029207141E-22, 1.385029207141E-22, 1.385029207141E-22,
1.385029207141E-22, -4.488982302467E-22, -4.488982302467E-22, -4.488982302467E-22,
-4.488982302467E-22, -4.488982302467E-22, -4.488982302467E-22, -8.350115450764E-22,
-8.350115450764E-22, -8.350115450764E-22, -8.350115450764E-22, -8.350115450764E-22,
-8.350115450764E-22, -7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22,
-7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22, -5.651707329729E-22,
-5.651707329729E-22, -5.651707329729E-22, -5.651707329729E-22, -5.651707329729E-22,
-5.651707329729E-22, -4.876973734940E-22, -4.876973734940E-22, -4.876973734940E-22,
-4.876973734940E-22, -4.876973734940E-22, -4.876973734940E-22, -5.651707329729E-22,
-5.651707329729E-22, -5.651707329729E-22, -5.651707329729E-22, -5.651707329729E-22,
-5.651707329729E-22, -7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22,
-7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22, -8.350115450764E-22,
-8.350115450764E-22, -8.350115450764E-22, -8.350115450764E-22, -8.350115450764E-22,
-8.350115450764E-22, -4.488982302467E-22, -4.488982302467E-22, -4.488982302467E-22,
-4.488982302467E-22, -4.488982302467E-22, -4.488982302467E-22, 1.385029207141E-22,
1.385029207141E-22, 1.385029207141E-22, 1.385029207141E-22, 1.385029207141E-22,
1.385029207141E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 1.385029207141E-22,
-4.488982302467E-22, -8.350115450764E-22, -7.975908114097E-22, -5.651707329729E-22,
-4.876973734940E-22, -5.651707329729E-22, -7.975908114097E-22, -8.350115450764E-22,
-4.488982302467E-22, 1.385029207141E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 1.385029207141E-22, -4.488982302467E-22,
-8.350115450764E-22, -7.975908114097E-22, -5.651707329729E-22, -4.876973734940E-22,
-5.651707329729E-22, -7.975908114097E-22, -8.350115450764E-22, -4.488982302467E-22,
1.385029207141E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 1.385029207141E-22, -4.488982302467E-22, -8.350115450764E-22,
-7.975908114097E-22, -5.651707329729E-22, -4.876973734940E-22, -5.651707329729E-22,
-7.975908114097E-22, -8.350115450764E-22, -4.488982302467E-22, 1.385029207141E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[5.663043205226E-21, 6.276115134204E-21, 6.889187063182E-21, 7.502258992160E-21,
7.655526974405E-21, -3.424867714738E-22, -1.065498256289E-20, -1.744516071724E-20,
-1.668065798131E-20, -1.642582373601E-20, -1.668065798131E-20, -1.744516071724E-20,
-1.065498256289E-20, -3.424867714738E-22, 7.655526974405E-21, 7.502258992160E-21,
6.889187063182E-21, 6.276115134204E-21, 5.663043205226E-21, 6.276115134204E-21,
5.929572720554E-21, 5.583030306904E-21, 5.236487893254E-21, 5.149852289841E-21,
-3.779572577314E-22, -7.381658890282E-21, -1.189597074863E-20, -1.130882889853E-20,
-1.111311494850E-20, -1.130882889853E-20, -1.189597074863E-20, -7.381658890282E-21,
-3.779572577314E-22, 5.149852289841E-21, 5.236487893254E-21, 5.583030306904E-21,
5.929572720554E-21, 6.276115134204E-21, 6.889187063182E-21, 5.583030306904E-21,
4.276873550626E-21, 2.970716794347E-21, 2.644177605278E-21, -4.134277439891E-22,
-4.108335217679E-21, -6.346780780020E-21, -5.936999815753E-21, -5.800406160998E-21,
-5.936999815753E-21, -6.346780780020E-21, -4.108335217679E-21, -4.134277439891E-22,
2.644177605278E-21, 2.970716794347E-21, 4.276873550626E-21, 5.583030306904E-21,
6.889187063182E-21, 7.502258992160E-21, 5.236487893254E-21, 2.970716794347E-21,
2.970716794347E-21, 5.236487893254E-21, 7.502258992160E-21, 7.655526974405E-21,
5.149852289841E-21, 2.644177605278E-21, 2.644177605278E-21, 5.149852289841E-21,
7.655526974405E-21, -3.424867714738E-22, -3.779572577314E-22, -4.134277439891E-22,
-4.134277439891E-22, -3.779572577314E-22, -3.424867714738E-22, -1.065498256289E-20,
-7.381658890282E-21, -4.108335217679E-21, -4.108335217679E-21, -7.381658890282E-21,
-1.065498256289E-20, -1.744516071724E-20, -1.189597074863E-20, -6.346780780020E-21,
-6.346780780020E-21, -1.189597074863E-20, -1.744516071724E-20, -1.668065798131E-20,
-1.130882889853E-20, -5.936999815753E-21, -5.936999815753E-21, -1.130882889853E-20,
-1.668065798131E-20, -1.642582373601E-20, -1.111311494850E-20, -5.800406160998E-21,
-5.800406160998E-21, -1.111311494850E-20, -1.642582373601E-20, -1.668065798131E-20,
-1.130882889853E-20, -5.936999815753E-21, -5.936999815753E-21, -1.130882889853E-20,
-1.668065798131E-20, -1.744516071724E-20, -1.189597074863E-20, -6.346780780020E-21,
-6.346780780020E-21, -1.189597074863E-20, -1.744516071724E-20, -1.065498256289E-20,
-7.381658890282E-21, -4.108335217679E-21, -4.108335217679E-21, -7.381658890282E-21,
-1.065498256289E-20, -3.424867714738E-22, -3.779572577314E-22, -4.134277439891E-22,
-4.134277439891E-22, -3.779572577314E-22, -3.424867714738E-22, 7.655526974405E-21,
5.149852289841E-21, 2.644177605278E-21, 2.644177605278E-21, 5.149852289841E-21,
7.655526974405E-21, 7.502258992160E-21, 5.236487893254E-21, 2.970716794347E-21,
2.970716794347E-21, 5.236487893254E-21, 7.502258992160E-21, 6.889187063182E-21,
5.583030306904E-21, 4.276873550626E-21, 2.970716794347E-21, 2.644177605278E-21,
-4.134277439891E-22, -4.108335217679E-21, -6.346780780020E-21, -5.936999815753E-21,
-5.800406160998E-21, -5.936999815753E-21, -6.346780780020E-21, -4.108335217679E-21,
-4.134277439891E-22, 2.644177605278E-21, 2.970716794347E-21, 4.276873550626E-21,
5.583030306904E-21, 6.889187063182E-21, 6.276115134204E-21, 5.929572720554E-21,
5.583030306904E-21, 5.236487893254E-21, 5.149852289841E-21, -3.779572577314E-22,
-7.381658890282E-21, -1.189597074863E-20, -1.130882889853E-20, -1.111311494850E-20,
-1.130882889853E-20, -1.189597074863E-20, -7.381658890282E-21, -3.779572577314E-22,
5.149852289841E-21, 5.236487893254E-21, 5.583030306904E-21, 5.929572720554E-21,
6.276115134204E-21, 5.663043205226E-21, 6.276115134204E-21, 6.889187063182E-21,
7.502258992160E-21, 7.655526974405E-21, -3.424867714738E-22, -1.065498256289E-20,
-1.744516071724E-20, -1.668065798131E-20, -1.642582373601E-20, -1.668065798131E-20,
-1.744516071724E-20, -1.065498256289E-20, -3.424867714738E-22, 7.655526974405E-21,
7.502258992160E-21, 6.889187063182E-21, 6.276115134204E-21, 5.663043205226E-21], dtype=np.float64
)
class TestInterpolatorLoadNormalValuesUneven(TestInterpolatorLoadValues):
"""
Loading normal sized values for a 2D sinc function test.
For description of data storage, see TestInterpolatorLoadValues.
"""
def __init__(self):
super().__init__()
#: data array from a function sampled on self.x. dtype should be np.float64
self.data: np.array = np.array(
[[7.049456954407E-02, 5.750613283457E-02, -5.031133752816E-03, -3.957902354963E-02,
-8.474851229653E-02, -9.121180789640E-02, -7.975908114097E-02, -6.835527608142E-02,
-4.876973734940E-02, -4.418624359019E-02, -4.876973734940E-02, -5.728794999748E-02,
-7.975908114097E-02, -8.851381966774E-02, -8.474851229653E-02, -6.734331948907E-02,
-5.031133752816E-03, 2.994648599639E-02, 7.049456954407E-02],
[5.750613283457E-02, 2.707313596327E-02, -4.947098908050E-02, -7.716977009236E-02,
-8.851381966774E-02, -7.454434661366E-02, -2.923247487940E-02, -6.867195016855E-03,
2.378357578524E-02, 3.010595454905E-02, 2.378357578524E-02, 1.127556015714E-02,
-2.923247487940E-02, -5.313921590225E-02, -8.851381966774E-02, -9.034807299146E-02,
-4.947098908050E-02, -1.193366977476E-02, 5.750613283457E-02],
[-5.031133752816E-03, -4.947098908050E-02, -9.121921863446E-02, -7.727418937786E-02,
-9.251264987298E-04, 4.278478892878E-02, 1.052139178127E-01, 1.201126954831E-01,
1.283205555674E-01, 1.282705054889E-01, 1.283205555674E-01, 1.266409993718E-01,
1.052139178127E-01, 7.942173990430E-02, -9.251264987298E-04, -4.418624359019E-02,
-9.121921863446E-02, -8.127030064783E-02, -5.031133752816E-03],
[-3.957902354963E-02, -7.716977009236E-02, -7.727418937786E-02, -3.939635588637E-02,
6.155045982467E-02, 1.005907311298E-01, 1.282705054889E-01, 1.215171020957E-01,
9.674890958243E-02, 8.947967120127E-02, 9.674890958243E-02, 1.089467585825E-01,
1.282705054889E-01, 1.227830098222E-01, 6.155045982467E-02, 1.127556015714E-02,
-7.727418937786E-02, -9.132515608025E-02, -3.957902354963E-02],
[-8.474851229653E-02, -8.851381966774E-02, -9.251264987298E-04, 6.155045982467E-02,
1.283205555674E-01, 1.138884597353E-01, 1.734970013481E-02, -3.806455343631E-02,
-1.140407180451E-01, -1.289967784984E-01, -1.140407180451E-01, -8.347707818621E-02,
1.734970013481E-02, 7.259972187812E-02, 1.283205555674E-01, 1.095087852132E-01,
-9.251264987298E-04, -5.728794999748E-02, -8.474851229653E-02],
[-9.121180789640E-02, -7.454434661366E-02, 4.278478892878E-02, 1.005907311298E-01,
1.138884597353E-01, 6.300331483592E-02, -8.347707818621E-02, -1.435151388671E-01,
-2.022780434934E-01, -2.095142217650E-01, -2.022780434934E-01, -1.824711128590E-01,
-8.347707818621E-02, -9.351916346701E-03, 1.138884597353E-01, 1.277678821031E-01,
4.278478892878E-02, -2.387837583277E-02, -9.121180789640E-02],
[-7.975908114097E-02, -2.923247487940E-02, 1.052139178127E-01, 1.282705054889E-01,
1.734970013481E-02, -8.347707818621E-02, -2.145503300375E-01, -2.052264171648E-01,
-9.241435356589E-02, -5.067031374727E-02, -9.241435356589E-02, -1.547945550760E-01,
-2.145503300375E-01, -1.704692811750E-01, 1.734970013480E-02, 9.674890958243E-02,
1.052139178127E-01, 4.278478892878E-02, -7.975908114097E-02],
[-6.835527608142E-02, -6.867195016855E-03, 1.201126954831E-01, 1.215171020957E-01,
-3.806455343631E-02, -1.435151388671E-01, -2.052264171648E-01, -1.268933271435E-01,
1.257727427008E-01, 2.044658799484E-01, 1.257727427008E-01, -9.251369377679E-04,
-2.052264171648E-01, -2.095142217650E-01, -3.806455343631E-02, 6.300331483592E-02,
1.201126954831E-01, 6.764157650466E-02, -6.835527608142E-02],
[-4.876973734940E-02, 2.378357578524E-02, 1.283205555674E-01, 9.674890958243E-02,
-1.140407180451E-01, -2.022780434934E-01, -9.241435356589E-02, 1.257727427008E-01,
6.446759109720E-01, 7.917136926885E-01, 6.446759109720E-01, 3.973381423908E-01,
-9.241435356589E-02, -2.052264171648E-01, -1.140407180451E-01, 4.282861041084E-03,
1.283205555674E-01, 9.566990623455E-02, -4.876973734940E-02],
[-4.418624359019E-02, 3.010595454905E-02, 1.282705054889E-01, 8.947967120127E-02,
-1.289967784984E-01, -2.095142217650E-01, -5.067031374727E-02, 2.044658799484E-01,
7.917136926885E-01, 9.560513212622E-01, 7.917136926885E-01, 5.136281978234E-01,
-5.067031374727E-02, -1.933844713753E-01, -1.289967784984E-01, -9.351916346701E-03,
1.282705054889E-01, 1.005907311298E-01, -4.418624359019E-02],
[-4.876973734940E-02, 2.378357578524E-02, 1.283205555674E-01, 9.674890958243E-02,
-1.140407180451E-01, -2.022780434934E-01, -9.241435356589E-02, 1.257727427008E-01,
6.446759109720E-01, 7.917136926885E-01, 6.446759109720E-01, 3.973381423908E-01,
-9.241435356589E-02, -2.052264171648E-01, -1.140407180451E-01, 4.282861041084E-03,
1.283205555674E-01, 9.566990623455E-02, -4.876973734940E-02],
[-5.728794999748E-02, 1.127556015714E-02, 1.266409993718E-01, 1.089467585825E-01,
-8.347707818621E-02, -1.824711128590E-01, -1.547945550760E-01, -9.251369377679E-04,
3.973381423908E-01, 5.136281978234E-01, 3.973381423908E-01, 2.044658799484E-01,
-1.547945550760E-01, -2.165899038868E-01, -8.347707818621E-02, 2.979548967146E-02,
1.266409993718E-01, 8.505592925358E-02, -5.728794999748E-02],
[-7.975908114097E-02, -2.923247487940E-02, 1.052139178127E-01, 1.282705054889E-01,
1.734970013481E-02, -8.347707818621E-02, -2.145503300375E-01, -2.052264171648E-01,
-9.241435356589E-02, -5.067031374727E-02, -9.241435356589E-02, -1.547945550760E-01,
-2.145503300375E-01, -1.704692811750E-01, 1.734970013480E-02, 9.674890958243E-02,
1.052139178127E-01, 4.278478892878E-02, -7.975908114097E-02],
[-8.851381966774E-02, -5.313921590225E-02, 7.942173990430E-02, 1.227830098222E-01,
7.259972187812E-02, -9.351916346701E-03, -1.704692811750E-01, -2.095142217650E-01,
-2.052264171648E-01, -1.933844713753E-01, -2.052264171648E-01, -2.165899038868E-01,
-1.704692811750E-01, -9.881655954565E-02, 7.259972187812E-02, 1.215171020957E-01,
7.942173990430E-02, 1.127556015714E-02, -8.851381966774E-02],
[-8.474851229653E-02, -8.851381966774E-02, -9.251264987298E-04, 6.155045982467E-02,
1.283205555674E-01, 1.138884597353E-01, 1.734970013480E-02, -3.806455343631E-02,
-1.140407180451E-01, -1.289967784984E-01, -1.140407180451E-01, -8.347707818621E-02,
1.734970013480E-02, 7.259972187812E-02, 1.283205555674E-01, 1.095087852132E-01,
-9.251264987296E-04, -5.728794999748E-02, -8.474851229653E-02],
[-6.734331948907E-02, -9.034807299146E-02, -4.418624359019E-02, 1.127556015714E-02,
1.095087852132E-01, 1.277678821031E-01, 9.674890958243E-02, 6.300331483592E-02,
4.282861041084E-03, -9.351916346701E-03, 4.282861041084E-03, 2.979548967146E-02,
9.674890958243E-02, 1.215171020957E-01, 1.095087852132E-01, 6.764157650466E-02,
-4.418624359019E-02, -8.199851501756E-02, -6.734331948907E-02],
[-5.031133752816E-03, -4.947098908050E-02, -9.121921863446E-02, -7.727418937786E-02,
-9.251264987298E-04, 4.278478892878E-02, 1.052139178127E-01, 1.201126954831E-01,
1.283205555674E-01, 1.282705054889E-01, 1.283205555674E-01, 1.266409993718E-01,
1.052139178127E-01, 7.942173990430E-02, -9.251264987296E-04, -4.418624359019E-02,
-9.121921863446E-02, -8.127030064783E-02, -5.031133752816E-03],
[2.994648599639E-02, -1.193366977476E-02, -8.127030064783E-02, -9.132515608025E-02,
-5.728794999748E-02, -2.387837583277E-02, 4.278478892878E-02, 6.764157650466E-02,
9.566990623455E-02, 1.005907311298E-01, 9.566990623455E-02, 8.505592925358E-02,
4.278478892878E-02, 1.127556015714E-02, -5.728794999748E-02, -8.199851501756E-02,
-8.127030064783E-02, -5.265231727816E-02, 2.994648599639E-02],
[7.049456954407E-02, 5.750613283457E-02, -5.031133752816E-03, -3.957902354963E-02,
-8.474851229653E-02, -9.121180789640E-02, -7.975908114097E-02, -6.835527608142E-02,
-4.876973734940E-02, -4.418624359019E-02, -4.876973734940E-02, -5.728794999748E-02,
-7.975908114097E-02, -8.851381966774E-02, -8.474851229653E-02, -6.734331948907E-02,
-5.031133752816E-03, 2.994648599639E-02, 7.049456954407E-02]],
dtype=np.float64
)
def setup_cubic(self):
self.precalc_interpolation = np.array(
[[7.049456954407E-02, 2.120303154043E-02, -5.412207605158E-02, -9.041927189809E-02,
-7.975908114097E-02, -5.490808448662E-02, -4.365385529969E-02, -5.493373238953E-02,
-7.975908114097E-02, -9.043881788286E-02, -5.458241224645E-02, 2.183159991917E-02,
7.049456954407E-02],
[2.120303154043E-02, -6.840828181977E-02, -8.291758075355E-02, -1.514915773345E-02,
6.146617965847E-02, 1.016705772106E-01, 1.117191819513E-01, 1.019683374662E-01,
6.146617965847E-02, -1.567520827568E-02, -8.211550352574E-02, -6.795064436020E-02,
2.120303154043E-02],
[-5.412207605158E-02, -8.291758075355E-02, 9.666098759062E-03, 1.115403574145E-01,
1.180976383194E-01, 7.071918180842E-02, 4.552636512940E-02, 7.066851884792E-02,
1.180976383194E-01, 1.094887240678E-01, 1.271424487456E-02, -8.489926255180E-02,
-5.412207605158E-02],
[-9.041927189809E-02, -1.514915773345E-02, 1.115403574145E-01, 9.058021229999E-02,
-5.921575988005E-02, -1.697171170804E-01, -1.986325220649E-01, -1.708674849009E-01,
-5.921575988005E-02, 9.071011939526E-02, 1.130155601111E-01, -1.774015779353E-02,
-9.041927189809E-02],
[-7.975908114097E-02, 6.146617965847E-02, 1.180976383194E-01, -5.921575988005E-02,
-2.145503300375E-01, -1.373726429185E-01, -4.677155115289E-02, -1.400744853311E-01,
-2.145503300375E-01, -5.608764908063E-02, 1.171252709523E-01, 5.937941570370E-02,
-7.975908114097E-02],
[-5.490808448662E-02, 1.016705772106E-01, 7.071918180842E-02, -1.697171170804E-01,
-1.373726429185E-01, 3.180255899274E-01, 6.051776838087E-01, 3.123175894536E-01,
-1.373726429185E-01, -1.640188016429E-01, 6.586737199675E-02, 1.009003074435E-01,
-5.490808448662E-02],
[-4.365385529969E-02, 1.117191819513E-01, 4.552636512940E-02, -1.986325220649E-01,
-4.677155115289E-02, 6.051776838087E-01, 9.899192445544E-01, 5.987956201910E-01,
-4.677155115289E-02, -1.913782291956E-01, 3.931492909576E-02, 1.117308113990E-01,
-4.365385529969E-02],
[-5.493373238953E-02, 1.019683374662E-01, 7.066851884792E-02, -1.708674849009E-01,
-1.400744853311E-01, 3.123175894536E-01, 5.987956201910E-01, 3.081035634172E-01,
-1.400744853311E-01, -1.646011917477E-01, 6.660176847751E-02, 1.011817145737E-01,
-5.493373238953E-02],
[-7.975908114097E-02, 6.146617965847E-02, 1.180976383194E-01, -5.921575988005E-02,
-2.145503300375E-01, -1.373726429185E-01, -4.677155115289E-02, -1.400744853311E-01,
-2.145503300375E-01, -5.608764908063E-02, 1.171252709523E-01, 5.937941570370E-02,
-7.975908114097E-02],
[-9.043881788286E-02, -1.567520827568E-02, 1.094887240678E-01, 9.071011939526E-02,
-5.608764908063E-02, -1.640188016429E-01, -1.913782291956E-01, -1.646011917477E-01,
-5.608764908063E-02, 9.061889238735E-02, 1.119056766335E-01, -1.844151449703E-02,
-9.043881788286E-02],
[-5.458241224645E-02, -8.211550352574E-02, 1.271424487456E-02, 1.130155601111E-01,
1.171252709523E-01, 6.586737199675E-02, 3.931492909576E-02, 6.660176847751E-02,
1.171252709523E-01, 1.119056766335E-01, 1.568973617012E-02, -8.405046373540E-02,
-5.458241224645E-02],
[2.183159991917E-02, -6.795064436020E-02, -8.489926255180E-02, -1.774015779353E-02,
5.937941570370E-02, 1.009003074435E-01, 1.117308113990E-01, 1.011817145737E-01,
5.937941570370E-02, -1.844151449703E-02, -8.405046373540E-02, -6.845929971507E-02,
2.183159991917E-02],
[7.049456954407E-02, 2.120303154043E-02, -5.412207605158E-02, -9.041927189809E-02,
-7.975908114097E-02, -5.490808448662E-02, -4.365385529969E-02, -5.493373238953E-02,
-7.975908114097E-02, -9.043881788286E-02, -5.458241224645E-02, 2.183159991917E-02,
7.049456954407E-02]], dtype=np.float64
)
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
2.120303154043E-02, -5.412207605158E-02, -9.041927189809E-02, -7.975908114097E-02,
-5.490808448662E-02, -4.365385529969E-02, -5.493373238953E-02, -7.975908114097E-02,
-9.043881788286E-02, -5.458241224645E-02, 2.183159991917E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 2.120303154043E-02,
-5.412207605158E-02, -9.041927189809E-02, -7.975908114097E-02, -5.490808448662E-02,
-4.365385529969E-02, -5.493373238953E-02, -7.975908114097E-02, -9.043881788286E-02,
-5.458241224645E-02, 2.183159991917E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 2.120303154043E-02, -5.412207605158E-02,
-9.041927189809E-02, -7.975908114097E-02, -5.490808448662E-02, -4.365385529969E-02,
-5.493373238953E-02, -7.975908114097E-02, -9.043881788286E-02, -5.458241224645E-02,
2.183159991917E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 2.120303154043E-02,
2.120303154043E-02, 2.120303154043E-02, 2.120303154043E-02, 2.120303154043E-02,
2.120303154043E-02, -5.412207605158E-02, -5.412207605158E-02, -5.412207605158E-02,
-5.412207605158E-02, -5.412207605158E-02, -5.412207605158E-02, -9.041927189809E-02,
-9.041927189809E-02, -9.041927189809E-02, -9.041927189809E-02, -9.041927189809E-02,
-9.041927189809E-02, -7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02,
-7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02, -5.490808448662E-02,
-5.490808448662E-02, -5.490808448662E-02, -5.490808448662E-02, -5.490808448662E-02,
-5.490808448662E-02, -4.365385529969E-02, -4.365385529969E-02, -4.365385529969E-02,
-4.365385529969E-02, -4.365385529969E-02, -4.365385529969E-02, -5.493373238953E-02,
-5.493373238953E-02, -5.493373238953E-02, -5.493373238953E-02, -5.493373238953E-02,
-5.493373238953E-02, -7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02,
-7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02, -9.043881788286E-02,
-9.043881788286E-02, -9.043881788286E-02, -9.043881788286E-02, -9.043881788286E-02,
-9.043881788286E-02, -5.458241224645E-02, -5.458241224645E-02, -5.458241224645E-02,
-5.458241224645E-02, -5.458241224645E-02, -5.458241224645E-02, 2.183159991917E-02,
2.183159991917E-02, 2.183159991917E-02, 2.183159991917E-02, 2.183159991917E-02,
2.183159991917E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 2.120303154043E-02,
-5.412207605158E-02, -9.041927189809E-02, -7.975908114097E-02, -5.490808448662E-02,
-4.365385529969E-02, -5.493373238953E-02, -7.975908114097E-02, -9.043881788286E-02,
-5.458241224645E-02, 2.183159991917E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 2.120303154043E-02, -5.412207605158E-02,
-9.041927189809E-02, -7.975908114097E-02, -5.490808448662E-02, -4.365385529969E-02,
-5.493373238953E-02, -7.975908114097E-02, -9.043881788286E-02, -5.458241224645E-02,
2.183159991917E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 2.120303154043E-02, -5.412207605158E-02, -9.041927189809E-02,
-7.975908114097E-02, -5.490808448662E-02, -4.365385529969E-02, -5.493373238953E-02,
-7.975908114097E-02, -9.043881788286E-02, -5.458241224645E-02, 2.183159991917E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[-1.194521420610E+01, -7.823082017163E+00, -3.700949828231E+00, 4.211823607006E-01,
1.132303125654E+00, 7.609499224352E-01, -4.084169620081E-01, -1.443977450203E+00,
-1.920403690376E+00, -2.047040864433E+00, -1.948441248529E+00, -1.443977450203E+00,
-3.911849985106E-01, 7.440065969941E-01, 1.211163300265E+00, 4.211823607006E-01,
-2.906695129325E+00, -6.234572619351E+00, -9.562450109377E+00, -7.823082017163E+00,
-5.113959201337E+00, -2.404836385511E+00, 3.042864303151E-01, 7.619364276159E-01,
4.892592562729E-01, -3.024177319714E-01, -9.892379938492E-01, -1.298571821746E+00,
-1.379245194722E+00, -1.317272076482E+00, -9.892379938492E-01, -2.909362716347E-01,
4.778102605806E-01, 8.147194001498E-01, 3.042864303151E-01, -1.853476437714E+00,
-4.011239305743E+00, -6.169002173772E+00, -3.700949828231E+00, -2.404836385511E+00,
-1.108722942791E+00, 1.873904999296E-01, 3.915697295782E-01, 2.175685901107E-01,
-1.964185019348E-01, -5.344985374951E-01, -6.767399531163E-01, -7.114495250108E-01,
-6.861029044360E-01, -5.344985374951E-01, -1.906875447588E-01, 2.116139241671E-01,
4.182755000345E-01, 1.873904999296E-01, -8.002577461027E-01, -1.787905992135E+00,
-2.775554238167E+00, 4.211823607006E-01, 3.042864303151E-01, 1.873904999296E-01,
2.529609455086E-01, 4.354273214732E-01, 6.178936974377E-01, 1.132303125654E+00,
7.619364276159E-01, 3.915697295782E-01, 3.717844299417E-01, 7.223658283430E-01,
1.072947226744E+00, 7.609499224352E-01, 4.892592562729E-01, 2.175685901107E-01,
9.604055355141E-02, 2.462031831544E-01, 3.963658127574E-01, -4.084169620081E-01,
-3.024177319714E-01, -1.964185019348E-01, -3.537002512839E-01, -6.169812306696E-01,
-8.802622100554E-01, -1.443977450203E+00, -9.892379938492E-01, -5.344985374951E-01,
-6.312064964548E-01, -1.182653911769E+00, -1.734101327083E+00, -1.920403690376E+00,
-1.298571821746E+00, -6.767399531163E-01, -6.947802448856E-01, -1.334652405285E+00,
-1.974524565683E+00, -2.047040864433E+00, -1.379245194722E+00, -7.114495250108E-01,
-6.952552096349E-01, -1.346856563970E+00, -1.998457918305E+00, -1.948441248529E+00,
-1.317272076482E+00, -6.861029044360E-01, -7.014023360164E-01, -1.347870939643E+00,
-1.994339543270E+00, -1.443977450203E+00, -9.892379938492E-01, -5.344985374951E-01,
-6.312064964548E-01, -1.182653911769E+00, -1.734101327083E+00, -3.911849985106E-01,
-2.909362716347E-01, -1.906875447588E-01, -3.422173851071E-01, -5.939959523313E-01,
-8.457745195555E-01, 7.440065969941E-01, 4.778102605806E-01, 2.116139241671E-01,
8.886095091330E-02, 2.323043140730E-01, 3.757476772328E-01, 1.211163300265E+00,
8.147194001498E-01, 4.182755000345E-01, 4.013604681385E-01, 7.808893363578E-01,
1.160418204577E+00, 4.211823607006E-01, 3.042864303151E-01, 1.873904999296E-01,
2.529609455086E-01, 4.354273214732E-01, 6.178936974378E-01, -2.906695129325E+00,
-1.853476437714E+00, -8.002577461027E-01, 2.529609455086E-01, 3.717844299417E-01,
9.604055355141E-02, -3.537002512839E-01, -6.312064964548E-01, -6.947802448856E-01,
-6.952552096349E-01, -7.014023360164E-01, -6.312064964548E-01, -3.422173851071E-01,
8.886095091330E-02, 4.013604681385E-01, 2.529609455086E-01, -4.160997529959E-01,
-1.085160451500E+00, -1.754221150005E+00, -6.234572619351E+00, -4.011239305743E+00,
-1.787905992135E+00, 4.354273214732E-01, 7.223658283430E-01, 2.462031831544E-01,
-6.169812306696E-01, -1.182653911769E+00, -1.334652405285E+00, -1.346856563970E+00,
-1.347870939643E+00, -1.182653911769E+00, -5.939959523313E-01, 2.323043140730E-01,
7.808893363578E-01, 4.354273214732E-01, -1.085160451500E+00, -2.605748224474E+00,
-4.126335997448E+00, -9.562450109377E+00, -6.169002173772E+00, -2.775554238167E+00,
6.178936974377E-01, 1.072947226744E+00, 3.963658127574E-01, -8.802622100554E-01,
-1.734101327083E+00, -1.974524565683E+00, -1.998457918305E+00, -1.994339543270E+00,
-1.734101327083E+00, -8.457745195555E-01, 3.757476772328E-01, 1.160418204577E+00,
6.178936974378E-01, -1.754221150005E+00, -4.126335997448E+00, -6.498450844890E+00], dtype=np.float64
)
def setup_linear(self):
self.precalc_interpolation = np.array(
[[7.049456954407E-02, 1.842034121745E-02, -5.087139573635E-02, -8.959598399643E-02,
-7.975908114097E-02, -5.611431437391E-02, -4.533211702999E-02, -5.515839683546E-02,
-7.975908114097E-02, -8.616050256073E-02, -5.176527305501E-02, 2.120208105909E-02,
7.049456954407E-02],
[1.842034121745E-02, -5.501487366574E-02, -6.636899571863E-02, -9.352949284003E-03,
5.479652055316E-02, 8.288520629779E-02, 9.087389620211E-02, 8.481401678700E-02,
5.479652055316E-02, -9.965035969377E-03, -6.501360534968E-02, -6.034270619075E-02,
1.842034121745E-02],
[-5.087139573635E-02, -6.636899571863E-02, 8.941006971131E-03, 9.749711840097E-02,
1.005403041504E-01, 5.814032225198E-02, 3.715829475115E-02, 5.664347521163E-02,
1.005403041504E-01, 9.024081028879E-02, 1.232866890135E-02, -7.665862183419E-02,
-5.087139573635E-02],
[-8.959598399643E-02, -9.352949284003E-03, 9.749711840097E-02, 8.616757171890E-02,
-5.827038360596E-02, -1.565688797731E-01, -1.870933237441E-01, -1.633466311759E-01,
-5.827038360596E-02, 7.761129976189E-02, 1.003666584284E-01, -1.620874951248E-02,
-8.959598399643E-02],
[-7.975908114097E-02, 5.479652055316E-02, 1.005403041504E-01, -5.827038360596E-02,
-2.145503300375E-01, -1.347188774155E-01, -6.110632370193E-02, -1.391995046985E-01,
-2.145503300375E-01, -5.308241785637E-02, 9.886516164000E-02, 5.839207114976E-02,
-7.975908114097E-02],
[-5.611431437391E-02, 8.288520629779E-02, 5.814032225198E-02, -1.565688797731E-01,
-1.347188774155E-01, 2.929381267349E-01, 5.411436279008E-01, 2.985138651995E-01,
-1.347188774155E-01, -1.310314141567E-01, 5.103792541956E-02, 9.518011394833E-02,
-5.611431437391E-02],
[-4.533211702999E-02, 9.087389620211E-02, 3.715829475115E-02, -1.870933237441E-01,
-6.110632370193E-02, 5.411436279008E-01, 8.749637474039E-01, 5.521553247888E-01,
-6.110632370193E-02, -1.519154612992E-01, 2.761333800232E-02, 1.065911481816E-01,
-4.533211702999E-02],
[-5.515839683546E-02, 8.481401678700E-02, 5.664347521163E-02, -1.633466311759E-01,
-1.391995046985E-01, 2.985138651995E-01, 5.521553247888E-01, 3.043061053033E-01,
-1.391995046985E-01, -1.371046296717E-01, 4.932822149057E-02, 9.754728972929E-02,
-5.515839683546E-02],
[-7.975908114097E-02, 5.479652055316E-02, 1.005403041504E-01, -5.827038360596E-02,
-2.145503300375E-01, -1.347188774155E-01, -6.110632370193E-02, -1.391995046985E-01,
-2.145503300375E-01, -5.308241785637E-02, 9.886516164000E-02, 5.839207114976E-02,
-7.975908114097E-02],
[-8.616050256073E-02, -9.965035969377E-03, 9.024081028879E-02, 7.761129976189E-02,
-5.308241785637E-02, -1.310314141567E-01, -1.519154612992E-01, -1.371046296717E-01,
-5.308241785637E-02, 7.026025796278E-02, 9.281016513370E-02, -1.638123816652E-02,
-8.616050256073E-02],
[-5.176527305501E-02, -6.501360534968E-02, 1.232866890135E-02, 1.003666584284E-01,
9.886516164000E-02, 5.103792541956E-02, 2.761333800232E-02, 4.932822149057E-02,
9.886516164000E-02, 9.281016513370E-02, 1.577734427290E-02, -7.534846790666E-02,
-5.176527305501E-02],
[2.120208105909E-02, -6.034270619075E-02, -7.665862183419E-02, -1.620874951248E-02,
5.839207114976E-02, 9.518011394833E-02, 1.065911481816E-01, 9.754728972929E-02,
5.839207114976E-02, -1.638123816652E-02, -7.534846790666E-02, -6.579449237655E-02,
2.120208105909E-02],
[7.049456954407E-02, 1.842034121745E-02, -5.087139573635E-02, -8.959598399643E-02,
-7.975908114097E-02, -5.611431437391E-02, -4.533211702999E-02, -5.515839683546E-02,
-7.975908114097E-02, -8.616050256073E-02, -5.176527305501E-02, 2.120208105909E-02,
7.049456954407E-02]], dtype=np.float64
)
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
1.842034121745E-02, -5.087139573635E-02, -8.959598399643E-02, -7.975908114097E-02,
-5.611431437391E-02, -4.533211702999E-02, -5.515839683546E-02, -7.975908114097E-02,
-8.616050256073E-02, -5.176527305501E-02, 2.120208105909E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 1.842034121745E-02,
-5.087139573635E-02, -8.959598399643E-02, -7.975908114097E-02, -5.611431437391E-02,
-4.533211702999E-02, -5.515839683546E-02, -7.975908114097E-02, -8.616050256073E-02,
-5.176527305501E-02, 2.120208105909E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 1.842034121745E-02, -5.087139573635E-02,
-8.959598399643E-02, -7.975908114097E-02, -5.611431437391E-02, -4.533211702999E-02,
-5.515839683546E-02, -7.975908114097E-02, -8.616050256073E-02, -5.176527305501E-02,
2.120208105909E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 1.842034121745E-02,
1.842034121745E-02, 1.842034121745E-02, 1.842034121745E-02, 1.842034121745E-02,
1.842034121745E-02, -5.087139573635E-02, -5.087139573635E-02, -5.087139573635E-02,
-5.087139573635E-02, -5.087139573635E-02, -5.087139573635E-02, -8.959598399643E-02,
-8.959598399643E-02, -8.959598399643E-02, -8.959598399643E-02, -8.959598399643E-02,
-8.959598399643E-02, -7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02,
-7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02, -5.611431437391E-02,
-5.611431437391E-02, -5.611431437391E-02, -5.611431437391E-02, -5.611431437391E-02,
-5.611431437391E-02, -4.533211702999E-02, -4.533211702999E-02, -4.533211702999E-02,
-4.533211702999E-02, -4.533211702999E-02, -4.533211702999E-02, -5.515839683546E-02,
-5.515839683546E-02, -5.515839683546E-02, -5.515839683546E-02, -5.515839683546E-02,
-5.515839683546E-02, -7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02,
-7.975908114097E-02, -7.975908114097E-02, -7.975908114097E-02, -8.616050256073E-02,
-8.616050256073E-02, -8.616050256073E-02, -8.616050256073E-02, -8.616050256073E-02,
-8.616050256073E-02, -5.176527305501E-02, -5.176527305501E-02, -5.176527305501E-02,
-5.176527305501E-02, -5.176527305501E-02, -5.176527305501E-02, 2.120208105909E-02,
2.120208105909E-02, 2.120208105909E-02, 2.120208105909E-02, 2.120208105909E-02,
2.120208105909E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 1.842034121745E-02,
-5.087139573635E-02, -8.959598399643E-02, -7.975908114097E-02, -5.611431437391E-02,
-4.533211702999E-02, -5.515839683546E-02, -7.975908114097E-02, -8.616050256073E-02,
-5.176527305501E-02, 2.120208105909E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 1.842034121745E-02, -5.087139573635E-02,
-8.959598399643E-02, -7.975908114097E-02, -5.611431437391E-02, -4.533211702999E-02,
-5.515839683546E-02, -7.975908114097E-02, -8.616050256073E-02, -5.176527305501E-02,
2.120208105909E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02,
7.049456954407E-02, 1.842034121745E-02, -5.087139573635E-02, -8.959598399643E-02,
-7.975908114097E-02, -5.611431437391E-02, -4.533211702999E-02, -5.515839683546E-02,
-7.975908114097E-02, -8.616050256073E-02, -5.176527305501E-02, 2.120208105909E-02,
7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02, 7.049456954407E-02], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[-1.194521420610E+01, -7.823082017163E+00, -3.700949828231E+00, 4.211823607006E-01,
1.076476993194E+00, 7.357570465096E-01, -4.016962502163E-01, -1.443977450203E+00,
-1.903018294300E+00, -2.039483993008E+00, -1.933304341125E+00, -1.443977450203E+00,
-3.807888037972E-01, 7.140500088303E-01, 1.169244258887E+00, 4.211823607006E-01,
-2.906695129325E+00, -6.234572619351E+00, -9.562450109377E+00, -7.823082017163E+00,
-5.113959201337E+00, -2.404836385511E+00, 3.042864303151E-01, 7.237914425352E-01,
4.735475657609E-01, -2.976628281430E-01, -9.892379938492E-01, -1.287383634324E+00,
-1.374766701016E+00, -1.307255693029E+00, -9.892379938492E-01, -2.825793700517E-01,
4.587782482018E-01, 7.865635329442E-01, 3.042864303151E-01, -1.853476437714E+00,
-4.011239305743E+00, -6.169002173772E+00, -3.700949828231E+00, -2.404836385511E+00,
-1.108722942791E+00, 1.873904999296E-01, 3.711058918763E-01, 2.113380850123E-01,
-1.936294060697E-01, -5.344985374951E-01, -6.717489743492E-01, -7.100494090228E-01,
-6.812070449321E-01, -5.344985374951E-01, -1.843699363062E-01, 2.035064875734E-01,
4.038828070016E-01, 1.873904999296E-01, -8.002577461027E-01, -1.787905992135E+00,
-2.775554238167E+00, 4.211823607006E-01, 3.042864303151E-01, 1.873904999296E-01,
2.529609455086E-01, 4.354273214732E-01, 6.178936974377E-01, 1.076476993194E+00,
7.237914425352E-01, 3.711058918763E-01, 3.500226650129E-01, 6.816249888084E-01,
1.013227312604E+00, 7.357570465096E-01, 4.735475657609E-01, 2.113380850123E-01,
9.287866896806E-02, 2.366287336725E-01, 3.803787983769E-01, -4.016962502163E-01,
-2.976628281430E-01, -1.936294060697E-01, -3.477394497976E-01, -6.058829155988E-01,
-8.640263814000E-01, -1.443977450203E+00, -9.892379938492E-01, -5.344985374951E-01,
-6.312064964548E-01, -1.182653911769E+00, -1.734101327083E+00, -1.903018294300E+00,
-1.287383634324E+00, -6.717489743492E-01, -6.918455006928E-01, -1.327576687012E+00,
-1.963307873331E+00, -2.039483993008E+00, -1.374766701016E+00, -7.100494090228E-01,
-6.964490057419E-01, -1.347565894454E+00, -1.998682783166E+00, -1.933304341125E+00,
-1.307255693029E+00, -6.812070449321E-01, -6.980635883397E-01, -1.340968779844E+00,
-1.983873971348E+00, -1.443977450203E+00, -9.892379938492E-01, -5.344985374951E-01,
-6.312064964548E-01, -1.182653911769E+00, -1.734101327083E+00, -3.807888037972E-01,
-2.825793700517E-01, -1.843699363062E-01, -3.317879124813E-01, -5.774153224019E-01,
-8.230427323224E-01, 7.140500088303E-01, 4.587782482018E-01, 2.035064875734E-01,
8.346507461054E-02, 2.186954222761E-01, 3.539257699416E-01, 1.169244258887E+00,
7.865635329442E-01, 4.038828070016E-01, 3.857421048676E-01, 7.502821286761E-01,
1.114822152485E+00, 4.211823607006E-01, 3.042864303151E-01, 1.873904999296E-01,
2.529609455086E-01, 4.354273214732E-01, 6.178936974377E-01, -2.906695129325E+00,
-1.853476437714E+00, -8.002577461027E-01, 2.529609455086E-01, 3.500226650129E-01,
9.287866896806E-02, -3.477394497976E-01, -6.312064964548E-01, -6.918455006928E-01,
-6.964490057419E-01, -6.980635883397E-01, -6.312064964548E-01, -3.317879124813E-01,
8.346507461054E-02, 3.857421048676E-01, 2.529609455086E-01, -4.160997529959E-01,
-1.085160451500E+00, -1.754221150005E+00, -6.234572619351E+00, -4.011239305743E+00,
-1.787905992135E+00, 4.354273214732E-01, 6.816249888084E-01, 2.366287336725E-01,
-6.058829155988E-01, -1.182653911769E+00, -1.327576687012E+00, -1.347565894454E+00,
-1.340968779844E+00, -1.182653911769E+00, -5.774153224019E-01, 2.186954222761E-01,
7.502821286761E-01, 4.354273214732E-01, -1.085160451500E+00, -2.605748224474E+00,
-4.126335997448E+00, -9.562450109377E+00, -6.169002173772E+00, -2.775554238167E+00,
6.178936974377E-01, 1.013227312604E+00, 3.803787983769E-01, -8.640263814000E-01,
-1.734101327083E+00, -1.963307873331E+00, -1.998682783166E+00, -1.983873971348E+00,
-1.734101327083E+00, -8.230427323224E-01, 3.539257699416E-01, 1.114822152485E+00,
6.178936974377E-01, -1.754221150005E+00, -4.126335997448E+00, -6.498450844891E+00], dtype=np.float64
)
class TestInterpolatorLoadBigValuesUneven(TestInterpolatorLoadValues):
"""
Loading small values (10^-20 times the original) instead of the original 2D sinc function test.
For description of data storage, see TestInterpolatorLoadValues.
"""
def __init__(self):
super().__init__()
#: data array from a function sampled on self.x. dtype should be np.float64
# self.data: np.array = np.sin(self.x)
self.data: np.array = np.array(
[[7.049456954407E+18, 5.750613283457E+18, -5.031133752816E+17, -3.957902354963E+18,
-8.474851229653E+18, -9.121180789640E+18, -7.975908114097E+18, -6.835527608142E+18,
-4.876973734940E+18, -4.418624359019E+18, -4.876973734940E+18, -5.728794999748E+18,
-7.975908114097E+18, -8.851381966774E+18, -8.474851229653E+18, -6.734331948907E+18,
-5.031133752816E+17, 2.994648599639E+18, 7.049456954407E+18],
[5.750613283457E+18, 2.707313596327E+18, -4.947098908050E+18, -7.716977009236E+18,
-8.851381966774E+18, -7.454434661366E+18, -2.923247487940E+18, -6.867195016855E+17,
2.378357578524E+18, 3.010595454905E+18, 2.378357578524E+18, 1.127556015714E+18,
-2.923247487940E+18, -5.313921590225E+18, -8.851381966774E+18, -9.034807299146E+18,
-4.947098908050E+18, -1.193366977476E+18, 5.750613283457E+18],
[-5.031133752816E+17, -4.947098908050E+18, -9.121921863446E+18, -7.727418937786E+18,
-9.251264987298E+16, 4.278478892878E+18, 1.052139178127E+19, 1.201126954831E+19,
1.283205555674E+19, 1.282705054889E+19, 1.283205555674E+19, 1.266409993718E+19,
1.052139178127E+19, 7.942173990430E+18, -9.251264987298E+16, -4.418624359019E+18,
-9.121921863446E+18, -8.127030064783E+18, -5.031133752816E+17],
[-3.957902354963E+18, -7.716977009236E+18, -7.727418937786E+18, -3.939635588637E+18,
6.155045982467E+18, 1.005907311298E+19, 1.282705054889E+19, 1.215171020957E+19,
9.674890958243E+18, 8.947967120127E+18, 9.674890958243E+18, 1.089467585825E+19,
1.282705054889E+19, 1.227830098222E+19, 6.155045982467E+18, 1.127556015714E+18,
-7.727418937786E+18, -9.132515608025E+18, -3.957902354963E+18],
[-8.474851229653E+18, -8.851381966774E+18, -9.251264987298E+16, 6.155045982467E+18,
1.283205555674E+19, 1.138884597353E+19, 1.734970013481E+18, -3.806455343631E+18,
-1.140407180451E+19, -1.289967784984E+19, -1.140407180451E+19, -8.347707818621E+18,
1.734970013481E+18, 7.259972187812E+18, 1.283205555674E+19, 1.095087852132E+19,
-9.251264987298E+16, -5.728794999748E+18, -8.474851229653E+18],
[-9.121180789640E+18, -7.454434661366E+18, 4.278478892878E+18, 1.005907311298E+19,
1.138884597353E+19, 6.300331483592E+18, -8.347707818621E+18, -1.435151388671E+19,
-2.022780434934E+19, -2.095142217650E+19, -2.022780434934E+19, -1.824711128590E+19,
-8.347707818621E+18, -9.351916346701E+17, 1.138884597353E+19, 1.277678821031E+19,
4.278478892878E+18, -2.387837583277E+18, -9.121180789640E+18],
[-7.975908114097E+18, -2.923247487940E+18, 1.052139178127E+19, 1.282705054889E+19,
1.734970013481E+18, -8.347707818621E+18, -2.145503300375E+19, -2.052264171648E+19,
-9.241435356589E+18, -5.067031374727E+18, -9.241435356589E+18, -1.547945550760E+19,
-2.145503300375E+19, -1.704692811750E+19, 1.734970013480E+18, 9.674890958243E+18,
1.052139178127E+19, 4.278478892878E+18, -7.975908114097E+18],
[-6.835527608142E+18, -6.867195016855E+17, 1.201126954831E+19, 1.215171020957E+19,
-3.806455343631E+18, -1.435151388671E+19, -2.052264171648E+19, -1.268933271435E+19,
1.257727427008E+19, 2.044658799484E+19, 1.257727427008E+19, -9.251369377679E+16,
-2.052264171648E+19, -2.095142217650E+19, -3.806455343631E+18, 6.300331483592E+18,
1.201126954831E+19, 6.764157650466E+18, -6.835527608142E+18],
[-4.876973734940E+18, 2.378357578524E+18, 1.283205555674E+19, 9.674890958243E+18,
-1.140407180451E+19, -2.022780434934E+19, -9.241435356589E+18, 1.257727427008E+19,
6.446759109720E+19, 7.917136926885E+19, 6.446759109720E+19, 3.973381423908E+19,
-9.241435356589E+18, -2.052264171648E+19, -1.140407180451E+19, 4.282861041084E+17,
1.283205555674E+19, 9.566990623455E+18, -4.876973734940E+18],
[-4.418624359019E+18, 3.010595454905E+18, 1.282705054889E+19, 8.947967120127E+18,
-1.289967784984E+19, -2.095142217650E+19, -5.067031374727E+18, 2.044658799484E+19,
7.917136926885E+19, 9.560513212622E+19, 7.917136926885E+19, 5.136281978234E+19,
-5.067031374727E+18, -1.933844713753E+19, -1.289967784984E+19, -9.351916346701E+17,
1.282705054889E+19, 1.005907311298E+19, -4.418624359019E+18],
[-4.876973734940E+18, 2.378357578524E+18, 1.283205555674E+19, 9.674890958243E+18,
-1.140407180451E+19, -2.022780434934E+19, -9.241435356589E+18, 1.257727427008E+19,
6.446759109720E+19, 7.917136926885E+19, 6.446759109720E+19, 3.973381423908E+19,
-9.241435356589E+18, -2.052264171648E+19, -1.140407180451E+19, 4.282861041084E+17,
1.283205555674E+19, 9.566990623455E+18, -4.876973734940E+18],
[-5.728794999748E+18, 1.127556015714E+18, 1.266409993718E+19, 1.089467585825E+19,
-8.347707818621E+18, -1.824711128590E+19, -1.547945550760E+19, -9.251369377679E+16,
3.973381423908E+19, 5.136281978234E+19, 3.973381423908E+19, 2.044658799484E+19,
-1.547945550760E+19, -2.165899038868E+19, -8.347707818621E+18, 2.979548967146E+18,
1.266409993718E+19, 8.505592925358E+18, -5.728794999748E+18],
[-7.975908114097E+18, -2.923247487940E+18, 1.052139178127E+19, 1.282705054889E+19,
1.734970013481E+18, -8.347707818621E+18, -2.145503300375E+19, -2.052264171648E+19,
-9.241435356589E+18, -5.067031374727E+18, -9.241435356589E+18, -1.547945550760E+19,
-2.145503300375E+19, -1.704692811750E+19, 1.734970013480E+18, 9.674890958243E+18,
1.052139178127E+19, 4.278478892878E+18, -7.975908114097E+18],
[-8.851381966774E+18, -5.313921590225E+18, 7.942173990430E+18, 1.227830098222E+19,
7.259972187812E+18, -9.351916346701E+17, -1.704692811750E+19, -2.095142217650E+19,
-2.052264171648E+19, -1.933844713753E+19, -2.052264171648E+19, -2.165899038868E+19,
-1.704692811750E+19, -9.881655954565E+18, 7.259972187812E+18, 1.215171020957E+19,
7.942173990430E+18, 1.127556015714E+18, -8.851381966774E+18],
[-8.474851229653E+18, -8.851381966774E+18, -9.251264987298E+16, 6.155045982467E+18,
1.283205555674E+19, 1.138884597353E+19, 1.734970013480E+18, -3.806455343631E+18,
-1.140407180451E+19, -1.289967784984E+19, -1.140407180451E+19, -8.347707818621E+18,
1.734970013480E+18, 7.259972187812E+18, 1.283205555674E+19, 1.095087852132E+19,
-9.251264987296E+16, -5.728794999748E+18, -8.474851229653E+18],
[-6.734331948907E+18, -9.034807299146E+18, -4.418624359019E+18, 1.127556015714E+18,
1.095087852132E+19, 1.277678821031E+19, 9.674890958243E+18, 6.300331483592E+18,
4.282861041084E+17, -9.351916346701E+17, 4.282861041084E+17, 2.979548967146E+18,
9.674890958243E+18, 1.215171020957E+19, 1.095087852132E+19, 6.764157650466E+18,
-4.418624359019E+18, -8.199851501756E+18, -6.734331948907E+18],
[-5.031133752816E+17, -4.947098908050E+18, -9.121921863446E+18, -7.727418937786E+18,
-9.251264987298E+16, 4.278478892878E+18, 1.052139178127E+19, 1.201126954831E+19,
1.283205555674E+19, 1.282705054889E+19, 1.283205555674E+19, 1.266409993718E+19,
1.052139178127E+19, 7.942173990430E+18, -9.251264987296E+16, -4.418624359019E+18,
-9.121921863446E+18, -8.127030064783E+18, -5.031133752816E+17],
[2.994648599639E+18, -1.193366977476E+18, -8.127030064783E+18, -9.132515608025E+18,
-5.728794999748E+18, -2.387837583277E+18, 4.278478892878E+18, 6.764157650466E+18,
9.566990623455E+18, 1.005907311298E+19, 9.566990623455E+18, 8.505592925358E+18,
4.278478892878E+18, 1.127556015714E+18, -5.728794999748E+18, -8.199851501756E+18,
-8.127030064783E+18, -5.265231727816E+18, 2.994648599639E+18],
[7.049456954407E+18, 5.750613283457E+18, -5.031133752816E+17, -3.957902354963E+18,
-8.474851229653E+18, -9.121180789640E+18, -7.975908114097E+18, -6.835527608142E+18,
-4.876973734940E+18, -4.418624359019E+18, -4.876973734940E+18, -5.728794999748E+18,
-7.975908114097E+18, -8.851381966774E+18, -8.474851229653E+18, -6.734331948907E+18,
-5.031133752816E+17, 2.994648599639E+18, 7.049456954407E+18]], dtype=np.float64
)
#: array holding precalculated quadratic extrapolation data
self.precalc_extrapolation_quadratic: np.array = np.array(
[], dtype=np.float64
)
def setup_cubic(self):
self.precalc_interpolation = np.array(
[[7.049456954407E+18, 2.120303154043E+18, -5.412207605158E+18, -9.041927189809E+18,
-7.975908114097E+18, -5.490808448662E+18, -4.365385529969E+18, -5.493373238953E+18,
-7.975908114097E+18, -9.043881788286E+18, -5.458241224645E+18, 2.183159991917E+18,
7.049456954407E+18],
[2.120303154043E+18, -6.840828181977E+18, -8.291758075355E+18, -1.514915773345E+18,
6.146617965847E+18, 1.016705772106E+19, 1.117191819513E+19, 1.019683374662E+19,
6.146617965847E+18, -1.567520827568E+18, -8.211550352574E+18, -6.795064436020E+18,
2.120303154043E+18],
[-5.412207605158E+18, -8.291758075355E+18, 9.666098759062E+17, 1.115403574145E+19,
1.180976383194E+19, 7.071918180842E+18, 4.552636512940E+18, 7.066851884792E+18,
1.180976383194E+19, 1.094887240678E+19, 1.271424487456E+18, -8.489926255180E+18,
-5.412207605158E+18],
[-9.041927189809E+18, -1.514915773345E+18, 1.115403574145E+19, 9.058021229999E+18,
-5.921575988005E+18, -1.697171170804E+19, -1.986325220649E+19, -1.708674849009E+19,
-5.921575988005E+18, 9.071011939526E+18, 1.130155601111E+19, -1.774015779353E+18,
-9.041927189809E+18],
[-7.975908114097E+18, 6.146617965847E+18, 1.180976383194E+19, -5.921575988005E+18,
-2.145503300375E+19, -1.373726429185E+19, -4.677155115289E+18, -1.400744853311E+19,
-2.145503300375E+19, -5.608764908063E+18, 1.171252709523E+19, 5.937941570370E+18,
-7.975908114097E+18],
[-5.490808448662E+18, 1.016705772106E+19, 7.071918180842E+18, -1.697171170804E+19,
-1.373726429185E+19, 3.180255899274E+19, 6.051776838087E+19, 3.123175894536E+19,
-1.373726429185E+19, -1.640188016429E+19, 6.586737199675E+18, 1.009003074435E+19,
-5.490808448662E+18],
[-4.365385529969E+18, 1.117191819513E+19, 4.552636512940E+18, -1.986325220649E+19,
-4.677155115289E+18, 6.051776838087E+19, 9.899192445544E+19, 5.987956201910E+19,
-4.677155115289E+18, -1.913782291956E+19, 3.931492909576E+18, 1.117308113990E+19,
-4.365385529968E+18],
[-5.493373238953E+18, 1.019683374662E+19, 7.066851884792E+18, -1.708674849009E+19,
-1.400744853311E+19, 3.123175894536E+19, 5.987956201910E+19, 3.081035634172E+19,
-1.400744853311E+19, -1.646011917477E+19, 6.660176847751E+18, 1.011817145737E+19,
-5.493373238953E+18],
[-7.975908114097E+18, 6.146617965847E+18, 1.180976383194E+19, -5.921575988005E+18,
-2.145503300375E+19, -1.373726429185E+19, -4.677155115289E+18, -1.400744853311E+19,
-2.145503300375E+19, -5.608764908063E+18, 1.171252709523E+19, 5.937941570370E+18,
-7.975908114097E+18],
[-9.043881788286E+18, -1.567520827568E+18, 1.094887240678E+19, 9.071011939526E+18,
-5.608764908063E+18, -1.640188016429E+19, -1.913782291956E+19, -1.646011917477E+19,
-5.608764908063E+18, 9.061889238735E+18, 1.119056766335E+19, -1.844151449703E+18,
-9.043881788286E+18],
[-5.458241224645E+18, -8.211550352574E+18, 1.271424487456E+18, 1.130155601111E+19,
1.171252709523E+19, 6.586737199675E+18, 3.931492909576E+18, 6.660176847751E+18,
1.171252709523E+19, 1.119056766335E+19, 1.568973617012E+18, -8.405046373540E+18,
-5.458241224645E+18],
[2.183159991917E+18, -6.795064436020E+18, -8.489926255180E+18, -1.774015779353E+18,
5.937941570370E+18, 1.009003074435E+19, 1.117308113990E+19, 1.011817145737E+19,
5.937941570370E+18, -1.844151449703E+18, -8.405046373540E+18, -6.845929971507E+18,
2.183159991917E+18],
[7.049456954407E+18, 2.120303154043E+18, -5.412207605158E+18, -9.041927189809E+18,
-7.975908114097E+18, -5.490808448662E+18, -4.365385529968E+18, -5.493373238953E+18,
-7.975908114097E+18, -9.043881788286E+18, -5.458241224645E+18, 2.183159991917E+18,
7.049456954407E+18]], dtype=np.float64
)
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
2.120303154043E+18, -5.412207605158E+18, -9.041927189809E+18, -7.975908114097E+18,
-5.490808448662E+18, -4.365385529969E+18, -5.493373238953E+18, -7.975908114097E+18,
-9.043881788286E+18, -5.458241224645E+18, 2.183159991917E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 2.120303154043E+18,
-5.412207605158E+18, -9.041927189809E+18, -7.975908114097E+18, -5.490808448662E+18,
-4.365385529969E+18, -5.493373238953E+18, -7.975908114097E+18, -9.043881788286E+18,
-5.458241224645E+18, 2.183159991917E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 2.120303154043E+18, -5.412207605158E+18,
-9.041927189809E+18, -7.975908114097E+18, -5.490808448662E+18, -4.365385529969E+18,
-5.493373238953E+18, -7.975908114097E+18, -9.043881788286E+18, -5.458241224645E+18,
2.183159991917E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 2.120303154043E+18,
2.120303154043E+18, 2.120303154043E+18, 2.120303154043E+18, 2.120303154043E+18,
2.120303154043E+18, -5.412207605158E+18, -5.412207605158E+18, -5.412207605158E+18,
-5.412207605158E+18, -5.412207605158E+18, -5.412207605158E+18, -9.041927189809E+18,
-9.041927189809E+18, -9.041927189809E+18, -9.041927189809E+18, -9.041927189809E+18,
-9.041927189809E+18, -7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18,
-7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18, -5.490808448662E+18,
-5.490808448662E+18, -5.490808448662E+18, -5.490808448662E+18, -5.490808448662E+18,
-5.490808448662E+18, -4.365385529969E+18, -4.365385529969E+18, -4.365385529969E+18,
-4.365385529968E+18, -4.365385529968E+18, -4.365385529968E+18, -5.493373238953E+18,
-5.493373238953E+18, -5.493373238953E+18, -5.493373238953E+18, -5.493373238953E+18,
-5.493373238953E+18, -7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18,
-7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18, -9.043881788286E+18,
-9.043881788286E+18, -9.043881788286E+18, -9.043881788286E+18, -9.043881788286E+18,
-9.043881788286E+18, -5.458241224645E+18, -5.458241224645E+18, -5.458241224645E+18,
-5.458241224645E+18, -5.458241224645E+18, -5.458241224645E+18, 2.183159991917E+18,
2.183159991917E+18, 2.183159991917E+18, 2.183159991917E+18, 2.183159991917E+18,
2.183159991917E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 2.120303154043E+18,
-5.412207605158E+18, -9.041927189809E+18, -7.975908114097E+18, -5.490808448662E+18,
-4.365385529968E+18, -5.493373238953E+18, -7.975908114097E+18, -9.043881788286E+18,
-5.458241224645E+18, 2.183159991917E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 2.120303154043E+18, -5.412207605158E+18,
-9.041927189809E+18, -7.975908114097E+18, -5.490808448662E+18, -4.365385529968E+18,
-5.493373238953E+18, -7.975908114097E+18, -9.043881788286E+18, -5.458241224645E+18,
2.183159991917E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 2.120303154043E+18, -5.412207605158E+18, -9.041927189809E+18,
-7.975908114097E+18, -5.490808448662E+18, -4.365385529968E+18, -5.493373238953E+18,
-7.975908114097E+18, -9.043881788286E+18, -5.458241224645E+18, 2.183159991917E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[-1.194521420610E+21, -7.823082017163E+20, -3.700949828231E+20, 4.211823607006E+19,
1.132303125654E+20, 7.609499224352E+19, -4.084169620081E+19, -1.443977450203E+20,
-1.920403690376E+20, -2.047040864433E+20, -1.948441248529E+20, -1.443977450203E+20,
-3.911849985106E+19, 7.440065969941E+19, 1.211163300265E+20, 4.211823607006E+19,
-2.906695129325E+20, -6.234572619351E+20, -9.562450109377E+20, -7.823082017163E+20,
-5.113959201337E+20, -2.404836385511E+20, 3.042864303151E+19, 7.619364276159E+19,
4.892592562729E+19, -3.024177319714E+19, -9.892379938492E+19, -1.298571821746E+20,
-1.379245194722E+20, -1.317272076482E+20, -9.892379938492E+19, -2.909362716347E+19,
4.778102605806E+19, 8.147194001498E+19, 3.042864303151E+19, -1.853476437714E+20,
-4.011239305743E+20, -6.169002173772E+20, -3.700949828231E+20, -2.404836385511E+20,
-1.108722942791E+20, 1.873904999296E+19, 3.915697295782E+19, 2.175685901107E+19,
-1.964185019348E+19, -5.344985374951E+19, -6.767399531163E+19, -7.114495250108E+19,
-6.861029044360E+19, -5.344985374951E+19, -1.906875447588E+19, 2.116139241671E+19,
4.182755000345E+19, 1.873904999296E+19, -8.002577461027E+19, -1.787905992135E+20,
-2.775554238167E+20, 4.211823607006E+19, 3.042864303151E+19, 1.873904999296E+19,
2.529609455086E+19, 4.354273214732E+19, 6.178936974377E+19, 1.132303125654E+20,
7.619364276159E+19, 3.915697295782E+19, 3.717844299417E+19, 7.223658283430E+19,
1.072947226744E+20, 7.609499224352E+19, 4.892592562729E+19, 2.175685901107E+19,
9.604055355141E+18, 2.462031831544E+19, 3.963658127574E+19, -4.084169620081E+19,
-3.024177319714E+19, -1.964185019348E+19, -3.537002512839E+19, -6.169812306696E+19,
-8.802622100554E+19, -1.443977450203E+20, -9.892379938492E+19, -5.344985374951E+19,
-6.312064964548E+19, -1.182653911769E+20, -1.734101327083E+20, -1.920403690376E+20,
-1.298571821746E+20, -6.767399531163E+19, -6.947802448856E+19, -1.334652405285E+20,
-1.974524565683E+20, -2.047040864433E+20, -1.379245194722E+20, -7.114495250108E+19,
-6.952552096349E+19, -1.346856563970E+20, -1.998457918305E+20, -1.948441248529E+20,
-1.317272076482E+20, -6.861029044360E+19, -7.014023360164E+19, -1.347870939643E+20,
-1.994339543270E+20, -1.443977450203E+20, -9.892379938492E+19, -5.344985374951E+19,
-6.312064964548E+19, -1.182653911769E+20, -1.734101327083E+20, -3.911849985106E+19,
-2.909362716347E+19, -1.906875447588E+19, -3.422173851071E+19, -5.939959523313E+19,
-8.457745195555E+19, 7.440065969941E+19, 4.778102605806E+19, 2.116139241671E+19,
8.886095091330E+18, 2.323043140730E+19, 3.757476772328E+19, 1.211163300265E+20,
8.147194001498E+19, 4.182755000345E+19, 4.013604681385E+19, 7.808893363578E+19,
1.160418204577E+20, 4.211823607006E+19, 3.042864303151E+19, 1.873904999296E+19,
2.529609455086E+19, 4.354273214732E+19, 6.178936974378E+19, -2.906695129325E+20,
-1.853476437714E+20, -8.002577461027E+19, 2.529609455086E+19, 3.717844299417E+19,
9.604055355141E+18, -3.537002512839E+19, -6.312064964548E+19, -6.947802448856E+19,
-6.952552096349E+19, -7.014023360164E+19, -6.312064964548E+19, -3.422173851071E+19,
8.886095091330E+18, 4.013604681385E+19, 2.529609455086E+19, -4.160997529959E+19,
-1.085160451500E+20, -1.754221150005E+20, -6.234572619351E+20, -4.011239305743E+20,
-1.787905992135E+20, 4.354273214732E+19, 7.223658283430E+19, 2.462031831544E+19,
-6.169812306696E+19, -1.182653911769E+20, -1.334652405285E+20, -1.346856563970E+20,
-1.347870939643E+20, -1.182653911769E+20, -5.939959523313E+19, 2.323043140730E+19,
7.808893363578E+19, 4.354273214732E+19, -1.085160451500E+20, -2.605748224474E+20,
-4.126335997448E+20, -9.562450109377E+20, -6.169002173772E+20, -2.775554238167E+20,
6.178936974377E+19, 1.072947226744E+20, 3.963658127574E+19, -8.802622100554E+19,
-1.734101327083E+20, -1.974524565683E+20, -1.998457918305E+20, -1.994339543270E+20,
-1.734101327083E+20, -8.457745195555E+19, 3.757476772328E+19, 1.160418204577E+20,
6.178936974378E+19, -1.754221150005E+20, -4.126335997448E+20, -6.498450844890E+20], dtype=np.float64
)
def setup_linear(self):
self.precalc_interpolation = np.array(
[[7.049456954407E+18, 1.842034121745E+18, -5.087139573635E+18, -8.959598399643E+18,
-7.975908114097E+18, -5.611431437391E+18, -4.533211702999E+18, -5.515839683546E+18,
-7.975908114097E+18, -8.616050256073E+18, -5.176527305501E+18, 2.120208105909E+18,
7.049456954407E+18],
[1.842034121745E+18, -5.501487366574E+18, -6.636899571863E+18, -9.352949284003E+17,
5.479652055316E+18, 8.288520629779E+18, 9.087389620211E+18, 8.481401678700E+18,
5.479652055316E+18, -9.965035969377E+17, -6.501360534968E+18, -6.034270619075E+18,
1.842034121745E+18],
[-5.087139573635E+18, -6.636899571863E+18, 8.941006971131E+17, 9.749711840097E+18,
1.005403041504E+19, 5.814032225198E+18, 3.715829475115E+18, 5.664347521163E+18,
1.005403041504E+19, 9.024081028879E+18, 1.232866890135E+18, -7.665862183419E+18,
-5.087139573635E+18],
[-8.959598399643E+18, -9.352949284003E+17, 9.749711840097E+18, 8.616757171890E+18,
-5.827038360596E+18, -1.565688797731E+19, -1.870933237441E+19, -1.633466311759E+19,
-5.827038360596E+18, 7.761129976189E+18, 1.003666584284E+19, -1.620874951248E+18,
-8.959598399643E+18],
[-7.975908114097E+18, 5.479652055316E+18, 1.005403041504E+19, -5.827038360596E+18,
-2.145503300375E+19, -1.347188774155E+19, -6.110632370193E+18, -1.391995046985E+19,
-2.145503300375E+19, -5.308241785637E+18, 9.886516164000E+18, 5.839207114976E+18,
-7.975908114097E+18],
[-5.611431437391E+18, 8.288520629779E+18, 5.814032225198E+18, -1.565688797731E+19,
-1.347188774155E+19, 2.929381267349E+19, 5.411436279008E+19, 2.985138651995E+19,
-1.347188774155E+19, -1.310314141567E+19, 5.103792541956E+18, 9.518011394833E+18,
-5.611431437391E+18],
[-4.533211702999E+18, 9.087389620211E+18, 3.715829475115E+18, -1.870933237441E+19,
-6.110632370193E+18, 5.411436279008E+19, 8.749637474039E+19, 5.521553247888E+19,
-6.110632370193E+18, -1.519154612992E+19, 2.761333800232E+18, 1.065911481816E+19,
-4.533211702999E+18],
[-5.515839683546E+18, 8.481401678700E+18, 5.664347521163E+18, -1.633466311759E+19,
-1.391995046985E+19, 2.985138651995E+19, 5.521553247888E+19, 3.043061053033E+19,
-1.391995046985E+19, -1.371046296717E+19, 4.932822149057E+18, 9.754728972929E+18,
-5.515839683546E+18],
[-7.975908114097E+18, 5.479652055316E+18, 1.005403041504E+19, -5.827038360596E+18,
-2.145503300375E+19, -1.347188774155E+19, -6.110632370193E+18, -1.391995046985E+19,
-2.145503300375E+19, -5.308241785637E+18, 9.886516164000E+18, 5.839207114976E+18,
-7.975908114097E+18],
[-8.616050256073E+18, -9.965035969377E+17, 9.024081028879E+18, 7.761129976189E+18,
-5.308241785637E+18, -1.310314141567E+19, -1.519154612992E+19, -1.371046296717E+19,
-5.308241785637E+18, 7.026025796278E+18, 9.281016513370E+18, -1.638123816652E+18,
-8.616050256073E+18],
[-5.176527305501E+18, -6.501360534968E+18, 1.232866890135E+18, 1.003666584284E+19,
9.886516164000E+18, 5.103792541956E+18, 2.761333800232E+18, 4.932822149057E+18,
9.886516164000E+18, 9.281016513370E+18, 1.577734427290E+18, -7.534846790666E+18,
-5.176527305501E+18],
[2.120208105909E+18, -6.034270619075E+18, -7.665862183419E+18, -1.620874951248E+18,
5.839207114976E+18, 9.518011394833E+18, 1.065911481816E+19, 9.754728972929E+18,
5.839207114976E+18, -1.638123816652E+18, -7.534846790666E+18, -6.579449237655E+18,
2.120208105909E+18],
[7.049456954407E+18, 1.842034121745E+18, -5.087139573635E+18, -8.959598399643E+18,
-7.975908114097E+18, -5.611431437391E+18, -4.533211702999E+18, -5.515839683546E+18,
-7.975908114097E+18, -8.616050256073E+18, -5.176527305501E+18, 2.120208105909E+18,
7.049456954407E+18]], dtype=np.float64
)
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
1.842034121745E+18, -5.087139573635E+18, -8.959598399643E+18, -7.975908114097E+18,
-5.611431437391E+18, -4.533211702999E+18, -5.515839683546E+18, -7.975908114097E+18,
-8.616050256073E+18, -5.176527305501E+18, 2.120208105909E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 1.842034121745E+18,
-5.087139573635E+18, -8.959598399643E+18, -7.975908114097E+18, -5.611431437391E+18,
-4.533211702999E+18, -5.515839683546E+18, -7.975908114097E+18, -8.616050256073E+18,
-5.176527305501E+18, 2.120208105909E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 1.842034121745E+18, -5.087139573635E+18,
-8.959598399643E+18, -7.975908114097E+18, -5.611431437391E+18, -4.533211702999E+18,
-5.515839683546E+18, -7.975908114097E+18, -8.616050256073E+18, -5.176527305501E+18,
2.120208105909E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 1.842034121745E+18,
1.842034121745E+18, 1.842034121745E+18, 1.842034121745E+18, 1.842034121745E+18,
1.842034121745E+18, -5.087139573635E+18, -5.087139573635E+18, -5.087139573635E+18,
-5.087139573635E+18, -5.087139573635E+18, -5.087139573635E+18, -8.959598399643E+18,
-8.959598399643E+18, -8.959598399643E+18, -8.959598399643E+18, -8.959598399643E+18,
-8.959598399643E+18, -7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18,
-7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18, -5.611431437391E+18,
-5.611431437391E+18, -5.611431437391E+18, -5.611431437391E+18, -5.611431437391E+18,
-5.611431437391E+18, -4.533211702999E+18, -4.533211702999E+18, -4.533211702999E+18,
-4.533211702999E+18, -4.533211702999E+18, -4.533211702999E+18, -5.515839683546E+18,
-5.515839683546E+18, -5.515839683546E+18, -5.515839683546E+18, -5.515839683546E+18,
-5.515839683546E+18, -7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18,
-7.975908114097E+18, -7.975908114097E+18, -7.975908114097E+18, -8.616050256073E+18,
-8.616050256073E+18, -8.616050256073E+18, -8.616050256073E+18, -8.616050256073E+18,
-8.616050256073E+18, -5.176527305501E+18, -5.176527305501E+18, -5.176527305501E+18,
-5.176527305501E+18, -5.176527305501E+18, -5.176527305501E+18, 2.120208105909E+18,
2.120208105909E+18, 2.120208105909E+18, 2.120208105909E+18, 2.120208105909E+18,
2.120208105909E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 1.842034121745E+18,
-5.087139573635E+18, -8.959598399643E+18, -7.975908114097E+18, -5.611431437391E+18,
-4.533211702999E+18, -5.515839683546E+18, -7.975908114097E+18, -8.616050256073E+18,
-5.176527305501E+18, 2.120208105909E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 1.842034121745E+18, -5.087139573635E+18,
-8.959598399643E+18, -7.975908114097E+18, -5.611431437391E+18, -4.533211702999E+18,
-5.515839683546E+18, -7.975908114097E+18, -8.616050256073E+18, -5.176527305501E+18,
2.120208105909E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18,
7.049456954407E+18, 1.842034121745E+18, -5.087139573635E+18, -8.959598399643E+18,
-7.975908114097E+18, -5.611431437391E+18, -4.533211702999E+18, -5.515839683546E+18,
-7.975908114097E+18, -8.616050256073E+18, -5.176527305501E+18, 2.120208105909E+18,
7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18, 7.049456954407E+18], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[-1.194521420610E+21, -7.823082017163E+20, -3.700949828231E+20, 4.211823607006E+19,
1.076476993194E+20, 7.357570465096E+19, -4.016962502163E+19, -1.443977450203E+20,
-1.903018294300E+20, -2.039483993008E+20, -1.933304341125E+20, -1.443977450203E+20,
-3.807888037972E+19, 7.140500088303E+19, 1.169244258887E+20, 4.211823607006E+19,
-2.906695129325E+20, -6.234572619351E+20, -9.562450109377E+20, -7.823082017163E+20,
-5.113959201337E+20, -2.404836385511E+20, 3.042864303151E+19, 7.237914425352E+19,
4.735475657609E+19, -2.976628281430E+19, -9.892379938492E+19, -1.287383634324E+20,
-1.374766701016E+20, -1.307255693029E+20, -9.892379938492E+19, -2.825793700517E+19,
4.587782482018E+19, 7.865635329442E+19, 3.042864303151E+19, -1.853476437714E+20,
-4.011239305743E+20, -6.169002173772E+20, -3.700949828231E+20, -2.404836385511E+20,
-1.108722942791E+20, 1.873904999296E+19, 3.711058918763E+19, 2.113380850123E+19,
-1.936294060697E+19, -5.344985374951E+19, -6.717489743492E+19, -7.100494090228E+19,
-6.812070449321E+19, -5.344985374951E+19, -1.843699363062E+19, 2.035064875734E+19,
4.038828070016E+19, 1.873904999296E+19, -8.002577461027E+19, -1.787905992135E+20,
-2.775554238167E+20, 4.211823607006E+19, 3.042864303151E+19, 1.873904999296E+19,
2.529609455086E+19, 4.354273214732E+19, 6.178936974377E+19, 1.076476993194E+20,
7.237914425352E+19, 3.711058918763E+19, 3.500226650129E+19, 6.816249888084E+19,
1.013227312604E+20, 7.357570465096E+19, 4.735475657609E+19, 2.113380850123E+19,
9.287866896806E+18, 2.366287336725E+19, 3.803787983769E+19, -4.016962502163E+19,
-2.976628281430E+19, -1.936294060697E+19, -3.477394497976E+19, -6.058829155988E+19,
-8.640263814000E+19, -1.443977450203E+20, -9.892379938492E+19, -5.344985374951E+19,
-6.312064964548E+19, -1.182653911769E+20, -1.734101327083E+20, -1.903018294300E+20,
-1.287383634324E+20, -6.717489743492E+19, -6.918455006928E+19, -1.327576687012E+20,
-1.963307873331E+20, -2.039483993008E+20, -1.374766701016E+20, -7.100494090228E+19,
-6.964490057419E+19, -1.347565894454E+20, -1.998682783166E+20, -1.933304341125E+20,
-1.307255693029E+20, -6.812070449321E+19, -6.980635883397E+19, -1.340968779844E+20,
-1.983873971348E+20, -1.443977450203E+20, -9.892379938492E+19, -5.344985374951E+19,
-6.312064964548E+19, -1.182653911769E+20, -1.734101327083E+20, -3.807888037972E+19,
-2.825793700517E+19, -1.843699363062E+19, -3.317879124813E+19, -5.774153224019E+19,
-8.230427323224E+19, 7.140500088303E+19, 4.587782482018E+19, 2.035064875734E+19,
8.346507461054E+18, 2.186954222761E+19, 3.539257699416E+19, 1.169244258887E+20,
7.865635329442E+19, 4.038828070016E+19, 3.857421048676E+19, 7.502821286761E+19,
1.114822152485E+20, 4.211823607006E+19, 3.042864303151E+19, 1.873904999296E+19,
2.529609455086E+19, 4.354273214732E+19, 6.178936974377E+19, -2.906695129325E+20,
-1.853476437714E+20, -8.002577461027E+19, 2.529609455086E+19, 3.500226650129E+19,
9.287866896806E+18, -3.477394497976E+19, -6.312064964548E+19, -6.918455006928E+19,
-6.964490057419E+19, -6.980635883397E+19, -6.312064964548E+19, -3.317879124813E+19,
8.346507461054E+18, 3.857421048676E+19, 2.529609455086E+19, -4.160997529959E+19,
-1.085160451500E+20, -1.754221150005E+20, -6.234572619351E+20, -4.011239305743E+20,
-1.787905992135E+20, 4.354273214732E+19, 6.816249888084E+19, 2.366287336725E+19,
-6.058829155988E+19, -1.182653911769E+20, -1.327576687012E+20, -1.347565894454E+20,
-1.340968779844E+20, -1.182653911769E+20, -5.774153224019E+19, 2.186954222761E+19,
7.502821286761E+19, 4.354273214732E+19, -1.085160451500E+20, -2.605748224474E+20,
-4.126335997448E+20, -9.562450109377E+20, -6.169002173772E+20, -2.775554238167E+20,
6.178936974377E+19, 1.013227312604E+20, 3.803787983769E+19, -8.640263814000E+19,
-1.734101327083E+20, -1.963307873331E+20, -1.998682783166E+20, -1.983873971348E+20,
-1.734101327083E+20, -8.230427323224E+19, 3.539257699416E+19, 1.114822152485E+20,
6.178936974377E+19, -1.754221150005E+20, -4.126335997448E+20, -6.498450844891E+20], dtype=np.float64
)
class TestInterpolatorLoadSmallValuesUneven(TestInterpolatorLoadValues):
"""
Loading small values (10^-20 times the original) instead of the original np.sin(x)
These data are saved to 12 significant figures.
"""
def __init__(self):
super().__init__()
#: data array from a function sampled on self.x. dtype should be np.float64
# self.data: np.array = np.sin(self.x)
self.data: np.array = np.array(
[[7.049456954407E-22, 5.750613283457E-22, -5.031133752816E-23, -3.957902354963E-22,
-8.474851229653E-22, -9.121180789640E-22, -7.975908114097E-22, -6.835527608142E-22,
-4.876973734940E-22, -4.418624359019E-22, -4.876973734940E-22, -5.728794999748E-22,
-7.975908114097E-22, -8.851381966774E-22, -8.474851229653E-22, -6.734331948907E-22,
-5.031133752816E-23, 2.994648599639E-22, 7.049456954407E-22],
[5.750613283457E-22, 2.707313596327E-22, -4.947098908050E-22, -7.716977009236E-22,
-8.851381966774E-22, -7.454434661366E-22, -2.923247487940E-22, -6.867195016855E-23,
2.378357578524E-22, 3.010595454905E-22, 2.378357578524E-22, 1.127556015714E-22,
-2.923247487940E-22, -5.313921590225E-22, -8.851381966774E-22, -9.034807299146E-22,
-4.947098908050E-22, -1.193366977476E-22, 5.750613283457E-22],
[-5.031133752816E-23, -4.947098908050E-22, -9.121921863446E-22, -7.727418937786E-22,
-9.251264987298E-24, 4.278478892878E-22, 1.052139178127E-21, 1.201126954831E-21,
1.283205555674E-21, 1.282705054889E-21, 1.283205555674E-21, 1.266409993718E-21,
1.052139178127E-21, 7.942173990430E-22, -9.251264987298E-24, -4.418624359019E-22,
-9.121921863446E-22, -8.127030064783E-22, -5.031133752816E-23],
[-3.957902354963E-22, -7.716977009236E-22, -7.727418937786E-22, -3.939635588637E-22,
6.155045982467E-22, 1.005907311298E-21, 1.282705054889E-21, 1.215171020957E-21,
9.674890958243E-22, 8.947967120127E-22, 9.674890958243E-22, 1.089467585825E-21,
1.282705054889E-21, 1.227830098222E-21, 6.155045982467E-22, 1.127556015714E-22,
-7.727418937786E-22, -9.132515608025E-22, -3.957902354963E-22],
[-8.474851229653E-22, -8.851381966774E-22, -9.251264987298E-24, 6.155045982467E-22,
1.283205555674E-21, 1.138884597353E-21, 1.734970013481E-22, -3.806455343631E-22,
-1.140407180451E-21, -1.289967784984E-21, -1.140407180451E-21, -8.347707818621E-22,
1.734970013481E-22, 7.259972187812E-22, 1.283205555674E-21, 1.095087852132E-21,
-9.251264987298E-24, -5.728794999748E-22, -8.474851229653E-22],
[-9.121180789640E-22, -7.454434661366E-22, 4.278478892878E-22, 1.005907311298E-21,
1.138884597353E-21, 6.300331483592E-22, -8.347707818621E-22, -1.435151388671E-21,
-2.022780434934E-21, -2.095142217650E-21, -2.022780434934E-21, -1.824711128590E-21,
-8.347707818621E-22, -9.351916346701E-23, 1.138884597353E-21, 1.277678821031E-21,
4.278478892878E-22, -2.387837583277E-22, -9.121180789640E-22],
[-7.975908114097E-22, -2.923247487940E-22, 1.052139178127E-21, 1.282705054889E-21,
1.734970013481E-22, -8.347707818621E-22, -2.145503300375E-21, -2.052264171648E-21,
-9.241435356589E-22, -5.067031374727E-22, -9.241435356589E-22, -1.547945550760E-21,
-2.145503300375E-21, -1.704692811750E-21, 1.734970013480E-22, 9.674890958243E-22,
1.052139178127E-21, 4.278478892878E-22, -7.975908114097E-22],
[-6.835527608142E-22, -6.867195016855E-23, 1.201126954831E-21, 1.215171020957E-21,
-3.806455343631E-22, -1.435151388671E-21, -2.052264171648E-21, -1.268933271435E-21,
1.257727427008E-21, 2.044658799484E-21, 1.257727427008E-21, -9.251369377679E-24,
-2.052264171648E-21, -2.095142217650E-21, -3.806455343631E-22, 6.300331483592E-22,
1.201126954831E-21, 6.764157650466E-22, -6.835527608142E-22],
[-4.876973734940E-22, 2.378357578524E-22, 1.283205555674E-21, 9.674890958243E-22,
-1.140407180451E-21, -2.022780434934E-21, -9.241435356589E-22, 1.257727427008E-21,
6.446759109720E-21, 7.917136926885E-21, 6.446759109720E-21, 3.973381423908E-21,
-9.241435356589E-22, -2.052264171648E-21, -1.140407180451E-21, 4.282861041084E-23,
1.283205555674E-21, 9.566990623455E-22, -4.876973734940E-22],
[-4.418624359019E-22, 3.010595454905E-22, 1.282705054889E-21, 8.947967120127E-22,
-1.289967784984E-21, -2.095142217650E-21, -5.067031374727E-22, 2.044658799484E-21,
7.917136926885E-21, 9.560513212622E-21, 7.917136926885E-21, 5.136281978234E-21,
-5.067031374727E-22, -1.933844713753E-21, -1.289967784984E-21, -9.351916346701E-23,
1.282705054889E-21, 1.005907311298E-21, -4.418624359019E-22],
[-4.876973734940E-22, 2.378357578524E-22, 1.283205555674E-21, 9.674890958243E-22,
-1.140407180451E-21, -2.022780434934E-21, -9.241435356589E-22, 1.257727427008E-21,
6.446759109720E-21, 7.917136926885E-21, 6.446759109720E-21, 3.973381423908E-21,
-9.241435356589E-22, -2.052264171648E-21, -1.140407180451E-21, 4.282861041084E-23,
1.283205555674E-21, 9.566990623455E-22, -4.876973734940E-22],
[-5.728794999748E-22, 1.127556015714E-22, 1.266409993718E-21, 1.089467585825E-21,
-8.347707818621E-22, -1.824711128590E-21, -1.547945550760E-21, -9.251369377679E-24,
3.973381423908E-21, 5.136281978234E-21, 3.973381423908E-21, 2.044658799484E-21,
-1.547945550760E-21, -2.165899038868E-21, -8.347707818621E-22, 2.979548967146E-22,
1.266409993718E-21, 8.505592925358E-22, -5.728794999748E-22],
[-7.975908114097E-22, -2.923247487940E-22, 1.052139178127E-21, 1.282705054889E-21,
1.734970013481E-22, -8.347707818621E-22, -2.145503300375E-21, -2.052264171648E-21,
-9.241435356589E-22, -5.067031374727E-22, -9.241435356589E-22, -1.547945550760E-21,
-2.145503300375E-21, -1.704692811750E-21, 1.734970013480E-22, 9.674890958243E-22,
1.052139178127E-21, 4.278478892878E-22, -7.975908114097E-22],
[-8.851381966774E-22, -5.313921590225E-22, 7.942173990430E-22, 1.227830098222E-21,
7.259972187812E-22, -9.351916346701E-23, -1.704692811750E-21, -2.095142217650E-21,
-2.052264171648E-21, -1.933844713753E-21, -2.052264171648E-21, -2.165899038868E-21,
-1.704692811750E-21, -9.881655954565E-22, 7.259972187812E-22, 1.215171020957E-21,
7.942173990430E-22, 1.127556015714E-22, -8.851381966774E-22],
[-8.474851229653E-22, -8.851381966774E-22, -9.251264987298E-24, 6.155045982467E-22,
1.283205555674E-21, 1.138884597353E-21, 1.734970013480E-22, -3.806455343631E-22,
-1.140407180451E-21, -1.289967784984E-21, -1.140407180451E-21, -8.347707818621E-22,
1.734970013480E-22, 7.259972187812E-22, 1.283205555674E-21, 1.095087852132E-21,
-9.251264987296E-24, -5.728794999748E-22, -8.474851229653E-22],
[-6.734331948907E-22, -9.034807299146E-22, -4.418624359019E-22, 1.127556015714E-22,
1.095087852132E-21, 1.277678821031E-21, 9.674890958243E-22, 6.300331483592E-22,
4.282861041084E-23, -9.351916346701E-23, 4.282861041084E-23, 2.979548967146E-22,
9.674890958243E-22, 1.215171020957E-21, 1.095087852132E-21, 6.764157650466E-22,
-4.418624359019E-22, -8.199851501756E-22, -6.734331948907E-22],
[-5.031133752816E-23, -4.947098908050E-22, -9.121921863446E-22, -7.727418937786E-22,
-9.251264987298E-24, 4.278478892878E-22, 1.052139178127E-21, 1.201126954831E-21,
1.283205555674E-21, 1.282705054889E-21, 1.283205555674E-21, 1.266409993718E-21,
1.052139178127E-21, 7.942173990430E-22, -9.251264987296E-24, -4.418624359019E-22,
-9.121921863446E-22, -8.127030064783E-22, -5.031133752816E-23],
[2.994648599639E-22, -1.193366977476E-22, -8.127030064783E-22, -9.132515608025E-22,
-5.728794999748E-22, -2.387837583277E-22, 4.278478892878E-22, 6.764157650466E-22,
9.566990623455E-22, 1.005907311298E-21, 9.566990623455E-22, 8.505592925358E-22,
4.278478892878E-22, 1.127556015714E-22, -5.728794999748E-22, -8.199851501756E-22,
-8.127030064783E-22, -5.265231727816E-22, 2.994648599639E-22],
[7.049456954407E-22, 5.750613283457E-22, -5.031133752816E-23, -3.957902354963E-22,
-8.474851229653E-22, -9.121180789640E-22, -7.975908114097E-22, -6.835527608142E-22,
-4.876973734940E-22, -4.418624359019E-22, -4.876973734940E-22, -5.728794999748E-22,
-7.975908114097E-22, -8.851381966774E-22, -8.474851229653E-22, -6.734331948907E-22,
-5.031133752816E-23, 2.994648599639E-22, 7.049456954407E-22]], dtype=np.float64
)
#: array holding precalculated quadratic extrapolation data
self.precalc_extrapolation_quadratic: np.array = np.array(
[], dtype=np.float64
)
def setup_cubic(self):
self.precalc_interpolation = np.array(
[[7.049456954407E-22, 2.120303154043E-22, -5.412207605158E-22, -9.041927189809E-22,
-7.975908114097E-22, -5.490808448662E-22, -4.365385529968E-22, -5.493373238953E-22,
-7.975908114097E-22, -9.043881788286E-22, -5.458241224645E-22, 2.183159991917E-22,
7.049456954407E-22],
[2.120303154043E-22, -6.840828181977E-22, -8.291758075355E-22, -1.514915773345E-22,
6.146617965847E-22, 1.016705772106E-21, 1.117191819513E-21, 1.019683374662E-21,
6.146617965847E-22, -1.567520827568E-22, -8.211550352574E-22, -6.795064436020E-22,
2.120303154043E-22],
[-5.412207605158E-22, -8.291758075355E-22, 9.666098759062E-23, 1.115403574145E-21,
1.180976383194E-21, 7.071918180842E-22, 4.552636512940E-22, 7.066851884792E-22,
1.180976383194E-21, 1.094887240678E-21, 1.271424487456E-22, -8.489926255180E-22,
-5.412207605158E-22],
[-9.041927189809E-22, -1.514915773345E-22, 1.115403574145E-21, 9.058021229999E-22,
-5.921575988005E-22, -1.697171170804E-21, -1.986325220649E-21, -1.708674849009E-21,
-5.921575988005E-22, 9.071011939526E-22, 1.130155601111E-21, -1.774015779353E-22,
-9.041927189809E-22],
[-7.975908114097E-22, 6.146617965847E-22, 1.180976383194E-21, -5.921575988005E-22,
-2.145503300375E-21, -1.373726429185E-21, -4.677155115289E-22, -1.400744853311E-21,
-2.145503300375E-21, -5.608764908063E-22, 1.171252709523E-21, 5.937941570370E-22,
-7.975908114097E-22],
[-5.490808448662E-22, 1.016705772106E-21, 7.071918180842E-22, -1.697171170804E-21,
-1.373726429185E-21, 3.180255899274E-21, 6.051776838087E-21, 3.123175894536E-21,
-1.373726429185E-21, -1.640188016429E-21, 6.586737199675E-22, 1.009003074435E-21,
-5.490808448662E-22],
[-4.365385529968E-22, 1.117191819513E-21, 4.552636512940E-22, -1.986325220649E-21,
-4.677155115289E-22, 6.051776838087E-21, 9.899192445544E-21, 5.987956201910E-21,
-4.677155115289E-22, -1.913782291956E-21, 3.931492909576E-22, 1.117308113990E-21,
-4.365385529968E-22],
[-5.493373238953E-22, 1.019683374662E-21, 7.066851884792E-22, -1.708674849009E-21,
-1.400744853311E-21, 3.123175894536E-21, 5.987956201910E-21, 3.081035634172E-21,
-1.400744853311E-21, -1.646011917477E-21, 6.660176847751E-22, 1.011817145737E-21,
-5.493373238953E-22],
[-7.975908114097E-22, 6.146617965847E-22, 1.180976383194E-21, -5.921575988005E-22,
-2.145503300375E-21, -1.373726429185E-21, -4.677155115289E-22, -1.400744853311E-21,
-2.145503300375E-21, -5.608764908063E-22, 1.171252709523E-21, 5.937941570370E-22,
-7.975908114097E-22],
[-9.043881788286E-22, -1.567520827568E-22, 1.094887240678E-21, 9.071011939526E-22,
-5.608764908063E-22, -1.640188016429E-21, -1.913782291956E-21, -1.646011917477E-21,
-5.608764908063E-22, 9.061889238735E-22, 1.119056766335E-21, -1.844151449703E-22,
-9.043881788286E-22],
[-5.458241224645E-22, -8.211550352574E-22, 1.271424487456E-22, 1.130155601111E-21,
1.171252709523E-21, 6.586737199675E-22, 3.931492909576E-22, 6.660176847751E-22,
1.171252709523E-21, 1.119056766335E-21, 1.568973617012E-22, -8.405046373540E-22,
-5.458241224645E-22],
[2.183159991917E-22, -6.795064436020E-22, -8.489926255180E-22, -1.774015779353E-22,
5.937941570370E-22, 1.009003074435E-21, 1.117308113990E-21, 1.011817145737E-21,
5.937941570370E-22, -1.844151449703E-22, -8.405046373540E-22, -6.845929971507E-22,
2.183159991917E-22],
[7.049456954407E-22, 2.120303154043E-22, -5.412207605158E-22, -9.041927189809E-22,
-7.975908114097E-22, -5.490808448662E-22, -4.365385529968E-22, -5.493373238953E-22,
-7.975908114097E-22, -9.043881788286E-22, -5.458241224645E-22, 2.183159991917E-22,
7.049456954407E-22]], dtype=np.float64
)
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
2.120303154043E-22, -5.412207605158E-22, -9.041927189809E-22, -7.975908114097E-22,
-5.490808448662E-22, -4.365385529968E-22, -5.493373238953E-22, -7.975908114097E-22,
-9.043881788286E-22, -5.458241224645E-22, 2.183159991917E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 2.120303154043E-22,
-5.412207605158E-22, -9.041927189809E-22, -7.975908114097E-22, -5.490808448662E-22,
-4.365385529968E-22, -5.493373238953E-22, -7.975908114097E-22, -9.043881788286E-22,
-5.458241224645E-22, 2.183159991917E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 2.120303154043E-22, -5.412207605158E-22,
-9.041927189809E-22, -7.975908114097E-22, -5.490808448662E-22, -4.365385529968E-22,
-5.493373238953E-22, -7.975908114097E-22, -9.043881788286E-22, -5.458241224645E-22,
2.183159991917E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 2.120303154043E-22,
2.120303154043E-22, 2.120303154043E-22, 2.120303154043E-22, 2.120303154043E-22,
2.120303154043E-22, -5.412207605158E-22, -5.412207605158E-22, -5.412207605158E-22,
-5.412207605158E-22, -5.412207605158E-22, -5.412207605158E-22, -9.041927189809E-22,
-9.041927189809E-22, -9.041927189809E-22, -9.041927189809E-22, -9.041927189809E-22,
-9.041927189809E-22, -7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22,
-7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22, -5.490808448662E-22,
-5.490808448662E-22, -5.490808448662E-22, -5.490808448662E-22, -5.490808448662E-22,
-5.490808448662E-22, -4.365385529968E-22, -4.365385529968E-22, -4.365385529968E-22,
-4.365385529968E-22, -4.365385529968E-22, -4.365385529968E-22, -5.493373238953E-22,
-5.493373238953E-22, -5.493373238953E-22, -5.493373238953E-22, -5.493373238953E-22,
-5.493373238953E-22, -7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22,
-7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22, -9.043881788286E-22,
-9.043881788286E-22, -9.043881788286E-22, -9.043881788286E-22, -9.043881788286E-22,
-9.043881788286E-22, -5.458241224645E-22, -5.458241224645E-22, -5.458241224645E-22,
-5.458241224645E-22, -5.458241224645E-22, -5.458241224645E-22, 2.183159991917E-22,
2.183159991917E-22, 2.183159991917E-22, 2.183159991917E-22, 2.183159991917E-22,
2.183159991917E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 2.120303154043E-22,
-5.412207605158E-22, -9.041927189809E-22, -7.975908114097E-22, -5.490808448662E-22,
-4.365385529968E-22, -5.493373238953E-22, -7.975908114097E-22, -9.043881788286E-22,
-5.458241224645E-22, 2.183159991917E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 2.120303154043E-22, -5.412207605158E-22,
-9.041927189809E-22, -7.975908114097E-22, -5.490808448662E-22, -4.365385529968E-22,
-5.493373238953E-22, -7.975908114097E-22, -9.043881788286E-22, -5.458241224645E-22,
2.183159991917E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 2.120303154043E-22, -5.412207605158E-22, -9.041927189809E-22,
-7.975908114097E-22, -5.490808448662E-22, -4.365385529968E-22, -5.493373238953E-22,
-7.975908114097E-22, -9.043881788286E-22, -5.458241224645E-22, 2.183159991917E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[-1.194521420610E-19, -7.823082017163E-20, -3.700949828231E-20, 4.211823607006E-21,
1.132303125654E-20, 7.609499224352E-21, -4.084169620081E-21, -1.443977450203E-20,
-1.920403690376E-20, -2.047040864433E-20, -1.948441248529E-20, -1.443977450203E-20,
-3.911849985106E-21, 7.440065969941E-21, 1.211163300265E-20, 4.211823607006E-21,
-2.906695129325E-20, -6.234572619351E-20, -9.562450109377E-20, -7.823082017163E-20,
-5.113959201337E-20, -2.404836385511E-20, 3.042864303151E-21, 7.619364276159E-21,
4.892592562729E-21, -3.024177319714E-21, -9.892379938492E-21, -1.298571821746E-20,
-1.379245194722E-20, -1.317272076482E-20, -9.892379938492E-21, -2.909362716347E-21,
4.778102605806E-21, 8.147194001498E-21, 3.042864303151E-21, -1.853476437714E-20,
-4.011239305743E-20, -6.169002173772E-20, -3.700949828231E-20, -2.404836385511E-20,
-1.108722942791E-20, 1.873904999296E-21, 3.915697295782E-21, 2.175685901107E-21,
-1.964185019348E-21, -5.344985374951E-21, -6.767399531163E-21, -7.114495250108E-21,
-6.861029044360E-21, -5.344985374951E-21, -1.906875447588E-21, 2.116139241671E-21,
4.182755000345E-21, 1.873904999296E-21, -8.002577461027E-21, -1.787905992135E-20,
-2.775554238167E-20, 4.211823607006E-21, 3.042864303151E-21, 1.873904999296E-21,
2.529609455086E-21, 4.354273214732E-21, 6.178936974377E-21, 1.132303125654E-20,
7.619364276159E-21, 3.915697295782E-21, 3.717844299417E-21, 7.223658283430E-21,
1.072947226744E-20, 7.609499224352E-21, 4.892592562729E-21, 2.175685901107E-21,
9.604055355141E-22, 2.462031831544E-21, 3.963658127574E-21, -4.084169620081E-21,
-3.024177319714E-21, -1.964185019348E-21, -3.537002512839E-21, -6.169812306696E-21,
-8.802622100554E-21, -1.443977450203E-20, -9.892379938492E-21, -5.344985374951E-21,
-6.312064964548E-21, -1.182653911769E-20, -1.734101327083E-20, -1.920403690376E-20,
-1.298571821746E-20, -6.767399531163E-21, -6.947802448856E-21, -1.334652405285E-20,
-1.974524565683E-20, -2.047040864433E-20, -1.379245194722E-20, -7.114495250108E-21,
-6.952552096349E-21, -1.346856563970E-20, -1.998457918305E-20, -1.948441248529E-20,
-1.317272076482E-20, -6.861029044360E-21, -7.014023360164E-21, -1.347870939643E-20,
-1.994339543270E-20, -1.443977450203E-20, -9.892379938492E-21, -5.344985374951E-21,
-6.312064964548E-21, -1.182653911769E-20, -1.734101327083E-20, -3.911849985106E-21,
-2.909362716347E-21, -1.906875447588E-21, -3.422173851071E-21, -5.939959523313E-21,
-8.457745195555E-21, 7.440065969941E-21, 4.778102605806E-21, 2.116139241671E-21,
8.886095091330E-22, 2.323043140730E-21, 3.757476772328E-21, 1.211163300265E-20,
8.147194001498E-21, 4.182755000345E-21, 4.013604681385E-21, 7.808893363578E-21,
1.160418204577E-20, 4.211823607006E-21, 3.042864303151E-21, 1.873904999296E-21,
2.529609455086E-21, 4.354273214732E-21, 6.178936974378E-21, -2.906695129325E-20,
-1.853476437714E-20, -8.002577461027E-21, 2.529609455086E-21, 3.717844299417E-21,
9.604055355141E-22, -3.537002512839E-21, -6.312064964548E-21, -6.947802448856E-21,
-6.952552096349E-21, -7.014023360164E-21, -6.312064964548E-21, -3.422173851071E-21,
8.886095091330E-22, 4.013604681385E-21, 2.529609455086E-21, -4.160997529959E-21,
-1.085160451500E-20, -1.754221150005E-20, -6.234572619351E-20, -4.011239305743E-20,
-1.787905992135E-20, 4.354273214732E-21, 7.223658283430E-21, 2.462031831544E-21,
-6.169812306696E-21, -1.182653911769E-20, -1.334652405285E-20, -1.346856563970E-20,
-1.347870939643E-20, -1.182653911769E-20, -5.939959523313E-21, 2.323043140730E-21,
7.808893363578E-21, 4.354273214732E-21, -1.085160451500E-20, -2.605748224474E-20,
-4.126335997448E-20, -9.562450109377E-20, -6.169002173772E-20, -2.775554238167E-20,
6.178936974377E-21, 1.072947226744E-20, 3.963658127574E-21, -8.802622100554E-21,
-1.734101327083E-20, -1.974524565683E-20, -1.998457918305E-20, -1.994339543270E-20,
-1.734101327083E-20, -8.457745195555E-21, 3.757476772328E-21, 1.160418204577E-20,
6.178936974378E-21, -1.754221150005E-20, -4.126335997448E-20, -6.498450844891E-20], dtype=np.float64
)
def setup_linear(self):
self.precalc_interpolation = np.array(
[[7.049456954407E-22, 1.842034121745E-22, -5.087139573635E-22, -8.959598399643E-22,
-7.975908114097E-22, -5.611431437391E-22, -4.533211702999E-22, -5.515839683546E-22,
-7.975908114097E-22, -8.616050256073E-22, -5.176527305501E-22, 2.120208105909E-22,
7.049456954407E-22],
[1.842034121745E-22, -5.501487366574E-22, -6.636899571863E-22, -9.352949284003E-23,
5.479652055316E-22, 8.288520629779E-22, 9.087389620211E-22, 8.481401678700E-22,
5.479652055316E-22, -9.965035969377E-23, -6.501360534968E-22, -6.034270619075E-22,
1.842034121745E-22],
[-5.087139573635E-22, -6.636899571863E-22, 8.941006971131E-23, 9.749711840097E-22,
1.005403041504E-21, 5.814032225198E-22, 3.715829475115E-22, 5.664347521163E-22,
1.005403041504E-21, 9.024081028879E-22, 1.232866890135E-22, -7.665862183419E-22,
-5.087139573635E-22],
[-8.959598399643E-22, -9.352949284003E-23, 9.749711840097E-22, 8.616757171890E-22,
-5.827038360596E-22, -1.565688797731E-21, -1.870933237441E-21, -1.633466311759E-21,
-5.827038360596E-22, 7.761129976189E-22, 1.003666584284E-21, -1.620874951248E-22,
-8.959598399643E-22],
[-7.975908114097E-22, 5.479652055316E-22, 1.005403041504E-21, -5.827038360596E-22,
-2.145503300375E-21, -1.347188774155E-21, -6.110632370193E-22, -1.391995046985E-21,
-2.145503300375E-21, -5.308241785637E-22, 9.886516164000E-22, 5.839207114976E-22,
-7.975908114097E-22],
[-5.611431437391E-22, 8.288520629779E-22, 5.814032225198E-22, -1.565688797731E-21,
-1.347188774155E-21, 2.929381267349E-21, 5.411436279008E-21, 2.985138651995E-21,
-1.347188774155E-21, -1.310314141567E-21, 5.103792541956E-22, 9.518011394833E-22,
-5.611431437391E-22],
[-4.533211702999E-22, 9.087389620211E-22, 3.715829475115E-22, -1.870933237441E-21,
-6.110632370193E-22, 5.411436279008E-21, 8.749637474039E-21, 5.521553247888E-21,
-6.110632370193E-22, -1.519154612992E-21, 2.761333800232E-22, 1.065911481816E-21,
-4.533211702999E-22],
[-5.515839683546E-22, 8.481401678700E-22, 5.664347521163E-22, -1.633466311759E-21,
-1.391995046985E-21, 2.985138651995E-21, 5.521553247888E-21, 3.043061053033E-21,
-1.391995046985E-21, -1.371046296717E-21, 4.932822149057E-22, 9.754728972929E-22,
-5.515839683546E-22],
[-7.975908114097E-22, 5.479652055316E-22, 1.005403041504E-21, -5.827038360596E-22,
-2.145503300375E-21, -1.347188774155E-21, -6.110632370193E-22, -1.391995046985E-21,
-2.145503300375E-21, -5.308241785637E-22, 9.886516164000E-22, 5.839207114976E-22,
-7.975908114097E-22],
[-8.616050256073E-22, -9.965035969377E-23, 9.024081028879E-22, 7.761129976189E-22,
-5.308241785637E-22, -1.310314141567E-21, -1.519154612992E-21, -1.371046296717E-21,
-5.308241785637E-22, 7.026025796278E-22, 9.281016513370E-22, -1.638123816652E-22,
-8.616050256073E-22],
[-5.176527305501E-22, -6.501360534968E-22, 1.232866890135E-22, 1.003666584284E-21,
9.886516164000E-22, 5.103792541956E-22, 2.761333800232E-22, 4.932822149057E-22,
9.886516164000E-22, 9.281016513370E-22, 1.577734427290E-22, -7.534846790666E-22,
-5.176527305501E-22],
[2.120208105909E-22, -6.034270619075E-22, -7.665862183419E-22, -1.620874951248E-22,
5.839207114976E-22, 9.518011394833E-22, 1.065911481816E-21, 9.754728972929E-22,
5.839207114976E-22, -1.638123816652E-22, -7.534846790666E-22, -6.579449237655E-22,
2.120208105909E-22],
[7.049456954407E-22, 1.842034121745E-22, -5.087139573635E-22, -8.959598399643E-22,
-7.975908114097E-22, -5.611431437391E-22, -4.533211702999E-22, -5.515839683546E-22,
-7.975908114097E-22, -8.616050256073E-22, -5.176527305501E-22, 2.120208105909E-22,
7.049456954407E-22]], dtype=np.float64
)
#: array holding precalculated nearest neighbour extrapolation data
self.precalc_extrapolation_nearest: np.array = np.array(
[7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
1.842034121745E-22, -5.087139573635E-22, -8.959598399643E-22, -7.975908114097E-22,
-5.611431437391E-22, -4.533211702999E-22, -5.515839683546E-22, -7.975908114097E-22,
-8.616050256073E-22, -5.176527305501E-22, 2.120208105909E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 1.842034121745E-22,
-5.087139573635E-22, -8.959598399643E-22, -7.975908114097E-22, -5.611431437391E-22,
-4.533211702999E-22, -5.515839683546E-22, -7.975908114097E-22, -8.616050256073E-22,
-5.176527305501E-22, 2.120208105909E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 1.842034121745E-22, -5.087139573635E-22,
-8.959598399643E-22, -7.975908114097E-22, -5.611431437391E-22, -4.533211702999E-22,
-5.515839683546E-22, -7.975908114097E-22, -8.616050256073E-22, -5.176527305501E-22,
2.120208105909E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 1.842034121745E-22,
1.842034121745E-22, 1.842034121745E-22, 1.842034121745E-22, 1.842034121745E-22,
1.842034121745E-22, -5.087139573635E-22, -5.087139573635E-22, -5.087139573635E-22,
-5.087139573635E-22, -5.087139573635E-22, -5.087139573635E-22, -8.959598399643E-22,
-8.959598399643E-22, -8.959598399643E-22, -8.959598399643E-22, -8.959598399643E-22,
-8.959598399643E-22, -7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22,
-7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22, -5.611431437391E-22,
-5.611431437391E-22, -5.611431437391E-22, -5.611431437391E-22, -5.611431437391E-22,
-5.611431437391E-22, -4.533211702999E-22, -4.533211702999E-22, -4.533211702999E-22,
-4.533211702999E-22, -4.533211702999E-22, -4.533211702999E-22, -5.515839683546E-22,
-5.515839683546E-22, -5.515839683546E-22, -5.515839683546E-22, -5.515839683546E-22,
-5.515839683546E-22, -7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22,
-7.975908114097E-22, -7.975908114097E-22, -7.975908114097E-22, -8.616050256073E-22,
-8.616050256073E-22, -8.616050256073E-22, -8.616050256073E-22, -8.616050256073E-22,
-8.616050256073E-22, -5.176527305501E-22, -5.176527305501E-22, -5.176527305501E-22,
-5.176527305501E-22, -5.176527305501E-22, -5.176527305501E-22, 2.120208105909E-22,
2.120208105909E-22, 2.120208105909E-22, 2.120208105909E-22, 2.120208105909E-22,
2.120208105909E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 1.842034121745E-22,
-5.087139573635E-22, -8.959598399643E-22, -7.975908114097E-22, -5.611431437391E-22,
-4.533211702999E-22, -5.515839683546E-22, -7.975908114097E-22, -8.616050256073E-22,
-5.176527305501E-22, 2.120208105909E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 1.842034121745E-22, -5.087139573635E-22,
-8.959598399643E-22, -7.975908114097E-22, -5.611431437391E-22, -4.533211702999E-22,
-5.515839683546E-22, -7.975908114097E-22, -8.616050256073E-22, -5.176527305501E-22,
2.120208105909E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22,
7.049456954407E-22, 1.842034121745E-22, -5.087139573635E-22, -8.959598399643E-22,
-7.975908114097E-22, -5.611431437391E-22, -4.533211702999E-22, -5.515839683546E-22,
-7.975908114097E-22, -8.616050256073E-22, -5.176527305501E-22, 2.120208105909E-22,
7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22, 7.049456954407E-22], dtype=np.float64
)
#: array holding precalculated linear extrapolation data
self.precalc_extrapolation_linear: np.array = np.array(
[-1.194521420610E-19, -7.823082017163E-20, -3.700949828231E-20, 4.211823607006E-21,
1.076476993194E-20, 7.357570465096E-21, -4.016962502163E-21, -1.443977450203E-20,
-1.903018294300E-20, -2.039483993008E-20, -1.933304341125E-20, -1.443977450203E-20,
-3.807888037972E-21, 7.140500088303E-21, 1.169244258887E-20, 4.211823607006E-21,
-2.906695129325E-20, -6.234572619351E-20, -9.562450109377E-20, -7.823082017163E-20,
-5.113959201337E-20, -2.404836385511E-20, 3.042864303151E-21, 7.237914425352E-21,
4.735475657609E-21, -2.976628281430E-21, -9.892379938492E-21, -1.287383634324E-20,
-1.374766701016E-20, -1.307255693029E-20, -9.892379938492E-21, -2.825793700517E-21,
4.587782482018E-21, 7.865635329442E-21, 3.042864303151E-21, -1.853476437714E-20,
-4.011239305743E-20, -6.169002173772E-20, -3.700949828231E-20, -2.404836385511E-20,
-1.108722942791E-20, 1.873904999296E-21, 3.711058918763E-21, 2.113380850123E-21,
-1.936294060697E-21, -5.344985374951E-21, -6.717489743492E-21, -7.100494090228E-21,
-6.812070449321E-21, -5.344985374951E-21, -1.843699363062E-21, 2.035064875734E-21,
4.038828070016E-21, 1.873904999296E-21, -8.002577461027E-21, -1.787905992135E-20,
-2.775554238167E-20, 4.211823607006E-21, 3.042864303151E-21, 1.873904999296E-21,
2.529609455086E-21, 4.354273214732E-21, 6.178936974377E-21, 1.076476993194E-20,
7.237914425352E-21, 3.711058918763E-21, 3.500226650129E-21, 6.816249888084E-21,
1.013227312604E-20, 7.357570465096E-21, 4.735475657609E-21, 2.113380850123E-21,
9.287866896806E-22, 2.366287336725E-21, 3.803787983769E-21, -4.016962502163E-21,
-2.976628281430E-21, -1.936294060697E-21, -3.477394497976E-21, -6.058829155988E-21,
-8.640263814000E-21, -1.443977450203E-20, -9.892379938492E-21, -5.344985374951E-21,
-6.312064964548E-21, -1.182653911769E-20, -1.734101327083E-20, -1.903018294300E-20,
-1.287383634324E-20, -6.717489743492E-21, -6.918455006928E-21, -1.327576687012E-20,
-1.963307873331E-20, -2.039483993008E-20, -1.374766701016E-20, -7.100494090228E-21,
-6.964490057419E-21, -1.347565894454E-20, -1.998682783166E-20, -1.933304341125E-20,
-1.307255693029E-20, -6.812070449321E-21, -6.980635883397E-21, -1.340968779844E-20,
-1.983873971348E-20, -1.443977450203E-20, -9.892379938492E-21, -5.344985374951E-21,
-6.312064964548E-21, -1.182653911769E-20, -1.734101327083E-20, -3.807888037972E-21,
-2.825793700517E-21, -1.843699363062E-21, -3.317879124813E-21, -5.774153224019E-21,
-8.230427323224E-21, 7.140500088303E-21, 4.587782482018E-21, 2.035064875734E-21,
8.346507461054E-22, 2.186954222761E-21, 3.539257699416E-21, 1.169244258887E-20,
7.865635329442E-21, 4.038828070016E-21, 3.857421048676E-21, 7.502821286761E-21,
1.114822152485E-20, 4.211823607006E-21, 3.042864303151E-21, 1.873904999296E-21,
2.529609455086E-21, 4.354273214732E-21, 6.178936974377E-21, -2.906695129325E-20,
-1.853476437714E-20, -8.002577461027E-21, 2.529609455086E-21, 3.500226650129E-21,
9.287866896806E-22, -3.477394497976E-21, -6.312064964548E-21, -6.918455006928E-21,
-6.964490057419E-21, -6.980635883397E-21, -6.312064964548E-21, -3.317879124813E-21,
8.346507461054E-22, 3.857421048676E-21, 2.529609455086E-21, -4.160997529959E-21,
-1.085160451500E-20, -1.754221150005E-20, -6.234572619351E-20, -4.011239305743E-20,
-1.787905992135E-20, 4.354273214732E-21, 6.816249888084E-21, 2.366287336725E-21,
-6.058829155988E-21, -1.182653911769E-20, -1.327576687012E-20, -1.347565894454E-20,
-1.340968779844E-20, -1.182653911769E-20, -5.774153224019E-21, 2.186954222761E-21,
7.502821286761E-21, 4.354273214732E-21, -1.085160451500E-20, -2.605748224474E-20,
-4.126335997448E-20, -9.562450109377E-20, -6.169002173772E-20, -2.775554238167E-20,
6.178936974377E-21, 1.013227312604E-20, 3.803787983769E-21, -8.640263814000E-21,
-1.734101327083E-20, -1.963307873331E-20, -1.998682783166E-20, -1.983873971348E-20,
-1.734101327083E-20, -8.230427323224E-21, 3.539257699416E-21, 1.114822152485E-20,
6.178936974377E-21, -1.754221150005E-20, -4.126335997448E-20, -6.498450844891E-20], dtype=np.float64
)
| 82.501037
| 118
| 0.679538
| 25,229
| 198,910
| 5.351778
| 0.04039
| 0.062213
| 0.0237
| 0.025196
| 0.784854
| 0.741535
| 0.734943
| 0.702422
| 0.680455
| 0.679744
| 0
| 0.729579
| 0.170097
| 198,910
| 2,410
| 119
| 82.53527
| 0.088347
| 0.020507
| 0
| 0.373578
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.008311
| false
| 0
| 0.000437
| 0
| 0.011811
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
9bc8adaa2aa970ca91a05eb47e260191843ef9c9
| 9,095
|
py
|
Python
|
tests/assessments/test_resolvability_assessments.py
|
felix781/market-access-python-frontend
|
3b0e49feb4fdf0224816326938a46002aa4a2b1c
|
[
"MIT"
] | 1
|
2021-12-15T04:14:03.000Z
|
2021-12-15T04:14:03.000Z
|
tests/assessments/test_resolvability_assessments.py
|
felix781/market-access-python-frontend
|
3b0e49feb4fdf0224816326938a46002aa4a2b1c
|
[
"MIT"
] | 19
|
2019-12-11T11:32:47.000Z
|
2022-03-29T15:40:57.000Z
|
tests/assessments/test_resolvability_assessments.py
|
felix781/market-access-python-frontend
|
3b0e49feb4fdf0224816326938a46002aa4a2b1c
|
[
"MIT"
] | 2
|
2021-02-09T09:38:45.000Z
|
2021-03-29T19:07:09.000Z
|
from http import HTTPStatus
from django.urls import reverse
from mock import patch
from core.tests import MarketAccessTestCase
class TestResolvabilityAssessments(MarketAccessTestCase):
assessment_id = "1181e104-4607-4231-b70e-b3f96ccf402f"
@patch("utils.api.resources.APIResource.create")
def test_add_resolvability_assessment(self, mock_create):
response = self.client.post(
reverse(
"barriers:add_resolvability_assessment",
kwargs={"barrier_id": self.barrier["id"]},
),
data={
"time_to_resolve": "3",
"effort_to_resolve": "4",
"explanation": "Explanation...",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_create.assert_called_with(
barrier_id=self.barrier["id"],
time_to_resolve="3",
effort_to_resolve="4",
explanation="Explanation...",
)
@patch("utils.api.resources.APIResource.create")
def test_add_resolvability_assessment_errors(self, mock_create):
response = self.client.post(
reverse(
"barriers:add_resolvability_assessment",
kwargs={"barrier_id": self.barrier["id"]},
),
data={
"time_to_resolve": "xxx",
"effort_to_resolve": "",
"explanation": "",
},
)
assert response.status_code == HTTPStatus.OK
assert "form" in response.context
form = response.context["form"]
assert form.is_valid() is False
assert "time_to_resolve" in form.errors
assert "effort_to_resolve" in form.errors
assert "explanation" in form.errors
assert mock_create.called is False
@patch("utils.api.resources.APIResource.patch")
def test_update_resolvability_assessment(self, mock_patch):
response = self.client.post(
reverse(
"barriers:edit_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
data={
"time_to_resolve": "1",
"effort_to_resolve": "0",
"explanation": "New explanation...",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.assessment_id,
time_to_resolve="1",
effort_to_resolve="0",
explanation="New explanation...",
)
@patch("utils.api.resources.APIResource.patch")
def test_update_resolvability_assessment_errors(self, mock_patch):
response = self.client.post(
reverse(
"barriers:edit_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
data={
"time_to_resolve": "1",
"effort_to_resolve": "12",
"explanation": "",
},
)
assert response.status_code == HTTPStatus.OK
assert "form" in response.context
form = response.context["form"]
assert form.is_valid() is False
assert "time_to_resolve" not in form.errors
assert "effort_to_resolve" in form.errors
assert "explanation" in form.errors
assert mock_patch.called is False
@patch("utils.api.resources.APIResource.patch")
def test_approve_resolvability_assessment(self, mock_patch):
response = self.client.post(
reverse(
"barriers:edit_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
data={
"time_to_resolve": "1",
"effort_to_resolve": "0",
"explanation": "New explanation...",
"approved": "True",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.assessment_id,
time_to_resolve="1",
effort_to_resolve="0",
explanation="New explanation...",
approved=True,
)
@patch("utils.api.resources.APIResource.patch")
def test_reject_resolvability_assessment(self, mock_patch):
response = self.client.post(
reverse(
"barriers:edit_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
data={
"time_to_resolve": "1",
"effort_to_resolve": "0",
"explanation": "New explanation...",
"approved": "False",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.assessment_id,
time_to_resolve="1",
effort_to_resolve="0",
explanation="New explanation...",
approved=False,
)
@patch("utils.api.resources.APIResource.patch")
def test_archive_resolvability_assessment(self, mock_patch):
response = self.client.post(
reverse(
"barriers:archive_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
data={
"are_you_sure": "yes",
"archived_reason": "Some reason",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.assessment_id,
archived=True,
archived_reason="Some reason",
)
@patch("utils.api.resources.APIResource.patch")
def test_archive_resolvability_assessment_exit(self, mock_patch):
response = self.client.post(
reverse(
"barriers:archive_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
data={
"are_you_sure": "no",
"archived_reason": "Some reason",
},
)
assert response.status_code == HTTPStatus.FOUND
assert mock_patch.called is False
@patch("utils.api.resources.UsersResource.get_current")
def test_resolvability_assessment_permissions_general_user(self, mock_user):
mock_user.return_value = self.general_user
response = self.client.get(
reverse(
"barriers:add_resolvability_assessment",
kwargs={"barrier_id": self.barrier["id"]},
),
)
assert response.status_code == HTTPStatus.FORBIDDEN
response = self.client.get(
reverse(
"barriers:edit_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
)
assert response.status_code == HTTPStatus.FORBIDDEN
response = self.client.get(
reverse(
"barriers:archive_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
)
assert response.status_code == HTTPStatus.FORBIDDEN
@patch("utils.api.resources.UsersResource.get_current")
def test_resolvability_assessment_permissions_approver(self, mock_user):
mock_user.return_value = self.approver_user
response = self.client.get(
reverse(
"barriers:add_resolvability_assessment",
kwargs={"barrier_id": self.barrier["id"]},
),
)
assert response.status_code == HTTPStatus.OK
response = self.client.get(
reverse(
"barriers:edit_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
)
assert response.status_code == HTTPStatus.OK
response = self.client.get(
reverse(
"barriers:archive_resolvability_assessment",
kwargs={
"barrier_id": self.barrier["id"],
"assessment_id": self.assessment_id,
},
),
)
assert response.status_code == HTTPStatus.OK
| 34.581749
| 80
| 0.536339
| 808
| 9,095
| 5.77599
| 0.112624
| 0.057853
| 0.041783
| 0.064281
| 0.92522
| 0.917934
| 0.917934
| 0.917934
| 0.88408
| 0.88408
| 0
| 0.007223
| 0.360638
| 9,095
| 262
| 81
| 34.71374
| 0.795357
| 0
| 0
| 0.681818
| 0
| 0
| 0.208796
| 0.105992
| 0
| 0
| 0
| 0
| 0.132231
| 1
| 0.041322
| false
| 0
| 0.016529
| 0
| 0.066116
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
9bd4bf61e27e8baeb481d4254bdbd9f6fd4096d2
| 28
|
py
|
Python
|
backend/lost/api/filebrowser/api_definition.py
|
JonasGoebel/lost
|
802be42fb6cd7d046db61a34d77c0b5d233eca46
|
[
"MIT"
] | 490
|
2019-01-16T12:57:22.000Z
|
2022-03-26T14:13:26.000Z
|
backend/lost/api/filebrowser/api_definition.py
|
JonasGoebel/lost
|
802be42fb6cd7d046db61a34d77c0b5d233eca46
|
[
"MIT"
] | 147
|
2019-01-23T13:22:42.000Z
|
2022-03-30T11:14:08.000Z
|
backend/lost/api/filebrowser/api_definition.py
|
JonasGoebel/lost
|
802be42fb6cd7d046db61a34d77c0b5d233eca46
|
[
"MIT"
] | 91
|
2019-03-11T10:37:50.000Z
|
2022-03-28T16:41:32.000Z
|
from lost.api.api import api
| 28
| 28
| 0.821429
| 6
| 28
| 3.833333
| 0.666667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.107143
| 28
| 1
| 28
| 28
| 0.92
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
506180fa7302ea094c0c4b42b2927491ef5e962d
| 121
|
py
|
Python
|
mac_data/marshmallow_ext/__init__.py
|
mbattifarano/mac-data
|
9c9cd608ee176a8d12427bbaeab2f3453b98c71c
|
[
"MIT"
] | 2
|
2018-05-21T23:29:54.000Z
|
2019-01-17T21:19:10.000Z
|
mac_data/marshmallow_ext/__init__.py
|
mbattifarano/mac-data
|
9c9cd608ee176a8d12427bbaeab2f3453b98c71c
|
[
"MIT"
] | 66
|
2018-07-13T01:49:20.000Z
|
2022-02-21T14:15:14.000Z
|
mac_data/marshmallow_ext/__init__.py
|
mbattifarano/mac-data
|
9c9cd608ee176a8d12427bbaeab2f3453b98c71c
|
[
"MIT"
] | null | null | null |
from fields import Union, Either, NullObject # NOQA
def fieldnames(schema):
return schema._declared_fields.keys()
| 20.166667
| 52
| 0.760331
| 15
| 121
| 6
| 0.866667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157025
| 121
| 5
| 53
| 24.2
| 0.882353
| 0.033058
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.333333
| 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
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
acabf23966d126c728b12bd9d274d41716145114
| 199
|
py
|
Python
|
models/classification/__init__.py
|
gyx1997/msr22-defects
|
769ebb5add21002c3234517b49b9363b44b243c4
|
[
"MIT"
] | null | null | null |
models/classification/__init__.py
|
gyx1997/msr22-defects
|
769ebb5add21002c3234517b49b9363b44b243c4
|
[
"MIT"
] | null | null | null |
models/classification/__init__.py
|
gyx1997/msr22-defects
|
769ebb5add21002c3234517b49b9363b44b243c4
|
[
"MIT"
] | null | null | null |
from models.classification.baseclassifier import BaseClassifier
from models.classification.textcnnclassifier import TextCNNClassifier
from models.classification.lstmclassifier import LSTMClassifier
| 66.333333
| 70
| 0.904523
| 18
| 199
| 10
| 0.388889
| 0.166667
| 0.4
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.065327
| 199
| 3
| 71
| 66.333333
| 0.967742
| 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
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
acb42a316b9d031ee1f195d9903c63cfbff089cb
| 27
|
py
|
Python
|
UnityPython.BackEnd/TestModules/__init__.py
|
thautwarm/Traffy.UnityPython
|
2133db6df44d70e766b51a32bbe949d3deb84dc1
|
[
"MIT"
] | 29
|
2022-02-21T01:48:23.000Z
|
2022-03-31T11:01:14.000Z
|
UnityPython.BackEnd/TestModules/__init__.py
|
thautwarm/Traffy.UnityPython
|
2133db6df44d70e766b51a32bbe949d3deb84dc1
|
[
"MIT"
] | 25
|
2022-02-20T23:32:06.000Z
|
2022-03-31T05:04:01.000Z
|
UnityPython.BackEnd/TestModules/__init__.py
|
thautwarm/Traffy.UnityPython
|
2133db6df44d70e766b51a32bbe949d3deb84dc1
|
[
"MIT"
] | null | null | null |
from .MyModule import add1
| 13.5
| 26
| 0.814815
| 4
| 27
| 5.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.043478
| 0.148148
| 27
| 1
| 27
| 27
| 0.913043
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
acc9a5ca62143cb045acabaf7f536eedc5bdf35b
| 137
|
py
|
Python
|
FingerSpell/Home_Register/views.py
|
sid-146/FingerSpell
|
52631df5d24a485210ce92e677891d9fa9fdd503
|
[
"MIT"
] | null | null | null |
FingerSpell/Home_Register/views.py
|
sid-146/FingerSpell
|
52631df5d24a485210ce92e677891d9fa9fdd503
|
[
"MIT"
] | null | null | null |
FingerSpell/Home_Register/views.py
|
sid-146/FingerSpell
|
52631df5d24a485210ce92e677891d9fa9fdd503
|
[
"MIT"
] | null | null | null |
from django.shortcuts import render
# from
# Create your views here.
def home(request):
return render(request, "Fingerspell.html")
| 17.125
| 46
| 0.744526
| 18
| 137
| 5.666667
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.160584
| 137
| 7
| 47
| 19.571429
| 0.886957
| 0.20438
| 0
| 0
| 0
| 0
| 0.150943
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.333333
| 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
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
ace37de63471ad7ad0a8b9c8cd46e72f1fe6e8e7
| 5,561
|
py
|
Python
|
cifra/tests/test_launcher.py
|
dante-signal31/cifra
|
3914822ec49cd238fe31fd58424fa2b058116b9a
|
[
"BSD-3-Clause"
] | null | null | null |
cifra/tests/test_launcher.py
|
dante-signal31/cifra
|
3914822ec49cd238fe31fd58424fa2b058116b9a
|
[
"BSD-3-Clause"
] | null | null | null |
cifra/tests/test_launcher.py
|
dante-signal31/cifra
|
3914822ec49cd238fe31fd58424fa2b058116b9a
|
[
"BSD-3-Clause"
] | null | null | null |
"""
Tests for some launcher commands.
"""
import pytest
import os.path
import tempfile
from test_common.fs.temp import temp_dir
import cifra.cifra_launcher as cifra_launcher
import cifra.cipher.substitution as substitution
from cifra.tests.test_dictionaries import loaded_dictionaries, LoadedDictionaries
from cifra.tests.test_caesar import ORIGINAL_MESSAGE as caesar_ORIGINAL_MESSAGE
from cifra.tests.test_caesar import CIPHERED_MESSAGE_KEY_13 as caesar_CIPHERED_MESSAGE_KEY_13
from cifra.tests.test_caesar import TEST_KEY as caesar_TEST_KEY
from cifra.tests.test_substitution import ORIGINAL_MESSAGE as substitution_ORIGINAL_MESSAGE
from cifra.tests.test_substitution import CIPHERED_MESSAGE as substitution_CIPHERED_MESSAGE
from cifra.tests.test_substitution import TEST_KEY as substitution_TEST_KEY
from cifra.tests.test_substitution import TEST_CHARSET as substitution_TEST_CHARSET
@pytest.mark.quick_slow
def test_cipher_caesar(temp_dir, loaded_dictionaries: LoadedDictionaries):
with tempfile.NamedTemporaryFile(mode="w") as message_file:
message_file.write(caesar_ORIGINAL_MESSAGE)
message_file.flush()
output_file_pathname = os.path.join(temp_dir, "ciphered_message.txt")
provided_args = f"cipher caesar {caesar_TEST_KEY} {message_file.name} --ciphered_file {output_file_pathname}".split()
cifra_launcher.main(provided_args, loaded_dictionaries.temp_dir)
with open(output_file_pathname, mode="r") as output_file:
recovered_content = output_file.read()
assert caesar_CIPHERED_MESSAGE_KEY_13 == recovered_content
@pytest.mark.quick_slow
def test_decipher_caesar(temp_dir, loaded_dictionaries: LoadedDictionaries):
with tempfile.NamedTemporaryFile(mode="w") as message_file:
message_file.write(caesar_CIPHERED_MESSAGE_KEY_13)
message_file.flush()
output_file_pathname = os.path.join(temp_dir, "deciphered_message.txt")
provided_args = f"decipher caesar {caesar_TEST_KEY} {message_file.name} --deciphered_file {output_file_pathname}".split()
cifra_launcher.main(provided_args, loaded_dictionaries.temp_dir)
with open(output_file_pathname, mode="r") as output_file:
recovered_content = output_file.read()
assert caesar_ORIGINAL_MESSAGE == recovered_content
@pytest.mark.quick_slow
def test_cipher_substitution(temp_dir, loaded_dictionaries: LoadedDictionaries):
with tempfile.NamedTemporaryFile(mode="w") as message_file:
message_file.write(substitution_ORIGINAL_MESSAGE)
message_file.flush()
output_file_pathname = os.path.join(temp_dir, "ciphered_message.txt")
provided_args = f"cipher substitution {substitution_TEST_KEY} {message_file.name} --ciphered_file {output_file_pathname} --charset {substitution_TEST_CHARSET}".split()
cifra_launcher.main(provided_args, loaded_dictionaries.temp_dir)
with open(output_file_pathname, mode="r") as output_file:
recovered_content = output_file.read()
assert substitution_CIPHERED_MESSAGE == recovered_content
@pytest.mark.quick_slow
def test_decipher_substitution(temp_dir, loaded_dictionaries: LoadedDictionaries):
with tempfile.NamedTemporaryFile(mode="w") as message_file:
message_file.write(substitution_CIPHERED_MESSAGE)
message_file.flush()
output_file_pathname = os.path.join(temp_dir, "deciphered_message.txt")
provided_args = f"decipher substitution {substitution_TEST_KEY} {message_file.name} --deciphered_file {output_file_pathname} --charset {substitution_TEST_CHARSET}".split()
cifra_launcher.main(provided_args, loaded_dictionaries.temp_dir)
with open(output_file_pathname, mode="r") as output_file:
recovered_content = output_file.read()
assert substitution_ORIGINAL_MESSAGE == recovered_content
@pytest.mark.quick_slow
def test_attack_caesar(temp_dir, loaded_dictionaries: LoadedDictionaries):
with tempfile.NamedTemporaryFile(mode="w") as message_file:
message_file.write(caesar_CIPHERED_MESSAGE_KEY_13)
message_file.flush()
output_file_pathname = os.path.join(temp_dir, "recovered_message.txt")
provided_args = f"attack caesar {message_file.name} --deciphered_file {output_file_pathname}".split()
cifra_launcher.main(provided_args, loaded_dictionaries.temp_dir)
with open(output_file_pathname, mode="r") as output_file:
recovered_content = output_file.read()
assert caesar_ORIGINAL_MESSAGE == recovered_content
@pytest.mark.quick_slow
def test_attack_substitution(temp_dir, loaded_dictionaries: LoadedDictionaries):
with tempfile.NamedTemporaryFile(mode="w") as message_file, \
open(os.path.join(os.getcwd(), "cifra", "tests", "resources/english_book_c1.txt")) as english_book:
original_message = english_book.read()
ciphered_text = substitution.cipher(original_message, substitution_TEST_KEY, substitution_TEST_CHARSET)
message_file.write(ciphered_text)
message_file.flush()
output_file_pathname = os.path.join(temp_dir, "recovered_message.txt")
provided_args = f"attack substitution {message_file.name} --deciphered_file {output_file_pathname} --charset {substitution_TEST_CHARSET}".split()
cifra_launcher.main(provided_args, loaded_dictionaries.temp_dir)
with open(output_file_pathname, mode="r") as output_file:
recovered_content = output_file.read()
assert original_message == recovered_content
| 55.61
| 179
| 0.773782
| 701
| 5,561
| 5.777461
| 0.094151
| 0.074074
| 0.08
| 0.035556
| 0.825185
| 0.813827
| 0.785926
| 0.735556
| 0.714321
| 0.687901
| 0
| 0.002315
| 0.145657
| 5,561
| 99
| 180
| 56.171717
| 0.850137
| 0.005934
| 0
| 0.542169
| 0
| 0
| 0.151658
| 0.067766
| 0
| 0
| 0
| 0
| 0.072289
| 1
| 0.072289
| false
| 0
| 0.168675
| 0
| 0.240964
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
ace84d105bf5458b9f64d0df33dcaa06bff1ae74
| 179
|
py
|
Python
|
src/graph_transpiler/webdnn/backend/webgpu/kernels/sqrt.py
|
urantialife/webdnn
|
dedc5da424288594cdfa605a015ddc7a3afcf2b7
|
[
"MIT"
] | 1
|
2021-04-09T15:55:35.000Z
|
2021-04-09T15:55:35.000Z
|
src/graph_transpiler/webdnn/backend/webgpu/kernels/sqrt.py
|
urantialife/webdnn
|
dedc5da424288594cdfa605a015ddc7a3afcf2b7
|
[
"MIT"
] | null | null | null |
src/graph_transpiler/webdnn/backend/webgpu/kernels/sqrt.py
|
urantialife/webdnn
|
dedc5da424288594cdfa605a015ddc7a3afcf2b7
|
[
"MIT"
] | null | null | null |
from webdnn.backend.webgpu.kernels.elementwise import register_elementwise_kernel
from webdnn.graph.operators.sqrt import Sqrt
register_elementwise_kernel(Sqrt, "y = sqrt(x0);")
| 35.8
| 81
| 0.837989
| 24
| 179
| 6.083333
| 0.583333
| 0.136986
| 0.342466
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.006024
| 0.072626
| 179
| 4
| 82
| 44.75
| 0.873494
| 0
| 0
| 0
| 0
| 0
| 0.072626
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
c5b52096ca5979ef22c987df3f42a858e050dec9
| 19,126
|
py
|
Python
|
unifonicnextgen/controllers/rest_controller.py
|
masaar/unifonic_python_sdk
|
9346f48a91dabc41aca6acd61961d30f78d2f75b
|
[
"MIT"
] | null | null | null |
unifonicnextgen/controllers/rest_controller.py
|
masaar/unifonic_python_sdk
|
9346f48a91dabc41aca6acd61961d30f78d2f75b
|
[
"MIT"
] | null | null | null |
unifonicnextgen/controllers/rest_controller.py
|
masaar/unifonic_python_sdk
|
9346f48a91dabc41aca6acd61961d30f78d2f75b
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
"""
unifonicnextgen
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from unifonicnextgen.api_helper import APIHelper
from unifonicnextgen.configuration import Configuration
from unifonicnextgen.controllers.base_controller import BaseController
from unifonicnextgen.http.auth.basic_auth import BasicAuth
from unifonicnextgen.models.send_scheduledmessages_response import SendScheduledmessagesResponse
from unifonicnextgen.models.send_response import SendResponse
from unifonicnextgen.models.get_scheduled_message_response import GetScheduledMessageResponse
from unifonicnextgen.models.stop_scheduled_messages_response import StopScheduledMessagesResponse
from unifonicnextgen.models.get_messages_details_response import GetMessagesDetailsResponse
from unifonicnextgen.exceptions.api_exception import APIException
class RestController(BaseController):
"""A Controller to access Endpoints in the unifonicnextgen API."""
def create_send_scheduled_messages(self,
app_sid,
sender_id,
recipient,
body,
time_scheduled,
response_type=None,
correlation_id=None,
base_encode=None):
"""Does a POST request to /rest/SMS/messages/scheduledmessages.
Unifonic Send Scheduled API allows you to schedule text messages to
users around the globe through simple RESTful API to be sent in
future.
Args:
app_sid (string): A character string that uniquely identifies your
app
sender_id (string): The SenderID to send from, App default
SenderID is used unless else stated
recipient (long|int): Destination mobile number, mobile numbers
must be in international format without 00 or + Example:
(4452023498)
body (string): Message body supports both English and unicodes
characters, concatenated messages is supported
time_scheduled (datetime): Schedule send messages, in the
following format yyyy-mm-dd HH:mm:ss
response_type (string, optional): Support json format only
correlation_id (string, optional): Is a unique identifier value
that is attached to requests and messages
base_encode (bool, optional): Binary-to-text encoding schemes that
represent binary data in an ASCII string format
Returns:
SendScheduledmessagesResponse: Response from the API.
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Validate required parameters
self.validate_parameters(app_sid=app_sid,
sender_id=sender_id,
recipient=recipient,
body=body,
time_scheduled=time_scheduled)
# Prepare query URL
_url_path = '/rest/SMS/messages/scheduledmessages'
_query_builder = Configuration.get_base_uri(Configuration.Server.BASE_URL)
_query_builder += _url_path
_query_parameters = {
'AppSid': app_sid,
'SenderID': sender_id,
'Recipient': recipient,
'Body': body,
'TimeScheduled': APIHelper.when_defined(APIHelper.HttpDateTime, time_scheduled),
'responseType': response_type,
'CorrelationID': correlation_id,
'baseEncode': base_encode
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.post(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Authentication failed', _context)
elif _context.response.status_code == 406:
raise APIException('Wrong parameter format', _context)
elif _context.response.status_code == 449:
raise APIException('Message body is empty', _context)
elif _context.response.status_code == 451:
raise APIException('TimeScheduled parameter must indicate time in the future', _context)
elif _context.response.status_code == 480:
raise APIException('This user cannot use specified SenderID', _context)
elif _context.response.status_code == 482:
raise APIException('Invalid dest num', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, SendScheduledmessagesResponse.from_dictionary)
def create_send_message(self,
app_sid,
sender_id,
body,
recipient,
response_type=None,
correlation_id=None,
base_encode=None,
status_callback=None,
_async=False):
"""Does a POST request to /rest/SMS/messages.
Unifonic Send API allows you to send text messages to users around
the globe through simple RESTful APIs
Args:
app_sid (string): A character string that uniquely identifies your
app
sender_id (string): The SenderID to send from, App default
SenderID is used unless else stated
body (string): Message body supports both English and unicodes
characters, concatenated messages is supported
recipient (long|int): Destination mobile number, mobile numbers
must be in international format without 00 or + Example:
(4452023498)
response_type (string, optional): Support json format only
correlation_id (string, optional): Is a unique identifier value
that is attached to requests and messages
base_encode (bool, optional): Binary-to-text encoding schemes that
represent binary data in an ASCII string format
status_callback (string, optional): Filter messages report
according to a specific message status, "Sent", "Queued",
"Rejected" or "Failed
_async (bool, optional): It specifies that the request will be
executed asynchronously as soon as it is sent
Returns:
SendResponse: Response from the API.
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Validate required parameters
self.validate_parameters(app_sid=app_sid,
sender_id=sender_id,
body=body,
recipient=recipient)
# Prepare query URL
_url_path = '/rest/SMS/messages'
_query_builder = Configuration.get_base_uri(Configuration.Server.BASE_URL)
_query_builder += _url_path
_query_parameters = {
'AppSid': app_sid,
'SenderID': sender_id,
'Body': body,
'Recipient': recipient,
'responseType': response_type,
'CorrelationID': correlation_id,
'baseEncode': base_encode,
'statusCallback': status_callback,
'async': _async
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.post(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Authentication failed', _context)
elif _context.response.status_code == 449:
raise APIException('Message body is empty', _context)
elif _context.response.status_code == 480:
raise APIException('This user cannot use specified SenderID', _context)
elif _context.response.status_code == 482:
raise APIException('Invalid dest num', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, SendResponse.from_dictionary)
def get_scheduled_message_details(self,
app_sid):
"""Does a GET request to /rest/SMS/messages/scheduledmessages.
Unifonic Scheduled message details allows you to get details of
scheduled messages through simple RESTful APIs
Args:
app_sid (string): A character string that uniquely identifies your
app
Returns:
GetScheduledMessageResponse: Response from the API.
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Validate required parameters
self.validate_parameters(app_sid=app_sid)
# Prepare query URL
_url_path = '/rest/SMS/messages/scheduledmessages'
_query_builder = Configuration.get_base_uri(Configuration.Server.BASE_URL)
_query_builder += _url_path
_query_parameters = {
'AppSid': app_sid
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.get(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Authentication failed', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, GetScheduledMessageResponse.from_dictionary)
def delete_stop_scheduled_messages(self,
app_sid,
message_id=None,
response_format=None,
base_encode=None):
"""Does a DELETE request to /rest/SMS/messages/scheduledmessages.
Unifonic Stop scheduled messages API allows you to Delete (Stops)
scheduled message,If MessageID is specified only one message is
stopped, Otherwise all messages are stopped through simple RESTful
APIs.
Args:
app_sid (string): A character string that uniquely identifies your
app
message_id (long|int, optional): A unique ID that identifies a
message
response_format (string, optional): support json format only
base_encode (bool, optional): Binary-to-text encoding schemes that
represent binary data in an ASCII string format
Returns:
StopScheduledMessagesResponse: Response from the API.
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Validate required parameters
self.validate_parameters(app_sid=app_sid)
# Prepare query URL
_url_path = '/rest/SMS/messages/scheduledmessages'
_query_builder = Configuration.get_base_uri(Configuration.Server.BASE_URL)
_query_builder += _url_path
_query_parameters = {
'AppSid': app_sid,
'MessageID': message_id,
'responseFormat': response_format,
'baseEncode': base_encode
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.delete(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Authentication failed', _context)
elif _context.response.status_code == 455:
raise APIException('Scheduled message not found for this User', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, StopScheduledMessagesResponse.from_dictionary)
def create_get_message_details(self,
app_sid,
message_id=None,
sender_id=None,
recipient=None,
date_from=None,
date_to=None,
correlation_id=None,
limit=None,
base_encode=None):
"""Does a POST request to /rest/SMS/Messages/GetMessagesDetails.
Unifonic Get message details API allows you to get details of messages
with optional filters,returns paginated messages, next page or
previous page through simple RESTful APIs
Args:
app_sid (string): A character string that uniquely identifies your
app
message_id (long|int, optional): A unique ID that identifies a
message
sender_id (string, optional): The SenderID to send from, App
default SenderID is used unless else stated
recipient (long|int, optional): Destination mobile number, mobile
numbers must be in international format without 00 or +
Example: (4452023498)
date_from (date, optional): The start date for the report time
interval, date format should be yyyy-mm-dd
date_to (date, optional): The end date for the report time
interval, date format should be yyyy-mm-dd
correlation_id (string, optional): Is a unique identifier value
that is attached to requests and messages
limit (long|int, optional): The maximum number of messages
details
base_encode (bool, optional): Binary-to-text encoding schemes that
represent binary data in an ASCII string format
Returns:
GetMessagesDetailsResponse: Response from the API.
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Validate required parameters
self.validate_parameters(app_sid=app_sid)
# Prepare query URL
_url_path = '/rest/SMS/Messages/GetMessagesDetails'
_query_builder = Configuration.get_base_uri(Configuration.Server.BASE_URL)
_query_builder += _url_path
_query_parameters = {
'AppSid': app_sid,
'MessageID': message_id,
'senderID': sender_id,
'Recipient': recipient,
'dateFrom': date_from,
'dateTo': date_to,
'CorrelationID': correlation_id,
'Limit': limit,
'baseEncode': base_encode
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.post(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Authentication failed', _context)
elif _context.response.status_code == 432:
raise APIException('MessageId must be numeric', _context)
elif _context.response.status_code == 599:
raise APIException('Request failed', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, GetMessagesDetailsResponse.from_dictionary)
| 44.273148
| 117
| 0.604883
| 1,894
| 19,126
| 5.897043
| 0.143083
| 0.01343
| 0.030083
| 0.035813
| 0.759513
| 0.746799
| 0.720834
| 0.709822
| 0.703554
| 0.686006
| 0
| 0.00689
| 0.339799
| 19,126
| 431
| 118
| 44.37587
| 0.877643
| 0.365837
| 0
| 0.658416
| 1
| 0
| 0.090542
| 0.013633
| 0
| 0
| 0
| 0
| 0
| 1
| 0.024752
| false
| 0
| 0.049505
| 0
| 0.10396
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
c5d55f51bd925a4016a014431a224b6848dabad2
| 525
|
py
|
Python
|
tests/api_types/__init__.py
|
0xOmarA/RadixLib
|
85d75a47d4c4df4c1a319b74857ae2c513933623
|
[
"MIT"
] | 32
|
2022-01-12T16:52:28.000Z
|
2022-03-24T18:05:47.000Z
|
tests/api_types/__init__.py
|
0xOmarA/RadixLib
|
85d75a47d4c4df4c1a319b74857ae2c513933623
|
[
"MIT"
] | 3
|
2022-01-12T17:01:55.000Z
|
2022-02-12T15:14:16.000Z
|
tests/api_types/__init__.py
|
0xOmarA/RadixLib
|
85d75a47d4c4df4c1a319b74857ae2c513933623
|
[
"MIT"
] | 1
|
2022-01-21T04:28:07.000Z
|
2022-01-21T04:28:07.000Z
|
# type: ignore
from tests.api_types.test_transaction_identifier import TestTransactionIdentifier
from tests.api_types.test_validator_identifier import TestValidatorIdentifier
from tests.api_types.test_account_identifier import TestAccountIdentifier
from tests.api_types.test_network_identifier import TestNetworkIdentifier
from tests.api_types.test_state_identifier import TestStateIdentifier
from tests.api_types.test_token_identifier import TestTokenIdentifier
from tests.api_types.test_token_amount import TestTokenAmount
| 58.333333
| 81
| 0.910476
| 65
| 525
| 7.030769
| 0.353846
| 0.137856
| 0.183807
| 0.260394
| 0.343545
| 0.113786
| 0
| 0
| 0
| 0
| 0
| 0
| 0.059048
| 525
| 9
| 82
| 58.333333
| 0.925101
| 0.022857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
680002cec2d13b358ff7150d0fa0c9d72817c186
| 1,056
|
py
|
Python
|
admin.py
|
wbthomason/cs3240-onedir
|
4bb1e8c2ef258d6f1ee4c2af02f04ceb4850dbdf
|
[
"MIT"
] | null | null | null |
admin.py
|
wbthomason/cs3240-onedir
|
4bb1e8c2ef258d6f1ee4c2af02f04ceb4850dbdf
|
[
"MIT"
] | null | null | null |
admin.py
|
wbthomason/cs3240-onedir
|
4bb1e8c2ef258d6f1ee4c2af02f04ceb4850dbdf
|
[
"MIT"
] | null | null | null |
import requests
def update_user(admin_password, old_email, new_email, new_password, addr):
url = "http://%s:3240/user/admin" % addr
args = {'password': admin_password, 'command': 'change', 'old_email': old_email, 'new_email': new_email, 'new_password': new_password}
requests.post(url, params=args, verify=False)
return True
def remove(admin_password, email, addr):
url = "http://%s:3240/user/admin" % addr
args = {'password': admin_password, 'command': 'remove', 'email': email}
requests.post(url, params=args, verify=False)
return True
def list_users(admin_password, addr):
url = "http://%s:3240/user/admin" % addr
args = {'password': admin_password, 'command': 'users'}
r = requests.post(url, params=args, verify=False)
return r.json()['users']
def list_files(admin_password, email, addr):
url = "http://%s:3240/user/admin" % addr
args = {'password': admin_password, 'command': 'files', 'email': email}
r = requests.post(url, params=args, verify=False)
return r.json()['files']
| 32
| 138
| 0.669508
| 143
| 1,056
| 4.804196
| 0.20979
| 0.151383
| 0.064047
| 0.069869
| 0.791849
| 0.713246
| 0.713246
| 0.713246
| 0.713246
| 0.713246
| 0
| 0.0181
| 0.162879
| 1,056
| 33
| 139
| 32
| 0.75905
| 0
| 0
| 0.47619
| 0
| 0
| 0.219489
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.190476
| false
| 0.380952
| 0.047619
| 0
| 0.428571
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
6811077ebc42011d40c1f9597bd03ce20deaf94c
| 90
|
py
|
Python
|
src/gadget_tools/cli/__init__.py
|
oarodriguez/gadget-tools
|
4ea07bedf45f633a6f92baea517867d96d7a7b75
|
[
"Apache-2.0"
] | null | null | null |
src/gadget_tools/cli/__init__.py
|
oarodriguez/gadget-tools
|
4ea07bedf45f633a6f92baea517867d96d7a7b75
|
[
"Apache-2.0"
] | null | null | null |
src/gadget_tools/cli/__init__.py
|
oarodriguez/gadget-tools
|
4ea07bedf45f633a6f92baea517867d96d7a7b75
|
[
"Apache-2.0"
] | 1
|
2021-08-04T18:43:00.000Z
|
2021-08-04T18:43:00.000Z
|
"""
gadget_tools.cli
Command-Line Interface for Gadget-Tools.
"""
from .main import main
| 12.857143
| 40
| 0.744444
| 13
| 90
| 5.076923
| 0.769231
| 0.333333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.133333
| 90
| 6
| 41
| 15
| 0.846154
| 0.644444
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
a861d8c87f655d3b3466f5eac8df3a8abc200588
| 241
|
py
|
Python
|
src/robustness/imagenet_models/__init__.py
|
nikola3794/robust-models-transfer
|
f5b80eae6d07fdb123c658a7f4fcd2bc26a50f02
|
[
"MIT"
] | null | null | null |
src/robustness/imagenet_models/__init__.py
|
nikola3794/robust-models-transfer
|
f5b80eae6d07fdb123c658a7f4fcd2bc26a50f02
|
[
"MIT"
] | null | null | null |
src/robustness/imagenet_models/__init__.py
|
nikola3794/robust-models-transfer
|
f5b80eae6d07fdb123c658a7f4fcd2bc26a50f02
|
[
"MIT"
] | null | null | null |
from .resnet import *
from .densenet import *
from .vgg import *
from .leaky_resnet import *
from .alexnet import *
from .squeezenet import *
from .vision_transformer_rnd_per_dim import *
from .vision_transformer_rnd_per_dim_fmap_i import *
| 26.777778
| 52
| 0.80083
| 35
| 241
| 5.2
| 0.428571
| 0.384615
| 0.175824
| 0.296703
| 0.395604
| 0.395604
| 0.395604
| 0
| 0
| 0
| 0
| 0
| 0.13278
| 241
| 8
| 53
| 30.125
| 0.870813
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
a87ec2125e4b328026a15e0f75b75ba85b9822c4
| 5,376
|
py
|
Python
|
src/python/test/test_knn.py
|
m0baxter/gudhi-devel
|
6e14ef1f31e09f3875316440303450ff870d9881
|
[
"MIT"
] | 146
|
2019-03-15T14:10:31.000Z
|
2022-03-23T21:14:52.000Z
|
src/python/test/test_knn.py
|
m0baxter/gudhi-devel
|
6e14ef1f31e09f3875316440303450ff870d9881
|
[
"MIT"
] | 398
|
2019-03-07T14:55:22.000Z
|
2022-03-31T14:50:40.000Z
|
src/python/test/test_knn.py
|
m0baxter/gudhi-devel
|
6e14ef1f31e09f3875316440303450ff870d9881
|
[
"MIT"
] | 51
|
2019-03-08T15:58:48.000Z
|
2022-03-14T10:23:23.000Z
|
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
Author(s): Marc Glisse
Copyright (C) 2020 Inria
Modification(s):
- YYYY/MM Author: Description of the modification
"""
from gudhi.point_cloud.knn import KNearestNeighbors
import numpy as np
import pytest
def test_knn_explicit():
base = np.array([[1.0, 1], [1, 2], [4, 2], [4, 3]])
query = np.array([[1.0, 1], [2, 2], [4, 4]])
knn = KNearestNeighbors(2, metric="manhattan", return_distance=True, return_index=True)
knn.fit(base)
r = knn.transform(query)
assert r[0] == pytest.approx(np.array([[0, 1], [1, 0], [3, 2]]))
assert r[1] == pytest.approx(np.array([[0.0, 1], [1, 2], [1, 2]]))
knn = KNearestNeighbors(2, metric="chebyshev", return_distance=True, return_index=False)
knn.fit(base)
r = knn.transform(query)
assert r == pytest.approx(np.array([[0.0, 1], [1, 1], [1, 2]]))
r = (
KNearestNeighbors(2, metric="chebyshev", return_distance=True, return_index=False, implementation="keops")
.fit(base)
.transform(query)
)
assert r == pytest.approx(np.array([[0.0, 1], [1, 1], [1, 2]]))
r = (
KNearestNeighbors(2, metric="chebyshev", return_distance=True, return_index=False, implementation="keops", enable_autodiff=True)
.fit(base)
.transform(query)
)
assert r == pytest.approx(np.array([[0.0, 1], [1, 1], [1, 2]]))
knn = KNearestNeighbors(2, metric="minkowski", p=3, return_distance=False, return_index=True)
knn.fit(base)
r = knn.transform(query)
assert np.array_equal(r, [[0, 1], [1, 0], [3, 2]])
r = (
KNearestNeighbors(2, metric="minkowski", p=3, return_distance=False, return_index=True, implementation="keops")
.fit(base)
.transform(query)
)
assert np.array_equal(r, [[0, 1], [1, 0], [3, 2]])
dist = np.array([[0.0, 3, 8], [1, 0, 5], [1, 2, 0]])
knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=False)
r = knn.fit_transform(dist)
assert np.array_equal(r, [[0, 1], [1, 0], [2, 0]])
knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=True, sort_results=True)
r = knn.fit_transform(dist)
assert np.array_equal(r[0], [[0, 1], [1, 0], [2, 0]])
assert np.array_equal(r[1], [[0, 3], [0, 1], [0, 1]])
# Second time in parallel
knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=False, n_jobs=2, sort_results=True)
r = knn.fit_transform(dist)
assert np.array_equal(r, [[0, 1], [1, 0], [2, 0]])
knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=True, n_jobs=2)
r = knn.fit_transform(dist)
assert np.array_equal(r[0], [[0, 1], [1, 0], [2, 0]])
assert np.array_equal(r[1], [[0, 3], [0, 1], [0, 1]])
def test_knn_compare():
base = np.array([[1.0, 1], [1, 2], [4, 2], [4, 3]])
query = np.array([[1.0, 1], [2, 2], [4, 4]])
r0 = (
KNearestNeighbors(2, implementation="ckdtree", return_index=True, return_distance=False)
.fit(base)
.transform(query)
)
r1 = (
KNearestNeighbors(2, implementation="sklearn", return_index=True, return_distance=False)
.fit(base)
.transform(query)
)
r2 = (
KNearestNeighbors(2, implementation="hnsw", return_index=True, return_distance=False).fit(base).transform(query)
)
r3 = (
KNearestNeighbors(2, implementation="keops", return_index=True, return_distance=False)
.fit(base)
.transform(query)
)
assert np.array_equal(r0, r1) and np.array_equal(r0, r2) and np.array_equal(r0, r3)
r0 = (
KNearestNeighbors(2, implementation="ckdtree", return_index=True, return_distance=True)
.fit(base)
.transform(query)
)
r1 = (
KNearestNeighbors(2, implementation="sklearn", return_index=True, return_distance=True)
.fit(base)
.transform(query)
)
r2 = KNearestNeighbors(2, implementation="hnsw", return_index=True, return_distance=True).fit(base).transform(query)
r3 = (
KNearestNeighbors(2, implementation="keops", return_index=True, return_distance=True).fit(base).transform(query)
)
assert np.array_equal(r0[0], r1[0]) and np.array_equal(r0[0], r2[0]) and np.array_equal(r0[0], r3[0])
d0 = pytest.approx(r0[1])
assert r1[1] == d0 and r2[1] == d0 and r3[1] == d0
def test_knn_nop():
# This doesn't look super useful...
p = np.array([[0.0]])
assert None is KNearestNeighbors(
k=1, return_index=False, return_distance=False, implementation="sklearn"
).fit_transform(p)
assert None is KNearestNeighbors(
k=1, return_index=False, return_distance=False, implementation="ckdtree"
).fit_transform(p)
assert None is KNearestNeighbors(
k=1, return_index=False, return_distance=False, implementation="hnsw", ef=5
).fit_transform(p)
assert None is KNearestNeighbors(
k=1, return_index=False, return_distance=False, implementation="keops"
).fit_transform(p)
assert None is KNearestNeighbors(
k=1, return_index=False, return_distance=False, metric="precomputed"
).fit_transform(p)
| 41.038168
| 136
| 0.635603
| 758
| 5,376
| 4.401055
| 0.141161
| 0.052458
| 0.067446
| 0.07554
| 0.818345
| 0.796463
| 0.791067
| 0.773981
| 0.764988
| 0.748501
| 0
| 0.04689
| 0.198661
| 5,376
| 130
| 137
| 41.353846
| 0.727484
| 0.067894
| 0
| 0.555556
| 0
| 0
| 0.038739
| 0
| 0
| 0
| 0
| 0
| 0.194444
| 1
| 0.027778
| false
| 0
| 0.027778
| 0
| 0.055556
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
a88e6b174ad81f2000e705788168ab012ecf7536
| 36
|
py
|
Python
|
balance/api/views.py
|
rockyfire/Django-China-API
|
e9c2fa9e40fd3aa3c27367e9ef7ac48d612a09a9
|
[
"MIT"
] | 187
|
2018-03-08T11:18:11.000Z
|
2021-12-26T13:29:02.000Z
|
src/apps/api/views.py
|
Flaiers/django-template
|
4d14c1a7426e162d5e413e8f70e16e269cd63f82
|
[
"MIT"
] | 67
|
2018-03-09T14:56:47.000Z
|
2021-06-24T08:52:40.000Z
|
src/apps/api/views.py
|
Flaiers/django-template
|
4d14c1a7426e162d5e413e8f70e16e269cd63f82
|
[
"MIT"
] | 52
|
2018-03-08T11:18:12.000Z
|
2021-08-02T16:07:04.000Z
|
from rest_framework import viewsets
| 18
| 35
| 0.888889
| 5
| 36
| 6.2
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.111111
| 36
| 1
| 36
| 36
| 0.96875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
a897814569153f11797fc922de02ad5e1e6294e4
| 22
|
py
|
Python
|
test/python/LIM2Metrics/py3/base/common/Python010/Python010.py
|
sagodiz/SonarQube-plug-in
|
4f8e111baecc4c9f9eaa5cd3d7ebeb1e365ace2c
|
[
"BSD-4-Clause"
] | 20
|
2015-06-16T17:39:10.000Z
|
2022-03-20T22:39:40.000Z
|
test/python/LIM2Metrics/py3/base/common/Python010/Python010.py
|
sagodiz/SonarQube-plug-in
|
4f8e111baecc4c9f9eaa5cd3d7ebeb1e365ace2c
|
[
"BSD-4-Clause"
] | 29
|
2015-12-29T19:07:22.000Z
|
2022-03-22T10:39:02.000Z
|
test/python/LIM2Metrics/py3/base/common/Python010/Python010.py
|
sagodiz/SonarQube-plug-in
|
4f8e111baecc4c9f9eaa5cd3d7ebeb1e365ace2c
|
[
"BSD-4-Clause"
] | 12
|
2015-08-28T01:22:18.000Z
|
2021-09-25T08:17:31.000Z
|
import math as valami
| 11
| 21
| 0.818182
| 4
| 22
| 4.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.181818
| 22
| 1
| 22
| 22
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
a89d42c5b29770d03399371f1ca4247a55c6795b
| 360
|
py
|
Python
|
ramda/apply_to_test.py
|
jakobkolb/ramda.py
|
982b2172f4bb95b9a5b09eff8077362d6f2f0920
|
[
"MIT"
] | 56
|
2018-08-06T08:44:58.000Z
|
2022-03-17T09:49:03.000Z
|
ramda/apply_to_test.py
|
jakobkolb/ramda.py
|
982b2172f4bb95b9a5b09eff8077362d6f2f0920
|
[
"MIT"
] | 28
|
2019-06-17T11:09:52.000Z
|
2022-02-18T16:59:21.000Z
|
ramda/apply_to_test.py
|
jakobkolb/ramda.py
|
982b2172f4bb95b9a5b09eff8077362d6f2f0920
|
[
"MIT"
] | 5
|
2019-09-18T09:24:38.000Z
|
2021-07-21T08:40:23.000Z
|
from .apply_to import apply_to
from .identity import identity
from .add import add
from ramda.private.asserts import assert_equal
def apply_nocurry_test():
assert_equal(apply_to(42, identity), 42)
assert_equal(apply_to(42, add(1)), 43)
def apply_curry_test():
assert_equal(apply_to(42)(identity), 42)
assert_equal(apply_to(42)(add(1)), 43)
| 24
| 46
| 0.747222
| 59
| 360
| 4.305085
| 0.305085
| 0.165354
| 0.251969
| 0.283465
| 0.472441
| 0.472441
| 0.472441
| 0.472441
| 0.472441
| 0.472441
| 0
| 0.058065
| 0.138889
| 360
| 14
| 47
| 25.714286
| 0.76129
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.5
| 1
| 0.2
| true
| 0
| 0.4
| 0
| 0.6
| 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
| 1
| 0
| 1
| 0
|
0
| 6
|
764ef9ee587a8bd23c45b6214f90b89c35f564d1
| 103,451
|
py
|
Python
|
test/functional/feature_alerts_instant.py
|
lunatechza/bitcoinvault
|
3110c208b1946ee5f689e469e58f80926282b0f2
|
[
"MIT"
] | null | null | null |
test/functional/feature_alerts_instant.py
|
lunatechza/bitcoinvault
|
3110c208b1946ee5f689e469e58f80926282b0f2
|
[
"MIT"
] | null | null | null |
test/functional/feature_alerts_instant.py
|
lunatechza/bitcoinvault
|
3110c208b1946ee5f689e469e58f80926282b0f2
|
[
"MIT"
] | null | null | null |
#!/usr/bin/env python3
# Copyright (c) 2016-2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the Alerts changeover logic."""
import os
import shutil
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException
from test_framework.util import get_datadir_path, hex_str_to_bytes
from test_framework.address import key_to_p2pkh
def introduce_and_reset_blockchain(func):
def func_wrapper(self):
self.reset_blockchain()
self.log.info(func.__name__.replace('_',' '))
return func(self)
return func_wrapper
class AlertsInstantTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
self.extra_args = [
[
"-reindex",
"-txindex",
],
[
"-reindex",
"-txindex",
],
[
"-reindex",
"-txindex",
],
]
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def find_address(self, listreceivedbyaddress, address):
for addr in listreceivedbyaddress:
if addr['address'] == address: return addr
def find_vout_n(self, rawtransaction, amount):
for vout in rawtransaction['vout']:
if vout['value'] == amount: return vout['n']
def sum_vouts_value(self, rawtransaction):
return sum(vout['value'] for vout in rawtransaction['vout'])
def reset_blockchain(self):
self.stop_nodes(wait=1)
for i in range(self.num_nodes):
datadir = get_datadir_path(self.options.tmpdir, i)
if os.path.exists(datadir):
shutil.rmtree(datadir)
os.mkdir(datadir)
self.nodes = []
self.setup_chain()
self.start_nodes(extra_args=self.extra_args)
self.setup_network()
self.sync_all()
def reset_node(self, i):
self.stop_node(i, wait=1)
datadir = get_datadir_path(self.options.tmpdir, i)
if os.path.exists(datadir):
shutil.rmtree(datadir)
os.mkdir(datadir)
self.start_node(i, extra_args=self.extra_args)
def run_test(self):
self.alert_recovery_pubkey = "02ecec100acb89f3049285ae01e7f03fb469e6b54d44b0f3c8240b1958e893cb8c"
self.alert_recovery_privkey = "cRfYLWua6WcpGbxuv5rJgA2eDESWxqgzmQjKQuqDFMfgbnEpqhrP"
self.alert_instant_pubkey = "0263451a52f3d3ae6918969e1c5ce934743185578481ef8130336ad1726ba61ddb"
self.alert_instant_privkey = "cN1XR72dusJgxpkT2AwENtTviskB96iB2Q6FTvAxqi24fT9DQZiR"
self.COINBASE_MATURITY = 100
self.COINBASE_AMOUNT = Decimal(175)
self.test_alert_tx_generate_transactions_and_filter_them_by_label()
self.test_alert_tx_generate_transactions_with_invalid_address_type()
self.test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_wallet_comments()
self.test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_replaceable_yes()
self.test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_conf_target_range_only()
self.test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_estimate_mode_check_only()
self.test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_replaceable_no()
self.reset_blockchain()
self.log.info("Test alert tx change is by default sent back to the sender")
self.test_alert_tx_change_is_by_default_sent_back_to_the_sender()
self.reset_blockchain()
self.log.info("Test instant tx change is by default sent back to the sender")
self.test_instant_tx_change_is_by_default_sent_back_to_the_sender()
self.reset_blockchain()
self.log.info("Test sendinstanttoaddress selects coins on instant addresses only")
self.test_sendinstanttoaddress_selects_coins_on_instant_addresses_only()
self.test_sendinstanttoaddress_selects_coins_on_instant_addresses_only_with_label()
self.test_sendinstanttoaddress_selects_coins_on_instant_addresses_only_differnet_addr_type()
self.reset_blockchain()
self.log.info("Test sendinstanttoaddress with multiple instant addresses")
self.test_sendinstanttoaddress_with_multiple_instant_addresses()
self.reset_blockchain()
self.log.info("Test sendinstanttoaddress fails when no coins available on instant addresses")
self.test_sendinstanttoaddress_fails_when_no_coins_available_on_instant_addresses()
self.reset_blockchain()
self.log.info("Test sendalerttoaddress selects coins on instant addresses only")
self.test_sendalerttoaddress_selects_coins_on_instant_addresses_only()
self.reset_blockchain()
self.log.info("Test sendalerttoaddress selects coins on instant and alert addresses only")
self.test_sendalerttoaddress_selects_coins_on_instant_and_alert_addresses_only()
self.reset_blockchain()
self.log.info("Test sendtoaddress fails when no coins available on regular addresses")
self.test_sendtoaddress_fails_when_no_coins_available_on_regular_addresses()
self.reset_blockchain()
self.log.info("Test sendtoaddress selects coins on regular addresses only")
self.test_sendtoaddress_selects_coins_on_regular_addresses_only()
self.reset_blockchain()
self.log.info("Test signalerttransaction when both instant and recovery keys imported")
self.test_signalerttransaction_when_both_recovery_and_instant_keys_imported()
self.reset_blockchain()
self.log.info("Test standard signalerttransaction flow")
self.test_signalerttransaction()
self.reset_blockchain()
self.log.info("Test standard signinstanttransaction flow")
self.test_signinstanttransaction()
self.reset_blockchain()
self.log.info("Test signinstanttransaction when instant key imported")
self.test_signinstanttransaction_when_instant_key_imported()
self.reset_blockchain()
self.log.info("Test signinstanttransaction when both instant and recovery keys imported")
self.test_signinstanttransaction_when_both_instant_and_recovery_keys_imported()
self.reset_blockchain()
self.log.info("Test signinstanttransaction is incomplete and rejected when missing key")
self.test_signinstanttransaction_is_incomplete_and_rejected_when_missing_key()
self.reset_blockchain()
self.log.info("Test signinstanttransaction when recovery key imported")
self.test_signinstanttransaction_when_recovery_key_imported()
self.reset_blockchain()
self.log.info("Test signinstanttransaction when all keys given")
self.test_signinstanttransaction_when_all_keys_given()
self.reset_blockchain()
self.log.info("Test recovery tx is incomplete and rejected when missing recovery key")
self.test_recovery_tx_is_incomplete_and_rejected_when_missing_recovery_key()
self.reset_blockchain()
self.log.info("Test recovery tx is incomplete and rejected when missing instant key")
self.test_recovery_tx_is_incomplete_and_rejected_when_missing_instant_key()
self.reset_blockchain()
self.log.info("Test recovery tx when all keys imported")
self.test_recovery_tx_when_all_keys_imported()
self.reset_blockchain()
self.log.info("Test recovery tx is rejected when missing both instant and recovery keys")
self.test_recovery_tx_is_rejected_when_missing_both_instant_and_recovery_keys()
self.reset_blockchain()
self.log.info("Test recovery tx is rejected when only recovery key imported")
self.test_recovery_tx_is_rejected_when_only_recovery_key_imported()
self.reset_blockchain()
self.log.info("Test recovery tx is rejected when only instant key imported")
self.test_recovery_tx_is_rejected_when_only_instant_key_imported()
self.reset_blockchain()
self.log.info("Test recovery tx when instant key imported and recovery key given")
self.test_recovery_tx_when_instant_key_imported_and_recovery_key_given()
self.reset_blockchain()
self.log.info("Test recovery tx when recovery key imported and instant key given")
self.test_recovery_tx_when_recovery_key_imported_and_instant_key_given()
self.test_recovery_tx_when_recovery_key_imported_and_instant_key_given_replaceable_no()
self.test_recovery_tx_when_recovery_key_imported_and_instant_key_given_locktime()
self.test_recovery_tx_when_recovery_key_imported_and_instant_key_given_sighashtype()
self.reset_blockchain()
self.log.info("Test recovery tx when both instant and recovery keys given")
self.test_recovery_tx_when_both_instant_and_recovery_keys_given()
self.reset_blockchain()
self.log.info("Test dumpwallet / importwallet with instant address")
self.test_dumpwallet()
self.reset_blockchain()
self.log.info("Test atx from imported instant address")
self.test_atx_from_imported_instant_address()
self.reset_blockchain()
self.log.info("Test getaddressinfo on instant address")
self.test_getaddressinfo_on_instant_address()
self.reset_blockchain()
self.log.info("Test getaddressinfo on imported instant address")
self.test_getaddressinfo_on_imported_instant_address()
self.reset_blockchain()
self.log.info("Test add watch-only instant address")
self.test_add_watchonly_instant_address()
self.reset_blockchain()
self.log.info("Test import instant address privkey")
self.test_import_instant_address_privkey()
self.reset_blockchain()
self.log.info("Test signrawtransactionwithwallet should reject alert transaction")
self.test_signrawtransactionwithwallet_should_reject_alert_transaction()
self.reset_blockchain()
self.log.info("Test signrawtransactionwithwallet should reject instant transaction")
self.test_signrawtransactionwithwallet_should_reject_instant_transaction()
self.reset_blockchain()
self.log.info("Test sign atx with recovery key")
self.test_sign_atx_with_recovery_key()
self.reset_blockchain()
self.log.info("Test tx from normal address to instant address")
self.test_tx_from_normal_addr_to_instant_addr()
self.reset_blockchain()
self.log.info("Test atx from instant address to normal address")
self.test_atx_from_instant_addr_to_normal_addr()
self.test_atx_with_multiple_inputs_from_alert_addr_to_normal_addr_invalid_address_type()
self.reset_blockchain()
self.log.info("Test atx with multiple inputs from alert address to normal address")
self.test_atx_with_multiple_inputs_from_alert_addr_to_normal_addr()
self.reset_blockchain()
self.log.info("Test atx becomes tx after 144 blocks")
self.test_atx_becomes_tx()
self.reset_blockchain()
self.log.info("Test atx fee is paid to original miner")
self.test_atx_fee_is_paid_to_original_miner()
self.reset_blockchain()
self.log.info("Test atx with inputs of different source")
self.test_atx_with_inputs_of_different_source()
self.reset_blockchain()
self.log.info("Test atx is rejected by wallet when contains non-alert type inputs")
self.test_atx_is_rejected_by_wallet_when_contains_non_alert_inputs()
self.reset_blockchain()
self.log.info("Test atx signed by signrawtransactionwithkey with inputs of different source")
self.test_atx_signed_by_signrawtransactionwithkey_with_inputs_of_different_source()
self.reset_blockchain()
self.log.info("Test atx is rejected by signrawtransactionwithkey when contains non-alert type inputs")
self.test_atx_is_rejected_by_signrawtransactionwithkey_when_contains_non_alert_inputs()
self.reset_blockchain()
self.log.info("Test atx is rejected by node when inputs are spent")
self.test_atx_is_rejected_by_node_when_inputs_are_spent()
self.reset_blockchain()
self.log.info("Test atx is rejected by node when inputs are spent by parallel atx")
self.test_atx_is_rejected_by_node_when_inputs_are_spent_by_parallel_atx()
self.reset_blockchain()
self.log.info("Test standard recovery transaction flow")
self.test_recovery_tx_flow()
self.reset_blockchain()
self.log.info("Test recovery transaction flow for two alerts")
self.test_recovery_tx_flow_for_two_alerts()
self.reset_blockchain()
self.log.info("Test recovery tx is rejected when alert inputs are missing")
self.test_recovery_tx_is_rejected_when_alert_inputs_are_missing()
self.reset_blockchain()
self.log.info("Test recovery tx is rejected when inputs are non alert")
self.test_recovery_tx_is_rejected_when_inputs_are_non_alert()
self.reset_blockchain()
self.log.info("Test getrawtransaction returns information about unconfirmed atx")
self.test_getrawtransaction_returns_information_about_unconfirmed_atx()
self.test_get_getalertbalance_dummy()
self.test_get_getalertbalance_miniconf()
self.test_get_getalertbalance_include_watchonly() #@TODO not implemented
@introduce_and_reset_blockchain
def test_alert_tx_generate_transactions_and_filter_them_by_label(self):
label = 'This is my super awesome label'
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey, label)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
listaddr = self.nodes[1].listaddressgroupings()
transactions = self.nodes[1].listtransactions(label)
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert alert_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
assert listaddr[0][0][2] == label
assert transactions != None
for transaction in transactions:
assert transaction['label'] == label
@introduce_and_reset_blockchain
def test_alert_tx_generate_transactions_with_invalid_address_type(self):
label = 'This is my super awesome label'
texts = { 'random text': -5 , 'p2sh-segwit': -1, 'bech32': -1 }
cnt = len(texts)
for text in texts:
try:
self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey, label, text)
except JSONRPCException as e:
assert 'Unknown address type' in e.error['message']
assert text in e.error['message']
assert e.error['code'] == texts[text]
cnt -= 1
assert cnt == 2
@introduce_and_reset_blockchain
def test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_wallet_comments(self):
comment = "my comment"
to = "my comment to"
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount, comment, to)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
cnt = 3
transactions = self.nodes[1].listtransactions()
for transaction in transactions:
if transaction['category'] in ['receive', 'send']:
assert transaction['comment'] == comment
assert transaction['to'] == to
cnt -= 1
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert alert_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
assert cnt == 0
@introduce_and_reset_blockchain
def test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_replaceable_no(self):
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount, '', '', False, False)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
cnt = 10
transactions = self.nodes[1].listtransactions()
for transaction in transactions:
if transaction['bip125-replaceable'] == 'no':
cnt -= 1
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert alert_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
assert cnt == 0
@introduce_and_reset_blockchain
def test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_replaceable_yes(self):
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount, '', '', False, True)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
cnt = 3
transactions = self.nodes[1].listtransactions()
for transaction in transactions:
if transaction['bip125-replaceable'] == 'yes':
cnt -= 1
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert alert_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
assert cnt == 0
@introduce_and_reset_blockchain
def test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_conf_target_range_only(self):
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
conf_targets = [0, 1, 10, 1009, "lubie placki", 1008]
# create atx
amount = 10
cnt = 3
for conf_target in conf_targets:
try:
atxid = self.nodes[1].sendalerttoaddress(addr0, amount, '', '', False, False, conf_target)
except JSONRPCException as e:
cnt -= 1
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert alert_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
assert cnt == 0
@introduce_and_reset_blockchain
def test_alert_tx_change_is_by_default_sent_back_to_the_sender_with_tx_estimate_mode_check_only(self):
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
estimate_mode = [ "UNSET", "ECONOMICAL", "CONSERVATIVE", "WRONG_OPTION" ]
# create atx
amount = 10
try:
atxid = self.nodes[1].sendalerttoaddress(addr0, amount, '', '', False, False, 1, estimate_mode[3])
assert(False)
except JSONRPCException as e:
pass
for i in estimate_mode[:-1]:
self.nodes[1].sendalerttoaddress(addr0, amount, '', '', False, False, 1, i)
def test_alert_tx_change_is_by_default_sent_back_to_the_sender(self):
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert alert_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
def test_instant_tx_change_is_by_default_sent_back_to_the_sender(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to instant_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# create itx
amount = 10
atxid = self.nodes[1].sendinstanttoaddress(addr0, amount, [self.alert_instant_privkey])
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
# assert
assert len(change_vout['scriptPubKey']['addresses']) == 1
assert instant_addr1['address'] == change_vout['scriptPubKey']['addresses'][0]
def test_sendalerttoaddress_selects_coins_on_instant_addresses_only(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
self.nodes[0].generatetoaddress(200, addr0)
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] == instant_addr0['address']]
assert len(coins_to_use) == 200
atxid = self.nodes[0].sendalerttoaddress(other_addr, self.COINBASE_AMOUNT * 200, '', '', True)
atx = self.nodes[0].getrawtransaction(atxid, True)
self.nodes[0].generatetoaddress(1, other_addr)
# assert
self.sync_all()
assert len(atx['vin']) == 200
assert {v['txid']: v['vout'] for v in atx['vin']} == {c['txid']: c['vout'] for c in coins_to_use}
assert atxid in self.nodes[0].getbestblock()['atx']
def test_sendalerttoaddress_selects_coins_on_instant_and_alert_addresses_only(self):
alert_addr0 = self.nodes[0].getnewvaultalertaddress(self.alert_instant_pubkey)
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(100, instant_addr0['address'])
self.nodes[0].generatetoaddress(100, alert_addr0['address'])
self.nodes[0].generatetoaddress(200, addr0)
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] == alert_addr0['address']]
assert len(coins_to_use) == 100
atxid = self.nodes[0].sendalerttoaddress(other_addr, self.COINBASE_AMOUNT * 100, '', '', True)
atx = self.nodes[0].getrawtransaction(atxid, True)
self.nodes[0].generatetoaddress(1, other_addr)
# assert
self.sync_all()
assert len(atx['vin']) == 100
assert {v['txid']: v['vout'] for v in atx['vin']} == {c['txid']: c['vout'] for c in coins_to_use}
assert atxid in self.nodes[0].getbestblock()['atx']
def test_sendinstanttoaddress_selects_coins_on_instant_addresses_only(self):
alert_addr0 = self.nodes[0].getnewvaultalertaddress(self.alert_recovery_pubkey)
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(100, alert_addr0['address'])
self.nodes[0].generatetoaddress(100, instant_addr0['address'])
self.nodes[0].generatetoaddress(200, addr0)
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] == instant_addr0['address']]
assert len(coins_to_use) == 100
txid = self.nodes[0].sendinstanttoaddress(other_addr, self.COINBASE_AMOUNT * 100, [self.alert_instant_privkey], '', '', True)
tx = self.nodes[0].getrawtransaction(txid, True)
self.nodes[0].generatetoaddress(1, other_addr)
# assert
self.sync_all()
assert len(tx['vin']) == 100
assert {v['txid']: v['vout'] for v in tx['vin']} == {c['txid']: c['vout'] for c in coins_to_use}
assert txid in self.nodes[0].getbestblock()['tx']
@introduce_and_reset_blockchain
def test_sendinstanttoaddress_selects_coins_on_instant_addresses_only_with_label(self):
label = "rainy day"
alert_addr0 = self.nodes[0].getnewvaultalertaddress(self.alert_recovery_pubkey, label)
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(100, alert_addr0['address'])
self.nodes[0].generatetoaddress(100, instant_addr0['address'])
self.nodes[0].generatetoaddress(200, addr0)
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] == instant_addr0['address']]
txid = self.nodes[0].sendinstanttoaddress(other_addr, self.COINBASE_AMOUNT * 100, [self.alert_instant_privkey], '', '', True)
tx = self.nodes[0].getrawtransaction(txid, True)
self.nodes[0].generatetoaddress(1, other_addr)
transactions = self.nodes[0].listtransactions(label)
# assert
self.sync_all()
assert len(tx['vin']) == 100
assert {v['txid']: v['vout'] for v in tx['vin']} == {c['txid']: c['vout'] for c in coins_to_use}
assert txid in self.nodes[0].getbestblock()['tx']
assert transactions != None
for transaction in transactions:
assert transaction['label'] == label
@introduce_and_reset_blockchain
def test_sendinstanttoaddress_selects_coins_on_instant_addresses_only_differnet_addr_type(self):
addresss = ['legacy', 'p2sh-segwit', 'bech32', 'invalid']
cnt = 1
for address in addresss:
try:
alert_addr0 = self.nodes[0].getnewvaultalertaddress(self.alert_recovery_pubkey, '', address)
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(100, alert_addr0['address'])
self.nodes[0].generatetoaddress(100, instant_addr0['address'])
self.nodes[0].generatetoaddress(200, addr0)
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] == instant_addr0['address']]
txid = self.nodes[0].sendinstanttoaddress(other_addr, self.COINBASE_AMOUNT * 100, [self.alert_instant_privkey], '', '', True)
tx = self.nodes[0].getrawtransaction(txid, True)
except JSONRPCException as e:
cnt -= 1
assert cnt == 0
def test_sendinstanttoaddress_with_multiple_instant_addresses(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
instant_addr01 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(100, instant_addr01['address'])
self.nodes[0].generatetoaddress(100, instant_addr0['address'])
self.nodes[0].generatetoaddress(200, addr0)
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] in [instant_addr0['address'], instant_addr01['address']]]
assert len(coins_to_use) == 200
txid = self.nodes[0].sendinstanttoaddress(other_addr, self.COINBASE_AMOUNT * 200, [self.alert_instant_privkey], '', '', True)
tx = self.nodes[0].getrawtransaction(txid, True)
self.nodes[0].generatetoaddress(1, other_addr)
# assert
self.sync_all()
assert len(tx['vin']) == 200
assert {v['txid']: v['vout'] for v in tx['vin']} == {c['txid']: c['vout'] for c in coins_to_use}
assert txid in self.nodes[0].getbestblock()['tx']
def test_sendinstanttoaddress_fails_when_no_coins_available_on_instant_addresses(self):
alert_addr0 = self.nodes[0].getnewvaultalertaddress(self.alert_instant_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].importprivkey(self.alert_instant_privkey)
self.nodes[0].generatetoaddress(200, alert_addr0['address']) # coins are available on alert address ...
self.nodes[0].generatetoaddress(200, addr0) # ... and regular address ...
error = None
try:
self.nodes[0].sendinstanttoaddress(other_addr, 10) # ... so this call should fail
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -4
assert 'Insufficient funds' in error['message']
def test_sendtoaddress_fails_when_no_coins_available_on_regular_addresses(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(200, instant_addr0['address']) # coins are available only on instant address ...
error = None
try:
self.nodes[0].sendtoaddress(other_addr, 10) # ... so this call should fail
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -4
assert 'Insufficient funds' in error['message']
def test_sendtoaddress_selects_coins_on_regular_addresses_only(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi'
self.nodes[0].generatetoaddress(200, addr0)
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
coins_to_use = self.nodes[0].listunspent()
coins_to_use = [c for c in coins_to_use if c['address'] == addr0]
assert len(coins_to_use) == 200
txid = self.nodes[0].sendtoaddress(other_addr, self.COINBASE_AMOUNT * 200, '', '', True)
tx = self.nodes[0].getrawtransaction(txid, True)
self.nodes[0].generatetoaddress(1, other_addr)
# assert
self.sync_all()
assert len(tx['vin']) == 200
assert {v['txid']: v['vout'] for v in tx['vin']} == {c['txid']: c['vout'] for c in coins_to_use}
assert txid in self.nodes[0].getbestblock()['tx']
def test_recovery_tx_is_incomplete_and_rejected_when_missing_recovery_key(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_instant_privkey], info['hex'], instant_addr0['redeemScript'])
assert not recoverytx['complete']
error = None
try:
self.nodes[0].sendrawtransaction(recoverytx['hex'])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -26
assert 'non-mandatory-script-verify-flag' in error['message']
def test_recovery_tx_is_rejected_when_missing_both_instant_and_recovery_keys(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
error = None
try:
self.nodes[0].signrecoverytransaction(recoverytx, [], info['hex'], instant_addr0['redeemScript'])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert int(self.nodes[0].getalertbalance('*', 0)) == 17664
assert int(self.nodes[0].getalertbalance('*', 1)) == 17500
assert error['code'] == -5
assert 'Produced invalid transaction type, type vaultrecovery was expected' in error['message']
def test_recovery_tx_is_incomplete_and_rejected_when_missing_instant_key(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_recovery_privkey], info['hex'], instant_addr0['redeemScript'])
assert not recoverytx['complete']
error = None
try:
self.nodes[0].sendrawtransaction(recoverytx['hex'])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -26
assert 'non-mandatory-script-verify-flag' in error['message']
def test_recovery_tx_when_all_keys_imported(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_recovery_privkey)
self.nodes[0].importprivkey(self.alert_instant_privkey)
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [], info['hex'], instant_addr0['redeemScript'])
# assert
self.sync_all()
assert recoverytx is not None
assert recoverytx != ''
def test_recovery_tx_is_rejected_when_only_recovery_key_imported(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_recovery_privkey)
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [], instant_addr0['redeemScript'])
self.sync_all()
assert not recoverytx['complete']
assert 'Unable to sign input, zero signature (possibly missing key)' in recoverytx['errors'][0]['error']
def test_recovery_tx_is_rejected_when_only_instant_key_imported(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_instant_privkey)
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [], instant_addr0['redeemScript'])
self.sync_all()
assert not recoverytx['complete']
assert 'Unable to sign input, zero signature (possibly missing key)' in recoverytx['errors'][0]['error']
def test_recovery_tx_when_instant_key_imported_and_recovery_key_given(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_instant_privkey)
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_recovery_privkey], instant_addr0['redeemScript'])
# assert
self.sync_all()
assert recoverytx is not None
assert recoverytx != ''
def test_recovery_tx_when_recovery_key_imported_and_instant_key_given(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_recovery_privkey)
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_instant_privkey], instant_addr0['redeemScript'])
# assert
self.sync_all()
assert recoverytx is not None
assert recoverytx != ''
@introduce_and_reset_blockchain
def test_recovery_tx_when_recovery_key_imported_and_instant_key_given_replaceable_no(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_recovery_privkey)
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_instant_privkey], instant_addr0['redeemScript'])
cnt = 10
transactions = self.nodes[0].listtransactions()
assert transactions != []
for transaction in transactions:
if transaction['bip125-replaceable'] == 'unknown':# valid state due to bip-125 is not used
cnt -= 1
if transaction['bip125-replaceable'] == 'no':
cnt -= 1
self.log.debug("Counter %d" % cnt)
assert cnt == 0
# assert
self.sync_all()
assert recoverytx is not None
assert recoverytx != ''
@introduce_and_reset_blockchain
def test_recovery_tx_when_recovery_key_imported_and_instant_key_given_locktime(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_recovery_privkey)
options = [ -1, 0, 1, 10 , 666, 0xFFFFFFFF , 0xFFFFFFFF+1]
cnt = 2
# recover atx
for i in options:
try:
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}], i)
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_instant_privkey], instant_addr0['redeemScript'])
except JSONRPCException as e:
cnt -= 1
assert cnt == 0
@introduce_and_reset_blockchain
def test_recovery_tx_when_recovery_key_imported_and_instant_key_given_sighashtype(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# import keys into wallet
self.nodes[0].importprivkey(self.alert_recovery_privkey)
sighashtypes = [ "ALL" , "NONE", "SINGLE", "ALL|ANYONECANPAY", "NONE|ANYONECANPAY", "SINGLE|ANYONECANPAY", "XFGH"]
cnt = 6
# recover atx
for sighashtype in sighashtypes:
try:
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_instant_privkey], instant_addr0['redeemScript'], instant_addr0['redeemScript'], sighashtype)
except JSONRPCException as e:
self.log.debug(e)
cnt -= 1
self.log.debug("@TODO counter %d" % cnt)
#assert cnt == 0
def test_recovery_tx_when_both_instant_and_recovery_keys_given(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
addr0 = self.nodes[0].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# send atx and mine block with this atx
atxid = self.nodes[0].sendalerttoaddress(addr1, 10)
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# recover atx
recoverytx = self.nodes[0].createrecoverytransaction(atxid, [{addr0: 174.99}])
recoverytx = self.nodes[0].signrecoverytransaction(recoverytx, [self.alert_instant_privkey, self.alert_recovery_privkey], instant_addr0['redeemScript'])
# assert
self.sync_all()
assert recoverytx is not None
assert recoverytx != ''
def test_dumpwallet(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# get pubkey
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
pubkey = info['embedded']['pubkeys'] if 'embedded' in info else info['pubkeys']
pubkey.remove(self.alert_recovery_pubkey)
pubkey = pubkey[0]
# dump wallet
wallet_path = os.path.join(self.nodes[0].datadir, "wallet.dump")
result = self.nodes[0].dumpwallet(wallet_path)
assert result['filename'] == wallet_path
# import wallet
self.nodes[1].importwallet(wallet_path)
info = self.nodes[1].getaddressinfo(instant_addr0['address'])
# assert
self.sync_all()
assert info['ismine'] is True
assert info['iswatchonly'] is False
if 'embedded' in info: info = info['embedded']
assert sorted(info['pubkeys']) == sorted([pubkey, self.alert_recovery_pubkey, self.alert_instant_pubkey])
def test_add_watchonly_instant_address(self):
instant_addr0 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr0['address'])
# import alert_addr1 to node0 as watch-only
self.nodes[0].importaddress(instant_addr0['redeemScript'], '', True, True)
self.nodes[0].importaddress(info['hex'], '', True, True)
# mine some coins to node2 and send tx to instant_addr0
self.nodes[2].generate(200)
txid = self.nodes[2].sendtoaddress(instant_addr0['address'], 10)
self.nodes[2].generate(1)
# assert
self.sync_all()
receivedbyaddress = self.find_address(self.nodes[0].listreceivedbyaddress(), instant_addr0['address'])
assert self.nodes[0].getinstantbalance() == 0
assert 'involvesWatchonly' in receivedbyaddress
assert receivedbyaddress['involvesWatchonly'] is True
assert receivedbyaddress['amount'] == 10
assert txid in receivedbyaddress['txids']
def test_getaddressinfo_on_instant_address(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
# assert
self.sync_all()
assert info['ismine'] is True
assert info['solvable'] is True
assert info['iswatchonly'] is False
assert info['isscript'] is True
if 'embedded' in info: info = info['embedded']
assert info['script'] == 'vaultinstant'
assert info['sigsrequired'] == 1
assert len(info['pubkeys']) == 3
assert self.alert_recovery_pubkey in info['pubkeys']
assert self.alert_instant_pubkey in info['pubkeys']
def test_getaddressinfo_on_imported_instant_address(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
# import instant_addr0 to node0 as watch-only
self.nodes[1].importaddress(instant_addr0['redeemScript'], '', True, True)
self.nodes[1].importaddress(info['hex'], '', True, True)
info = self.nodes[1].getaddressinfo(instant_addr0['address'])
# assert
self.sync_all()
assert info['ismine'] is False
assert info['solvable'] is True # Whether we know how to spend coins sent to this address, ignoring the possible lack of private keys
assert info['iswatchonly'] is True
assert info['isscript'] is True
if 'embedded' in info: info = info['embedded']
assert info['script'] == 'vaultinstant'
assert info['sigsrequired'] == 1
assert len(info['pubkeys']) == 3
assert self.alert_recovery_pubkey in info['pubkeys']
assert self.alert_instant_pubkey in info['pubkeys']
def test_import_instant_address_privkey(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# get pubkey
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
pubkey = info['embedded']['pubkeys'] if 'embedded' in info else info['pubkeys']
pubkey.remove(self.alert_recovery_pubkey)
pubkey = pubkey[0]
# dump privkey
p2pkh = key_to_p2pkh(pubkey)
privkey = self.nodes[0].dumpprivkey(p2pkh)
# import address and privkey on node1
self.nodes[1].importaddress(instant_addr0['redeemScript'], '', True, True)
self.nodes[1].importaddress(info['hex'], '', True, True)
self.nodes[1].importprivkey(privkey)
info = self.nodes[1].getaddressinfo(instant_addr0['address'])
# assert
self.sync_all()
assert info['ismine'] is True
assert info['iswatchonly'] is False
if 'embedded' in info: info = info['embedded']
assert sorted(info['pubkeys']) == sorted([pubkey, self.alert_recovery_pubkey, self.alert_instant_pubkey])
def test_atx_from_imported_instant_address(self):
# TODO-fork: fails sometimes because of nodes synchronization timing?
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
other_addr = '2N34KyQQj97pAivV59wfTkzksYuPdR2jLfi' # not owned by test nodes
# mine some coins to instant_addr0
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# get pubkey
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
pubkey = info['embedded']['pubkeys'] if 'embedded' in info else info['pubkeys']
pubkey.remove(self.alert_recovery_pubkey)
pubkey = pubkey[0]
# dump privkey
p2pkh = key_to_p2pkh(pubkey)
privkey = self.nodes[0].dumpprivkey(p2pkh)
# import address and privkey on node1
self.nodes[1].importaddress(instant_addr0['redeemScript'], '', True, True)
self.nodes[1].importaddress(info['hex'], '', True, True)
self.nodes[1].importprivkey(privkey)
# send atx from node1 and mine block with this atx
atxid = self.nodes[1].sendalerttoaddress(other_addr, 10)
self.nodes[1].generatetoaddress(1, instant_addr0['address'])
# assert
self.sync_all()
assert atxid is not None
assert atxid != ''
self.sync_all()
assert atxid in self.nodes[1].getbestblock()['atx']
def test_tx_from_normal_addr_to_instant_addr(self):
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to node0
self.nodes[0].generate(200)
# send tx from node0 to instant_addr1 and generate block with this tx
txid = self.nodes[0].sendtoaddress(instant_addr1['address'], 10)
self.nodes[0].generate(1)
# assert
self.sync_all()
assert self.nodes[1].getinstantbalance() == 10
assert txid in self.nodes[0].getbestblock()['tx']
assert txid not in self.nodes[0].getbestblock()['atx']
assert txid in self.find_address(self.nodes[1].listreceivedbyaddress(), instant_addr1['address'])['txids']
def test_atx_from_instant_addr_to_normal_addr(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to instant_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# send atx from instant_addr1 to addr0 and generate block with this atx
atxid = self.nodes[1].sendalerttoaddress(addr0, 10)
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# assert
self.sync_all()
assert self.nodes[0].getbalance() == 0
assert atxid in self.nodes[0].getbestblock()['atx']
# generate more blocks so atx becomes tx
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
txid = atxid
# assert
self.sync_all()
assert self.nodes[0].getbalance() == 10
assert txid in self.find_address(self.nodes[0].listreceivedbyaddress(), addr0)['txids']
@introduce_and_reset_blockchain
def test_atx_with_multiple_inputs_from_alert_addr_to_normal_addr_invalid_address_type(self):
addr0 = self.nodes[0].getnewaddress()
addr0_pubkey = self.nodes[0].getaddressinfo(addr0)['pubkey']
address_types = ["legacy", "p2sh-segwit", "bech32", "invalid"]
cnt = 1
for address_type in address_types:
try:
# mine some coins to alert_addr1
alert_addr1 = self.nodes[1].createvaultinstantaddress(addr0_pubkey, self.alert_instant_pubkey, self.alert_recovery_pubkey, address_type)
self.nodes[1].generatetoaddress(300, alert_addr1['address'])
except JSONRPCException as e:
cnt -= 1
assert cnt == 0
def test_atx_with_multiple_inputs_from_alert_addr_to_normal_addr(self):
addr0 = self.nodes[0].getnewaddress()
addr0_pubkey = self.nodes[0].getaddressinfo(addr0)['pubkey']
addr0_p2pkh = key_to_p2pkh(addr0_pubkey)
addr0_prvkey = self.nodes[0].dumpprivkey(addr0_p2pkh)
# mine some coins to alert_addr1
alert_addr1 = self.nodes[1].createvaultinstantaddress(addr0_pubkey, self.alert_instant_pubkey, self.alert_recovery_pubkey)
self.nodes[1].generatetoaddress(300, alert_addr1['address'])
# import key
self.nodes[1].importprivkey(addr0_prvkey)
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
txtospendhash2 = self.nodes[1].getblockbyheight(60)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
# create atx
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
atxtosend = self.nodes[1].signrawtransactionwithkey(atxtosend, [addr0_prvkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript'], 'amount': 175},
{'txid': txtospendhash2, 'vout': vouttospend2, 'scriptPubKey': txtospend2['vout'][vouttospend2]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript'], 'amount': 175}
])
# send atx
atxid = self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, alert_addr1['address'])
# assert
self.sync_all()
assert atxid in self.nodes[0].getbestblock()['atx']
def test_atx_becomes_tx(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to instant_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# send atx from instant_addr1 to addr0 and generate block with this atx
atxid = self.nodes[1].sendalerttoaddress(addr0, 10)
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# assert
self.sync_all()
assert self.nodes[0].getbalance() == 0
assert atxid in self.nodes[0].getbestblock()['atx']
# generate 144 more blocks
self.nodes[1].generatetoaddress(144, instant_addr1['address'])
txid = atxid
# assert
self.sync_all()
assert self.nodes[0].getbalance() == 10
assert txid in self.nodes[0].getbestblock()['tx']
assert txid in self.find_address(self.nodes[0].listreceivedbyaddress(), addr0)['txids']
def test_signrawtransactionwithwallet_should_reject_alert_transaction(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to instant_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and sign atx from instant_addr1 to addr0
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
error = None
try:
self.nodes[1].signrawtransactionwithwallet(atxtosend, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': instant_addr1['redeemScript'], 'amount': 175}])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -5
assert 'Unable to sign transaction from vault address' in error['message']
def test_signrawtransactionwithwallet_should_reject_instant_transaction(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to instant_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# import instant key
self.nodes[1].importprivkey(self.alert_instant_privkey)
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and sign instant tx from instant_addr1 to addr0
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
error = None
try:
self.nodes[1].signrawtransactionwithwallet(atxtosend, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': instant_addr1['redeemScript'], 'amount': 175}])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -5
assert 'Unable to sign transaction from vault address' in error['message']
def test_sign_atx_with_recovery_key(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to instant_addr1
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and sign atx from instant_addr1 to addr0
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
atxtosend = self.nodes[1].signrawtransactionwithkey(atxtosend, [self.alert_recovery_privkey], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
atxsent = self.nodes[1].decoderawtransaction(atxtosend['hex'])
# broadcast atx and mine block with this atx
self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# assert
self.sync_all()
assert atxsent['txid'] in self.nodes[0].getbestblock()['atx']
def test_signalerttransaction_when_both_recovery_and_instant_keys_imported(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# import key
self.nodes[1].importprivkey(self.alert_recovery_privkey)
self.nodes[1].importprivkey(self.alert_instant_privkey)
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and sign atx from alert_addr1 to addr0
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
atxtosend = self.nodes[1].signalerttransaction(atxtosend, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
atxsent = self.nodes[1].decoderawtransaction(atxtosend['hex'])
# broadcast atx and mine block with this atx
self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# assert
self.sync_all()
assert atxsent['txid'] in self.nodes[0].getbestblock()['atx']
def test_signalerttransaction(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and sign atx from alert_addr1 to addr0
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
atxtosend = self.nodes[1].signalerttransaction(atxtosend, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
atxsent = self.nodes[1].decoderawtransaction(atxtosend['hex'])
# broadcast atx and mine block with this atx
self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# assert
self.sync_all()
assert atxsent['txid'] in self.nodes[0].getbestblock()['atx']
def test_atx_fee_is_paid_to_original_miner(self):
mine_addr = self.nodes[0].getnewaddress()
mine_addr2 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine coins and send 10 to instant_addr0
self.nodes[0].generatetoaddress(200, mine_addr)
amount = 10
self.nodes[0].sendtoaddress(instant_addr1['address'], amount)
self.nodes[0].generatetoaddress(1, mine_addr)
# send coins back by atx and confirm it
self.sync_all()
assert self.nodes[1].getalertbalance() == amount
txid = self.nodes[1].sendalerttoaddress(mine_addr, amount - 1)
tx = self.nodes[1].getrawtransaction(txid, 1)
fee = amount - tx['vout'][0]['value'] - tx['vout'][1]['value']
self.nodes[1].generatetoaddress(1, mine_addr2) # mine to separate address
self.nodes[1].generatetoaddress(144, mine_addr)
# assert
self.sync_all()
coinbase_id = self.nodes[1].getbestblock()['tx'][0]
coinbase = self.nodes[1].getrawtransaction(coinbase_id, 1)
assert coinbase['vout'][1]['value'] == fee
def test_atx_with_inputs_of_different_source(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to instant_addr1
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info1 = self.nodes[1].getaddressinfo(instant_addr1['address'])
self.nodes[1].generatetoaddress(50, instant_addr1['address'])
instant_addr2 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info2 = self.nodes[1].getaddressinfo(instant_addr2['address'])
self.nodes[1].generatetoaddress(50, instant_addr2['address'])
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
txtospendhash2 = self.nodes[1].getblockbyheight(60)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
# create and sign atx from instant_addr1 and instant_addr2 to addr0
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
atxtosend = self.nodes[1].signalerttransaction(atxtosend, [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info1['hex'], 'amount': 175},
{'txid': txtospendhash2, 'vout': vouttospend2, 'scriptPubKey': txtospend2['vout'][vouttospend2]['scriptPubKey']['hex'], 'witnessScript': instant_addr2['redeemScript'], 'redeemScript': info2['hex'], 'amount': 175}
])
atxid = self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
self.sync_all()
assert atxid in self.nodes[0].getbestblock()['atx']
def test_atx_is_rejected_by_wallet_when_contains_non_alert_inputs(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to instant_addr1
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
self.nodes[1].generatetoaddress(50, instant_addr1['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[1].generatetoaddress(50, addr1)
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
txtospendhash2 = self.nodes[1].getblockbyheight(60)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
# create and sign atx from instant_addr1 and alert_addr2 to addr0
txtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
try:
self.nodes[1].signalerttransaction(txtosend, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -5
assert 'Produced invalid transaction type, type vaultalert was expected' in error['message']
def test_atx_signed_by_signrawtransactionwithkey_with_inputs_of_different_source(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to alert_addr1
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
alert_addr2 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
self.nodes[1].generatetoaddress(50, alert_addr1['address'])
self.nodes[1].generatetoaddress(50, alert_addr2['address'])
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
txtospendhash2 = self.nodes[1].getblockbyheight(60)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
# create atx
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
atxtosend = self.nodes[1].signrawtransactionwithkey(atxtosend, [self.alert_instant_privkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript'], 'amount': 175},
{'txid': txtospendhash2, 'vout': vouttospend2, 'scriptPubKey': txtospend2['vout'][vouttospend2]['scriptPubKey']['hex'], 'redeemScript': alert_addr2['redeemScript'], 'amount': 175}
])
atxid = self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, alert_addr1['address'])
self.sync_all()
assert atxid in self.nodes[0].getbestblock()['atx']
def test_atx_is_rejected_by_signrawtransactionwithkey_when_contains_non_alert_inputs(self):
addr0 = self.nodes[1].getnewaddress()
addr1 = self.nodes[1].getnewaddress()
# mine some coins to alert_addr1
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
self.nodes[1].generatetoaddress(50, alert_addr1['address'])
self.nodes[1].generatetoaddress(50, addr1)
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
txtospendhash2 = self.nodes[1].getblockbyheight(60)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
error = ''
try:
self.nodes[1].signrawtransactionwithkey(atxtosend, [self.alert_instant_privkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript'], 'amount': 175},
{'txid': txtospendhash2, 'vout': vouttospend2, 'scriptPubKey': txtospend2['vout'][vouttospend2]['scriptPubKey']['hex'], 'amount': 175}
])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -5
assert 'Produced invalid transaction type, type vaultalert was expected' in error['message']
def test_signinstanttransaction_when_instant_key_imported(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# import instant key
self.nodes[0].importprivkey(self.alert_instant_privkey)
# create, sign and mine instant tx from instant_addr0 to addr1
txtospendhash = self.nodes[0].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[0].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
instant_tx = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr1: 174.99})
instant_tx = self.nodes[0].signinstanttransaction(instant_tx, [], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr0['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
instant_txid = self.nodes[0].sendrawtransaction(instant_tx['hex'])
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# assert
self.sync_all()
assert instant_txid in self.nodes[0].getbestblock()['tx']
assert instant_txid not in self.nodes[0].getbestblock()['atx']
def test_signinstanttransaction_when_recovery_key_imported(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# import recovery key
self.nodes[0].importprivkey(self.alert_recovery_privkey)
# create, sign and mine instant tx from instant_addr0 to addr1
txtospendhash = self.nodes[0].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[0].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
instant_tx = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr1: 174.99})
instant_tx = self.nodes[0].signinstanttransaction(instant_tx, [], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr0['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
instant_txid = self.nodes[0].sendrawtransaction(instant_tx['hex'])
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# assert
self.sync_all()
assert instant_txid in self.nodes[0].getbestblock()['tx']
assert instant_txid not in self.nodes[0].getbestblock()['atx']
def test_signinstanttransaction_when_all_keys_given(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# create, sign and mine instant tx from instant_addr0 to addr1
txtospendhash = self.nodes[0].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[0].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
instant_tx = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr1: 174.99})
instant_tx = self.nodes[0].signinstanttransaction(instant_tx, [self.alert_recovery_privkey, self.alert_instant_privkey], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr0['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
instant_txid = self.nodes[0].sendrawtransaction(instant_tx['hex'])
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# assert
self.sync_all()
assert instant_txid in self.nodes[0].getbestblock()['tx']
assert instant_txid not in self.nodes[0].getbestblock()['atx']
def test_signinstanttransaction_when_both_instant_and_recovery_keys_imported(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# import keys
self.nodes[0].importprivkey(self.alert_instant_privkey)
self.nodes[0].importprivkey(self.alert_recovery_privkey)
# create, sign and mine instant tx from instant_addr0 to addr1
txtospendhash = self.nodes[0].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[0].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
instant_tx = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr1: 174.99})
instant_tx = self.nodes[0].signinstanttransaction(instant_tx, [], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr0['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
instant_txid = self.nodes[0].sendrawtransaction(instant_tx['hex'])
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# assert
self.sync_all()
assert instant_txid in self.nodes[0].getbestblock()['tx']
assert instant_txid not in self.nodes[0].getbestblock()['atx']
def test_signinstanttransaction_is_incomplete_and_rejected_when_missing_key(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# create, sign and mine instant tx from instant_addr0 to addr1
txtospendhash = self.nodes[0].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[0].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
instant_tx = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr1: 174.99})
instant_tx = self.nodes[0].signinstanttransaction(instant_tx, [], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr0['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
assert not instant_tx['complete']
error = None
try:
self.nodes[0].sendrawtransaction(instant_tx['hex'])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -26
assert 'non-mandatory-script-verify-flag' in error['message']
def test_signinstanttransaction(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[0].getaddressinfo(instant_addr0['address'])
addr1 = self.nodes[1].getnewaddress()
self.nodes[0].generatetoaddress(200, instant_addr0['address'])
# create, sign and mine instant tx from instant_addr0 to addr1
txtospendhash = self.nodes[0].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[0].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
instant_tx = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr1: 174.99})
instant_tx = self.nodes[0].signinstanttransaction(instant_tx, [self.alert_instant_privkey], [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr0['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
instant_txid = self.nodes[0].sendrawtransaction(instant_tx['hex'])
self.nodes[0].generatetoaddress(1, instant_addr0['address'])
# assert
self.sync_all()
assert instant_txid in self.nodes[0].getbestblock()['tx']
assert instant_txid not in self.nodes[0].getbestblock()['atx']
def test_atx_is_rejected_by_node_when_inputs_are_spent(self):
addr0 = self.nodes[0].getnewaddress()
addr0_prvkey = self.nodes[0].dumpprivkey(addr0)
addr0_pubkey = self.nodes[0].getaddressinfo(addr0)['pubkey']
addr1 = self.nodes[0].getnewaddress()
addr1_prvkey = self.nodes[0].dumpprivkey(addr1)
addr1_pubkey = self.nodes[0].getaddressinfo(addr1)['pubkey']
# mine some coins to alert_addr1
alert_addr1 = self.nodes[1].createvaultinstantaddress(addr0_pubkey, addr1_pubkey, self.alert_recovery_pubkey)
self.nodes[1].generatetoaddress(150, alert_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and send 1st atx
amount = 174.99
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: amount})
atxtosend = self.nodes[1].signrawtransactionwithkey(atxtosend, [addr0_prvkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript']},
])
self.nodes[1].sendrawtransaction(atxtosend['hex'])
self.nodes[1].generatetoaddress(1, alert_addr1['address'])
self.sync_all()
# create and send 2nd atx
amount = 174.98
atxtosend = self.nodes[0].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: amount})
atxtosend = self.nodes[0].signrawtransactionwithkey(atxtosend, [addr0_prvkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript']},
])
error = ''
try:
self.nodes[0].sendrawtransaction(atxtosend['hex'])
except Exception as e:
error = e.error
assert error['code'] == -26
assert 'bad-txn-inputs-spent' in error['message']
def test_atx_is_rejected_by_node_when_inputs_are_spent_by_parallel_atx(self):
addr0 = self.nodes[0].getnewaddress()
addr0_prvkey = self.nodes[0].dumpprivkey(addr0)
addr0_pubkey = self.nodes[0].getaddressinfo(addr0)['pubkey']
addr1 = self.nodes[0].getnewaddress()
addr1_prvkey = self.nodes[0].dumpprivkey(addr1)
addr1_pubkey = self.nodes[0].getaddressinfo(addr1)['pubkey']
# mine some coins to alert_addr1
alert_addr1 = self.nodes[1].createvaultinstantaddress(addr0_pubkey, addr1_pubkey, self.alert_recovery_pubkey)
self.nodes[1].generatetoaddress(150, alert_addr1['address'])
# find vout to spend
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
# create and send 1st atx
amount = 174.99
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: amount})
atxtosend = self.nodes[1].signrawtransactionwithkey(atxtosend, [addr0_prvkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript'], 'amount': 175},
])
self.nodes[1].sendrawtransaction(atxtosend['hex'])
# create 2nd atx
amount = 174.69
atxtosend = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: amount})
atxtosend = self.nodes[1].signrawtransactionwithkey(atxtosend, [addr0_prvkey], [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'redeemScript': alert_addr1['redeemScript'], 'amount': 175},
])
error = ''
try:
self.nodes[1].sendrawtransaction(atxtosend['hex'])
except Exception as e:
error = e.error
# assert
self.sync_all()
assert error['code'] == -26
assert 'txn-mempool-conflict' in error['message']
def test_recovery_tx_flow(self):
instant_addr0 = self.nodes[0].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
other_addr0 = self.nodes[0].getnewaddress()
attacker_addr1 = self.nodes[1].getnewaddress()
# mine some coins to node0
self.nodes[0].generatetoaddress(200, instant_addr0['address']) # 200
assert self.nodes[0].getinstantbalance() == (200 - self.COINBASE_MATURITY) * self.COINBASE_AMOUNT
# send atx to node1
atx_to_recover = self.nodes[0].sendalerttoaddress(attacker_addr1, 10)
atx_to_recover = self.nodes[0].gettransaction(atx_to_recover)['hex']
atx_to_recover = self.nodes[0].decoderawtransaction(atx_to_recover)
atx_fee = (200 - self.COINBASE_MATURITY) * self.COINBASE_AMOUNT - 10 - self.nodes[0].getalertbalance()
# generate block with atx above
self.nodes[0].generatetoaddress(1, instant_addr0['address']) # 201
# assert
self.sync_all()
assert self.nodes[0].getalertbalance() + 10 < (201 - self.COINBASE_MATURITY) * self.COINBASE_AMOUNT
assert self.nodes[1].getbalance() == 0
assert atx_to_recover['txid'] in self.nodes[0].getbestblock()['atx']
# recover atx
amount_to_recover = sum([vout['value'] for vout in atx_to_recover['vout']])
assert atx_fee == self.COINBASE_AMOUNT - amount_to_recover
recovery_tx = self.nodes[0].createrecoverytransaction(atx_to_recover['txid'], {other_addr0: amount_to_recover})
recovery_tx = self.nodes[0].signrecoverytransaction(recovery_tx, [self.alert_instant_privkey, self.alert_recovery_privkey], instant_addr0['redeemScript'])
recovery_txid = self.nodes[0].sendrawtransaction(recovery_tx['hex'])
self.nodes[0].generatetoaddress(1, instant_addr0['address']) # 202
# assert
self.sync_all()
assert recovery_txid in self.nodes[0].getbestblock()['tx']
assert recovery_txid in self.find_address(self.nodes[0].listreceivedbyaddress(), other_addr0)['txids']
assert self.nodes[0].getbalance() + self.nodes[0].getalertbalance() == (202 - self.COINBASE_MATURITY) * self.COINBASE_AMOUNT - atx_fee
# generate blocks so atx might become tx
self.nodes[0].generatetoaddress(143, instant_addr0['address']) # 345
# assert
self.sync_all()
assert self.nodes[0].getbalance() + self.nodes[0].getalertbalance() == (345 - self.COINBASE_MATURITY) * self.COINBASE_AMOUNT # dont subtract atx_fee because node0 takes it as a block miner
assert atx_to_recover['txid'] not in self.nodes[0].getbestblock()['tx']
assert self.find_address(self.nodes[1].listreceivedbyaddress(), attacker_addr1)['amount'] == 0
assert self.find_address(self.nodes[1].listreceivedbyaddress(), attacker_addr1)['txids'] == []
assert self.find_address(self.nodes[0].listreceivedbyaddress(), other_addr0)['amount'] == self.COINBASE_AMOUNT - atx_fee
assert self.find_address(self.nodes[0].listreceivedbyaddress(), other_addr0)['txids'] == [recovery_txid]
def test_recovery_tx_flow_for_two_alerts(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to instant_addr1
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# create, sign and mine 1st atx from instant_addr1 to addr0
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
tx_alert1 = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
tx_alert1 = self.nodes[1].signalerttransaction(tx_alert1, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
self.nodes[1].sendrawtransaction(tx_alert1['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# create, sign and mine 2nd atx from instant_addr1 to addr0
self.sync_all()
txtospendhash2 = self.nodes[1].getblockbyheight(20)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
tx_alert2 = self.nodes[1].createrawtransaction([{'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 174.99})
tx_alert2 = self.nodes[1].signalerttransaction(tx_alert2, [{'txid': txtospendhash2, 'vout': vouttospend2, 'scriptPubKey': txtospend2['vout'][vouttospend2]['scriptPubKey']['hex'], 'redeemScript': instant_addr1['redeemScript'], 'amount': 175}])
self.nodes[1].sendrawtransaction(tx_alert2['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
self.sync_all()
# create and sign recovery tx spending both alerts inputs
recovery_tx = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
recovery_tx = self.nodes[1].signrecoverytransaction(recovery_tx, [self.alert_instant_privkey, self.alert_recovery_privkey], instant_addr1['redeemScript'])
recovery_txid = self.nodes[1].sendrawtransaction(recovery_tx['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# assert
self.sync_all()
assert recovery_txid in self.nodes[0].getbestblock()['tx']
# generate blocks so atx 1 might become tx
self.nodes[0].generatetoaddress(143, instant_addr1['address'])
assert tx_alert1 not in self.nodes[0].getbestblock()['tx']
# generate blocks so atx 2 might become tx
self.nodes[0].generatetoaddress(1, instant_addr1['address'])
assert tx_alert2 not in self.nodes[0].getbestblock()['tx']
def test_recovery_tx_is_rejected_when_alert_inputs_are_missing(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to instant_addr1
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# create, sign and mine 1st atx from instant_addr1 to addr0
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
txtospendhash2 = self.nodes[1].getblockbyheight(20)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
tx_alert1 = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
tx_alert1 = self.nodes[1].signalerttransaction(tx_alert1, [
{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175},
{'txid': txtospendhash2, 'vout': vouttospend2, 'scriptPubKey': txtospend2['vout'][vouttospend2]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}
])
self.nodes[1].sendrawtransaction(tx_alert1['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# create, sign and mine 2nd atx from instant_addr1 to addr0
self.sync_all()
txtospendhash3 = self.nodes[1].getblockbyheight(30)['tx'][0]
txtospend3 = self.nodes[1].getrawtransaction(txtospendhash3, True)
vouttospend3 = self.find_vout_n(txtospend3, 175)
tx_alert2 = self.nodes[1].createrawtransaction([{'txid': txtospendhash3, 'vout': vouttospend3}], {addr0: 174.99})
tx_alert2 = self.nodes[1].signalerttransaction(tx_alert2, [{'txid': txtospendhash3, 'vout': vouttospend3, 'scriptPubKey': txtospend3['vout'][vouttospend3]['scriptPubKey']['hex'], 'redeemScript': instant_addr1['redeemScript'], 'amount': 175}])
self.nodes[1].sendrawtransaction(tx_alert2['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
self.sync_all()
# create and sign (invalid) recovery tx spending both alerts inputs
recovery_tx = self.nodes[1].createrawtransaction([{'txid': txtospendhash2, 'vout': vouttospend2}, {'txid': txtospendhash3, 'vout': vouttospend3}], {addr0: 349.99})
recovery_tx = self.nodes[1].signrecoverytransaction(recovery_tx, [self.alert_instant_privkey, self.alert_recovery_privkey], instant_addr1['redeemScript'])
# broadcast recovery tx and mine block
self.nodes[1].sendrawtransaction(recovery_tx['hex'])
error = None
try:
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
except Exception as e:
error = e.error
assert error['code'] == -1
assert 'bad-txn-recovery' in error['message']
def test_recovery_tx_is_rejected_when_inputs_are_non_alert(self):
addr0 = self.nodes[0].getnewaddress()
# mine some coins to instant_addr1
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
info = self.nodes[1].getaddressinfo(instant_addr1['address'])
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# create, sign and mine 1st atx from instant_addr1 to addr0
txtospendhash = self.nodes[1].getblockbyheight(10)['tx'][0]
txtospend = self.nodes[1].getrawtransaction(txtospendhash, True)
vouttospend = self.find_vout_n(txtospend, 175)
tx_alert1 = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}], {addr0: 174.99})
tx_alert1 = self.nodes[1].signalerttransaction(tx_alert1, [{'txid': txtospendhash, 'vout': vouttospend, 'scriptPubKey': txtospend['vout'][vouttospend]['scriptPubKey']['hex'], 'witnessScript': instant_addr1['redeemScript'], 'redeemScript': info['hex'], 'amount': 175}])
self.nodes[1].sendrawtransaction(tx_alert1['hex'])
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# create, sign and mine 2nd atx from instant_addr1 to addr0
self.sync_all()
txtospendhash2 = self.nodes[1].getblockbyheight(20)['tx'][0]
txtospend2 = self.nodes[1].getrawtransaction(txtospendhash2, True)
vouttospend2 = self.find_vout_n(txtospend2, 175)
# create and sign (invalid) recovery tx spending both alerts inputs
recovery_tx = self.nodes[1].createrawtransaction([{'txid': txtospendhash, 'vout': vouttospend}, {'txid': txtospendhash2, 'vout': vouttospend2}], {addr0: 349.99})
recovery_tx = self.nodes[1].signrecoverytransaction(recovery_tx, [self.alert_instant_privkey, self.alert_recovery_privkey], instant_addr1['redeemScript'])
# broadcast recovery tx and mine block
error = None
try:
self.nodes[1].sendrawtransaction(recovery_tx['hex'])
except Exception as e:
error = e.error
assert error['code'] == -26
assert 'bad-txn-inputs-not-spent' in error['message']
def test_getrawtransaction_returns_information_about_unconfirmed_atx(self):
addr0 = self.nodes[0].getnewaddress()
instant_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, instant_addr1['address'])
# create atx
atxid = self.nodes[1].sendalerttoaddress(addr0, 10)
self.nodes[1].generatetoaddress(1, instant_addr1['address'])
# getrawtransaction
rawtx = self.nodes[1].getrawtransaction(atxid, True)
# assert
assert rawtx['txid'] == atxid
@introduce_and_reset_blockchain
def test_get_getalertbalance_dummy(self):
label = 'label'
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey, label)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
self.sync_all()
# assert
try:
self.log.debug(self.nodes[1].getalertbalance('label'))
assert False
except JSONRPCException as e:
pass
assert self.nodes[0].getalertbalance() == 0
assert self.nodes[1].getalertbalance() > 17489
@introduce_and_reset_blockchain
def test_get_getalertbalance_miniconf(self):
label = 'label'
addr0 = self.nodes[0].getnewaddress()
alert_addr1 = self.nodes[1].getnewvaultinstantaddress(self.alert_instant_pubkey, self.alert_recovery_pubkey, label)
# mine some coins to alert_addr1
self.nodes[1].generatetoaddress(200, alert_addr1['address'])
# create atx
amount = 10
atxid = self.nodes[1].sendalerttoaddress(addr0, amount)
atx = self.nodes[1].getrawtransaction(atxid, True)
fee = self.COINBASE_AMOUNT - self.sum_vouts_value(atx)
change = self.COINBASE_AMOUNT - amount - fee
change_vout = atx['vout'][self.find_vout_n(atx, change)]
# assert
self.sync_all()
assert self.nodes[0].getalertbalance('*', 0) == 0
assert int(self.nodes[1].getalertbalance('*', 0)) == 17489
assert self.nodes[0].getalertbalance('*', 1) == 0
assert int(self.nodes[1].getalertbalance('*', 1)) == 17325
assert self.nodes[0].getalertbalance('*', 2) == 0
assert int(self.nodes[1].getalertbalance('*', 2)) == 17325
assert self.nodes[0].getalertbalance('*', 666) == 0
assert int(self.nodes[1].getalertbalance('*', 666)) == 0
@introduce_and_reset_blockchain
def test_get_getalertbalance_include_watchonly(self):
# @TODO
pass
if __name__ == '__main__':
AlertsInstantTest().main()
| 49.262381
| 339
| 0.683821
| 12,100
| 103,451
| 5.64281
| 0.037355
| 0.089106
| 0.05463
| 0.019552
| 0.922083
| 0.902004
| 0.886845
| 0.855986
| 0.830121
| 0.799291
| 0
| 0.032732
| 0.1982
| 103,451
| 2,099
| 340
| 49.28585
| 0.79042
| 0.057206
| 0
| 0.690821
| 0
| 0
| 0.104538
| 0.009702
| 0
| 0
| 0.000206
| 0.000476
| 0.136646
| 1
| 0.05314
| false
| 0.00207
| 0.05452
| 0.00069
| 0.110421
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
76bdb595fa0630eafcea0e881758f0cbd8301b1b
| 46
|
py
|
Python
|
ofdft_ml/quantum/__init__.py
|
HamletWantToCode/ofdft-ml
|
4115405b6f530cdf8956d0b5b353569ce7c09496
|
[
"MIT"
] | 6
|
2019-01-16T07:00:27.000Z
|
2022-03-18T07:09:25.000Z
|
ofdft_ml/quantum/__init__.py
|
HamletWantToCode/ofdft-ml
|
4115405b6f530cdf8956d0b5b353569ce7c09496
|
[
"MIT"
] | null | null | null |
ofdft_ml/quantum/__init__.py
|
HamletWantToCode/ofdft-ml
|
4115405b6f530cdf8956d0b5b353569ce7c09496
|
[
"MIT"
] | null | null | null |
from .solver import *
from .ofdft import OFDFT
| 23
| 24
| 0.782609
| 7
| 46
| 5.142857
| 0.571429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.152174
| 46
| 2
| 24
| 23
| 0.923077
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
76c4d09969c17b00df3e8dd8d37cb3d229e29c42
| 4,737
|
py
|
Python
|
tests/plugins/test_add_dockerfile.py
|
tveverka-RH/atomic-reactor
|
e3fca7dd435250cb06565f19c8758a908f7f3c62
|
[
"BSD-3-Clause"
] | 16
|
2019-07-04T16:00:13.000Z
|
2022-01-28T19:51:58.000Z
|
tests/plugins/test_add_dockerfile.py
|
tveverka-RH/atomic-reactor
|
e3fca7dd435250cb06565f19c8758a908f7f3c62
|
[
"BSD-3-Clause"
] | 577
|
2019-06-03T07:53:16.000Z
|
2022-03-31T04:01:23.000Z
|
tests/plugins/test_add_dockerfile.py
|
ben-alkov/atomic-reactor
|
be6b626b7d822f77999f245193fefcc00c501ca9
|
[
"BSD-3-Clause"
] | 17
|
2020-02-21T13:30:06.000Z
|
2022-02-15T10:42:32.000Z
|
"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.
This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
"""
from flexmock import flexmock
from atomic_reactor.plugin import PreBuildPluginsRunner
from atomic_reactor.plugins.pre_add_dockerfile import AddDockerfilePlugin
from atomic_reactor.plugins.pre_add_labels_in_df import AddLabelsPlugin
from atomic_reactor.util import df_parser
from tests.stubs import StubSource
def prepare(workflow, df_path):
workflow.source = StubSource()
flexmock(workflow, df_path=df_path)
def test_adddockerfile_plugin(tmpdir, workflow): # noqa
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
prepare(workflow, df.dockerfile_path)
runner = PreBuildPluginsRunner(
workflow,
[{
'name': AddDockerfilePlugin.key,
'args': {'nvr': 'rhel-server-docker-7.1-20'}
}]
)
runner.run()
assert AddDockerfilePlugin.key is not None
expected_output = """
FROM fedora
RUN yum install -y python-django
ADD Dockerfile-rhel-server-docker-7.1-20 /root/buildinfo/Dockerfile-rhel-server-docker-7.1-20
CMD blabla"""
assert df.content == expected_output
def test_adddockerfile_todest(tmpdir, workflow): # noqa
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
prepare(workflow, df.dockerfile_path)
runner = PreBuildPluginsRunner(
workflow,
[{
'name': AddDockerfilePlugin.key,
'args': {'nvr': 'jboss-eap-6-docker-6.4-77',
'destdir': '/usr/share/doc/'}
}]
)
runner.run()
assert AddDockerfilePlugin.key is not None
expected_output = """
FROM fedora
RUN yum install -y python-django
ADD Dockerfile-jboss-eap-6-docker-6.4-77 /usr/share/doc/Dockerfile-jboss-eap-6-docker-6.4-77
CMD blabla"""
assert df.content == expected_output
def test_adddockerfile_nvr_from_labels(tmpdir, workflow): # noqa
df_content = """
FROM fedora
RUN yum install -y python-django
LABEL Name="jboss-eap-6-docker" "Version"="6.4" "Release"=77
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
prepare(workflow, df.dockerfile_path)
runner = PreBuildPluginsRunner(
workflow,
[{
'name': AddDockerfilePlugin.key
}]
)
runner.run()
assert AddDockerfilePlugin.key is not None
assert "ADD Dockerfile-jboss-eap-6-docker-6.4-77 /root/buildinfo/Dockerfile-jboss-eap-6-docker-6.4-77" in df.content # noqa
def test_adddockerfile_nvr_from_labels2(tmpdir, workflow): # noqa
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
prepare(workflow, df.dockerfile_path)
runner = PreBuildPluginsRunner(
workflow,
[{
'name': AddLabelsPlugin.key,
'args': {'labels': {'Name': 'jboss-eap-6-docker',
'Version': '6.4',
'Release': '77'},
'auto_labels': []}
},
{
'name': AddDockerfilePlugin.key
}]
)
runner.run()
assert AddDockerfilePlugin.key is not None
assert "ADD Dockerfile-jboss-eap-6-docker-6.4-77 /root/buildinfo/Dockerfile-jboss-eap-6-docker-6.4-77" in df.content # noqa
def test_adddockerfile_fails(tmpdir, caplog, workflow): # noqa
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
prepare(workflow, df.dockerfile_path)
runner = PreBuildPluginsRunner(
workflow,
[{
'name': AddDockerfilePlugin.key
}]
)
runner.run()
assert "plugin 'add_dockerfile' raised an exception: ValueError" in caplog.text
def test_adddockerfile_final(tmpdir, workflow): # noqa
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
prepare(workflow, df.dockerfile_path)
runner = PreBuildPluginsRunner(
workflow,
[{
'name': AddDockerfilePlugin.key,
'args': {'nvr': 'rhel-server-docker-7.1-20', "use_final_dockerfile": True}
}]
)
runner.run()
assert AddDockerfilePlugin.key is not None
expected_output = """
FROM fedora
RUN yum install -y python-django
ADD Dockerfile /root/buildinfo/Dockerfile-rhel-server-docker-7.1-20
CMD blabla"""
assert df.content == expected_output
| 26.762712
| 128
| 0.659489
| 585
| 4,737
| 5.230769
| 0.189744
| 0.067647
| 0.038235
| 0.047059
| 0.785621
| 0.781046
| 0.761438
| 0.748693
| 0.739216
| 0.733007
| 0
| 0.019178
| 0.22947
| 4,737
| 176
| 129
| 26.914773
| 0.819178
| 0.044332
| 0
| 0.729927
| 0
| 0.036496
| 0.285683
| 0.111481
| 0
| 0
| 0
| 0
| 0.080292
| 1
| 0.051095
| false
| 0
| 0.043796
| 0
| 0.094891
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4f265efdd510cefac18e8e99e2b670ecb77ce525
| 29
|
py
|
Python
|
test.py
|
dhunganabibek13/myTODOs
|
2e676a5f3be4d67729e3d9f2f0907ae9cb55b3d5
|
[
"MIT"
] | null | null | null |
test.py
|
dhunganabibek13/myTODOs
|
2e676a5f3be4d67729e3d9f2f0907ae9cb55b3d5
|
[
"MIT"
] | null | null | null |
test.py
|
dhunganabibek13/myTODOs
|
2e676a5f3be4d67729e3d9f2f0907ae9cb55b3d5
|
[
"MIT"
] | null | null | null |
print("Testing from Python")
| 14.5
| 28
| 0.758621
| 4
| 29
| 5.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.103448
| 29
| 1
| 29
| 29
| 0.846154
| 0
| 0
| 0
| 0
| 0
| 0.655172
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 1
| 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
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 6
|
4f46b3e6330eac9cef0776ba3ed1a19487773dbf
| 112
|
py
|
Python
|
7 kyu/Leap Years.py
|
mwk0408/codewars_solutions
|
9b4f502b5f159e68024d494e19a96a226acad5e5
|
[
"MIT"
] | 6
|
2020-09-03T09:32:25.000Z
|
2020-12-07T04:10:01.000Z
|
7 kyu/Leap Years.py
|
mwk0408/codewars_solutions
|
9b4f502b5f159e68024d494e19a96a226acad5e5
|
[
"MIT"
] | 1
|
2021-12-13T15:30:21.000Z
|
2021-12-13T15:30:21.000Z
|
7 kyu/Leap Years.py
|
mwk0408/codewars_solutions
|
9b4f502b5f159e68024d494e19a96a226acad5e5
|
[
"MIT"
] | null | null | null |
def isLeapYear(year):
return True if year%400==0 else False if year%100==0 else True if year%4==0 else False
| 56
| 90
| 0.723214
| 23
| 112
| 3.521739
| 0.521739
| 0.222222
| 0.246914
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.107527
| 0.169643
| 112
| 2
| 90
| 56
| 0.763441
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| false
| 0
| 0
| 0.5
| 1
| 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
| 1
| 0
| 0
| 0
| 1
| 0
| 0
|
0
| 6
|
4f608e6045904017691de5ed134136e9e728653f
| 19,426
|
py
|
Python
|
entity_emailer/tests/test_tasks.py
|
wesleykendall/django-entity-emailer
|
60d078a12cccc4912d0a2aab8c2d9710d9241f22
|
[
"MIT"
] | null | null | null |
entity_emailer/tests/test_tasks.py
|
wesleykendall/django-entity-emailer
|
60d078a12cccc4912d0a2aab8c2d9710d9241f22
|
[
"MIT"
] | null | null | null |
entity_emailer/tests/test_tasks.py
|
wesleykendall/django-entity-emailer
|
60d078a12cccc4912d0a2aab8c2d9710d9241f22
|
[
"MIT"
] | null | null | null |
from datetime import datetime
from django.core import mail
from django.core.management import call_command
from django.test import TestCase, SimpleTestCase
from django.test.utils import override_settings
from django_dynamic_fixture import G
from entity.models import Entity, EntityRelationship, EntityKind
from entity_event.models import (
Medium, Source, Subscription, Unsubscription, Event, EventActor
)
from freezegun import freeze_time
from mock import patch
from entity_emailer import tasks
from entity_emailer.models import Email
from entity_emailer.tests.utils import g_email
class ExtractEmailSubjectFromHtmlContentTest(SimpleTestCase):
def test_blank(self):
subject = tasks.extract_email_subject_from_html_content('')
self.assertEquals(subject, '')
def test_with_title_block(self):
subject = tasks.extract_email_subject_from_html_content('<html><head><title> Hello! </title></head></html>')
self.assertEquals(subject, 'Hello!')
def test_wo_title_block_under_40_chars_content(self):
subject = tasks.extract_email_subject_from_html_content(' Small content ')
self.assertEquals(subject, 'Small content')
def test_wo_title_block_under_40_chars_multiline_content(self):
subject = tasks.extract_email_subject_from_html_content((
' Small content \n'
'that spans multiple lines'
))
self.assertEquals(subject, 'Small content')
def test_wo_title_block_gt_40_chars_content(self):
subject = tasks.extract_email_subject_from_html_content((
' This is reallly long content that is greater than 40 chars on the first line. It should have ...'
))
self.assertEquals(subject, 'This is reallly long content that is gre...')
class ConvertEventsToEmailsTest(TestCase):
def setUp(self):
call_command('add_email_medium')
self.email_medium = Medium.objects.get(name='email')
@patch('entity_emailer.tasks.convert_events_to_emails', spec_set=True)
def test_task(self, mock_convert_events_to_emails):
tasks.ConvertEventsToEmails().run()
mock_convert_events_to_emails.assert_called_once_with()
def test_no_events(self):
tasks.convert_events_to_emails()
self.assertFalse(Email.objects.exists())
def test_no_subscriptions(self):
G(Event, context={})
tasks.convert_events_to_emails()
self.assertFalse(Email.objects.exists())
@freeze_time('2013-1-2')
def test_basic_only_following_false_subscription(self):
source = G(Source)
e = G(Entity)
G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=e)
tasks.convert_events_to_emails()
email = Email.objects.get()
self.assertEquals(list(email.recipients.all()), [e])
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_basic_only_following_false_subscription_marked_seen(self):
source = G(Source)
e = G(Entity)
G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=e)
tasks.convert_events_to_emails()
tasks.convert_events_to_emails()
email = Email.objects.get()
self.assertEquals(list(email.recipients.all()), [e])
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_basic_only_following_true_subscription(self):
source = G(Source)
e = G(Entity)
se = G(Entity)
G(EntityRelationship, sub_entity=e, super_entity=se)
other_e = G(Entity)
G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=True)
G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=True)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=se)
tasks.convert_events_to_emails()
email = Email.objects.get()
# Since the other_e entity does not follow the se entity, only the e entity receives an email
self.assertEquals(set(email.recipients.all()), set([e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_super_entity_only_following_false_subscription(self):
source = G(Source)
e = G(Entity)
se = G(Entity)
G(EntityRelationship, sub_entity=e, super_entity=se)
other_e = G(Entity)
G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False)
G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=False)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=se)
G(EventActor, event=event, entity=other_e)
G(EventActor, event=event, entity=e)
tasks.convert_events_to_emails()
email = Email.objects.get()
self.assertEquals(set(email.recipients.all()), set([e, other_e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_basic_only_following_true_group_subscription(self):
source = G(Source)
ek = G(EntityKind)
e = G(Entity, entity_kind=ek)
se = G(Entity)
G(EntityRelationship, sub_entity=e, super_entity=se)
other_e = G(Entity, entity_kind=ek)
G(EntityRelationship, sub_entity=other_e, super_entity=se)
G(Subscription, entity=se, sub_entity_kind=ek, source=source, medium=self.email_medium, only_following=True)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=se)
tasks.convert_events_to_emails()
email = Email.objects.get()
# Both entities are subscribed with a group subscription and are following the super entity of the event
self.assertEquals(set(email.recipients.all()), set([e, other_e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_basic_only_following_false_group_subscription(self):
source = G(Source)
ek = G(EntityKind)
e = G(Entity, entity_kind=ek)
se = G(Entity)
G(EntityRelationship, sub_entity=e, super_entity=se)
other_e = G(Entity, entity_kind=ek)
G(EntityRelationship, sub_entity=other_e, super_entity=se)
G(Subscription, entity=se, sub_entity_kind=ek, source=source, medium=self.email_medium, only_following=False)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=e)
tasks.convert_events_to_emails()
email = Email.objects.get()
# Both entities are subscribed with a group subscription and are following the super entity of the event
self.assertEquals(set(email.recipients.all()), set([e, other_e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_basic_only_following_false_group_subscription_with_unsubscribed(self):
source = G(Source)
ek = G(EntityKind)
e = G(Entity, entity_kind=ek)
se = G(Entity)
G(EntityRelationship, sub_entity=e, super_entity=se)
other_e = G(Entity, entity_kind=ek)
G(EntityRelationship, sub_entity=other_e, super_entity=se)
G(Subscription, entity=se, sub_entity_kind=ek, source=source, medium=self.email_medium, only_following=False)
G(Unsubscription, entity=e, source=source, medium=self.email_medium)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=e)
tasks.convert_events_to_emails()
email = Email.objects.get()
self.assertEquals(set(email.recipients.all()), set([other_e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_multiple_events_only_following_false(self):
source = G(Source)
e = G(Entity)
other_e = G(Entity)
G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False)
G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=False)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
G(Event, source=source, context=email_context)
G(Event, source=source, context=email_context)
tasks.convert_events_to_emails()
self.assertEquals(Email.objects.count(), 2)
for email in Email.objects.all():
self.assertEquals(set(email.recipients.all()), set([e, other_e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2013-1-2')
def test_multiple_events_only_following_true(self):
source = G(Source)
e = G(Entity)
other_e = G(Entity)
G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=True)
G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=True)
email_context = {
'entity_emailer_template': 'template',
'entity_emailer_subject': 'hi',
}
G(Event, source=source, context=email_context)
event = G(Event, source=source, context=email_context)
G(EventActor, event=event, entity=e)
tasks.convert_events_to_emails()
email = Email.objects.get()
self.assertEquals(set(email.recipients.all()), set([e]))
self.assertEquals(email.event.context, email_context)
self.assertEquals(email.subject, '')
self.assertEquals(email.scheduled, datetime(2013, 1, 2))
@freeze_time('2014-01-05')
class SendUnsentScheduledEmailsTest(TestCase):
def setUp(self):
G(Medium, name='email')
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, BROKER_BACKEND='memory')
@patch('entity_emailer.tasks.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
def test_sends_all_scheduled_emails_no_email_addresses(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = []
g_email(context={}, scheduled=datetime.min)
g_email(context={}, scheduled=datetime.min)
tasks.SendUnsentScheduledEmails().delay()
self.assertEqual(len(mail.outbox), 0)
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, BROKER_BACKEND='memory')
@patch('entity_emailer.tasks.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
def test_sends_all_scheduled_emails(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = ['test1@example.com', 'test2@example.com']
g_email(context={}, scheduled=datetime.min)
g_email(context={}, scheduled=datetime.min)
tasks.SendUnsentScheduledEmails().delay()
self.assertEqual(len(mail.outbox), 2)
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, BROKER_BACKEND='memory')
@patch('entity_emailer.tasks.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
def test_sends_email_with_specified_from_address(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = ['test1@example.com', 'test2@example.com']
from_address = 'test@example.com'
g_email(context={}, from_address=from_address, scheduled=datetime.min)
tasks.SendUnsentScheduledEmails().delay()
self.assertEqual(mail.outbox[0].from_email, from_address)
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, BROKER_BACKEND='memory')
@patch('entity_emailer.tasks.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
def test_sends_no_future_emails(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = ['test1@example.com', 'test2@example.com']
g_email(context={}, scheduled=datetime(2014, 1, 6))
tasks.SendUnsentScheduledEmails().delay()
self.assertEqual(len(mail.outbox), 0)
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, BROKER_BACKEND='memory')
@patch('entity_emailer.tasks.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
def test_sends_no_sent_emails(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = ['test1@example.com', 'test2@example.com']
g_email(context={}, scheduled=datetime.min, sent=datetime.utcnow())
tasks.SendUnsentScheduledEmails().delay()
self.assertEqual(len(mail.outbox), 0)
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, BROKER_BACKEND='memory')
@patch('entity_emailer.tasks.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
def test_updates_times(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = ['test1@example.com', 'test2@example.com']
g_email(context={}, scheduled=datetime.min)
tasks.SendUnsentScheduledEmails().delay()
sent_email = Email.objects.filter(sent__isnull=False)
self.assertEqual(sent_email.count(), 1)
class CreateEmailObjectTest(TestCase):
def test_no_html(self):
email = tasks.create_email_message(
['to@example.com'], 'from@example.com', 'Subject', 'Email Body.', ''
)
email.send()
self.assertEqual(mail.outbox[0].attachments, [])
def test_html(self):
email = tasks.create_email_message(
['to@example.com'], 'from@example.com', 'Subject', 'Email Body.', '<html>A</html>'
)
email.send()
expected_alternatives = [('<html>A</html>', 'text/html')]
self.assertEqual(mail.outbox[0].alternatives, expected_alternatives)
class GetSubscribedEmailAddressesTest(TestCase):
def test_get_emails_default_settings(self):
e1 = G(Entity, entity_meta={'email': 'hello1@hello.com'})
e2 = G(Entity, entity_meta={'email': 'hello2@hello.com'})
email = g_email(recipients=[e1, e2], context={})
addresses = tasks.get_subscribed_email_addresses(email)
self.assertEqual(set(addresses), set(['hello1@hello.com', 'hello2@hello.com']))
@override_settings(ENTITY_EMAILER_EMAIL_KEY='email_address')
@override_settings(ENTITY_EMAILER_EXCLUDE_KEY='last_invite_time')
def test_get_emails_override_email_key(self):
e1 = G(Entity, entity_meta={'email_address': 'hello1@hello.com', 'last_invite_time': 1000})
e2 = G(Entity, entity_meta={'email_address': 'hello2@hello.com', 'last_invite_time': None})
email = g_email(recipients=[e1, e2], context={})
addresses = tasks.get_subscribed_email_addresses(email)
self.assertEqual(set(addresses), set(['hello1@hello.com']))
@override_settings(ENTITY_EMAILER_EMAIL_KEY='email_address')
def test_get_emails_override_email_key_exclude_key(self):
e1 = G(Entity, entity_meta={'email_address': 'hello1@hello.com'})
e2 = G(Entity, entity_meta={'email_address': 'hello2@hello.com'})
email = g_email(recipients=[e1, e2], context={})
addresses = tasks.get_subscribed_email_addresses(email)
self.assertEqual(set(addresses), set(['hello1@hello.com', 'hello2@hello.com']))
class GetFromEmailAddressTest(TestCase):
def test_default_from_email(self):
# settings.DEFAULT_FROM_EMAIL is already set to test@example.com
from_email = tasks.get_from_email_address()
expected = 'test@example.com'
self.assertEqual(from_email, expected)
@override_settings(ENTITY_EMAILER_FROM_EMAIL='test_entity@example.com')
def test_entity_emailer_from_email(self):
from_email = tasks.get_from_email_address()
expected = 'test_entity@example.com'
self.assertEqual(from_email, expected)
class GetEmailAddressesTest(TestCase):
def test_returns_own_email(self):
entity_1 = G(Entity, entity_meta={'email': 'test_1@example.com'})
entity_2 = G(Entity, entity_meta={'email': 'test_2@example.com'})
email = g_email(recipients=[entity_1, entity_2], context={})
addresses = tasks.get_subscribed_email_addresses(email)
expected_addresses = {u'test_1@example.com', u'test_2@example.com'}
self.assertEqual(set(addresses), expected_addresses)
def test_no_recipients(self):
email = g_email(recipients=[], context={})
addresses = tasks.get_subscribed_email_addresses(email)
self.assertEqual(addresses, [])
| 44.863741
| 118
| 0.688356
| 2,423
| 19,426
| 5.271564
| 0.086669
| 0.052611
| 0.046035
| 0.024661
| 0.823064
| 0.802396
| 0.798325
| 0.774368
| 0.75871
| 0.738119
| 0
| 0.01175
| 0.193864
| 19,426
| 432
| 119
| 44.967593
| 0.803895
| 0.018532
| 0
| 0.663866
| 0
| 0
| 0.127643
| 0.04323
| 0
| 0
| 0
| 0
| 0.168067
| 1
| 0.095238
| false
| 0
| 0.036415
| 0
| 0.151261
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
8c10025fef80cb12951fb1284490ec28fe0f1eed
| 196
|
py
|
Python
|
machina/noise/base.py
|
AswinRetnakumar/Machina
|
6519935ca4553192ac99fc1c7c1e7cab9dd72693
|
[
"MIT"
] | 302
|
2019-03-13T10:21:29.000Z
|
2022-03-25T10:01:46.000Z
|
machina/noise/base.py
|
AswinRetnakumar/Machina
|
6519935ca4553192ac99fc1c7c1e7cab9dd72693
|
[
"MIT"
] | 50
|
2019-03-13T09:45:00.000Z
|
2021-12-23T18:32:00.000Z
|
machina/noise/base.py
|
AswinRetnakumar/Machina
|
6519935ca4553192ac99fc1c7c1e7cab9dd72693
|
[
"MIT"
] | 55
|
2019-03-17T01:59:57.000Z
|
2022-03-28T01:13:40.000Z
|
class BaseActionNoise(object):
"""
Base class of action noise.
"""
def __init__(self, action_space):
self.action_space = action_space
def reset(self):
pass
| 15.076923
| 40
| 0.607143
| 22
| 196
| 5.090909
| 0.590909
| 0.294643
| 0.267857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.295918
| 196
| 12
| 41
| 16.333333
| 0.811594
| 0.137755
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.4
| false
| 0.2
| 0
| 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
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 6
|
8c46df1672bca0d6b819e65e8b827bbad20f9096
| 26
|
py
|
Python
|
variational_principle/plot/__init__.py
|
Tiernan8r/Variational-Principle
|
e5f82956c3bfd57f7d73c7220ac2cdd9c8f09935
|
[
"MIT"
] | 1
|
2020-05-21T08:10:24.000Z
|
2020-05-21T08:10:24.000Z
|
variational_principle/plot/__init__.py
|
Tiernan8r/Variational_Principle
|
e5f82956c3bfd57f7d73c7220ac2cdd9c8f09935
|
[
"MIT"
] | 33
|
2020-01-21T12:02:06.000Z
|
2020-06-23T16:50:57.000Z
|
variational_principle/plot/__init__.py
|
Tiernan8r/Variational_Principle
|
e5f82956c3bfd57f7d73c7220ac2cdd9c8f09935
|
[
"MIT"
] | 1
|
2022-03-17T01:50:25.000Z
|
2022-03-17T01:50:25.000Z
|
from .plot import plotting
| 26
| 26
| 0.846154
| 4
| 26
| 5.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.115385
| 26
| 1
| 26
| 26
| 0.956522
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8c4b48dcb4de95c9f0253e77f484a9cf4cc1a333
| 48
|
py
|
Python
|
tests/fixtures/sample-dir/dir2/f2_1.py
|
swiperthefox/python-source-browser
|
12f276179253fb87326e054137698e89f3354886
|
[
"MIT"
] | null | null | null |
tests/fixtures/sample-dir/dir2/f2_1.py
|
swiperthefox/python-source-browser
|
12f276179253fb87326e054137698e89f3354886
|
[
"MIT"
] | 3
|
2015-06-20T02:30:10.000Z
|
2015-07-05T10:07:05.000Z
|
tests/fixtures/sample-dir/dir2/f2_1.py
|
swiperthefox/python-source-browser
|
12f276179253fb87326e054137698e89f3354886
|
[
"MIT"
] | null | null | null |
class Test:
def method1(self):
pass
| 12
| 22
| 0.5625
| 6
| 48
| 4.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.032258
| 0.354167
| 48
| 3
| 23
| 16
| 0.83871
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0.333333
| 0
| 0
| 0.666667
| 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
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 6
|
8c60f4361b929dd4fd1ffa3e3d3a9e4285c820c6
| 3,096
|
py
|
Python
|
flatland/database/population/node/compartment_type_instances.py
|
erik-soederholm/flatland-model-diagram-editor
|
088e27cded9eca2cacba2c6168c03caf4b43ef72
|
[
"MIT"
] | 10
|
2021-01-03T16:47:34.000Z
|
2022-03-30T18:47:07.000Z
|
flatland/database/population/node/compartment_type_instances.py
|
modelint/flatland-model-diagram-editor
|
088e27cded9eca2cacba2c6168c03caf4b43ef72
|
[
"MIT"
] | 91
|
2021-01-09T02:14:13.000Z
|
2022-02-24T10:24:10.000Z
|
flatland/database/population/node/compartment_type_instances.py
|
erik-soederholm/flatland-model-diagram-editor
|
088e27cded9eca2cacba2c6168c03caf4b43ef72
|
[
"MIT"
] | 1
|
2021-01-13T22:13:19.000Z
|
2021-01-13T22:13:19.000Z
|
"""
compartment_type_instances.py
"""
population = [
# Class diagram
# Class
{'Name': 'name', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 5, 'Pad bottom': 10, 'Pad left': 5, 'Pad right': 5, 'Text style': 'TITLE',
'Node type': 'class', 'Diagram type': 'class', 'Stack order': 1},
{'Name': 'attribute', 'Horizontal alignment': 'LEFT', 'Vertical alignment': 'TOP',
'Pad top': 5, 'Pad bottom': 10, 'Pad left': 5, 'Pad right': 5, 'Text style': 'BODY',
'Node type': 'class', 'Diagram type': 'class', 'Stack order': 2},
{'Name': 'method', 'Horizontal alignment': 'LEFT', 'Vertical alignment': 'TOP',
'Pad top': 5, 'Pad bottom': 4, 'Pad left': 5, 'Pad right': 5, 'Text style': 'BODY',
'Node type': 'class', 'Diagram type': 'class', 'Stack order': 3},
# Imported class
{'Name': 'name', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 5, 'Pad bottom': 10, 'Pad left': 5, 'Pad right': 5, 'Text style': 'TITLE',
'Node type': 'imported class', 'Diagram type': 'class', 'Stack order': 1},
{'Name': 'attribute', 'Horizontal alignment': 'LEFT', 'Vertical alignment': 'TOP',
'Pad top': 5, 'Pad bottom': 10, 'Pad left': 5, 'Pad right': 5, 'Text style': 'BODY',
'Node type': 'imported class', 'Diagram type': 'class', 'Stack order': 2},
# State machine diagram
# State
{'Name': 'name', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 5, 'Pad bottom': 10, 'Pad left': 10, 'Pad right': 10, 'Text style': 'TITLE',
'Node type': 'state', 'Diagram type': 'state machine', 'Stack order': 1},
{'Name': 'name only', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 20, 'Pad bottom': 20, 'Pad left': 10, 'Pad right': 10, 'Text style': 'TITLE',
'Node type': 'state', 'Diagram type': 'state machine', 'Stack order': 3},
{'Name': 'activity', 'Horizontal alignment': 'LEFT', 'Vertical alignment': 'TOP',
'Pad top': 4, 'Pad bottom': 10, 'Pad left': 5, 'Pad right': 5, 'Text style': 'BODY',
'Node type': 'state', 'Diagram type': 'state machine', 'Stack order': 2},
# Domain diagram
# Domain
{'Name': 'name', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 5, 'Pad bottom': 5, 'Pad left': 5, 'Pad right': 5, 'Text style': 'TITLE',
'Node type': 'domain', 'Diagram type': 'domain', 'Stack order': 1},
# Class collaboration diagram
# External entity
{'Name': 'name', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 5, 'Pad bottom': 5, 'Pad left': 5, 'Pad right': 5, 'Text style': 'TITLE',
'Node type': 'external entity', 'Diagram type': 'class collaboration', 'Stack order': 1},
# Overview class
{'Name': 'name', 'Horizontal alignment': 'CENTER', 'Vertical alignment': 'CENTER',
'Pad top': 5, 'Pad bottom': 5, 'Pad left': 5, 'Pad right': 5, 'Text style': 'TITLE',
'Node type': 'overview class', 'Diagram type': 'class collaboration', 'Stack order': 2}
]
| 52.474576
| 94
| 0.593346
| 386
| 3,096
| 4.753886
| 0.111399
| 0.045777
| 0.034332
| 0.049046
| 0.857221
| 0.857221
| 0.814714
| 0.813624
| 0.757493
| 0.711172
| 0
| 0.026864
| 0.194444
| 3,096
| 59
| 95
| 52.474576
| 0.708901
| 0.056202
| 0
| 0.428571
| 0
| 0
| 0.594288
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.057143
| 0
| 0.057143
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
4fc090f599e43cb9edb8422a72cb068cbe1cca5d
| 7,947
|
py
|
Python
|
tenable_io/api/agent_groups.py
|
skrtu/Tenable.io-SDK-for-Python
|
fde8871ba558666609183ac8702149ecf08421b5
|
[
"MIT"
] | 90
|
2017-02-02T18:36:17.000Z
|
2022-02-05T17:58:50.000Z
|
tenable_io/api/agent_groups.py
|
skrtu/Tenable.io-SDK-for-Python
|
fde8871ba558666609183ac8702149ecf08421b5
|
[
"MIT"
] | 64
|
2017-02-03T00:54:00.000Z
|
2020-08-06T14:06:50.000Z
|
tenable_io/api/agent_groups.py
|
skrtu/Tenable.io-SDK-for-Python
|
fde8871ba558666609183ac8702149ecf08421b5
|
[
"MIT"
] | 49
|
2017-02-03T01:01:00.000Z
|
2022-02-25T13:25:28.000Z
|
from json import loads
from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import AgentGroup, AgentGroupList, AgentList
class AgentGroupsApi(BaseApi):
def add_agent(self, agent_group_id, agent_id, scanner_id=1):
"""Add an agent to the given agent group.
:param agent_group_id: The agent group ID.
:param agent_id: The agent ID.
:param scanner_id: The scanner ID.
:raise TenableIOApiException: When API error is encountered.
:return: True if successful.
"""
self._client.put('scanners/%(scanner_id)s/agent-groups/%(agent_group_id)s/agents/%(agent_id)s',
path_params={
'scanner_id': scanner_id,
'agent_group_id': agent_group_id,
'agent_id': agent_id
})
return True
def agents(
self,
agent_group_id,
scanner_id=1,
offset=None,
limit=None,
sort=None,
f=None,
ft=None,
w=None,
wf=None
):
"""Get agent list for given agent group.
:param agent_group_id: The agent group ID.
:param scanner_id: The scanner ID.
:param offset: The starting record to retrieve, defaults to 0 if not defined.
:param limit: The number of records to retrieve, API will defaults to 50 if not defined.
:param sort: The sort order of the returned records.
:param f: Apply a filter in the format '<field_name>:<operation>:<value>'.
:param ft: Filter type. ("and" or "or").
:param w: Wildcard filter text.
:param wf: A comma delimited subset of wildcard_fields to search when applying the wildcard filter.
:raise TenableIOApiException: When API error is encountered.
:return: An instance of :class:`tenable_io.api.models.AgentList`.
"""
params = {
'offset': offset,
'limit': limit,
'sort': sort,
'f': f,
'ft': ft,
'w': w,
'wf': wf
}
params = {k: v for k, v in params.items() if v is not None}
response = self._client.get('scanners/%(scanner_id)s/agent-groups/%(agent_group_id)s/agents',
path_params={
'scanner_id': scanner_id,
'agent_group_id': agent_group_id
},
params=params)
return AgentList.from_json(response.text)
def configure(self, agent_group_id, configure_agent_group, scanner_id=1):
"""Configure name of give agent group.
:param agent_group_id: The agent group ID.
:param scanner_id: The scanner ID.
:param configure_agent_group: An instance of :class:`AgentGroupSaveRequest`.
:raise TenableIOApiException: When API error is encountered.
:return: True if successful.
"""
self._client.put('scanners/%(scanner_id)s/agent-groups/%(agent_group_id)s',
configure_agent_group,
path_params={
'scanner_id': scanner_id,
'agent_group_id': agent_group_id
})
return True
def create(self, create_agent_group, scanner_id=1):
"""Create an agent group.
:param create_agent_group: An instance of :class:`AgentGroupSaveRequest`.
:param scanner_id: The scanner ID.
:raise TenableIOApiException: When API error is encountered.
:return: The ID of agent group just created.
"""
response = self._client.post('scanners/%(scanner_id)s/agent-groups',
create_agent_group,
path_params={
'scanner_id': scanner_id
})
return loads(response.text).get('id')
def delete(self, agent_group_id, scanner_id=1):
"""Delete an agent group.
:param agent_group_id: The agent group ID.
:param scanner_id: The scanner ID.
:raise TenableIOApiException: When API error is encountered.
:return: True if successful.
"""
self._client.delete('scanners/%(scanner_id)s/agent-groups/%(agent_group_id)s',
path_params={
'scanner_id': scanner_id,
'agent_group_id': agent_group_id
})
return True
def delete_agent(self, agent_group_id, agent_id, scanner_id=1):
"""Delete an agent from the given agent group.
:param agent_group_id: The agent group ID.
:param agent_id: The agent ID.
:param scanner_id: The scanner ID.
:raise TenableIOApiException: When API error is encountered.
:return: True if successful.
"""
self._client.delete('scanners/%(scanner_id)s/agent-groups/%(agent_group_id)s/agents/%(agent_id)s',
path_params={
'scanner_id': scanner_id,
'agent_group_id': agent_group_id,
'agent_id': agent_id
})
return True
def details(
self,
agent_group_id,
scanner_id=1,
offset=None,
limit=None,
sort=None,
f=None,
ft=None,
w=None,
wf=None
):
"""Get details of given agent group.
:param agent_group_id: The agent group ID.
:param scanner_id: The scanner ID.
:param offset: The starting record to retrieve, defaults to 0 if not defined.
:param limit: The number of records to retrieve, API will defaults to 50 if not defined.
:param sort: The sort order of the returned records.
:param f: Apply a filter in the format '<field_name>:<operation>:<value>'.
:param ft: Filter type. ("and" or "or").
:param w: Wildcard filter text.
:param wf: A comma delimited subset of wildcard_fields to search when applying the wildcard filter.
:raise TenableIOApiException: When API error is encountered.
:return: An instance of :class:`tenable_io.api.models.AgentGroup`.
"""
params = {
'offset': offset,
'limit': limit,
'sort': sort,
'f': f,
'ft': ft,
'w': w,
'wf': wf
}
params = {k: v for k, v in params.items() if v is not None}
response = self._client.get('scanners/%(scanner_id)s/agent-groups/%(agent_group_id)s',
path_params={
'scanner_id': scanner_id,
'agent_group_id': agent_group_id
},
params=params)
return AgentGroup.from_json(response.text)
def list(self, scanner_id=1):
"""Return agent groups for the given scanner.
:param scanner_id: The scanner ID.
:raise TenableIOApiException: When API error is encountered.
:return: An instance of :class:`tenable_io.api.models.AgentGroupList`.
"""
response = self._client.get('scanners/%(scanner_id)s/agent-groups',
path_params={
'scanner_id': scanner_id
})
return AgentGroupList.from_json(response.text)
class AgentGroupSaveRequest(BaseRequest):
def __init__(
self,
name
):
self.name = name
| 39.934673
| 107
| 0.535045
| 883
| 7,947
| 4.638732
| 0.121178
| 0.12207
| 0.105469
| 0.041016
| 0.849121
| 0.828125
| 0.821045
| 0.776367
| 0.764648
| 0.764648
| 0
| 0.002833
| 0.378256
| 7,947
| 198
| 108
| 40.136364
| 0.826149
| 0.355732
| 0
| 0.696429
| 0
| 0
| 0.145576
| 0.097123
| 0
| 0
| 0
| 0
| 0
| 1
| 0.080357
| false
| 0
| 0.026786
| 0
| 0.196429
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
8b03e9bddf048e2b0bd8ad8893097105024e1cc5
| 124
|
py
|
Python
|
features/steps/use_steplib_behave4git.py
|
arichtman/pyadr
|
92a1a3495c92f50aca8966a5187fc96bff7ad3d1
|
[
"MIT"
] | 5
|
2020-07-08T08:19:18.000Z
|
2022-02-26T23:29:12.000Z
|
features/steps/use_steplib_behave4git.py
|
arichtman/pyadr
|
92a1a3495c92f50aca8966a5187fc96bff7ad3d1
|
[
"MIT"
] | 50
|
2020-04-05T22:40:41.000Z
|
2022-02-26T23:53:12.000Z
|
features/steps/use_steplib_behave4git.py
|
arichtman/pyadr
|
92a1a3495c92f50aca8966a5187fc96bff7ad3d1
|
[
"MIT"
] | 1
|
2022-02-26T23:46:38.000Z
|
2022-02-26T23:46:38.000Z
|
# flake8: noqa
"""
Use behave4git step library.
"""
# -- REGISTER-STEPS FROM STEP-LIBRARY:
import behave4git.__all_steps__
| 15.5
| 38
| 0.733871
| 15
| 124
| 5.733333
| 0.733333
| 0.255814
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.028037
| 0.137097
| 124
| 7
| 39
| 17.714286
| 0.775701
| 0.637097
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8c70a83e1e2cef0d07d73e428e31ca2a457ea971
| 7,246
|
py
|
Python
|
spacy/tests/doc/test_span_group.py
|
stungkit/spaCy
|
a83a50119520ea8708f0ef0730f65f486556c273
|
[
"MIT"
] | 1
|
2019-11-27T13:14:04.000Z
|
2019-11-27T13:14:04.000Z
|
spacy/tests/doc/test_span_group.py
|
stungkit/spaCy
|
a83a50119520ea8708f0ef0730f65f486556c273
|
[
"MIT"
] | 2
|
2022-02-21T05:50:08.000Z
|
2022-03-15T03:19:49.000Z
|
spacy/tests/doc/test_span_group.py
|
stungkit/spaCy
|
a83a50119520ea8708f0ef0730f65f486556c273
|
[
"MIT"
] | null | null | null |
import pytest
from random import Random
from spacy.matcher import Matcher
from spacy.tokens import Span, SpanGroup
@pytest.fixture
def doc(en_tokenizer):
doc = en_tokenizer("0 1 2 3 4 5 6")
matcher = Matcher(en_tokenizer.vocab, validate=True)
# fmt: off
matcher.add("4", [[{}, {}, {}, {}]])
matcher.add("2", [[{}, {}, ]])
matcher.add("1", [[{}, ]])
# fmt: on
matches = matcher(doc)
spans = []
for match in matches:
spans.append(
Span(doc, match[1], match[2], en_tokenizer.vocab.strings[match[0]])
)
Random(42).shuffle(spans)
doc.spans["SPANS"] = SpanGroup(
doc, name="SPANS", attrs={"key": "value"}, spans=spans
)
return doc
@pytest.fixture
def other_doc(en_tokenizer):
doc = en_tokenizer("0 1 2 3 4 5 6")
matcher = Matcher(en_tokenizer.vocab, validate=True)
# fmt: off
matcher.add("4", [[{}, {}, {}, {}]])
matcher.add("2", [[{}, {}, ]])
matcher.add("1", [[{}, ]])
# fmt: on
matches = matcher(doc)
spans = []
for match in matches:
spans.append(
Span(doc, match[1], match[2], en_tokenizer.vocab.strings[match[0]])
)
Random(42).shuffle(spans)
doc.spans["SPANS"] = SpanGroup(
doc, name="SPANS", attrs={"key": "value"}, spans=spans
)
return doc
@pytest.fixture
def span_group(en_tokenizer):
doc = en_tokenizer("0 1 2 3 4 5 6")
matcher = Matcher(en_tokenizer.vocab, validate=True)
# fmt: off
matcher.add("4", [[{}, {}, {}, {}]])
matcher.add("2", [[{}, {}, ]])
matcher.add("1", [[{}, ]])
# fmt: on
matches = matcher(doc)
spans = []
for match in matches:
spans.append(
Span(doc, match[1], match[2], en_tokenizer.vocab.strings[match[0]])
)
Random(42).shuffle(spans)
doc.spans["SPANS"] = SpanGroup(
doc, name="SPANS", attrs={"key": "value"}, spans=spans
)
def test_span_group_copy(doc):
span_group = doc.spans["SPANS"]
clone = span_group.copy()
assert clone != span_group
assert clone.name == span_group.name
assert clone.attrs == span_group.attrs
assert len(clone) == len(span_group)
assert list(span_group) == list(clone)
clone.name = "new_name"
clone.attrs["key"] = "new_value"
clone.append(Span(doc, 0, 6, "LABEL"))
assert clone.name != span_group.name
assert clone.attrs != span_group.attrs
assert span_group.attrs["key"] == "value"
assert list(span_group) != list(clone)
def test_span_group_set_item(doc, other_doc):
span_group = doc.spans["SPANS"]
index = 5
span = span_group[index]
span.label_ = "NEW LABEL"
span.kb_id = doc.vocab.strings["KB_ID"]
assert span_group[index].label != span.label
assert span_group[index].kb_id != span.kb_id
span_group[index] = span
assert span_group[index].start == span.start
assert span_group[index].end == span.end
assert span_group[index].label == span.label
assert span_group[index].kb_id == span.kb_id
assert span_group[index] == span
with pytest.raises(IndexError):
span_group[-100] = span
with pytest.raises(IndexError):
span_group[100] = span
span = Span(other_doc, 0, 2)
with pytest.raises(ValueError):
span_group[index] = span
def test_span_group_has_overlap(doc):
span_group = doc.spans["SPANS"]
assert span_group.has_overlap
def test_span_group_concat(doc, other_doc):
span_group_1 = doc.spans["SPANS"]
spans = [doc[0:5], doc[0:6]]
span_group_2 = SpanGroup(
doc,
name="MORE_SPANS",
attrs={"key": "new_value", "new_key": "new_value"},
spans=spans,
)
span_group_3 = span_group_1._concat(span_group_2)
assert span_group_3.name == span_group_1.name
assert span_group_3.attrs == {"key": "value", "new_key": "new_value"}
span_list_expected = list(span_group_1) + list(span_group_2)
assert list(span_group_3) == list(span_list_expected)
# Inplace
span_list_expected = list(span_group_1) + list(span_group_2)
span_group_3 = span_group_1._concat(span_group_2, inplace=True)
assert span_group_3 == span_group_1
assert span_group_3.name == span_group_1.name
assert span_group_3.attrs == {"key": "value", "new_key": "new_value"}
assert list(span_group_3) == list(span_list_expected)
span_group_2 = other_doc.spans["SPANS"]
with pytest.raises(ValueError):
span_group_1._concat(span_group_2)
def test_span_doc_delitem(doc):
span_group = doc.spans["SPANS"]
length = len(span_group)
index = 5
span = span_group[index]
next_span = span_group[index + 1]
del span_group[index]
assert len(span_group) == length - 1
assert span_group[index] != span
assert span_group[index] == next_span
with pytest.raises(IndexError):
del span_group[-100]
with pytest.raises(IndexError):
del span_group[100]
def test_span_group_add(doc):
span_group_1 = doc.spans["SPANS"]
spans = [doc[0:5], doc[0:6]]
span_group_2 = SpanGroup(
doc,
name="MORE_SPANS",
attrs={"key": "new_value", "new_key": "new_value"},
spans=spans,
)
span_group_3_expected = span_group_1._concat(span_group_2)
span_group_3 = span_group_1 + span_group_2
assert len(span_group_3) == len(span_group_3_expected)
assert span_group_3.attrs == {"key": "value", "new_key": "new_value"}
assert list(span_group_3) == list(span_group_3_expected)
def test_span_group_iadd(doc):
span_group_1 = doc.spans["SPANS"].copy()
spans = [doc[0:5], doc[0:6]]
span_group_2 = SpanGroup(
doc,
name="MORE_SPANS",
attrs={"key": "new_value", "new_key": "new_value"},
spans=spans,
)
span_group_1_expected = span_group_1._concat(span_group_2)
span_group_1 += span_group_2
assert len(span_group_1) == len(span_group_1_expected)
assert span_group_1.attrs == {"key": "value", "new_key": "new_value"}
assert list(span_group_1) == list(span_group_1_expected)
span_group_1 = doc.spans["SPANS"].copy()
span_group_1 += spans
assert len(span_group_1) == len(span_group_1_expected)
assert span_group_1.attrs == {
"key": "value",
}
assert list(span_group_1) == list(span_group_1_expected)
def test_span_group_extend(doc):
span_group_1 = doc.spans["SPANS"].copy()
spans = [doc[0:5], doc[0:6]]
span_group_2 = SpanGroup(
doc,
name="MORE_SPANS",
attrs={"key": "new_value", "new_key": "new_value"},
spans=spans,
)
span_group_1_expected = span_group_1._concat(span_group_2)
span_group_1.extend(span_group_2)
assert len(span_group_1) == len(span_group_1_expected)
assert span_group_1.attrs == {"key": "value", "new_key": "new_value"}
assert list(span_group_1) == list(span_group_1_expected)
span_group_1 = doc.spans["SPANS"]
span_group_1.extend(spans)
assert len(span_group_1) == len(span_group_1_expected)
assert span_group_1.attrs == {"key": "value"}
assert list(span_group_1) == list(span_group_1_expected)
def test_span_group_dealloc(span_group):
with pytest.raises(AttributeError):
print(span_group.doc)
| 29.81893
| 79
| 0.642699
| 1,045
| 7,246
| 4.167464
| 0.075598
| 0.254191
| 0.101033
| 0.032147
| 0.822503
| 0.80597
| 0.73938
| 0.725144
| 0.688863
| 0.656487
| 0
| 0.027476
| 0.211427
| 7,246
| 242
| 80
| 29.942149
| 0.734687
| 0.008004
| 0
| 0.584211
| 0
| 0
| 0.068524
| 0
| 0
| 0
| 0
| 0
| 0.221053
| 1
| 0.063158
| false
| 0
| 0.021053
| 0
| 0.094737
| 0.005263
| 0
| 0
| 0
| null | 1
| 0
| 0
| 1
| 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
| 6
|
8c8488f3d727a3465931d0d9c0840f862ac57133
| 1,648
|
py
|
Python
|
src/py/test_day2_dive.py
|
errantsky/advent-of-code-2021
|
a86f8fe1342d865ae417c9eba8adaf075df93b55
|
[
"MIT"
] | null | null | null |
src/py/test_day2_dive.py
|
errantsky/advent-of-code-2021
|
a86f8fe1342d865ae417c9eba8adaf075df93b55
|
[
"MIT"
] | null | null | null |
src/py/test_day2_dive.py
|
errantsky/advent-of-code-2021
|
a86f8fe1342d865ae417c9eba8adaf075df93b55
|
[
"MIT"
] | null | null | null |
def part1(pairs):
depth = 0
h_pos = 0
for cmd, val in pairs:
val = int(val)
if cmd == "forward":
h_pos += val
elif cmd == "up":
depth -= val
elif cmd == "down":
depth += val
else:
raise Exception
return h_pos * depth
def part2(pairs):
h_pos = 0
depth = 0
aim = 0
for cmd, val in pairs:
val = int(val)
if cmd == "forward":
depth += aim * val
h_pos += val
elif cmd == "up":
aim -= val
elif cmd == "down":
aim += val
else:
raise Exception
return h_pos * depth
def test_day2_sample():
with open("/Users/sep/CLionProjects/aoc-2021/src/test_files/day2_sample.txt") as f:
cmd_pairs = [s.rstrip("\n").split(" ") for s in f.readlines()]
assert part1(cmd_pairs) == 150
def test_day2_submission():
with open(
"/Users/sep/CLionProjects/aoc-2021/src/test_files/day2_submission.txt"
) as f:
cmd_pairs = [s.rstrip("\n").split(" ") for s in f.readlines()]
assert part1(cmd_pairs) == 1746616
def test_day1_part2_sample():
with open("/Users/sep/CLionProjects/aoc-2021/src/test_files/day2_sample.txt") as f:
cmd_pairs = [s.rstrip("\n").split(" ") for s in f.readlines()]
assert part2(cmd_pairs) == 900
def test_day1_part2_submission():
with open(
"/Users/sep/CLionProjects/aoc-2021/src/test_files/day2_submission.txt"
) as f:
cmd_pairs = [s.rstrip("\n").split(" ") for s in f.readlines()]
assert part2(cmd_pairs) == 1741971043
| 26.15873
| 87
| 0.554612
| 225
| 1,648
| 3.92
| 0.222222
| 0.072562
| 0.045351
| 0.072562
| 0.800454
| 0.800454
| 0.764172
| 0.764172
| 0.764172
| 0.675737
| 0
| 0.052817
| 0.31068
| 1,648
| 62
| 88
| 26.580645
| 0.723592
| 0
| 0
| 0.68
| 0
| 0
| 0.183252
| 0.160194
| 0
| 0
| 0
| 0
| 0.08
| 1
| 0.12
| false
| 0
| 0
| 0
| 0.16
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
5090d4fd0182f2f4c753fb2821daf861fcd4e075
| 1,702
|
py
|
Python
|
pirates/leveleditor/worldData/jungle_area_a.py
|
itsyaboyrocket/pirates
|
6ca1e7d571c670b0d976f65e608235707b5737e3
|
[
"BSD-3-Clause"
] | 3
|
2021-02-25T06:38:13.000Z
|
2022-03-22T07:00:15.000Z
|
pirates/leveleditor/worldData/jungle_area_a.py
|
itsyaboyrocket/pirates
|
6ca1e7d571c670b0d976f65e608235707b5737e3
|
[
"BSD-3-Clause"
] | null | null | null |
pirates/leveleditor/worldData/jungle_area_a.py
|
itsyaboyrocket/pirates
|
6ca1e7d571c670b0d976f65e608235707b5737e3
|
[
"BSD-3-Clause"
] | 1
|
2021-02-25T06:38:17.000Z
|
2021-02-25T06:38:17.000Z
|
# uncompyle6 version 3.2.0
# Python bytecode 2.4 (62061)
# Decompiled from: Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
# Embedded file name: pirates.leveleditor.worldData.jungle_area_a
from pandac.PandaModules import Point3, VBase3
objectStruct = {'Objects': {'1157485817.84sdnaik': {'Type': 'Island Game Area', 'Name': 'jungle_area_a', 'Objects': {'1164917380.86sdnaik': {'Type': 'Locator Node', 'Name': 'portal_interior_1', 'Hpr': VBase3(-153.319, 0.0, 0.0), 'Pos': Point3(406.169, 250.261, 8.467), 'Scale': VBase3(1.0, 1.0, 1.0)}, '1164917380.88sdnaik': {'Type': 'Locator Node', 'Name': 'portal_interior_2', 'Hpr': VBase3(96.892, 0.711, -0.076), 'Pos': Point3(-120.867, -365.049, -0.26), 'Scale': VBase3(1.0, 1.0, 1.0)}, '1164917380.88sdnaik0': {'Type': 'Locator Node', 'Name': 'portal_interior_3', 'Hpr': VBase3(-61.504, -3.202, 1.38), 'Pos': Point3(-352.561, 241.702, 3.28), 'Scale': VBase3(1.0, 1.0, 1.0)}, '1164917416.75sdnaik': {'Type': 'Tree', 'Hpr': Point3(0.0, 0.0, 0.0), 'Pos': Point3(-154.594, -9.413, -14.779), 'Scale': VBase3(1.0, 1.0, 1.0), 'Visual': {'Model': 'models/vegetation/jungle_tree_a'}}}, 'Visual': {'Model': 'models/jungles/jungle_a_zero'}}}, 'Node Links': [], 'Layers': {}, 'ObjectIds': {'1157485817.84sdnaik': '["Objects"]["1157485817.84sdnaik"]', '1164917380.86sdnaik': '["Objects"]["1157485817.84sdnaik"]["Objects"]["1164917380.86sdnaik"]', '1164917380.88sdnaik': '["Objects"]["1157485817.84sdnaik"]["Objects"]["1164917380.88sdnaik"]', '1164917380.88sdnaik0': '["Objects"]["1157485817.84sdnaik"]["Objects"]["1164917380.88sdnaik0"]', '1164917416.75sdnaik': '["Objects"]["1157485817.84sdnaik"]["Objects"]["1164917416.75sdnaik"]'}}
| 283.666667
| 1,427
| 0.668038
| 242
| 1,702
| 4.640496
| 0.42562
| 0.021371
| 0.021371
| 0.028495
| 0.303651
| 0.189671
| 0.078362
| 0.078362
| 0.048085
| 0
| 0
| 0.26739
| 0.079318
| 1,702
| 6
| 1,427
| 283.666667
| 0.449266
| 0.128672
| 0
| 0
| 0
| 0
| 0.553753
| 0.247465
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
0fd33c4c0a24820a76a9427ccea1f37a469e6642
| 108
|
py
|
Python
|
qiskit_braket_provider/exception.py
|
Morcu/qiskit-braket-plugin
|
f486dc542204d54699673835a9c0bdc61ae34cca
|
[
"Apache-2.0"
] | 1
|
2022-03-22T21:07:00.000Z
|
2022-03-22T21:07:00.000Z
|
qiskit_braket_provider/exception.py
|
Morcu/qiskit-braket-plugin
|
f486dc542204d54699673835a9c0bdc61ae34cca
|
[
"Apache-2.0"
] | 11
|
2022-02-22T14:39:26.000Z
|
2022-03-23T20:18:09.000Z
|
qiskit_braket_provider/exception.py
|
Morcu/qiskit-braket-plugin
|
f486dc542204d54699673835a9c0bdc61ae34cca
|
[
"Apache-2.0"
] | 1
|
2022-03-13T12:41:28.000Z
|
2022-03-13T12:41:28.000Z
|
"""Qiskit-Braket exception."""
class QiskitBraketException(Exception):
"""Qiskit-Braket exception."""
| 18
| 39
| 0.712963
| 9
| 108
| 8.555556
| 0.555556
| 0.311688
| 0.545455
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.111111
| 108
| 5
| 40
| 21.6
| 0.802083
| 0.453704
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 1
| 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
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 6
|
0fe293da3f55b17d81694c79062ccb4a7fb3201a
| 3,692
|
py
|
Python
|
server/mainML.py
|
dewancse/model-similarity
|
dcc14f850eb8101c4e302f8db060968cd37aed5c
|
[
"MIT"
] | null | null | null |
server/mainML.py
|
dewancse/model-similarity
|
dcc14f850eb8101c4e302f8db060968cd37aed5c
|
[
"MIT"
] | null | null | null |
server/mainML.py
|
dewancse/model-similarity
|
dcc14f850eb8101c4e302f8db060968cd37aed5c
|
[
"MIT"
] | null | null | null |
# Importing the libraries
import csv
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
def polyML(data):
# writing a csv data sheet for the X_grid and y_grid
with open('modelML.csv', 'w', newline='') as csvfile:
fieldnames = ['X', 'Y']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for i in range(len(data)):
writer.writerow({'X': data[i]['xaxis'], 'Y': data[i]['yaxis']})
# Importing the dataset
dataset = pd.read_csv('modelML.csv')
X = dataset.iloc[:, 0:1].values
y = dataset.iloc[:, 1].values
# Fitting Polynomial Regression to the dataset
poly_reg = PolynomialFeatures(degree = 7)
X_poly = poly_reg.fit_transform(X)
poly_reg.fit(X_poly, y)
lin_reg_2 = LinearRegression()
lin_reg_2.fit(X_poly, y)
# Visualising the Polynomial Regression results (for higher resolution and smoother curve)
X_grid = np.arange(min(X), max(X), 0.1)
X_grid = X_grid.reshape((len(X_grid), 1))
y_grid = lin_reg_2.predict(poly_reg.fit_transform(X_grid))
objList = []
for i in range(len(X_grid)):
objList.append({'xaxis': X_grid[i][0], 'yaxis': y_grid[i]})
return objList
def decisionML(data):
# writing a csv data sheet for the X_grid and y_grid
with open('modelML.csv', 'w', newline='') as csvfile:
fieldnames = ['X', 'Y']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for i in range(len(data)):
writer.writerow({'X': data[i]['xaxis'], 'Y': data[i]['yaxis']})
# Importing the dataset
dataset = pd.read_csv('modelML.csv')
X = dataset.iloc[:, 0:1].values
y = dataset.iloc[:, 1].values
# Fitting the Decision Tree Regression to the dataset
regressor = DecisionTreeRegressor(random_state = 0)
regressor.fit(X, y)
# Predicting a new result
y_pred = regressor.predict([[6.5]])
# Visualising the Decision Tree Regression results (for higher resolution and smoother curve)
X_grid = np.arange(min(X), max(X), 0.1)
X_grid = X_grid.reshape((len(X_grid), 1))
y_grid = regressor.predict(X_grid)
objList = []
for i in range(len(X_grid)):
objList.append({'xaxis': X_grid[i][0], 'yaxis': y_grid[i]})
return objList
def forestML(data):
# writing a csv data sheet for the X_grid and y_grid
with open('modelML.csv', 'w', newline='') as csvfile:
fieldnames = ['X', 'Y']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for i in range(len(data)):
writer.writerow({'X': data[i]['xaxis'], 'Y': data[i]['yaxis']})
# Importing the dataset
dataset = pd.read_csv('modelML.csv')
X = dataset.iloc[:, 0:1].values
y = dataset.iloc[:, 1].values
# Fitting the Random Forest Regression to the dataset
regressor = RandomForestRegressor(n_estimators = 300, random_state = 0)
regressor.fit(X, y)
# Predicting a new result
y_pred = regressor.predict([[6.5]])
# Visualising the Regression results (for higher resolution and smoother curve)
X_grid = np.arange(min(X), max(X), 0.01)
X_grid = X_grid.reshape((len(X_grid), 1))
y_grid = regressor.predict(X_grid)
objList = []
for i in range(len(X_grid)):
objList.append({'xaxis': X_grid[i][0], 'yaxis': y_grid[i]})
return objList
| 34.504673
| 97
| 0.634615
| 513
| 3,692
| 4.45614
| 0.191033
| 0.052493
| 0.015748
| 0.028871
| 0.770779
| 0.726597
| 0.726597
| 0.726597
| 0.726597
| 0.726597
| 0
| 0.012376
| 0.23402
| 3,692
| 107
| 98
| 34.504673
| 0.795969
| 0.18987
| 0
| 0.724638
| 0
| 0
| 0.047379
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.043478
| false
| 0
| 0.101449
| 0
| 0.188406
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
0fe839f20a6697f337a3938b46626f8c7712c5c3
| 86
|
py
|
Python
|
addons/test_mail_full/models/__init__.py
|
SHIVJITH/Odoo_Machine_Test
|
310497a9872db7844b521e6dab5f7a9f61d365a4
|
[
"Apache-2.0"
] | null | null | null |
addons/test_mail_full/models/__init__.py
|
SHIVJITH/Odoo_Machine_Test
|
310497a9872db7844b521e6dab5f7a9f61d365a4
|
[
"Apache-2.0"
] | null | null | null |
addons/test_mail_full/models/__init__.py
|
SHIVJITH/Odoo_Machine_Test
|
310497a9872db7844b521e6dab5f7a9f61d365a4
|
[
"Apache-2.0"
] | null | null | null |
# -*- coding: utf-8 -*-
from . import test_mail_models
from . import mailing_mailing
| 17.2
| 30
| 0.709302
| 12
| 86
| 4.833333
| 0.75
| 0.344828
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.013889
| 0.162791
| 86
| 4
| 31
| 21.5
| 0.791667
| 0.244186
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
ba0f693f0df7a34f03dd9d9a24dc641e9058852a
| 23
|
py
|
Python
|
tests/dir0/dir1/module12.py
|
peterprescott/numdoclinter
|
b7ae705e500114394dad96dcb0871ec7a22bd2da
|
[
"MIT"
] | null | null | null |
tests/dir0/dir1/module12.py
|
peterprescott/numdoclinter
|
b7ae705e500114394dad96dcb0871ec7a22bd2da
|
[
"MIT"
] | null | null | null |
tests/dir0/dir1/module12.py
|
peterprescott/numdoclinter
|
b7ae705e500114394dad96dcb0871ec7a22bd2da
|
[
"MIT"
] | null | null | null |
def func12():
pass
| 7.666667
| 13
| 0.565217
| 3
| 23
| 4.333333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.125
| 0.304348
| 23
| 2
| 14
| 11.5
| 0.6875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| true
| 0.5
| 0
| 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
| 1
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
e851d12587f8cb27069268e7b4700bfb713b8bd0
| 153
|
py
|
Python
|
gooey/__init__.py
|
shachar-xor/Gooey
|
cfed2f7ded442882c46a303f00fe6c1708829a5e
|
[
"MIT"
] | null | null | null |
gooey/__init__.py
|
shachar-xor/Gooey
|
cfed2f7ded442882c46a303f00fe6c1708829a5e
|
[
"MIT"
] | null | null | null |
gooey/__init__.py
|
shachar-xor/Gooey
|
cfed2f7ded442882c46a303f00fe6c1708829a5e
|
[
"MIT"
] | null | null | null |
import os
from gooey.python_bindings.gooey_decorator import Gooey
from gooey.python_bindings.gooey_parser import GooeyParser
__version__ = '1.0.1'
| 25.5
| 59
| 0.816993
| 22
| 153
| 5.318182
| 0.545455
| 0.153846
| 0.25641
| 0.393162
| 0.478632
| 0
| 0
| 0
| 0
| 0
| 0
| 0.022388
| 0.124183
| 153
| 5
| 60
| 30.6
| 0.850746
| 0
| 0
| 0
| 0
| 0
| 0.033784
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.75
| 0
| 0.75
| 0
| 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
| 1
| 0
| 1
| 0
|
0
| 6
|
e8714362c350756de15f7f55869a698a4b9e83fe
| 209
|
py
|
Python
|
__init__.py
|
Jokoe66/Ultra-Fast-Lane-Detection
|
b857e41d3026f1cdb70354c4267f42053a145f90
|
[
"MIT"
] | null | null | null |
__init__.py
|
Jokoe66/Ultra-Fast-Lane-Detection
|
b857e41d3026f1cdb70354c4267f42053a145f90
|
[
"MIT"
] | null | null | null |
__init__.py
|
Jokoe66/Ultra-Fast-Lane-Detection
|
b857e41d3026f1cdb70354c4267f42053a145f90
|
[
"MIT"
] | null | null | null |
import os
import sys
from .data import *
from .model import *
from .utils import *
from .inference import init_model, inference_model, show_result
__all__ = ['init_model', 'inference)model', 'show_result']
| 19
| 63
| 0.755981
| 29
| 209
| 5.137931
| 0.413793
| 0.201342
| 0.241611
| 0.308725
| 0.442953
| 0.442953
| 0
| 0
| 0
| 0
| 0
| 0
| 0.143541
| 209
| 10
| 64
| 20.9
| 0.832402
| 0
| 0
| 0
| 0
| 0
| 0.172249
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.857143
| 0
| 0.857143
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e8a53728281d962cc2a4a57f702f9db23588f699
| 8,018
|
py
|
Python
|
ckanext/visualize/tests/test_controllers.py
|
open-data-toronto/ckanext-visualize
|
a85dfdb1e82e837e172f8b9cc0d14b5437c0541e
|
[
"MIT"
] | null | null | null |
ckanext/visualize/tests/test_controllers.py
|
open-data-toronto/ckanext-visualize
|
a85dfdb1e82e837e172f8b9cc0d14b5437c0541e
|
[
"MIT"
] | null | null | null |
ckanext/visualize/tests/test_controllers.py
|
open-data-toronto/ckanext-visualize
|
a85dfdb1e82e837e172f8b9cc0d14b5437c0541e
|
[
"MIT"
] | null | null | null |
from routes import url_for
from ckan import plugins as p
from ckan.tests import helpers, factories
from ckanext.visualize.controllers.visualize import VisualizeDataController
from ckanext.visualize.tests.helpers import mock_pylons
class TestVisualizeDataController(helpers.FunctionalTestBase):
@classmethod
def setup_class(self):
super(TestVisualizeDataController, self).setup_class()
if not p.plugin_loaded('visualize'):
p.load('visualize')
if not p.plugin_loaded('datastore'):
p.load('datastore')
@classmethod
def teardown_class(self):
super(TestVisualizeDataController, self).teardown_class()
p.unload('visualize')
p.unload('datastore')
helpers.reset_db()
def test_visualize_data_endpoint_no_resource_provided(self):
app = self._get_test_app()
controller =\
'ckanext.visualize.controllers.visualize:VisualizeDataController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
response = app.get(route)
assert 'Please provide the query parameter `resource_id`.' in \
response.body
def test_visualize_data_endpoint_resource_not_found(self):
app = self._get_test_app()
controller =\
'ckanext.visualize.controllers.visualize:VisualizeDataController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
response = app.get(route + '?resource_id=test')
assert 'The provided resource with id `test` was not found.' in \
response.body
def test_visualize_data_endpoint_not_authorized(self):
app = self._get_test_app()
controller =\
'ckanext.visualize.controllers.visualize:VisualizeDataController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
org = factories.Organization()
dataset = factories.Dataset(private=True, owner_org=org.get('id'))
resource = factories.Resource(
schema='',
validation_options='',
package_id=dataset.get('id'),
datastore_active=True,
)
resource_id = resource.get('id')
data = {
'fields': [
{'id': 'Age', 'type': 'numeric'},
{'id': 'Name', 'type': 'text'},
],
'records': [
{'Age': 35, 'Name': 'John'},
{'Age': 28, 'Name': 'Sara'},
],
'force': True,
'resource_id': resource_id,
}
helpers.call_action('datastore_create', **data)
response = app.get(route + '?resource_id={0}'.format(resource_id))
assert 'You don\'t have access to the resource with id `{0}`.'.format(
resource_id) == response.body
def test_visualize_data_endpoint(self):
app = self._get_test_app()
controller =\
'ckanext.visualize.controllers.visualize:VisualizeDataController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
dataset = factories.Dataset()
resource = factories.Resource(
schema='',
validation_options='',
package_id=dataset.get('id'),
datastore_active=True,
)
resource_id = resource.get('id')
data = {
'fields': [
{'id': 'Age', 'type': 'numeric'},
{'id': 'Name', 'type': 'text'},
],
'records': [
{'Age': 35, 'Name': 'John'},
{'Age': 28, 'Name': 'Sara'},
],
'force': True,
'resource_id': resource_id,
}
helpers.call_action('datastore_create', **data)
response = app.get(route + '?resource_id={0}'.format(resource_id))
assert '<div class="chart-container hidden">' in \
response.body
class TestAdminController(helpers.FunctionalTestBase):
@classmethod
def setup_class(self):
super(TestAdminController, self).setup_class()
if not p.plugin_loaded('visualize'):
p.load('visualize')
@classmethod
def teardown_class(self):
super(TestAdminController, self).teardown_class()
p.unload('visualize')
helpers.reset_db()
def test_visualize_data_endpoint_admin(self):
app = self._get_test_app()
user = factories.Sysadmin()
env = {'REMOTE_USER': user.get('name').encode('ascii')}
controller =\
'ckanext.visualize.controllers.admin:AdminController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
response = app.get(url=route, extra_environ=env)
assert 'Visualize' in response.body
@helpers.change_config('visualize_colors', '{"color_1":"#fff"}')
def test_visualize_data_endpoint_predefined_color(self):
app = self._get_test_app()
user = factories.Sysadmin()
env = {'REMOTE_USER': user.get('name').encode('ascii')}
controller =\
'ckanext.visualize.controllers.admin:AdminController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
response = app.get(url=route, extra_environ=env)
assert 'Visualize' in response.body
def test_visualize_data_endpoint_post(self):
app = self._get_test_app()
user = factories.Sysadmin()
env = {'REMOTE_USER': user.get('name').encode('ascii')}
controller =\
'ckanext.visualize.controllers.admin:AdminController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
params = {
'save': True,
'color_1': '#332288',
'color_2': '#117733',
}
response = app.post(url=route, extra_environ=env, params=params)
assert '302 Found' in response.body
def test_visualize_data_endpoint_post_icon_url(self):
app = self._get_test_app()
user = factories.Sysadmin()
env = {'REMOTE_USER': user.get('name').encode('ascii')}
controller =\
'ckanext.visualize.controllers.admin:AdminController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
params = {
'save': True,
'bar_chart_upload': 'http://example.com/image.png'
}
response = app.post(url=route, extra_environ=env,
params=params)
assert '302 Found' in response.body
def test_visualize_data_endpoint_post_icon_upload(self):
app = self._get_test_app()
user = factories.Sysadmin()
env = {'REMOTE_USER': user.get('name').encode('ascii')}
controller =\
'ckanext.visualize.controllers.admin:AdminController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
params = {
'save': True,
}
upload_content = 'image data'
upload_info = ('bar_chart_upload', 'image.png', upload_content)
response = app.post(url=route, extra_environ=env,
params=params, upload_files=[upload_info])
assert '302 Found' in response.body
def test_visualize_data_endpoint_reset(self):
app = self._get_test_app()
user = factories.Sysadmin()
env = {'REMOTE_USER': user.get('name').encode('ascii')}
controller =\
'ckanext.visualize.controllers.admin:AdminController'
action = 'visualize_data'
route = url_for(controller=controller, action=action)
params = {
'reset': 'true',
'color_1': '#332288',
'color_2': '#117733',
}
response = app.post(url=route, extra_environ=env, params=params)
assert '302 Found' in response.body
| 35.0131
| 78
| 0.601147
| 821
| 8,018
| 5.668697
| 0.163216
| 0.055866
| 0.063816
| 0.042974
| 0.825956
| 0.792222
| 0.760421
| 0.751826
| 0.699828
| 0.682853
| 0
| 0.008995
| 0.278997
| 8,018
| 228
| 79
| 35.166667
| 0.796056
| 0
| 0
| 0.743456
| 0
| 0
| 0.192068
| 0.072337
| 0
| 0
| 0
| 0
| 0.052356
| 1
| 0.073298
| false
| 0
| 0.026178
| 0
| 0.109948
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
e8bea1af777971866975df232351f7d05ab2c3d8
| 20
|
py
|
Python
|
hackathon/sorting/__init__.py
|
jasonrobwebster/edsa-analyse-hackathon
|
ebe4d0b2334e6986fba7261fe49379451a1fd31c
|
[
"MIT"
] | 1
|
2021-04-29T11:44:21.000Z
|
2021-04-29T11:44:21.000Z
|
hackathon/sorting/__init__.py
|
jasonrobwebster/edsa-analyse-hackathon
|
ebe4d0b2334e6986fba7261fe49379451a1fd31c
|
[
"MIT"
] | null | null | null |
hackathon/sorting/__init__.py
|
jasonrobwebster/edsa-analyse-hackathon
|
ebe4d0b2334e6986fba7261fe49379451a1fd31c
|
[
"MIT"
] | null | null | null |
from .sorts import *
| 20
| 20
| 0.75
| 3
| 20
| 5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15
| 20
| 1
| 20
| 20
| 0.882353
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
2cd1d0148d9463dac2c012bca0a84424d884b7a4
| 17,819
|
py
|
Python
|
sdk/python/pulumi_aws_native/athena/_inputs.py
|
AaronFriel/pulumi-aws-native
|
5621690373ac44accdbd20b11bae3be1baf022d1
|
[
"Apache-2.0"
] | 29
|
2021-09-30T19:32:07.000Z
|
2022-03-22T21:06:08.000Z
|
sdk/python/pulumi_aws_native/athena/_inputs.py
|
AaronFriel/pulumi-aws-native
|
5621690373ac44accdbd20b11bae3be1baf022d1
|
[
"Apache-2.0"
] | 232
|
2021-09-30T19:26:26.000Z
|
2022-03-31T23:22:06.000Z
|
sdk/python/pulumi_aws_native/athena/_inputs.py
|
AaronFriel/pulumi-aws-native
|
5621690373ac44accdbd20b11bae3be1baf022d1
|
[
"Apache-2.0"
] | 4
|
2021-11-10T19:42:01.000Z
|
2022-02-05T10:15:49.000Z
|
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from .. import _utilities
from ._enums import *
__all__ = [
'DataCatalogTagArgs',
'WorkGroupConfigurationUpdatesArgs',
'WorkGroupConfigurationArgs',
'WorkGroupEncryptionConfigurationArgs',
'WorkGroupEngineVersionArgs',
'WorkGroupResultConfigurationUpdatesArgs',
'WorkGroupResultConfigurationArgs',
'WorkGroupTagArgs',
]
@pulumi.input_type
class DataCatalogTagArgs:
def __init__(__self__, *,
key: pulumi.Input[str],
value: pulumi.Input[str]):
pulumi.set(__self__, "key", key)
pulumi.set(__self__, "value", value)
@property
@pulumi.getter
def key(self) -> pulumi.Input[str]:
return pulumi.get(self, "key")
@key.setter
def key(self, value: pulumi.Input[str]):
pulumi.set(self, "key", value)
@property
@pulumi.getter
def value(self) -> pulumi.Input[str]:
return pulumi.get(self, "value")
@value.setter
def value(self, value: pulumi.Input[str]):
pulumi.set(self, "value", value)
@pulumi.input_type
class WorkGroupConfigurationUpdatesArgs:
def __init__(__self__, *,
bytes_scanned_cutoff_per_query: Optional[pulumi.Input[int]] = None,
enforce_work_group_configuration: Optional[pulumi.Input[bool]] = None,
engine_version: Optional[pulumi.Input['WorkGroupEngineVersionArgs']] = None,
publish_cloud_watch_metrics_enabled: Optional[pulumi.Input[bool]] = None,
remove_bytes_scanned_cutoff_per_query: Optional[pulumi.Input[bool]] = None,
requester_pays_enabled: Optional[pulumi.Input[bool]] = None,
result_configuration_updates: Optional[pulumi.Input['WorkGroupResultConfigurationUpdatesArgs']] = None):
"""
The configuration information that will be updated for this workgroup, which includes the location in Amazon S3 where query results are stored, the encryption option, if any, used for query results, whether the Amazon CloudWatch Metrics are enabled for the workgroup, whether the workgroup settings override the client-side settings, and the data usage limit for the amount of bytes scanned per query, if it is specified.
"""
if bytes_scanned_cutoff_per_query is not None:
pulumi.set(__self__, "bytes_scanned_cutoff_per_query", bytes_scanned_cutoff_per_query)
if enforce_work_group_configuration is not None:
pulumi.set(__self__, "enforce_work_group_configuration", enforce_work_group_configuration)
if engine_version is not None:
pulumi.set(__self__, "engine_version", engine_version)
if publish_cloud_watch_metrics_enabled is not None:
pulumi.set(__self__, "publish_cloud_watch_metrics_enabled", publish_cloud_watch_metrics_enabled)
if remove_bytes_scanned_cutoff_per_query is not None:
pulumi.set(__self__, "remove_bytes_scanned_cutoff_per_query", remove_bytes_scanned_cutoff_per_query)
if requester_pays_enabled is not None:
pulumi.set(__self__, "requester_pays_enabled", requester_pays_enabled)
if result_configuration_updates is not None:
pulumi.set(__self__, "result_configuration_updates", result_configuration_updates)
@property
@pulumi.getter(name="bytesScannedCutoffPerQuery")
def bytes_scanned_cutoff_per_query(self) -> Optional[pulumi.Input[int]]:
return pulumi.get(self, "bytes_scanned_cutoff_per_query")
@bytes_scanned_cutoff_per_query.setter
def bytes_scanned_cutoff_per_query(self, value: Optional[pulumi.Input[int]]):
pulumi.set(self, "bytes_scanned_cutoff_per_query", value)
@property
@pulumi.getter(name="enforceWorkGroupConfiguration")
def enforce_work_group_configuration(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "enforce_work_group_configuration")
@enforce_work_group_configuration.setter
def enforce_work_group_configuration(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "enforce_work_group_configuration", value)
@property
@pulumi.getter(name="engineVersion")
def engine_version(self) -> Optional[pulumi.Input['WorkGroupEngineVersionArgs']]:
return pulumi.get(self, "engine_version")
@engine_version.setter
def engine_version(self, value: Optional[pulumi.Input['WorkGroupEngineVersionArgs']]):
pulumi.set(self, "engine_version", value)
@property
@pulumi.getter(name="publishCloudWatchMetricsEnabled")
def publish_cloud_watch_metrics_enabled(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "publish_cloud_watch_metrics_enabled")
@publish_cloud_watch_metrics_enabled.setter
def publish_cloud_watch_metrics_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "publish_cloud_watch_metrics_enabled", value)
@property
@pulumi.getter(name="removeBytesScannedCutoffPerQuery")
def remove_bytes_scanned_cutoff_per_query(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "remove_bytes_scanned_cutoff_per_query")
@remove_bytes_scanned_cutoff_per_query.setter
def remove_bytes_scanned_cutoff_per_query(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "remove_bytes_scanned_cutoff_per_query", value)
@property
@pulumi.getter(name="requesterPaysEnabled")
def requester_pays_enabled(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "requester_pays_enabled")
@requester_pays_enabled.setter
def requester_pays_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "requester_pays_enabled", value)
@property
@pulumi.getter(name="resultConfigurationUpdates")
def result_configuration_updates(self) -> Optional[pulumi.Input['WorkGroupResultConfigurationUpdatesArgs']]:
return pulumi.get(self, "result_configuration_updates")
@result_configuration_updates.setter
def result_configuration_updates(self, value: Optional[pulumi.Input['WorkGroupResultConfigurationUpdatesArgs']]):
pulumi.set(self, "result_configuration_updates", value)
@pulumi.input_type
class WorkGroupConfigurationArgs:
def __init__(__self__, *,
bytes_scanned_cutoff_per_query: Optional[pulumi.Input[int]] = None,
enforce_work_group_configuration: Optional[pulumi.Input[bool]] = None,
engine_version: Optional[pulumi.Input['WorkGroupEngineVersionArgs']] = None,
publish_cloud_watch_metrics_enabled: Optional[pulumi.Input[bool]] = None,
requester_pays_enabled: Optional[pulumi.Input[bool]] = None,
result_configuration: Optional[pulumi.Input['WorkGroupResultConfigurationArgs']] = None):
if bytes_scanned_cutoff_per_query is not None:
pulumi.set(__self__, "bytes_scanned_cutoff_per_query", bytes_scanned_cutoff_per_query)
if enforce_work_group_configuration is not None:
pulumi.set(__self__, "enforce_work_group_configuration", enforce_work_group_configuration)
if engine_version is not None:
pulumi.set(__self__, "engine_version", engine_version)
if publish_cloud_watch_metrics_enabled is not None:
pulumi.set(__self__, "publish_cloud_watch_metrics_enabled", publish_cloud_watch_metrics_enabled)
if requester_pays_enabled is not None:
pulumi.set(__self__, "requester_pays_enabled", requester_pays_enabled)
if result_configuration is not None:
pulumi.set(__self__, "result_configuration", result_configuration)
@property
@pulumi.getter(name="bytesScannedCutoffPerQuery")
def bytes_scanned_cutoff_per_query(self) -> Optional[pulumi.Input[int]]:
return pulumi.get(self, "bytes_scanned_cutoff_per_query")
@bytes_scanned_cutoff_per_query.setter
def bytes_scanned_cutoff_per_query(self, value: Optional[pulumi.Input[int]]):
pulumi.set(self, "bytes_scanned_cutoff_per_query", value)
@property
@pulumi.getter(name="enforceWorkGroupConfiguration")
def enforce_work_group_configuration(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "enforce_work_group_configuration")
@enforce_work_group_configuration.setter
def enforce_work_group_configuration(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "enforce_work_group_configuration", value)
@property
@pulumi.getter(name="engineVersion")
def engine_version(self) -> Optional[pulumi.Input['WorkGroupEngineVersionArgs']]:
return pulumi.get(self, "engine_version")
@engine_version.setter
def engine_version(self, value: Optional[pulumi.Input['WorkGroupEngineVersionArgs']]):
pulumi.set(self, "engine_version", value)
@property
@pulumi.getter(name="publishCloudWatchMetricsEnabled")
def publish_cloud_watch_metrics_enabled(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "publish_cloud_watch_metrics_enabled")
@publish_cloud_watch_metrics_enabled.setter
def publish_cloud_watch_metrics_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "publish_cloud_watch_metrics_enabled", value)
@property
@pulumi.getter(name="requesterPaysEnabled")
def requester_pays_enabled(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "requester_pays_enabled")
@requester_pays_enabled.setter
def requester_pays_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "requester_pays_enabled", value)
@property
@pulumi.getter(name="resultConfiguration")
def result_configuration(self) -> Optional[pulumi.Input['WorkGroupResultConfigurationArgs']]:
return pulumi.get(self, "result_configuration")
@result_configuration.setter
def result_configuration(self, value: Optional[pulumi.Input['WorkGroupResultConfigurationArgs']]):
pulumi.set(self, "result_configuration", value)
@pulumi.input_type
class WorkGroupEncryptionConfigurationArgs:
def __init__(__self__, *,
encryption_option: pulumi.Input['WorkGroupEncryptionOption'],
kms_key: Optional[pulumi.Input[str]] = None):
"""
If query results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE-KMS or CSE-KMS) and key information.
"""
pulumi.set(__self__, "encryption_option", encryption_option)
if kms_key is not None:
pulumi.set(__self__, "kms_key", kms_key)
@property
@pulumi.getter(name="encryptionOption")
def encryption_option(self) -> pulumi.Input['WorkGroupEncryptionOption']:
return pulumi.get(self, "encryption_option")
@encryption_option.setter
def encryption_option(self, value: pulumi.Input['WorkGroupEncryptionOption']):
pulumi.set(self, "encryption_option", value)
@property
@pulumi.getter(name="kmsKey")
def kms_key(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "kms_key")
@kms_key.setter
def kms_key(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "kms_key", value)
@pulumi.input_type
class WorkGroupEngineVersionArgs:
def __init__(__self__, *,
effective_engine_version: Optional[pulumi.Input[str]] = None,
selected_engine_version: Optional[pulumi.Input[str]] = None):
"""
The Athena engine version for running queries.
"""
if effective_engine_version is not None:
pulumi.set(__self__, "effective_engine_version", effective_engine_version)
if selected_engine_version is not None:
pulumi.set(__self__, "selected_engine_version", selected_engine_version)
@property
@pulumi.getter(name="effectiveEngineVersion")
def effective_engine_version(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "effective_engine_version")
@effective_engine_version.setter
def effective_engine_version(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "effective_engine_version", value)
@property
@pulumi.getter(name="selectedEngineVersion")
def selected_engine_version(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "selected_engine_version")
@selected_engine_version.setter
def selected_engine_version(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "selected_engine_version", value)
@pulumi.input_type
class WorkGroupResultConfigurationUpdatesArgs:
def __init__(__self__, *,
encryption_configuration: Optional[pulumi.Input['WorkGroupEncryptionConfigurationArgs']] = None,
output_location: Optional[pulumi.Input[str]] = None,
remove_encryption_configuration: Optional[pulumi.Input[bool]] = None,
remove_output_location: Optional[pulumi.Input[bool]] = None):
"""
The result configuration information about the queries in this workgroup that will be updated. Includes the updated results location and an updated option for encrypting query results.
"""
if encryption_configuration is not None:
pulumi.set(__self__, "encryption_configuration", encryption_configuration)
if output_location is not None:
pulumi.set(__self__, "output_location", output_location)
if remove_encryption_configuration is not None:
pulumi.set(__self__, "remove_encryption_configuration", remove_encryption_configuration)
if remove_output_location is not None:
pulumi.set(__self__, "remove_output_location", remove_output_location)
@property
@pulumi.getter(name="encryptionConfiguration")
def encryption_configuration(self) -> Optional[pulumi.Input['WorkGroupEncryptionConfigurationArgs']]:
return pulumi.get(self, "encryption_configuration")
@encryption_configuration.setter
def encryption_configuration(self, value: Optional[pulumi.Input['WorkGroupEncryptionConfigurationArgs']]):
pulumi.set(self, "encryption_configuration", value)
@property
@pulumi.getter(name="outputLocation")
def output_location(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "output_location")
@output_location.setter
def output_location(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "output_location", value)
@property
@pulumi.getter(name="removeEncryptionConfiguration")
def remove_encryption_configuration(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "remove_encryption_configuration")
@remove_encryption_configuration.setter
def remove_encryption_configuration(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "remove_encryption_configuration", value)
@property
@pulumi.getter(name="removeOutputLocation")
def remove_output_location(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "remove_output_location")
@remove_output_location.setter
def remove_output_location(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "remove_output_location", value)
@pulumi.input_type
class WorkGroupResultConfigurationArgs:
def __init__(__self__, *,
encryption_configuration: Optional[pulumi.Input['WorkGroupEncryptionConfigurationArgs']] = None,
output_location: Optional[pulumi.Input[str]] = None):
"""
The location in Amazon S3 where query results are stored and the encryption option, if any, used for query results. These are known as "client-side settings". If workgroup settings override client-side settings, then the query uses the workgroup settings.
"""
if encryption_configuration is not None:
pulumi.set(__self__, "encryption_configuration", encryption_configuration)
if output_location is not None:
pulumi.set(__self__, "output_location", output_location)
@property
@pulumi.getter(name="encryptionConfiguration")
def encryption_configuration(self) -> Optional[pulumi.Input['WorkGroupEncryptionConfigurationArgs']]:
return pulumi.get(self, "encryption_configuration")
@encryption_configuration.setter
def encryption_configuration(self, value: Optional[pulumi.Input['WorkGroupEncryptionConfigurationArgs']]):
pulumi.set(self, "encryption_configuration", value)
@property
@pulumi.getter(name="outputLocation")
def output_location(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "output_location")
@output_location.setter
def output_location(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "output_location", value)
@pulumi.input_type
class WorkGroupTagArgs:
def __init__(__self__, *,
key: pulumi.Input[str],
value: pulumi.Input[str]):
pulumi.set(__self__, "key", key)
pulumi.set(__self__, "value", value)
@property
@pulumi.getter
def key(self) -> pulumi.Input[str]:
return pulumi.get(self, "key")
@key.setter
def key(self, value: pulumi.Input[str]):
pulumi.set(self, "key", value)
@property
@pulumi.getter
def value(self) -> pulumi.Input[str]:
return pulumi.get(self, "value")
@value.setter
def value(self, value: pulumi.Input[str]):
pulumi.set(self, "value", value)
| 44.884131
| 430
| 0.721645
| 1,980
| 17,819
| 6.173737
| 0.080808
| 0.080088
| 0.102585
| 0.041967
| 0.813154
| 0.757281
| 0.735193
| 0.678583
| 0.655923
| 0.63948
| 0
| 0.000274
| 0.179752
| 17,819
| 396
| 431
| 44.997475
| 0.83607
| 0.067961
| 0
| 0.652459
| 1
| 0
| 0.187773
| 0.15484
| 0
| 0
| 0
| 0
| 0
| 1
| 0.203279
| false
| 0
| 0.019672
| 0.088525
| 0.337705
| 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
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
fa12a60effd543529dd43672c83d2e532dceea42
| 1,848
|
py
|
Python
|
cosmos/tests/postprocess/test_group.py
|
hadarohana/myCosmos
|
6e4682a2af822eb828180658aaa6d3e304cc85bf
|
[
"Apache-2.0"
] | null | null | null |
cosmos/tests/postprocess/test_group.py
|
hadarohana/myCosmos
|
6e4682a2af822eb828180658aaa6d3e304cc85bf
|
[
"Apache-2.0"
] | 5
|
2020-01-28T23:13:10.000Z
|
2022-02-10T00:28:15.000Z
|
cosmos/tests/postprocess/test_group.py
|
hadarohana/myCosmos
|
6e4682a2af822eb828180658aaa6d3e304cc85bf
|
[
"Apache-2.0"
] | 1
|
2021-03-10T19:25:44.000Z
|
2021-03-10T19:25:44.000Z
|
"""
Testing for group_cls
"""
import ipdb
from postprocess.postprocess import group_cls
import unittest
def test_basic_merge():
obj_list = [('Table', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('Table', [25, 25, 35, 35], 1)]
expected_list = [('Table', [10, 10, 35, 35], 1)]
actual_list = group_cls(obj_list, 'Table')
assert expected_list == actual_list
def test_basic_merge_fail():
obj_list = [('NotTable', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('NotTable', [25, 25, 35, 35], 1)]
expected_list = [('NotTable', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('NotTable', [25, 25, 35, 35], 1)]
actual_list = group_cls(obj_list, 'Table')
unittest.TestCase().assertCountEqual(expected_list, actual_list)
def test_merge_one_leave_two():
obj_list = [('Table', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('NotTable', [25, 25, 35, 35], 1)]
expected_list = [('Table', [10, 10, 35, 20], 1), ('Table', [10, 25, 20, 35], 1), ('NotTable', [25, 25, 35, 35], 1)]
actual_list = group_cls(obj_list, 'Table')
unittest.TestCase().assertCountEqual(expected_list, actual_list)
def test_merge_two_leave_one():
obj_list = [('Table', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('Table', [25, 25, 35, 35], 1),
('NotTable', [10, 22, 35, 23], 1)]
expected_list = [('Table', [10, 10, 35, 20], 1), ('NotTable', [10, 22, 35, 23], 1), ('Table', [10, 25, 35, 35], 1)]
actual_list = group_cls(obj_list, 'Table')
unittest.TestCase().assertCountEqual(expected_list, actual_list)
| 45.073171
| 139
| 0.547078
| 273
| 1,848
| 3.545788
| 0.120879
| 0.086777
| 0.090909
| 0.05062
| 0.844008
| 0.844008
| 0.81405
| 0.779959
| 0.779959
| 0.752066
| 0
| 0.176347
| 0.226732
| 1,848
| 40
| 140
| 46.2
| 0.50105
| 0.011364
| 0
| 0.448276
| 0
| 0
| 0.101266
| 0
| 0
| 0
| 0
| 0
| 0.137931
| 1
| 0.137931
| false
| 0
| 0.103448
| 0
| 0.241379
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
fa6553d8428219658417b6dc6e87f04db546d2cc
| 9,450
|
py
|
Python
|
test/test_npu/test_network_ops/test_cdist.py
|
Ascend/pytorch
|
39849cf72dafe8d2fb68bd1679d8fd54ad60fcfc
|
[
"BSD-3-Clause"
] | 1
|
2021-12-02T03:07:35.000Z
|
2021-12-02T03:07:35.000Z
|
test/test_npu/test_network_ops/test_cdist.py
|
Ascend/pytorch
|
39849cf72dafe8d2fb68bd1679d8fd54ad60fcfc
|
[
"BSD-3-Clause"
] | 1
|
2021-11-12T07:23:03.000Z
|
2021-11-12T08:28:13.000Z
|
test/test_npu/test_network_ops/test_cdist.py
|
Ascend/pytorch
|
39849cf72dafe8d2fb68bd1679d8fd54ad60fcfc
|
[
"BSD-3-Clause"
] | null | null | null |
# Copyright (c) 2020, Huawei Technologies.All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import torch
import copy
import torch.nn as nn
import numpy as np
from common_utils import TestCase, run_tests
from common_device_type import dtypes, instantiate_device_type_tests
from util_test import create_common_tensor
class Testcdist(TestCase):
def generate_data(self, min_n, max_n, shape_x, shape_y, src_type):
np.random.seed(10086)
x1 = np.random.uniform(min_n, max_n, shape_x).astype(src_type)
x2 = np.random.uniform(min_n, max_n, shape_y).astype(src_type)
return x1, x2
def op_exec(self, x1, x2, p, device='cpu'):
is_fp16 = x1.dtype == np.float16
if device == 'cpu' and is_fp16:
x1 = x1.astype(np.float32)
x2 = x2.astype(np.float32)
x1 = torch.from_numpy(x1)
x2 = torch.from_numpy(x2)
x1 = x1.to(device)
x2 = x2.to(device)
y = torch.cdist(x1, x2, p)
y = y.cpu().numpy()
if device == 'cpu' and is_fp16:
y = y.astype(np.float16)
return y
def test_cdist_float16_1(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 64), (4, 64), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 0.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 0.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float16_2(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 0.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 0.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float16_3(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 1.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 1.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float16_4(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 1.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 1.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float16_5(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float16_6(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float16_7(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(3, 5, 500), (4, 500), np.float16)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_1(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 0.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 0.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_2(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 0.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 0.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_3(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 1.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 1.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_4(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 1.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 1.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_5(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_6(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 10), (4, 10), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_7(self, device):
npu_input1, npu_input2 = self.generate_data(-1, 1,
(5, 500), (3, 4, 500), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_8(self, device):
npu_input1, npu_input2 = self.generate_data(-100, 100,
(5, 100), (3, 4, 100), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_9(self, device):
npu_input1, npu_input2 = self.generate_data(-1000, 1000,
(5, 100), (3, 4, 100), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 1.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 1.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_10(self, device):
npu_input1, npu_input2 = self.generate_data(-0.1, 0.1,
(5, 100), (3, 4, 100), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_11(self, device):
npu_input1, npu_input2 = self.generate_data(-0.1, 0.1,
(5, 100), (3, 4, 100), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 0.5, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 0.5, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_12(self, device):
npu_input1, npu_input2 = self.generate_data(-0.1, 0.1,
(16, 11, 17, 5, 84, 2), (16, 11, 17, 5, 84, 2), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
def test_cdist_float32_13(self, device):
npu_input1, npu_input2 = self.generate_data(-0.1, 0.1,
(2, 2, 13, 39, 97, 14, 2, 7), (2, 2, 13, 39, 97, 14, 12, 7), np.float32)
cpu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'cpu')
npu_output = self.op_exec(npu_input1, npu_input2, 2.0, 'npu')
self.assertRtolEqual(cpu_output, npu_output)
instantiate_device_type_tests(Testcdist, globals(), except_for="cpu")
if __name__ == "__main__":
run_tests()
| 48.71134
| 124
| 0.59418
| 1,339
| 9,450
| 3.92233
| 0.109783
| 0.102818
| 0.137091
| 0.205636
| 0.790937
| 0.790937
| 0.772848
| 0.772848
| 0.762186
| 0.74543
| 0
| 0.086251
| 0.28963
| 9,450
| 193
| 125
| 48.963731
| 0.696112
| 0.060741
| 0
| 0.633333
| 0
| 0
| 0.015798
| 0
| 0
| 0
| 0
| 0
| 0.133333
| 1
| 0.146667
| false
| 0
| 0.046667
| 0
| 0.213333
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 1
| 1
| 1
| 1
| 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
| 6
|
d71ca2044406c258ba08d4fff1b79371e73c39b5
| 141
|
py
|
Python
|
restbase/__init__.py
|
sweetpay/restbase
|
99b122192bd5ec3a57f59d56c74cdaaf25499c02
|
[
"Apache-2.0"
] | null | null | null |
restbase/__init__.py
|
sweetpay/restbase
|
99b122192bd5ec3a57f59d56c74cdaaf25499c02
|
[
"Apache-2.0"
] | null | null | null |
restbase/__init__.py
|
sweetpay/restbase
|
99b122192bd5ec3a57f59d56c74cdaaf25499c02
|
[
"Apache-2.0"
] | null | null | null |
from .base import BaseResource, BaseConnector, BaseClient, operation
__all__ = ["BaseResource", "BaseConnector", "BaseClient", "operation"]
| 35.25
| 70
| 0.77305
| 12
| 141
| 8.75
| 0.666667
| 0.47619
| 0.666667
| 0.838095
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.099291
| 141
| 3
| 71
| 47
| 0.826772
| 0
| 0
| 0
| 0
| 0
| 0.312057
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 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
| 1
| 0
| 0
| 0
|
0
| 6
|
d73a4705d0da0b5281f7ce48cf212411a22f9340
| 30,691
|
py
|
Python
|
tests/test_utilities.py
|
sulan/reconchess
|
0bd7c81f1a09d50427d91ff5336875a291f9c9a9
|
[
"BSD-3-Clause"
] | 34
|
2019-02-19T13:27:37.000Z
|
2022-02-09T07:53:20.000Z
|
tests/test_utilities.py
|
sulan/reconchess
|
0bd7c81f1a09d50427d91ff5336875a291f9c9a9
|
[
"BSD-3-Clause"
] | 21
|
2019-02-19T14:43:31.000Z
|
2022-03-30T15:25:25.000Z
|
tests/test_utilities.py
|
sulan/reconchess
|
0bd7c81f1a09d50427d91ff5336875a291f9c9a9
|
[
"BSD-3-Clause"
] | 19
|
2019-04-03T16:30:35.000Z
|
2022-03-26T03:48:20.000Z
|
import unittest
from reconchess import *
from reconchess.utilities import *
from chess import *
import random
class CastlingTestCase(unittest.TestCase):
def test_legal_castle(self):
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . K . . R
"""
board = Board()
board.set_board_fen('8/8/8/8/8/8/8/R3K2R')
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertFalse(is_illegal_castle(board, Move(E1, C1)))
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertFalse(is_illegal_castle(board, Move(E1, G1)))
def test_non_castle(self):
board = Board()
self.assertFalse(is_illegal_castle(board, Move(A2, A3)))
self.assertFalse(is_psuedo_legal_castle(board, Move(A2, A3)))
def test_queenside_castle_piece_between(self):
board = Board()
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . p K . . R
"""
board.set_board_fen('8/8/8/8/8/8/8/R2pK2R')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertTrue(is_illegal_castle(board, Move(E1, C1)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . p . K . . R
"""
board.set_board_fen('8/8/8/8/8/8/8/R1p1K2R')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertTrue(is_illegal_castle(board, Move(E1, C1)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R p . . K . . R
"""
board.set_board_fen('8/8/8/8/8/8/8/Rp2K2R')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertTrue(is_illegal_castle(board, Move(E1, C1)))
def test_kingside_castle_piece_between(self):
board = Board()
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . K p . R
"""
board.set_board_fen('8/8/8/8/8/8/8/R3Kp1R')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertTrue(is_illegal_castle(board, Move(E1, G1)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . K . p R
"""
board.set_board_fen('8/8/8/8/8/8/8/R3K1pR')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertTrue(is_illegal_castle(board, Move(E1, G1)))
def test_castle_no_rights(self):
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . K . . R
"""
board = Board()
board.set_board_fen('8/8/8/8/8/8/8/R3K2R')
board.set_castling_fen('-')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertTrue(is_illegal_castle(board, Move(E1, G1)))
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertTrue(is_illegal_castle(board, Move(E1, C1)))
board.set_castling_fen('Q')
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertTrue(is_illegal_castle(board, Move(E1, G1)))
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertFalse(is_illegal_castle(board, Move(E1, C1)))
board.set_castling_fen('K')
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertFalse(is_illegal_castle(board, Move(E1, G1)))
self.assertFalse(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertTrue(is_illegal_castle(board, Move(E1, C1)))
board.set_castling_fen('KQ')
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertFalse(is_illegal_castle(board, Move(E1, G1)))
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, C1)))
self.assertFalse(is_illegal_castle(board, Move(E1, C1)))
def test_castling_into_check(self):
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . q .
. . . . . . . .
. . . . . . . .
. . . . K . . R
"""
board = Board()
board.set_board_fen('8/8/8/8/6q1/8/8/4K2R')
self.assertFalse(board.is_check())
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertFalse(is_illegal_castle(board, Move(E1, G1)))
board.push(Move(E1, G1))
board.turn = WHITE
self.assertTrue(board.is_check())
def test_castling_out_of_check(self):
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
q . . . K . . R
"""
board = Board()
board.set_board_fen('8/8/8/8/8/8/8/q3K2R')
self.assertTrue(board.is_check())
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertFalse(is_illegal_castle(board, Move(E1, G1)))
board.push(Move(E1, G1))
board.turn = WHITE
self.assertFalse(board.is_check())
def test_castling_stay_in_check(self):
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . q .
. . . . . . . .
. . . . K . . R
"""
board = Board()
board.set_board_fen('8/8/8/8/8/6q1/8/4K2R')
self.assertTrue(board.is_check())
self.assertTrue(is_psuedo_legal_castle(board, Move(E1, G1)))
self.assertFalse(is_illegal_castle(board, Move(E1, G1)))
board.push(Move(E1, G1))
board.turn = WHITE
self.assertTrue(board.is_check())
class SlidingMoveTestCase(unittest.TestCase):
def test_sliding_pawn(self):
"""Tests a pawn moving forwards 1 and 2 spaces through enemy pawns"""
board = Board()
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . p . . . .
. . . P . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/8/8/8/3p4/3P4/8')
for to_square in [D2, D3, D4, D5, D6, D7, D8]:
self.assertEqual(None, slide_move(board, Move(D2, to_square)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . p . . . .
. . . . . . . .
. . . P . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/8/8/3p4/8/3P4/8')
self.assertEqual(Move(D2, D3), slide_move(board, Move(D2, D3)))
self.assertEqual(Move(D2, D3), slide_move(board, Move(D2, D4)))
self.assertEqual(Move(D2, D3), slide_move(board, Move(D2, D5)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . p . . . .
. . . . . . . .
. . . . . . . .
. . . P . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/8/3p4/8/8/3P4/8')
self.assertEqual(Move(D2, D3), slide_move(board, Move(D2, D3)))
self.assertEqual(Move(D2, D4), slide_move(board, Move(D2, D4)))
self.assertEqual(Move(D2, D4), slide_move(board, Move(D2, D5)))
"""
. . . . . . . .
. . . . . . . .
. . . p . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . P . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/3p4/8/8/8/3P4/8')
self.assertEqual(Move(D2, D3), slide_move(board, Move(D2, D3)))
self.assertEqual(Move(D2, D4), slide_move(board, Move(D2, D4)))
self.assertEqual(Move(D2, D4), slide_move(board, Move(D2, D5)))
self.assertEqual(Move(D2, D4), slide_move(board, Move(D2, D6)))
def test_sliding_straight_captures(self, piece_type=ROOK):
"""Tests a rook moving through enemy pieces and capturing them"""
board = Board()
moves = [Move(D5, C5), Move(D5, B5), Move(D5, A5), Move(D5, D6), Move(D5, D7), Move(D5, D8), Move(D5, E5),
Move(D5, F5), Move(D5, G5), Move(D5, H5), Move(D5, D4), Move(D5, D3), Move(D5, D2), Move(D5, D1)]
# NOTE: In board diagrams for this function X = piece_type
"""
. . . . . . . .
. . . p . . . .
. . p X p . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/3p4/2pRp3/8/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C5), Move(D5, C5), Move(D5, C5), Move(D5, D6), Move(D5, D6), Move(D5, D6), Move(D5, E5),
Move(D5, E5), Move(D5, E5), Move(D5, E5), Move(D5, D4), Move(D5, D3), Move(D5, D2), Move(D5, D1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. . . p . . . .
. . . . . . . .
. p . X . p . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/3p4/8/1p1R1p2/8/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C5), Move(D5, B5), Move(D5, B5), Move(D5, D6), Move(D5, D7), Move(D5, D7), Move(D5, E5),
Move(D5, F5), Move(D5, F5), Move(D5, F5), Move(D5, D4), Move(D5, D3), Move(D5, D2), Move(D5, D1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . p . . . .
. . . . . . . .
. . . . . . . .
p . . X . . p .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('3p4/8/8/p2R2p1/8/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C5), Move(D5, B5), Move(D5, A5), Move(D5, D6), Move(D5, D7), Move(D5, D8), Move(D5, E5),
Move(D5, F5), Move(D5, G5), Move(D5, G5), Move(D5, D4), Move(D5, D3), Move(D5, D2), Move(D5, D1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . X . . . p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/8/3R3p/8/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C5), Move(D5, B5), Move(D5, A5), Move(D5, D6), Move(D5, D7), Move(D5, D8), Move(D5, E5),
Move(D5, F5), Move(D5, G5), Move(D5, H5), Move(D5, D4), Move(D5, D3), Move(D5, D2), Move(D5, D1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . X . . . p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/8/3R4/8/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C5), Move(D5, B5), Move(D5, A5), Move(D5, D6), Move(D5, D7), Move(D5, D8), Move(D5, E5),
Move(D5, F5), Move(D5, G5), Move(D5, H5), Move(D5, D4), Move(D5, D3), Move(D5, D2), Move(D5, D1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
def test_sliding_straight_allies(self, piece_type=ROOK):
"""Tests a rook moving through a ally piece"""
board = Board()
# NOTE: In board diagrams for this function X = piece_type
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
"""
moves = [Move(A1, A2), Move(A1, A3), Move(A1, A4), Move(A1, A5), Move(A1, A6), Move(A1, A7), Move(A1, A8),
Move(A1, B1), Move(A1, C1), Move(A1, D1), Move(A1, E1), Move(A1, F1), Move(A1, G1), Move(A1, H1)]
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
X N B Q K B N R
"""
board.set_board_fen('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR')
board.set_piece_at(A1, Piece(piece_type, WHITE))
results = [None, None, None, None, None, None, None, None, None, None, None, None, None, None]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
P . . . . . . .
. . . . . . . .
. P P P P P P P
X N B Q K B N R
"""
board.set_board_fen('rnbqkbnr/pppppppp/8/8/P7/8/1PPPPPPP/RNBQKBNR')
board.set_piece_at(A1, Piece(piece_type, WHITE))
results = [Move(A1, A2), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3),
None, None, None, None, None, None, None]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
P . . . . . . .
. . N . . . . .
. P P P P P P P
X . B Q K B N R
"""
board.set_board_fen('rnbqkbnr/pppppppp/8/8/P7/2N5/1PPPPPPP/R1BQKBNR')
board.set_piece_at(A1, Piece(piece_type, WHITE))
results = [Move(A1, A2), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3),
Move(A1, B1), Move(A1, B1), Move(A1, B1), Move(A1, B1), Move(A1, B1), Move(A1, B1), Move(A1, B1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
P . . . . . . .
. . N P . . . .
. P P B P P P P
X . . Q K B N R
"""
board.set_board_fen('rnbqkbnr/pppppppp/8/8/P7/2NP4/1PPBPPPP/R2QKBNR')
board.set_piece_at(A1, Piece(piece_type, WHITE))
results = [Move(A1, A2), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3),
Move(A1, B1), Move(A1, C1), Move(A1, C1), Move(A1, C1), Move(A1, C1), Move(A1, C1), Move(A1, C1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
P . . . . . . .
. . N P P N . .
. P P B K P P P
X . . Q . B . R
"""
board.set_board_fen('rnbqkbnr/pppppppp/8/8/P7/2NPPN2/1PPBKPPP/R2Q1B1R')
board.set_piece_at(A1, Piece(piece_type, WHITE))
results = [Move(A1, A2), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3), Move(A1, A3),
Move(A1, B1), Move(A1, C1), Move(A1, C1), Move(A1, C1), Move(A1, C1), Move(A1, C1), Move(A1, C1)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
def test_sliding_diagonal_captures(self, piece_type=BISHOP):
"""Tests moving a bishop diagonally through enemy pieces and capturing them"""
board = Board()
moves = [Move(D5, C6), Move(D5, B7), Move(D5, A8), Move(D5, E6), Move(D5, F7), Move(D5, G8),
Move(D5, E4), Move(D5, F3), Move(D5, G2), Move(D5, C4), Move(D5, B3), Move(D5, A2)]
# NOTE: In board diagrams for this function X = piece_type
"""
. . . . . . . .
. . . . . . . .
. . p . p . . .
. . . X . . . .
. . p . p . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/2p1p3/3B4/2p1p3/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, C6), Move(D5, C6), Move(D5, E6), Move(D5, E6), Move(D5, E6),
Move(D5, E4), Move(D5, E4), Move(D5, E4), Move(D5, C4), Move(D5, C4), Move(D5, C4)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. p . . . p . .
. . . . . . . .
. . . X . . . .
. . . . . . . .
. p . . . p . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/1p3p2/8/3B4/8/1p3p2/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, B7), Move(D5, B7), Move(D5, E6), Move(D5, F7), Move(D5, F7),
Move(D5, E4), Move(D5, F3), Move(D5, F3), Move(D5, C4), Move(D5, B3), Move(D5, B3)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
p . . . . . p .
. . . . . . . .
. . . . . . . .
. . . X . . . .
. . . . . . . .
. . . . . . . .
p . . . . . p .
. . . . . . . .
"""
board.set_board_fen('p5p1/8/8/3B4/8/8/p5p1/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, B7), Move(D5, A8), Move(D5, E6), Move(D5, F7), Move(D5, G8),
Move(D5, E4), Move(D5, F3), Move(D5, G2), Move(D5, C4), Move(D5, B3), Move(D5, A2)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . X . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . p
"""
board.set_board_fen('8/8/8/3B4/8/8/8/7p')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, B7), Move(D5, A8), Move(D5, E6), Move(D5, F7), Move(D5, G8),
Move(D5, E4), Move(D5, F3), Move(D5, G2), Move(D5, C4), Move(D5, B3), Move(D5, A2)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
def test_sliding_diagonal_allies(self, piece_type=BISHOP):
"""Tests moving a bishop diagonally through allies and stopping before them"""
board = Board()
# NOTE: In board diagrams for this function X = piece_type
"""
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
"""
moves = [Move(D5, C6), Move(D5, B7), Move(D5, A8), Move(D5, E6), Move(D5, F7), Move(D5, G8),
Move(D5, E4), Move(D5, F3), Move(D5, G2), Move(D5, C4), Move(D5, B3), Move(D5, A2)]
"""
. . . . . . . .
. . . . . . . .
. . P . P . . .
. . . R . . . .
. . P . P . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/8/2P1P3/3B4/2P1P3/8/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [None, None, None, None, None, None, None, None, None, None, None, None]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. P . . . P . .
. . . . . . . .
. . . R . . . .
. . . . . . . .
. P . . . P . .
. . . . . . . .
. . . . . . . .
"""
board.set_board_fen('8/1P3P2/8/3B4/8/1P3P2/8/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, C6), Move(D5, C6), Move(D5, E6), Move(D5, E6), Move(D5, E6),
Move(D5, E4), Move(D5, E4), Move(D5, E4), Move(D5, C4), Move(D5, C4), Move(D5, C4)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
P . . . . . P .
. . . . . . . .
. . . . . . . .
. . . R . . . .
. . . . . . . .
. . . . . . . .
P . . . . . P .
. . . . . . . .
"""
board.set_board_fen('P5P1/8/8/3B4/8/8/P5P1/8')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, B7), Move(D5, B7), Move(D5, E6), Move(D5, F7), Move(D5, F7),
Move(D5, E4), Move(D5, F3), Move(D5, F3), Move(D5, C4), Move(D5, B3), Move(D5, B3)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
"""
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . R . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . P
"""
board.set_board_fen('8/8/8/3B4/8/8/8/7P')
board.set_piece_at(D5, Piece(piece_type, WHITE))
results = [Move(D5, C6), Move(D5, B7), Move(D5, A8), Move(D5, E6), Move(D5, F7), Move(D5, G8),
Move(D5, E4), Move(D5, F3), Move(D5, G2), Move(D5, C4), Move(D5, B3), Move(D5, A2)]
self.assertEqual(results, list(map(lambda m: slide_move(board, m), moves)))
def test_sliding_queen_allies(self):
"""Tests queens sliding through allies and stopping before them"""
self.test_sliding_straight_allies(piece_type=QUEEN)
self.test_sliding_diagonal_allies(piece_type=QUEEN)
def test_sliding_queen_captures(self):
"""Tests sliding queen through enemies and capturing them"""
self.test_sliding_straight_captures(piece_type=QUEEN)
self.test_sliding_diagonal_captures(piece_type=QUEEN)
class CaptureSquareTestCase(unittest.TestCase):
def test_pass(self):
board = Board()
self.assertEqual(capture_square_of_move(board, None), None)
board.turn = BLACK
self.assertEqual(capture_square_of_move(board, None), None)
def test_white_en_passant(self):
"""
r n b q k b n r
. p p p p p p p
. . . . . . . .
p P . . . . . .
. . . . . . . .
. . . . . . . .
P . P P P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('rnbqkbnr/pppppppp/8/1P6/8/8/P1PPPPPP/RNBQKBNR')
board.turn = BLACK
board.push(Move(A7, A5))
self.assertEqual(capture_square_of_move(board, Move(B5, A6)), A5)
def test_black_en_passant(self):
"""
r n b q k b n r
p . p p p p p p
. . . . . . . .
. . . . . . . .
P p . . . . . .
. . . . . . . .
. P P P P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('rnbqkbnr/p1pppppp/8/8/1p6/8/PPPPPPPP/RNBQKBNR')
board.turn = WHITE
board.push(Move(A2, A4))
self.assertEqual(capture_square_of_move(board, Move(B4, A3)), A4)
def test_fuzz_capture(self, max_turns=500):
board = Board()
turn = 1
while not board.is_game_over() and turn < max_turns:
move = random.choice(list(board.generate_pseudo_legal_moves()))
if board.is_en_passant(move):
self.assertNotEqual(capture_square_of_move(board, move), move.to_square)
elif board.is_capture(move):
self.assertEqual(capture_square_of_move(board, move), move.to_square)
else:
self.assertEqual(capture_square_of_move(board, move), None)
board.push(move)
turn += 1
class NoOpponentsPiecesTestCase(unittest.TestCase):
def test_white(self, board=Board()):
board.turn = WHITE
no_opponents_board = without_opponent_pieces(board)
for piece_type in PIECE_TYPES:
self.assertEqual(board.pieces(piece_type, WHITE), no_opponents_board.pieces(piece_type, WHITE))
self.assertEqual(SquareSet(), no_opponents_board.pieces(piece_type, BLACK))
def test_black(self, board=Board()):
board.turn = BLACK
no_opponents_board = without_opponent_pieces(board)
for piece_type in PIECE_TYPES:
self.assertEqual(board.pieces(piece_type, BLACK), no_opponents_board.pieces(piece_type, BLACK))
self.assertEqual(SquareSet(), no_opponents_board.pieces(piece_type, WHITE))
def test_en_passant(self):
board = Board()
board.set_board_fen('rnbqkbnr/pppppppp/8/1P6/8/8/P1PPPPPP/RNBQKBNR')
board.turn = BLACK
board.push(Move(A7, A5))
self.assertEqual(board.ep_square, chess.A6)
self.assertIn(chess.Move(chess.B5, chess.A6), board.generate_pseudo_legal_moves())
self.assertNotIn(chess.Move(chess.B5, chess.A6), moves_without_opponent_pieces(board))
def test_fuzz(self, turns=500):
board = Board()
turn = 1
while not board.is_game_over() and turn < turns:
if board.turn == WHITE:
self.test_white(board)
else:
self.test_black(board)
board.push(random.choice(list(board.generate_legal_moves())))
turn += 1
class PawnCaptureMovesTestCase(unittest.TestCase):
def setUp(self):
"""
r n b q . b n r
. . . k . P . P
. p p P p . p .
p . . p . p . p
P P P . P . P .
. . . . . . . .
. . . . . . . .
R N B Q K B N R
"""
self.board = Board()
self.board.set_board_fen('rnbq1bnr/3k1P1P/1ppPp1p1/p2p1p1p/PPP1P1P1/8/8/RNBQKBNR')
def test_white_moves(self):
moves = set(pawn_capture_moves_on(self.board))
expected = {Move(A4, B5), Move(B4, A5), Move(B4, C5), Move(C4, B5), Move(C4, D5),
Move(D6, C7), Move(D6, E7), Move(E4, D5), Move(E4, F5), Move(G4, F5), Move(G4, H5),
Move(F7, E8), Move(F7, E8, ROOK), Move(F7, E8, KNIGHT), Move(F7, E8, BISHOP), Move(F7, E8, QUEEN),
Move(F7, G8), Move(F7, G8, ROOK), Move(F7, G8, KNIGHT), Move(F7, G8, BISHOP), Move(F7, G8, QUEEN),
Move(H7, G8), Move(H7, G8, ROOK), Move(H7, G8, KNIGHT), Move(H7, G8, BISHOP), Move(H7, G8, QUEEN)}
self.assertSetEqual(moves, expected)
def test_black_moves(self):
self.board.turn = BLACK
moves = set(pawn_capture_moves_on(self.board))
expected = {Move(A5, B4), Move(B6, C5), Move(C6, B5), Move(D5, C4), Move(D5, E4),
Move(F5, E4), Move(F5, G4), Move(H5, G4)}
self.assertSetEqual(moves, expected)
class AddPawnQueenPromotionTestCase(unittest.TestCase):
def test_white_pawn(self):
"""
. n b q k b n r
P p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. P P P P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('1nbqkbnr/Pppppppp/8/8/8/8/1PPPPPPP/RNBQKBNR')
self.assertEqual(add_pawn_queen_promotion(board, Move(A7, A8)), Move(A7, A8, promotion=chess.QUEEN))
self.assertEqual(add_pawn_queen_promotion(board, Move(A7, B8)), Move(A7, B8, promotion=chess.QUEEN))
def test_black_pawn(self):
"""
r n b q k b n r
p p p . p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P p P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('rnbqkbnr/ppp1pppp/8/8/8/8/PPPpPPPP/RNBQKBNR')
self.assertEqual(add_pawn_queen_promotion(board, Move(D2, D1)), Move(D2, D1, promotion=chess.QUEEN))
self.assertEqual(add_pawn_queen_promotion(board, Move(D2, C1)), Move(D2, C1, promotion=chess.QUEEN))
self.assertEqual(add_pawn_queen_promotion(board, Move(D2, E1)), Move(D2, E1, promotion=chess.QUEEN))
def test_non_pawn(self):
"""
r n b q k b n r
R p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. P P P P P P P
. N B Q K B N R
"""
board = Board()
board.set_board_fen('rnbqkbnr/Rppppppp/8/8/8/8/1PPPPPPP/1NBQKBNR')
self.assertEqual(add_pawn_queen_promotion(board, Move(A7, A8)), Move(A7, A8))
def test_non_backrack(self):
"""
r n b q k b n r
p p p p p p p p
P . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. P P P P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('rnbqkbnr/pppppppp/P7/8/8/8/1PPPPPPP/RNBQKBNR')
self.assertEqual(add_pawn_queen_promotion(board, Move(A6, A7)), Move(A6, A7))
self.assertEqual(add_pawn_queen_promotion(board, Move(A6, B7)), Move(A6, B7))
def test_no_piece(self):
"""
r n b q k b n r
. p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('rnbqkbnr/1ppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR')
self.assertEqual(add_pawn_queen_promotion(board, Move(A7, A8)), Move(A7, A8))
self.assertEqual(add_pawn_queen_promotion(board, Move(A7, B8)), Move(A7, B8))
def test_already_has_promotion(self):
"""
. n b q k b n r
P p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. P P P P P P P
R N B Q K B N R
"""
board = Board()
board.set_board_fen('1nbqkbnr/Pppppppp/8/8/8/8/1PPPPPPP/RNBQKBNR')
for piece_type in chess.PIECE_TYPES[1:-1]:
self.assertEqual(add_pawn_queen_promotion(board, Move(A7, A8, promotion=piece_type)),
Move(A7, A8, promotion=piece_type))
| 36.32071
| 118
| 0.458766
| 3,892
| 30,691
| 3.49075
| 0.058582
| 0.036361
| 0.045488
| 0.054762
| 0.835787
| 0.803842
| 0.788312
| 0.769248
| 0.746283
| 0.712719
| 0
| 0.059093
| 0.352123
| 30,691
| 844
| 119
| 36.363744
| 0.62417
| 0.079828
| 0
| 0.544343
| 0
| 0
| 0.058584
| 0.043003
| 0
| 0
| 0
| 0
| 0.30581
| 1
| 0.097859
| false
| 0.015291
| 0.015291
| 0
| 0.131498
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
d73ecb33284029aca4f940c7ed3078ebb4858e03
| 167
|
py
|
Python
|
src/utils/conf_util.py
|
Taurin190/py-db-migration
|
9b77ac186c742851e2b5c0e45f234ba85051cc04
|
[
"MIT"
] | null | null | null |
src/utils/conf_util.py
|
Taurin190/py-db-migration
|
9b77ac186c742851e2b5c0e45f234ba85051cc04
|
[
"MIT"
] | null | null | null |
src/utils/conf_util.py
|
Taurin190/py-db-migration
|
9b77ac186c742851e2b5c0e45f234ba85051cc04
|
[
"MIT"
] | null | null | null |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import configparser
config = configparser.ConfigParser()
def get_conf(directory, key):
return config[directory][key]
| 20.875
| 36
| 0.718563
| 21
| 167
| 5.666667
| 0.761905
| 0.201681
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.006849
| 0.125749
| 167
| 8
| 37
| 20.875
| 0.808219
| 0.245509
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0.25
| 0.75
| 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
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
d74f2efd9ae3c8c20304afeeda5997be6e0043f3
| 96
|
py
|
Python
|
venv/lib/python3.8/site-packages/virtualenv/create/creator.py
|
GiulianaPola/select_repeats
|
17a0d053d4f874e42cf654dd142168c2ec8fbd11
|
[
"MIT"
] | 2
|
2022-03-13T01:58:52.000Z
|
2022-03-31T06:07:54.000Z
|
venv/lib/python3.8/site-packages/virtualenv/create/creator.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | 19
|
2021-11-20T04:09:18.000Z
|
2022-03-23T15:05:55.000Z
|
venv/lib/python3.8/site-packages/virtualenv/create/creator.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | null | null | null |
/home/runner/.cache/pip/pool/ae/f7/45/84178a640d3308aa1516ef37470ef16b83c23eea7043f9152f1ef08ca4
| 96
| 96
| 0.895833
| 9
| 96
| 9.555556
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.4375
| 0
| 96
| 1
| 96
| 96
| 0.458333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
d78c4a7bef27eb9bea9d56c27b641f456f10a8cc
| 44
|
py
|
Python
|
pyxb/bundles/opengis/_sam.py
|
eLBati/pyxb
|
14737c23a125fd12c954823ad64fc4497816fae3
|
[
"Apache-2.0"
] | 123
|
2015-01-12T06:43:22.000Z
|
2022-03-20T18:06:46.000Z
|
pyxb/bundles/opengis/_sam.py
|
eLBati/pyxb
|
14737c23a125fd12c954823ad64fc4497816fae3
|
[
"Apache-2.0"
] | 103
|
2015-01-08T18:35:57.000Z
|
2022-01-18T01:44:14.000Z
|
pyxb/bundles/opengis/_sam.py
|
eLBati/pyxb
|
14737c23a125fd12c954823ad64fc4497816fae3
|
[
"Apache-2.0"
] | 54
|
2015-02-15T17:12:00.000Z
|
2022-03-07T23:02:32.000Z
|
from pyxb.bundles.opengis.raw._sam import *
| 22
| 43
| 0.795455
| 7
| 44
| 4.857143
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.090909
| 44
| 1
| 44
| 44
| 0.85
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
ad09013fb50770c4d07059022a06f92c5ba26972
| 25
|
py
|
Python
|
modules/uicontrols/back/__init__.py
|
danlkv/pywebviz
|
5892ef90f28dbd43c33fefbfa5a199d15322a120
|
[
"MIT"
] | null | null | null |
modules/uicontrols/back/__init__.py
|
danlkv/pywebviz
|
5892ef90f28dbd43c33fefbfa5a199d15322a120
|
[
"MIT"
] | 3
|
2019-11-24T21:03:39.000Z
|
2019-12-08T04:58:07.000Z
|
modules/uicontrols/back/__init__.py
|
DaniloZZZ/pywebviz
|
5892ef90f28dbd43c33fefbfa5a199d15322a120
|
[
"MIT"
] | null | null | null |
from . import uicontrols
| 12.5
| 24
| 0.8
| 3
| 25
| 6.666667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.16
| 25
| 1
| 25
| 25
| 0.952381
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
ad2c6bb377e07df4d055636137a59660d6f8b296
| 45
|
py
|
Python
|
pyecharts/see_version.py
|
jiaweiM/PlotNotes
|
c62dd1884466fbc87eb2968163a8630dee7e41c1
|
[
"MIT"
] | null | null | null |
pyecharts/see_version.py
|
jiaweiM/PlotNotes
|
c62dd1884466fbc87eb2968163a8630dee7e41c1
|
[
"MIT"
] | null | null | null |
pyecharts/see_version.py
|
jiaweiM/PlotNotes
|
c62dd1884466fbc87eb2968163a8630dee7e41c1
|
[
"MIT"
] | null | null | null |
import pyecharts
print(pyecharts.__version__)
| 22.5
| 28
| 0.888889
| 5
| 45
| 7.2
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.044444
| 45
| 2
| 28
| 22.5
| 0.837209
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0.5
| 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
| 1
| 0
| 1
| 0
| 0
| 1
|
0
| 6
|
ad48eb34bcc5b9664b567354129c65014743ab2d
| 7,275
|
py
|
Python
|
example/analyze_roc.py
|
SoftSec-KAIST/tiknib
|
5f1e25df0ff652cf35574dae3e6a3cfb3b163e63
|
[
"MIT"
] | 69
|
2020-11-24T06:50:49.000Z
|
2022-03-22T08:53:38.000Z
|
example/analyze_roc.py
|
SoftSec-KAIST/tiknib
|
5f1e25df0ff652cf35574dae3e6a3cfb3b163e63
|
[
"MIT"
] | 8
|
2020-11-27T12:11:25.000Z
|
2022-03-20T14:11:13.000Z
|
example/analyze_roc.py
|
SoftSec-KAIST/tiknib
|
5f1e25df0ff652cf35574dae3e6a3cfb3b163e63
|
[
"MIT"
] | 13
|
2020-11-26T03:25:14.000Z
|
2022-03-24T03:25:24.000Z
|
import os
import sys
import yaml
from test_roc import load_options
fnames = [
"results/config_gnu_normal_all/2020-11-18 13:46:56.393364/data-9.pickle",
"results/config_gnu_normal_all_type/2020-11-18 15:34:08.325131/data-9.pickle",
"results/config_gnu_normal_arch_all/2020-11-18 13:53:26.976885/data-9.pickle",
"results/config_gnu_normal_arch_all_type/2020-11-18 15:40:57.209088/data-9.pickle",
"results/config_gnu_normal_arch_arm_mips/2020-11-18 13:59:06.807332/data-9.pickle",
"results/config_gnu_normal_arch_arm_mips_type/2020-11-18 15:52:16.457207/data-9.pickle",
"results/config_gnu_normal_arch_bits/2020-11-18 14:00:58.467297/data-9.pickle",
"results/config_gnu_normal_arch_bits_type/2020-11-18 15:54:18.953425/data-9.pickle",
"results/config_gnu_normal_arch_endian/2020-11-18 14:04:25.204567/data-9.pickle",
"results/config_gnu_normal_arch_endian_type/2020-11-18 15:58:04.408998/data-9.pickle",
"results/config_gnu_normal_arch_x86_32-mipseb_64/2020-11-18 14:06:39.619138/data-9.pickle",
"results/config_gnu_normal_arch_x86_32-mipseb_64_type/2020-11-18 16:00:22.271610/data-9.pickle",
"results/config_gnu_normal_arch_x86_arm/2020-11-18 14:08:29.490628/data-9.pickle",
"results/config_gnu_normal_arch_x86_arm_type/2020-11-18 16:02:11.646741/data-9.pickle",
"results/config_gnu_normal_arch_x86_mips/2020-11-18 14:10:12.834826/data-9.pickle",
"results/config_gnu_normal_arch_x86_mips_type/2020-11-18 16:04:07.967808/data-9.pickle",
"results/config_gnu_normal_comp_all/2020-11-18 14:11:57.116225/data-9.pickle",
"results/config_gnu_normal_comp_all_type/2020-11-18 16:06:00.642131/data-9.pickle",
"results/config_gnu_normal_comp_clang/2020-11-18 14:20:32.530987/data-9.pickle",
"results/config_gnu_normal_comp_clang4-gcc8/2020-11-18 14:18:15.595060/data-9.pickle",
"results/config_gnu_normal_comp_clang4-gcc8_type/2020-11-18 16:12:10.109482/data-9.pickle",
"results/config_gnu_normal_comp_clang_type/2020-11-18 16:14:24.004042/data-9.pickle",
"results/config_gnu_normal_comp_gcc/2020-11-18 14:28:42.864321/data-9.pickle",
"results/config_gnu_normal_comp_gcc4-clang7/2020-11-18 14:22:53.992912/data-9.pickle",
"results/config_gnu_normal_comp_gcc4-clang7_type/2020-11-18 16:16:51.813816/data-9.pickle",
"results/config_gnu_normal_comp_gcc-clang/2020-11-18 14:25:15.189431/data-9.pickle",
"results/config_gnu_normal_comp_gcc-clang_type/2020-11-18 16:18:58.020710/data-9.pickle",
"results/config_gnu_normal_comp_gcc_type/2020-11-18 16:22:04.013482/data-9.pickle",
"results/config_gnu_normal_hard/2020-11-18 14:30:51.026836/data-9.pickle",
"results/config_gnu_normal_hard_type/2020-11-18 16:24:10.376050/data-9.pickle",
"results/config_gnu_normal_obfus_all/2020-11-18 14:32:11.739096/data-9.pickle",
"results/config_gnu_normal_obfus_all_type/2020-11-18 16:25:28.413030/data-9.pickle",
"results/config_gnu_normal_obfus_bcf/2020-11-18 14:34:10.010568/data-9.pickle",
"results/config_gnu_normal_obfus_bcf_type/2020-11-18 16:27:34.066475/data-9.pickle",
"results/config_gnu_normal_obfus_fla/2020-11-18 14:36:08.986059/data-9.pickle",
"results/config_gnu_normal_obfus_fla_type/2020-11-18 16:29:44.656577/data-9.pickle",
"results/config_gnu_normal_obfus_hard/2020-11-18 14:38:26.912991/data-9.pickle",
"results/config_gnu_normal_obfus_hard_type/2020-11-18 16:31:48.797762/data-9.pickle",
"results/config_gnu_normal_obfus_sub/2020-11-18 14:39:46.049780/data-9.pickle",
"results/config_gnu_normal_obfus_sub_type/2020-11-18 16:33:08.511015/data-9.pickle",
"results/config_gnu_normal_opti_all_Os/2020-11-18 14:42:18.972945/data-9.pickle",
"results/config_gnu_normal_opti_all_Os_type/2020-11-18 16:35:41.904540/data-9.pickle",
"results/config_gnu_normal_opti_O0-O3/2020-11-18 14:48:53.159331/data-9.pickle",
"results/config_gnu_normal_opti_O0-O3_type/2020-11-18 16:41:32.105557/data-9.pickle",
"results/config_gnu_normal_opti_O0-Os/2020-11-18 14:51:04.318574/data-9.pickle",
"results/config_gnu_normal_opti_O0-Os_type/2020-11-18 16:43:20.273041/data-9.pickle",
"results/config_gnu_normal_opti_O0toO3/2020-11-18 14:53:21.164339/data-9.pickle",
"results/config_gnu_normal_opti_O0toO3_type/2020-11-18 16:45:26.474475/data-9.pickle",
"results/config_gnu_normal_opti_O1-O2/2020-11-18 14:58:56.411886/data-9.pickle",
"results/config_gnu_normal_opti_O1-O2_type/2020-11-18 16:50:15.961717/data-9.pickle",
"results/config_gnu_normal_opti_O1-Os/2020-11-18 15:01:00.279025/data-9.pickle",
"results/config_gnu_normal_opti_O1-Os_type/2020-11-18 16:52:14.760052/data-9.pickle",
"results/config_gnu_normal_opti_O2-O3/2020-11-18 15:03:07.179628/data-9.pickle",
"results/config_gnu_normal_opti_O2-O3_type/2020-11-18 16:54:16.951183/data-9.pickle",
"results/config_gnu_normal_opti_O2-Os/2020-11-18 15:05:03.819592/data-9.pickle",
"results/config_gnu_normal_opti_O2-Os_type/2020-11-18 16:56:05.352433/data-9.pickle",
"results/config_gnu_normal_opti_O3-Os/2020-11-18 15:07:11.550331/data-9.pickle",
"results/config_gnu_normal_opti_O3-Os_type/2020-11-18 16:58:03.572961/data-9.pickle",
"results/config_gnu_normal_others_lto/2020-11-18 15:10:30.730843/data-9.pickle",
"results/config_gnu_normal_others_lto_hard/2020-11-18 15:09:11.708610/data-9.pickle",
"results/config_gnu_normal_others_lto_hard_type/2020-11-18 16:59:54.801029/data-9.pickle",
"results/config_gnu_normal_others_lto_type/2020-11-18 17:01:14.123024/data-9.pickle",
"results/config_gnu_normal_others_noinline/2020-11-18 15:20:22.294422/data-9.pickle",
"results/config_gnu_normal_others_noinline_from_O1/2020-11-18 15:17:25.625257/data-9.pickle",
"results/config_gnu_normal_others_noinline_from_O1_hard/2020-11-18 15:15:46.402218/data-9.pickle",
"results/config_gnu_normal_others_noinline_from_O1_hard_type/2020-11-18 17:04:08.727242/data-9.pickle",
"results/config_gnu_normal_others_noinline_from_O1_type/2020-11-18 17:05:29.132283/data-9.pickle",
"results/config_gnu_normal_others_noinline_type/2020-11-18 17:08:15.539633/data-9.pickle",
"results/config_gnu_normal_others_pie/2020-11-18 15:26:14.232021/data-9.pickle",
"results/config_gnu_normal_others_pie_hard/2020-11-18 15:24:42.728424/data-9.pickle",
"results/config_gnu_normal_others_pie_hard_type/2020-11-18 17:11:47.505651/data-9.pickle",
"results/config_gnu_normal_others_pie_type/2020-11-18 17:13:05.941983/data-9.pickle",
]
import pickle
for fname in fnames:
with open(fname, "rb") as f:
data = pickle.load(f)
config_fname = fname.split("/")[1]
if "type" in config_fname:
continue
config_fname = os.path.join("config", "gnu", config_fname + ".yml")
with open(config_fname, "r") as f:
config = yaml.safe_load(f)
config["fname"] = config_fname
# setup output directory
options, dst_options = load_options(config)
train_func_keys, train_tps, train_tns, train_opts = data[:4]
train_roc, train_ap, train_time = data[4:7]
test_func_keys, test_tps, test_tns, test_opts = data[7:11]
test_roc, test_ap, test_time = data[11:14]
features, feature_indices = data[14:16]
print("=" * 30)
print(fname)
print(test_roc)
| 67.361111
| 107
| 0.768935
| 1,361
| 7,275
| 3.83468
| 0.155768
| 0.125886
| 0.220732
| 0.303506
| 0.719103
| 0.635371
| 0.586511
| 0.580188
| 0.566009
| 0.326116
| 0
| 0.238203
| 0.085361
| 7,275
| 107
| 108
| 67.990654
| 0.546138
| 0.003024
| 0
| 0
| 0
| 0.734694
| 0.809681
| 0.796028
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.05102
| 0
| 0.05102
| 0.030612
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
ad71938c1160ee69e6735fed8a9f519dd3df94ba
| 144
|
py
|
Python
|
winter/exceptions/exceptions.py
|
EvgenySmekalin/winter
|
24b6a02f958478547a4a120324823743a1f7e1a1
|
[
"MIT"
] | 3
|
2020-04-14T11:17:55.000Z
|
2021-12-27T03:34:45.000Z
|
winter/exceptions/exceptions.py
|
EvgenySmekalin/winter
|
24b6a02f958478547a4a120324823743a1f7e1a1
|
[
"MIT"
] | 10
|
2020-04-09T02:31:02.000Z
|
2022-02-08T20:02:27.000Z
|
winter/exceptions/exceptions.py
|
EvgenySmekalin/winter
|
24b6a02f958478547a4a120324823743a1f7e1a1
|
[
"MIT"
] | 8
|
2020-07-16T13:56:50.000Z
|
2021-12-27T03:33:23.000Z
|
class RedirectException(Exception):
def __init__(self, redirect_to: str):
super().__init__()
self.redirect_to = redirect_to
| 28.8
| 41
| 0.6875
| 16
| 144
| 5.5
| 0.625
| 0.340909
| 0.363636
| 0.409091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.208333
| 144
| 4
| 42
| 36
| 0.77193
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
0f8b49adc89f1ce9c777d2f40f63ba193139aeff
| 142
|
py
|
Python
|
app.py
|
ricklei/faceid-python
|
8bc727d4b419d1c3ba9bbaa8701b515c458bc012
|
[
"MIT"
] | null | null | null |
app.py
|
ricklei/faceid-python
|
8bc727d4b419d1c3ba9bbaa8701b515c458bc012
|
[
"MIT"
] | null | null | null |
app.py
|
ricklei/faceid-python
|
8bc727d4b419d1c3ba9bbaa8701b515c458bc012
|
[
"MIT"
] | null | null | null |
class App(object):
@property
def ScreenWidth(self):
return 1024
@property
def ScreenHeight(self):
return 768
| 15.777778
| 27
| 0.605634
| 15
| 142
| 5.733333
| 0.733333
| 0.255814
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.072165
| 0.316901
| 142
| 9
| 28
| 15.777778
| 0.814433
| 0
| 0
| 0.285714
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0
| 0
| 0.285714
| 0.714286
| 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
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
7e70ec855fb8f427b7e7193195b71e722e595acb
| 51,404
|
py
|
Python
|
splunk_sdk/action/gen_models.py
|
ahallur/splunk-cloud-sdk-python
|
27914e4cb624bcc67788408688553cfb99f64aa1
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
splunk_sdk/action/gen_models.py
|
ahallur/splunk-cloud-sdk-python
|
27914e4cb624bcc67788408688553cfb99f64aa1
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
splunk_sdk/action/gen_models.py
|
ahallur/splunk-cloud-sdk-python
|
27914e4cb624bcc67788408688553cfb99f64aa1
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
# Copyright © 2019 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# [http://www.apache.org/licenses/LICENSE-2.0]
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
############# This file is auto-generated. Do not edit! #############
"""
SDC Service: Action Service
With the Splunk Cloud Action service, you can receive incoming trigger events and use pre-defined action templates to turn these events into meaningful actions.
OpenAPI spec version: v1beta2.7
Generated by: https://openapi-generator.tech
"""
from datetime import datetime
from typing import List, Dict
from splunk_sdk.common.sscmodel import SSCModel
from splunk_sdk.base_client import dictify, inflate
from enum import Enum
class Action(SSCModel):
from_dict_handlers = dict()
@staticmethod
def _from_dict(model: dict) -> "Action":
kind = model['kind']
handler = Action.from_dict_handlers[kind]
if handler is not None:
return handler(model)
else:
raise ValueError("Unknown value for kind")
def __init__(self, created_at: "datetime" = None, created_by: "str" = None, name: "str" = None, updated_at: "datetime" = None, updated_by: "str" = None, **extra):
"""Action"""
self._attrs = dict()
if name is not None:
self._attrs["name"] = name
if created_at is not None:
self._attrs["createdAt"] = created_at
if created_by is not None:
self._attrs["createdBy"] = created_by
if updated_at is not None:
self._attrs["updatedAt"] = updated_at
if updated_by is not None:
self._attrs["updatedBy"] = updated_by
for k, v in extra.items():
self._attrs[k] = v
@property
def name(self) -> "str":
""" Gets the name of this Action.
The name of the action, as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit.
"""
return self._attrs.get("name")
@name.setter
def name(self, name: "str"):
"""Sets the name of this Action.
The name of the action, as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit.
:param name: The name of this Action.
:type: str
"""
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`")
self._attrs["name"] = name
@property
def created_at(self) -> "datetime":
""" Gets the created_at of this Action.
The date and time this action template was created (ISO-8601 date/time with zone).
"""
return self._attrs.get("createdAt")
@created_at.setter
def created_at(self, created_at: "datetime"):
"""Sets the created_at of this Action.
The date and time this action template was created (ISO-8601 date/time with zone).
:param created_at: The created_at of this Action.
:type: datetime
"""
self._attrs["createdAt"] = created_at
@property
def created_by(self) -> "str":
""" Gets the created_by of this Action.
The principal that created this action template.
"""
return self._attrs.get("createdBy")
@created_by.setter
def created_by(self, created_by: "str"):
"""Sets the created_by of this Action.
The principal that created this action template.
:param created_by: The created_by of this Action.
:type: str
"""
self._attrs["createdBy"] = created_by
@property
def updated_at(self) -> "datetime":
""" Gets the updated_at of this Action.
The date and time this action template was updated (ISO-8601 date/time with zone).
"""
return self._attrs.get("updatedAt")
@updated_at.setter
def updated_at(self, updated_at: "datetime"):
"""Sets the updated_at of this Action.
The date and time this action template was updated (ISO-8601 date/time with zone).
:param updated_at: The updated_at of this Action.
:type: datetime
"""
self._attrs["updatedAt"] = updated_at
@property
def updated_by(self) -> "str":
""" Gets the updated_by of this Action.
The principal that updated this action template.
"""
return self._attrs.get("updatedBy")
@updated_by.setter
def updated_by(self, updated_by: "str"):
"""Sets the updated_by of this Action.
The principal that updated this action template.
:param updated_by: The updated_by of this Action.
:type: str
"""
self._attrs["updatedBy"] = updated_by
def to_dict(self):
raise NotImplementedError()
class ActionKind(str, Enum):
WEBHOOK = "webhook"
EMAIL = "email"
@staticmethod
def from_value(value: str):
if value == "webhook":
return ActionKind.WEBHOOK
if value == "email":
return ActionKind.EMAIL
class ActionMutable(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "ActionMutable":
instance = ActionMutable.__new__(ActionMutable)
instance._attrs = model
return instance
def __init__(self, **extra):
"""ActionMutable"""
self._attrs = dict()
for k, v in extra.items():
self._attrs[k] = v
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class StatusState(str, Enum):
QUEUED = "QUEUED"
RUNNING = "RUNNING"
DONE = "DONE"
FAILED = "FAILED"
@staticmethod
def from_value(value: str):
if value == "QUEUED":
return StatusState.QUEUED
if value == "RUNNING":
return StatusState.RUNNING
if value == "DONE":
return StatusState.DONE
if value == "FAILED":
return StatusState.FAILED
class ActionResult(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "ActionResult":
instance = ActionResult.__new__(ActionResult)
instance._attrs = model
return instance
def __init__(self, action_name: "str", state: "StatusState", status_id: "str", message: "str" = None, **extra):
"""ActionResult"""
self._attrs = dict()
if action_name is not None:
self._attrs["actionName"] = action_name
if state is not None:
self._attrs["state"] = state
if status_id is not None:
self._attrs["statusId"] = status_id
if message is not None:
self._attrs["message"] = message
for k, v in extra.items():
self._attrs[k] = v
@property
def action_name(self) -> "str":
""" Gets the action_name of this ActionResult.
"""
return self._attrs.get("actionName")
@action_name.setter
def action_name(self, action_name: "str"):
"""Sets the action_name of this ActionResult.
:param action_name: The action_name of this ActionResult.
:type: str
"""
if action_name is None:
raise ValueError("Invalid value for `action_name`, must not be `None`")
self._attrs["actionName"] = action_name
@property
def state(self) -> "StatusState":
""" Gets the state of this ActionResult.
"""
return StatusState.from_value(self._attrs.get("state"))
@state.setter
def state(self, state: "StatusState"):
"""Sets the state of this ActionResult.
:param state: The state of this ActionResult.
:type: StatusState
"""
if state is None:
raise ValueError("Invalid value for `state`, must not be `None`")
if isinstance(state, Enum):
self._attrs["state"] = state.value
else:
self._attrs["state"] = state # If you supply a string, we presume you know the service will take it.
@property
def status_id(self) -> "str":
""" Gets the status_id of this ActionResult.
"""
return self._attrs.get("statusId")
@status_id.setter
def status_id(self, status_id: "str"):
"""Sets the status_id of this ActionResult.
:param status_id: The status_id of this ActionResult.
:type: str
"""
if status_id is None:
raise ValueError("Invalid value for `status_id`, must not be `None`")
self._attrs["statusId"] = status_id
@property
def message(self) -> "str":
""" Gets the message of this ActionResult.
"""
return self._attrs.get("message")
@message.setter
def message(self, message: "str"):
"""Sets the message of this ActionResult.
:param message: The message of this ActionResult.
:type: str
"""
self._attrs["message"] = message
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class StateEnum(str, Enum):
PENDING = "PENDING"
NOT_FOUND = "NOT_FOUND"
SUCCEEDED = "SUCCEEDED"
BOUNCED = "BOUNCED"
RECIPIENT_COMPLAINED = "RECIPIENT_COMPLAINED"
@staticmethod
def from_value(value: str):
if value == "PENDING":
return StateEnum.PENDING
if value == "NOT_FOUND":
return StateEnum.NOT_FOUND
if value == "SUCCEEDED":
return StateEnum.SUCCEEDED
if value == "BOUNCED":
return StateEnum.BOUNCED
if value == "RECIPIENT_COMPLAINED":
return StateEnum.RECIPIENT_COMPLAINED
class ActionResultEmailDetail(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "ActionResultEmailDetail":
instance = ActionResultEmailDetail.__new__(ActionResultEmailDetail)
instance._attrs = model
return instance
def __init__(self, email_address: "str" = None, state: "str" = None, **extra):
"""ActionResultEmailDetail"""
self._attrs = dict()
if email_address is not None:
self._attrs["emailAddress"] = email_address
if state is not None:
self._attrs["state"] = state
for k, v in extra.items():
self._attrs[k] = v
@property
def email_address(self) -> "str":
""" Gets the email_address of this ActionResultEmailDetail.
"""
return self._attrs.get("emailAddress")
@email_address.setter
def email_address(self, email_address: "str"):
"""Sets the email_address of this ActionResultEmailDetail.
:param email_address: The email_address of this ActionResultEmailDetail.
:type: str
"""
self._attrs["emailAddress"] = email_address
@property
def state(self) -> "StateEnum":
""" Gets the state of this ActionResultEmailDetail.
"""
return StateEnum.from_value(self._attrs.get("state"))
@state.setter
def state(self, state: "str"):
"""Sets the state of this ActionResultEmailDetail.
:param state: The state of this ActionResultEmailDetail.
:type: str
"""
if isinstance(state, Enum):
self._attrs["state"] = state.value
else:
self._attrs["state"] = state # If you supply a string, we presume you know the service will take it.
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class EmailAction(Action):
@staticmethod
def _from_dict(model: dict) -> "EmailAction":
instance = EmailAction.__new__(EmailAction)
instance._attrs = model
return instance
def __init__(self, name: "str", addresses: "List[str]" = None, body: "str" = None, body_plain_text: "str" = None, created_at: "datetime" = None, created_by: "str" = None, from_name: "str" = None, members: "List[str]" = None, subject: "str" = None, title: "str" = None, updated_at: "datetime" = None, updated_by: "str" = None, **extra):
"""EmailAction"""
self._attrs = dict()
self._attrs["kind"] = "email"
if name is not None:
self._attrs["name"] = name
if addresses is not None:
self._attrs["addresses"] = addresses
if body is not None:
self._attrs["body"] = body
if body_plain_text is not None:
self._attrs["bodyPlainText"] = body_plain_text
if created_at is not None:
self._attrs["createdAt"] = created_at
if created_by is not None:
self._attrs["createdBy"] = created_by
if from_name is not None:
self._attrs["fromName"] = from_name
if members is not None:
self._attrs["members"] = members
if subject is not None:
self._attrs["subject"] = subject
if title is not None:
self._attrs["title"] = title
if updated_at is not None:
self._attrs["updatedAt"] = updated_at
if updated_by is not None:
self._attrs["updatedBy"] = updated_by
for k, v in extra.items():
self._attrs[k] = v
@property
def kind(self) -> str:
return "email"
@property
def name(self) -> "str":
""" Gets the name of this EmailAction.
The name of the action, as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit.
"""
return self._attrs.get("name")
@name.setter
def name(self, name: "str"):
"""Sets the name of this EmailAction.
The name of the action, as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit.
:param name: The name of this EmailAction.
:type: str
"""
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`")
self._attrs["name"] = name
@property
def addresses(self) -> "List[str]":
""" Gets the addresses of this EmailAction.
An array of email addresses to include as recipients. Requires a special permission set for use. Please DO NOT include actual bouncing emails in automated testing.
"""
return self._attrs.get("addresses")
@addresses.setter
def addresses(self, addresses: "List[str]"):
"""Sets the addresses of this EmailAction.
An array of email addresses to include as recipients. Requires a special permission set for use. Please DO NOT include actual bouncing emails in automated testing.
:param addresses: The addresses of this EmailAction.
:type: List[str]
"""
self._attrs["addresses"] = addresses
@property
def body(self) -> "str":
""" Gets the body of this EmailAction.
HTML content to send as the body of the email. You can use a template in this field.
"""
return self._attrs.get("body")
@body.setter
def body(self, body: "str"):
"""Sets the body of this EmailAction.
HTML content to send as the body of the email. You can use a template in this field.
:param body: The body of this EmailAction.
:type: str
"""
self._attrs["body"] = body
@property
def body_plain_text(self) -> "str":
""" Gets the body_plain_text of this EmailAction.
Optional text to send as the text/plain part of the email. If this field is not set for an email action, the Action service converts the value from the body field to text and sends that as the text/plain part when triggering the action.
"""
return self._attrs.get("bodyPlainText")
@body_plain_text.setter
def body_plain_text(self, body_plain_text: "str"):
"""Sets the body_plain_text of this EmailAction.
Optional text to send as the text/plain part of the email. If this field is not set for an email action, the Action service converts the value from the body field to text and sends that as the text/plain part when triggering the action.
:param body_plain_text: The body_plain_text of this EmailAction.
:type: str
"""
self._attrs["bodyPlainText"] = body_plain_text
@property
def created_at(self) -> "datetime":
""" Gets the created_at of this EmailAction.
The date and time this action template was created (ISO-8601 date/time with zone).
"""
return self._attrs.get("createdAt")
@created_at.setter
def created_at(self, created_at: "datetime"):
"""Sets the created_at of this EmailAction.
The date and time this action template was created (ISO-8601 date/time with zone).
:param created_at: The created_at of this EmailAction.
:type: datetime
"""
self._attrs["createdAt"] = created_at
@property
def created_by(self) -> "str":
""" Gets the created_by of this EmailAction.
The principal that created this action template.
"""
return self._attrs.get("createdBy")
@created_by.setter
def created_by(self, created_by: "str"):
"""Sets the created_by of this EmailAction.
The principal that created this action template.
:param created_by: The created_by of this EmailAction.
:type: str
"""
self._attrs["createdBy"] = created_by
@property
def from_name(self) -> "str":
""" Gets the from_name of this EmailAction.
Optional text providing a human-friendly name for the sender. Must be less than or equal to 81 characters.
"""
return self._attrs.get("fromName")
@from_name.setter
def from_name(self, from_name: "str"):
"""Sets the from_name of this EmailAction.
Optional text providing a human-friendly name for the sender. Must be less than or equal to 81 characters.
:param from_name: The from_name of this EmailAction.
:type: str
"""
self._attrs["fromName"] = from_name
@property
def members(self) -> "List[str]":
""" Gets the members of this EmailAction.
An array of tenant member names, whose profile email addresses will be included as recipients.
"""
return self._attrs.get("members")
@members.setter
def members(self, members: "List[str]"):
"""Sets the members of this EmailAction.
An array of tenant member names, whose profile email addresses will be included as recipients.
:param members: The members of this EmailAction.
:type: List[str]
"""
self._attrs["members"] = members
@property
def subject(self) -> "str":
""" Gets the subject of this EmailAction.
"""
return self._attrs.get("subject")
@subject.setter
def subject(self, subject: "str"):
"""Sets the subject of this EmailAction.
:param subject: The subject of this EmailAction.
:type: str
"""
self._attrs["subject"] = subject
@property
def title(self) -> "str":
""" Gets the title of this EmailAction.
A human-readable title for the action. Must be less than or equal to 128 characters.
"""
return self._attrs.get("title")
@title.setter
def title(self, title: "str"):
"""Sets the title of this EmailAction.
A human-readable title for the action. Must be less than or equal to 128 characters.
:param title: The title of this EmailAction.
:type: str
"""
self._attrs["title"] = title
@property
def updated_at(self) -> "datetime":
""" Gets the updated_at of this EmailAction.
The date and time this action template was updated (ISO-8601 date/time with zone).
"""
return self._attrs.get("updatedAt")
@updated_at.setter
def updated_at(self, updated_at: "datetime"):
"""Sets the updated_at of this EmailAction.
The date and time this action template was updated (ISO-8601 date/time with zone).
:param updated_at: The updated_at of this EmailAction.
:type: datetime
"""
self._attrs["updatedAt"] = updated_at
@property
def updated_by(self) -> "str":
""" Gets the updated_by of this EmailAction.
The principal that updated this action template.
"""
return self._attrs.get("updatedBy")
@updated_by.setter
def updated_by(self, updated_by: "str"):
"""Sets the updated_by of this EmailAction.
The principal that updated this action template.
:param updated_by: The updated_by of this EmailAction.
:type: str
"""
self._attrs["updatedBy"] = updated_by
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
Action.from_dict_handlers["email"] = EmailAction._from_dict
class EmailActionMutable(ActionMutable):
@staticmethod
def _from_dict(model: dict) -> "EmailActionMutable":
instance = EmailActionMutable.__new__(EmailActionMutable)
instance._attrs = model
return instance
def __init__(self, addresses: "List[str]" = None, body: "str" = None, body_plain_text: "str" = None, from_name: "str" = None, members: "List[str]" = None, subject: "str" = None, title: "str" = None, **extra):
"""EmailActionMutable"""
self._attrs = dict()
if addresses is not None:
self._attrs["addresses"] = addresses
if body is not None:
self._attrs["body"] = body
if body_plain_text is not None:
self._attrs["bodyPlainText"] = body_plain_text
if from_name is not None:
self._attrs["fromName"] = from_name
if members is not None:
self._attrs["members"] = members
if subject is not None:
self._attrs["subject"] = subject
if title is not None:
self._attrs["title"] = title
for k, v in extra.items():
self._attrs[k] = v
@property
def addresses(self) -> "List[str]":
""" Gets the addresses of this EmailActionMutable.
An array of email addresses to include as recipients. Requires a special permission set for use. Please DO NOT include actual bouncing emails in automated testing.
"""
return self._attrs.get("addresses")
@addresses.setter
def addresses(self, addresses: "List[str]"):
"""Sets the addresses of this EmailActionMutable.
An array of email addresses to include as recipients. Requires a special permission set for use. Please DO NOT include actual bouncing emails in automated testing.
:param addresses: The addresses of this EmailActionMutable.
:type: List[str]
"""
self._attrs["addresses"] = addresses
@property
def body(self) -> "str":
""" Gets the body of this EmailActionMutable.
HTML content to send as the body of the email. You can use a template in this field.
"""
return self._attrs.get("body")
@body.setter
def body(self, body: "str"):
"""Sets the body of this EmailActionMutable.
HTML content to send as the body of the email. You can use a template in this field.
:param body: The body of this EmailActionMutable.
:type: str
"""
self._attrs["body"] = body
@property
def body_plain_text(self) -> "str":
""" Gets the body_plain_text of this EmailActionMutable.
Optional text to send as the text/plain part of the email. If this field is not set for an email action, the Action service converts the value from the body field to text and sends that as the text/plain part when triggering the action.
"""
return self._attrs.get("bodyPlainText")
@body_plain_text.setter
def body_plain_text(self, body_plain_text: "str"):
"""Sets the body_plain_text of this EmailActionMutable.
Optional text to send as the text/plain part of the email. If this field is not set for an email action, the Action service converts the value from the body field to text and sends that as the text/plain part when triggering the action.
:param body_plain_text: The body_plain_text of this EmailActionMutable.
:type: str
"""
self._attrs["bodyPlainText"] = body_plain_text
@property
def from_name(self) -> "str":
""" Gets the from_name of this EmailActionMutable.
Optional text providing a human-friendly name for the sender. Must be less than or equal to 81 characters.
"""
return self._attrs.get("fromName")
@from_name.setter
def from_name(self, from_name: "str"):
"""Sets the from_name of this EmailActionMutable.
Optional text providing a human-friendly name for the sender. Must be less than or equal to 81 characters.
:param from_name: The from_name of this EmailActionMutable.
:type: str
"""
self._attrs["fromName"] = from_name
@property
def members(self) -> "List[str]":
""" Gets the members of this EmailActionMutable.
An array of tenant member names, whose profile email addresses will be included as recipients.
"""
return self._attrs.get("members")
@members.setter
def members(self, members: "List[str]"):
"""Sets the members of this EmailActionMutable.
An array of tenant member names, whose profile email addresses will be included as recipients.
:param members: The members of this EmailActionMutable.
:type: List[str]
"""
self._attrs["members"] = members
@property
def subject(self) -> "str":
""" Gets the subject of this EmailActionMutable.
"""
return self._attrs.get("subject")
@subject.setter
def subject(self, subject: "str"):
"""Sets the subject of this EmailActionMutable.
:param subject: The subject of this EmailActionMutable.
:type: str
"""
self._attrs["subject"] = subject
@property
def title(self) -> "str":
""" Gets the title of this EmailActionMutable.
A human-readable title for the action. Must be less than or equal to 128 characters.
"""
return self._attrs.get("title")
@title.setter
def title(self, title: "str"):
"""Sets the title of this EmailActionMutable.
A human-readable title for the action. Must be less than or equal to 128 characters.
:param title: The title of this EmailActionMutable.
:type: str
"""
self._attrs["title"] = title
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class PublicWebhookKey(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "PublicWebhookKey":
instance = PublicWebhookKey.__new__(PublicWebhookKey)
instance._attrs = model
return instance
def __init__(self, key: "str", **extra):
"""PublicWebhookKey"""
self._attrs = dict()
if key is not None:
self._attrs["key"] = key
for k, v in extra.items():
self._attrs[k] = v
@property
def key(self) -> "str":
""" Gets the key of this PublicWebhookKey.
A PEM-formatted, ASN.1 DER-encoded PKCS#1 key.
"""
return self._attrs.get("key")
@key.setter
def key(self, key: "str"):
"""Sets the key of this PublicWebhookKey.
A PEM-formatted, ASN.1 DER-encoded PKCS#1 key.
:param key: The key of this PublicWebhookKey.
:type: str
"""
if key is None:
raise ValueError("Invalid value for `key`, must not be `None`")
self._attrs["key"] = key
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class ServiceError(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "ServiceError":
instance = ServiceError.__new__(ServiceError)
instance._attrs = model
return instance
def __init__(self, code: "str", message: "str", details: "object" = None, more_info: "str" = None, **extra):
"""ServiceError"""
self._attrs = dict()
if code is not None:
self._attrs["code"] = code
if message is not None:
self._attrs["message"] = message
if details is not None:
self._attrs["details"] = details
if more_info is not None:
self._attrs["moreInfo"] = more_info
for k, v in extra.items():
self._attrs[k] = v
@property
def code(self) -> "str":
""" Gets the code of this ServiceError.
"""
return self._attrs.get("code")
@code.setter
def code(self, code: "str"):
"""Sets the code of this ServiceError.
:param code: The code of this ServiceError.
:type: str
"""
if code is None:
raise ValueError("Invalid value for `code`, must not be `None`")
self._attrs["code"] = code
@property
def message(self) -> "str":
""" Gets the message of this ServiceError.
"""
return self._attrs.get("message")
@message.setter
def message(self, message: "str"):
"""Sets the message of this ServiceError.
:param message: The message of this ServiceError.
:type: str
"""
if message is None:
raise ValueError("Invalid value for `message`, must not be `None`")
self._attrs["message"] = message
@property
def details(self) -> "dict":
""" Gets the details of this ServiceError.
"""
return self._attrs.get("details")
@details.setter
def details(self, details: "dict"):
"""Sets the details of this ServiceError.
:param details: The details of this ServiceError.
:type: object
"""
self._attrs["details"] = details
@property
def more_info(self) -> "str":
""" Gets the more_info of this ServiceError.
"""
return self._attrs.get("moreInfo")
@more_info.setter
def more_info(self, more_info: "str"):
"""Sets the more_info of this ServiceError.
:param more_info: The more_info of this ServiceError.
:type: str
"""
self._attrs["moreInfo"] = more_info
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class TriggerEventKind(str, Enum):
TRIGGER = "trigger"
@staticmethod
def from_value(value: str):
if value == "trigger":
return TriggerEventKind.TRIGGER
class TriggerEventActionMetadata(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "TriggerEventActionMetadata":
instance = TriggerEventActionMetadata.__new__(TriggerEventActionMetadata)
instance._attrs = model
return instance
def __init__(self, addresses: "List[str]" = None, members: "List[str]" = None, **extra):
"""TriggerEventActionMetadata"""
self._attrs = dict()
if addresses is not None:
self._attrs["addresses"] = addresses
if members is not None:
self._attrs["members"] = members
for k, v in extra.items():
self._attrs[k] = v
@property
def addresses(self) -> "List[str]":
""" Gets the addresses of this TriggerEventActionMetadata.
An array of email addresses to include as recipients. Requires a special permission set for use. Please DO NOT include actual bouncing emails in automated testing.
"""
return self._attrs.get("addresses")
@addresses.setter
def addresses(self, addresses: "List[str]"):
"""Sets the addresses of this TriggerEventActionMetadata.
An array of email addresses to include as recipients. Requires a special permission set for use. Please DO NOT include actual bouncing emails in automated testing.
:param addresses: The addresses of this TriggerEventActionMetadata.
:type: List[str]
"""
self._attrs["addresses"] = addresses
@property
def members(self) -> "List[str]":
""" Gets the members of this TriggerEventActionMetadata.
An array of tenant member names, whose profile email addresses will be included as recipients.
"""
return self._attrs.get("members")
@members.setter
def members(self, members: "List[str]"):
"""Sets the members of this TriggerEventActionMetadata.
An array of tenant member names, whose profile email addresses will be included as recipients.
:param members: The members of this TriggerEventActionMetadata.
:type: List[str]
"""
self._attrs["members"] = members
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class TriggerEvent(SSCModel):
@staticmethod
def _from_dict(model: dict) -> "TriggerEvent":
instance = TriggerEvent.__new__(TriggerEvent)
instance._attrs = model
return instance
def __init__(self, kind: "TriggerEventKind", action_metadata: "TriggerEventActionMetadata" = None, created_at: "str" = None, created_by: "str" = None, id: "str" = None, payload: "Dict[str, object]" = None, tenant: "str" = None, trigger_condition: "str" = None, trigger_name: "str" = None, ttl_seconds: "int" = 3600, **extra):
"""TriggerEvent"""
self._attrs = dict()
if kind is not None:
self._attrs["kind"] = kind
if action_metadata is not None:
self._attrs["actionMetadata"] = action_metadata.to_dict()
if created_at is not None:
self._attrs["createdAt"] = created_at
if created_by is not None:
self._attrs["createdBy"] = created_by
if id is not None:
self._attrs["id"] = id
if payload is not None:
self._attrs["payload"] = payload
if tenant is not None:
self._attrs["tenant"] = tenant
if trigger_condition is not None:
self._attrs["triggerCondition"] = trigger_condition
if trigger_name is not None:
self._attrs["triggerName"] = trigger_name
if ttl_seconds is not None:
self._attrs["ttlSeconds"] = ttl_seconds
for k, v in extra.items():
self._attrs[k] = v
@property
def kind(self) -> "TriggerEventKind":
""" Gets the kind of this TriggerEvent.
"""
return TriggerEventKind.from_value(self._attrs.get("kind"))
@kind.setter
def kind(self, kind: "TriggerEventKind"):
"""Sets the kind of this TriggerEvent.
:param kind: The kind of this TriggerEvent.
:type: TriggerEventKind
"""
if kind is None:
raise ValueError("Invalid value for `kind`, must not be `None`")
if isinstance(kind, Enum):
self._attrs["kind"] = kind.value
else:
self._attrs["kind"] = kind # If you supply a string, we presume you know the service will take it.
@property
def action_metadata(self) -> "TriggerEventActionMetadata":
""" Gets the action_metadata of this TriggerEvent.
"""
return TriggerEventActionMetadata._from_dict(self._attrs["actionMetadata"])
@action_metadata.setter
def action_metadata(self, action_metadata: "TriggerEventActionMetadata"):
"""Sets the action_metadata of this TriggerEvent.
:param action_metadata: The action_metadata of this TriggerEvent.
:type: TriggerEventActionMetadata
"""
self._attrs["actionMetadata"] = action_metadata.to_dict()
@property
def created_at(self) -> "str":
""" Gets the created_at of this TriggerEvent.
string-ified ISO-8601 date/time with zone.
"""
return self._attrs.get("createdAt")
@created_at.setter
def created_at(self, created_at: "str"):
"""Sets the created_at of this TriggerEvent.
string-ified ISO-8601 date/time with zone.
:param created_at: The created_at of this TriggerEvent.
:type: str
"""
self._attrs["createdAt"] = created_at
@property
def created_by(self) -> "str":
""" Gets the created_by of this TriggerEvent.
The principal that generated the trigger event.
"""
return self._attrs.get("createdBy")
@created_by.setter
def created_by(self, created_by: "str"):
"""Sets the created_by of this TriggerEvent.
The principal that generated the trigger event.
:param created_by: The created_by of this TriggerEvent.
:type: str
"""
self._attrs["createdBy"] = created_by
@property
def id(self) -> "str":
""" Gets the id of this TriggerEvent.
A unique identifier for this trigger event. Generated from a hash of all recursively-sorted event field values.
"""
return self._attrs.get("id")
@id.setter
def id(self, id: "str"):
"""Sets the id of this TriggerEvent.
A unique identifier for this trigger event. Generated from a hash of all recursively-sorted event field values.
:param id: The id of this TriggerEvent.
:type: str
"""
self._attrs["id"] = id
@property
def payload(self) -> "dict":
""" Gets the payload of this TriggerEvent.
"""
return self._attrs.get("payload")
@payload.setter
def payload(self, payload: "dict"):
"""Sets the payload of this TriggerEvent.
:param payload: The payload of this TriggerEvent.
:type: Dict[str, object]
"""
self._attrs["payload"] = payload
@property
def tenant(self) -> "str":
""" Gets the tenant of this TriggerEvent.
The tenant within which the trigger event was generated.
"""
return self._attrs.get("tenant")
@tenant.setter
def tenant(self, tenant: "str"):
"""Sets the tenant of this TriggerEvent.
The tenant within which the trigger event was generated.
:param tenant: The tenant of this TriggerEvent.
:type: str
"""
self._attrs["tenant"] = tenant
@property
def trigger_condition(self) -> "str":
""" Gets the trigger_condition of this TriggerEvent.
A description of the condition that caused the trigger event.
"""
return self._attrs.get("triggerCondition")
@trigger_condition.setter
def trigger_condition(self, trigger_condition: "str"):
"""Sets the trigger_condition of this TriggerEvent.
A description of the condition that caused the trigger event.
:param trigger_condition: The trigger_condition of this TriggerEvent.
:type: str
"""
self._attrs["triggerCondition"] = trigger_condition
@property
def trigger_name(self) -> "str":
""" Gets the trigger_name of this TriggerEvent.
The name of the trigger for which this event was created.
"""
return self._attrs.get("triggerName")
@trigger_name.setter
def trigger_name(self, trigger_name: "str"):
"""Sets the trigger_name of this TriggerEvent.
The name of the trigger for which this event was created.
:param trigger_name: The trigger_name of this TriggerEvent.
:type: str
"""
self._attrs["triggerName"] = trigger_name
@property
def ttl_seconds(self) -> "int":
""" Gets the ttl_seconds of this TriggerEvent.
A time to live (TTL), expressed as seconds after createdAt, after which the trigger event will no longer be acted upon.
"""
return self._attrs.get("ttlSeconds")
@ttl_seconds.setter
def ttl_seconds(self, ttl_seconds: "int"):
"""Sets the ttl_seconds of this TriggerEvent.
A time to live (TTL), expressed as seconds after createdAt, after which the trigger event will no longer be acted upon.
:param ttl_seconds: The ttl_seconds of this TriggerEvent.
:type: int
"""
self._attrs["ttlSeconds"] = ttl_seconds
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
class WebhookAction(Action):
@staticmethod
def _from_dict(model: dict) -> "WebhookAction":
instance = WebhookAction.__new__(WebhookAction)
instance._attrs = model
return instance
def __init__(self, name: "str", created_at: "datetime" = None, created_by: "str" = None, title: "str" = None, updated_at: "datetime" = None, updated_by: "str" = None, webhook_headers: "Dict[str, List[str]]" = None, webhook_payload: "str" = None, webhook_url: "str" = None, **extra):
"""WebhookAction"""
self._attrs = dict()
self._attrs["kind"] = "webhook"
if name is not None:
self._attrs["name"] = name
if created_at is not None:
self._attrs["createdAt"] = created_at
if created_by is not None:
self._attrs["createdBy"] = created_by
if title is not None:
self._attrs["title"] = title
if updated_at is not None:
self._attrs["updatedAt"] = updated_at
if updated_by is not None:
self._attrs["updatedBy"] = updated_by
if webhook_headers is not None:
self._attrs["webhookHeaders"] = webhook_headers
if webhook_payload is not None:
self._attrs["webhookPayload"] = webhook_payload
if webhook_url is not None:
self._attrs["webhookUrl"] = webhook_url
for k, v in extra.items():
self._attrs[k] = v
@property
def kind(self) -> str:
return "webhook"
@property
def name(self) -> "str":
""" Gets the name of this WebhookAction.
The name of the action, as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit.
"""
return self._attrs.get("name")
@name.setter
def name(self, name: "str"):
"""Sets the name of this WebhookAction.
The name of the action, as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit.
:param name: The name of this WebhookAction.
:type: str
"""
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`")
self._attrs["name"] = name
@property
def created_at(self) -> "datetime":
""" Gets the created_at of this WebhookAction.
The date and time this action template was created (ISO-8601 date/time with zone).
"""
return self._attrs.get("createdAt")
@created_at.setter
def created_at(self, created_at: "datetime"):
"""Sets the created_at of this WebhookAction.
The date and time this action template was created (ISO-8601 date/time with zone).
:param created_at: The created_at of this WebhookAction.
:type: datetime
"""
self._attrs["createdAt"] = created_at
@property
def created_by(self) -> "str":
""" Gets the created_by of this WebhookAction.
The principal that created this action template.
"""
return self._attrs.get("createdBy")
@created_by.setter
def created_by(self, created_by: "str"):
"""Sets the created_by of this WebhookAction.
The principal that created this action template.
:param created_by: The created_by of this WebhookAction.
:type: str
"""
self._attrs["createdBy"] = created_by
@property
def title(self) -> "str":
""" Gets the title of this WebhookAction.
A human-readable title for the action. Must be less than 128 characters.
"""
return self._attrs.get("title")
@title.setter
def title(self, title: "str"):
"""Sets the title of this WebhookAction.
A human-readable title for the action. Must be less than 128 characters.
:param title: The title of this WebhookAction.
:type: str
"""
self._attrs["title"] = title
@property
def updated_at(self) -> "datetime":
""" Gets the updated_at of this WebhookAction.
The date and time this action template was updated (ISO-8601 date/time with zone).
"""
return self._attrs.get("updatedAt")
@updated_at.setter
def updated_at(self, updated_at: "datetime"):
"""Sets the updated_at of this WebhookAction.
The date and time this action template was updated (ISO-8601 date/time with zone).
:param updated_at: The updated_at of this WebhookAction.
:type: datetime
"""
self._attrs["updatedAt"] = updated_at
@property
def updated_by(self) -> "str":
""" Gets the updated_by of this WebhookAction.
The principal that updated this action template.
"""
return self._attrs.get("updatedBy")
@updated_by.setter
def updated_by(self, updated_by: "str"):
"""Sets the updated_by of this WebhookAction.
The principal that updated this action template.
:param updated_by: The updated_by of this WebhookAction.
:type: str
"""
self._attrs["updatedBy"] = updated_by
@property
def webhook_headers(self) -> "Dict[str, List[str]]":
""" Gets the webhook_headers of this WebhookAction.
"""
return self._attrs.get("webhookHeaders")
@webhook_headers.setter
def webhook_headers(self, webhook_headers: "Dict[str, List[str]]"):
"""Sets the webhook_headers of this WebhookAction.
:param webhook_headers: The webhook_headers of this WebhookAction.
:type: Dict[str, List[str]]
"""
self._attrs["webhookHeaders"] = webhook_headers
@property
def webhook_payload(self) -> "str":
""" Gets the webhook_payload of this WebhookAction.
The (possibly) templated payload body, which is POSTed to the webhookUrl when triggered.
"""
return self._attrs.get("webhookPayload")
@webhook_payload.setter
def webhook_payload(self, webhook_payload: "str"):
"""Sets the webhook_payload of this WebhookAction.
The (possibly) templated payload body, which is POSTed to the webhookUrl when triggered.
:param webhook_payload: The webhook_payload of this WebhookAction.
:type: str
"""
self._attrs["webhookPayload"] = webhook_payload
@property
def webhook_url(self) -> "str":
""" Gets the webhook_url of this WebhookAction.
Only HTTPS is allowed.
"""
return self._attrs.get("webhookUrl")
@webhook_url.setter
def webhook_url(self, webhook_url: "str"):
"""Sets the webhook_url of this WebhookAction.
Only HTTPS is allowed.
:param webhook_url: The webhook_url of this WebhookAction.
:type: str
"""
self._attrs["webhookUrl"] = webhook_url
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
Action.from_dict_handlers["webhook"] = WebhookAction._from_dict
class WebhookActionMutable(ActionMutable):
@staticmethod
def _from_dict(model: dict) -> "WebhookActionMutable":
instance = WebhookActionMutable.__new__(WebhookActionMutable)
instance._attrs = model
return instance
def __init__(self, title: "str" = None, webhook_headers: "Dict[str, List[str]]" = None, webhook_payload: "str" = None, webhook_url: "str" = None, **extra):
"""WebhookActionMutable"""
self._attrs = dict()
if title is not None:
self._attrs["title"] = title
if webhook_headers is not None:
self._attrs["webhookHeaders"] = webhook_headers
if webhook_payload is not None:
self._attrs["webhookPayload"] = webhook_payload
if webhook_url is not None:
self._attrs["webhookUrl"] = webhook_url
for k, v in extra.items():
self._attrs[k] = v
@property
def title(self) -> "str":
""" Gets the title of this WebhookActionMutable.
A human-readable title for the action. Must be less than 128 characters.
"""
return self._attrs.get("title")
@title.setter
def title(self, title: "str"):
"""Sets the title of this WebhookActionMutable.
A human-readable title for the action. Must be less than 128 characters.
:param title: The title of this WebhookActionMutable.
:type: str
"""
self._attrs["title"] = title
@property
def webhook_headers(self) -> "Dict[str, List[str]]":
""" Gets the webhook_headers of this WebhookActionMutable.
"""
return self._attrs.get("webhookHeaders")
@webhook_headers.setter
def webhook_headers(self, webhook_headers: "Dict[str, List[str]]"):
"""Sets the webhook_headers of this WebhookActionMutable.
:param webhook_headers: The webhook_headers of this WebhookActionMutable.
:type: Dict[str, List[str]]
"""
self._attrs["webhookHeaders"] = webhook_headers
@property
def webhook_payload(self) -> "str":
""" Gets the webhook_payload of this WebhookActionMutable.
The (possibly) templated payload body, which is POSTed to the webhookUrl when triggered.
"""
return self._attrs.get("webhookPayload")
@webhook_payload.setter
def webhook_payload(self, webhook_payload: "str"):
"""Sets the webhook_payload of this WebhookActionMutable.
The (possibly) templated payload body, which is POSTed to the webhookUrl when triggered.
:param webhook_payload: The webhook_payload of this WebhookActionMutable.
:type: str
"""
self._attrs["webhookPayload"] = webhook_payload
@property
def webhook_url(self) -> "str":
""" Gets the webhook_url of this WebhookActionMutable.
Only HTTPS is allowed.
"""
return self._attrs.get("webhookUrl")
@webhook_url.setter
def webhook_url(self, webhook_url: "str"):
"""Sets the webhook_url of this WebhookActionMutable.
Only HTTPS is allowed.
:param webhook_url: The webhook_url of this WebhookActionMutable.
:type: str
"""
self._attrs["webhookUrl"] = webhook_url
def to_dict(self):
return {k: v for (k, v) in self._attrs.items() if v is not None}
| 33.379221
| 339
| 0.624309
| 6,343
| 51,404
| 4.932682
| 0.050292
| 0.063283
| 0.020711
| 0.02493
| 0.826675
| 0.785349
| 0.744918
| 0.698031
| 0.666006
| 0.653989
| 0
| 0.002879
| 0.276963
| 51,404
| 1,539
| 340
| 33.40091
| 0.838916
| 0.368298
| 0
| 0.716667
| 0
| 0
| 0.116241
| 0.004362
| 0
| 0
| 0
| 0
| 0
| 1
| 0.225
| false
| 0
| 0.006944
| 0.018056
| 0.406944
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
7e8d303053b79643182c309ee864ac8877723bfe
| 45
|
py
|
Python
|
src/__init__.py
|
bogdan-zs/requests-thread-pool
|
ddc530d814273c5a88fb8519d64bad3e852c51b4
|
[
"MIT"
] | null | null | null |
src/__init__.py
|
bogdan-zs/requests-thread-pool
|
ddc530d814273c5a88fb8519d64bad3e852c51b4
|
[
"MIT"
] | null | null | null |
src/__init__.py
|
bogdan-zs/requests-thread-pool
|
ddc530d814273c5a88fb8519d64bad3e852c51b4
|
[
"MIT"
] | null | null | null |
from .thread_pool import RequestPoolExecutor
| 22.5
| 44
| 0.888889
| 5
| 45
| 7.8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.088889
| 45
| 1
| 45
| 45
| 0.95122
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
0e76dbf576d77c50e7e154f11577d5d2a02ab8e5
| 62
|
py
|
Python
|
moulton/__init__.py
|
alvations/moulton
|
078a071ec9c549131486384032d5433471194cae
|
[
"MIT"
] | 1
|
2020-01-15T03:03:28.000Z
|
2020-01-15T03:03:28.000Z
|
moulton/__init__.py
|
alvations/moulton
|
078a071ec9c549131486384032d5433471194cae
|
[
"MIT"
] | null | null | null |
moulton/__init__.py
|
alvations/moulton
|
078a071ec9c549131486384032d5433471194cae
|
[
"MIT"
] | null | null | null |
from moulton.semantic import *
from moulton.google import *
| 12.4
| 30
| 0.774194
| 8
| 62
| 6
| 0.625
| 0.458333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.16129
| 62
| 4
| 31
| 15.5
| 0.923077
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
0e8351da744e35b7d25af52a66849906097bf61d
| 7,823
|
py
|
Python
|
tests/functional/test_institutions.py
|
ourresearch/openalex-elastic-api
|
36bf5f8906aa4d009571ec2b7e9ab745fd13933c
|
[
"MIT"
] | 2
|
2022-03-15T10:50:35.000Z
|
2022-03-24T11:03:20.000Z
|
tests/functional/test_institutions.py
|
ourresearch/openalex-elastic-api
|
36bf5f8906aa4d009571ec2b7e9ab745fd13933c
|
[
"MIT"
] | null | null | null |
tests/functional/test_institutions.py
|
ourresearch/openalex-elastic-api
|
36bf5f8906aa4d009571ec2b7e9ab745fd13933c
|
[
"MIT"
] | null | null | null |
class TestInstitutionsSearch:
def test_institutions_search(self, client):
res = client.get("/institutions?search=university")
json_data = res.get_json()
assert "university" in json_data["results"][0]["display_name"].lower()
for result in json_data["results"][:25]:
assert "university" in result["display_name"].lower()
def test_institutions_search_display_name(self, client):
res = client.get("/institutions?filter=display_name.search:university")
json_data = res.get_json()
assert "university" in json_data["results"][0]["display_name"].lower()
for result in json_data["results"][:25]:
assert "university" in result["display_name"].lower()
def test_institutions_search_exact(self, client):
res = client.get(
"/institutions?filter=display_name:Chinese Academy of Sciences"
)
json_data = res.get_json()
assert json_data["results"][0]["display_name"] == "Chinese Academy of Sciences"
class TestInstitutionsWorksCountFilter:
def test_institutions_works_count_equal(self, client):
res = client.get("/institutions?filter=works_count:850")
json_data = res.get_json()
assert json_data["meta"]["count"] == 5
for result in json_data["results"][:25]:
assert result["works_count"] == 850
def test_institutions_works_count_greater_than(self, client):
res = client.get("/institutions?filter=works_count:>200")
json_data = res.get_json()
assert json_data["meta"]["count"] == 6712
for result in json_data["results"][:25]:
assert result["works_count"] > 200
def test_institutions_works_count_less_than(self, client):
res = client.get("/institutions?filter=works_count:<200")
json_data = res.get_json()
assert json_data["meta"]["count"] == 3279
for result in json_data["results"][:25]:
assert result["works_count"] < 200
def test_institutions_works_count_error(self, client):
res = client.get("/institutions?filter=works_count:>ff")
json_data = res.get_json()
assert res.status_code == 403
assert json_data["error"] == "Invalid query parameters error."
assert json_data["message"] == "Value for param works_count must be a number."
class TestInstitutionsCitedByCountFilter:
def test_institutions_cited_by_count_equal(self, client):
res = client.get("/institutions?filter=cited_by_count:20")
json_data = res.get_json()
assert json_data["meta"]["count"] == 4
for result in json_data["results"][:25]:
assert result["cited_by_count"] == 20
def test_institutions_cited_by_count_greater_than(self, client):
res = client.get("/institutions?filter=cited_by_count:>20")
json_data = res.get_json()
assert json_data["meta"]["count"] == 9914
for result in json_data["results"][:25]:
assert result["cited_by_count"] > 20
def test_institutions_cited_by_count_less_than(self, client):
res = client.get("/institutions?filter=cited_by_count:<20")
json_data = res.get_json()
assert json_data["meta"]["count"] == 82
for result in json_data["results"][:25]:
assert result["cited_by_count"] < 20
def test_institutions_cited_by_count_error(self, client):
res = client.get("/institutions?filter=cited_by_count:>ff")
json_data = res.get_json()
assert res.status_code == 403
assert json_data["error"] == "Invalid query parameters error."
assert (
json_data["message"] == "Value for param cited_by_count must be a number."
)
class TestInstitutionsXConceptsIDFilter:
def test_institutions_x_concepts_id_short(self, client):
res = client.get("/institutions?filter=x_concepts.id:c185592680")
json_data = res.get_json()
concept_found = False
for concept in json_data["results"][0]["x_concepts"]:
if concept["id"] == "https://openalex.org/C185592680":
concept_found = True
assert concept_found == True
def test_institutions_x_concepts_id_long(self, client):
res = client.get(
"/institutions?filter=x_concepts.id:https://openalex.org/c185592680"
)
json_data = res.get_json()
concept_found = False
for concept in json_data["results"][0]["x_concepts"]:
if concept["id"] == "https://openalex.org/C185592680":
concept_found = True
assert concept_found == True
class TestInstitutionsCountryCodeFilter:
def test_institutions_country_code(self, client):
res = client.get("/institutions?filter=country_code:us")
json_data = res.get_json()
assert json_data["results"][0]["country_code"].lower() == "us"
for result in json_data["results"][:25]:
assert result["country_code"].lower() == "us"
class TestInstitutionsTypeFilter:
def test_institutions_type(self, client):
res = client.get("/institutions?filter=type:education")
json_data = res.get_json()
assert json_data["results"][0]["type"].lower() == "education"
for result in json_data["results"][:25]:
assert result["type"].lower() == "education"
class TestInstitutionsExternalIDs:
def test_institutions_has_ror_true(self, client):
res = client.get("/institutions?filter=has_ror:true")
json_data = res.get_json()
assert json_data["meta"]["count"] == 7220
for result in json_data["results"][:25]:
assert result["ids"]["ror"] is not None
def test_institutions_has_ror_false(self, client):
res = client.get("/institutions?filter=has_ror:false")
json_data = res.get_json()
assert json_data["meta"]["count"] == 2780
for result in json_data["results"][:25]:
assert result["ids"]["ror"] is None
def test_institutions_has_ror_error(self, client):
res = client.get("/institutions?filter=has_ror:stt")
json_data = res.get_json()
assert json_data["error"] == "Invalid query parameters error."
assert (
json_data["message"] == "Value for has_ror must be true or false, not stt."
)
class TestInstitutionsMultipleIDs:
def test_Institutions_openalex_multiple_long(self, client):
res = client.get(
"/institutions?filter=openalex_id:https://openalex.org/I19820366|https://openalex.org/I136199984"
)
json_data = res.get_json()
assert json_data["meta"]["count"] == 2
assert json_data["results"][0]["id"] == "https://openalex.org/I19820366"
assert json_data["results"][1]["id"] == "https://openalex.org/I136199984"
def test_institutions_ror_single_long(self, client):
res = client.get("/institutions?filter=ror:https://ror.org/034t30j35")
json_data = res.get_json()
assert json_data["meta"]["count"] == 1
assert json_data["results"][0]["ror"] == "https://ror.org/034t30j35"
def test_institutions_ror_single_short(self, client):
res = client.get("/institutions?filter=ror:034t30j35")
json_data = res.get_json()
assert json_data["meta"]["count"] == 1
assert json_data["results"][0]["ror"] == "https://ror.org/034t30j35"
def test_institutions_ror_multiple(self, client):
res = client.get(
"/institutions?filter=ror:https://ror.org/034t30j35|https://ror.org/03vek6s52"
)
json_data = res.get_json()
assert json_data["meta"]["count"] == 2
assert json_data["results"][0]["ror"] == "https://ror.org/034t30j35"
assert json_data["results"][1]["ror"] == "https://ror.org/03vek6s52"
| 43.461111
| 109
| 0.646683
| 968
| 7,823
| 4.989669
| 0.108471
| 0.10766
| 0.078261
| 0.086542
| 0.85528
| 0.809524
| 0.750932
| 0.734369
| 0.707867
| 0.615735
| 0
| 0.036426
| 0.217436
| 7,823
| 179
| 110
| 43.703911
| 0.752532
| 0
| 0
| 0.437086
| 0
| 0.013245
| 0.263965
| 0.086028
| 0
| 0
| 0
| 0
| 0.298013
| 1
| 0.145695
| false
| 0
| 0
| 0
| 0.198676
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
0ea607c04e68b96e0ae56ffaf53ffa905ca016f6
| 4,876
|
py
|
Python
|
tests/openbb_terminal/core/log/collection/test_s3_sender.py
|
tehcoderer/GamestonkTerminal
|
54a1b6f545a0016c576e9e00eef5c003d229dacf
|
[
"MIT"
] | 255
|
2022-03-29T16:43:51.000Z
|
2022-03-31T23:57:08.000Z
|
tests/openbb_terminal/core/log/collection/test_s3_sender.py
|
tehcoderer/GamestonkTerminal
|
54a1b6f545a0016c576e9e00eef5c003d229dacf
|
[
"MIT"
] | 14
|
2022-03-29T14:20:33.000Z
|
2022-03-31T23:39:20.000Z
|
tests/openbb_terminal/core/log/collection/test_s3_sender.py
|
tehcoderer/GamestonkTerminal
|
54a1b6f545a0016c576e9e00eef5c003d229dacf
|
[
"MIT"
] | 24
|
2022-03-29T15:28:56.000Z
|
2022-03-31T23:54:15.000Z
|
# IMPORTATION STANDARD
from pathlib import Path
# IMPORTATION THIRDPARTY
import pytest
# IMPORTATION INTERNAL
from openbb_terminal.core.log.generation.settings import AWSSettings
from openbb_terminal.core.log.constants import DEFAULT_API_URL
from openbb_terminal.core.log.collection import s3_sender
# pylint: disable=W0611
@pytest.mark.vcr(record_mode="none")
def test_send_to_s3_directly(mocker):
s3_sender.boto3 = mocker.Mock()
mocker.patch.object(
target=s3_sender,
attribute="WITH_BOTO3",
new=True,
)
aws_access_key_id = "MOCK_ACCESS_KEY_ID"
aws_secret_access_key = "MOCK_ACCESS_SECRET_KEY"
bucket = "MOCK_BUCKET"
file = Path(__file__)
object_key = "MOCK_S3/OBJECT_KEY"
s3_sender.send_to_s3_directly(
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
bucket=bucket,
file=file,
object_key=object_key,
)
@pytest.mark.vcr(record_mode="none")
def test_send_to_s3_directly_exception(mocker):
s3_sender.boto3 = mocker.Mock()
mocker.patch.object(
target=s3_sender,
attribute="WITH_BOTO3",
new=False,
)
aws_access_key_id = "MOCK_ACCESS_KEY_ID"
aws_secret_access_key = "MOCK_ACCESS_SECRET_KEY"
bucket = "MOCK_BUCKET"
file = Path(__file__)
object_key = "MOCK_S3/OBJECT_KEY"
with pytest.raises(ModuleNotFoundError):
s3_sender.send_to_s3_directly(
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
bucket=bucket,
file=file,
object_key=object_key,
)
@pytest.mark.vcr
def test_fetch_presigned_url():
object_key = "gst-app/logs/MOCK_OBJECT_KEY"
s3_sender.fetch_presigned_url(api_url=DEFAULT_API_URL, object_key=object_key)
@pytest.mark.vcr(record_mode="none")
def test_send_to_s3_using_presigned_url(mocker, tmp_path):
mocker.patch(
"openbb_terminal.core.log.collection.s3_sender.fetch_presigned_url",
return_value={"fields": [1, 2, 3], "url": "http://"},
)
mocker.patch("openbb_terminal.core.log.collection.s3_sender.requests")
api_url = DEFAULT_API_URL
file = tmp_path.joinpath("mock_log_file")
object_key = "MOCK_S3/OBJECT_KEY"
with open(file, "w") as f:
f.write("Mocking a log file to send to s3.")
s3_sender.send_to_s3_using_presigned_url(
api_url=api_url,
file=file,
object_key=object_key,
)
@pytest.mark.vcr(record_mode="none")
@pytest.mark.parametrize(
"aws_settings, last",
[
(
AWSSettings(
aws_access_key_id="MOCK_AWS_ACCESS_KEY_ID",
aws_secret_access_key="MOCK_AWS_ACCESS_KEY",
),
False,
),
(
AWSSettings(
aws_access_key_id="REPLACE_ME",
aws_secret_access_key="REPLACE_ME",
),
True,
),
],
)
def test_send_to_s3(aws_settings, mocker, last, tmp_path):
mocker.patch("openbb_terminal.core.log.collection.s3_sender.send_to_s3_directly")
mocker.patch(
"openbb_terminal.core.log.collection.s3_sender.send_to_s3_using_presigned_url"
)
archives_file = tmp_path.joinpath("archives").joinpath("mock_log_file")
tmp_file = tmp_path.joinpath("tmp").joinpath("mock_log_file")
file = tmp_path.joinpath("mock_log_file")
object_key = "MOCK_S3/OBJECT_KEY"
with open(file, "w") as f:
f.write("Mocking a log file to send to s3.")
assert file.exists()
assert not archives_file.exists()
assert not tmp_file.exists()
s3_sender.send_to_s3(
archives_file=archives_file,
aws_settings=aws_settings,
file=file,
object_key=object_key,
tmp_file=tmp_file,
last=last,
)
assert last or not file.exists()
assert archives_file.exists()
assert not tmp_file.exists()
@pytest.mark.vcr(record_mode="none")
def test_send_to_s3_exception(mocker, tmp_path):
mocker.patch("openbb_terminal.core.log.collection.s3_sender.send_to_s3_directly")
mocker.patch(
"openbb_terminal.core.log.collection.s3_sender.send_to_s3_using_presigned_url"
)
archives_file = tmp_path.joinpath("archives").joinpath("mock_log_file")
tmp_file = tmp_path.joinpath("tmp").joinpath("mock_log_file")
file = tmp_path.joinpath("mock_log_file")
file.touch()
object_key = "MOCK_S3/OBJECT_KEY"
with pytest.raises(AttributeError):
s3_sender.send_to_s3(
archives_file=archives_file,
aws_settings=AWSSettings(
aws_access_key_id="REPLACE_ME",
aws_secret_access_key="REPLACE_ME",
),
file=file,
object_key=object_key,
tmp_file=tmp_file,
last=False,
)
| 28.852071
| 86
| 0.673298
| 655
| 4,876
| 4.606107
| 0.138931
| 0.071594
| 0.042426
| 0.046404
| 0.831289
| 0.760689
| 0.755055
| 0.755055
| 0.705668
| 0.670534
| 0
| 0.013001
| 0.22703
| 4,876
| 168
| 87
| 29.02381
| 0.787477
| 0.017637
| 0
| 0.6
| 0
| 0
| 0.2
| 0.103448
| 0
| 0
| 0
| 0
| 0.044444
| 1
| 0.044444
| false
| 0
| 0.037037
| 0
| 0.081481
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
7efcd2a3b9bb685a96284848f3966c52261fb380
| 1,870
|
py
|
Python
|
setupLum.py
|
OrsayDev/swift_lumiere
|
d1d067f957b86a0b6042f0a185d73479e26bc2f6
|
[
"MIT"
] | null | null | null |
setupLum.py
|
OrsayDev/swift_lumiere
|
d1d067f957b86a0b6042f0a185d73479e26bc2f6
|
[
"MIT"
] | null | null | null |
setupLum.py
|
OrsayDev/swift_lumiere
|
d1d067f957b86a0b6042f0a185d73479e26bc2f6
|
[
"MIT"
] | null | null | null |
from setuptools import setup
setup(
name="OrsayLumiere",
version="5.27.8",
author="Yves Auad",
description="Set of tools to run a VG Microscope in Nionswift",
url="https://github.com/yvesauad/swift_lumiere",
packages=['nionswift_plugin.EELS_spec', 'nionswift_plugin.diaf',
'nionswift_plugin.IVG', 'nionswift_plugin.IVG.virtual_instruments',
'nionswift_plugin.IVG.tp3', 'nionswift_plugin.IVG.camera',
'nionswift_plugin.IVG.scan', 'nionswift_plugin.lenses',
'nionswift_plugin.OptSpec', 'nionswift_plugin.stage'],
python_requires='>=3.8.5',
data_files=[('nionswift_plugin/aux_files/config', [
'nionswift_plugin/aux_files/config/Lumiere/global_settings.json',
'nionswift_plugin/aux_files/config/Lumiere/diafs_settings.json',
'nionswift_plugin/aux_files/config/Lumiere/eels_settings.json',
'nionswift_plugin/aux_files/config/Lumiere/lenses_settings.json',
'nionswift_plugin/aux_files/config/Lumiere/Orsay_cameras_list.json',
]), ('nionswift_plugin/aux_files/DLLs', [
'nionswift_plugin/aux_files/DLLs/Cameras.dll',
'nionswift_plugin/aux_files/DLLs/atmcd64d.dll',
'nionswift_plugin/aux_files/DLLs/Scan.dll',
'nionswift_plugin/aux_files/DLLs/udk3-1.4-x86_64.dll',
'nionswift_plugin/aux_files/DLLs/udk3mod-1.4-winusb-x86_64.dll',
'nionswift_plugin/aux_files/DLLs/STEMSerial.dll',
'nionswift_plugin/aux_files/DLLs/Stepper.dll',
'nionswift_plugin/aux_files/DLLs/delib64.dll',
'nionswift_plugin/aux_files/DLLs/SpectroCL.dll',
'nionswift_plugin/aux_files/DLLs/AttoClient.dll',
]), ('swift_rust/target/release', [
'swift_rust/target/release/rust2swift.pyd'
]
)],
install_requires=["pyserial>=3.5", "requests>=2.25.1", "nionswift-usim>=0.3.0"]
)
| 46.75
| 83
| 0.698396
| 235
| 1,870
| 5.302128
| 0.365957
| 0.32504
| 0.245586
| 0.313804
| 0.477528
| 0.407705
| 0.210273
| 0.210273
| 0
| 0
| 0
| 0.02293
| 0.160428
| 1,870
| 39
| 84
| 47.948718
| 0.770701
| 0
| 0
| 0
| 0
| 0
| 0.709091
| 0.617112
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.027778
| 0
| 0.027778
| 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
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
add331a9a60691a33bf8ad4f4650c8a0c22fb4e4
| 4,835
|
py
|
Python
|
tests/test_g_fast_ssc/test_node.py
|
MingxuZhang/python-polar-coding
|
bfab8e1cdcffaefea8e6d0209b13465fbd7fa936
|
[
"MIT"
] | 2
|
2021-12-07T09:52:15.000Z
|
2022-01-06T14:35:37.000Z
|
tests/test_g_fast_ssc/test_node.py
|
manhduc1811/python-polar-coding
|
bfab8e1cdcffaefea8e6d0209b13465fbd7fa936
|
[
"MIT"
] | null | null | null |
tests/test_g_fast_ssc/test_node.py
|
manhduc1811/python-polar-coding
|
bfab8e1cdcffaefea8e6d0209b13465fbd7fa936
|
[
"MIT"
] | 4
|
2020-07-03T14:20:04.000Z
|
2021-07-04T13:20:40.000Z
|
from unittest import TestCase
import numpy as np
from python_polar_coding.polar_codes.base import NodeTypes
from python_polar_coding.polar_codes.g_fast_ssc import GFastSSCNode
class GeneralizedFastSSCNodeTest(TestCase):
def setUp(self):
self.llr = np.array([
-2.7273, -8.7327, 0.1087, -1.6463,
2.7273, -8.7327, -0.1087, 1.6463,
-2.7273, -8.7327, -0.1087, 1.6463,
2.7273, 8.7326, 1.1087, -1.6463,
])
self.g_rep_one = np.array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
])
self.g_rep_one_long = np.array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
])
self.g_rep_spc = np.array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
])
self.g_rep_spc_long = np.array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
])
self.rg_parity_ones = np.array([
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
])
self.rg_parity_ones_long = np.array([
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
])
self.rg_parity_ones_spc = np.array([
0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
])
self.rg_parity_ones_spc_long = np.array([
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
])
def test_g_repetition_one(self):
node = GFastSSCNode(mask=self.g_rep_one)
self.assertEqual(node.node_type, NodeTypes.G_REPETITION)
expected_result = np.array([0, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 0, ])
node.alpha = self.llr
node()
np.testing.assert_array_equal(node.beta, expected_result)
def test_g_repetition_one_long(self):
node = GFastSSCNode(mask=self.g_rep_one_long)
self.assertEqual(node.node_type, NodeTypes.G_REPETITION)
def test_g_repetition_spc(self):
node = GFastSSCNode(mask=self.g_rep_spc)
self.assertEqual(node.node_type, NodeTypes.G_REPETITION)
expected_result = np.array([1, 1, 0, 0,
1, 1, 0, 0,
1, 1, 0, 0,
1, 1, 0, 0, ])
node.alpha = self.llr
node()
np.testing.assert_array_equal(node.beta, expected_result)
def test_g_repetition_spc_long(self):
node = GFastSSCNode(mask=self.g_rep_spc_long)
self.assertEqual(node.node_type, NodeTypes.G_REPETITION)
def test_rg_parity_ones(self):
node = GFastSSCNode(mask=self.rg_parity_ones)
self.assertEqual(node.node_type, NodeTypes.RG_PARITY)
expected_result = np.array([1, 1, 0, 1,
0, 1, 1, 0,
1, 1, 1, 0,
0, 1, 0, 1, ])
node.alpha = self.llr
node()
np.testing.assert_array_equal(node.beta, expected_result)
def test_rg_parity_ones_long(self):
node = GFastSSCNode(mask=self.rg_parity_ones_long)
self.assertEqual(node.node_type, NodeTypes.RG_PARITY)
def test_rg_parity_spc_ones_spc_AF_1(self):
node = GFastSSCNode(mask=self.rg_parity_ones_spc, AF=1)
self.assertEqual(node.node_type, NodeTypes.RG_PARITY)
expected_result = np.array([1, 1, 0, 1,
0, 1, 1, 0,
1, 1, 1, 0,
0, 1, 0, 1, ])
node.alpha = self.llr
node()
np.testing.assert_array_equal(node.beta, expected_result)
def test_rg_parity_spc_ones_long_AF_1(self):
node = GFastSSCNode(mask=self.rg_parity_ones_spc_long, AF=1)
self.assertEqual(node.node_type, NodeTypes.RG_PARITY)
def test_rg_parity_spc_ones_spc_AF_2(self):
mask = np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, ])
node = GFastSSCNode(mask=mask)
self.assertNotEqual(node.node_type, NodeTypes.RG_PARITY)
node = GFastSSCNode(mask=mask, AF=2)
self.assertEqual(node.node_type, NodeTypes.RG_PARITY)
def test_rg_parity_spc_ones_spc_AF_3(self):
mask = np.array([0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, ])
node = GFastSSCNode(mask=mask, AF=2)
self.assertNotEqual(node.node_type, NodeTypes.RG_PARITY)
node = GFastSSCNode(mask=mask, AF=3)
self.assertEqual(node.node_type, NodeTypes.RG_PARITY)
| 36.628788
| 75
| 0.520372
| 753
| 4,835
| 3.15405
| 0.074369
| 0.092632
| 0.113684
| 0.129684
| 0.922947
| 0.897684
| 0.865263
| 0.852211
| 0.725895
| 0.724211
| 0
| 0.119078
| 0.345191
| 4,835
| 131
| 76
| 36.908397
| 0.63108
| 0
| 0
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.153846
| 1
| 0.105769
| false
| 0
| 0.038462
| 0
| 0.153846
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
addbdcbe2472cc7620c69b5291c50f874986d7b9
| 11,705
|
py
|
Python
|
api/tests/integration/features/multivariate/test_integration_multivariate.py
|
SolidStateGroup/Bullet-Train-API
|
ea47ccbdadf665a806ae4e0eff6ad1a2f1b0ba19
|
[
"BSD-3-Clause"
] | 126
|
2019-12-13T18:41:43.000Z
|
2020-11-10T13:33:55.000Z
|
api/tests/integration/features/multivariate/test_integration_multivariate.py
|
SolidStateGroup/Bullet-Train-API
|
ea47ccbdadf665a806ae4e0eff6ad1a2f1b0ba19
|
[
"BSD-3-Clause"
] | 30
|
2019-12-12T16:52:01.000Z
|
2020-11-09T18:55:29.000Z
|
api/tests/integration/features/multivariate/test_integration_multivariate.py
|
SolidStateGroup/Bullet-Train-API
|
ea47ccbdadf665a806ae4e0eff6ad1a2f1b0ba19
|
[
"BSD-3-Clause"
] | 20
|
2020-02-14T21:55:36.000Z
|
2020-11-03T22:29:03.000Z
|
import json
from django.urls import reverse
from rest_framework import status
def test_can_create_mv_option(project, mv_option_50_percent, admin_client, feature):
# Given
url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
data = {
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 50,
}
# When
response = admin_client.post(
url,
data=json.dumps(data),
content_type="application/json",
)
# Then
assert response.status_code == status.HTTP_201_CREATED
assert response.json()["id"]
assert set(data.items()).issubset(set(response.json().items()))
def test_can_list_mv_option(project, mv_option_50_percent, admin_client, feature):
# Given
url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
# When
response = admin_client.get(
url,
content_type="application/json",
)
# Then
assert response.status_code == status.HTTP_200_OK
assert response.json()["count"] == 1
assert response.json()["results"][0]["id"] == mv_option_50_percent
def test_creating_mv_options_with_accumulated_total_gt_100_returns_400(
project, mv_option_50_percent, admin_client, feature
):
url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
data = {
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 51,
}
# When
response = admin_client.post(
url,
data=json.dumps(data),
content_type="application/json",
)
# Then
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.json()["default_percentage_allocation"] == [
"Invalid percentage allocation"
]
def test_can_update_default_percentage_allocation(
project, mv_option_50_percent, admin_client, feature
):
url = reverse(
"api-v1:projects:feature-mv-options-detail",
args=[project, feature, mv_option_50_percent],
)
data = {
"id": mv_option_50_percent,
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 70,
}
# When
response = admin_client.put(
url,
data=json.dumps(data),
content_type="application/json",
)
# Then
assert response.status_code == status.HTTP_200_OK
assert response.json()["id"] == mv_option_50_percent
assert set(data.items()).issubset(set(response.json().items()))
def test_updating_default_percentage_allocation_that_pushes_the_total_percentage_allocation_over_100_returns_400(
project, mv_option_50_percent, admin_client, feature
):
# First let's create another mv_option with 30 percent allocation
url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
data = {
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 30,
}
response = admin_client.post(
url,
data=json.dumps(data),
content_type="application/json",
)
mv_option_30_percent = response.json()["id"]
# Next, let's update the 30 percent mv option to 51 percent
url = reverse(
"api-v1:projects:feature-mv-options-detail",
args=[project, feature, mv_option_30_percent],
)
data = {
"id": mv_option_30_percent,
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 51,
}
# When
response = admin_client.put(
url,
data=json.dumps(data),
content_type="application/json",
)
# Then
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.json()["default_percentage_allocation"] == [
"Invalid percentage allocation"
]
def test_can_remove_mv_option(project, mv_option_50_percent, admin_client, feature):
# Given
mv_option_url = reverse(
"api-v1:projects:feature-mv-options-detail",
args=[project, feature, mv_option_50_percent],
)
# When
response = admin_client.delete(
mv_option_url,
content_type="application/json",
)
# Then
assert response.status_code == status.HTTP_204_NO_CONTENT
# and
url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
assert (
admin_client.get(
url,
content_type="application/json",
).json()["count"]
== 0
)
def test_create_and_update_multivariate_feature_with_2_variations_50_percent(
project, environment, environment_api_key, admin_client, feature
):
"""
Specific test to reproduce issue #234 in Github
https://github.com/Flagsmith/flagsmith/issues/234
"""
first_mv_option_data = {
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 50,
}
second_mv_option_data = {
"type": "unicode",
"feature": feature,
"string_value": "biggest",
"default_percentage_allocation": 50,
}
mv_option_url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
# Create first mv option
mv_option_response = admin_client.post(
mv_option_url,
data=json.dumps(first_mv_option_data),
content_type="application/json",
)
assert mv_option_response.status_code == status.HTTP_201_CREATED
assert set(first_mv_option_data.items()).issubset(
set(mv_option_response.json().items())
)
# Create second mv option
mv_option_response = admin_client.post(
mv_option_url,
data=json.dumps(second_mv_option_data),
content_type="application/json",
)
assert mv_option_response.status_code == status.HTTP_201_CREATED
assert set(second_mv_option_data.items()).issubset(
set(mv_option_response.json().items())
)
# Now get the feature states for the environment so we can get the id of the
# feature state and multivariate feature states in the given environment
get_feature_states_url = reverse(
"api-v1:environments:environment-featurestates-list", args=[environment_api_key]
)
get_feature_states_response = admin_client.get(get_feature_states_url)
results = get_feature_states_response.json()["results"]
feature_state = next(filter(lambda fs: fs["feature"] == feature, results))
feature_state_id = feature_state["id"]
assert get_feature_states_response.status_code == status.HTTP_200_OK
assert len(feature_state["multivariate_feature_state_values"]) == 2
# Now we just want to try and update the feature state in the environment without
# changing anything
update_url = reverse(
"api-v1:environments:environment-featurestates-detail",
args=[environment_api_key, feature_state_id],
)
update_feature_state_data = {
"id": feature_state_id,
"feature_state_value": "big",
"multivariate_feature_state_values": [
{
"multivariate_feature_option": mv_option_id,
"id": mv_fsv_id,
"percentage_allocation": 50,
}
for mv_fsv_id, mv_option_id in [
(mv_fsv["id"], mv_fsv["multivariate_feature_option"])
for mv_fsv in feature_state["multivariate_feature_state_values"]
]
],
"identity": None,
"enabled": False,
"feature": feature,
"environment": environment,
"feature_segment": None,
}
update_feature_state_response = admin_client.put(
update_url,
data=json.dumps(update_feature_state_data),
content_type="application/json",
)
assert update_feature_state_response.status_code == status.HTTP_200_OK
def test_modify_weight_of_2_variations_in_single_request(
project, environment, environment_api_key, admin_client, feature
):
"""
Specific test to reproduce issue #807 in Github
https://github.com/Flagsmith/flagsmith/issues/807
"""
first_mv_option_data = {
"type": "unicode",
"feature": feature,
"string_value": "bigger",
"default_percentage_allocation": 0,
}
second_mv_option_data = {
"type": "unicode",
"feature": feature,
"string_value": "biggest",
"default_percentage_allocation": 100,
}
mv_option_url = reverse(
"api-v1:projects:feature-mv-options-list",
args=[project, feature],
)
# Create first mv option
mv_option_response = admin_client.post(
mv_option_url,
data=json.dumps(first_mv_option_data),
content_type="application/json",
)
assert mv_option_response.status_code == status.HTTP_201_CREATED
assert set(first_mv_option_data.items()).issubset(
set(mv_option_response.json().items())
)
# Create second mv option
mv_option_response = admin_client.post(
mv_option_url,
data=json.dumps(second_mv_option_data),
content_type="application/json",
)
assert mv_option_response.status_code == status.HTTP_201_CREATED
assert set(second_mv_option_data.items()).issubset(
set(mv_option_response.json().items())
)
# Now get the feature states for the environment so we can get the id of the
# feature state and multivariate feature states in the given environment
get_feature_states_url = reverse(
"api-v1:environments:environment-featurestates-list", args=[environment_api_key]
)
get_feature_states_response = admin_client.get(get_feature_states_url)
results = get_feature_states_response.json()["results"]
feature_state = next(filter(lambda fs: fs["feature"] == feature, results))
feature_state_id = feature_state["id"]
assert get_feature_states_response.status_code == status.HTTP_200_OK
assert len(feature_state["multivariate_feature_state_values"]) == 2
# Now we want to switch the weighting so that the opposite variation is 100% as
# well as adding another new variation
update_url = reverse(
"api-v1:environments:environment-featurestates-detail",
args=[environment_api_key, feature_state_id],
)
update_feature_state_data = {
"id": feature_state_id,
"feature_state_value": "big",
"multivariate_feature_state_values": [
{
"multivariate_feature_option": mv_option_id,
"id": mv_fsv_id,
"percentage_allocation": 100 if percentage_allocation == 0 else 0,
}
for mv_fsv_id, mv_option_id, percentage_allocation in [
(
mv_fsv["id"],
mv_fsv["multivariate_feature_option"],
mv_fsv["percentage_allocation"],
)
for mv_fsv in feature_state["multivariate_feature_state_values"]
]
],
"identity": None,
"enabled": False,
"feature": feature,
"environment": environment,
"feature_segment": None,
}
update_feature_state_response = admin_client.put(
update_url,
data=json.dumps(update_feature_state_data),
content_type="application/json",
)
assert update_feature_state_response.status_code == status.HTTP_200_OK
| 32.604457
| 113
| 0.650491
| 1,364
| 11,705
| 5.257331
| 0.11217
| 0.065821
| 0.039743
| 0.029285
| 0.876447
| 0.865988
| 0.865988
| 0.86041
| 0.837401
| 0.826524
| 0
| 0.017091
| 0.245194
| 11,705
| 358
| 114
| 32.695531
| 0.794567
| 0.085348
| 0
| 0.687075
| 0
| 0
| 0.198252
| 0.121075
| 0
| 0
| 0
| 0
| 0.098639
| 1
| 0.027211
| false
| 0
| 0.010204
| 0
| 0.037415
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
adedca420d2df3219baddaffce936e758cb3b9bf
| 96
|
py
|
Python
|
venv/lib/python3.8/site-packages/clikit/ui/help/abstract_help.py
|
GiulianaPola/select_repeats
|
17a0d053d4f874e42cf654dd142168c2ec8fbd11
|
[
"MIT"
] | 2
|
2022-03-13T01:58:52.000Z
|
2022-03-31T06:07:54.000Z
|
venv/lib/python3.8/site-packages/clikit/ui/help/abstract_help.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | 19
|
2021-11-20T04:09:18.000Z
|
2022-03-23T15:05:55.000Z
|
venv/lib/python3.8/site-packages/clikit/ui/help/abstract_help.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | null | null | null |
/home/runner/.cache/pip/pool/eb/5a/63/1db574cfe6a3751aa2e5b0d799e22876e848b8163943dd938212fc3335
| 96
| 96
| 0.895833
| 9
| 96
| 9.555556
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.447917
| 0
| 96
| 1
| 96
| 96
| 0.447917
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
adf2f90051a6275b0f4c0b1e91e9a5a6f30ae132
| 38
|
py
|
Python
|
app/helpers/__init__.py
|
jordiyapz/indostock-vizz
|
276de41b6aceeac12bd74e1702e56ed117a157d0
|
[
"MIT"
] | null | null | null |
app/helpers/__init__.py
|
jordiyapz/indostock-vizz
|
276de41b6aceeac12bd74e1702e56ed117a157d0
|
[
"MIT"
] | null | null | null |
app/helpers/__init__.py
|
jordiyapz/indostock-vizz
|
276de41b6aceeac12bd74e1702e56ed117a157d0
|
[
"MIT"
] | null | null | null |
from .data import PATH, download_data
| 19
| 37
| 0.815789
| 6
| 38
| 5
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.131579
| 38
| 1
| 38
| 38
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
bc18d6b8546ca85ed2ef15c60fcd8776f2a57362
| 40,486
|
py
|
Python
|
pymmrouting/inferenceengine.py
|
tumluliu/pymmrouting
|
948ddfa2bd419baffde68440e98e3531277c98d6
|
[
"MIT"
] | 5
|
2017-06-17T21:02:16.000Z
|
2022-03-15T10:14:06.000Z
|
pymmrouting/inferenceengine.py
|
tumluliu/pymmrouting
|
948ddfa2bd419baffde68440e98e3531277c98d6
|
[
"MIT"
] | null | null | null |
pymmrouting/inferenceengine.py
|
tumluliu/pymmrouting
|
948ddfa2bd419baffde68440e98e3531277c98d6
|
[
"MIT"
] | null | null | null |
"""
Infer feasible routing plans according to user preferences
"""
from .datamodel import VERTEX_VALIDATION_CHECKER
from .orm_graphmodel import SwitchType, StreetJunction, Mode, Session, Vertex
from geoalchemy2.functions import ST_AsGeoJSON as st_asgeojson
import logging
import json
logger = logging.getLogger(__name__)
INTERNAL_SRID = 4326
# Read modes and switch_types from database instead of hard coding it here
MODES = {
str(m_name): m_id
for m_name, m_id in Session.query(Mode.mode_name, Mode.mode_id)
}
SWITCH_TYPES = {
str(t_name): t_id
for t_name, t_id in Session.query(SwitchType.type_name, SwitchType.type_id)
}
class RoutingPlan(object):
"""
A plan of routing including transportation tools to use
during the trip
"""
mode_list = []
switch_type_list = []
switch_condition_list = []
switch_constraint_list = []
target_constraint = None
public_transit_set = []
cost_factor = ''
description = ''
source = {}
target = {}
def __init__(self,
desc,
source,
target,
modes,
cost,
switch_types=None,
switch_conditions=None,
switch_constraints=None,
target_constraint=None,
public_transits=None):
self.description = desc
self.source = source
self.target = target
self.mode_list = modes
self.cost_factor = cost
self.switch_type_list = [] if switch_types is None else switch_types
self.switch_condition_list = [] if switch_conditions is None else switch_conditions
self.switch_constraint_list = [] if switch_constraints is None else switch_constraints
self.target_constraint = target_constraint
self.public_transit_set = [] if public_transits is None else public_transits
@property
def is_multimodal(self):
return True if (len(self.mode_list) >= 2) or \
(MODES['public_transportation'] in self.mode_list) else False
@property
def has_public_transit(self):
return True if MODES['public_transportation'] in self.mode_list \
else False
class RoutingPlanInferer(object):
"""
Infer the feasible routing plans according to routing options
"""
def __init__(self):
self.options = {}
def load_routing_options_from_file(self, options_file_path):
with open(options_file_path) as options_file:
self.options = json.load(options_file)
def load_routing_options_from_string(self, options_json_string):
self.options = json.loads(options_json_string)
def load_routing_options(self, options_dict):
self.options = options_dict
def _reproject(self, old_x, old_y, old_srid, new_srid):
# TODO: transform coordinate from given srid to 4326 in lon and lat
return old_x, old_y
def _geodecode(self, address):
return 0, 0
def _get_lon_lat_position(self, position_info):
if position_info['type'] == 'coordinate':
lon, lat = self._reproject(
position_info['value']['x'], position_info['value']['y'],
position_info['value']['srid'], INTERNAL_SRID)
elif position_info['type'] == 'address':
# TODO: Do geo-decoding to get the geo-coordinate
lon, lat = self._geodecode(position_info['value'])
return {"lon": lon, "lat": lat}
def _find_nearest_point(self, location):
point = 'POINT(' + str(location['lon']) + ' ' + \
str(location['lat']) + ')'
nearest_neighbor = Session.query(StreetJunction).order_by(
StreetJunction.geom.distance_box(point)).first()
raw_point_id = nearest_neighbor.osm_id
point_geom = json.loads(Session.scalar(st_asgeojson(
nearest_neighbor.geom)))
logger.debug("found nearest neighbor, osm_id is " + str(raw_point_id))
return {'point_id': raw_point_id, 'geometry': point_geom}
def _find_candidate_vertices(self, raw_point_id):
candidate_vertices = Session.query(Vertex).filter(
Vertex.raw_point_id == raw_point_id).all()
v_id_list = [str(v.vertex_id) for v in candidate_vertices]
logger.debug("candidate vertices: " + ','.join(v_id_list))
return {v.mode_id: v.vertex_id for v in candidate_vertices}
def _get_cost_factor(self, objective):
if objective == 'shortest': return 'length'
elif objective == 'fastest': return 'speed'
return 'speed'
def _find_valid_source_target_pairs(self,
sources,
targets,
modes,
public_transit_modes=[]):
s_mode = modes[0]
t_mode = modes[-1]
st_pairs = []
if (s_mode != MODES['public_transportation']) and \
(t_mode != MODES['public_transportation']):
source = sources[s_mode] if s_mode in sources else None
target = targets[t_mode] if t_mode in targets else None
if (not source is None) and (not target is None):
st_pairs.append({"source": source, "target": target})
elif (s_mode == MODES['public_transportation']) and \
(t_mode != MODES['public_transportation']):
target = targets[t_mode] if t_mode in targets else None
source_list = [sources[m] \
for m in public_transit_modes + [MODES['foot']] \
if m in sources]
if (not target is None) and (len(source_list) > 0):
st_pairs = map(lambda s: {"source": s, "target": target},
source_list)
elif (s_mode != MODES['public_transportation']) and \
(t_mode == MODES['public_transportation']):
source = sources[s_mode] if s_mode in sources else None
target_list = [targets[m] \
for m in public_transit_modes + [MODES['foot']] \
if m in targets]
if (not source is None) and (len(target_list) > 0):
st_pairs = map(lambda t: {"source": source, "target": t},
target_list)
elif (s_mode == MODES['public_transportation']) and \
(t_mode == MODES['public_transportation']):
source_list = [sources[m] \
for m in public_transit_modes + [MODES['foot']] \
if m in sources]
target_list = [targets[m] \
for m in public_transit_modes + [MODES['foot']] \
if m in targets]
if (len(source_list) > 0) and (len(target_list) > 0):
st_pairs = [{"source": s, "target": t} for s in source_list \
for t in target_list]
return st_pairs
def generate_routing_plan(self):
if self.options == {}:
raise Exception('Empty routing options!')
source_lon_lat = self._get_lon_lat_position(self.options['source'])
target_lon_lat = self._get_lon_lat_position(self.options['target'])
nearest_source = self._find_nearest_point(source_lon_lat)
nearest_target = self._find_nearest_point(target_lon_lat)
candidate_sources = self._find_candidate_vertices(nearest_source[
'point_id'])
candidate_targets = self._find_candidate_vertices(nearest_target[
'point_id'])
cost_factor = self._get_cost_factor(self.options['objective'])
plans = []
if self.options['objective'] == 'fastest':
if len(self.options['available_public_modes']) == 0:
if not self.options['has_private_car']:
# only can walk, mono-modal routing
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets, [MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan('Walking', routing_src,
routing_tgt, [MODES['foot']],
cost_factor))
return plans
if self.options['has_private_car'] and \
(not self.options['need_parking']):
# somebody else will be the driver
# the car can be parked temporarily anywhere
# There are 3 possible mode combinations in this case:
# car; foot; car-foot with geo_connection as Switch Point
# 1st: car only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_plan = RoutingPlan(
'Take a car', routing_src, routing_tgt,
[MODES['private_car']], cost_factor)
if 'driving_distance_limit' in self.options:
car_plan.target_constraint = VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
plans.append(car_plan)
# 2nd: foot only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets, [MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan('Walking', routing_src,
routing_tgt, [MODES['foot']],
cost_factor))
# 3rd: car-foot with geo_connection as Switch Point
type_id = SWITCH_TYPES['geo_connection']
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_foot_plan = RoutingPlan(
'By car first, then walking without parking',
routing_src, routing_tgt,
[MODES['private_car'], MODES['foot']], cost_factor,
[type_id], ["type_id=" + str(type_id) +
" AND is_available=true"])
# FIXME: It is unreasonable to use driving distance limit
# as the extream driving distance because the driver can
# not drive any more after the passenger leaves. So it
# must be convenient to leave some gas for the driver.
# remaining_gas_factor = 0.75
if 'driving_distance_limit' in self.options:
car_foot_plan.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
]
else:
car_foot_plan.switch_constraint_list = [None]
plans.append(car_foot_plan)
return plans
if self.options['has_private_car'] and self.options[
'need_parking']:
# the user may be the driver
# and he/she surely need a parking lot for the car
# There are also 2 possible mode combinations in this case:
# foot; car-foot with parking as Switch Point
# 1st: foot only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets, [MODES['foot']])
logger.debug("Found valid source target pairs: %s",
st_pairs)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan('Walking', routing_src,
routing_tgt, [MODES['foot']],
cost_factor))
# 2nd: car-foot with parking lots as Switch Point
type_id = SWITCH_TYPES['car_parking']
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_foot_plan = RoutingPlan(
'Driving, parking and walking', routing_src,
routing_tgt, [MODES['private_car'], MODES['foot']],
cost_factor, [type_id], ["type_id=" + str(
type_id) + " AND is_available=true"])
remaining_gas_factor = 0.5
if 'driving_distance_limit' in self.options:
car_foot_plan.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 * remaining_gas_factor else -1)
]
else:
car_foot_plan.switch_constraint_list = [None]
plans.append(car_foot_plan)
return plans
else:
# can use public transportation system
if not self.options['has_private_car']:
# the user can walk or take public transportation
# 2 possible mode combinations:
# 1. foot;
# 2. PT
#
# 1: foot only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets, [MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan('Walking', routing_src,
routing_tgt, [MODES['foot']],
cost_factor))
# 2: public transportation
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['public_transportation']], public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
public_plan = RoutingPlan(
'Walking and taking public transit', routing_src,
routing_tgt, [MODES['public_transportation']],
cost_factor)
public_plan.public_transit_set = public_modes
plans.append(public_plan)
return plans
if self.options['has_private_car'] and \
(not self.options['need_parking']):
# somebody else will be the driver
# the car can be parked temporarily anywhere
# There are 5 possible mode combinations in this case:
# 1. car;
# 2. foot;
# 3. car-foot with geo_connection as Switch Point;
# 4. PT;
# 5. car-PT with geo_connection as Switch Point;
# 6. car-PT with kiss+R as Switch Point;
#
# 1: car only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_plan = RoutingPlan('Take a car', routing_src,
routing_tgt, [MODES['private_car']],
cost_factor)
if 'driving_distance_limit' in self.options:
car_plan.target_constraint = VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
plans.append(car_plan)
# 2: foot only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets, [MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan('Walking', routing_src,
routing_tgt, [MODES['foot']],
cost_factor))
# 3: car-foot with geo_connection as Switch Point
type_id = SWITCH_TYPES['geo_connection']
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_foot_plan = RoutingPlan(
'By car first, then walking without parking',
routing_src, routing_tgt,
[MODES['private_car'], MODES['foot']], cost_factor,
[type_id],
["type_id=" + str(type_id) + " AND is_available=true"])
if 'driving_distance_limit' in self.options:
car_foot_plan.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
]
else:
car_foot_plan.switch_constraint_list = [None]
plans.append(car_foot_plan)
# 4: public transportation
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['public_transportation']], public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
public_plan = RoutingPlan(
'Walking and taking public transit', routing_src,
routing_tgt, [MODES['public_transportation']],
cost_factor)
public_plan.public_transit_set = public_modes
plans.append(public_plan)
# 5: car-PT with geo_connection as Switch Point
type_id = SWITCH_TYPES['geo_connection']
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['public_transportation']],
public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_public_plan1 = RoutingPlan(
'Driving and taking public transit', routing_src,
routing_tgt,
[MODES['private_car'], MODES['public_transportation']],
cost_factor, [type_id],
["type_id=" + str(type_id) + " AND is_available=true"])
car_public_plan1.public_transit_set = public_modes
if 'driving_distance_limit' in self.options:
car_public_plan1.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
]
else:
car_public_plan1.switch_constraint_list = [None]
plans.append(car_public_plan1)
# 6: car-PT with kiss+R as Switch Point
type_id = SWITCH_TYPES['kiss_and_ride']
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['public_transportation']],
public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_public_plan2 = RoutingPlan(
'Driving and taking public transit via Kiss+R',
routing_src, routing_tgt,
[MODES['private_car'], MODES['public_transportation']],
cost_factor, [type_id],
["type_id=" + str(type_id) + " AND is_available=true"])
car_public_plan2.public_transit_set = public_modes
if 'driving_distance_limit' in self.options:
car_public_plan2.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
]
else:
car_public_plan2.switch_constraint_list = [None]
plans.append(car_public_plan2)
return plans
if self.options['has_private_car'] and self.options[
'need_parking']:
# the user may be the driver
# and he/she surely need a parking lot for the car
# There are 5 possible mode combinations in this case:
# 1. foot;
# 2. car-foot with parking as Switch Point;
# 3. PT;
# 4. car-PT with parking as Switch Points;
# 5. car-PT with P+R as Switch Points;
#
# 1: foot only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets, [MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan('Walking', routing_src,
routing_tgt, [MODES['foot']],
cost_factor))
# 2: car-foot with parking lots as Switch Point
type_id = SWITCH_TYPES['car_parking']
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_foot_plan = RoutingPlan(
'Driving, parking and walking', routing_src,
routing_tgt, [MODES['private_car'], MODES['foot']],
cost_factor, [type_id],
["type_id=" + str(type_id) + " AND is_available=true"])
remaining_gas_factor = 0.5
if 'driving_distance_limit' in self.options:
car_foot_plan.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 * remaining_gas_factor else -1)
]
else:
car_foot_plan.switch_constraint_list = [None]
plans.append(car_foot_plan)
# 3: public transportation
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['public_transportation']], public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
public_plan = RoutingPlan(
'Walking and taking public transit', routing_src,
routing_tgt, [MODES['public_transportation']],
cost_factor)
public_plan.public_transit_set = public_modes
plans.append(public_plan)
# 4: car-PT with parking as Switch Point
type_id = SWITCH_TYPES['car_parking']
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['public_transportation']],
public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_public_plan1 = RoutingPlan(
'Driving, parking and taking public transit',
routing_src, routing_tgt,
[MODES['private_car'], MODES['public_transportation']],
cost_factor, [type_id],
["type_id=" + str(type_id) + " AND is_available=true"])
car_public_plan1.public_transit_set = public_modes
remaining_gas_factor = 0.5
if 'driving_distance_limit' in self.options:
car_public_plan1.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 * remaining_gas_factor else -1)
]
else:
car_public_plan1.switch_constraint_list = [None]
plans.append(car_public_plan1)
# 5: car-PT with P+R as Switch Point
type_id = SWITCH_TYPES['park_and_ride']
public_modes = [MODES[m] for m in \
self.options['available_public_modes']]
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car'], MODES['public_transportation']],
public_modes)
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_public_plan1 = RoutingPlan(
'Driving, parking and taking public transit',
routing_src, routing_tgt,
[MODES['private_car'], MODES['public_transportation']],
cost_factor, [type_id],
["type_id=" + str(type_id) + " AND is_available=true"])
car_public_plan1.public_transit_set = public_modes
if 'driving_distance_limit' in self.options:
car_public_plan1.switch_constraint_list = [
VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
]
else:
car_public_plan1.switch_constraint_list = [None]
plans.append(car_public_plan1)
return plans
elif self.options['objective'] == 'shortest':
if not self.options['can_use_public']:
if not self.options['has_private_car']:
# no car, walk only
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan(
'Walking', routing_src, routing_tgt, [MODES[
'foot']], cost_factor))
else:
# car
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['private_car']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
car_plan = RoutingPlan(
'Take a car', routing_src, routing_tgt,
[MODES['private_car']], cost_factor)
if 'driving_distance_limit' in self.options:
car_plan.target_constraint = VERTEX_VALIDATION_CHECKER(
lambda v: 0 if v[0].distance <= float(self.options['driving_distance_limit']) * 1000.0 else -1)
plans.append(car_plan)
# foot
st_pairs = self._find_valid_source_target_pairs(
candidate_sources, candidate_targets,
[MODES['foot']])
for st in st_pairs:
routing_src = {
'type': 'Feature',
'geometry': nearest_source['geometry'],
'properties': {'id': st['source']}
}
routing_tgt = {
'type': 'Feature',
'geometry': nearest_target['geometry'],
'properties': {'id': st['target']}
}
plans.append(RoutingPlan(
'Walking', routing_src, routing_tgt, [MODES[
'foot']], cost_factor))
return plans
else:
# TODO: finish this branch
return []
| 51.183312
| 154
| 0.4568
| 3,536
| 40,486
| 4.949661
| 0.071833
| 0.034567
| 0.047766
| 0.065364
| 0.787624
| 0.771112
| 0.760656
| 0.747
| 0.734202
| 0.714261
| 0
| 0.007774
| 0.453515
| 40,486
| 790
| 155
| 51.248101
| 0.783277
| 0.056242
| 0
| 0.707246
| 0
| 0
| 0.127021
| 0.030548
| 0
| 0
| 0
| 0.001266
| 0
| 1
| 0.021739
| false
| 0
| 0.007246
| 0.005797
| 0.071014
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
bc18e11845f374fb42802049a83cef74beba8ee7
| 26
|
py
|
Python
|
magpie/model/unsupervised/__init__.py
|
daemon/magpie
|
aa52da47551765c681da2fa68f515e2d02ceed58
|
[
"MIT"
] | 3
|
2018-07-29T15:42:08.000Z
|
2018-12-28T03:18:49.000Z
|
magpie/model/unsupervised/__init__.py
|
daemon/magpie
|
aa52da47551765c681da2fa68f515e2d02ceed58
|
[
"MIT"
] | null | null | null |
magpie/model/unsupervised/__init__.py
|
daemon/magpie
|
aa52da47551765c681da2fa68f515e2d02ceed58
|
[
"MIT"
] | null | null | null |
from .autoencoder import *
| 26
| 26
| 0.807692
| 3
| 26
| 7
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.115385
| 26
| 1
| 26
| 26
| 0.913043
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
70bb7e64d12a6d776c9317c802e7caebb6134c90
| 279
|
py
|
Python
|
translob/nn/__init__.py
|
simaki/translob
|
d243cffe7832b5b9e34c25b0266ff2491e26f410
|
[
"BSD-3-Clause"
] | 6
|
2021-09-09T09:41:56.000Z
|
2021-12-24T19:58:14.000Z
|
translob/nn/__init__.py
|
simaki/translob
|
d243cffe7832b5b9e34c25b0266ff2491e26f410
|
[
"BSD-3-Clause"
] | 1
|
2021-11-05T01:46:10.000Z
|
2021-11-05T01:46:10.000Z
|
translob/nn/__init__.py
|
simaki/translob
|
d243cffe7832b5b9e34c25b0266ff2491e26f410
|
[
"BSD-3-Clause"
] | 2
|
2021-11-04T01:50:25.000Z
|
2021-12-26T22:54:25.000Z
|
from .modules.conv import CausalConv1d
from .modules.conv import CausalConvLayers
from .modules.mlp import MultiLayerPerceptron
from .modules.position import PositionalEncoding
from .modules.transformer import CausalTransformerEncoderLayer
from .modules.translob import TransLOB
| 39.857143
| 62
| 0.870968
| 30
| 279
| 8.1
| 0.433333
| 0.271605
| 0.123457
| 0.17284
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.003922
| 0.086022
| 279
| 6
| 63
| 46.5
| 0.94902
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
cb34bc2385d765ee3aa9278bdf773e0c0c5abfad
| 12,847
|
py
|
Python
|
examples/question_answering/matches.py
|
haroldNLP/Distiller
|
f3ab5f94a9092fca1e2bdb9f486e66fd0b24bcfd
|
[
"MIT"
] | 2
|
2022-03-21T08:02:02.000Z
|
2022-03-21T08:29:07.000Z
|
examples/question_answering/matches.py
|
haroldNLP/Distiller
|
f3ab5f94a9092fca1e2bdb9f486e66fd0b24bcfd
|
[
"MIT"
] | null | null | null |
examples/question_answering/matches.py
|
haroldNLP/Distiller
|
f3ab5f94a9092fca1e2bdb9f486e66fd0b24bcfd
|
[
"MIT"
] | null | null | null |
L3_attention_mse=[{"layer_T":4, "layer_S":1, "feature":"attention", "loss":"attention_mse", "weight":1},
{"layer_T":8, "layer_S":2, "feature":"attention", "loss":"attention_mse", "weight":1},
{"layer_T":12, "layer_S":3, "feature":"attention", "loss":"attention_mse", "weight":1}]
L3_attention_ce=[{"layer_T":0, "layer_S":0, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":5, "layer_S":1, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":11, "layer_S":2, "feature":"attention", "loss":"attention_ce", "weight":1}]
L3_hybrid=[{"layer_T":[0,0], "layer_S":[0,0], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[1,1], "layer_S":[1,1], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[2,2], "layer_S":[2,2], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[3,3],"layer_S":[3,3], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":1, "layer_S":1, "feature":"hidden", "loss":"hidden_ce", "weight":0.5},
{"layer_T":2, "layer_S":1, "feature":"hidden", "loss":"hidden_ce", "weight":0.5},
{"layer_T":3, "layer_S":2, "feature":"hidden", "loss":"hidden_ce", "weight":0.5},
{"layer_T":4, "layer_S":2, "feature":"hidden", "loss":"hidden_ce", "weight":0.5},
{"layer_T":5, "layer_S":3, "feature":"hidden", "loss":"hidden_ce", "weight":0.5},
{"layer_T":6, "layer_S":3, "feature":"hidden", "loss":"hidden_ce", "weight":0.5}
]
L3_attention_mse_sum=[{"layer_T":4, "layer_S":1, "feature":"attention", "loss":"attention_mse_sum", "weight":1},
{"layer_T":8, "layer_S":2, "feature":"attention", "loss":"attention_mse_sum", "weight":1},
{"layer_T":12, "layer_S":3, "feature":"attention", "loss":"attention_mse_sum", "weight":1}]
L3_attention_ce_mean=[{"layer_T":4, "layer_S":1, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":8, "layer_S":2, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":12, "layer_S":3, "feature":"attention", "loss":"attention_ce_mean", "weight":1}]
L3_hidden_smmd=[{"layer_T":[0,0], "layer_S":[0,0], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[4,4], "layer_S":[1,1], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[8,8], "layer_S":[2,2], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[12,12],"layer_S":[3,3], "feature":"hidden", "loss":"mmd", "weight":1}]
L3n_hidden_mse=[{"layer_T":0, "layer_S":0, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":4, "layer_S":1, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":8, "layer_S":2, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":12,"layer_S":3, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]}]
L3_hidden_mse=[{"layer_T":0, "layer_S":0, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T":4, "layer_S":1, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T":8, "layer_S":2, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T":12,"layer_S":3, "feature":"hidden", "loss":"hidden_mse", "weight":1}]
L3l_hidden_mse=[{"layer_T":0, "layer_S":0, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",1024,768]},
{"layer_T":4, "layer_S":1, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",1024,768]},
{"layer_T":8, "layer_S":2, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",1024,768]},
{"layer_T":12,"layer_S":3, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",1024,768]}]
#######################L4################
L4_attention_mse=[{"layer_T":3, "layer_S":1, "feature":"attention", "loss":"attention_mse", "weight":1},
{"layer_T":6, "layer_S":2, "feature":"attention", "loss":"attention_mse", "weight":1},
{"layer_T":9, "layer_S":3, "feature":"attention", "loss":"attention_mse", "weight":1},
{"layer_T":12, "layer_S":4, "feature":"attention", "loss":"attention_mse", "weight":1}]
L4_attention_ce=[{"layer_T":3, "layer_S":1, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":6, "layer_S":2, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":9, "layer_S":3, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":12, "layer_S":4, "feature":"attention", "loss":"attention_ce", "weight":1}]
L4_attention_ce_large=[{"layer_T":6, "layer_S":1, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":12, "layer_S":2, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":18, "layer_S":3, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":24, "layer_S":4, "feature":"attention", "loss":"attention_ce", "weight":1}]
L4_attention_mse_sum=[{"layer_T":3, "layer_S":1, "feature":"attention", "loss":"attention_mse_sum", "weight":1},
{"layer_T":6, "layer_S":2, "feature":"attention", "loss":"attention_mse_sum", "weight":1},
{"layer_T":9, "layer_S":3, "feature":"attention", "loss":"attention_mse_sum", "weight":1},
{"layer_T":12, "layer_S":4, "feature":"attention", "loss":"attention_mse_sum", "weight":1}]
L4_attention_ce_mean=[{"layer_T":3, "layer_S":1, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":6, "layer_S":2, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":9, "layer_S":3, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":12, "layer_S":4, "feature":"attention", "loss":"attention_ce_mean", "weight":1}]
L4_hidden_smmd=[{"layer_T":[0,0], "layer_S":[0,0], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[3,3], "layer_S":[1,1], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[6,6], "layer_S":[2,2], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[9,9], "layer_S":[3,3], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[12,12],"layer_S":[4,4], "feature":"hidden", "loss":"mmd", "weight":1}]
L4_hidden_smmd_large=[{"layer_T":[20,20], "layer_S":[0,0], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[21,21], "layer_S":[1,1], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[22,22], "layer_S":[2,2], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[23,23], "layer_S":[3,3], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[24,24],"layer_S":[4,4], "feature":"hidden", "loss":"mmd", "weight":1}]
L4t_hidden_mse=[{"layer_T":0, "layer_S":0, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":3, "layer_S":1, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":6, "layer_S":2, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":9, "layer_S":3, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]},
{"layer_T":12,"layer_S":4, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,768]}]
L4t_hidden_mse_large=[{"layer_T":20, "layer_S":0, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,1024]},
{"layer_T":21, "layer_S":1, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,1024]},
{"layer_T":22, "layer_S":2, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,1024]},
{"layer_T":23, "layer_S":3, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,1024]},
{"layer_T":24,"layer_S":4, "feature":"hidden", "loss":"hidden_mse", "weight":1, "proj":["linear",384,1024]}]
L4t_attention_ce_large=[{"layer_T":0, "layer_S":0, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":21, "layer_S":1, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":22, "layer_S":2, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":23, "layer_S":3, "feature":"attention", "loss":"attention_ce", "weight":1}]
L6_hidden_mse=[{"layer_T":0, "layer_S":0, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T":2, "layer_S":1, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T":4, "layer_S":2, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T":6,"layer_S":3, "feature":"hidden", "loss":"hidden_mse", "weight":1},
{"layer_T": 8, "layer_S": 4, "feature": "hidden", "loss": "hidden_mse", "weight": 1},
{"layer_T": 10, "layer_S": 5, "feature": "hidden", "loss": "hidden_mse", "weight": 1},
{"layer_T": 12, "layer_S": 6, "feature": "hidden", "loss": "hidden_mse", "weight": 1}
]
L6_hidden_smmd=[{"layer_T":[0,0], "layer_S":[0,0], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[2,2], "layer_S":[1,1], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[4,4], "layer_S":[2,2], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T":[6,6],"layer_S":[3,3], "feature":"hidden", "loss":"mmd", "weight":1},
{"layer_T": [8, 8], "layer_S": [4, 4], "feature": "hidden", "loss": "mmd", "weight": 1},
{"layer_T": [10, 10], "layer_S": [5, 5], "feature": "hidden", "loss": "mmd", "weight": 1},
{"layer_T": [12, 12], "layer_S": [6, 6], "feature": "hidden", "loss": "mmd", "weight": 1}
]
L6_attention_ce=[{"layer_T":2, "layer_S": 1, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":4, "layer_S": 2, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T":6, "layer_S": 3, "feature":"attention", "loss":"attention_ce", "weight":1},
{"layer_T": 8, "layer_S": 4, "feature": "attention", "loss": "attention_ce", "weight": 1},
{"layer_T": 10, "layer_S": 5, "feature": "attention", "loss": "attention_ce", "weight": 1},
{"layer_T": 12, "layer_S": 6, "feature": "attention", "loss": "attention_ce", "weight": 1}
]
L6_attention_ce_mean=[{"layer_T":2, "layer_S":1, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":4, "layer_S":2, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T":6, "layer_S":3, "feature":"attention", "loss":"attention_ce_mean", "weight":1},
{"layer_T": 8, "layer_S": 4, "feature": "attention", "loss": "attention_ce_mean", "weight": 1},
{"layer_T": 10, "layer_S": 5, "feature": "attention", "loss": "attention_ce_mean", "weight": 1},
{"layer_T": 12, "layer_S": 6, "feature": "attention", "loss": "attention_ce_mean", "weight": 1}
]
matches={'L3_attention_mse':L3_attention_mse,'L3_attention_mse_sum':L3_attention_mse_sum,
'L3_attention_ce' :L3_attention_ce, 'L3_attention_ce_mean':L3_attention_ce_mean,
'L3n_hidden_mse' :L3n_hidden_mse, 'L3_hidden_smmd' :L3_hidden_smmd,
'L3l_hidden_mse' :L3l_hidden_mse, 'L3_hidden_mse': L3_hidden_mse,
'L4_attention_mse':L4_attention_mse,'L4_attention_mse_sum':L4_attention_mse_sum,
'L4_attention_ce' :L4_attention_ce, 'L4_attention_ce_mean':L4_attention_ce_mean,
'L4t_hidden_mse' :L4t_hidden_mse, 'L4_hidden_smmd' :L4_hidden_smmd,
'L6_hidden_mse' : L6_hidden_mse, 'L6_hidden_smmd' : L6_hidden_smmd,
'L6_attention_ce': L6_attention_ce, 'L6_attention_ce_mean': L6_attention_ce_mean,
'L3_hybrid':L3_hybrid, 'L4_hidden_smmd_large':L4_hidden_smmd_large,
'L4t_hidden_mse_large':L4t_hidden_mse_large, 'L4_attention_ce_large':L4_attention_ce_large,
'L4t_attention_ce_large': L4t_attention_ce_large
}
| 83.422078
| 131
| 0.553592
| 1,760
| 12,847
| 3.767614
| 0.026136
| 0.097723
| 0.119439
| 0.129392
| 0.944805
| 0.901976
| 0.867893
| 0.845121
| 0.839391
| 0.835621
| 0
| 0.05884
| 0.187748
| 12,847
| 153
| 132
| 83.96732
| 0.576617
| 0.000156
| 0
| 0
| 0
| 0
| 0.452991
| 0.003358
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
cb64c82bcb94b88bef69b1049a0d6cad3b14ba95
| 2,404
|
py
|
Python
|
poo/inicio_coisas_gerais/teste_2.py
|
rikardalves/python
|
dc3d34e9759c2b9245c66c1bce2b101b2125da5a
|
[
"MIT"
] | null | null | null |
poo/inicio_coisas_gerais/teste_2.py
|
rikardalves/python
|
dc3d34e9759c2b9245c66c1bce2b101b2125da5a
|
[
"MIT"
] | null | null | null |
poo/inicio_coisas_gerais/teste_2.py
|
rikardalves/python
|
dc3d34e9759c2b9245c66c1bce2b101b2125da5a
|
[
"MIT"
] | null | null | null |
choice = int(input())
if choice == 1:
# Código final 2 param opcional
class Conta:
def __init__(self, titular, saldo, numero, limite = 1000):
self.titular = titular
self.saldo = saldo
self.numero = numero
self.limite = limite
def depositar(self, valor):
self.saldo += float(valor)
def sacar(self, valor):
if self.saldo < valor:
return False
else:
self.saldo -= float(valor)
return True
def transferir(self, destino, valor):
retirada = self.sacar(valor)
if retirada:
destino.depositar(valor)
return True
else:
return False
def extrato(self):
print(f'Conta: {self.numero}')
print(f'Saldo: {self.saldo}')
conta = Conta('Ríkard', 3000, '111-1', 2000)
conta2 = Conta('Desconhecido', 0, '222-2')
print(conta2.saldo, conta.saldo)
conta.extrato()
conta.depositar(3000)
conta.extrato()
saque = conta.sacar(1001000)
if saque:
print('Êxito no saque')
else:
print('Saque um valor abaixo do seu saldo')
conta.extrato()
conta.transferir(conta2, 2500)
print(conta2.saldo, conta.saldo)
conta2.extrato()
elif choice == 2:
# Código final com return
class Conta:
def __init__(self, titular, saldo, numero, limite = 1000):
self.titular = titular
self.saldo = saldo
self.numero = numero
self.limite = limite
def depositar(self, valor):
self.saldo += float(valor)
def sacar(self, valor):
if self.saldo < valor:
return False
else:
self.saldo -= float(valor)
return True
def extrato(self):
print(f'Conta: {self.numero}')
print(f'Saldo: {self.saldo}')
conta = Conta('Ríkard', 3000, '111-1', 2000)
conta.extrato()
conta.depositar(3000)
conta.extrato()
saque = conta.sacar(1001000)
if saque:
print('Êxito no saque')
else:
print('Saque um valor abaixo do seu saldo')
conta.extrato()
| 25.849462
| 66
| 0.50416
| 249
| 2,404
| 4.835341
| 0.212851
| 0.074751
| 0.046512
| 0.063123
| 0.793189
| 0.75
| 0.75
| 0.75
| 0.75
| 0.75
| 0
| 0.048764
| 0.394343
| 2,404
| 92
| 67
| 26.130435
| 0.778159
| 0.022047
| 0
| 0.855072
| 0
| 0
| 0.090716
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.130435
| false
| 0
| 0
| 0
| 0.246377
| 0.144928
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
cb73f548b4d79c78dfb03b215e5e0ed0442ad31f
| 335
|
py
|
Python
|
meiduo/meiduo/utils/converters.py
|
q934744153/meiduo_mall
|
6f5b0ae38cc80c21ddca161c428fea09584d4b95
|
[
"MIT"
] | null | null | null |
meiduo/meiduo/utils/converters.py
|
q934744153/meiduo_mall
|
6f5b0ae38cc80c21ddca161c428fea09584d4b95
|
[
"MIT"
] | null | null | null |
meiduo/meiduo/utils/converters.py
|
q934744153/meiduo_mall
|
6f5b0ae38cc80c21ddca161c428fea09584d4b95
|
[
"MIT"
] | null | null | null |
class UsernameConverters:
regex= '[a-zA-Z0-9]{5,20}'
def to_python(self,value):
return str(value)
def to_url(self,value):
return str(value)
class MobileConverter:
regex = '1[3-9]\d{9}'
def to_python(self,value):
return str(value)
def to_url(self,value):
return str(value)
| 17.631579
| 30
| 0.6
| 49
| 335
| 4.020408
| 0.428571
| 0.101523
| 0.304569
| 0.365482
| 0.659898
| 0.659898
| 0.659898
| 0.659898
| 0.659898
| 0.659898
| 0
| 0.036437
| 0.262687
| 335
| 18
| 31
| 18.611111
| 0.761134
| 0
| 0
| 0.666667
| 0
| 0
| 0.083582
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0.333333
| 1
| 0
| 0
| 0
| 0
| null | 0
| 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
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
cb894d09f3d307cf5453924d19172fb7b509532a
| 31
|
py
|
Python
|
minemeld/extensions/__init__.py
|
zul126/minemeld-core
|
2eb9b9bfd7654aee57aabd5fb280d4e89a438daf
|
[
"Apache-2.0"
] | 147
|
2016-07-22T18:15:49.000Z
|
2022-03-26T23:32:44.000Z
|
minemeld/extensions/__init__.py
|
zul126/minemeld-core
|
2eb9b9bfd7654aee57aabd5fb280d4e89a438daf
|
[
"Apache-2.0"
] | 167
|
2016-07-27T07:02:25.000Z
|
2021-12-16T16:26:52.000Z
|
minemeld/extensions/__init__.py
|
zul126/minemeld-core
|
2eb9b9bfd7654aee57aabd5fb280d4e89a438daf
|
[
"Apache-2.0"
] | 112
|
2016-07-22T07:14:29.000Z
|
2022-03-24T18:43:12.000Z
|
from .manager import * # noqa
| 15.5
| 30
| 0.677419
| 4
| 31
| 5.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.225806
| 31
| 1
| 31
| 31
| 0.875
| 0.129032
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
1deb64ac0443c6c5910323971704f9bf57b77c8b
| 37
|
py
|
Python
|
phaxbot/chat_overlay/config.py
|
haliphax/stream-avatars
|
0d8d365f6113d2ce45387f4d83570b5c0cd73ba4
|
[
"MIT"
] | 4
|
2021-04-16T04:24:52.000Z
|
2021-07-03T23:51:20.000Z
|
phaxbot/chat_overlay/config.py
|
haliphax/phaxbot
|
0d8d365f6113d2ce45387f4d83570b5c0cd73ba4
|
[
"MIT"
] | 14
|
2021-09-27T21:13:10.000Z
|
2022-03-30T21:16:25.000Z
|
phaxbot/chat_overlay/config.py
|
haliphax/phaxbot
|
0d8d365f6113d2ce45387f4d83570b5c0cd73ba4
|
[
"MIT"
] | 1
|
2021-06-10T04:17:35.000Z
|
2021-06-10T04:17:35.000Z
|
"phaxbot chat overlay configuration"
| 18.5
| 36
| 0.837838
| 4
| 37
| 7.75
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.108108
| 37
| 1
| 37
| 37
| 0.939394
| 0.918919
| 0
| 0
| 0
| 0
| 0.918919
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 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
| 1
| 0
| 0
| 0
| 0
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
6972de735bcbf91066ef9ee680ff32d968959af0
| 6,575
|
py
|
Python
|
src/ansible_collections/sodalite/hpc/tests/unit/plugins/modules/test_torque_job.py
|
SODALITE-EU/platform-discovery-service
|
fb10a2fdab8544713fe8065d31061c8cd0fa16c9
|
[
"Apache-2.0"
] | 1
|
2021-08-09T10:34:25.000Z
|
2021-08-09T10:34:25.000Z
|
src/ansible_collections/sodalite/hpc/tests/unit/plugins/modules/test_torque_job.py
|
SODALITE-EU/platform-discovery-service
|
fb10a2fdab8544713fe8065d31061c8cd0fa16c9
|
[
"Apache-2.0"
] | 13
|
2020-09-21T08:37:53.000Z
|
2021-03-23T13:15:22.000Z
|
src/ansible_collections/sodalite/hpc/tests/unit/plugins/modules/test_torque_job.py
|
SODALITE-EU/platform-discovery-service
|
fb10a2fdab8544713fe8065d31061c8cd0fa16c9
|
[
"Apache-2.0"
] | null | null | null |
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils import basic
from ansible_collections.sodalite.hpc.plugins.modules import torque_job
from mock import patch, call
import pytest
from .utils import (
AnsibleExitJson, AnsibleFailJson, TestHPCModule, set_module_args,
)
class TestTorqueJobModule(TestHPCModule):
def test_job_create(self, torque_job_stdout_1_r):
set_module_args({"job_name": "my_job", "job_contents": "sleep 30", "keep_job_script": False})
with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
stdout_submit = "2310.cloudserver"
mock_run_command.side_effect = [(0, stdout_submit, ""),
(0, torque_job_stdout_1_r, ""),
(0, torque_job_stdout_1_r, "")]
with pytest.raises(AnsibleExitJson) as result:
torque_job.main()
assert result.value.args[0]['changed'] is True
assert len(result.value.args[0]['jobs']) == 1
assert result.value.args[0]['jobs'][0]['job_id'] == '2310.cloudserver'
assert result.value.args[0]['jobs'][0]['job_state'] == 'RUNNING'
mock_run_command.assert_has_calls([call("qsub my_job.torque"),
call("qstat -f 2310.cloudserver"),
call("qstat -f 2310.cloudserver")])
def test_job_pause(self, torque_job_stdout_1_r, torque_job_stdout_1_s):
set_module_args({"job_id": "2310.cloudserver", "state": "paused"})
with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
mock_run_command.side_effect = [(0, torque_job_stdout_1_r, ""),
(0, "", ""),
(0, torque_job_stdout_1_s, ""),
(0, torque_job_stdout_1_s, "")]
with pytest.raises(AnsibleExitJson) as result:
torque_job.main()
assert result.value.args[0]['changed'] is True
assert len(result.value.args[0]['jobs']) == 1
assert result.value.args[0]['jobs'][0]['job_id'] == '2310.cloudserver'
assert result.value.args[0]['jobs'][0]['job_state'] == 'SUSPENDED'
mock_run_command.assert_has_calls([call("qstat -f 2310.cloudserver"),
call("qhold 2310.cloudserver"),
call("qstat -f 2310.cloudserver"),
call("qstat -f 2310.cloudserver")])
def test_job_resume(self, torque_job_stdout_1_r, torque_job_stdout_1_s):
set_module_args({"job_id": "2310.cloudserver"})
with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
mock_run_command.side_effect = [(0, torque_job_stdout_1_s, ""),
(0, "", ""),
(0, torque_job_stdout_1_r, ""),
(0, torque_job_stdout_1_r, "")]
with pytest.raises(AnsibleExitJson) as result:
torque_job.main()
assert result.value.args[0]['changed'] is True
assert len(result.value.args[0]['jobs']) == 1
assert result.value.args[0]['jobs'][0]['job_id'] == '2310.cloudserver'
assert result.value.args[0]['jobs'][0]['job_state'] == 'RUNNING'
mock_run_command.assert_has_calls([call("qstat -f 2310.cloudserver"),
call("qrls 2310.cloudserver"),
call("qstat -f 2310.cloudserver"),
call("qstat -f 2310.cloudserver")])
def test_job_cancel(self, torque_job_stdout_1_r, torque_job_stdout_1_c):
set_module_args({"job_id": "2310.cloudserver", "state": "cancelled"})
with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
mock_run_command.side_effect = [(0, torque_job_stdout_1_r, ""),
(0, "", ""),
(0, torque_job_stdout_1_c, ""),
(0, torque_job_stdout_1_c, "")]
with pytest.raises(AnsibleExitJson) as result:
torque_job.main()
assert result.value.args[0]['changed'] is True
assert len(result.value.args[0]['jobs']) == 1
assert result.value.args[0]['jobs'][0]['job_id'] == '2310.cloudserver'
assert result.value.args[0]['jobs'][0]['job_state'] == 'COMPLETED'
mock_run_command.assert_has_calls([call("qstat -f 2310.cloudserver"),
call("qdel 2310.cloudserver"),
call("qstat -f 2310.cloudserver"),
call("qstat -f 2310.cloudserver")])
def test_get_job_timeout_fail(self, torque_job_stdout_1_s):
set_module_args({"job_name": "my_job", "job_contents": "sleep 30", "keep_job_script": False})
with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
stdout_submit = "2310.cloudserver"
stdout_status = torque_job_stdout_1_s
mock_run_command.side_effect = [(0, stdout_submit, ""),
(0, stdout_status, ""),
(0, stdout_status, "")]
with pytest.raises(AnsibleFailJson) as result:
torque_job.main()
assert result.value.args[0]['failed'] is True
assert result.value.args[0]['msg'] == "Failed to execute qstat -f 2310.cloudserver command"
mock_run_command.assert_has_calls([call("qsub my_job.torque"),
call("qstat -f 2310.cloudserver"),
call("qstat -f 2310.cloudserver")])
def test_get_job_params_fail(self, torque_job_stdout_1_r):
set_module_args({})
with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
stdout = torque_job_stdout_1_r
stderr = ''
rc = 0
mock_run_command.return_value = rc, stdout, stderr
with pytest.raises(AnsibleFailJson):
torque_job.main()
assert not mock_run_command.called
| 49.810606
| 103
| 0.544791
| 731
| 6,575
| 4.592339
| 0.139535
| 0.077748
| 0.098302
| 0.104856
| 0.809056
| 0.792076
| 0.777778
| 0.776586
| 0.763777
| 0.719988
| 0
| 0.041064
| 0.337034
| 6,575
| 131
| 104
| 50.19084
| 0.729066
| 0
| 0
| 0.588235
| 0
| 0
| 0.1527
| 0
| 0
| 0
| 0
| 0
| 0.235294
| 1
| 0.058824
| false
| 0
| 0.058824
| 0
| 0.127451
| 0.009804
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
69fdeb86f6a8405df681adffcb67e9f004180be4
| 5,509
|
py
|
Python
|
gcn_prot/models/models.py
|
carrascomj/gcn-prot
|
21bdcc4a701a301b84c49784f84e6832bf5a74a4
|
[
"MIT"
] | 2
|
2020-08-17T12:09:42.000Z
|
2020-08-17T13:49:27.000Z
|
gcn_prot/models/models.py
|
carrascomj/gcn-prot
|
21bdcc4a701a301b84c49784f84e6832bf5a74a4
|
[
"MIT"
] | 14
|
2020-03-16T10:04:51.000Z
|
2020-08-17T12:31:45.000Z
|
gcn_prot/models/models.py
|
carrascomj/gcn-prot
|
21bdcc4a701a301b84c49784f84e6832bf5a74a4
|
[
"MIT"
] | 2
|
2020-03-29T17:50:08.000Z
|
2020-10-21T02:24:57.000Z
|
"""Custom layers for graph convolutional neural networks."""
import torch.nn as nn
import torch.nn.functional as F
from .layers import GraphConvolution, NormalizationLayer
from .utils import sparsize
class GCN_simple(nn.Module):
"""Simplest GCN model."""
def __init__(
self,
feats,
hidden,
label,
nb_nodes,
dropout,
bias=False,
act=F.relu,
cuda=False,
):
"""Initialize GCN model.
Parameters
----------
feats: int
dimension of inputs
hidden: Iterable[int]
a vector of dimensions of the hidden graph convolutional layers
label: int
dimension of output
nb_nodes: int
number of aminoacids. Used for last layer.
dropout: float
bias: bool (False)
act: function
activation function. Default: F.relu
cuda: bool
important to correctly sparsize
"""
super(GCN_simple, self).__init__()
hidden = [hidden] if isinstance("hidden", int) else hidden
gc_layers = [
GraphConvolution(in_dim, out_dim, dropout, bias, act)
for in_dim, out_dim in zip([feats] + hidden[:-1], hidden)
]
self.hidden_layers = nn.Sequential(*gc_layers)
self.out_layer = nn.Linear(nb_nodes, label)
# self.out_layer = nn.Sequential(
# nn.Flatten(), nn.Linear(nb_nodes * hidden[-1], label)
# )
self.in_cuda = cuda
def forward(self, input):
"""Pass forward GCN model.
Parameters
----------
input:
v: torch.Tensor
3D Tensor containing the features of nodes
adj: torch.Tensor
3D tensor with the values of the adjacency matrix
"""
v, adj = input
input = [v, sparsize(adj, self.in_cuda)]
x, _ = self.hidden_layers.forward(input)
x = x.sum(axis=-1)
x = self.out_layer(x)
return x
class GCN_normed(nn.Module):
"""Simplest GCN model."""
def __init__(
self,
feats,
hidden,
label,
nb_nodes,
dropout,
bias=False,
act=F.relu,
D=1,
cuda=False,
):
"""Initialize GCN model.
Parameters
----------
feats: int
dimension of inputs
hidden: Iterable[int]
a vector of dimensions of the hidden graph convolutional layers
label: int
dimension of output
nb_nodes: int
number of aminoacids. Used for last layer.
dropout: float
bias: bool (False)
act: function
activation function. Default: F.relu
D: int
initial diameter for normalization
cuda: bool
important to correctly sparsize
"""
super(GCN_normed, self).__init__()
self.in_cuda = cuda
hidden = [hidden] if isinstance("hidden", int) else hidden
gc_layers = [
nn.Sequential(
NormalizationLayer(in_dim, D=D),
GraphConvolution(in_dim, out_dim, dropout, bias, act),
)
for in_dim, out_dim in zip([feats] + hidden[:-1], hidden)
]
self.hidden_layers = nn.Sequential(*gc_layers)
self.out_layer = nn.Sequential(
nn.Flatten(), nn.Linear(nb_nodes * hidden[-1], label)
)
def forward(self, input):
"""Pass forward GCN model.
Parameters
----------
input:
v: torch.Tensor
3D Tensor containing the features of nodes
adj: torch.Tensor
3D tensor with the values of the adjacency matrix
"""
v, adj = input
x, _ = self.hidden_layers.forward(input)
x = self.out_layer(x)
return x
class FFNN(nn.Module):
"""Plain Feed Forward Neural Network."""
def __init__(
self, feats, hidden, label, nb_nodes, dropout, cuda=False,
):
"""Initialize FFNN model.
The activation function is set to Relu.
Parameters
----------
feats: int
dimension of inputs
hidden: Iterable[int]
a vector of dimensions of the hidden graph convolutional layers
label: int
dimension of output
nb_nodes: int
number of aminoacids. Used for last layer.
dropout: float
cuda: bool
important to correctly sparsize
"""
super(FFNN, self).__init__()
hidden = [hidden] if isinstance("hidden", int) else hidden
gc_layers = [
nn.Sequential(nn.Linear(in_dim, out_dim), nn.ReLU(), nn.Dropout(dropout))
for in_dim, out_dim in zip([feats] + hidden[:-1], hidden)
]
self.hidden_layers = nn.Sequential(*gc_layers)
self.out_layer = nn.Sequential(
nn.Flatten(), nn.Linear(nb_nodes * hidden[-1], label)
)
self.in_cuda = cuda
def forward(self, input):
"""Pass forward GCN model.
Parameters
----------
input:
v: torch.Tensor
3D Tensor containing the features of nodes
adj: torch.Tensor
3D tensor with the values of the adjacency matrix
"""
v, adj = input
x = self.hidden_layers.forward(v)
x = self.out_layer(x)
return x
| 27.683417
| 85
| 0.541478
| 617
| 5,509
| 4.711507
| 0.168558
| 0.02408
| 0.028896
| 0.022704
| 0.833849
| 0.833849
| 0.833849
| 0.800482
| 0.752322
| 0.738218
| 0
| 0.003998
| 0.364313
| 5,509
| 198
| 86
| 27.823232
| 0.826099
| 0.373389
| 0
| 0.678571
| 0
| 0
| 0.006459
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.071429
| false
| 0
| 0.047619
| 0
| 0.190476
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
38d3a478d999fba1b3998eeee9f05c72331d903b
| 25,474
|
py
|
Python
|
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_afs_commands.py
|
xaliciayang/azure-cli
|
38c80c875e8a79d08d06a2f42ec82fd54934343e
|
[
"MIT"
] | 4
|
2016-08-23T06:19:01.000Z
|
2018-03-20T22:47:15.000Z
|
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_afs_commands.py
|
xaliciayang/azure-cli
|
38c80c875e8a79d08d06a2f42ec82fd54934343e
|
[
"MIT"
] | 120
|
2018-03-27T19:14:40.000Z
|
2020-12-10T23:53:35.000Z
|
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_afs_commands.py
|
xaliciayang/azure-cli
|
38c80c875e8a79d08d06a2f42ec82fd54934343e
|
[
"MIT"
] | 11
|
2018-08-23T21:31:06.000Z
|
2020-09-03T21:39:51.000Z
|
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import json
from datetime import datetime, timedelta
import unittest
from azure.cli.testsdk import ScenarioTest, JMESPathCheckExists, ResourceGroupPreparer, \
StorageAccountPreparer, record_only
from .preparers import VaultPreparer, FileSharePreparer, AFSPolicyPreparer, AFSItemPreparer, \
AFSRPPreparer, FilePreparer
subscription_id = "da364f0f-307b-41c9-9d47-b7413ec45535"
unprotected_afs = "clitestafs"
protected_afs1 = "sarathtestafs"
protected_afs2 = "afstest1"
target_afs = "afstest2"
storage_account = "sarathsa"
resource_group_name = "sarath-rg"
vault_name = "sarath-vault"
class BackupTests(ScenarioTest, unittest.TestCase):
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@AFSPolicyPreparer()
def test_afs_backup_scenario(self, resource_group, vault_name, storage_account, afs_name, policy_name):
self.kwargs.update({
'vault': vault_name,
'item': afs_name,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
'policy': policy_name
})
self.cmd('backup protection enable-for-azurefileshare -g {rg} -v {vault} --storage-account {container} --azure-file-share {item} -p {policy}')
self.kwargs['retain_date'] = (datetime.utcnow() + timedelta(days=30)).strftime('%d-%m-%Y')
self.kwargs['job'] = self.cmd('backup protection backup-now -g {rg} -v {vault} -c {container} -i {item} --retain-until {retain_date} --backup-management-type AzureStorage --query name').get_output_in_json()
self.cmd('backup job wait -g {rg} -v {vault} -n {job}')
self.kwargs['rp'] = self.cmd('backup recoverypoint list -g {rg} -v {vault} -c {container} -i {item} --backup-management-type AzureStorage --query [0].name').get_output_in_json()
# Trigger Restore
self.kwargs['job'] = self.cmd('backup restore restore-azurefileshare -g {rg} -v {vault} -c {container} -i {item} -r {rp} --resolve-conflict Overwrite --restore-mode OriginalLocation --query name').get_output_in_json()
self.cmd('backup job wait -g {rg} -v {vault} -n {job}')
# Disable Protection
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item} --backup-management-type AzureStorage --delete-backup-data true --yes')
self.cmd('backup container unregister -g {rg} -v {vault} -c {container} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@AFSPolicyPreparer()
@AFSItemPreparer()
@StorageAccountPreparer(location="southeastasia", parameter_name="sa2")
@FileSharePreparer(storage_account_parameter_name="sa2", parameter_name="afs2")
@AFSItemPreparer(afs_parameter_name="afs2", storage_account_parameter_name="sa2")
def test_afs_backup_container(self, resource_group, vault_name, storage_account, sa2, afs_name, afs2):
self.kwargs.update({
'vault': vault_name,
'sa1': storage_account,
'sa2': sa2,
'rg': resource_group,
'type': "AzureStorage",
'item1': afs_name,
'item2': afs2
})
container_json = self.cmd('backup container show -n {sa2} -v {vault} -g {rg} --backup-management-type {type}', checks=[
self.check('properties.friendlyName', '{sa2}'),
self.check('properties.healthStatus', 'Healthy'),
self.check('properties.registrationStatus', 'Registered'),
self.check('resourceGroup', '{rg}')
]).get_output_in_json()
self.kwargs['container_name'] = container_json['name']
self.cmd('backup container show -n {container_name} -v {vault} -g {rg}', checks=[
self.check('properties.friendlyName', '{sa2}'),
self.check('properties.healthStatus', 'Healthy'),
self.check('properties.registrationStatus', 'Registered'),
self.check('name', '{container_name}'),
self.check('resourceGroup', '{rg}')
]).get_output_in_json()
self.cmd('backup container list -v {vault} -g {rg} --backup-management-type {type}', checks=[
self.check("length(@)", 2),
self.check("length([?properties.friendlyName == '{sa1}'])", 1),
self.check("length([?properties.friendlyName == '{sa2}'])", 1)])
self.cmd('backup protection disable -g {rg} -v {vault} -c {sa1} -i {item1} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup protection disable -g {rg} -v {vault} -c {sa2} -i {item2} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup container unregister -g {rg} -v {vault} -c {sa1} --yes --backup-management-type AzureStorage')
self.cmd('backup container unregister -g {rg} -v {vault} -c {sa2} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@FileSharePreparer(parameter_name="afs2")
@AFSPolicyPreparer()
@AFSPolicyPreparer(parameter_name="newpolicy")
@AFSItemPreparer()
@AFSItemPreparer(afs_parameter_name="afs2")
def test_afs_backup_item(self, resource_group, vault_name, storage_account, afs_name, policy_name, afs2, newpolicy):
self.kwargs.update({
'vault': vault_name,
'item1': afs_name,
'item2': afs2,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
'policy': policy_name,
'newpolicy': newpolicy
})
self.kwargs['container1'] = self.cmd('backup container show -g {rg} -v {vault} -n {container} --backup-management-type {type} --query name').get_output_in_json()
item1_json = self.cmd('backup item show -g {rg} -v {vault} -c {container1} -n {item1}', checks=[
self.check('properties.friendlyName', '{item1}'),
self.check('properties.protectionState', 'IRPending'),
self.check('properties.protectionStatus', 'Healthy'),
self.check('resourceGroup', '{rg}')
]).get_output_in_json()
self.kwargs['item1_fullname'] = item1_json['name']
self.cmd('backup item show -g {rg} -v {vault} -c {container1} -n {item1_fullname}', checks=[
self.check('properties.friendlyName', '{item1}'),
self.check('properties.protectionState', 'IRPending'),
self.check('properties.protectionStatus', 'Healthy'),
self.check('resourceGroup', '{rg}')
])
self.cmd('backup item list -g {rg} -v {vault} -c {container}', checks=[
self.check("length(@)", 2),
self.check("length([?properties.friendlyName == '{item1}'])", 1)
])
self.cmd('backup item list -g {rg} -v {vault} -c {container}', checks=[
self.check("length(@)", 2),
self.check("length([?properties.friendlyName == '{item2}'])", 1)
])
self.cmd('backup item list -g {rg} -v {vault} -c {container1}', checks=[
self.check("length(@)", 2),
self.check("length([?properties.friendlyName == '{item1}'])", 1)
])
self.cmd('backup item set-policy -g {rg} -v {vault} -c {container1} -n {item1} -p {newpolicy}', checks=[
self.check("properties.operation", "ConfigureBackup"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
item1_json = self.cmd('backup item show -g {rg} -v {vault} -c {container1} -n {item1}').get_output_in_json()
self.assertIn(self.kwargs['newpolicy'].lower(), item1_json['properties']['policyId'].split('/')[-1].lower())
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item2} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup container unregister -g {rg} -v {vault} -c {container} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@AFSPolicyPreparer()
@AFSItemPreparer()
@AFSRPPreparer()
def test_afs_backup_rp(self, resource_group, vault_name, storage_account, afs_name, policy_name, item_name, rp_name):
self.kwargs.update({
'vault': vault_name,
'subscription_id': subscription_id,
'item1': afs_name,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
})
rp_names = self.cmd('backup recoverypoint list -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type {type} --query [].name').get_output_in_json()
self.kwargs['rp1'] = rp_names[0]
self.cmd('backup recoverypoint show -g {rg} -v {vault} -c {container} -i {item1} -n {rp1} --backup-management-type {type}', checks=[
self.check("name", '{rp1}'),
self.check("resourceGroup", '{rg}')
])
rp_list = self.cmd('backup recoverypoint list -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type {type}').get_output_in_json()
rp_count1 = len(rp_list)
self.kwargs['retain_date'] = (datetime.utcnow() + timedelta(days=30)).strftime('%d-%m-%Y')
self.kwargs['job'] = self.cmd('backup protection backup-now -g {rg} -v {vault} -c {container} -i {item1} --retain-until {retain_date} --backup-management-type AzureStorage --query name').get_output_in_json()
self.cmd('backup job wait -g {rg} -v {vault} -n {job}')
rp_list = self.cmd('backup recoverypoint list -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type {type}').get_output_in_json()
rp_count2 = len(rp_list)
self.assertTrue(rp_count1 + 1 == rp_count2)
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup container unregister -g {rg} -v {vault} -c {container} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FilePreparer()
@FilePreparer()
@FilePreparer(parameter_name="file2")
@FileSharePreparer(file_upload=True, file_parameter_name=['file_name', 'file2'])
@AFSPolicyPreparer()
@AFSItemPreparer()
@AFSRPPreparer()
@FileSharePreparer(parameter_name="afs2")
def test_afs_backup_restore(self, resource_group, vault_name, storage_account, file_name, afs_name, afs2, file2):
self.kwargs.update({
'vault': vault_name,
'item1': afs_name,
'item2': afs2,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
'file': file_name,
'file2': file2
})
# full share restore original location
rp_names = self.cmd('backup recoverypoint list -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type {type} --query [].name').get_output_in_json()
self.kwargs['rp1'] = rp_names[0]
trigger_restore_job1_json = self.cmd('backup restore restore-azurefileshare -g {rg} -v {vault} -c {container} -i {item1} -r {rp1} --resolve-conflict Overwrite --restore-mode OriginalLocation', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "InProgress"),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
self.kwargs['job1'] = trigger_restore_job1_json['name']
self.cmd('backup job wait -g {rg} -v {vault} -n {job1}')
self.cmd('backup job show -g {rg} -v {vault} -n {job1}', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
# full share alternate location
trigger_restore_job2_json = self.cmd('backup restore restore-azurefileshare -g {rg} -v {vault} -c {container} -i {item1} -r {rp1} --resolve-conflict Overwrite --restore-mode AlternateLocation --target-storage-account {container} --target-file-share {item2} --target-folder folder1', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "InProgress"),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
self.kwargs['job2'] = trigger_restore_job2_json['name']
self.cmd('backup job wait -g {rg} -v {vault} -n {job2}')
self.cmd('backup job show -g {rg} -v {vault} -n {job2}', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
# item level recovery alternate location
trigger_restore_job3_json = self.cmd('backup restore restore-azurefiles -g {rg} -v {vault} -c {container} -i {item1} -r {rp1} --resolve-conflict Overwrite --restore-mode AlternateLocation --source-file-type File --source-file-path {file} --target-storage-account {container} --target-file-share {item2} --target-folder folder1', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "InProgress"),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
self.kwargs['job3'] = trigger_restore_job3_json['name']
self.cmd('backup job wait -g {rg} -v {vault} -n {job3}')
self.cmd('backup job show -g {rg} -v {vault} -n {job3}', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
# item level recovery original location
trigger_restore_job4_json = self.cmd('backup restore restore-azurefiles -g {rg} -v {vault} -c {container} -i {item1} -r {rp1} --resolve-conflict Overwrite --restore-mode OriginalLocation --source-file-type File --source-file-path {file}', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "InProgress"),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
self.kwargs['job4'] = trigger_restore_job4_json['name']
self.cmd('backup job wait -g {rg} -v {vault} -n {job4}')
self.cmd('backup job show -g {rg} -v {vault} -n {job4}', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
# item level multiple file restore to original location
trigger_restore_job5_json = self.cmd('backup restore restore-azurefiles -g {rg} -v {vault} -c {container} -i {item1} -r {rp1} --resolve-conflict Overwrite --restore-mode AlternateLocation --source-file-type File --source-file-path {file} {file2} --target-storage-account {container} --target-file-share {item2} --target-folder folder1', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "InProgress"),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
self.kwargs['job5'] = trigger_restore_job5_json['name']
self.cmd('backup job wait -g {rg} -v {vault} -n {job5}')
self.cmd('backup job show -g {rg} -v {vault} -n {job5}', checks=[
self.check("properties.entityFriendlyName", '{item1}'),
self.check("properties.operation", "Restore"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item1} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup container unregister -g {rg} -v {vault} -c {container} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@AFSPolicyPreparer()
def test_afs_backup_protection(self, resource_group, vault_name, storage_account, afs_name, policy_name):
self.kwargs.update({
'vault': vault_name,
'item': afs_name,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
'policy': policy_name
})
self.cmd('backup protection enable-for-azurefileshare -g {rg} -v {vault} --storage-account {container} --azure-file-share {item} -p {policy}', checks=[
self.check("properties.entityFriendlyName", '{item}'),
self.check("properties.operation", "ConfigureBackup"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
item_json = self.cmd('backup item list -g {rg} -v {vault} -c {container} --backup-management-type {type}').get_output_in_json()
protected_item_count1 = len(item_json)
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item} --backup-management-type {type} --yes', checks=[
self.check("properties.entityFriendlyName", '{item}'),
self.check("properties.operation", "DisableBackup"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
self.cmd('backup item show -g {rg} -v {vault} -c {container} -n {item} --backup-management-type {type}', checks=[
self.check("properties.friendlyName", '{item}'),
self.check("properties.protectionState", "ProtectionStopped"),
self.check("resourceGroup", '{rg}')
])
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {item} --backup-management-type {type} --delete-backup-data true --yes', checks=[
self.check("properties.entityFriendlyName", '{item}'),
self.check("properties.operation", "DeleteBackupData"),
self.check("properties.status", "Completed"),
self.check("resourceGroup", '{rg}')
])
item_json = self.cmd('backup item list -g {rg} -v {vault} -c {container} --backup-management-type {type}').get_output_in_json()
protected_item_count2 = len(item_json)
self.assertTrue(protected_item_count1 == protected_item_count2 + 1)
self.cmd('backup container unregister -g {rg} -v {vault} -c {container} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@AFSPolicyPreparer()
@AFSItemPreparer()
def test_afs_backup_policy(self, resource_group, vault_name, storage_account, afs_name, policy_name, item_name):
self.kwargs.update({
'vault': vault_name,
'item': item_name,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
'policy': policy_name,
'policy2': "clitestafspolicy"
})
policies_json = self.cmd('backup policy list -g {rg} -v {vault} --backup-management-type {type}').get_output_in_json()
policy_count1 = len(policies_json)
self.kwargs['policy1_json'] = self.cmd('backup policy show -g {rg} -v {vault} -n {policy}', checks=[
self.check("name", '{policy}'),
self.check("properties.backupManagementType", '{type}'),
self.check("resourceGroup", '{rg}')
]).get_output_in_json()
self.kwargs['policy1_json']['name'] = self.kwargs['policy2']
self.kwargs['policy1_json']['properties']['retentionPolicy']['dailySchedule']['retentionDuration']['count'] = 25
self.kwargs['policy1_json'] = json.dumps(self.kwargs['policy1_json'])
self.cmd("backup policy create -g {rg} -v {vault} --policy '{policy1_json}' --name {policy2} --backup-management-type {type}")
self.kwargs['policy2_json'] = self.cmd('backup policy show -g {rg} -v {vault} --n {policy2}', checks=[
self.check("name", '{policy2}'),
self.check("properties.backupManagementType", '{type}'),
self.check("properties.protectedItemsCount", 0),
self.check("properties.retentionPolicy.dailySchedule.retentionDuration.count", 25),
]).get_output_in_json()
policies_json = self.cmd('backup policy list -g {rg} -v {vault} --backup-management-type {type}').get_output_in_json()
policy_count2 = len(policies_json)
self.assertTrue(policy_count2 == policy_count1 + 1)
self.kwargs['policy2_json']['properties']['retentionPolicy']['dailySchedule']['retentionDuration']['count'] = 20
self.kwargs['policy2_json'] = json.dumps(self.kwargs['policy2_json'])
self.cmd("backup policy set -g {rg} -v {vault} --policy '{policy2_json}' -n {policy2}")
self.cmd('backup policy show -g {rg} -v {vault} -n {policy2}', checks=[
self.check("properties.retentionPolicy.dailySchedule.retentionDuration.count", 20),
]).get_output_in_json()
self.kwargs['afsitem'] = self.cmd('backup item list -g {rg} -v {vault} -c {container} --backup-management-type AzureStorage --query [0].name').get_output_in_json()
self.cmd('backup protection disable -g {rg} -v {vault} -c {container} -i {afsitem} --backup-management-type AzureStorage --delete-backup-data true --yes').get_output_in_json()
self.cmd('backup container unregister -g {rg} -v {vault} -c {container} --yes --backup-management-type AzureStorage')
@record_only()
@ResourceGroupPreparer(location="southeastasia", random_name_length=20)
@VaultPreparer()
@StorageAccountPreparer(location="southeastasia")
@FileSharePreparer()
@AFSPolicyPreparer()
@AFSItemPreparer()
def test_afs_unregister_container(self, resource_group, vault_name, storage_account, afs_name, policy_name, item_name):
self.kwargs.update({
'vault': vault_name,
'item': item_name,
'container': storage_account,
'rg': resource_group,
'type': "AzureStorage",
'policy': policy_name,
'afs': afs_name
})
container_json = self.cmd('backup container show -n {container} -v {vault} -g {rg} --backup-management-type {type}', checks=[
self.check('properties.friendlyName', '{container}'),
self.check('properties.healthStatus', 'Healthy'),
self.check('properties.registrationStatus', 'Registered'),
self.check('resourceGroup', '{rg}')
]).get_output_in_json()
self.kwargs['container_name'] = container_json['name']
self.kwargs['item'] = self.cmd('backup item list -g {rg} -v {vault} -c {container} --query [0].name').get_output_in_json()
self.cmd('backup protection disable -g {rg} -v {vault} -c {container_name} -i {item} --backup-management-type AzureStorage --delete-backup-data true --yes')
self.cmd('backup container unregister -g {rg} -v {vault} -c {container_name} --yes')
self.cmd('backup container list -v {vault} -g {rg} --backup-management-type {type}', checks=[
self.check("length([?properties.friendlyName == '{container}'])", 0)])
| 53.742616
| 353
| 0.631428
| 2,821
| 25,474
| 5.573201
| 0.074442
| 0.056672
| 0.061188
| 0.039499
| 0.839779
| 0.814464
| 0.792075
| 0.762498
| 0.739155
| 0.732795
| 0
| 0.011379
| 0.20307
| 25,474
| 473
| 354
| 53.856237
| 0.763066
| 0.022337
| 0
| 0.67268
| 0
| 0.136598
| 0.455831
| 0.095408
| 0
| 0
| 0
| 0
| 0.010309
| 1
| 0.020619
| false
| 0
| 0.012887
| 0
| 0.036082
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
38d6f6aeedc2a21c0d53662e5aa60eb82e5b1b8e
| 76
|
py
|
Python
|
repostatus/commit_mgr.py
|
avattathil/repostatus
|
39e83df970ce90d5ab493af88fea3d0f577252ce
|
[
"Apache-2.0"
] | null | null | null |
repostatus/commit_mgr.py
|
avattathil/repostatus
|
39e83df970ce90d5ab493af88fea3d0f577252ce
|
[
"Apache-2.0"
] | 1
|
2019-05-17T06:30:44.000Z
|
2019-05-17T06:30:44.000Z
|
repostatus/commit_mgr.py
|
avattathil/repostatus
|
39e83df970ce90d5ab493af88fea3d0f577252ce
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/env python
class CommitMgr(object):
def __init__():
pass
| 10.857143
| 24
| 0.657895
| 10
| 76
| 4.6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.197368
| 76
| 6
| 25
| 12.666667
| 0.754098
| 0.263158
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| true
| 0.333333
| 0
| 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
| 1
| 1
| 1
| 0
| 0
| 1
| 0
|
0
| 6
|
38e9d049a18d9b1682603acf2df93b11635476ef
| 162
|
py
|
Python
|
dumpSTR/__init__.py
|
richyanicky/TRTools
|
6582912ad3fade6e905b78b08c991a08baca8649
|
[
"MIT"
] | null | null | null |
dumpSTR/__init__.py
|
richyanicky/TRTools
|
6582912ad3fade6e905b78b08c991a08baca8649
|
[
"MIT"
] | null | null | null |
dumpSTR/__init__.py
|
richyanicky/TRTools
|
6582912ad3fade6e905b78b08c991a08baca8649
|
[
"MIT"
] | null | null | null |
# expose the code in the file dumpSTR/dumpSTR.py
# through the statement import dumpSTR
# instead of through import dumpSTR.dumpSTR
from dumpSTR.dumpSTR import *
| 32.4
| 48
| 0.802469
| 24
| 162
| 5.416667
| 0.541667
| 0.323077
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.148148
| 162
| 4
| 49
| 40.5
| 0.942029
| 0.771605
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
2a550cbc82e7a766e3b193be22c2f776e638d64d
| 55,261
|
py
|
Python
|
pkgs/conf-pkg/src/genie/libs/conf/lisp/iosxe/lisp.py
|
jbronikowski/genielibs
|
200a34e5fe4838a27b5a80d5973651b2e34ccafb
|
[
"Apache-2.0"
] | 94
|
2018-04-30T20:29:15.000Z
|
2022-03-29T13:40:31.000Z
|
pkgs/conf-pkg/src/genie/libs/conf/lisp/iosxe/lisp.py
|
jbronikowski/genielibs
|
200a34e5fe4838a27b5a80d5973651b2e34ccafb
|
[
"Apache-2.0"
] | 67
|
2018-12-06T21:08:09.000Z
|
2022-03-29T18:00:46.000Z
|
pkgs/conf-pkg/src/genie/libs/conf/lisp/iosxe/lisp.py
|
jbronikowski/genielibs
|
200a34e5fe4838a27b5a80d5973651b2e34ccafb
|
[
"Apache-2.0"
] | 49
|
2018-06-29T18:59:03.000Z
|
2022-03-10T02:07:59.000Z
|
'''
LISP Genie Conf Object Implementation for IOSXE - CLI.
'''
# Pyhon
from abc import ABC
# Genie
from genie.conf.base.attributes import AttributesHelper
from genie.conf.base.cli import CliConfigBuilder
from genie.conf.base.config import CliConfig
# LISP Heirarchy
# --------------
# Lisp
# +- DeviceAttributes
# +- InterfaceAttributes
# | +- MobilityDynamicEidAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
# | +- InterfaceAttributes
# | +- InterfacdTypeAttributes
# +- ServiceAttributes
# | +- ItrMrAttributes
# | +- EtrMsAttributes
# | +- ProxyItrAttributes
# +- InstanceAttributes
# | +- DynamicEidAttributes
# | +- DbMappingAttributes
# | +- ServiceAttributes
# | +- DbMappingAttributes
# | +- UsePetrAttributes
# | +- MapCacheAttributes
# +- SiteAttributes
# | +- InstanceIdAttributes
# | +- EidRecordAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
# +- EidRecordProviderAttributes
# +- EidRecordSubscriberAttributes
class Lisp(ABC):
class DeviceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False,
**kwargs):
assert not kwargs, kwargs
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# +- DeviceAttributes
# +- InterfaceAttributes
# ------------------------
# Add InterfaceAttributes configurations under DeviceAttributes
for sub, attributes2 in attributes.mapping_values('intf_attr',
sort=True,
keys=self.intf_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# -----------------------------
# Add RouterInstanceAttributes configurations under DeviceAttributes
for sub, attributes2 in attributes.mapping_values('router_instance_attr',
sort=True,
keys=self.router_instance_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- InterfaceAttributes
class InterfaceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# interface GigabitEthernet1
with configurations.submode_context(
attributes.format('interface {interface.name}', force=True)):
# interface GigabitEthernet1
# no lisp mobility liveness test
if attributes.value('if_mobility_liveness_test_disabled') is True:
config_cmd = 'no lisp mobility liveness test'
unconfig_cmd = 'lisp mobility liveness test'
configurations.append_line(attributes.format(config_cmd),
unconfig_cmd=unconfig_cmd)
# +- DeviceAttributes
# +- InterfaceAttributes
# +- MobilityDynamicEidAttributes
# -----------------------------------
# Add MobilityDynamicEidAttributes configurations under InterfaceAttributes
for sub, attributes2 in attributes.mapping_values('mobility_dynamic_eid_attr',
sort=True,
keys=self.mobility_dynamic_eid_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
class MobilityDynamicEidAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
configurations.append_line(
attributes.format('lisp mobility {if_mobility_dynamic_eid_name}'))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
class RouterInstanceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# router lisp 101
with configurations.submode_context(
attributes.format('router lisp {lisp_router_instance_id}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
# -----------------------------------
# Add LocatorSetAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('locator_set_attr',
sort=True,
keys=self.locator_set_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# -----------------------------------
# Add ServiceAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('service_attr',
sort=True,
keys=self.service_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# -----------------------------------
# Add InstanceAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('instance_id_attr',
sort=True,
keys=self.instance_id_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- SiteAttributes
# -----------------------------------
# Add SiteAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('site_attr',
sort=True,
keys=self.site_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# -----------------------------------
# Add ExtranetAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('extranet_attr',
sort=True,
keys=self.extranet_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
class LocatorSetAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# locator-set RLOC
with configurations.submode_context(
attributes.format('locator-set {locator_set_name}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
# +- InterfaceAttributes
# -----------------------------------
# Add InterfaceAttributes configurations under LocatorSetAttributes
for sub, attributes2 in attributes.mapping_values('locator_set_intf_attr',
sort=True,
keys=self.locator_set_intf_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
# +- InterfaceAttributes
class InterfaceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
# +- InterfaceAttributes
# +- InterfaceTypeAttributes
# -----------------------------------
# Add InterfaceTypeAttributes configurations under InterfaceAttributes
for sub, attributes2 in attributes.mapping_values('locator_set_intf_type_attr',
sort=True,
keys=self.locator_set_intf_type_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
ls_interface=self.ls_interface))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- LocatorSetAttributes
# +- InterfaceAttributes
# +- InterfaceTypeAttributes
class InterfaceTypeAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
if self.ls_interface_type == 'ipv4':
intf_type = 'IPv4-interface'
elif self.ls_interface_type == 'ipv6':
intf_type = 'IPv6-interface'
cfg_str = '{type} {interface}'.format(type=intf_type, interface=kwargs['ls_interface'])
if attributes.value('ls_priority'):
cfg_str += ' priority {ls_priority}'
if attributes.value('ls_weight'):
cfg_str += ' weight {ls_weight}'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
class ServiceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# service ipv4
with configurations.submode_context(
attributes.format('service {service}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
# service ipv4
# itr
if attributes.value('itr_enabled') is True:
configurations.append_line('itr')
# service ipv4
# etr
if attributes.value('etr_enabled') is True:
configurations.append_line('etr')
# service ipv4
# map-server
if attributes.value('ms_enabled') is True:
configurations.append_line('map-server')
# service ipv4
# map-resolver
if attributes.value('mr_enabled') is True:
configurations.append_line('map-resolver')
# service ipv4
# proxy-etr
if attributes.value('proxy_etr_enabled') is True:
configurations.append_line('proxy-etr')
# service ipv4
# encapsulation vxlan
if attributes.value('encapsulation'):
configurations.append_line('encapsulation {}'.\
format(attributes.value('encapsulation').value))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# +- ItrMrAttributes
# -----------------------------------
# Add ItrMrAttributes configurations under ServiceAttributes
for sub, attributes2 in attributes.mapping_values('itr_mr_attr',
sort=True,
keys=self.itr_mr_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# +- EtrMsAttributes
# -----------------------------------
# Add EtrMsAttributes configurations under ServiceAttributes
for sub, attributes2 in attributes.mapping_values('etr_ms_attr',
sort=True,
keys=self.etr_ms_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# +- ProxyItrAttributes
# -----------------------------------
# Add ProxyItrAttributes configurations under ServiceAttributes
for sub, attributes2 in attributes.mapping_values('proxy_attr',
sort=True,
keys=self.proxy_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# +- ItrMrAttributes
class ItrMrAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# service ipv4
# itr map-resolver 6.6.6.6
configurations.append_line(attributes.format('itr map-resolver {itr_map_resolver}'))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# +- EtrMsAttributes
class EtrMsAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# service ipv4
# etr map-server 5.5.5.5 key cisco123
if attributes.value('etr_auth_key'):
cfg_str = 'etr map-resolver {etr_map_server} key {etr_auth_key}'
if attributes.value('etr_auth_key_type').value is not None:
cfg_str += ' hash-function {}'.format(attributes.value('etr_auth_key_type').name)
configurations.append_line(attributes.format(cfg_str))
# service ipv4
# etr map-server 5.5.5.5 proxy-reply
if attributes.value('etr_proxy_reply') is True:
configurations.append_line(attributes.format('etr map-resolver {etr_map_server} proxy-reply'))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ServiceAttributes
# +- ProxyItrAttributes
class ProxyItrAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# service ipv4
# proxy-itr 10.10.10.10
if attributes.value('proxy_itr'):
configurations.append_line(attributes.format('proxy-itr {proxy_itr}'))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
class InstanceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
with configurations.submode_context(
attributes.format('instance-id {instance_id}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- DynamicEidAttributes
# -----------------------------------
# Add DynamicEidAttributes configurations under InstanceAttributes
for sub, attributes2 in attributes.mapping_values('dynamic_eid_attr',
sort=True,
keys=self.dynamic_eid_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# -----------------------------------
# Add ServiceAttributes configurations under InstanceAttributes
for sub, attributes2 in attributes.mapping_values('inst_service_attr',
sort=True,
keys=self.inst_service_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
instance_id=self.instance_id))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- DynamicEidAttributes
class DynamicEidAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
# dynamic-eid 192
with configurations.submode_context(
attributes.format('dynamic-eid {inst_dyn_eid}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- DynamicEidAttributes
# +- DbMappingAttributes
# -----------------------------------
# Add DbMappingAttributes configurations under DynamicEidAttributes
for sub, attributes2 in attributes.mapping_values('db_mapping_attr',
sort=True,
keys=self.db_mapping_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- DynamicEidAttributes
# +- DbMappingAttributes
class DbMappingAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
# dynamic-eid 192
# database-mapping 192.168.0.0/24
cfg_str = 'datbase-mapping {etr_dyn_eid_id}'
# instance-id 101
# dynamic-eid 192
# database-mapping 192.168.0.0/24 locator-set RLOC1
if attributes.value('etr_dyn_eid_rlocs'):
cfg_str += ' locator-set {etr_dyn_eid_rlocs}'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
class ServiceAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
# service ipv4
with configurations.submode_context(
attributes.format('service {inst_service}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
if attributes.value('etr_eid_vrf'):
configurations.append_line(attributes.format('eid-table vrf {etr_eid_vrf}'))
else:
configurations.append_line(attributes.format('eid-table default'))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# +- DbMappingAttributes
# -----------------------------------
# Add DbMappingAttributes configurations under ServiceAttributes
for sub, attributes2 in attributes.mapping_values('service_db_mapping_attr',
sort=True,
keys=self.service_db_mapping_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# +- UsePetrAttributes
# -----------------------------------
# Add UsePetrAttributes configurations under ServiceAttributes
for sub, attributes2 in attributes.mapping_values('use_petr_attr',
sort=True,
keys=self.use_petr_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
instance_id=kwargs['instance_id']))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# +- MapCacheAttributes
# -----------------------------------
# Add MapCacheAttributes configurations under ServiceAttributes
for sub, attributes2 in attributes.mapping_values('map_cache_attr',
sort=True,
keys=self.map_cache_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# +- DbMappingAttributes
class DbMappingAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
# service ipv4
# database-mapping 192.168.0.0/24
cfg_str = 'datbase-mapping {etr_eid_id}'
# instance-id 101
# service ipv4
# database-mapping 192.168.0.0/24 locator-set RLOC1
if attributes.value('etr_eid_rlocs'):
cfg_str += ' locator-set {etr_eid_rlocs}'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# +- UsePetrAttributes
class UsePetrAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
# service ipv4
# use-petr 10.10.10.10
cfg_str = 'use-petr {petr} instance-id {iid}'.\
format(petr=self.etr_use_petr, iid=kwargs['instance_id'])
# instance-id 101
# service ipv4
# use-petr 10.10.10.10 priority 10
if attributes.value('etr_use_petr_priority'):
cfg_str += ' priority {etr_use_petr_priority}'
# instance-id 101
# service ipv4
# use-petr 10.10.10.10 priority 10 weight 30
if attributes.value('etr_use_petr_weight'):
cfg_str += ' weight {etr_use_petr_weight}'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- InstanceAttributes
# +- ServiceAttributes
# +- MapCacheAttributes
class MapCacheAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# instance-id 101
# service ipv4
# map-cache 10.1.1.0/24
cfg_str = 'map-cache {itr_mc_id}'
# instance-id 101
# service ipv4
# map-cache 10.1.1.0/24 map-request
if attributes.value('itr_mc_map_request') is True:
cfg_str += ' map-request'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- SiteAttributes
class SiteAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# site xtr1_1
with configurations.submode_context(
attributes.format('site {ms_site_id}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
if attributes.value('ms_site_auth_key'):
configurations.append_line(attributes.format('authentication-key {ms_site_auth_key}'))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- SiteAttributes
# +- InstanceIdAttributes
# -----------------------------------
# Add SiteAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('site_inst_id_attr',
sort=True,
keys=self.site_inst_id_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
ms_site_id=self.ms_site_id))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- SiteAttributes
# +- InstanceIdAttributes
class InstanceIdAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- SiteAttributes
# +- InstanceIdAttributes
# +- EidRecordAttributes
# -----------------------------------
# Add SiteAttributes configurations under RouterInstanceAttributes
for sub, attributes2 in attributes.mapping_values('eid_record_attr',
sort=True,
keys=self.eid_record_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
instance_id=self.site_inst_id))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- SiteAttributes
# +- InstanceIdAttributes
# +- EidRecordAttributes
class EidRecordAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# eid-record instance-id 101 88.88.88.0/24
cfg_str = 'eid-record instance-id {iid} {eid}'.\
format(iid=kwargs['instance_id'], eid=self.ms_eid_id)
if attributes.value('ms_eid_accept_more_specifics') is True:
cfg_str += ' accept-more-specifics'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
class ExtranetAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# extranet ext1
with configurations.submode_context(
attributes.format('extranet {ms_extranet}', force=True)):
if unconfig and attributes.iswildcard:
configurations.submode_unconfig()
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
# -----------------------------------
# Add InstanceIdAttributes configurations under ExtranetAttributes
for sub, attributes2 in attributes.mapping_values('extranet_inst_id_attr',
sort=True,
keys=self.extranet_inst_id_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
class InstanceIdAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
# +- EidRecordProviderAttributes
# --------------------------------------
# Add EidRecordProviderAttributes configurations under InstanceIdAttributes
for sub, attributes2 in attributes.mapping_values('eid_record_provider_attr',
sort=True,
keys=self.eid_record_provider_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
instance_id=self.extranet_inst_id))
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
# +- EidRecordSubscriberAttributes
# ----------------------------------------
# Add EidRecordSubscriberAttributes configurations under InstanceIdAttributes
for sub, attributes2 in attributes.mapping_values('eid_record_subscriber_attr',
sort=True,
keys=self.eid_record_subscriber_attr):
configurations.append_block(
sub.build_config(apply=False,
attributes=attributes2,
unconfig=unconfig,
instance_id=self.extranet_inst_id))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
# +- EidRecordProviderAttributes
class EidRecordProviderAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# extranet ext1
# eid-record-provider instance-id 101 88.88.88.0/24
cfg_str = 'eid-record-provider instance-id {iid} {provider}'.\
format(iid=kwargs['instance_id'], provider=self.ms_extranet_provider_eid)
# extranet ext1
# eid-record-provider instance-id 101 88.88.88.0/24 bidirectional
if attributes.value('ms_extranet_provider_bidir') is True:
cfg_str += ' bidirectional'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
# +- DeviceAttributes
# +- RouterInstanceAttributes
# +- ExtranetAttributes
# +- InstanceIdAttributes
# +- EidRecordSubscriberAttributes
class EidRecordSubscriberAttributes(ABC):
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs):
assert not apply
attributes = AttributesHelper(self, attributes)
configurations = CliConfigBuilder(unconfig=unconfig)
# extranet ext1
# eid-record-provider instance-id 101 88.88.88.0/24
cfg_str = 'eid-record-subscriber instance-id {iid} {subscriber}'.\
format(iid=kwargs['instance_id'], subscriber=self.ms_extranet_subscriber_eid)
# extranet ext1
# eid-record-provider instance-id 101 88.88.88.0/24 bidirectional
if attributes.value('ms_extranet_subscriber_bidir') is True:
cfg_str += ' bidirectional'
configurations.append_line(attributes.format(cfg_str))
return str(configurations)
def build_unconfig(self, apply=True, attributes=None, **kwargs):
return self.build_config(apply=apply, attributes=attributes,
unconfig=True, **kwargs)
| 52.88134
| 122
| 0.437162
| 3,342
| 55,261
| 7.088271
| 0.049072
| 0.034362
| 0.027439
| 0.048546
| 0.837435
| 0.776225
| 0.749208
| 0.716113
| 0.710372
| 0.698805
| 0
| 0.010476
| 0.486962
| 55,261
| 1,044
| 123
| 52.931992
| 0.825086
| 0.179856
| 0
| 0.7
| 0
| 0
| 0.045088
| 0.009871
| 0
| 0
| 0
| 0
| 0.048077
| 1
| 0.096154
| false
| 0
| 0.007692
| 0.048077
| 0.25
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
2a58bbde6cb38304395263c09760b2ed67719f57
| 165
|
py
|
Python
|
app/views/static.py
|
greggparrish/ucitelj
|
10c5510aa28561953b98d959d45025655b6a21be
|
[
"MIT"
] | null | null | null |
app/views/static.py
|
greggparrish/ucitelj
|
10c5510aa28561953b98d959d45025655b6a21be
|
[
"MIT"
] | null | null | null |
app/views/static.py
|
greggparrish/ucitelj
|
10c5510aa28561953b98d959d45025655b6a21be
|
[
"MIT"
] | null | null | null |
from flask import Blueprint, render_template
static = Blueprint('static', __name__)
@static.route('/')
def home():
return render_template('static/home.html')
| 18.333333
| 46
| 0.733333
| 20
| 165
| 5.75
| 0.65
| 0.243478
| 0.347826
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.127273
| 165
| 8
| 47
| 20.625
| 0.798611
| 0
| 0
| 0
| 0
| 0
| 0.139394
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.2
| 0.2
| 0.6
| 0.4
| 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
| 1
| 1
| 0
|
0
| 6
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.