Skip to content

Commit 08a6071

Browse files
authored
Merge pull request #122 from xsuite/release/v0.5.11
Release 0.5.11
2 parents afe4c9d + 3c3aed7 commit 08a6071

File tree

12 files changed

+66
-30
lines changed

12 files changed

+66
-30
lines changed

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "xcoll"
3-
version = "0.5.10"
3+
version = "0.5.11"
44
description = "Xsuite collimation package"
55
homepage = "https://github.com/xsuite/xcoll"
66
repository = "https://github.com/xsuite/xcoll"
@@ -26,16 +26,16 @@ ruamel-yaml = { version = "^0.17.31", optional = true }
2626
numpy = ">=1.0"
2727
pandas = ">=1.4"
2828
xobjects = ">=0.4.5"
29-
xdeps = ">=0.7.4"
30-
xpart = ">=0.19.1"
31-
xtrack = ">=0.69.7"
29+
xdeps = ">=0.8.1"
30+
xpart = ">=0.19.3"
31+
xtrack = ">=0.70.3"
3232

3333
[tool.poetry.dev-dependencies]
3434
pytest = ">=7.3"
3535
xaux = ">=0.2.1"
3636

3737
[tool.poetry.extras]
38-
tests = ["pytest", "ruamel-yaml"]
38+
tests = ["pytest", "ruamel-yaml", "pytest-html", "pytest-xdist"]
3939

4040
[build-system]
4141
# Needed for pip install -e (BTW: need pip version 22)

tests/data/assert_listing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
from pathlib import Path
88

9+
from xobjects.context import get_test_contexts
910

1011
path = Path(__file__).parent
1112

@@ -25,9 +26,14 @@ def pytest_collection_modifyitems(self, session, config, items):
2526
with contextlib.redirect_stdout(open(os.devnull, 'w')):
2627
pytest.main(["--collect-only"], plugins=[TestCollector()])
2728

29+
# do not keep GPU contexts as tests in the listing, as the names can change
30+
collected_tests = [tst for tst in collected_tests
31+
if 'Context' not in tst or 'ContextCpu' in tst]
32+
2833
return set(collected_tests)
2934

3035
current_tests = _collect_tests()
36+
# available_contexts = [ctx.__class__.__name__ for ctx in get_test_contexts()]
3137
with open(path / 'all_tests.list', 'r') as fid:
3238
expected_tests = set([line.replace('\n', '') for line in fid.readlines()])
3339
only_current = current_tests.difference(expected_tests)

tests/data/colldb_lhc_run3_ir7.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ emittance:
1515
collimators:
1616
b1:
1717
tcp.d6l7.b1: { <<: *TCP7, angle: 90, material: MoGR, length: 1.565 }
18-
tcp.c6l7.b1: { <<: *TCP7, angle: 0, material: MoGR, tilt: [-250e-6, 250e-6] }
18+
tcp.c6l7.b1: { <<: *TCP7, angle: 0, material: MoGR, tilt: [2.5e-6, -2.5e-6] }
1919
tcp.b6l7.b1: { <<: *TCP7, angle: 127.5 }
2020
tcsg.a6l7.b1: { <<: *TCSG7, angle: 141.1 }
2121
tcpcv.a6l7.b1: { <<: *CRY7, angle: 90, bending_radius: 85.10, width: 5.0e-3, height: 30.0e-3 }
@@ -29,7 +29,7 @@ collimators:
2929

3030
b2:
3131
tcp.d6r7.b2: { <<: *TCP7, angle: 90, material: MoGR, length: 1.565 }
32-
tcp.c6r7.b2: { <<: *TCP7, angle: 0, material: MoGR, tilt: [-250e-6, 250e-6] }
32+
tcp.c6r7.b2: { <<: *TCP7, angle: 0, material: MoGR, tilt: [2.5e-6, -2.5e-6] }
3333
tcp.b6r7.b2: { <<: *TCP7, angle: 127.5 }
3434
tcsg.a6r7.b2: { <<: *TCSG7, angle: 141.1 }
3535
tcpcv.a6r7.b2: { <<: *CRY7, angle: 90, bending_radius: 74.88, width: 5.0e-3, height: 30.0e-3 }

tests/data/store_all_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def pytest_collection_modifyitems(self, session, config, items):
2525
with contextlib.redirect_stdout(open(os.devnull, 'w')):
2626
pytest.main(["--collect-only"], plugins=[TestCollector()])
2727

28+
# do not keep GPU contexts as tests in the listing, as the names can change
29+
collected_tests = [tst for tst in collected_tests
30+
if 'Context' not in tst or 'ContextCpu' in tst]
31+
2832
with open(path / 'all_tests.list', 'w') as fid:
2933
for line in collected_tests:
3034
fid.write(f"{line}\n")

tests/run_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ then
1313
xsuite-prebuild r
1414
# "xsuite-prebuild c" to remove kernels
1515
echo "done."
16-
pytest -n 10 -vv --html="pytest_results.html" --self-contained-html
16+
pytest -n 13 -vv --html="pytest_results.html" --self-contained-html
1717
else
1818
echo "Not all tests are verified. Aborting."
1919
exit 1

tests/test_elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
{'field': 'record_exits', 'val': True, 'expected': {'record_impacts': True, 'record_exits': True, 'record_scatterings': True, '_record_interactions': 7}}
6565
]
6666
base_user_fields = {}
67-
base_user_fields_read_only = []
67+
base_user_fields_read_only = ['gemitt_x', 'gemitt_y']
6868

6969
# BaseCollimator
7070
base_coll_fields = {**base_fields,

tests/test_lossmap.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
[2, 'V', 500, 0.3, True],
2525
[1, 'V', 3500, 0.1, False],
2626
[2, 'H', 30000, 0.15, False]
27-
], ids=["B1", "B2V", "B1V_crystals", "B2H_crystals"])
27+
], ids=["B1H", "B2V", "B1V_crystals", "B2H_crystals"])
2828
def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_context):
2929

3030
line = xt.Line.from_json(path / f'sequence_lhc_run3_b{beam}.json')
@@ -45,12 +45,15 @@ def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_co
4545
line.scattering.enable()
4646
line.track(part, num_turns=2)
4747
line.scattering.disable()
48+
assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals, 'EverestCollimator', 'EverestCrystal')
4849

49-
line_is_reversed = True if beam == 2 else False
50-
with flaky_assertions():
5150

51+
def assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals, coll_cls, cry_cls):
52+
with flaky_assertions():
53+
line_is_reversed = True if beam == 2 else False
5254
ThisLM = xc.LossMap(line, line_is_reversed=line_is_reversed, part=part,
5355
interpolation=interpolation)
56+
print(ThisLM.summary)
5457

5558
ThisLM.to_json("lossmap.json")
5659
assert Path("lossmap.json").exists()
@@ -65,9 +68,10 @@ def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_co
6568
# TODO: check the lossmap quantitaively: rough amount of losses at given positions
6669
summ = ThisLM.summary
6770
assert list(summ.columns) == ['collname', 'nabs', 'length', 's', 'type']
68-
assert len(summ[summ.type=='EverestCollimator']) == 10
71+
assert len(summ[summ.type==coll_cls]) == 10
6972
if not ignore_crystals:
70-
assert len(summ[summ.type=='EverestCrystal']) == 2
73+
assert len(summ[summ.type==cry_cls]) == 2
74+
7175
# We want at least 5% absorption on the primary
7276
assert summ.loc[summ.collname==tcp,'nabs'].values[0] > 0.05*npart
7377

@@ -94,5 +98,3 @@ def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_co
9498
assert np.all([s < lm['machine_length'] for s in lm['aperture']['s']])
9599
assert lm['interpolation'] == interpolation
96100
assert lm['reversed'] == line_is_reversed
97-
98-

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.10'
9+
assert __version__ == '0.5.11'

xcoll/beam_elements/base.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from ..general import _pkg_root
1313

1414

15-
OPEN_JAW = 3.
16-
OPEN_GAP = 999.
15+
OPEN_JAW = 3
16+
OPEN_GAP = 999
1717

1818

1919
class InvalidXcoll(xt.BeamElement):
@@ -659,6 +659,11 @@ def nemitt_x(self, val):
659659
self._nemitt_x = val
660660
self._apply_optics()
661661

662+
@property
663+
def gemitt_x(self):
664+
if self.nemitt_x is not None and self.optics_ready():
665+
return self.nemitt_x / self.optics['beta_gamma_rel']
666+
662667
@property
663668
def nemitt_y(self):
664669
if self._nemitt_y == 0:
@@ -674,6 +679,11 @@ def nemitt_y(self, val):
674679
self._nemitt_y = val
675680
self._apply_optics()
676681

682+
@property
683+
def gemitt_y(self):
684+
if self.nemitt_y is not None and self.optics_ready():
685+
return self.nemitt_y / self.optics['beta_gamma_rel']
686+
677687
@property
678688
def emittance(self):
679689
if self.nemitt_x is not None and self.nemitt_y is not None:
@@ -734,8 +744,8 @@ def divergence(self):
734744
alfy = self.optics[self.align]['alfy'][0]
735745
betx = self.optics[self.align]['betx'][0]
736746
bety = self.optics[self.align]['bety'][0]
737-
divx = -np.sqrt(self.nemitt_x/self.optics['beta_gamma_rel']/betx)*alfx
738-
divy = -np.sqrt(self.nemitt_y/self.optics['beta_gamma_rel']/bety)*alfy
747+
divx = -np.sqrt(self.gemitt_x/betx)*alfx
748+
divy = -np.sqrt(self.gemitt_y/bety)*alfy
739749
if hasattr(self, '_cos_zL'):
740750
if self.side != 'right':
741751
return divx if abs(self.angle_L) < 1e-6 else divy
@@ -1256,6 +1266,10 @@ def nemitt_x(self):
12561266
def nemitt_x(self, val):
12571267
BaseCollimator.nemitt_x.fset(self, val)
12581268

1269+
@property
1270+
def gemitt_x(self):
1271+
return BaseCollimator.gemitt_x.fget(self)
1272+
12591273
@property
12601274
def nemitt_y(self):
12611275
return BaseCollimator.nemitt_y.fget(self)
@@ -1264,6 +1278,10 @@ def nemitt_y(self):
12641278
def nemitt_y(self, val):
12651279
BaseCollimator.nemitt_y.fset(self, val)
12661280

1281+
@property
1282+
def gemitt_y(self):
1283+
return BaseCollimator.gemitt_y.fget(self)
1284+
12671285
@property
12681286
def emittance(self):
12691287
return BaseCollimator.emittance.fget(self)

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.10'
15+
__version__ = '0.5.11'
1616
# ======================

0 commit comments

Comments
 (0)