Closed Heath123 closed 3 years ago
https://stackoverflow.com/a/59345651/4012708
So it seems this is only valid for numpy arrays but rgba_colors
is a normal Python list
Also even if they were numpy arrays wouldn't this make it only return True if none of the elements are equal?
Python 3.9.6 (default, Jul 3 2021, 16:40:50)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> a = np.array([1, 2, 3])
>>> b = np.array([1, 1, 1])
>>> c = (a == b)
>>> c
array([ True, False, False])
>>> c.all()
False
>>>
Because this checks if all of them are True when you want to check if all of them are False (so if not (self.rgba_colors == color.rgba_colors).all():
would work in that case)
Well the fix is wrong but now I can't reproduce the bug and I didn't attach an example file...
I believe the desired behavior is to check if the two are equal. Because it may be either ndarray or a list, the best fix would be to check the length of the outside dimensions and use a for loop to compare each element if the lengths are equal.
Oh, they are both Numpy arrays, but comparing them can return a single boolean sometimes for some reason
@Robert-N7 My first thought was wrong, I assumed it was a list but it isn't
I narrowed down the problem at https://replit.com/@HeathMitchell1/nparray
Looks like the correct fix is to use https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html
Made a new PR: #71
(this is using VS Code so the stacktrace is backwards from usual)