Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
obackhouse committed Jun 22, 2023
1 parent 3f29c1d commit c117ad6
Show file tree
Hide file tree
Showing 199 changed files with 9,828 additions and 8,467 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ target-version = [
include = "vayesta"
exclude = """
/(
| *__pycache__*
| __pycache__
| .git
)/
"""
53 changes: 30 additions & 23 deletions vayesta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vayesta.mpi import init_mpi


__version__ = '1.0.1'
__version__ = "1.0.1"

Check warning on line 12 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L12

Added line #L12 was not covered by tests

# Command line arguments
args = cmdargs.parse_cmd_args()
Expand All @@ -23,6 +23,7 @@

# Logging
from vayesta.core import vlog

if args.output_dir:
os.makedirs(args.output_dir, exist_ok=True)

Expand All @@ -32,7 +33,7 @@

fmt = vlog.VFormatter(indent=True)
# Log to stream
if (not args.quiet and mpi.is_master):
if not args.quiet and mpi.is_master:

Check warning on line 36 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L36

Added line #L36 was not covered by tests
# Everything except logging.OUTPUT goes to stderr:
errh = vlog.VStreamHandler(sys.stderr, formatter=fmt)
errh.addFilter(vlog.LevelExcludeFilter(exclude=[logging.OUTPUT]))
Expand All @@ -42,8 +43,8 @@
outh.addFilter(vlog.LevelIncludeFilter(include=[logging.OUTPUT]))
log.addHandler(outh)
# Log to file
if (args.log or not mpi.is_master):
logname = (args.log or "output")
if args.log or not mpi.is_master:
logname = args.log or "output"

Check warning on line 47 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L46-L47

Added lines #L46 - L47 were not covered by tests
if args.output_dir:
logname = os.path.join(args.output_dir, logname)
log.addHandler(vlog.VFileHandler(logname, formatter=fmt))
Expand All @@ -58,22 +59,23 @@
log.addHandler(errhandler)

# Print Logo, unless interactive Python interpreter
is_interactive = hasattr(sys, 'ps1')
is_interactive = hasattr(sys, "ps1")

Check warning on line 62 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L62

Added line #L62 was not covered by tests
if not is_interactive:
logofile = os.path.abspath(os.path.join(os.path.dirname(__file__), 'logo.txt'))
logofile = os.path.abspath(os.path.join(os.path.dirname(__file__), "logo.txt"))

Check warning on line 64 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L64

Added line #L64 was not covered by tests
try:
with open(logofile, 'r') as f:
with open(logofile, "r") as f:

Check warning on line 66 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L66

Added line #L66 was not covered by tests
logo = f.read()
logo = (logo.rstrip() + ' ')
logo = logo.rstrip() + " "

Check warning on line 68 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L68

Added line #L68 was not covered by tests
except FileNotFoundError:
log.error("%s not found.", logofile)
logo = ''
log.info(logo + '\n', "version " + __version__)
logo = ""
log.info(logo + "\n", "version " + __version__)

Check warning on line 72 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L71-L72

Added lines #L71 - L72 were not covered by tests

# --- Required modules


def import_package(name, required=True):
fmt = ' * %-10s v%-8s location: %s'
fmt = " * %-10s v%-8s location: %s"

Check warning on line 78 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L78

Added line #L78 was not covered by tests
try:
package = importlib.import_module(name.lower())
log.debug(fmt, name, package.__version__, os.path.dirname(package.__file__))
Expand All @@ -85,28 +87,31 @@ def import_package(name, required=True):
log.debug("%s not found.", name)
return None


log.debug("Required packages:")
numpy = import_package('NumPy')
import_package('SciPy')
import_package('h5py')
pyscf = import_package('PySCF')
numpy = import_package("NumPy")
import_package("SciPy")
import_package("h5py")
pyscf = import_package("PySCF")

Check warning on line 95 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L92-L95

Added lines #L92 - L95 were not covered by tests
# Optional
import_package('mpi4py', False)
import_package('cvxpy', False)
dyson = import_package('dyson', False)
ebcc = import_package('ebcc', False)
import_package("mpi4py", False)
import_package("cvxpy", False)
dyson = import_package("dyson", False)
ebcc = import_package("ebcc", False)

Check warning on line 100 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L97-L100

Added lines #L97 - L100 were not covered by tests

# --- Git hashes


def get_git_hash(dir):
git_dir = os.path.join(dir, '.git')
cmd = ['git', '--git-dir=%s' % git_dir, 'rev-parse', '--short', 'HEAD']
git_dir = os.path.join(dir, ".git")
cmd = ["git", "--git-dir=%s" % git_dir, "rev-parse", "--short", "HEAD"]

Check warning on line 107 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L106-L107

Added lines #L106 - L107 were not covered by tests
try:
githash = subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.STDOUT).rstrip()
except subprocess.CalledProcessError:
githash = "<Not Found>"
return githash


log.debug("Git hashes:")
vdir = os.path.dirname(os.path.dirname(__file__))
vhash = get_git_hash(vdir)
Expand All @@ -124,21 +129,22 @@ def get_git_hash(dir):
log.debug(" * EBCC: %s", ehash)

Check warning on line 129 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L122-L129

Added lines #L122 - L129 were not covered by tests

# --- System information
log.debug('System: node= %s processor= %s' % (platform.node(), platform.processor()))
log.debug("System: node= %s processor= %s" % (platform.node(), platform.processor()))

Check warning on line 132 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L132

Added line #L132 was not covered by tests

# --- MPI
if mpi:
log.debug("MPI: rank= %d size= %d node= %s", mpi.rank, mpi.size, platform.node())

# --- Environment
log.debug("Environment variables:")
omp_num_threads = os.getenv('OMP_NUM_THREADS')
omp_num_threads = os.getenv("OMP_NUM_THREADS")

Check warning on line 140 in vayesta/__init__.py

View check run for this annotation

Codecov / codecov/patch

vayesta/__init__.py#L140

Added line #L140 was not covered by tests
if omp_num_threads is not None:
omp_num_threads = int(omp_num_threads)
log.debug(" OMP_NUM_THREADS= %s", omp_num_threads)

# ---


def new_log(logname, fmt=None, remove_existing=True):
if fmt is None:
fmt = vlog.VFormatter(indent=True)
Expand All @@ -150,5 +156,6 @@ def new_log(logname, fmt=None, remove_existing=True):
log.removeHandler(hdl)
log.addHandler(vlog.VFileHandler(logname, formatter=fmt))


# --- NumPy
numpy.set_printoptions(linewidth=120)
Loading

0 comments on commit c117ad6

Please sign in to comment.