Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

'numpy.ndarray' object has no attribute 'index' #293

Open
Labels
bugSomething isn't working
@GaidaiIgor

Description

On line 1683 in pygad.py the code says
solution_idx = self.best_solutions.index(list(sol))
apparently assuming that self.best_solutions is always a list. However, it is possible that self.best_solutions is a numpy.ndarray, in which case the index method is undefined and the program crashes.

Adding

if type(self.best_solutions) is numpy.ndarray:
 self.best_solutions = self.best_solutions.tolist()

before the first if statement (if (self.save_solutions) and (len(self.solutions) > 0) and (list(sol) in self.solutions):) seems to resolve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /