Skip to content

Commit

Permalink
Revert "refactor: directly use nplike.asarray"
Browse files Browse the repository at this point in the history
This reverts commit f52401e.
  • Loading branch information
agoose77 committed Jan 21, 2023
1 parent 5be618c commit 03ef002
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/awkward/_nplikes.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,13 @@ def raw(self, array: ArrayLike, nplike: NumpyLike) -> ArrayLike:
if isinstance(nplike, Numpy):
return array
elif isinstance(nplike, Cupy):
return nplike.asarray(array, order="C")
cupy = Cupy.instance()
return cupy.asarray(array, dtype=array.dtype, order="C")
elif isinstance(nplike, ak._typetracer.TypeTracer):
return nplike.asarray(array)
return ak._typetracer.TypeTracerArray(dtype=array.dtype, shape=array.shape)
elif isinstance(nplike, Jax):
jax = Jax.instance()
return jax.asarray(array)
return jax.asarray(array, dtype=array.dtype)
else:
raise ak._errors.wrap_error(
TypeError(
Expand Down Expand Up @@ -595,11 +596,13 @@ def raw(self, array: ArrayLike, nplike: NumpyLike) -> ArrayLike:
if isinstance(nplike, Cupy):
return array
elif isinstance(nplike, Numpy):
return nplike.asarray(array.get(), dtype=array.dtype, order="C")
numpy = Numpy.instance()
return numpy.asarray(array.get(), dtype=array.dtype, order="C")
elif isinstance(nplike, ak._typetracer.TypeTracer):
return nplike.asarray(array, dtype=array.dtype)
return ak._typetracer.TypeTracerArray(dtype=array.dtype, shape=array.shape)
elif isinstance(nplike, Jax):
return nplike.asarray(array.get(), dtype=array.dtype)
jax = Jax.instance()
return jax.asarray(array.get(), dtype=array.dtype)
else:
raise ak._errors.wrap_error(
TypeError(
Expand Down Expand Up @@ -760,11 +763,13 @@ def raw(self, array: ArrayLike, nplike: NumpyLike) -> ArrayLike:
if isinstance(nplike, Jax):
return array
elif isinstance(nplike, ak._nplikes.Cupy):
return nplike.asarray(array)
cupy = ak._nplikes.Cupy.instance()
return cupy.asarray(array)
elif isinstance(nplike, ak._nplikes.Numpy):
return nplike.asarray(array)
numpy = ak._nplikes.Numpy.instance()
return numpy.asarray(array)
elif isinstance(nplike, ak._typetracer.TypeTracer):
return nplike.asarray(array, dtype=array.dtype)
return ak._typetracer.TypeTracerArray(dtype=array.dtype, shape=array.shape)
else:
raise ak._errors.wrap_error(
TypeError(
Expand Down

0 comments on commit 03ef002

Please sign in to comment.