Ejemplo n.º 1
0
def test_view_peak_indices():
    """Prints dataset information to the console.
    """
    dataset_file = join(get_test_data_path(), 'gclda_dataset.pkl')
    dset = Dataset.load(dataset_file)

    captured_output = StringIO()  # Create StringIO object
    sys.stdout = captured_output  #  and redirect stdout.
    dset.view_peak_indices(n_peak_indices=5)  # Call unchanged function.
    sys.stdout = sys.__stdout__  # Reset redirect.

    assert len(captured_output.getvalue()) > 0
Ejemplo n.º 2
0
def test_save_dataset2():
    """Test gclda.dataset.Dataset.save with gzipped file.
    """
    dataset_file = join(get_test_data_path(), 'gclda_dataset.pklz')
    temp_file = join(get_test_data_path(), 'temp.pklz')
    dset = Dataset.load(dataset_file)
    dset.save(temp_file)
    file_found = isfile(temp_file)
    assert file_found

    # Perform cleanup
    remove(temp_file)
Ejemplo n.º 3
0
def test_init():
    """Smoke test for Model class.
    """
    dataset_file = join(get_test_data_path(), 'gclda_dataset.pkl')
    dset = Dataset.load(dataset_file)
    model = Model(dset,
                  n_topics=50,
                  n_regions=1,
                  symmetric=False,
                  alpha=.1,
                  beta=.01,
                  gamma=.01,
                  delta=1.,
                  dobs=25,
                  roi_size=10.,
                  seed_init=1)
    assert isinstance(model, Model)
Ejemplo n.º 4
0
def test_symmetric():
    """Test running a model with symmetric ROIs.
    """
    dataset_file = join(get_test_data_path(), 'gclda_dataset.pkl')
    dset = Dataset.load(dataset_file)
    model = Model(dset,
                  n_topics=50,
                  n_regions=2,
                  symmetric=True,
                  alpha=.1,
                  beta=.01,
                  gamma=.01,
                  delta=1.,
                  dobs=25,
                  roi_size=10.,
                  seed_init=1)
    initial_iter = model.iter
    model.run_complete_iteration()
    assert model.iter == initial_iter + 1
Ejemplo n.º 5
0
def test_init():
    """Smoke test for Dataset class.
    """
    dataset_dir = get_test_data_path()
    dset = Dataset('dataset_files', dataset_dir)
    assert isinstance(dset, Dataset)
Ejemplo n.º 6
0
def test_load_dataset2():
    """Test gclda.dataset.Dataset.load with gzipped file.
    """
    dataset_file = join(get_test_data_path(), 'gclda_dataset.pklz')
    dset = Dataset.load(dataset_file)
    assert isinstance(dset, Dataset)
Ejemplo n.º 7
0
"""
###############################################################################
# Start with the necessary imports
# --------------------------------
from os.path import join

from gclda.dataset import Dataset
from gclda.model import Model
from gclda.utils import get_resource_path

###############################################################################
# Initialize dataset
# ----------------------------------
dataset_label = 'Neurosynth2015Filtered2_1000docs'
dataset_dir = join(get_resource_path(), 'datasets')
dataset = Dataset(dataset_label, dataset_dir)
dataset.display_dataset_summary()

###############################################################################
# Initialize model
# ----------------------
model = Model(dataset,
              n_topics=200,
              n_regions=2,
              alpha=.1,
              beta=.01,
              gamma=.01,
              delta=1.0,
              dobs=25,
              roi_size=50,
              symmetric=True,