From 2542dfffbe21eb2a29fe3b1f482da665267e77df Mon Sep 17 00:00:00 2001 From: Matthew Wardrop Date: Mon, 7 Dec 2015 16:44:46 +1100 Subject: [PATCH] Use python3 print statements more globally, and neaten exception syntax. --- parampy/iteration.py | 1 - parampy/parameters.pyx | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/parampy/iteration.py b/parampy/iteration.py index 4c26a39..ae2e1be 100644 --- a/parampy/iteration.py +++ b/parampy/iteration.py @@ -1,5 +1,4 @@ import sys -import multiprocessing import threading import resource import datetime diff --git a/parampy/parameters.pyx b/parampy/parameters.pyx index d1119e7..263af18 100644 --- a/parampy/parameters.pyx +++ b/parampy/parameters.pyx @@ -1,3 +1,5 @@ +from __future__ import print_function + from . import errors from . import physical_constants from .definitions import SIUnitDispenser @@ -1017,7 +1019,7 @@ class Parameters(object): f = sympy.utilities.lambdify(syms, expr, dummify=False, modules=['numpy','mpmath','math','sympy']) return f except Exception, e: - print e + print(e) raise errors.SymbolicEvaluationError('String \'%s\' is not a valid symbolic expression.' % (expr)) def __get_function(self, expr): @@ -1104,7 +1106,7 @@ class Parameters(object): def __getattr__(self, name): if name[:2] == "__" or name[:11] == "_Parameters": - raise AttributeError + raise AttributeError() return self.__get_param(name) def __setattr__(self, attr, value): @@ -1209,7 +1211,7 @@ class Parameters(object): if param not in self.__parameters: parameters.append([colour_text(param, 'CYAN'), colour_text("- %s" % self.__parameters_spec[param], 'CYAN'), colour_text("-", 'CYAN')]) - print self.__table(parameters) + print(self.__table(parameters)) ################## PARAMETER BOUNDS #################################### @@ -1619,7 +1621,7 @@ class Parameters(object): units[param] = self.__parameters_spec.get(param, None) if len(params)==1 and not use_dict: - return units[units.keys()[0]] + return units[list(units.keys())[0]] return units def convert(self, quantity, input=None, output=None, value=True): @@ -1877,7 +1879,7 @@ class Parameters(object): try: import matplotlib.pyplot as plt except: - print colour_text("Matplotlib is required for plotting features.", "RED", True) + print(colour_text("Matplotlib is required for plotting features.", "RED", True)) return if len(params) == 0: