[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Releases: scikit-hep/pyhf

v0.7.6

05 Jan 17:55
Compare
Choose a tag to compare

This is a patch release from v0.7.5 β†’ v0.7.6.

Fixes

Contributors

v0.7.6 benefited from contributions from:

What's Changed

Full Changelog: v0.7.5...v0.7.6

v0.7.5

26 Oct 17:26
Compare
Choose a tag to compare

This is a patch release from v0.7.4 β†’ v0.7.5.

Fixes

  • Remove operating system dependent components of schema validation to allow for validation on Windows. (PR #2357)

What's Changed

Full Changelog: v0.7.4...v0.7.5

v0.7.4

07 Sep 03:58
Compare
Choose a tag to compare

This is a patch release from v0.7.3 β†’ v0.7.4.

Fixes

  • Skip callbacks with dead weakrefs while iterating over callbacks in pyhf events, like pyhf.set_backend, to avoid the possibility of accessing dead weakrefs before they could be garbage collected. (PR #2310)

    The fixed bug was subtle and occurred nondeterministically when the pyhf.tensorlib was changed repeatedly causing dead weakrefs to be accessed before Python's garbage collection could remove them. Most users should be unaffected.

Contributors

v0.7.4 benefited from contributions from:

  • Daniel Werner
  • Jonas Rembser

What's Changed

Full Changelog: v0.7.3...v0.7.4

v0.7.3

17 Aug 15:40
Compare
Choose a tag to compare

This is a patch release from v0.7.2 β†’ v0.7.3.

Fixes

  • Use np.prod API over np.product as np.product is deprecated as of NumPy v1.25.0. (PR #2242)

  • Guard pyhf.optimize.opt_minuit.minuit_optimizer optimizer strategy from None to ensure iminuit.Minuit.strategy strategies are correctly handled. (PRs #2277, #2278)

    The fixed bug was subtle and only occurred for specific configurations of settings and arguments where do_grad=False was used (either explicitly by provided kwarg or implicitly through defaults). To determine if you might have been affected by it, check your code for setups like the following.

    # Bug is backend independent. JAX is selected as an example where
    # do_grad=False might be selected in response to the backend's value of
    # pyhf.tensorlib.default_do_grad being True.
    pyhf.set_backend("jax", pyhf.optimize.minuit_optimizer(strategy=0))
    
    ...
    
    fit_result, opt_result = pyhf.infer.mle.fit(
        data, model, return_result_obj=True, do_grad=False
    )
    assert opt_result.minuit.strategy.strategy == 0  # fails for pyhf v0.7.2

    Full example that fails in pyhf v0.7.2:

    import pyhf
    
    pyhf.set_backend("jax", pyhf.optimize.minuit_optimizer(strategy=0))
    
    model = pyhf.simplemodels.uncorrelated_background(
        signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
    )
    data = [51, 48] + model.config.auxdata
    
    # passing with strategy kwarg explicitly given
    fit_result, opt_result = pyhf.infer.mle.fit(
        data, model, return_result_obj=True, do_grad=False, strategy=0
    )
    minuit_strategy = opt_result.minuit.strategy.strategy
    print(f"# Minuit minimization strategy: {minuit_strategy}")
    assert minuit_strategy == 0
    
    # strategy kwarg not given
    fit_result, opt_result = pyhf.infer.mle.fit(
        data, model, return_result_obj=True, do_grad=False
    )
    minuit_strategy = opt_result.minuit.strategy.strategy
    print(f"# Minuit minimization strategy: {minuit_strategy}")
    assert minuit_strategy == 0  # fails for pyhf v0.7.2

Contributors

v0.7.3 benefited from contributions from:

  • Alexander Held
  • Daniel Werner

What's Changed

Full Changelog: v0.7.2...v0.7.3

v0.7.2

18 May 07:49
Compare
Choose a tag to compare

This is a patch release from v0.7.1 β†’ v0.7.2.

Important Notes

Fixes

Contributors

v0.7.2 benefited from contributions from:

  • Alexander Held

What's Changed

Full Changelog: v0.7.1...v0.7.2

v0.7.1

06 Apr 23:59
Compare
Choose a tag to compare

This is a patch release from v0.7.0 β†’ v0.7.1.

Important Notes

  • All backends are now fully compatible and tested with Python 3.11. (PR #2145)
  • The tensorflow extra ('pyhf[tensorflow]') now automatically installs tensorflow-macos for Apple silicon machines. (PR #2119)

Fixes

Contributors

v0.7.1 benefited from contributions from:

  • Alexander Held

What's Changed

Full Changelog: v0.7.0...v0.7.1

v0.7.0

24 Sep 19:10
Compare
Choose a tag to compare

This is a minor release from v0.6.3 β†’ v0.7.0.

Important Notes

  • Please note this release has API breaking changes and carefully read these notes while updating your code to the v0.7.0 API.

  • All backends are now fully compatible and tested with Python 3.10. (PR #1809)

  • The pyhf.tensorlib.poisson API now allows for the expected rate parameter lam to be 0 in the case that the observed events n is 0 given that the limit $$\lim_{\lambda \to 0} ,\mathrm{Pois}(n | \lambda)$$ is well defined. (PR #1657)

  • pyhf.readxml.parse now supports reading of XML configurations with absolute paths. To support this, pyhf xlm2json now has a -v/--mount option. (PR #1909)

  • Support for model specifications without a parameter of interest defined is added. (PRs #1638, #1636)

  • The pyhf.parameters.paramsets classes suggested_fixed attribute behavior has been updated. To access the behavior used in pyhf v0.6.x use the suggested_fixed_as_bool attribute. (PR #1639)

  • pyhf.pdf._ModelConfig.par_names is changed to be a property attribute. (PR #2027)

  • The order of model parameters is now sorted by model parameter name. (PR #1625)

  • Support for writing user custom modifiers is added. (PRs #1625, #1644)

  • Performance in pyhf.readxml is increased by improvements to pyhf.readxml.import_root_histogram. (PR #1691)

  • pyhf.contrib.utils.download is now more robust to different target file types. (PRs #1697, #1704)

  • A pyhf.default_backend has been added that is configurable through a default kwarg in pyhf.set_backend. (PR #1646) This is part of work to make pyhf fully automatic differentiable. (Issue #882)

  • Schema validation now allows for both list and pyhf.tensorlib objects to exist in the model specification. (PR #1647)

  • The minimum required dependencies have been updated to support added features:

    • scipy>=1.2.0 (PR #1274)
    • click>=8.0.0 (PRs #1909, #1958)
    • jsonschema>=4.15.0 (PRs #1976, #1979)
    • importlib_resources>=1.4.0 (for Python 3.7, 3.8) (PR #1979)
    • typing_extensions>=3.7.4.3 (for Python 3.7 only) (PRs #1940, #1961)
  • The minimum required backend versions have been updated to support added features:

    • JAX backend requires jax>=0.2.10, jaxlib>=0.1.61 (PR #1962)
    • PyTorch backend requires torch>=1.10.0 (PR #1657)
    • TensorFlow backend requires tensorflow>=2.7.0, tensorflow-probability>=0.11.0 (PRs #1962, #1657)
    • iminuit optimizer requires iminuit>=2.7.0 (PR #1895)
    • 'xmlio' extra requires uproot>=4.1.1 (PR #1567)

Fixes

  • Use improvements to jsonschema.RefResolver to avoid jsonschema.exceptions.RefResolutionError. (PR #1976)

  • Use the conditional maximum likelihood estimators of the nuisance parameters to create the sampling distributions for pyhf.infer.calculators.ToyCalculator. (PR #1610) This follows the joint recommendations of the ATLAS and CMS experiments in Procedure for the LHC Higgs boson search combination in Summer 2011.

Features

Python API

  • The following functions have been added to the pyhf.tensorlib API:

    • pyhf.tensorlib.transpose (PR #1696)
    • pyhf.tensorlib.percentile (PR #817)
  • pyhf.readxml.parse now supports reading of XML configurations with absolute paths with the addition of the mounts optional argument. (PR #1909)

  • Support for overriding the paths for finding schemas is added, using the pyhf installed location as a base via pyhf.utils.schemas. (PRs #1753, #1818)

      >>> from pathlib import Path
      >>> import pyhf.schema
      >>> current_schema_path = pyhf.schema.path
      >>> current_schema_path
      PosixPath('/path/to/your/venv/lib/python3.X/site-packages/pyhf/schemas')
      >>> custom_schema_path = Path("/path/to/custom/pyhf/schema")
      >>> with pyhf.schema(custom_schema_path):
      ...     print(repr(pyhf.schema.path))
      ...
      PosixPath('/path/to/custom/pyhf/schema')
      >>> pyhf.schema.path
      PosixPath('/path/to/your/venv/lib/python3.X/site-packages/pyhf/schemas')
  • In pyhf.workspace.Workspace.model the parameter of interest specified in the measurement may now be overridden using the added poi_name kwarg. (PR #1636)

  • The pyhf.parameters.paramsets classes suggested_fixed attribute behavior has been updated to return a list of bool of length n_parameters. To access the behavior used in pyhf v0.6.x use the suggested_fixed_as_bool attribute. (PR #1639)

  • pyhf.pdf._ModelConfig.par_names is changed to be a property attribute. (PR #2027)

  • The order of model parameters is now sorted by model parameter name. (PR #1625)

      >>> import pyhf
      >>> model = pyhf.simplemodels.correlated_background(
      ...     signal=[12.0, 11.0],
      ...     bkg=[50.0, 52.0],
      ...     bkg_up=[45.0, 57.0],
      ...     bkg_down=[55.0, 47.0],
      ... )
      >>> model.config.par_order
      ['correlated_bkg_uncertainty', 'mu']
      >>> model.config.par_names
      ['correlated_bkg_uncertainty', 'mu']
  • Support for writing user custom modifiers is added.
    (PRs #1625, #1644) This is still in the stage where it is targeted at expert users.

  • {modifier}_builder classes are added for all modifiers. (PRs #1625) For example, pyhf.modifiers.histosys.histosys_builder.

  • When using pyhf.writexml and the normfactor parameter config is missing inits or bounds, fall back to using default values. (PRs #1819)

  • Supported options for pyhf.infer.hypotest can now be passed as kwargs through the pyhf.infer.intervals.upper_limits.upper_limit API. (PR #1613) This now enables things like using pyhf.infer.calculators.ToyCalculator as the calculator used for the hypothesis test scan:

      >>> import numpy as np
      >>> import pyhf
      >>> pyhf.set_backend("jax")
      >>> model = pyhf.simplemodels.uncorrelated_background(
      ...     signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
      ... )
      >>> observations = [51, 48]
      >>> data = pyhf.tensorlib.astensor(observations + model.config.auxdata)
      >>> scan = np.linspace(0, 5, 21)
      >>> obs_limit, exp_limits, (scan, results) = pyhf.infer.intervals.upper_limits.upper_limit(
      ...     data, model, scan, return_results=True, calctype="toybased", ntoys=3000
      ... )
  • Allow for fit parameter values from required fits in pyhf.infer.test_statistics functions to be returned by use of return_fitted_pars kwarg with the pyhf.infer.test_statistics functions and return_calculator kwarg with pyhf.infer.hypotest. (PR #1554)

  • A validate kwarg has been added to pyhf.workspace.Workspace and
    pyhf.pdf.Model to allow skipping validation. (PR #1646) This should only be used by expert users who understand the risks.

  • A pyhf.default_backend has been added that is configurable through a default kwarg in pyhf.set_backend. (PR #1646) This allows setting the pyhf.default_backend to be different from the value of pyhf.tensorlib returned by pyhf.get_backend, which can be useful in situations where differentiable model construction is needed.

      >>> import jax
      >>> import pyhf
      >>> pyhf.set_backend("jax", default=True)
      >>> pyhf.set_backend("numpy")
      >>> pyhf.get_backend()
      (<pyhf.tensor.numpy_backend.numpy_backend object at 0x...>, <pyhf.optimize.scipy_optimizer object at 0x...>)
      >>> pyhf.default_backend
      <pyhf.tensor.jax_backend.jax_backend object at 0x...>
      >>> def example_op(x):
      ...     return 2 * pyhf.default_backend.power(pyhf.default_backend.astensor(x), 3)
      ...
      >>> example_op([2.0])
      DeviceArray([16.], dtype=float64)
      >>> jax.jacrev(jax.jit(example_op))([2.0])
      [DeviceArray([24.], dtype=float64, weak_type=True)]
  • Schema validation now allows for both list and pyhf.tensorlib objects to exist in the model specification. (PR #1647)

        >>> import pyhf
        >>> signal = pyhf.tensorlib.astensor([12.0, 11.0])
        >>> background = pyhf.tensorlib.astensor([50.0, 52.0])
        >>> background_uncertainty = pyhf.tensorlib.astensor([3.0, 7.0])
        >>> model = pyhf.simplemodels.uncorrelated_background(
        ...     signal=signal, bkg=background, bkg_uncertainty=background_uncertainty
        ... )

CLI API

  • The pyhf xlm2json CLI API now has a -v/--mount option to support reading XML configurations with absolute paths. (PR #1909) Similar to Docker volume mounts, the options allows a user to pass two fields separated by a colon (:). The first field is a local path and the second field is the absolute path specified in the XML configuration to be substituted. Without the -v/--mount option a user would have to manually edit the absolute path in each XML file it appeared in!

    pyhf xml2json \
        --mount /local/path/to/workspace:/absolute/path/to/replace/inside/xml \
        --output-file workspace.json \
        workspace/analysis_config.xml

Deprecations

Python API

  • The pyhf.infer.intervals.upperlimit API has been deprecated in favor of pyhf.infer.intervals.upper_limits.upper_limit.
    The pyhf.infer.intervals.upperlimit API will removed in pyhf v0.9.0. (PR #1274)

Removals

Python API

  • The pyhf.simplemodels.hepdata_like API, deprecated since pyhf v0.6.2, has been removed. (PR #1670) Use the pyhf.simplemodels.uncorrelated_background API instead.

  • pyhf.workspace.Workspace's parameters attribute is removed in favor of using pyhf.pdf._ModelConfig's parameters. (PR #1625)

  • `pyhf.works...

Read more

v0.7.0rc4

10 Sep 02:47
Compare
Choose a tag to compare
v0.7.0rc4 Pre-release
Pre-release

Notes

This is the fourth v0.7.0 release candidate. Please use this for API testing, and for testing correctness or performance for v0.7.0.

To install the release candidate you can either use pip install's --pre flag

python -m pip install --upgrade --pre pyhf

or specify the version number exactly

python -m pip install --upgrade 'pyhf==0.7.0rc4'

What's Changed

  • docs: Document Channel Summary Mixin by @kratsg in #1972
  • docs: Harmonize docstring for test_stat in ToyCalculator by @kratsg in #1970
  • feat: Add support for _ModelConfig.set_poi(None) to unset model POI by @kratsg in #1985
  • chore: [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in #1989
  • fix: Add guards against shared shapesys paramsets by @kratsg in #1977
  • feat: Add type hints for tensor manager by @kratsg in #1963
  • fix: Form data through loop over channels for multichannel coupled histo notebook by @kratsg in #1974
  • feat: Allow schema validation with tensor types by @kratsg in #1665
  • fix: Guard against nan in test stat calculation by @matthewfeickert in #1993
  • fix: Pin codemetapy to v0.3.5 for --no-extras functionality by @matthewfeickert in #1995
  • ci: Install release candidates for 'current release' test workflow by @matthewfeickert in #1996
  • refactor: Use urllib.parse.urlsplit over urlparse by @matthewfeickert in #1997

Full Changelog: v0.7.0rc3...v0.7.0rc4

v0.7.0rc3

03 Sep 06:21
Compare
Choose a tag to compare
v0.7.0rc3 Pre-release
Pre-release

Notes

This is the third v0.7.0 release candidate. Please use this for API testing, and for testing correctness or performance for v0.7.0.

To install the release candidate you can either use pip install's --pre flag

python -m pip install --upgrade --pre pyhf

or specify the version number exactly

python -m pip install --upgrade 'pyhf==0.7.0rc3'

What's Changed

  • docs: Add typehint aliases by @kratsg in #1969
  • fix: Base URI for jsonschema.RefResolver has better behavior by @kratsg in #1976
  • build: Update lower bounds to jsonschema v4.15.0, importlib-resources v1.4.0 by @matthewfeickert in #1979
  • fix: Add PR number to Semantic PR Title Check concurrency group by @kratsg in #1981
  • feat: Promote validate kwarg to top-level functions in pyhf.simplemodels by @phinate in #1858
  • docs: Clarify absolute/relative for histosys by @kratsg in #1971

New Contributors

Full Changelog: v0.7.0rc2...v0.7.0rc3

v0.7.0rc2

29 Aug 06:06
Compare
Choose a tag to compare
v0.7.0rc2 Pre-release
Pre-release

Notes

This is the second v0.7.0 release candidate. Please use this for API testing, and for testing correctness or performance for v0.7.0.

To install the release candidate you can either use pip install's --pre flag

python -m pip install --upgrade --pre pyhf

or specify the version number exactly

python -m pip install --upgrade 'pyhf==0.7.0rc2'

What's Changed

Full Changelog: v0.7.0rc1...v0.7.0rc2