Skip to content

Commit

Permalink
Merge pull request #375 from open2c/hotfix-361
Browse files Browse the repository at this point in the history
Fix uninitialized binedges #361
  • Loading branch information
gfudenberg authored Aug 12, 2022
2 parents 623d196 + 8e8699d commit a4f04a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cooltools/api/saddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,17 @@ def __call__(self, x, pos=None):
track_value_col = track.columns[3]
track_values = track[track_value_col].values

# Digitize the track and calculate histogram
digitized_track, binedges = digitize(track, n_bins, vrange=vrange, qrange=qrange)
x = digitized_track[digitized_track.columns[3]].values.astype(int).copy()
x = x[(x > -1) & (x < len(binedges) + 1)]
hist = np.bincount(x, minlength=len(binedges) + 1)

if vrange is not None:
lo, hi = vrange
if qrange is not None:
lo, hi = qrange
# Reset the binedges for plotting
binedges = np.linspace(lo, hi, n_bins + 1)

# Histogram and saddledata are flanked by outlier bins
Expand Down
2 changes: 2 additions & 0 deletions tests/test_compartments_saddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def test_saddle_cli(request, tmpdir):
"30",
"--scale",
"log",
"--fig",
"png",
in_cool,
f"{out_eig_prefix}.cis.vecs.tsv",
out_expected,
Expand Down

0 comments on commit a4f04a5

Please sign in to comment.