class MoransITests(TestCase): """Tests for the MoransI class.""" def setUp(self): """Define some sample data that will be used by the tests.""" self.inst = MoransI() self.morans_i_results_str1 = morans_i_results_str1.split('\n') self.morans_i_results_str2 = morans_i_results_str2.split('\n') def test_parse(self): """Test parsing moran's i results file.""" obs = self.inst.parse(self.morans_i_results_str1) self.assertFloatEqual(obs, (-0.06005486, 4.442088e-05)) def test_parse_invalid_p_value(self): """Test parsing moran's i results file with invalid p-value.""" # Moran's I will sometimes calculate a p-value of 2.0. From looking at # the R code, it seems like this is a bug, and that the p-value should # be 1.0. obs = self.inst.parse(self.morans_i_results_str2) self.assertFloatEqual(obs, (-0.25, 1.0))
def setUp(self): """Define some sample data that will be used by the tests.""" self.inst = MoransI() self.morans_i_results_str1 = morans_i_results_str1.split('\n') self.morans_i_results_str2 = morans_i_results_str2.split('\n')