Skip to content

Commit d19bc03

Browse files
Merge branch 'master' into Almu
2 parents 2017fe3 + bc42bcc commit d19bc03

27 files changed

+459
-63
lines changed

README.md

+117-42
Original file line numberDiff line numberDiff line change
@@ -57,38 +57,17 @@ Link to commit:(same as for the first one)
5757
Screenshot of branch measurement:
5858
![image](https://github.com/CatalinAnt/algorithms-SEP-95/assets/113595149/94eec9b6-3dd6-46e3-b087-40892eccc10e)
5959

60-
#### Abdullah Abdelkhalik
61-
6260

63-
pythagoras
64-
65-
https://github.com/CatalinAnt/algorithms-SEP-95/commit/5651abafebe8ae3a5ea63e74883bb991acf19303
6661

67-
![pythagoras_hits](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/0df1fa2b-2185-4b9f-ae65-5d969edb009b)
6862

6963

70-
first_unique_char
7164

72-
https://github.com/CatalinAnt/algorithms-SEP-95/commit/c16f26e952322b2c1729778a4141a57103ba7658
7365

74-
![first_unique_char_hits](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/10d7c45c-398e-4408-8f11-6771f51fa95c)
7566

7667

77-
#### Abdullah Abdelkhalik
7868

7969

80-
pythagoras
8170

82-
https://github.com/CatalinAnt/algorithms-SEP-95/commit/5651abafebe8ae3a5ea63e74883bb991acf19303
83-
84-
![pythagoras_hits](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/0df1fa2b-2185-4b9f-ae65-5d969edb009b)
85-
86-
87-
first_unique_char
88-
89-
https://github.com/CatalinAnt/algorithms-SEP-95/commit/c16f26e952322b2c1729778a4141a57103ba7658
90-
91-
![first_unique_char_hits](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/10d7c45c-398e-4408-8f11-6771f51fa95c)
9271

9372

9473
#### Almuthana Almustafa
@@ -110,6 +89,41 @@ result:
11089

11190
![alt text](result_image_2.png)
11291

92+
#### Ayman Errahmouni
93+
94+
##### Function 1: simplify_path_v2
95+
96+
[Link the commit](https://github.com/CatalinAnt/algorithms-SEP-95/pull/2/commits/22ee6fa1df4785596c603af61a725c558973eb0b)
97+
98+
Screenshot of branch measurement:<br>
99+
![alt text](image-7.png)
100+
101+
##### Function 2: insertion_sort
102+
103+
[Link to commit](https://github.com/CatalinAnt/algorithms-SEP-95/pull/2/commits/5dae7f28036f89b7f6ff673639a922dd714aff3e)
104+
105+
Screenshot of branch measurement:<br>
106+
![alt text](image-11.png)
107+
108+
#### Catalin Antonescu
109+
110+
##### Function 1: strong_password
111+
112+
Link to commit:
113+
[https://github.com/CatalinAnt/algorithms-SEP-95/commit/eaad6d32ecd73bb8fde876a4d4852cb522aea6f8](https://github.com/CatalinAnt/algorithms-SEP-95/commit/2b0b9187c1c040e4476b1ca14f2c2249273566b7)
114+
115+
Screenshot of branch measurement:
116+
![image](https://github.com/CatalinAnt/algorithms-SEP-95/assets/113595149/e718a47f-5ea0-412c-b250-25a193412164)
117+
118+
##### Function 2: rotate_image
119+
120+
Link to commit:(same as for the first one)
121+
[https://github.com/CatalinAnt/algorithms-SEP-95/commit/eaad6d32ecd73bb8fde876a4d4852cb522aea6f8](https://github.com/CatalinAnt/algorithms-SEP-95/commit/2b0b9187c1c040e4476b1ca14f2c2249273566b7)
122+
123+
Screenshot of branch measurement:
124+
![image](https://github.com/CatalinAnt/algorithms-SEP-95/assets/113595149/94eec9b6-3dd6-46e3-b087-40892eccc10e)
125+
126+
113127
## Coverage improvement
114128

115129
### Individual tests
@@ -143,6 +157,7 @@ Old coverage:<br>
143157

144158
Diff (LHS = new code, RHS = old code):<br>
145159
![LHS: new code, RHS: old code](image.png)
160+
![alt text](image-9.png)
146161

147162
New coverage:<br>
148163
![new coverage result (100%)](image-1.png)
@@ -161,6 +176,8 @@ Diff (LHS: new code, RHS: old code):<br>
161176
![LHS: new code, RHS: old code](image-5.png)<br>
162177
(Changes in imports)<br>
163178
![LHS: new code, RHS: old code](image-6.png)
179+
(Instrumentation)<br>
180+
![alt text](image-8.png)
164181

165182
Old coverage:<br>
166183
![Old coverage result (4%)](image-3.png)
@@ -192,7 +209,6 @@ New coverage:
192209

193210
For strong_password there was a 26% coverage improvement with the existing tool and 40% with manual measurement tool.
194211

195-
196212
Test 2:
197213

198214
In test_matrix:
@@ -212,27 +228,7 @@ New coverage:
212228
For rotate_image, thre was a 33% coverage improvement with the existing tool and 25% with manual tool.
213229

214230

215-
## Abdullah Abdelkhalik
216-
217-
test_maths
218-
219-
https://github.com/CatalinAnt/algorithms-SEP-95/commit/60832d9c672efd586848077cc41a52630d34371b
220-
221-
![pythagoras_before](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/cf57112b-1aef-4a10-a41f-bd4b797e2012)
222-
223-
![pythagoras_after](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/1aa45c17-46fc-49d3-944a-03c2276d1be6)
224-
225-
the coverage is improved by 28%, the code only hit one of the five branches and cover only one of the three cases of the pythagoras theory. I added the other two cases, i could have a fourth case where none of the cases is present.
226-
227-
test_strings
228-
229-
https://github.com/CatalinAnt/algorithms-SEP-95/commit/5651abafebe8ae3a5ea63e74883bb991acf19303
230231

231-
![first_unique_char_before](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/9910ec69-73b0-4c87-afc8-abc01f65a423)
232-
233-
![first_unique_char_after](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/10859fac-776c-4a48-8a1c-9531afcbfa9b)
234-
235-
The coverage is improved by 13%, the code only hit three out of five branches and only set up two examples. I added a case where there is no unique letter.
236232

237233
## Almuthana Almustafa
238234

@@ -267,6 +263,85 @@ existing tool result after:
267263

268264
The coverage improved by 86% due to the creation of new tests.
269265

266+
267+
268+
269+
270+
271+
272+
273+
274+
275+
276+
277+
278+
279+
280+
281+
282+
283+
284+
285+
286+
287+
288+
289+
#### Abdullah Abdelkhalik
290+
291+
292+
pythagoras
293+
294+
https://github.com/CatalinAnt/algorithms-SEP-95/commit/5651abafebe8ae3a5ea63e74883bb991acf19303
295+
296+
![pythagoras_hits](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/c61bff67-be7e-4bd2-b892-0a0f2dada1f3)
297+
298+
299+
300+
301+
first_unique_char
302+
303+
https://github.com/CatalinAnt/algorithms-SEP-95/commit/c16f26e952322b2c1729778a4141a57103ba7658
304+
305+
![first_unique_char_hits (2)](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/8c1b704e-cadb-4f54-aea7-795005348538)
306+
307+
308+
309+
310+
311+
## Improvements
312+
313+
test_maths
314+
315+
https://github.com/CatalinAnt/algorithms-SEP-95/commit/60832d9c672efd586848077cc41a52630d34371b
316+
317+
![pythagoras_before](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/cf57112b-1aef-4a10-a41f-bd4b797e2012)
318+
319+
![pythagoras_after](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/1aa45c17-46fc-49d3-944a-03c2276d1be6)
320+
321+
the coverage is improved by 28%, the code only hit one of the five branches and cover only one of the three cases of the pythagoras theory. I added the other two cases, i could have a fourth case where none of the cases is present.
322+
323+
test_strings
324+
325+
https://github.com/CatalinAnt/algorithms-SEP-95/commit/5651abafebe8ae3a5ea63e74883bb991acf19303
326+
327+
![first_unique_char_before](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/9910ec69-73b0-4c87-afc8-abc01f65a423)
328+
329+
![first_unique_char_after](https://github.com/CatalinAnt/algorithms-SEP-95/assets/114078193/10859fac-776c-4a48-8a1c-9531afcbfa9b)
330+
331+
The coverage is improved by 13%, the code only hit three out of five branches and only set up two examples. I added a case where there is no unique letter.
332+
333+
334+
335+
336+
337+
338+
339+
340+
341+
342+
343+
344+
270345
### Overall
271346

272347
<Provide a screenshot of the old coverage results by running an existing tool (the same as you already showed above)>

algorithms/maths/find_order_simple.py

+25
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,42 @@
1111

1212
import math
1313

14+
branch_coverage = {
15+
"branch_6": False,
16+
"branch_7": False,
17+
"branch_8": False,
18+
"branch_9": False,
19+
"branch_10": False
20+
}
21+
1422
def find_order(a, n):
1523
"""
1624
Find order for positive integer n and given integer a that satisfies gcd(a, n) = 1.
1725
"""
26+
1827
if (a == 1) & (n == 1):
1928
# Exception Handeling : 1 is the order of of 1
29+
branch_coverage["branch_6"] = True
30+
print("branch_6")
2031
return 1
2132
if math.gcd(a, n) != 1:
33+
branch_coverage["branch_7"] = True
34+
print("branch_7")
2235
print ("a and n should be relative prime!")
2336
return -1
2437
for i in range(1, n):
38+
branch_coverage["branch_8"] = True
39+
print("branch_8")
2540
if pow(a, i) % n == 1:
41+
branch_coverage["branch_9"] = True
42+
print("branch_9")
2643
return i
44+
branch_coverage["branch_10"] = True
45+
print("branch_10")
2746
return -1
47+
48+
def print_coverage():
49+
for branch, hit in branch_coverage.items():
50+
print(f"{branch} was {'hit' if hit else 'not hit'}")
51+
52+
print_coverage()

algorithms/maths/prime_check.py

+25
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
1+
branch_coverage = {
2+
"branch_1": False, # n <= 1
3+
"branch_2": False, # n == 2 or n == 3
4+
"branch_3": False, # n % 2 == 0 or n % 3 == 0
5+
"branch_4": False, # while j * j <= n
6+
"branch_5": False # n % j == 0 or n % (j + 2) == 0
7+
}
18
def prime_check(n):
29
"""Return True if n is a prime number
310
Else return False.
411
"""
12+
print(f"Checking {n}") # Debugging statement
513

614
if n <= 1:
15+
branch_coverage["branch_1"] = True
16+
print("branch_1")
717
return False
18+
819
if n == 2 or n == 3:
20+
branch_coverage["branch_2"] = True
21+
print("branch_2")
922
return True
1023
if n % 2 == 0 or n % 3 == 0:
24+
branch_coverage["branch_3"] = True
25+
print("branch_3")
1126
return False
1227
j = 5
1328
while j * j <= n:
29+
branch_coverage["branch_4"] = True
30+
print("branch_4")
1431
if n % j == 0 or n % (j + 2) == 0:
32+
branch_coverage["branch_5"] = True
33+
print("branch_5")
1534
return False
1635
j += 6
1736
return True
37+
38+
def print_coverage():
39+
for branch, hit in branch_coverage.items():
40+
print(f"{branch} was {'hit' if hit else 'not hit'}")
41+
42+
print_coverage()

algorithms/maths/pythagoras.py

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Given the lengths of two of the three sides of a right angled triangle, this function returns the
33
length of the third side.
44
"""
5+
branch_coverage = {
6+
"branch_31": False,
7+
"branch_32": False,
8+
"branch_33": False,
9+
"branch_34": False,
10+
"branch_35": False
11+
}
512

613
def pythagoras(opposite, adjacent, hypotenuse):
714
"""
@@ -10,11 +17,25 @@ def pythagoras(opposite, adjacent, hypotenuse):
1017
"""
1118
try:
1219
if opposite == str("?"):
20+
branch_coverage["branch_31"] = True
1321
return ("Opposite = " + str(((hypotenuse**2) - (adjacent**2))**0.5))
1422
if adjacent == str("?"):
23+
branch_coverage["branch_32"] = True
1524
return ("Adjacent = " + str(((hypotenuse**2) - (opposite**2))**0.5))
1625
if hypotenuse == str("?"):
26+
branch_coverage["branch_33"] = True
1727
return ("Hypotenuse = " + str(((opposite**2) + (adjacent**2))**0.5))
28+
branch_coverage["branch_34"] = True
1829
return "You already know the answer!"
1930
except:
31+
branch_coverage["branch_35"] = True
2032
raise ValueError("invalid argument(s) were given.")
33+
34+
def print_coverage():
35+
for branch, hit in branch_coverage.items():
36+
print(f"{branch} was {'hit' if hit else 'not hit'}")
37+
38+
pythagoras(3, 2, "?")
39+
40+
print_coverage()
41+

0 commit comments

Comments
 (0)