Skip to content

Code quality and API improvements#46

Merged
raphaelvallat merged 2 commits intomasterfrom
improve_code_quality
Mar 6, 2026
Merged

Code quality and API improvements#46
raphaelvallat merged 2 commits intomasterfrom
improve_code_quality

Conversation

@raphaelvallat
Copy link
Copy Markdown
Owner

Bug fixes

  • epsilon value corrected (utils.py): epsilon = 10e-9 (= 1e-8) was a silent typo; fixed to 1e-9. This constant guards against division by zero in the Numba linear regression used by detrended_fluctuation.
  • __all__ instead of all (entropy.py, fractal.py, utils.py): All three modules assigned to a bare all variable, inadvertently exporting every imported name (np, jit, KDTree, …) on from antropy import *. Fixed
    to __all__
  • sample_entropy undefined case returns np.nan: When no template of length m matches within the tolerance (denominator = 0), the function previously returned 0. This is mathematically undefined.

API additions

  • hjorth_params(sf=None): New optional sf parameter converts mobility from samples⁻¹ to Hz by multiplying by the sampling frequency. Complexity is unaffected (dimensionless ratio).

Documentation

  • lziv_complexity: Added .. warning:: about float/int arrays being truncated to uint32
  • hjorth_params: Added note clarifying mobility units and sf conversion; updated example.
  • num_zerocross: Added Notes section documenting signbit(0) == False behaviour (a transition through exactly 0 counts as one crossing, not two).
  • spectral_entropy: Added note that the DC component (f = 0) is included in the entropy sum.
  • detrended_fluctuation: Added note that α ≈ 1 is ambiguous between the fGn/fBm regimes.
  • svd_entropy: Clarified normalisation wording (maximum is reached when all singular values are equal).
  • Removed stale Python 2 comment (np.true_divide) and dead Timmermann et al. commented-out code block.

@raphaelvallat raphaelvallat self-assigned this Mar 6, 2026
@raphaelvallat raphaelvallat merged commit 7150019 into master Mar 6, 2026
18 checks passed
@raphaelvallat raphaelvallat deleted the improve_code_quality branch March 6, 2026 15:57
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (372dd11) to head (183f641).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #46   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          302       312   +10     
  Branches        45        52    +7     
=========================================
+ Hits           302       312   +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants