Skip to content

Commit 8091610

Browse files
authored
Add random_groups example (#7)
* create_random_teams example * Run create_random_teams example in integration test (and validate test works)
1 parent 3ef2bd2 commit 8091610

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ on:
66
paths:
77
- 'balanced_group_system/**'
88
- 'tests/**'
9+
- 'examples/**'
910
pull_request:
1011
branches:
1112
- main
1213
paths:
1314
- 'balanced_group_system/**'
1415
- 'tests/**'
16+
- 'examples/**'
1517

1618
jobs:
1719
unit_tests:
@@ -35,3 +37,14 @@ jobs:
3537
- name: Run tests with pytest
3638
run: |
3739
poetry run pytest
40+
41+
integration_tests:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: Install dependencies
46+
run: |
47+
pip3 install -r examples/create_random_teams/requirements.txt
48+
- name: Run create_random_teams example
49+
run: |
50+
cd examples/create_random_teams && python3 main.py
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from balanced_group_system import BalancedGroupSystem
2+
import csv
3+
4+
if __name__ == '__main__':
5+
with open('participants.csv', 'r') as f:
6+
reader = csv.reader(f)
7+
next(reader) # Skip header
8+
members = [row[0] for row in reader]
9+
10+
N = 20
11+
12+
for i in range(1, N):
13+
group_system = BalancedGroupSystem(members)
14+
groups = group_system.create_balanced_groups(N)
15+
print(f"N = {i}:")
16+
for j, g in enumerate(groups):
17+
print(f" Group {j+1}: {g}")
18+
for g in groups:
19+
assert abs(len(g) - len(members)//N) <= 1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Name,Email,Number
2+
Alice,alice@example.com,12345667890
3+
Bob,bob@example.com,12345667890
4+
Charlie,charlie@example.com,12345667890
5+
Daniel,daniel@example.com,12345667890
6+
Eve,eve@example.com,12345667890
7+
Frank,frank@example.com,12345667890
8+
Grace,grace@example.com,12345667890
9+
Harold,harold@example.com,12345667890
10+
Ivy,ivy@example.com,12345667890
11+
Jack,jack@example.com,12345667890
12+
Kate,kate@example.com,12345667890
13+
Leo,leo@example.com,12345667890
14+
Martin,martin@example.com,12345667890
15+
Nancy,nancy@example.com,12345667890
16+
Oscar,oscar@example.com,12345667890
17+
Paul,paul@example.com,12345667890
18+
Quinn,quinn@example.com,12345667890
19+
Rachel,rachel@example.com,12345667890
20+
Sam,sam@example.com,12345667890
21+
Tessa,tessa@example.com,12345667890
22+
Ursula,ursula@example.com,12345667890
23+
Victor,victor@example.com,12345667890
24+
Wendy,wendy@example.com,12345667890
25+
Xavier,xavier@example.com,12345667890
26+
Yvonne,yvonne@example.com,12345667890
27+
Zack,zack@example.com,12345667890
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
balanced-group-system

0 commit comments

Comments
 (0)