Skip to content

Commit

Permalink
Simple and not-very-stringent test of LCM estimation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiffyclub committed Apr 21, 2014
1 parent b1bb27b commit 0c3b19c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions urbansim/models/tests/test_lcm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pandas as pd
import pytest

from .. import LocationChoiceModel


@pytest.fixture
def choosers():
return pd.DataFrame(
{'var1': range(5, 10),
'thing_id': range(5)})


@pytest.fixture
def alternatives():
return pd.DataFrame(
{'var2': range(10, 20),
'var3': range(20, 30)},
index=range(10))


def test_lcm(choosers, alternatives):
lcm = LocationChoiceModel(
['var3 != 15'], ['var2 != 14'], 'var2 + var1:var3', 5,
name='Test LCM')
loglik = lcm.fit(choosers, alternatives, choosers.thing_id)

# hard to test things exactly because there's some randomness
# involved, but can at least do a smoke test.
assert len(loglik) == 3
assert len(lcm.fit_results) == 2

0 comments on commit 0c3b19c

Please sign in to comment.