def test_get_unsaved_data_no_storage(self): test_data_amount = 3 test_data = get_data(test_data_amount, save_data=False) assert len(test_data.get("images")) == test_data_amount assert len(test_data.get("labels")) == test_data_amount
def lambda_handler(event, context): query = ''' SELECT cr.name as character, array_agg(co.title) as Comics FROM target_characters tc JOIN characters ct ON tc.character_id = ct.id JOIN character_comic cct ON ct.id = cct.character_id JOIN character_comic ccr ON cct.comic_id = ccr.comic_id JOIN comics co ON co.id = cct.comic_id JOIN characters cr ON cr.id = ccr.character_id WHERE tc.name = '{id}' AND cr.id != ct.id GROUP BY cr.name ''' for aven in target_avengers: df = get_data(query.format(id=aven)) char_com = df.to_dict(orient='records') str_now = datetime.datetime.now().strftime('%d/%m/%Y %H:%M:%S') response = {'last_sync': str_now, 'characters': char_com} put_item_dynamo({ 'id': aven, 'response': response }, 'partners-avengers-db')
def lambda_handler(event, context): query = ''' SELECT ccr.role, array_agg(DISTINCT cr.full_name) creators FROM target_characters tc JOIN characters ct ON tc.character_id = ct.id JOIN character_comic cct ON ct.id = cct.character_id JOIN creator_comic ccr ON cct.comic_id = ccr.comic_id JOIN creators cr ON cr.id = ccr.creator_id WHERE tc.name = '{id}' AND ccr.role in ('colorist', 'writer', 'editor') GROUP BY ccr.role; ''' for aven in target_avengers: df = get_data(query.format(id=aven)) creators = {} for index, row in df.iterrows(): creators[row.role] = row.creators str_now = datetime.datetime.now().strftime('%d/%m/%Y %H:%M:%S') creators.update({'last_sync': str_now}) put_item_dynamo({ 'id': aven, 'response': creators }, 'creators-avengers-db')
def test_get_unsaved_data_with_storage(self): test_data_amount = 3 test_data = get_data(test_data_amount, save_data=True) directory = os.path.join("helpers", "data_files", "data") file_name_list = ["data_amount", f"{test_data_amount}"] test_file_name = "_".join(file_name_list) test_file_path = os.path.join(ROOT_DIRECTORY, directory, test_file_name) assert len(test_data.get("images")) == test_data_amount assert len(test_data.get("labels")) == test_data_amount assert os.path.exists(test_file_path) os.remove(test_file_path)
def test_get_saved_data(self): test_data_amount = 3 test_object = { "images": [0]*test_data_amount, "labels": [0]*test_data_amount } directory = os.path.join("helpers", "data_files", "data") file_name_list = ["data_amount", f"{test_data_amount}"] test_file_name = "_".join(file_name_list) test_file_path = os.path.join(ROOT_DIRECTORY, directory, test_file_name) pickle_object(directory, file_name_list, test_object) test_data = get_data(test_data_amount, save_data=False) assert len(test_data.get("images")) == test_data_amount assert len(test_data.get("labels")) == test_data_amount os.remove(test_file_path)
def main(): get_data(ARGS.train_channel)
from svc.net import * from helpers.helpers import get_data import numpy as np import matplotlib.pyplot as plt n = 10 min = 0.0 max = 3.0 l_nodes = [784, 10] training_iter = 500 data_amount = 500 data = get_data(data_amount) images = data[0] labels = data[1] learn_rates = np.linspace(min, max, n) acc = [] co = [] for rate in learn_rates: print(rate) net = NeuNetBuilder(l_nodes).act("relu").cost("expquadratic").build() cost = net.train(images, labels, training_iter, learn_rate=rate, save=False)
from classes.pairSum import PairSum from helpers.helpers import get_data, save_data arr = get_data('array.txt') pairSum = PairSum() arr_output = pairSum.return_sum(arr) save_data(arr_output)