Ejemplo n.º 1
0
def test_bckgrnd_correc_rect():

    #check expected outputs
    a = int(40)
    b = int(40)
    ch = bckgrnd_correc_rect(I1_test, a, b)
    plt.close()
    assert type(
        ch
    ) == np.ndarray, "Function output should be numpy ndarray. Please check function for expected error"

    # try pandas loaded image data
    data = pd.read_csv('tdj_grbp5_1um_1hr_3rd_020717.001.txt', sep=" ")
    try:
        bckgrnd_correc_rect(data, a, b)
    except Exception:
        pass
    else:
        raise Exception(
            'Image data must be numpy ndarray. Check function for error')

    # try oddball input
    a = float(60)
    b = float(60)
    try:
        bckgrnd_correc_rect(I1_test, a, b)
    except Exception:
        pass
    else:
        raise Exception(
            'Morphology.rectangle only takes int dtype for structuring dimensions. Check function for error'
        )

    return
Ejemplo n.º 2
0
from sklearn import cluster
from scipy import ndimage
import cv2

from ImageSeparation import sep
from ImageSegmentationFunc import convert_to_grayscale
from ImageSegmentationFunc import seg_random_walker
from ImagePreprocessing import bckgrnd_correc_rect

from unittest import mock
from unittest import TestCase
import sys
from io import StringIO

I1_test = np.loadtxt('tdj_grbp5_1um_1hr_3rd_020717.001.txt')
gh = bckgrnd_correc_rect(I1_test, 10, 200)
plt.close()
gray_I1 = convert_to_grayscale(gh)
plt.close()
trial_t = seg_random_walker(gray_I1, 0.15)
plt.close()
plt.close()
plt.close()


class sepTests(TestCase):
    @mock.patch('ImageSeparation.input', create=True)

    #check expected outputs for specific user inputs
    def test_sep(self, mocked_input):
        mocked_input.side_effect = ['Y', 'Y']