histogrammar.util.CachedFcn

class histogrammar.util.CachedFcn(expr, name=None)[source]

Bases: histogrammar.util.UserFcn

Represents a cached UserFcn.

Note that the histogrammar.util.cached function creates a CachedFcn, avoids duplication, and commutes with histogrammar.util.named and histogrammar.util.serializable (they can be applied in any order).

Example:

f = cached(lambda x: complexFunction(x))
f(3.14)   # computes the function
f(3.14)   # re-uses the old value
f(4.56)   # computes the function again at a new point
np = <module 'numpy' from '/home/pivarski/.local/lib/python2.7/site-packages/numpy/__init__.pyc'>
numpy = <module 'numpy' from '/home/pivarski/.local/lib/python2.7/site-packages/numpy/__init__.pyc'>