tvaLib
Public Member Functions | Public Attributes | List of all members
lib.tools_constructors.SuperList Class Reference

The following objects define generic constructors. More...

Inheritance diagram for lib.tools_constructors.SuperList:
include.config.AggMethods include.config.InteractionClassificationMethods include.config.PredictionMethods lib.tools_constructors.SuperListParse

Public Member Functions

def __init__ (self)
 
def __repr__ (self)
 
def __str__ (self)
 
def __len__ (self)
 
def __getitem__ (self, i)
 
def __iter__ (self)
 
def __add__ (self, slist)
 
def append (self, value)
 
def reverse (self)
 
def count (self, value)
 
def index (self, value)
 
def asNpArray (self)
 
def write (self)
 
def get (self, i=None, id=None, name=None)
 
def getIndex (self, kwargs)
 
def getRange (self)
 

Public Attributes

 data
 

Detailed Description

The following objects define generic constructors.

A SuperList is an object which behaves similar to a regular python list
    but includes methods that are useful for manipulating the data
    contained inside the list. This is especially useful for lists of
    object instances which may not be manipulated with simple list
    comprehensions.
    
    This is a generic class from which many object-instance-dependant
    methods are derived, but defines the generic object structure.

Definition at line 21 of file tools_constructors.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.tools_constructors.SuperList.__init__ (   self)

Definition at line 32 of file tools_constructors.py.

32  def __init__(self):
33  self.data = []
34  return
35 

Member Function Documentation

◆ __add__()

def lib.tools_constructors.SuperList.__add__ (   self,
  slist 
)

Definition at line 41 of file tools_constructors.py.

41  def __add__(self, slist): self.data += slist.data; return None

◆ __getitem__()

def lib.tools_constructors.SuperList.__getitem__ (   self,
  i 
)

Definition at line 39 of file tools_constructors.py.

39  def __getitem__(self, i): return self.data[i]

◆ __iter__()

def lib.tools_constructors.SuperList.__iter__ (   self)

Definition at line 40 of file tools_constructors.py.

40  def __iter__(self): return iter(self.data)

◆ __len__()

def lib.tools_constructors.SuperList.__len__ (   self)

Definition at line 38 of file tools_constructors.py.

38  def __len__(self): return len(self.data)

◆ __repr__()

def lib.tools_constructors.SuperList.__repr__ (   self)

Definition at line 36 of file tools_constructors.py.

36  def __repr__(self): return self.__class__.__name__+' '+str(self.data)

◆ __str__()

def lib.tools_constructors.SuperList.__str__ (   self)

Definition at line 37 of file tools_constructors.py.

37  def __str__(self): return self.__class__.__name__+' '+str(self.data)

◆ append()

def lib.tools_constructors.SuperList.append (   self,
  value 
)

Definition at line 42 of file tools_constructors.py.

42  def append(self,value): return self.data.append(value)

◆ asNpArray()

def lib.tools_constructors.SuperList.asNpArray (   self)

Definition at line 46 of file tools_constructors.py.

46  def asNpArray(self): return np_array(self.data)

◆ count()

def lib.tools_constructors.SuperList.count (   self,
  value 
)

Definition at line 44 of file tools_constructors.py.

44  def count(self, value): return self.data.count(value)

◆ get()

def lib.tools_constructors.SuperList.get (   self,
  i = None,
  id = None,
  name = None 
)

Definition at line 51 of file tools_constructors.py.

51  def get(self, i=None, id=None, name=None):
52  if(i != None):
53  return self.data[i]
54  elif(id != None and len(self.data) > 0 and hasattr(self.data[0], 'id')):
55  for i in self.data:
56  if(i.id == id):
57  return i
58  return False
59  elif(name != None and len(self.data) > 0 and hasattr(self.data[0], 'name')):
60  for i in self.data:
61  if(i.name == name):
62  return i
63  return False
64  else:
65  return False
66 

◆ getIndex()

def lib.tools_constructors.SuperList.getIndex (   self,
  kwargs 
)
Get index of object based on that object's property value.

    Example usage to return the index for a child object who's name is
    'foobar': 

    idx = myList.getIndex(name='foobar')

Definition at line 67 of file tools_constructors.py.

67  def getIndex(self, **kwargs):
68  ''' Get index of object based on that object's property value.
69 
70  Example usage to return the index for a child object who's name is
71  'foobar':
72 
73  idx = myList.getIndex(name='foobar')
74 
75  '''
76  if(kwargs is not None):
77  for key, value in kwargs.iteritems():
78  if(len(self.data) > 0 and hasattr(self.data[0], key)):
79  for i in range(len(self.data)):
80  if(getattr(self.data[i], key) == value): return i
81  return None
82 
83 

◆ getRange()

def lib.tools_constructors.SuperList.getRange (   self)

Definition at line 84 of file tools_constructors.py.

84  def getRange(self): return range(len(self.data))
85 
86 
87 

◆ index()

def lib.tools_constructors.SuperList.index (   self,
  value 
)

Definition at line 45 of file tools_constructors.py.

45  def index(self, value): return self.data.index(value)

◆ reverse()

def lib.tools_constructors.SuperList.reverse (   self)

Definition at line 43 of file tools_constructors.py.

43  def reverse(self): self.data.reverse();return None

◆ write()

def lib.tools_constructors.SuperList.write (   self)

Definition at line 47 of file tools_constructors.py.

47  def write(self):
48  if(len(self.data)>0 and hasattr(self.data[0],'write')): return str([x.write() for x in self.data])
49  else: return str(self.data)
50 

Member Data Documentation

◆ data

lib.tools_constructors.SuperList.data

Definition at line 33 of file tools_constructors.py.


The documentation for this class was generated from the following file: