From 175716b96e95af57b1baa1c77bf41b7def6a1887 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sun, 27 Dec 2020 21:33:29 +0530 Subject: [PATCH 1/4] Fix mypy errors for scheduling/first_come_first_served --- scheduling/first_come_first_served.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scheduling/first_come_first_served.py b/scheduling/first_come_first_served.py index c5f61720f97e..b51fc9fe0c04 100644 --- a/scheduling/first_come_first_served.py +++ b/scheduling/first_come_first_served.py @@ -2,10 +2,10 @@ # In this Algorithm we just care about the order that the processes arrived # without carring about their duration time # https://en.wikipedia.org/wiki/Scheduling_(computing)#First_come,_first_served -from __future__ import annotations +from typing import List -def calculate_waiting_times(duration_times: list[int]) -> list[int]: +def calculate_waiting_times(duration_times: List[int]) -> List[int]: """ This function calculates the waiting time of some processes that have a specified duration time. @@ -24,8 +24,8 @@ def calculate_waiting_times(duration_times: list[int]) -> list[int]: def calculate_turnaround_times( - duration_times: list[int], waiting_times: list[int] -) -> list[int]: + duration_times: List[int], waiting_times: List[int] +) -> List[int]: """ This function calculates the turnaround time of some processes. Return: The time difference between the completion time and the @@ -44,7 +44,7 @@ def calculate_turnaround_times( ] -def calculate_average_turnaround_time(turnaround_times: list[int]) -> float: +def calculate_average_turnaround_time(turnaround_times: List[int]) -> float: """ This function calculates the average of the turnaround times Return: The average of the turnaround times. @@ -58,7 +58,7 @@ def calculate_average_turnaround_time(turnaround_times: list[int]) -> float: return sum(turnaround_times) / len(turnaround_times) -def calculate_average_waiting_time(waiting_times: list[int]) -> float: +def calculate_average_waiting_time(waiting_times: List[int]) -> float: """ This function calculates the average of the waiting times Return: The average of the waiting times. From dd2ac7ce25fd16c0095ce0dc9e9ed5950a92ec17 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sun, 27 Dec 2020 21:33:50 +0530 Subject: [PATCH 2/4] Fix mypy errors for scheduling/round_robin.py --- scheduling/round_robin.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scheduling/round_robin.py b/scheduling/round_robin.py index e8d54dd9a553..72a750839d10 100644 --- a/scheduling/round_robin.py +++ b/scheduling/round_robin.py @@ -3,12 +3,11 @@ In Round Robin each process is assigned a fixed time slot in a cyclic way. https://en.wikipedia.org/wiki/Round-robin_scheduling """ -from __future__ import annotations - +from typing import List from statistics import mean -def calculate_waiting_times(burst_times: list[int]) -> list[int]: +def calculate_waiting_times(burst_times: List[int]) -> List[int]: """ Calculate the waiting times of a list of processes that have a specified duration. @@ -41,8 +40,8 @@ def calculate_waiting_times(burst_times: list[int]) -> list[int]: def calculate_turn_around_times( - burst_times: list[int], waiting_times: list[int] -) -> list[int]: + burst_times: List[int], waiting_times: List[int] +) -> List[int]: """ >>> calculate_turn_around_times([1, 2, 3, 4], [0, 1, 3]) [1, 3, 6] From 42866c5f6704c28186706041c35c2f4e1921eaea Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sun, 27 Dec 2020 21:34:04 +0530 Subject: [PATCH 3/4] Fix mypy errors for scheduling/shortest_job_first.py --- scheduling/shortest_job_first.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scheduling/shortest_job_first.py b/scheduling/shortest_job_first.py index f9e2ad975627..62829b97e132 100644 --- a/scheduling/shortest_job_first.py +++ b/scheduling/shortest_job_first.py @@ -3,17 +3,16 @@ Please note arrival time and burst Please use spaces to separate times entered. """ -from __future__ import annotations - +from typing import List import pandas as pd def calculate_waitingtime( - arrival_time: list[int], burst_time: list[int], no_of_processes: int -) -> list[int]: + arrival_time: List[int], burst_time: List[int], no_of_processes: int +) -> List[int]: """ Calculate the waiting time of each processes - Return: list of waiting times. + Return: List of waiting times. >>> calculate_waitingtime([1,2,3,4],[3,3,5,1],4) [0, 3, 5, 0] >>> calculate_waitingtime([1,2,3],[2,5,1],3) @@ -72,8 +71,8 @@ def calculate_waitingtime( def calculate_turnaroundtime( - burst_time: list[int], no_of_processes: int, waiting_time: list[int] -) -> list[int]: + burst_time: List[int], no_of_processes: int, waiting_time: List[int] +) -> List[int]: """ Calculate the turn around time of each Processes Return: list of turn around times. @@ -91,8 +90,8 @@ def calculate_turnaroundtime( def calculate_average_times( - waiting_time: list[int], turn_around_time: list[int], no_of_processes: int -): + waiting_time: List[int], turn_around_time: List[int], no_of_processes: int +) -> None: """ This function calculates the average of the waiting & turnaround times Prints: Average Waiting time & Average Turn Around Time From 9d68bcf38c2b0611b4a9e1a0cc7f10c545e4c0e0 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sun, 27 Dec 2020 22:28:06 +0530 Subject: [PATCH 4/4] Fix isort errors --- scheduling/round_robin.py | 2 +- scheduling/shortest_job_first.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scheduling/round_robin.py b/scheduling/round_robin.py index 72a750839d10..4a79301c1816 100644 --- a/scheduling/round_robin.py +++ b/scheduling/round_robin.py @@ -3,8 +3,8 @@ In Round Robin each process is assigned a fixed time slot in a cyclic way. https://en.wikipedia.org/wiki/Round-robin_scheduling """ -from typing import List from statistics import mean +from typing import List def calculate_waiting_times(burst_times: List[int]) -> List[int]: diff --git a/scheduling/shortest_job_first.py b/scheduling/shortest_job_first.py index 62829b97e132..a49d037d6a23 100644 --- a/scheduling/shortest_job_first.py +++ b/scheduling/shortest_job_first.py @@ -4,6 +4,7 @@ Please use spaces to separate times entered. """ from typing import List + import pandas as pd