Esempio n. 1
0
 def __repr__(self, *args, **kwargs):
     ''' Use pretty repr, like sc.prettyobj, but displaying full values '''
     output  = sc.prepr(self, skip=['values', 'low', 'high'], use_repr=False)
     output += 'values:\n' + repr(self.values)
     if self.low is not None:
         output += '\nlow:\n' + repr(self.low)
     if self.high is not None:
         output += '\nhigh:\n' + repr(self.high)
     return output
Esempio n. 2
0
 def __repr__(self):
     ''' Print out useful information when called'''
     output = sc.prepr(self)
     output += 'Health packages name: %s\n' % self.name
     output += '        Date created: %s\n' % sc.getdate(self.created)
     output += '       Date modified: %s\n' % sc.getdate(self.modified)
     output += '                 UID: %s\n' % self.uid
     output += '============================================================\n'
     return output
Esempio n. 3
0
 def __repr__(self):
     ''' Return a JSON-friendly output if possible, else revert to pretty repr '''
     try:
         json = self.to_json()
         which = json['which']
         pars = json['pars']
         output = f"cv.InterventionDict('{which}', pars={pars})"
     except:
         output = sc.prepr(self)
     return output
Esempio n. 4
0
def test_prepr_slots():
    sc.heading('Test pretty representation of an object using slots')

    class Foo():
        __slots__ = ['bar']

        def __init__(self):
            self.bar = 1

    x = Foo()
    print(sc.prepr(x))
    return x
Esempio n. 5
0
 def __repr__(self, *args, **kwargs):
     ''' Use pretty repr, like sc.prettyobj, but displaying full values '''
     output = sc.prepr(self, skip='values')
     output += 'values:\n' + repr(self.values)
     return output
Esempio n. 6
0
 def _disp(self):
     ''' Verbose output -- use Sciris' pretty repr by default '''
     return sc.prepr(self)
Esempio n. 7
0
 def _disp(self):
     '''
     Print a verbose display of the sim object. Used by repr(). See sim.disp()
     for the user version. Equivalent to sc.prettyobj().
     '''
     return sc.prepr(self)
Esempio n. 8
0
 def new_repr(self):
     return sc.prepr(self)
Esempio n. 9
0
 def disp(self):
     ''' Print a detailed representation of the intervention '''
     return print(sc.prepr(self))