Skip to content

Commit 78e8a6c

Browse files
authored
Merge pull request #115 from xsuite/release/v0.5.7
Release 0.5.7
2 parents 71869e0 + 7cad995 commit 78e8a6c

File tree

9 files changed

+15
-23
lines changed

9 files changed

+15
-23
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "xcoll"
3-
version = "0.5.6"
3+
version = "0.5.7"
44
description = "Xsuite collimation package"
55
homepage = "https://github.com/xsuite/xcoll"
66
repository = "https://github.com/xsuite/xcoll"

tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
from xcoll import __version__
77

88
def test_version():
9-
assert __version__ == '0.5.6'
9+
assert __version__ == '0.5.7'

xcoll/beam_elements/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,3 @@
2020
if isinstance(v, type) and issubclass(v, BaseCrystal) and v != BaseCrystal)
2121

2222
element_classes = block_classes + (BlowUp, EmittanceMonitor)
23-
24-
# For compatibility with _K2Collimators
25-
_all_block_classes = block_classes
26-
_all_collimator_classes = collimator_classes
27-
_all_crystal_classes = crystal_classes

xcoll/beam_elements/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,6 @@ def optics_ready(self):
597597

598598
def assign_optics(self, *, nemitt_x=None, nemitt_y=None, beta_gamma_rel=None, name=None, twiss=None,
599599
twiss_upstream=None, twiss_downstream=None):
600-
from xcoll.beam_elements import _all_collimator_classes
601-
if not isinstance(self, _all_collimator_classes):
602-
raise ValueError("Please install collimator before assigning optics.")
603600
if nemitt_x is None:
604601
if self.nemitt_x is None:
605602
raise ValueError("Need to provide `nemitt_x`.")

xcoll/colldb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import xtrack as xt
1414

1515
from .beam_elements import BlackAbsorber, BlackCrystal, EverestCollimator, EverestCrystal, \
16-
BaseCollimator, BaseCrystal, _all_collimator_classes
16+
BaseCollimator, BaseCrystal, collimator_classes
1717
from .scattering_routines.everest.materials import SixTrack_to_xcoll
1818

1919

@@ -526,7 +526,7 @@ def _get_names_from_line(self, line, names, families):
526526
def _check_installed(self, line, name, collimator_class):
527527
# Check that collimator is not installed as different type
528528
# TODO: automatically replace collimator type and print warning
529-
if isinstance(line[name], _all_collimator_classes):
529+
if isinstance(line[name], collimator_classes):
530530
raise ValueError(f"Trying to install {name} as {collimator_class.__name__}, "
531531
+ f"but it is already installed as {line[name].__class__.__name__}!\n"
532532
+ f"Please reconstruct the line.")

xcoll/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# ======================
1313
# Do not change
1414
# ======================
15-
__version__ = '0.5.6'
15+
__version__ = '0.5.7'
1616
# ======================

xcoll/initial_distribution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import xobjects as xo
1111
import xpart as xp
1212

13-
from .beam_elements import _all_collimator_classes, EverestCrystal
13+
from .beam_elements import collimator_classes, EverestCrystal
1414

1515

1616
def generate_pencil_on_collimator(line, name, num_particles, *, side='+-', pencil_spread=1e-6,
@@ -25,7 +25,7 @@ def generate_pencil_on_collimator(line, name, num_particles, *, side='+-', penci
2525

2626
coll = line[name]
2727

28-
if not isinstance(coll, tuple(_all_collimator_classes)):
28+
if not isinstance(coll, tuple(collimator_classes)):
2929
raise ValueError("Need to provide a valid collimator!")
3030

3131
if coll.optics is None:

xcoll/line_tools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import xtrack as xt
1010

11-
from .beam_elements import element_classes, _all_collimator_classes, _all_block_classes
11+
from .beam_elements import element_classes, collimator_classes, block_classes
1212

1313

1414
class XcollScatteringAPI:
@@ -79,7 +79,7 @@ def install(self, names, elements, *, at_s=None, apertures=None, need_apertures=
7979
# Verify elements
8080
for el in elements:
8181
print(el.__class__)
82-
assert isinstance(el, _all_block_classes)
82+
assert isinstance(el, block_classes)
8383
el._tracking = False
8484

8585
# Get positions
@@ -239,7 +239,7 @@ def assign_optics(self, *, nemitt_x=None, nemitt_y=None, twiss=None, tw=None):
239239
twiss = tw
240240
if not self.line._has_valid_tracker():
241241
raise Exception("Please build tracker before setting the openings!")
242-
names = self.line.get_elements_of_type(_all_collimator_classes, _all_block_classes)[1]
242+
names = self.line.get_elements_of_type(collimator_classes)[1]
243243
tw_upstream, tw_downstream = self.get_optics_at(names, twiss=twiss)
244244
beta_gamma_rel = self.line.particle_ref._xobject.gamma0[0]*self.line.particle_ref._xobject.beta0[0]
245245
for coll in names:
@@ -248,7 +248,7 @@ def assign_optics(self, *, nemitt_x=None, nemitt_y=None, twiss=None, tw=None):
248248

249249
def open(self, names=None):
250250
if names is None:
251-
names = self.line.get_elements_of_type(_all_collimator_classes, _all_block_classes)[1]
251+
names = self.line.get_elements_of_type(collimator_classes)[1]
252252
if len(names) == 0:
253253
print("No collimators found in line.")
254254
else:
@@ -258,7 +258,7 @@ def open(self, names=None):
258258

259259
def to_parking(self, names=None):
260260
if names is None:
261-
names = self.line.get_elements_of_type(_all_collimator_classes)[1]
261+
names = self.line.get_elements_of_type(collimator_classes)[1]
262262
if len(names) == 0:
263263
print("No collimators found in line.")
264264
else:

xcoll/lossmap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import xpart as xp
1313
import xobjects as xo
1414

15-
from .beam_elements import _all_collimator_classes, _all_crystal_classes
15+
from .beam_elements import collimator_classes, crystal_classes
1616

1717

1818
class LossMap:
@@ -114,7 +114,7 @@ def weights(self):
114114
def _correct_absorbed(self, verbose=True):
115115
# Correct particles that are at an aperture directly after a collimator
116116
part = self._part
117-
coll_classes = list(set(_all_collimator_classes) - set(_all_crystal_classes))
117+
coll_classes = list(set(collimator_classes) - set(crystal_classes))
118118
coll_elements = self._line.get_elements_of_type(coll_classes)[1]
119119
for idx, elem in enumerate(part.at_element):
120120
if part.state[idx] == 0:
@@ -156,7 +156,7 @@ def _interpolate(self):
156156

157157

158158
def _make_coll_summary(self):
159-
collimator_names = self._line.get_elements_of_type(_all_collimator_classes)[1]
159+
collimator_names = self._line.get_elements_of_type(collimator_classes)[1]
160160
coll_mask = (self._part.state <= -330) & (self._part.state >= -340)
161161
coll_losses = np.array([self._line.element_names[i]
162162
for i in self._part.at_element[coll_mask]])

0 commit comments

Comments
 (0)