power_color() mutates input power array and raises IndexError when freqs_to_exclude reaches frequency bounds
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 80/100
Research direction
Start by reading stingray.power_colors.power_color() and inspect how it builds the exclusion mask and finds the boundary indices. Reproduce both cases from the issue: an input array that is mutated and an exclusion range extending past the final frequency. Done means the caller's array stays unchanged and both boundary cases complete without an IndexError; the issue names no test file.
Written by the indexing model from the issue text.
Description
Description of the Bug
In stingray.power_colors.power_color(), when freqs_to_exclude is provided:
- In-place input mutation:
power = np.asanyarray(power)does not copy whenpoweris already a NumPy array, sopower[frequency_mask] = np.mean([power[idx0], power[idx1]])mutates the caller'spowerarray in-place. - Boundary
IndexError: When an excluded range extends to or past the upper edge offrequency(for example,freqs_to_exclude=[10.0, 20.0]on a spectrum ending at16.0),np.searchsorted(frequency, [f0, f1])returnsidx1 == len(frequency), and indexingpower[idx1]raisesIndexError.
Steps/Code to Replicate the Bug
import numpy as np
from stingray.power_colors import power_color
f = np.linspace(0.004, 16.0, 200)
p = f.copy()
p_orig = p.copy()
# 1. Input array is mutated in-place
power_color(f, p, freqs_to_exclude=[1.0, 2.0])
print("input mutated?", not np.array_equal(p, p_orig))
# 2. Boundary exclusion raises IndexError
power_color(f, p_orig, freqs_to_exclude=[10.0, 20.0])
Expected Results
power_color() should not mutate the caller's power array, and freqs_to_exclude ranges reaching or exceeding the frequency boundaries should be handled cleanly without raising IndexError.
Actual Results
input mutated? Truepower_color(f, p_orig, freqs_to_exclude=[10.0, 20.0])raises:
IndexError: index 200 is out of bounds for axis 0 with size 200
- Dominant language
- Python
- Stars
- 230
- Forks
- 200
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from StingraySoftware/stingray
-
Lightcurve slicing raises IndexError when the slice bounds are outside the light curvePossibly taken @prathameshfuke claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
StingraySoftware/stingray#1054 ·
Maintainers usually reply within 2 days
-
ts[-1] on a StingrayTimeseries or EventList raises TypeError; negative integer indices are wrongPossibly taken @prathameshfuke claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
StingraySoftware/stingray#1056 ·
Maintainers usually reply within 2 days
-
create_gti_mask drops valid points after empty GTIs and crashes with min_length > 0 and dtPossibly taken @Rohan-Dedhia claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
StingraySoftware/stingray#1044 ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
StingraySoftware/stingray#1042 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
StingraySoftware/stingray#1039 · 1 comment ·
Maintainers usually reply within 2 days
All issues in StingraySoftware/stingray
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
needs-triage type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
pollen-robotics/reachy_mini_conversation_app#631 ·
Maintainers usually reply within 7 days
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100