Add tests for nested_dict_to_numpy and nested_dict_to_torch

This commit is contained in:
2025-03-18 13:13:47 +01:00
parent a30930b082
commit 5b6fd79b28
3 changed files with 84 additions and 32 deletions
+1 -1
View File
@@ -946,7 +946,7 @@ def nested_dict_to_torch(d, device=None):
elif isinstance(value, str):
new_dict[key] = value
elif isinstance(value, Mapping):
new_dict[key] = nested_dict_to_torch(value, dtype=dtype)
new_dict[key] = nested_dict_to_torch(value, device=device)
else:
raise ValueError(f'{value} is not a number, numpy array, torch tensor, string, or mapping')