def test_single_random_variable(self): frame = model_frame("~ 1 | Subject", self.data) assert frame.response is None assert frame.coef_model_matrix.shape == (180, 1) assert frame.ranef_model_matrix.shape == ( 180, len(np.unique(self.data["Subject"])), )
def test_another_combination_of_variables(self): frame = model_frame("~ Days + (Days | Subject)", self.data) assert frame.response is None assert frame.coef_model_matrix.shape == (180, 2) assert frame.ranef_model_matrix.shape == ( 180, 2 * len(np.unique(self.data["Subject"])), )
def test_final_combination_of_variables(self): frame = model_frame("~ (Days + Reaction | Subject)", self.data) assert frame.response is None assert frame.coef_model_matrix.shape == (180, 1) assert frame.ranef_model_matrix.shape == ( 180, 3 * len(np.unique(self.data["Subject"])), )
def test_full_formula(self): frame = model_frame("Reaction ~ Days + (Days | Subject)", self.data) assert frame.response.shape == (180,) assert len(frame.ranef_list) == 1 assert frame.coef_model_matrix.shape == (180, 2) assert frame.ranef_model_matrix.shape == ( 180, 2 * len(np.unique(self.data["Subject"])), )
def test_single_fixed_variable(self): frame = model_frame("~ Days", self.data) assert frame.response is None assert frame.ranef_list is None assert frame.ranef_model_matrix is None assert frame.coef_model_matrix.shape == (180, 2)
def test_bad_response(self): with pytest.raises(ValueError): model_frame("x ~ ", self.data)
def test_bad_formula_3(self): with pytest.raises(ValueError): model_frame("~ Subject ++ Days", self.data)
def test_bad_formula(self): with pytest.raises(ValueError): model_frame("~ Days + Reaction | Subject", self.data)
def test_response(self): frame = model_frame("Reaction ~ ", self.data) assert frame.response.shape == (180,) assert frame.coef_model_matrix is None assert frame.ranef_model_matrix is None