Create an array in taichi kernel

Hello, can anyone tell me how to create an array in taichi kernel and loop through it?

I have a sample code here:

    @ti.kernel
    def intersect(self):
        for i in self.X:
            v = 1.0
            rad_arr = np.arange(0.02, v+0.02, v/5.0)

and my error is the following:

  File "myfilename.py", line 234, in solve
    self.intersect()
  File "/usr/local/lib/python3.7/site-packages/taichi/lang/kernel.py", line 606, in __call__
    return self._primal(self._kernel_owner, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/taichi/lang/kernel.py", line 501, in __call__
    self.materialize(key=key, args=args, arg_features=arg_features)
  File "/usr/local/lib/python3.7/site-packages/taichi/lang/kernel.py", line 370, in materialize
    taichi_kernel = taichi_kernel.define(taichi_ast_generator)
  File "/usr/local/lib/python3.7/site-packages/taichi/lang/kernel.py", line 367, in taichi_ast_generator
    compiled()
  File "myfilename.py", line 143, in intersect
    rad_arr = np.arange(0.02, v+0.02, v/5.0)
TypeError: must be real number, not Expr

Dynamically allocating memory inside a kernel is impossible in current version of Taichi. This is because the compiled kernel is executed in a non-Python environment (e.g. CUDA or OpenGL shader), only primitive types (int, float) are supported, Python objects won’t be available.
The error message TypeError: must be real number, not Expr is because v is an ti.Expr, which is not float, but a dummy ‘node’ for generating CUDA / GLSL codes from Python code. (If you’re familiar about tensorflow, then ti.Expr and ti.Expr.__add__ is similar to tf.constant, tf.add, etc.)

Try this if that’s what you want:

@ti.kernel
def intersect(self):
  for i in self.X:
    v = 1.0
    x = 0.02
    while x < v + 0.02:
      print(x)
      x += v / 5.0