lal_cuda._internal.log module

This module provides a log_stream class for generating logging information. It is intended for the generation of course-grained reporting of program execution for the user and should not be used in performance-critical situations, in tight loops, etc.

Formatting is organized by indenting levels which can be increased/decreased by calling the open/close methods of the stream respectively.

lal_cuda._internal.log.format_time(seconds, granularity=None)[source]

Create a nice ASCII representation of a time interval, given in seconds.

Parameters:
  • seconds – Time in seconds
  • granularity – The maximum number of interval levels to report
Returns:

string

class lal_cuda._internal.log.log_stream(fp_out=None)[source]

Bases: object

This class provides a file pointer for logging user feedback and methods for writing to it.

Generate an instance of the log_stream class.

Parameters:fp_out – An optional file pointer to use for the log.
set_fp(fp_out=None)[source]

Set the file pointer to be used for logging. Default is sys.stderr.

Parameters:fp_out – File pointer
Returns:None
open(msg, splice=None)[source]

Open a new indent bracket for the log.

Parameters:msg – An object with a __str__ method, or a list thereof
Returns:None
close(msg=None, time_elapsed=False)[source]

Close a new indent bracket for the log.

Add an elapsed time since the last open to the end if time_elapsed=True

Parameters:
  • msg – An object with a __str__ method, or a list thereof
  • time_elapsed – Boolean flag indicating whether to report the time elapsed for this indent level
Returns:

None

comment(msg, unhang=True, overwrite=False, blankline_before=False, blankline_after=False)[source]

Add a one-line comment to the log.

Parameters:
  • msg – An object with a __str__ method, or a list thereof
  • unhang
  • overwrite
Returns:

None

append(msg)[source]

Add to the end of the current line in the log.

Parameters:msg – An object with a __str__ method, or a list thereof
Returns:None
progress_bar(gen, count, *args, **kwargs)[source]

Display a progress bar for a generator.

Parameters:
  • gen – Generator
  • count – Number of generator iterations
  • args – Positional arguments to pass to the generator
  • kwargs – Keyword arguments to pass to the generator
Returns:

None

error(err_msg, code=None)[source]

Raise an exception.

Parameters:
  • err_msg – Error message
  • code – Optional error code to report
Returns:

None

blankline()[source]

Print a blank line to the stream.

Returns:None
raw(msg)[source]

Print raw, unformatted text to the log.

Parameters:msg – An object with a __str__ method, or a list thereof
Returns:None