I am trying to do the following with nimpy. In python I can do,
>>>
>>> import numpy
>>> a = numpy.arange(5)
>>> for i in a:
print(i)
0
1
2
3
4
>>>
Similarly when I do the following using nimpy,
import nimpy
let numpy = pyImport("numpy")
let a = numpy.arange(5)
for i in a:
echo("i = ", $i)
I get this error:
call_py_2.nim(6, 10) Error: type mismatch: got <PyObject>
but expected one of:
iterator items(a: cstring): char
iterator items(E: typedesc[enum]): E:type
iterator items[IX, T](a: array[IX, T]): T
iterator items[T](a: set[T]): T
iterator items[T](a: openArray[T]): T
iterator items(a: string): char
iterator items[T](a: seq[T]): T
iterator items[T](s: HSlice[T, T]): T
How do I correct this?
I don't think nimpy works with numpy yet. You'd have to implement these functions: https://docs.scipy.org/doc/numpy-1.15.0/reference/c-api.array.html
But how it should work if a was a regular python array would be:
for i in a.to(seq[int]):
echo("i = ", $i)