Skip to content

Commit e766e82

Browse files
committed
Update FODO example
1 parent 0b02e43 commit e766e82

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

examples/fodo.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pals import Drift
33
from pals import Quadrupole
44
from pals import BeamLine
5+
from pals import Lattice
56

67

78
def main():
@@ -42,26 +43,31 @@ def main():
4243
drift3,
4344
],
4445
)
46+
# Create lattice with the line as a branch
47+
lattice = Lattice(
48+
name="fodo_lattice",
49+
branches=[line],
50+
)
4551

4652
# Serialize to YAML
4753
yaml_file = "examples_fodo.pals.yaml"
48-
line.to_file(yaml_file)
54+
lattice.to_file(yaml_file)
4955

5056
# Read YAML data from file
51-
loaded_line = BeamLine.from_file(yaml_file)
57+
loaded_lattice = Lattice.from_file(yaml_file)
5258

5359
# Validate loaded data
54-
assert line == loaded_line
60+
assert lattice == loaded_lattice
5561

5662
# Serialize to JSON
5763
json_file = "examples_fodo.pals.json"
58-
line.to_file(json_file)
64+
lattice.to_file(json_file)
5965

6066
# Read JSON data from file
61-
loaded_line = BeamLine.from_file(json_file)
67+
loaded_lattice = Lattice.from_file(json_file)
6268

6369
# Validate loaded data
64-
assert line == loaded_line
70+
assert lattice == loaded_lattice
6571

6672

6773
if __name__ == "__main__":

0 commit comments

Comments
 (0)