def test1 (self):
		'''Test expansion of simple terms.'''
		# single bits all around
		expected = np.array ([0], np.int8)
		actual = M.expand_template (1, ((1,0),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		expected = np.array ([1], np.int8)
		actual = M.expand_template (1, ((1,1),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())

		# single RLE series
		expected = np.array ([0,0,0], np.int8)
		actual = M.expand_template (3, ((1,0),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		expected = np.array ([1,1,1,1], np.int8)
		actual = M.expand_template (4, ((1,1),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		# combined samples/bit and run lengths
		expected = np.array ([0,]*2*3, np.int8)
		actual = M.expand_template (2, ((3,0),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		expected = np.array ([1,]*5*2, np.int8)
		actual = M.expand_template (5, ((2,1),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
	def test1 (self):
		'''Test expansion of simple terms.'''
		# single bits all around
		expected = np.array ([0], np.int8)
		actual = M.expand_template (1, ((1,0),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		expected = np.array ([1], np.int8)
		actual = M.expand_template (1, ((1,1),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())

		# single RLE series
		expected = np.array ([0,0,0], np.int8)
		actual = M.expand_template (3, ((1,0),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		expected = np.array ([1,1,1,1], np.int8)
		actual = M.expand_template (4, ((1,1),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		# combined samples/bit and run lengths
		expected = np.array ([0,]*2*3, np.int8)
		actual = M.expand_template (2, ((3,0),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
		
		expected = np.array ([1,]*5*2, np.int8)
		actual = M.expand_template (5, ((2,1),) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())
Exemple #3
0
 def test2(self):
     '''Test combined samples/bit and RLE series.'''
     expected = np.array([
         1,
     ] * 3 + [
         0,
     ] * 3 * 4 + [
         0,
     ] * 3 * 5 + [
         1,
     ] * 3 * 7, np.int8)
     actual = M.expand_template(3, ((1, 1), (4, 0), (5, 0), (7, 1)))
     self.assertEqual(len(actual), len(expected))
     self.assert_((expected == actual).all())
Exemple #4
0
    def test0(self):
        '''Test special-case null inputs.'''
        expected = np.array([], np.int8)

        # samples/bit = 0
        actual = M.expand_template(0, ((22, 1), (33, 0), (44, 1)))
        self.assertEqual(len(actual), 0)
        self.assert_((expected == actual).all())

        # empty RLE terms-series
        actual = M.expand_template(1, ())
        self.assertEqual(len(actual), 0)
        self.assert_((expected == actual).all())
        actual = M.expand_template(13, ())
        self.assertEqual(len(actual), 0)
        self.assert_((expected == actual).all())

        # zero run lengths
        actual = M.expand_template(1, ((0, 1), ))
        self.assertEqual(len(actual), 0)
        self.assert_((expected == actual).all())
        actual = M.expand_template(1, ((0, 0), ))
        self.assertEqual(len(actual), 0)
        self.assert_((expected != actual).all())
	def test0 (self):
		'''Test special-case null inputs.'''
		expected = np.array ([], np.int8)
		
		# samples/bit = 0
		actual = M.expand_template (0, ((22,1),(33,0),(44,1)) )
		self.assertEqual (len (actual), 0)
		self.assert_((expected == actual).all())

		# empty RLE terms-series
		actual = M.expand_template (1, () )
		self.assertEqual (len (actual), 0)
		self.assert_((expected == actual).all())
		actual = M.expand_template (13, () )
		self.assertEqual (len (actual), 0)
		self.assert_((expected == actual).all())
		
		# zero run lengths
		actual = M.expand_template (1, ((0,1),) )
		self.assertEqual (len (actual), 0)
		self.assert_((expected == actual).all())
		actual = M.expand_template (1, ((0,0),) )
		self.assertEqual (len (actual), 0)
		self.assert_((expected != actual).all())
	def test2 (self):
		'''Test combined samples/bit and RLE series.'''
		expected = np.array ([1,]*3 + [0,]*3*4 + [0,]*3*5 + [1,]*3*7, np.int8)
		actual = M.expand_template (3, ((1,1),(4,0),(5,0),(7,1)) )
		self.assertEqual (len (actual), len (expected))
		self.assert_((expected == actual).all())