Docstrings that name parameters the function does not take: full list, categorised (25 sites)

Open
#1,042 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
api, documentation

Research direction

Start with the sites in the Group 3 and Group 4 tables: each row names a file, line and function, so open that function's Parameters section and compare it with the real signature. Group 1 (utils.rebin_data_log, yerr vs y_err) needs a maintainer decision on the API before any edit, so leave it out. Group 2 (accelsearch.interbin_fft) only needs a dashed underline added under Returns. Done means every listed docstring matches its signature and the numpydoc check reports no mismatches.

Written by the indexing model from the issue text.

Description

@matteobachetti suggested this on #1038: rather than fixing a couple of these in a PR, here is the full list so they can be worked through one by one. I have also separated the cases where, as he pointed out, the right fix is probably an API change rather than a docstring edit.

25 sites, all on main at 66af58e9. In each case a Parameters entry names something the function does not accept, so the name a reader copies out of the rendered docs cannot be passed.

How to reproduce the list

numpydoc-only check: parse each Parameters section and compare the documented names against the actual signature. No output means no mismatch.

I verified each of the 25 individually rather than trusting the scan, and for each one checked whether the documented name is a near-miss of a real parameter (a typo) or a name that genuinely belongs to a sibling function (which is what makes it an API question).


Group 1 — needs an API decision, not a docstring edit (1)
  • utils.rebin_data_log (utils.py:818) documents yerr; the parameter is y_err. This is the case @matteobachetti flagged. The two rebin functions in the same file disagree:
    def rebin_data(x, y, dx_new, yerr=None, method="sum", dx=None):   # utils.py:651
    def rebin_data_log(x, y, f, y_err=None, dx=None):                 # utils.py:794
    
    So editing the docstring would record the inconsistency rather than fix it. Unifying on one spelling is a (small) breaking change for anyone passing it by keyword, so it is your call which way it goes.
Group 2 — a malformed section header, so Returns entries parse as parameters (1)
  • pulse.accelsearch.interbin_fft (accelsearch.py:526). Its Returns header has no underline:
        Returns
        new_freqs : array of floats, twice the length of the original array
            The new frequency array
        new_fft : array of complex numbers
    
    Without the -------, numpydoc never closes Parameters, so new_freqs and new_fft are read as parameters of a function whose signature is (freq, fft). Adding the underline fixes it; nothing else about the docstring is wrong.
Group 3 — stale or misspelled name, docstring-only (4)
Site Function Documents Actual parameter
utils.py:1114 get_random_state seed random_state (the body only ever uses random_state)
modeling/parameterestimation.py:745 _compute_pvalue obs_value obs_val
modeling/gpmodeling.py:761 weighted_posterior_plot key rkey
modeling/gpmodeling.py:858 comparison_plot key rkey
Group 4 — the entry belongs to a different function (19)

These read as copy-paste from a neighbour: the documented name is a real parameter somewhere else, just not here.

Site Function (actual parameters) Documents Where that name really lives
crossspectrum.py:2495 Crossspectrum.shift_and_add(f0_list, nbins, output_obj_type, rebin) freqs fourier.shift_and_add
crossspectrum.py:2498 same power_list fourier.shift_and_add
powerspectrum.py:1097 Powerspectrum.shift_and_add(f0_list, nbins, rebin) freqs fourier.shift_and_add
powerspectrum.py:1100 same power_list fourier.shift_and_add
fourier.py:531 normalize_leahy_poisson(unnorm_power, n_ph) variance normalize_leahy_from_variance
fourier.py:533 same n_bin normalize_abs, normalize_frac, others
fourier.py:1073 _intrinsic_coherence(cross_power, power1, power2, power1_noise, power2_noise, n_ave) return_uncertainty intrinsic_coherence, raw_coherence
fourier.py:3926 lsft_fast(y, t, freqs, sign, oversampling) fullspec 21 other functions, not this one
fourier.py:4067 lsft_slow(y, t, freqs, sign) fullspec as above
gti.py:1408 gti_border_bins(gtis, time, dt, epsilon) fraction_step bin_intervals_from_gtis, calculate_segment_bin_start
modeling/parameterestimation.py:1432 simulate_lrts(s_all, lpost1, t1, lpost2, t2, seed) max_post compute_lrt, calibrate_lrt, others
modeling/posterior.py:714 PSDPosterior(freq, power, model, priors, m) ps scripts.fit_powerspectrum, fit_lorentzians
modeling/scripts.py:41 fit_powerspectrum(ps, model, starting_pars, max_post, priors, fitmethod) fit_whitenoise fit_lorentzians
power_colors.py:251 plot_power_colors(p1, p1e, p2, p2e, plot_spans, configuration) center hue_from_power_color, _hue_line_data
powerspectrum.py:610 Powerspectrum.from_lightcurve(lc, segment_size, gti, norm, silent, use_common_mean, save_all) events from_events
powerspectrum.py:612 same dt widely used elsewhere, not accepted here
utils.py:821 rebin_data_log(x, y, f, y_err, dx) method rebin_data
utils.py:1867 hist2d_numba_seq(x, y, bins, range, use_memmap, tmp) shape _allocate_array_or_memmap
varenergyspectrum.py:735 ExcessVarianceSpectrum(events, freq_interval, energy_spec, bin_time, use_pi, segment_size, normalization) ref_band get_non_overlapping_ref_band; no __init__ in that module takes it, including the VarEnergySpectrum parent

In several of these the real parameter ends up with no entry at all as a side effect — normalize_leahy_poisson, for instance, documents variance and n_bin but not its actual n_ph. I have not listed those separately; fixing the wrong name is the part that misleads a caller.

Note that utils.py:821's method and Group 1's yerr are the same copy: rebin_data_log's docstring has picked up two of rebin_data's parameters.


What I am not doing

Not opening PRs for these unless you want them. If it would help, the obvious split is one small PR per file for Groups 3 and 4 (pure docstring text, no behaviour), leaving Groups 1 and 2 to you since one is an API decision and the other is a formatting fix in a function you may want to look at anyway. Say which you prefer, or take the list and ignore me — either is fine.

On @matteobachetti's second point: understood, and the Co-authored-by trailers are gone from anything I send to this repo from now on.

🤖 Generated with Claude Code

Dominant language
Python
Stars
229
Forks
196
Avg merge
4d 12h
Merged PRs (30d)
20

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/stingray

All issues in StingraySoftware/stingray

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.