コード例 #1
0
ファイル: commoner.py プロジェクト: pjlohr/biosys-analytics
def main():
    """Make a jazz noise here"""
    args = get_args()
    min_len = args.min_len
    files = args.FILE
    hamm = args.hamming_distance
    logfile = args.logfile
    table = args.table

    logging.basicConfig(
        filename=logfile,
        filemode='w',
        level=logging.DEBUG if args.debug else logging.CRITICAL)

    file1 = files[0]
    file2 = files[1]

    logging.debug('file1 = {}, file2 = {}'.format(file1, file2))

    if hamm < 0:
        die('--distance "{}" must be > 0'.format(hamm))

    words1 = sorted(uniq_words(file1, min_len))
    words2 = sorted(uniq_words(file2, min_len))
    matches = {}
    for str1 in words1:
        for str2 in words2:
            d = dist(str1, str2)
            if d <= hamm:
                matches[(str1, str2)] = d

    if len(matches) > 0:
        t = []
        for pairs, count in matches.items():
            col1 = pairs[0]
            col2 = pairs[1]
            col3 = count
            column = col1, col2, col3
            t.append(column)

        if table:
            print(
                tbl(t, headers=['word1', 'word2', 'distance'],
                    tablefmt='psql'))
        else:
            print('{}\t{}\t{}'.format('word1', 'word2', 'distance'))
            for row in t:
                print('{}\t{}\t{}'.format(row[0], row[1], row[2]))

    else:
        print('No words in common.')
コード例 #2
0
# https://github.com/dhava-stmkg/interpolation

import numpy as np  # Import modul numpy sebagai np
import sympy as sy  # Import modul sympy sebagai sy
from tabulate import tabulate as tbl  # Import sub-modul tabulate dari modul tabulate sebagai tbl

# Define t as symbol using sympy lib
t = sy.Symbol('t')

# Data
x = np.array([0, 10, 15, 20, 22.5, 30])
y = np.array([0, 227.04, 362.78, 517.35, 602.97, 901.67])
tabel = []
for i in range(len(x)):
    tabel.append([x[i], y[i]])
table = tbl(tabel, headers=['t(s)', 'v(t) (mm/s)'], tablefmt='orgtbl')
print(table)


# Function
def direct_method(x, y):
    vander_matrix = np.vander(
        x, increasing=False
    )  # Membuat matrix Vandermonde dengan menggunakan modul numpy
    coef = np.linalg.solve(vander_matrix,
                           y)  # Menyelesaikan persamaan dengan modul numpy
    return coef  # Mengembalikan nilai koefisien


def newt_method(x, y):
    m = len(x)  # Mengambil jumlah data
コード例 #3
0
    c.get_rate(base_cur, MXN, date_obj),
    c.get_rate(base_cur, BGN, date_obj),
    c.get_rate(base_cur, HUF, date_obj),
    c.get_rate(base_cur, MYR, date_obj),
    c.get_rate(base_cur, HRK, date_obj),
    c.get_rate(base_cur, THB, date_obj),
    c.get_rate(base_cur, NOK, date_obj),
    c.get_rate(base_cur, PLN, date_obj),
    c.get_rate(base_cur, CZK, date_obj)
]]

tbl_header = (USD, GBP, ZAR, EUR, AUD, SGD, CAD, CNY, JPY, NZD, INR, CHF, MXN,
              BGN, HUF, MYR, HRK, THB, NOK, PLN, CZK)

print(">>Table Results:")
print('>>Base Currency = ', base_cur)
print(tbl(tbl_data, tbl_header, tablefmt="fancy_grid"))
print(">>DOne loading table...")

print("\n::Lets Check Bitcoin now...!")
print("Bitcoin price for => ", base_cur)

print("1 BITCOIN = %(base)s %(price).2F" % {
    'base': base_cur,
    'price': b.get_latest_price(base_cur)
})

print(">>Done checking bitcoin...")
print("Goodbye!")
print("PS, From [[[ElectronSz]]] :)")
コード例 #4
0
ファイル: LZ4-example.py プロジェクト: yceugene/_TINY_ACMSIMC
dic3=lz4.frame.get_frame_info(compressed)
bs=dic3['block_size']
ty=nd.dtype.name

dic=[['LZ4 library version',lz4lver],
     ['LZ4 python module version',lz4ver],
     ['LZ4 block size',"{0}kB".format(int(np.round(bs/1024)))],
     ['LZ4 compression level',0],
     ['Zstd library version',zzs],
     ['Zstd Compression level',1],
     ['Zstd Compression Threads',4],
     ['Type of element',ty],
     ['Shape of data',sp],
     ['Original Size',"{0}kB".format(int(np.round(result3/1024)))],
     ['Compressed Size(LZ4)',"{0}kB".format(int(np.round(result2/1024)))],
     ['Compressed Size(Zstd)',"{0}kB".format(int(np.round(result4/1024)))],
     ['Compression Ratio(LZ4)',"{0:.6f}".format(result3/result2)],
     ['Compression Ratio(Zstd)',"{0:.6f}".format(result3/result4)],
     ['Compression Time(LZ4)',"{0:.6f}s".format(time)],
     ['Compression Time(Zstd)',"{0:.6f}s".format(time2)],
     ['Decompression Time(LZ4)',"{0:.6f}s".format(time4)],
     ['Decompression Time(Zstd)',"{0:.6f}s".format(time3)],
     ['Original == Compressed ?',result]]
with open('data.json', 'w') as fp:
    json.dump(dic, fp)

with open('data.json', 'r') as fp:
    dic2 = json.load(fp)
print(tbl(dic2,
          tablefmt="fancy_grid",
          headers=['Name','Value']))
コード例 #5
0
def MoneyTable():
    global all_users, money
    out = tbl(list(zip(all_users, money)), tablefmt = 'psql', headers=('Players', 'Money'))
    print('Current Money Distribution')
    print(out)
コード例 #6
0
    winner = all_users[final_hands_original.index(final_hands[0])]


#Display a table with final hands of all players with winner marked separately
print(tbl
        (list
            (zip
                (
                    [f'Winner >> [{i}]' if i is winner else i for i in all_users],
                    final_hands_original,
                    
                    [_dispCards(*k) for k in \
                        [i.replace('10', 'T').split() for i in final_hands_original]
                    
                    ]
                )
            ),
                    
        headers = (
                    'Player',
                    'Cards',
                    ''
                  ),

        tablefmt='psql'
        
        )
    )

win_msg = f"player [{winner}] won with '{get_best_hand_of_user(winner)[1]}'\nCards are: {'['+', '.join(get_best_hand_of_user(winner)[0])+']'}"
コード例 #7
0
ファイル: magix.py プロジェクト: MightyPhoenix/python-assgn
Created on Tue Nov 19 12:07:06 2019

@author: agnib
"""

# Create an N x N magic square. N must be odd.
from tabulate import tabulate as tbl
import numpy as np

N = 9
magic_square = np.zeros((N, N), dtype=int)

i, j, n = 0, N // 2, 1

while n <= N**2:
    magic_square[i, j] = n
    n += 1
    newi, newj = (i - 1) % N, (j + 1) % N
    if magic_square[newi, newj]:
        i += 1
    else:
        i, j = newi, newj

for i in magic_square:
    for j in i:
        print(j, end="  ")

    print("\n")

print(tbl(magic_square, tablefmt="grid"))
コード例 #8
0
headers += ['covariance']
headers += ['Linear mean [dBm]']
row_0 = [2]
row_1 = [5]
row_2 = [3.4]
for x, y, z in zip(qunatile_2m, qunatile_5m, qunatile_ant):
    row_0.append(x)
    row_1.append(y)
    row_2.append(z)
row_0.append(cov_2m)
row_1.append(cov_5m)
row_0.append(linear_mean(rssi_2m))
row_1.append(linear_mean(rssi_5m))
row_2.append(cov_ant)
tble = [row_0, row_1]
table = tbl(tble, headers=headers, tablefmt='github')
print('*' * 150)
print(table)
print('*' * 150)
fig, ax = plt.subplots()
ax.plot(_2x, z2m, label='RSSI - 2m pdf')
ax.plot(_5x, z5m, label='RSSI - 5m pdf')
ax.set_title('PDF 2m, 5m')
ax.legend()
ax.grid()
plt.xlabel('power [dBm]')
fig.show()
fig, ax = plt.subplots()
ax.plot(_2x, cdf2m, label='RSSI - 2m CDF')
ax.plot(_5x, cdf5m, label='RSSI - 5m CDF')
ax.set_title('CDF 2m, 5m')