File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -338,6 +338,26 @@ def count( # pyright: ignore[reportIncompatibleMethodOverride]
338
338
"""
339
339
return self ._channels .count (obj )
340
340
341
+ def get_channels_by_name (self : Self , * names : str ) -> Self :
342
+ """
343
+ Get a a ChannelTuple that only contains the selected names.
344
+
345
+ Args:
346
+ *names: channel names
347
+
348
+ """
349
+ if len (names ) == 0 :
350
+ raise Exception ("one or more names must be given" )
351
+ selected_channels = tuple (self ._channel_mapping [name ] for name in names )
352
+ return type (self )(
353
+ self ._parent ,
354
+ self ._name ,
355
+ self ._chan_type ,
356
+ selected_channels ,
357
+ self ._snapshotable ,
358
+ self ._paramclass ,
359
+ )
360
+
341
361
def get_channel_by_name (self : Self , * names : str ) -> InstrumentModuleType | Self :
342
362
"""
343
363
Get a channel by name, or a ChannelTuple if multiple names are given.
@@ -350,6 +370,11 @@ def get_channel_by_name(self: Self, *names: str) -> InstrumentModuleType | Self:
350
370
raise Exception ("one or more names must be given" )
351
371
if len (names ) == 1 :
352
372
return self ._channel_mapping [names [0 ]]
373
+
374
+ raise Warning (
375
+ "Supplying more than one name to get_channel_by_name is deprecated, use get_channels_by_name instead"
376
+ )
377
+
353
378
selected_channels = tuple (self ._channel_mapping [name ] for name in names )
354
379
return type (self )(
355
380
self ._parent ,
You can’t perform that action at this time.
0 commit comments