Skip to content

Commit

Permalink
Merge pull request #188 from NREL/bugfix/batch-logic
Browse files Browse the repository at this point in the history
Bugfix/batch logic
  • Loading branch information
nreinicke authored Jul 23, 2024
2 parents 7bd91b1 + aa4fd98 commit 1707f4e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions mappymatch/matchers/lcss/lcss.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools as ft
import logging
from multiprocessing import Pool

from shapely.geometry import Point

Expand Down Expand Up @@ -152,10 +151,14 @@ 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:
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
4 changes: 2 additions & 2 deletions mappymatch/matchers/match_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]
Expand Down

0 comments on commit 1707f4e

Please sign in to comment.