Skip to content
Prev Previous commit
Next Next commit
fix: get none valued study object from server
  • Loading branch information
LennartPurucker committed Oct 14, 2024
commit 339172520271111b2d53264a1d045d27ca0de5e9
6 changes: 6 additions & 0 deletions openml/study/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ def _get_study(id_: int | str, entity_type: str) -> BaseStudy:
alias = result_dict.get("oml:alias", None)
main_entity_type = result_dict["oml:main_entity_type"]

# Parses edge cases where the server returns a string with a newline character for empty values.
none_value_indicator = "\n "
for key in result_dict:
if result_dict[key] == none_value_indicator:
result_dict[key] = None

if entity_type != main_entity_type:
raise ValueError(
f"Unexpected entity type '{main_entity_type}' reported by the server"
Expand Down