PYFTS / pyFTS

An open source library for Fuzzy Time Series in Python
http://pyfts.github.io/pyFTS/
GNU General Public License v3.0
262 stars 54 forks source link

Bug in binary search #20

Closed RobinloveCode closed 5 years ago

RobinloveCode commented 5 years ago

Hi. Dr.,

I think there is a bug in FuzzySet.binary search,

elif midpoint <= 1: return [0] elif midpoint >= max_len: return [max_len] the first elif should be midpoint<1: return[0]. Because the index of fuzzy sets start from 0 and end at (max_len= len(Fuzzysets)-1)

petroniocandido commented 5 years ago

Hi @RobinloveCode ! Thanks to get in touch!

I was waiting an opportunity to make that binary search obsolete for a long time, and I make that change today. That old code still there to ensure retrocompatibility but now the FTS methods calls the partitioner.fuzzyfy method.

I replaced the __binary_search by an KDTree index inside the partitioner, which is more adequate to perform fuzzy searches, especially if there are many overlapped fuzzy sets (depending on the partitioner this may occur). That search now is executed by the method partitioner.search.

After testing all methods I changed the references to those old methods on the tutorials and I can conclude that pyFTS is more stable now.

Thanks very much!