LBL-EESA / fastkde

Other
50 stars 10 forks source link

Exception when running pdf_at_points with list_of_points #14

Closed pmacg closed 9 months ago

pmacg commented 1 year ago

When I run fastKDE.pdf_at_points(var1, var2, list_of_points=query_points) I get the following error:

File ".../lib/python3.9/site-packages/fastkde/fastKDE.py", line 1269, in pdf_at_points
    raise RuntimeError("Could not convert list_of_points to a numpy array.")
RuntimeError: Could not convert list_of_points to a numpy array.

I have included the minimal code example which reproduces this below.

This seems to be caused by using npy.float instead of npy.float_ when converting the list_of_points parameter.

Minimum Example

import numpy as np
from fastkde import fastKDE

var1 = np.array([1., 2.])
var2 = np.array([3., 2.])
query_points = [(1., 1.), (2., 2.)]

result = fastKDE.pdf_at_points(var1, var2, list_of_points=query_points)
print(result)

Fixed Version

import numpy as np
from fastkde import fastKDE

var1 = np.array([1., 2.])
var2 = np.array([3., 2.])
query_points = [(1., 1.), (2., 2.)]

np.float = np.float_
result = fastKDE.pdf_at_points(var1, var2, list_of_points=query_points)
print(result)