Skip to content

Instantly share code, notes, and snippets.

@ntim
Created February 21, 2016 13:42
Show Gist options
  • Select an option

  • Save ntim/7367270bffba0db2ed0b to your computer and use it in GitHub Desktop.

Select an option

Save ntim/7367270bffba0db2ed0b to your computer and use it in GitHub Desktop.
Luigi Parameter with a number with uncertainty
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