Add doctests to radix_sort() (#2148)

* Add doctests to radix_sort()

* fixup! Format Python code with psf/black push

* Update radix_sort.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2020-06-23 15:37:24 +02:00
committed by GitHub
parent f1ce2d6e80
commit 5b6ebf8f12
3 changed files with 33 additions and 25 deletions

View File

@ -4,9 +4,9 @@ from typing import Dict, List, Tuple
class MarkovChainGraphUndirectedUnweighted:
'''
"""
Undirected Unweighted Graph for running Markov Chain Algorithm
'''
"""
def __init__(self):
self.connections = {}
@ -14,9 +14,9 @@ class MarkovChainGraphUndirectedUnweighted:
def add_node(self, node: str) -> None:
self.connections[node] = {}
def add_transition_probability(self, node1: str,
node2: str,
probability: float) -> None:
def add_transition_probability(
self, node1: str, node2: str, probability: float
) -> None:
if node1 not in self.connections:
self.add_node(node1)
if node2 not in self.connections:
@ -36,10 +36,10 @@ class MarkovChainGraphUndirectedUnweighted:
return dest
def get_transitions(start: str,
transitions: List[Tuple[str, str, float]],
steps: int) -> Dict[str, int]:
'''
def get_transitions(
start: str, transitions: List[Tuple[str, str, float]], steps: int
) -> Dict[str, int]:
"""
Running Markov Chain algorithm and calculating the number of times each node is
visited
@ -59,7 +59,7 @@ def get_transitions(start: str,
>>> result['a'] > result['b'] > result['c']
True
'''
"""
graph = MarkovChainGraphUndirectedUnweighted()