Skip to content

Commit 6a580cc

Browse files
Deprecate those kwargs in v3 that will break in v4 (#5226)
* Upgrade pre-commit from main and apply automated code style Except the check against print statements. * XFAIL KroneckerNormal test on Windows because of #5253 * Add deprecat dependency For more automation in kwarg deprecations. * Deprecation of testval→initval and related start kwarg * Partially add admonition style for rendering warnings With css taken from pydata-sphinx-theme. Co-authored-by: Oriol (ZBook) <[email protected]>
1 parent c332f8c commit 6a580cc

31 files changed

+371
-99
lines changed

.pre-commit-config.yaml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exclude: ^(docs/logos|pymc3/tests/data)/
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v3.4.0
4+
rev: v4.0.1
55
hooks:
66
- id: check-merge-conflict
77
- id: check-toml
@@ -14,44 +14,43 @@ repos:
1414
exclude: ^requirements-dev\.txt$
1515
- id: trailing-whitespace
1616
- repo: https://github.com/PyCQA/isort
17-
rev: 5.7.0
17+
rev: 5.10.1
1818
hooks:
1919
- id: isort
2020
name: isort
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.10.0
22+
rev: v2.29.1
2323
hooks:
2424
- id: pyupgrade
2525
args: [--py37-plus]
2626
- repo: https://github.com/psf/black
27-
rev: 20.8b1
27+
rev: 21.12b0
2828
hooks:
2929
- id: black
3030
- repo: https://github.com/PyCQA/pylint
31-
rev: pylint-2.6.0
31+
rev: v2.12.2
3232
hooks:
3333
- id: pylint
3434
args: [--rcfile=.pylintrc]
35-
files: ^pymc3/
35+
files: ^pymc/
36+
- repo: https://github.com/MarcoGorelli/madforhooks
37+
rev: 0.2.1
38+
hooks:
39+
- id: conda-env-sorter
40+
files: ^conda-envs/environment-dev-py.+\.yml$
3641
- repo: local
3742
hooks:
3843
- id: check-no-tests-are-ignored
44+
additional_dependencies: [pandas,pyyaml]
3945
entry: python scripts/check_all_tests_are_covered.py
4046
files: ^\.github/workflows/pytest\.yml$
4147
language: python
4248
name: Check no tests are ignored
4349
pass_filenames: false
44-
- id: conda-env-sort
45-
additional_dependencies: [pyyaml]
46-
entry: python scripts/sort_conda_envs.py
47-
files: ^conda-envs/environment-dev-py37\.yml$
48-
language: python
49-
name: Sort dependencies in conda envs
50-
types: [yaml]
5150
- id: pip-from-conda
5251
additional_dependencies: [pyyaml]
5352
entry: python scripts/generate_pip_deps_from_conda.py
54-
files: ^conda-envs/
53+
files: ^conda-envs/environment-dev-py.+.yml$
5554
language: python
5655
name: Generate pip dependency from conda
5756
- id: no-relative-imports

RELEASE-NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## PyMC 3.11.5 (TBD)
44
### Backports
55
+ The `pm.logp(rv, x)` syntax is now available and recommended to make your model code `v4`-ready. Note that this backport is just an alias and much less capable than what's available with `pymc >=4` (see [#5083](https://github.com/pymc-devs/pymc/pulls/5083)).
6+
+ The `pm.Distribution(testval=...)` kwarg was deprecated and will be replaced by `pm.Distribution(initval=...)`in `pymc >=4` (see [#5226](https://github.com/pymc-devs/pymc/pulls/5226)).
7+
+ The `pm.sample(start=...)` kwarg was deprecated and will be replaced by `pm.sample(initvals=...)`in `pymc >=4` (see [#5226](https://github.com/pymc-devs/pymc/pulls/5226)).
68

79
## PyMC3 3.11.4 (20 August 2021)
810

conda-envs/environment-dev-py37.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies:
1111
- numpy=1.15
1212
- numpydoc>=0.9
1313
- pandas=0.24
14+
- pip
1415
- pre-commit>=2.8.0
1516
- pytest-cov>=2.5
1617
- pytest>=3.0
@@ -21,3 +22,5 @@ dependencies:
2122
- sphinx-autobuild>=0.7
2223
- sphinx>=1.5
2324
- watermark
25+
- pip:
26+
- deprecat

conda-envs/environment-dev-py38.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
- mkl-service
1010
- nbsphinx>=0.4
1111
- numpydoc>=0.9
12+
- pip
1213
- pre-commit>=2.8.0
1314
- pytest-cov>=2.5
1415
- pytest>=3.0
@@ -18,3 +19,5 @@ dependencies:
1819
- sphinx-autobuild>=0.7
1920
- sphinx>=1.5
2021
- watermark
22+
- pip:
23+
- deprecat

conda-envs/environment-dev-py39.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
- mkl-service
1010
- nbsphinx>=0.4
1111
- numpydoc>=0.9
12+
- pip
1213
- pre-commit>=2.8.0
1314
- pytest-cov>=2.5
1415
- pytest>=3.0
@@ -18,3 +19,5 @@ dependencies:
1819
- sphinx-autobuild>=0.7
1920
- sphinx>=1.5
2021
- watermark
22+
- pip:
23+
- deprecat

conda-envs/windows-environment-dev-py38.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ dependencies:
2424
- sphinx-autobuild>=0.7
2525
- sphinx>=1.5
2626
- watermark
27+
- pip:
28+
- deprecat

docs/source/_static/main.css

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,130 @@
33
margin: 0.5em;
44
content: ":";
55
}
6+
7+
:root {
8+
--pst-color-primary: 19, 6, 84;
9+
--pst-color-success: 40, 167, 69;
10+
--pst-color-info: 0, 123, 255; /*23, 162, 184;*/
11+
--pst-color-warning: 255, 193, 7;
12+
--pst-color-danger: 220, 53, 69;
13+
--pst-color-text-base: 51, 51, 51;
14+
15+
--pst-color-admonition-default: var(--pst-color-info);
16+
--pst-color-admonition-note: var(--pst-color-info);
17+
--pst-color-admonition-attention: var(--pst-color-warning);
18+
--pst-color-admonition-caution: var(--pst-color-warning);
19+
--pst-color-admonition-warning: var(--pst-color-warning);
20+
--pst-color-admonition-danger: var(--pst-color-danger);
21+
--pst-color-admonition-error: var(--pst-color-danger);
22+
--pst-color-admonition-hint: var(--pst-color-success);
23+
--pst-color-admonition-tip: var(--pst-color-success);
24+
--pst-color-admonition-important: var(--pst-color-success);
25+
}
26+
27+
.admonition,
28+
div.admonition {
29+
margin:1.5625em auto;
30+
padding:0 .6rem .8rem;
31+
overflow:hidden;
32+
page-break-inside:avoid;
33+
border-left:.2rem solid;
34+
border-left-color:rgba(var(--pst-color-admonition-default),1);
35+
border-bottom-color:rgba(var(--pst-color-admonition-default),1);
36+
border-right-color:rgba(var(--pst-color-admonition-default),1);
37+
border-top-color:rgba(var(--pst-color-admonition-default),1);
38+
border-radius:.2rem;
39+
box-shadow:0 .2rem .5rem rgba(0,0,0,.05),0 0 .0625rem rgba(0,0,0,.1);
40+
transition:color .25s,background-color .25s,border-color .25s
41+
}
42+
.admonition :last-child,
43+
div.admonition :last-child {
44+
margin-bottom:0
45+
}
46+
.admonition p.admonition-title~*,
47+
div.admonition p.admonition-title~* {
48+
padding:0 1.4rem
49+
}
50+
.admonition>ol,
51+
.admonition>ul,
52+
div.admonition>ol,
53+
div.admonition>ul {
54+
margin-left:1em
55+
}
56+
.admonition>.admonition-title,
57+
div.admonition>.admonition-title {
58+
position:relative;
59+
margin:0 -.6rem;
60+
padding:.4rem .6rem .4rem 2rem;
61+
font-weight:700;
62+
background-color:rgba(var(--pst-color-admonition-default),.1)
63+
}
64+
.admonition>.admonition-title+*,
65+
div.admonition>.admonition-title+* {
66+
margin-top:.4em
67+
}
68+
.admonition.attention,
69+
div.admonition.attention {
70+
border-color:rgba(var(--pst-color-admonition-attention),1)
71+
}
72+
.admonition.attention>.admonition-title,
73+
div.admonition.attention>.admonition-title {
74+
background-color:rgba(var(--pst-color-admonition-attention),.1)
75+
}
76+
.admonition.caution,
77+
div.admonition.caution {
78+
border-color:rgba(var(--pst-color-admonition-caution),1)
79+
}
80+
.admonition.caution>.admonition-title,
81+
div.admonition.caution>.admonition-title {
82+
background-color:rgba(var(--pst-color-admonition-caution),.1)
83+
}
84+
div.admonition.warning {
85+
border-color:rgba(var(--pst-color-admonition-warning),1)
86+
}
87+
.admonition.warning>.admonition-title,
88+
div.admonition.warning>.admonition-title {
89+
background-color:rgba(var(--pst-color-admonition-warning),.1)
90+
}
91+
div.admonition.danger {
92+
border-color:rgba(var(--pst-color-admonition-danger),1)
93+
}
94+
.admonition.danger>.admonition-title,
95+
div.admonition.danger>.admonition-title {
96+
background-color:rgba(var(--pst-color-admonition-danger),.1)
97+
}
98+
div.admonition.error {
99+
border-color:rgba(var(--pst-color-admonition-error),1)
100+
}
101+
.admonition.error>.admonition-title,
102+
div.admonition.error>.admonition-title {
103+
background-color:rgba(var(--pst-color-admonition-error),.1)
104+
}
105+
div.admonition.hint {
106+
border-color:rgba(var(--pst-color-admonition-hint),1)
107+
}
108+
.admonition.hint>.admonition-title,
109+
div.admonition.hint>.admonition-title {
110+
background-color:rgba(var(--pst-color-admonition-hint),.1)
111+
}
112+
div.admonition.tip {
113+
border-color:rgba(var(--pst-color-admonition-tip),1)
114+
}
115+
.admonition.tip>.admonition-title,
116+
div.admonition.tip>.admonition-title {
117+
background-color:rgba(var(--pst-color-admonition-tip),.1)
118+
}
119+
div.admonition.important {
120+
border-color:rgba(var(--pst-color-admonition-important),1)
121+
}
122+
.admonition.important>.admonition-title,
123+
div.admonition.important>.admonition-title {
124+
background-color:rgba(var(--pst-color-admonition-important),.1)
125+
}
126+
div.admonition.note {
127+
border-color:rgba(var(--pst-color-admonition-note),1)
128+
}
129+
.admonition.note>.admonition-title,
130+
div.admonition.note>.admonition-title {
131+
background-color:rgba(var(--pst-color-admonition-note),.1)
132+
}

docs/source/sphinxext/gallery_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def build_gallery(srcdir, gallery):
194194
with open(table_of_contents_file) as toc:
195195
table_of_contents = toc.read()
196196

197-
js_contents = "Gallery.examples = {}\n{}".format(json.dumps(data), table_of_contents)
197+
js_contents = f"Gallery.examples = {json.dumps(data)}\n{table_of_contents}"
198198

199199
with open(js_file, "w") as js:
200200
js.write(js_contents)

pymc3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __set_compiler_flags():
6363

6464

6565
def _hotfix_theano_printing():
66-
""" This is a workaround for https://github.com/pymc-devs/aesara/issues/309 """
66+
"""This is a workaround for https://github.com/pymc-devs/aesara/issues/309"""
6767
try:
6868
import pydot
6969
import theano.printing

pymc3/backends/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def __getattr__(self, name):
364364
return self.get_values(name)
365365
if name in self.stat_names:
366366
return self.get_sampler_stats(name)
367-
raise AttributeError("'{}' object has no attribute '{}'".format(type(self).__name__, name))
367+
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
368368

369369
def __len__(self):
370370
chain = self.chains[-1]

0 commit comments

Comments
 (0)