Skip to content
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ dmypy.json

.scikit-mol.code-workspace.swp
scikit-mol.code-workspace
notebooks/25747817
*.ipynb


# test data
tests/data/
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ repos:
args: [ --fix ]
types_or: [ python, pyi ]
# Run the formatter.
- id: ruff-format
- id: ruff-format

11 changes: 2 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
sync-notebooks:
uv run jupytext --set-formats docs//notebooks//ipynb,docs//notebooks//scripts//py:percent --sync docs/notebooks/*.ipynb
uv run ruff format "docs/notebooks/"
uv run jupytext --sync "docs/notebooks/*.ipynb"

run-notebooks:
# Execute the notebooks, gives a .nbconvert.ipynb extension
jupyter nbconvert --to notebook --execute *ipynb
# move the .nbconvert.ipynb to the original .ipynb
for file in *.nbconvert.ipynb; do
fname=${file/.nbconvert.ipynb/};
rm $fname.ipynb
mv $file $fname.ipynb
done
uv run jupytext --execute docs/notebooks/*ipynb
7 changes: 5 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ Scikit-Learn has a check_estimator that we should strive to get to work, some cl
## Notebooks

Another way of contributing is by providing notebooks with examples on how to use the project to build models together with Scikit-Learn and other tools. There are .ipynb files in the `docs/notebooks` and .py files in the `script` subfolder as the first are useful for online rendering in the documentation, whereas the latter is useful for sub version control.
If you want to create new notebook you can create .ipynb file, and then you run `make sync-notebooks` to create the corresponding .py file for the commit.

If you want to create new notebook you can first create .ipynb file, and then you run `make sync-notebooks` to create the corresponding .py file for the commit.

If you updated any of the existing py/ipynb files, you can run `make sync-notebooks` to update the outdated file in the pair. The .py files are used for nice diffs, and the .ipynb files are used for rendering in the documentation.

`make sync-notebooks` will sync all the notebooks with the .py files in the `scripts` folder.

`make run-notebooks` will sync, run and save the notebooks, expects an ipython kernel with scikit-mol installed called Python3.
`make run-notebooks` will sync, run and save the notebooks, expects an ipython kernel with scikit-mol installed.

## Documentation

Expand Down
120 changes: 67 additions & 53 deletions docs/notebooks/01_basic_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"id": "2c8cad03",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:16.292725Z",
"iopub.status.busy": "2024-11-24T09:27:16.292083Z",
"iopub.status.idle": "2024-11-24T09:27:16.306663Z",
"shell.execute_reply": "2024-11-24T09:27:16.304935Z"
"iopub.execute_input": "2025-05-08T16:22:29.627872Z",
"iopub.status.busy": "2025-05-08T16:22:29.627571Z",
"iopub.status.idle": "2025-05-08T16:22:29.632065Z",
"shell.execute_reply": "2025-05-08T16:22:29.631373Z"
}
},
"outputs": [],
Expand All @@ -42,10 +42,10 @@
"id": "8d5b2333",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:16.313611Z",
"iopub.status.busy": "2024-11-24T09:27:16.313028Z",
"iopub.status.idle": "2024-11-24T09:27:16.510254Z",
"shell.execute_reply": "2024-11-24T09:27:16.509620Z"
"iopub.execute_input": "2025-05-08T16:22:29.634712Z",
"iopub.status.busy": "2025-05-08T16:22:29.634423Z",
"iopub.status.idle": "2025-05-08T16:22:29.845389Z",
"shell.execute_reply": "2025-05-08T16:22:29.844169Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -78,10 +78,10 @@
"id": "0a625dda",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:16.513123Z",
"iopub.status.busy": "2024-11-24T09:27:16.512856Z",
"iopub.status.idle": "2024-11-24T09:27:17.089043Z",
"shell.execute_reply": "2024-11-24T09:27:17.088357Z"
"iopub.execute_input": "2025-05-08T16:22:29.850211Z",
"iopub.status.busy": "2025-05-08T16:22:29.848822Z",
"iopub.status.idle": "2025-05-08T16:22:30.986417Z",
"shell.execute_reply": "2025-05-08T16:22:30.984810Z"
}
},
"outputs": [
Expand Down Expand Up @@ -118,10 +118,10 @@
"id": "9a801d0f",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.091942Z",
"iopub.status.busy": "2024-11-24T09:27:17.091571Z",
"iopub.status.idle": "2024-11-24T09:27:17.098501Z",
"shell.execute_reply": "2024-11-24T09:27:17.097922Z"
"iopub.execute_input": "2025-05-08T16:22:30.991850Z",
"iopub.status.busy": "2025-05-08T16:22:30.990911Z",
"iopub.status.idle": "2025-05-08T16:22:31.011512Z",
"shell.execute_reply": "2025-05-08T16:22:31.010309Z"
}
},
"outputs": [
Expand All @@ -130,7 +130,8 @@
"text/html": [
"<style>#sk-container-id-1 {\n",
" /* Definition of color scheme common for light and dark mode */\n",
" --sklearn-color-text: black;\n",
" --sklearn-color-text: #000;\n",
" --sklearn-color-text-muted: #666;\n",
" --sklearn-color-line: gray;\n",
" /* Definition of color scheme for unfitted estimators */\n",
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
Expand Down Expand Up @@ -275,12 +276,21 @@
"/* Toggleable label */\n",
"#sk-container-id-1 label.sk-toggleable__label {\n",
" cursor: pointer;\n",
" display: block;\n",
" display: flex;\n",
" width: 100%;\n",
" margin-bottom: 0;\n",
" padding: 0.5em;\n",
" box-sizing: border-box;\n",
" text-align: center;\n",
" align-items: start;\n",
" justify-content: space-between;\n",
" gap: 0.5em;\n",
"}\n",
"\n",
"#sk-container-id-1 label.sk-toggleable__label .caption {\n",
" font-size: 0.6rem;\n",
" font-weight: lighter;\n",
" color: var(--sklearn-color-text-muted);\n",
"}\n",
"\n",
"#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
Expand Down Expand Up @@ -433,7 +443,8 @@
" height: 1em;\n",
" width: 1em;\n",
" text-decoration: none !important;\n",
" margin-left: 1ex;\n",
" margin-left: 0.5em;\n",
" text-align: center;\n",
" /* unfitted */\n",
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
" color: var(--sklearn-color-unfitted-level-1);\n",
Expand Down Expand Up @@ -532,7 +543,7 @@
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-3);\n",
"}\n",
"</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>MorganFingerprintTransformer(radius=3)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow \">&nbsp;MorganFingerprintTransformer<span class=\"sk-estimator-doc-link \">i<span>Not fitted</span></span></label><div class=\"sk-toggleable__content \"><pre>MorganFingerprintTransformer(radius=3)</pre></div> </div></div></div></div>"
"</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>MorganFingerprintTransformer(radius=3)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>MorganFingerprintTransformer</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-mol.readthedocs.org/en/latest/api/scikit_mol.fingerprints/#scikit_mol.fingerprints.MorganFingerprintTransformer\">?<span>Documentation for MorganFingerprintTransformer</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\"><pre>MorganFingerprintTransformer(radius=3)</pre></div> </div></div></div></div>"
],
"text/plain": [
"MorganFingerprintTransformer(radius=3)"
Expand Down Expand Up @@ -561,18 +572,18 @@
"id": "500dc6f7",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.101153Z",
"iopub.status.busy": "2024-11-24T09:27:17.100929Z",
"iopub.status.idle": "2024-11-24T09:27:17.105319Z",
"shell.execute_reply": "2024-11-24T09:27:17.104586Z"
"iopub.execute_input": "2025-05-08T16:22:31.015226Z",
"iopub.status.busy": "2025-05-08T16:22:31.014511Z",
"iopub.status.idle": "2025-05-08T16:22:31.022448Z",
"shell.execute_reply": "2025-05-08T16:22:31.021051Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'fpSize': 2048,\n",
" 'parallel': False,\n",
" 'n_jobs': None,\n",
" 'radius': 3,\n",
" 'safe_inference_mode': False,\n",
" 'useBondTypes': True,\n",
Expand Down Expand Up @@ -605,10 +616,10 @@
"id": "3a27b07a",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.107710Z",
"iopub.status.busy": "2024-11-24T09:27:17.107495Z",
"iopub.status.idle": "2024-11-24T09:27:17.111268Z",
"shell.execute_reply": "2024-11-24T09:27:17.110754Z"
"iopub.execute_input": "2025-05-08T16:22:31.026293Z",
"iopub.status.busy": "2025-05-08T16:22:31.025546Z",
"iopub.status.idle": "2025-05-08T16:22:31.032975Z",
"shell.execute_reply": "2025-05-08T16:22:31.031700Z"
}
},
"outputs": [
Expand Down Expand Up @@ -641,10 +652,10 @@
"id": "0f141920",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.113572Z",
"iopub.status.busy": "2024-11-24T09:27:17.113344Z",
"iopub.status.idle": "2024-11-24T09:27:17.117356Z",
"shell.execute_reply": "2024-11-24T09:27:17.116845Z"
"iopub.execute_input": "2025-05-08T16:22:31.036752Z",
"iopub.status.busy": "2025-05-08T16:22:31.036118Z",
"iopub.status.idle": "2025-05-08T16:22:31.043904Z",
"shell.execute_reply": "2025-05-08T16:22:31.042561Z"
}
},
"outputs": [
Expand Down Expand Up @@ -675,10 +686,10 @@
"id": "481e527f",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.119855Z",
"iopub.status.busy": "2024-11-24T09:27:17.119584Z",
"iopub.status.idle": "2024-11-24T09:27:17.124520Z",
"shell.execute_reply": "2024-11-24T09:27:17.124025Z"
"iopub.execute_input": "2025-05-08T16:22:31.047228Z",
"iopub.status.busy": "2025-05-08T16:22:31.046700Z",
"iopub.status.idle": "2025-05-08T16:22:31.054569Z",
"shell.execute_reply": "2025-05-08T16:22:31.053275Z"
}
},
"outputs": [
Expand All @@ -690,7 +701,7 @@
" [1, 0, 0, ..., 0, 0, 0],\n",
" [0, 0, 0, ..., 0, 0, 1],\n",
" [1, 1, 0, ..., 0, 0, 0],\n",
" [1, 1, 0, ..., 0, 0, 0]], dtype=uint8)"
" [1, 1, 0, ..., 0, 0, 0]], shape=(6, 256), dtype=uint8)"
]
},
"execution_count": 8,
Expand All @@ -717,10 +728,10 @@
"id": "7773a5a0",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.126934Z",
"iopub.status.busy": "2024-11-24T09:27:17.126713Z",
"iopub.status.idle": "2024-11-24T09:27:17.131063Z",
"shell.execute_reply": "2024-11-24T09:27:17.130539Z"
"iopub.execute_input": "2025-05-08T16:22:31.057901Z",
"iopub.status.busy": "2025-05-08T16:22:31.057134Z",
"iopub.status.idle": "2025-05-08T16:22:31.064119Z",
"shell.execute_reply": "2025-05-08T16:22:31.063046Z"
}
},
"outputs": [
Expand All @@ -745,23 +756,23 @@
"id": "fa484453",
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-24T09:27:17.133328Z",
"iopub.status.busy": "2024-11-24T09:27:17.133133Z",
"iopub.status.idle": "2024-11-24T09:27:17.137378Z",
"shell.execute_reply": "2024-11-24T09:27:17.136857Z"
"iopub.execute_input": "2025-05-08T16:22:31.067178Z",
"iopub.status.busy": "2025-05-08T16:22:31.066755Z",
"iopub.status.idle": "2025-05-08T16:22:31.074756Z",
"shell.execute_reply": "2025-05-08T16:22:31.073587Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[<rdkit.Chem.rdchem.Mol object at 0x7ec3603d1e00>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7ec3603d1e70>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7ec3603d1ee0>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7ec3603d1f50>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7ec3603d1fc0>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7ec3603d2030>]]\n"
"[[<rdkit.Chem.rdchem.Mol object at 0x7feda5e663b0>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7feda5e66420>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7feda5e66490>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7feda5e66500>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7feda5e66570>]\n",
" [<rdkit.Chem.rdchem.Mol object at 0x7feda5e665e0>]]\n"
]
}
],
Expand All @@ -771,6 +782,9 @@
}
],
"metadata": {
"jupytext": {
"formats": "docs//notebooks//ipynb,docs//notebooks//scripts//py:percent"
},
"kernelspec": {
"display_name": "Python 3.9.4 ('rdkit')",
"language": "python",
Expand All @@ -786,7 +800,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.6"
}
},
"nbformat": 4,
Expand Down
65 changes: 28 additions & 37 deletions docs/notebooks/02_descriptor_transformer.ipynb

Large diffs are not rendered by default.

Loading