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] committed Feb 5, 2024
1 parent 648c190 commit 384859b
Show file tree
Hide file tree
Showing 36 changed files with 61 additions and 27 deletions.
8 changes: 5 additions & 3 deletions docs/examples/notebooks/ImpactPlot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@
" model, _, b, e = fitresults()\n",
" widths = pyhf.tensorlib.concatenate(\n",
" [\n",
" model.config.param_set(k).width()\n",
" if model.config.param_set(k).constrained\n",
" else [None] * model.config.param_set(k).n_parameters\n",
" (\n",
" model.config.param_set(k).width()\n",
" if model.config.param_set(k).constrained\n",
" else [None] * model.config.param_set(k).n_parameters\n",
" )\n",
" for k, v in model.config.par_map.items()\n",
" ]\n",
" )\n",
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The pyhf command line interface."""

from pyhf.cli.cli import pyhf as cli
from pyhf.cli.rootio import cli as rootio
from pyhf.cli.spec import cli as spec
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The pyhf Command Line Interface."""

import logging

import click
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/cli/complete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'''Shell completions for pyhf.'''

import click

try:
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/cli/infer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The inference CLI group."""

import logging

import click
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/cli/patchset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The pyhf spec CLI subcommand."""

import logging

import click
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/cli/rootio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI subapps to handle conversion from ROOT."""

import logging

import click
Expand Down
9 changes: 6 additions & 3 deletions src/pyhf/cli/spec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The pyhf spec CLI subcommand."""

import logging

import click
Expand Down Expand Up @@ -149,9 +150,11 @@ def inspect(workspace, output_file, measurement):
('(*) ' if measurement_name == default_measurement['name'] else '')
+ measurement_name,
measurement_poi,
','.join(measurement_parameters)
if measurement_parameters
else '(none)',
(
','.join(measurement_parameters)
if measurement_parameters
else '(none)'
),
)
)

Expand Down
1 change: 1 addition & 0 deletions src/pyhf/contrib/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI for functionality that will get migrated out eventually."""

import logging
import click
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/contrib/viz/brazil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Brazil Band Plots."""

from collections import namedtuple

import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/infer/calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Using the calculators hypothesis tests can then be performed.
"""

from pyhf.infer.mle import fixed_poi_fit
from pyhf import get_backend
from pyhf.infer import utils
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/infer/intervals/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interval estimation"""

import pyhf.infer.intervals.upper_limits

__all__ = ["upper_limits.upper_limit"]
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/infer/intervals/upper_limits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interval estimation"""

import numpy as np
from scipy.optimize import toms748

Expand Down
1 change: 1 addition & 0 deletions src/pyhf/infer/mle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for Maximum Likelihood Estimation."""

from pyhf import get_backend
from pyhf.exceptions import UnspecifiedPOI

Expand Down
1 change: 1 addition & 0 deletions src/pyhf/interpolators/code0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Piecewise-linear Interpolation. (Code 0)."""

import logging
import pyhf
from pyhf.tensor.manager import get_backend
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/interpolators/code1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Piecewise-Exponential Interpolation (Code 1)."""

import logging
import math
import pyhf
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/interpolators/code2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Quadratic Interpolation (Code 2)."""

import logging
import pyhf
from pyhf.tensor.manager import get_backend
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/interpolators/code4.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Polynomial Interpolation (Code 4)."""

import logging
import math
import pyhf
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/interpolators/code4p.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Piecewise-Linear + Polynomial Interpolation (Code 4p)."""

import logging
import pyhf
from pyhf.tensor.manager import get_backend
Expand Down
6 changes: 3 additions & 3 deletions src/pyhf/modifiers/shapesys.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ def _reindex_access_field(self, pdfconfig):

sample_mask = self._shapesys_mask[syst_index][singular_sample_index][0]
access_field_for_syst_and_batch[sample_mask] = selection
self._access_field[
syst_index, batch_index
] = access_field_for_syst_and_batch
self._access_field[syst_index, batch_index] = (
access_field_for_syst_and_batch
)

def _precompute(self):
tensorlib, _ = get_backend()
Expand Down
15 changes: 9 additions & 6 deletions src/pyhf/modifiers/staterror.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ def finalize(self):
relerrs = default_backend.sum(
[
[
(modifier_data['data']['uncrt'][binnr] / nomsall[binnr]) ** 2
if nomsall[binnr] > 0
else 0.0
(
(modifier_data['data']['uncrt'][binnr] / nomsall[binnr])
** 2
if nomsall[binnr] > 0
else 0.0
)
for binnr in range(len(modifier_data['data']['nom_data']))
]
for modifier_data in self.builder_data[modname].values()
Expand Down Expand Up @@ -184,9 +187,9 @@ def _reindex_access_field(self, pdfconfig):

sample_mask = self._staterror_mask[syst_index][singular_sample_index][0]
access_field_for_syst_and_batch[sample_mask] = selection
self._access_field[
syst_index, batch_index
] = access_field_for_syst_and_batch
self._access_field[syst_index, batch_index] = (
access_field_for_syst_and_batch
)

def _precompute(self):
if not self.param_viewer.index_selection:
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/optimize/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common Backend Shim to prepare minimization for optimizer."""

from pyhf.tensor.manager import get_backend
from pyhf.tensor.common import _TensorViewer

Expand Down
1 change: 1 addition & 0 deletions src/pyhf/optimize/mixins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper Classes for use of automatic differentiation."""

import logging

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/optimize/opt_minuit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Minuit Optimizer Class."""

from pyhf import exceptions
from pyhf.optimize.mixins import OptimizerMixin
import scipy
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/optimize/opt_scipy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SciPy Optimizer Class."""

from pyhf import exceptions
from pyhf.optimize.mixins import OptimizerMixin
import scipy
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/optimize/opt_tflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tensorflow Backend Function Shim."""

from pyhf import get_backend
import tensorflow as tf

Expand Down
8 changes: 5 additions & 3 deletions src/pyhf/parameters/paramview.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def extract_index_access(baseviewer, subviewer, indices):

# the transpose is here so that modifier code doesn't have to do it
indices_concatenated = tensorlib.astensor(
tensorlib.einsum('ij->ji', stitched)
if len(tensorlib.shape(stitched)) > 1
else stitched,
(
tensorlib.einsum('ij->ji', stitched)
if len(tensorlib.shape(stitched)) > 1
else stitched
),
dtype='int',
)
return index_selection, stitched, indices_concatenated
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/patchset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
pyhf patchset provides a user-friendly interface for interacting with patchsets.
"""

import logging
import jsonpatch
from pyhf import exceptions
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/probability.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The probability density function module."""

from pyhf import get_backend

__all__ = ["Independent", "Normal", "Poisson", "Simultaneous"]
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/schema/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
See :class:`~pyhf.schema.Schema` for documentation.
"""

import pathlib
import sys
from pyhf.schema.loader import load_schema
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/tensor/numpy_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NumPy Tensor Library Module."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/tensor/pytorch_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PyTorch Tensor Library Module."""

import torch
import torch.autograd
from torch.distributions.utils import broadcast_all
Expand Down
1 change: 1 addition & 0 deletions src/pyhf/tensor/tensorflow_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tensorflow Tensor Library Module."""

import logging
import tensorflow as tf
import tensorflow_probability as tfp
Expand Down
9 changes: 3 additions & 6 deletions src/pyhf/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,14 @@ class TensorBackend(Protocol):
precision: str
default_do_grad: bool

def _setup(self) -> None:
...
def _setup(self) -> None: ...


class Optimizer(Protocol):
name: str


class PDF(Protocol):
def sample(self, sample_shape: Shape) -> Any:
...
def sample(self, sample_shape: Shape) -> Any: ...

def log_prob(self, value: Any) -> Any:
...
def log_prob(self, value: Any) -> Any: ...
1 change: 1 addition & 0 deletions src/pyhf/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* the observed data (optional)
* fit configurations ("measurements")
"""

from __future__ import annotations

import collections
Expand Down
4 changes: 1 addition & 3 deletions tests/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ def test_code0_validation(backend, do_tensorized_calc):
def test_code1_validation(backend, do_tensorized_calc):
histogramssets = [[[[0.9], [1.0], [1.1]]]]
alphasets = pyhf.tensorlib.astensor([[-2, -1, 0, 1, 2]])
expected = pyhf.tensorlib.astensor(
[[[[0.9**2], [0.9], [1.0], [1.1], [1.1**2]]]]
)
expected = pyhf.tensorlib.astensor([[[[0.9**2], [0.9], [1.0], [1.1], [1.1**2]]]])

interpolator = pyhf.interpolators.get(1, do_tensorized_calc=do_tensorized_calc)(
histogramssets, subscribe=False
Expand Down

0 comments on commit 384859b

Please sign in to comment.