Skip to content

Commit 222b84f

Browse files
committed
Raise ValueError when function_prefix is empty
1 parent 75472f0 commit 222b84f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

adaptive/utils.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def __call__(self, *args, **kwargs):
101101
return obj
102102

103103

104-
def _default_parameters(function, function_prefix: str = "", start_index: int = 1):
104+
def _default_parameters(
105+
function, function_prefix: str = "function.", start_index: int = 1
106+
):
105107
sig = inspect.signature(function)
106108
defaults = {
107109
f"{function_prefix}{k}": v.default
@@ -111,13 +113,20 @@ def _default_parameters(function, function_prefix: str = "", start_index: int =
111113
return defaults
112114

113115

114-
def assign_defaults(function, df, function_prefix: str = "", start_index: int = 1):
116+
def assign_defaults(
117+
function, df, function_prefix: str = "function.", start_index: int = 1
118+
):
115119
defaults = _default_parameters(function, function_prefix, start_index)
116120
for k, v in defaults.items():
117121
df[k] = len(df) * [v]
118122

119123

120-
def partial_function_from_dataframe(function, df, function_prefix: str = ""):
124+
def partial_function_from_dataframe(function, df, function_prefix: str = "function."):
125+
if function_prefix == "":
126+
raise ValueError(
127+
"The function_prefix cannot be an empty string because"
128+
" it is used to distinguish between function and learner parameters."
129+
)
121130
kwargs = {}
122131
for col in df.columns:
123132
if col.startswith(function_prefix):

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# -- Project information -----------------------------------------------------
1818

1919
project = "adaptive"
20-
copyright = "2018-2021, Adaptive Authors"
20+
copyright = "2018-2022, Adaptive Authors"
2121
author = "Adaptive Authors"
2222

2323
# The short X.Y version

0 commit comments

Comments
 (0)