From cead35f211cb2c52bd6f0ff7a1854db2344ff9c5 Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Mon, 22 Jul 2024 09:00:45 -0600 Subject: [PATCH 1/5] fix conditional check for number of processes in LCSSMatcher --- mappymatch/matchers/lcss/lcss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mappymatch/matchers/lcss/lcss.py b/mappymatch/matchers/lcss/lcss.py index f6707ba..fed198c 100644 --- a/mappymatch/matchers/lcss/lcss.py +++ b/mappymatch/matchers/lcss/lcss.py @@ -152,7 +152,7 @@ def match_trace_batch( trace_batch: List[Trace], processes: int = 1, ) -> List[MatchResult]: - if processes > 1: + if processes <= 1: results = [self.match_trace(t) for t in trace_batch] else: with Pool(processes=processes) as p: From cf06b88415c32e89f60c38f5c9b437e240059bca Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Mon, 22 Jul 2024 09:01:39 -0600 Subject: [PATCH 2/5] bump version to v0.4.5 for bugfix --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 88bab5d..906ca29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mappymatch" -version = "0.4.4" +version = "0.4.5" description = "Package for mapmatching." readme = "README.md" authors = [{ name = "National Renewable Energy Laboratory" }] From 4728427caa04ad445b4ec3b723389fb156a18183 Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Mon, 22 Jul 2024 09:12:39 -0600 Subject: [PATCH 3/5] add not implemented error for broken multiprocessing code --- mappymatch/matchers/lcss/lcss.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mappymatch/matchers/lcss/lcss.py b/mappymatch/matchers/lcss/lcss.py index fed198c..8f45f76 100644 --- a/mappymatch/matchers/lcss/lcss.py +++ b/mappymatch/matchers/lcss/lcss.py @@ -1,6 +1,5 @@ import functools as ft import logging -from multiprocessing import Pool from shapely.geometry import Point @@ -155,7 +154,11 @@ def match_trace_batch( if processes <= 1: results = [self.match_trace(t) for t in trace_batch] else: - with Pool(processes=processes) as p: - results = p.map(self.match_trace, trace_batch) + raise NotImplementedError( + "Using `processes>1` is not available due to a known issue with rtree serialization." + "See https://github.com/Toblerity/rtree/issues/87 for more information." + ) + # with Pool(processes=processes) as p: + # results = p.map(self.match_trace, trace_batch) return results From 3a6d09f73445e316892a2dd01ad75dc52d23e850 Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Mon, 22 Jul 2024 09:34:38 -0600 Subject: [PATCH 4/5] fix ruff command in lint_test.yml to use 'check' instead of '.' --- .github/workflows/lint_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_test.yml b/.github/workflows/lint_test.yml index 02dedac..cd10eed 100644 --- a/.github/workflows/lint_test.yml +++ b/.github/workflows/lint_test.yml @@ -25,7 +25,7 @@ jobs: - name: Run black run: black . --check - name: Run ruff - run: ruff . + run: ruff check . - name: Run mypy run: mypy . - name: Run Tests From aa4fd98dc0c6332790419fd49025aae603b76a5c Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Mon, 22 Jul 2024 09:40:06 -0600 Subject: [PATCH 5/5] fix numpy mypy errors --- mappymatch/matchers/match_result.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mappymatch/matchers/match_result.py b/mappymatch/matchers/match_result.py index 8629d8a..5eb89bd 100644 --- a/mappymatch/matchers/match_result.py +++ b/mappymatch/matchers/match_result.py @@ -21,7 +21,7 @@ def matches_to_dataframe(self) -> pd.DataFrame: A pandas dataframe """ df = pd.DataFrame([m.to_flat_dict() for m in self.matches]) - df = df.fillna(np.NAN) + df = df.fillna(np.nan) return df @@ -37,6 +37,6 @@ def path_to_dataframe(self) -> pd.DataFrame: return pd.DataFrame() df = pd.DataFrame([r.to_flat_dict() for r in self.path]) - df = df.fillna(np.NAN) + df = df.fillna(np.nan) return df