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

Fix NaN comparison #1958

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Fix NaN comparison #1958

merged 1 commit into from
Feb 11, 2025

Conversation

NolanTrem
Copy link
Collaborator

@NolanTrem NolanTrem commented Feb 11, 2025

Important

Fixes NaN comparison in create_providers method of factory.py to ensure consistent embedding dimensions.

  • Behavior:
    • Fixes NaN comparison in create_providers method of factory.py.
    • Ensures embedding.base_dimension and completion_embedding.base_dimension are either both NaN or equal.
  • Imports:
    • Adds import math to handle NaN comparisons.

This description was created by Ellipsis for e0671c8. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to e0671c8 in 1 minute and 36 seconds

More details
  • Looked at 24 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. py/core/main/assembly/factory.py:315
  • Draft comment:
    Using math.isnan on base_dimension assumes it's a float. Ensure type safety; if base_dimension could be an int or None, this might raise a TypeError.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    This is a valid concern - math.isnan() is specifically for float values and will raise TypeError if called on int or None. However, I don't have enough context about the EmbeddingConfig class to know if base_dimension is guaranteed to be a float. The fact that the code was changed to add isnan checks suggests the author knows the type. Without seeing the config class definition, I can't be 100% sure this is an issue.
    I don't have visibility into the EmbeddingConfig class definition, so I can't verify if base_dimension is actually typed as something other than float. The author may have good reason to know it's always a float.
    While the type concern is theoretically valid, without being able to confirm the actual type of base_dimension, this comment risks being incorrect or unnecessary if base_dimension is already guaranteed to be a float.
    Given the uncertainty about the underlying types and lack of strong evidence that this is definitely an issue, we should err on the side of removing this comment.
2. py/core/main/assembly/factory.py:315
  • Draft comment:
    Consider extracting the math.isnan() results into well-named variables for clarity, e.g. isEmbeddingNaN and isCompletionNaN. This would simplify the condition and improve readability.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
3. py/core/main/assembly/factory.py:315
  • Draft comment:
    The updated condition correctly handles cases where one dimension is NaN and the other is not, and allows both to be NaN. This fix addresses the NaN comparison issue.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_uRonrTwrtQ4sVDMB


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -311,7 +312,12 @@ async def create_providers(
**kwargs,
) -> R2RProviders:
if (
self.config.embedding.base_dimension
math.isnan(self.config.embedding.base_dimension)
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability, consider caching the is-NaN checks in variables instead of repeating math.isnan calls.

@NolanTrem NolanTrem merged commit b83348c into main Feb 11, 2025
13 of 14 checks passed
@NolanTrem NolanTrem deleted the Nolan/FixNaN branch February 11, 2025 03:53
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.

1 participant