def initialize(self):
"""Initialize HistogramFillerBase"""
# check basic attribute settings
assert isinstance(self.read_key, str) and len(self.read_key), 'read_key has not been set correctly'
if self.store_key is not None:
assert isinstance(self.store_key, str) and len(self.store_key), 'store_key has not been set to string'
# default histogram creation is at execute(). Storage at finalize is useful for
# looping over datasets.
if self.store_at_finalize:
self.log().debug('Storing (and possible post-processing) at finalize, not execute')
# check that columns are set correctly.
for i, c in enumerate(self.columns):
if isinstance(c, str):
self.columns[i] = [c]
if not isinstance(self.columns[i], list):
raise TypeError('columns "{}" needs to be a string or list of strings'.format(self.columns[i]))
# check for supported data types
for k in self.var_dtype.keys():
try:
self.var_dtype[k] = np.dtype(self.var_dtype[k]).type
if self.var_dtype[k] is np.string_ or self.var_dtype[k] is np.object_:
self.var_dtype[k] = str
except BaseException:
raise RuntimeError('unknown assigned datatype to variable "{}"'.format(k))
return StatusCode.Success
评论列表
文章目录