Test your Code!

Luigi Pizza (6120 points)
11 20 65
asked Dec 4, 2021 in HW6 by Luigi Pizza (6,120 points)

Hi Guys,

I've noticed a question about changing the value of 'spacing', so I got to work. If you want to test your code against other values This is the code for you!

k = 0

print(ex(r'matrices\example.txt', r'results\result_example.png', 42 + 2*k)==( 288+8*k, 348+8*k))
print(ex(r'matrices\minimal.txt', r'results\result_minimal.png', 30 + k)==(  82+2*k, 140+2*k))
print(ex(r'matrices\mat-3-1.txt', r'results\result_mat-3-1.png', 1 + 48*k)==( 466+864*k, 120+192*k))
print(ex(r'matrices\mat-4-5.txt', r'results\result_mat-4-5.png', 5 + 24*k)==( 120+240*k,  61+120*k))
print(ex(r'matrices\mat-5-5.txt', r'results\result_mat-5-5.png', 5 + 60*k)==( 150+720*k,  78+360*k))
print(ex(r'matrices\mat-2-97.txt', r'results\result_mat-2-97.png', 97 + 4*k)== (690+24*k, 341+12*k))

This works for every value of k, as far as k is a natural number.

Let me know if this has been useful! (You might need to change the path where your files are going to be saved. I've created a folder named results)

271 views

5 Answers

gabrimat (5630 points)
2 2 25
answered Dec 4, 2021 by gabrimat (5,630 points)
Used them right now, thank you for the extra testing!
Luigi Pizza (6120 points)
11 20 65
commented Dec 4, 2021 by Luigi Pizza (6,120 points)
You're welcome! I could do the same also for hw8 next time
rokshana03 (7140 points)
1 2 26
answered Dec 4, 2021 by rokshana03 (7,140 points)
Thanks!!! This is gonna be very useful to further test the code I wrote!
Luigi Pizza (6120 points)
11 20 65
commented Dec 4, 2021 by Luigi Pizza (6,120 points)
You're welcome!
Quellocinese (2700 points)
2 4 22
answered Dec 4, 2021 by Quellocinese (2,700 points)
Thank you so much, let's make no one fail this hw!
Luigi Pizza (6120 points)
11 20 65
commented Dec 4, 2021 by Luigi Pizza (6,120 points)
You're welcome! Let's hope everybody passes it
James_F (4580 points)
7 14 36
answered Dec 4, 2021 by James_F (4,580 points)
in unix-like system you may need to change the backslash with a regular one '/' to let bash understand what path you are referring to; that said, they seem to work, but i dunno if it may be any useful to test the behavior of our programs.
Noneteless, thank you for sharing!
:D
Simone Russolillo (5790 points)
5 10 22
answered Dec 5, 2021 by Simone Russolillo (5,790 points)
Sorry Luigi should we add the above code under the command if __name__==__main__?

Thanks in advance.
gabrimat (5630 points)
2 2 25
commented Dec 5, 2021 by gabrimat (5,630 points)
Yes thore are tests you should run under that condition
Simone Russolillo (5790 points)
5 10 22
commented Dec 6, 2021 by Simone Russolillo (5,790 points)
thanks Gabriele!
Luigi Pizza (6120 points)
11 20 65
commented Dec 6, 2021 by Luigi Pizza (6,120 points)
Yes, otherwise they would be executed when imported, slowing the testing (in test_01.py) by a lot.