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 3d95941..c188b9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,25 +10,53 @@ 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", "Operating System :: OS Independent", ] [project.optional-dependencies] -test = [ +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"} 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)