Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/test_treegp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ]
python-version: [ 3.9, "3.10", "3.11", "3.12", "3.13" ]

steps:
- uses: actions/checkout@v2
Expand Down
18 changes: 10 additions & 8 deletions treegp/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
kernel = sklearn.gaussian_process.kernels.RBF(1)
"""

namespace = {}

def recurse_subclasses(cls):
out = []
for c in cls.__subclasses__():
Expand All @@ -36,17 +38,17 @@

clses = recurse_subclasses(Kernel)
for cls in clses:
module = __import__(cls.__module__, globals(), locals(), cls)
execstr = "{0} = module.{0}".format(cls.__name__)
exec(execstr, globals(), locals())
module = __import__(cls.__module__, globals(), namespace, [cls.__name__])
namespace[cls.__name__] = getattr(module, cls.__name__)

from numpy import array # if needed in the namespace

from numpy import array # noqa: F401
# Add array to the namespace if necessary
namespace["array"] = array

try:
k = eval(kernel)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e: # pragma: no cover
k = eval(kernel, namespace)
except Exception as e:

Check warning on line 51 in treegp/kernels.py

View check run for this annotation

Codecov / codecov/patch

treegp/kernels.py#L51

Added line #L51 was not covered by tests
raise RuntimeError(
"Failed to evaluate kernel string {0!r}. "
"Original exception: {1}".format(kernel, e)
Expand Down