In _even_test(), the variable out is formed as a list from the values of self._shape, then tested for its equality against self._shape.
# ...
w, h = self._shape
if w % 2 > 0: w -= 1
if h % 2 > 0: h -= 1
out = [w, h]
if out != self._shape:
# ...
Because the user can pass a new self._shape in through .config(output_resolution=) , if that value is of the type tuple() it will not be equal to the list() type out.
(1920, 1080) != [1920, 1080]
# True
The simple solution is to just force the type of self._shape during _even_test()'s comparison.
So let's not do that!
Instead, the unnecessarily comprehensive solution I'm going to push eliminates lists in the VideoStream object entirely. Having been forced to consider it in this issue, there's just no reason to invoke the read-write list() type in these variables when the read-only tuple() type will do. (and is theoretically faster and smaller)
So in the coming commit, self._shape and self._crop initialize as tuples; The .config() method forces the pertinent arguments into tuple types; And _even_test() now reads out = (w, h) before comparison.
@bml1g12 reports:
In
_even_test()
, the variableout
is formed as a list from the values ofself._shape
, then tested for its equality againstself._shape
.Because the user can pass a new self._shape in through
.config(output_resolution=)
, if that value is of the typetuple()
it will not be equal to thelist()
typeout
.The simple solution is to just force the type of self._shape during _even_test()'s comparison. So let's not do that!
Instead, the unnecessarily comprehensive solution I'm going to push eliminates lists in the VideoStream object entirely. Having been forced to consider it in this issue, there's just no reason to invoke the read-write
list()
type in these variables when the read-onlytuple()
type will do. (and is theoretically faster and smaller)So in the coming commit,
self._shape
andself._crop
initialize as tuples; The.config()
method forces the pertinent arguments into tuple types; And_even_test()
now readsout = (w, h)
before comparison.