From 91c0d9a573dee19ca0e8c803d3db4a83d038bb96 Mon Sep 17 00:00:00 2001 From: Nick Frasser <1693461+nfrasser@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:09:42 -0400 Subject: [PATCH] fix: correct Dataset.descr() implementation Make sure exclude_uid param works --- cryosparc/dataset.py | 3 ++- tests/test_dataset.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cryosparc/dataset.py b/cryosparc/dataset.py index 185e42c3..86bbcd3b 100644 --- a/cryosparc/dataset.py +++ b/cryosparc/dataset.py @@ -932,7 +932,8 @@ def descr(self, exclude_uid=False) -> List[Field]: Returns: list[Field]: Fields """ - return [get_data_field(self._data, self._data.key(i)) for i in range(self._data.ncol())] + descr = [get_data_field(self._data, self._data.key(i)) for i in range(self._data.ncol())] + return [f for f in descr if f[0] != "uid"] if exclude_uid else descr def copy(self): """ diff --git a/tests/test_dataset.py b/tests/test_dataset.py index 68addbe7..8f713d38 100644 --- a/tests/test_dataset.py +++ b/tests/test_dataset.py @@ -62,6 +62,19 @@ def test_empty_data_constructor(): assert len(data.descr()) == 1 +def test_fields(): + data = Dataset.allocate(3, [("test1", "