Skip to content

DavidGilson24/TheAlgorithms-Python-SEP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,005 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Report for Assignment 1

Project chosen

Name: TheAlgorithms Python

Programming language: Python

Number of lines + Tool

11810 python lines counted using lizard

How to:

    > pip install lizard

    > lizard -l python # -l chooses the lines of the language lizard should count
Screenshot_2 Screenshot_1

Coverage measurement with existing tool

Tool Used: coverage

How to:

    > pip install coverage


    > coverage run -m pytest # in tests folder


    > coverage report  # or "coverage html" for a nice representation

Results:

Screenshot_3 Screenshot_4

For 'coverage html'

Screenshot_5

Coverage measurement with our own "tool"

David Gilson

depth_of_tree:

Link to commit for coverage instrumentation Screenshot 2024-06-12 161958

is_full_binary_tree:

Link to commit for coverage instrumentation Screenshot 2024-06-12 161958)

Melisa Damian

binary_search.py

Link to the commit with coverage measurement Edited the print_coverage later on [Screenshot of the coverage measurement]Screenshot 2024-06-12 211542

bucket_sort.py

Link to the commit with coverage measurement [Screenshot of the coverage measurement]Screenshot 2024-06-12 212839

For bucket sort, the coverage should be the same for all lists except for the empty one, because all the possible inputs trigger all the branches except for the one checking for an empty list. Due to an error whenever I am attempting to input an empty list which could be fixed only by editing the code of the authors of this repo, I am unable to present that one in the screenshot.

Ashwin Iyer

gnome_sort.py

[Link to the commit for gnome_sort.py] [Added more coverage]

Screenshot 2024-06-13 at 10 46 54 AM

jump_search.py

[Link to the commit for jump_search.py]

Screenshot 2024-06-13 at 10 50 32 AM

Patrick Darie

bubble_sort.py

Link to the commit with coverage measurement SCR-20240613-pkhb

merge_sort.py

Link to the commit with coverage measurement SCR-20240613-ppho

Coverage improvement

David Gilson

test_tree_depth.py:

Link to a commit the new test tree depth tests

Before adding new tests

Screenshot 2024-06-12 163654

After adding new tests

Screenshot 2024-06-12 16384

The coverage goes straight to 96% as it had no previous tests covering it. So by creating tests covering each branch of the depth_of_tree function, we could already cover 96% of it without needing to enchance anything, just making new tests.

test_full_binary:

Link to a commit the new test tree depth tests

Before adding new tests

Screenshot 2024-06-12 16384

After adding new tests

Screenshot 2024-06-12 165137

The coverage goes straight to 97% as it had no previous tests covering it. So by creating tests covering each branch of the is_full_binary function, we could already cover 97% of it without needing to enchance anything, just making new tests.

Melisa Damian

test_binary_search.py

Link to the commit

Before adding new tests

image

After adding new tests

image

The overall coverage for the project went lower because there are functions inside of the binary_search.py file which are not being covered by any other tests than mine. The coverage for the whole binary_search.py file is 41% due to the fact that there are multiple functions within it, and I have improved the coverage only for one of them. Furthermore, the code doesn't have any tests to cover for those missing it. Below I will provide a screenshot of the coverage html with my binary_search function.

image

test_bucket_sort.py

Link to the commit

Before adding new tests

image

After adding new tests

Screenshot 2024-06-12 222703

image

Here, the overall coverage for the project increases due to the fact that within bucket_sort.py, the only function in it is bucket_sort, which is 95% covered by the tests I've added. It's 95% because it lacks the case for an empty list, which doesn't work (mentioned above why).

Ashwin Iyer

jump_search.py

Link to the commit

Before adding new tests

Screenshot 2024-06-13 at 1 19 04 PM

After adding new tests

Screenshot 2024-06-13 at 1 19 23 PM

There were no previous tests for jump_search, and therefore the coverage is at 94% for test_jump_search.py. As we can see, the overall coverage has increased from 92% to 93%. This has been achieved by creating tests for each branch of the jump_sort function.

gnome_sort.py

Link to the commit

Before adding new tests

Screenshot 2024-06-13 at 1 19 23 PM

After adding new tests

Screenshot 2024-06-13 at 3 02 20 PM

There were no previous tests for gnome_sort and hence, the coverage for test_gnome_sort.py is 97%. As we can observe, the overall coverage has jumped from 93% to 94%. This has been achieved by creating tests for each branch of the gnome_sort function.

Patrick Darie

bubble_sort.py

Link to the commit

Before adding new tests

before adding bubble

After adding new tests

after adding bubble

The overall coverage goes down a bit from 92% to 86% because bubble_sort is also included in the report and it's percentage is 56% because not all the functions are tested in the file bubble_sort.py, just the main function bubble_sort(), as we can see in the html report down below the coverage for the function bubble_sort is at 100%. But we can see the coverage of the function with the test file test_bubble_sort() being at 95% this contributing to the higher overall coverage.

merge_sort.py

Link to the commit

Before adding new tests

after adding bubble

After adding new tests

after adding merge

We can see here the same things happening as with bubble_sort. The overall coverage goes down from 86% to 84% because the coverage report is also considering the merge_sort.py file and all of it's functions, but from the html report we can see that the coverage for merge_sort is at 100%. Adding the test to the coverage improves it, but becuase it considers also the merge_sort.py file the overall coverage is reduced

coverage html

Overall

Old Results

Screenshot_4

New results

Screenshot_1

Statement of individual contributions

David Gilson:

  • Made README until coverage html + individual parts + overall
  • Own 2 function coverage instrumentation
  • Test files for chosen functions

Patrick Darie:

  • Wrote my individual part on the README
  • Own 2 function coverage instrumentation
  • Test files for chosen functions

Melisa Damian

  • Wrote my own part of the README
  • Do 2 function coverage instrumentations
  • Test files for the two functions mentioned above

Ashwin Iyer

  • Wrote my own part of the README
  • Chose 2 functions and instrumented them
  • Made test files for the two functions

About

TheAlgorithms/Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 65.1%
  • Jupyter Notebook 34.9%