Thanks for the contributions. Took a while but I got the function done. My problem was in the first two lines, I had to import the python file in my test code which I did not do earlier