Skip to content

Commit

Permalink
TST: regression test for issue #952
Browse files Browse the repository at this point in the history
  • Loading branch information
wasade committed May 2, 2024
1 parent 7182747 commit 48c1410
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Binary file added biom/tests/test_data/edgecase_issue_952.biom
Binary file not shown.
17 changes: 17 additions & 0 deletions biom/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,23 @@ def f(vals, id_, md):
with errstate(empty='raise'), self.assertRaises(TableException):
self.st_rich.filter(f, 'observation')

def test_subsample_edgecase_issue_952(self):
# this file triggers an exception on Linux on subsample
# with replacement where the pvals computed sum to > 1. It is a
# subset of the data reported in issue 952, specifically constrained
# to the first 10 features with any empty samples removed.
path = 'test_data/edgecase_issue_952.biom'

# ...existing logic for test_data, not ideal, but consistent
cwd = os.getcwd()
if '/' in __file__:
os.chdir(__file__.rsplit('/', 1)[0])
table = Table.from_hdf5(h5py.File(path, 'r'))
os.chdir(cwd)

obs = table.subsample(10, with_replacement=True)
self.assertEqual(set(obs.sum('sample')), {10.0, })

def test_subsample_same_seed_without_replacement(self):
table = Table(np.array([[3, 1, 2], [0, 3, 4]]), ['O1', 'O2'],
['S1', 'S2', 'S3'])
Expand Down

0 comments on commit 48c1410

Please sign in to comment.