Skip to content

Commit 9071869

Browse files
authored
Merge pull request #149 from xsuite/release/v0.6.2
Release 0.6.2
2 parents c0f419c + 38e4d3d commit 9071869

File tree

5 files changed

+52
-23
lines changed

5 files changed

+52
-23
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "xcoll"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
description = "Xsuite collimation package"
55
homepage = "https://github.com/xsuite/xcoll"
66
repository = "https://github.com/xsuite/xcoll"
@@ -28,7 +28,7 @@ pandas = ">=1.4"
2828
xobjects = ">=0.5.0"
2929
xdeps = ">=0.10.5"
3030
xpart = ">=0.23.0"
31-
xtrack = ">=0.84.6"
31+
xtrack = ">=0.84.8"
3232

3333
[poetry.group.dev.dependencies]
3434
pytest = ">=7.3"

tests/data/all_tests.list

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,22 @@ tests/test_line_tools.py::test_line_accessor[1-ContextCpu]
159159
tests/test_line_tools.py::test_line_accessor[1-ContextCpu:auto]
160160
tests/test_line_tools.py::test_line_accessor[2-ContextCpu]
161161
tests/test_line_tools.py::test_line_accessor[2-ContextCpu:auto]
162-
tests/test_lossmap.py::test_lossmap_everest[B1H-ContextCpu]
163-
tests/test_lossmap.py::test_lossmap_everest[B1H-ContextCpu:auto]
164-
tests/test_lossmap.py::test_lossmap_everest[B2V-ContextCpu]
165-
tests/test_lossmap.py::test_lossmap_everest[B2V-ContextCpu:auto]
166-
tests/test_lossmap.py::test_lossmap_everest[B1V_crystals-ContextCpu]
167-
tests/test_lossmap.py::test_lossmap_everest[B1V_crystals-ContextCpu:auto]
168-
tests/test_lossmap.py::test_lossmap_everest[B2H_crystals-ContextCpu]
169-
tests/test_lossmap.py::test_lossmap_everest[B2H_crystals-ContextCpu:auto]
162+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B1H-ContextCpu]
163+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B1H-ContextCpu:auto]
164+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B2V-ContextCpu]
165+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B2V-ContextCpu:auto]
166+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B1V_crystals-ContextCpu]
167+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B1V_crystals-ContextCpu:auto]
168+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B2H_crystals-ContextCpu]
169+
tests/test_lossmap.py::test_lossmap_everest_with_plot[B2H_crystals-ContextCpu:auto]
170+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B1H-ContextCpu]
171+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B1H-ContextCpu:auto]
172+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B2V-ContextCpu]
173+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B2V-ContextCpu:auto]
174+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B1V_crystals-ContextCpu]
175+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B1V_crystals-ContextCpu:auto]
176+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B2H_crystals-ContextCpu]
177+
tests/test_lossmap.py::test_lossmap_everest_without_plot[B2H_crystals-ContextCpu:auto]
170178
tests/test_rf_sweep.py::test_rf_sweep[DP pos-ContextCpu]
171179
tests/test_rf_sweep.py::test_rf_sweep[DP pos-ContextCpu:auto]
172180
tests/test_rf_sweep.py::test_rf_sweep[DP neg-ContextCpu]

tests/test_lossmap.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
import pytest
1313
from xpart.test_helpers import flaky_assertions, retry
1414
from xobjects.test_helpers import for_all_test_contexts
15+
try:
16+
import matplotlib.pyplot as plt
17+
matplotlib_installed = True
18+
except (ImportError, ModuleNotFoundError):
19+
matplotlib_installed = False
1520

1621
path = Path(__file__).parent / 'data'
1722

1823

24+
@pytest.mark.skipif(not matplotlib_installed, reason="matplolib not installed")
1925
@for_all_test_contexts(
2026
excluding=('ContextCupy', 'ContextPyopencl') # Rutherford RNG not on GPU
2127
)
@@ -26,31 +32,48 @@
2632
[1, 'V', 3500, False, False],
2733
[2, 'H', 30000, 0.15, False]
2834
], ids=["B1H", "B2V", "B1V_crystals", "B2H_crystals"])
29-
def test_lossmap_everest(beam, plane, npart, interpolation, ignore_crystals, test_context):
35+
def test_lossmap_everest_with_plot(beam, plane, npart, interpolation, ignore_crystals, test_context):
36+
_test_lossmap_everest(beam, plane, npart, interpolation, ignore_crystals, test_context, True)
3037

31-
line = xt.Line.from_json(path / f'sequence_lhc_run3_b{beam}.json')
3238

39+
@pytest.mark.skipif(matplotlib_installed, reason="matplolib installed")
40+
@for_all_test_contexts(
41+
excluding=('ContextCupy', 'ContextPyopencl') # Rutherford RNG not on GPU
42+
)
43+
@retry()
44+
@pytest.mark.parametrize("beam, plane, npart, interpolation, ignore_crystals", [
45+
[1, 'H', 2500, 0.2, True],
46+
[2, 'V', 500, 0.3, True],
47+
[1, 'V', 3500, False, False],
48+
[2, 'H', 30000, 0.15, False]
49+
], ids=["B1H", "B2V", "B1V_crystals", "B2H_crystals"])
50+
def test_lossmap_everest_without_plot(beam, plane, npart, interpolation, ignore_crystals, test_context):
51+
_test_lossmap_everest(beam, plane, npart, interpolation, ignore_crystals, test_context, False)
52+
53+
54+
def _test_lossmap_everest(beam, plane, npart, interpolation, ignore_crystals, test_context, do_plot):
55+
line = xt.Line.from_json(path / f'sequence_lhc_run3_b{beam}.json')
3356
colldb = xc.CollimatorDatabase.from_yaml(path / f'colldb_lhc_run3_ir7.yaml',
3457
beam=beam, ignore_crystals=ignore_crystals)
35-
3658
colldb.install_everest_collimators(line=line)
3759
df_with_coll = line.check_aperture()
3860
assert not np.any(df_with_coll.has_aperture_problem)
39-
4061
line.build_tracker(_context=test_context)
4162
line.collimators.assign_optics()
42-
4363
tcp = f"tcp.{'c' if plane=='H' else 'd'}6{'l' if beam==1 else 'r'}7.b{beam}"
4464
part = line[tcp].generate_pencil(npart)
45-
4665
line.scattering.enable()
4766
line.track(part, num_turns=2)
4867
line.scattering.disable()
4968
this_id = f"B{beam}{plane}-{npart}-{interpolation}-{ignore_crystals}-{test_context}"
50-
assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals, 'EverestCollimator', 'EverestCrystal', this_id)
69+
ThisLM = _assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals, 'EverestCollimator', 'EverestCrystal', this_id)
70+
if do_plot:
71+
ThisLM.plot(show=False, savefig=f"test-{this_id}.jpg")
72+
assert Path(f"test-{this_id}.jpg").exists()
73+
Path(f"test-{this_id}.jpg").unlink()
5174

5275

53-
def assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals, coll_cls, cry_cls, this_id):
76+
def _assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals, coll_cls, cry_cls, this_id):
5477
with flaky_assertions():
5578
line_is_reversed = True if beam == 2 else False
5679
ThisLM = xc.LossMap(line, line_is_reversed=line_is_reversed, part=part,
@@ -73,9 +96,6 @@ def assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals,
7396
ThisLM.save_summary(f"coll_summary-{this_id}.txt")
7497
assert Path(f"coll_summary-{this_id}.txt").exists()
7598
Path(f"coll_summary-{this_id}.txt").unlink()
76-
ThisLM.plot(show=False, savefig=f"test-{this_id}.jpg")
77-
assert Path(f"test-{this_id}.jpg").exists()
78-
Path(f"test-{this_id}.jpg").unlink()
7999

80100
# TODO: check the lossmap quantitaively: rough amount of losses at given positions
81101
summ = ThisLM.summary
@@ -122,3 +142,4 @@ def assert_lossmap(beam, npart, line, part, tcp, interpolation, ignore_crystals,
122142
assert np.all([s < lm['machine_length'] for s in lm['aperture']['s']])
123143
assert lm['interpolation'] == interpolation
124144
assert lm['reversed'] == line_is_reversed
145+
return ThisLM

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.6.1'
9+
assert __version__ == '0.6.2'

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

0 commit comments

Comments
 (0)