def _brief(self): ''' Return a one-line description of a sim -- used internally and by repr(); see sim.brief() for the user version. ''' # Try to get a detailed description of the sim... try: if self.results_ready: infections = self.summary['cum_infections'] deaths = self.summary['cum_deaths'] results = f'{infections:n}⚙, {deaths:n}☠' else: results = 'not run' # Set label string labelstr = f'"{self.label}"' if self.label else '<no label>' start = sc.date(self['start_day'], as_date=False) if self['end_day']: end = sc.date(self['end_day'], as_date=False) else: end = sc.date(self['n_days'], start_date=start) pop_size = self['pop_size'] pop_type = self['pop_type'] string = f'Sim({labelstr}; {start} to {end}; pop: {pop_size:n} {pop_type}; epi: {results})' # ...but if anything goes wrong, return the default with a warning except Exception as E: string = sc.objectid(self) string += f'Warning, sim appears to be malformed:\n{str(E)}' return string
def __repr__(self): ''' Use brief repr by default ''' try: string = self._brief() except Exception as E: string = sc.objectid(self) string += f'Warning, something went wrong printing object:\n{str(E)}' return string
def __repr__(self): ''' Set display options based on current level of verbosity ''' try: if cvo['verbose']: string = self._disp() else: string = self._brief() except Exception as E: string = sc.objectid(self) string += f'Warning, something went wrong printing object:\n{str(E)}' return string
def _brief(self): ''' Return a one-line description of the people -- used internally and by repr(); see people.brief() for the user version. ''' try: layerstr = ', '.join([str(k) for k in self.layer_keys()]) string = f'People(n={len(self):0n}; layers: {layerstr})' except Exception as E: string = sc.objectid(self) string += f'Warning, multisim appears to be malformed:\n{str(E)}' return string
def _brief(self): ''' Brief output -- use a one-line output, a la Python's default ''' return sc.objectid(self)
def __repr__(self): ''' Brief representation ''' output = sc.objectid(self) output += 'Covasim options (see also cv.options.disp()):\n' output += sc.pp(self.to_dict(), output=True) return output