Commits

Anonymous committed d5b0418

Fix typo.

Comments (0)

Files changed (1)

PyML/containers/baseDatasets.py

 
         self.isTrained = False
         self.isTested = False
-        
+
     def setTrainingFunc(self, func) :
 
         assert func is None or type(func).__name__ == 'function'
             return self._trainingFunc
         else :
             return None
-                   
+
     trainingFunc = property(getTrainingFunc, setTrainingFunc,
                             None, '_trainingFunc')
 
             return self._testingFunc
         else :
             return None
-                   
+
     testingFunc = property(getTestingFunc, setTestingFunc,
                            None, '_testingFunc')
 
         if self.testingFunc is not None and not self.isTested :
             self.testingFunc(self, trainingData, **args)
             self.isTested = True
-            
+
     def registerAttribute(self, attributeName, attributeValue = None, action = None) :
 
         if not hasattr(self, '_registeredAttributes') :
             setattr(self, attributeName, attributeValue)
         if not hasattr(self, '_actions') : self._actions = {}
         self._actions[attributeName] = action
-            
+
     def copyConstruct(self, other, **args) :
 
         forgetClassLabels = False
         raise NotImplementedError
 
     def getKernelMatrix(self) :
-        """ 
+        """
         returns the kernel matrix as a numpy array
         """
 
             self.kernel = data.kernel.__class__(data.kernel)
         elif hasattr(kernel, 'type') and kernel.type == 'kernel' :
             self.kernel = kernel.__class__(kernel)
-        
+
     def attachLabels(self, labels) :
 
         if labels.__class__.__name__ == 'Labels' :
     """A base class for vector dataset container classes
 
     Construction::
-    
+
       DataSet(fileName)  -  read data from a file
       DataSet(fileName, classes = listOfClasses) - read only the
       classes that are named in listOfClasses
       using a list of classes to copy
 
     Keywords::
-    
+
       deepcopy - whether to deepcopy a dataset (default = True)
       The only container that implements a shallow copy is the SparseDataSet.
 
     Usage/attributes::
-    
+
       len(dataset) - the number of patterns
       numFeatures - the number of features in the data (when applicable)
     """
             patternID = args['patternID'][:]
         if 'featureID' in args :
             if self.__class__.__name__ == 'SparseDataSet' :
-                raise vluaeError, 'cannot set feature ID for SparseDataSet'
+                raise ValueError, 'cannot set feature ID for SparseDataSet'
             self.featureID = args['featureID'][:]
 
-        if L is not None : assert len(X) == len(L)                
+        if L is not None : assert len(X) == len(L)
         if self.featureID is None :
             self.featureID = [str(i) for i in range(len(X[0]))]
         if patternID is None :
             self.initializeDataMatrix(len(X), len(X[0]))
             for i in range(len(X)) :
                 self.addPattern(X[i], i)
-            
+
     def __repr__(self) :
-        
+
         rep = '<' + self.__class__.__name__ + ' instance>\n'
         rep += 'number of patterns: ' + str(len(self)) +'\n'
         if self.X is not None :
             rep += 'number of features: ' + str(self.numFeatures) + '\n'
         rep += self.labels.__repr__()
-        
+
         return rep
 
     def save(self, fileName, **args) :
                 labels = ''
             else :
                 labels = 'labels' + delim
-            fileHandle.write('#' + 'patternID' + delim + labels + 
+            fileHandle.write('#' + 'patternID' + delim + labels +
                              delim.join(self.featureID) + '\n')
         for i in patterns :
             x = self.getPattern(i)
         for i in range(len(self)) :
             X[i] = self.getPattern(i)
         return X
-            
+
     def extend(self, other, patterns = None) :
 
         if self.__class__ != other.__class__ :
             if (hash(id) in self.featureKeyDict and
                 id != self.featureID[self.featureKeyDict[hash(id)]]) :
                 raise ValueError, 'bad hash'
-        
+
         # recompute featureID related stuff
         self.featureKey = misc.union(self.featureKey, other.featureKey)
         self.featureKey.sort()
         for id in featureIDs :
             self.featureID[self.featureKeyDict[hash(id)]] = id
 
-        self.extendX(other, patterns) 
+        self.extendX(other, patterns)
         self.labels.extend(other.labels, patterns)
         #self.attachLabels(self.labels.L)
 
             features = self.featureNames2IDs(features)
         self.eliminateFeatures(misc.setminus(range(self.numFeatures), features))
 
-        
+
     def featureNames2IDs(self, featureList) :
         """convert a list of feature Names into their numeric IDs"""
 
         if hasattr(self.labels, 'Y') and self.labels.Y is not None :
             for i in range(len(labels)) :
                 self.setY(i, labels.Y[i])
-    
+
     attachKernel = ker.attachKernel