import arrayfire

# We're going to test several arrayfire behaviours that we rely on


from asserts import *
import afnumpy as af
import numpy as np

def test_cast():
    a = afnumpy.random.rand(2,3)
    # Check that device_ptr does not cause a copy
    assert a.d_array.device_ptr() == a.d_array.device_ptr()
    # Check that cast does not cause a copy
    assert arrayfire.cast(a.d_array, a.d_array.dtype()).device_ptr() == a.d_array.device_ptr()

import arrayfire

# We're going to test several arrayfire behaviours that we rely on


from asserts import *
import afnumpy as af
import numpy as np

def test_af_cast():
    a = afnumpy.arrayfire.randu(2,3)
    # Check that device_ptr does not cause a copy
    assert a.device_ptr() == a.device_ptr()
    # Check that cast does not cause a copy
    assert arrayfire.cast(a, a.dtype()).device_ptr() == a.device_ptr()

def test_cast():
    a = afnumpy.random.rand(2,3)
    # Check that device_ptr does not cause a copy
    assert a.d_array.device_ptr() == a.d_array.device_ptr()
    # Check that cast does not cause a copy
    assert arrayfire.cast(a.d_array, a.d_array.dtype()).device_ptr() == a.d_array.device_ptr()

Add a pure arrayfire cast test to check for seg faults
Add a pure arrayfire cast test to check for seg faults

  import arrayfire
  
  # We're going to test several arrayfire behaviours that we rely on
  
  
  from asserts import *
  import afnumpy as af
  import numpy as np
  
+ def test_af_cast():
+     a = afnumpy.arrayfire.randu(2,3)
+     # Check that device_ptr does not cause a copy
+     assert a.device_ptr() == a.device_ptr()
+     # Check that cast does not cause a copy
+     assert arrayfire.cast(a, a.dtype()).device_ptr() == a.device_ptr()
+ 
  def test_cast():
      a = afnumpy.random.rand(2,3)
      # Check that device_ptr does not cause a copy
      assert a.d_array.device_ptr() == a.d_array.device_ptr()
      # Check that cast does not cause a copy
      assert arrayfire.cast(a.d_array, a.d_array.dtype()).device_ptr() == a.d_array.device_ptr()
  
Add a pure arrayfire cast test to check for seg faults
## Code Before:
import arrayfire

# We're going to test several arrayfire behaviours that we rely on


from asserts import *
import afnumpy as af
import numpy as np

def test_cast():
    a = afnumpy.random.rand(2,3)
    # Check that device_ptr does not cause a copy
    assert a.d_array.device_ptr() == a.d_array.device_ptr()
    # Check that cast does not cause a copy
    assert arrayfire.cast(a.d_array, a.d_array.dtype()).device_ptr() == a.d_array.device_ptr()

## Instruction:
Add a pure arrayfire cast test to check for seg faults
## Code After:
import arrayfire

# We're going to test several arrayfire behaviours that we rely on


from asserts import *
import afnumpy as af
import numpy as np

def test_af_cast():
    a = afnumpy.arrayfire.randu(2,3)
    # Check that device_ptr does not cause a copy
    assert a.device_ptr() == a.device_ptr()
    # Check that cast does not cause a copy
    assert arrayfire.cast(a, a.dtype()).device_ptr() == a.device_ptr()

def test_cast():
    a = afnumpy.random.rand(2,3)
    # Check that device_ptr does not cause a copy
    assert a.d_array.device_ptr() == a.d_array.device_ptr()
    # Check that cast does not cause a copy
    assert arrayfire.cast(a.d_array, a.d_array.dtype()).device_ptr() == a.d_array.device_ptr()
