Skip to content

Commit 8b56595

Browse files
committed
Merge branch 'develop' into notebook_interface
2 parents d6a8233 + eb68bfb commit 8b56595

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

pypop/extrae.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
from pkg_resources import resource_filename
1919

20-
import pandas as pd
21-
import numpy as np
20+
import pandas
21+
import numpy
2222

2323
from .prv import PRV, get_prv_header_info
2424
from . import config
@@ -144,7 +144,10 @@ def chop_prv_to_roi(prv_file, outfile=None):
144144
"Failed to filter ROI file:\n{}" "".format(result.stdout.decode())
145145
)
146146

147-
starttime, endtime = _get_roi_times(roi_prv)
147+
try:
148+
starttime, endtime = _get_roi_times(roi_prv)
149+
except ValueError as err:
150+
raise ValueError("Error cutting trace to ROI: {}".format(str(err)))
148151

149152
remove_trace(roi_prv)
150153

@@ -205,7 +208,12 @@ def _get_roi_times(roi_prv):
205208
raise ValueError("Unexpected event value: expected 40000012:1")
206209
if not (offs["value"] == 0).all():
207210
raise ValueError("Unexpected event value: expected 40000012:0")
208-
return ons["time"].min(), 1 + offs["time"].max()
211+
ontime, offtime = (ons["time"].min(), 1 + offs["time"].max())
212+
213+
if ontime is numpy.nan or offtime is numpy.nan:
214+
raise ValueError("Unable to locate valid ON-OFF bracket in trace")
215+
216+
return ontime, offtime
209217

210218

211219
def paramedir_analyze(
@@ -318,7 +326,7 @@ def _analyze_hist2D(tracefile, paramedir_config, variables, index_by_thread, sta
318326
os.remove(histfile)
319327

320328
if stat_names:
321-
data.index = pd.Index(stat_names)
329+
data.index = pandas.Index(stat_names)
322330

323331
if index_by_thread:
324332
return reindex_by_thread(data)
@@ -331,7 +339,7 @@ def reindex_by_thread(stats_dframe, thread_prefix="THREAD"):
331339
332340
Parameters
333341
----------
334-
stats_dframe: pd.DataFrame
342+
stats_dframe: pandas.DataFrame
335343
Dataframe to reindex. Typically this will have been produced using
336344
paramedir_analyze().
337345
@@ -341,11 +349,11 @@ def reindex_by_thread(stats_dframe, thread_prefix="THREAD"):
341349
the rank number and t the thread number.
342350
"""
343351

344-
if not isinstance(stats_dframe, pd.DataFrame):
352+
if not isinstance(stats_dframe, pandas.DataFrame):
345353
raise TypeError("stats_dframe must be a Pandas DataFrame")
346354

347355
oc_select = [c for c in stats_dframe.columns if c.startswith(thread_prefix)]
348-
newcols = pd.MultiIndex.from_tuples(
356+
newcols = pandas.MultiIndex.from_tuples(
349357
[tuple(int(x) for x in y.split(".")[1:]) for y in oc_select]
350358
)
351359
stats_dframe = stats_dframe[oc_select].set_axis(
@@ -443,12 +451,12 @@ def _split_binline(binline):
443451
# Grab the first float from each binspec, we'll return lower edges
444452
# Note that commas must be stripped from numbers...
445453
try:
446-
bins = np.fromiter(
454+
bins = numpy.fromiter(
447455
(floatmatch.findall(x)[0].replace(",", "") for x in bin_strings),
448-
dtype=np.float64,
456+
dtype=numpy.float64,
449457
)
450458
except IndexError:
451-
bins = np.asarray(bin_strings)
459+
bins = numpy.asarray(bin_strings)
452460

453461
return bins
454462

@@ -476,9 +484,9 @@ def _split_countline(countline, bins):
476484
# However many extra strings there are, join them to make the name
477485
count_name = " ".join(count_strings[0:extra_strings])
478486

479-
counts = np.asarray(count_strings[extra_strings:], dtype=np.float64)
487+
counts = numpy.asarray(count_strings[extra_strings:], dtype=numpy.float64)
480488

481-
return (count_name, pd.Series(counts, index=bins))
489+
return (count_name, pandas.Series(counts, index=bins))
482490

483491

484492
def load_paraver_histdata(hist_file):
@@ -501,7 +509,7 @@ def load_paraver_histdata(hist_file):
501509
if count_line.strip():
502510
name, data_dict[name] = _split_countline(count_line, bins)
503511

504-
return pd.DataFrame.from_dict(data_dict)
512+
return pandas.DataFrame.from_dict(data_dict)
505513

506514

507515
def is_extrae_tracefile(tracefile):

0 commit comments

Comments
 (0)