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

Commit 4091e51

Browse files
committed
fixes #2: numbers NameError and proper handling of weights scalar-to-array broadcasting
1 parent 2378068 commit 4091e51

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

uproot_methods/classes/TH1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31+
import numbers
3132
import sys
3233

3334
import numpy
@@ -183,7 +184,7 @@ def fillallw(self, data, weights):
183184
data = numpy.array(data)
184185

185186
if isinstance(weights, numbers.Real):
186-
weights = numpy.empty_like(data)
187+
weights = numpy.full(data.shape, weights)
187188

188189
freq, edges = numpy.histogram(data, bins=numbins, range=(low, high), weights=weights, density=False)
189190
for i, x in enumerate(freq):

uproot_methods/classes/TH2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31+
import numbers
3132
import sys
3233

3334
import numpy
@@ -236,9 +237,7 @@ def fillallw(self, datax, datay, weights):
236237
datay = numpy.array(datay)
237238

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

243242
freq, xedges, yedges = numpy.histogram2d(datax,
244243
datay,

uproot_methods/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import re
3232

33-
__version__ = "0.0.8"
33+
__version__ = "0.0.9"
3434
version = __version__
3535
version_info = tuple(re.split(r"[-\.]", __version__))
3636

0 commit comments

Comments
 (0)