cta-observatory/pyirf

attribute renamed in SimulatedEventsInfo but not in PowerLaw.from_simulation

Closed this issue · 3 comments

kosack commented
simualtion_info = SimulatedEventsInfo(
    n_showers=shower_distribution["histogram"].sum(),
    energy_min=simulation_config["energy_range_min"][0],
    energy_max=simulation_config["energy_range_max"][0],
    max_impact=simulation_config["max_scatter_range"][0],
    spectral_index=simulation_config["spectral_index"][0],
    viewcone_min=simulation_config["min_viewcone_radius"][0],
    viewcone_max=simulation_config["max_viewcone_radius"][0],
)

spectral.PowerLaw.from_simulation(simulation_info, obstime=obstime)
    117 index = simulated_event_info.spectral_index
    118 n_showers = simulated_event_info.n_showers
--> 119 viewcone = simulated_event_info.viewcone
    121 if viewcone.value > 0:
    122     solid_angle = 2 * np.pi * (1 - np.cos(viewcone)) * u.sr

AttributeError: 'SimulatedEventsInfo' object has no attribute 'viewcone'

Should use the new viewcone_min and viewcone_max attributes.

maxnoe commented

Huh... that means that this part is not covered by tests. How embarrassing...

kosack commented

The class is immutable with __slots__ as well, so i can't even fake it!

kosack commented

By the way, might as well make it a dataclass (if you don't have to support pre python 3.7)