Studies API: declarative spatial sweeps, remove JoblibBackend and hardcoded Merrill methods#56
Draft
endolith wants to merge 4 commits into
Draft
Studies API: declarative spatial sweeps, remove JoblibBackend and hardcoded Merrill methods#56endolith wants to merge 4 commits into
endolith wants to merge 4 commits into
Conversation
Introduce parameter expansion helpers (expand_product, expand_zip, expand_rows), serial and Joblib backends with map_repeat and map_each, run_batched and merge_counters, and Merrill-style Condorcet-efficiency tallies. Refactor three examples to use the new helpers, document the module in Sphinx, add tests, and include joblib in the test extra for CI. Co-authored-by: endolith <endolith@gmail.com>
Add social_utility helpers for Merrill/Weber-style utility totals. Refactor every batch-style example to use JoblibBackend (or studies metrics) instead of raw joblib, document the Hypothesis script as out of scope, and restore tabulate/elapsed output where tooling had stripped it. Co-authored-by: endolith <endolith@gmail.com>
Exercise social_utility branches, runner edge cases, parameter helpers, Serial/Joblib backend error paths (including simulated missing joblib), and Merrill Condorcet rated-method tallies. Use Optional[str] for UW tiebreaker annotation for Python 3.8. Co-authored-by: endolith <endolith@gmail.com>
Remove the hardcoded merrill_1984_comparison_methods factory and the thin JoblibBackend wrapper. Add approval_at_optimal for declarative rated-method maps, plus accumulate_spatial_condorcet_by_ncands and accumulate_spatial_sue_by_ncands for the shared Merrill-style nested loops. Merrill spatial examples now declare n_voters, n_cands_list, corr, disp, and method dicts, then call one accumulator per figure. Examples that only needed parallelism use joblib.Parallel again. Restore narrower docstring tables in merrill_1984_fig_4a_4b. Simplify merrill_1984_fig_2a_2b to a plain dispersion loop. Co-authored-by: endolith <endolith@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56 +/- ##
==========================================
+ Coverage 96.31% 97.12% +0.80%
==========================================
Files 19 26 +7
Lines 489 661 +172
==========================================
+ Hits 471 642 +171
- Misses 18 19 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This addresses feedback that
JoblibBackendonly wrappedjoblibwithout shortening scripts, thatmerrill_1984_comparison_methodshardcoded a method set callers should own, and that Merrill-style examples should read as declarative scenario + method maps + one aggregation call.Changes
merrill_1984_comparison_methodsandJoblibBackend(examples usejoblib.Parallel/delayeddirectly again;SerialBackendremains forrun_batched).approval_at_optimalincondorcet_metricsso rated-method dicts avoid repeating lambdas without shipping a full comparison preset.elsim.studies.spatial_normal:accumulate_spatial_condorcet_by_ncands— one call replaces the nestedn_elections×n_cands_list× draw ×tally_condorcet_agreementloop for spatial normal electorates (figures 2.c / 2.d pattern).accumulate_spatial_sue_by_ncands— same for social-utility totals + random reference (figures 4.a / 4.b pattern).merrill_1984_fig_4a_4b.pydocstring (matches the pre-refactor column widths).merrill_1984_fig_2a_2b.pytofor disp in (0.5, 1.0):instead ofexpand_productfor a single axis.ranked_methods/rated_methodslocally withapproval_at_optimal.Tests
tests/test_studies.py(removed backend-specific tests; added coverage for the new accumulators andapproval_at_optimal).Branch:
cursor/declarative-spatial-studies-44e5.