Skip to content

Commit

Permalink
Workflows: Handle Int/Float/Bool properly in Array init (#6632)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 9ab3559c101e4af60fa47866927952c469d1e2e7
  • Loading branch information
sdelany2 authored and Descartes Labs Build committed Apr 1, 2020
1 parent 3f20204 commit 229eb91
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions descarteslabs/workflows/types/array/array_.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ class Array(NumPyMixin, Proxytype):
def __init__(self, arr):
self._literal_value = arr

if isinstance(arr, (Int, Float, Bool)):
arr = arr.literal_value

if not isinstance(arr, np.ndarray):
try:
arr = np.asarray(arr)
except Exception:
raise ValueError("Cannot construct Array from {!r}".format(arr))
if isinstance(arr, (Int, Float, Bool, int, float, bool)):
self.graft = client.apply_graft("array.create", arr)
else:
if not isinstance(arr, np.ndarray):
try:
arr = np.asarray(arr)
except Exception:
raise ValueError("Cannot construct Array from {!r}".format(arr))

if arr.dtype.kind not in ("b", "i", "f"):
raise TypeError(
"Invalid dtype {} for an {}".format(arr.dtype, type(self).__name__)
)
if arr.dtype.kind not in ("b", "i", "f"):
raise TypeError(
"Invalid dtype {} for an {}".format(arr.dtype, type(self).__name__)
)

arr_list = arr.tolist()
self.graft = client.apply_graft("array.create", arr_list)
arr_list = arr.tolist()
self.graft = client.apply_graft("array.create", arr_list)

@classmethod
def _promote(cls, obj):
Expand Down

0 comments on commit 229eb91

Please sign in to comment.