Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Feb 26, 2024
1 parent a60829b commit def40d3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions glue_astronomy/translators/spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def _has_homogenous_spectral_solution(self, data):

def to_data(self, obj):

# specutils 2.0 doesn't care where the spectral axis anymore, but we still need PaddedSpectrumWCS for now
# specutils 2.0 doesn't care where the spectral axis anymore, but we still need
# PaddedSpectrumWCS for now
if obj.flux.ndim > 1 and obj.wcs.world_n_dim == 1:
data = Data(coords=PaddedSpectrumWCS(obj.wcs, obj.flux.ndim, obj.spectral_axis_index))
else:
Expand Down Expand Up @@ -233,17 +234,19 @@ def to_object(self, data_or_subset, attribute=None, statistic='mean'):
wcs_args[spectral_axis_index] = np.arange(data.shape[spectral_axis_index])
wcs_args.reverse()
spectral_and_spatial = data.coords.pixel_to_world(*wcs_args)
spectral_axis = [x for x in spectral_and_spatial if isinstance(x, SpectralCoord)][0]
spectral_axis = [x for x in spectral_and_spatial if isinstance(x, SpectralCoord)][0] # noqa
kwargs = {'spectral_axis': spectral_axis}

Check warning on line 238 in glue_astronomy/translators/spectrum1d.py

View check run for this annotation

Codecov / codecov/patch

glue_astronomy/translators/spectrum1d.py#L230-L238

Added lines #L230 - L238 were not covered by tests

else:
# In this case we should resample the flux onto a common spectral axis before collapsing
warnings.warn("Spectral solution is not the same at all spatial points,"
" collapsing may give inaccurate results.")
# In this case the flux should be resampled onto a common spectral axis
# before collapsing
warnings.warn('Spectral solution is not the same at all spatial points,'

Check warning on line 243 in glue_astronomy/translators/spectrum1d.py

View check run for this annotation

Codecov / codecov/patch

glue_astronomy/translators/spectrum1d.py#L243

Added line #L243 was not covered by tests
' collapsing may give inaccurate results.')
kwargs = {'wcs': data.coords}

Check warning on line 245 in glue_astronomy/translators/spectrum1d.py

View check run for this annotation

Codecov / codecov/patch

glue_astronomy/translators/spectrum1d.py#L245

Added line #L245 was not covered by tests
else:
# Shouldn't get here anymore, but just in case.
raise ValueError('Can only use statistic= if the Data object has a GWCS or FITS WCS')
raise ValueError('Can only use statistic= if the Data object has a GWCS'

Check warning on line 248 in glue_astronomy/translators/spectrum1d.py

View check run for this annotation

Codecov / codecov/patch

glue_astronomy/translators/spectrum1d.py#L248

Added line #L248 was not covered by tests
' or FITS WCS')

elif isinstance(data.coords, SpectralCoordinates):

Expand Down

0 comments on commit def40d3

Please sign in to comment.