fix: Crash caused by numpy.vectorize (#21936)

This commit is contained in:
John Bodley 2022-10-26 15:06:18 -07:00 committed by GitHub
parent 40024064ae
commit 059e53a39f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -63,8 +63,13 @@ def stringify(obj: Any) -> str:
def stringify_values(array: np.ndarray) -> np.ndarray:
vstringify = np.vectorize(stringify)
return vstringify(array)
result = np.copy(array)
with np.nditer(result, flags=["refs_ok"], op_flags=["readwrite"]) as it:
for obj in it:
obj[...] = stringify(obj)
return result
def destringify(obj: str) -> Any: