Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: allow ignoring NaNs in JS transforms, too #235

Merged
merged 4 commits into from
Jan 14, 2025
Merged

feat!: allow ignoring NaNs in JS transforms, too #235

merged 4 commits into from
Jan 14, 2025

Conversation

sd2k
Copy link
Collaborator

@sd2k sd2k commented Jan 13, 2025

Unfortunately this requires a breaking change to the JS API;
while transforms were previously specified as an array of strings,
they are now specified as an array of objects with a type property.

This is a breaking change, but it's a sensible one, because it will
allow us to add further options to transforms in future.

BREAKING CHANGE: transforms are now specified as an array of objects
with a type property.

Summary by CodeRabbit

  • New Features

    • Added support for handling NaN values in data transformations
    • Introduced option to ignore NaN values during StandardScaler and YeoJohnson transformations
  • Tests

    • Added test cases for pipelines with NaN values
    • Expanded test coverage for transformation scenarios involving missing data

Similar to #227, but for power transforms.

Also add tests for ignoring NaNs in exponential transforms.
Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces modifications to the Transform enum in the Rust code, specifically enhancing the StandardScaler and YeoJohnson variants to include a new ignore_nans boolean field. This change allows more nuanced control over handling NaN values during data transformations. The into_transformer method has been updated to accommodate these changes, constructing StandardScaler and YeoJohnson instances with the new NaN-handling parameter. Corresponding test cases have been added to verify the pipeline's behavior with NaN values.

Changes

File Change Summary
js/augurs-transforms-js/src/lib.rs - Updated StandardScaler and YeoJohnson enum variants to include ignore_nans: bool field
- Modified serde attributes to use tag for type identification
- Updated into_transformer method to pass ignore_nans parameter
js/testpkg/transforms.test.ts - Added new test suite for pipelines with NaN values
- Modified Pipeline instantiation to use objects with type and ignoreNaNs properties
- Added tests for NaN handling in transformations

Sequence Diagram

Loading
sequenceDiagram
    participant User
    participant Pipeline
    participant Transform
    participant Transformer

    User->>Pipeline: Create with transforms
    Pipeline->>Transform: Configure with ignoreNaNs
    Transform-->>Transformer: Initialize with NaN handling
    User->>Pipeline: Transform data
    Pipeline->>Transformer: Apply transformation
    Transformer-->>User: Return transformed data

Possibly related PRs

Poem

🐰 In the realm of data's wild terrain,
NaNs once caused a coding strain,
With ignoreNaNs now in sight,
Transformations dance with delight!
A rabbit's code, both smart and lean 🧮


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

@sd2k
Copy link
Collaborator Author

sd2k commented Jan 13, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
js/augurs-transforms-js/src/lib.rs (1)

34-39: Consider standardizing the method names for consistency.

The implementation uses different method names for similar functionality:

  • ignore_nans() for StandardScaler
  • with_ignore_nans() for YeoJohnson

Consider standardizing these method names across both transformers for better API consistency.

js/testpkg/transforms.test.ts (2)

67-71: Consider expanding NaN test cases.

The test data setup is good but could be more comprehensive. Consider adding test cases for:

  • NaNs at the start/end of the array
  • Consecutive NaNs
  • Edge cases with all NaNs

84-93: Consider optimizing test suite structure.

The empty pipeline and invalid transform tests are duplicated from the main suite. Consider:

  1. Moving these to a shared test helper or using test.each
  2. Adding NaN-specific edge cases (e.g., testing transforms with mixed ignoreNaNs settings)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 23005ec and c58cf25.

📒 Files selected for processing (2)
  • js/augurs-transforms-js/src/lib.rs (1 hunks)
  • js/testpkg/transforms.test.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (3)
js/augurs-transforms-js/src/lib.rs (1)

14-28: LGTM! Well-documented enum changes.

The Transform enum changes are well-structured with proper serde attributes and documentation. The breaking change is clearly implemented by adding the ignore_nans field to both transform variants.

js/testpkg/transforms.test.ts (2)

45-45: LGTM! Test updated to use new transform format.

The test correctly implements the breaking change by using objects with type property instead of strings.


72-82: LGTM! Comprehensive transform pipeline test with NaNs.

The test properly verifies the transformation pipeline with NaN values, including both forward and inverse transformations.

It flows a bit nicer.
sd2k added 2 commits January 13, 2025 11:40
Unfortunately this requires a breaking change to the JS API;
while transforms were previously specified as an array of strings,
they are now specified as an array of objects with a `type` property.

This is a breaking change, but it's a sensible one, because it will
allow us to add further options to transforms in future.

BREAKING CHANGE: transforms are now specified as an array of objects
with a `type` property.
Base automatically changed from power-transforms-ignore-nans to main January 14, 2025 08:15
@sd2k sd2k merged commit 22be0e3 into main Jan 14, 2025
24 checks passed
@sd2k sd2k deleted the ignore-nans-js branch January 14, 2025 08:15
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.

None yet

1 participant