Skip to content

Commit 5daf8fb

Browse files
committed
Fix g.change() type checking
1 parent 9af767d commit 5daf8fb

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/genie_python/genie.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import numpy as np
1515
import numpy.typing as npt
16-
from typing_extensions import Unpack
1716

1817
from genie_python.genie_api_setup import __api as _genie_api
1918

@@ -2015,7 +2014,14 @@ class ChangeParams(TypedDict):
20152014

20162015

20172016
@log_command_and_handle_exception
2018-
def change(**params: Unpack[ChangeParams]) -> None:
2017+
def change(
2018+
title: str | None = None,
2019+
period: int | None = None,
2020+
nperiods: int | None = None,
2021+
user: str | None = None,
2022+
users: str | None = None,
2023+
rb: int | None = None,
2024+
) -> None:
20192025
"""
20202026
Change experiment parameters.
20212027
@@ -2026,7 +2032,8 @@ def change(**params: Unpack[ChangeParams]) -> None:
20262032
period (int, optional): the new period (must be in a non-running state)
20272033
nperiods (int, optional): the new number of software periods
20282034
(must be in a non-running state)
2029-
user (string, optional): the new user(s) as a comma-separated list
2035+
user (string, optional): the new user
2036+
users (string, optional): the new user(s) as a comma-separated list
20302037
rb (int, optional): the new RB number
20312038
20322039
Examples:
@@ -2040,26 +2047,24 @@ def change(**params: Unpack[ChangeParams]) -> None:
20402047
20412048
Set multiple users:
20422049
2043-
>>> change(user="Thouless, Haldane, Kosterlitz")
2050+
>>> change(users="Thouless, Haldane, Kosterlitz")
20442051
20452052
Change the RB number and the users:
20462053
20472054
>>> change(rb=123456, user="Smith, Jones")
20482055
"""
2049-
for k in params:
2050-
key = k.lower().strip()
2051-
if key == "title":
2052-
change_title(params[k])
2053-
elif key == "period":
2054-
change_period(params[k])
2055-
elif key == "nperiods":
2056-
change_number_soft_periods(params[k])
2057-
elif key == "user" or key == "users":
2058-
change_users(params[k])
2059-
elif key == "rb":
2060-
change_rb(params[k])
2061-
else:
2062-
raise KeyError("Unknown parameter supplied. Type help(change) for more information")
2056+
if title is not None:
2057+
change_title(users)
2058+
if period is not None:
2059+
change_period(period)
2060+
if nperiods is not None:
2061+
change_number_soft_periods(nperiods)
2062+
if user is not None:
2063+
change_users(user)
2064+
if users is not None:
2065+
change_users(users)
2066+
if rb is not None:
2067+
change_rb(rb)
20632068

20642069

20652070
@usercommand

0 commit comments

Comments
 (0)