icecube / ASTERIA

A Supernova TEst Routine for IceCube Analysis
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Using asteria.neutrino.Flavor enum items as hashes in source.py can causes odd errors #51

Closed sgriswol closed 4 years ago

sgriswol commented 4 years ago

The dictionary containing the SciPy interpolation objects in source.py (Link to definition uses the enumeration items of asteria.neutrino.Flavor as keys. More specifically, it uses the object location of those enumeration items as part of those keys.

When the upcoming SimulationHandler parses the simulation flavor configuration, it creates and stores its own instances of <enum 'Flavor'> objects. So, when comparing the instances created by the handler to those used to define the source objects, the equality operator returns false, due to the fact that their location is not the same. According to the Python dict documentation, only hashable (fixed) values should be used as keys. The name and value members of the flavor enumeration items are suitable for this, but in order to use these, the __hash__ and __eq__ methods must be overwritten.

It is not sufficient to only change the keys used to define the dictionaries mentioned above. The attached figures show the expected DOM signal (top), and the DOM signal having changed only the definition of the dictionary keys to use the flavor names (bottom). The cause of this difference is not yet understood.

Expected DOM Signal. flavorhashing_noerror

DOM Signal having changed only key definitions in source.py flavorhashing_error

sgriswol commented 4 years ago

Resolved by commit d5d8bda, I messed up the issue reference when I made it....