question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

refactor shapesys

See original GitHub issue

Summary

with the custom_mod stuff we can quite cleanly refactor shapesys (and remove its finalize)

def required_parset(sample_data, modifier_data):
    # count the number of bins with nonzero, positive yields
    valid_bins = [
        (sample_bin > 0 and modifier_bin > 0)
        for sample_bin, modifier_bin in zip(modifier_data, sample_data)
    ]

    factors = [
        (nom_yield / unc) ** 2
        for is_valid, nom_yield, unc in zip(valid_bins, sample_data, modifier_data)
        if is_valid
    ]
    n_parameters = sum(valid_bins)
    return {
        "paramset_type": "constrained_by_poisson",
        "n_parameters": n_parameters,
        "is_shared": False,
        "is_scalar": False,
        "inits": (1.0,) * n_parameters,
        "bounds": ((1e-10, 10.0),) * n_parameters,
        "fixed": False,
        "auxdata": tuple(factors),
        "factors": tuple(factors),
    }

Additional Information

No response

Code of Conduct

  • I agree to follow the Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lukasheinrichcommented, Oct 14, 2021

yes this works

1reaction
lukasheinrichcommented, Oct 13, 2021

yes, this is a very quick / straight-forward PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refactor modifier classes and add docstrings #1641 - GitHub
PR #1625 added the modifier builder and combine classes, but they might be good candidates for a refactor that allows for a base...
Read more >
RooStats::HistFactory::ShapeSys Class Reference - ROOT
Public Member Functions. ShapeSys (). Constraint::Type · GetConstraintType (). TH1 *, GetErrorHist (). std::string, GetHistoName ().
Read more >
histosys — pyhf 0.5.3 documentation - Read the Docs
histosys; normfactor · normsys · shapefactor · shapesys · staterror ... refactor-validationtest · refactor-remove-numpy-from-jax-backend ...
Read more >
Number of steps for refactoring by shapes | Download Table
In Refactoring by shapes it is possible to see that some numbers between brackets are lower than the correspondent steps numbers of Refactoring...
Read more >
pyhf | Read the Docs
... refactor-improve-error-message-for-sys-number-mismatch ... docs-copybutton-regex · docs-clarify-warning-shapesys-staterror · docs-clarifyfitparams ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found