Skip to content

Commit

Permalink
fixed bug with hexbin3d plot ZeroDivisionError
Browse files Browse the repository at this point in the history
  • Loading branch information
darianyang committed Feb 29, 2024
1 parent 4408a76 commit 6952715
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wedap/h5_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,12 @@ def reduce_C_function(C):
Custom C function to account for weights in hexbins.
In this case, C is the Zindices.
'''
return np.average(Z_and_weights[C, 0], weights=Z_and_weights[C, 1])
# when I have a zeroed weight h5 e.g. from succ_only, this doesn't work
# need an extra checking step here likely (for all zero weights)
try:
return np.average(Z_and_weights[C, 0], weights=Z_and_weights[C, 1])
except ZeroDivisionError:
return np.nan

# if weighted attr is passed as False, don't weight hexbins
try:
Expand Down

0 comments on commit 6952715

Please sign in to comment.