astrofrog / fast-histogram

:zap: Fast 1D and 2D histogram functions in Python :zap:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Long doubles make histogram2d fail subtly, maybe add type check?

matteobachetti opened this issue · comments

I'm experimenting with various optimizations in the pulsar search code in HENDRICS (StingraySoftware/HENDRICS#65). One of my bottlenecks was a 2d histogram operation, and I gave a shot to yours. Tested with simulated data, everything worked and histogram2d was not a bottleneck anymore. Yay!
However...
When I used it on real data, Jupyter notebook was giving "dead kernel" messages with no information whatsoever. After spending one day banging my head, I tried to cast the longdouble arrays to double, and everything worked again.

It would help to add a type check, raising a ValueError or something similar if the number type is unsupported.

The code should normally cast to double automatically here:

https://github.com/astrofrog/fast-histogram/blob/master/fast_histogram/_histogram_core.c#L111

but it might be this doesn't work for long double somehow. If anyone wants to help investigate, please feel free to! (otherwise will try and look soon)

has there been any update in this? I am trying with np.float128 and it returns this error:

    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "/Users/tomascassanelli/anaconda3/lib/python3.8/site-packages/fast_histogram/histogram.py", line 58, in histogram1d
    return _histogram1d(x, nx, xmin, xmax)
RuntimeError: Couldn't set up iterator

I haven't had a chance to investigate