From 66372e54aef108d02714bba85cd605218e08514e Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 4 Aug 2020 15:58:44 +0000 Subject: [PATCH] fixup! Format Python code with psf/black push --- graphs/karger.py | 35 +++++++++++++++----------- web_programming/world_covid19_stats.py | 8 +++--- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/graphs/karger.py b/graphs/karger.py index d5a27c285fd4..589b8c733dde 100644 --- a/graphs/karger.py +++ b/graphs/karger.py @@ -5,20 +5,19 @@ import random from typing import Dict, List, Set, Tuple - # Adjacency list representation of this graph: # https://en.wikipedia.org/wiki/File:Single_run_of_Karger%E2%80%99s_Mincut_algorithm.svg TEST_GRAPH = { - '1': ['2', '3', '4', '5'], - '2': ['1', '3', '4', '5'], - '3': ['1', '2', '4', '5', '10'], - '4': ['1', '2', '3', '5', '6'], - '5': ['1', '2', '3', '4', '7'], - '6': ['7', '8', '9', '10', '4'], - '7': ['6', '8', '9', '10', '5'], - '8': ['6', '7', '9', '10'], - '9': ['6', '7', '8', '10'], - '10': ['6', '7', '8', '9', '3'] + "1": ["2", "3", "4", "5"], + "2": ["1", "3", "4", "5"], + "3": ["1", "2", "4", "5", "10"], + "4": ["1", "2", "3", "5", "6"], + "5": ["1", "2", "3", "4", "7"], + "6": ["7", "8", "9", "10", "4"], + "7": ["6", "8", "9", "10", "5"], + "8": ["6", "7", "9", "10"], + "9": ["6", "7", "8", "10"], + "10": ["6", "7", "8", "9", "3"], } @@ -61,8 +60,10 @@ def partition_graph(graph: Dict[str, List[str]]) -> Set[Tuple[str, str]]: for neighbor in uv_neighbors: graph_copy[neighbor].append(uv) - contracted_nodes[uv] = {contracted_node for contracted_node in - contracted_nodes[u].union(contracted_nodes[v])} + contracted_nodes[uv] = { + contracted_node + for contracted_node in contracted_nodes[u].union(contracted_nodes[v]) + } # Remove nodes u and v. del graph_copy[u] @@ -75,8 +76,12 @@ def partition_graph(graph: Dict[str, List[str]]) -> Set[Tuple[str, str]]: # Find cutset. groups = [contracted_nodes[node] for node in graph_copy] - return {(node, neighbor) for node in groups[0] - for neighbor in graph[node] if neighbor in groups[1]} + return { + (node, neighbor) + for node in groups[0] + for neighbor in graph[node] + if neighbor in groups[1] + } if __name__ == "__main__": diff --git a/web_programming/world_covid19_stats.py b/web_programming/world_covid19_stats.py index 1907ed5f35f7..1dd1ff6d188e 100644 --- a/web_programming/world_covid19_stats.py +++ b/web_programming/world_covid19_stats.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -''' +""" Provide the current worldwide COVID-19 statistics. This data is being scrapped from 'https://www.worldometers.info/coronavirus/'. -''' +""" import requests from bs4 import BeautifulSoup @@ -13,8 +13,8 @@ def world_covid19_stats(url: str = "https://www.worldometers.info/coronavirus") """ Return a dict of current worldwide COVID-19 statistics """ - soup = BeautifulSoup(requests.get(url).text, 'html.parser') - keys = soup.findAll('h1') + soup = BeautifulSoup(requests.get(url).text, "html.parser") + keys = soup.findAll("h1") values = soup.findAll("div", {"class": "maincounter-number"}) keys += soup.findAll("span", {"class": "panel-title"}) values += soup.findAll("div", {"class": "number-table-main"})