fix: debug prints

This commit is contained in:
Felix Spöttel
2022-07-01 18:48:17 +02:00
parent 8657bd73ec
commit 62da0806c7

View File

@@ -8,10 +8,6 @@ import geoclustering.encoding as encoding
import geoclustering.io as io import geoclustering.io as io
def print_debug(s):
click.secho(s, fg="bright_black")
@click.command( @click.command(
help="Tool to cluster geolocations. A cluster is created when a certain number of points (--size) each are within a given distance (--distance) of at least one other point in the cluster. Input is supplied as a csv file. At a minimum, each row needs to have a 'lat' and a 'lon' column. Other rows are reflected to the output." help="Tool to cluster geolocations. A cluster is created when a certain number of points (--size) each are within a given distance (--distance) of at least one other point in the cluster. Input is supplied as a csv file. At a minimum, each row needs to have a 'lat' and a 'lon' column. Other rows are reflected to the output."
) )
@@ -54,12 +50,13 @@ def print_debug(s):
@click.option("--debug", is_flag=True, help="Print debug output.") @click.option("--debug", is_flag=True, help="Print debug output.")
@click.argument("filename", type=click.Path(exists=True)) @click.argument("filename", type=click.Path(exists=True))
def main(distance, size, output, filename, algorithm, open, debug): def main(distance, size, output, filename, algorithm, open, debug):
if debug: def print_debug(s):
print_debug(f"Reading input from {Path(filename).absolute()}") if debug:
click.secho(s, fg="bright_black")
df = io.read_csv_file(filename) df = io.read_csv_file(filename)
if debug: print_debug(f"Read {len(df)} valid coordinates from {Path(filename).absolute()}")
print_debug(f"Read {len(df)} valid coordinates")
clusters = clustering.cluster_locations( clusters = clustering.cluster_locations(
df=df, algorithm=algorithm, radius_km=distance, min_cluster_size=size df=df, algorithm=algorithm, radius_km=distance, min_cluster_size=size