Skip to content

Commit 8cd472d

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

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

src/genie_python/genie.py

Lines changed: 23 additions & 26 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

@@ -2006,16 +2005,15 @@ def define_hard_period(
20062005
configure_internal_periods(None, None, period, daq, dwell, unused, frames, output, label)
20072006

20082007

2009-
class ChangeParams(TypedDict):
2010-
title: str
2011-
period: int
2012-
nperiods: int
2013-
user: str
2014-
rb: int
2015-
2016-
20172008
@log_command_and_handle_exception
2018-
def change(**params: Unpack[ChangeParams]) -> None:
2009+
def change(
2010+
title: str | None = None,
2011+
period: int | None = None,
2012+
nperiods: int | None = None,
2013+
user: str | None = None,
2014+
users: str | None = None,
2015+
rb: int | None = None,
2016+
) -> None:
20192017
"""
20202018
Change experiment parameters.
20212019
@@ -2026,7 +2024,8 @@ def change(**params: Unpack[ChangeParams]) -> None:
20262024
period (int, optional): the new period (must be in a non-running state)
20272025
nperiods (int, optional): the new number of software periods
20282026
(must be in a non-running state)
2029-
user (string, optional): the new user(s) as a comma-separated list
2027+
user (string, optional): the new user
2028+
users (string, optional): the new user(s) as a comma-separated list
20302029
rb (int, optional): the new RB number
20312030
20322031
Examples:
@@ -2040,26 +2039,24 @@ def change(**params: Unpack[ChangeParams]) -> None:
20402039
20412040
Set multiple users:
20422041
2043-
>>> change(user="Thouless, Haldane, Kosterlitz")
2042+
>>> change(users="Thouless, Haldane, Kosterlitz")
20442043
20452044
Change the RB number and the users:
20462045
20472046
>>> change(rb=123456, user="Smith, Jones")
20482047
"""
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")
2048+
if title is not None:
2049+
change_title(title)
2050+
if period is not None:
2051+
change_period(period)
2052+
if nperiods is not None:
2053+
change_number_soft_periods(nperiods)
2054+
if user is not None:
2055+
change_users(user)
2056+
if users is not None:
2057+
change_users(users)
2058+
if rb is not None:
2059+
change_rb(rb)
20632060

20642061

20652062
@usercommand

0 commit comments

Comments
 (0)