예제 #1
0
def get_P(network):
    num_vertices = len(network["vertices"])
    P = numpy.zeros(shape=(num_vertices, num_vertices))
    total_out = numpy.zeros(num_vertices)
    edges = network["edges"]
    for edge in edges:
        end1 = edge["end1"]
        end1_index = find(network["vertices"], "id", end1)
        total_out[end1_index] = total_out[end1_index] + edge["flow"]
    for edge in edges:
        end1 = edge["end1"]
        end1_index = find(network["vertices"], "id", end1)
        end2 = edge["end2"]
        end2_index = find(network["vertices"], "id", end2)
        P[end1_index][end2_index] = edge["flow"] / total_out[end1_index]
    return P
예제 #2
0
def check_pnumber():
    pnum = input("Skriv personnummer YYMMDDXXXX:")
    pnum_multiplied = multiply(pnum)
    num = summary(pnum_multiplied)
    control = find(num)
    print("Din kontrollsiffra bör vara:", control)

    return int(pnum[-1]) == control #True/False
예제 #3
0
def process_tags(data):
    path = settings.upload_folder + data['tag'][0] + '/'
    if not os.path.exists(path):
        os.makedirs(path)
    for item in data['ids[]']:
        print 'Moving item ' + item
        # old_item_path = helpers.find(item + '.*', settings.upload_folder)
        old_item_path = helpers.find(item, settings.upload_folder)
        # old_item_path = settings.upload_folder + item;
        new_item_path = path + old_item_path.split('/')[-1]
        os.rename(old_item_path, new_item_path)
예제 #4
0
파일: rex.py 프로젝트: shadowx30/bot
def get_market_summaries():
    """
    get_market_summaries gets the top 40% highest volume market summaries for
    btc, eth and usdt based markets
    TODO: how can we automate the btc/eth/usdt lists into automated list generation based on the split[0] for the MarketName?
    """
    summaries = Rex.get_market_summaries()["result"]
    currencies = Rex.get_currencies()["result"]

    btc_summaries = []
    eth_summaries = []
    usdt_summaries = []

    for summary in reversed(sorted(summaries, key=itemgetter("Volume"))):
        market = summary["MarketName"].split("-")[0]
        coin = summary["MarketName"].split("-")[1]

        entry = {}
        entry["symbol"] = coin

        coin_info = find(currencies, "Currency", coin)

        if coin_info:
            entry["name"] = coin_info["CurrencyLong"].lower()

        if market == "BTC":
            btc_summaries.append(entry)

        if market == "ETH":
            eth_summaries.append(entry)

        if market == "USDT":
            usdt_summaries.append(entry)

    summaries = btc_summaries[:get_cream(btc_summaries)] + eth_summaries[:get_cream(
        eth_summaries)] + usdt_summaries[:get_cream(usdt_summaries)]

    # get rid of blacklist terms
    for blacklisted in blacklist:
        for summary in summaries:
            if summary["symbol"] == blacklisted:
                summaries.remove(summary)

    # ensure no duplicates
    final = []
    for i in summaries:
        if i not in final:
            final.append(i)

    if env == "test":
        return final[:5]

    return final
예제 #5
0
def read_EPANET_Flows(network, path, net_name, hour):
    flow_file_name = path + net_name + "_EdgeFlow_" + str(hour) + "am.txt"
    f = open(flow_file_name, "r")
    contents = f.readlines()
    line_no = 4
    while line_no < len(contents):
        line = contents[line_no]
        line_parts = line.split()
        while len(line_parts) > 0:
            edgeID = line_parts[1]
            edge_index = find(network["edges"], "id", edgeID)
            flow = float(line_parts[2])
            end1 = network["edges"][edge_index]["end1"]
            end2 = network["edges"][edge_index]["end2"]
            vertex_index_1 = find(network["vertices"], "id", end1)
            vertex_index_2 = find(network["vertices"], "id", end2)

            if (flow < 0):
                network["edges"][edge_index].update({
                    "flow": -1 * flow,
                    "end1": end2,
                    "end2": end1
                })
                children = network["vertices"][vertex_index_2]["children"]
                parents = network["vertices"][vertex_index_1]["parents"]
                children.append(network["vertices"][vertex_index_1]["id"])
                parents.append(network["vertices"][vertex_index_2]["id"])
            else:
                network["edges"][edge_index].update({"flow": flow})
                children = network["vertices"][vertex_index_1]["children"]
                parents = network["vertices"][vertex_index_2]["parents"]
                children.append(network["vertices"][vertex_index_2]["id"])
                parents.append(network["vertices"][vertex_index_1]["id"])
            line_no = line_no + 1
            if line_no == len(contents):
                break
            line = contents[line_no]
            line_parts = line.split()
    return network
예제 #6
0
def search_results(request):
    search_key = request.GET['search']
    results = find(search_key, max_size)
    paginator = Paginator(results, 15) # Show 15 results per page
    page = request.GET.get('page')
    try:
        page_results = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        page_results = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        page_results = paginator.page(paginator.num_pages)
    return render(request, "searchapp/results.html", {'res' : page_results, 'search_key' : search_key})
예제 #7
0
def search_results(request):
    search_key = request.GET['search']
    results = find(search_key, max_size)
    paginator = Paginator(results, 15)  # Show 15 results per page
    page = request.GET.get('page')
    try:
        page_results = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        page_results = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        page_results = paginator.page(paginator.num_pages)
    return render(request, "searchapp/results.html", {
        'res': page_results,
        'search_key': search_key
    })
from bitstruct import *
import numpy
import matplotlib.pyplot as plt
from helpers import find, centerBins,lstSearch



wiredata = numpy.load('Ch3.dat.npy')


indiwire=find(wiredata,150,1300)
wireHist=numpy.histogram(wiredata[indiwire],8*16)

wireLUVals=centerBins(wireHist[1])


griddata = numpy.load('Ch7.dat.npy')

indigrid=find(griddata,150,1000)
gridHist=numpy.histogram(griddata[indigrid],2*48)

gridLUVals=centerBins(gridHist[1])

#print(gridLUVals,wireLUVals)

LUT=dict()

#NOTE THE DATA SEEM TO INDICATE THAT THE GRID NUMBERING IS MISREPRESENTED IN THE MULTIGRID.PDF FILE. IT LOOKS LIKE WIRES 1-64 GO WITH GRIDS 49-96
pixID=0
for j in range(48,96):
    for k in range(0,64):
from bitstruct import *
import numpy
import matplotlib.pyplot as plt
from helpers import find, centerBins, lstSearch

wiredata = numpy.load('Ch3.dat.npy')

indiwire = find(wiredata, 150, 1300)
wireHist = numpy.histogram(wiredata[indiwire], 8 * 16)

wireLUVals = centerBins(wireHist[1])

griddata = numpy.load('Ch7.dat.npy')

indigrid = find(griddata, 150, 1000)
gridHist = numpy.histogram(griddata[indigrid], 2 * 48)

gridLUVals = centerBins(gridHist[1])

#print(gridLUVals,wireLUVals)

LUT = dict()

#NOTE THE DATA SEEM TO INDICATE THAT THE GRID NUMBERING IS MISREPRESENTED IN THE MULTIGRID.PDF FILE. IT LOOKS LIKE WIRES 1-64 GO WITH GRIDS 49-96
pixID = 0
for j in range(48, 96):
    for k in range(0, 64):
        LUT.update({(int(wireLUVals[k]), int(gridLUVals[j])): pixID})
        pixID += 1

for j in range(0, 48):
예제 #10
0
def rest_name(request):
    search_key = request.GET['search']
    results = find(search_key, 20)
    return JsonResponse({'res': results})
예제 #11
0
def rest_name(request):
    search_key = request.GET['search']
    results = find(search_key, 20)
    return JsonResponse({'res' : results})