def test_empty_equals_split_subset(self): sar_empty = emp.sar(self.pat1, self.cols1, "", '1,1') sar_split = emp.sar(self.pat1, self.cols1, "x:1; y:1", '1,1') print sar_empty print sar_split assert_frame_equal(sar_empty[0][1].sort(axis=1), sar_split[0][1].sort(axis=1))
def test_with_split(self): sar = emp.sar(self.pat1, self.cols1, 'year:split', '2,1;1,3', ear=True) assert_array_equal(sar[0][1]['y'], [0.5, 0]) assert_array_equal(sar[1][1]['y'], [0.5, 1/3.])
def test_no_splits(self): sar = emp.sar(self.pat1, self.cols1, None, '1,1; 2,1; 2,3', ear=True) assert_array_equal(sar[0][1]['y'], [2, 0.5, 0])
def test_single_division(self): sar = emp.sar(self.pat1, self.cols1, None, '2,1') assert_array_almost_equal(sar[0][1]['x'], [0.5*self.A1]) assert_array_equal(sar[0][1]['y'], [1.5])
def test_with_split(self): sar = emp.sar(self.pat1, self.cols1, 'year:split', '2,1; 1,3') assert_array_almost_equal(sar[0][1]['x'], [0.5*self.A1, 1/3.*self.A1]) assert_array_almost_equal(sar[1][1]['x'], [0.5*self.A1, 1/3.*self.A1]) assert_array_equal(sar[0][1]['y'], [0.5, 2/3.]) assert_array_equal(sar[1][1]['y'], [3/2., 1])
def test_no_splits(self): sar = emp.sar(self.pat1, self.cols1, None, '1,1; 2,1; 2,3') assert_array_almost_equal(sar[0][1]['x'], [1*self.A1, 0.5*self.A1, 1/6*self.A1]) assert_array_equal(sar[0][1]['y'], [2, 1.5, (1+2+1+0+0+1)/6.])