memmapped_arange ignores the start value and drops the last point above the memmap threshold

Open Beginner friendly
#213 0 comments 0 reactions 0 assignees View on GitHub

@prathameshfuke is already working on this.

Since Dec 5, 2026.

  • #214 by @prathameshfuke — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python
Domain
data

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StingraySoftware/HENDRICS

All issues in StingraySoftware/HENDRICS

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.