def test_dataqc_stuckvaluetest_random(self): max = int(1e6) a = np.random.random_sample(max)*(20-10)+10 # Random values between 10 & 20 # Get a random range, set them to the same value si = np.random.randint(0,max-20,1) sl = slice(si, si+20) a[sl] = a[si] out = qcfunc.dataqc_stuckvaluetest(a, 0.1, num=10) # Make sure the expected failures are 0 self.assertTrue((out[sl] == 0).all()) # Delete the indices and make sure everything that's left is 1 self.assertTrue((np.delete(out, sl) == 1).all())
def test_dataqc_stuckvaluetest_random(self): max = int(1e6) a = np.random.random_sample(max)*(20-10)+10 # Random values between 10 & 20 # Get a random range, set them to the same value si = np.random.randint(0,max-20,1)[0] sl = slice(si, si+20) a[sl] = a[si] out = qcfunc.dataqc_stuckvaluetest(a, 0.1, num=10) # Make sure the expected failures are 0 self.assertTrue((out[sl] == 0).all()) # Delete the indices and make sure everything that's left is 1 self.assertTrue((np.delete(out, sl) == 1).all())
def test_dataqc_stuckvaluetest(self): """ Test of the Stuck Value Test function. Test values based on those defined in DPS: OOI (2012). Data Product Specification for Stuck Value Test. Document Control Number 1341-10007. https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >> Controlled >> 1000 System Level >> 1341-10007_Data_Product_SPEC_TRNDTST_OOI.pdf) Implemented by Christopher Wingard, April 2013 """ x = [4.83, 1.40, 3.33, 3.33, 3.33, 3.33, 4.09, 2.97, 2.85, 3.67] reso = 0.001 num = 4 out = [1, 1, 0, 0, 0, 0, 1, 1, 1, 1] got = qcfunc.dataqc_stuckvaluetest(x, reso, num) np.testing.assert_array_equal(got,out)