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 custom bounds handling in test problems #1760

Closed
wants to merge 1 commit into from

Conversation

saitcakmak
Copy link
Contributor

Summary: Fixes #1759

Differential Revision: D44326798

@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Mar 23, 2023
@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@Balandat Balandat left a comment

Choose a reason for hiding this comment

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

Some tests are still failing, o/w this generally lgtm, thanks.

if len(self._bounds) != self.dim:
raise InputDataError(
"Expected the bounds to match the dimensionality of the domain. "
f"Got {self.dim=} and {self._bounds=}."
Copy link
Contributor

Choose a reason for hiding this comment

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

should we print the dimension of the bounds rather than the bounds themselves here? If this is a high-dim problem that would likely be a lot easier to comprehend.

@@ -45,8 +47,34 @@ class DummySyntheticTestFunctionWithOptimizers(DummySyntheticTestFunction):


class TestSyntheticTestFunction(BotorchTestCase):
functions_with_custom_bounds = [
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment what the int value here is

Comment on lines +95 to +100
for func_class, dim in self.functions_with_custom_bounds:
bounds = [(-1e5, 1e5) for _ in range(dim)]
bounds_tensor = torch.tensor(bounds).T
func = func_class(bounds=bounds)
self.assertEqual(func._bounds, bounds)
self.assertTrue(torch.allclose(func.bounds, bounds_tensor))
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for this!

@esantorella
Copy link
Member

Do these problems need to have a _bounds attribute at all? It seems like self._bounds is never accessed after it’s set. (code search) I feel a lot better about having both now that we have the unit test that they contain the same values though!

@saitcakmak
Copy link
Contributor Author

Do these problems need to have a _bounds attribute at all? It seems like self._bounds is never accessed after it’s set. (code search) I feel a lot better about having both now that we have the unit test that they contain the same values though!

Do they need to? Probably not. They've had it for a long time, so it makes sense to keep it around. I generally wouldn't rely on code search to find usage of test problems since they'll mostly be used for benchmarking by us or external users. I guess this makes it a bit harder to catch non-breaking bugs with them as well.

Summary:
Pull Request resolved: pytorch#1760

Fixes pytorch#1759

Reviewed By: Balandat

Differential Revision: D44326798

fbshipit-source-id: 5ce9481fc2376b66d62be1edd08fdb7f81c9a858
@facebook-github-bot
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Merging #1760 (ef12d9a) into main (f596e71) will not change coverage.
The diff coverage is 100.00%.

❗ Current head ef12d9a differs from pull request most recent head 480ef5f. Consider uploading reports for the commit 480ef5f to get more accurate results

@@            Coverage Diff            @@
##              main     #1760   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          170       170           
  Lines        14717     14729   +12     
=========================================
+ Hits         14717     14729   +12     
Impacted Files Coverage Δ
botorch/test_functions/base.py 100.00% <100.00%> (ø)
botorch/test_functions/synthetic.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 005fd56.

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.

[Bug] Weird bounds handling in Ackley (and potentially others)
4 participants