Skip to content

Commit 7aca2d7

Browse files
committed
made some changes
1 parent ae525dc commit 7aca2d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+277
-230
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#vs code settings
2+
.vscode/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

AVX2_and_FMA_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
def avx2_and_fma():
6-
76
for j in range(3):
87
i = j * 64
98
dest = i + 63 * i + 63 * i + 63 - i + 63 + 2
@@ -25,4 +24,3 @@ def avx2_and_fma():
2524

2625

2726
avx2_and_fma()
28-

Class.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Klass:
2-
other = ''
2+
other = ""
33

44
def a_method(self, thing):
55
print(thing)
@@ -12,9 +12,9 @@ def last_thing(self):
1212
k = Klass()
1313
k2 = Klass()
1414

15-
Klass.other = 'a class variable.'
15+
Klass.other = "a class variable."
1616

17-
k.a_method('an instance variable')
17+
k.a_method("an instance variable")
1818
k2.a_method(34)
1919

2020
k.last_thing()

DMA_cell.exe

-556 KB
Binary file not shown.

DMA_cell.pdb

240 KB
Binary file not shown.

DMA_cell.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
from typing import Union, Tuple, List
1+
from typing import List, Tuple, Union
22

33

4-
def dma_list(dst: int, ea_low: int, nbytes: int) -> Union[Tuple[None], Tuple[int, List[Tuple[int, int, int, int, int, int]]]]:
4+
def dma_list(
5+
dst: int, ea_low: int, nbytes: int
6+
) -> Union[Tuple[None], Tuple[int, List[Tuple[int, int, int, int, int, int]]]]:
57
result: List[Tuple[int, int, int, int, int, int]] = []
68
tag_id: int = 0
79
dma_list_elem: List[int] = [0, 31, 1, ea_low]
810
size: int = dma_list_elem.__sizeof__()
911
all_32: int = dma_list_elem[0]
1012
stall: int = dma_list_elem[2]
11-
12-
dma_list_elem[0] = size + all_32
13+
list_size: int = nbytes * size
14+
aligned_ea_low = (ea_low >> 2) * 4
1315

1416
if nbytes == 0:
1517
return None
1618

1719
i: int = 0
18-
list_size: int = nbytes * size
19-
2020
while nbytes > 0:
2121
sz: int = min(nbytes, 16384)
2222
nbytes -= sz
2323
ea_low += sz
2424
all_32 = 32
25-
dma_list_elem[3] = ea_low
2625
dma_list_elem[0] = size + all_32
26+
dma_list_elem[3] = aligned_ea_low
2727
sz += size
28-
bits: int = sz // 8
28+
bits: int = sz >> 3
2929

3030
result.append((dma_list_elem[0], tag_id, dst, bits, all_32, stall))
3131
i += 1

DiscordBot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@client.event
77
async def on_ready():
8-
print('We have logged in as {0.user}'.format(client))
8+
print(f"We have logged in as {client.user}")
99

1010

1111
@client.event

HelloWorld.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Prints a bunch of stuff
22
print("Hello World")
3-
a = 'what'
3+
a = "what"
44
print(a)
55

66

77
def plus(x, y):
88
# This function adds numbers together
9-
print('plus')
9+
print("plus")
1010
return x + y
1111

1212

13-
print('begin')
13+
print("begin")
1414
b = plus(54, 46)
1515

1616
print(b)

IfStatement.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,49 @@
44

55
b = 4
66

7+
78
def compare_numbers():
8-
99
done = True
1010

1111
while done:
12+
print("true")
1213

13-
print('true')
14-
15-
print('false')
14+
print("false")
1615

17-
done = False
16+
done = False
1817

1918
if not done:
19+
done = True
2020

21-
done = True
22-
23-
if a < b or done:
24-
25-
print('lesser then')
21+
if a < b or done:
22+
print("lesser then")
2623

2724
elif a == b:
28-
29-
print('equal')
25+
print("equal")
3026

3127
else:
32-
33-
print('bigger then')
28+
print("bigger then")
29+
3430

3531
done = False
3632

3733
i = 0
3834

3935
while not done and i != 10:
40-
41-
i+=1
42-
43-
print(i)
44-
45-
if i == 10:
46-
47-
print('end')
48-
49-
done = True
50-
51-
done = None
52-
53-
done = True
54-
55-
break
56-
57-
36+
i += 1
37+
38+
print(i)
39+
40+
if i == 10:
41+
print("end")
42+
43+
done = True
44+
45+
done = None
46+
47+
done = True
48+
49+
break
50+
51+
5852
compare_numbers()

LinearSearch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
21
lst: tuple[int, ...] = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
32

43

54
def sequential_search(lst_: tuple[int, ...], num: int) -> bool:
65
for i in lst_:
7-
86
if i == num:
97
print()
108

MachineLearning.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1+
import matplotlib.pyplot as plt
12
import numpy as np
2-
33
import torch
4-
5-
from math import *
6-
74
from scipy import stats
85

9-
import matplotlib.pyplot as plt
10-
116
speed = [100, 80, 130, 111, 96, 110, 90, 94, 86, 150, 120, 144, 146]
127

138
rotation = [180, 90, 260, 360, 720, 144, 146, 80, 94, 86, 120, 1080, 333]

MultTable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
def mult_table():
2-
for lst in [[a * b for a in range(1, 11)] for b in range(1, 11)]: print(lst)
2+
for lst in [[a * b for a in range(1, 11)] for b in range(1, 11)]:
3+
print(lst)
34
return lst
45

56

bubblesort.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
2-
31
def bubble_sort(speed):
42
n = len(speed)
53

64
for i in range(n):
7-
85
for j in range(n - i - 1):
9-
106
if speed[j] > speed[j + 1]:
11-
127
speed[j], speed[j + 1] = speed[j + 1], speed[j]
138

149

@@ -17,5 +12,4 @@ def bubble_sort(speed):
1712
bubble_sort(speed)
1813

1914
for item in speed:
20-
2115
print(item)

cell_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from operator import mul
2-
from typing import Tuple
32

43

5-
def vmult(arr: Tuple[float, float, float, float, float, float, float, float],
6-
arr2: Tuple[float, float, float, float, float, float, float, float],
7-
size: int) -> Tuple[float, float, float, float, float, float,
8-
float, float]:
9-
4+
def vmult(
5+
arr: tuple[float, float, float, float, float, float, float, float],
6+
arr2: tuple[float, float, float, float, float, float, float, float],
7+
size: int,
8+
) -> tuple[float, float, float, float, float, float, float, float]:
109
array_size_by_four = size >> 2
1110
varr = arr[:7] * array_size_by_four
1211
varr2 = arr2[:8] * array_size_by_four
@@ -15,5 +14,8 @@ def vmult(arr: Tuple[float, float, float, float, float, float, float, float],
1514
return vout
1615

1716

18-
vmult((2.2, 4.2, 8.2, 16.2, 32.2, 64.2, 128.2, 256.2),
19-
(2.4, 4.4, 8.4, 16.4, 32.4, 64.4, 128.4, 256.4), 8)
17+
vmult(
18+
(2.2, 4.2, 8.2, 16.2, 32.8, 64.2, 128.2, 256.2),
19+
(2.8, 4.8, 8.8, 16.8, 32.8, 64.8, 128.8, 256.8),
20+
8,
21+
)

custom_square_root.exe

19.5 MB
Binary file not shown.

custom_square_root.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ def custom_square_root(x: float) -> float:
22
xhalf = 0.5 * x
33
xhalf = int(xhalf)
44
i = x = xhalf & int(x)
5-
i = 0x5f3759df - (i >> 1)
5+
i = 0x5F3759DF - (i >> 1)
66
x = float(i)
77
x = x * (1.5 - xhalf * x * x)
88
print(x)

debt.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,41 @@
22

33

44
def debt():
5-
6-
names_of_data = ("Date ", "total", "treasury", "bonds", "swaps", "green lottery", "national", "savings", "bills", "other", "foreign", "debt", " debt in swaps")
7-
8-
numbers_of_data = ["2020M11", 1136528, 678311, 176738, 31250, 20000, 2889, 5, 0, 145241, 18773, 271309, 31250]
5+
names_of_data = (
6+
"Date ",
7+
"total",
8+
"treasury",
9+
"bonds",
10+
"swaps",
11+
"green lottery",
12+
"national",
13+
"savings",
14+
"bills",
15+
"other",
16+
"foreign",
17+
"debt",
18+
" debt in swaps",
19+
)
20+
21+
numbers_of_data = [
22+
"2020M11",
23+
1136528,
24+
678311,
25+
176738,
26+
31250,
27+
20000,
28+
2889,
29+
5,
30+
0,
31+
145241,
32+
18773,
33+
271309,
34+
31250,
35+
]
936

1037
title = "Central government debt, balance, SEK million by item and month. "
1138

12-
plt.figure(figsize=(13,13))
39+
plt.figure(figsize=(13, 13))
1340

1441
plt.bar(names_of_data[1:13], numbers_of_data[1:13])
1542

dis_module_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dis
22
from time import sleep
3+
34
done = False
45

56

@@ -19,4 +20,3 @@ def if_statement():
1920

2021
if_statement()
2122
dis.dis(if_statement)
22-

email_slicer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
email = input("What is your email address:").strip()
33

44
# Slice username
5-
username = email[:email.index("@")]
5+
username = email[: email.index("@")]
66

77
# Slice domain name
8-
domain = email[email.index("@") + 1:]
8+
domain = email[email.index("@") + 1 :]
99

1010
# Format message
11-
message = "Your username is '{}' and your domain name is '{}'".format(username, domain)
11+
message = f"Your username is '{username}' and your domain name is '{domain}'"
1212

1313
# Print message
1414
print(message)

fib.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
def fib(n):
7-
print('Fibonacci series')
7+
print("Fibonacci series")
88
phi = (1 + sqrt(5)) / 2
9-
Fn = round((phi ** n) / sqrt(5))
9+
Fn = round((phi**n) / sqrt(5))
1010
print(Fn)
1111

1212

@@ -15,11 +15,11 @@ def fib(n):
1515

1616
# O(n)
1717
def fib(n):
18-
print('Fibonacci series')
18+
print("Fibonacci series")
1919
phi = (1 + sqrt(5)) / 2
2020
for i in range(n):
21-
Fn = round((phi ** i) / sqrt(5))
22-
print(Fn, end=' ')
21+
Fn = round((phi**i) / sqrt(5))
22+
print(Fn, end=" ")
2323
print()
2424

2525

fstrings.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
def fstring_test():
12

3+
name = "John"
4+
surname = "Doe"
25

3-
name = "Adam"
4-
surname = "Segerlund"
6+
print(f"Hi {name} {surname}")
57

6-
print(f"Hi {name} {surname}")
8+
9+
fstring_test()

0 commit comments

Comments
 (0)