Skip to content

Conversation

@demvlad
Copy link
Contributor

@demvlad demvlad commented May 13, 2025

Reverts #819
I doubted that it was bug and i've found an answer.
The source spectrum code used FFT zero padding method, to get bigger fft resolution at the chart. It uses big input/output size with big zero values pad. As result we had high fft resolution as fs/N. But zero pad does not change frequency resolution, what is 1/T.
The current PR uses current sample size for fft input, what is not good for fft speed.
I want try to use fft input size as nearest power 2 value and fill zero values in empty cells only.
The both methods is working. But we need to test and compare new method before.
Those methods choice is ground of my next PSD PRs. I will need the big rebase of PSD PRs in any case. I will use new method for PSD.
Therefore i suggest to revert this and PSD :) PRs.
The PSD works good and i have power2 sized version, but let's test and compare the all these before.

Summary by CodeRabbit

  • Bug Fixes
    • Improved data consistency by returning complete arrays in certain calculations, ensuring all available data is included in results.

@coderabbitai
Copy link

coderabbitai bot commented May 13, 2025

Walkthrough

The update removes array slicing operations from three internal functions in src/graph_spectrum_calc.js, causing these functions to return full arrays rather than subsets limited by a sample count. A minor indentation adjustment was also made in another function, without changing its logic or output.

Changes

File(s) Change Summary
src/graph_spectrum_calc.js Removed array slicing before returning in three functions, causing them to return full arrays. Minor indentation fix in another function.

Suggested reviewers

  • haslinghuis

Poem

In the code where arrays once were sliced,
Now full and whole, their length’s enticed.
No more snipping at the ends,
The data’s whole—on this depends!
With tidy tabs and lines anew,
The rabbit hops and thanks the crew.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1480a62 and 21d9bca.

📒 Files selected for processing (1)
  • src/graph_spectrum_calc.js (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/graph_spectrum_calc.js (1)
src/flightlog.js (1)
  • minValue (1360-1361)
🔇 Additional comments (4)
src/graph_spectrum_calc.js (4)

207-214: Indentation change looks good.

This is a minor formatting change that improves the code's readability without affecting functionality.


332-334: Array slicing removed as part of revert.

The function now returns the full samples array instead of slicing it to samplesCount. This aligns with the PR objective of reverting the slicing operations to test different FFT zero padding approaches.

Downstream functions that use this result (dataLoadFrequency and dataLoadPSD) appear to properly handle the full array by using the count property or checking array lengths.


447-450: Array slicing removed as part of revert.

Both piderror and setpoint arrays are now returned in full instead of being sliced to samplesCount. The consumer function (dataLoadPidErrorVsSetpoint) correctly iterates only up to flightSamples.count, so this change should not cause functionality issues.


413-419:

❌ Incorrect review comment

Verify consistency between samples and vsValues arrays.

The samples array is no longer sliced while the vsValues arrays are still sliced at line 412. This could potentially lead to inconsistency in array lengths between samples and vsValues.


🏁 Script executed:

#!/bin/bash
# Check if there are any places in the code that assume samples and vsValues have the same length

# Search for places where both arrays are used together
rg -A 10 -B 10 "samples.*vsValues|vsValues.*samples" src/

Length of output: 1454


No inconsistency between samples and vsValues
Both arrays are explicitly truncated to samplesCount before being returned—samples.slice(0, samplesCount) and slicedVsValues (each inner array of vsValues is similarly sliced). You can safely ignore the length-mismatch warning.

Likely an incorrect or invalid review comment.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

Preview URL: https://376c8713.betaflight-blackbox.pages.dev

@sonarqubecloud
Copy link

@nerdCopter
Copy link
Member

nerdCopter commented May 13, 2025

please merge this. investigating slice introduction and using AI is opening a can of worms.

@nerdCopter nerdCopter marked this pull request as draft May 13, 2025 14:03
@nerdCopter nerdCopter marked this pull request as ready for review May 13, 2025 14:07
@nerdCopter
Copy link
Member

i marked, then removed draft. -- the preview is not working, but local build works.

@haslinghuis haslinghuis merged commit abfac2c into betaflight:master May 13, 2025
4 checks passed
@haslinghuis haslinghuis added this to the 4.0.0 milestone May 13, 2025
@demvlad demvlad deleted the revert-819-slice_spectrum_samples branch September 17, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants