3

I'm using Arrayfire on Python and I can't use the af.sum() function since my input array has NaNs in it and it would return NAN as sum.

Using numpy.nansum/numpy.nan_to_num is not an option due to speed problems.

I just need a way to convert those NaNs to floating point zeros in arrayfire.

ggdm
  • 31
  • 1
  • I overwent the problem eliminating the cause, that is the algebraic operations prior to the creation of the raster with NaNs. Still interesting if someone could answer this question, maybe someone from Arrayfire coders. – ggdm Sep 25 '12 at 12:27
  • I am the developer of ArrayFire + Python. I just realized there is no "isnan" function in the library. I will be adding it as soon as possible. Ping me to know when you can download it. Email address is on my profile. – Pavan Yalamanchili Sep 25 '12 at 18:11

2 Answers2

1

bottleneck is worth looking into. They have performed several optimizations over the numpy.nanxxx functions which, in my experience, makes it around 5x faster than numpy.

tnknepp
  • 5,888
  • 6
  • 43
  • 57
0

You could use numpy.nansum, which treats nan as 0 in the array sum.

numpy.nansum(arrayfire)
Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
  • As I said converting an arrayfire.array to a numpy.array and operating on it works (except for memory errors in the long term) but it's too slow for my script. I need some expression to check against NaN using arrayfire python module: [Arrayfire](http://www.accelereyes.com/arrayfire/python/modules.htm) – ggdm Sep 25 '12 at 11:46