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

Add Warnings whenever a floating-point value is used as a Dictionary key #11417

Merged
merged 24 commits into from
Nov 14, 2024

Conversation

GregoryTravis
Copy link
Contributor

@GregoryTravis GregoryTravis commented Oct 25, 2024

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@GregoryTravis GregoryTravis added the CI: No changelog needed Do not require a changelog entry for this PR. label Oct 25, 2024
@GregoryTravis GregoryTravis marked this pull request as ready for review October 31, 2024 19:05
Comment on lines 273 to 276
group_builder.specify "should attach a warning when a Float is used as a key" <|
m = Dictionary.empty . insert 1.2 3
m.at 1.2 . should_equal 3
Problems.expect_only_warning Float_Used_As_Dictionary_Key m
Copy link
Member

Choose a reason for hiding this comment

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

Please also add a test that checks if we have the same behaviour when we construct the dictionary using Dictionary.from_vector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@GregoryTravis
Copy link
Contributor Author

I am still evaluating benchmarks for this change.

Comment on lines 581 to 582
## Indicates that a Float was used as a Dicionary key.
type Float_Used_As_Dictionary_Key
Copy link
Member

Choose a reason for hiding this comment

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

This type feels slightly redundant with already existing Floating_Point_Equality.

However, I do like that we get a more precise message ('Float used as dictionary key'). What about merging this into the Floating_Point_Equality error, perhaps by distinguishing different constructors (we already have multi-constructor errors, e.g. Invalid_Value_Type).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done -- moved Floating_Point_Equality into Base.

Comment on lines 55 to 56
# Scenario similar to what is done in distinct
# 'Dense' ints have more duplicates and cause fewer inserts to happen.
Copy link
Member

Choose a reason for hiding this comment

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

I'd add

Suggested change
# Scenario similar to what is done in distinct
# 'Dense' ints have more duplicates and cause fewer inserts to happen.
# Scenario similar to what is done in distinct
# 'Dense' ints have more duplicates and cause fewer inserts, but more key updates to happen.

(assuming it's true, but it feels it should be)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@GregoryTravis
Copy link
Contributor Author

Benchmarks look good.

@@ -4,6 +4,7 @@ import Standard.Base.Data.Filter_Condition as Filter_Condition_Module
import Standard.Base.Data.Time.Errors.Date_Time_Format_Parse_Error
import Standard.Base.Data.Vector.Builder
import Standard.Base.Errors.Common.Additional_Warnings
import Standard.Base.Errors.Common.Floating_Point_Equality
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? Looks like only change to this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Floating_Point_Equality is used in this file, and was previously imported by from Standard.Table.Errors import all, but not anymore because it has moved to Common.

@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Nov 12, 2024
@GregoryTravis GregoryTravis added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Nov 13, 2024
@mergify mergify bot merged commit 159a7a3 into develop Nov 14, 2024
36 checks passed
@mergify mergify bot deleted the wip/gmt/9608-warn-float-dict-key branch November 14, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants