Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summing Map with uncertainties over all dimensions fails #579

Open
atrettin opened this issue Mar 17, 2020 · 0 comments
Open

Summing Map with uncertainties over all dimensions fails #579

atrettin opened this issue Mar 17, 2020 · 0 comments
Assignees
Labels

Comments

@atrettin
Copy link
Contributor

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

@atrettin atrettin changed the title Summing Map with uncertainties over all dimensions fails. Summing Map with uncertainties over all dimensions fails Mar 17, 2020
@JKrishnamoorthi JKrishnamoorthi self-assigned this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants