pisa
pisa copied to clipboard
Summing Map with uncertainties over all dimensions fails
When summing a map that has errors over all of its dimensions with map.sum()
, the following error occurs:
AttributeError Traceback (most recent call last)
in ----> 1 mu_map.sum() </afs/ifh.de/group/amanda/scratch/trettin/fridge3/fridge3/lib/python3.6/site-packages/decorator.py:decorator-gen-128> in sum(self, axis, keepdims)
/afs/ifh.de/group/amanda/scratch/trettin/pisa/pisa/core/map.py in new_function(*args, **kwargs) 201 new_state[slot] = deepcopy(getattr(self, slot)) 202 if len(new_state['binning']) == 0: --> 203 return np.asscalar(new_state['hist']) 204 return Map(**new_state) 205 return decorate(original_function, new_function)
<array_function internals> in asscalar(*args, **kwargs)
/afs/ifh.de/group/amanda/scratch/trettin/fridge3/fridge3/lib/python3.6/site-packages/numpy/lib/type_check.py in asscalar(a) 573 24 574 """ --> 575 return a.item() 576 577 #-----------------------------------------------------------------------------
AttributeError: 'AffineScalarFunc' object has no attribute 'item'
This is not a problem when just summing over some axes such as in map.sum(axis=('reco_energy', 'reco_coszen'))
, and it is also not a problem when the map has no errors. Without errors, a single count over all bins is returned, as one would expect.
I attached a map with uncertainties in JSON for testing: muon_map.json.zip