esa / pygmo2

A Python platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pygmo2/
Mozilla Public License 2.0
436 stars 56 forks source link

[BUG] A bug in tests #103

Closed InCogNiTo124 closed 2 years ago

InCogNiTo124 commented 2 years ago

Describe the bug There seem to be a bug in the tests. This line expects a RuntimeError https://github.com/esa/pygmo2/blob/6d3a776f6f88294d22c50e18e27955df4971fd29/pygmo/_problem_test.py#L193

However, a ValueError seems to be thrown:

Traceback (most recent call last):
  File "/home/Projects/ksp/venv/lib/python3.10/site-packages/pygmo/_problem_test.py", line 28, in runTest
    self.run_basic_tests()
  File "/home/Projects/ksp/venv/lib/python3.10/site-packages/pygmo/_problem_test.py", line 193, in run_basic_tests
    self.assertRaises(RuntimeError, lambda: problem(p()))
  File "/usr/lib/python3.10/unittest/case.py", line 738, in assertRaises
    return context.handle('assertRaises', args, kwargs)
  File "/usr/lib/python3.10/unittest/case.py", line 201, in handle
    callable_obj(*args, **kwargs)
  File "/home/Projects/ksp/venv/lib/python3.10/site-packages/pygmo/_problem_test.py", line 193, in <lambda>
    self.assertRaises(RuntimeError, lambda: problem(p()))
ValueError: 
function: check_problem_bounds
where: /home/Projects/ksp/pagmo2/src/problem.cpp, 86
what: The lower bound at position 0 is 0.000000 while the upper bound has the smaller value -1.000000

To Reproduce Steps to reproduce the behavior:

  1. Clone the repo
  2. Install from source (master branch)
  3. import pygmo
  4. pygmo.test.run_test_suite()

Expected behavior All tests should pass

Screenshots N/A

Environment (please complete the following information):

Additional context A simple change RuntimeError -> ValueError will probably solve the issue

bluescarni commented 2 years ago

@InCogNiTo124 thanks for the report.

We are seeing the same issue in recent rebuilds of the conda packages. My guess is that something changed in recent versions of pybind11 regarding exception translation.

I'll try to work out a patch in the next couple of days.

bluescarni commented 2 years ago

PR is now up at #104.

bluescarni commented 2 years ago

@InCogNiTo124 gonna close this, thanks again for the report.

InCogNiTo124 commented 2 years ago

Thank you for the prompt solution :D