Source code for ccsd.src.utils.print

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""print.py: utility functions for printing to the console.
"""

import argparse
import os
from typing import Any, Dict, Union






[docs] def get_experiment_desc(args: Union[argparse.Namespace, Dict[str, Any]]) -> str: """Get the experiment description. Args: args (Union[argparse.Namespace, Dict[str, Any]]): parsed arguments for the experiment. Returns: str: the experiment description. """ experiment_desc = "Current experiment:\n\n" if isinstance(args, argparse.Namespace): for arg in vars(args): experiment_desc += f"\t{arg}: {getattr(args, arg)}\n" else: for arg in args: experiment_desc += f"\t{arg}: {args[arg]}\n" return experiment_desc
[docs] def initial_print( args: Union[argparse.Namespace, Dict[str, Any]], ascii_logo_path: str = "ascii_logo.txt", ) -> None: """Print the initial message to the console. Args: args (Union[argparse.Namespace, Dict[str, Any]]): parsed arguments for the experiment. ascii_logo_path (str, optional): path of the logo. Defaults to "ascii_logo.txt". """ # Get the ascii logo and the experiment description ascii_logo = get_ascii_logo(os.path.join(args.folder, ascii_logo_path)) experiment_desc = get_experiment_desc(args) # Print the initial message print(ascii_logo) print(100 * "-") print(experiment_desc)