@@ -511,3 +511,29 @@ def test_UnionEle():
511511 assert len (element_with_children .elements ) == 2
512512 assert element_with_children .elements [0 ].name == "m1"
513513 assert element_with_children .elements [1 ].name == "d1"
514+
515+
516+ def test_Lattice ():
517+ # Create first line with one base element
518+ element1 = pals .Marker (name = "element1" )
519+ line1 = pals .BeamLine (name = "line1" , line = [element1 ])
520+ assert line1 .line == [element1 ]
521+ # Extend first line with one thick element
522+ element2 = pals .Drift (name = "element2" , length = 2.0 )
523+ line1 .line .extend ([element2 ])
524+ assert line1 .line == [element1 , element2 ]
525+ # Create second line with one drift element
526+ element3 = pals .Drift (name = "element3" , length = 3.0 )
527+ line2 = pals .BeamLine (name = "line2" , line = [element3 ])
528+ # Extend first line with second line
529+ line1 .line .extend (line2 .line )
530+ assert line1 .line == [element1 , element2 , element3 ]
531+ # Build lattice with two lines
532+ lattice = pals .Lattice (name = "lattice" , branches = [line1 , line2 ])
533+ assert lattice .name == "lattice"
534+ assert lattice .kind == "Lattice"
535+ assert len (lattice .branches ) == 2
536+ assert lattice .branches [0 ].name == "line1"
537+ assert lattice .branches [1 ].name == "line2"
538+ assert lattice .branches [0 ].line == [element1 , element2 , element3 ]
539+ assert lattice .branches [1 ].line == [element3 ]
0 commit comments