<s> """<STR_LIT>""" <EOL> __all__ = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> import os <EOL> import numpy as np <EOL> from . dream . state import load_state <EOL> from . import plugin <EOL> from . cli import load_model , load_best <EOL> def reload_errors ( model , store , nshown = <NUM_LIT:50> , random = True ) : <EOL> """<STR_LIT>""" <EOL> problem = load_model ( model ) <EOL> load_best ( problem , os . path . join ( store , model [ : - <NUM_LIT:3> ] + "<STR_LIT>" ) ) <EOL> state = load_state ( os . path . join ( store , model [ : - <NUM_LIT:3> ] ) ) <EOL> state . mark_outliers ( ) <EOL> return calc_errors_from_state ( problem , state , <EOL> nshown = nshown , random = random ) <EOL> def calc_errors_from_state ( problem , state , nshown = <NUM_LIT:50> , random = True ) : <EOL> """<STR_LIT>""" <EOL> points , _logp = state . sample ( ) <EOL> if points . shape [ <NUM_LIT:0> ] < nshown : <EOL> nshown = points . shape [ <NUM_LIT:0> ] <EOL> if random : <EOL> points = points [ np . random . permutation ( len ( points ) - <NUM_LIT:1> ) ] <EOL> return calc_errors ( problem , points [ - nshown : - <NUM_LIT:1> ] ) <EOL> def calc_errors ( problem , points ) : <EOL> """<STR_LIT>""" <EOL> original = problem . getp ( ) <EOL> try : <EOL> ret = plugin . calc_errors ( problem , points ) <EOL> except Exception : <EOL> import traceback , logging <EOL> info = [ "<STR_LIT>" , <EOL> traceback . format_exc ( ) ] <EOL> logging . error ( "<STR_LIT:\n>" . join ( info ) ) <EOL> ret = None <EOL> finally : <EOL> problem . setp ( original ) <EOL> return ret <EOL> def show_errors ( errs ) : <EOL> """<STR_LIT>""" <EOL> return plugin . show_errors ( errs ) </s>
