示例#1
0
    def test_data_by_param(self):
        data = get_data()
        data1 = data_by_param(7, '25')
        data2 = [
            [
                '12191/001', 'Burnsall Grange',
                'CTIL (Vodafone/O2/T Mobile) Cornerstone Telecommunications Infrastructure Ltd',
                'Burnsall Grange', 'LS12 3LG', '26-Jul-07', '25-Jul-32', '25',
                '25-Jul-12', '12000', 'Antenna'
            ],
            [
                '06084/001', 'Queenswood Heights',
                'CTIL (Vodafone/O2/T Mobile) Cornerstone Telecommunications Infrastructure Ltd',
                'Queenswood Heights', 'LS6 3EE', '08-Nov-04', '07-Nov-29',
                '25', '08-Nov-14', '9500', 'Antenna'
            ],
            [
                '14148/001', 'Seacroft Gate (Chase) block 2',
                'CTIL (Vodafone/O2/T Mobile) Cornerstone Telecommunications Infrastructure Ltd',
                'Seacroft Gate (Chase) - Block 2', 'LS14', '30-Jan-04',
                '29-Jan-29', '25', '30-Jan-14', '12250', 'Antenna'
            ],
            [
                '14148/002', 'Seacroft Gate (Chase) - Block 2',
                'Everything Everywhere Ltd & Hutchinson 3G UK (MBNL)',
                'Seacroft Gate (Chase) - Block 2', 'LS14', '21-Aug-07',
                '20-Aug-32', '25', '21-Aug-17', '12750', 'Antenna'
            ]
        ]

        self.assertCountEqual(data1, data2)
示例#2
0
文件: main.py 项目: wumzi/metro
def main(start, destination, file, delai_correspondance, delai_stations):
    """The Main Controller of the program, the functions are called here"""

    #Opening the file
    data = get_data(file)
    if not data:
        print('Fichier de description introuvable !')
        exit()

    #Building the linking map for each stations
    corresp = get_corresp(data, start, destination)
    
    if not corresp:
        return'Format du fichier de description invalide !'
    inexistant = 0
    if clean_name(start) not in corresp:
        inexistant = start
    elif clean_name(destination) not in corresp:
        inexistant = destination
    if inexistant:
        return 'Station "%s" introuvable dans ce fichier de description' % inexistant
       

    #Finding the shortest path
    path_done = path(start, destination, corresp, delai_correspondance, delai_stations)

    #Show results
    return display(path_done)
示例#3
0
def main(argv):
    #default cache configuration - in bits
    n_way = int(math.log(0x10, 0x2))
    #16-way
    line_sz = int(math.log(0x40, 0x2))
    #64B
    #cache_sz = int(math.log(0x400, 0x2));                                   #1KB
    #cache_sz = int(math.log(0x8000, 0x2));                                 #32KB
    #cache_sz = int(math.log(0x40000, 0x2));                               #256KB
    cache_sz = int(math.log(0x100000, 0x2))
    #1MB
    #cache_sz = int(math.log(0x400000, 0x2));                                #4MB
    user_policy = "LRU"

    if len(argv) > 2:  #change defaults to user supplied arguements
        line_sz = int(math.log(int(argv[2]), 2))

        if argv[3] == "1KB":
            cache_sz = int(math.log(0x400, 0x2))
        elif argv[3] == "32KB":
            cache_sz = int(math.log(0x8000, 0x2))
        elif argv[3] == "256KB":
            cache_sz = int(math.log(0x40000, 0x2))
        elif argv[3] == "1MB":
            cache_sz = int(math.log(0x100000, 0x2))
        elif argv[3] == "4MB":
            cache_sz = int(math.log(0x400000, 0x2))

        n_way = int(math.log(int(argv[4]), 0x2))
        user_policy = argv[5]

    print(line_sz, cache_sz, n_way, user_policy)
    miss = 0
    access = 0
    cache = []
    for i in range((2**(cache_sz - line_sz - n_way))):
        cache.append(cache_set(user_policy, 2**n_way))

    for pc, md, va in get_data(argv[1]):
        offset = va & ((1 << line_sz) - 1)
        #only offset bits are unmasked
        va = va >> line_sz
        #remove offset bits
        index = va & ((1 << (cache_sz - line_sz - n_way)) - 1)
        #set index
        va = va >> (cache_sz - line_sz - n_way)
        #remove index bits
        tag = va
        #only tag bits remain

        if cache[index].search(tag) == False:
            miss += 1

        access += 1

    # print("Miss     : ", miss);
    # print("Access   : ", access);
    print("Cache miss rate: ", round((miss / access) * 100, 2), "%", sep='')
示例#4
0
def command_country(message):
    if message.text in countries:
        data = get_data(message.text)
        msg = f"Всего случаев: {data['total_cases']}\n" \
              f"Новых случаев: {data['new_cases']}\n" \
              f"Всего смертей: {data['total_deaths']}\n" \
              f"Динамика смертей: {data['new_deaths']}\n" \
              f"Всего вылечившихся: {data['total_recovered']}\n"
        bot.send_message(message.chat.id, msg)
    else:
        bot.send_message(message.chat.id, 'Выберите странну из списка:')
示例#5
0
def main() -> None:
    vk_session = vk_api.VkApi(token=config.VK_TOKEN)
    longpoll = VkBotLongPoll(vk_session, config.VK_GROUP_ID)
    for event in longpoll.listen():
        if event.type == VkBotEventType.MESSAGE_NEW:
            peer_id = event.object.message['peer_id']
            nickname = event.object.message['text']
            stats_message = get_data(nickname)
            vk_session.method(
                "messages.send", {
                    "peer_id": peer_id,
                    "random_id": get_random_id(),
                    "message": stats_message
                })
示例#6
0
def main():

    graph = True if 'graph' in argv else False
    if not graph:
        print('pro tip: you can display graphs with "graph" argument')
    data = parser.get_data('data.csv')
    km = parser.normalize(data.km, min(data.km), max(data.km))
    price = parser.normalize(data.price, min(data.price), max(data.price))
    try:
        theta, record = gradient_descent(km, price, float(len(data)))
        if graph is True:
            display(data, theta[0], theta[1], record)
    except (KeyboardInterrupt, SystemExit):
        exit('\nInterrupted')
    parser.store_theta('theta.csv', theta)
    print("training done! t0: {} and t1: {} are stored in theta.csv".format(
        theta[0], theta[1]))
示例#7
0
    def __init__(self, fns=None, start_time=10, end_time=15, efficiency=0.95):
        super(DataSource, self).__init__()

        # defaults to northeast ohio if no other data provided
        if fns == None:
            fns = [
                "data/cleveland.csv", "data/akron.csv", "data/mansfield.csv"
            ]
        self.data = get_data(fns)

        # create array of corresponding dates
        next_year = datetime.datetime.now().year + 1
        start = datetime.datetime(next_year, 1, 1)
        h = datetime.timedelta(hours=1)
        self.dates = [start + i * h for i in range(self.data.shape[0])]
        self.weekdays = np.array([i.weekday() for i in self.dates])
        # set efficiency from input
        self.efficiency = efficiency

        # usable PV power only between specified start and end times
        idx = np.where(self.data[:, 2] < start_time)
        self.data[idx, power_idx] = 0.0
        idx = np.where(self.data[:, 2] > end_time)
        self.data[idx, power_idx] = 0.0

        # length of time series
        self.n = self.data.shape[0]

        # Variables that will be outputted
        self.add_output("cell_temperature", np.zeros(self.n), units="degC")
        self.add_output("ambient_temperature", np.zeros(self.n), units="degC")
        self.add_output("hour", np.zeros(self.n), units="h")
        self.add_output("day", np.zeros(self.n), units="d")
        self.add_output("weekday", self.weekdays)
        self.add_output("month", np.zeros(self.n), units="mo")
        self.add_output("P_base", np.zeros(self.n), units="W")
        self.add_output("wind", np.zeros(self.n), units="m/s")
        self.add_output("irradiance", np.zeros(self.n))
    def __init__(self, fns=None, start_time=10, end_time=15, efficiency=0.95):
        super(DataSource, self).__init__()

        # defaults to northeast ohio if no other data provided
        if fns == None:
            fns = ["data/cleveland.csv", "data/akron.csv", "data/mansfield.csv"]
        self.data = get_data(fns)

        # create array of corresponding dates
        next_year = datetime.datetime.now().year + 1
        start = datetime.datetime(next_year, 1, 1)
        h = datetime.timedelta(hours=1)
        self.dates = [start + i*h for i in range(self.data.shape[0])]
        self.weekdays = np.array([i.weekday() for i in self.dates])
        # set efficiency from input
        self.efficiency = efficiency

        # usable PV power only between specified start and end times
        idx = np.where(self.data[:, 2] < start_time)
        self.data[idx, power_idx] = 0.0
        idx = np.where(self.data[:, 2] > end_time)
        self.data[idx, power_idx] = 0.0
        
        # length of time series
        self.n = self.data.shape[0]

        # Variables that will be outputted
        self.add_output("cell_temperature", np.zeros(self.n), units="degC")
        self.add_output("ambient_temperature", np.zeros(self.n), units="degC")
        self.add_output("hour", np.zeros(self.n), units="h")
        self.add_output("day", np.zeros(self.n), units="d")
        self.add_output("weekday", self.weekdays)
        self.add_output("month", np.zeros(self.n), units="mo")
        self.add_output("P_base", np.zeros(self.n), units="W")
        self.add_output("wind", np.zeros(self.n), units="m/s")
        self.add_output("irradiance", np.zeros(self.n))
示例#9
0
import csv
import operator
import datetime
import re
import argparse

from parser import get_data, sort_data, data_by_param, total, \
    count_items_in_col, format_date, list_rentals, option_one, \
    option_two, option_three, option_four

current_dir = '/home/seraphina/Documents/TRAINING/training_2019/\
    JOB_APPLICATIONS/bink/data-parser/'

data_source_location = current_dir + 'Mobile_Phone_Masts_01_04_2019a.csv'

data = get_data()[1:]


class TestParser(unittest.TestCase):
    def test_get_data(self):
        orig_data = list(data)
        test_data = [
            [
                '14173/001', 'Baileys Towers, Bailey Lane ',
                'CTIL (Vodafone/O2/T Mobile) Cornerstone Telecommunications Infrastructure Ltd',
                'Bailey Lane', 'LS14 6PY', '31-Mar-15', 'n/a', '0',
                '31-Mar-20', '15000', 'Antenna'
            ],
            [
                '14173/003', 'Baileys Towers Bailey Lane',
                'The Office of Communications (Ofcom)', 'Bailey Lane',
示例#10
0
def method_one():
    typer.echo(tabulate(get_data()))
示例#11
0
def main():
    dir_path = "../data/semeval2013-Task7-2and3way/training/2way/beetle"
    data = parser.get_data(dir_path)
    data = correct_student_answers(data)
示例#12
0
import parser
import pandas as pd

a, columns = parser.get_data()
data = pd.DataFrame(data=a).transpose()
data.columns = columns
print(data)
data.to_excel("keymap.xls")
示例#13
0
                fixed_d.append(data[i])
            else:
                others_l.append(labels[i])
                others_d.append(data[i])

    return fixed_l, fixed_d, others_l, others_d


def main(labels, data):
    acc = 0
    params = ()
    for max_depth in [None] + [i for i in range(1, 50)]:
        for max_features in range(1, len(data[0]) + 1):
            for min_samples_leaf in range(1, 50):
                tmp_acc = cross_validation(data, labels, max_depth, max_features, min_samples_leaf)
                if tmp_acc > acc:
                    acc = tmp_acc
                    params = (max_depth, max_features, min_samples_leaf)
    print(acc)
    print(params[0], params[1], params[2])


if __name__ == '__main__':
    labels, data = parser.get_data()
    labels, data, not_teached_labels, not_teached_data = fix_data_set(data, labels)
    print(len(not_teached_labels))
    for md, mf, msl in ((None, 22, 3), (45, 33, 2)):
        _ = cross_validation(data, labels, md, mf, msl, not_teached_data, not_teached_labels)

# 45, 33, 2; 44, 3, 3, 42, 13, 2, 41, 21, 3, 38, 29, 3, 38, 26, 3, 38, 22, 2, 33, 30, 3, 32, 28, 2, None 22, 3
示例#14
0
def main():

    data = parser.get_data('data.csv')
    theta = parser.get_theta('theta.csv')
    price = estimate_price(data, theta)
    print('This car is worth %d$' % price)
示例#15
0
文件: api.py 项目: edgar-ch/mstation
def push_to_server():
	raw_data = get_binary_data(ORIGIN)
	data = get_data(raw_data)

	return json.dumps(data)
示例#16
0
文件: main.py 项目: IsaacTay/ARP1
import parser

model = Model()

optimizer = optim.Adam(model.parameters(), eps=10**-4)

save_file = "saves/model.state"
if os.path.isfile(save_file):
    state = torch.load(save_file)
    model.load_state_dict(state)
test_accuracy_file = "saves/test_accuracy.state"
test_accuracy = []
if os.path.isfile(test_accuracy_file):
    test_accuracy = torch.load(test_accuracy_file)["test_accuracy"]

train_data = np.array(parser.get_data("data/sign_mnist_train.csv"),
                      dtype=object)
test_data = np.array(parser.get_data("data/sign_mnist_test.csv"), dtype=object)


def train():
    prev_accuracy = 0
    if len(test_accuracy) > 0:
        prev_accuracy = test_accuracy[-1] * 100
    for i in range(1):
        sub_data = train_data[np.random.randint(0, len(train_data), 16)]
        data, target = np.stack(sub_data[:, 1]), np.array(sub_data[:, 0],
                                                          dtype=np.int32)
        data = np.expand_dims(data, axis=1)
        data, target = Variable(torch.Tensor(data)), Variable(
            torch.LongTensor(target))
示例#17
0
def main():
	dir_path = "../data/semeval2013-Task7-2and3way/training/2way/beetle"
	data = parser.get_data(dir_path)
	data = correct_student_answers(data)
示例#18
0

def xz_rotate_all(verts, angle):
    out = []
    for vert in verts:
        new = xz_rotation(vert, angle)
        out.append(new)

    return out


start = time.time()

# Load data
source_file = "../../models/simplified/simplified_900/simplified_900.obj"
verts, faces = parser.get_data(source_file)
print(len(verts), len(faces))

# Make source point
source = (30, 30, 50)

# Translate all points to make source origin
verts = translate_all(verts, invert(source))
# Save original locations before rotation
og_verts = verts[:]
og_sets = parser.make_sets(verts, faces)

# Rotate on xy plane to center model
print("XY ROTATION")
center = center_of_mass(verts)
angle = xy_angle(center)
示例#19
0
import math
import parser
import operations

from warehouse import Warehouse

nb_octet = 0
instructions = []
data = parser.get_data()
nb_order = data['orders']['number']
nb_warehouse = data['warehouses']['number']

class Drone:
    def __init__(self, id):
        self.id = id
        self.item_list = {}
        self.at_warehouse = True
        self.position_id = 0
        self.payload = 0
        self.tick = 0

    def go_to_delivery(self, order_id):
        if len(self.item_list) > 0:
            if self.at_warehouse:
                for item_id, nb_item in self.item_list.iteritems():
                    self.tick = self.tick + 1
                    if self.tick < data['turns']:
                        instructions.append('{} L {} {} {}'.format(self.id, self.position_id, item_id, nb_item))
                self.at_warehouse = False
                self.tick += warehouse_distance_mat[order_id][self.position_id]
                self.position_id = order_id