From 6102c35d96ebf169111e010e1ef89cb7a3e42564 Mon Sep 17 00:00:00 2001 From: Florian Huber <36473328+florian-huber@users.noreply.github.com> Date: Fri, 6 Jan 2023 10:47:41 +0100 Subject: [PATCH 1/7] Move to matchms >=0.18.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d0a4170..69d3f3d 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ python_requires='>=3.7', install_requires=[ "gensim >=4.2.0", - "matchms >=0.11.0", + "matchms >=0.18.0", "numba >=0.51", "numpy", "scipy", From 7a743c37b8fa081475d0a1bc2b61a8388fdd248a Mon Sep 17 00:00:00 2001 From: florian-huber Date: Fri, 6 Jan 2023 14:52:56 +0100 Subject: [PATCH 2/7] update arguments and tests --- .../test_user_workflow_spec2vec.py | 26 ++++++++++--------- spec2vec/Spec2Vec.py | 5 ++++ spec2vec/serialization/model_importing.py | 5 +++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/integration-tests/test_user_workflow_spec2vec.py b/integration-tests/test_user_workflow_spec2vec.py index a505c84..6012eeb 100644 --- a/integration-tests/test_user_workflow_spec2vec.py +++ b/integration-tests/test_user_workflow_spec2vec.py @@ -1,6 +1,6 @@ import os import gensim -import pytest +import numpy as np from matchms import calculate_scores from matchms.filtering import (add_losses, add_parent_mass, default_filters, normalize_intensities, @@ -68,16 +68,18 @@ def apply_my_filters(s): actual_top10 = sorted_by_score[:10] expected_top10 = [ - (documents[19], documents[25], pytest.approx(0.9999121928249473, rel=1e-9)), - (documents[20], documents[25], pytest.approx(0.9998846890269892, rel=1e-9)), - (documents[20], documents[45], pytest.approx(0.9998756073673759, rel=1e-9)), - (documents[25], documents[45], pytest.approx(0.9998750427994474, rel=1e-9)), - (documents[19], documents[27], pytest.approx(0.9998722768460854, rel=1e-9)), - (documents[22], documents[27], pytest.approx(0.9998633023352553, rel=1e-9)), - (documents[18], documents[27], pytest.approx(0.9998616961532616, rel=1e-9)), - (documents[19], documents[45], pytest.approx(0.9998528723697396, rel=1e-9)), - (documents[14], documents[71], pytest.approx(0.9998404364805897, rel=1e-9)), - (documents[20], documents[27], pytest.approx(0.9998336807761137, rel=1e-9)) + (documents[19], documents[25], 0.9999121928249473), + (documents[20], documents[25], 0.9998846890269892), + (documents[20], documents[45], 0.9998756073673759), + (documents[25], documents[45], 0.9998750427994474), + (documents[19], documents[27], 0.9998722768460854), + (documents[22], documents[27], 0.9998633023352553), + (documents[18], documents[27], 0.9998616961532616), + (documents[19], documents[45], 0.9998528723697396), + (documents[14], documents[71], 0.9998404364805897), + (documents[20], documents[27], 0.9998336807761137) ] - assert actual_top10 == expected_top10, "Expected different top 10 table." + assert [x[0] for x in actual_top10] == [x[0] for x in expected_top10] + assert [x[1] for x in actual_top10] == [x[1] for x in expected_top10] + assert np.allclose([x[2][0] for x in actual_top10], [x[2] for x in expected_top10]), "Expected different top 10 table." diff --git a/spec2vec/Spec2Vec.py b/spec2vec/Spec2Vec.py index db96447..cf009c9 100644 --- a/spec2vec/Spec2Vec.py +++ b/spec2vec/Spec2Vec.py @@ -134,6 +134,7 @@ def pair(self, reference: Union[SpectrumDocument, Spectrum], def matrix(self, references: Union[List[SpectrumDocument], List[Spectrum]], queries: Union[List[SpectrumDocument], List[Spectrum]], + array_type: str = "numpy", is_symmetric: bool = False) -> np.ndarray: """Calculate the spec2vec similarities between all references and queries. @@ -143,6 +144,10 @@ def matrix(self, references: Union[List[SpectrumDocument], List[Spectrum]], Reference spectrums or spectrum documents. queries: Query spectrums or spectrum documents. + array_type + Specify the output array type. Can be "numpy" or "sparse". + Currently, only "numpy" is supported and will return a numpy array. + Future versions will include "sparse" as option to return a COO-sparse array. is_symmetric: Set to True if references == queries to speed up calculation about 2x. Uses the fact that in this case score[i, j] = score[j, i]. Default is False. diff --git a/spec2vec/serialization/model_importing.py b/spec2vec/serialization/model_importing.py index 1e03d1f..8459ad3 100644 --- a/spec2vec/serialization/model_importing.py +++ b/spec2vec/serialization/model_importing.py @@ -38,9 +38,12 @@ def build(self) -> KeyedVectors: def from_dict(self, dictionary: dict): expected_keys = {"vector_size", "__numpys", "__scipys", "__ignoreds", "__recursive_saveloads", - "index_to_key", "norms", "key_to_index", "next_index", "__weights_format"} + "index_to_key", "norms", "key_to_index", "__weights_format"} if dictionary.keys() == expected_keys: self.__dict__ = dictionary + elif expected_keys.symmetric_difference(dictionary.keys()) == {"next_index"}: # backward compatibility + dictionary.pop("next_index") + self.__dict__ = dictionary else: raise ValueError("The keys of model's dictionary representation do not match the expected keys.") return self From 75ffc08a487d43ea610a00892fb5eed05492f5ba Mon Sep 17 00:00:00 2001 From: Florian Huber <36473328+florian-huber@users.noreply.github.com> Date: Fri, 6 Jan 2023 15:02:46 +0100 Subject: [PATCH 3/7] check compatibility --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 69d3f3d..fec7886 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ python_requires='>=3.7', install_requires=[ "gensim >=4.2.0", - "matchms >=0.18.0", + "matchms >=0.14.0, <0.18.0", "numba >=0.51", "numpy", "scipy", From c866318314a43a844312691d9b4a9f4c1e4e083c Mon Sep 17 00:00:00 2001 From: Florian Huber <36473328+florian-huber@users.noreply.github.com> Date: Fri, 6 Jan 2023 15:08:18 +0100 Subject: [PATCH 4/7] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fec7886..c5da5f5 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ python_requires='>=3.7', install_requires=[ "gensim >=4.2.0", - "matchms >=0.14.0, <0.18.0", + "matchms >=0.14.0", "numba >=0.51", "numpy", "scipy", From dd3aea5ceae189a6f0c910b5e78e29c66b742e17 Mon Sep 17 00:00:00 2001 From: florian-huber Date: Fri, 6 Jan 2023 15:54:12 +0100 Subject: [PATCH 5/7] update to 0.8.0 --- CHANGELOG.md | 10 +++++++++- setup.cfg | 2 +- spec2vec/__version__.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9104972..276c26b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0] - 2022-01-06 + +### Changed + +- Minor changes to make tests pass with new matchms versions (>=0.18.0). Should nearly always be backwards compatible though. +- Now dependency requirement is set to `matchms>=0.14.0` + ## [0.7.0] - 2022-10-01 ### Added @@ -135,7 +142,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fossa configuration - Flowchart -[Unreleased]: https://github.com/iomega/spec2vec/compare/0.7.0...HEAD +[Unreleased]: https://github.com/iomega/spec2vec/compare/0.8.0...HEAD +[0.8.0]: https://github.com/iomega/spec2vec/compare/0.6.0...0.7.0 [0.7.0]: https://github.com/iomega/spec2vec/compare/0.6.0...0.7.0 [0.6.0]: https://github.com/iomega/spec2vec/compare/0.5.0...0.6.0 [0.5.0]: https://github.com/iomega/spec2vec/compare/0.4.0...0.5.0 diff --git a/setup.cfg b/setup.cfg index 2e6ea60..9ed1c30 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.7.0 +current_version = 0.8.0 [bumpversion:file:conda/meta.yaml] search = set version = "{current_version}" diff --git a/spec2vec/__version__.py b/spec2vec/__version__.py index a71c5c7..32a90a3 100644 --- a/spec2vec/__version__.py +++ b/spec2vec/__version__.py @@ -1 +1 @@ -__version__ = '0.7.0' +__version__ = '0.8.0' From c1fe3985bdd88d6b44eed74f94cd130fd5dab4aa Mon Sep 17 00:00:00 2001 From: florian-huber Date: Fri, 6 Jan 2023 15:59:33 +0100 Subject: [PATCH 6/7] update recipe --- spec2vec/meta.yaml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 spec2vec/meta.yaml diff --git a/spec2vec/meta.yaml b/spec2vec/meta.yaml new file mode 100644 index 0000000..d1f449a --- /dev/null +++ b/spec2vec/meta.yaml @@ -0,0 +1,45 @@ +{% set name = "spec2vec" %} +{% set version = "0.8.0" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/spec2vec-{{ version }}.tar.gz + sha256: bf37cee48b9558216ba4e4215fc47f9dccdf5c522191222d387ede35a31e4a87 + +build: + noarch: python + script: {{ PYTHON }} -m pip install . -vv + number: 0 + +requirements: + host: + - pip + - python >=3.7 + run: + - gensim >=4.0.0 + - matchms >=0.14.0 + - numba >=0.51 + - numpy + - python >=3.7 + - tqdm + +test: + imports: + - spec2vec + commands: + - pip check + requires: + - pip + +about: + home: https://github.com/iomega/spec2vec + summary: Word2Vec based similarity measure of mass spectrometry data. + license: Apache-2.0 + license_file: LICENSE + +extra: + recipe-maintainers: + - florian-huber From 8bdbf2cf1af85de17b3b83fe720e3df187007c06 Mon Sep 17 00:00:00 2001 From: florian-huber Date: Fri, 6 Jan 2023 19:11:18 +0100 Subject: [PATCH 7/7] move to proper meta.yaml --- conda/meta.yaml | 4 ++-- spec2vec/meta.yaml | 45 --------------------------------------------- 2 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 spec2vec/meta.yaml diff --git a/conda/meta.yaml b/conda/meta.yaml index 5c95da1..f188996 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,5 +1,5 @@ {% set name = "spec2vec" %} -{% set version = "0.7.0" %} +{% set version = "0.8.0" %} package: name: {{ name|lower }} @@ -37,7 +37,7 @@ requirements: - setuptools run: - gensim >=4.2.0 - - matchms >=0.6.0 + - matchms >=0.14.0 - numba >=0.51 - numpy - pip diff --git a/spec2vec/meta.yaml b/spec2vec/meta.yaml deleted file mode 100644 index d1f449a..0000000 --- a/spec2vec/meta.yaml +++ /dev/null @@ -1,45 +0,0 @@ -{% set name = "spec2vec" %} -{% set version = "0.8.0" %} - -package: - name: {{ name|lower }} - version: {{ version }} - -source: - url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/spec2vec-{{ version }}.tar.gz - sha256: bf37cee48b9558216ba4e4215fc47f9dccdf5c522191222d387ede35a31e4a87 - -build: - noarch: python - script: {{ PYTHON }} -m pip install . -vv - number: 0 - -requirements: - host: - - pip - - python >=3.7 - run: - - gensim >=4.0.0 - - matchms >=0.14.0 - - numba >=0.51 - - numpy - - python >=3.7 - - tqdm - -test: - imports: - - spec2vec - commands: - - pip check - requires: - - pip - -about: - home: https://github.com/iomega/spec2vec - summary: Word2Vec based similarity measure of mass spectrometry data. - license: Apache-2.0 - license_file: LICENSE - -extra: - recipe-maintainers: - - florian-huber