diff --git a/cgp/ea/mu_plus_lambda.py b/cgp/ea/mu_plus_lambda.py index 913f2ac3..b24b1b3f 100644 --- a/cgp/ea/mu_plus_lambda.py +++ b/cgp/ea/mu_plus_lambda.py @@ -214,7 +214,9 @@ def _create_new_offspring_generation(self, pop: Population) -> List[IndividualBa offsprings: List[IndividualBase] = [] while len(offsprings) < self.n_offsprings: - tournament_pool = pop.rng.permutation(pop.parents)[: self.tournament_size] + tournament_pool = pop.rng.permutation(pop.parents)[ # type: ignore + : self.tournament_size + ] best_in_tournament = sorted(tournament_pool, reverse=True)[0] offsprings.append(best_in_tournament.clone()) diff --git a/cgp/hl_api.py b/cgp/hl_api.py index 4fff772c..c4195c9d 100644 --- a/cgp/hl_api.py +++ b/cgp/hl_api.py @@ -64,7 +64,7 @@ def evolve( callback(pop) # perform evolution - max_fitness = np.finfo(float).min + max_fitness = float(np.finfo(float).min) # Main loop: -1 offset since the last loop iteration will still increase generation by one while pop.generation < max_generations - 1 and ea.n_objective_calls < max_objective_calls: diff --git a/extra-requirements.txt b/extra-requirements.txt index 3f164d5e..1be89425 100644 --- a/extra-requirements.txt +++ b/extra-requirements.txt @@ -1,21 +1,21 @@ # extra requirements -matplotlib ~= 3.4.1 -scipy ~= 1.6.2 -sympy ~= 1.8 -torch ~= 1.8.0 -gym ~= 0.18.3 +matplotlib >= 3.4.1 +scipy >= 1.6.2 +sympy >= 1.8 +torch >= 1.8.0 +gym ~= 0.25.0 # dev requirements pytest ~= 5.4.1 -mypy ~= 0.800 +mypy >= 0.800 click ~= 8.0.1 black ~= 19.10b0 flake8 ~= 3.7.9 isort ~=5.2.2 # doc requirements -jinja2 ~= 3.0.1 -sphinx ~=3.1.2 -recommonmark~=0.6.0 -msmb_theme~=1.2.0 -sphinx-rtd-theme~=0.5.0 -sphinx-gallery~=0.8.0 -pillow~=8.1.1 +jinja2 >= 3.0.1 +sphinx >=3.1.2 +recommonmark >= 0.6.0 +msmb_theme >= 1.2.0 +sphinx-rtd-theme >= 0.5.0 +sphinx-gallery >= 0.8.0 +pillow ~= 8.1.1 diff --git a/requirements.txt b/requirements.txt index 66618e8f..b89ee47e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -numpy ~= 1.19.0 +numpy >= 1.19.0 docopt-ng~=0.7.2 diff --git a/test/test_node.py b/test/test_node.py index 8c1d20f5..f2d76896 100644 --- a/test/test_node.py +++ b/test/test_node.py @@ -58,7 +58,9 @@ def _test_to_numpy(genome, x, y_target): def _test_to_torch(genome, x, y_target): torch = pytest.importorskip("torch") graph = cgp.CartesianGraph(genome) - assert graph.to_torch()(torch.Tensor(x).reshape(1, -1)) == pytest.approx(y_target) + assert graph.to_torch()(torch.Tensor(x).reshape(1, -1)).detach().numpy() == pytest.approx( + y_target + ) def _test_to_sympy(genome, x, y_target): @@ -461,7 +463,7 @@ class CustomAdd(cgp.OperatorNode): def test_raise_broken_def_numpy_output(): - with pytest.raises(ValueError): + with pytest.raises(TypeError): class CustomAdd(cgp.OperatorNode): _arity = 2