Skip to content

Commit

Permalink
Stop writing nan for ovl-cov-stats
Browse files Browse the repository at this point in the history
Bump micro version
  • Loading branch information
Christopher Dunn committed Jul 7, 2021
1 parent 262d7e0 commit b07290f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion falconc.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "1.13.0"
version = "1.13.1"
author = "Zev Kronenberg"
author = "Christopher Dunn"
description = "C Utilities for bioinformatics"
Expand Down
6 changes: 6 additions & 0 deletions src/falconcpkg/ovl_cov_stats.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ proc collect_from_fofn*(in_fn_list: seq[string]): seq[int] =
allCounts.add(counts)
return allCounts

proc standardDeviation(s: RunningStat): float =
if s.n == 0:
return 0.0
else:
return stats.standardDeviation(s)

proc calc_stats*(counts: seq[int]): tuple[mean, stddev, median: float, min, max, n: int] =
var rs: RunningStat
rs.push(counts)
Expand Down
6 changes: 3 additions & 3 deletions tests/t_ovl_cov_stats.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ suite "ovl_cov_stats calc_stats":
test "empty input":
let data: seq[int] = @[]
let results = ovl_cov_stats.calc_stats(data)
let expected = (mean: float(0.0), stddev: float(NaN), median: float(0.0), min: 0, max: 0, n: 0)
let expected = (mean: float(0.0), stddev: float(0.0), median: float(0.0), min: 0, max: 0, n: 0)
# If this is not converted to string, tuple comparison fails for some reason.
check $results == $expected

Expand All @@ -48,14 +48,14 @@ suite "ovl_cov_stats calc_stats":
suite "ovl_cov_stats collect_from_stream":
# This implicitly tests the count_overlaps proc.

test "empty input":
test "empty stream":
let inStr = ""
let inStream: Stream = newStringStream(inStr)
let results = ovl_cov_stats.collect_from_stream(inStream)
let expected: seq[int] = @[]
check results == expected

test "empty input":
test "test data 1":
let inStr = testDataCollectFromStream1
let inStream: Stream = newStringStream(inStr)
let results = ovl_cov_stats.collect_from_stream(inStream)
Expand Down

0 comments on commit b07290f

Please sign in to comment.