def cluster_label(self, cluster_label): if not isinstance(cluster_label, int): raise e.TypeError('`cluster_label` should be an integer') if cluster_label < 0: raise e.ValueError('`cluster_label` should be >= 0') self._cluster_label = cluster_label
def predicted_label(self, predicted_label): if not isinstance(predicted_label, int): raise e.TypeError('`predicted_label` should be an integer') if predicted_label < 0: raise e.ValueError('`predicted_label` should be >= 0') self._predicted_label = predicted_label
def label(self, label): if not isinstance(label, int): raise e.TypeError('`label` should be an integer') if label < 1: raise e.ValueError('`label` should be >= 1') self._label = label
def min_k(self, min_k): if not isinstance(min_k, int): raise e.TypeError('`min_k` should be an integer') if min_k < 1: raise e.ValueError('`min_k` should be >= 1') self._min_k = min_k
def pred(self, pred): if not isinstance(pred, int): raise e.TypeError('`pred` should be an integer') if pred < c.NIL: raise e.ValueError( '`pred` should have a value larger than `NIL`, e.g., -1') self._pred = pred
def _read_distances(self, file_path): """Reads the distance between nodes from a pre-defined file. Args: file_path (str): File to be loaded. Returns: A matrix with pre-computed distances. """ logger.debug('Running private method: read_distances().') # Getting file extension extension = file_path.split('.')[-1] # Check if extension is .csv if extension == 'csv': # If yes, call the method that actually loads csv distances = loader.load_csv(file_path) # Check if extension is .txt elif extension == 'txt': # If yes, call the method that actually loads txt distances = loader.load_txt(file_path) # If extension is not recognized else: # Raises an ArgumentError exception raise e.ArgumentError( 'File extension not recognized. It should be either `.csv` or .txt`') # Check if distances have been properly loaded if distances is None: # If not, raises a ValueError raise e.ValueError( 'Pre-computed distances could not been properly loaded') return distances
def policy(self, policy): if policy not in ['min', 'max']: raise e.ValueError('`policy` should be `min` or `max`') self._policy = policy