mirror of
https://github.com/tgorordo/carousel.git
synced 2026-06-05 18:12:14 -07:00
prelim cli, working core
This commit is contained in:
parent
39c0ad1f7c
commit
f4fb70e23b
7 changed files with 464 additions and 181 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import polars as pl
|
||||
from polars.testing import assert_frame_equal
|
||||
from carousel import GS_deferred_acceptance
|
||||
from carousel import def_acc_GS
|
||||
|
||||
|
||||
def test_prefs():
|
||||
|
|
@ -68,8 +68,57 @@ def test_prefs():
|
|||
)
|
||||
|
||||
assert_frame_equal(
|
||||
GS_deferred_acceptance(
|
||||
people_prefs, fruit_prefs, capacities, app_col="people", pos_col="fruit"
|
||||
def_acc_GS(
|
||||
people_prefs,
|
||||
fruit_prefs,
|
||||
capacities,
|
||||
app_col="people",
|
||||
pos_col="fruit",
|
||||
by="preference",
|
||||
).sort(["people", "fruit"]),
|
||||
pl.DataFrame(
|
||||
{
|
||||
"people": ["Alice", "Bob", "Charlie"],
|
||||
"fruit": ["apple", "banana", "cherry"],
|
||||
}
|
||||
).sort(["people", "fruit"]),
|
||||
)
|
||||
|
||||
|
||||
def test_ranks():
|
||||
people_ranks = pl.DataFrame(
|
||||
{
|
||||
"people": ["Alice", "Bob", "Charlie"],
|
||||
"apple": [1, 3, 2],
|
||||
"banana": [2, 1, 3],
|
||||
"cherry": [3, 2, 1],
|
||||
}
|
||||
)
|
||||
|
||||
fruit_ranks = pl.DataFrame(
|
||||
{
|
||||
"fruit": ["apple", "banana", "cherry"],
|
||||
"Alice": [1, 1, 1],
|
||||
"Bob": [1, 1, 1],
|
||||
"Charlie": [1, 1, 1],
|
||||
}
|
||||
)
|
||||
|
||||
capacities = pl.DataFrame(
|
||||
{
|
||||
"fruit": ["apple", "cherry", "banana"],
|
||||
"capacity": [1, 1, 1], # have one of each
|
||||
}
|
||||
)
|
||||
|
||||
assert_frame_equal(
|
||||
def_acc_GS(
|
||||
people_ranks,
|
||||
fruit_ranks,
|
||||
capacities,
|
||||
app_col="people",
|
||||
pos_col="fruit",
|
||||
by="ranking",
|
||||
).sort(["people", "fruit"]),
|
||||
pl.DataFrame(
|
||||
{
|
||||
4
test/test_ap.csv
Normal file
4
test/test_ap.csv
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
applicant, pos1, pos2, pos3
|
||||
Alice, 1, 2, 3
|
||||
Bob, 2, 3, 1
|
||||
Charlie, 2, 1, 3
|
||||
|
4
test/test_pp.csv
Normal file
4
test/test_pp.csv
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
position, Alice, Bob, Charlie
|
||||
pos1, 3, 2, 1
|
||||
pos2, 2, 3, 1
|
||||
pos3, 3, 1, 2
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue