From f5e914b6b4428494d8cda9c596bcffe59219c4d3 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 22 Dec 2025 10:17:05 -0700 Subject: [PATCH 1/6] BUG: unable to parse non-trivial UTF-8 characters --- biom/tests/test_parse.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/biom/tests/test_parse.py b/biom/tests/test_parse.py index 1b310160..76d937a1 100644 --- a/biom/tests/test_parse.py +++ b/biom/tests/test_parse.py @@ -17,6 +17,7 @@ import numpy as np import numpy.testing as npt +from biom import example_table from biom.parse import (generatedby, MetadataMap, parse_biom_table, parse_uc, load_table, save_table) from biom.table import Table @@ -283,6 +284,15 @@ def test_parse_adjacency_table_no_header(self): obs = Table.from_adjacency(''.join(lines)) self.assertEqual(obs, exp) + def test_parse_biom_table_hdf5_accent_utf8_regression(self): + tab = example_table.copy() + tab.update_ids({i: f'{i}fóó' for i in tab.ids()}, inplace=True) + with NamedTemporaryFile(delete=False) as tmpfile: + with h5py.File(tmpfile.name, 'w') as fp: + tab.to_hdf5(fp, 'asf') + obs = load_table(tmpfile.name) + self.assertEqual(obs, tab) + def test_parse_biom_table_hdf5(self): """Make sure we can parse a HDF5 table through the same loader""" cwd = os.getcwd() From 14d9bf3e2843b82ee3040eb5d8457e9c9e0dd3b5 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 22 Dec 2025 10:22:27 -0700 Subject: [PATCH 2/6] BUG: use .asstr per h5py recommendations ('https://docs.h5py.org/en/latest/strings.html#reading-strings') --- biom/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biom/table.py b/biom/table.py index f8e8db98..692b86b3 100644 --- a/biom/table.py +++ b/biom/table.py @@ -4182,7 +4182,7 @@ def ensure_utf8(x): def axis_load(grp): """Loads all the data of the given group""" # fetch all of the IDs - ids = grp['ids'][:] + ids = grp['ids'].asstr()[:] if ids.size > 0: ids_dtype = 'U%d' % max([len(v) for v in ids]) From 0293f5f00ec14dac05dc56d1cf0c6196b64ebf00 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 22 Dec 2025 10:24:18 -0700 Subject: [PATCH 3/6] asstr does not handle an empty dataset --- biom/table.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/biom/table.py b/biom/table.py index 692b86b3..4468accc 100644 --- a/biom/table.py +++ b/biom/table.py @@ -4182,11 +4182,15 @@ def ensure_utf8(x): def axis_load(grp): """Loads all the data of the given group""" # fetch all of the IDs - ids = grp['ids'].asstr()[:] + ids = grp['ids'] if ids.size > 0: + ids = ids.asstr()[:] ids_dtype = 'U%d' % max([len(v) for v in ids]) ids = np.asarray(ids, dtype=ids_dtype) + else: + # .asstr does not handle an empty dataset + ids = ids[:] parser = defaultdict(lambda: general_parser) parser['taxonomy'] = vlen_list_of_str_parser From b5fcffb53854d1a90b5d06d26770229567cb4f38 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 22 Dec 2025 10:25:34 -0700 Subject: [PATCH 4/6] MAINT: in1d was deprecated in numpy switch to isin --- biom/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biom/table.py b/biom/table.py index 4468accc..9f352892 100644 --- a/biom/table.py +++ b/biom/table.py @@ -4238,7 +4238,7 @@ def _get_ids(source_ids, desired_ids): else: desired_ids = np.asarray(desired_ids) # Get the index of the source ids to include - idx = np.in1d(source_ids, desired_ids) + idx = np.isin(source_ids, desired_ids) # Retrieve only the ids that we are interested on ids = source_ids[idx] # Check that all desired ids have been found on source ids From 3fd33a0c94798e7b73708426a5424b0daa187062 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 22 Dec 2025 10:27:17 -0700 Subject: [PATCH 5/6] DOC: changelog mention --- ChangeLog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 139a97a0..8998957a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,13 @@ BIOM-Format ChangeLog ===================== +biom-2.1.18-dev +--------------- + +Bug fixes: + +* A regression with parse of UTF-8 characters was introduced, reported [here](https://forum.qiime2.org/t/feature-table-gives-ascii-codec-cant-decode-byte-0xc3-in-position-4-error/33858/7) + biom-2.1.17 ----------- From c53d283f0daf6a5a710aef1cc0bc0324e4efafe6 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 22 Dec 2025 10:42:02 -0700 Subject: [PATCH 6/6] macos-13 no longer supported --- .github/workflows/python-package-conda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml index dd38be0c..b31d8401 100644 --- a/.github/workflows/python-package-conda.yml +++ b/.github/workflows/python-package-conda.yml @@ -81,7 +81,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, macos-13] + os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, macos-15-intel] python_version: ${{ fromJSON(needs.conf.outputs.supported_pythons) }} use_conda: [true, false] steps: