diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d742de..61b510a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,17 +36,19 @@ jobs: run: | python setup.py check python setup.py bdist_wheel sdist - - python: "3.10" task: - name: "Style" + name: "Lint" run: | black --check . - python: "3.10" task: name: "Test" run: pytest --exitfirst --failed-first - + - python: "3.7" + task: + name: "Test (3.7)" + run: pytest --exitfirst --failed-first steps: - uses: actions/checkout@v3 diff --git a/geoclustering/__main__.py b/geoclustering/__main__.py index 6b2a4d0..a732727 100644 --- a/geoclustering/__main__.py +++ b/geoclustering/__main__.py @@ -75,14 +75,14 @@ def main(distance, size, output, filename, algorithm, _open, debug): vis = io.write_visualization(output, "result.html", encoded["geojson"]) if vis is None: - print_debug(f"Skipped generating visualization: kepler is not installed.") + print_debug("Skipped generating visualization: kepler is not installed.") click.echo(f"Output files saved to {Path(output).absolute()}") if _open: if vis: webbrowser.open_new_tab("file://" + str(vis.absolute())) - print_debug(f"Opened visualization in default browser.") + print_debug("Opened visualization in default browser.") else: click.secho( "Can't open kepler.gl: package not installed. Please re-install geoclustering with `pip install geoclustering[full]`.", diff --git a/geoclustering/io.py b/geoclustering/io.py index 4efe44b..55dce25 100644 --- a/geoclustering/io.py +++ b/geoclustering/io.py @@ -58,13 +58,16 @@ def read_csv_file(filename): valid_index = df.lat.apply(is_valid_lat) & df.lon.apply(is_valid_lon) df_invalid = df[~valid_index] - if count_invalid := len(df_invalid): + count_invalid = len(df_invalid) + if count_invalid: df_not_empty = df_invalid[ (df_invalid.lat.apply(is_not_none) | df_invalid.lon.apply(is_not_none)) ] - count_not_empty = len(df_not_empty) - if count_empty := count_invalid - count_not_empty: + count_not_empty = len(df_not_empty) + count_empty = count_invalid - count_not_empty + + if count_empty: print(f"Removed {count_empty} empty coordinate pairs.") if count_not_empty: diff --git a/tests/clustering.py b/tests/clustering.py index 8c49874..d25fb2a 100644 --- a/tests/clustering.py +++ b/tests/clustering.py @@ -1,6 +1,5 @@ from geoclustering.clustering import cluster_locations -from geoclustering.io import read_csv_file -from tests.helpers import get_fixture_path, read_fixture_csv +from tests.helpers import read_fixture_csv df = read_fixture_csv("clustering.csv") diff --git a/tests/encoding.py b/tests/encoding.py index 7defb53..2be0638 100644 --- a/tests/encoding.py +++ b/tests/encoding.py @@ -1,4 +1,3 @@ -from geoclustering.clustering import cluster_locations from geoclustering.encoding import encode_clusters from tests.helpers import read_fixture_csv, read_fixture_content