memmapped_arange ignores the start value and drops the last point above the memmap threshold
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
The issue identifies hendrics.base.memmapped_arange and gives reproductions for the memory-mapped branch. Read that function and compare its results with np.arange for the supplied positive and negative steps, including cases where the step does not divide the range. Done means the memory-mapped results match np.arange for the reported inputs.
Written by the indexing model from the issue text.
Description
Describe the bug
hendrics.base.memmapped_arange returns a different array from np.arange when it goes through the memory-mapped branch (Nbins >= nbin_threshold, 10**7 by default): the start i0 is ignored (the values always start from 0), and the length is truncated with int() where np.arange rounds up, so the last point can be lost. Below the threshold the function is just np.arange, so the docstring examples (which both start at 0 with a step that divides the range) do not show it. The function is used by HENaccelsearch to build the time axis (memmapped_arange(-0.5 * max_length, 1.5 * max_length, dt) with --pad-to-double), where a negative start is the normal case.
To Reproduce
import numpy as np
from hendrics.base import memmapped_arange
for args in [(1, 2, 0.25), (0, 10, 3), (5, 0, -1), (-1, 1, 0.5)]:
print(args, np.arange(*args), np.asarray(memmapped_arange(*args, nbin_threshold=1)))
(1, 2, 0.25) [1. 1.25 1.5 1.75] [0. 0.25 0.5 0.75]
(0, 10, 3) [0 3 6 9] [0. 3. 6.]
(5, 0, -1) [5 4 3 2 1] [ 0. -1. -2. -3. -4.]
(-1, 1, 0.5) [-1. -0.5 0. 0.5] [0. 0.5 1. 1.5]
Expected behavior
The same values as np.arange(i0, i1, istep).
Desktop
- OS: macOS
- Python version 3.12
- HENDRICS Version: development from github (main)
- Dominant language
- Jupyter Notebook
- Stars
- 26
- Forks
- 18
- Avg merge
- 1h 26m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No 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/HENDRICS
-
Single-element arrays are read back as scalars from NetCDF filesPossibly taken @prathameshfuke claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
StingraySoftware/HENDRICS#211 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
StingraySoftware/HENDRICS#198 ·
-
HEN2xspec cannot handle Lomb-Scargle spectraMay be free again @aviralgarg05 claimed this 26 days ago, and no pull request is open. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
StingraySoftware/HENDRICS#197 · 1 comment ·
-
tmp filesOpen
Difficulty 3/5 1-2 days Newbie friendliness 35/100
StingraySoftware/HENDRICS#174 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 20/100
StingraySoftware/HENDRICS#155 ·
All issues in StingraySoftware/HENDRICS
Similar issues
-
country:US rating:6 request-theme type:TV SHOW
Difficulty 1/5 Under an hour Newbie friendliness 65/100
LizardByte/ThemerrDB#10501 · 1 comment ·
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
agentscope-ai/agentscope#4563 ·
Maintainers usually reply within 2 days
-
Split part lines show the bare category name, ordinary booking lines show the full category pathOpenbugfix
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
GiroCrab/GiroCrab#2528 · 1 comment ·
Maintainers usually reply within 1 day
-
approved correction metadata
Difficulty 1/5 Under an hour Newbie friendliness 80/100
acl-org/acl-anthology#11237 · 1 comment ·
Maintainers usually reply within 1 day
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sOpen
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
Maintainers usually reply within 1 day