Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An inplace update which fails will still modify IDs #892

Closed
wasade opened this issue Jan 20, 2023 · 0 comments · Fixed by #921
Closed

An inplace update which fails will still modify IDs #892

wasade opened this issue Jan 20, 2023 · 0 comments · Fixed by #921

Comments

@wasade
Copy link
Member

wasade commented Jan 20, 2023

See below, this is unexpected behavior and the inplace operation should be rolled back

In [11]: print(biom.example_table)
# Constructed from biom file
#OTU ID	S1	S2	S3
O1	0.0	1.0	2.0
O2	3.0	4.0	5.0

In [12]: biom.example_table.update_ids({i: 'foo' for i in biom.example_table.ids()},
    ...:                               inplace=True)
---------------------------------------------------------------------------
TableException                            Traceback (most recent call last)
Cell In[12], line 1
----> 1 biom.example_table.update_ids({i: 'foo' for i in biom.example_table.ids()},
      2                               inplace=True)

File ~/miniconda3/envs/qiime2-2022.11/lib/python3.8/site-packages/biom/table.py:1428, in Table.update_ids(self, id_map, axis, strict, inplace)
   1424 result._index_ids(None, None)
   1426 # check for errors (specifically, we want to esnsure that duplicate
   1427 # ids haven't been introduced)
-> 1428 errcheck(result)
   1430 return result

File ~/miniconda3/envs/qiime2-2022.11/lib/python3.8/site-packages/biom/err.py:474, in errcheck(table, *errtypes)
    472 ret = __errprof.test(table, *errtypes)
    473 if isinstance(ret, Exception):
--> 474     raise ret
    475 else:
    476     return ret

TableException: Duplicate sample IDs!

In [13]: print(biom.example_table)
# Constructed from biom file
#OTU ID	foo	foo	foo
O1	0.0	1.0	2.0
O2	3.0	4.0	5.0
wasade added a commit to wasade/biom-format that referenced this issue Apr 5, 2023
wasade added a commit to wasade/biom-format that referenced this issue Apr 5, 2023
@wasade wasade mentioned this issue Apr 5, 2023
wasade added a commit that referenced this issue May 2, 2023
* BUG/TST: regression test for #892

* BUG: fixes #892

* DOC: note bug fix in changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant