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

More precise type annotations for MultiObjectiveOptimizationConfig #2620

Closed
wants to merge 1 commit into from

Conversation

esantorella
Copy link
Contributor

Summary:
Context: Type annotations imply that any Objective works with a MultiObjectiveOptimizationConfig, but the code makes clear that only a MultiObjective or ScalarizedObjective works, and even has tests for this. I was misled myself into trying to privde an Objective to a MultiObjectiveOptimizationConfig.

This PR:

  • Changes annotations from Objective to Union[MultiObjective, ScalarizedObjective]
  • Adds a pyre-fixme: Inconsistent override. The indirect cause of why this is needed is that Objective.clone_with_args returns an Objective type even in subclasses unless the method is overriden, rather than a self type.
  • Added a couple pyre-fixmes in unit tests that were deliberately testing inappropriate types.

Differential Revision: D60476566

Summary:
Context: Type annotations imply that any `Objective` works with a `MultiObjectiveOptimizationConfig`, but the code makes clear that only a `MultiObjective` or `ScalarizedObjective` works, and even has tests for this. I was misled myself into trying to privde an `Objective` to a `MultiObjectiveOptimizationConfig`.

This PR:
* Changes annotations from `Objective` to `Union[MultiObjective, ScalarizedObjective]`
* Adds a pyre-fixme: Inconsistent override. The indirect cause of why this is needed is that `Objective.clone_with_args` returns an `Objective` type even in subclasses unless the method is overriden, rather than a self type.
* Added a couple pyre-fixmes in unit tests that were deliberately testing inappropriate types.

Differential Revision: D60476566
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jul 30, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60476566

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.22%. Comparing base (8e07000) to head (7395dc2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2620   +/-   ##
=======================================
  Coverage   95.22%   95.22%           
=======================================
  Files         492      492           
  Lines       47672    47673    +1     
=======================================
+ Hits        45394    45395    +1     
  Misses       2278     2278           

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in f25b4ce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants