From 1edf68e23f30b456a131ee34d6856a4cb2f84cb7 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 5 Jan 2024 10:29:04 -0600 Subject: [PATCH] docs(backport): Correct fixed_params type to tuple or list (#2428) * Backport PR https://github.com/scikit-hep/pyhf/pull/2420 * `fixed_params` is an iterable that is of type tuple or list. Though operations on it may support tensor types, not all operations will necessarily be supported and so the docs should not list it as being a tensor. --- src/pyhf/infer/__init__.py | 4 ++-- src/pyhf/infer/calculators.py | 12 ++++++------ src/pyhf/infer/mle.py | 8 ++++---- src/pyhf/infer/test_statistics.py | 20 ++++++++++---------- src/pyhf/infer/utils.py | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/pyhf/infer/__init__.py b/src/pyhf/infer/__init__.py index 5aaaf2c1c6..dc5531cd93 100644 --- a/src/pyhf/infer/__init__.py +++ b/src/pyhf/infer/__init__.py @@ -61,8 +61,8 @@ def hypotest( par_bounds (:obj:`tensor`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`tensor` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. calctype (:obj:`str`): The calculator to create. Choose either 'asymptotics' (default) or 'toybased'. return_tail_probs (:obj:`bool`): Bool for returning :math:`\mathrm{CL}_{s+b}` and :math:`\mathrm{CL}_{b}` return_expected (:obj:`bool`): Bool for returning :math:`\mathrm{CL}_{\mathrm{exp}}` diff --git a/src/pyhf/infer/calculators.py b/src/pyhf/infer/calculators.py index ed9642e085..1889dec0c7 100644 --- a/src/pyhf/infer/calculators.py +++ b/src/pyhf/infer/calculators.py @@ -61,8 +61,8 @@ def generate_asimov_data( par_bounds (:obj:`tensor`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`tensor` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. return_fitted_pars (:obj:`bool`): Return the best-fit parameter values for the given ``asimov_mu``. @@ -241,8 +241,8 @@ def __init__( par_bounds (:obj:`tensor`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`tensor` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. test_stat (:obj:`str`): The test statistic to use as a numerical summary of the data: ``'qtilde'``, ``'q'``, or ``'q0'``. @@ -685,8 +685,8 @@ def __init__( par_bounds (:obj:`tensor`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`tensor` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. test_stat (:obj:`str`): The test statistic to use as a numerical summary of the data: ``'qtilde'``, ``'q'``, or ``'q0'``. diff --git a/src/pyhf/infer/mle.py b/src/pyhf/infer/mle.py index fffff84131..61559b0ed0 100644 --- a/src/pyhf/infer/mle.py +++ b/src/pyhf/infer/mle.py @@ -106,8 +106,8 @@ def fit(data, pdf, init_pars=None, par_bounds=None, fixed_params=None, **kwargs) par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. kwargs: Keyword arguments passed through to the optimizer API Returns: @@ -180,8 +180,8 @@ def fixed_poi_fit( par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. kwargs: Keyword arguments passed through to the optimizer API Returns: diff --git a/src/pyhf/infer/test_statistics.py b/src/pyhf/infer/test_statistics.py index cf11e09c86..97b6babe79 100644 --- a/src/pyhf/infer/test_statistics.py +++ b/src/pyhf/infer/test_statistics.py @@ -112,8 +112,8 @@ def qmu(mu, data, pdf, init_pars, par_bounds, fixed_params, return_fitted_pars=F par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. return_fitted_pars (:obj:`bool`): Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. :math:`\mu, \hat{\hat{\theta}}` and :math:`\hat{\mu}, \hat{\theta}`) @@ -207,8 +207,8 @@ def qmu_tilde( par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. return_fitted_pars (:obj:`bool`): Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. :math:`\mu, \hat{\hat{\theta}}` and :math:`\hat{\mu}, \hat{\theta}`) @@ -290,8 +290,8 @@ def tmu(mu, data, pdf, init_pars, par_bounds, fixed_params, return_fitted_pars=F par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. return_fitted_pars (:obj:`bool`): Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. :math:`\mu, \hat{\hat{\theta}}` and :math:`\hat{\mu}, \hat{\theta}`) @@ -380,8 +380,8 @@ def tmu_tilde( par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. return_fitted_pars (:obj:`bool`): Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. :math:`\mu, \hat{\hat{\theta}}` and :math:`\hat{\mu}, \hat{\theta}`) @@ -458,8 +458,8 @@ def q0(mu, data, pdf, init_pars, par_bounds, fixed_params, return_fitted_pars=Fa par_bounds (:obj:`list` of :obj:`list`/:obj:`tuple`): The extrema of values the model parameters are allowed to reach in the fit. The shape should be ``(n, 2)`` for ``n`` model parameters. - fixed_params (:obj:`list` of :obj:`bool`): The flag to set a parameter constant to its starting - value during minimization. + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): The flag to set a parameter + constant to its starting value during minimization. return_fitted_pars (:obj:`bool`): Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. :math:`\mu, \hat{\hat{\theta}}` and :math:`\hat{\mu}, \hat{\theta}`) diff --git a/src/pyhf/infer/utils.py b/src/pyhf/infer/utils.py index 1131b01de9..a9eeefac49 100644 --- a/src/pyhf/infer/utils.py +++ b/src/pyhf/infer/utils.py @@ -22,7 +22,7 @@ def all_pois_floating(pdf, fixed_params): Args: pdf (~pyhf.pdf.Model): The statistical model adhering to the schema ``model.json``. - fixed_params (:obj:`list` or `tensor` of :obj:`bool`): Array of + fixed_params (:obj:`tuple` or :obj:`list` of :obj:`bool`): Array of :obj:`bool` indicating if model parameters are fixed. Returns: