mlreco.utils.utils module

mlreco.utils.utils.local_cdist(v1, v2)[source]
mlreco.utils.utils.to_numpy(s)[source]
mlreco.utils.utils.round_decimals(val, digits)[source]
mlreco.utils.utils.moving_average(a, n=3)[source]
mlreco.utils.utils.progress_bar(count, total, message='')[source]
Args: count …. int/float, current progress counter

total …. int/float, total counter message .. string, appended after the progress bar

mlreco.utils.utils.print_memory(msg='')[source]
class mlreco.utils.utils.stopwatch[source]

Bases: object

Simple stopwatch class to organize various time measurement. Not very precise but good enough for a millisecond level precision

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

start(key)[source]

Starts a stopwatch for a unique key INPUT

  • key can be any object but typically a string to tag a time measurement

stop(key)[source]

Stops a stopwatch for a unique key INPUT

  • key can be any object but typically a string to tag a time measurement

start_cputime(key)[source]
stop_cputime(key)[source]
time_cputime(key)[source]
time(key)[source]

Returns the time recorded or past so far (if not stopped) INPUT

  • key can be any object but typically a string to tag a time measurement

__dict__ = mappingproxy({'__module__': 'mlreco.utils.utils', '__doc__': '\n    Simple stopwatch class to organize various time measurement.\n    Not very precise but good enough for a millisecond level precision\n    ', '__init__': <function stopwatch.__init__>, 'start': <function stopwatch.start>, 'stop': <function stopwatch.stop>, 'start_cputime': <function stopwatch.start_cputime>, 'stop_cputime': <function stopwatch.stop_cputime>, 'time_cputime': <function stopwatch.time_cputime>, 'time': <function stopwatch.time>, '__dict__': <attribute '__dict__' of 'stopwatch' objects>, '__weakref__': <attribute '__weakref__' of 'stopwatch' objects>, '__annotations__': {}})
__module__ = 'mlreco.utils.utils'
__weakref__

list of weak references to the object (if defined)

class mlreco.utils.utils.ForwardData[source]

Bases: object

Utility class for computing averages of loss and accuracies.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

__getitem__(name)[source]
update_mean(name, value)[source]
update_dict(d)[source]
as_dict()[source]
__repr__()[source]

Return repr(self).

__dict__ = mappingproxy({'__module__': 'mlreco.utils.utils', '__doc__': '\n    Utility class for computing averages of loss and accuracies.\n    ', '__init__': <function ForwardData.__init__>, '__getitem__': <function ForwardData.__getitem__>, 'update_mean': <function ForwardData.update_mean>, 'update_dict': <function ForwardData.update_dict>, 'as_dict': <function ForwardData.as_dict>, '__repr__': <function ForwardData.__repr__>, '__dict__': <attribute '__dict__' of 'ForwardData' objects>, '__weakref__': <attribute '__weakref__' of 'ForwardData' objects>, '__annotations__': {}})
__module__ = 'mlreco.utils.utils'
__weakref__

list of weak references to the object (if defined)

class mlreco.utils.utils.CSVData(fout, append=False)[source]

Bases: object

__init__(fout, append=False)[source]

Initialize self. See help(type(self)) for accurate signature.

record(keys, vals)[source]
write()[source]
flush()[source]
close()[source]
__dict__ = mappingproxy({'__module__': 'mlreco.utils.utils', '__init__': <function CSVData.__init__>, 'record': <function CSVData.record>, 'write': <function CSVData.write>, 'flush': <function CSVData.flush>, 'close': <function CSVData.close>, '__dict__': <attribute '__dict__' of 'CSVData' objects>, '__weakref__': <attribute '__weakref__' of 'CSVData' objects>, '__doc__': None, '__annotations__': {}})
__module__ = 'mlreco.utils.utils'
__weakref__

list of weak references to the object (if defined)

class mlreco.utils.utils.ChunkCSVData(fout, append=True, chunksize=1000)[source]

Bases: object

__init__(fout, append=True, chunksize=1000)[source]

Initialize self. See help(type(self)) for accurate signature.

__dict__ = mappingproxy({'__module__': 'mlreco.utils.utils', '__init__': <function ChunkCSVData.__init__>, 'record': <function ChunkCSVData.record>, '__dict__': <attribute '__dict__' of 'ChunkCSVData' objects>, '__weakref__': <attribute '__weakref__' of 'ChunkCSVData' objects>, '__doc__': None, '__annotations__': {}})
__module__ = 'mlreco.utils.utils'
__weakref__

list of weak references to the object (if defined)

record(df, verbose=False)[source]