Skip to content

Commit b5bd503

Browse files
0.12.7
new function: map_to_True_False
1 parent 7371100 commit b5bd503

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotPython"
10-
version = "0.12.6"
10+
version = "0.12.7"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/utils/convert.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,27 @@ def add_logical_columns(X, arity=2, operations=["and", "or", "xor"]):
115115
# Join all the new columns at once
116116
X = pd.concat([X] + new_cols, axis=1)
117117
return X
118+
119+
120+
def map_to_True_False(value):
121+
"""
122+
Map the string value to a boolean value.
123+
If the value is "True" or "true", return True.
124+
Otherwise, return False.
125+
126+
Args:
127+
value (str):
128+
The string to be mapped to a boolean value.
129+
Returns:
130+
bool:
131+
True if the value is "True" or "true", False otherwise.
132+
133+
Examples:
134+
>>> from spotPython.utils.convert import map_to_True_False
135+
map_to_True_False("True")
136+
True
137+
"""
138+
if value.lower() == "true":
139+
return True
140+
else:
141+
return False

0 commit comments

Comments
 (0)