-
Notifications
You must be signed in to change notification settings - Fork 107
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
Convert example notebooks to Markdown files #243
Conversation
Codecov Report
@@ Coverage Diff @@
## main #243 +/- ##
=======================================
Coverage 98.63% 98.63%
=======================================
Files 43 43
Lines 1757 1757
=======================================
Hits 1733 1733
Misses 24 24 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
```python | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty cell
states.position["loc"].block_until_ready() | ||
``` | ||
|
||
In this example the result is a dictionnary and each entry has shape `(num_samples, num_chains)`. Here's how to access the samples of the second chains for `loc`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are some lines missing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
* L-BFGS algorithm struggles with float32s and log-likelihood functions; it's suggested to use double precision numbers. In order to do that in `jax` a configuration variable needs to be set up at initialization time (see [here](https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html#double-64bit-precision)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linebreaks are not necessary
examples/TemperedSMC.md
Outdated
name: python3 | ||
--- | ||
|
||
<!-- #region pycharm={"name": "#%% md\n"} --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all the <!--- --->
stuff added by PyCharm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
many things added by PyCharm in this file, please remove all of them
examples/TemperedSMC.md
Outdated
|
||
We plot the resulting tempered density for 5 different values of $\lambda_k$: from $\lambda_k =1$ which correponds to the original density to $\lambda_k=0$. The lower the value of $\lambda_k$ the easier it is to sampler from the posterior log-density. | ||
|
||
```python pycharm={"name": "#%%\n"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
examples/TemperedSMC.md
Outdated
|
||
We first try to sample from the posterior density using an HMC kernel. | ||
|
||
```python pycharm={"name": "#%%\n"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
examples/TemperedSMC.md
Outdated
ax.legend(list(lambdas)) | ||
``` | ||
|
||
```python pycharm={"name": "#%%\n"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
examples/use_with_pymc.md
Outdated
name: blackjax | ||
--- | ||
|
||
<!-- #region id="397995ab" --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean the file as the previous one.
examples/use_with_tfp.md
Outdated
|
||
# Use BlackJAX with TFP | ||
|
||
<!-- #region --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
This looks great, well done. It looks like some text editors added some unnecessary comments/ids, could you remove them manually please? Next we can work on running the notebooks in CI to include them in the documentation :) |
Sure 😃 |
I removed most of the metadata from the markdown files and kept only notebooks' metadata at the top of each file. I used |
Looks much better!
If it is important for people who clone the repo to have the same experience running / keeping the notebooks in sync with the md files I would say yes. |
I added markdown conversion instruction and updated documentation in docs/examples.rst |
Great, Now we need to have the CI run the notebooks and display them with images in the documentation so people can visualize their content browsing the doc. |
I follow this link to add rendering configuration in |
I don't know. Does it work when you build the doc locally? |
Just to drop an update. Rendering I'll try to follow those repos. Hope I can finish this issue by this weekend. |
Did you manage to build the docs without the images at least? |
yes, I did. the docs without images look fine. |
Nice! I'll take a look around too for the figures |
I am wondering if you can't just convert the |
Oh, that works too. I thought we are going to remove all That means we keep examples in Markdown format on git and convert them into notebooks for documentation. is that correct? |
That sounds a like a good strategy to me. Notebooks are not under version control, results are displayed in the docs, everyone happy! |
Any progress on this @bkktimber ? |
This looks good! Two things:
|
I removed them in the latest commit.
Assuming all examples are in Markdown format before committing to the repo, all markdown - jupyter conversions are done in examples/conf.py. I also write steps to prepare example files to build documentation in examples/README With that assumption, I use |
Looks good. Before merging could you rebase your commits? There should be one commit for converting to |
Got it. I rebased and pushed. |
All right this looks fantastic. @junpenglao wdyt? |
examples/README.md
Outdated
|
||
## Converting Notebook Files to Text Files | ||
|
||
Please convert your `.ipynb` to `markdown` before commit your example to this repo. You can use the command below: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert your `.ipynb` to `markdown` before commit your example to this repo. You can use the command below: | |
If you implemented your example in a notebook you can convert your `.ipynb` file to Markdown using the command below: |
|
||
3. Verify the generated documentation in `docs/builds` | ||
|
||
### Execution Times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw that, very useful!
Thank you 😄 Should I commit your suggestions or leave them to you when the PR is merged? |
I will apply my suggestions and rebase once @junpenglao has reviewed the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor nit, great job!
@bkktimber It looks like at least one notebook wasn't fully converted and the markdown version is shorter than the notebook version. Could you double-check that every notebook has been fully converted? |
I was thinking about |
Merging. Great job! |
No worry @rlouf! Let's see how it's doing 😁 |
A notebook fails in CI, I need to investigate. |
Just a quick note to say that I've worked with the documentation recently and it's fantastic, so thank you again! |
It's my pleasure. Glad to know my contribution is helpful. |
Convert all notebooks in examples to Markdown files (#128). Could you review this PR? @rlouf
A few important guidelines and requirements before we can merge your PR:
main
commit;pre-commit
is installed and configured on your machine, and you ran it before opening the PR;Consider opening a Draft PR if your work is still in progress but you would like some feedback from other contributors.