Skip to content

Commit

Permalink
fix of get_sub_hist() when Bin histogram is filled only with nans
Browse files Browse the repository at this point in the history
- fix of util._get_sub_hist()
  • Loading branch information
mbaak committed Dec 16, 2022
1 parent 3b09f31 commit 43f69c9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release notes
=============

Version 1.0.33, Sep 2022
------------------------
* fix of get_sub_hist() when Bin histogram is filled only with nans.

Version 1.0.32, Sep 2022
------------------------
* Support for decimal datetype in pandas and spark.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PyCUDA is available, they can also be filled from Numpy arrays by JIT-compiling

This Python implementation of histogrammar been tested to guarantee compatibility with its Scala implementation.

Latest Python release: v1.0.32 (Sep 2022).
Latest Python release: v1.0.33 (Dec 2022).


Announcements
Expand Down
11 changes: 8 additions & 3 deletions histogrammar/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,17 @@ def _get_sub_hist(hist):
if isinstance(hist, histogrammar.Categorize):
sub_hist = hist.values[0] if hist.values else hist.value
elif isinstance(hist, histogrammar.Bin):
if hist.entries > 0:
if hist.entries > 0 and len(hist.values) > 0:
# pick first sub-hist found that is filled
idx = next(i for i, b in enumerate(hist.values) if b.entries > 0)
# note: could still be that all bins are unfilled. if so pick first bin.
idx = 0
for i, b in enumerate(hist.values):
if b.entries > 0:
idx = i
break
sub_hist = hist.values[idx]
else:
sub_hist = hist.values[0] if hist.values else histogrammar.Count()
sub_hist = hist.values[0] if len(hist.values) > 0 else histogrammar.Count()
elif isinstance(hist, (histogrammar.SparselyBin, histogrammar.CentrallyBin)):
sub_hist = list(dict(hist.bins).values())[0] if hist.bins else hist.value
elif isinstance(hist, (histogrammar.IrregularlyBin, histogrammar.Stack)):
Expand Down
6 changes: 3 additions & 3 deletions histogrammar/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import re

name = "histogrammar"
__version__ = "1.0.32"
version = "1.0.32"
full_version = "1.0.32"
__version__ = "1.0.33"
version = "1.0.33"
full_version = "1.0.33"
release = True

version_info = tuple(re.split(r"[-\.]", __version__))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

MAJOR = 1
REVISION = 0
PATCH = 32
PATCH = 33
DEV = False
# NOTE: also update version at: README.rst and update CHANGES.rst

Expand Down

0 comments on commit 43f69c9

Please sign in to comment.