From 738e9e13725428de2b1172b973fa3f0cfb3f7a05 Mon Sep 17 00:00:00 2001 From: William Grisaitis Date: Wed, 14 Sep 2016 14:10:29 -0400 Subject: [PATCH] Remove libdvid references in tests --- tests/data_io/config.py | 2 -- tests/data_io/load_datasets.py | 10 +++++----- tests/data_io/test_data_loader.py | 4 ++-- tests/data_io/test_get_numpy_dataset.py | 15 ++++++++------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/data_io/config.py b/tests/data_io/config.py index 1aa7da7..dfcd694 100644 --- a/tests/data_io/config.py +++ b/tests/data_io/config.py @@ -1,14 +1,12 @@ from __future__ import print_function import os -from libdvid.voxels import VoxelsAccessor import h5py DEBUG = True using_in_memory = False -# dataset_source_type = VoxelsAccessor # dataset_source_type = 'hdf5 file paths' dataset_source_type = h5py.File diff --git a/tests/data_io/load_datasets.py b/tests/data_io/load_datasets.py index e9c0d47..449dcfb 100644 --- a/tests/data_io/load_datasets.py +++ b/tests/data_io/load_datasets.py @@ -6,8 +6,7 @@ import malis import numpy as np -from libdvid.voxels import VoxelsAccessor - +from dvision import DVIDDataInstance from .config import using_in_memory, path_to_training_datasets, training_dataset_names, dataset_source_type, dvid_uuid @@ -25,14 +24,15 @@ def get_train_dataset(dataset_source_type_, using_in_memory=False): data='grayscale', components='labels', ) - dvid_hostname = 'emdata2.int.janelia.org:7000' + dvid_hostname = 'emdata2.int.janelia.org' + dvid_port = 7000 dataset['name'] = dname dataset['nhood'] = malis.mknhood3d() for key in ['data', 'components']: - if dataset_source_type_ == VoxelsAccessor: + if dataset_source_type_ == DVIDDataInstance: if key in dvid_data_names: data_name = dvid_data_names[key] - dataset[key] = VoxelsAccessor(hostname=dvid_hostname, uuid=dvid_uuid, data_name=data_name) + dataset[key] = DVIDDataInstance(dvid_hostname, dvid_port, dvid_uuid, data_name) elif dataset_source_type_ == h5py.File: dataset[key] = h5py.File(h5_filenames[key], 'r')['main'] if using_in_memory: diff --git a/tests/data_io/test_data_loader.py b/tests/data_io/test_data_loader.py index 7bebb07..620c883 100644 --- a/tests/data_io/test_data_loader.py +++ b/tests/data_io/test_data_loader.py @@ -3,18 +3,18 @@ import unittest import h5py -from libdvid.voxels import VoxelsAccessor import numpy as np from data_io import DataLoader from data_io.dataset_reading import get_numpy_dataset +from dvision import DVIDDataInstance from .load_datasets import get_train_dataset class TestDataLoader(unittest.TestCase): # @mock.patch('data_io.get_numpy_dataset', side_effect=mock_get_numpy_dataset) def test_loads_data_chunks_from_dvid(self): - train_dataset = get_train_dataset(VoxelsAccessor) + train_dataset = get_train_dataset(DVIDDataInstance) dataset_to_test = train_dataset[0] dataset, numpy_dataset = self.get_datasets_for(dataset_to_test, offset=(3000, 3000, 3000)) for key in ['data', 'components', 'label', 'mask']: diff --git a/tests/data_io/test_get_numpy_dataset.py b/tests/data_io/test_get_numpy_dataset.py index 5ba61ff..d69bc7c 100644 --- a/tests/data_io/test_get_numpy_dataset.py +++ b/tests/data_io/test_get_numpy_dataset.py @@ -3,14 +3,15 @@ import unittest import numpy as np -from libdvid.voxels import VoxelsAccessor import h5py import malis from data_io.dataset_reading import get_numpy_dataset -from .load_datasets import get_train_dataset -from data_io.dvid_connectivity import get_good_components from data_io.util import replace_array_except_whitelist +from dvision import DVIDDataInstance +from dvision.component_filtering import get_good_components +from tests.data_io.load_datasets import get_train_dataset + class TestGetNumpyDataset(unittest.TestCase): def test_works_with_hdf5_fibsem(self): @@ -27,7 +28,7 @@ def test_works_with_hdf5_fibsem(self): ) def test_works_with_dvid(self): - train_dataset = get_train_dataset(VoxelsAccessor) + train_dataset = get_train_dataset(DVIDDataInstance) dataset = train_dataset[0] dataset['body_names_to_exclude'] = ['out'] origin = (3000, 3000, 3000) @@ -61,8 +62,8 @@ def get_datasets(dataset, origin): components_slices[-3:] = output_slices components_slices = tuple(components_slices) expected_components_array = np.array(dataset['components'][components_slices]).reshape((1,) + output_shape) - if type(dataset['components']) is VoxelsAccessor: - print("Is VoxelsAccessor...") + if type(dataset['components']) is DVIDDataInstance: + print("Is DVIDDataInstance...") print("uniques before:", np.unique(expected_components_array)) dvid_uuid = dataset['components'].uuid body_names_to_exclude = dataset.get('body_names_to_exclude') @@ -74,7 +75,7 @@ def get_datasets(dataset, origin): components_for_affinity_generation = expected_components_array.reshape(output_shape) expected_label = malis.seg_to_affgraph(components_for_affinity_generation, malis.mknhood3d()) expected_dataset['label'] = expected_label - if type(dataset['components']) is VoxelsAccessor: + if type(dataset['components']) is DVIDDataInstance: expected_mask = np.array(expected_components_array > 0).astype(np.uint8) else: expected_mask = np.ones(shape=(1,) + output_shape, dtype=np.uint8)