Remove redundant type annotations "int|float"
This commit is contained in:
		
							parent
							
								
									b2d4de41f9
								
							
						
					
					
						commit
						f2e8ca1357
					
				|  | @ -18,7 +18,7 @@ from mwmatching import (maximum_weight_matching, | |||
|                         adjust_weights_for_maximum_cardinality_matching) | ||||
| 
 | ||||
| 
 | ||||
| def parse_int_or_float(s: str) -> int|float: | ||||
| def parse_int_or_float(s: str) -> float: | ||||
|     """Convert a string to integer or float value.""" | ||||
|     try: | ||||
|         return int(s) | ||||
|  | @ -27,7 +27,7 @@ def parse_int_or_float(s: str) -> int|float: | |||
|     return float(s) | ||||
| 
 | ||||
| 
 | ||||
| def read_dimacs_graph(f: TextIO) -> list[tuple[int, int, int|float]]: | ||||
| def read_dimacs_graph(f: TextIO) -> list[tuple[int, int, float]]: | ||||
|     """Read a graph in DIMACS edge list format.""" | ||||
| 
 | ||||
|     edges: list[tuple[int, int, float]] = [] | ||||
|  | @ -70,7 +70,7 @@ def read_dimacs_graph(f: TextIO) -> list[tuple[int, int, int|float]]: | |||
|     return edges | ||||
| 
 | ||||
| 
 | ||||
| def read_dimacs_graph_file(filename: str) -> list[tuple[int, int, int|float]]: | ||||
| def read_dimacs_graph_file(filename: str) -> list[tuple[int, int, float]]: | ||||
|     """Read a graph from file or stdin.""" | ||||
|     if filename: | ||||
|         with open(filename, "r", encoding="ascii") as f: | ||||
|  | @ -87,11 +87,11 @@ def read_dimacs_graph_file(filename: str) -> list[tuple[int, int, int|float]]: | |||
| 
 | ||||
| def read_dimacs_matching( | ||||
|         f: TextIO | ||||
|         ) -> tuple[int|float, list[tuple[int, int]]]: | ||||
|         ) -> tuple[float, list[tuple[int, int]]]: | ||||
|     """Read a matching solution in DIMACS format.""" | ||||
| 
 | ||||
|     have_weight = False | ||||
|     weight: int|float = 0 | ||||
|     weight: float = 0 | ||||
|     pairs: list[tuple[int, int]] = [] | ||||
| 
 | ||||
|     for line in f: | ||||
|  | @ -138,7 +138,7 @@ def read_dimacs_matching( | |||
| 
 | ||||
| def read_dimacs_matching_file( | ||||
|         filename: str | ||||
|         ) -> tuple[int|float, list[tuple[int, int]]]: | ||||
|         ) -> tuple[float, list[tuple[int, int]]]: | ||||
|     """Read a matching from file.""" | ||||
|     with open(filename, "r", encoding="ascii") as f: | ||||
|         try: | ||||
|  | @ -149,7 +149,7 @@ def read_dimacs_matching_file( | |||
| 
 | ||||
| def write_dimacs_matching( | ||||
|         f: TextIO, | ||||
|         weight: int|float, | ||||
|         weight: float, | ||||
|         pairs: list[tuple[int, int]] | ||||
|         ) -> None: | ||||
|     """Write a matching solution in DIMACS format.""" | ||||
|  | @ -165,7 +165,7 @@ def write_dimacs_matching( | |||
| 
 | ||||
| def write_dimacs_matching_file( | ||||
|         filename: str, | ||||
|         weight: int|float, | ||||
|         weight: float, | ||||
|         pairs: list[tuple[int, int]] | ||||
|         ) -> None: | ||||
|     """Write a matching to file or stdout.""" | ||||
|  | @ -177,15 +177,15 @@ def write_dimacs_matching_file( | |||
| 
 | ||||
| 
 | ||||
| def calc_matching_weight( | ||||
|         edges: list[tuple[int, int, int|float]], | ||||
|         edges: list[tuple[int, int, float]], | ||||
|         pairs: list[tuple[int, int]] | ||||
|         ) -> int|float: | ||||
|         ) -> float: | ||||
|     """Verify that the matching is valid and calculate its weight. | ||||
| 
 | ||||
|     Matched pairs are assumed to be in the same order as edges. | ||||
|     """ | ||||
| 
 | ||||
|     weight: int|float = 0 | ||||
|     weight: float = 0 | ||||
| 
 | ||||
|     edge_pos = 0 | ||||
|     for pair in pairs: | ||||
|  | @ -267,7 +267,7 @@ def verify_matching(filename: str, maxcard: bool, wfactor: float) -> bool: | |||
|     edges = read_dimacs_graph_file(filename) | ||||
|     (gold_weight, gold_pairs) = read_dimacs_matching_file(matching_filename) | ||||
| 
 | ||||
|     edges_adj: Sequence[tuple[int, int, int|float]] = edges | ||||
|     edges_adj: Sequence[tuple[int, int, float]] = edges | ||||
| 
 | ||||
|     if wfactor != 1.0: | ||||
|         if wfactor.is_integer(): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue