ahkab.printing¶
This is the printing module of the simulator. Using its functions, the output will be somewhat uniform.
The functions defined in this module can be divided in the following groups:
- Informative functions: functions to print information, errors and warnings to the user during command-line execution.
- Printing netlist lines: functions to print conformingly to the netlist syntax, often to show information to the user for debugging purposes.
- Convenience functions: functions to abstract low level issues such as Unicode handling of text and number printing formats,
- Tabular formatting of data: functions to format and display data into tables,
which we provide straight from the
tabulatemodule. - Printing analysis results in a consistent fashion.
Informative functions¶
print_general_error(description[, ...]) |
Prints an error message to stderr |
print_info_line(msg_relevance_tuple, verbose) |
Conditionally print out a message |
print_parse_error(nline, line[, print_to_stdout]) |
Prints a parsing error to stderr |
print_warning(description[, print_to_stdout]) |
Prints a warning message to stderr |
Printing netlist lines¶
print_analysis(an) |
Prints an analysis to stdout in the netlist syntax |
Printing analysis results¶
print_fourier(label, f, F, THD[, outfile]) |
Print the results of a Fourier postprocess |
print_spicefft(label, f, F[, THD, uformat, ...]) |
Print the results of an FFT postprocess |
print_symbolic_equations(eq_list) |
Print symbolic equations for visual inspection |
print_symbolic_results(x) |
Print out symbolic results |
print_symbolic_transfer_functions(x) |
Print symbolic transfer functions |
Convenience functions¶
open_utf8(filename) |
Get a file handle wrapped in a UTF-8 writer |
printoptions(*args, **kwds) |
A context manager for numpy.set_printoptions |
All functions in alphabetical order¶
-
open_utf8(filename)[source]¶ Get a file handle wrapped in a UTF-8 writer
The file is opened in
wmode.Parameters:
- filename : string
- The file name, just like you would pass to Python’s built-in
open()method.
Returns:
- fp : codecs.UTF8Writer object
- The wrapped file pointer.
-
print_analysis(an)[source]¶ Prints an analysis to
stdoutin the netlist syntaxParameters:
- an : dict
- An analysis description in dictionary format.
-
print_fourier(label, f, F, THD, outfile=u'stdout')[source]¶ Print the results of a Fourier postprocess
Parameters:
- label : str, or tuple of str
- The identifier of a variable. Eg.
'Vn1'or'I(VS)'. If a tuple of two identifiers is provided, it will be interpreted as the difference of the two, in the formlabel[0]-label[1]. - f : ndarray of floats
- The frequencies, including the DC.
- F : ndarray of complex data
- The result of the Fourier transform.
- THD : float, optional
- The total harmonic distortion, if
freqwas specified in the FFT analysis. Defaults toNone. - outfile : str, optional
- The file name to print to. Defaults to
'stdout', for the standard output.
-
print_general_error(description, print_to_stdout=False)[source]¶ Prints an error message to
stderrParameters:
- description : str
- The error description.
- print_to_stdout : bool, optional
- When set to
True, printing tostdoutinstead ofstderr. Defaults toFalse.
-
print_info_line(msg_relevance_tuple, verbose, print_nl=True)[source]¶ Conditionally print out a message
Parameters:
- msg_relevance_tuple : sequence
- A tuple or list made of
msgandimportance, wheremsgis a string, containing the information to be displayed to the user, andimportance, an integer, is its importance level. Zero corresponds to the highest possible importance level, which is always printed out by the simple algorithm discussed below. - verbose : int
- The verbosity level of the program execution. Admissible levels are in the 0-6 range.
- print_nl : boolean, optional
- Whether a new line character should be appended or not to the string
msgdescribed above, if it’s printed out. Defaults toTrue.
Algorithm selecting when to print:
The message
msgis printed out if the verbosity level is greater or equal than its importance.
-
print_parse_error(nline, line, print_to_stdout=False)[source]¶ Prints a parsing error to
stderrParameters:
- nline : int
- The number of the line on which the error occurred.
- line : str
- The line of the file with the error.
- print_to_stdout : bool, optional
- When set to
True, printing tostdoutinstead ofstderr. Defaults toFalse.
-
print_result_check(badvars, verbose=2)[source]¶ Prints out the results of an OP check
It assumes one set of results is calculated with \(G_{min}\), the other without.
Parameters:
- badvars : list
- The list returned by
results.op_solution.gmin_check(). - verbose : int, optional
- The verbosity level, from 0 (silent) to 6.
-
print_spicefft(label, f, F, THD=None, uformat=u'NORM', window=None, outfile=u'stdout')[source]¶ Print the results of an FFT postprocess
Parameters:
- label : str, or tuple of string
- The identifier of a variable. Eg.
'Vn1'or'I(VS)'. If a tuple of two identifiers is provided, it will be interpreted as the difference of the two, in the formlabel[0]-label[1]. - f : ndarray of floats
- The frequencies, including the DC.
- F : ndarray of complex data
- The result of the Fourier transform.
- THD : float, optional
- The total harmonic distortion, if
freqwas specified in the FFT analysis. Defaults toNone. - uformat : str, optional
- The parameter format selects whether normalized or unnormalized magnitudes are printed. It is to be set to ‘NORM’ (default value) for normalized magnitude, to ‘UNORM’ for unnormalized.
- window : str, optional
- The window employed in the FFT analisys. Defaults to rectangular.
- outfile : str
- The file name to print to. Defaults to
'stdout', for the standard output.
-
print_symbolic_equations(eq_list)[source]¶ Print symbolic equations for visual inspection
Parameters:
- eq_list : list
- The list of equations to be printed. This is what
sympywill be asked to solve, typically.
-
print_symbolic_results(x)[source]¶ Print out symbolic results
Parameters:
- x : dict
- A dictionary composed of elements like
{v:expr}, wherevis a circuit variable andexpris thesympyexpression corresponding to it, as found by the solver.
-
print_symbolic_transfer_functions(x)[source]¶ Print symbolic transfer functions
Parameters:
- x : dict
- A dictionary of dictionaries. Each top level dictionary is a
symbol : symbolic transfer function pair, eg.
{vo/vin:<tf>}. Each transfer function (<tf>) is itself a dictionary, having as keys the following strings:'gain', corresponding to the complete symbolic TF expression,'gain0', corresponding to the DC gain and'poles'and'zeros', corresponding to lists of symbolic expressions of the singularities.
-
print_warning(description, print_to_stdout=False)[source]¶ Prints a warning message to
stderrParameters:
- description : str
- The warning message.
- print_to_stdout : bool, optional
- When set to
True, printing tostdoutinstead ofstderr. Defaults toFalse.
-
table(data, *args, **argsd)[source]¶ Format a fixed width table for pretty printing
No data processing is done here, instead we call tabulate‘s
tabulate.tabulate(), passing all arguments unmodified.Parameters:
- data : list-of-lists or a dictionary of iterables or a 2D NumPy array (or more).
- The tabular data.
The remaining arguments, not documented here, are:
- headers : sequence, optional
- An explicit list of column headers.
- tablefmt : str, optional
- Table formatting specification.
- floatfmt : str, optional
- Floats formatting specification.
- numalign : str, optional
- Alignment flag for numbers.
- stralign : str, optional
- Alignment specification for strings, eg. “right”.
- missingval : str, optional
- Element for the missing values.