1717
1818from pkg_resources import resource_filename
1919
20- import pandas as pd
21- import numpy as np
20+ import pandas
21+ import numpy
2222
2323from .prv import PRV , get_prv_header_info
2424from . 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
@@ -208,7 +211,12 @@ def _get_roi_times(roi_prv):
208211 raise ValueError (
209212 "Unexpected event value: expected 40000012:0"
210213 )
211- return ons ['time' ].min (), 1 + offs ['time' ].max ()
214+ ontime , offtime = (ons ['time' ].min (), 1 + offs ['time' ].max ())
215+
216+ if ontime is numpy .nan or offtime is numpy .nan :
217+ raise ValueError ("Unable to locate valid ON-OFF bracket in trace" )
218+
219+ return ontime , offtime
212220
213221
214222def paramedir_analyze (
@@ -321,7 +329,7 @@ def _analyze_hist2D(tracefile, paramedir_config, variables, index_by_thread, sta
321329 os .remove (histfile )
322330
323331 if stat_names :
324- data .index = pd .Index (stat_names )
332+ data .index = pandas .Index (stat_names )
325333
326334 if index_by_thread :
327335 return reindex_by_thread (data )
@@ -334,7 +342,7 @@ def reindex_by_thread(stats_dframe, thread_prefix="THREAD"):
334342
335343 Parameters
336344 ----------
337- stats_dframe: pd .DataFrame
345+ stats_dframe: pandas .DataFrame
338346 Dataframe to reindex. Typically this will have been produced using
339347 paramedir_analyze().
340348
@@ -344,11 +352,11 @@ def reindex_by_thread(stats_dframe, thread_prefix="THREAD"):
344352 the rank number and t the thread number.
345353 """
346354
347- if not isinstance (stats_dframe , pd .DataFrame ):
355+ if not isinstance (stats_dframe , pandas .DataFrame ):
348356 raise TypeError ("stats_dframe must be a Pandas DataFrame" )
349357
350358 oc_select = [c for c in stats_dframe .columns if c .startswith (thread_prefix )]
351- newcols = pd .MultiIndex .from_tuples (
359+ newcols = pandas .MultiIndex .from_tuples (
352360 [tuple (int (x ) for x in y .split ("." )[1 :]) for y in oc_select ]
353361 )
354362 stats_dframe = stats_dframe [oc_select ].set_axis (
@@ -446,12 +454,12 @@ def _split_binline(binline):
446454 # Grab the first float from each binspec, we'll return lower edges
447455 # Note that commas must be stripped from numbers...
448456 try :
449- bins = np .fromiter (
457+ bins = numpy .fromiter (
450458 (floatmatch .findall (x )[0 ].replace ("," , "" ) for x in bin_strings ),
451- dtype = np .float64 ,
459+ dtype = numpy .float64 ,
452460 )
453461 except IndexError :
454- bins = np .asarray (bin_strings )
462+ bins = numpy .asarray (bin_strings )
455463
456464 return bins
457465
@@ -479,9 +487,9 @@ def _split_countline(countline, bins):
479487 # However many extra strings there are, join them to make the name
480488 count_name = " " .join (count_strings [0 :extra_strings ])
481489
482- counts = np .asarray (count_strings [extra_strings :], dtype = np .float64 )
490+ counts = numpy .asarray (count_strings [extra_strings :], dtype = numpy .float64 )
483491
484- return (count_name , pd .Series (counts , index = bins ))
492+ return (count_name , pandas .Series (counts , index = bins ))
485493
486494
487495def load_paraver_histdata (hist_file ):
@@ -504,7 +512,7 @@ def load_paraver_histdata(hist_file):
504512 if count_line .strip ():
505513 name , data_dict [name ] = _split_countline (count_line , bins )
506514
507- return pd .DataFrame .from_dict (data_dict )
515+ return pandas .DataFrame .from_dict (data_dict )
508516
509517
510518def is_extrae_tracefile (tracefile ):
0 commit comments