Skip to content

Commit cf49cae

Browse files
committed
Fix pre-commit
1 parent f90b714 commit cf49cae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1571
-958
lines changed

.pre-commit-config.yaml

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exclude: ^(docs/logos|homepy/tests|)/
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.0.1
4+
rev: v5.0.0
55
hooks:
66
- id: check-merge-conflict
77
- id: check-toml
@@ -13,46 +13,31 @@ repos:
1313
- id: requirements-txt-fixer
1414
exclude: ^requirements-dev\.txt$
1515
- id: trailing-whitespace
16-
- repo: https://github.com/PyCQA/isort
17-
rev: 5.12.0
18-
hooks:
19-
- id: isort
20-
name: isort
21-
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.29.1
23-
hooks:
24-
- id: pyupgrade
25-
args: [--py37-plus]
26-
- repo: https://github.com/psf/black
27-
rev: 22.3.0
28-
hooks:
29-
- id: black
30-
- repo: https://github.com/PyCQA/pylint
31-
rev: v2.12.1
32-
hooks:
33-
- id: pylint
34-
args: [--rcfile=.pylintrc]
35-
files: ^homepy/
3616
- repo: https://github.com/MarcoGorelli/madforhooks
37-
rev: 0.2.1
17+
rev: 0.4.1
3818
hooks:
3919
- id: no-print-statements
4020
files: ^homepy/
4121
- id: conda-env-sorter
4222
files: ^conda-envs/environment-dev-py.+\.yml$
43-
- repo: https://github.com/nbQA-dev/nbQA
44-
rev: 1.6.1
45-
hooks:
46-
- id: nbqa-pyupgrade
47-
additional_dependencies: [pyupgrade==2.29.1]
48-
args: ["--py37-plus"]
49-
- id: nbqa-isort
50-
additional_dependencies: [isort==5.12.0]
51-
- id: nbqa-black
52-
additional_dependencies: [black==22.3.0]
53-
- id: nbqa-pylint
54-
args: [--rcfile=.pylintrc]
55-
additional_dependencies: [pylint==2.12.1]
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: v0.12.7
25+
hooks:
26+
- id: ruff
27+
types_or:
28+
- python
29+
- pyi
30+
- jupyter
31+
args:
32+
- --fix
33+
- --exit-non-zero-on-fix
34+
exclude: ^(docs)
35+
- id: ruff-format
36+
types_or:
37+
- python
38+
- pyi
39+
- jupyter
40+
exclude: ^(docs)
5641
- repo: local
5742
hooks:
5843
- id: check-no-tests-are-ignored
@@ -68,3 +53,11 @@ repos:
6853
files: ^conda-envs/environment-dev-py.+.yml$
6954
language: python
7055
name: Generate pip dependency from conda
56+
- repo: https://github.com/lucianopaz/head_of_apache
57+
rev: "0.1.1"
58+
hooks:
59+
- id: head_of_apache
60+
args:
61+
- --author
62+
- PyMC Labs
63+
- --last-year-present

docs/02_modeling.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5796,4 +5796,4 @@
57965796
},
57975797
"nbformat": 4,
57985798
"nbformat_minor": 5
5799-
}
5799+
}

docs/04_customizing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3883,4 +3883,4 @@
38833883
},
38843884
"nbformat": 4,
38853885
"nbformat_minor": 5
3886-
}
3886+
}

docs/05_predicting.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8614,4 +8614,4 @@
86148614
},
86158615
"nbformat": 4,
86168616
"nbformat_minor": 5
8617-
}
8617+
}

docs/08_gp_refresher.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,4 @@
589589
},
590590
"nbformat": 4,
591591
"nbformat_minor": 5
592-
}
592+
}

homepy/__init__.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
"""
2-
Copyright 2023-present PyMC Labs
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
"""
16-
17-
18-
import re
19-
import warnings
20-
21-
# Suppress JAX omnistaging from pytensor
22-
warnings.filterwarnings(
23-
"ignore",
24-
category=UserWarning,
25-
message=re.escape("JAX omnistaging couldn't be disabled:"),
26-
)
1+
# Copyright 2023 - present PyMC Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
2714

2815
from homepy import (
29-
pytensorf,
3016
blocks,
3117
jax_utils,
3218
model_comparison,
3319
models,
3420
nested_hierarchy_rvs,
3521
nested_hierarchy_utils,
22+
pytensorf,
3623
utils,
3724
)
3825

26+
__all__ = [
27+
"pytensorf",
28+
"blocks",
29+
"jax_utils",
30+
"model_comparison",
31+
"models",
32+
"nested_hierarchy_rvs",
33+
"nested_hierarchy_utils",
34+
"utils",
35+
]
36+
3937
__version__ = "0.0.2"

homepy/blocks/__init__.py

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,63 @@
1-
"""
2-
Copyright 2023-present PyMC Labs
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
"""
16-
1+
# Copyright 2023 - present PyMC Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
1714

1815
from homepy.blocks import base, distributions, gp, likelihoods, linear
19-
from homepy.blocks.base import *
20-
from homepy.blocks.gp import *
21-
from homepy.blocks.likelihoods import *
22-
from homepy.blocks.linear import *
16+
from homepy.blocks.base import (
17+
MethodNotImplementedError,
18+
ModelBlock,
19+
SortNestedHierarchies,
20+
)
21+
from homepy.blocks.gp import (
22+
WithinBlockCorrelatedGP,
23+
WithinBlockCorrelatedGPBase,
24+
WithinBlockGP,
25+
WithinBlockLKJCorrelatedGP,
26+
)
27+
from homepy.blocks.likelihoods import (
28+
GeneralizedPoissonLikelihood,
29+
NegBinLikelihood,
30+
NormalLikelihood,
31+
PoissonLikelihood,
32+
ZeroInfNegBinLikelihood,
33+
)
34+
from homepy.blocks.linear import (
35+
BaselineActivity,
36+
LinearLongTermTrend,
37+
QuadraticLongTermTrend,
38+
SummaryCalculator,
39+
)
40+
41+
__all__ = [
42+
"base",
43+
"distributions",
44+
"gp",
45+
"likelihoods",
46+
"linear",
47+
"ModelBlock",
48+
"MethodNotImplementedError",
49+
"SortNestedHierarchies",
50+
"WithinBlockGP",
51+
"WithinBlockLKJCorrelatedGP",
52+
"WithinBlockCorrelatedGP",
53+
"WithinBlockCorrelatedGPBase",
54+
"NegBinLikelihood",
55+
"ZeroInfNegBinLikelihood",
56+
"NormalLikelihood",
57+
"PoissonLikelihood",
58+
"GeneralizedPoissonLikelihood",
59+
"SummaryCalculator",
60+
"BaselineActivity",
61+
"LinearLongTermTrend",
62+
"QuadraticLongTermTrend",
63+
]

homepy/blocks/base.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
"""
2-
Copyright 2023-present PyMC Labs
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
"""
16-
1+
# Copyright 2023 - present PyMC Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
1714

1815
import warnings
19-
2016
from typing import Dict, Iterable, List, Optional
2117

22-
from pytensor.tensor import TensorVariable
2318
from arviz import InferenceData
2419
from pandas import DataFrame
20+
from pytensor.tensor import TensorVariable
2521

2622
from homepy.nested_hierarchy_utils import (
2723
NestedHierarchy,
@@ -94,9 +90,15 @@ class ModelBlock:
9490
default_config_key = "base"
9591

9692
def __init__(
97-
self, *, data=None, config: Optional[Dict] = None, config_key: Optional[str] = None
93+
self,
94+
*,
95+
data=None,
96+
config: Optional[Dict] = None,
97+
config_key: Optional[str] = None,
9898
):
99-
self.config_key = config_key if config_key is not None else self.default_config_key
99+
self.config_key = (
100+
config_key if config_key is not None else self.default_config_key
101+
)
100102
self.level_random_effects = None
101103

102104
def read_config(self, config=None):
@@ -125,7 +127,9 @@ def make_observations(self, inputs, *, data=None, config: Optional[Dict] = None)
125127
f"{self.__class__} class does not implement a make_observations method"
126128
)
127129

128-
def sum_reduce_inputs(self, inputs: Iterable[Optional[TensorVariable]]) -> TensorVariable:
130+
def sum_reduce_inputs(
131+
self, inputs: Iterable[Optional[TensorVariable]]
132+
) -> TensorVariable:
129133
return sum(i for i in inputs if i is not None)
130134

131135
def make_summaries(
@@ -153,7 +157,8 @@ def make_summaries(
153157
selected_summaries = [
154158
method_name
155159
for method_name in dir(self)
156-
if callable(getattr(self, method_name)) and method_name.startswith("summary_")
160+
if callable(getattr(self, method_name))
161+
and method_name.startswith("summary_")
157162
]
158163
summaries = {}
159164
for summary_method in selected_summaries:
@@ -181,7 +186,8 @@ def make_plots(
181186
selected_plots = [
182187
method_name
183188
for method_name in dir(self)
184-
if callable(getattr(self, method_name)) and method_name.startswith("plot_")
189+
if callable(getattr(self, method_name))
190+
and method_name.startswith("plot_")
185191
]
186192
plots = {}
187193
for plot_method in selected_plots:

0 commit comments

Comments
 (0)