code: def test_buffer_get_host_array(ctx_factory):
      if cl._PYPY:
          # FIXME
          pytest.xfail("Buffer.get_host_array not yet working on pypy")
  
      ctx = ctx_factory()
      mf = cl.mem_flags
  
      rng = np.random.default_rng(seed=42)
      host_buf = rng.random(25, dtype=np.float32)
      buf = cl.Buffer(
          ctx, mf.READ_WRITE | mf.USE_HOST_PTR, hostbuf=host_buf
      )
      host_buf2 = buf.get_host_array(25, np.float32)
      assert (host_buf == host_buf2).all()
      assert (
          host_buf.__array_interface__["data"][0]
          == host_buf.__array_interface__["data"][0]
      )
      assert host_buf2.base is buf
  
      buf = cl.Buffer(ctx, mf.READ_WRITE | mf.ALLOC_HOST_PTR, size=100)
      try:
          host_buf2 = buf.get_host_array(25, np.float32)
          raise AssertionError(
              "MemoryObject.get_host_array should not accept buffer "
              "without USE_HOST_PTR"
          )
      except cl.LogicError:
          pass
  
      host_buf = rng.random(25, dtype=np.float32)
      buf = cl.Buffer(
          ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=host_buf
      )
      try:
          host_buf2 = buf.get_host_array(25, np.float32)
          raise AssertionError(
              "MemoryObject.get_host_array should not accept buffer "
              "without USE_HOST_PTR"
          )
      except cl.LogicError:
          pass
  
imports: import numpy
  import numpy.linalg
  import pytest
  import pyopencl
  import pyopencl.array
  import pyopencl.cltypes
  import pyopencl.clrandom
  from pyopencl.tools import pytest_generate_tests_for_pyopencl, ImmediateAllocator, DeferredAllocator
  from pyopencl.characterize import get_pocl_version
label_desc: Use image node_id 26 for calling a global function with example usage: test_buffer_get_host_array(ctx_factory) without return types