From 6b8fc67268181dacffe0de8e47ba972ea125ca49 Mon Sep 17 00:00:00 2001 From: Steven Byrnes Date: Mon, 16 May 2016 21:37:47 -0400 Subject: [PATCH] fix imports for python 2+3 compatibility All files now use "from __future__ import absolute_import" --- colorpy/blackbody.py | 6 +++--- colorpy/ciexyz.py | 4 +++- colorpy/figures.py | 11 ++++------- colorpy/illuminants.py | 6 +++--- colorpy/misc.py | 6 +++--- colorpy/plots.py | 5 ++--- colorpy/rayleigh.py | 8 +++----- colorpy/test.py | 10 +++------- colorpy/test_blackbody.py | 5 ++--- colorpy/test_ciexyz.py | 4 ++-- colorpy/test_colormodels.py | 5 ++--- colorpy/test_illuminants.py | 4 ++-- colorpy/test_rayleigh.py | 6 ++---- colorpy/test_thinfilm.py | 5 ++--- colorpy/thinfilm.py | 7 +++---- 15 files changed, 39 insertions(+), 53 deletions(-) diff --git a/colorpy/blackbody.py b/colorpy/blackbody.py index 16da3ae..9152a1a 100644 --- a/colorpy/blackbody.py +++ b/colorpy/blackbody.py @@ -67,13 +67,13 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' +from __future__ import absolute_import + import math import numpy import pylab -import colormodels -import ciexyz -import plots +from . import colormodels, ciexyz, plots # Physical constants in mks units PLANCK_CONSTANT = 6.6237e-34 # J-sec diff --git a/colorpy/ciexyz.py b/colorpy/ciexyz.py index 7ebb5b6..557e6f0 100644 --- a/colorpy/ciexyz.py +++ b/colorpy/ciexyz.py @@ -116,9 +116,11 @@ def get_normalized_spectral_line_colors ( You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' +from __future__ import absolute_import + import math, numpy -import colormodels +from . import colormodels # Assumed physical brightness of the monitor [W/m^2] # 80 cd/m^2 * 20.3 mW/cd (assuming light at 556 nm) diff --git a/colorpy/figures.py b/colorpy/figures.py index d212d0d..30b1331 100644 --- a/colorpy/figures.py +++ b/colorpy/figures.py @@ -42,13 +42,10 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -import colormodels -import illuminants -import plots -import blackbody -import rayleigh -import thinfilm -import misc +from __future__ import absolute_import + +from . import (colormodels, illuminants, plots, blackbody, rayleigh, + thinfilm, misc) def figures (): '''Create all the ColorPy sample figures.''' diff --git a/colorpy/illuminants.py b/colorpy/illuminants.py index 3a95378..2f5e88a 100644 --- a/colorpy/illuminants.py +++ b/colorpy/illuminants.py @@ -88,9 +88,9 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -import ciexyz -import blackbody -import plots +from __future__ import absolute_import + +from . import ciexyz, blackbody, plots # table of CIE Illuminant D65 spectrum. # data from: http://cvrl.ioo.ucl.ac.uk/database/data/cie/Illuminantd65.txt diff --git a/colorpy/misc.py b/colorpy/misc.py index aa1eb81..b5fd37b 100644 --- a/colorpy/misc.py +++ b/colorpy/misc.py @@ -61,11 +61,11 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' +from __future__ import absolute_import + import math, numpy -import colormodels -import ciexyz -import plots +from . import colormodels, ciexyz, plots # Some sample lists of displayable RGB colors as hex strings diff --git a/colorpy/plots.py b/colorpy/plots.py index 6ee288c..1af162d 100644 --- a/colorpy/plots.py +++ b/colorpy/plots.py @@ -121,13 +121,12 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import math import numpy, pylab -import colormodels -import ciexyz +from . import colormodels, ciexyz # Miscellaneous utilities for plots diff --git a/colorpy/rayleigh.py b/colorpy/rayleigh.py index 6c412bc..4b2d83b 100644 --- a/colorpy/rayleigh.py +++ b/colorpy/rayleigh.py @@ -62,14 +62,12 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' +from __future__ import absolute_import + import math import numpy, pylab -import colormodels -import ciexyz -import illuminants -import blackbody -import plots +from . import colormodels, ciexyz, illuminants, blackbody, plots def rayleigh_scattering (wl_nm): '''Get the Rayleigh scattering factor for the wavelength. diff --git a/colorpy/test.py b/colorpy/test.py index f827029..181e29e 100644 --- a/colorpy/test.py +++ b/colorpy/test.py @@ -27,16 +27,12 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import unittest -import test_colormodels -import test_ciexyz -import test_illuminants -import test_blackbody -import test_rayleigh -import test_thinfilm +from . import (test_colormodels, test_ciexyz, test_illuminants, + test_blackbody, test_rayleigh, test_thinfilm) def test (): # no test cases for plots/misc - but figures.py will exercise those. diff --git a/colorpy/test_blackbody.py b/colorpy/test_blackbody.py index f4c7ef6..09f10ab 100644 --- a/colorpy/test_blackbody.py +++ b/colorpy/test_blackbody.py @@ -22,14 +22,13 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import math import numpy import unittest -import blackbody -import colormodels +from . import blackbody, colormodels # FIXME: The following calculation is not working currently. # It is an attempt to get the scale of the intensity correct. diff --git a/colorpy/test_ciexyz.py b/colorpy/test_ciexyz.py index 75fdd56..c9fc153 100644 --- a/colorpy/test_ciexyz.py +++ b/colorpy/test_ciexyz.py @@ -22,12 +22,12 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import random import unittest -import ciexyz +from . import ciexyz class TestCiexyz(unittest.TestCase): diff --git a/colorpy/test_colormodels.py b/colorpy/test_colormodels.py index 8d01d66..0ab88fb 100644 --- a/colorpy/test_colormodels.py +++ b/colorpy/test_colormodels.py @@ -22,13 +22,12 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import math, random, numpy import unittest -import colormodels -import ciexyz +from . import colormodels, ciexyz # Functions to calculate the cutoff point between various algorithms. # These do not really belong here... diff --git a/colorpy/test_illuminants.py b/colorpy/test_illuminants.py index e0908e7..43f6460 100644 --- a/colorpy/test_illuminants.py +++ b/colorpy/test_illuminants.py @@ -22,11 +22,11 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import unittest -import illuminants +from . import illuminants class TestIlluminants(unittest.TestCase): diff --git a/colorpy/test_rayleigh.py b/colorpy/test_rayleigh.py index da7bbff..426d8f6 100644 --- a/colorpy/test_rayleigh.py +++ b/colorpy/test_rayleigh.py @@ -22,16 +22,14 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import math import numpy import random import unittest -import ciexyz -import rayleigh -import illuminants +from . import ciexyz, rayleigh, illuminants class TestRayleigh(unittest.TestCase): diff --git a/colorpy/test_thinfilm.py b/colorpy/test_thinfilm.py index 6748497..56ba919 100644 --- a/colorpy/test_thinfilm.py +++ b/colorpy/test_thinfilm.py @@ -22,13 +22,12 @@ You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' -from __future__ import print_function +from __future__ import print_function, absolute_import import random import unittest -import illuminants -import thinfilm +from . import illuminants, thinfilm class TestThinFilm(unittest.TestCase): diff --git a/colorpy/thinfilm.py b/colorpy/thinfilm.py index 847eb30..b470ee8 100644 --- a/colorpy/thinfilm.py +++ b/colorpy/thinfilm.py @@ -82,12 +82,11 @@ class thin_film (n1, n2, n3, thickness_nm) - You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see . ''' +from __future__ import absolute_import + import math, cmath, numpy -import colormodels -import ciexyz -import illuminants -import plots +from . import colormodels, ciexyz, illuminants, plots class thin_film: '''A thin film of dielectric material.'''