Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto citation based on pyproject toml #3

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/gen-citation.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Auto commit after successful merge"
git push


32 changes: 30 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
9 changes: 5 additions & 4 deletions tests/test_readdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading