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.

Model parameter index for components of non-scalar parameters

See original GitHub issue

Summary

With the addition of model.config.par_names, there is a well-defined name for components of non-scalar parameters available within pyhf. It would be useful if model.config.par_slice would support parameter indexing to access components of non-scalar parameters. At the moment it will return the slice of all components, and return a KeyError when using it with the name of a component.

This can be worked around (example utility in cabinetry: model_utils._parameter_index), but it would be convenient to support this in the pyhf API.

related:

Additional Information

Example usage for a model with multiple bins for a channel and staterror modifier

model: pyhf.pdf.Model
model.config.par_names()  # ['mu', 'staterror_SR[0]', 'staterror_SR[1]', 'staterror_SR[2]', 'staterror_SR[3]'] 
model.config.par_slice("staterror_SR")  # returns e.g. slice(1, 5, None)
model.config.par_slice("staterror_SR[0]")  # KeyError: 'staterror_SR[0]'

Code of Conduct

  • I agree to follow the Code of Conduct

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kratsgcommented, Oct 14, 2021

I think arguably, if you want to support that, we could have experimental query language support plugged in, so that the par_slice can delegate to the query language functionality…

0reactions
alexander-heldcommented, Oct 14, 2021

As far as I remember, yes #994 allows for this too. I opened this issue because I think it makes sense to have it in the model.config.par_slice API directly instead of just in the pyhf.experimental API. I would say that

model.config.par_slice("staterror_SR[0]")  # KeyError: 'staterror_SR[0]

not working could almost be viewed as a bug, since par_names is perfectly happy to provide that name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enter new value for parameter - Simulink - MathWorks
When the value of the selected variable or block parameter is nonscalar, use the text box at the bottom of the Connection table...
Read more >
SIT Set Model Parameters VI - NI - National Instruments
Simulation Data In specifies unique information about the model DLL. param index specifies the index number of a scalar or nonscalar parameter.
Read more >
Modeling Language GNU MathProg
A dummy index is an auxiliary model object, which acts like an individual variable. Values assigned to dummy indices are components of n-tuples...
Read more >
5 Parameters + Variables · Mimi.jl
For the latter case, model parameters can be unshared, such that they can only connect to one component/parameter pair and must be accessed...
Read more >
jagsUI: A Wrapper Around 'rjags' to Streamline 'JAGS' Analyses
Parameter names must match parameters included in the model. Calling non-scalar parameters without subsetting (e.g. alpha) will plot all ...
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