From 6e9d5c3cfb4cdc1ef14c6f87a7ff06670cbb4c8f Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 22 May 2014 01:30:15 -0400 Subject: [PATCH] Python 3 fixes for new demos --- examples/optics/__init__.py | 2 +- examples/optics/pyoptic.py | 6 +++--- examples/verlet_chain/__init__.py | 2 +- examples/verlet_chain/chain.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/optics/__init__.py b/examples/optics/__init__.py index 577c24da..b3d31cd0 100644 --- a/examples/optics/__init__.py +++ b/examples/optics/__init__.py @@ -1 +1 @@ -from pyoptic import * \ No newline at end of file +from .pyoptic import * \ No newline at end of file diff --git a/examples/optics/pyoptic.py b/examples/optics/pyoptic.py index 486f653d..dc493568 100644 --- a/examples/optics/pyoptic.py +++ b/examples/optics/pyoptic.py @@ -14,7 +14,7 @@ class GlassDB: def __init__(self, fileName='schott_glasses.csv'): path = os.path.dirname(__file__) fh = gzip.open(os.path.join(path, 'schott_glasses.csv.gz'), 'rb') - r = csv.reader(fh.readlines()) + r = csv.reader(map(str, fh.readlines())) lines = [x for x in r] self.data = {} header = lines[0] @@ -47,8 +47,8 @@ class GlassDB: info = self.data[glass] cache = info['ior_cache'] if wl not in cache: - B = map(float, [info['B1'], info['B2'], info['B3']]) - C = map(float, [info['C1'], info['C2'], info['C3']]) + B = list(map(float, [info['B1'], info['B2'], info['B3']])) + C = list(map(float, [info['C1'], info['C2'], info['C3']])) w2 = (wl/1000.)**2 n = np.sqrt(1.0 + (B[0]*w2 / (w2-C[0])) + (B[1]*w2 / (w2-C[1])) + (B[2]*w2 / (w2-C[2]))) cache[wl] = n diff --git a/examples/verlet_chain/__init__.py b/examples/verlet_chain/__init__.py index abd9e103..f473190f 100644 --- a/examples/verlet_chain/__init__.py +++ b/examples/verlet_chain/__init__.py @@ -1 +1 @@ -from chain import ChainSim \ No newline at end of file +from .chain import ChainSim \ No newline at end of file diff --git a/examples/verlet_chain/chain.py b/examples/verlet_chain/chain.py index 9671e0a5..896505ac 100644 --- a/examples/verlet_chain/chain.py +++ b/examples/verlet_chain/chain.py @@ -1,7 +1,7 @@ import pyqtgraph as pg import numpy as np import time -from relax import relax +from .relax import relax class ChainSim(pg.QtCore.QObject):