Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename converter modules #167

Merged
merged 5 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Update versions in pre-commit config (see #148) (@jank324)
- Split `accelerator` and `beam` into separate submodules (see #158) (@jank324)
- Update reference from arXiv preprint to PRAB publication (see #166) (@jank324)
- Rename converter modules to the respective name of the accelerator code (see #167) (@jank324)

## [v0.6.3](https://github.com/desy-ml/cheetah/releases/tag/v0.6.3) (2024-03-28)

Expand Down
4 changes: 2 additions & 2 deletions cheetah/accelerator/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scipy.constants import physical_constants
from torch import Size, nn

from cheetah.converters.dontbmad import convert_bmad_lattice
from cheetah.converters.bmad import convert_bmad_lattice
from cheetah.converters.nxtables import read_nx_tables
from cheetah.latticejson import load_cheetah_model, save_cheetah_model
from cheetah.particles import Beam, ParticleBeam
Expand Down Expand Up @@ -273,7 +273,7 @@ def from_ocelot(
Cheetah or converted with potentially unexpected behavior.
:return: Cheetah segment closely resembling the Ocelot cell.
"""
from cheetah.converters.nocelot import ocelot2cheetah
from cheetah.converters.ocelot import ocelot2cheetah

converted = [
ocelot2cheetah(element, warnings=warnings, device=device, dtype=dtype)
Expand Down
2 changes: 1 addition & 1 deletion cheetah/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# flake8: noqa
from cheetah.converters import astralavista, dontbmad, nocelot, nxtables
from cheetah.converters import astra, bmad, nxtables, ocelot
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cheetah/particles/parameter_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def from_ocelot(cls, parray, device=None, dtype=torch.float32) -> "ParameterBeam
@classmethod
def from_astra(cls, path: str, device=None, dtype=torch.float32) -> "ParameterBeam":
"""Load an Astra particle distribution as a Cheetah Beam."""
from cheetah.converters.astralavista import from_astrabeam
from cheetah.converters.astra import from_astrabeam

particles, energy, particle_charges = from_astrabeam(path)
mu = torch.ones(7)
Expand Down
2 changes: 1 addition & 1 deletion cheetah/particles/particle_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def from_ocelot(cls, parray, device=None, dtype=torch.float32) -> "ParticleBeam"
@classmethod
def from_astra(cls, path: str, device=None, dtype=torch.float32) -> "ParticleBeam":
"""Load an Astra particle distribution as a Cheetah Beam."""
from cheetah.converters.astralavista import from_astrabeam
from cheetah.converters.astra import from_astrabeam

particles, energy, particle_charges = from_astrabeam(path)
particles_7d = torch.ones((particles.shape[0], 7))
Expand Down
8 changes: 0 additions & 8 deletions docs/astralavista.rst

This file was deleted.

20 changes: 20 additions & 0 deletions docs/converters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. Documents converters

Converters
==========

.. automodule:: converters.astra
:members:
:undoc-members:

.. automodule:: converters.bmad
:members:
:undoc-members:

.. automodule:: converters.nxtables
:members:
:undoc-members:

.. automodule:: converters.ocelot
:members:
:undoc-members:
8 changes: 0 additions & 8 deletions docs/dontbmad.rst

This file was deleted.

4 changes: 1 addition & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ For more advanced usage, please refer to the in-depth documentation.
:caption: Documentation

accelerator
astralavista
dontbmad
converters
error
latticejson
nocelot
particles
track_methods
utils
Expand Down
8 changes: 0 additions & 8 deletions docs/nocelot.rst

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_compare_ocelot.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def test_ares_ea():
Test that the tracking results through a Experimental Area (EA) lattice of the ARES
accelerator at DESY match those using Ocelot.
"""
cell = cheetah.converters.nocelot.subcell_of_ocelot(
cell = cheetah.converters.ocelot.subcell_of_ocelot(
ares.cell, "AREASOLA1", "AREABSCR1"
)
ares.areamqzm1.k1 = 5.0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# TODO: Test that Cheeath tracks faster than Ocelot
def test_tracking_speed():
"""Really only tests that Cheetah isn't super slow."""
cell = cheetah.converters.nocelot.subcell_of_ocelot(
cell = cheetah.converters.ocelot.subcell_of_ocelot(
ares.cell, "AREASOLA1", "AREABSCR1"
)
segment = cheetah.Segment.from_ocelot(cell)
Expand Down