Run black on gammapy/maps/utils.py
@@ -4,7 +4,7 @@ from astropy.io import fits
from ..utils.random import get_random_state
-def fill_poisson(map_in, mu, random_state='random-seed'):
+def fill_poisson(map_in, mu, random_state="random-seed"):
"""Fill a map object with a poisson random variable.
This can be useful for testing, to make a simulated counts image.
@@ -40,7 +40,7 @@ def swap_byte_order(arr_in):
arr_out : `~numpy.ndarray`
Array with native byte order.
"""
- if arr_in.dtype.byteorder not in ('=', '|'):
+ if arr_in.dtype.byteorder not in ("=", "|"):
return arr_in.byteswap().newbyteorder()
return arr_in
@@ -51,13 +51,7 @@ def interp_to_order(interp):
if isinstance(interp, int):
return interp
- order_map = {
- None: 0,
- 'nearest': 0,
- 'linear': 1,
- 'quadratic': 2,
- 'cubic': 3,
- }
+ order_map = {None: 0, "nearest": 0, "linear": 1, "quadratic": 2, "cubic": 3}
return order_map.get(interp, None)
@@ -93,22 +87,28 @@ def find_bands_hdu(hdu_list, hdu):
hduname : str
Extension name of the BANDS HDU. None if no BANDS HDU was found.
"""
- if 'BANDSHDU' in hdu.header:
- return hdu.header['BANDSHDU']
+ if "BANDSHDU" in hdu.header:
+ return hdu.header["BANDSHDU"]
has_cube_data = False
- if isinstance(hdu, (fits.ImageHDU, fits.PrimaryHDU)) and hdu.header.get('NAXIS', None) == 3:
+ if (
+ isinstance(hdu, (fits.ImageHDU, fits.PrimaryHDU))
+ and hdu.header.get("NAXIS", None) == 3
+ ):
has_cube_data = True
elif isinstance(hdu, fits.BinTableHDU):
- if hdu.header.get('INDXSCHM', '') in ['EXPLICIT', 'IMPLICIT', ''] and len(hdu.columns) > 1:
+ if (
+ hdu.header.get("INDXSCHM", "") in ["EXPLICIT", "IMPLICIT", ""]
+ and len(hdu.columns) > 1
+ ):
has_cube_data = True
if has_cube_data:
- if 'EBOUNDS' in hdu_list:
- return 'EBOUNDS'
- elif 'ENERGIES' in hdu_list:
- return 'ENERGIES'
+ if "EBOUNDS" in hdu_list:
+ return "EBOUNDS"
+ elif "ENERGIES" in hdu_list:
+ return "ENERGIES"
return None
@@ -119,7 +119,7 @@ def find_hdu(hdulist):
if hdu.data is not None:
return hdu
- raise AttributeError('No Image or BinTable HDU found.')
+ raise AttributeError("No Image or BinTable HDU found.")
def find_image_hdu(hdulist):
@@ -127,7 +127,7 @@ def find_image_hdu(hdulist):
if hdu.data is not None and isinstance(hdu, fits.ImageHDU):
return hdu
- raise AttributeError('No Image HDU found.')
+ raise AttributeError("No Image HDU found.")
def find_bintable_hdu(hdulist):
@@ -135,4 +135,4 @@ def find_bintable_hdu(hdulist):
if hdu.data is not None and isinstance(hdu, fits.BinTableHDU):
return hdu
- raise AttributeError('No BinTable HDU found.')
+ raise AttributeError("No BinTable HDU found.")
