From ef52fca5384275dac58be53c159345be23d47196 Mon Sep 17 00:00:00 2001 From: Florent Jaillet <florent.jaillet@lif.univ-mrs.fr> Date: Tue, 2 Aug 2016 14:38:10 +0200 Subject: [PATCH] Modify fractions.gcd() import in lcm due to deprecation in Python 3.5 According to the documentation of Python 3.5, the function fractions.gcd() is deprecated and should be replaced by math.gcd(). So we modify the import of gcd() in lcm.py to import it from the math module when possible, keeping the import from the fractions module if not possible in order to keep the compatibility with older versions of Python. --- ltfatpy/tools/lcm.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ltfatpy/tools/lcm.py b/ltfatpy/tools/lcm.py index 2618c9c..93af7f2 100644 --- a/ltfatpy/tools/lcm.py +++ b/ltfatpy/tools/lcm.py @@ -6,8 +6,14 @@ from __future__ import print_function, division -from fractions import gcd from math import copysign +try: + from math import gcd +except ImportError: + # fractions.gcd() is deprecated since Python 3.5 and math.gcd() should be + # used instead, but for backward compatibilty we use fractions.gcd() if + # math.gcd() is not available + from fractions import gcd def lcm(X, Y): -- GitLab