Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and matthewfeickert committed Dec 13, 2023
1 parent b4daa59 commit 803b842
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/pyhf/infer/calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def __init__(
test_stat="qtilde",
ntoys=2000,
track_progress=True,
skip_failing_toys = False,
skip_failing_toys=False,
):
r"""
Toy-based Calculator.
Expand Down Expand Up @@ -756,7 +756,7 @@ def distributions(self, poi_test, track_progress=None):
"""

print('skip?',self.skip_failing_toys)
print('skip?', self.skip_failing_toys)

tensorlib, _ = get_backend()
sample_shape = (self.ntoys,)
Expand Down Expand Up @@ -796,14 +796,14 @@ def distributions(self, poi_test, track_progress=None):

signal_teststat = []
for sample in tqdm.tqdm(signal_sample, **tqdm_options, desc='Signal-like'):
try:
try:
value = teststat_func(
poi_test,
sample,
self.pdf,
self.init_pars,
self.par_bounds,
self.fixed_params,
poi_test,
sample,
self.pdf,
self.init_pars,
self.par_bounds,
self.fixed_params,
)
except RuntimeError:

Check warning on line 808 in src/pyhf/infer/calculators.py

View check run for this annotation

Codecov / codecov/patch

src/pyhf/infer/calculators.py#L808

Added line #L808 was not covered by tests
if self.skip_failing_toys:
Expand All @@ -812,20 +812,18 @@ def distributions(self, poi_test, track_progress=None):
raise

Check warning on line 812 in src/pyhf/infer/calculators.py

View check run for this annotation

Codecov / codecov/patch

src/pyhf/infer/calculators.py#L812

Added line #L812 was not covered by tests

if (value is not None) and (tensorlib.isfinite(value)):
signal_teststat.append(
value
)
signal_teststat.append(value)

bkg_teststat = []
for sample in tqdm.tqdm(bkg_sample, **tqdm_options, desc='Background-like'):
try:
try:
value = teststat_func(
poi_test,
sample,
self.pdf,
self.init_pars,
self.par_bounds,
self.fixed_params,
poi_test,
sample,
self.pdf,
self.init_pars,
self.par_bounds,
self.fixed_params,
)
except RuntimeError:

Check warning on line 828 in src/pyhf/infer/calculators.py

View check run for this annotation

Codecov / codecov/patch

src/pyhf/infer/calculators.py#L828

Added line #L828 was not covered by tests
if self.skip_failing_toys:
Expand All @@ -834,9 +832,7 @@ def distributions(self, poi_test, track_progress=None):
raise

Check warning on line 832 in src/pyhf/infer/calculators.py

View check run for this annotation

Codecov / codecov/patch

src/pyhf/infer/calculators.py#L832

Added line #L832 was not covered by tests

if (value is not None) and (tensorlib.isfinite(value)):
bkg_teststat.append(
value
)
bkg_teststat.append(value)

s_plus_b = EmpiricalDistribution(tensorlib.astensor(signal_teststat))
b_only = EmpiricalDistribution(tensorlib.astensor(bkg_teststat))
Expand Down

0 comments on commit 803b842

Please sign in to comment.