8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 58be67e commit 65538e8Copy full SHA for 65538e8
src/utils.py
@@ -16,7 +16,7 @@ def to_python_primitive(v: Any) -> Any:
16
17
Args:
18
v: Any value, particularly those with a 'source' attribute
19
- containing numpy arrays or generic types.
+ containing numpy arrays or generic types.
20
21
Returns:
22
The primitive representation of the input value.
@@ -29,6 +29,13 @@ def to_python_primitive(v: Any) -> Any:
29
return v.source.item()
30
31
return str(v.source)
32
+
33
+ if isinstance(v, (np.generic,)):
34
+ return v.item()
35
36
+ if isinstance(v, (np.ndarray,)):
37
+ return v.tolist()
38
39
return str(v)
40
41
0 commit comments