Skip to content

Support command line arguments in sample_generator and fix spoil rate#162

Merged
keithrfung merged 2 commits intomainfrom
feature/parameterized-sample-generation
Sep 4, 2020
Merged

Support command line arguments in sample_generator and fix spoil rate#162
keithrfung merged 2 commits intomainfrom
feature/parameterized-sample-generation

Conversation

@rkorsak
Copy link
Copy Markdown
Contributor

@rkorsak rkorsak commented Sep 4, 2020

Issue

Fixes #161
Closes #160

Description

Adds arguments to the sample generator:

$ pipenv run python ./src/electionguardtest/sample_generator.py --help
usage: sample_generator.py [-h] [-n <count>] [-s <rate>] [-a]

Generate sample ballot data

optional arguments:
  -h, --help            show this help message and exit
  -n <count>, --number-of-ballots <count>
                        The number of ballots to generate. (default: 5)
  -s <rate>, --spoil-rate <rate>
                        The approximate percentage of total ballots to spoil instead of
                        cast. Provide a number from 0-100. (default: 50)
  -a, --all-guardians   If specified, all guardians will be included. Otherwise, only the
                        threshold number will be included. (default: False)

Optional arguments have also been added to the Makefile: SAMPLE_BALLOT_COUNT and SAMPLE_BALLOT_SPOIL_RATE. There's no argument for --all-guardians because we want to encourage decryption with a quorum.

This also fixes a bug with spoiling the generated ballots.

Testing

  • Verify all tests continue to pass
  • Verify that calling sample_generator.py with no arguments preserves the original behavior (5 ballots, 50% spoil rate, quorum # of guardians)
  • Verify that different parameters for -n, -s, and -a reflect the correct behavior

Checklist

🚨Please review the guidelines for contributing to this repository.

  • 🤔 CONSIDER adding a unit test if your PR resolves an issue.
  • DO check open PR's to avoid duplicates.
  • DO keep pull requests small so they can be easily reviewed.
  • DO build locally before pushing.
  • DO make sure tests pass.
  • DO make sure any new changes are documented.
  • DO make sure not to introduce any compiler warnings.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

💚Thank you!

Run `pipenv run ./src/electionguardtest/sample_generator.py --help` for more information.

This also fixes a bug with spoiling the generated ballots.  Because it was using a modulo operator when spoiling, only ~1% of the ballots would ever be spoiled, regardless of the desired amount.
AddressXception
AddressXception previously approved these changes Sep 4, 2020
@keithrfung keithrfung merged commit cf995e9 into main Sep 4, 2020
@keithrfung keithrfung deleted the feature/parameterized-sample-generation branch September 4, 2020 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spoil rate doesn't work in sample ballot generation Support command line arguments in sample ballot generation

3 participants