Skip to content

Commit

Permalink
Python 3 compatibility
Browse files Browse the repository at this point in the history
use now print() function (even in notebook)
  • Loading branch information
nikolasibalic committed Jan 11, 2017
1 parent 16adc37 commit b6413a1
Show file tree
Hide file tree
Showing 9 changed files with 44,780 additions and 39,111 deletions.
8 changes: 4 additions & 4 deletions arc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Google-style docstrings are used for documenting code
# for more on those, see http://www.sphinx-doc.org/en/stable/ext/example_google.html#example-google
# this is automatically parsed by Aphinx module in Python, using napoleon addon
from __future__ import division
from __future__ import division, print_function, absolute_import

from alkali_atom_data import *
from calculations_atom_single import *
from calculations_atom_pairstate import *
from .alkali_atom_data import *
from .calculations_atom_single import *
from .calculations_atom_pairstate import *
4 changes: 2 additions & 2 deletions arc/alkali_atom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
------
"""

from __future__ import print_function
from __future__ import division, print_function, absolute_import

from alkali_atom_functions import *
from .alkali_atom_functions import *


class Hydrogen(AlkaliAtom):
Expand Down
52 changes: 22 additions & 30 deletions arc/alkali_atom_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from __future__ import print_function
from __future__ import division, print_function, absolute_import

from math import exp,log,sqrt
# for web-server execution, uncomment the following two lines
Expand All @@ -22,7 +22,7 @@
import numpy as np
import re
#from algebra_nikola import *
from wigner import Wigner6j,Wigner3j,wignerD,CG,wignerDmatrix
from .wigner import Wigner6j,Wigner3j,wignerD,CG,wignerDmatrix
from scipy.constants import physical_constants,pi,k,c,h,epsilon_0,hbar
from scipy.constants import e as elemCharge
from scipy.optimize import curve_fit
Expand All @@ -42,6 +42,8 @@
from scipy import floor
#from scipy.integrate import ode
import sys
if sys.version_info > (2,):
xrange = range

# for calling C++ Numerov
import shlex
Expand All @@ -54,7 +56,10 @@
#from nbconvert.exporters.exporter import FilenameExtension
# END of modules for online (server) execution

import cPickle as pickle # fast, C implementation of the pickle
try:
import cPickle as pickle # fast, C implementation of the pickle
except:
import pickle
import gzip

import csv
Expand Down Expand Up @@ -707,10 +712,15 @@ def getRadialMatrixElement(self,n1,l1,j1,n2,l2,j2,useLiterature=True):
j1 = j2
j2 = temp

n1 = int(n1)
n2 = int(n2)
l1 = int(l1)
l2 = int(l2)
j1_x2 = int(round(2*j1))
j2_x2 = int(round(2*j2))

if useLiterature:
# is there literature value for this DME? If there is, use the best one (smalles error)
j1_x2 = 2*j1
j2_x2 = 2*j2
self.c.execute('''SELECT dme FROM literatureDME WHERE
n1= ? AND l1 = ? AND j1_x2 = ? AND
n2 = ? AND l2 = ? AND j2_x2 = ?
Expand All @@ -722,8 +732,6 @@ def getRadialMatrixElement(self,n1,l1,j1,n2,l2,j2,useLiterature=True):


# was this calculated before? If it was, retrieve from memory
j1_x2 = 2*j1
j2_x2 = 2*j2
self.c.execute('''SELECT dme FROM dipoleME WHERE
n1= ? AND l1 = ? AND j1_x2 = ? AND
n2 = ? AND l2 = ? AND j2_x2 = ?''',(n1,l1,j1_x2,n2,l2,j2_x2))
Expand Down Expand Up @@ -753,17 +761,6 @@ def getRadialMatrixElement(self,n1,l1,j1,n2,l2,j2,useLiterature=True):
self.c.execute(''' INSERT INTO dipoleME VALUES (?,?,?, ?,?,?, ?)''',\
[n1,l1,j1_x2,n2,l2,j2_x2, dipoleElement] )
self.conn.commit()


# with dipoleMatrixElement as numpy array
#if (len(self.dipoleMatrixElement)>0):
# self.dipoleMatrixElement = np.concatenate( (self.dipoleMatrixElement,\
# np.array([[n1,l1,j1,n2,\
# l2,j2,\
# dipoleElement]])),\
# axis=0)
#else:
# self.dipoleMatrixElement = np.array([[n1,l1,j1,n2,l2,j2,dipoleElement]])

return dipoleElement

Expand Down Expand Up @@ -808,9 +805,14 @@ def getQuadrupoleMatrixElement(self,n1,l1,j1,n2,l2,j2):
j1 = j2
j2 = temp

n1 = int(n1)
n2 = int(n2)
l1 = int(l1)
l2 = int(l2)
j1_x2 = int(round(2*j1))
j2_x2 = int(round(2*j2))

# was this calculated before? If yes, retrieve from memory.
j1_x2 = 2*j1
j2_x2 = 2*j2
self.c.execute('''SELECT qme FROM quadrupoleME WHERE
n1= ? AND l1 = ? AND j1_x2 = ? AND
n2 = ? AND l2 = ? AND j2_x2 = ?''',(n1,l1,j1_x2,n2,l2,j2_x2))
Expand Down Expand Up @@ -848,16 +850,6 @@ def getQuadrupoleMatrixElement(self,n1,l1,j1,n2,l2,j2):
[n1,l1,j1_x2,n2,l2,j2_x2, quadrupoleElement] )
self.conn.commit()

#if (len(self.quadrupoleMatrixElement)>0):
# self.quadrupoleMatrixElement = np.concatenate((self.quadrupoleMatrixElement,
# np.array([[n1,l1,j1,\
# n2,l2,j2,\
# quadrupoleElement]])),\
# axis=0)
#else:
# self.quadrupoleMatrixElement = np.array([[n1,l1,j1,n2,l2,j2,\
# quadrupoleElement]])

return quadrupoleElement


Expand Down
14 changes: 9 additions & 5 deletions arc/calculations_atom_pairstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"""

from __future__ import print_function
from __future__ import division, print_function, absolute_import

from math import exp,log,sqrt
import matplotlib.pyplot as plt
Expand All @@ -44,7 +44,7 @@

import numpy as np
import re
from wigner import Wigner6j,Wigner3j,CG,wignerDmatrix
from .wigner import Wigner6j,Wigner3j,CG,wignerDmatrix
from scipy.constants import physical_constants,pi,k,c,h,epsilon_0,hbar
from scipy.constants import e as elemCharge
from scipy.optimize import curve_fit
Expand All @@ -60,13 +60,17 @@
from scipy import floor

#from scipy.integrate import ode
from alkali_atom_functions import *
from alkali_atom_functions import _EFieldCoupling,_atomLightAtomCoupling
from calculations_atom_single import StarkMap
from .alkali_atom_functions import *
from .alkali_atom_functions import _EFieldCoupling,_atomLightAtomCoupling
from .calculations_atom_single import StarkMap

from matplotlib.colors import LinearSegmentedColormap
import matplotlib

import sys
if sys.version_info > (2,):
xrange = range

import gzip

class PairStateInteractions:
Expand Down
6 changes: 4 additions & 2 deletions arc/calculations_atom_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import numpy as np
import re
#from algebra_nikola import *
from wigner import Wigner6j,Wigner3j,CG
from .wigner import Wigner6j,Wigner3j,CG
from scipy.constants import physical_constants,pi,k,c,h,epsilon_0,hbar
from scipy.constants import e as elemCharge
from scipy.optimize import curve_fit
Expand All @@ -45,7 +45,9 @@
#from scipy.integrate import ode

import sys
from alkali_atom_functions import printStateString, _EFieldCoupling, printStateLetter,printStateStringLatex
if sys.version_info > (2,):
xrange = range
from .alkali_atom_functions import printStateString, _EFieldCoupling, printStateLetter,printStateStringLatex

from matplotlib.colors import LinearSegmentedColormap
import matplotlib
Expand Down
2 changes: 1 addition & 1 deletion arc/wigner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import division, print_function
from __future__ import division, print_function, absolute_import
from scipy import floor, sqrt
from scipy.misc import factorial
from numpy import arange
Expand Down
Loading

0 comments on commit b6413a1

Please sign in to comment.