Skip to content

Devel docs #31

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 1 addition & 9 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ name: Build docs
# Controls when the workflow will run
on:
workflow_dispatch:
inputs:
LABS:
description: 'Labs version'
required: true
default: 'v2'
type: string

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -39,12 +33,10 @@ jobs:

# Checkout labs
- name: Checkout version of labs
env:
LABS: ${{ inputs.LABS }}
run: |
git submodule update --init --force docs/ISLP_labs
cd docs
python fix_and_clear_notebooks.py --version $LABS
python source/fix_and_clear_notebooks.py --noclear
rm source/labs/Ch*md

- name: Make docs
Expand Down
1 change: 1 addition & 0 deletions ISLP/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ def confusion_table(predicted_labels,

from . import _version
__version__ = _version.get_versions()['version']

23 changes: 21 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@

# -- Project information

import json
import os

project = 'ISLP'
copyright = '2023, ISLP authors'
author = 'Jonathan Taylor'

release = '0.1'
version = '0.1.0'
import ISLP
version = ISLP.__version__


# this should agree with
docs_version = {"labs": "v2.2",
"library": "v0.4"}

lab_version = docs_version['labs']

myst_enable_extensions = ['substitution']

myst_substitutions = {
"ISLP_lab_link": f"[ISLP_labs/{lab_version}](https://github.com/intro-stat-learning/ISLP_labs/tree/{lab_version})",
"ISLP_binder_code": f"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/intro-stat-learning/ISLP_labs/{lab_version})",
"ISLP_lab_version": "[ISLP/{0}](https://github.com/intro-stat-learning/ISLP/tree/{0})".format(docs_version['library'])
}
myst_number_code_blocks = ['python', 'ipython3']

# -- General configuration

Expand Down
4 changes: 4 additions & 0 deletions docs/source/docs_version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"labs": "v2.2",
"library": "v0.4",
"comment":"library should be version of ISLP pointed to in ISLP/labs"
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import os
import sys
import json
import nbformat
from argparse import ArgumentParser
from glob import glob

import __main__
dirname = os.path.abspath(os.path.join(os.path.split(__main__.__file__)[0], '..'))
from conf import docs_version

parser = ArgumentParser()
parser.add_argument('--version', default='v2')
parser.add_argument('--version', default=docs_version['labs'])
parser.add_argument('--clear', dest='clear', action='store_true', default=False)
parser.add_argument('--noclear', dest='clear', action='store_false')
args = parser.parse_args()
version = args.version

import __main__
dirname = os.path.split(__main__.__file__)[0]
print(dirname)

for f in glob(os.path.join(dirname, 'source', 'labs', 'Ch14*')):
os.remove(f)
print(f)
Expand Down Expand Up @@ -63,9 +67,10 @@
if labname[:4] not in ['Ch10', 'Ch13']:

# clear outputs for all but Ch10,Ch13
cmd = f'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace {nbfile}'
print(f'Running: {cmd}')
os.system(cmd)
if args.clear:
cmd = f'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace {nbfile}'
print(f'Running the clearing command: {cmd}')
os.system(cmd)

cmd = f'jupytext --set-formats ipynb,md:myst {nbfile}; jupytext --sync {nbfile}'
print(f'Running: {cmd}')
Expand All @@ -84,7 +89,6 @@

open(f'{base}.md', 'w').write(myst)

# cmd = f'jupytext --sync {base}.ipynb; rm {base}.md'
cmd = f'jupytext --sync {base}.ipynb; '
print(f'Running: {cmd}')
os.system(cmd)
Expand Down
14 changes: 2 additions & 12 deletions docs/source/installation.myst
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,10 @@ pip install ISLP
```{attention}

Python packages change frequently. The labs here are built
with specific versions of the various packages.
with {{ ISLP_lab_link }}. Visit the lab git repo for specific instructions
to install the frozen environment.
```

To ensure you have the same package versions as those built here, run:

```{code-cell} ipython3
---
tags: [skip-execution]
---
pip install -r https://raw.githubusercontent.com/intro-stat-learning/ISLP_labs/v2/requirements.txt
```

For more specific install instructions go to [ISLP_labs](https://github.com/intro-stat-learning/ISLP_labs/tree/v2).

## Torch requirements

The `ISLP` labs use `torch` and various related packages for the lab
Expand Down
54 changes: 54 additions & 0 deletions docs/source/labs.myst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
file_format: mystnb
kernelspec:
name: python3
display_name: python3
myst_number_code_blocks: python
---

# Labs

{{ ISLP_binder_code }}

The current version of the labs for `ISLP` are included here.

## Package versions


```{attention}

Python packages change frequently. The labs here are built
with {{ ISLP_lab_link }}. Visit the lab git repo for specific instructions
to install the frozen environment.


```

```{warning}
The version of the `ISLP` library used to build these labs
may differ slightly from the one documented here.
The labs are built with {{ ISLP_lab_version }}.

The [Binder](http://mybinder.org) link above will run {{ ISLP_lab_link }} with
library version {{ ISLP_lab_version }}.

```


```{toctree}
maxdepth: 1

labs/Ch02-statlearn-lab
labs/Ch03-linreg-lab
labs/Ch04-classification-lab
labs/Ch05-resample-lab
labs/Ch06-varselect-lab
labs/Ch07-nonlin-lab
labs/Ch08-baggboost-lab
labs/Ch09-svm-lab
labs/Ch10-deeplearning-lab
labs/Ch11-surv-lab
labs/Ch12-unsup-lab
labs/Ch13-multiple-lab
```

36 changes: 0 additions & 36 deletions docs/source/labs.rst

This file was deleted.

Loading