Skip to content

Commit 19cdfee

Browse files
Merge pull request #63 from ISISComputingGroup/8849_change_command_type_checking
Fix g.change() type checking
2 parents ffc5cbc + 8cd472d commit 19cdfee

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

@@ -2008,16 +2007,15 @@ def define_hard_period(
20082007
configure_internal_periods(None, None, period, daq, dwell, unused, frames, output, label)
20092008

20102009

2011-
class ChangeParams(TypedDict):
2012-
title: str
2013-
period: int
2014-
nperiods: int
2015-
user: str
2016-
rb: int
2017-
2018-
20192010
@log_command_and_handle_exception
2020-
def change(**params: Unpack[ChangeParams]) -> None:
2011+
def change(
2012+
title: str | None = None,
2013+
period: int | None = None,
2014+
nperiods: int | None = None,
2015+
user: str | None = None,
2016+
users: str | None = None,
2017+
rb: int | None = None,
2018+
) -> None:
20212019
"""
20222020
Change experiment parameters.
20232021
@@ -2028,7 +2026,8 @@ def change(**params: Unpack[ChangeParams]) -> None:
20282026
period (int, optional): the new period (must be in a non-running state)
20292027
nperiods (int, optional): the new number of software periods
20302028
(must be in a non-running state)
2031-
user (string, optional): the new user(s) as a comma-separated list
2029+
user (string, optional): the new user
2030+
users (string, optional): the new user(s) as a comma-separated list
20322031
rb (int, optional): the new RB number
20332032
20342033
Examples:
@@ -2042,26 +2041,24 @@ def change(**params: Unpack[ChangeParams]) -> None:
20422041
20432042
Set multiple users:
20442043
2045-
>>> change(user="Thouless, Haldane, Kosterlitz")
2044+
>>> change(users="Thouless, Haldane, Kosterlitz")
20462045
20472046
Change the RB number and the users:
20482047
20492048
>>> change(rb=123456, user="Smith, Jones")
20502049
"""
2051-
for k in params:
2052-
key = k.lower().strip()
2053-
if key == "title":
2054-
change_title(params[k])
2055-
elif key == "period":
2056-
change_period(params[k])
2057-
elif key == "nperiods":
2058-
change_number_soft_periods(params[k])
2059-
elif key == "user" or key == "users":
2060-
change_users(params[k])
2061-
elif key == "rb":
2062-
change_rb(params[k])
2063-
else:
2064-
raise KeyError("Unknown parameter supplied. Type help(change) for more information")
2050+
if title is not None:
2051+
change_title(title)
2052+
if period is not None:
2053+
change_period(period)
2054+
if nperiods is not None:
2055+
change_number_soft_periods(nperiods)
2056+
if user is not None:
2057+
change_users(user)
2058+
if users is not None:
2059+
change_users(users)
2060+
if rb is not None:
2061+
change_rb(rb)
20652062

20662063

20672064
@usercommand

0 commit comments

Comments
 (0)