Skip to content

Commit

Permalink
add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
chancyk committed Dec 19, 2024
1 parent 64ff098 commit 8e995d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
3 changes: 0 additions & 3 deletions examples/example.nim

This file was deleted.

10 changes: 0 additions & 10 deletions src/derichekde.nim
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,3 @@ proc density_1d*(

deriche_conv_1d(config, grid, bins, 1, y_causal, y_anticausal, h, d)
return (d, lo, hi)


when isMainModule:
# Example usage of density1d
var data = @[1.2, 2.3, 23, 40, 50, 60, 70, 60, 50, 400, 700, 1000]
let (density, lo, hi) = density_1d(data, extent=(0.0, 1000.0), bandwidth=2.0)

echo "Density estimation results:"
echo fmt"Range: [{lo:.2f}, {hi:.2f}]"
echo fmt"Density: {density}"
10 changes: 8 additions & 2 deletions tests/test.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## Put your tests here.

import derichekde


block:
var data = @[1.2, 2.3, 23, 40, 50, 60, 70, 60, 50, 400, 700, 1000]
let (density, lo, hi) = density_1d(data, extent=(0.0, 1000.0), bandwidth=2.0, bins=512)

doAssert density.len == 512
doAssert lo == 0.0
doAssert hi == 1000.0

0 comments on commit 8e995d2

Please sign in to comment.