Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b538221
Merge pull request #2 from GradHackersGuild/varun
V4run14 Sep 12, 2024
923c470
added autopep8 workflow
MakarandPundlik Sep 13, 2024
50bf492
added autopep8
MakarandPundlik Sep 13, 2024
19e7fba
Merge branch 'master' of https://github.com/GradHackersGuild/se-homew…
MakarandPundlik Sep 13, 2024
86c7de2
added autopep 8 badge
MakarandPundlik Sep 13, 2024
4366693
changed workflows
MakarandPundlik Sep 13, 2024
df46883
added pytest installtion
MakarandPundlik Sep 13, 2024
455756e
fixed test case
MakarandPundlik Sep 13, 2024
abd237a
Merge pull request #3 from GradHackersGuild/makarand
MakarandPundlik Sep 13, 2024
93a8157
splitted single workflow file into 3
MakarandPundlik Sep 13, 2024
d6e6525
resolved autopep error
MakarandPundlik Sep 13, 2024
cfb2c19
fixed workflow
MakarandPundlik Sep 13, 2024
a7811d9
deleted old workflow
MakarandPundlik Sep 13, 2024
f5cda64
fixed workflow
MakarandPundlik Sep 13, 2024
6d93b08
fixed autopep
MakarandPundlik Sep 13, 2024
69564af
fixed UT autopep
MakarandPundlik Sep 13, 2024
b094acd
Merge pull request #5 from GradHackersGuild/makarand
MakarandPundlik Sep 13, 2024
36af8cc
Made changes suggested by static analysis tool pylint and pyflakes
michellevarghese Sep 13, 2024
68bc2bf
Made changes suggested by static analysis tool pylint and pyflakes
michellevarghese Sep 13, 2024
5809c6e
Updated rand.py error
michellevarghese Sep 13, 2024
f8bf789
Updated test_mergesort.py after static tool analysis
michellevarghese Sep 13, 2024
8aa7945
Update hw2_debugging.py after static tool analysis
michellevarghese Sep 13, 2024
e67277b
Update README.md
MakarandPundlik Sep 13, 2024
ea641ce
Add files via upload
MakarandPundlik Sep 13, 2024
41e0fb5
Delete .github/workflows/static-analysis.yml
MakarandPundlik Sep 13, 2024
7e2a3fd
added post traces
MakarandPundlik Sep 13, 2024
e632155
d
MakarandPundlik Sep 13, 2024
bff8cbc
resolved pylint errors
MakarandPundlik Sep 13, 2024
ed17e55
Merge pull request #8 from GradHackersGuild/workflows-mak
MakarandPundlik Sep 13, 2024
fe32bc2
Add files via upload
michellevarghese Sep 13, 2024
4e4557b
Create pylint_output_test_mergesort.txt
michellevarghese Sep 13, 2024
93f8f28
Update pylint_output_test_mergesort.txt after static tool analysis
michellevarghese Sep 13, 2024
380185a
Update pyflakes_output_rand.txt
V4run14 Sep 13, 2024
1c9fe4a
Delete post_traces/pylint_output_test_mergesort.txt
michellevarghese Sep 13, 2024
de9422a
Updated pyflakes_output_rand.txt after static tool changes
michellevarghese Sep 13, 2024
290f52a
Update pylint_output_hw2_debugging.txt
michellevarghese Sep 13, 2024
c374099
Updated pylint_output_hw2_debugging.txt after static tool changes
michellevarghese Sep 13, 2024
9b6592c
Update pylint_output_rand.txt
michellevarghese Sep 13, 2024
e433b0d
Updated pylint_output_rand.txt after static tool changes
michellevarghese Sep 13, 2024
1a81bc6
Delete post_traces/dummy.txt
michellevarghese Sep 13, 2024
a13059c
Update pyflakes_output_hw2_debugging.txt
michellevarghese Sep 13, 2024
c395571
Updated pyflakes_output_hw2_debugging.txt after static tool changes
michellevarghese Sep 13, 2024
1f9072b
Updated test_merge_sort traces after static tool changes
michellevarghese Sep 13, 2024
c4c710a
Updated badges
michellevarghese Sep 19, 2024
53df01f
Updated unit test badge
michellevarghese Sep 19, 2024
2657dd9
Update autopep.yml
michellevarghese Sep 19, 2024
ad3deaa
Updated unit-test-cases.yml name
michellevarghese Sep 19, 2024
8641303
Updated Static Analysis tools badges
michellevarghese Sep 19, 2024
af90fbb
Update README.md
MakarandPundlik Oct 3, 2024
2cc8796
Update README.md
MakarandPundlik Oct 3, 2024
df79da2
updated readme file
MakarandPundlik Oct 3, 2024
1e6e026
updated readme
MakarandPundlik Oct 3, 2024
361dca6
Merge branch 'master' of https://github.com/GradHackersGuild/se-homew…
MakarandPundlik Oct 3, 2024
6cda0e5
Merge pull request #9 from GradHackersGuild/unit-tests
MakarandPundlik Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/autopep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Autopep 8

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install autopep8
run: |
pip install autopep8
- name: Run autopep8
run: |
autopep8 --diff --exit-code --recursive .
32 changes: 0 additions & 32 deletions .github/workflows/hw-2-workflow.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/pyflake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Python PyFlakes

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip install pyflakes
- name: Run linters
run: |
pyflakes $(find . -name "*.py") > post_traces/pyflakes_report.txt
19 changes: 19 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Python PyLint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip install pylint
- name: Run linters
run: |
pylint $(find . -name "*.py")
26 changes: 26 additions & 0 deletions .github/workflows/unit-test-cases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit Test Cases

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Dependencies and pytest
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pytest coverage
- name: Run Unit Tests
run: |
coverage run -m pytest
- name: Generate Coverage Report
run: |
coverage report -m
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Group 38 - SE Homwork 2

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![Language](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)
![Platform](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)
![Unit tests](https://github.com/GradHackersGuild/se-homework/actions/workflows/git-commit-workflow.yml/badge.svg)
[![Language](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)](https://www.python.org/)
[![Platform](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)](https://www.linux.org/)
[![Unit tests](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/unit-test-cases.yml/badge.svg)](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/unit-test-cases.yml)
[![PEP8 Check](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/autopep.yml/badge.svg)](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/autopep.yml)
[![PyLint Check](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/pylint.yml/badge.svg)](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/pylint.yml)
[![PyFlake Check](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/pyflake.yml/badge.svg)](https://github.com/GradHackersGuild/se-homework-2/actions/workflows/pyflake.yml)
Binary file modified __pycache__/rand.cpython-312.pyc
Binary file not shown.
Binary file removed __pycache__/rand.cpython-39.pyc
Binary file not shown.
67 changes: 42 additions & 25 deletions hw2_debugging.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
"""
Module implementing the Merge Sort algorithm.

This script contains functions to perform merge sort on a given list and merge two sorted arrays.
"""
import rand

def mergeSort(arr):
if (len(arr) == 1):

def merge_sort(arr):
"""
Recursively divides and sorts an array using the merge sort algorithm.

:param array: List of integers to be sorted.
:return: Sorted list of integers.
"""
if len(arr) == 1:
return arr
half = len(arr)//2
return recombine(mergeSort(arr[:half]), mergeSort(arr[half:]))

def recombine(leftArr, rightArr):
leftIndex = 0
rightIndex = 0
mergeArr = [None] * (len(leftArr) + len(rightArr))
while leftIndex < len(leftArr) and rightIndex < len(rightArr):
if leftArr[leftIndex] < rightArr[rightIndex]:
mergeArr[leftIndex + rightIndex] = leftArr[leftIndex]
leftIndex += 1
half = len(arr) // 2
return recombine(merge_sort(arr[:half]), merge_sort(arr[half:]))


def recombine(left_arr, right_arr):
"""
Merges two sorted arrays into a single sorted array.

:param left_arr: Left half sorted array.
:param right_arr: Right half sorted array.
:return: Merged sorted array.
"""
left_index = 0
right_index = 0
merge_arr = [None] * (len(left_arr) + len(right_arr))
while left_index < len(left_arr) and right_index < len(right_arr):
if left_arr[left_index] < right_arr[right_index]:
merge_arr[left_index + right_index] = left_arr[left_index]
left_index += 1
else:
mergeArr[leftIndex + rightIndex] = rightArr[rightIndex]
rightIndex += 1
merge_arr[left_index + right_index] = right_arr[right_index]
right_index += 1

for i in range(rightIndex, len(rightArr)):
mergeArr[leftIndex + i] = rightArr[i]

for i in range(leftIndex, len(leftArr)):
mergeArr[i + rightIndex] = leftArr[i]
for i in range(right_index, len(right_arr)):
merge_arr[left_index + i] = right_arr[i]
for i in range(left_index, len(left_arr)):
merge_arr[i + right_index] = left_arr[i]
return merge_arr

return mergeArr

arr = rand.random_array([int] * 20)
arr_out = mergeSort(arr)
array = rand.random_array([int] * 20)
arr_out = merge_sort(array)

print(arr_out)


Empty file.
1 change: 1 addition & 0 deletions post_traces/pyflakes_output_hw2_debugging.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions post_traces/pyflakes_output_rand.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
4 changes: 4 additions & 0 deletions post_traces/pylint_output_hw2_debugging.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

4 changes: 4 additions & 0 deletions post_traces/pylint_output_rand.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

4 changes: 4 additions & 0 deletions post_traces/pylint_output_test_merge_sort.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 8.18/10, +1.82)

20 changes: 16 additions & 4 deletions rand.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
"""
Module for generating random arrays.

This module contains a function to create a list of random integers.
"""

import random

def random_array(arr)-> list[int]:
shuffled_num = None
for i in range(len(arr)):
arr[i] = random.randint(1,20)

def random_array(arr) -> list[int]:
"""
Fill the provided list with random integers between 1 and 20.

:param arr: List of integers to be filled with random values.
:return: The list filled with random integers.
"""
for i, _ in enumerate(arr):
arr[i] = random.randint(1, 20)
return arr
23 changes: 19 additions & 4 deletions test_mergesort.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
"""
Module implementing the unit test cases for Merge Sort algorithm.
"""
import hw2_debugging as OP


def test_mergesort1():
"""
Takes array of random integers and checks whether it is sorted or not
"""
arr = [10, 12, 2, 4, 1, 14, 10, 15, 16, 7, 9, 10]
assert OP.mergeSort(arr) == [1, 2, 4, 7, 9, 10, 10, 10, 12, 14, 15, 16]
assert OP.merge_sort(arr) == [1, 2, 4, 7, 9, 10, 10, 10, 12, 14, 15, 16]


def test_mergesort2():
"""
Takes array of random integers and checks whether it is sorted or not
"""
arr = [8, 12, 2, 1, 4, 10, 14, 15, 20, 7, 9, 4]
assert OP.mergeSort(arr) == [1, 2, 4, 4, 7, 8, 9, 10, 12, 14, 15, 20]
assert OP.merge_sort(arr) == [1, 2, 4, 4, 7, 8, 9, 10, 12, 14, 15, 20]


def test_mergesort3():
arr = [8, 12, 2, 4, 1, 14, 10, 15, 16, 7, 9, 10]
assert OP.mergeSort(arr) == [1, 2, 4, 7, 9, 8, 10, 10, 12, 14, 15, 16, 17]
"""
Takes array of random integers and checks whether it is sorted or not
"""
arr = [-10, -17, -5, -5, -3, 1, -1000, 10]
assert OP.merge_sort(arr) == [-1000, -17, -10, -5, -5, -3, 1, 10]