prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  compress
  
  
  </issue>
  <code>
  [start of ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py]
  1 import ivy
  2 from ivy.functional.frontends.numpy.func_wrapper import (
  3     to_ivy_arrays_and_back,
  4     inputs_to_ivy_arrays,
  5 )
  6 
  7 
  8 @to_ivy_arrays_and_back
  9 def take_along_axis(arr, indices, axis):
  10     return ivy.take_along_axis(arr, indices, axis)
  11 
  12 
  13 @to_ivy_arrays_and_back
  14 def tril_indices(n, k=0, m=None):
  15     return ivy.tril_indices(n, m, k)
  16 
  17 
  18 @to_ivy_arrays_and_back
  19 def indices(dimensions, dtype=int, sparse=False):
  20     dimensions = tuple(dimensions)
  21     N = len(dimensions)
  22     shape = (1,) * N
  23     if sparse:
  24         res = tuple()
  25     else:
  26         res = ivy.empty((N,) + dimensions, dtype=dtype)
  27     for i, dim in enumerate(dimensions):
  28         idx = ivy.arange(dim, dtype=dtype).reshape(shape[:i] + (dim,) + shape[i + 1 :])
  29         if sparse:
  30             res = res + (idx,)
  31         else:
  32             res[i] = idx
  33     return res
  34 
  35 
  36 # unravel_index
  37 @to_ivy_arrays_and_back
  38 def unravel_index(indices, shape, order="C"):
  39     ret = [x.astype("int64") for x in ivy.unravel_index(indices, shape)]
  40     return tuple(ret)
  41 
  42 
  43 @to_ivy_arrays_and_back
  44 def fill_diagonal(a, val, wrap=False):
  45     if a.ndim < 2:
  46         raise ValueError("array must be at least 2-d")
  47     end = None
  48     if a.ndim == 2:
  49         # Explicit, fast formula for the common case.  For 2-d arrays, we
  50         # accept rectangular ones.
  51         step = a.shape[1] + 1
  52         # This is needed to don't have tall matrix have the diagonal wrap.
  53         if not wrap:
  54             end = a.shape[1] * a.shape[1]
  55     else:
  56         # For more than d=2, the strided formula is only valid for arrays with
  57         # all dimensions equal, so we check first.
  58         if not ivy.all(ivy.diff(a.shape) == 0):
  59             raise ValueError("All dimensions of input must be of equal length")
  60         step = 1 + ivy.sum(ivy.cumprod(a.shape[:-1]))
  61 
  62     # Write the value out into the diagonal.
  63     shape = a.shape
  64     a = ivy.reshape(a, a.size)
  65     a[:end:step] = val
  66     a = ivy.reshape(a, shape)
  67 
  68 
  69 @inputs_to_ivy_arrays
  70 def put_along_axis(arr, indices, values, axis):
  71     ivy.put_along_axis(arr, indices, values, axis)
  72 
  73 
  74 def diag(v, k=0):
  75     return ivy.diag(v, k=k)
  76 
  77 
  78 @to_ivy_arrays_and_back
  79 def diagonal(a, offset, axis1, axis2):
  80     return ivy.diagonal(a, offset=offset, axis1=axis1, axis2=axis2)
  81
  [end of ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py b/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py
  --- a/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py
  +++ b/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py
  @@ -2,6 +2,7 @@
   from ivy.functional.frontends.numpy.func_wrapper import (
       to_ivy_arrays_and_back,
       inputs_to_ivy_arrays,
  +    handle_numpy_out,
   )
   
   
  @@ -78,3 +79,22 @@
   @to_ivy_arrays_and_back
   def diagonal(a, offset, axis1, axis2):
       return ivy.diagonal(a, offset=offset, axis1=axis1, axis2=axis2)
  +
  +
  +@to_ivy_arrays_and_back
  +@handle_numpy_out
  +def compress(condition, a, axis=None, out=None):
  +    condition_arr = ivy.asarray(condition).astype(bool)
  +    if condition_arr.ndim != 1:
  +        raise ivy.utils.exceptions.IvyException("Condition must be a 1D array")
  +    if axis is None:
  +        arr = ivy.asarray(a).flatten()
  +        axis = 0
  +    else:
  +        arr = ivy.moveaxis(a, axis, 0)
  +    if condition_arr.shape[0] > arr.shape[0]:
  +        raise ivy.utils.exceptions.IvyException(
  +            "Condition contains entries that are out of bounds"
  +        )
  +    arr = arr[: condition_arr.shape[0]]
  +    return ivy.moveaxis(arr[condition_arr], 0, axis)
  
verification_info: {"golden_diff": "diff --git a/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py b/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py\n--- a/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py\n+++ b/ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py\n@@ -2,6 +2,7 @@\n from ivy.functional.frontends.numpy.func_wrapper import (\n     to_ivy_arrays_and_back,\n     inputs_to_ivy_arrays,\n+    handle_numpy_out,\n )\n \n \n@@ -78,3 +79,22 @@\n @to_ivy_arrays_and_back\n def diagonal(a, offset, axis1, axis2):\n     return ivy.diagonal(a, offset=offset, axis1=axis1, axis2=axis2)\n+\n+\n+@to_ivy_arrays_and_back\n+@handle_numpy_out\n+def compress(condition, a, axis=None, out=None):\n+    condition_arr = ivy.asarray(condition).astype(bool)\n+    if condition_arr.ndim != 1:\n+        raise ivy.utils.exceptions.IvyException(\"Condition must be a 1D array\")\n+    if axis is None:\n+        arr = ivy.asarray(a).flatten()\n+        axis = 0\n+    else:\n+        arr = ivy.moveaxis(a, axis, 0)\n+    if condition_arr.shape[0] > arr.shape[0]:\n+        raise ivy.utils.exceptions.IvyException(\n+            \"Condition contains entries that are out of bounds\"\n+        )\n+    arr = arr[: condition_arr.shape[0]]\n+    return ivy.moveaxis(arr[condition_arr], 0, axis)\n", "issue": "compress\n\n", "before_files": [{"content": "import ivy\nfrom ivy.functional.frontends.numpy.func_wrapper import (\n    to_ivy_arrays_and_back,\n    inputs_to_ivy_arrays,\n)\n\n\n@to_ivy_arrays_and_back\ndef take_along_axis(arr, indices, axis):\n    return ivy.take_along_axis(arr, indices, axis)\n\n\n@to_ivy_arrays_and_back\ndef tril_indices(n, k=0, m=None):\n    return ivy.tril_indices(n, m, k)\n\n\n@to_ivy_arrays_and_back\ndef indices(dimensions, dtype=int, sparse=False):\n    dimensions = tuple(dimensions)\n    N = len(dimensions)\n    shape = (1,) * N\n    if sparse:\n        res = tuple()\n    else:\n        res = ivy.empty((N,) + dimensions, dtype=dtype)\n    for i, dim in enumerate(dimensions):\n        idx = ivy.arange(dim, dtype=dtype).reshape(shape[:i] + (dim,) + shape[i + 1 :])\n        if sparse:\n            res = res + (idx,)\n        else:\n            res[i] = idx\n    return res\n\n\n# unravel_index\n@to_ivy_arrays_and_back\ndef unravel_index(indices, shape, order=\"C\"):\n    ret = [x.astype(\"int64\") for x in ivy.unravel_index(indices, shape)]\n    return tuple(ret)\n\n\n@to_ivy_arrays_and_back\ndef fill_diagonal(a, val, wrap=False):\n    if a.ndim < 2:\n        raise ValueError(\"array must be at least 2-d\")\n    end = None\n    if a.ndim == 2:\n        # Explicit, fast formula for the common case.  For 2-d arrays, we\n        # accept rectangular ones.\n        step = a.shape[1] + 1\n        # This is needed to don't have tall matrix have the diagonal wrap.\n        if not wrap:\n            end = a.shape[1] * a.shape[1]\n    else:\n        # For more than d=2, the strided formula is only valid for arrays with\n        # all dimensions equal, so we check first.\n        if not ivy.all(ivy.diff(a.shape) == 0):\n            raise ValueError(\"All dimensions of input must be of equal length\")\n        step = 1 + ivy.sum(ivy.cumprod(a.shape[:-1]))\n\n    # Write the value out into the diagonal.\n    shape = a.shape\n    a = ivy.reshape(a, a.size)\n    a[:end:step] = val\n    a = ivy.reshape(a, shape)\n\n\n@inputs_to_ivy_arrays\ndef put_along_axis(arr, indices, values, axis):\n    ivy.put_along_axis(arr, indices, values, axis)\n\n\ndef diag(v, k=0):\n    return ivy.diag(v, k=k)\n\n\n@to_ivy_arrays_and_back\ndef diagonal(a, offset, axis1, axis2):\n    return ivy.diagonal(a, offset=offset, axis1=axis1, axis2=axis2)\n", "path": "ivy/functional/frontends/numpy/indexing_routines/indexing_like_operations.py"}]}