From 7d84e7d1958322db3c00f25dc0f9ebd293a9e529 Mon Sep 17 00:00:00 2001 From: jurra Date: Fri, 16 Jun 2023 11:26:02 +0200 Subject: [PATCH 1/3] corrected reference to data file for testing --- tests/test_readdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_readdata.py b/tests/test_readdata.py index 93f4563..855ce94 100644 --- a/tests/test_readdata.py +++ b/tests/test_readdata.py @@ -10,7 +10,7 @@ @pytest.fixture def dl_from_file() -> np.ndarray: ''' Read data from DL formatted file and return as numpy array''' - x, y = read_from_file("_no_anneal.txt") + x, y = read_from_file("./tests/fixtures/test_dataset.txt") x = x.to_numpy() y = y.to_numpy() return np.concatenate((y.reshape(-1,1), x), axis=1).astype(np.int32) From 4c0e2c42f87defbcfd075d738192301c39d16dd3 Mon Sep 17 00:00:00 2001 From: jurra Date: Fri, 16 Jun 2023 11:26:02 +0200 Subject: [PATCH 2/3] corrected reference to data file for testing --- pyproject.toml | 2 +- tests/test_readdata.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3d95941..437bf06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ "Operating System :: OS Independent", ] [project.optional-dependencies] -test = [ +dev = [ "pytest>=5.3.0", "pytest-cov>=2.8.0", ] diff --git a/tests/test_readdata.py b/tests/test_readdata.py index 93f4563..50cd02a 100644 --- a/tests/test_readdata.py +++ b/tests/test_readdata.py @@ -6,11 +6,12 @@ import pymurtree.lib as lib import pprint +TRAIN_DATA = "./tests/fixtures/test_dataset.txt" @pytest.fixture def dl_from_file() -> np.ndarray: ''' Read data from DL formatted file and return as numpy array''' - x, y = read_from_file("_no_anneal.txt") + x, y = read_from_file(TRAIN_DATA) x = x.to_numpy() y = y.to_numpy() return np.concatenate((y.reshape(-1,1), x), axis=1).astype(np.int32) @@ -19,7 +20,7 @@ def dl_from_file() -> np.ndarray: def dl_x_y() -> tuple: ''' Read data from DL formatted file and return as tuple with two numpy arrays (x, y) where x is the feature vectors and y is the labels''' - x, y = read_from_file("_no_anneal.txt") + x, y = read_from_file(TRAIN_DATA) return x, y @pytest.fixture @@ -33,7 +34,7 @@ def dl_data_sample() -> np.ndarray: # test that data read is correct def test_read_from_file(): - x, y = read_from_file("_no_anneal.txt") + x, y = read_from_file(TRAIN_DATA) assert x is not None assert y is not None assert type(x) == pd.core.frame.DataFrame @@ -63,7 +64,7 @@ def test_nparray_to_feature_vectors(dl_data_sample): def test_compare_feature_vectors(dl_from_file): ''' Test that we get exactly the same feature vectors from the file and from the numpy array''' - feature_vectors_from_file = lib._read_data_dl("_no_anneal.txt", 1) + feature_vectors_from_file = lib._read_data_dl(TRAIN_DATA, 1) assert feature_vectors_from_file is not None assert type(feature_vectors_from_file) == list assert type(feature_vectors_from_file[0]== lib.FeatureVectorBinary) From a962a5189a2065007856290ba6d1315923c3fe84 Mon Sep 17 00:00:00 2001 From: jurra Date: Tue, 29 Aug 2023 20:32:04 +0200 Subject: [PATCH 3/3] feature: Auto citate after pull request is accepted With this commit we make sure we can generate citation metadata from pyproject.toml, this allows us to keep both metadata files up to date and use the pyproject.toml as a source of truth --- .github/workflows/gen-citation.yaml | 32 +++++++++++++++++++++++++++++ pyproject.toml | 30 ++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/gen-citation.yaml diff --git a/.github/workflows/gen-citation.yaml b/.github/workflows/gen-citation.yaml new file mode 100644 index 0000000..e76a36a --- /dev/null +++ b/.github/workflows/gen-citation.yaml @@ -0,0 +1,32 @@ +on: + pull_request: + types: + - closed + +jobs: + if_merged: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: 3.10 + + - name: Install dependencies + run: | + pip install .[citation] + + - name: Generate citation based on pyproject.toml + run: | + cff-from-621 + + - name: Commit and push changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add . + git commit -m "Auto commit after successful merge" + git push + + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 437bf06..c188b9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,11 +10,27 @@ target-version = "py37" [project] name = "pymurtree" version = "0.0.1" +description = "Python bindings for MurTree" +readme = "README.md" +license = "MIT" +keywords = ["MurTree", "Optimal decision tree", "Python bindings"] + +authors = [ + {name = "Yasel Quintero", orcid = "0000-0000-0000-0001"}, + {name = "Jose Urra", orcid = "0000-0000-0000-0002"}, +] + dependencies =[ "pandas>=1.0.0", "numpy>=1.18.0", ] +[project.urls] +homepage = "https://github.com/MurTree/pymurtree.git" +MurTreeCpp = "https://github.com/MurTree/murtree" +sample_data = "https://github.com/MurTree/murtree-data" +journal = "https://doi.org/10.48550/arXiv.2007.12652" + classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", @@ -25,10 +41,22 @@ dev = [ "pytest>=5.3.0", "pytest-cov>=2.8.0", ] +citation = [ + "cff-from-621", +] [tool.pytest.ini_options] pythonpath = [ ".", "src/pymurtree", ] -[project.urls] + +[tool.cff-from-621] +order = ["message", "cff-version", "title", "abstract", "version", "date-released", "authors", "keywords"] + +[tool.cff-from-621.static] +date-released = "2022-09-18" +message = "If you use this software, please cite it as below." + +[tool.setuptools.dynamic] +version = {attr = "cff_from_621.version.VERSION"}