Repository navigation
Warn users about the upcoming move to UNC draft v0.2 - #39
Merged
Merged
Conversation
obsarray writes uncertainty metadata following v0.1 of the UNC specification. Draft v0.2 is being adopted into the CF conventions, is not backwards compatible with v0.1, and will become obsarray's default in a future release. - Add obsarray.set_options / get_options, with an unc_conventions option. "v0.1" (current behaviour) is the only valid value for now; the option is intended to become the conventions backend selector. - Add UNCConventionsWarning (a FutureWarning, so shown to end users by default). It is issued once per session, the first time obsarray writes uncertainty metadata (adding an uncertainty variable via the unc accessor or the templater), unless unc_conventions has been set explicitly. Reading uncertainty information never warns. - The warning's stacklevel is found dynamically so it points at the first frame outside obsarray, i.e. the user's own code.
- New user guide page covering what changes between v0.1 and draft v0.2, when the warning is shown, how to choose the conventions version or filter the warning, and guidance for packages built on obsarray - Site-wide announcement banner linking to it - Add set_options, get_options and UNCConventionsWarning to the API reference - Note the upcoming change in the README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #40.
obsarray writes uncertainty metadata following v0.1 of the UNC specification. Draft v0.2 is a major revision. It has been proposed for inclusion in the CF conventions, is not backwards compatible with v0.1, and will become obsarray's default in a future release. This PR tells users about the change ahead of time, and adds the option that is intended to become the conventions backend selector.
Behaviour
UNCConventionsWarning: a subclass ofFutureWarning, so Python shows it to end users by default.ds.unc[...](tuple orDataArray), or creating one from a template.stacklevelis found at runtime, so it points at the user's own code rather than obsarray internals.obsarray.set_options(unc_conventions="v0.1"): works either globally or as awithblock. Choosing a version explicitly silences the warning."v0.1"is the only valid value for now;"v0.2"will be added with the new backend.obsarray.get_options()returns the current settings.obsarray/options.pyandobsarray/conventions.py. The second is intended to grow into the conventions backend system.Docs
with obsarray.set_options(unc_conventions="v0.1"):rather than setting the option globally.set_options,get_optionsandUNCConventionsWarningadded to the API reference.The docs examples already use
:okwarning:, so the warning doesn't appear in the rendered examples.Testing
test_options.pyandtest_conventions.py. They cover: warning on both creation paths and the templater, once per session, silence under the option (global and block), no warning on read, the warning pointing at the calling code, the message content, and rejection of invalid options and values.ruffandmypypass locally.Notes for review
/en/latest/...), which will return a 404 until this is merged andlatestrebuilds.unc_conventions, after v0.2 becomes the default.DSWriter.writedoesn't warn, because it only writes out metadata that already exists. The warning fires when that metadata is created.with set_options(...)pattern.