Skip to content

Commit 0d3dcd2

Browse files
[Andrew Polyakov] Change python-executor to correctly serialise numpy types
1 parent e651988 commit 0d3dcd2

File tree

1 file changed

+13
-5
lines changed
  • utbot-python-executor/src/main/python/utbot_executor/utbot_executor/deep_serialization

1 file changed

+13
-5
lines changed

utbot-python-executor/src/main/python/utbot_executor/utbot_executor/deep_serialization/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def get_constructor_info(constructor: object, obj: object) -> TypeInfo:
9595

9696

9797
def has_reduce(py_object: object) -> bool:
98+
if get_kind(py_object).module == "numpy":
99+
return False
98100
reduce = getattr(py_object, "__reduce__", None)
99101
if reduce is None:
100102
return False
@@ -161,6 +163,10 @@ def check_eval(py_object: object) -> bool:
161163
except Exception:
162164
return False
163165

166+
try:
167+
import numpy as np
168+
except ImportError:
169+
pass
164170

165171
def has_repr(py_object: object) -> bool:
166172
reprable_types = [
@@ -171,11 +177,13 @@ def has_repr(py_object: object) -> bool:
171177
bytes,
172178
bytearray,
173179
str,
174-
# tuple,
175-
# list,
176-
# dict,
177-
# set,
178-
# frozenset,
180+
np.int64,
181+
np.int32,
182+
np.int16,
183+
np.int8,
184+
np.float32,
185+
np.float16,
186+
np.float64,
179187
type,
180188
]
181189
if type(py_object) in reprable_types:

0 commit comments

Comments
 (0)