11from __future__ import division
22
3+ import warnings
34import numpy as np
45from scipy .integrate import dblquad , simps
56
@@ -25,13 +26,13 @@ def integrate(self): pass
2526
2627
2728class Boundary :
28- _boundary = 0.0 ;
29+ _boundary = 0.0
2930
30- def __init__ (self ,boundary ):
31- self ._boundary = boundary ;
31+ def __init__ (self , boundary ):
32+ self ._boundary = boundary
3233
33- def __call__ (self ,x ):
34- return self ._boundary ;
34+ def __call__ (self , x ):
35+ return self ._boundary
3536
3637
3738class DblquadIntegrator (Integrator ):
@@ -50,10 +51,12 @@ def integrate(self, Q):
5051 rDispersion = RealDispersion (self .distribution , self .detuning , Q )
5152 iDispersion = ImaginaryDispersion (self .distribution , self .detuning , Q )
5253
53- realPart , realErr = dblquad (rDispersion , self .minJx , self .maxJx ,
54- self .minJy , self .maxJy )
55- imagPart , imagErr = dblquad (iDispersion , self .minJx , self .maxJx ,
56- self .minJy , self .maxJy )
54+ realPart , realErr = dblquad (rDispersion ,
55+ self .minJx , self .maxJx ,
56+ self .minJy , self .maxJy )
57+ imagPart , imagErr = dblquad (iDispersion ,
58+ self .minJx , self .maxJx ,
59+ self .minJy , self .maxJy )
5760
5861 return - 1.0 / complex (realPart , imagPart )
5962
@@ -64,17 +67,23 @@ def __init__(self, *args, **kwargs):
6467
6568 super (SimpsonIntegrator , self ).__init__ (* args , ** kwargs )
6669
67- if 'n_steps' not in kwargs : kwargs ['n_steps' ] = 2000
68- self .jx = np .linspace (self .minJx , self .maxJx , kwargs ['n_steps' ])
69- self .jy = np .linspace (self .minJy , self .maxJy , kwargs ['n_steps' ])
70+ if 'n_steps' not in kwargs :
71+ kwargs ['n_steps' ] = 1000
72+ n_steps = kwargs ['n_steps' ]
73+ self .jx = np .linspace (self .minJx , self .maxJx , n_steps )
74+ self .jy = np .linspace (self .minJy , self .maxJy , n_steps )
7075 self .JX , self .JY = np .meshgrid (self .jx , self .jy )
7176
7277 def integrate (self , Q , epsilon = 1e-6 ):
7378
74- # dd = Dispersion(self.distribution, self.detuning, Q, epsilon=epsilon).getValue(self.JX, self.JY)
75- dd = np .array ([[
76- Dispersion (self .distribution , self .detuning , Q , epsilon = epsilon ).getValue (x , y )
77- for y in self .jy ] for x in self .jx ])
79+ dd = Dispersion (
80+ self .distribution , self .detuning , Q , epsilon = epsilon
81+ ).getValue (self .JX , self .JY )
82+ # dd = np.array([[
83+ # Dispersion(
84+ # self.distribution, self.detuning, Q, epsilon=epsilon
85+ # ).getValue(x, y)
86+ # for y in self.jy] for x in self.jx])
7887
7988 return - 1. / simps (simps (dd , self .jx ), self .jy )
8089
@@ -85,20 +94,33 @@ def __init__(self, *args, **kwargs):
8594
8695 super (TrapzIntegrator , self ).__init__ (* args , ** kwargs )
8796
88- if 'n_steps' not in kwargs : kwargs ['n_steps' ] = 1000
89- self .jx = np .linspace (self .minJx , self .maxJx , kwargs ['n_steps' ])
90- self .jy = np .linspace (self .minJy , self .maxJy , kwargs ['n_steps' ])
97+ if 'n_steps' not in kwargs :
98+ kwargs ['n_steps' ] = 1000
99+ n_steps = 1000
100+ self .jx = np .linspace (self .minJx , self .maxJx , n_steps )
101+ self .jy = np .linspace (self .minJy , self .maxJy , n_steps )
91102 self .JX , self .JY = np .meshgrid (self .jx , self .jy )
92103
93104 def integrate (self , Q , epsilon = 1e-6 ):
94105
95- dd = Dispersion (self .distribution , self .detuning , Q , epsilon = epsilon ).getValue (self .JX , self .JY )
106+ dd = Dispersion (
107+ self .distribution , self .detuning , Q , epsilon = epsilon
108+ ).getValue (self .JX , self .JY )
109+
96110 return - 1. / np .trapz (np .trapz (dd , self .jx ), self .jy )
97111
98112
99113class FixedTrapezoidalIntegrator (Integrator ):
100114
101- def __init__ (self , distribution = None , detuning = None , minJ = 0 , maxJ = 18 , nStep = 2000 ):
115+ def __init__ (self , distribution = None , detuning = None ,
116+ minJ = 0 , maxJ = 18 , nStep = 2000 ):
117+ warnings .simplefilter ('always' , DeprecationWarning )
118+ warnings .warn ('Class "{:s}" ' .format (self .__name__ ) +
119+ 'is deprecated and will be replaced in the ' +
120+ 'near future.' ,
121+ category = DeprecationWarning , stacklevel = 2 )
122+ warnings .simplefilter ('default' , DeprecationWarning )
123+
102124 self ._distribution = distribution
103125 self ._detuning = detuning
104126 self ._minJx = minJ
@@ -158,7 +180,14 @@ class AdaptiveRectangularIntegrator(Integrator):
158180 _arrayY = None ;
159181
160182
161- def __init__ (self ,distribution ,detuning ,minJ = 0.0 ,maxJ = 18.0 ):
183+ def __init__ (self , distribution , detuning , minJ = 0.0 , maxJ = 18.0 ):
184+ warnings .simplefilter ('always' , DeprecationWarning )
185+ warnings .warn ('Class "{:s}" ' .format (self .__name__ ) +
186+ 'is deprecated and will be replaced in the ' +
187+ 'near future.' ,
188+ category = DeprecationWarning , stacklevel = 2 )
189+ warnings .simplefilter ('default' , DeprecationWarning )
190+
162191 self ._distribution = distribution ;
163192 self ._detuning = detuning ;
164193 self ._minJx = minJ ;
0 commit comments