Skip to content
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

Add support python 3.11 #109

Merged
merged 6 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.11"

- name: Install pypa/build
run: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
juanitorduz marked this conversation as resolved.
Show resolved Hide resolved

name: Set up Python ${{ matrix.python-version }}
steps:
Expand Down
9 changes: 0 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ disable=missing-docstring,
too-many-branches,
too-many-statements,
too-many-instance-attributes,
no-self-use,
too-few-public-methods,
bad-continuation,
import-error,
protected-access

Expand Down Expand Up @@ -136,13 +134,6 @@ max-line-length=100
# Maximum number of lines in a module
max-module-lines=1000

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand Down
36 changes: 18 additions & 18 deletions pymc_bart/bart.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from multiprocessing import Manager
from typing import List, Optional, Tuple
import warnings

import numpy as np
import numpy.typing as npt
Expand All @@ -26,9 +26,9 @@
from pymc.logprob.abstract import _logprob
from pytensor.tensor.random.op import RandomVariable

from .split_rules import SplitRule
from .tree import Tree
from .utils import TensorLike, _sample_posterior
from .split_rules import SplitRule

__all__ = ["BART"]

Expand All @@ -47,7 +47,7 @@ def _supp_shape_from_params(self, dist_params, rep_param_idx=1, param_shapes=Non
return dist_params[0].shape[:1]

@classmethod
def rng_fn(
def rng_fn( # pylint: disable=W0237
cls, rng=None, X=None, Y=None, m=None, alpha=None, beta=None, split_prior=None, size=None
):
if not cls.all_trees:
Expand Down Expand Up @@ -147,21 +147,21 @@ def __new__(
bart_op = type(
f"BART_{name}",
(BARTRV,),
dict(
name="BART",
all_trees=cls.all_trees,
inplace=False,
initval=Y.mean(),
X=X,
Y=Y,
m=m,
response=response,
alpha=alpha,
beta=beta,
split_prior=split_prior,
split_rules=split_rules,
separate_trees=separate_trees,
),
{
"name": "BART",
"all_trees": cls.all_trees,
"inplace": False,
"initval": Y.mean(),
"X": X,
"Y": Y,
"m": m,
"response": response,
"alpha": alpha,
"beta": beta,
"split_prior": split_prior,
"split_rules": split_rules,
"separate_trees": separate_trees,
},
)()

Distribution.register(BARTRV)
Expand Down
12 changes: 10 additions & 2 deletions pymc_bart/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ def plot_ice(
rng = np.random.default_rng(random_seed)

if func is None:
func = lambda x: x

def identity(x):
return x

func = identity

(
X,
Expand Down Expand Up @@ -392,7 +396,11 @@ def plot_pdp(
rng = np.random.default_rng(random_seed)

if func is None:
func = lambda x: x

def identity(x):
return x

func = identity

(
X,
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ click==8.0.4
mypy>=1.1.1
pandas-stubs==1.5.3.230304
pre-commit
pylint==2.10.2
pylint==2.17.4
pytest-cov>=2.6.1
pytest>=4.4.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
Expand Down