Skip to content

community/py3-niapy: fix tests with numpy 2.0

mio requested to merge mio/aports:py3-niapy into master

Update numpy float reference to fix failed tests. Resolves rebuild error due to failed tests on the 3.21 builders.

tests/test_shade.py:56:
tests/test_algorithm.py:328: in test_algorithm_run
    raise a.exception
niapy/algorithms/algorithm.py:314: in run
    pop, fpop, xb, fxb, params = self.run_iteration(task, pop, fpop, xb, fxb, **params)
niapy/algorithms/modified/shade.py:454: in run_iteration
    population, archive, arc_ind_cnt, best_x, best_fitness = self.post_selection(population, archive, arc_ind_cnt,
niapy/algorithms/modified/shade.py:517: in post_selection
    next_pop_size = np.int_(np.around((((4.0 - self.population_size) / np.float_(max_nfe)) * nfe) + self.population_size))
[...]
        if attr in __expired_attributes__:
>           raise AttributeError(
                f"`np.{attr}` was removed in the NumPy 2.0 release. "
                f"{__expired_attributes__[attr]}",
                name=None
            )
E           AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.

/usr/lib/python3.12/site-packages/numpy/__init__.py:400: AttributeError

Failed tests:

FAILED tests/test_shade.py::LSHADETestCase::test_custom - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
FAILED tests/test_shade.py::LSHADETestCase::test_griewank - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
Edited by mio

Merge request reports

Loading