syned 1.0.44__tar.gz → 1.0.45__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {syned-1.0.44/syned.egg-info → syned-1.0.45}/PKG-INFO +1 -1
- {syned-1.0.44 → syned-1.0.45}/setup.py +1 -1
- syned-1.0.45/syned/__test/__init__.py +46 -0
- syned-1.0.45/syned/__test/test.py +28 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/electron_beam.py +53 -39
- {syned-1.0.44 → syned-1.0.45}/syned/syned_object.py +0 -10
- syned-1.0.45/syned/util/__init__.py +22 -0
- {syned-1.0.44 → syned-1.0.45/syned.egg-info}/PKG-INFO +1 -1
- {syned-1.0.44 → syned-1.0.45}/syned.egg-info/SOURCES.txt +2 -0
- syned-1.0.44/syned/widget/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/LICENSE +0 -0
- {syned-1.0.44 → syned-1.0.45}/MANIFEST.in +0 -0
- {syned-1.0.44 → syned-1.0.45}/README.rst +0 -0
- {syned-1.0.44 → syned-1.0.45}/setup.cfg +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/beamline.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/beamline_element.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/element_coordinates.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_element.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_element_with_surface_shape.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/absorber.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/beam_stopper.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/filter.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/holed_filter.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/slit.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/crystals/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/crystals/crystal.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/gratings/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/gratings/grating.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_element.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_fzp.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_lens.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/screen.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/mirrors/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/mirrors/mirror.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/refractors/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/refractors/crl.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/refractors/interface.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/refractors/lens.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/beamline/shape.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/empty_light_source.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/light_source.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/magnetic_structure.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/magnetic_structures/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/magnetic_structures/bending_magnet.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/magnetic_structures/insertion_device.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/magnetic_structures/undulator.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/storage_ring/magnetic_structures/wiggler.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/util/json_tools.py +0 -0
- {syned-1.0.44/syned/util → syned-1.0.45/syned/widget}/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned/widget/widget_decorator.py +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned.egg-info/dependency_links.txt +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned.egg-info/not-zip-safe +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned.egg-info/requires.txt +0 -0
- {syned-1.0.44 → syned-1.0.45}/syned.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2025, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2025. UChicago Argonne, LLC. This software was produced #
|
|
7
|
+
# under U.S. Government contract DE-AC02-06CH11357 for Argonne National #
|
|
8
|
+
# Laboratory (ANL), which is operated by UChicago Argonne, LLC for the #
|
|
9
|
+
# U.S. Department of Energy. The U.S. Government has rights to use, #
|
|
10
|
+
# reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR #
|
|
11
|
+
# UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR #
|
|
12
|
+
# ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is #
|
|
13
|
+
# modified to produce derivative works, such modified software should #
|
|
14
|
+
# be clearly marked, so as not to confuse it with the version available #
|
|
15
|
+
# from ANL. #
|
|
16
|
+
# #
|
|
17
|
+
# Additionally, redistribution and use in source and binary forms, with #
|
|
18
|
+
# or without modification, are permitted provided that the following #
|
|
19
|
+
# conditions are met: #
|
|
20
|
+
# #
|
|
21
|
+
# * Redistributions of source code must retain the above copyright #
|
|
22
|
+
# notice, this list of conditions and the following disclaimer. #
|
|
23
|
+
# #
|
|
24
|
+
# * Redistributions in binary form must reproduce the above copyright #
|
|
25
|
+
# notice, this list of conditions and the following disclaimer in #
|
|
26
|
+
# the documentation and/or other materials provided with the #
|
|
27
|
+
# distribution. #
|
|
28
|
+
# #
|
|
29
|
+
# * Neither the name of UChicago Argonne, LLC, Argonne National #
|
|
30
|
+
# Laboratory, ANL, the U.S. Government, nor the names of its #
|
|
31
|
+
# contributors may be used to endorse or promote products derived #
|
|
32
|
+
# from this software without specific prior written permission. #
|
|
33
|
+
# #
|
|
34
|
+
# THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS #
|
|
35
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
|
|
36
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS #
|
|
37
|
+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago #
|
|
38
|
+
# Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, #
|
|
39
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, #
|
|
40
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #
|
|
41
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
|
|
42
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
|
|
43
|
+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN #
|
|
44
|
+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
|
|
45
|
+
# POSSIBILITY OF SUCH DAMAGE. #
|
|
46
|
+
# ----------------------------------------------------------------------- #
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import traceback
|
|
2
|
+
import warnings
|
|
3
|
+
warnings.simplefilter("always")
|
|
4
|
+
|
|
5
|
+
from syned.storage_ring.electron_beam import ElectronBeam
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
a = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,
|
|
9
|
+
current=0.2,
|
|
10
|
+
energy_spread=0.00095,
|
|
11
|
+
moment_xx =1.0,
|
|
12
|
+
moment_xxp =1.0,
|
|
13
|
+
moment_xpxp =1.0,
|
|
14
|
+
moment_yy =1.0,
|
|
15
|
+
moment_yyp =1.0,
|
|
16
|
+
moment_ypyp =1.0,
|
|
17
|
+
dispersion_x =1.0,
|
|
18
|
+
dispersion_y =1.0,
|
|
19
|
+
dispersionp_x=1.0,
|
|
20
|
+
dispersionp_y=1.0)
|
|
21
|
+
a.set_twiss_horizontal (0, 0, 0)
|
|
22
|
+
a.set_twiss_vertical (0, 1, 1, eta_y=2.0, etap_y=3.0)
|
|
23
|
+
|
|
24
|
+
print(a.info())
|
|
25
|
+
|
|
26
|
+
print(a.get_twiss_no_dispersion_all())
|
|
27
|
+
except:
|
|
28
|
+
traceback.print_exc()
|
|
@@ -4,9 +4,13 @@ Base class for electron beams.
|
|
|
4
4
|
This class is intentionally shorten for simplicity.
|
|
5
5
|
Usually we would need to consider also the electron distribution within the beam.
|
|
6
6
|
"""
|
|
7
|
-
from syned.syned_object import SynedObject
|
|
8
7
|
import scipy.constants as codata
|
|
9
8
|
import numpy
|
|
9
|
+
import warnings
|
|
10
|
+
|
|
11
|
+
from syned.util import deprecated
|
|
12
|
+
from syned.syned_object import SynedObject
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class ElectronBeam(SynedObject):
|
|
12
16
|
def __init__(self,
|
|
@@ -136,17 +140,27 @@ class ElectronBeam(SynedObject):
|
|
|
136
140
|
@classmethod
|
|
137
141
|
def _get_twiss_from_moments(cls, moment_ss, moment_sa, moment_aa):
|
|
138
142
|
emittance = cls._emittance_without_dispersion(moment_ss, moment_sa, moment_aa)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
if emittance == 0.0:
|
|
144
|
+
warnings.warn(message="All moments are 0.0 and the calculation is not possible. \u03b5 = \u03b1 = \u03b2 = \u03b3 = 0.0 is returned.",
|
|
145
|
+
category=UserWarning, stacklevel=2)
|
|
146
|
+
return 0.0, 0.0, 0.0, 0.0
|
|
147
|
+
else:
|
|
148
|
+
alpha = -moment_sa / emittance
|
|
149
|
+
beta = moment_ss / emittance
|
|
150
|
+
gamma = (1 + alpha**2) / beta
|
|
142
151
|
|
|
143
|
-
|
|
152
|
+
alpha = 0.0 if alpha == 0 else alpha # to avoid -0.0
|
|
144
153
|
|
|
145
|
-
|
|
154
|
+
return emittance, alpha, beta, gamma
|
|
146
155
|
|
|
147
156
|
@classmethod
|
|
148
157
|
def _get_moments_from_twiss_without_dispersion(cls, emittance, alpha, beta):
|
|
149
|
-
|
|
158
|
+
if beta == 0:
|
|
159
|
+
warnings.warn(message="With \u03b2 = 0.0 the calculation of \u03b3 is not possible. \u03b3 = 0.0 is used.",
|
|
160
|
+
category=UserWarning, stacklevel=2)
|
|
161
|
+
gamma = 0.0
|
|
162
|
+
else:
|
|
163
|
+
gamma = (1 + alpha ** 2) / beta
|
|
150
164
|
|
|
151
165
|
moment_ss = beta * emittance
|
|
152
166
|
moment_sa = -alpha * emittance
|
|
@@ -168,7 +182,7 @@ class ElectronBeam(SynedObject):
|
|
|
168
182
|
# --- GETTERS
|
|
169
183
|
# # ---------------------------------------------------------------------------------------------------------------------------------------------
|
|
170
184
|
#
|
|
171
|
-
def get_sigmas_horizontal(self, dispersion=
|
|
185
|
+
def get_sigmas_horizontal(self, dispersion=True):
|
|
172
186
|
"""
|
|
173
187
|
Returns the sigmas in horizontal direction.
|
|
174
188
|
|
|
@@ -183,7 +197,7 @@ class ElectronBeam(SynedObject):
|
|
|
183
197
|
|
|
184
198
|
return numpy.sqrt(moment_xx), numpy.sqrt(moment_xpxp)
|
|
185
199
|
|
|
186
|
-
def get_sigmas_vertical(self, dispersion=
|
|
200
|
+
def get_sigmas_vertical(self, dispersion=True):
|
|
187
201
|
"""
|
|
188
202
|
Returns the sigmas in vertical direction.
|
|
189
203
|
|
|
@@ -197,7 +211,7 @@ class ElectronBeam(SynedObject):
|
|
|
197
211
|
|
|
198
212
|
return numpy.sqrt(moment_yy), numpy.sqrt(moment_ypyp)
|
|
199
213
|
|
|
200
|
-
def get_sigmas_all(self, dispersion=
|
|
214
|
+
def get_sigmas_all(self, dispersion=True):
|
|
201
215
|
"""
|
|
202
216
|
Returns all sigmas.
|
|
203
217
|
|
|
@@ -213,7 +227,7 @@ class ElectronBeam(SynedObject):
|
|
|
213
227
|
|
|
214
228
|
return sigma_x, sigmap_x, sigma_y, sigmap_y
|
|
215
229
|
|
|
216
|
-
def get_moments_horizontal(self, dispersion=
|
|
230
|
+
def get_moments_horizontal(self, dispersion=True):
|
|
217
231
|
"""
|
|
218
232
|
Returns the moments in the horizontal direction.
|
|
219
233
|
|
|
@@ -231,7 +245,7 @@ class ElectronBeam(SynedObject):
|
|
|
231
245
|
self._dispersion_x,
|
|
232
246
|
self._dispersionp_x)
|
|
233
247
|
|
|
234
|
-
def get_moments_vertical(self, dispersion=
|
|
248
|
+
def get_moments_vertical(self, dispersion=True):
|
|
235
249
|
"""
|
|
236
250
|
Returns the moments in the vertical direction.
|
|
237
251
|
|
|
@@ -250,7 +264,7 @@ class ElectronBeam(SynedObject):
|
|
|
250
264
|
self._dispersion_y,
|
|
251
265
|
self._dispersionp_y)
|
|
252
266
|
|
|
253
|
-
def get_moments_all(self, dispersion=
|
|
267
|
+
def get_moments_all(self, dispersion=True):
|
|
254
268
|
"""
|
|
255
269
|
Returns all moments.
|
|
256
270
|
|
|
@@ -542,16 +556,16 @@ class ElectronBeam(SynedObject):
|
|
|
542
556
|
self._moment_xpxp = moment_xpxp
|
|
543
557
|
|
|
544
558
|
# RETROCOMPATIBILITY
|
|
545
|
-
eta_x
|
|
546
|
-
etap_x = kwargs.get("etap_x",
|
|
547
|
-
|
|
548
|
-
if eta_x is not None or etap_x is not None:
|
|
549
|
-
self._send_deprectation_warning("Setting dispersion parameters with set_twiss_horizontal(..., eta_x, etap_x)",
|
|
550
|
-
"set_dispersion_horizontal(eta_x, etap_x) separately")
|
|
551
|
-
self.set_dispersion_vertical(0.0 if eta_x is None else eta_x,
|
|
552
|
-
0.0 if etap_x is None else etap_x)
|
|
559
|
+
eta_x = kwargs.get("eta_x", 0.0)
|
|
560
|
+
etap_x = kwargs.get("etap_x", 0.0)
|
|
553
561
|
|
|
554
|
-
|
|
562
|
+
if eta_x != 0.0 or etap_x != 0.0:
|
|
563
|
+
warnings.warn(message="Setting dispersion parameters with `set_twiss_horizontal(..., eta_x, etap_x)` is deprecated "
|
|
564
|
+
"and will be removed in a future version. "
|
|
565
|
+
"Use `set_dispersion_horizontal(eta_x, etap_x)` separately instead.",
|
|
566
|
+
category=DeprecationWarning, stacklevel=2)
|
|
567
|
+
self.set_dispersion_horizontal(0.0 if eta_x is None else eta_x,
|
|
568
|
+
0.0 if etap_x is None else etap_x)
|
|
555
569
|
|
|
556
570
|
def set_twiss_vertical(self, emittance_y, alpha_y, beta_y, **kwargs):
|
|
557
571
|
"""
|
|
@@ -578,12 +592,15 @@ class ElectronBeam(SynedObject):
|
|
|
578
592
|
self._moment_ypyp = moment_ypyp
|
|
579
593
|
|
|
580
594
|
# RETROCOMPATIBILITY
|
|
581
|
-
eta_y = kwargs.get("eta_y",
|
|
582
|
-
etap_y = kwargs.get("etap_y",
|
|
595
|
+
eta_y = kwargs.get("eta_y", 0.0)
|
|
596
|
+
etap_y = kwargs.get("etap_y", 0.0)
|
|
597
|
+
|
|
598
|
+
if eta_y != 0.0 or etap_y != 0.0:
|
|
599
|
+
warnings.warn(message="Setting dispersion parameters with `set_twiss_vertical(..., eta_y, etap_y)` is deprecated "
|
|
600
|
+
"and will be removed in a future version. "
|
|
601
|
+
"Use `set_dispersion_vertical(eta_y, etap_y)` separately instead.",
|
|
602
|
+
category=DeprecationWarning, stacklevel=2)
|
|
583
603
|
|
|
584
|
-
if eta_y is not None or etap_y is not None:
|
|
585
|
-
self._send_deprectation_warning("Setting dispersion parameters with set_twiss_vertical(..., eta_y, etap_y)",
|
|
586
|
-
"set_dispersion_vertical(eta_y, etap_y) separately")
|
|
587
604
|
self.set_dispersion_vertical(0.0 if eta_y is None else eta_y,
|
|
588
605
|
0.0 if etap_y is None else etap_y)
|
|
589
606
|
|
|
@@ -646,7 +663,7 @@ class ElectronBeam(SynedObject):
|
|
|
646
663
|
"""
|
|
647
664
|
return numpy.sqrt(1.0 - 1.0 / self.lorentz_factor() ** 2)
|
|
648
665
|
|
|
649
|
-
def emittance(self, dispersion=
|
|
666
|
+
def emittance(self, dispersion=True):
|
|
650
667
|
if not dispersion:
|
|
651
668
|
emittance_x = self._emittance_without_dispersion(self._moment_xx, self._moment_xxp, self._moment_xpxp)
|
|
652
669
|
emittance_y = self._emittance_without_dispersion(self._moment_yy, self._moment_yyp, self._moment_ypyp)
|
|
@@ -668,17 +685,14 @@ class ElectronBeam(SynedObject):
|
|
|
668
685
|
#
|
|
669
686
|
# backcompatibility (deprecated)
|
|
670
687
|
#
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
return self.get_twiss_all()
|
|
688
|
+
@deprecated("Use `get_twiss_all()` instead")
|
|
689
|
+
def get_twiss_no_dispersion_all(self): return self.get_twiss_all()
|
|
674
690
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
return self.get_twiss_horizontal()
|
|
691
|
+
@deprecated("Use `get_twiss_horizontal()` instead")
|
|
692
|
+
def get_twiss_no_dispersion_horizontal(self): return self.get_twiss_horizontal()
|
|
678
693
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return self.get_twiss_vertical()
|
|
694
|
+
@deprecated("Use `get_twiss_vertical()` instead")
|
|
695
|
+
def get_twiss_no_dispersion_vertical(self): return self.get_twiss_vertical()
|
|
682
696
|
|
|
683
697
|
|
|
684
698
|
if __name__ == "__main__":
|
|
@@ -779,10 +793,10 @@ if __name__ == "__main__":
|
|
|
779
793
|
# yyp = 1.0488e-14
|
|
780
794
|
# ypyp = 3.7609e-12
|
|
781
795
|
print("moments (with dispersion): ", a.get_moments_all(dispersion=True))
|
|
782
|
-
print("moments (without dispersion): ", a.get_moments_all(dispersion=
|
|
796
|
+
print("moments (without dispersion): ", a.get_moments_all(dispersion=True))
|
|
783
797
|
# sigma x = 3.1199e-05
|
|
784
798
|
# sigma x' = 4.5183e-06
|
|
785
799
|
# sigma y = 5.1565e-06
|
|
786
800
|
# sigma y' = 1.9393e-06
|
|
787
801
|
print("sigmas (with dispersion): ", a.get_sigmas_all(dispersion=True))
|
|
788
|
-
print("sigmas (without dispersion): ", a.get_sigmas_all(dispersion=
|
|
802
|
+
print("sigmas (without dispersion): ", a.get_sigmas_all(dispersion=True))
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import copy
|
|
2
|
-
import warnings
|
|
3
2
|
from collections import OrderedDict
|
|
4
3
|
try:
|
|
5
4
|
import json_tricks as json # to save numpy arrays
|
|
@@ -263,12 +262,3 @@ class SynedObject(object):
|
|
|
263
262
|
|
|
264
263
|
"""
|
|
265
264
|
return copy.deepcopy(self)
|
|
266
|
-
|
|
267
|
-
@classmethod
|
|
268
|
-
def _send_deprectation_warning(cls, function_name_use, new_function_use):
|
|
269
|
-
warnings.warn(
|
|
270
|
-
f"{function_name_use} is deprecated and will be removed in a future version. "
|
|
271
|
-
f"Use {new_function_use} instead.",
|
|
272
|
-
DeprecationWarning,
|
|
273
|
-
stacklevel=2
|
|
274
|
-
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import warnings
|
|
3
|
+
|
|
4
|
+
def deprecated(reason: str = ""):
|
|
5
|
+
"""
|
|
6
|
+
Decorator to mark functions as deprecated.
|
|
7
|
+
It will result in a warning being emitted when the function is used.
|
|
8
|
+
"""
|
|
9
|
+
def decorator(func):
|
|
10
|
+
msg = f"The function `{func.__name__}` is deprecated."
|
|
11
|
+
if reason:
|
|
12
|
+
msg += f" {reason}"
|
|
13
|
+
|
|
14
|
+
@functools.wraps(func)
|
|
15
|
+
def wrapper(*args, **kwargs):
|
|
16
|
+
warnings.simplefilter("always", DeprecationWarning) # show even if filtered
|
|
17
|
+
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
|
|
18
|
+
warnings.simplefilter("default", DeprecationWarning) # reset filter
|
|
19
|
+
return func(*args, **kwargs)
|
|
20
|
+
return wrapper
|
|
21
|
+
|
|
22
|
+
return decorator
|
|
@@ -10,6 +10,8 @@ syned.egg-info/dependency_links.txt
|
|
|
10
10
|
syned.egg-info/not-zip-safe
|
|
11
11
|
syned.egg-info/requires.txt
|
|
12
12
|
syned.egg-info/top_level.txt
|
|
13
|
+
syned/__test/__init__.py
|
|
14
|
+
syned/__test/test.py
|
|
13
15
|
syned/beamline/__init__.py
|
|
14
16
|
syned/beamline/beamline.py
|
|
15
17
|
syned/beamline/beamline_element.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{syned-1.0.44 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_element.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|