from __future__ import annotations (#2464)

* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2020-09-23 13:30:13 +02:00
committed by GitHub
parent 6e6a49d19f
commit 9200a2e543
72 changed files with 275 additions and 250 deletions

View File

@ -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 typing import List
from __future__ import annotations
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.

View File

@ -3,11 +3,12 @@ Round Robin is a scheduling algorithm.
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 statistics import mean
from typing import List
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.
@ -40,8 +41,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]

View File

@ -3,14 +3,14 @@ Shortest job remaining first
Please note arrival time and burst
Please use spaces to separate times entered.
"""
from typing import List
from __future__ import annotations
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.
@ -72,8 +72,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,7 +91,7 @@ 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
):
"""
This function calculates the average of the waiting & turnaround times