Skip to content

Commit 625857e

Browse files
committed
MAINT: Fix use of importlib.resources.files; PosixPath object does not support the context manager protocol in Python 3.13
1 parent a43fd77 commit 625857e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

skypy/galaxies/spectrum.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ class KCorrectTemplates(SpectrumTemplates):
107107
'''
108108

109109
def __init__(self, hdu=1):
110-
with resources.files('skypy') / 'data/kcorrect/k_nmf_derived.default.fits' as filename:
111-
with fits.open(filename) as hdul:
112-
self.templates = hdul[hdu].data * units.Unit('erg s-1 cm-2 angstrom-1')
113-
self.wavelength = hdul[11].data * units.Unit('angstrom')
114-
self.mass = hdul[16].data
115-
self.mremain = hdul[17].data
116-
self.mets = hdul[18].data
117-
self.mass300 = hdul[19].data
118-
self.mass1000 = hdul[20].data
110+
filename = resources.files('skypy') / 'data/kcorrect/k_nmf_derived.default.fits'
111+
with fits.open(filename) as hdul:
112+
self.templates = hdul[hdu].data * units.Unit('erg s-1 cm-2 angstrom-1')
113+
self.wavelength = hdul[11].data * units.Unit('angstrom')
114+
self.mass = hdul[16].data
115+
self.mremain = hdul[17].data
116+
self.mets = hdul[18].data
117+
self.mass300 = hdul[19].data
118+
self.mass1000 = hdul[20].data
119119

120120
def stellar_mass(self, coefficients, magnitudes, filter):
121121
r'''Compute stellar mass from absolute magnitudes in a reference filter.

0 commit comments

Comments
 (0)