Skip to content

Commit 175e3dd

Browse files
github-actions[bot]DanRyanIrishsamaloney
authoredJan 28, 2025
Updates from the package template (sunpy#179)
* Automatic package template update * Ignore A005 for the moment --------- Co-authored-by: DanRyanIrish <6806704+DanRyanIrish@users.noreply.github.com> Co-authored-by: Shane Maloney <shane.maloney@dias.ie>
1 parent d6ca8af commit 175e3dd

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed
 

‎.cruft.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sunpy/package-template",
3-
"commit": "d6b86e07efa31959f43e99ba32d323cf76736a05",
3+
"commit": "37ffb52646450caa4de8ea084725dbff65fe0995",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -32,7 +32,7 @@
3232
".github/workflows/sub_package_update.yml"
3333
],
3434
"_template": "https://github.com/sunpy/package-template",
35-
"_commit": "d6b86e07efa31959f43e99ba32d323cf76736a05"
35+
"_commit": "37ffb52646450caa4de8ea084725dbff65fe0995"
3636
}
3737
},
3838
"directory": null

‎.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# This should be before any formatting hooks like isort
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: "v0.8.6"
4+
rev: "v0.9.2"
55
hooks:
66
- id: ruff
77
args: ["--fix"]
@@ -27,7 +27,7 @@ repos:
2727
- id: mixed-line-ending
2828
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"
2929
- repo: https://github.com/codespell-project/codespell
30-
rev: v2.3.0
30+
rev: v2.4.0
3131
hooks:
3232
- id: codespell
3333
additional_dependencies:

‎.ruff.toml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extend-ignore = [
5454
"N802", # Function name should be lowercase
5555
"N803", # Argument name should be lowercase
5656
"N806", # Variable in function should be lowercase
57+
"A005", # Module `io` shadows a Python standard-library module
5758
]
5859

5960
[lint.per-file-ignores]

‎sunkit_spex/legacy/emission.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def _split_and_integrate(*, model, photon_energies, maxfcn, rerr, eelow, eebrk,
525525
clight = const.get_constant("clight")
526526

527527
if not eelow <= eebrk <= eehigh:
528-
raise ValueError(f"Condition eelow <= eebrek <= eehigh not satisfied " f"({eelow}<={eebrk}<={eehigh}).")
528+
raise ValueError(f"Condition eelow <= eebrek <= eehigh not satisfied ({eelow}<={eebrk}<={eehigh}).")
529529

530530
# Create arrays for integral sums and error flags.
531531
intsum1 = np.zeros_like(photon_energies, dtype=np.float64)
@@ -740,7 +740,7 @@ def bremsstrahlung_thin_target(photon_energies, p, eebrk, q, eelow, eehigh, efd=
740740
flux *= fcoeff
741741

742742
return flux
743-
raise Warning("The photon energies are higher than the highest electron energy or not " "greater than zero")
743+
raise Warning("The photon energies are higher than the highest electron energy or not greater than zero")
744744

745745

746746
def bremsstrahlung_thick_target(photon_energies, p, eebrk, q, eelow, eehigh, integrator=None):
@@ -835,4 +835,4 @@ def bremsstrahlung_thick_target(photon_energies, p, eebrk, q, eelow, eehigh, int
835835

836836
return (fcoeff / decoeff) * flux
837837

838-
raise Warning("The photon energies are higher than the highest electron energy or not " "greater than zero")
838+
raise Warning("The photon energies are higher than the highest electron energy or not greater than zero")

‎sunkit_spex/legacy/fitting/photon_models_for_fitting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
defined_photon_models = {
1919
"f_vth": ["T", "EM"],
2020
"thick_fn": ["total_eflux", "index", "e_c"],
21-
"thick_warm": ["tot_eflux", "indx", "ec", "plasma_d", "loop_temp", "length"],
21+
"thick_warm": ["tot_eflux", "index", "ec", "plasma_d", "loop_temp", "length"],
2222
}
2323

2424

‎sunkit_spex/legacy/integrate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,6 @@ def fixed_quad(func, a, b, n=5, args=(), func_kwargs={}):
154154
x, w = _cached_roots_legendre(n)
155155
x = np.real(x)
156156
if np.any(np.isinf(a)) or np.any(np.isinf(b)):
157-
raise ValueError("Gaussian quadrature is only available for " "finite limits.")
157+
raise ValueError("Gaussian quadrature is only available for finite limits.")
158158
y = (b - a).reshape(-1, 1) * (x + 1) / 2.0 + a.reshape(-1, 1)
159159
return np.squeeze((b - a).reshape(1, -1) / 2.0 * np.sum(w * func(y, *args, **func_kwargs), axis=1))

‎sunkit_spex/legacy/thermal.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ def _calculate_abundance_normalized_line_intensities(logT, data_grid, line_logT_
551551
for i in range(n_temperatures):
552552
# Identify the "temperature" bin to which the input "temperature"
553553
# corresponds and its two nearest neighbors.
554-
indx = temperature_bins[i] - 1 + np.arange(3)
554+
index = temperature_bins[i] - 1 + np.arange(3)
555555
# Interpolate the 2nd axis to produce a function that gives the data
556556
# as a function of 1st axis, say energy, at a given value along the 2nd axis,
557557
# say "temperature".
558-
get_intensities_at_logT = interpolate.interp1d(line_logT_bins[indx], data_grid[:, indx], kind="quadratic")
558+
get_intensities_at_logT = interpolate.interp1d(line_logT_bins[index], data_grid[:, index], kind="quadratic")
559559
# Use function to get interpolated_data as a function of the first axis at
560560
# the input value along the 2nd axis,
561561
# e.g. line intensities as a function of energy at a given temperature.
@@ -733,8 +733,7 @@ def _error_if_input_outside_valid_range(input_values, grid_range, param_name, pa
733733
grid_range = u.Quantity(grid_range, unit=param_unit).to_value(message_unit)
734734
param_unit = message_unit
735735
message = (
736-
f"All input {param_name} values must be within the range "
737-
f"{grid_range[0]}--{grid_range[1]} {param_unit}. "
736+
f"All input {param_name} values must be within the range {grid_range[0]}--{grid_range[1]} {param_unit}. "
738737
)
739738
raise ValueError(message)
740739

@@ -925,8 +924,8 @@ def _calculate_abundances(abundance_type, relative_abundances):
925924
# logt = LOGT # grid temperatures = log(temperature)
926925
# ntemp = len(logt)
927926
# selt = np.argwhere(logt<=u)[-1] # what gap does my temp land in the logt array (inclusive of the lower boundary)
928-
# indx = np.clip([selt-1, selt, selt+1], 0, ntemp-1) # find the indexes either side of that gap
929-
# tband = logt[indx]
927+
# index = np.clip([selt-1, selt, selt+1], 0, ntemp-1) # find the indexes either side of that gap
928+
# tband = logt[index]
930929
# s=1
931930
# x0, x1, x2 = tband[0][0], tband[1][0], tband[2][0] # temperatures either side of that gap
932931

@@ -936,7 +935,7 @@ def _calculate_abundances(abundance_type, relative_abundances):
936935

937936
# # all wavelengths divided by corresponding temp[0] (first row), then exvl/temp[1] second row, exvl/temp[2] third row
938937
# # inverse boltzmann factor of hv/kT and 11.6e6 from keV-to-J conversion over k = 1.6e-16 / 1.381e-23 ~ 11.6e6
939-
# exponential = (np.ones((3,1)) @ ewvl_exp) / ((10**logt[indx]/11.6e6) @ np.ones((1,nwvl)))
938+
# exponential = (np.ones((3,1)) @ ewvl_exp) / ((10**logt[index]/11.6e6) @ np.ones((1,nwvl)))
940939
# exponential = np.exp(np.clip(exponential, None, 80)) # not sure why clipping at 80
941940
# # this is just from dE/dA = E/A from E=hc/A (A=wavelength) for change of variables from Angstrom to keV: dE = dA * (E/A)
942941
# # have this repeated for 3 rows since this is the form of the expontial's different temps
@@ -966,7 +965,7 @@ def _calculate_abundances(abundance_type, relative_abundances):
966965
# # totcont_lo is the continuum <1 keV I think and totcont is >=1 keV, so adding the wavelength dimension of each of these you get the number of wavlengths provided by continuum_info[1]['edge_str']['WVL']
967966
# # look here for more info on how the CHIANTI file is set-up **** https://hesperia.gsfc.nasa.gov/ssw/packages/xray/idl/setup_chianti_cont.pro ****
968967
# # this exact script won't create the folder Python is using the now since some of the wavelengths and deltas don't match-up
969-
# totcontindx = np.concatenate((continuum_info[1]["totcont_lo"][:, indx.T[0], :], continuum_info[1]["totcont"][:, indx.T[0], :]), axis=2) # isolate temps and then combine along wavelength axis
968+
# totcontindx = np.concatenate((continuum_info[1]["totcont_lo"][:, index.T[0], :], continuum_info[1]["totcont"][:, index.T[0], :]), axis=2) # isolate temps and then combine along wavelength axis
970969
# # careful from here on out. IDL's indexes are backwards to Pythons
971970
# # Python's a[:,:,0] == IDL's a[0,*,*], a[:,0,:] == a[*,0,*], and then a[0,:,:] == a[*,*,0]
972971
# tcdbase = totcontindx # double(totcontindx[*, *, *])

‎sunkit_spex/models/physical/thermal.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ def _calculate_abundance_normalized_line_intensities(logT, data_grid, line_logT_
555555
for i in range(n_temperatures):
556556
# Identify the "temperature" bin to which the input "temperature"
557557
# corresponds and its two nearest neighbors.
558-
indx = temperature_bins[i] - 1 + np.arange(3)
558+
index = temperature_bins[i] - 1 + np.arange(3)
559559
# Interpolate the 2nd axis to produce a function that gives the data
560560
# as a function of 1st axis, say energy, at a given value along the 2nd axis,
561561
# say "temperature".
562-
get_intensities_at_logT = interpolate.interp1d(line_logT_bins[indx], data_grid[:, indx], kind="quadratic")
562+
get_intensities_at_logT = interpolate.interp1d(line_logT_bins[index], data_grid[:, index], kind="quadratic")
563563
# Use function to get interpolated_data as a function of the first axis at
564564
# the input value along the 2nd axis,
565565
# e.g. line intensities as a function of energy at a given temperature.
@@ -737,8 +737,7 @@ def _error_if_input_outside_valid_range(input_values, grid_range, param_name, pa
737737
grid_range = u.Quantity(grid_range, unit=param_unit).to_value(message_unit)
738738
param_unit = message_unit
739739
message = (
740-
f"All input {param_name} values must be within the range "
741-
f"{grid_range[0]}--{grid_range[1]} {param_unit}. "
740+
f"All input {param_name} values must be within the range {grid_range[0]}--{grid_range[1]} {param_unit}. "
742741
)
743742
raise ValueError(message)
744743

@@ -929,8 +928,8 @@ def _calculate_abundances(abundance_type, relative_abundances):
929928
# logt = LOGT # grid temperatures = log(temperature)
930929
# ntemp = len(logt)
931930
# selt = np.argwhere(logt<=u)[-1] # what gap does my temp land in the logt array (inclusive of the lower boundary)
932-
# indx = np.clip([selt-1, selt, selt+1], 0, ntemp-1) # find the indexes either side of that gap
933-
# tband = logt[indx]
931+
# index = np.clip([selt-1, selt, selt+1], 0, ntemp-1) # find the indexes either side of that gap
932+
# tband = logt[index]
934933
# s=1
935934
# x0, x1, x2 = tband[0][0], tband[1][0], tband[2][0] # temperatures either side of that gap
936935

@@ -940,7 +939,7 @@ def _calculate_abundances(abundance_type, relative_abundances):
940939

941940
# # all wavelengths divided by corresponding temp[0] (first row), then exvl/temp[1] second row, exvl/temp[2] third row
942941
# # inverse boltzmann factor of hv/kT and 11.6e6 from keV-to-J conversion over k = 1.6e-16 / 1.381e-23 ~ 11.6e6
943-
# exponential = (np.ones((3,1)) @ ewvl_exp) / ((10**logt[indx]/11.6e6) @ np.ones((1,nwvl)))
942+
# exponential = (np.ones((3,1)) @ ewvl_exp) / ((10**logt[index]/11.6e6) @ np.ones((1,nwvl)))
944943
# exponential = np.exp(np.clip(exponential, None, 80)) # not sure why clipping at 80
945944
# # this is just from dE/dA = E/A from E=hc/A (A=wavelength) for change of variables from Angstrom to keV: dE = dA * (E/A)
946945
# # have this repeated for 3 rows since this is the form of the expontial's different temps
@@ -970,7 +969,7 @@ def _calculate_abundances(abundance_type, relative_abundances):
970969
# # totcont_lo is the continuum <1 keV I think and totcont is >=1 keV, so adding the wavelength dimension of each of these you get the number of wavlengths provided by continuum_info[1]['edge_str']['WVL']
971970
# # look here for more info on how the CHIANTI file is set-up **** https://hesperia.gsfc.nasa.gov/ssw/packages/xray/idl/setup_chianti_cont.pro ****
972971
# # this exact script won't create the folder Python is using the now since some of the wavelengths and deltas don't match-up
973-
# totcontindx = np.concatenate((continuum_info[1]["totcont_lo"][:, indx.T[0], :], continuum_info[1]["totcont"][:, indx.T[0], :]), axis=2) # isolate temps and then combine along wavelength axis
972+
# totcontindx = np.concatenate((continuum_info[1]["totcont_lo"][:, index.T[0], :], continuum_info[1]["totcont"][:, index.T[0], :]), axis=2) # isolate temps and then combine along wavelength axis
974973
# # careful from here on out. IDL's indexes are backwards to Pythons
975974
# # Python's a[:,:,0] == IDL's a[0,*,*], a[:,0,:] == a[*,0,*], and then a[0,:,:] == a[*,*,0]
976975
# tcdbase = totcontindx # double(totcontindx[*, *, *])

‎sunkit_spex/spectrum/spectrum.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from astropy.utils import lazyproperty
1010

1111
__all__ = ["SpectralAxis", "Spectrum", "gwcs_from_array"]
12+
__doctest_requires__ = {"Spectrum": ["ndcube>=2.3"]}
1213

1314

1415
def gwcs_from_array(array):
@@ -158,7 +159,7 @@ class Spectrum(NDCube):
158159
<sunkit_spex.spectrum.spectrum.Spectrum object at ...
159160
NDCube
160161
------
161-
Dimensions: [10.] pix
162+
Shape: (10,)
162163
Physical Types of Axes: [('em.energy',)]
163164
Unit: W
164165
Data Type: float64
@@ -204,7 +205,7 @@ def __init__(
204205
if spectral_axis is not None:
205206
# Ensure that the spectral axis is an astropy Quantity
206207
if not isinstance(spectral_axis, u.Quantity):
207-
raise ValueError("Spectral axis must be a `Quantity` or " "`SpectralAxis` object.")
208+
raise ValueError("Spectral axis must be a `Quantity` or `SpectralAxis` object.")
208209

209210
# If a spectral axis is provided as an astropy Quantity, convert it
210211
# to a SpectralAxis object.

0 commit comments

Comments
 (0)
Please sign in to comment.