def max_k(self, max_k): if not isinstance(max_k, int): raise e.TypeError('`max_k` should be an integer') if max_k < 1: raise e.ValueError('`max_k` should be >= 1') self._max_k = max_k
def root(self, root): if not isinstance(root, int): raise e.TypeError('`root` should be an integer') if root < 0: raise e.ValueError('`root` should be >= 0') self._root = root
def test_type_error(): new_exception = exception.TypeError('error') try: raise new_exception except exception.TypeError: pass
def n_plateaus(self, n_plateaus): if not isinstance(n_plateaus, int): raise e.TypeError('`n_plateaus` should be an integer') if n_plateaus < 0: raise e.ValueError('`n_plateaus` should be >= 0') self._n_plateaus = n_plateaus
def label(self, label): if not isinstance(label, int): raise e.TypeError('`label` should be an integer') if label < 0: raise e.ValueError('`label` should be >= 0') self._label = label
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 n_clusters(self, n_clusters): if not isinstance(n_clusters, int): raise e.TypeError('`n_clusters` should be an integer') if n_clusters < 0: raise e.ValueError('`n_clusters` should be >= 0') self._n_clusters = n_clusters
def best_k(self, best_k): if not isinstance(best_k, int): raise e.TypeError('`best_k` should be an integer') if best_k < 0: raise e.ValueError('`best_k` should be >= 0') self._best_k = best_k
def size(self, size): if not isinstance(size, int): raise e.TypeError('`size` should be an integer') if size < 1: raise e.ValueError('`size` should be > 0') self._size = size
def distance(self, distance): if distance not in [ 'additive_symmetric', 'average_euclidean', 'bhattacharyya', 'bray_curtis', 'canberra', 'chebyshev', 'chi_squared', 'chord', 'clark', 'cosine', 'dice', 'divergence', 'euclidean', 'gaussian', 'gower', 'hamming', 'hassanat', 'hellinger', 'jaccard', 'jeffreys', 'jensen', 'jensen_shannon', 'k_divergence', 'kulczynski', 'kullback_leibler', 'log_euclidean', 'log_squared_euclidean', 'lorentzian', 'manhattan', 'matusita', 'max_symmetric', 'mean_censored_euclidean', 'min_symmetric', 'neyman', 'non_intersection', 'pearson', 'sangvi', 'soergel', 'squared', 'squared_chord', 'squared_euclidean', 'statistic', 'topsoe', 'vicis_symmetric1', 'vicis_symmetric2', 'vicis_symmetric3', 'vicis_wave_hedges' ]: raise e.TypeError( '`distance` should be `additive_symmetric`, `average_euclidean`, `bhattacharyya`, ' '`bray_curtis`, `canberra`, `chebyshev`, `chi_squared`, `chord`, `clark`, `cosine`, ' '`dice`, `divergence`, `euclidean`, `gaussian`, `gower`, `hamming`, `hassanat`, `hellinger`, ' '`jaccard`, `jeffreys`, `jensen`, `jensen_shannon`, `k_divergence`, `kulczynski`, ' '`kullback_leibler`, `log_euclidean`, `log_squared_euclidean`, `lorentzian`, `manhattan`, ' '`matusita`, `max_symmetric`, `mean_censored_euclidean`, `min_symmetric`, `neyman`, ' '`non_intersection`, `pearson`, `sangvi`, `soergel`, `squared`, `squared_chord`, ' '`squared_euclidean`, `statistic`, `topsoe`, `vicis_symmetric1`, `vicis_symmetric2`, ' '`vicis_symmetric3` or `vicis_wave_hedges`') self._distance = distance
def last(self, last): if not isinstance(last, int): raise e.TypeError('`last` should be an integer') if last < -1: raise e.ValueError('`last` should be > -1') self._last = last
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 constant(self, constant): if not (isinstance(constant, float) or isinstance(constant, int) or isinstance(constant, np.int32) or isinstance(constant, np.int64)): raise e.TypeError('`constant` should be a float or integer') self._constant = constant
def max_density(self, max_density): if not (isinstance(max_density, float) or isinstance(max_density, int) or isinstance(max_density, np.int32) or isinstance(max_density, np.int64)): raise e.TypeError('`max_density` should be a float or integer') self._max_density = max_density
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 idx(self, idx): if not isinstance(idx, int): raise e.TypeError('`idx` should be an integer') if idx < 0: raise e.ValueError('`idx` should be >= 0') self._idx = idx
def n_features(self, n_features): if not isinstance(n_features, int): raise e.TypeError('`n_features` should be an integer') if n_features < 0: raise e.ValueError('`n_features` should be >= 0') self._n_features = n_features
def distance(self, distance): if distance not in [ 'bray_curtis', 'canberra', 'chi_squared', 'euclidean', 'gaussian', 'log_euclidean', 'log_squared_euclidean', 'manhattan', 'squared_chi_squared', 'squared_cord', 'squared_euclidean' ]: raise e.TypeError( '`distance` should be `bray_curtis`, `canberra`, `chi_squared`, `euclidean`, `gaussian`, `log_euclidean`, `log_squared_euclidean`, `manhattan`, `squared_chi_squared`, `squared_cord` or `squared_euclidean`' ) self._distance = distance
def distance(self, distance): if distance not in d.DISTANCES.keys(): raise e.TypeError('`distance` should be `additive_symmetric`, `average_euclidean`, `bhattacharyya`, ' '`bray_curtis`, `canberra`, `chebyshev`, `chi_squared`, `chord`, `clark`, `cosine`, ' '`dice`, `divergence`, `euclidean`, `gaussian`, `gower`, `hamming`, `hassanat`, `hellinger`, ' '`jaccard`, `jeffreys`, `jensen`, `jensen_shannon`, `k_divergence`, `kulczynski`, ' '`kullback_leibler`, `log_euclidean`, `log_squared_euclidean`, `lorentzian`, `manhattan`, ' '`matusita`, `max_symmetric`, `mean_censored_euclidean`, `min_symmetric`, `neyman`, ' '`non_intersection`, `pearson`, `sangvi`, `soergel`, `squared`, `squared_chord`, ' '`squared_euclidean`, `statistic`, `topsoe`, `vicis_symmetric1`, `vicis_symmetric2`, ' '`vicis_symmetric3` or `vicis_wave_hedges`') self._distance = distance
def trained(self, trained): if not isinstance(trained, bool): raise e.TypeError('`trained` should be a boolean') self._trained = trained
def status(self, status): if status not in [c.STANDARD, c.PROTOTYPE]: raise e.TypeError('`status` should be `STANDARD` or `PROTOTYPE`') self._status = status
def nodes(self, nodes): if not isinstance(nodes, list): raise e.TypeError('`nodes` should be a list') self._nodes = nodes
def idx_nodes(self, idx_nodes): if not isinstance(idx_nodes, list): raise e.TypeError('`idx_nodes` should be a list') self._idx_nodes = idx_nodes
def adjacency(self, adjacency): if not isinstance(adjacency, list): raise e.TypeError('`adjacency` should be a list') self._adjacency = adjacency
def radius(self, radius): if not isinstance(radius, (float, int, np.int32, np.int64)): raise e.TypeError('`radius` should be a float or integer') self._radius = radius
def relevant(self, relevant): if relevant not in [c.RELEVANT, c.IRRELEVANT]: raise e.TypeError( '`relevant` should be `RELEVANT` or `IRRELEVANT`') self._relevant = relevant
def subgraph(self, subgraph): if subgraph is not None: if not isinstance(subgraph, Subgraph): raise e.TypeError('`subgraph` should be a subgraph') self._subgraph = subgraph
def pre_distances(self, pre_distances): if pre_distances is not None: if not isinstance(pre_distances, np.ndarray): raise e.TypeError('`pre_distances` should be a numpy array') self._pre_distances = pre_distances
def pre_computed_distance(self, pre_computed_distance): if not isinstance(pre_computed_distance, bool): raise e.TypeError('`pre_computed_distance` should be a boolean') self._pre_computed_distance = pre_computed_distance
def distance_fn(self, distance_fn): if not callable(distance_fn): raise e.TypeError('`distance_fn` should be a callable') self._distance_fn = distance_fn