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

When constructing parameters from lists of names and values, ensure that names and values have the same length #3231

Closed
wants to merge 1 commit into from

Conversation

esantorella
Copy link
Contributor

Summary:
Context: There is code like

parameters={p: float(xbest[i]) for i, p in enumerate(self.parameters)}

If xbest is longer than self.parameters (which indicates a problem), the extra elements in xbest will be silently discarded. The new behavior will generate an exception.

I did not check everywhere that this might be a problem, just in the places where it was causing trouble for me.

This PR:

  • Updates two places where parameters are constructed to use dict(zip(..., strict=True))

Reviewed By: Balandat

Differential Revision: D68035646

…hat names and values have the same length

Summary:
Context: There is code like

`parameters={p: float(xbest[i]) for i, p in enumerate(self.parameters)}`

If `xbest` is longer than `self.parameters` (which indicates a problem), the extra elements in `xbest` will be silently discarded. The new behavior will generate an exception.

I did not check everywhere that this might be a problem, just in the places where it was causing trouble for me.

This PR:
* Updates two places where  parameters are constructed to use `dict(zip(..., strict=True))`

Reviewed By: Balandat

Differential Revision: D68035646
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 13, 2025
@facebook-github-bot
Copy link
Contributor

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

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.88%. Comparing base (d340d44) to head (90afb55).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3231   +/-   ##
=======================================
  Coverage   95.88%   95.88%           
=======================================
  Files         513      513           
  Lines       51687    51689    +2     
=======================================
+ Hits        49558    49560    +2     
  Misses       2129     2129           

☔ 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 bdceb7f.

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