gerrytools 2.0.0__tar.gz → 2.0.1__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.
- {gerrytools-2.0.0 → gerrytools-2.0.1}/PKG-INFO +1 -1
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/ben/__init__.py +4 -4
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/ben/recorded_chain.py +17 -16
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/__init__.py +15 -15
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/constraints.py +2 -2
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/objectives.py +3 -3
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/run_config.py +1 -1
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/run_container.py +75 -75
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/runners/forest.py +41 -41
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/runners/recom.py +110 -110
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/runners/smc.py +33 -33
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/__init__.py +2 -2
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/_manifest.py +6 -4
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/evaluator.py +29 -28
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/result.py +80 -31
- {gerrytools-2.0.0 → gerrytools-2.0.1}/pyproject.toml +1 -1
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/README.md +7 -47
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/cut_edges.rs +2 -2
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/stream.rs +3 -3
- {gerrytools-2.0.0 → gerrytools-2.0.1}/LICENSE +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/README.md +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/_election_math.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/_geodataframe.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/_geometry.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/_ipython.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/_partisan_math.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/_scoring_engine.pyi +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/ben/_graph_prep.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/_latex_table.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/_sources.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/_value.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/core.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/districtr.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/latex.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/seaborn.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/colors/utils.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/_geometry_etags.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/geometries.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/_api.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/acs.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/block_cvap.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/census.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/census_tables.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/data/uscensus/ptable_column_aliases.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_colors.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_render.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_table_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_table_layout.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_table_options.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_table_preamble.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_text.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/_tikz_plot_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/commands.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/document.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/formatters.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/paintball.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/seatsvotes.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/table.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/latex/tikz_table.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/logging.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/mgrp/runners/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plan_comparison/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plan_comparison/overlap.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plan_comparison/relabel.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_artist_registry.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_axes_backed.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_axes_state.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_figure_io.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_legend_mixin.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_legend_utils.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/_rng.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_annotation_api.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_annotations.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_arrow_renderer.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_axis_api.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_categorical_distribution_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_gerryplot_dataclasses.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/_unit_square_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/barplot.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/boxplot.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/gerryplot.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/histogram.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/options.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/paintball.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/scatterplot.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/sealevel.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/seatsvotes.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/data/violin.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_dot_sampling.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_labels.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_layers/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_layers/_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_layers/_categorical.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_layers/_continuous.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/_layers/_marker.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/dotdensity.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/geoplot.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/geometry/geoplotbase.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/axis_title_style.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/geoplot_options.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/label_text_options.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/legend_options.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/marker_options.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/mpl/tick_style.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/other/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/other/subway.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/plan/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/plan/drawgraph.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/plotting/utils.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/py.typed +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/_types.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/formulas.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/metrics/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/metrics/_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/metrics/_geometry.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/single_plan/__init__.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/single_plan/_base.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/scoring/single_plan/_geometry.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/gerrytools/typing.py +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/Cargo.lock +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/Cargo.toml +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/adjacency.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/error.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/geometry/mod.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/geometry/precise_area.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/geometry/unit_hulls.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/lib.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/area_perimeter.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/convex_hull_ratio.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/formulas.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/hull_metric.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/mod.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/polsby_popper.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/population_polygon.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/region.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/region_parts.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/region_tally.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/reock.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/schwartzberg.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/state_clipped_convex_hull_ratio.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/metrics/tally.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/python.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/delta.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/district.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/input.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/mod.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/output.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/result.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/scoring/uniqueness.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/convex_hull_ratio.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/cut_edges.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/district.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/formulas.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/geometry.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/input.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/output.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/polsby_popper.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/population_polygon.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/region.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/region_tally.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/reock.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/schwartzberg.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/state_clipped_convex_hull_ratio.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/stream.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/support.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/tally.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/twodelta.rs +0 -0
- {gerrytools-2.0.0 → gerrytools-2.0.1}/rust/src/tests/unit_hulls.rs +0 -0
|
@@ -14,12 +14,12 @@ import pandas as pd
|
|
|
14
14
|
from binary_ensemble import BendlDecoder, BendlEncoder
|
|
15
15
|
|
|
16
16
|
from .recorded_chain import (
|
|
17
|
+
EncodingVariant,
|
|
17
18
|
GraphOrder,
|
|
18
19
|
GraphOrderName,
|
|
19
20
|
RecordedChain,
|
|
21
|
+
RecordedChainIterator,
|
|
20
22
|
RecordedRun,
|
|
21
|
-
RunIterator,
|
|
22
|
-
Variant,
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
|
|
@@ -63,12 +63,12 @@ def read_geoparquet_asset(
|
|
|
63
63
|
__all__ = [
|
|
64
64
|
"BendlDecoder",
|
|
65
65
|
"BendlEncoder",
|
|
66
|
+
"EncodingVariant",
|
|
66
67
|
"GraphOrder",
|
|
67
68
|
"GraphOrderName",
|
|
68
69
|
"RecordedChain",
|
|
70
|
+
"RecordedChainIterator",
|
|
69
71
|
"RecordedRun",
|
|
70
|
-
"RunIterator",
|
|
71
72
|
"read_geoparquet_asset",
|
|
72
73
|
"read_parquet_asset",
|
|
73
|
-
"Variant",
|
|
74
74
|
]
|
|
@@ -37,7 +37,7 @@ from ._graph_prep import (
|
|
|
37
37
|
_source_graph,
|
|
38
38
|
)
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
EncodingVariant = Literal["standard", "mkv_chain", "twodelta"]
|
|
41
41
|
|
|
42
42
|
# Filesystems without hard-link support (exFAT, some network mounts) surface one of these.
|
|
43
43
|
_HARD_LINK_UNSUPPORTED_ERRNOS = frozenset(
|
|
@@ -45,7 +45,7 @@ _HARD_LINK_UNSUPPORTED_ERRNOS = frozenset(
|
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
class
|
|
48
|
+
class RecordedChainIterator(Iterator[Partition], Protocol):
|
|
49
49
|
"""Run iterator that, like a generator, can also be closed early."""
|
|
50
50
|
|
|
51
51
|
def close(self) -> None:
|
|
@@ -84,7 +84,7 @@ class _BendlTransaction:
|
|
|
84
84
|
graph_order: GraphOrder,
|
|
85
85
|
graph_order_key: str | None,
|
|
86
86
|
metadata: dict[str, Any] | list[Any] | None,
|
|
87
|
-
variant:
|
|
87
|
+
variant: EncodingVariant,
|
|
88
88
|
) -> None:
|
|
89
89
|
self._output_path = output_path
|
|
90
90
|
self._source_graph = source_graph
|
|
@@ -92,7 +92,7 @@ class _BendlTransaction:
|
|
|
92
92
|
self._graph_order: GraphOrder = graph_order
|
|
93
93
|
self._graph_order_key = graph_order_key
|
|
94
94
|
self._metadata = metadata
|
|
95
|
-
self._variant:
|
|
95
|
+
self._variant: EncodingVariant = variant
|
|
96
96
|
self.temporary_directory = Path(
|
|
97
97
|
tempfile.mkdtemp(prefix=f".{output_path.name}.", dir=output_path.parent)
|
|
98
98
|
)
|
|
@@ -616,7 +616,7 @@ class RecordedChain(MarkovChain):
|
|
|
616
616
|
"_variant",
|
|
617
617
|
)
|
|
618
618
|
_graph_order: GraphOrder
|
|
619
|
-
_variant:
|
|
619
|
+
_variant: EncodingVariant
|
|
620
620
|
|
|
621
621
|
def __init__(
|
|
622
622
|
self,
|
|
@@ -625,10 +625,10 @@ class RecordedChain(MarkovChain):
|
|
|
625
625
|
output_path: str | os.PathLike[str],
|
|
626
626
|
total_steps: int | None = None,
|
|
627
627
|
rng: Any = None,
|
|
628
|
-
graph_order: GraphOrder =
|
|
628
|
+
graph_order: GraphOrder = None,
|
|
629
629
|
graph_order_key: str | None = None,
|
|
630
630
|
metadata: dict[str, Any] | list[Any] | None = None,
|
|
631
|
-
variant:
|
|
631
|
+
variant: EncodingVariant = "twodelta",
|
|
632
632
|
) -> None:
|
|
633
633
|
"""Initialize a RecordedChain.
|
|
634
634
|
|
|
@@ -646,12 +646,12 @@ class RecordedChain(MarkovChain):
|
|
|
646
646
|
graph_order (GraphOrder): Node reordering applied before encoding: ``"mlc"`` (the
|
|
647
647
|
default), ``"rcm"``, ``"key"`` (sort by the ``graph_order_key`` node attribute),
|
|
648
648
|
or ``None`` to keep the input order. Reordering improves compression; the
|
|
649
|
-
permutation back to the source order is stored in the file.
|
|
649
|
+
permutation back to the source order is stored in the file. Defaults to None.
|
|
650
650
|
graph_order_key (str | None): Node attribute to sort by; required exactly when
|
|
651
651
|
``graph_order="key"``.
|
|
652
652
|
metadata (dict[str, Any] | list[Any] | None, optional): JSON-serializable metadata
|
|
653
653
|
embedded in the bundle. Defaults to None.
|
|
654
|
-
variant (
|
|
654
|
+
variant (EncodingVariant): Assignment-stream encoding: ``"twodelta"`` (the default),
|
|
655
655
|
``"mkv_chain"``, or ``"standard"``.
|
|
656
656
|
|
|
657
657
|
Raises:
|
|
@@ -664,7 +664,7 @@ class RecordedChain(MarkovChain):
|
|
|
664
664
|
raise ValueError("graph_order must be 'mlc', 'rcm', 'key', or None")
|
|
665
665
|
if (graph_order == "key") != (graph_order_key is not None):
|
|
666
666
|
raise ValueError("graph_order_key is required only when graph_order='key'")
|
|
667
|
-
if variant not in get_args(
|
|
667
|
+
if variant not in get_args(EncodingVariant):
|
|
668
668
|
raise ValueError("variant must be 'standard', 'mkv_chain', or 'twodelta'")
|
|
669
669
|
if metadata is not None and not isinstance(metadata, (dict, list)):
|
|
670
670
|
raise TypeError("metadata must be a dict, list, or None")
|
|
@@ -718,7 +718,7 @@ class RecordedChain(MarkovChain):
|
|
|
718
718
|
return copy.deepcopy(self._metadata)
|
|
719
719
|
|
|
720
720
|
@property
|
|
721
|
-
def variant(self) ->
|
|
721
|
+
def variant(self) -> EncodingVariant:
|
|
722
722
|
"""Assignment-stream encoding variant written by runs."""
|
|
723
723
|
return self._variant
|
|
724
724
|
|
|
@@ -742,20 +742,21 @@ class RecordedChain(MarkovChain):
|
|
|
742
742
|
raise RuntimeError("recording is unavailable before a successful recording")
|
|
743
743
|
return self._recording
|
|
744
744
|
|
|
745
|
-
def __iter__(self) ->
|
|
745
|
+
def __iter__(self) -> RecordedChainIterator:
|
|
746
746
|
"""Return the single-use run iterator; the destination file must not already exist."""
|
|
747
|
-
return cast(
|
|
747
|
+
return cast(RecordedChainIterator, self._record(overwrite=False))
|
|
748
748
|
|
|
749
|
-
def allow_overwrite(self) ->
|
|
749
|
+
def allow_overwrite(self) -> RecordedChainIterator:
|
|
750
750
|
"""Return one run iterator authorized to replace the destination file.
|
|
751
751
|
|
|
752
752
|
The replacement is atomic: the new recording is finalized in a temporary location and
|
|
753
753
|
moved over ``output_path`` only on clean completion.
|
|
754
754
|
|
|
755
755
|
Returns:
|
|
756
|
-
|
|
756
|
+
RecordedChainIterator: Single-use iterator that records the run and may replace the
|
|
757
|
+
output file.
|
|
757
758
|
"""
|
|
758
|
-
return cast(
|
|
759
|
+
return cast(RecordedChainIterator, self._record(overwrite=True))
|
|
759
760
|
|
|
760
761
|
def _publish_run(
|
|
761
762
|
self,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
try:
|
|
2
|
-
from .run_container import
|
|
2
|
+
from .run_container import RunnerConfig, RunnerSession, RunSpec, SupportsUpdaters
|
|
3
3
|
except ModuleNotFoundError as e:
|
|
4
4
|
if e.name and e.name.split(".")[0] == "docker":
|
|
5
5
|
raise ModuleNotFoundError(
|
|
@@ -9,30 +9,30 @@ except ModuleNotFoundError as e:
|
|
|
9
9
|
raise
|
|
10
10
|
from .constraints import Constraints
|
|
11
11
|
from .objectives import Objective
|
|
12
|
-
from .runners.forest import
|
|
12
|
+
from .runners.forest import ForestRunnerConfig, ForestRunSpec
|
|
13
13
|
from .runners.recom import (
|
|
14
|
-
|
|
15
|
-
RecomRunInfo,
|
|
14
|
+
OptimizerRunSpecBase,
|
|
16
15
|
RecomRunnerConfig,
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
RecomRunSpec,
|
|
17
|
+
ShortBurstsRunSpec,
|
|
18
|
+
TiltedRunSpec,
|
|
19
19
|
)
|
|
20
|
-
from .runners.smc import
|
|
20
|
+
from .runners.smc import SMCRunnerConfig, SMCRunSpec
|
|
21
21
|
|
|
22
22
|
__all__ = [
|
|
23
23
|
"Constraints",
|
|
24
24
|
"Objective",
|
|
25
25
|
"RecomRunnerConfig",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
26
|
+
"RecomRunSpec",
|
|
27
|
+
"OptimizerRunSpecBase",
|
|
28
|
+
"ShortBurstsRunSpec",
|
|
29
|
+
"TiltedRunSpec",
|
|
30
30
|
"ForestRunnerConfig",
|
|
31
|
-
"
|
|
31
|
+
"ForestRunSpec",
|
|
32
32
|
"SMCRunnerConfig",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"SMCRunSpec",
|
|
34
|
+
"RunnerSession",
|
|
35
35
|
"RunnerConfig",
|
|
36
|
-
"
|
|
36
|
+
"RunSpec",
|
|
37
37
|
"SupportsUpdaters",
|
|
38
38
|
]
|
|
@@ -306,7 +306,7 @@ class Constraints:
|
|
|
306
306
|
strength (float): Coefficient multiplying the penalty statistic.
|
|
307
307
|
group_pop_col (str): Map column containing the focal-group population.
|
|
308
308
|
total_pop_col (str | None, optional): Denominator population column. If ``None``,
|
|
309
|
-
``redist`` uses the population column supplied through ``
|
|
309
|
+
``redist`` uses the population column supplied through ``SMCRunSpec.pop_col``.
|
|
310
310
|
Defaults to None.
|
|
311
311
|
targets (Sequence[float], optional): Nonempty target-share sequence. Values should be
|
|
312
312
|
finite and in ``[0, 1]``. Defaults to ``(0.55,)``.
|
|
@@ -674,7 +674,7 @@ def validate_constraint_spec(value: object) -> ConstraintSpec:
|
|
|
674
674
|
return cast(ConstraintSpec, spec)
|
|
675
675
|
|
|
676
676
|
|
|
677
|
-
# Accepted constraint input forms for each
|
|
677
|
+
# Accepted constraint input forms for each RunSpec dataclass.
|
|
678
678
|
ConstraintsLike = Constraints | Sequence[ConstraintSpec] | ConstraintSpec | None
|
|
679
679
|
|
|
680
680
|
|
|
@@ -7,16 +7,16 @@ constructed without memorizing the JSON schema; each builder returns a plain dic
|
|
|
7
7
|
spec dicts remain interchangeable with builder output.
|
|
8
8
|
|
|
9
9
|
Every run needs exactly one objective, passed as the ``objective`` argument of
|
|
10
|
-
:class:`~gerrytools.mgrp.
|
|
10
|
+
:class:`~gerrytools.mgrp.ShortBurstsRunSpec` or :class:`~gerrytools.mgrp.TiltedRunSpec`. Whether
|
|
11
11
|
the optimizer drives the score up or down is controlled by the run's ``maximize`` flag, not by the
|
|
12
12
|
objective itself: for example, ``by_district_abs_deviation`` measures a distance and is normally
|
|
13
13
|
*minimized*, while ``gingles_partial`` counts districts and is normally *maximized*.
|
|
14
14
|
|
|
15
15
|
Example::
|
|
16
16
|
|
|
17
|
-
from gerrytools.mgrp import Objective,
|
|
17
|
+
from gerrytools.mgrp import Objective, ShortBurstsRunSpec
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
run_spec = ShortBurstsRunSpec(
|
|
20
20
|
pop_col="TOTPOP",
|
|
21
21
|
assignment_col="CD",
|
|
22
22
|
objective=Objective.gingles_partial(
|
|
@@ -155,7 +155,7 @@ class EngineRunConfig(TypedDict):
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
NOT_ENGINE_CONFIG = {"engine_config": False}
|
|
158
|
-
"""Field metadata excluding a run-
|
|
158
|
+
"""Field metadata excluding a run-spec field from the config's ``run`` section, either because
|
|
159
159
|
it is Python-side only (updaters, output naming) or because it is marshaled into another
|
|
160
160
|
section (``io``, ``map``, ``constraints``)."""
|
|
161
161
|
|