Skip to content

Commit

Permalink
Handle str type in ParameterProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
schmoelder committed Dec 7, 2024
1 parent 12f541f commit 4dd0580
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cadet/cadet_dll_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,15 @@ def param_provider_get_string_array_item(
str_value = current_reader[name_str]
if isinstance(str_value, bytes):
bytes_val = str_value
else:
elif isinstance(str_value, str):
bytes_val = str_value.encode('utf-8')
elif isinstance(str_value, np.ndarray):
bytes_val = str_value[index]
else:
raise TypeError(
"Unexpected type for str_value. "
"Must be of type bytes, str, or np.ndarray."
)

reader.buffer = bytes_val
val[0] = ctypes.cast(reader.buffer, ctypes.c_char_p)
Expand Down

0 comments on commit 4dd0580

Please sign in to comment.