Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
def test_type_error():
    new_exception = exception.TypeError('error')

    try:
        raise new_exception
    except exception.TypeError:
        pass
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
    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
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
    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
Exemplo n.º 14
0
    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
Exemplo n.º 15
0
    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
Exemplo n.º 16
0
    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
Exemplo n.º 17
0
    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
Exemplo n.º 18
0
    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
Exemplo n.º 19
0
    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
Exemplo n.º 20
0
    def trained(self, trained):
        if not isinstance(trained, bool):
            raise e.TypeError('`trained` should be a boolean')

        self._trained = trained
Exemplo n.º 21
0
    def status(self, status):
        if status not in [c.STANDARD, c.PROTOTYPE]:
            raise e.TypeError('`status` should be `STANDARD` or `PROTOTYPE`')

        self._status = status
Exemplo n.º 22
0
    def nodes(self, nodes):
        if not isinstance(nodes, list):
            raise e.TypeError('`nodes` should be a list')

        self._nodes = nodes
Exemplo n.º 23
0
    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
Exemplo n.º 24
0
    def adjacency(self, adjacency):
        if not isinstance(adjacency, list):
            raise e.TypeError('`adjacency` should be a list')

        self._adjacency = adjacency
Exemplo n.º 25
0
    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
Exemplo n.º 26
0
    def relevant(self, relevant):
        if relevant not in [c.RELEVANT, c.IRRELEVANT]:
            raise e.TypeError(
                '`relevant` should be `RELEVANT` or `IRRELEVANT`')

        self._relevant = relevant
Exemplo n.º 27
0
    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
Exemplo n.º 28
0
    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
Exemplo n.º 29
0
    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
Exemplo n.º 30
0
    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