threeML / hawc_hal

HAWC Accelerated Likelihood - python-only framework for HAWC data analysis
BSD 3-Clause "New" or "Revised" License
11 stars 22 forks source link

The InvalidPSF objects should not be used, but we should be able to copy them #7

Closed colasri closed 6 years ago

colasri commented 6 years ago

The HAL.get_simulated_dataset(self, name) function calls makes a deepcopy of the HAL instance clone = copy.deepcopy(self) on https://github.com/giacomov/hawc_hal/blob/master/hawc_hal/HAL.py#L523. It crashes when any of the response bin contains an invalid PSF (even if the bin is not part of the active planes):

File "/Users/cr/miniconda2/envs/myconda/lib/python2.7/site-packages/hawc_hal/psf_fast/psf_wrapper.py", line 179, in __getattribute__
    raise InvalidPSFError("Trying to use an invalid PSF")
hawc_hal.psf_fast.psf_wrapper.InvalidPSFError: Trying to use an invalid PSF

This commit fixes that. I'm not sure if that's the best solution though, comments welcome.

codecov[bot] commented 6 years ago

Codecov Report

Merging #7 into master will increase coverage by 0.08%. The diff coverage is 100%.

@@            Coverage Diff             @@
##           master       #7      +/-   ##
==========================================
+ Coverage   93.41%   93.49%   +0.08%     
==========================================
  Files          38       38              
  Lines        1442     1446       +4     
==========================================
+ Hits         1347     1352       +5     
+ Misses         95       94       -1
giacomov commented 6 years ago

That's perfect!

Please add a comment to explain why that is necessary and a quick test using the copy module (not the parallel feature, for which you would need a running ipython cluster) that both copy.copy and copy.deepcopy work.