def test_munge_metadata_missing_samples(self): md = qiime2.CategoricalMetadataColumn( pd.Series(['milo', 'russ'], name='pet', index=pd.Index(['S1', 'S3'], name='id'))) with self.assertRaisesRegex(ValueError, 'not present.*S2'): _munge_metadata(md, self.table, 'both')
def test_munge_metadata_empty_values(self): md = qiime2.CategoricalMetadataColumn( pd.Series([None, 'russ', np.nan], name='pet', index=pd.Index(['S1', 'S2', 'S3'], name='id'))) obs = _munge_metadata(md, self.table, 'both') exp_idx = pd.Index(['[No Value] | S1', 'russ | S2', '[No Value] | S3'], name='pet | id') exp = pd.DataFrame([[0, 10], [10, 12], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_sort_samples(self): md = qiime2.CategoricalMetadataColumn( pd.Series(['peanut', 'milo', 'russ'], name='pet', index=pd.Index(['S1', 'S2', 'S3'], name='id'))) obs = _munge_metadata(md, self.table, 'features') exp_idx = pd.Index(['milo | S2', 'peanut | S1', 'russ | S3'], name='pet | id') exp = pd.DataFrame([[10, 12], [0, 10], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_sort_samples(self): md = qiime2.CategoricalMetadataColumn( pd.Series(['peanut', 'milo', 'russ'], name='pet', index=pd.Index(['S1', 'S2', 'S3'], name='id'))) obs = _munge_metadata(md, self.table, 'features') exp_idx = pd.Index(['milo | S2', 'peanut | S1', 'russ | S3'], name='pet | id') exp = pd.DataFrame([[10, 12], [0, 10], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_ids_different_order(self): md = qiime2.CategoricalMetadataColumn( pd.Series(['russ', 'milo', 'russ'], name='pet', index=pd.Index(['S2', 'S1', 'S3'], name='id'))) obs = _munge_metadata(md, self.table, 'both') exp_idx = pd.Index(['milo | S1', 'russ | S2', 'russ | S3'], name='pet | id') exp = pd.DataFrame([[0, 10], [10, 12], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_empty_values(self): md = qiime2.CategoricalMetadataColumn( pd.Series([None, 'russ', np.nan], name='pet', index=pd.Index(['S1', 'S2', 'S3'], name='id'))) obs = _munge_metadata(md, self.table, 'both') exp_idx = pd.Index(['[No Value] | S1', 'russ | S2', '[No Value] | S3'], name='pet | id') exp = pd.DataFrame([[0, 10], [10, 12], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_ids_different_order(self): md = qiime2.CategoricalMetadataColumn( pd.Series(['russ', 'milo', 'russ'], name='pet', index=pd.Index(['S2', 'S1', 'S3'], name='id'))) obs = _munge_metadata(md, self.table, 'both') exp_idx = pd.Index(['milo | S1', 'russ | S2', 'russ | S3'], name='pet | id') exp = pd.DataFrame([[0, 10], [10, 12], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_simple(self): md = pd.Series(['milo', 'russ', 'russ'], name='pet', index=['S1', 'S2', 'S3']) obs = _munge_metadata(md, self.table, 'both') exp_idx = pd.Index(['milo | S1', 'russ | S2', 'russ | S3'], name='pet | None') exp = pd.DataFrame([[0, 10], [10, 12], [10, 11]], columns=['O1', 'O2'], index=exp_idx) assert_frame_equal(exp, obs)
def test_munge_metadata_missing_samples(self): md = qiime2.CategoricalMetadataColumn( pd.Series(['milo', 'russ'], name='pet', index=pd.Index(['S1', 'S3'], name='id'))) with self.assertRaisesRegex(ValueError, 'not present.*S2'): _munge_metadata(md, self.table, 'both')
def test_munge_metadata_missing_samples(self): md = pd.Series(['milo', 'russ'], name='pet', index=['S1', 'S3']) with self.assertRaisesRegex(ValueError, 'Missing.*S2'): _munge_metadata(md, self.table, 'both')