Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
fixes #2: numbers NameError and proper handling of weights scalar-to-…
Browse files Browse the repository at this point in the history
…array broadcasting
  • Loading branch information
jpivarski committed Sep 20, 2018
1 parent 2378068 commit 4091e51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion uproot_methods/classes/TH1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import numbers
import sys

import numpy
Expand Down Expand Up @@ -183,7 +184,7 @@ def fillallw(self, data, weights):
data = numpy.array(data)

if isinstance(weights, numbers.Real):
weights = numpy.empty_like(data)
weights = numpy.full(data.shape, weights)

freq, edges = numpy.histogram(data, bins=numbins, range=(low, high), weights=weights, density=False)
for i, x in enumerate(freq):
Expand Down
5 changes: 2 additions & 3 deletions uproot_methods/classes/TH2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import numbers
import sys

import numpy
Expand Down Expand Up @@ -236,9 +237,7 @@ def fillallw(self, datax, datay, weights):
datay = numpy.array(datay)

if isinstance(weights, numbers.Real):
tmp_weight = weights
weights = numpy.empty_like(datax)
weights.fill(tmp_weight) # assign all elements of the array to the initial value
weights = numpy.full(datax.shape, weights)

freq, xedges, yedges = numpy.histogram2d(datax,
datay,
Expand Down
2 changes: 1 addition & 1 deletion uproot_methods/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import re

__version__ = "0.0.8"
__version__ = "0.0.9"
version = __version__
version_info = tuple(re.split(r"[-\.]", __version__))

Expand Down

0 comments on commit 4091e51

Please sign in to comment.