Skip to content

Commit 5aed91c

Browse files
enryHenryh
andauthored
🎨 dpi argument and tight_layout (#16)
* 🎨 dpi argument and tight_layout * 🎨 format * 🐛 rename parameter now njab and scikit-learn have different api names... keep for compatibility for now * 🐛 installation was moved to notebook * 🐛 move installation further to notebooks * 🐛 install non PyPI version... * 🐛 fix workflow * 🐛 commit id did not work for install * 🐛 try to use njab... * 🎨 see if tag is picked up from local install * :arrow-up: fix minimal scikit-learn version - as cross-validate needs to have `params` parameter --------- Co-authored-by: enryh <henry.webel@cpr.ku.dk>
1 parent b3a905e commit 5aed91c

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

.github/workflows/colab.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,24 @@ jobs:
1414
image: europe-docker.pkg.dev/colab-images/public/runtime:latest
1515
steps:
1616
- uses: actions/checkout@v4
17+
- name: Dev - Install njab (from branch) - optional
18+
if: github.event_name == 'push'
19+
run: |
20+
echo GITHUB_REF= $GITHUB_REF
21+
echo GITHUB_SHA= $GITHUB_SHA
22+
echo "Branch or Tag: ${{ github.ref }}"
23+
pip install .
24+
# pip install git+https://github.com/RasmussenLab/njab.git@$GITHUB_SHA
25+
cd docs
26+
echo
27+
echo Installed version of njab:
28+
python3 -c "import njab; print(njab.__version__)"
1729
- name: Test tutorials
1830
run: |
1931
python3 -m pip install papermill ipykernel njab
2032
cd docs/tutorial
2133
papermill explorative_analysis.ipynb --help-notebook
2234
papermill log_reg.ipynb --help-notebook
23-
papermill explorative_analysis.ipynb explorative_analysis_tested.ipynb
24-
pip install njab heatmapz openpyxl "matplotlib<3.7" plotly
2535
papermill log_reg.ipynb log_reg_tested.ipynb
36+
papermill explorative_analysis.ipynb explorative_analysis_tested.ipynb
37+

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"omegaconf",
1818
"numpy",
1919
"pandas",
20-
"scikit-learn",
20+
"scikit-learn>=1.4",
2121
"statsmodels",
2222
"matplotlib",
2323
"mrmr_selection",

src/njab/plotting/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010
import pandas as pd
11-
1211
from njab.plotting.lifelines import plot_lifelines
1312

1413
__all__ = ['plot_lifelines']
@@ -26,19 +25,24 @@
2625

2726
def savefig(fig: matplotlib.figure.Figure,
2827
name: str,
29-
folder: pathlib.Path = '.',
30-
pdf=True):
28+
folder: str = '.',
29+
dpi: int = 300,
30+
pdf: bool = True,
31+
tight_layout: bool = True) -> None:
3132
"""Save matplotlib Figure (having method `savefig`) as pdf and png."""
3233
folder = pathlib.Path(folder)
3334
fname = folder / name
3435
folder = fname.parent # in case name specifies folders
3536
folder.mkdir(exist_ok=True, parents=True)
36-
if not fig.get_constrained_layout():
37+
if tight_layout and not fig.get_constrained_layout():
3738
fig.tight_layout()
38-
fig.savefig(fname.with_suffix('.png'), bbox_inches='tight')
39+
fname = fname.with_suffix('.png')
40+
fig.savefig(fname, dpi=dpi, bbox_inches='tight')
41+
logger.info("Saved Figures to %s", fname)
3942
if pdf:
40-
fig.savefig(fname.with_suffix('.pdf'), bbox_inches='tight')
41-
logger.info(f"Saved Figures to {fname}")
43+
fname = fname.with_suffix('.pdf')
44+
fig.savefig(fname, bbox_inches='tight')
45+
logger.info("Saved Figures to %s", fname)
4246

4347

4448
def select_xticks(ax: matplotlib.axes.Axes, max_ticks: int = 50) -> list:

src/njab/sklearn/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def find_n_best_features(
122122
scoring=scoring,
123123
cv=cv,
124124
return_train_score=return_train_score,
125-
fit_params=fit_params,
125+
params=fit_params,
126126
error_score='raise')
127127
scores['n_features'] = n_features
128128
scores['test_case'] = name

0 commit comments

Comments
 (0)