def setUp(self):
        self.path_prefix = os.path.dirname(visualization.__file__) + \
                           '/tests/images/'
        np.random.seed(0)
        self.X, self.y = make_classification(n_features=2,
                                             n_redundant=0,
                                             random_state=0)
        train_indices = np.random.randint(0, len(self.X), size=20)
        cand_indices = np.setdiff1d(np.arange(len(self.X)), train_indices)
        self.X_train = self.X[train_indices]
        self.y_train = self.y[train_indices]
        self.X_cand = self.X[cand_indices]
        self.clf = PWC()
        self.clf.fit(self.X_train, self.y_train)
        self.qs = UncertaintySampling()
        self.qs_dict = {'clf': self.clf, 'X': self.X_train, 'y': self.y_train}

        x1_min = min(self.X[:, 0])
        x1_max = max(self.X[:, 0])
        x2_min = min(self.X[:, 1])
        x2_max = max(self.X[:, 1])
        self.bound = [[x1_min, x2_min], [x1_max, x2_max]]

        self.cmap = 'jet'

        testing.set_font_settings_for_testing()
        testing.set_reproducibility_for_testing()
        testing.setup()
Esempio n. 2
0
    def setUp(self):
        self.path_prefix = os.path.dirname(visualization.__file__) + \
                           '/multi/tests/images/'

        self.X, self.y_true = make_classification(n_features=2,
                                                  n_redundant=0,
                                                  random_state=0)

        self.n_samples = self.X.shape[0]
        self.n_annotators = 5

        rng = np.random.default_rng(seed=0)

        noise = rng.binomial(n=1,
                             p=.2,
                             size=(self.n_samples, self.n_annotators))

        self.y = (self.y_true.reshape(-1, 1) + noise) % 2

        estimators = []
        for a in range(self.n_annotators):
            estimators.append((f'pwc_{a}', PWC(random_state=0)))
        self.clf_multi = MultiAnnotEnsemble(estimators=estimators,
                                            voting='soft')
        self.clf = PWC(random_state=0)
        self.ma_qs = IEThresh(random_state=0, n_annotators=self.n_annotators)

        testing.set_font_settings_for_testing()
        testing.set_reproducibility_for_testing()
        testing.setup()
Esempio n. 3
0
from pathlib import Path
from itertools import repeat, chain, combinations

import pytest
from matplotlib.testing import setup

setup()

from matplotlib.testing.compare import compare_images
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from anndata import AnnData

import scanpy as sc

HERE: Path = Path(__file__).parent
ROOT = HERE / '_images'
FIGS = HERE / 'figures'

sc.pl.set_rcParams_defaults()
sc.set_figure_params(dpi=40, color_map='viridis')

#####
# Test images are saved under the folder ./figures
# if test images need to be updated, simply copy them from
# the ./figures folder to ./_images/


def test_heatmap(image_comparer):
    save_and_compare_images = image_comparer(ROOT, FIGS, tol=15)
Esempio n. 4
0
def setupMpl():
    setup()
    plt.clf()
Esempio n. 5
0
def clean_mpl():
    rcdefaults()
    pyplot.close("all")
    setup()
    yield
    pyplot.close("all")