Skip to content

Commit e2d5f10

Browse files
authored
Merge pull request #6 from PLN-team/github
Complete CI. Release test
2 parents b4b18b5 + 4809c46 commit e2d5f10

File tree

8 files changed

+150
-15
lines changed

8 files changed

+150
-15
lines changed

.github/workflows/ci.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- github
8+
pull_request:
9+
branches:
10+
- main
11+
release:
12+
types: [created]
13+
14+
jobs:
15+
black:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.9'
23+
- name: Install Black
24+
run: pip install black
25+
- name: Run Black
26+
run: black --check --verbose -- .
27+
28+
# pylint:
29+
# runs-on: ubuntu-22.04
30+
# needs: black
31+
# steps:
32+
# - uses: actions/checkout@v4
33+
# - name: Set up Python
34+
# uses: actions/setup-python@v4
35+
# with:
36+
# python-version: '3.9'
37+
# - name: Install Pylint
38+
# run: |
39+
# pip install pylint
40+
41+
# - name: Run Pylint
42+
# run: find . -type f -name "*.py" | xargs pylint --disable=import-error,missing-module-docstring,invalid-name,not-callable,duplicate-code --load-plugins=pylint.extensions.docparams
43+
44+
tests:
45+
runs-on: ubuntu-22.04
46+
container:
47+
image: ghcr.io/bastien-mva/docker_image:latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Install package and run tests
51+
run: |
52+
pip install '.[tests]'
53+
pip install -e .
54+
jupyter nbconvert Getting_started.ipynb --to python --output tests/test_getting_started
55+
cd tests
56+
python _create_readme_getting_started_and_docstrings_tests.py
57+
rm test_getting_started.py
58+
pytest test_ar.py
59+
60+
build_package:
61+
runs-on: ubuntu-22.04
62+
steps:
63+
- uses: actions/checkout@v4
64+
- name: Set up Python
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: '3.9'
68+
- name: Install build
69+
run: pip install build
70+
- name: Build package
71+
run: |
72+
rm -rf dist/
73+
python -m build
74+
- name: Upload artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: dist
78+
path: dist/
79+
80+
publish_package:
81+
runs-on: ubuntu-22.04
82+
needs:
83+
- build_package
84+
- tests
85+
# if: github.event_name == 'release'
86+
if: github.event_name == 'release' && github.ref == 'refs/heads/main'
87+
steps:
88+
- uses: actions/checkout@v4
89+
- name: Set up Python
90+
uses: actions/setup-python@v4
91+
with:
92+
python-version: '3.9'
93+
- name: Install Twine
94+
run: pip install twine
95+
- name: download artifacts and publish
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: dist
99+
path: dist/
100+
- name: Publish package
101+
env:
102+
TWINE_USERNAME: __token__
103+
TWINE_PASSWORD: ${{ secrets.PYPLN_TOKEN }}
104+
run: python -m twine upload dist/*
105+
106+
pages:
107+
runs-on: ubuntu-22.04
108+
needs: publish_package
109+
if: github.event_name == 'release' && github.ref == 'refs/heads/main'
110+
111+
steps:
112+
- uses: actions/checkout@v4
113+
- name: Set up Python
114+
uses: actions/setup-python@v4
115+
with:
116+
python-version: '3.9'
117+
- name: Install dependencies
118+
run: pip install '.[build-doc]'
119+
- name: Install Pandoc
120+
run: |
121+
wget https://github.com/jgm/pandoc/releases/download/1.15.1/pandoc-1.15.1-1-amd64.deb
122+
sudo dpkg -i pandoc-1.15.1-1-amd64.deb
123+
- name: Convert README
124+
run: pandoc README.md --from markdown --to rst -s -o docs/source/readme.rst
125+
- name: Build docs
126+
run: |
127+
pip install .
128+
make -C docs html
129+
- name: Deploy to GitHub Pages
130+
uses: peaceiris/actions-gh-pages@v4
131+
with:
132+
github_token: ${{ secrets.GITHUB_TOKEN }}
133+
publish_dir: ./docs/build/html

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
> the significance of each variable, their correlations, and the
2525
> weight of covariates (if available).
2626
27+
The package documentation can be found [here](https://pln-team.github.io/pyPLNmodels/).
28+
2729
## Getting started
2830
[A notebook to get started can be found here](https://github.com/PLN-team/pyPLNmodels/blob/main/Getting_started.ipynb).
2931
If you need just a quick view of the package, see the quickstart next. Note
@@ -41,11 +43,11 @@ pip install pyPLNmodels
4143

4244
## Statistical description
4345

44-
For those unfamiliar with the concepts of Poisson or Gaussian random variables,
45-
it is not necessary to delve into these statistical descriptions. The key
46-
takeaway is as follows: This package is designed to analyze multi-dimensional count data. It
47-
effectively extracts significant information, such as
48-
the mean, the relationships with covariates, and the correlation between count
46+
For those unfamiliar with Poisson or Gaussian random variables,
47+
it's not necessary to delve into these statistical concepts. The
48+
key takeaway is that this package analyzes multi-dimensional count
49+
data, extracting significant information such as the mean,
50+
relationships with covariates, and correlations between count
4951
variables, in a manner appropriate for count data.
5052

5153
Consider $\mathbf Y$ a count matrix (denoted as `endog` in the package) consisting of $n$ rows and $p$ columns.
@@ -276,7 +278,7 @@ print(ar)
276278

277279
## 👐 Contributing
278280

279-
Feel free to contribute, but read the [CONTRIBUTING.md](https://forgemia.inra.fr/bbatardiere/pyplnmodels/-/blob/main/CONTRIBUTING.md) first. A public roadmap will be available soon.
281+
Feel free to contribute, but read the [CONTRIBUTING.md](https://github.com/PLN-team/pyPLNmodels/blob/main/CONTRIBUTING.md) first. A public roadmap will be available soon.
280282

281283
## ⚡️ Citations
282284

pyPLNmodels/calculations/entropies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def entropy_gaussian(latent_variance, latent_prob=None):
2121
is for a mixture of gaussians.
2222
"""
2323
if latent_prob is None:
24-
latent_prob = torch.ones((latent_variance).shape)
24+
latent_prob = torch.ones((latent_variance).shape).to(latent_variance.device)
2525
product_dimensions = torch.prod(torch.tensor(list(latent_variance.shape[-2:])))
2626
return (
2727
1 / 2 * torch.sum((latent_prob.T).unsqueeze(2) * latent_variance)

pyPLNmodels/models/plnar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def _init_model_parameters(self):
254254
self._ar_diff_coef = torch.tensor([0.5]).to(DEVICE)
255255
else:
256256
self._ar_diff_coef = torch.ones(self.dim).to(DEVICE) / 2
257-
self._diff_ortho_components = torch.eye(self.dim)
257+
self._diff_ortho_components = torch.eye(self.dim).to(DEVICE)
258258
self._diff_diag_cov = torch.ones(self.dim).to(DEVICE) / (
259259
self.dim ** (3 / 2)
260260
)

pyPLNmodels/utils/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def calculate_correlation(data, transformed_data):
160160

161161
def _trunc_log(tens: torch.Tensor, eps: float = 1e-16) -> torch.Tensor:
162162
integer = torch.min(
163-
torch.max(tens, torch.tensor([eps], device=DEVICE)),
164-
torch.tensor([1 - eps], device=DEVICE),
163+
torch.max(tens, torch.tensor([eps], device=tens.device)),
164+
torch.tensor([1 - eps], device=tens.device),
165165
)
166166
return torch.log(integer)
167167

tests/_create_readme_getting_started_and_docstrings_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _write_file(examples, filename, string_definer, directory):
6363
for i, example in enumerate(examples):
6464
nb_example = str(i + 1)
6565
example_filename = (
66-
f"{directory}/mytest_{filename}_{string_definer}_{nb_example}.py"
66+
f"{directory}/test_{filename}_{string_definer}_{nb_example}.py"
6767
)
6868
try:
6969
os.remove(example_filename)

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
)
66

77

8-
dict_unfit_models = get_dict_models_unfit()
9-
dict_fitted_models = get_dict_models_fitted()
10-
dict_collections_fitted = get_dict_collections_fitted()
8+
# dict_unfit_models = get_dict_models_unfit()
9+
# dict_fitted_models = get_dict_models_fitted()
10+
# dict_collections_fitted = get_dict_collections_fitted()

tests/run_readme_docstrings_getting_started.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
run_with_probability() {
5-
if [ $((RANDOM % 3)) -eq 0 ]; then
5+
if [ $((RANDOM % 1)) -eq 0 ]; then
66
python "$1"
77
fi
88
}

0 commit comments

Comments
 (0)