From 1fb1fdd130506e1db137dbcc2087b391c1880849 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 6 Aug 2020 17:50:23 +0200 Subject: [PATCH] requirements.txt: Unpin numpy (#2287) * requirements.txt: Unpin numpy * fixup! Format Python code with psf/black push * Less clutter * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> --- graphs/karger.py | 34 ++++++++++++++------------ other/scoring_algorithm.py | 10 ++++---- requirements.txt | 2 +- web_programming/world_covid19_stats.py | 8 +++--- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/graphs/karger.py b/graphs/karger.py index d5a27c285..baa0eebd9 100644 --- a/graphs/karger.py +++ b/graphs/karger.py @@ -5,20 +5,19 @@ An implementation of Karger's Algorithm for partitioning a graph. 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,9 @@ 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] = { + node for node in contracted_nodes[u].union(contracted_nodes[v]) + } # Remove nodes u and v. del graph_copy[u] @@ -75,8 +75,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/other/scoring_algorithm.py b/other/scoring_algorithm.py index a5d073d5e..77e614e26 100644 --- a/other/scoring_algorithm.py +++ b/other/scoring_algorithm.py @@ -1,4 +1,4 @@ -''' +""" developed by: markmelnic original repo: https://github.com/markmelnic/Scoring-Algorithm @@ -23,17 +23,17 @@ Thus the weights for each column are as follows: >>> procentual_proximity([[20, 60, 2012],[23, 90, 2015],[22, 50, 2011]], [0, 0, 1]) [[20, 60, 2012, 2.0], [23, 90, 2015, 1.0], [22, 50, 2011, 1.3333333333333335]] -''' +""" -def procentual_proximity(source_data : list, weights : list) -> list: +def procentual_proximity(source_data: list, weights: list) -> list: - ''' + """ weights - int list possible values - 0 / 1 0 if lower values have higher weight in the data set 1 if higher values have higher weight in the data set - ''' + """ # getting data data_lists = [] diff --git a/requirements.txt b/requirements.txt index d21c13a54..8362afc62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ flake8 keras matplotlib mypy -numpy>=1.17.4 +numpy opencv-python pandas pillow diff --git a/web_programming/world_covid19_stats.py b/web_programming/world_covid19_stats.py index 1907ed5f3..1dd1ff6d1 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"})