Пример #1
0
def mime(path: PathIsh) -> Optional[str]:
    ps = str(path)
    mimetypes = _mimetypes()
    # first try mimetypes, it's only using the filename without opening the file
    pm, _ = mimetypes.guess_type(ps)
    if pm is not None:
        return pm
    # next, libmagic, it might access the file, so a bit slower
    magic = _magic()
    return magic(ps)
Пример #2
0
from magic import *

ob = magic()
ob1 = magic()

ob.input()
ob1.input()

while True:
        print("1- add \n ")
        print("2- sub \n ")
        print("3- mul \n ")
        print("4- truediv \n ")
        print("0- exit \n ")

        ch = int(input('Enter your choice : '))
        if ch == 1:
            ob+ob1
        elif ch==2:
            ob-ob1
        elif ch==3:
            ob*ob1
        elif ch==4:
            ob/ob1
        else:
            break
def test_complex2_magic(a):
    assert a == magic(a, 1)
    assert a == magic(1, a)
def test_complex1_magic(a, b):
    assert magic(b, a) == magic(a, b)
def test_comple3_magic(a, b, c):
    assert magic(a, magic(b, c)) == magic(magic(a, b), c)
Пример #6
0
from magic import *

if __name__ == "__main__":
    t = magic()
    print("... at step {0} you have {1} triangles".format(1, next(t)))
    next(t)
    print("... at step {0} you have {1} triangles".format(3, next(t)))
    next(t)
    next(t)
    next(t)
    print("... at step {0} you have {1} triangles".format(7, next(t)))
    next(t)
    next(t)
    next(t)
    next(t)
    next(t)
    next(t)
    print("... at step {0} (the whole picture) you have {1} triangles".
    format(14, next(t)))
Пример #7
0
# Copyright © 2020 Julian Bustamante <*****@*****.**>
#
# Distributed under terms of the MIT license.

"""
Use my Pcajb class
"""
from magic import *
from Pcajb import Pcajb
import matplotlib.pyplot as plt

N   = 99
nx  = 3
#sel = [0,2,4]
sel = np.arange(0,N)
X   = np.array(magic(N))
Z   = np.append(X, X[0,:]).reshape(N+1, N)
px  = Pcajb(Z,nx)

x   = px.Data
#m,u = px.meanSubtract()
#c   = px.covarMatrix()
#e,v = px.eigens()
#s   = px.PCAScores(sel)
#V,T = px.VarExplained(0.8)
xx  = px.SimData()

#print(np.shape(xx))
#print(xx)
#print(np.shape(x))
#print(x)