def human_format(err): from dolo.misc.termcolor import colored err_type = err['type'] err_type = colored(err_type, color=('red' if err_type == 'error' else 'yellow')) err_range = str([e + 1 for e in err['range'][0]])[1:-1] return '{:7}: {:6}: {}'.format(err_type, err_range, err['text'])
def __str__(self): from dolo.misc.termcolor import colored s = u''' Model: ------ name: "{name}" type: "{type}" file: "{filename}\n'''.format(**self.infos) ss = '\nEquations:\n----------\n\n' res = self.residuals() # for eqgroup, eqlist in self.symbolic.equations.items(): for eqgroup in res.keys(): if eqgroup == 'auxiliary': continue if eqgroup == 'dynare': eqlist = self.symbolic.equations else: eqlist = self.symbolic.equations[eqgroup] ss += u"{}\n".format(eqgroup) for i, eq in enumerate(eqlist): val = res[eqgroup][i] if abs(val) < 1e-8: val = 0 vals = '{:.4f}'.format(val) if abs(val) > 1e-8: vals = colored(vals, 'red') ss += u" {eqn:2} : {vals} : {eqs}\n".format(eqn=str(i+1), vals=vals, eqs=eq) ss += "\n" s += ss return s
def warning_on_one_line(message, category, filename, lineno, file=None, line=None): return '{}:{}:{}\n {}\n'.format(colored(category.__name__, 'yellow'), filename, lineno, message)
def __str__(self): from dolo.misc.termcolor import colored from numpy import zeros s = u''' Model: ------ name: "{name}" type: "{type}" file: "{filename}\n'''.format(**self.infos) ss = '\nEquations:\n----------\n\n' res = self.residuals() res.update({'definitions': zeros(1)}) if self.model_type == 'dynare': equations = {"dynare": self.symbolic.equations.copy()} else: equations = self.symbolic.equations.copy() definitions = self.symbolic.definitions tmp = [] for deftype in definitions: tmp.append(deftype + ' = ' + definitions[deftype]) definitions = {'definitions': tmp} equations.update(definitions) # for eqgroup, eqlist in self.symbolic.equations.items(): for eqgroup in res.keys(): if eqgroup == 'auxiliary': continue if eqgroup == 'dynare': eqlist = equations if eqgroup == 'definitions': eqlist = equations[eqgroup] # Update the residuals section with the right number of empty # values. Note: adding 'zeros' was easiest (rather than empty # cells), since other variable types have arrays of zeros. res.update({'definitions': [None for i in range(len(eqlist))]}) else: eqlist = equations[eqgroup] ss += u"{}\n".format(eqgroup) for i, eq in enumerate(eqlist): val = res[eqgroup][i] if val is None: ss += u" {eqn:2} : {eqs}\n".format(eqn=str(i + 1), eqs=eq) else: if abs(val) < 1e-8: val = 0 vals = '{:.4f}'.format(val) if abs(val) > 1e-8: vals = colored(vals, 'red') ss += u" {eqn:2} : {vals} : {eqs}\n".format(eqn=str(i + 1), vals=vals, eqs=eq) ss += "\n" s += ss return s
def human_format(err): from dolo.misc.termcolor import colored err_type = err['type'] err_type = colored(err_type, color=('red' if err_type=='error' else 'yellow')) err_range = str([e+1 for e in err['range'][0]])[1:-1] return '{:7}: {:6}: {}'.format( err_type, err_range, err['text'] )
def __str__(self): from dolo.misc.termcolor import colored from numpy import zeros s = "Model:\n------\nname: \"{name}\"\ntype: \"{type}\"\n".format( **self.infos) s += "\nFeatures:\n----------\n" features = self.features for f in features.keys(): ind = features[f] if ind: s += "{feature} {tick}".format(feature=f, tick=colored("✓", "green")) else: s += "{feature} {tick}".format(feature=f, tick=colored("✗", "red")) s += "\n" return s
def __str__(self): from dolo.misc.termcolor import colored from numpy import zeros s = u''' Model: ------ name: "{name}" type: "{type}" file: "{filename}\n'''.format(**self.infos) ss = '\nEquations:\n----------\n\n' res = self.residuals() res.update({'definitions': zeros(1)}) equations = self.symbolic.equations.copy() definitions = self.symbolic.definitions tmp = [] for deftype in definitions: tmp.append(deftype + ' = ' + definitions[deftype]) definitions = {'definitions': tmp} equations.update(definitions) # for eqgroup, eqlist in self.symbolic.equations.items(): for eqgroup in res.keys(): if eqgroup == 'auxiliary': continue if eqgroup == 'dynare': eqlist = equations if eqgroup == 'definitions': eqlist = equations[eqgroup] # Update the residuals section with the right number of empty # values. Note: adding 'zeros' was easiest (rather than empty # cells), since other variable types have arrays of zeros. res.update({'definitions': [None for i in range(len(eqlist))]}) else: eqlist = equations[eqgroup] ss += u"{}\n".format(eqgroup) for i, eq in enumerate(eqlist): val = res[eqgroup][i] if val is None: ss += u" {eqn:2} : {eqs}\n".format(eqn=str(i+1), eqs=eq) else: if abs(val) < 1e-8: val = 0 vals = '{:.4f}'.format(val) if abs(val) > 1e-8: vals = colored(vals, 'red') ss += u" {eqn:2} : {vals} : {eqs}\n".format(eqn=str(i+1), vals=vals, eqs=eq) ss += "\n" s += ss return s
def __str__(self): from dolo.misc.termcolor import colored s = u''' Model object: ------------ - name: "{name}" - type: "{type}" - file: "{filename}\n'''.format(**self.infos) ss = '\n- residuals:\n\n' res = self.residuals() for eqgroup, eqlist in self.symbolic.equations.iteritems(): ss += u" {}\n".format(eqgroup) for i, eq in enumerate(eqlist): val = res[eqgroup][i] if abs(val) < 1e-8: val = 0 vals = '{:.4f}'.format(val) if abs(val) > 1e-8: vals = colored(vals, 'red') # eq = eq.replace('|', u"\u27C2") ss += u" {eqn:3} : {vals} : {eqs}\n".format(eqn=str(i + 1), vals=vals, eqs=eq) ss += "\n" s += ss # import pprint # s += '- residuals:\n' # s += pprint.pformat(compute_residuals(self),indent=2, depth=1) return s
def __str__(self): from dolo.misc.termcolor import colored s = u''' Model object: ------------ - name: "{name}" - type: "{type}" - file: "{filename}\n'''.format(**self.infos) ss = '\n- residuals:\n\n' res = self.residuals() # for eqgroup, eqlist in self.symbolic.equations.items(): for eqgroup in res.keys(): eqlist = self.symbolic.equations[eqgroup] ss += u" {}\n".format(eqgroup) for i, eq in enumerate(eqlist): val = res[eqgroup][i] if abs(val) < 1e-8: val = 0 vals = '{:.4f}'.format(val) if abs(val) > 1e-8: vals = colored(vals, 'red') # eq = eq.replace('|', u"\u27C2") ss += u" {eqn:3} : {vals} : {eqs}\n".format(eqn=str(i+1), vals=vals, eqs=eq) ss += "\n" s += ss # import pprint # s += '- residuals:\n' # s += pprint.pformat(compute_residuals(self),indent=2, depth=1) return s
def __str__(self): from dolo.misc.termcolor import colored s = u''' Model: ------ name: "{name}" type: "{type}" file: "{filename}\n'''.format(**self.infos) ss = '\nEquations:\n----------\n\n' res = self.residuals() # for eqgroup, eqlist in self.symbolic.equations.items(): for eqgroup in res.keys(): if eqgroup == 'auxiliary': continue if eqgroup == 'dynare': eqlist = self.symbolic.equations else: eqlist = self.symbolic.equations[eqgroup] ss += u"{}\n".format(eqgroup) for i, eq in enumerate(eqlist): val = res[eqgroup][i] if abs(val) < 1e-8: val = 0 vals = '{:.4f}'.format(val) if abs(val) > 1e-8: vals = colored(vals, 'red') ss += u" {eqn:2} : {vals} : {eqs}\n".format(eqn=str(i + 1), vals=vals, eqs=eq) ss += "\n" s += ss return s
def warning_on_one_line(message, category, filename, lineno, file=None, line=None): return '{}:{}:{}\n {}\n'.format( colored( category.__name__, 'yellow'), filename, lineno, message)