Skip to content

Commit

Permalink
Test plotting with nonleave tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Hespe committed Oct 28, 2024
1 parent 94c52df commit 9aca0cd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,26 @@ def test_reference_particle_plot_vectorized_2d():

# Run the plotting to see if it raises an exception
segment.plot_overview(incoming=incoming, resolution=0.1, vector_idx=(0, 2))


def test_plotting_with_nonleave_tensors():
"""
Test that the plotting routines can handle elements with non-leave tensors.
"""
segment = cheetah.Segment(
elements=[
cheetah.Drift(length=torch.tensor(1.0, requires_grad=True)),
cheetah.BPM(is_active=True),
]
)

incoming = cheetah.ParticleBeam.from_astra(
"tests/resources/ACHIP_EA1_2021.1351.001"
)

# Prepopulate the segment
segment.track(incoming)

# Test that plotting does not raise an exception
segment.plot_overview(incoming=incoming)
segment.plot_twiss(incoming=incoming)

0 comments on commit 9aca0cd

Please sign in to comment.