diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 848593a..9676e57 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.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.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.13 , requirements: pinned , python-ver: "3.13", os: macos-latest } steps: - name: Checkout repo uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index a963ea9..a7026d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 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]])