MCPcopy Create free account
hub / github.com/PyTTaMaster/PyTTa / ChannelsList

Class ChannelsList

pytta/classes/_base.py:557–803  ·  view source on GitHub ↗

.. class:: ChannelsList(self, chList: list): Class to wrap a list of ChannelObj and handle multi-channel SignalObj \ operations. .. attribute:: _channels: List holding each ChannelObj; # TODO rest of it Attributes: ------------ .. attribute::

Source from the content-addressed store, hash-verified

555
556
557class ChannelsList(object):
558 """
559 .. class:: ChannelsList(self, chList: list):
560
561 Class to wrap a list of ChannelObj and handle multi-channel SignalObj \
562 operations.
563
564 .. attribute:: _channels: List holding each ChannelObj;
565
566 # TODO rest of it
567
568 Attributes:
569 ------------
570
571 .. attribute:: _channels:
572 :type:`list` holding each :class:`ChannelObj`
573 """
574 def __init__(self, chList=None):
575 self._channels = []
576 if chList is not None:
577 if type(chList) is list:
578 for memb in chList:
579 if type(memb) is ChannelObj:
580 self._channels.append(memb)
581 elif (type(memb) is int) or (type(memb) is float):
582 self._channels.append(ChannelObj(int(memb)))
583 else:
584 raise TypeError("Could not resolve ChannelsList initialization parameters.")
585 elif type(chList) is int:
586 self._channels.append(ChannelObj(chList))
587 elif type(chList) is ChannelObj:
588 self._channels.append(chList)
589 elif type(chList) is ChannelsList:
590 self._channels = chList._channels.copy()
591 """
592 Added .copy() on ChannelsList initialization;
593 Implies that:
594
595 >>> chList1 = pytta.ChannelsList(1)
596 >>> chList2 = pytta.ChannelsList(chList1)
597
598 will make chList2._channels have the same values, and not just
599 pointers, to chList1._channels
600 """
601 else:
602 raise TypeError('List initializer must be either positive ' +
603 'int, a list of positive int or ' +
604 'ChannelObj.')
605 return
606
607 def __repr__(self):
608 return (f'{self.__class__.__name__}('
609 f'chList={self._channels!r})')
610
611 def __len__(self):
612 return len(self._channels)
613
614 def __getitem__(self, key):

Callers 4

filterMethod · 0.90
__dismember_takeMethod · 0.90
__mul__Method · 0.85
__truediv__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected