gerrytools 2.0.1__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. {gerrytools-2.0.1 → gerrytools-2.0.2}/PKG-INFO +1 -1
  2. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/_geodataframe.py +13 -3
  3. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/run_container.py +51 -8
  4. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/barplot.py +1 -1
  5. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/histogram.py +1 -1
  6. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/evaluator.py +39 -20
  7. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/metrics/_geometry.py +29 -23
  8. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/result.py +3 -3
  9. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/single_plan/__init__.py +2 -2
  10. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/single_plan/_base.py +5 -4
  11. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/single_plan/_geometry.py +23 -14
  12. {gerrytools-2.0.1 → gerrytools-2.0.2}/pyproject.toml +1 -1
  13. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/geometry.rs +1 -1
  14. {gerrytools-2.0.1 → gerrytools-2.0.2}/LICENSE +0 -0
  15. {gerrytools-2.0.1 → gerrytools-2.0.2}/README.md +0 -0
  16. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/__init__.py +0 -0
  17. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/_election_math.py +0 -0
  18. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/_geometry.py +0 -0
  19. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/_ipython.py +0 -0
  20. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/_partisan_math.py +0 -0
  21. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/_scoring_engine.pyi +0 -0
  22. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/ben/__init__.py +0 -0
  23. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/ben/_graph_prep.py +0 -0
  24. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/ben/recorded_chain.py +0 -0
  25. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/__init__.py +0 -0
  26. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/_latex_table.py +0 -0
  27. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/_sources.py +0 -0
  28. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/_value.py +0 -0
  29. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/core.py +0 -0
  30. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/districtr.py +0 -0
  31. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/latex.py +0 -0
  32. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/seaborn.py +0 -0
  33. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/colors/utils.py +0 -0
  34. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/__init__.py +0 -0
  35. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/_geometry_etags.py +0 -0
  36. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/geometries.py +0 -0
  37. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/__init__.py +0 -0
  38. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/_api.py +0 -0
  39. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/acs.py +0 -0
  40. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/block_cvap.py +0 -0
  41. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/census.py +0 -0
  42. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/census_tables.py +0 -0
  43. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/data/uscensus/ptable_column_aliases.py +0 -0
  44. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/__init__.py +0 -0
  45. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_colors.py +0 -0
  46. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_render.py +0 -0
  47. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_table_base.py +0 -0
  48. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_table_layout.py +0 -0
  49. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_table_options.py +0 -0
  50. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_table_preamble.py +0 -0
  51. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_text.py +0 -0
  52. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/_tikz_plot_base.py +0 -0
  53. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/commands.py +0 -0
  54. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/document.py +0 -0
  55. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/formatters.py +0 -0
  56. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/paintball.py +0 -0
  57. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/seatsvotes.py +0 -0
  58. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/table.py +0 -0
  59. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/latex/tikz_table.py +0 -0
  60. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/logging.py +0 -0
  61. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/__init__.py +0 -0
  62. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/constraints.py +0 -0
  63. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/objectives.py +0 -0
  64. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/run_config.py +0 -0
  65. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/runners/__init__.py +0 -0
  66. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/runners/forest.py +0 -0
  67. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/runners/recom.py +0 -0
  68. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/mgrp/runners/smc.py +0 -0
  69. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plan_comparison/__init__.py +0 -0
  70. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plan_comparison/overlap.py +0 -0
  71. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plan_comparison/relabel.py +0 -0
  72. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/__init__.py +0 -0
  73. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_artist_registry.py +0 -0
  74. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_axes_backed.py +0 -0
  75. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_axes_state.py +0 -0
  76. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_figure_io.py +0 -0
  77. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_legend_mixin.py +0 -0
  78. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_legend_utils.py +0 -0
  79. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/_rng.py +0 -0
  80. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/__init__.py +0 -0
  81. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_annotation_api.py +0 -0
  82. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_annotations.py +0 -0
  83. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_arrow_renderer.py +0 -0
  84. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_axis_api.py +0 -0
  85. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_categorical_distribution_base.py +0 -0
  86. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_gerryplot_dataclasses.py +0 -0
  87. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/_unit_square_base.py +0 -0
  88. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/boxplot.py +0 -0
  89. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/gerryplot.py +0 -0
  90. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/options.py +0 -0
  91. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/paintball.py +0 -0
  92. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/scatterplot.py +0 -0
  93. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/sealevel.py +0 -0
  94. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/seatsvotes.py +0 -0
  95. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/data/violin.py +0 -0
  96. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/__init__.py +0 -0
  97. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_dot_sampling.py +0 -0
  98. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_labels.py +0 -0
  99. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_layers/__init__.py +0 -0
  100. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_layers/_base.py +0 -0
  101. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_layers/_categorical.py +0 -0
  102. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_layers/_continuous.py +0 -0
  103. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/_layers/_marker.py +0 -0
  104. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/dotdensity.py +0 -0
  105. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/geoplot.py +0 -0
  106. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/geometry/geoplotbase.py +0 -0
  107. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/__init__.py +0 -0
  108. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/axis_title_style.py +0 -0
  109. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/geoplot_options.py +0 -0
  110. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/label_text_options.py +0 -0
  111. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/legend_options.py +0 -0
  112. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/marker_options.py +0 -0
  113. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/mpl/tick_style.py +0 -0
  114. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/other/__init__.py +0 -0
  115. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/other/subway.py +0 -0
  116. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/plan/__init__.py +0 -0
  117. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/plan/drawgraph.py +0 -0
  118. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/plotting/utils.py +0 -0
  119. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/py.typed +0 -0
  120. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/__init__.py +0 -0
  121. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/_manifest.py +0 -0
  122. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/_types.py +0 -0
  123. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/formulas.py +0 -0
  124. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/metrics/__init__.py +0 -0
  125. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/scoring/metrics/_base.py +0 -0
  126. {gerrytools-2.0.1 → gerrytools-2.0.2}/gerrytools/typing.py +0 -0
  127. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/Cargo.lock +0 -0
  128. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/Cargo.toml +0 -0
  129. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/README.md +0 -0
  130. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/adjacency.rs +0 -0
  131. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/error.rs +0 -0
  132. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/geometry/mod.rs +0 -0
  133. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/geometry/precise_area.rs +0 -0
  134. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/geometry/unit_hulls.rs +0 -0
  135. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/lib.rs +0 -0
  136. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/area_perimeter.rs +0 -0
  137. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/convex_hull_ratio.rs +0 -0
  138. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/cut_edges.rs +0 -0
  139. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/formulas.rs +0 -0
  140. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/hull_metric.rs +0 -0
  141. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/mod.rs +0 -0
  142. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/polsby_popper.rs +0 -0
  143. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/population_polygon.rs +0 -0
  144. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/region.rs +0 -0
  145. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/region_parts.rs +0 -0
  146. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/region_tally.rs +0 -0
  147. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/reock.rs +0 -0
  148. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/schwartzberg.rs +0 -0
  149. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/state_clipped_convex_hull_ratio.rs +0 -0
  150. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/metrics/tally.rs +0 -0
  151. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/python.rs +0 -0
  152. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/delta.rs +0 -0
  153. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/district.rs +0 -0
  154. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/input.rs +0 -0
  155. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/mod.rs +0 -0
  156. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/output.rs +0 -0
  157. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/result.rs +0 -0
  158. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/stream.rs +0 -0
  159. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/scoring/uniqueness.rs +0 -0
  160. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/convex_hull_ratio.rs +0 -0
  161. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/cut_edges.rs +0 -0
  162. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/district.rs +0 -0
  163. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/formulas.rs +0 -0
  164. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/input.rs +0 -0
  165. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/output.rs +0 -0
  166. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/polsby_popper.rs +0 -0
  167. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/population_polygon.rs +0 -0
  168. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/region.rs +0 -0
  169. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/region_tally.rs +0 -0
  170. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/reock.rs +0 -0
  171. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/schwartzberg.rs +0 -0
  172. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/state_clipped_convex_hull_ratio.rs +0 -0
  173. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/stream.rs +0 -0
  174. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/support.rs +0 -0
  175. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/tally.rs +0 -0
  176. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/twodelta.rs +0 -0
  177. {gerrytools-2.0.1 → gerrytools-2.0.2}/rust/src/tests/unit_hulls.rs +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gerrytools
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -77,10 +77,18 @@ def _validated_geometry_frame(
77
77
  """Transform and validate a geometry frame whose rows are already aligned."""
78
78
  if frame.crs is None:
79
79
  raise ValueError("geometries must have a CRS")
80
+ _require_valid_polygons(frame, "geometries")
81
+ if crs is None and frame.crs.is_geographic:
82
+ try:
83
+ crs = frame.estimate_utm_crs()
84
+ except (RuntimeError, ValueError) as error:
85
+ raise ValueError(
86
+ "Cannot determine a UTM CRS; supply an explicit projected CRS"
87
+ ) from error
80
88
  if crs is not None:
81
89
  frame = frame.to_crs(crs)
90
+ _require_valid_polygons(frame, "geometries")
82
91
  _require_projected_crs(frame, "geometry scoring")
83
- _require_valid_polygons(frame, "geometries")
84
92
  return frame
85
93
 
86
94
 
@@ -103,7 +111,8 @@ def aligned_geodataframe(
103
111
  geometries (gpd.GeoDataFrame): One geometry row per graph node.
104
112
  node_column (str | None): Optional column containing graph node identifiers.
105
113
  crs (Any | None): Optional projected CRS to which the geometries are transformed. Without
106
- this argument, ``geometries`` must already use a projected CRS.
114
+ this argument, geographic input is projected to an estimated UTM CRS; projected input
115
+ retains its CRS.
107
116
 
108
117
  Returns:
109
118
  gpd.GeoDataFrame: An aligned copy of ``geometries``.
@@ -111,7 +120,8 @@ def aligned_geodataframe(
111
120
  Raises:
112
121
  TypeError: If ``geometries`` is not a GeoDataFrame.
113
122
  ValueError: If identifiers are missing, duplicated, or do not match the node set; if CRS
114
- information is absent or geographic; or if a geometry is missing, empty, or invalid.
123
+ information is absent or no projected CRS can be determined; or if a geometry is
124
+ missing, empty, or invalid.
115
125
  """
116
126
  if not isinstance(geometries, gpd.GeoDataFrame):
117
127
  raise TypeError("geometries must be a GeoDataFrame")
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import codecs
4
+ import errno
4
5
  import hashlib
5
6
  import json
6
7
  import logging
@@ -9,18 +10,19 @@ import sys
9
10
  import tempfile
10
11
  import warnings
11
12
  from abc import ABC, abstractmethod
12
- from collections.abc import Callable, Mapping
13
+ from collections.abc import Callable, Generator, Mapping
13
14
  from contextlib import contextmanager
14
15
  from pathlib import Path, PureWindowsPath
15
16
  from types import TracebackType
16
- from typing import ClassVar, Generic, Iterator, Protocol, TypeVar, cast, runtime_checkable
17
+ from typing import ClassVar, Generic, Protocol, TypeVar, cast, runtime_checkable
17
18
 
18
19
  import docker.errors
20
+ from docker.types.daemon import CancellableStream
19
21
  from gerrychain import Graph, Partition
20
22
 
21
23
  logger = logging.getLogger(__name__)
22
24
 
23
- DEFAULT_DOCKER_IMAGE = "mgggdev/replicate:v2.0.1@sha256:fe03dd8c70e72e15d50410317892c32a6b04e1d254d0a4af6f16b4a10d14768f"
25
+ DEFAULT_DOCKER_IMAGE = "mgggdev/replicate:v2.0.2@sha256:fe03dd8c70e72e15d50410317892c32a6b04e1d254d0a4af6f16b4a10d14768f"
24
26
 
25
27
  BINARY_WRITERS = ("pcompress", "ben", "bendl")
26
28
  """Writers whose output cannot be decoded from a console stream."""
@@ -82,7 +84,7 @@ def _partial_output_path(output: Path) -> Path:
82
84
 
83
85
 
84
86
  @contextmanager
85
- def _preserve_outputs_on_failure(expected_files: list[str]) -> Iterator[None]:
87
+ def _preserve_outputs_on_failure(expected_files: list[str]) -> Generator[None, None, None]:
86
88
  """Hide old outputs during a rerun and preserve failed output under partial names."""
87
89
  outputs = [Path(output) for output in expected_files]
88
90
  backup_dirs: dict[Path, Path] = {}
@@ -149,7 +151,7 @@ def _preserve_outputs_on_failure(expected_files: list[str]) -> Iterator[None]:
149
151
 
150
152
 
151
153
  @contextmanager
152
- def _preserve_log_on_failure(log_file: str) -> Iterator[None]:
154
+ def _preserve_log_on_failure(log_file: str) -> Generator[None, None, None]:
153
155
  """Back up an existing log during a rerun and restore it if the rerun fails.
154
156
 
155
157
  Unlike outputs, a failed run's fresh log is kept when there was no previous log to
@@ -729,14 +731,55 @@ class RunnerSession(Generic[RunSpecT]):
729
731
  raise RuntimeError("Could not stop the abandoned streamed engine command.") from error
730
732
  self.container = None
731
733
 
734
+ @staticmethod
735
+ def _close_exec_stream(stream: object) -> None:
736
+ """Close the stream even if Docker's socket shutdown finds it disconnected."""
737
+ close = getattr(stream, "close", None)
738
+ if close is None:
739
+ return
740
+
741
+ try:
742
+ close()
743
+ except OSError as error:
744
+ if error.errno != errno.ENOTCONN:
745
+ raise
746
+ else:
747
+ return
748
+
749
+ if isinstance(stream, CancellableStream):
750
+ RunnerSession._close_disconnected_docker_stream(stream)
751
+
752
+ @staticmethod
753
+ def _close_disconnected_docker_stream(stream: CancellableStream) -> None:
754
+ """Release Docker's response even when its private socket layout is unfamiliar."""
755
+ # Docker's failed shutdown skips socket.close(); release both owners.
756
+ # NOTE: This uses a private SDK socket layout; revisit if/when Docker fixes close().
757
+ response = getattr(stream, "_response", None)
758
+ if response is None:
759
+ raise RuntimeError("Docker exec stream response is unavailable; cannot finish cleanup.")
760
+
761
+ try:
762
+ try:
763
+ socket_file = response.raw._fp.fp
764
+ raw_socket_file = getattr(socket_file, "raw", socket_file)
765
+ response_socket = getattr(raw_socket_file, "sock", None)
766
+ if response_socket is None:
767
+ response_socket = raw_socket_file._sock
768
+ except AttributeError as error:
769
+ raise RuntimeError(
770
+ "Docker exec stream socket layout has changed; cannot finish socket cleanup."
771
+ ) from error
772
+
773
+ response_socket.close()
774
+ finally:
775
+ response.close()
776
+
732
777
  def _cleanup_exec_stream(self, stream: object, *, completed: bool) -> None:
733
778
  """Close a Docker exec stream and stop its container if consumption failed."""
734
779
  primary_error = sys.exception()
735
780
  cleanup_errors: list[Exception] = []
736
- close = getattr(stream, "close", None)
737
781
  try:
738
- if close is not None:
739
- close()
782
+ self._close_exec_stream(stream)
740
783
  except Exception as error:
741
784
  cleanup_errors.append(error)
742
785
  if not completed:
@@ -229,7 +229,7 @@ class BarPlot(CategoricalDistributionPlotBase):
229
229
  uniques, counts = np.unique(vals, return_counts=True)
230
230
  # Default :g formatting can merge values beyond six significant digits.
231
231
  heights_dict = {
232
- np.format_float_positional(unique_value, trim="-"): float(count)
232
+ np.format_float_positional(float(unique_value), trim="-"): float(count)
233
233
  for unique_value, count in zip(uniques, counts, strict=True)
234
234
  }
235
235
  self._add_bar_set(
@@ -717,7 +717,7 @@ class Histogram(GerryPlotBase):
717
717
  visited_indexes = set()
718
718
  placement_edges = bin_edges if pointlist.centered else display_edges
719
719
  for i, val in enumerate(pointlist.values):
720
- bin_idx = np.searchsorted(placement_edges, val, side="right") - 1
720
+ bin_idx = int(np.searchsorted(placement_edges, val, side="right")) - 1
721
721
  if val == placement_edges[-1]:
722
722
  bin_idx -= 1
723
723
  in_range = 0 <= bin_idx < len(max_heights)
@@ -13,12 +13,13 @@ from types import MappingProxyType
13
13
  from typing import Any, Literal, TypeAlias, cast
14
14
  from weakref import WeakSet
15
15
 
16
+ import gerrychain
16
17
  import networkx as nx
17
18
  import numpy as np
18
19
  import pandas as pd
19
20
  from geopandas import GeoDataFrame
20
- from gerrychain import Graph as GerryGraph
21
21
  from gerrychain import Partition
22
+ from gerrychain.graph import FrozenGraph
22
23
  from pyproj import CRS
23
24
  from tqdm.auto import tqdm
24
25
 
@@ -131,14 +132,16 @@ class _ResourceCandidate:
131
132
  class PlanEvaluator:
132
133
  """Prepare graph and geometry resources once, then evaluate plans with engine kernels.
133
134
 
134
- Graph structure is captured lazily, while metric columns are snapshotted when first required.
135
- Assignments must follow construction-time node order when supplied as sequences; mappings are
136
- reordered by node identifier. Arbitrary hashable district labels are mapped densely for Rust
137
- and restored in the result.
135
+ NetworkX inputs are read lazily; RustworkX-backed GerryChain inputs are copied at construction.
136
+ Metric columns are prepared when first required. Sequence assignments follow construction-time
137
+ node order; mappings are reordered by node identifier. Arbitrary hashable district labels are
138
+ mapped densely for Rust and restored in the result.
138
139
 
139
140
  Args:
140
- graph (nx.Graph): An undirected, simple NetworkX-compatible graph containing metric
141
- attributes.
141
+ graph (nx.Graph | gerrychain.Graph | FrozenGraph): An undirected, simple NetworkX or
142
+ GerryChain graph containing metric attributes. RustworkX-backed GerryChain graphs
143
+ are copied once using original node identifiers, in internal node-index order.
144
+ Assignments and geometry identifiers use those original labels.
142
145
  geometry (GeoDataFrame | None, optional): GeoDataFrame with exactly one row per graph node.
143
146
  The whole aligned frame is authoritative for ordinary node and region columns, except
144
147
  that its active geometry column is reserved for geometry-backed metrics. Defaults to
@@ -146,7 +149,7 @@ class PlanEvaluator:
146
149
  node_id_column (str | None, optional): Geometry-frame column containing graph node
147
150
  identifiers. Defaults to None, which uses the GeoDataFrame index.
148
151
  target_crs (Any | None, optional): Projected CRS used by geometry-backed metrics. Defaults
149
- to None, which uses the geometry's CRS.
152
+ to None, which preserves projected input or estimates UTM for geographic input.
150
153
 
151
154
  Raises:
152
155
  ValueError: If the graph is empty, directed, a multigraph, or otherwise incompatible with
@@ -155,12 +158,13 @@ class PlanEvaluator:
155
158
 
156
159
  def __init__(
157
160
  self,
158
- graph: nx.Graph,
161
+ graph: nx.Graph | gerrychain.Graph | FrozenGraph,
159
162
  *,
160
163
  geometry: GeoDataFrame | None = None,
161
164
  node_id_column: str | None = None,
162
165
  target_crs: Any | None = None,
163
166
  ) -> None:
167
+ graph = _normalize_graph(graph)
164
168
  if graph.is_directed():
165
169
  raise ValueError("graph must be undirected")
166
170
  if graph.is_multigraph():
@@ -181,7 +185,7 @@ class PlanEvaluator:
181
185
  self._graph = graph
182
186
  self._geometry_source: _GeometrySource | None = None
183
187
  self._edge_labels: frozenset[frozenset[Hashable]] | None = None
184
- self._verified_partition_graphs: WeakSet[GerryGraph] = WeakSet()
188
+ self._verified_partition_graphs: WeakSet[gerrychain.Graph] = WeakSet()
185
189
  self._metrics: list[tuple[str, _MetricBase]] = []
186
190
  self._resources: _PreparedResources | None = None
187
191
  self._preparing: _ResourceCandidate | None = None
@@ -223,7 +227,8 @@ class PlanEvaluator:
223
227
  geometry (GeoDataFrame): Frame containing one row per graph node.
224
228
  node_id_column (str | None, optional): Column containing graph node identifiers.
225
229
  Defaults to None, which uses the frame index.
226
- target_crs (Any | None, optional): Projected CRS for geometry metrics. Defaults to None.
230
+ target_crs (Any | None, optional): Projected CRS for geometry metrics. Defaults to None,
231
+ preserving projected input or estimating UTM for geographic input.
227
232
 
228
233
  Returns:
229
234
  PlanEvaluator: This evaluator, for chained registration.
@@ -1093,6 +1098,10 @@ def _merge_ensemble_result(
1093
1098
  installed.append(destination)
1094
1099
 
1095
1100
  existing_manifest["metrics"] = merged
1101
+ if staged_result.summary.unique_plans is not None:
1102
+ summary = cast("dict[str, object]", existing_manifest["summary"])
1103
+ summary["unique_plans"] = staged_result.summary.unique_plans
1104
+ summary["unique_districts"] = staged_result.summary.unique_districts
1096
1105
  _write_run_manifest(output, existing_manifest)
1097
1106
  except BaseException:
1098
1107
  for destination in reversed(installed):
@@ -1217,27 +1226,37 @@ def _node_order_json(node_order: tuple[Hashable, ...]) -> str | None:
1217
1226
  return None
1218
1227
 
1219
1228
 
1220
- def _partition_graph(partition: Partition) -> nx.Graph:
1221
- """Reconstruct a NetworkX graph under a partition's original node identifiers."""
1222
- source = partition.graph.graph
1229
+ def _normalize_graph(source: nx.Graph | gerrychain.Graph | FrozenGraph) -> nx.Graph:
1230
+ """Normalize scoring graphs without losing original labels or parallel edges."""
1231
+ if isinstance(source, FrozenGraph):
1232
+ source = source.graph
1233
+ if isinstance(source, nx.Graph):
1234
+ return source
1235
+ if not isinstance(source, gerrychain.Graph):
1236
+ raise TypeError("graph must be a NetworkX or GerryChain graph")
1237
+ if source.is_nx_graph():
1238
+ return source.get_nx_graph()
1239
+
1223
1240
  graph = nx.Graph()
1224
1241
  internal_nodes = []
1225
1242
  for internal in source.node_indices:
1226
1243
  if not isinstance(internal, numbers.Integral):
1227
- raise ValueError("partition graph must use assignment-vector node identifiers")
1244
+ raise ValueError("GerryChain graph must use integer internal node identifiers")
1228
1245
  internal_nodes.append(int(internal))
1229
1246
  for internal in sorted(internal_nodes):
1230
1247
  original = source.original_nx_node_id_for_internal_node_id(internal)
1248
+ if original in graph:
1249
+ raise ValueError("GerryChain graph original node identifiers must be unique")
1231
1250
  data = dict(source.node_data(internal))
1232
1251
  data.pop("__networkx_node__", None)
1233
1252
  graph.add_node(original, **data)
1234
1253
  for edge in source.edge_indices:
1235
1254
  left, right = source.get_edge_from_edge_id(edge)
1236
- graph.add_edge(
1237
- source.original_nx_node_id_for_internal_node_id(left),
1238
- source.original_nx_node_id_for_internal_node_id(right),
1239
- **dict(source.edge_data(edge)),
1240
- )
1255
+ left = source.original_nx_node_id_for_internal_node_id(left)
1256
+ right = source.original_nx_node_id_for_internal_node_id(right)
1257
+ if graph.has_edge(left, right):
1258
+ raise ValueError("graph must be simple, not a multigraph")
1259
+ graph.add_edge(left, right, **dict(source.edge_data(edge)))
1241
1260
  return graph
1242
1261
 
1243
1262
 
@@ -6,12 +6,13 @@ import math
6
6
  import numbers
7
7
  from collections.abc import Callable, Iterable, Mapping
8
8
  from dataclasses import dataclass
9
- from typing import TYPE_CHECKING, ClassVar, Literal, TypeAlias, cast
9
+ from typing import TYPE_CHECKING, Any, ClassVar, Literal, TypeAlias, cast
10
10
 
11
- from geopandas import GeoDataFrame
11
+ from geopandas import GeoDataFrame, GeoSeries
12
12
  from pyproj import CRS
13
13
  from shapely.geometry.base import BaseGeometry
14
14
 
15
+ from ..._geodataframe import _validated_geometry_frame
15
16
  from .._types import _Dtype, _ResultShape
16
17
  from ._base import (
17
18
  _KeyedMetric,
@@ -89,8 +90,8 @@ class StateClippedConvexHullRatio(_MetricBase):
89
90
 
90
91
  Clipping removes the ordinary convex hull's area outside the state, so this score is at least
91
92
  the standard :class:`ConvexHullRatio`. Values lie in :math:`(0, 1]`. Unit and state geometry
92
- must use the same projected CRS appropriate for area calculations, and the state must cover
93
- every unit geometry.
93
+ are measured in the evaluator's projected CRS, and the state must cover every unit geometry.
94
+ Set ``state_crs`` to transform the boundary; otherwise it must already use the scoring CRS.
94
95
 
95
96
  This boundary-adjusted variant follows the clipped convex-hull construction discussed by Moon
96
97
  Duchin in `Political Geometry
@@ -101,6 +102,8 @@ class StateClippedConvexHullRatio(_MetricBase):
101
102
  Args:
102
103
  state_geometry (BaseGeometry): Nonempty, valid Polygon or MultiPolygon covering every
103
104
  scoring unit.
105
+ state_crs (Any | None, optional): CRS of the state boundary. Defaults to None, meaning
106
+ the boundary already uses the evaluator's projected CRS.
104
107
  result_name (str | None, optional): Result key. Defaults to
105
108
  ``"state_clipped_convex_hull_ratio"``.
106
109
 
@@ -111,8 +114,11 @@ class StateClippedConvexHullRatio(_MetricBase):
111
114
 
112
115
  _kind: ClassVar[str] = "state_clipped_convex_hull_ratio"
113
116
  state_geometry: BaseGeometry
117
+ state_crs: Any | None = None
114
118
 
115
119
  def __post_init__(self) -> None:
120
+ if self.state_crs is not None:
121
+ object.__setattr__(self, "state_crs", CRS.from_user_input(self.state_crs))
116
122
  state = self.state_geometry
117
123
  if not isinstance(state, BaseGeometry):
118
124
  raise TypeError("state_geometry must be a Shapely Polygon or MultiPolygon")
@@ -129,10 +135,12 @@ class StateClippedConvexHullRatio(_MetricBase):
129
135
  return _ResourceSpec(geometry=True)
130
136
 
131
137
  def _prepare(self, backend: ScoringEngine, evaluator: PlanEvaluator) -> _OutputSpec:
132
- backend.add_state_clipped_convex_hull_ratio(
133
- evaluator._require_geometry("StateClippedConvexHullRatio").native,
134
- bytes(self.state_geometry.wkb),
135
- )
138
+ geometry = evaluator._require_geometry("StateClippedConvexHullRatio")
139
+ state = self.state_geometry
140
+ if self.state_crs is not None:
141
+ frame = GeoDataFrame(geometry=[state], crs=self.state_crs)
142
+ state = _validated_geometry_frame(frame, crs=geometry.crs).geometry.iloc[0]
143
+ backend.add_state_clipped_convex_hull_ratio(geometry.native, bytes(state.wkb))
136
144
  return _OutputSpec(_ResultShape.DISTRICT, ("score",), ("float",))
137
145
 
138
146
  def _options(self) -> dict[str, object]:
@@ -164,8 +172,8 @@ class PopulationPolygon(_MetricBase):
164
172
 
165
173
  Every alternative population polygon must be covered by exactly one evaluator geometry. Weights
166
174
  must be finite and nonnegative, with positive total weight overall and within every observed
167
- district. Alternative and scorer geometries must use the same projected CRS. Duplicate
168
- observations contribute independently.
175
+ district. Alternative population geometries are transformed into the scorer's projected CRS.
176
+ Duplicate observations contribute independently.
169
177
 
170
178
  This statistic is resolution-dependent. A coarse polygon contributes its full population even
171
179
  if only a small sliver intersects the hull. It is not areal interpolation and must not be
@@ -177,7 +185,7 @@ class PopulationPolygon(_MetricBase):
177
185
 
178
186
  Args:
179
187
  population_col (str): Column containing nonnegative population values.
180
- population_units (GeoDataFrame | None, optional): Projected GeoDataFrame containing a
188
+ population_units (GeoDataFrame | None, optional): GeoDataFrame with a declared CRS containing a
181
189
  finer population surface. Defaults to None, which reads ``population_col`` from the
182
190
  evaluator's aligned geometry.
183
191
  result_name (str | None, optional): Result key. Defaults to ``"population_polygon"``.
@@ -221,8 +229,6 @@ class PopulationPolygon(_MetricBase):
221
229
  if population_units.crs is None:
222
230
  raise ValueError("PopulationPolygon population_units must have a CRS")
223
231
  population_crs = CRS.from_user_input(population_units.crs)
224
- if not population_crs.is_projected:
225
- raise ValueError("PopulationPolygon population_units must use a projected CRS")
226
232
 
227
233
  geometry = population_units.geometry
228
234
  if geometry.isna().any():
@@ -235,7 +241,7 @@ class PopulationPolygon(_MetricBase):
235
241
  raise ValueError(
236
242
  "PopulationPolygon geometries must contain only Polygon or MultiPolygon values"
237
243
  )
238
- if (geometry.area <= 0).any():
244
+ if any(polygon.area <= 0 for polygon in geometry):
239
245
  raise ValueError("PopulationPolygon geometries must have positive area")
240
246
 
241
247
  weight_values = tuple(population_units[population_col])
@@ -269,10 +275,6 @@ class PopulationPolygon(_MetricBase):
269
275
  raise ValueError("PopulationPolygon population must have a positive total")
270
276
  return geometry.native, weights
271
277
  assert self.alternative_crs is not None and self.alternative_weights is not None
272
- if CRS.from_user_input(self.alternative_crs) != geometry.crs:
273
- raise ValueError(
274
- "PopulationPolygon population_units and evaluator geometry must use the same CRS"
275
- )
276
278
  return geometry.native, list(self.alternative_weights)
277
279
 
278
280
  def _validate(self, evaluator: PlanEvaluator) -> None:
@@ -291,11 +293,15 @@ class PopulationPolygon(_MetricBase):
291
293
  if self.alternative_geometries is None:
292
294
  backend.add_population_polygon_aligned(geometry, weights)
293
295
  else:
294
- backend.add_population_polygon(
295
- geometry,
296
- list(self.alternative_geometries),
297
- weights,
298
- )
296
+ target_crs = evaluator._require_geometry("PopulationPolygon").crs
297
+ polygons = list(self.alternative_geometries)
298
+ if CRS.from_user_input(self.alternative_crs) != target_crs:
299
+ population = GeoDataFrame(
300
+ geometry=GeoSeries.from_wkb(polygons, crs=self.alternative_crs)
301
+ )
302
+ population = _validated_geometry_frame(population, crs=target_crs)
303
+ polygons = list(population.geometry.to_wkb(hex=False))
304
+ backend.add_population_polygon(geometry, polygons, weights)
299
305
  return _OutputSpec(_ResultShape.DISTRICT, ("score",), ("float",))
300
306
 
301
307
  def _options(self) -> dict[str, object]:
@@ -8,7 +8,7 @@ import json
8
8
  import numbers
9
9
  import os
10
10
  import warnings
11
- from collections.abc import Hashable, Iterable, Iterator, Mapping
11
+ from collections.abc import Generator, Hashable, Iterable, Iterator, Mapping
12
12
  from contextlib import ExitStack, contextmanager
13
13
  from pathlib import Path
14
14
  from typing import BinaryIO, Literal, TypeAlias, cast, overload
@@ -791,7 +791,7 @@ def _open_metric_readers(
791
791
  expand_repetitions: bool = False,
792
792
  allow_large: bool,
793
793
  batch_size: int | None = None,
794
- ) -> Iterator[list[tuple[_RunTable, pq.ParquetFile]]]:
794
+ ) -> Generator[list[tuple[_RunTable, pq.ParquetFile]], None, None]:
795
795
  selected = metric.tables[:1] if operation == "frames" else metric.tables
796
796
  with ExitStack() as stack:
797
797
  verified = [
@@ -881,7 +881,7 @@ def _open_metric_readers(
881
881
  def _verified_metric_file(
882
882
  metric: _RunMetric,
883
883
  table: _RunTable,
884
- ) -> Iterator[tuple[BinaryIO, int]]:
884
+ ) -> Generator[tuple[BinaryIO, int], None, None]:
885
885
  with table.path.open("rb") as file:
886
886
  size = os.fstat(file.fileno()).st_size
887
887
  if size != table.size:
@@ -99,7 +99,7 @@ def tally(
99
99
  """Sum one or more unit columns by district for a single plan.
100
100
 
101
101
  Args:
102
- source (SinglePlanSource): GerryChain Partition, NetworkX graph, or authoritative
102
+ source (SinglePlanSource): GerryChain Partition, NetworkX or GerryChain graph, or authoritative
103
103
  GeoDataFrame.
104
104
  assignment (GeoAssignment | None, optional): Graph assignment mapping or node-ordered
105
105
  sequence, or a GeoDataFrame assignment column, mapping, or row-ordered sequence.
@@ -146,7 +146,7 @@ def eguia(
146
146
  wins for neither party. See :class:`Eguia` for the full definition and input contract.
147
147
 
148
148
  Args:
149
- source (SinglePlanSource): GerryChain Partition, NetworkX graph, or authoritative
149
+ source (SinglePlanSource): GerryChain Partition, NetworkX or GerryChain graph, or authoritative
150
150
  GeoDataFrame.
151
151
  assignment (GeoAssignment | None, optional): Graph assignment mapping or node-ordered
152
152
  sequence, or a GeoDataFrame assignment column, mapping, or row-ordered sequence.
@@ -5,9 +5,11 @@ from __future__ import annotations
5
5
  from collections.abc import Hashable, Iterable
6
6
  from typing import Any, TypeAlias, TypeVar, cast, overload
7
7
 
8
+ import gerrychain
8
9
  import networkx as nx
9
10
  from geopandas import GeoDataFrame
10
11
  from gerrychain import Partition
12
+ from gerrychain.graph import FrozenGraph
11
13
  from pandas import DataFrame, Series
12
14
 
13
15
  from ..evaluator import (
@@ -16,12 +18,11 @@ from ..evaluator import (
16
18
  _assignment_mapping,
17
19
  _is_missing,
18
20
  _partition_assignment,
19
- _partition_graph,
20
21
  _result_name,
21
22
  )
22
23
  from ..metrics import Metric
23
24
 
24
- SinglePlanSource: TypeAlias = Partition | nx.Graph | GeoDataFrame
25
+ SinglePlanSource: TypeAlias = Partition | nx.Graph | gerrychain.Graph | FrozenGraph | GeoDataFrame
25
26
 
26
27
 
27
28
  SinglePlanResult: TypeAlias = float | int | Series | DataFrame
@@ -104,13 +105,13 @@ def _evaluate(
104
105
  if geometry is None and (node_id_column is not None or target_crs is not None):
105
106
  raise ValueError("node_id_column and target_crs require geometry")
106
107
  evaluator = PlanEvaluator(
107
- _partition_graph(source),
108
+ source.graph,
108
109
  geometry=geometry,
109
110
  node_id_column=node_id_column,
110
111
  target_crs=target_crs,
111
112
  )
112
113
  plan: Assignment = _partition_assignment(source)
113
- elif isinstance(source, nx.Graph):
114
+ elif isinstance(source, (nx.Graph, gerrychain.Graph, FrozenGraph)):
114
115
  if assignment is None:
115
116
  raise TypeError("a graph source requires an assignment")
116
117
  if isinstance(assignment, str):