class TestReturns(object): """ Class for testing correct parameters are returned from firststage""" def __init__(self): self.opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1, 'verbose': 1} self.bbl = BBL(self.opts['tables'], self.opts['reaction'], self.opts['entrance'], self.opts['verbose']) self.bbl._firststage() self.fs_params = self.bbl.fs_params def test_demand(self): tvars = [ 'tuition_hat', 'MedianLSAT', 'UndergraduatemedianGPA', 'OverallRank', 'treat', 'RankTreat', 'AL', 'AR', 'WY' ] expected = np.array([ -0.927284, 19.286605, -203.475186, -1.167404, -22.917197, 0.354199, -1749.431023, -1799.828207, -1875.056317 ]) print("Actual") print(self.fs_params['demand'][tvars]) assert np.allclose(self.fs_params['demand'][tvars], expected) def test_react(self): pass def test_entry(self): pass def test_rank(self): pass
def __init__(self): opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1, 'verbose': 1} bbl = BBL(opts) data = bbl.data bbl._firststage() self.fs_params = bbl.fs_params path = dirname(dirname(dirname(__file__))) path = join(path, 'Results', 'SecondStage', 'SSEst.npy') ss_params = np.load(path) self.countersim = lps.CounterfactualSim(data, self.fs_params, ss_params, opts)
class Second(object): """ Base class for testing Second Stage classes/methods """ def __init__(self): self.opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1, 'verbose': 1} self.bbl = BBL(self.opts) self.data = self.bbl.data self.fs_params = self.first_stage() self.sim = ss.Simulation( fs_params=self.fs_params, ss_params=[], constants={'n_periods': 2, 'n_sims': 2}, opts=self.opts ) def first_stage(self): """ Get first-stage coefficients """ self.bbl._firststage() return self.bbl.fs_params