You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the comparison functions for BitSequence may be erroneous? There are nots in the functions for <=, <, >, >= that shouldn't be there, unless I'm understanding the purpose of comparison wrong
Adding to this, the base function _cmp(self, other) also seems odd. I'm assuming the comparison is based on int value, but the function compares length first (which would fail in an example case: 101 vs 0010), then compares bit by bit. However, n from enumerate should only have values from 0 to len(self)-1. This makes the function less than always return True if both BitSequences have the same length.
A simplier way to compare would be to convert to int and compare directly, for example int(self) and int(other). Again, I may be understanding the purpose wrong, but if comparison deals with the int values of BitSequences then using the conversion function directly should make it simple.
The text was updated successfully, but these errors were encountered:
It seems the comparison functions for BitSequence may be erroneous? There are
not
s in the functions for <=, <, >, >= that shouldn't be there, unless I'm understanding the purpose of comparison wrongpyftdi/pyftdi/bits.py
Lines 234 to 250 in 2ad8a1a
Adding to this, the base function
_cmp(self, other)
also seems odd. I'm assuming the comparison is based on int value, but the function compares length first (which would fail in an example case: 101 vs 0010), then compares bit by bit. However,n
fromenumerate
should only have values from 0 tolen(self)-1
. This makes the function less than always return True if both BitSequences have the same length.pyftdi/pyftdi/bits.py
Lines 252 to 260 in 2ad8a1a
A simplier way to compare would be to convert to int and compare directly, for example
int(self)
andint(other)
. Again, I may be understanding the purpose wrong, but if comparison deals with the int values of BitSequences then using the conversion function directly should make it simple.The text was updated successfully, but these errors were encountered: