Created
February 21, 2016 13:42
-
-
Save ntim/7367270bffba0db2ed0b to your computer and use it in GitHub Desktop.
Luigi Parameter with a number with uncertainty
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
| import luigi | |
| import uncertainties | |
| class UncertaintyParameter(luigi.Parameter): | |
| """ | |
| Implements luigi.Parameter for the uncertainties package. | |
| https://github.com/spotify/luigi/ | |
| https://github.com/lebigot/uncertainties | |
| """ | |
| def parse(self, s): | |
| return uncertainties.ufloat_fromstr(s) | |
| def serialize(self, x): | |
| """ | |
| Serialize with a high precision. | |
| """ | |
| return "{:.18e}".format(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment