Skip to content

Commit 59e2f21

Browse files
authored
try alternative pymc object backtracing (#276)
* try alternative pymc objct backtracing * add more objects to index * fix highlighting of diataxis categories * update object usage index * remove pre-commit that adds pymc objects as tags * remove double adds
1 parent 972c32d commit 59e2f21

File tree

12 files changed

+89
-180
lines changed

12 files changed

+89
-180
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ repos:
5656
minimum_pre_commit_version: 2.8.0
5757
name: Check notebooks have watermark (see Jupyter style guide from PyMC docs)
5858
types: [jupyter]
59-
- id: add-tags
60-
entry: python scripts/add_tags.py
61-
language: python
62-
name: Add PyMC3 classes used to tags
63-
types: [jupyter]
64-
additional_dependencies:
65-
- nbqa==1.1.1
66-
- beautifulsoup4==4.9.3
67-
- myst_parser==0.13.7
6859
- repo: https://github.com/mwouts/jupytext
6960
rev: v1.13.7
7061
hooks:

_templates/postcard_categories.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ <h3>
5050
<div class="container sd-fs-6 sd-font-weight-bold">
5151
<div class="row border-top border-bottom">
5252
{% set t_bool = "tutorial" in post.category|map('string') %}
53-
<div class="col {{ setcolorclass(t_bool) }}"><a href="{{ pathtocategory('tutorial') }}">Tutorial</a></div>
53+
<div class="col"><a class="{{ setcolorclass(t_bool) }}" href="{{ pathtocategory('tutorial') }}">Tutorial</a></div>
5454
{% set h_bool = "how-to" in post.category|map('string') %}
55-
<div class="col {{ setcolorclass(h_bool) }}"><a href="{{ pathtocategory('how-to') }}">How-to</a></div>
55+
<div class="col"><a class="{{ setcolorclass(h_bool) }}" href="{{ pathtocategory('how-to') }}">How-to</a></div>
5656
<div class="w-100"></div>
5757
{% set e_bool = "explanation" in post.category|map('string') %}
58-
<div class="col {{ setcolorclass(e_bool) }}"><a href="{{ pathtocategory('explanation') }}">Explanation</a></div>
58+
<div class="col"><a class="{{ setcolorclass(e_bool) }}" href="{{ pathtocategory('explanation') }}">Explanation</a></div>
5959
{% set r_bool = "reference" in post.category|map('string') %}
60-
<div class="col {{ setcolorclass(r_bool) }}"><a href="{{ pathtocategory('reference') }}">Reference</a></div>
60+
<div class="col"><a class="{{ setcolorclass(r_bool) }}" href="{{ pathtocategory('reference') }}">Reference</a></div>
6161
</div>
6262
</div>
6363

examples/conf.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
{"name": "API", "url": "https://docs.pymc.io/en/stable/api.html"},
7070
],
7171
"page_sidebar_items": ["postcard", "page-toc", "edit-this-page"],
72+
"google_analytics_id": "G-6KPRBTE6WV",
7273
}
7374
version = os.environ.get("READTHEDOCS_VERSION", "")
7475
version = version if "." in version else "main"
@@ -99,12 +100,11 @@
99100
# "sidebar-nav-bs.html",
100101
"postcard_categories.html",
101102
"tagcloud.html",
102-
"sidebar-ethical-ads.html",
103103
],
104104
}
105105

106106
# ablog config
107-
blog_baseurl = "https://examples.pymc.io"
107+
blog_baseurl = "https://docs.pymc.io/projects/examples/en/latest/"
108108
blog_title = "PyMC Examples"
109109
blog_path = "blog"
110110
blog_authors = {
@@ -145,22 +145,8 @@
145145
bibtex_reference_style = "author_year"
146146

147147
# OpenGraph config
148-
# ogp_site_url = "https://predictablynoisy.com"
149-
# ogp_image = "https://predictablynoisy.com/_static/profile-bw.png"
148+
# use default readthedocs integration aka no config here
150149

151-
# codeautolink config
152-
from IPython.core.inputtransformer2 import TransformerManager
153-
154-
155-
def ipython_cell_transform(source):
156-
out = TransformerManager().transform_cell(source)
157-
return source, out
158-
159-
160-
# codeautolink
161-
codeautolink_custom_blocks = {
162-
"ipython3": ipython_cell_transform,
163-
}
164150
codeautolink_autodoc_inject = False
165151
codeautolink_concat_default = True
166152

@@ -172,7 +158,7 @@ def ipython_cell_transform(source):
172158
"mpl": ("https://matplotlib.org/", None),
173159
"numpy": ("https://numpy.org/doc/stable/", None),
174160
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
175-
"pymc": ("https://docs.pymc.io/en/stable/", None),
161+
"pymc": ("https://docs.pymc.io/en/latest/", None),
176162
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
177163
"xarray": ("http://xarray.pydata.org/en/stable/", None),
178164
}

examples/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ has tags in its metadata they are listed on the right sidebar after the {fas}`ta
7676
:hidden:
7777

7878
blog
79+
object_index/index
7980
:::
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-------------
2+
Distributions
3+
-------------
4+
5+
.. toctree::
6+
:maxdepth: 2
7+
8+
distributions/continuous
9+
distributions/discrete
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Continuous
2+
**********
3+
4+
.. autolink-examples:: pymc.Beta
5+
:type: class
6+
:collapse:
7+
8+
.. autolink-examples:: pymc.Exponential
9+
:type: class
10+
:collapse:
11+
12+
.. autolink-examples:: pymc.Normal
13+
:type: class
14+
:collapse:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Discrete
2+
********
3+
4+
.. autolink-examples:: pymc.Poisson
5+
:type: class
6+
:collapse:

examples/object_index/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
================
2+
Object use index
3+
================
4+
5+
This page is structured like the {ref}`PyMC API Reference page <pymc:api>` and
6+
for each function in the API it lists all the examples where that PyMC object
7+
is used.
8+
9+
.. warning::
10+
11+
This page is still a proof of concept only. See
12+
`pymc-examples#289 <https://github.com/pymc-devs/pymc-examples/issues/289>`_
13+
for more details.
14+
15+
.. toctree::
16+
:maxdepth: 2
17+
18+
distributions
19+
samplers
20+

examples/object_index/samplers.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
------------------
2+
Sampling functions
3+
------------------
4+
5+
.. autolink-examples:: pymc.sample
6+
:type: func
7+
:collapse:
8+
9+
.. autolink-examples:: pymc.sample_posterior_predictive
10+
:type: func
11+
:collapse:
12+
13+
.. autolink-examples:: pymc.sample_prior_predictive
14+
:type: func
15+
:collapse:
16+
17+
--------
18+
Samplers
19+
--------
20+
21+
.. autolink-examples:: pymc.NUTS
22+
:type: class
23+
:collapse:
24+
25+
.. autolink-examples:: pymc.Metropolis
26+
:type: class
27+
:collapse:
28+
29+
.. autolink-examples:: pymc.Slice
30+
:type: class
31+
:collapse:

scripts/__init__.py

Whitespace-only changes.

scripts/add_tags.py

Lines changed: 0 additions & 92 deletions
This file was deleted.

scripts/find_pm_classes.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)