def test_beta_errors(self): skl = Sculptor(self.bt, self.mf, self.tree, 'Day', 'Host', 'unittest-beta-errors') self.to_delete.append('roc-curves/%s' % skl.name) skl.randomly_select(5) with self.assertRaisesRegex(ValueError, 'find one or more metrics'): skl.beta_table(metrics=['does_not_exist'])
def test_random_select_errors(self): obs = Sculptor(self.bt, self.mf, self.tree, 'Day', 'Host', 'random-select-errors') with self.assertRaisesRegex(ValueError, 'uniformly subsampled'): obs.alpha_table() with self.assertRaisesRegex(ValueError, 'uniformly subsampled'): obs.beta_table() with self.assertRaisesRegex(ValueError, 'uniformly subsampled'): obs.microbes_over_time()
def test_beta(self): skl = Sculptor(self.bt, self.mf, self.tree, 'Day', 'Host', 'unittest-test-beta') path = 'roc-curves/%s/cached-matrices/' % skl.name # avoid any unwanted accidents self.to_delete.append('roc-curves/%s/' % skl.name) np.random.seed(0) skl.randomly_select(5) obs = skl.beta_table(['unweighted_unifrac', 'jaccard']) data = [[ 0.3927777777777778, 0.4126532637086283, 0.9375, 0.12499999999999999 ], [0.6557886557886559, 0.1365522219610505, 1.0, 0.0]] columns = [ 'unweighted_unifrac_mean', 'unweighted_unifrac_std', 'jaccard_mean', 'jaccard_std' ] exp = pd.DataFrame(data=data, columns=columns, index=pd.Index(['A', 'B'], name='Host')) pd.util.testing.assert_frame_equal(obs, exp) self.assertTrue(os.path.exists(path)) self.assertTrue( os.path.exists(os.path.join(path, 'unweighted_unifrac.full.' 'txt'))) self.assertTrue(os.path.exists(os.path.join(path, 'jaccard.full.txt')))