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

plot_fitness(plot_type="scatter") fails after 2nd run() #62

Open
Assignees
Labels
bugSomething isn't working
@andrey-bat

Description

Hi! Great project, thanks. However I've experianced some bugs.

model = pygad.GA(someparameters - may be even sample model from documentation)
model.run()
model.plot_fitness(plot_type="scatter")
ok
model.run()
model.plot_fitess()
ok
model.plot_fitness(plot_type="scatter")


ValueError Traceback (most recent call last)
in
----> 1 ga_instance.plot_fitness(plot_type="scatter")

~/.conda/envs/test/lib/python3.9/site-packages/pygad/pygad.py in plot_fitness(self, title, xlabel, ylabel, linewidth, font_size, plot_type, color, save_dir)
3150 matplotlib.pyplot.plot(self.best_solutions_fitness, linewidth=linewidth, color=color)
3151 elif plot_type == "scatter":
-> 3152 matplotlib.pyplot.scatter(range(self.generations_completed + 1), self.best_solutions_fitness, linewidth=linewidth, color=color)
3153 elif plot_type == "bar":
3154 matplotlib.pyplot.bar(range(self.generations_completed + 1), self.best_solutions_fitness, linewidth=linewidth, color=color)

~/.conda/envs/test/lib/python3.9/site-packages/matplotlib/pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, edgecolors, plotnonfinite, data, **kwargs)
3066 vmin=None, vmax=None, alpha=None, linewidths=None, *,
3067 edgecolors=None, plotnonfinite=False, data=None, **kwargs):
-> 3068 __ret = gca().scatter(
3069 x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
3070 vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths,

~/.conda/envs/test/lib/python3.9/site-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs)
1359 def inner(ax, *args, data=None, **kwargs):
1360 if data is None:
-> 1361 return func(ax, *map(sanitize_sequence, args), **kwargs)
1362
1363 bound = new_sig.bind(ax, *args, **kwargs)

~/.conda/envs/test/lib/python3.9/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, edgecolors, plotnonfinite, **kwargs)
4496 y = np.ma.ravel(y)
4497 if x.size != y.size:
-> 4498 raise ValueError("x and y must be the same size")
4499
4500 if s is None:

ValueError: x and y must be the same size

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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