Skip to content

Commit

Permalink
Merge pull request #92 from mggg/Patch-1.1.3
Browse files Browse the repository at this point in the history
Update indexed_geometries.py
  • Loading branch information
peterrrock2 authored Nov 21, 2023
2 parents 2a7bc29 + a83356c commit c5d8dd0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion maup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"`geopandas.options.use_pygeos = False` before importing your shapefile."
)

__version__ = "1.1.2"
__version__ = "1.1.3"
__all__ = [
"adjacencies",
"assign",
Expand Down
32 changes: 18 additions & 14 deletions maup/indexed_geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,26 @@ def assign(self, targets):
)
]
if groups:
# New in pandas 2.1.2: Only concatenate Series of positive length
groups = [group for group in groups if len(group) > 0]
groups_concat = pandas.concat(groups)
# No reindexing allowed with a non-unique Index,
# so we need to find and remove repetitions. (This only happens when the
# targets have overlaps and some source is completely covered by more
# than one target.)
# Any that get removed here will be randomly assigned to one of the
# covering units at the assign_by_area step by maup.assign.
groups_concat_index_list = list(groups_concat.index)
seen = set()
bad_indices = list(set([x for x in groups_concat_index_list if x in seen or seen.add(x)]))
if len(bad_indices)>0:
groups_concat = groups_concat.drop(bad_indices)
return groups_concat.reindex(self.index)
if groups:
groups_concat = pandas.concat(groups)
# New in pandas 2.1.2: No reindexing allowed with a non-unique Index,
# so we need to find and remove repetitions. (This only happens when the
# targets have overlaps and some source is completely covered by more
# than one target.)
# Any that get removed here will be randomly assigned to one of the
# covering units at the assign_by_area step ub maup.assign.
groups_concat_index_list = list(groups_concat.index)
seen = set()
bad_indices = list(set([x for x in groups_concat_index_list if x in seen or seen.add(x)]))
if len(bad_indices)>0:
groups_concat = groups_concat.drop(bad_indices)
return groups_concat.reindex(self.index)
else:
return geopandas.GeoSeries().reindex(self.index)
else:
return geopandas.GeoSeries()
return geopandas.GeoSeries().reindex(self.index)


def enumerate_intersections(self, targets):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "maup"
version = "1.1.2"
version = "1.1.3"
description = "The geospatial toolkit for redistricting data"
authors = [
"Metric Geometry and Gerrymandering Group <[email protected]>",
Expand Down

0 comments on commit c5d8dd0

Please sign in to comment.