Skip to content
Snippets Groups Projects
Commit 05703d12 authored by Matthias Diener's avatar Matthias Diener
Browse files

simplify ravel

parent 41a208bc
No related branches found
No related tags found
No related merge requests found
...@@ -149,26 +149,10 @@ class _PytatoFakeNumpyNamespace(BaseFakeNumpyNamespace): ...@@ -149,26 +149,10 @@ class _PytatoFakeNumpyNamespace(BaseFakeNumpyNamespace):
return rec_multimap_array_container(pt.arctan2, y, x) return rec_multimap_array_container(pt.arctan2, y, x)
def ravel(self, a, order="C"): def ravel(self, a, order="C"):
def _rec_ravel(a): # FIXME: implement the other orders:
import pytato as pt # https://github.com/inducer/arraycontext/pull/14/#issuecomment-860886719
if order in "FC": import pytato as pt
return pt.reshape(a, (-1,), order=order) return pt.reshape(a, (-1,), order="C")
elif order == "A":
if a.flags.f_contiguous:
return pt.reshape(a, (-1,), order="F")
elif a.flags.c_contiguous:
return pt.reshape(a, (-1,), order="C")
else:
raise ValueError("For `order='A'`, array should be either"
" F-contiguous or C-contiguous.")
elif order == "K":
raise NotImplementedError("PytatoArrayContext.np.ravel not "
"implemented for 'order=K'")
else:
raise ValueError("`order` can be one of 'F', 'C', 'A' or 'K'. "
f"(got {order})")
return rec_map_array_container(_rec_ravel, a)
# }}} # }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment