Welcome to hepbasestack’s documentation!¶
hepbasestack¶
Tools for resource management, etc.
Miscellaneous tools
-
hepbasestack.
timed_progressbar
(runtime)[source]¶ Show a progress bar increasing every second for runtime seconds. This runs in its own thread, so the program can continue in the meantime. This can be useful for while loops which run for a certain time for example.
Parameters: runtime (int) – maxtime of the progress bar in seconds
-
hepbasestack.
timeit
(func)[source]¶ Use as decorator to get the effective execution time of the decorated function
Parameters: func (func) – Measure the execution time of this function Returns: wrapped func Return type: func
hepbasestack.colors module¶
Color management. Colors are handled nicely in seaborn. For a quicker acces, we mix the seaborn color palette with the way colors handled in matplotlib. E.g. we can define our own color + the seaborn colors in the palette, but if they are not found this will automatically fall back to matplotlib
-
class
hepbasestack.colors.
ColorDict
[source]¶ Bases:
dict
Sole purpose is not to throw an error in case a key does not exist, but to return the key instead. This basically comes down to if a color is not prepdefined, then we rely on matplotlib to find it with the key instead.
-
hepbasestack.colors.
get_color_palette
(name='dark')[source]¶ Load a color pallete. This will get the predefined color palette, but returns a ColorDict instead, which allows for transparent pass through of non-exisiting color names. We will only allow for the first 9 colors of the specified seaborn color palette. It will also offer a color accessible by the key ‘inhibited’, which can be used to mark ‘forbidden’ regions in a plot.
Keyword Arguments: name (str) – A string which is passed though seaborn.color_palette Returns: HErmes.plotting.plot_colors.ColorDict
hepbasestack.itools module¶
Tools for managing iterables
-
hepbasestack.itools.
flatten
(iterable_of_iterables)[source]¶ Concat an iterable of iterables in a single iterable, chaining its elements
Parameters: iterable_of_iterables (iterable) – Currently supported is dimensionality of 2 Returns: np.ndarray
-
hepbasestack.itools.
multiplex
(iterable, iterable_of_iterables)[source]¶ More or less the inverse of flatten. Adjust the shape of iterable to match that of iterable_of_iterables by stretching each value to be an iterable with the length of the respective element in iterable_of_iterables, but with always the same value
Parameters: - iterable – The array to be multiplexed
- iterable_of_iterables – The shape to be matched
Returns: np.ndarray
hepbasestack.logger module¶
A logger with customizable loglevel at runtime. The loglevel can be set via the global LOGLEVEL variable.
-
class
hepbasestack.logger.
AbstractCustomLoggerType
[source]¶ Bases:
type
A modified logging.logger. Do not use directly, but as metaclass. Whenever the logger is called, HErmes.utils.logger.LOGLEVEL is queried to check for a change in the loglevel and a new logger instance is created accordingly. Python inspect is used to inspect the stack.
-
class
hepbasestack.logger.
Logger
[source]¶ Bases:
object
A custom logger with loglevel changeable at runtime. To change the loglevel, set global LOGLEVEL variable in this namespace: 10 = DEBUG, 20 = INFO, 30 = WARNING
-
hepbasestack.logger.
alertstring
(x)¶
hepbasestack.visual module¶
Set styles to a more simplistic and well readable setting. It might look less sophisticated, but the goal is to make it easy to read. Also provide some helper functions
hepbasestack.layout module¶
Figure sizes for A4 paper.
A set of figure sizes for publication-ready figures on A4 paper based on the golden ratio. For the use with pylabe figure, e.g. fig =pylab.figure(figsize=FIGSIZE_A4)
Available layouts:
- FIGSIZE_A4: Figure on full A4 width, portrait mode, golden ratio
- FIGSIZE_A4_LANDSCAPE: Figure on full A4 width, landscape mode, golden ratio
- FIGSIZE_A4_LANDSCAPE_HALF_HEIGHT: Figure on full A4 width, landscape mode, height half of golden ratio
- FIGSIZE_A4_SQUARE: Figure on full A4 width, square