def test_dataqc_spiketest_extended(self):
        dat = [-1 , 3 , 40 , -1 , 1 , -6 , -6 , 1 , 2 , 4 , 3 , 1 , -1 , 40 , 1 , 1 , 4 , 2 , 2 , 2 , 1 , 2 , 100]
        out = [ 1 , 1 , 1  , 1  , 1 , 1  , 1  , 1 , 1 , 1 , 1 , 1 , 1  , 0  , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0]
        acc = 0.1
        N = 5
        L = 7

        got = qcfunc.dataqc_spiketest(dat, acc, N, L)

        np.testing.assert_array_equal(got,out)

        dat = np.arange(20)
        dat[0] = 100 # spike at the beginning
        dat[10] = 100 # spike in the middle
        dat[19] = 100 # spike at the end
        out = np.empty(20, dtype=np.int8)
        out.fill(1)
        out[0] = 0
        out[10] = 0
        out[19] = 0

        acc = 0.1
        N = 5
        L = 7 # longer smooothing

        got = qcfunc.dataqc_spiketest(dat, acc, N, L)

        np.testing.assert_array_equal(got,out)
    def test_dataqc_spiketest_extended(self):
        dat = [-1 , 3 , 40 , -1 , 1 , -6 , -6 , 1 , 2 , 4 , 3 , 1 , -1 , 40 , 1 , 1 , 4 , 2 , 2 , 2 , 1 , 2 , 100]
        out = [ 1 , 1 , 1  , 1  , 1 , 1  , 1  , 1 , 1 , 1 , 1 , 1 , 1  , 0  , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0]
        acc = 0.1
        N = 5
        L = 7

        got = qcfunc.dataqc_spiketest(dat, acc, N, L)

        np.testing.assert_array_equal(got,out)

        dat = np.arange(20)
        dat[0] = 100 # spike at the beginning
        dat[10] = 100 # spike in the middle
        dat[19] = 100 # spike at the end
        out = np.empty(20, dtype=np.int8)
        out.fill(1)
        out[0] = 0
        out[10] = 0
        out[19] = 0

        acc = 0.1
        N = 5
        L = 7 # longer smooothing

        got = qcfunc.dataqc_spiketest(dat, acc, N, L)

        np.testing.assert_array_equal(got,out)
    def test_dataqc_spiketest_random(self):
        max = int(1e6)
        a = np.array([10] * max)

        # Set some indices to values that are within the tolerance
        in_inds = np.random.randint(0,max,10)
        a[in_inds] = 13

        # Set some indices to values that are outside the tolerance
        out_inds = np.random.randint(0,max,10)
        a[out_inds] = 20

        out = qcfunc.dataqc_spiketest(a, 1, N=5, L=5)

        # Make sure the expected failures are 0
        self.assertTrue((out[out_inds] == 0).all())

        # Delete the indices and make sure everything that's left is 1
        self.assertTrue((np.delete(out, out_inds) == 1).all())
    def test_dataqc_spiketest_random(self):
        max = int(1e6)
        a = np.array([10] * max)

        # Set some indices to values that are within the tolerance
        in_inds = np.random.randint(0,max,10)
        a[in_inds] = 13

        # Set some indices to values that are outside the tolerance
        out_inds = np.random.randint(0,max,10)
        a[out_inds] = 20

        out = qcfunc.dataqc_spiketest(a, 1, N=5, L=5)

        # Make sure the expected failures are 0
        self.assertTrue((out[out_inds] == 0).all())

        # Delete the indices and make sure everything that's left is 1
        self.assertTrue((np.delete(out, out_inds) == 1).all())
    def test_dataqc_spiketest(self):
        """
        Test of the Spike Test function.

        Test values based on those defined in DPS:

        OOI (2012). Data Product Specification for Spike Test. Document Control
            Number 1341-10006. https://alfresco.oceanobservatories.org/ (See:
            Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-10006_Data_Product_SPEC_SPKETST_OOI.pdf)

        Implemented by Christopher Wingard, April 2013
        """
        dat = [-1, 3, 40, -1, 1, -6, -6, 1]
        acc = 0.1
        N = 5
        L = 5
        out = [1, 1, 0, 1, 1, 1, 1, 1]

        got = qcfunc.dataqc_spiketest(dat, acc, N, L)

        np.testing.assert_array_equal(got,out)
    def test_dataqc_spiketest(self):
        """
        Test of the Spike Test function.

        Test values based on those defined in DPS:

        OOI (2012). Data Product Specification for Spike Test. Document Control
            Number 1341-10006. https://alfresco.oceanobservatories.org/ (See:
            Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-10006_Data_Product_SPEC_SPKETST_OOI.pdf)

        Implemented by Christopher Wingard, April 2013
        """
        dat = [-1, 3, 40, -1, 1, -6, -6, 1]
        acc = 0.1
        N = 5
        L = 5
        out = [1, 1, 0, 1, 1, 1, 1, 1]

        got = qcfunc.dataqc_spiketest(dat, acc, N, L)

        np.testing.assert_array_equal(got,out)