fix: compatibility with python < 3.8 (#16)

* ci: run tests in python 3.7 as well
This commit is contained in:
Felix Spöttel
2022-07-07 10:21:21 +02:00
committed by GitHub
parent ff094a1d3e
commit 99e844c6ce
5 changed files with 14 additions and 11 deletions

View File

@@ -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

View File

@@ -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]`.",

View File

@@ -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:

View File

@@ -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")

View File

@@ -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