Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openpathsampling/numerics/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def xvals(self, bin_edge_type):
np.array :
The values of the bin edges
"""
int_bins = np.array(self._histogram.keys())
left_bins = int_bins * self.bin_widths + self.left_bin_edges
int_bins = np.array(list(self._histogram.keys()))
left_bins = int_bins * np.array(self.bin_widths) + self.left_bin_edges
return self._left_edge_to_bin_edge_type(left_bins, self.bin_widths,
bin_edge_type)

Expand Down
9 changes: 9 additions & 0 deletions openpathsampling/tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .test_helpers import assert_items_almost_equal, assert_items_equal
import pytest
import logging
from numpy import testing as npt
logging.getLogger('openpathsampling.initialization').setLevel(logging.CRITICAL)
logging.getLogger('openpathsampling.ensemble').setLevel(logging.CRITICAL)
logging.getLogger('openpathsampling.storage').setLevel(logging.CRITICAL)
Expand Down Expand Up @@ -212,6 +213,14 @@ def test_call(self):
# empty voxel gives 0
assert histo_fcn((2.00, 2.00)) == 0

@pytest.mark.parametrize('side,expected', [
('l', [[0.0, -0.1], [0.0, 0.5], [0.5, 0.8]]),
('r', [[0.5, 0.2], [0.5, 0.8], [1.0, 1.1]]),
('m', [[0.25, 0.05], [0.25, 0.65], [0.75, 0.95]]),
])
def test_xvals(self, side, expected):
npt.assert_almost_equal(self.histo.xvals(side), expected)

def test_normalized(self):
raw_prob_normed = self.histo.normalized(raw_probability=True)
assert pytest.approx(raw_prob_normed((0.25, 0.65))) == 0.5
Expand Down