From 7d31c4deb125c0c52303406f84764211e5c7da44 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Mon, 13 May 2024 12:16:40 +0200 Subject: [PATCH] Move prior package to top level --- baybe/kernels/base.py | 2 +- baybe/kernels/basic.py | 2 +- baybe/{kernels => }/priors/__init__.py | 4 ++-- baybe/{kernels => }/priors/base.py | 0 baybe/{kernels => }/priors/basic.py | 5 +++-- baybe/surrogates/gaussian_process.py | 2 +- tests/conftest.py | 2 +- tests/hypothesis_strategies/priors.py | 2 +- tests/serialization/test_prior_serialization.py | 2 +- tests/test_iterations.py | 2 +- 10 files changed, 12 insertions(+), 11 deletions(-) rename baybe/{kernels => }/priors/__init__.py (80%) rename baybe/{kernels => }/priors/base.py (100%) rename baybe/{kernels => }/priors/basic.py (96%) diff --git a/baybe/kernels/base.py b/baybe/kernels/base.py index a01a5a9d7..4ccde2007 100644 --- a/baybe/kernels/base.py +++ b/baybe/kernels/base.py @@ -7,7 +7,7 @@ from attrs import define -from baybe.kernels.priors.base import Prior +from baybe.priors.base import Prior from baybe.serialization.core import ( converter, get_base_structure_hook, diff --git a/baybe/kernels/basic.py b/baybe/kernels/basic.py index d4083bc54..af58d5f06 100644 --- a/baybe/kernels/basic.py +++ b/baybe/kernels/basic.py @@ -8,7 +8,7 @@ from attrs.validators import optional as optional_v from baybe.kernels.base import Kernel -from baybe.kernels.priors.base import Prior +from baybe.priors.base import Prior from baybe.utils.conversion import fraction_to_float from baybe.utils.validation import finite_float diff --git a/baybe/kernels/priors/__init__.py b/baybe/priors/__init__.py similarity index 80% rename from baybe/kernels/priors/__init__.py rename to baybe/priors/__init__.py index 459e45d27..b133c61f9 100644 --- a/baybe/kernels/priors/__init__.py +++ b/baybe/priors/__init__.py @@ -1,6 +1,6 @@ -"""Available priors.""" +"""Prior distributions.""" -from baybe.kernels.priors.basic import ( +from baybe.priors.basic import ( GammaPrior, HalfCauchyPrior, HalfNormalPrior, diff --git a/baybe/kernels/priors/base.py b/baybe/priors/base.py similarity index 100% rename from baybe/kernels/priors/base.py rename to baybe/priors/base.py diff --git a/baybe/kernels/priors/basic.py b/baybe/priors/basic.py similarity index 96% rename from baybe/kernels/priors/basic.py rename to baybe/priors/basic.py index 0c1b57f50..28536157d 100644 --- a/baybe/kernels/priors/basic.py +++ b/baybe/priors/basic.py @@ -1,10 +1,11 @@ -"""Priors that can be used for kernels.""" +"""A collection of common prior distributions.""" + from typing import Any from attrs import define, field from attrs.validators import gt -from baybe.kernels.priors.base import Prior +from baybe.priors.base import Prior from baybe.utils.validation import finite_float diff --git a/baybe/surrogates/gaussian_process.py b/baybe/surrogates/gaussian_process.py index ec462a692..49679cc36 100644 --- a/baybe/surrogates/gaussian_process.py +++ b/baybe/surrogates/gaussian_process.py @@ -8,7 +8,7 @@ from baybe.kernels import MaternKernel, ScaleKernel from baybe.kernels.base import Kernel -from baybe.kernels.priors import GammaPrior +from baybe.priors import GammaPrior from baybe.searchspace import SearchSpace from baybe.surrogates.base import Surrogate diff --git a/tests/conftest.py b/tests/conftest.py index 6216ccf5a..d94c2bbcc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,7 +28,6 @@ ) from baybe.exceptions import OptionalImportError from baybe.kernels import MaternKernel -from baybe.kernels.priors import GammaPrior from baybe.objectives.desirability import DesirabilityObjective from baybe.objectives.single import SingleTargetObjective from baybe.parameters import ( @@ -39,6 +38,7 @@ SubstanceEncoding, TaskParameter, ) +from baybe.priors import GammaPrior from baybe.recommenders.meta.base import MetaRecommender from baybe.recommenders.meta.sequential import ( SequentialMetaRecommender, diff --git a/tests/hypothesis_strategies/priors.py b/tests/hypothesis_strategies/priors.py index c438f9404..6ff647de4 100644 --- a/tests/hypothesis_strategies/priors.py +++ b/tests/hypothesis_strategies/priors.py @@ -2,7 +2,7 @@ import hypothesis.strategies as st -from baybe.kernels.priors import ( +from baybe.priors import ( GammaPrior, HalfCauchyPrior, HalfNormalPrior, diff --git a/tests/serialization/test_prior_serialization.py b/tests/serialization/test_prior_serialization.py index cd75b3363..79653fe80 100644 --- a/tests/serialization/test_prior_serialization.py +++ b/tests/serialization/test_prior_serialization.py @@ -2,7 +2,7 @@ from hypothesis import given -from baybe.kernels.priors.base import Prior +from baybe.priors.base import Prior from tests.hypothesis_strategies.priors import priors diff --git a/tests/test_iterations.py b/tests/test_iterations.py index 1077f030f..f48d09b89 100644 --- a/tests/test_iterations.py +++ b/tests/test_iterations.py @@ -6,7 +6,7 @@ from baybe.acquisition.base import AcquisitionFunction from baybe.kernels import MaternKernel, ScaleKernel -from baybe.kernels.priors import ( +from baybe.priors import ( GammaPrior, HalfCauchyPrior, HalfNormalPrior,