Skip to content

Commit

Permalink
fix xarray 1D bug, add test, add example
Browse files Browse the repository at this point in the history
  • Loading branch information
taobrienlbl committed Mar 27, 2024
1 parent 560df37 commit 81d0e35
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 114 deletions.
4 changes: 2 additions & 2 deletions examples/Plotting.ipynb

Large diffs are not rendered by default.

258 changes: 154 additions & 104 deletions examples/fastKDE and xarray.ipynb

Large diffs are not rendered by default.

84 changes: 77 additions & 7 deletions examples/readme_test.ipynb

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/fastkde/fastKDE.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,10 @@ def pdf(*args, **kwargs):
# set the variable name
varname = var_names[i]
# set the coordinate
coords[varname] = pdf_tuple[1][i]
if num_variables == 1:
coords[varname] = pdf_tuple[1]
else:
coords[varname] = pdf_tuple[1][i]
# set the dimension
dims.append(varname)

Expand Down
9 changes: 9 additions & 0 deletions tests/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def test_simple_3D():
# the numPoints argument results in a coarser PDF--but one that is calculated
# faster (and with less memory)

def test_simple_1D_with_xarray():
np.random.seed(42)
N = int(2e5)
var1 = 50 * np.random.normal(size=N) + 0.1

# Do the self-consistent density estimate
myPDF = fastkde.pdf(var1, use_xarray=True)


def test_simple_2D_with_xarray():
np.random.seed(42)
N = int(2e5)
Expand Down

0 comments on commit 81d0e35

Please sign in to comment.