Skip to content

Commit

Permalink
Merge pull request #45 from artoonie/upgrade-deps
Browse files Browse the repository at this point in the history
upgrade dependencies
  • Loading branch information
artoonie authored Jun 9, 2023
2 parents 6dc769e + a97e1f3 commit 3b79a01
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install nose pylint autopep8
pip install -r requirements-test.txt
pip install -r requirements.txt
- name: Unit tests with nose
run: |
Expand All @@ -31,14 +31,14 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install nose pylint autopep8
python -m pip install -r requirements-test.txt
pip install -r requirements.txt
- name: Lint with pylint
run: |
Expand All @@ -47,10 +47,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -62,10 +62,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -84,10 +84,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ except Exception as e:
In addition to data normalization for RCV Summary formats, we would like similar functionality for cast vote records.

## Running test suite
Run `python3 -m nose` in the root directory, and `./scripts/lint.sh` to run the linter.
`pip3 install -r requirements-test.txt`, then run `python3 -m nose` in the root directory, and `./scripts/lint.sh` to run the linter.
1 change: 1 addition & 0 deletions docs/source/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r ../../requirements.txt
-r ../../requirements-test.txt
m2r==0.2.1
mistune==0.8.4
docutils<0.19
9 changes: 5 additions & 4 deletions rcvformats/conversions/dominion_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from openpyxl.cell.read_only import EmptyCell, ReadOnlyCell

from rcvformats.conversions.base import GenericGuessAtTransferConverter
from rcvformats.schemas.base import DataError


class DominionXlsxConverter(GenericGuessAtTransferConverter):
Expand Down Expand Up @@ -91,7 +92,7 @@ def _count_num_header_rows(cls, sheet):
continue

return row
raise Exception("Could not find the end of the headers")
raise DataError("Could not find the end of the headers")

def _find_row_of_inactive_ballots(self, sheet, num_candidates):
"""
Expand All @@ -105,7 +106,7 @@ def _find_row_of_inactive_ballots(self, sheet, num_candidates):
for row in range(row + min_num_rows, row + max_num_rows):
if sheet.cell(row, 1).value == "Non Transferable Total":
return row
raise Exception("Could not find the end of the non-transferable rows")
raise DataError("Could not find the end of the non-transferable rows")

def _try_to_find_row_of_threshold(self, sheet, inactive_row):
"""
Expand Down Expand Up @@ -192,7 +193,7 @@ def _parse_rounds(self):

col += 1
if col >= max_cols:
raise Exception("This document is not in the correct format..."
raise DataError("This document is not in the correct format..."
"or there are more than 500 rounds")

# Is this a merged cell? If so, ignore it.
Expand Down Expand Up @@ -241,7 +242,7 @@ def _parse_candidates(self):
if candidate_name == end_of_candidates_marker:
break
if row == max_num_rows:
raise Exception("This document is not in the correct format..."
raise DataError("This document is not in the correct format..."
"or there are more than 500 candidates")
cell = self.sheet['A' + str(row)]
name = cell.value
Expand Down
4 changes: 2 additions & 2 deletions rcvformats/conversions/electionbuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _threshold_for_round(cls, rounds, round_i):
return rounds[round_i]['threshold']

last_round = rounds[-1]
num_voters_in_last_round = sum([v for k, v in last_round['candidates'].items()])
num_voters_in_last_round = sum(v for (k, v) in last_round['candidates'].items())
return num_voters_in_last_round / 2.0

@classmethod
Expand Down Expand Up @@ -109,5 +109,5 @@ def _get_threshold(cls, csv_data):
if last_round['threshold']:
return last_round['threshold']

num_voters_in_last_round = sum([v for k, v in last_round['candidates'].items()])
num_voters_in_last_round = sum(v for (k, v) in last_round['candidates'].items())
return num_voters_in_last_round / 2.0
3 changes: 1 addition & 2 deletions rcvformats/conversions/opavote.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def _convert_file_object_to_ut(self, file_object):
'round': round_i + 1,
'tally': {}
}
for candidate_i, _ in enumerate(candidate_names):
for candidate_i, name in enumerate(candidate_names):
votes = self._votes_on_round(candidate_i, rounds, round_i)
name = candidate_names[candidate_i]
ut_round['tally'][name] = votes
ut_rounds.append(ut_round)

Expand Down
3 changes: 3 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nose-py3==1.6.2
pylint==2.17.4
autopep8==1.5.7
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
jsonschema==3.2.0
pylint==2.11.1
openpyxl==3.0.9
defusedxml==0.7.1

0 comments on commit 3b79a01

Please sign in to comment.