Skip to content

Commit

Permalink
Make to_numpy match boost-histogram's flow=False default (and mplhep'…
Browse files Browse the repository at this point in the history
…s expectation). (#49)
  • Loading branch information
jpivarski authored Jul 17, 2020
1 parent cce6b79 commit ee3a8b4
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions tests/test_0046-histograms-bh-hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def test_numpy_1d():
with uproot4.open(skhep_testdata.data_path("uproot-hepdata-example.root")) as f:
values, edges = f["hpx"].to_numpy()
values, edges = f["hpx"].to_numpy(flow=True)
assert values.tolist() == [
2.0,
2.0,
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_numpy_1d():

def test_numpy_2d():
with uproot4.open(skhep_testdata.data_path("uproot-hepdata-example.root")) as f:
values, xedges, yedges = f["hpxpy"].to_numpy()
values, xedges, yedges = f["hpxpy"].to_numpy(flow=True)

assert values.tolist() == [
[
Expand Down Expand Up @@ -2183,7 +2183,7 @@ def test_numpy_profile():
with uproot4.open(skhep_testdata.data_path("uproot-hepdata-example.root")) as f:
obj = f["hprof"]

assert obj.to_numpy(errors=True)[1].tolist() == [
assert obj.to_numpy(flow=True, errors=True)[1].tolist() == [
-numpy.inf,
-4.0,
-3.92,
Expand Down Expand Up @@ -2289,7 +2289,7 @@ def test_numpy_profile():
numpy.inf,
]

assert obj.to_numpy(errors=True)[0][0].tolist() == [
assert obj.to_numpy(flow=True, errors=True)[0][0].tolist() == [
17.99833583831787,
17.05295467376709,
16.96826426188151,
Expand Down Expand Up @@ -2394,7 +2394,7 @@ def test_numpy_profile():
17.8403746287028,
]

assert obj.to_numpy(errors=True)[0][1].tolist() == [
assert obj.to_numpy(flow=True, errors=True)[0][1].tolist() == [
0.2425426377130359,
0.7421210342302459,
0.4940066334987832,
Expand Down Expand Up @@ -2500,7 +2500,7 @@ def test_numpy_profile():
]

assert obj.to_numpy(
errors=True, error_mode=uproot4.behaviors.TProfile._kERRORSPREAD
flow=True, errors=True, error_mode=uproot4.behaviors.TProfile._kERRORSPREAD
)[0][1].tolist() == [
0.34300708770751953,
1.0495176315307617,
Expand Down Expand Up @@ -2607,7 +2607,7 @@ def test_numpy_profile():
]

assert obj.to_numpy(
errors=True, error_mode=uproot4.behaviors.TProfile._kERRORSPREADI
flow=True, errors=True, error_mode=uproot4.behaviors.TProfile._kERRORSPREADI
)[0][1].tolist() == [
0.2425426377130359,
0.7421210342302459,
Expand Down Expand Up @@ -2714,7 +2714,7 @@ def test_numpy_profile():
]

assert obj.to_numpy(
errors=True, error_mode=uproot4.behaviors.TProfile._kERRORSPREADG
flow=True, errors=True, error_mode=uproot4.behaviors.TProfile._kERRORSPREADG
)[0][1].tolist() == [
0.7071067811865475,
0.7071067811865475,
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TH1.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def values_errors(self):

return values, errors

def to_numpy(self, flow=True, dd=False, errors=False):
def to_numpy(self, flow=False, dd=False, errors=False):
if errors:
values, errs = self.values_errors()
else:
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TH2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def values_errors(self):

return values, errors

def to_numpy(self, flow=True, dd=False, errors=False):
def to_numpy(self, flow=False, dd=False, errors=False):
if errors:
values, errs = self.values_errors()
else:
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TH2Poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def values(self):
def values_errors(self, error_mode=0):
raise NotImplementedError(repr(self))

def to_numpy(self, flow=True, dd=False, errors=False):
def to_numpy(self, flow=False, dd=False, errors=False):
raise NotImplementedError(repr(self))

def to_boost(self):
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TH3.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def values_errors(self):

return values, errors

def to_numpy(self, flow=True, dd=False, errors=False):
def to_numpy(self, flow=False, dd=False, errors=False):
if errors:
values, errs = self.values_errors()
else:
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def values_errors(self, error_mode=0):
out[nonzero] = root_eprim[nonzero] / numpy.sqrt(root_neff[nonzero])
return root_contsum, out

def to_numpy(self, flow=True, dd=False, errors=False, error_mode=0):
def to_numpy(self, flow=False, dd=False, errors=False, error_mode=0):
if errors:
values, errs = self.values_errors(error_mode=error_mode)
else:
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TProfile2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def values(self):
def values_errors(self, error_mode=0):
raise NotImplementedError(repr(self))

def to_numpy(self, flow=True, dd=False, errors=False, error_mode=0):
def to_numpy(self, flow=False, dd=False, errors=False, error_mode=0):
raise NotImplementedError(repr(self))

def to_boost(self):
Expand Down
2 changes: 1 addition & 1 deletion uproot4/behaviors/TProfile3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def values(self):
def values_errors(self, error_mode=0):
raise NotImplementedError(repr(self))

def to_numpy(self, flow=True, dd=False, errors=False, error_mode=0):
def to_numpy(self, flow=False, dd=False, errors=False, error_mode=0):
raise NotImplementedError(repr(self))

def to_boost(self):
Expand Down

0 comments on commit ee3a8b4

Please sign in to comment.