From 01094d92b38a0c5fe68c097f33524e698f5d3ace Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 12:01:24 -0800 Subject: [PATCH 1/8] Add column for storing visualization embeddings --- src/hdmf_ai/results_table.py | 32 +++++++++++++++++++++++++++ src/hdmf_ai/schema/results_table.yaml | 4 ++++ tests/test_results_table.py | 6 +++++ 3 files changed, 42 insertions(+) diff --git a/src/hdmf_ai/results_table.py b/src/hdmf_ai/results_table.py index 042f742..72f829f 100644 --- a/src/hdmf_ai/results_table.py +++ b/src/hdmf_ai/results_table.py @@ -454,3 +454,35 @@ def add_embedding(self, **kwargs): # `n_dims` kwarg is passed into `__add_col` and will be read as the length of the second dimension # of the data only if the `data` kwarg is None. return self.__add_col(EmbeddedValues, **kwargs) + + @docval( + { + "name": "data", + "type": ("array_data", "data"), + "doc": "Embedding (float) of each sample.", + "default": None, + }, + { + "name": "description", + "type": str, + "doc": "A description for this column.", + "default": "A column to store embeddings, e.g., from dimensionality reduction, for each sample.", + }, + { + "name": "n_dims", + "type": int, + "doc": ( + "The number of dimensions in the embedding, " + "used to define the shape of the column only if data is None" + ), + "default": None, + }, + ) + def add_viz_embedding(self, **kwargs): + """Add embedding (a.k.a. transformation or representation) of each sample.""" + kwargs["name"] = "viz_embedding" + kwargs["dtype"] = float + kwargs["dim2_kwarg"] = "n_dims" + # `n_dims` kwarg is passed into `__add_col` and will be read as the length of the second dimension + # of the data only if the `data` kwarg is None. + return self.__add_col(EmbeddedValues, **kwargs) diff --git a/src/hdmf_ai/schema/results_table.yaml b/src/hdmf_ai/schema/results_table.yaml index 2e6b859..9c3d135 100644 --- a/src/hdmf_ai/schema/results_table.yaml +++ b/src/hdmf_ai/schema/results_table.yaml @@ -185,4 +185,8 @@ groups: data_type_inc: EmbeddedValues doc: A column to store embeddings, e.g., from dimensionality reduction, for each sample. quantity: '?' + - name: viz_embedding + data_type_inc: EmbeddedValues + doc: A column to store embeddings meant for visualization. + quantity: '?' diff --git a/tests/test_results_table.py b/tests/test_results_table.py index a843eae..ed99d12 100644 --- a/tests/test_results_table.py +++ b/tests/test_results_table.py @@ -122,6 +122,12 @@ def test_add_embedding(self): with self.get_hdf5io() as io: io.write(rt) + def test_add_viz_embedding(self): + rt = ResultsTable(name="foo", description="a test results table") + rt.add_viz_embedding([[1.1, 2.9], [1.2, 2.8], [1.3, 2.7], [1.4, 2.6], [1.5, 2.5]]) + with self.get_hdf5io() as io: + io.write(rt) + def test_add_topk_classes(self): rt = ResultsTable(name="foo", description="a test results table") rt.add_topk_classes([[1, 2], [3, 4], [5, 6], [7, 8], [9, 0]]) From 360cc1ced9136e72978b01cc018815caecf2c1e0 Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 12:10:43 -0800 Subject: [PATCH 2/8] Update Python versions for test runner --- .github/workflows/run_tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 848593a..2c6c504 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -20,12 +20,12 @@ jobs: fail-fast: false matrix: include: - - { name: linux-python3.7-minimum , requirements: minimum, python-ver: "3.7" , os: ubuntu-latest } - - { name: linux-python3.12 , requirements: pinned , python-ver: "3.12", os: ubuntu-latest } - - { name: windows-python3.7-minimum , requirements: minimum, python-ver: "3.7" , os: windows-latest } - - { name: windows-python3.12 , requirements: pinned , python-ver: "3.12", os: windows-latest } - - { name: macos-python3.7-minimum , requirements: minimum, python-ver: "3.7" , os: macos-13 } - - { name: macos-python3.12 , requirements: pinned , python-ver: "3.12", os: macos-latest } + - { name: linux-python3.10-minimum , requirements: minimum, python-ver: "3.10", os: ubuntu-latest } + - { name: linux-python3.14 , requirements: pinned , python-ver: "3.14", os: ubuntu-latest } + - { name: windows-python3.10-minimum , requirements: minimum, python-ver: "3.10", os: windows-latest } + - { name: windows-python3.14 , requirements: pinned , python-ver: "3.14", os: windows-latest } + - { name: macos-python3.10-minimum , requirements: minimum, python-ver: "3.10", os: macos-13 } + - { name: macos-python3.14 , requirements: pinned , python-ver: "3.14", os: macos-latest } steps: - name: Checkout repo uses: actions/checkout@v4 From 91423e9109f1207228212641d293ff34bd0283d3 Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 14:08:27 -0800 Subject: [PATCH 3/8] lower python version --- .github/workflows/run_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 2c6c504..9676e57 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -21,11 +21,11 @@ jobs: matrix: include: - { name: linux-python3.10-minimum , requirements: minimum, python-ver: "3.10", os: ubuntu-latest } - - { name: linux-python3.14 , requirements: pinned , python-ver: "3.14", os: ubuntu-latest } + - { name: linux-python3.13 , requirements: pinned , python-ver: "3.13", os: ubuntu-latest } - { name: windows-python3.10-minimum , requirements: minimum, python-ver: "3.10", os: windows-latest } - - { name: windows-python3.14 , requirements: pinned , python-ver: "3.14", os: windows-latest } + - { name: windows-python3.13 , requirements: pinned , python-ver: "3.13", os: windows-latest } - { name: macos-python3.10-minimum , requirements: minimum, python-ver: "3.10", os: macos-13 } - - { name: macos-python3.14 , requirements: pinned , python-ver: "3.14", os: macos-latest } + - { name: macos-python3.13 , requirements: pinned , python-ver: "3.13", os: macos-latest } steps: - name: Checkout repo uses: actions/checkout@v4 From 717bdbb6d77966d9cb94c555d61e615141f469fa Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 14:20:35 -0800 Subject: [PATCH 4/8] bump minimum numpy version --- requirements-min.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-min.txt b/requirements-min.txt index 8c16de2..c3791ea 100644 --- a/requirements-min.txt +++ b/requirements-min.txt @@ -1,4 +1,4 @@ # minimum versions of package dependencies for installing HDMF-AI, used in testing hdmf==3.5.1 -numpy==1.21 +numpy==1.22 scikit-learn==1.0 From 3781261963a3377812cec06edb5a720021f53f73 Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 14:32:13 -0800 Subject: [PATCH 5/8] set minimum cython for build --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a963ea9..ba70e82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "cython>=3.0.10"] build-backend = "setuptools.build_meta" [project] @@ -44,7 +44,7 @@ dependencies = [ "numpy>=1.21", "scikit-learn>=1", ] -version = "0.2.0" +version = "0.3.0" # dynamic = ["version"] [project.urls] @@ -108,4 +108,4 @@ exclude = [ "example.py" = ["E501", "T201"] [tool.ruff.lint.mccabe] -max-complexity = 17 \ No newline at end of file +max-complexity = 17 From ca53198367c31e4e8ee4b047d3fe3b1175e2d4c0 Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 14:37:04 -0800 Subject: [PATCH 6/8] set maximum version requirement --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ba70e82..2c8e844 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "cython>=3.0.10"] +requires = ["setuptools>=45,<65", "setuptools_scm[toml]>=6.2", "cython>=3.0.10"] build-backend = "setuptools.build_meta" [project] From d305fab24dfa0636d5d6737fef16ec850227a91a Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 14:37:29 -0800 Subject: [PATCH 7/8] revert min numpy version change --- requirements-min.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-min.txt b/requirements-min.txt index c3791ea..8c16de2 100644 --- a/requirements-min.txt +++ b/requirements-min.txt @@ -1,4 +1,4 @@ # minimum versions of package dependencies for installing HDMF-AI, used in testing hdmf==3.5.1 -numpy==1.22 +numpy==1.21 scikit-learn==1.0 From d2556d1ab59e1c099f6dbe754989cb7f03a541ca Mon Sep 17 00:00:00 2001 From: ajtritt Date: Tue, 7 Jan 2025 14:52:27 -0800 Subject: [PATCH 8/8] roll back changes --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2c8e844..a7026d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=45,<65", "setuptools_scm[toml]>=6.2", "cython>=3.0.10"] +requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [project]