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

Commit

Permalink
rename 'bins' as 'edges' and introduce 2-component 'bins' with the sa…
Browse files Browse the repository at this point in the history
…me cardinality as 'values' (also for 'all*')
  • Loading branch information
jpivarski committed Dec 13, 2018
1 parent 0a30767 commit ec66503
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions uproot_methods/classes/TH1.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,38 @@ def overflows(self):
return self[-1]

@property
def bins(self):
def edges(self):
axis = self._fXaxis
if hasattr(axis, "_fXbins"):
if len(getattr(axis, "_fXbins", [])) > 0:
return numpy.array(axis._fXbins)
else:
return numpy.linspace(axis._fXmin, axis._fXmax, axis._fNbins + 1)

@property
def allbins(self):
def alledges(self):
axis = self._fXaxis
v = numpy.empty(axis._fNbins + 3)
v[0] = -numpy.inf
v[-1] = numpy.inf
v[1:-1] = self.bins
v[1:-1] = self.edges
return v

@property
def bins(self):
edges = self.edges
out = numpy.empty((len(edges) - 1, 2))
out[:, 0] = edges[:-1]
out[:, 1] = edges[1:]
return out

@property
def allbins(self):
edges = self.alledges
out = numpy.empty((len(edges) - 1, 2))
out[:, 0] = edges[:-1]
out[:, 1] = edges[1:]
return out

@property
def values(self):
return self[1:-1]
Expand Down

0 comments on commit ec66503

Please sign in to comment.