Add elsim.studies API and migrate Monte Carlo examples (#10)#52
Draft
endolith wants to merge 3 commits into
Draft
Add elsim.studies API and migrate Monte Carlo examples (#10)#52endolith wants to merge 3 commits into
elsim.studies API and migrate Monte Carlo examples (#10)#52endolith wants to merge 3 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>
elsim.studies API for Monte Carlo example scripts (closes #10)elsim.studies API for Monte Carlo example scripts (#10)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #52 +/- ##
==========================================
+ Coverage 96.31% 97.09% +0.77%
==========================================
Files 19 25 +6
Lines 489 654 +165
==========================================
+ Hits 471 635 +164
- 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:
|
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>
elsim.studies API for Monte Carlo example scripts (#10)elsim.studies API and migrate Monte Carlo examples (#10)
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>
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 PR addresses issue #10 with a new
elsim.studiessubpackage and refactors all Monte Carlo–style examples to use it.elsim.studies(building blocks)expand_product,expand_zip,expand_rows— explicit Cartesian vs zipped vs fixed scenario rows.SerialBackend/JoblibBackendwithmap_repeatandmap_each(forfunctools.partialjob lists).run_batched,merge_counters.merrill_1984_comparison_methods,tally_condorcet_agreement.spatial_random_reference_utility_updates,random_society_utility_updates,ranked_rated_utility_updates— shared per-election float totals for Merrill / Weber scripts.hypothesis_election_finder.pyis documented as Hypothesis-based search, not batched Monte Carlo, so it intentionally does not importstudies.weber_1977_expressions.pystays analytical only.Examples
Parallel examples now use
JoblibBackendinstead ofjoblib.Parallel/delayeddirectly. Merrill / Weber loops use the tallies above where they match prior logic (includingutility_winner(utilities)without tiebreaker for Weber effectiveness / Merrill Table 3 UW).Tests
tests/test_studies.pycovers expansion, backends, batching, Condorcet tallies, and the new social-utility helpers.Other
joblibadded to thetestoptional extra so CI exercisesJoblibBackend.elsim.studies.