Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit allowed values #5

Open
IzaakWN opened this issue Jan 19, 2021 · 2 comments · Fixed by #37
Open

Limit allowed values #5

IzaakWN opened this issue Jan 19, 2021 · 2 comments · Fixed by #37
Labels
enhancement New feature or request
Milestone

Comments

@IzaakWN
Copy link
Contributor

IzaakWN commented Jan 19, 2021

In some cases, one might want to limit the allowed values of an input variable to some discrete list or range. If the input is not within the predefined range, an error is thrown. This would be an optional key in the input variables, e.g.

  'inputs': [
      {'name': "eta",      'type': "real", range: [-2.5,2.5] },
      {'name': "pt",       'type': "real" },
      {'name': "genmatch", 'type': "int", allow: [0,1,2,3,4,5,6] },
      {'name': "wp",       'type': "string", 'allow': ["Loose","Medium","Tight"]},
  ],

Of course in some cases you might capture these cases with overflow, underflow, or default values elsewhere down the line.

@nsmith-
Copy link
Collaborator

nsmith- commented Jan 26, 2021

I think the nodes encode this information already: if a value is out of range or a key is not in the map then an error is thrown. Each node should probably get a flag to declare alternative handling of out-of-range, like clamp or default.

@nsmith- nsmith- added this to the Schema v2 milestone Feb 15, 2021
nsmith- added a commit that referenced this issue Feb 16, 2021
@nsmith- nsmith- added the enhancement New feature or request label Feb 16, 2021
nsmith- added a commit that referenced this issue Feb 16, 2021
* Add overflow behavior handling in binning nodes

Closes #5

* Add binning tests

And fix a bug! std::lower_bound gives edges[i] < x <= edges[i+1]
std::upper_bound gives edges[i] <= x < edges[i+1] which is what we specified

* Update rendered schemas

Need to add this to pre-commit or something
lwezenbe referenced this issue in lwezenbe/correctionlib Apr 7, 2021
Rebase & add JSONEncode
@IzaakWN
Copy link
Contributor Author

IzaakWN commented Mar 7, 2023

Hi @nsmith-, could we reopen this issue?

There's a use case in the TauPOG for limiting the values of string keys for systematic variations of the tau ID SF: We would like to decorrelate the statistical uncertainties between pt bins. To keep the file size down, we are using the default field in the Category node to assign the nominal SF to systematic variation that do not affect a given pt bin. As it is now in schema v2, any misspelling of the systematic key by the user would not throw an error.

Implementing an optional field of allowed values in the Variable node (or perhaps in each Category) would like to protect against this at the top of evaluation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

2 participants