Gerrychain

Latest version: v0.3.1

Safety actively analyzes 613734 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

0.3.1

This release is a small patch that improves the performance of our region-aware method and adds Python 3.12 support

What's Changed

- All spanning trees are now drawn with a minimum spanning tree instead of a maximum spanning tree (if you run old code with the same random seed, this means that you are likely to get different results since the trees will be different)
- Region-aware recom now looks for and deterministically selects for cut edges that bridge regions first before randomly selecting a cut edge.
- Python 3.12 is now officially supported by GerryChain.

Breaking Changes

- The API has changed the usage of `weight_dict` to `region_surcharge` across any instance where region-aware is called

Resolved Issues

- \407 Now, `bipartition_tree` has different behaviour when region-aware recom is used. This method also allows for pair reselection whereas the `biparition_tree_random` does not have any modifications for region-aware or pair reselection.

**Full Changelog**: https://github.com/mggg/GerryChain/compare/v0.3.0...v0.3.1

0.3.0

This release adds the capacity to run region-aware chains, makes some major updates to the documentation, and resolves quite a few of the long-standing issues on the repo.

What's Changed

- Major updates have been made to all of the documentation to try to make it

(i) More complete
(ii) More accessible for new Python users

- Bipartition Tree now has max_attempts default set to 100000 to prevent infinite loop conditions, but this value should also give plenty of time to sample sufficiently from the set of spanning trees.

- The `recom` method now has functionality for running region-aware chains which allow for the construction of ensembles of districting plans that try not to split a particular region or set of regions

- An updater `tally_region_splits` has been added to make quick tallying of the number of splits of a region type easy

- Many of the issue tickets have been resolved. See below for more info.

Deprecations

- Installation through conda-forge is no longer supported
- Python 3.8 is no longer supported due to deprecated support in dependencies
- We no longer support `gerrychain.random` for setting seeds. Instead, import the `random` module and set the random seed using `random.seed(<seed-number>)`

Resolved Issues

- \412 Resolved due to deprecation of conda-forge

- \409 Related to the following issue:

- \325 *SOME* Partition objects are pickle-able, but not all. Any partition that uses an updater defined in terms of a lambda function or which contains an inner function that uses nonlocal data will not be pickle-able, and we want to maintain this functionality. For those wishing to store an entire chain state, please see the [PCompress](https://github.com/mggg/pcompress) tool.

- \408 Resolved with deprecation of the conda-forge

- \364: The global random seed is no longer set in a custom random file. The user must now set the seed manually if they wish for their work to be reproducible.

- \319 is now fixed for recom. In `bipartition_tree` the user may now specify the parameter `allow_pair_reslection` as true or false. The default is false to maintain backward compatibility, but in the case where this parameter is set to true, an error is propagated back up to `recom` and a new pair is selected there. The selection of the new pair does not advance the chain. See the documentation for more information.

- \294 This is now a part of the "Good Data Practices" section of the documentation

- \288 `__repr__` methods have been added across the package

- \235 The MarkovChain class now has an alias `constraints` for the `is_valid` property that allows for the printing and editing of constraints. For example. one may print the constraints with the call `print(chain.constraints)` which will print something like `[<function single_flip_contiguous at 0x7f3d80f45b20>]`, and the constraints can be set with something like `chain.constraints = [contiguous]`. When set, the constraints are checked against the initial state of the chain. This improves the UX by making it so that you do not need to reinitialize a full MarkovChain object to experiment with different constraints.

- \279 This has been partially addressed in the documentation update and the remaining reference materials for how to plot data are left to the documentation of [matplotlib](https://matplotlib.org/) and [seaborn](https://seaborn.pydata.org/)

- \44 This is now a part of the documentation.

**Full Changelog**: https://github.com/mggg/GerryChain/compare/v0.2.22...v0.3.0

0.2.22

Changes:
* Adds support for Shapely 2.0 (405)
* Adds some type annotations to key functions (377)
* Fixes the use of `node_repeats` in `_bipartitions_tree_random_all` (406)
* Adds updaters for sample diversity statistics (400)
* Fixes a bug in `uniform_spanning_tree` (401)

0.2.20

This release contains some bug fixes that were reported for the v0.2.19 release.

What's Changed
* Remove duplicate frozen call in FrozenGraph by InnovativeInventor in https://github.com/mggg/GerryChain/pull/393
* Fix default updaters bug in GeographicPartition by InnovativeInventor in https://github.com/mggg/GerryChain/pull/391


**Full Changelog**: https://github.com/mggg/GerryChain/compare/v0.2.19...v0.2.20

0.2.19

This release adds faster scoring/replaying of chains, as well as storing of CRS information in dual graphs. This is planned to be the last `v0.2` release; the next release will be `v0.3` and will contain massive speedups (15-16x) in chain run times.

If you use GerryChain, you may be interested in [`plan-evaluation-processing`](https://github.com/mggg/plan-evaluation-processing) ([docs](https://mggg.github.io/plan-evaluation-processing/)), our production-tested plan evaluation tools that we use for our public reports and litigation work. In the future, this may be packaged as a submodule in GerryChain itself.

Cheers!

What's Changed
* Use __slots__ in Partition by pjrule in https://github.com/mggg/GerryChain/pull/363
* Add seed and freeze test to loudly detect when breaking changes are made by InnovativeInventor in https://github.com/mggg/GerryChain/pull/378
* Add neighborhood flips caching by InnovativeInventor in https://github.com/mggg/GerryChain/pull/373
* More __slots__ by InnovativeInventor in https://github.com/mggg/GerryChain/pull/374
* Add option to disable cut_edges updater with use_cut_edges flag by InnovativeInventor in https://github.com/mggg/GerryChain/pull/375
* Replace references to assignment[node] to assignment.mapping[node] to reduce __getitem__ overhead by InnovativeInventor in https://github.com/mggg/GerryChain/pull/382
* Refactor out Assignment.update (replace with Assignment.update_flows) to prevent double-calculating flows by InnovativeInventor in https://github.com/mggg/GerryChain/pull/383
* Cache flow_from_changes by InnovativeInventor in https://github.com/mggg/GerryChain/pull/384
* Simplify Assignment iterators by InnovativeInventor in https://github.com/mggg/GerryChain/pull/385
* Frozen graph implementation! by InnovativeInventor in https://github.com/mggg/GerryChain/pull/386
* Add projection information to serialized dual graph. by jenni-niels in https://github.com/mggg/GerryChain/pull/388

New Contributors
* jenni-niels made their first contribution in https://github.com/mggg/GerryChain/pull/388

**Full Changelog**: https://github.com/mggg/GerryChain/compare/0.2.18...v0.2.19

0.2.17

Same as last release, but with the citation removed because it seems to have been causing issues with twine.

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.