From 5ffd42a25d3b6535bab0360c66f78c2ca875b386 Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Sun, 20 Dec 2015 10:08:31 -0800 Subject: [PATCH] Fixed FilterPy versioning check error. The code only worked for the third version number. If the first or second version numbers were too small it didn't detect it. --- book_format.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/book_format.py b/book_format.py index 4b9a9ab..5433086 100644 --- a/book_format.py +++ b/book_format.py @@ -38,21 +38,17 @@ np.set_printoptions(precision=3) sys.path.insert(0, './code') # allow us to import book_format def test_filterpy_version(): - import filterpy - min_version = [0,0,28] - v = filterpy.__version__ - tokens = v.split('.') - for i,v in enumerate(tokens): - if int(v) > min_version[i]: - return - i = len(tokens) - 1 - if min_version[i] > int(tokens[i]): - raise Exception("Minimum FilterPy version supported is {}.{}.{}.\n" + import filterpy + from distutils.version import LooseVersion + + v = filterpy.__version__ + min_version = "0.1.0" + if LooseVersion(v) < LooseVersion(min_version): + raise Exception("Minimum FilterPy version supported is {}.\n" "Please install a more recent version.\n" " ex: pip install filterpy --upgrade".format( - *min_version)) - v = int(tokens[0]*1000) + min_version)) # ensure that we have the correct filterpy loaded. This is