Decorators

Decorators that extend evaluator functionality with caching and logging capabilities.

Caching

class cacher

Bases: object

Add caching ability to an evaluator. When evaluating sites the cache will be checked to determine if any of the sites have already been evaluated. If so, then the cached sites will take their response values from the cache. The remaining, uncached sites will be evaluated and added to the cache. The cache operates using an underlying SQLite database.

Methods:

__init__(func, opt_problem, db_name[, ...])

Initialize the cacher.

__call__(sites)

Evaluate sites using the cache for previously evaluated sites.

get_cache()

Return a copy of the current cache.

__init__(func, opt_problem, db_name, table_name='Design_Data', delta=1e-08, auto_update=False)

Initialize the cacher.

Parameters:
  • func (Callable) – Function to apply caching to.

  • opt_problem (OptProblem) – Problem definition as an OptProblem instance.

  • db_name (str) – Name of database file to read/write cached sites.

  • table_name (str) – Name of the table where site data is stored. Defaults to ‘Design_Data’.

  • delta (float) – Unscaled distance used to determine if two sites are duplicate. Defaults to 1e-8.

  • auto_update (bool) – When True the database will be re-read before evaluating sites. Defaults to False.

Return type:

None

__call__(sites)

Evaluate sites using the cache for previously evaluated sites.

Parameters:

sites (DataFrame) – Sites to evaluate.

Return type:

None

get_cache()

Return a copy of the current cache.

Return type:

DataFrame

Site Logger

class site_logger

Bases: object

Decorator that keeps track of evaluated sites in the order they were evaluated. Logged sites can be accessed using the get_log() method. Note that this will not check for duplicate sites.

Methods:

__init__(func)

Initialize the site logger.

__call__(sites, **kwargs)

Evaluate responses and log sites.

get_log()

Get all the sites that have been logged.

__init__(func)

Initialize the site logger.

Parameters:

func (Callable) – Function to log evaluated sites of.

Return type:

None

__call__(sites, **kwargs)

Evaluate responses and log sites.

Parameters:
  • sites (DataFrame) – Sites to be evaluated.

  • **kwargs – Additional keyword arguments.

Return type:

None

get_log()

Get all the sites that have been logged.

Returns:

Copy of the logged sites.

Return type:

pd.DataFrame