Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update abitimer in io.abinit #4319

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/pymatgen/io/abinit/abitimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import collections
import logging
import os
import re
import sys

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -141,7 +142,16 @@ def _read(self, fh, fname):

def parse_line(line):
"""Parse single line."""
name, vals = line[:25], line[25:].split()
# Assume the first element of the values is a float. Use the first
# float appearing as a split between the name and the values.
# Also only digits, "." and spaces can be present after the fist float.
match = re.search(r"\s(\d+\.\d+[-\d.\s]*)$", line)
if not match:
raise self.Error(f"Cannot properly split line in label and values: {line}")
split_index = match.start()
name = line[:split_index].rstrip()
vals = line[split_index:].strip().split()

try:
ctime, cfract, wtime, wfract, ncalls, gflops = vals
except ValueError:
Expand Down Expand Up @@ -712,15 +722,11 @@ def to_table(self, sort_key="wall_time", stop=None):

def get_dataframe(self, sort_key="wall_time", **kwargs):
"""Return a pandas DataFrame with entries sorted according to `sort_key`."""
frame = pd.DataFrame(columns=AbinitTimerSection.FIELDS)

for osect in self.order_sections(sort_key):
frame = frame.append(osect.to_dict(), ignore_index=True)
data = [osect.to_dict() for osect in self.order_sections(sort_key)]
frame = pd.DataFrame(data, columns=AbinitTimerSection.FIELDS)

# Monkey patch
frame.info = self.info
frame.cpu_time = self.cpu_time
frame.wall_time = self.wall_time
frame.mpi_nprocs = self.mpi_nprocs
frame.omp_nthreads = self.omp_nthreads
frame.mpi_rank = self.mpi_rank
Expand Down
Loading