Skip to content

BUG: FFTLog truncates the span: n = np.int64(maxf - minf)*pts_per_dec #258

Closed

Description

@rcgiri-physics

In empymod/utils.py (line 1194):

minf = np.log10(1/time.max()) + targ['add_dec'][0]
maxf = np.log10(1/time.min()) + targ['add_dec'][1]
n = np.int64(maxf - minf)*targ['pts_per_dec']

np.int64 is applied to the span in decades before multiplying, so a fractional part of the span is dropped. transform.get_fftlog_input(minf, maxf, n, ...) keeps the full span and sets dlogr = (rmax - rmin)/n, so the result is fewer points per decade than requested, not a shorter range.

Check (the line evaluated with pts_per_dec = 10): a span of 0.5 decades gives n = 0 (n = 0 would make get_fftlog_input divide by zero); a span of 2.5 gives 20, i.e. 8 points per decade instead of 10. The counts implied by the requested density are 5 and 25. With the default add_dec the span is usually several decades, so the loss is up to one decade's worth of points (for a span of 3.7, 30 points instead of 37).

Suggested fix: n = np.int64(np.ceil((maxf - minf)*targ['pts_per_dec'])) (possibly + 1, depending on the intended endpoint convention). If the truncation is intentional, a short comment would help.

I found this while testing physverify, a small verification tool I'm working on, against public codes. The tests and this write-up were done with help from an AI assistant; the numbers come from actually running the code.

Activity

  1. prisae commented on Nov 16, 2026

    @prisae
    Member

    Thanks for your input @rcgiri-physics - I will try to have a closer look soon, feel free to remind me if it fall silent!

  2. prisae commented on Nov 18, 2026

    @prisae
    Member

    I will implement your suggestion in #261. I tried to remember how it came to this, but it is just some organically grown thing from FFTLog, then pyfftlog and internal implementation. I don't expect any real-world differences due to this change, except for edge cases, but it is good to have it fixed. Thanks!

  3. changed the title [-]FFTLog: `n = np.int64(maxf - minf)*pts_per_dec` truncates the span before multiplying, so the sampling is sparser than `pts_per_dec`[/-] [+]BUG: FFTLog truncates the span: `n = np.int64(maxf - minf)*pts_per_dec`[/+] on Nov 18, 2026
  4. added
    bug
    on Nov 18, 2026
  5. added a commit that references this issue on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions