Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram Comparison (Private) #779

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
29 changes: 29 additions & 0 deletions src/boost_histogram/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,32 @@ def zip_strict(*args: Any) -> Iterator[Tuple[Any, ...]]:
if val is marker:
raise ValueError("zip() arguments are not the same length")
yield each


def compare(self: "Histogram", hist2: "Histogram", **kwargs) -> str:
if not np.allclose(self.view().shape, hist2.view().shape, **kwargs):
return False
if not np.allclose(self.view(), hist2.view(), **kwargs):
return False
if not np.allclose(self.to_numpy()[1], hist2.to_numpy()[1], **kwargs):
return False
if self._storage_type != hist2._storage_type:
return False
if list(self.axes) != list(hist2.axes):
return False
return True


"""
def test_compare(self: "Histogram", hist2: "Histogram", **kwargs) -> str:
if not np.allclose(self.view().shape, hist2.view().shape, **kwargs):
assert self.view().shape == hist2.view().shape, 'The dimensions are not similar.'
if not np.allclose(self.view(), hist2.view(), **kwargs):
assert self.view() == hist2.view(), 'The contents are not similar.'
if not np.allclose(self.to_numpy()[1], hist2.to_numpy()[1], **kwargs):
assert self.to_numpy()[1] == hist2.to_numpy()[1], 'The edges are not similar.'
if self._storage_type != hist2._storage_type:
assert str(self._storage_type).split('.')[-1][:-2] == str(hist2._storage_type).split('.')[-1][:-2], 'The storages are not similar.'
if list(self.axes) != list(hist2.axes):
assert list(self.axes) == list(hist2.axes), 'The edges are not similar'
"""