Logtaker

class triqs_maxent.logtaker.Logtaker[source]

Bases: object

Handling logging and error messages.

This class allows to log all the information that is written to the screen to a file as well.

Methods

clear_error_messages()

clear the list of all error messages raised

close_logfile()

close the log file

error_message(msg, *args, **kwargs)

report error and keep track of the error message

get_error_messages()

get a list of all error messages raised

log_time([message_verbosity])

print the current time

logged_message(msg, *args, **kwargs)

print a message and write it to the log file

message(message_verbosity, msg, *args, **kwargs)

print a message and write it to the log file

open_logfile(name[, append])

open the log file

welcome_message([always, message_verbosity])

print a welcome message

solver_verbose_callback

verbosity_message

clear_error_messages()[source]

clear the list of all error messages raised

close_logfile()[source]

close the log file

error_message(msg, *args, **kwargs)[source]

report error and keep track of the error message

Parameters:
msgstr

the error message

get_error_messages()[source]

get a list of all error messages raised

log_time(message_verbosity=1)[source]

print the current time

logged_message(msg, *args, **kwargs)[source]

print a message and write it to the log file

Warning

The use of logged_message is deprecated. Use message instead.

Parameters:
msgstr

the message

message(message_verbosity, msg, *args, **kwargs)[source]

print a message and write it to the log file

Parameters:
message_verbosityVerbosityFlags

verbosity flags that must be set in order to write that message (can be one flag or a | combination)

msgstr

the message; it can contain {} that are formatted with format using the args and kwargs

open_logfile(name, append=True)[source]

open the log file

Parameters:
namestr

the name of the log file

welcome_message(always=False, message_verbosity=1)[source]

print a welcome message

class triqs_maxent.logtaker.VerbosityFlags[source]

Setting verbosity

This describes different verbosity levels for controlling how much output is generated.

Note that the actual integer values are considered implementation details and might not be conserved across versions.

VerbosityFlags can be combined using |, e.g. in order to write out header and timing information, use:

self.verbose = VerbosityFlags.Header | VerbosityFlags.Timing

Additional VerbosityFlags can be set with |=:

self.verbose |= VerbosityFlags.AlphaLoop

and unset with &= ~:

self.verbose &= ~VerbosityFlags.AlphaLoop

Testing for a particular flag can be done with &.

Use this in the Logtaker or in the MaxEntLoop.set_verbosity() method.

The following shows a typical output of the code and together with the VerbosityFlags for the individual lines:

ElementInfo     Calculating diagonal elements.
                Calling MaxEnt for element 0 0
Header          2018-11-22 16:51:11.012704
                MaxEnt run
                TRIQS application maxent
                ...
                scaling alpha by a factor 201 (number of data points)
AlphaLoop       alpha[0] =   1.00500000e+05, chi2 =   6.90348835e+04, n_iter=       9
SolverDetails   6 Q: 7.031977e+06, max_f: 1.494887e-05, conv: 5.297643e-16
AlphaLoop       alpha[1] =   2.69610927e+04, chi2 =   2.69219648e+04, n_iter=       7
                ...
Timing          MaxEnt loop finished in 0:00:00.548325
Quiet = 0
Header = 1
ElementInfo = 2
Timing = 4
AlphaLoop = 8
SolverDetails = 16
Errors = 32
Default = 47