Skip to content

Commit 34dbc9c

Browse files
committed
Fix get_sublattice
1 parent e0c9ea8 commit 34dbc9c

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

orbit_tools/lattice.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,14 @@
1515

1616
def get_sublattice(
1717
lattice: AccLattice,
18-
start: Union[int, str] = None,
19-
stop: Union[int, str] = None,
18+
start: int | str = None,
19+
stop: int | str = None,
2020
) -> AccLattice:
21-
22-
def get_index(argument: Union[int, str], default: int = 0) -> int:
23-
index = default
24-
if type(argument) is str:
25-
name = argument
26-
index = lattice.getNodeIndex(lattice.getNodeForName(node_name))
27-
else:
28-
index = argument
29-
return index
30-
31-
start_index = get_index(start, default=0)
32-
stop_index = get_index(stop, default=-1)
33-
return lattice.getSubLattice(start_index, stop_index)
21+
if type(start) is str:
22+
start = lattice.getNodeIndex(lattice.getNodeForName(start))
23+
if type(stop) is str:
24+
stop = lattice.getNodeIndex(lattice.getNodeForName(stop))
25+
return lattice.getSubLattice(start, stop)
3426

3527

3628
def split_node(node: AccNode, max_part_length: float = None) -> AccNode:

0 commit comments

Comments
 (0)